import{s as Io,z as Uo,o as Wo,n as Xe}from"../chunks/scheduler.18a86fab.js";import{S as Fo,i as zo,g as i,s as r,r as h,A as Po,h as l,f as o,c as s,j as Z,u as f,x as c,k as R,y as d,a as n,v as g,d as u,t as _,w as T}from"../chunks/index.98837b22.js";import{T as At}from"../chunks/Tip.77304350.js";import{D as F}from"../chunks/Docstring.6758ea23.js";import{C as Kt}from"../chunks/CodeBlock.8d0c2e8a.js";import{E as Oo}from"../chunks/ExampleCodeBlock.0c42463f.js";import{P as Lo}from"../chunks/PipelineTag.7749150e.js";import{H as q}from"../chunks/Heading.7e7e0c5b.js";import{E as Ho}from"../chunks/index.499f366c.js";function Vo(j){let a,M="Example:",p,b,v;return b=new Kt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyT0NSQ29uZmlnJTJDJTIwVHJPQ1JGb3JDYXVzYWxMTSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBUck9DUi1iYXNlJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFRyT0NSQ29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjAod2l0aCUyMHJhbmRvbSUyMHdlaWdodHMpJTIwZnJvbSUyMHRoZSUyMFRyT0NSLWJhc2UlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFRyT0NSRm9yQ2F1c2FsTE0oY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrOCRConfig, TrOCRForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a TrOCR-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = TrOCRConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the TrOCR-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TrOCRForCausalLM(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){a=i("p"),a.textContent=M,p=r(),h(b.$$.fragment)},l(m){a=l(m,"P",{"data-svelte-h":!0}),c(a)!=="svelte-11lpom8"&&(a.textContent=M),p=s(m),f(b.$$.fragment,m)},m(m,C){n(m,a,C),n(m,p,C),g(b,m,C),v=!0},p:Xe,i(m){v||(u(b.$$.fragment,m),v=!0)},o(m){_(b.$$.fragment,m),v=!1},d(m){m&&(o(a),o(p)),T(b,m)}}}function No(j){let a,M=`This class method is simply calling the feature extractor
<a href="/docs/transformers/main/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained">from_pretrained()</a>, image processor
<a href="/docs/transformers/main/en/internal/image_processing_utils#transformers.ImageProcessingMixin">ImageProcessingMixin</a> and the tokenizer
<code>~tokenization_utils_base.PreTrainedTokenizer.from_pretrained</code> methods. Please refer to the docstrings of the
methods above for more information.`;return{c(){a=i("p"),a.innerHTML=M},l(p){a=l(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-i4rz41"&&(a.innerHTML=M)},m(p,b){n(p,a,b)},p:Xe,d(p){p&&o(a)}}}function Bo(j){let a,M=`This class method is simply calling <a href="/docs/transformers/main/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained">save_pretrained()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.save_pretrained">save_pretrained()</a>. Please refer to the docstrings of the
methods above for more information.`;return{c(){a=i("p"),a.innerHTML=M},l(p){a=l(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-1qvfzw2"&&(a.innerHTML=M)},m(p,b){n(p,a,b)},p:Xe,d(p){p&&o(a)}}}function Eo(j){let a,M=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){a=i("p"),a.innerHTML=M},l(p){a=l(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-fincs2"&&(a.innerHTML=M)},m(p,b){n(p,a,b)},p:Xe,d(p){p&&o(a)}}}function Go(j){let a,M="Example:",p,b,v;return b=new Kt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBUck9DUkNvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMFRyT0NSUHJvY2Vzc29yJTJDJTBBJTIwJTIwJTIwJTIwVHJPQ1JGb3JDYXVzYWxMTSUyQyUwQSUyMCUyMCUyMCUyMFZpVENvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMFZpVE1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbCUyQyUwQSklMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQSUwQSUyMyUyMFRyT0NSJTIwaXMlMjBhJTIwZGVjb2RlciUyMG1vZGVsJTIwYW5kJTIwc2hvdWxkJTIwYmUlMjB1c2VkJTIwd2l0aGluJTIwYSUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMjMlMjBpbml0JTIwdmlzaW9uMnRleHQlMjBtb2RlbCUyMHdpdGglMjByYW5kb20lMjB3ZWlnaHRzJTBBZW5jb2RlciUyMCUzRCUyMFZpVE1vZGVsKFZpVENvbmZpZygpKSUwQWRlY29kZXIlMjAlM0QlMjBUck9DUkZvckNhdXNhbExNKFRyT0NSQ29uZmlnKCkpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsKGVuY29kZXIlM0RlbmNvZGVyJTJDJTIwZGVjb2RlciUzRGRlY29kZXIpJTBBJTBBJTIzJTIwSWYlMjB5b3UlMjB3YW50JTIwdG8lMjBzdGFydCUyMGZyb20lMjB0aGUlMjBwcmV0cmFpbmVkJTIwbW9kZWwlMkMlMjBsb2FkJTIwdGhlJTIwY2hlY2twb2ludCUyMHdpdGglMjAlNjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsJTYwJTBBcHJvY2Vzc29yJTIwJTNEJTIwVHJPQ1JQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnRyb2NyLWJhc2UtaGFuZHdyaXR0ZW4lMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZ0cm9jci1iYXNlLWhhbmR3cml0dGVuJTIyKSUwQSUwQSUyMyUyMGxvYWQlMjBpbWFnZSUyMGZyb20lMjB0aGUlMjBJQU0lMjBkYXRhc2V0JTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZma2kudGljLmhlaWEtZnIuY2glMkZzdGF0aWMlMkZpbWclMkZhMDEtMTIyLTAyLmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KS5jb252ZXJ0KCUyMlJHQiUyMiklMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5waXhlbF92YWx1ZXMlMEF0ZXh0JTIwJTNEJTIwJTIyaW5kdXN0cnklMkMlMjAnJTIwTXIuJTIwQnJvd24lMjBjb21tZW50ZWQlMjBpY2lseS4lMjAnJTIwTGV0JTIwdXMlMjBoYXZlJTIwYSUyMiUwQSUwQSUyMyUyMHRyYWluaW5nJTBBbW9kZWwuY29uZmlnLmRlY29kZXJfc3RhcnRfdG9rZW5faWQlMjAlM0QlMjBwcm9jZXNzb3IudG9rZW5pemVyLmVvc190b2tlbl9pZCUwQW1vZGVsLmNvbmZpZy5wYWRfdG9rZW5faWQlMjAlM0QlMjBwcm9jZXNzb3IudG9rZW5pemVyLnBhZF90b2tlbl9pZCUwQW1vZGVsLmNvbmZpZy52b2NhYl9zaXplJTIwJTNEJTIwbW9kZWwuY29uZmlnLmRlY29kZXIudm9jYWJfc2l6ZSUwQSUwQWxhYmVscyUyMCUzRCUyMHByb2Nlc3Nvci50b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLmlucHV0X2lkcyUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChwaXhlbF92YWx1ZXMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQXJvdW5kKGxvc3MuaXRlbSgpJTJDJTIwMiklMEElMEElMjMlMjBpbmZlcmVuY2UlMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUocGl4ZWxfdmFsdWVzKSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RCUwQWdlbmVyYXRlZF90ZXh0",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    TrOCRConfig,
<span class="hljs-meta">... </span>    TrOCRProcessor,
<span class="hljs-meta">... </span>    TrOCRForCausalLM,
<span class="hljs-meta">... </span>    ViTConfig,
<span class="hljs-meta">... </span>    ViTModel,
<span class="hljs-meta">... </span>    VisionEncoderDecoderModel,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># TrOCR is a decoder model and should be used within a VisionEncoderDecoderModel</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># init vision2text model with random weights</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoder = ViTModel(ViTConfig())
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder = TrOCRForCausalLM(TrOCRConfig())
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel(encoder=encoder, decoder=decoder)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># If you want to start from the pretrained model, load the checkpoint with \`VisionEncoderDecoderModel\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>processor = TrOCRProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/trocr-base-handwritten&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;microsoft/trocr-base-handwritten&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load image from the IAM dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://fki.tic.heia-fr.ch/static/img/a01-122-02.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values
<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;industry, &#x27; Mr. Brown commented icily. &#x27; Let us have a&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># training</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.decoder_start_token_id = processor.tokenizer.eos_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = processor.tokenizer.pad_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.vocab_size = model.config.decoder.vocab_size

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = processor.tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(pixel_values, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">round</span>(loss.item(), <span class="hljs-number">2</span>)
<span class="hljs-number">5.30</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># inference</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(pixel_values)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text
<span class="hljs-string">&#x27;industry, &quot; Mr. Brown commented icily. &quot; Let us have a&#x27;</span>`,wrap:!1}}),{c(){a=i("p"),a.textContent=M,p=r(),h(b.$$.fragment)},l(m){a=l(m,"P",{"data-svelte-h":!0}),c(a)!=="svelte-11lpom8"&&(a.textContent=M),p=s(m),f(b.$$.fragment,m)},m(m,C){n(m,a,C),n(m,p,C),g(b,m,C),v=!0},p:Xe,i(m){v||(u(b.$$.fragment,m),v=!0)},o(m){_(b.$$.fragment,m),v=!1},d(m){m&&(o(a),o(p)),T(b,m)}}}function Xo(j){let a,M,p,b,v,m,C,eo='<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/>',Se,Y,qe,Q,to=`The TrOCR model was proposed in <a href="https://arxiv.org/abs/2109.10282" rel="nofollow">TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models</a> by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang,
Zhoujun Li, Furu Wei. TrOCR consists of an image Transformer encoder and an autoregressive text Transformer decoder to
perform <a href="https://en.wikipedia.org/wiki/Optical_character_recognition" rel="nofollow">optical character recognition (OCR)</a>.`,Ye,D,oo="The abstract from the paper is the following:",Qe,A,no=`<em>Text recognition is a long-standing research problem for document digitalization. Existing approaches for text recognition
are usually built based on CNN for image understanding and RNN for char-level text generation. In addition, another language
model is usually needed to improve the overall accuracy as a post-processing step. In this paper, we propose an end-to-end
text recognition approach with pre-trained image Transformer and text Transformer models, namely TrOCR, which leverages the
Transformer architecture for both image understanding and wordpiece-level text generation. The TrOCR model is simple but
effective, and can be pre-trained with large-scale synthetic data and fine-tuned with human-labeled datasets. Experiments
show that the TrOCR model outperforms the current state-of-the-art models on both printed and handwritten text recognition
tasks.</em>`,De,z,ro,Ae,K,so='TrOCR architecture. Taken from the <a href="https://arxiv.org/abs/2109.10282">original paper</a>.',Ke,ee,ao="Please refer to the <code>VisionEncoderDecoder</code> class on how to use this model.",et,te,io=`This model was contributed by <a href="https://huggingface.co/nielsr" rel="nofollow">nielsr</a>. The original code can be found
<a href="https://github.com/microsoft/unilm/tree/6f60612e7cc86a2a1ae85c47231507a587ab4e01/trocr" rel="nofollow">here</a>.`,tt,oe,ot,ne,lo=`<li>The quickest way to get started with TrOCR is by checking the <a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/TrOCR" rel="nofollow">tutorial
notebooks</a>, which show how to use the model
at inference time as well as fine-tuning on custom data.</li> <li>TrOCR is pre-trained in 2 stages before being fine-tuned on downstream datasets. It achieves state-of-the-art results
on both printed (e.g. the <a href="https://paperswithcode.com/dataset/sroie" rel="nofollow">SROIE dataset</a> and handwritten (e.g. the <a href="https://fki.tic.heia-fr.ch/databases/iam-handwriting-database%3E" rel="nofollow">IAM
Handwriting dataset</a> text recognition tasks. For more
information, see the <a href="https://huggingface.co/models?other=trocr%3E" rel="nofollow">official models</a>.</li> <li>TrOCR is always used within the <a href="vision-encoder-decoder">VisionEncoderDecoder</a> framework.</li>`,nt,re,rt,se,co="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with TrOCR. If you’re interested in submitting a resource to be included here, please feel free to open a Pull Request and we’ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.",st,ae,at,ie,mo='<li>A blog post on <a href="https://huggingface.co/blog/document-ai" rel="nofollow">Accelerating Document AI</a> with TrOCR.</li> <li>A blog post on how to <a href="https://github.com/philschmid/document-ai-transformers" rel="nofollow">Document AI</a> with TrOCR.</li> <li>A notebook on how to <a href="https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Fine_tune_TrOCR_on_IAM_Handwriting_Database_using_Seq2SeqTrainer.ipynb" rel="nofollow">finetune TrOCR on IAM Handwriting Database using Seq2SeqTrainer</a>.</li> <li>A notebook on <a href="https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Inference_with_TrOCR_%2B_Gradio_demo.ipynb" rel="nofollow">inference with TrOCR</a> and Gradio demo.</li> <li>A notebook on <a href="https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Fine_tune_TrOCR_on_IAM_Handwriting_Database_using_native_PyTorch.ipynb" rel="nofollow">finetune TrOCR on the IAM Handwriting Database</a> using native PyTorch.</li> <li>A notebook on <a href="https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Evaluating_TrOCR_base_handwritten_on_the_IAM_test_set.ipynb" rel="nofollow">evaluating TrOCR on the IAM test set</a>.</li>',it,le,lt,de,po='<li><a href="https://huggingface.co/docs/transformers/tasks/language_modeling" rel="nofollow">Casual language modeling</a> task guide.</li>',dt,ce,ho="⚡️ Inference",ct,me,fo='<li>An interactive-demo on <a href="https://huggingface.co/spaces/nielsr/TrOCR-handwritten" rel="nofollow">TrOCR handwritten character recognition</a>.</li>',mt,pe,pt,he,go=`TrOCR’s <code>VisionEncoderDecoder</code> model accepts images as input and makes use of
<a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a> to autoregressively generate text given the input image.`,ht,fe,uo=`The [<code>ViTImageProcessor</code>/<code>DeiTImageProcessor</code>] class is responsible for preprocessing the input image and
[<code>RobertaTokenizer</code>/<code>XLMRobertaTokenizer</code>] decodes the generated target tokens to the target string. The
<a href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor">TrOCRProcessor</a> wraps [<code>ViTImageProcessor</code>/<code>DeiTImageProcessor</code>] and [<code>RobertaTokenizer</code>/<code>XLMRobertaTokenizer</code>]
into a single instance to both extract the input features and decode the predicted token ids.`,ft,ge,_o="<li>Step-by-step Optical Character Recognition (OCR)</li>",gt,ue,ut,_e,To='See the <a href="https://huggingface.co/models?filter=trocr" rel="nofollow">model hub</a> to look for TrOCR checkpoints.',_t,Te,Tt,$,be,jt,Oe,bo=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRForCausalLM">TrOCRForCausalLM</a>. It is used to instantiate an
TrOCR model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configuration to that of the TrOCR
<a href="https://huggingface.co/microsoft/trocr-base-handwritten" rel="nofollow">microsoft/trocr-base-handwritten</a> architecture.`,xt,Le,yo=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Jt,P,bt,ye,yt,y,Me,Zt,Ie,Mo="Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor.",Ot,Ue,wo=`<a href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor">TrOCRProcessor</a> offers all the functionalities of [<code>ViTImageProcessor</code>/<code>DeiTImageProcessor</code>] and
[<code>RobertaTokenizer</code>/<code>XLMRobertaTokenizer</code>]. See the <a href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor.__call__"><strong>call</strong>()</a> and <a href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRProcessor.decode">decode()</a> for
more information.`,Lt,H,we,It,We,vo=`When used in normal mode, this method forwards all its arguments to AutoImageProcessor’s
<code>__call__()</code> and returns its output. If used in the context
<code>as_target_processor()</code> this method forwards all its arguments to TrOCRTokenizer’s
<code>~TrOCRTokenizer.__call__</code>. Please refer to the docstring of the above two methods for more information.`,Ut,O,ve,Wt,Fe,Co="Instantiate a processor associated with a pretrained model.",Ft,V,zt,L,Ce,Pt,ze,ko=`Saves the attributes of this processor (feature extractor, tokenizer…) in the specified directory so that it
can be reloaded using the <a href="/docs/transformers/main/en/main_classes/processors#transformers.ProcessorMixin.from_pretrained">from_pretrained()</a> method.`,Ht,N,Vt,B,ke,Nt,Pe,Ro=`This method forwards all its arguments to TrOCRTokenizer’s <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.batch_decode">batch_decode()</a>. Please refer
to the docstring of this method for more information.`,Bt,E,Re,Et,He,$o=`This method forwards all its arguments to TrOCRTokenizer’s <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.decode">decode()</a>. Please refer to the
docstring of this method for more information.`,Mt,$e,wt,k,je,Gt,Ve,jo='The TrOCR Decoder with a language modeling head. Can be used as the decoder part of <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> and',Xt,Ne,xo=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,St,Be,Jo=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,qt,x,xe,Yt,Ee,Zo='The <a href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRForCausalLM">TrOCRForCausalLM</a> forward method, overrides the <code>__call__</code> special method.',Qt,G,Dt,X,vt,Je,Ct,Ge,kt;return v=new q({props:{title:"TrOCR",local:"trocr",headingTag:"h1"}}),Y=new q({props:{title:"Overview",local:"overview",headingTag:"h2"}}),oe=new q({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),re=new q({props:{title:"Resources",local:"resources",headingTag:"h2"}}),ae=new Lo({props:{pipeline:"text-classification"}}),le=new Lo({props:{pipeline:"text-generation"}}),pe=new q({props:{title:"Inference",local:"inference",headingTag:"h2"}}),ue=new Kt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyT0NSUHJvY2Vzc29yJTJDJTIwVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbCUwQWltcG9ydCUyMHJlcXVlc3RzJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBcHJvY2Vzc29yJTIwJTNEJTIwVHJPQ1JQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnRyb2NyLWJhc2UtaGFuZHdyaXR0ZW4lMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZ0cm9jci1iYXNlLWhhbmR3cml0dGVuJTIyKSUwQSUwQSUyMyUyMGxvYWQlMjBpbWFnZSUyMGZyb20lMjB0aGUlMjBJQU0lMjBkYXRhc2V0JTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZma2kudGljLmhlaWEtZnIuY2glMkZzdGF0aWMlMkZpbWclMkZhMDEtMTIyLTAyLmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KS5jb252ZXJ0KCUyMlJHQiUyMiklMEElMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5waXhlbF92YWx1ZXMlMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUocGl4ZWxfdmFsdWVzKSUwQSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrOCRProcessor, VisionEncoderDecoderModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = TrOCRProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/trocr-base-handwritten&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;microsoft/trocr-base-handwritten&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load image from the IAM dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://fki.tic.heia-fr.ch/static/img/a01-122-02.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw).convert(<span class="hljs-string">&quot;RGB&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(pixel_values)

<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = processor.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]`,wrap:!1}}),Te=new q({props:{title:"TrOCRConfig",local:"transformers.TrOCRConfig",headingTag:"h2"}}),be=new F({props:{name:"class transformers.TrOCRConfig",anchor:"transformers.TrOCRConfig",parameters:[{name:"vocab_size",val:" = 50265"},{name:"d_model",val:" = 1024"},{name:"decoder_layers",val:" = 12"},{name:"decoder_attention_heads",val:" = 16"},{name:"decoder_ffn_dim",val:" = 4096"},{name:"activation_function",val:" = 'gelu'"},{name:"max_position_embeddings",val:" = 512"},{name:"dropout",val:" = 0.1"},{name:"attention_dropout",val:" = 0.0"},{name:"activation_dropout",val:" = 0.0"},{name:"decoder_start_token_id",val:" = 2"},{name:"init_std",val:" = 0.02"},{name:"decoder_layerdrop",val:" = 0.0"},{name:"use_cache",val:" = True"},{name:"scale_embedding",val:" = False"},{name:"use_learned_position_embeddings",val:" = True"},{name:"layernorm_embedding",val:" = True"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrOCRConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50265) &#x2014;
Vocabulary size of the TrOCR model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRForCausalLM">TrOCRForCausalLM</a>.`,name:"vocab_size"},{anchor:"transformers.TrOCRConfig.d_model",description:`<strong>d_model</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Dimensionality of the layers and the pooler layer.`,name:"d_model"},{anchor:"transformers.TrOCRConfig.decoder_layers",description:`<strong>decoder_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of decoder layers.`,name:"decoder_layers"},{anchor:"transformers.TrOCRConfig.decoder_attention_heads",description:`<strong>decoder_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer decoder.`,name:"decoder_attention_heads"},{anchor:"transformers.TrOCRConfig.decoder_ffn_dim",description:`<strong>decoder_ffn_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in decoder.`,name:"decoder_ffn_dim"},{anchor:"transformers.TrOCRConfig.activation_function",description:`<strong>activation_function</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the pooler. If string, <code>&quot;gelu&quot;</code>, <code>&quot;relu&quot;</code>,
<code>&quot;silu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"activation_function"},{anchor:"transformers.TrOCRConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.TrOCRConfig.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, and pooler.`,name:"dropout"},{anchor:"transformers.TrOCRConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.TrOCRConfig.activation_dropout",description:`<strong>activation_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for activations inside the fully connected layer.`,name:"activation_dropout"},{anchor:"transformers.TrOCRConfig.init_std",description:`<strong>init_std</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"init_std"},{anchor:"transformers.TrOCRConfig.decoder_layerdrop",description:`<strong>decoder_layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The LayerDrop probability for the decoder. See the [LayerDrop paper](see <a href="https://arxiv.org/abs/1909.11556" rel="nofollow">https://arxiv.org/abs/1909.11556</a>)
for more details.`,name:"decoder_layerdrop"},{anchor:"transformers.TrOCRConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.TrOCRConfig.scale_embedding",description:`<strong>scale_embedding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to scale the word embeddings by sqrt(d_model).`,name:"scale_embedding"},{anchor:"transformers.TrOCRConfig.use_learned_position_embeddings",description:`<strong>use_learned_position_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use learned position embeddings. If not, sinusoidal position embeddings will be used.`,name:"use_learned_position_embeddings"},{anchor:"transformers.TrOCRConfig.layernorm_embedding",description:`<strong>layernorm_embedding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use a layernorm after the word + position embeddings.`,name:"layernorm_embedding"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/configuration_trocr.py#L24"}}),P=new Oo({props:{anchor:"transformers.TrOCRConfig.example",$$slots:{default:[Vo]},$$scope:{ctx:j}}}),ye=new q({props:{title:"TrOCRProcessor",local:"transformers.TrOCRProcessor",headingTag:"h2"}}),Me=new F({props:{name:"class transformers.TrOCRProcessor",anchor:"transformers.TrOCRProcessor",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrOCRProcessor.image_processor",description:`<strong>image_processor</strong> ([<code>ViTImageProcessor</code>/<code>DeiTImageProcessor</code>], <em>optional</em>) &#x2014;
An instance of [<code>ViTImageProcessor</code>/<code>DeiTImageProcessor</code>]. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.TrOCRProcessor.tokenizer",description:`<strong>tokenizer</strong> ([<code>RobertaTokenizer</code>/<code>XLMRobertaTokenizer</code>], <em>optional</em>) &#x2014;
An instance of [<code>RobertaTokenizer</code>/<code>XLMRobertaTokenizer</code>]. The tokenizer is a required input.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/processing_trocr.py#L33"}}),we=new F({props:{name:"__call__",anchor:"transformers.TrOCRProcessor.__call__",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']] = None"},{name:"text",val:": typing.Union[str, typing.List[str], typing.List[typing.List[str]]] = None"},{name:"audio",val:" = None"},{name:"videos",val:" = None"},{name:"**kwargs",val:": typing_extensions.Unpack[transformers.models.trocr.processing_trocr.TrOCRProcessorKwargs]"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/processing_trocr.py#L72"}}),ve=new F({props:{name:"from_pretrained",anchor:"transformers.TrOCRProcessor.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike]"},{name:"cache_dir",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"force_download",val:": bool = False"},{name:"local_files_only",val:": bool = False"},{name:"token",val:": typing.Union[str, bool, NoneType] = None"},{name:"revision",val:": str = 'main'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrOCRProcessor.from_pretrained.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
This can be either:</p>
<ul>
<li>a string, the <em>model id</em> of a pretrained feature_extractor hosted inside a model repo on
huggingface.co.</li>
<li>a path to a <em>directory</em> containing a feature extractor file saved using the
<a href="/docs/transformers/main/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained">save_pretrained()</a> method, e.g., <code>./my_model_directory/</code>.</li>
<li>a path or url to a saved feature extractor JSON <em>file</em>, e.g.,
<code>./my_model_directory/preprocessor_config.json</code>.</li>
</ul>`,name:"pretrained_model_name_or_path"},{anchor:"transformers.TrOCRProcessor.from_pretrained.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments passed along to both
<a href="/docs/transformers/main/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained">from_pretrained()</a> and
<code>~tokenization_utils_base.PreTrainedTokenizer.from_pretrained</code>.`,name:"*kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/processing_utils.py#L1126"}}),V=new At({props:{$$slots:{default:[No]},$$scope:{ctx:j}}}),Ce=new F({props:{name:"save_pretrained",anchor:"transformers.TrOCRProcessor.save_pretrained",parameters:[{name:"save_directory",val:""},{name:"push_to_hub",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrOCRProcessor.save_pretrained.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory where the feature extractor JSON file and the tokenizer files will be saved (directory will
be created if it does not exist).`,name:"save_directory"},{anchor:"transformers.TrOCRProcessor.save_pretrained.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
repository you want to push to with <code>repo_id</code> (will default to the name of <code>save_directory</code> in your
namespace).`,name:"push_to_hub"},{anchor:"transformers.TrOCRProcessor.save_pretrained.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/main/en/main_classes/model#transformers.utils.PushToHubMixin.push_to_hub">push_to_hub()</a> method.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/processing_utils.py#L582"}}),N=new At({props:{$$slots:{default:[Bo]},$$scope:{ctx:j}}}),ke=new F({props:{name:"batch_decode",anchor:"transformers.TrOCRProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/processing_trocr.py#L112"}}),Re=new F({props:{name:"decode",anchor:"transformers.TrOCRProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/processing_trocr.py#L119"}}),$e=new q({props:{title:"TrOCRForCausalLM",local:"transformers.TrOCRForCausalLM",headingTag:"h2"}}),je=new F({props:{name:"class transformers.TrOCRForCausalLM",anchor:"transformers.TrOCRForCausalLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.TrOCRForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRForCausalLM">TrOCRForCausalLM</a>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/modeling_trocr.py#L714"}}),xe=new F({props:{name:"forward",anchor:"transformers.TrOCRForCausalLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attn_head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.TrOCRForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TrOCRForCausalLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TrOCRForCausalLM.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention
if the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.TrOCRForCausalLM.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.TrOCRForCausalLM.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TrOCRForCausalLM.forward.cross_attn_head_mask",description:`<strong>cross_attn_head_mask</strong> (<code>torch.Tensor</code> of shape <code>(decoder_layers, decoder_attention_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the cross-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"cross_attn_head_mask"},{anchor:"transformers.TrOCRForCausalLM.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.FloatTensor]]</code>, <em>optional</em>) &#x2014;
Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used to speed up sequential decoding. This typically consists in the <code>past_key_values</code>
returned by the model at a previous stage of decoding, when <code>use_cache=True</code> or <code>config.use_cache=True</code>.</p>
<p>Two formats are allowed:</p>
<ul>
<li>a <a href="/docs/transformers/main/en/internal/generation_utils#transformers.Cache">Cache</a> instance, see our <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">kv cache guide</a>;</li>
<li>Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of
shape <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>). This is also known as the legacy
cache format.</li>
</ul>
<p>The model will output the same cache format that is fed as input. If no <code>past_key_values</code> are passed, the
legacy cache format will be returned.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>input_ids</code> (those that don&#x2019;t
have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all <code>input_ids</code>
of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.TrOCRForCausalLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TrOCRForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should either be in <code>[0, ..., config.vocab_size]</code> or -100 (see <code>input_ids</code> docstring). Tokens with indices set to <code>-100</code> are ignored
(masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"labels"},{anchor:"transformers.TrOCRForCausalLM.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TrOCRForCausalLM.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TrOCRForCausalLM.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TrOCRForCausalLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/trocr/modeling_trocr.py#L752",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/trocr#transformers.TrOCRConfig"
>TrOCRConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>Cache</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — It is a <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.Cache"
>Cache</a> instance. For more details, see our <a
  href="https://huggingface.co/docs/transformers/en/kv_cache"
  rel="nofollow"
>kv cache guide</a>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),G=new At({props:{$$slots:{default:[Eo]},$$scope:{ctx:j}}}),X=new Oo({props:{anchor:"transformers.TrOCRForCausalLM.forward.example",$$slots:{default:[Go]},$$scope:{ctx:j}}}),Je=new Ho({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/trocr.md"}}),{c(){a=i("meta"),M=r(),p=i("p"),b=r(),h(v.$$.fragment),m=r(),C=i("div"),C.innerHTML=eo,Se=r(),h(Y.$$.fragment),qe=r(),Q=i("p"),Q.innerHTML=to,Ye=r(),D=i("p"),D.textContent=oo,Qe=r(),A=i("p"),A.innerHTML=no,De=r(),z=i("img"),Ae=r(),K=i("small"),K.innerHTML=so,Ke=r(),ee=i("p"),ee.innerHTML=ao,et=r(),te=i("p"),te.innerHTML=io,tt=r(),h(oe.$$.fragment),ot=r(),ne=i("ul"),ne.innerHTML=lo,nt=r(),h(re.$$.fragment),rt=r(),se=i("p"),se.textContent=co,st=r(),h(ae.$$.fragment),at=r(),ie=i("ul"),ie.innerHTML=mo,it=r(),h(le.$$.fragment),lt=r(),de=i("ul"),de.innerHTML=po,dt=r(),ce=i("p"),ce.textContent=ho,ct=r(),me=i("ul"),me.innerHTML=fo,mt=r(),h(pe.$$.fragment),pt=r(),he=i("p"),he.innerHTML=go,ht=r(),fe=i("p"),fe.innerHTML=uo,ft=r(),ge=i("ul"),ge.innerHTML=_o,gt=r(),h(ue.$$.fragment),ut=r(),_e=i("p"),_e.innerHTML=To,_t=r(),h(Te.$$.fragment),Tt=r(),$=i("div"),h(be.$$.fragment),jt=r(),Oe=i("p"),Oe.innerHTML=bo,xt=r(),Le=i("p"),Le.innerHTML=yo,Jt=r(),h(P.$$.fragment),bt=r(),h(ye.$$.fragment),yt=r(),y=i("div"),h(Me.$$.fragment),Zt=r(),Ie=i("p"),Ie.textContent=Mo,Ot=r(),Ue=i("p"),Ue.innerHTML=wo,Lt=r(),H=i("div"),h(we.$$.fragment),It=r(),We=i("p"),We.innerHTML=vo,Ut=r(),O=i("div"),h(ve.$$.fragment),Wt=r(),Fe=i("p"),Fe.textContent=Co,Ft=r(),h(V.$$.fragment),zt=r(),L=i("div"),h(Ce.$$.fragment),Pt=r(),ze=i("p"),ze.innerHTML=ko,Ht=r(),h(N.$$.fragment),Vt=r(),B=i("div"),h(ke.$$.fragment),Nt=r(),Pe=i("p"),Pe.innerHTML=Ro,Bt=r(),E=i("div"),h(Re.$$.fragment),Et=r(),He=i("p"),He.innerHTML=$o,Mt=r(),h($e.$$.fragment),wt=r(),k=i("div"),h(je.$$.fragment),Gt=r(),Ve=i("p"),Ve.innerHTML=jo,Xt=r(),Ne=i("p"),Ne.innerHTML=xo,St=r(),Be=i("p"),Be.innerHTML=Jo,qt=r(),x=i("div"),h(xe.$$.fragment),Yt=r(),Ee=i("p"),Ee.innerHTML=Zo,Qt=r(),h(G.$$.fragment),Dt=r(),h(X.$$.fragment),vt=r(),h(Je.$$.fragment),Ct=r(),Ge=i("p"),this.h()},l(e){const t=Po("svelte-u9bgzb",document.head);a=l(t,"META",{name:!0,content:!0}),t.forEach(o),M=s(e),p=l(e,"P",{}),Z(p).forEach(o),b=s(e),f(v.$$.fragment,e),m=s(e),C=l(e,"DIV",{class:!0,"data-svelte-h":!0}),c(C)!=="svelte-13t8s2t"&&(C.innerHTML=eo),Se=s(e),f(Y.$$.fragment,e),qe=s(e),Q=l(e,"P",{"data-svelte-h":!0}),c(Q)!=="svelte-1ueqt35"&&(Q.innerHTML=to),Ye=s(e),D=l(e,"P",{"data-svelte-h":!0}),c(D)!=="svelte-vfdo9a"&&(D.textContent=oo),Qe=s(e),A=l(e,"P",{"data-svelte-h":!0}),c(A)!=="svelte-u8sjcw"&&(A.innerHTML=no),De=s(e),z=l(e,"IMG",{src:!0,alt:!0,width:!0}),Ae=s(e),K=l(e,"SMALL",{"data-svelte-h":!0}),c(K)!=="svelte-745sv3"&&(K.innerHTML=so),Ke=s(e),ee=l(e,"P",{"data-svelte-h":!0}),c(ee)!=="svelte-1qnnowp"&&(ee.innerHTML=ao),et=s(e),te=l(e,"P",{"data-svelte-h":!0}),c(te)!=="svelte-38zca0"&&(te.innerHTML=io),tt=s(e),f(oe.$$.fragment,e),ot=s(e),ne=l(e,"UL",{"data-svelte-h":!0}),c(ne)!=="svelte-10xobs4"&&(ne.innerHTML=lo),nt=s(e),f(re.$$.fragment,e),rt=s(e),se=l(e,"P",{"data-svelte-h":!0}),c(se)!=="svelte-j67pez"&&(se.textContent=co),st=s(e),f(ae.$$.fragment,e),at=s(e),ie=l(e,"UL",{"data-svelte-h":!0}),c(ie)!=="svelte-14fopzs"&&(ie.innerHTML=mo),it=s(e),f(le.$$.fragment,e),lt=s(e),de=l(e,"UL",{"data-svelte-h":!0}),c(de)!=="svelte-1k3rqn7"&&(de.innerHTML=po),dt=s(e),ce=l(e,"P",{"data-svelte-h":!0}),c(ce)!=="svelte-1wntqpp"&&(ce.textContent=ho),ct=s(e),me=l(e,"UL",{"data-svelte-h":!0}),c(me)!=="svelte-16d3ard"&&(me.innerHTML=fo),mt=s(e),f(pe.$$.fragment,e),pt=s(e),he=l(e,"P",{"data-svelte-h":!0}),c(he)!=="svelte-1ssx7pl"&&(he.innerHTML=go),ht=s(e),fe=l(e,"P",{"data-svelte-h":!0}),c(fe)!=="svelte-1eos4qd"&&(fe.innerHTML=uo),ft=s(e),ge=l(e,"UL",{"data-svelte-h":!0}),c(ge)!=="svelte-1noonjl"&&(ge.innerHTML=_o),gt=s(e),f(ue.$$.fragment,e),ut=s(e),_e=l(e,"P",{"data-svelte-h":!0}),c(_e)!=="svelte-1iv4swp"&&(_e.innerHTML=To),_t=s(e),f(Te.$$.fragment,e),Tt=s(e),$=l(e,"DIV",{class:!0});var J=Z($);f(be.$$.fragment,J),jt=s(J),Oe=l(J,"P",{"data-svelte-h":!0}),c(Oe)!=="svelte-r74b6l"&&(Oe.innerHTML=bo),xt=s(J),Le=l(J,"P",{"data-svelte-h":!0}),c(Le)!=="svelte-o55m63"&&(Le.innerHTML=yo),Jt=s(J),f(P.$$.fragment,J),J.forEach(o),bt=s(e),f(ye.$$.fragment,e),yt=s(e),y=l(e,"DIV",{class:!0});var w=Z(y);f(Me.$$.fragment,w),Zt=s(w),Ie=l(w,"P",{"data-svelte-h":!0}),c(Ie)!=="svelte-ndaubh"&&(Ie.textContent=Mo),Ot=s(w),Ue=l(w,"P",{"data-svelte-h":!0}),c(Ue)!=="svelte-dh9xun"&&(Ue.innerHTML=wo),Lt=s(w),H=l(w,"DIV",{class:!0});var Ze=Z(H);f(we.$$.fragment,Ze),It=s(Ze),We=l(Ze,"P",{"data-svelte-h":!0}),c(We)!=="svelte-xwje5k"&&(We.innerHTML=vo),Ze.forEach(o),Ut=s(w),O=l(w,"DIV",{class:!0});var U=Z(O);f(ve.$$.fragment,U),Wt=s(U),Fe=l(U,"P",{"data-svelte-h":!0}),c(Fe)!=="svelte-1cj8dcb"&&(Fe.textContent=Co),Ft=s(U),f(V.$$.fragment,U),U.forEach(o),zt=s(w),L=l(w,"DIV",{class:!0});var W=Z(L);f(Ce.$$.fragment,W),Pt=s(W),ze=l(W,"P",{"data-svelte-h":!0}),c(ze)!=="svelte-ovc737"&&(ze.innerHTML=ko),Ht=s(W),f(N.$$.fragment,W),W.forEach(o),Vt=s(w),B=l(w,"DIV",{class:!0});var Rt=Z(B);f(ke.$$.fragment,Rt),Nt=s(Rt),Pe=l(Rt,"P",{"data-svelte-h":!0}),c(Pe)!=="svelte-1blqecf"&&(Pe.innerHTML=Ro),Rt.forEach(o),Bt=s(w),E=l(w,"DIV",{class:!0});var $t=Z(E);f(Re.$$.fragment,$t),Et=s($t),He=l($t,"P",{"data-svelte-h":!0}),c(He)!=="svelte-8dkssl"&&(He.innerHTML=$o),$t.forEach(o),w.forEach(o),Mt=s(e),f($e.$$.fragment,e),wt=s(e),k=l(e,"DIV",{class:!0});var I=Z(k);f(je.$$.fragment,I),Gt=s(I),Ve=l(I,"P",{"data-svelte-h":!0}),c(Ve)!=="svelte-vqv7st"&&(Ve.innerHTML=jo),Xt=s(I),Ne=l(I,"P",{"data-svelte-h":!0}),c(Ne)!=="svelte-6pahdo"&&(Ne.innerHTML=xo),St=s(I),Be=l(I,"P",{"data-svelte-h":!0}),c(Be)!=="svelte-hswkmf"&&(Be.innerHTML=Jo),qt=s(I),x=l(I,"DIV",{class:!0});var S=Z(x);f(xe.$$.fragment,S),Yt=s(S),Ee=l(S,"P",{"data-svelte-h":!0}),c(Ee)!=="svelte-1c1jf4j"&&(Ee.innerHTML=Zo),Qt=s(S),f(G.$$.fragment,S),Dt=s(S),f(X.$$.fragment,S),S.forEach(o),I.forEach(o),vt=s(e),f(Je.$$.fragment,e),Ct=s(e),Ge=l(e,"P",{}),Z(Ge).forEach(o),this.h()},h(){R(a,"name","hf:doc:metadata"),R(a,"content",So),R(C,"class","flex flex-wrap space-x-1"),Uo(z.src,ro="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/trocr_architecture.jpg")||R(z,"src",ro),R(z,"alt","drawing"),R(z,"width","600"),R($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){d(document.head,a),n(e,M,t),n(e,p,t),n(e,b,t),g(v,e,t),n(e,m,t),n(e,C,t),n(e,Se,t),g(Y,e,t),n(e,qe,t),n(e,Q,t),n(e,Ye,t),n(e,D,t),n(e,Qe,t),n(e,A,t),n(e,De,t),n(e,z,t),n(e,Ae,t),n(e,K,t),n(e,Ke,t),n(e,ee,t),n(e,et,t),n(e,te,t),n(e,tt,t),g(oe,e,t),n(e,ot,t),n(e,ne,t),n(e,nt,t),g(re,e,t),n(e,rt,t),n(e,se,t),n(e,st,t),g(ae,e,t),n(e,at,t),n(e,ie,t),n(e,it,t),g(le,e,t),n(e,lt,t),n(e,de,t),n(e,dt,t),n(e,ce,t),n(e,ct,t),n(e,me,t),n(e,mt,t),g(pe,e,t),n(e,pt,t),n(e,he,t),n(e,ht,t),n(e,fe,t),n(e,ft,t),n(e,ge,t),n(e,gt,t),g(ue,e,t),n(e,ut,t),n(e,_e,t),n(e,_t,t),g(Te,e,t),n(e,Tt,t),n(e,$,t),g(be,$,null),d($,jt),d($,Oe),d($,xt),d($,Le),d($,Jt),g(P,$,null),n(e,bt,t),g(ye,e,t),n(e,yt,t),n(e,y,t),g(Me,y,null),d(y,Zt),d(y,Ie),d(y,Ot),d(y,Ue),d(y,Lt),d(y,H),g(we,H,null),d(H,It),d(H,We),d(y,Ut),d(y,O),g(ve,O,null),d(O,Wt),d(O,Fe),d(O,Ft),g(V,O,null),d(y,zt),d(y,L),g(Ce,L,null),d(L,Pt),d(L,ze),d(L,Ht),g(N,L,null),d(y,Vt),d(y,B),g(ke,B,null),d(B,Nt),d(B,Pe),d(y,Bt),d(y,E),g(Re,E,null),d(E,Et),d(E,He),n(e,Mt,t),g($e,e,t),n(e,wt,t),n(e,k,t),g(je,k,null),d(k,Gt),d(k,Ve),d(k,Xt),d(k,Ne),d(k,St),d(k,Be),d(k,qt),d(k,x),g(xe,x,null),d(x,Yt),d(x,Ee),d(x,Qt),g(G,x,null),d(x,Dt),g(X,x,null),n(e,vt,t),g(Je,e,t),n(e,Ct,t),n(e,Ge,t),kt=!0},p(e,[t]){const J={};t&2&&(J.$$scope={dirty:t,ctx:e}),P.$set(J);const w={};t&2&&(w.$$scope={dirty:t,ctx:e}),V.$set(w);const Ze={};t&2&&(Ze.$$scope={dirty:t,ctx:e}),N.$set(Ze);const U={};t&2&&(U.$$scope={dirty:t,ctx:e}),G.$set(U);const W={};t&2&&(W.$$scope={dirty:t,ctx:e}),X.$set(W)},i(e){kt||(u(v.$$.fragment,e),u(Y.$$.fragment,e),u(oe.$$.fragment,e),u(re.$$.fragment,e),u(ae.$$.fragment,e),u(le.$$.fragment,e),u(pe.$$.fragment,e),u(ue.$$.fragment,e),u(Te.$$.fragment,e),u(be.$$.fragment,e),u(P.$$.fragment,e),u(ye.$$.fragment,e),u(Me.$$.fragment,e),u(we.$$.fragment,e),u(ve.$$.fragment,e),u(V.$$.fragment,e),u(Ce.$$.fragment,e),u(N.$$.fragment,e),u(ke.$$.fragment,e),u(Re.$$.fragment,e),u($e.$$.fragment,e),u(je.$$.fragment,e),u(xe.$$.fragment,e),u(G.$$.fragment,e),u(X.$$.fragment,e),u(Je.$$.fragment,e),kt=!0)},o(e){_(v.$$.fragment,e),_(Y.$$.fragment,e),_(oe.$$.fragment,e),_(re.$$.fragment,e),_(ae.$$.fragment,e),_(le.$$.fragment,e),_(pe.$$.fragment,e),_(ue.$$.fragment,e),_(Te.$$.fragment,e),_(be.$$.fragment,e),_(P.$$.fragment,e),_(ye.$$.fragment,e),_(Me.$$.fragment,e),_(we.$$.fragment,e),_(ve.$$.fragment,e),_(V.$$.fragment,e),_(Ce.$$.fragment,e),_(N.$$.fragment,e),_(ke.$$.fragment,e),_(Re.$$.fragment,e),_($e.$$.fragment,e),_(je.$$.fragment,e),_(xe.$$.fragment,e),_(G.$$.fragment,e),_(X.$$.fragment,e),_(Je.$$.fragment,e),kt=!1},d(e){e&&(o(M),o(p),o(b),o(m),o(C),o(Se),o(qe),o(Q),o(Ye),o(D),o(Qe),o(A),o(De),o(z),o(Ae),o(K),o(Ke),o(ee),o(et),o(te),o(tt),o(ot),o(ne),o(nt),o(rt),o(se),o(st),o(at),o(ie),o(it),o(lt),o(de),o(dt),o(ce),o(ct),o(me),o(mt),o(pt),o(he),o(ht),o(fe),o(ft),o(ge),o(gt),o(ut),o(_e),o(_t),o(Tt),o($),o(bt),o(yt),o(y),o(Mt),o(wt),o(k),o(vt),o(Ct),o(Ge)),o(a),T(v,e),T(Y,e),T(oe,e),T(re,e),T(ae,e),T(le,e),T(pe,e),T(ue,e),T(Te,e),T(be),T(P),T(ye,e),T(Me),T(we),T(ve),T(V),T(Ce),T(N),T(ke),T(Re),T($e,e),T(je),T(xe),T(G),T(X),T(Je,e)}}}const So='{"title":"TrOCR","local":"trocr","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2},{"title":"TrOCRConfig","local":"transformers.TrOCRConfig","sections":[],"depth":2},{"title":"TrOCRProcessor","local":"transformers.TrOCRProcessor","sections":[],"depth":2},{"title":"TrOCRForCausalLM","local":"transformers.TrOCRForCausalLM","sections":[],"depth":2}],"depth":1}';function qo(j){return Wo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class rn extends Fo{constructor(a){super(),zo(this,a,qo,Xo,Io,{})}}export{rn as component};
