import{s as Zr,f as Or,o as Ur,n as ro}from"../chunks/scheduler.9bc65507.js";import{S as Ir,i as Wr,g as r,s as l,u as f,A as Lr,h as n,f as t,c as i,j as h,v as g,y as m,k as d,o as a,a as s,w as _,d as T,t as v,x as b}from"../chunks/index.78c82d43.js";import{T as xr}from"../chunks/Tip.87d55b76.js";import{D as F}from"../chunks/Docstring.4e7352e2.js";import{C as Uo}from"../chunks/CodeBlock.73e038be.js";import{I as Ne}from"../chunks/IconCopyLink.bedaa44d.js";import{E as jr}from"../chunks/ExampleCodeBlock.872b014d.js";import{P as Jr}from"../chunks/PipelineTag.75b0f707.js";function zr(j){let c,C="Example:",u,y,M;return y=new Uo({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(){c=r("p"),c.textContent=C,u=l(),f(y.$$.fragment)},l(p){c=n(p,"P",{"data-svelte-h":!0}),m(c)!=="svelte-11lpom8"&&(c.textContent=C),u=i(p),g(y.$$.fragment,p)},m(p,R){s(p,c,R),s(p,u,R),_(y,p,R),M=!0},p:ro,i(p){M||(T(y.$$.fragment,p),M=!0)},o(p){v(y.$$.fragment,p),M=!1},d(p){p&&(t(c),t(u)),b(y,p)}}}function Fr(j){let c,C=`This class method is simply calling the feature extractor
<a href="/docs/transformers/v4.34.0/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained">from_pretrained()</a>, image processor
<a href="/docs/transformers/v4.34.0/en/main_classes/image_processor#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(){c=r("p"),c.innerHTML=C},l(u){c=n(u,"P",{"data-svelte-h":!0}),m(c)!=="svelte-gbwq5r"&&(c.innerHTML=C)},m(u,y){s(u,c,y)},p:ro,d(u){u&&t(c)}}}function Pr(j){let c,C=`This class method is simply calling <a href="/docs/transformers/v4.34.0/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.save_pretrained">save_pretrained()</a> and
<a href="/docs/transformers/v4.34.0/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(){c=r("p"),c.innerHTML=C},l(u){c=n(u,"P",{"data-svelte-h":!0}),m(c)!=="svelte-1rzuu8q"&&(c.innerHTML=C)},m(u,y){s(u,c,y)},p:ro,d(u){u&&t(c)}}}function Nr(j){let c,C="Example:",u,y,M;return y=new Uo({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBUck9DUkNvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMFRyT0NSUHJvY2Vzc29yJTJDJTBBJTIwJTIwJTIwJTIwVHJPQ1JGb3JDYXVzYWxMTSUyQyUwQSUyMCUyMCUyMCUyMFZpVENvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMFZpVE1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbCUyQyUwQSklMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQSUwQSUyMyUyMFRyT0NSJTIwaXMlMjBhJTIwZGVjb2RlciUyMG1vZGVsJTIwYW5kJTIwc2hvdWxkJTIwYmUlMjB1c2VkJTIwd2l0aGluJTIwYSUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMjMlMjBpbml0JTIwdmlzaW9uMnRleHQlMjBtb2RlbCUyMHdpdGglMjByYW5kb20lMjB3ZWlnaHRzJTBBZW5jb2RlciUyMCUzRCUyMFZpVE1vZGVsKFZpVENvbmZpZygpKSUwQWRlY29kZXIlMjAlM0QlMjBUck9DUkZvckNhdXNhbExNKFRyT0NSQ29uZmlnKCkpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsKGVuY29kZXIlM0RlbmNvZGVyJTJDJTIwZGVjb2RlciUzRGRlY29kZXIpJTBBJTBBJTIzJTIwSWYlMjB5b3UlMjB3YW50JTIwdG8lMjBzdGFydCUyMGZyb20lMjB0aGUlMjBwcmV0cmFpbmVkJTIwbW9kZWwlMkMlMjBsb2FkJTIwdGhlJTIwY2hlY2twb2ludCUyMHdpdGglMjAlNjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsJTYwJTBBcHJvY2Vzc29yJTIwJTNEJTIwVHJPQ1JQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnRyb2NyLWJhc2UtaGFuZHdyaXR0ZW4lMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZ0cm9jci1iYXNlLWhhbmR3cml0dGVuJTIyKSUwQSUwQSUyMyUyMGxvYWQlMjBpbWFnZSUyMGZyb20lMjB0aGUlMjBJQU0lMjBkYXRhc2V0JTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZma2kudGljLmhlaWEtZnIuY2glMkZzdGF0aWMlMkZpbWclMkZhMDEtMTIyLTAyLmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KS5jb252ZXJ0KCUyMlJHQiUyMiklMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5waXhlbF92YWx1ZXMlMEF0ZXh0JTIwJTNEJTIwJTIyaW5kdXN0cnklMkMlMjAnJTIwTXIuJTIwQnJvd24lMjBjb21tZW50ZWQlMjBpY2lseS4lMjAnJTIwTGV0JTIwdXMlMjBoYXZlJTIwYSUyMiUwQSUwQSUyMyUyMHRyYWluaW5nJTBBbW9kZWwuY29uZmlnLmRlY29kZXJfc3RhcnRfdG9rZW5faWQlMjAlM0QlMjBwcm9jZXNzb3IudG9rZW5pemVyLmNsc190b2tlbl9pZCUwQW1vZGVsLmNvbmZpZy5wYWRfdG9rZW5faWQlMjAlM0QlMjBwcm9jZXNzb3IudG9rZW5pemVyLnBhZF90b2tlbl9pZCUwQW1vZGVsLmNvbmZpZy52b2NhYl9zaXplJTIwJTNEJTIwbW9kZWwuY29uZmlnLmRlY29kZXIudm9jYWJfc2l6ZSUwQSUwQWxhYmVscyUyMCUzRCUyMHByb2Nlc3Nvci50b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLmlucHV0X2lkcyUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChwaXhlbF92YWx1ZXMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQXJvdW5kKGxvc3MuaXRlbSgpJTJDJTIwMiklMEElMEElMjMlMjBpbmZlcmVuY2UlMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUocGl4ZWxfdmFsdWVzKSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwcHJvY2Vzc29yLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RCUwQWdlbmVyYXRlZF90ZXh0",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.cls_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(){c=r("p"),c.textContent=C,u=l(),f(y.$$.fragment)},l(p){c=n(p,"P",{"data-svelte-h":!0}),m(c)!=="svelte-11lpom8"&&(c.textContent=C),u=i(p),g(y.$$.fragment,p)},m(p,R){s(p,c,R),s(p,u,R),_(y,p,R),M=!0},p:ro,i(p){M||(T(y.$$.fragment,p),M=!0)},o(p){v(y.$$.fragment,p),M=!1},d(p){p&&(t(c),t(u)),b(y,p)}}}function Er(j){let c,C,u,y,M,p,R,oe,no,Ee,Io="TrOCR",gt,O,P,lt,re,so,Ve,Wo="Overview",_t,ne,Lo=`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>.`,Tt,se,zo="The abstract from the paper is the following:",vt,ae,Fo=`<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>`,bt,N,Po,yt,le,No='TrOCR architecture. Taken from the <a href="https://arxiv.org/abs/2109.10282">original paper</a>.',wt,ie,Eo="Please refer to the <code>VisionEncoderDecoder</code> class on how to use this model.",Mt,de,Vo=`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>.`,Ct,ce,Ho="Tips:",kt,me,Bo=`<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>`,Rt,U,E,it,pe,ao,He,So="Resources",$t,he,Xo="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.",xt,ue,jt,fe,Go='<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>',Jt,ge,Zt,_e,qo='<li><a href="https://huggingface.co/docs/transformers/tasks/language_modeling" rel="nofollow">Casual language modeling</a> task guide.</li>',Ot,Te,Ao="⚡️ Inference",Ut,ve,Yo='<li>An interactive-demo on <a href="https://huggingface.co/spaces/nielsr/TrOCR-handwritten" rel="nofollow">TrOCR handwritten character recognition</a>.</li>',It,I,V,dt,be,lo,Be,Qo="Inference",Wt,ye,Do=`TrOCR’s <code>VisionEncoderDecoder</code> model accepts images as input and makes use of
<a href="/docs/transformers/v4.34.0/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a> to autoregressively generate text given the input image.`,Lt,we,Ko=`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/v4.34.0/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.`,zt,Me,er="<li>Step-by-step Optical Character Recognition (OCR)</li>",Ft,Ce,Pt,ke,tr='See the <a href="https://huggingface.co/models?filter=trocr" rel="nofollow">model hub</a> to look for TrOCR checkpoints.',Nt,W,H,ct,Re,io,Se,or="TrOCRConfig",Et,$,$e,co,Xe,rr=`This is the configuration class to store the configuration of a <a href="/docs/transformers/v4.34.0/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.`,mo,Ge,nr=`Configuration objects inherit from <a href="/docs/transformers/v4.34.0/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/v4.34.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,po,B,Vt,L,S,mt,xe,ho,qe,sr="TrOCRProcessor",Ht,w,je,uo,Ae,ar="Constructs a TrOCR processor which wraps a vision image processor and a TrOCR tokenizer into a single processor.",fo,Ye,lr=`<a href="/docs/transformers/v4.34.0/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/v4.34.0/en/model_doc/trocr#transformers.TrOCRProcessor.__call__"><strong>call</strong>()</a> and <a href="/docs/transformers/v4.34.0/en/model_doc/trocr#transformers.TrOCRProcessor.decode">decode()</a> for
more information.`,go,X,Je,_o,Qe,ir=`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 doctsring of the above two methods for more information.`,To,J,Ze,vo,De,dr="Instantiate a processor associated with a pretrained model.",bo,G,yo,Z,Oe,wo,Ke,cr=`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/v4.34.0/en/model_doc/nougat#transformers.NougatProcessor.from_pretrained">from_pretrained()</a> method.`,Mo,q,Co,A,Ue,ko,et,mr=`This method forwards all its arguments to TrOCRTokenizer’s <a href="/docs/transformers/v4.34.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.batch_decode">batch_decode()</a>. Please refer
to the docstring of this method for more information.`,Ro,Y,Ie,$o,tt,pr=`This method forwards all its arguments to TrOCRTokenizer’s <a href="/docs/transformers/v4.34.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.decode">decode()</a>. Please refer to the
docstring of this method for more information.`,Bt,z,Q,pt,We,xo,ot,hr="TrOCRForCausalLM",St,x,Le,jo,rt,ur=`The TrOCR Decoder with a language modeling head. Can be used as the decoder part of <a href="/docs/transformers/v4.34.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> and <code>VisionEncoderDecoder</code>.
This model inherits from <a href="/docs/transformers/v4.34.0/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.)`,Jo,nt,fr=`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.`,Zo,D,ze,Oo,K,Xt,ht,Gt;return oe=new Ne({}),re=new Ne({}),pe=new Ne({}),ue=new Jr({props:{pipeline:"text-classification"}}),ge=new Jr({props:{pipeline:"text-generation"}}),be=new Ne({}),Ce=new Uo({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}}),Re=new Ne({}),$e=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/v4.34.0/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/v4.34.0/src/transformers/models/trocr/configuration_trocr.py#L31"}}),B=new jr({props:{anchor:"transformers.TrOCRConfig.example",$$slots:{default:[zr]},$$scope:{ctx:j}}}),xe=new Ne({}),je=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>]) &#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>]) &#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/v4.34.0/src/transformers/models/trocr/processing_trocr.py#L24"}}),Je=new F({props:{name:"__call__",anchor:"transformers.TrOCRProcessor.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/trocr/processing_trocr.py#L62"}}),Ze=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[bool, str, 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. Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or
namespaced under a user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>a path to a <em>directory</em> containing a feature extractor file saved using the
<a href="/docs/transformers/v4.34.0/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>.
**kwargs &#x2014;
Additional keyword arguments passed along to both
<a href="/docs/transformers/v4.34.0/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin.from_pretrained">from_pretrained()</a> and
<code>~tokenization_utils_base.PreTrainedTokenizer.from_pretrained</code>.</li>
</ul>`,name:"pretrained_model_name_or_path"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/processing_utils.py#L167"}}),G=new xr({props:{$$slots:{default:[Fr]},$$scope:{ctx:j}}}),Oe=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/v4.34.0/en/main_classes/processors#transformers.ProcessorMixin.push_to_hub">push_to_hub()</a> method.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/processing_utils.py#L93"}}),q=new xr({props:{$$slots:{default:[Pr]},$$scope:{ctx:j}}}),Ue=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/v4.34.0/src/transformers/models/trocr/processing_trocr.py#L95"}}),Ie=new F({props:{name:"decode",anchor:"transformers.TrOCRProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/trocr/processing_trocr.py#L102"}}),We=new Ne({}),Le=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/v4.34.0/en/model_doc/trocr#transformers.TrOCRConfig">TrOCRConfig</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/v4.34.0/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/v4.34.0/src/transformers/models/trocr/modeling_trocr.py#L790"}}),ze=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>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.34.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.34.0/en/model_doc/vits#transformers.VitsTokenizer.__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.FloatTensor</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>:`,name:"encoder_attention_mask"},{anchor:"transformers.TrOCRForCausalLM.forward.head_mask",description:`<strong>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 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>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
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>) and 2 additional tensors of
shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>. The two additional
tensors are only required when the model is used as a decoder in a Sequence to Sequence model.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the
cross-attention blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_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>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{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>).</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:"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/v4.34.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/trocr/modeling_trocr.py#L823",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.34.0/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/v4.34.0/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>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — Tuple of <code>torch.FloatTensor</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if <code>config.is_decoder = True</code>.</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:`
<p><a
  href="/docs/transformers/v4.34.0/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),K=new jr({props:{anchor:"transformers.TrOCRForCausalLM.forward.example",$$slots:{default:[Nr]},$$scope:{ctx:j}}}),{c(){c=r("meta"),C=l(),u=r("p"),y=l(),M=r("h1"),p=r("a"),R=r("span"),f(oe.$$.fragment),no=l(),Ee=r("span"),Ee.textContent=Io,gt=l(),O=r("h2"),P=r("a"),lt=r("span"),f(re.$$.fragment),so=l(),Ve=r("span"),Ve.textContent=Wo,_t=l(),ne=r("p"),ne.innerHTML=Lo,Tt=l(),se=r("p"),se.textContent=zo,vt=l(),ae=r("p"),ae.innerHTML=Fo,bt=l(),N=r("img"),yt=l(),le=r("small"),le.innerHTML=No,wt=l(),ie=r("p"),ie.innerHTML=Eo,Mt=l(),de=r("p"),de.innerHTML=Vo,Ct=l(),ce=r("p"),ce.textContent=Ho,kt=l(),me=r("ul"),me.innerHTML=Bo,Rt=l(),U=r("h2"),E=r("a"),it=r("span"),f(pe.$$.fragment),ao=l(),He=r("span"),He.textContent=So,$t=l(),he=r("p"),he.textContent=Xo,xt=l(),f(ue.$$.fragment),jt=l(),fe=r("ul"),fe.innerHTML=Go,Jt=l(),f(ge.$$.fragment),Zt=l(),_e=r("ul"),_e.innerHTML=qo,Ot=l(),Te=r("p"),Te.textContent=Ao,Ut=l(),ve=r("ul"),ve.innerHTML=Yo,It=l(),I=r("h2"),V=r("a"),dt=r("span"),f(be.$$.fragment),lo=l(),Be=r("span"),Be.textContent=Qo,Wt=l(),ye=r("p"),ye.innerHTML=Do,Lt=l(),we=r("p"),we.innerHTML=Ko,zt=l(),Me=r("ul"),Me.innerHTML=er,Ft=l(),f(Ce.$$.fragment),Pt=l(),ke=r("p"),ke.innerHTML=tr,Nt=l(),W=r("h2"),H=r("a"),ct=r("span"),f(Re.$$.fragment),io=l(),Se=r("span"),Se.textContent=or,Et=l(),$=r("div"),f($e.$$.fragment),co=l(),Xe=r("p"),Xe.innerHTML=rr,mo=l(),Ge=r("p"),Ge.innerHTML=nr,po=l(),f(B.$$.fragment),Vt=l(),L=r("h2"),S=r("a"),mt=r("span"),f(xe.$$.fragment),ho=l(),qe=r("span"),qe.textContent=sr,Ht=l(),w=r("div"),f(je.$$.fragment),uo=l(),Ae=r("p"),Ae.textContent=ar,fo=l(),Ye=r("p"),Ye.innerHTML=lr,go=l(),X=r("div"),f(Je.$$.fragment),_o=l(),Qe=r("p"),Qe.innerHTML=ir,To=l(),J=r("div"),f(Ze.$$.fragment),vo=l(),De=r("p"),De.textContent=dr,bo=l(),f(G.$$.fragment),yo=l(),Z=r("div"),f(Oe.$$.fragment),wo=l(),Ke=r("p"),Ke.innerHTML=cr,Mo=l(),f(q.$$.fragment),Co=l(),A=r("div"),f(Ue.$$.fragment),ko=l(),et=r("p"),et.innerHTML=mr,Ro=l(),Y=r("div"),f(Ie.$$.fragment),$o=l(),tt=r("p"),tt.innerHTML=pr,Bt=l(),z=r("h2"),Q=r("a"),pt=r("span"),f(We.$$.fragment),xo=l(),ot=r("span"),ot.textContent=hr,St=l(),x=r("div"),f(Le.$$.fragment),jo=l(),rt=r("p"),rt.innerHTML=ur,Jo=l(),nt=r("p"),nt.innerHTML=fr,Zo=l(),D=r("div"),f(ze.$$.fragment),Oo=l(),f(K.$$.fragment),Xt=l(),ht=r("p"),this.h()},l(e){const o=Lr("svelte-1phssyn",document.head);c=n(o,"META",{name:!0,content:!0}),o.forEach(t),C=i(e),u=n(e,"P",{}),h(u).forEach(t),y=i(e),M=n(e,"H1",{class:!0});var Fe=h(M);p=n(Fe,"A",{id:!0,class:!0,href:!0});var ut=h(p);R=n(ut,"SPAN",{});var ft=h(R);g(oe.$$.fragment,ft),ft.forEach(t),ut.forEach(t),no=i(Fe),Ee=n(Fe,"SPAN",{"data-svelte-h":!0}),m(Ee)!=="svelte-1tn81sh"&&(Ee.textContent=Io),Fe.forEach(t),gt=i(e),O=n(e,"H2",{class:!0});var Pe=h(O);P=n(Pe,"A",{id:!0,class:!0,href:!0});var gr=h(P);lt=n(gr,"SPAN",{});var _r=h(lt);g(re.$$.fragment,_r),_r.forEach(t),gr.forEach(t),so=i(Pe),Ve=n(Pe,"SPAN",{"data-svelte-h":!0}),m(Ve)!=="svelte-1jsw1pg"&&(Ve.textContent=Wo),Pe.forEach(t),_t=i(e),ne=n(e,"P",{"data-svelte-h":!0}),m(ne)!=="svelte-1ueqt35"&&(ne.innerHTML=Lo),Tt=i(e),se=n(e,"P",{"data-svelte-h":!0}),m(se)!=="svelte-vfdo9a"&&(se.textContent=zo),vt=i(e),ae=n(e,"P",{"data-svelte-h":!0}),m(ae)!=="svelte-u8sjcw"&&(ae.innerHTML=Fo),bt=i(e),N=n(e,"IMG",{src:!0,alt:!0,width:!0}),yt=i(e),le=n(e,"SMALL",{"data-svelte-h":!0}),m(le)!=="svelte-745sv3"&&(le.innerHTML=No),wt=i(e),ie=n(e,"P",{"data-svelte-h":!0}),m(ie)!=="svelte-1qnnowp"&&(ie.innerHTML=Eo),Mt=i(e),de=n(e,"P",{"data-svelte-h":!0}),m(de)!=="svelte-38zca0"&&(de.innerHTML=Vo),Ct=i(e),ce=n(e,"P",{"data-svelte-h":!0}),m(ce)!=="svelte-axv494"&&(ce.textContent=Ho),kt=i(e),me=n(e,"UL",{"data-svelte-h":!0}),m(me)!=="svelte-10xobs4"&&(me.innerHTML=Bo),Rt=i(e),U=n(e,"H2",{class:!0});var qt=h(U);E=n(qt,"A",{id:!0,class:!0,href:!0});var Tr=h(E);it=n(Tr,"SPAN",{});var vr=h(it);g(pe.$$.fragment,vr),vr.forEach(t),Tr.forEach(t),ao=i(qt),He=n(qt,"SPAN",{"data-svelte-h":!0}),m(He)!=="svelte-w4zzv6"&&(He.textContent=So),qt.forEach(t),$t=i(e),he=n(e,"P",{"data-svelte-h":!0}),m(he)!=="svelte-j67pez"&&(he.textContent=Xo),xt=i(e),g(ue.$$.fragment,e),jt=i(e),fe=n(e,"UL",{"data-svelte-h":!0}),m(fe)!=="svelte-14fopzs"&&(fe.innerHTML=Go),Jt=i(e),g(ge.$$.fragment,e),Zt=i(e),_e=n(e,"UL",{"data-svelte-h":!0}),m(_e)!=="svelte-1k3rqn7"&&(_e.innerHTML=qo),Ot=i(e),Te=n(e,"P",{"data-svelte-h":!0}),m(Te)!=="svelte-1wntqpp"&&(Te.textContent=Ao),Ut=i(e),ve=n(e,"UL",{"data-svelte-h":!0}),m(ve)!=="svelte-16d3ard"&&(ve.innerHTML=Yo),It=i(e),I=n(e,"H2",{class:!0});var At=h(I);V=n(At,"A",{id:!0,class:!0,href:!0});var br=h(V);dt=n(br,"SPAN",{});var yr=h(dt);g(be.$$.fragment,yr),yr.forEach(t),br.forEach(t),lo=i(At),Be=n(At,"SPAN",{"data-svelte-h":!0}),m(Be)!=="svelte-199uz7g"&&(Be.textContent=Qo),At.forEach(t),Wt=i(e),ye=n(e,"P",{"data-svelte-h":!0}),m(ye)!=="svelte-z8x53z"&&(ye.innerHTML=Do),Lt=i(e),we=n(e,"P",{"data-svelte-h":!0}),m(we)!=="svelte-10lxz3t"&&(we.innerHTML=Ko),zt=i(e),Me=n(e,"UL",{"data-svelte-h":!0}),m(Me)!=="svelte-1noonjl"&&(Me.innerHTML=er),Ft=i(e),g(Ce.$$.fragment,e),Pt=i(e),ke=n(e,"P",{"data-svelte-h":!0}),m(ke)!=="svelte-1iv4swp"&&(ke.innerHTML=tr),Nt=i(e),W=n(e,"H2",{class:!0});var Yt=h(W);H=n(Yt,"A",{id:!0,class:!0,href:!0});var wr=h(H);ct=n(wr,"SPAN",{});var Mr=h(ct);g(Re.$$.fragment,Mr),Mr.forEach(t),wr.forEach(t),io=i(Yt),Se=n(Yt,"SPAN",{"data-svelte-h":!0}),m(Se)!=="svelte-k9xanf"&&(Se.textContent=or),Yt.forEach(t),Et=i(e),$=n(e,"DIV",{class:!0});var ee=h($);g($e.$$.fragment,ee),co=i(ee),Xe=n(ee,"P",{"data-svelte-h":!0}),m(Xe)!=="svelte-1w5kc2x"&&(Xe.innerHTML=rr),mo=i(ee),Ge=n(ee,"P",{"data-svelte-h":!0}),m(Ge)!=="svelte-10kqkkl"&&(Ge.innerHTML=nr),po=i(ee),g(B.$$.fragment,ee),ee.forEach(t),Vt=i(e),L=n(e,"H2",{class:!0});var Qt=h(L);S=n(Qt,"A",{id:!0,class:!0,href:!0});var Cr=h(S);mt=n(Cr,"SPAN",{});var kr=h(mt);g(xe.$$.fragment,kr),kr.forEach(t),Cr.forEach(t),ho=i(Qt),qe=n(Qt,"SPAN",{"data-svelte-h":!0}),m(qe)!=="svelte-1atbqlj"&&(qe.textContent=sr),Qt.forEach(t),Ht=i(e),w=n(e,"DIV",{class:!0});var k=h(w);g(je.$$.fragment,k),uo=i(k),Ae=n(k,"P",{"data-svelte-h":!0}),m(Ae)!=="svelte-ndaubh"&&(Ae.textContent=ar),fo=i(k),Ye=n(k,"P",{"data-svelte-h":!0}),m(Ye)!=="svelte-vzubv"&&(Ye.innerHTML=lr),go=i(k),X=n(k,"DIV",{class:!0});var Dt=h(X);g(Je.$$.fragment,Dt),_o=i(Dt),Qe=n(Dt,"P",{"data-svelte-h":!0}),m(Qe)!=="svelte-9cxgu"&&(Qe.innerHTML=ir),Dt.forEach(t),To=i(k),J=n(k,"DIV",{class:!0});var st=h(J);g(Ze.$$.fragment,st),vo=i(st),De=n(st,"P",{"data-svelte-h":!0}),m(De)!=="svelte-1cj8dcb"&&(De.textContent=dr),bo=i(st),g(G.$$.fragment,st),st.forEach(t),yo=i(k),Z=n(k,"DIV",{class:!0});var at=h(Z);g(Oe.$$.fragment,at),wo=i(at),Ke=n(at,"P",{"data-svelte-h":!0}),m(Ke)!=="svelte-7negql"&&(Ke.innerHTML=cr),Mo=i(at),g(q.$$.fragment,at),at.forEach(t),Co=i(k),A=n(k,"DIV",{class:!0});var Kt=h(A);g(Ue.$$.fragment,Kt),ko=i(Kt),et=n(Kt,"P",{"data-svelte-h":!0}),m(et)!=="svelte-11tzdco"&&(et.innerHTML=mr),Kt.forEach(t),Ro=i(k),Y=n(k,"DIV",{class:!0});var eo=h(Y);g(Ie.$$.fragment,eo),$o=i(eo),tt=n(eo,"P",{"data-svelte-h":!0}),m(tt)!=="svelte-1vgsmz6"&&(tt.innerHTML=pr),eo.forEach(t),k.forEach(t),Bt=i(e),z=n(e,"H2",{class:!0});var to=h(z);Q=n(to,"A",{id:!0,class:!0,href:!0});var Rr=h(Q);pt=n(Rr,"SPAN",{});var $r=h(pt);g(We.$$.fragment,$r),$r.forEach(t),Rr.forEach(t),xo=i(to),ot=n(to,"SPAN",{"data-svelte-h":!0}),m(ot)!=="svelte-1sln71k"&&(ot.textContent=hr),to.forEach(t),St=i(e),x=n(e,"DIV",{class:!0});var te=h(x);g(Le.$$.fragment,te),jo=i(te),rt=n(te,"P",{"data-svelte-h":!0}),m(rt)!=="svelte-13kiztc"&&(rt.innerHTML=ur),Jo=i(te),nt=n(te,"P",{"data-svelte-h":!0}),m(nt)!=="svelte-hswkmf"&&(nt.innerHTML=fr),Zo=i(te),D=n(te,"DIV",{class:!0});var oo=h(D);g(ze.$$.fragment,oo),Oo=i(oo),g(K.$$.fragment,oo),oo.forEach(t),te.forEach(t),Xt=i(e),ht=n(e,"P",{}),h(ht).forEach(t),this.h()},h(){d(c,"name","hf:doc:metadata"),d(c,"content",JSON.stringify(Vr)),d(p,"id","trocr"),d(p,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(p,"href","#trocr"),d(M,"class","relative group"),d(P,"id","overview"),d(P,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(P,"href","#overview"),d(O,"class","relative group"),Or(N.src,Po="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/trocr_architecture.jpg")||d(N,"src",Po),d(N,"alt","drawing"),d(N,"width","600"),d(E,"id","resources"),d(E,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(E,"href","#resources"),d(U,"class","relative group"),d(V,"id","inference"),d(V,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(V,"href","#inference"),d(I,"class","relative group"),d(H,"id","transformers.TrOCRConfig"),d(H,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(H,"href","#transformers.TrOCRConfig"),d(W,"class","relative group"),d($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(S,"id","transformers.TrOCRProcessor"),d(S,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(S,"href","#transformers.TrOCRProcessor"),d(L,"class","relative group"),d(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(Q,"id","transformers.TrOCRForCausalLM"),d(Q,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Q,"href","#transformers.TrOCRForCausalLM"),d(z,"class","relative group"),d(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(x,"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,o){a(document.head,c),s(e,C,o),s(e,u,o),s(e,y,o),s(e,M,o),a(M,p),a(p,R),_(oe,R,null),a(M,no),a(M,Ee),s(e,gt,o),s(e,O,o),a(O,P),a(P,lt),_(re,lt,null),a(O,so),a(O,Ve),s(e,_t,o),s(e,ne,o),s(e,Tt,o),s(e,se,o),s(e,vt,o),s(e,ae,o),s(e,bt,o),s(e,N,o),s(e,yt,o),s(e,le,o),s(e,wt,o),s(e,ie,o),s(e,Mt,o),s(e,de,o),s(e,Ct,o),s(e,ce,o),s(e,kt,o),s(e,me,o),s(e,Rt,o),s(e,U,o),a(U,E),a(E,it),_(pe,it,null),a(U,ao),a(U,He),s(e,$t,o),s(e,he,o),s(e,xt,o),_(ue,e,o),s(e,jt,o),s(e,fe,o),s(e,Jt,o),_(ge,e,o),s(e,Zt,o),s(e,_e,o),s(e,Ot,o),s(e,Te,o),s(e,Ut,o),s(e,ve,o),s(e,It,o),s(e,I,o),a(I,V),a(V,dt),_(be,dt,null),a(I,lo),a(I,Be),s(e,Wt,o),s(e,ye,o),s(e,Lt,o),s(e,we,o),s(e,zt,o),s(e,Me,o),s(e,Ft,o),_(Ce,e,o),s(e,Pt,o),s(e,ke,o),s(e,Nt,o),s(e,W,o),a(W,H),a(H,ct),_(Re,ct,null),a(W,io),a(W,Se),s(e,Et,o),s(e,$,o),_($e,$,null),a($,co),a($,Xe),a($,mo),a($,Ge),a($,po),_(B,$,null),s(e,Vt,o),s(e,L,o),a(L,S),a(S,mt),_(xe,mt,null),a(L,ho),a(L,qe),s(e,Ht,o),s(e,w,o),_(je,w,null),a(w,uo),a(w,Ae),a(w,fo),a(w,Ye),a(w,go),a(w,X),_(Je,X,null),a(X,_o),a(X,Qe),a(w,To),a(w,J),_(Ze,J,null),a(J,vo),a(J,De),a(J,bo),_(G,J,null),a(w,yo),a(w,Z),_(Oe,Z,null),a(Z,wo),a(Z,Ke),a(Z,Mo),_(q,Z,null),a(w,Co),a(w,A),_(Ue,A,null),a(A,ko),a(A,et),a(w,Ro),a(w,Y),_(Ie,Y,null),a(Y,$o),a(Y,tt),s(e,Bt,o),s(e,z,o),a(z,Q),a(Q,pt),_(We,pt,null),a(z,xo),a(z,ot),s(e,St,o),s(e,x,o),_(Le,x,null),a(x,jo),a(x,rt),a(x,Jo),a(x,nt),a(x,Zo),a(x,D),_(ze,D,null),a(D,Oo),_(K,D,null),s(e,Xt,o),s(e,ht,o),Gt=!0},p(e,[o]){const Fe={};o&2&&(Fe.$$scope={dirty:o,ctx:e}),B.$set(Fe);const ut={};o&2&&(ut.$$scope={dirty:o,ctx:e}),G.$set(ut);const ft={};o&2&&(ft.$$scope={dirty:o,ctx:e}),q.$set(ft);const Pe={};o&2&&(Pe.$$scope={dirty:o,ctx:e}),K.$set(Pe)},i(e){Gt||(T(oe.$$.fragment,e),T(re.$$.fragment,e),T(pe.$$.fragment,e),T(ue.$$.fragment,e),T(ge.$$.fragment,e),T(be.$$.fragment,e),T(Ce.$$.fragment,e),T(Re.$$.fragment,e),T($e.$$.fragment,e),T(B.$$.fragment,e),T(xe.$$.fragment,e),T(je.$$.fragment,e),T(Je.$$.fragment,e),T(Ze.$$.fragment,e),T(G.$$.fragment,e),T(Oe.$$.fragment,e),T(q.$$.fragment,e),T(Ue.$$.fragment,e),T(Ie.$$.fragment,e),T(We.$$.fragment,e),T(Le.$$.fragment,e),T(ze.$$.fragment,e),T(K.$$.fragment,e),Gt=!0)},o(e){v(oe.$$.fragment,e),v(re.$$.fragment,e),v(pe.$$.fragment,e),v(ue.$$.fragment,e),v(ge.$$.fragment,e),v(be.$$.fragment,e),v(Ce.$$.fragment,e),v(Re.$$.fragment,e),v($e.$$.fragment,e),v(B.$$.fragment,e),v(xe.$$.fragment,e),v(je.$$.fragment,e),v(Je.$$.fragment,e),v(Ze.$$.fragment,e),v(G.$$.fragment,e),v(Oe.$$.fragment,e),v(q.$$.fragment,e),v(Ue.$$.fragment,e),v(Ie.$$.fragment,e),v(We.$$.fragment,e),v(Le.$$.fragment,e),v(ze.$$.fragment,e),v(K.$$.fragment,e),Gt=!1},d(e){e&&(t(C),t(u),t(y),t(M),t(gt),t(O),t(_t),t(ne),t(Tt),t(se),t(vt),t(ae),t(bt),t(N),t(yt),t(le),t(wt),t(ie),t(Mt),t(de),t(Ct),t(ce),t(kt),t(me),t(Rt),t(U),t($t),t(he),t(xt),t(jt),t(fe),t(Jt),t(Zt),t(_e),t(Ot),t(Te),t(Ut),t(ve),t(It),t(I),t(Wt),t(ye),t(Lt),t(we),t(zt),t(Me),t(Ft),t(Pt),t(ke),t(Nt),t(W),t(Et),t($),t(Vt),t(L),t(Ht),t(w),t(Bt),t(z),t(St),t(x),t(Xt),t(ht)),t(c),b(oe),b(re),b(pe),b(ue,e),b(ge,e),b(be),b(Ce,e),b(Re),b($e),b(B),b(xe),b(je),b(Je),b(Ze),b(G),b(Oe),b(q),b(Ue),b(Ie),b(We),b(Le),b(ze),b(K)}}}const Vr={local:"trocr",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"inference",title:"Inference"},{local:"transformers.TrOCRConfig",title:"TrOCRConfig"},{local:"transformers.TrOCRProcessor",title:"TrOCRProcessor"},{local:"transformers.TrOCRForCausalLM",title:"TrOCRForCausalLM"}],title:"TrOCR"};function Hr(j){return Ur(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Dr extends Ir{constructor(c){super(),Wr(this,c,Hr,Er,Zr,{})}}export{Dr as component};
