import{s as _n,f as bn,o as vn,n as Bt}from"../chunks/scheduler.9bc65507.js";import{S as Mn,i as yn,g as o,s as r,u as g,A as wn,h as n,f as t,c as l,j as p,v as f,y as m,k as d,o as s,a as i,w as _,d as b,t as v,x as M}from"../chunks/index.78c82d43.js";import{T as go}from"../chunks/Tip.87d55b76.js";import{D as I}from"../chunks/Docstring.4e7352e2.js";import{C as Nt}from"../chunks/CodeBlock.73e038be.js";import{I as Y}from"../chunks/IconCopyLink.bedaa44d.js";import{E as fn}from"../chunks/ExampleCodeBlock.872b014d.js";function Tn(U){let c,T="Example:",u,y,j;return y=new Nt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERvbnV0U3dpbkNvbmZpZyUyQyUyMERvbnV0U3dpbk1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMERvbnV0JTIwbmF2ZXItY2xvdmEtaXglMkZkb251dC1iYXNlJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMERvbnV0U3dpbkNvbmZpZygpJTBBJTBBJTIzJTIwUmFuZG9tbHklMjBpbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwbmF2ZXItY2xvdmEtaXglMkZkb251dC1iYXNlJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBEb251dFN3aW5Nb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DonutSwinConfig, DonutSwinModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Donut naver-clova-ix/donut-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = DonutSwinConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Randomly initializing a model from the naver-clova-ix/donut-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DonutSwinModel(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=o("p"),c.textContent=T,u=r(),g(y.$$.fragment)},l(h){c=n(h,"P",{"data-svelte-h":!0}),m(c)!=="svelte-11lpom8"&&(c.textContent=T),u=l(h),f(y.$$.fragment,h)},m(h,x){i(h,c,x),i(h,u,x),_(y,h,x),j=!0},p:Bt,i(h){j||(b(y.$$.fragment,h),j=!0)},o(h){v(y.$$.fragment,h),j=!1},d(h){h&&(t(c),t(u)),M(y,h)}}}function jn(U){let c,T=`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=o("p"),c.innerHTML=T},l(u){c=n(u,"P",{"data-svelte-h":!0}),m(c)!=="svelte-gbwq5r"&&(c.innerHTML=T)},m(u,y){i(u,c,y)},p:Bt,d(u){u&&t(c)}}}function Jn(U){let c,T=`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=o("p"),c.innerHTML=T},l(u){c=n(u,"P",{"data-svelte-h":!0}),m(c)!=="svelte-1rzuu8q"&&(c.innerHTML=T)},m(u,y){i(u,c,y)},p:Bt,d(u){u&&t(c)}}}function xn(U){let c,T=`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(){c=o("p"),c.innerHTML=T},l(u){c=n(u,"P",{"data-svelte-h":!0}),m(c)!=="svelte-fincs2"&&(c.innerHTML=T)},m(u,y){i(u,c,y)},p:Bt,d(u){u&&t(c)}}}function kn(U){let c,T="Example:",u,y,j;return y=new Nt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMERvbnV0U3dpbk1vZGVsJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGF0YXNldHMlMjBpbXBvcnQlMjBsb2FkX2RhdGFzZXQlMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmh1Z2dpbmdmYWNlJTJGY2F0cy1pbWFnZSUyMiklMEFpbWFnZSUyMCUzRCUyMGRhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTVCJTIyaW1hZ2UlMjIlNUQlNUIwJTVEJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGbmF2ZXItY2xvdmEtaXglMkZkb251dC1iYXNlJTIyKSUwQW1vZGVsJTIwJTNEJTIwRG9udXRTd2luTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZuYXZlci1jbG92YS1peCUyRmRvbnV0LWJhc2UlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGUlMEFsaXN0KGxhc3RfaGlkZGVuX3N0YXRlcy5zaGFwZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, DonutSwinModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;https://huggingface.co/naver-clova-ix/donut-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DonutSwinModel.from_pretrained(<span class="hljs-string">&quot;https://huggingface.co/naver-clova-ix/donut-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_states.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">49</span>, <span class="hljs-number">768</span>]`,wrap:!1}}),{c(){c=o("p"),c.textContent=T,u=r(),g(y.$$.fragment)},l(h){c=n(h,"P",{"data-svelte-h":!0}),m(c)!=="svelte-11lpom8"&&(c.textContent=T),u=l(h),f(y.$$.fragment,h)},m(h,x){i(h,c,x),i(h,u,x),_(y,h,x),j=!0},p:Bt,i(h){j||(b(y.$$.fragment,h),j=!0)},o(h){v(y.$$.fragment,h),j=!1},d(h){h&&(t(c),t(u)),M(y,h)}}}function In(U){let c,T,u,y,j,h,x,me,zs,Oe,fo="Donut",Xt,W,S,xt,he,$s,et,_o="Overview",Gt,ue,bo=`The Donut model was proposed in <a href="https://arxiv.org/abs/2111.15664" rel="nofollow">OCR-free Document Understanding Transformer</a> by
Geewook Kim, Teakgyu Hong, Moonbin Yim, Jeongyeon Nam, Jinyoung Park, Jinyeong Yim, Wonseok Hwang, Sangdoo Yun, Dongyoon Han, Seunghyun Park.
Donut consists of an image Transformer encoder and an autoregressive text Transformer decoder to perform document understanding
tasks such as document image classification, form understanding and visual question answering.`,Et,ge,vo="The abstract from the paper is the following:",Ft,fe,Mo="<em>Understanding document images (e.g., invoices) is a core but challenging task since it requires complex functions such as reading text and a holistic understanding of the document. Current Visual Document Understanding (VDU) methods outsource the task of reading text to off-the-shelf Optical Character Recognition (OCR) engines and focus on the understanding task with the OCR outputs. Although such OCR-based approaches have shown promising performance, they suffer from 1) high computational costs for using OCR; 2) inflexibility of OCR models on languages or types of document; 3) OCR error propagation to the subsequent process. To address these issues, in this paper, we introduce a novel OCR-free VDU model named Donut, which stands for Document understanding transformer. As the first step in OCR-free VDU research, we propose a simple architecture (i.e., Transformer) with a pre-training objective (i.e., cross-entropy loss). Donut is conceptually simple yet effective. Through extensive experiments and analyses, we show a simple OCR-free VDU model, Donut, achieves state-of-the-art performances on various VDU tasks in terms of both speed and accuracy. In addition, we offer a synthetic data generator that helps the model pre-training to be flexible in various languages and domains.</em>",Yt,q,yo,St,_e,wo='Donut high-level overview. Taken from the <a href="https://arxiv.org/abs/2111.15664">original paper</a>.',qt,be,To=`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/clovaai/donut" rel="nofollow">here</a>.`,Pt,ve,jo="Tips:",Ht,Me,Jo=`<li>The quickest way to get started with Donut is by checking the <a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/Donut" 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>Donut is always used within the <a href="vision-encoder-decoder">VisionEncoderDecoder</a> framework.</li>`,Lt,V,P,kt,ye,Rs,tt,xo="Inference",At,we,ko=`Donut’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.`,Qt,Te,Io=`The <a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutImageProcessor">DonutImageProcessor</a> class is responsible for preprocessing the input image and
[<code>XLMRobertaTokenizer</code>/<code>XLMRobertaTokenizerFast</code>] decodes the generated target tokens to the target string. The
<a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutProcessor">DonutProcessor</a> wraps <a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutImageProcessor">DonutImageProcessor</a> and [<code>XLMRobertaTokenizer</code>/<code>XLMRobertaTokenizerFast</code>]
into a single instance to both extract the input features and decode the predicted token ids.`,Kt,je,Uo="<li>Step-by-step Document Image Classification</li>",Ot,Je,es,xe,Co="<li>Step-by-step Document Parsing</li>",ts,ke,ss,Ie,Zo="<li>Step-by-step Document Visual Question Answering (DocVQA)</li>",os,Ue,ns,Ce,zo='See the <a href="https://huggingface.co/models?filter=donut" rel="nofollow">model hub</a> to look for Donut checkpoints.',as,D,H,It,Ze,Ws,st,$o="Training",rs,ze,Ro='We refer to the <a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/Donut" rel="nofollow">tutorial notebooks</a>.',ls,N,L,Ut,$e,Vs,ot,Wo="DonutSwinConfig",is,k,Re,Ds,nt,Vo=`This is the configuration class to store the configuration of a <a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutSwinModel">DonutSwinModel</a>. It is used to instantiate a
Donut 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 Donut
<a href="https://huggingface.co/naver-clova-ix/donut-base" rel="nofollow">naver-clova-ix/donut-base</a> architecture.`,Ns,at,Do=`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.`,Bs,A,ds,B,Q,Ct,We,Xs,rt,No="DonutImageProcessor",cs,Z,Ve,Gs,lt,Bo="Constructs a Donut image processor.",Es,K,De,Fs,it,Xo="Preprocess an image or batch of images.",ps,X,O,Zt,Ne,Ys,dt,Go="DonutFeatureExtractor",ms,G,Be,Ss,ee,Xe,qs,ct,Eo="Preprocess an image or a batch of images.",hs,E,te,zt,Ge,Ps,pt,Fo="DonutProcessor",us,w,Ee,Hs,mt,Yo=`Constructs a Donut processor which wraps a Donut image processor and an XLMRoBERTa tokenizer into a single
processor.`,Ls,ht,So=`<a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutProcessor">DonutProcessor</a> offers all the functionalities of <a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutImageProcessor">DonutImageProcessor</a> and
[<code>XLMRobertaTokenizer</code>/<code>XLMRobertaTokenizerFast</code>]. See the <a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutProcessor.__call__"><strong>call</strong>()</a> and
<a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutProcessor.decode">decode()</a> for more information.`,As,se,Fe,Qs,ut,qo=`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 DonutTokenizer’s
<code>~DonutTokenizer.__call__</code>. Please refer to the doctsring of the above two methods for more information.`,Ks,$,Ye,Os,gt,Po="Instantiate a processor associated with a pretrained model.",eo,oe,to,R,Se,so,ft,Ho=`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.`,oo,ne,no,ae,qe,ao,_t,Lo=`This method forwards all its arguments to DonutTokenizer’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,re,Pe,lo,bt,Ao=`This method forwards all its arguments to DonutTokenizer’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.`,gs,F,le,$t,He,io,vt,Qo="DonutSwinModel",fs,z,Le,co,Mt,Ko=`The bare Donut Swin Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,po,C,Ae,mo,yt,Oo='The <a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutSwinModel">DonutSwinModel</a> forward method, overrides the <code>__call__</code> special method.',ho,ie,uo,de,_s,Rt,bs;return me=new Y({}),he=new Y({}),ye=new Y({}),Je=new Nt({props:{code:"aW1wb3J0JTIwcmUlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwRG9udXRQcm9jZXNzb3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wYWRfdG9rZW4lMkMlMjAlMjIlMjIpJTBBc2VxdWVuY2UlMjAlM0QlMjByZS5zdWIociUyMiUzQy4qJTNGJTNFJTIyJTJDJTIwJTIyJTIyJTJDJTIwc2VxdWVuY2UlMkMlMjBjb3VudCUzRDEpLnN0cmlwKCklMjAlMjAlMjMlMjByZW1vdmUlMjBmaXJzdCUyMHRhc2slMjBzdGFydCUyMHRva2VuJTBBcHJpbnQocHJvY2Vzc29yLnRva2VuMmpzb24oc2VxdWVuY2UpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> re

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DonutProcessor, VisionEncoderDecoderModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = DonutProcessor.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-rvlcdip&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-rvlcdip&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load document image</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/example-documents&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-number">1</span>][<span class="hljs-string">&quot;image&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare decoder inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>task_prompt = <span class="hljs-string">&quot;&lt;s_rvlcdip&gt;&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<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>outputs = model.generate(
<span class="hljs-meta">... </span>    pixel_values.to(device),
<span class="hljs-meta">... </span>    decoder_input_ids=decoder_input_ids.to(device),
<span class="hljs-meta">... </span>    max_length=model.decoder.config.max_position_embeddings,
<span class="hljs-meta">... </span>    pad_token_id=processor.tokenizer.pad_token_id,
<span class="hljs-meta">... </span>    eos_token_id=processor.tokenizer.eos_token_id,
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    bad_words_ids=[[processor.tokenizer.unk_token_id]],
<span class="hljs-meta">... </span>    return_dict_in_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = processor.batch_decode(outputs.sequences)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = sequence.replace(processor.tokenizer.eos_token, <span class="hljs-string">&quot;&quot;</span>).replace(processor.tokenizer.pad_token, <span class="hljs-string">&quot;&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = re.sub(<span class="hljs-string">r&quot;&lt;.*?&gt;&quot;</span>, <span class="hljs-string">&quot;&quot;</span>, sequence, count=<span class="hljs-number">1</span>).strip()  <span class="hljs-comment"># remove first task start token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(processor.token2json(sequence))
{<span class="hljs-string">&#x27;class&#x27;</span>: <span class="hljs-string">&#x27;advertisement&#x27;</span>}`,wrap:!1}}),ke=new Nt({props:{code:"aW1wb3J0JTIwcmUlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwRG9udXRQcm9jZXNzb3IlMkMlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBaW1wb3J0JTIwdG9yY2glMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBEb251dFByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIybmF2ZXItY2xvdmEtaXglMkZkb251dC1iYXNlLWZpbmV0dW5lZC1jb3JkLXYyJTIyKSUwQW1vZGVsJTIwJTNEJTIwVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIybmF2ZXItY2xvdmEtaXglMkZkb251dC1iYXNlLWZpbmV0dW5lZC1jb3JkLXYyJTIyKSUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBbW9kZWwudG8oZGV2aWNlKSUwQSUyMyUyMGxvYWQlMjBkb2N1bWVudCUyMGltYWdlJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGZXhhbXBsZS1kb2N1bWVudHMlMjIlMkMlMjBzcGxpdCUzRCUyMnRlc3QlMjIpJTBBaW1hZ2UlMjAlM0QlMjBkYXRhc2V0JTVCMiU1RCU1QiUyMmltYWdlJTIyJTVEJTBBJTBBJTIzJTIwcHJlcGFyZSUyMGRlY29kZXIlMjBpbnB1dHMlMEF0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jBwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKG91dHB1dHMuc2VxdWVuY2VzKSU1QjAlNUQlMEFzZXF1ZW5jZSUyMCUzRCUyMHNlcXVlbmNlLnJlcGxhY2UocHJvY2Vzc29yLnRva2VuaXplci5lb3NfdG9rZW4lMkMlMjAlMjIlMjIpLnJlcGxhY2UocHJvY2Vzc29yLnRva2VuaXplci5wYWRfdG9rZW4lMkMlMjAlMjIlMjIpJTBBc2VxdWVuY2UlMjAlM0QlMjByZS5zdWIociUyMiUzQy4qJTNGJTNFJTIyJTJDJTIwJTIyJTIyJTJDJTIwc2VxdWVuY2UlMkMlMjBjb3VudCUzRDEpLnN0cmlwKCklMjAlMjAlMjMlMjByZW1vdmUlMjBmaXJzdCUyMHRhc2slMjBzdGFydCUyMHRva2VuJTBBcHJpbnQocHJvY2Vzc29yLnRva2VuMmpzb24oc2VxdWVuY2UpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> re

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DonutProcessor, VisionEncoderDecoderModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = DonutProcessor.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-cord-v2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-cord-v2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load document image</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/example-documents&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-number">2</span>][<span class="hljs-string">&quot;image&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare decoder inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>task_prompt = <span class="hljs-string">&quot;&lt;s_cord-v2&gt;&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<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>outputs = model.generate(
<span class="hljs-meta">... </span>    pixel_values.to(device),
<span class="hljs-meta">... </span>    decoder_input_ids=decoder_input_ids.to(device),
<span class="hljs-meta">... </span>    max_length=model.decoder.config.max_position_embeddings,
<span class="hljs-meta">... </span>    pad_token_id=processor.tokenizer.pad_token_id,
<span class="hljs-meta">... </span>    eos_token_id=processor.tokenizer.eos_token_id,
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    bad_words_ids=[[processor.tokenizer.unk_token_id]],
<span class="hljs-meta">... </span>    return_dict_in_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = processor.batch_decode(outputs.sequences)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = sequence.replace(processor.tokenizer.eos_token, <span class="hljs-string">&quot;&quot;</span>).replace(processor.tokenizer.pad_token, <span class="hljs-string">&quot;&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = re.sub(<span class="hljs-string">r&quot;&lt;.*?&gt;&quot;</span>, <span class="hljs-string">&quot;&quot;</span>, sequence, count=<span class="hljs-number">1</span>).strip()  <span class="hljs-comment"># remove first task start token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(processor.token2json(sequence))
{<span class="hljs-string">&#x27;menu&#x27;</span>: {<span class="hljs-string">&#x27;nm&#x27;</span>: <span class="hljs-string">&#x27;CINNAMON SUGAR&#x27;</span>, <span class="hljs-string">&#x27;unitprice&#x27;</span>: <span class="hljs-string">&#x27;17,000&#x27;</span>, <span class="hljs-string">&#x27;cnt&#x27;</span>: <span class="hljs-string">&#x27;1 x&#x27;</span>, <span class="hljs-string">&#x27;price&#x27;</span>: <span class="hljs-string">&#x27;17,000&#x27;</span>}, <span class="hljs-string">&#x27;sub_total&#x27;</span>: {<span class="hljs-string">&#x27;subtotal_price&#x27;</span>: <span class="hljs-string">&#x27;17,000&#x27;</span>}, <span class="hljs-string">&#x27;total&#x27;</span>: {<span class="hljs-string">&#x27;total_price&#x27;</span>: <span class="hljs-string">&#x27;17,000&#x27;</span>, <span class="hljs-string">&#x27;cashprice&#x27;</span>: <span class="hljs-string">&#x27;20,000&#x27;</span>, <span class="hljs-string">&#x27;changeprice&#x27;</span>: <span class="hljs-string">&#x27;3,000&#x27;</span>}}`,wrap:!1}}),Ue=new Nt({props:{code:"aW1wb3J0JTIwcmUlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwRG9udXRQcm9jZXNzb3IlMkMlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBaW1wb3J0JTIwdG9yY2glMEElMEFwcm9jZXNzb3IlMjAl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zKSU1QjAlNUQlMEFzZXF1ZW5jZSUyMCUzRCUyMHNlcXVlbmNlLnJlcGxhY2UocHJvY2Vzc29yLnRva2VuaXplci5lb3NfdG9rZW4lMkMlMjAlMjIlMjIpLnJlcGxhY2UocHJvY2Vzc29yLnRva2VuaXplci5wYWRfdG9rZW4lMkMlMjAlMjIlMjIpJTBBc2VxdWVuY2UlMjAlM0QlMjByZS5zdWIociUyMiUzQy4qJTNGJTNFJTIyJTJDJTIwJTIyJTIyJTJDJTIwc2VxdWVuY2UlMkMlMjBjb3VudCUzRDEpLnN0cmlwKCklMjAlMjAlMjMlMjByZW1vdmUlMjBmaXJzdCUyMHRhc2slMjBzdGFydCUyMHRva2VuJTBBcHJpbnQocHJvY2Vzc29yLnRva2VuMmpzb24oc2VxdWVuY2UpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> re

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DonutProcessor, VisionEncoderDecoderModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = DonutProcessor.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-docvqa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;naver-clova-ix/donut-base-finetuned-docvqa&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load document image from the DocVQA dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/example-documents&quot;</span>, split=<span class="hljs-string">&quot;test&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;image&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare decoder inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>task_prompt = <span class="hljs-string">&quot;&lt;s_docvqa&gt;&lt;s_question&gt;{user_input}&lt;/s_question&gt;&lt;s_answer&gt;&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;When is the coffee break?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = task_prompt.replace(<span class="hljs-string">&quot;{user_input}&quot;</span>, question)
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = processor.tokenizer(prompt, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<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>outputs = model.generate(
<span class="hljs-meta">... </span>    pixel_values.to(device),
<span class="hljs-meta">... </span>    decoder_input_ids=decoder_input_ids.to(device),
<span class="hljs-meta">... </span>    max_length=model.decoder.config.max_position_embeddings,
<span class="hljs-meta">... </span>    pad_token_id=processor.tokenizer.pad_token_id,
<span class="hljs-meta">... </span>    eos_token_id=processor.tokenizer.eos_token_id,
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    bad_words_ids=[[processor.tokenizer.unk_token_id]],
<span class="hljs-meta">... </span>    return_dict_in_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = processor.batch_decode(outputs.sequences)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = sequence.replace(processor.tokenizer.eos_token, <span class="hljs-string">&quot;&quot;</span>).replace(processor.tokenizer.pad_token, <span class="hljs-string">&quot;&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = re.sub(<span class="hljs-string">r&quot;&lt;.*?&gt;&quot;</span>, <span class="hljs-string">&quot;&quot;</span>, sequence, count=<span class="hljs-number">1</span>).strip()  <span class="hljs-comment"># remove first task start token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(processor.token2json(sequence))
{<span class="hljs-string">&#x27;question&#x27;</span>: <span class="hljs-string">&#x27;When is the coffee break?&#x27;</span>, <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;11-14 to 11:39 a.m.&#x27;</span>}`,wrap:!1}}),Ze=new Y({}),$e=new Y({}),Re=new I({props:{name:"class transformers.DonutSwinConfig",anchor:"transformers.DonutSwinConfig",parameters:[{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 4"},{name:"num_channels",val:" = 3"},{name:"embed_dim",val:" = 96"},{name:"depths",val:" = [2, 2, 6, 2]"},{name:"num_heads",val:" = [3, 6, 12, 24]"},{name:"window_size",val:" = 7"},{name:"mlp_ratio",val:" = 4.0"},{name:"qkv_bias",val:" = True"},{name:"hidden_dropout_prob",val:" = 0.0"},{name:"attention_probs_dropout_prob",val:" = 0.0"},{name:"drop_path_rate",val:" = 0.1"},{name:"hidden_act",val:" = 'gelu'"},{name:"use_absolute_embeddings",val:" = False"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutSwinConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 224) &#x2014;
The size (resolution) of each image.`,name:"image_size"},{anchor:"transformers.DonutSwinConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.DonutSwinConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of input channels.`,name:"num_channels"},{anchor:"transformers.DonutSwinConfig.embed_dim",description:`<strong>embed_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 96) &#x2014;
Dimensionality of patch embedding.`,name:"embed_dim"},{anchor:"transformers.DonutSwinConfig.depths",description:`<strong>depths</strong> (<code>list(int)</code>, <em>optional</em>, defaults to [2, 2, 6, 2]) &#x2014;
Depth of each layer in the Transformer encoder.`,name:"depths"},{anchor:"transformers.DonutSwinConfig.num_heads",description:`<strong>num_heads</strong> (<code>list(int)</code>, <em>optional</em>, defaults to [3, 6, 12, 24]) &#x2014;
Number of attention heads in each layer of the Transformer encoder.`,name:"num_heads"},{anchor:"transformers.DonutSwinConfig.window_size",description:`<strong>window_size</strong> (<code>int</code>, <em>optional</em>, defaults to 7) &#x2014;
Size of windows.`,name:"window_size"},{anchor:"transformers.DonutSwinConfig.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
Ratio of MLP hidden dimensionality to embedding dimensionality.`,name:"mlp_ratio"},{anchor:"transformers.DonutSwinConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Whether or not a learnable bias should be added to the queries, keys and values.`,name:"qkv_bias"},{anchor:"transformers.DonutSwinConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability for all fully connected layers in the embeddings and encoder.`,name:"hidden_dropout_prob"},{anchor:"transformers.DonutSwinConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.DonutSwinConfig.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Stochastic depth rate.`,name:"drop_path_rate"},{anchor:"transformers.DonutSwinConfig.hidden_act",description:`<strong>hidden_act</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 encoder. If string, <code>&quot;gelu&quot;</code>, <code>&quot;relu&quot;</code>,
<code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.DonutSwinConfig.use_absolute_embeddings",description:`<strong>use_absolute_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to False) &#x2014;
Whether or not to add absolute position embeddings to the patch embeddings.`,name:"use_absolute_embeddings"},{anchor:"transformers.DonutSwinConfig.initializer_range",description:`<strong>initializer_range</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:"initializer_range"},{anchor:"transformers.DonutSwinConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/configuration_donut_swin.py#L29"}}),A=new fn({props:{anchor:"transformers.DonutSwinConfig.example",$$slots:{default:[Tn]},$$scope:{ctx:U}}}),We=new Y({}),Ve=new I({props:{name:"class transformers.DonutImageProcessor",anchor:"transformers.DonutImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_thumbnail",val:": bool = True"},{name:"do_align_long_axis",val:": bool = False"},{name:"do_pad",val:": bool = True"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>size</code>. Can be overridden by
<code>do_resize</code> in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.DonutImageProcessor.size",description:`<strong>size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to <code>{&quot;shortest_edge&quot; -- 224}</code>):
Size of the image after resizing. The shortest edge of the image is resized to size[&#x201C;shortest_edge&#x201D;], with
the longest edge resized to keep the input aspect ratio. Can be overridden by <code>size</code> in the <code>preprocess</code>
method.`,name:"size"},{anchor:"transformers.DonutImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BILINEAR</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by <code>resample</code> in the <code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.DonutImageProcessor.do_thumbnail",description:`<strong>do_thumbnail</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image using thumbnail method.`,name:"do_thumbnail"},{anchor:"transformers.DonutImageProcessor.do_align_long_axis",description:`<strong>do_align_long_axis</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to align the long axis of the image with the long axis of <code>size</code> by rotating by 90 degrees.`,name:"do_align_long_axis"},{anchor:"transformers.DonutImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to pad the image. If <code>random_padding</code> is set to <code>True</code> in <code>preprocess</code>, each image is padded with a
random amont of padding on each size, up to the largest image size in the batch. Otherwise, all images are
padded to the largest image size in the batch.`,name:"do_pad"},{anchor:"transformers.DonutImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by <code>do_rescale</code> in
the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.DonutImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Can be overridden by <code>rescale_factor</code> in the <code>preprocess</code>
method.
do_normalize &#x2014;
Whether to normalize the image. Can be overridden by <code>do_normalize</code> in the <code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.DonutImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.DonutImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_STD</code>) &#x2014;
Image standard deviation.`,name:"image_std"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/image_processing_donut.py#L52"}}),De=new I({props:{name:"preprocess",anchor:"transformers.DonutImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"do_resize",val:": bool = None"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = None"},{name:"do_thumbnail",val:": bool = None"},{name:"do_align_long_axis",val:": bool = None"},{name:"do_pad",val:": bool = None"},{name:"random_padding",val:": bool = False"},{name:"do_rescale",val:": bool = None"},{name:"rescale_factor",val:": float = None"},{name:"do_normalize",val:": bool = None"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"data_format",val:": typing.Optional[transformers.image_utils.ChannelDimension] = <ChannelDimension.FIRST: 'channels_first'>"},{name:"input_data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.DonutImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.DonutImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Size of the image after resizing. Shortest edge of the image is resized to min(size[&#x201C;height&#x201D;],
size[&#x201C;width&#x201D;]) with the longest edge resized to keep the input aspect ratio.`,name:"size"},{anchor:"transformers.DonutImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only
has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.DonutImageProcessor.preprocess.do_thumbnail",description:`<strong>do_thumbnail</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_thumbnail</code>) &#x2014;
Whether to resize the image using thumbnail method.`,name:"do_thumbnail"},{anchor:"transformers.DonutImageProcessor.preprocess.do_align_long_axis",description:`<strong>do_align_long_axis</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_align_long_axis</code>) &#x2014;
Whether to align the long axis of the image with the long axis of <code>size</code> by rotating by 90 degrees.`,name:"do_align_long_axis"},{anchor:"transformers.DonutImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_pad</code>) &#x2014;
Whether to pad the image. If <code>random_padding</code> is set to <code>True</code>, each image is padded with a random
amont of padding on each size, up to the largest image size in the batch. Otherwise, all images are
padded to the largest image size in the batch.`,name:"do_pad"},{anchor:"transformers.DonutImageProcessor.preprocess.random_padding",description:`<strong>random_padding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.random_padding</code>) &#x2014;
Whether to use random padding when padding the image. If <code>True</code>, each image in the batch with be padded
with a random amount of padding on each side up to the size of the largest image in the batch.`,name:"random_padding"},{anchor:"transformers.DonutImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image pixel values.`,name:"do_rescale"},{anchor:"transformers.DonutImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.DonutImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.DonutImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to use for normalization.`,name:"image_mean"},{anchor:"transformers.DonutImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to use for normalization.`,name:"image_std"},{anchor:"transformers.DonutImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.DonutImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: defaults to the channel dimension format of the input image.</li>
</ul>`,name:"data_format"},{anchor:"transformers.DonutImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/image_processing_donut.py#L297"}}),Ne=new Y({}),Be=new I({props:{name:"class transformers.DonutFeatureExtractor",anchor:"transformers.DonutFeatureExtractor",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/feature_extraction_donut.py#L26"}}),Xe=new I({props:{name:"__call__",anchor:"transformers.DonutFeatureExtractor.__call__",parameters:[{name:"images",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/image_processing_utils.py#L544"}}),Ge=new Y({}),Ee=new I({props:{name:"class transformers.DonutProcessor",anchor:"transformers.DonutProcessor",parameters:[{name:"image_processor",val:" = None"},{name:"tokenizer",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutProcessor.image_processor",description:`<strong>image_processor</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutImageProcessor">DonutImageProcessor</a>) &#x2014;
An instance of <a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutImageProcessor">DonutImageProcessor</a>. The image processor is a required input.`,name:"image_processor"},{anchor:"transformers.DonutProcessor.tokenizer",description:`<strong>tokenizer</strong> ([<code>XLMRobertaTokenizer</code>/<code>XLMRobertaTokenizerFast</code>]) &#x2014;
An instance of [<code>XLMRobertaTokenizer</code>/<code>XLMRobertaTokenizerFast</code>]. The tokenizer is a required input.`,name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/processing_donut.py#L25"}}),Fe=new I({props:{name:"__call__",anchor:"transformers.DonutProcessor.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/processing_donut.py#L64"}}),Ye=new I({props:{name:"from_pretrained",anchor:"transformers.DonutProcessor.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.DonutProcessor.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"}}),oe=new go({props:{$$slots:{default:[jn]},$$scope:{ctx:U}}}),Se=new I({props:{name:"save_pretrained",anchor:"transformers.DonutProcessor.save_pretrained",parameters:[{name:"save_directory",val:""},{name:"push_to_hub",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DonutProcessor.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.DonutProcessor.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.DonutProcessor.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"}}),ne=new go({props:{$$slots:{default:[Jn]},$$scope:{ctx:U}}}),qe=new I({props:{name:"batch_decode",anchor:"transformers.DonutProcessor.batch_decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/processing_donut.py#L97"}}),Pe=new I({props:{name:"decode",anchor:"transformers.DonutProcessor.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/processing_donut.py#L104"}}),He=new Y({}),Le=new I({props:{name:"class transformers.DonutSwinModel",anchor:"transformers.DonutSwinModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"},{name:"use_mask_token",val:" = False"}],parametersDescription:[{anchor:"transformers.DonutSwinModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/donut#transformers.DonutSwinConfig">DonutSwinConfig</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/donut/modeling_donut_swin.py#L871"}}),Ae=new I({props:{name:"forward",anchor:"transformers.DonutSwinModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"bool_masked_pos",val:": typing.Optional[torch.BoolTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = 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.DonutSwinModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/v4.34.0/en/model_doc/deit#transformers.DeiTFeatureExtractor.__call__">DonutImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.DonutSwinModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</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.DonutSwinModel.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.DonutSwinModel.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.DonutSwinModel.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"},{anchor:"transformers.DonutSwinModel.forward.bool_masked_pos",description:`<strong>bool_masked_pos</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, num_patches)</code>) &#x2014;
Boolean masked positions. Indicates which patches are masked (1) and which aren&#x2019;t (0).`,name:"bool_masked_pos"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/donut/modeling_donut_swin.py#L897",returnDescription:`
<p>A <code>transformers.models.donut.modeling_donut_swin.DonutSwinModelOutput</code> 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/donut#transformers.DonutSwinConfig"
>DonutSwinConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>, <em>optional</em>, returned when <code>add_pooling_layer=True</code> is passed) — Average pooling of the last layer hidden-state.</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 + one for the output of each stage) 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 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 stage) 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>reshaped_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 + one for the output of each stage) of
shape <code>(batch_size, hidden_size, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs reshaped to
include the spatial dimensions.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.donut.modeling_donut_swin.DonutSwinModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ie=new go({props:{$$slots:{default:[xn]},$$scope:{ctx:U}}}),de=new fn({props:{anchor:"transformers.DonutSwinModel.forward.example",$$slots:{default:[kn]},$$scope:{ctx:U}}}),{c(){c=o("meta"),T=r(),u=o("p"),y=r(),j=o("h1"),h=o("a"),x=o("span"),g(me.$$.fragment),zs=r(),Oe=o("span"),Oe.textContent=fo,Xt=r(),W=o("h2"),S=o("a"),xt=o("span"),g(he.$$.fragment),$s=r(),et=o("span"),et.textContent=_o,Gt=r(),ue=o("p"),ue.innerHTML=bo,Et=r(),ge=o("p"),ge.textContent=vo,Ft=r(),fe=o("p"),fe.innerHTML=Mo,Yt=r(),q=o("img"),St=r(),_e=o("small"),_e.innerHTML=wo,qt=r(),be=o("p"),be.innerHTML=To,Pt=r(),ve=o("p"),ve.textContent=jo,Ht=r(),Me=o("ul"),Me.innerHTML=Jo,Lt=r(),V=o("h2"),P=o("a"),kt=o("span"),g(ye.$$.fragment),Rs=r(),tt=o("span"),tt.textContent=xo,At=r(),we=o("p"),we.innerHTML=ko,Qt=r(),Te=o("p"),Te.innerHTML=Io,Kt=r(),je=o("ul"),je.innerHTML=Uo,Ot=r(),g(Je.$$.fragment),es=r(),xe=o("ul"),xe.innerHTML=Co,ts=r(),g(ke.$$.fragment),ss=r(),Ie=o("ul"),Ie.innerHTML=Zo,os=r(),g(Ue.$$.fragment),ns=r(),Ce=o("p"),Ce.innerHTML=zo,as=r(),D=o("h2"),H=o("a"),It=o("span"),g(Ze.$$.fragment),Ws=r(),st=o("span"),st.textContent=$o,rs=r(),ze=o("p"),ze.innerHTML=Ro,ls=r(),N=o("h2"),L=o("a"),Ut=o("span"),g($e.$$.fragment),Vs=r(),ot=o("span"),ot.textContent=Wo,is=r(),k=o("div"),g(Re.$$.fragment),Ds=r(),nt=o("p"),nt.innerHTML=Vo,Ns=r(),at=o("p"),at.innerHTML=Do,Bs=r(),g(A.$$.fragment),ds=r(),B=o("h2"),Q=o("a"),Ct=o("span"),g(We.$$.fragment),Xs=r(),rt=o("span"),rt.textContent=No,cs=r(),Z=o("div"),g(Ve.$$.fragment),Gs=r(),lt=o("p"),lt.textContent=Bo,Es=r(),K=o("div"),g(De.$$.fragment),Fs=r(),it=o("p"),it.textContent=Xo,ps=r(),X=o("h2"),O=o("a"),Zt=o("span"),g(Ne.$$.fragment),Ys=r(),dt=o("span"),dt.textContent=Go,ms=r(),G=o("div"),g(Be.$$.fragment),Ss=r(),ee=o("div"),g(Xe.$$.fragment),qs=r(),ct=o("p"),ct.textContent=Eo,hs=r(),E=o("h2"),te=o("a"),zt=o("span"),g(Ge.$$.fragment),Ps=r(),pt=o("span"),pt.textContent=Fo,us=r(),w=o("div"),g(Ee.$$.fragment),Hs=r(),mt=o("p"),mt.textContent=Yo,Ls=r(),ht=o("p"),ht.innerHTML=So,As=r(),se=o("div"),g(Fe.$$.fragment),Qs=r(),ut=o("p"),ut.innerHTML=qo,Ks=r(),$=o("div"),g(Ye.$$.fragment),Os=r(),gt=o("p"),gt.textContent=Po,eo=r(),g(oe.$$.fragment),to=r(),R=o("div"),g(Se.$$.fragment),so=r(),ft=o("p"),ft.innerHTML=Ho,oo=r(),g(ne.$$.fragment),no=r(),ae=o("div"),g(qe.$$.fragment),ao=r(),_t=o("p"),_t.innerHTML=Lo,ro=r(),re=o("div"),g(Pe.$$.fragment),lo=r(),bt=o("p"),bt.innerHTML=Ao,gs=r(),F=o("h2"),le=o("a"),$t=o("span"),g(He.$$.fragment),io=r(),vt=o("span"),vt.textContent=Qo,fs=r(),z=o("div"),g(Le.$$.fragment),co=r(),Mt=o("p"),Mt.innerHTML=Ko,po=r(),C=o("div"),g(Ae.$$.fragment),mo=r(),yt=o("p"),yt.innerHTML=Oo,ho=r(),g(ie.$$.fragment),uo=r(),g(de.$$.fragment),_s=r(),Rt=o("p"),this.h()},l(e){const a=wn("svelte-1phssyn",document.head);c=n(a,"META",{name:!0,content:!0}),a.forEach(t),T=l(e),u=n(e,"P",{}),p(u).forEach(t),y=l(e),j=n(e,"H1",{class:!0});var Qe=p(j);h=n(Qe,"A",{id:!0,class:!0,href:!0});var Wt=p(h);x=n(Wt,"SPAN",{});var Vt=p(x);f(me.$$.fragment,Vt),Vt.forEach(t),Wt.forEach(t),zs=l(Qe),Oe=n(Qe,"SPAN",{"data-svelte-h":!0}),m(Oe)!=="svelte-ifm0mr"&&(Oe.textContent=fo),Qe.forEach(t),Xt=l(e),W=n(e,"H2",{class:!0});var Ke=p(W);S=n(Ke,"A",{id:!0,class:!0,href:!0});var Dt=p(S);xt=n(Dt,"SPAN",{});var en=p(xt);f(he.$$.fragment,en),en.forEach(t),Dt.forEach(t),$s=l(Ke),et=n(Ke,"SPAN",{"data-svelte-h":!0}),m(et)!=="svelte-1jsw1pg"&&(et.textContent=_o),Ke.forEach(t),Gt=l(e),ue=n(e,"P",{"data-svelte-h":!0}),m(ue)!=="svelte-pmkljw"&&(ue.innerHTML=bo),Et=l(e),ge=n(e,"P",{"data-svelte-h":!0}),m(ge)!=="svelte-vfdo9a"&&(ge.textContent=vo),Ft=l(e),fe=n(e,"P",{"data-svelte-h":!0}),m(fe)!=="svelte-m8jgiq"&&(fe.innerHTML=Mo),Yt=l(e),q=n(e,"IMG",{src:!0,alt:!0,width:!0}),St=l(e),_e=n(e,"SMALL",{"data-svelte-h":!0}),m(_e)!=="svelte-16kwx1q"&&(_e.innerHTML=wo),qt=l(e),be=n(e,"P",{"data-svelte-h":!0}),m(be)!=="svelte-1ka58uc"&&(be.innerHTML=To),Pt=l(e),ve=n(e,"P",{"data-svelte-h":!0}),m(ve)!=="svelte-axv494"&&(ve.textContent=jo),Ht=l(e),Me=n(e,"UL",{"data-svelte-h":!0}),m(Me)!=="svelte-1dzhhy7"&&(Me.innerHTML=Jo),Lt=l(e),V=n(e,"H2",{class:!0});var vs=p(V);P=n(vs,"A",{id:!0,class:!0,href:!0});var tn=p(P);kt=n(tn,"SPAN",{});var sn=p(kt);f(ye.$$.fragment,sn),sn.forEach(t),tn.forEach(t),Rs=l(vs),tt=n(vs,"SPAN",{"data-svelte-h":!0}),m(tt)!=="svelte-199uz7g"&&(tt.textContent=xo),vs.forEach(t),At=l(e),we=n(e,"P",{"data-svelte-h":!0}),m(we)!=="svelte-1mvbxl1"&&(we.innerHTML=ko),Qt=l(e),Te=n(e,"P",{"data-svelte-h":!0}),m(Te)!=="svelte-1sqj9dr"&&(Te.innerHTML=Io),Kt=l(e),je=n(e,"UL",{"data-svelte-h":!0}),m(je)!=="svelte-1q30tw8"&&(je.innerHTML=Uo),Ot=l(e),f(Je.$$.fragment,e),es=l(e),xe=n(e,"UL",{"data-svelte-h":!0}),m(xe)!=="svelte-rxs8tv"&&(xe.innerHTML=Co),ts=l(e),f(ke.$$.fragment,e),ss=l(e),Ie=n(e,"UL",{"data-svelte-h":!0}),m(Ie)!=="svelte-e6gv24"&&(Ie.innerHTML=Zo),os=l(e),f(Ue.$$.fragment,e),ns=l(e),Ce=n(e,"P",{"data-svelte-h":!0}),m(Ce)!=="svelte-dntm9d"&&(Ce.innerHTML=zo),as=l(e),D=n(e,"H2",{class:!0});var Ms=p(D);H=n(Ms,"A",{id:!0,class:!0,href:!0});var on=p(H);It=n(on,"SPAN",{});var nn=p(It);f(Ze.$$.fragment,nn),nn.forEach(t),on.forEach(t),Ws=l(Ms),st=n(Ms,"SPAN",{"data-svelte-h":!0}),m(st)!=="svelte-1q1s287"&&(st.textContent=$o),Ms.forEach(t),rs=l(e),ze=n(e,"P",{"data-svelte-h":!0}),m(ze)!=="svelte-yi1sug"&&(ze.innerHTML=Ro),ls=l(e),N=n(e,"H2",{class:!0});var ys=p(N);L=n(ys,"A",{id:!0,class:!0,href:!0});var an=p(L);Ut=n(an,"SPAN",{});var rn=p(Ut);f($e.$$.fragment,rn),rn.forEach(t),an.forEach(t),Vs=l(ys),ot=n(ys,"SPAN",{"data-svelte-h":!0}),m(ot)!=="svelte-1vgked4"&&(ot.textContent=Wo),ys.forEach(t),is=l(e),k=n(e,"DIV",{class:!0});var ce=p(k);f(Re.$$.fragment,ce),Ds=l(ce),nt=n(ce,"P",{"data-svelte-h":!0}),m(nt)!=="svelte-zl5hdp"&&(nt.innerHTML=Vo),Ns=l(ce),at=n(ce,"P",{"data-svelte-h":!0}),m(at)!=="svelte-10kqkkl"&&(at.innerHTML=Do),Bs=l(ce),f(A.$$.fragment,ce),ce.forEach(t),ds=l(e),B=n(e,"H2",{class:!0});var ws=p(B);Q=n(ws,"A",{id:!0,class:!0,href:!0});var ln=p(Q);Ct=n(ln,"SPAN",{});var dn=p(Ct);f(We.$$.fragment,dn),dn.forEach(t),ln.forEach(t),Xs=l(ws),rt=n(ws,"SPAN",{"data-svelte-h":!0}),m(rt)!=="svelte-1ve9qg0"&&(rt.textContent=No),ws.forEach(t),cs=l(e),Z=n(e,"DIV",{class:!0});var wt=p(Z);f(Ve.$$.fragment,wt),Gs=l(wt),lt=n(wt,"P",{"data-svelte-h":!0}),m(lt)!=="svelte-1h1jbqe"&&(lt.textContent=Bo),Es=l(wt),K=n(wt,"DIV",{class:!0});var Ts=p(K);f(De.$$.fragment,Ts),Fs=l(Ts),it=n(Ts,"P",{"data-svelte-h":!0}),m(it)!=="svelte-1x3yxsa"&&(it.textContent=Xo),Ts.forEach(t),wt.forEach(t),ps=l(e),X=n(e,"H2",{class:!0});var js=p(X);O=n(js,"A",{id:!0,class:!0,href:!0});var cn=p(O);Zt=n(cn,"SPAN",{});var pn=p(Zt);f(Ne.$$.fragment,pn),pn.forEach(t),cn.forEach(t),Ys=l(js),dt=n(js,"SPAN",{"data-svelte-h":!0}),m(dt)!=="svelte-leiy1t"&&(dt.textContent=Go),js.forEach(t),ms=l(e),G=n(e,"DIV",{class:!0});var Js=p(G);f(Be.$$.fragment,Js),Ss=l(Js),ee=n(Js,"DIV",{class:!0});var xs=p(ee);f(Xe.$$.fragment,xs),qs=l(xs),ct=n(xs,"P",{"data-svelte-h":!0}),m(ct)!=="svelte-khengj"&&(ct.textContent=Eo),xs.forEach(t),Js.forEach(t),hs=l(e),E=n(e,"H2",{class:!0});var ks=p(E);te=n(ks,"A",{id:!0,class:!0,href:!0});var mn=p(te);zt=n(mn,"SPAN",{});var hn=p(zt);f(Ge.$$.fragment,hn),hn.forEach(t),mn.forEach(t),Ps=l(ks),pt=n(ks,"SPAN",{"data-svelte-h":!0}),m(pt)!=="svelte-qer6ux"&&(pt.textContent=Fo),ks.forEach(t),us=l(e),w=n(e,"DIV",{class:!0});var J=p(w);f(Ee.$$.fragment,J),Hs=l(J),mt=n(J,"P",{"data-svelte-h":!0}),m(mt)!=="svelte-13663wp"&&(mt.textContent=Yo),Ls=l(J),ht=n(J,"P",{"data-svelte-h":!0}),m(ht)!=="svelte-1rh78pj"&&(ht.innerHTML=So),As=l(J),se=n(J,"DIV",{class:!0});var Is=p(se);f(Fe.$$.fragment,Is),Qs=l(Is),ut=n(Is,"P",{"data-svelte-h":!0}),m(ut)!=="svelte-1ahfbom"&&(ut.innerHTML=qo),Is.forEach(t),Ks=l(J),$=n(J,"DIV",{class:!0});var Tt=p($);f(Ye.$$.fragment,Tt),Os=l(Tt),gt=n(Tt,"P",{"data-svelte-h":!0}),m(gt)!=="svelte-1cj8dcb"&&(gt.textContent=Po),eo=l(Tt),f(oe.$$.fragment,Tt),Tt.forEach(t),to=l(J),R=n(J,"DIV",{class:!0});var jt=p(R);f(Se.$$.fragment,jt),so=l(jt),ft=n(jt,"P",{"data-svelte-h":!0}),m(ft)!=="svelte-7negql"&&(ft.innerHTML=Ho),oo=l(jt),f(ne.$$.fragment,jt),jt.forEach(t),no=l(J),ae=n(J,"DIV",{class:!0});var Us=p(ae);f(qe.$$.fragment,Us),ao=l(Us),_t=n(Us,"P",{"data-svelte-h":!0}),m(_t)!=="svelte-rj9em6"&&(_t.innerHTML=Lo),Us.forEach(t),ro=l(J),re=n(J,"DIV",{class:!0});var Cs=p(re);f(Pe.$$.fragment,Cs),lo=l(Cs),bt=n(Cs,"P",{"data-svelte-h":!0}),m(bt)!=="svelte-12q4usg"&&(bt.innerHTML=Ao),Cs.forEach(t),J.forEach(t),gs=l(e),F=n(e,"H2",{class:!0});var Zs=p(F);le=n(Zs,"A",{id:!0,class:!0,href:!0});var un=p(le);$t=n(un,"SPAN",{});var gn=p($t);f(He.$$.fragment,gn),gn.forEach(t),un.forEach(t),io=l(Zs),vt=n(Zs,"SPAN",{"data-svelte-h":!0}),m(vt)!=="svelte-1m7ognb"&&(vt.textContent=Qo),Zs.forEach(t),fs=l(e),z=n(e,"DIV",{class:!0});var Jt=p(z);f(Le.$$.fragment,Jt),co=l(Jt),Mt=n(Jt,"P",{"data-svelte-h":!0}),m(Mt)!=="svelte-gtr45t"&&(Mt.innerHTML=Ko),po=l(Jt),C=n(Jt,"DIV",{class:!0});var pe=p(C);f(Ae.$$.fragment,pe),mo=l(pe),yt=n(pe,"P",{"data-svelte-h":!0}),m(yt)!=="svelte-bb4dq9"&&(yt.innerHTML=Oo),ho=l(pe),f(ie.$$.fragment,pe),uo=l(pe),f(de.$$.fragment,pe),pe.forEach(t),Jt.forEach(t),_s=l(e),Rt=n(e,"P",{}),p(Rt).forEach(t),this.h()},h(){d(c,"name","hf:doc:metadata"),d(c,"content",JSON.stringify(Un)),d(h,"id","donut"),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","#donut"),d(j,"class","relative group"),d(S,"id","overview"),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","#overview"),d(W,"class","relative group"),bn(q.src,yo="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/donut_architecture.jpg")||d(q,"src",yo),d(q,"alt","drawing"),d(q,"width","600"),d(P,"id","inference"),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","#inference"),d(V,"class","relative group"),d(H,"id","training"),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","#training"),d(D,"class","relative group"),d(L,"id","transformers.DonutSwinConfig"),d(L,"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(L,"href","#transformers.DonutSwinConfig"),d(N,"class","relative group"),d(k,"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.DonutImageProcessor"),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.DonutImageProcessor"),d(B,"class","relative group"),d(K,"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(O,"id","transformers.DonutFeatureExtractor"),d(O,"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(O,"href","#transformers.DonutFeatureExtractor"),d(X,"class","relative group"),d(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(te,"id","transformers.DonutProcessor"),d(te,"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(te,"href","#transformers.DonutProcessor"),d(E,"class","relative group"),d(se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),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(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(re,"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(le,"id","transformers.DonutSwinModel"),d(le,"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(le,"href","#transformers.DonutSwinModel"),d(F,"class","relative group"),d(C,"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")},m(e,a){s(document.head,c),i(e,T,a),i(e,u,a),i(e,y,a),i(e,j,a),s(j,h),s(h,x),_(me,x,null),s(j,zs),s(j,Oe),i(e,Xt,a),i(e,W,a),s(W,S),s(S,xt),_(he,xt,null),s(W,$s),s(W,et),i(e,Gt,a),i(e,ue,a),i(e,Et,a),i(e,ge,a),i(e,Ft,a),i(e,fe,a),i(e,Yt,a),i(e,q,a),i(e,St,a),i(e,_e,a),i(e,qt,a),i(e,be,a),i(e,Pt,a),i(e,ve,a),i(e,Ht,a),i(e,Me,a),i(e,Lt,a),i(e,V,a),s(V,P),s(P,kt),_(ye,kt,null),s(V,Rs),s(V,tt),i(e,At,a),i(e,we,a),i(e,Qt,a),i(e,Te,a),i(e,Kt,a),i(e,je,a),i(e,Ot,a),_(Je,e,a),i(e,es,a),i(e,xe,a),i(e,ts,a),_(ke,e,a),i(e,ss,a),i(e,Ie,a),i(e,os,a),_(Ue,e,a),i(e,ns,a),i(e,Ce,a),i(e,as,a),i(e,D,a),s(D,H),s(H,It),_(Ze,It,null),s(D,Ws),s(D,st),i(e,rs,a),i(e,ze,a),i(e,ls,a),i(e,N,a),s(N,L),s(L,Ut),_($e,Ut,null),s(N,Vs),s(N,ot),i(e,is,a),i(e,k,a),_(Re,k,null),s(k,Ds),s(k,nt),s(k,Ns),s(k,at),s(k,Bs),_(A,k,null),i(e,ds,a),i(e,B,a),s(B,Q),s(Q,Ct),_(We,Ct,null),s(B,Xs),s(B,rt),i(e,cs,a),i(e,Z,a),_(Ve,Z,null),s(Z,Gs),s(Z,lt),s(Z,Es),s(Z,K),_(De,K,null),s(K,Fs),s(K,it),i(e,ps,a),i(e,X,a),s(X,O),s(O,Zt),_(Ne,Zt,null),s(X,Ys),s(X,dt),i(e,ms,a),i(e,G,a),_(Be,G,null),s(G,Ss),s(G,ee),_(Xe,ee,null),s(ee,qs),s(ee,ct),i(e,hs,a),i(e,E,a),s(E,te),s(te,zt),_(Ge,zt,null),s(E,Ps),s(E,pt),i(e,us,a),i(e,w,a),_(Ee,w,null),s(w,Hs),s(w,mt),s(w,Ls),s(w,ht),s(w,As),s(w,se),_(Fe,se,null),s(se,Qs),s(se,ut),s(w,Ks),s(w,$),_(Ye,$,null),s($,Os),s($,gt),s($,eo),_(oe,$,null),s(w,to),s(w,R),_(Se,R,null),s(R,so),s(R,ft),s(R,oo),_(ne,R,null),s(w,no),s(w,ae),_(qe,ae,null),s(ae,ao),s(ae,_t),s(w,ro),s(w,re),_(Pe,re,null),s(re,lo),s(re,bt),i(e,gs,a),i(e,F,a),s(F,le),s(le,$t),_(He,$t,null),s(F,io),s(F,vt),i(e,fs,a),i(e,z,a),_(Le,z,null),s(z,co),s(z,Mt),s(z,po),s(z,C),_(Ae,C,null),s(C,mo),s(C,yt),s(C,ho),_(ie,C,null),s(C,uo),_(de,C,null),i(e,_s,a),i(e,Rt,a),bs=!0},p(e,[a]){const Qe={};a&2&&(Qe.$$scope={dirty:a,ctx:e}),A.$set(Qe);const Wt={};a&2&&(Wt.$$scope={dirty:a,ctx:e}),oe.$set(Wt);const Vt={};a&2&&(Vt.$$scope={dirty:a,ctx:e}),ne.$set(Vt);const Ke={};a&2&&(Ke.$$scope={dirty:a,ctx:e}),ie.$set(Ke);const Dt={};a&2&&(Dt.$$scope={dirty:a,ctx:e}),de.$set(Dt)},i(e){bs||(b(me.$$.fragment,e),b(he.$$.fragment,e),b(ye.$$.fragment,e),b(Je.$$.fragment,e),b(ke.$$.fragment,e),b(Ue.$$.fragment,e),b(Ze.$$.fragment,e),b($e.$$.fragment,e),b(Re.$$.fragment,e),b(A.$$.fragment,e),b(We.$$.fragment,e),b(Ve.$$.fragment,e),b(De.$$.fragment,e),b(Ne.$$.fragment,e),b(Be.$$.fragment,e),b(Xe.$$.fragment,e),b(Ge.$$.fragment,e),b(Ee.$$.fragment,e),b(Fe.$$.fragment,e),b(Ye.$$.fragment,e),b(oe.$$.fragment,e),b(Se.$$.fragment,e),b(ne.$$.fragment,e),b(qe.$$.fragment,e),b(Pe.$$.fragment,e),b(He.$$.fragment,e),b(Le.$$.fragment,e),b(Ae.$$.fragment,e),b(ie.$$.fragment,e),b(de.$$.fragment,e),bs=!0)},o(e){v(me.$$.fragment,e),v(he.$$.fragment,e),v(ye.$$.fragment,e),v(Je.$$.fragment,e),v(ke.$$.fragment,e),v(Ue.$$.fragment,e),v(Ze.$$.fragment,e),v($e.$$.fragment,e),v(Re.$$.fragment,e),v(A.$$.fragment,e),v(We.$$.fragment,e),v(Ve.$$.fragment,e),v(De.$$.fragment,e),v(Ne.$$.fragment,e),v(Be.$$.fragment,e),v(Xe.$$.fragment,e),v(Ge.$$.fragment,e),v(Ee.$$.fragment,e),v(Fe.$$.fragment,e),v(Ye.$$.fragment,e),v(oe.$$.fragment,e),v(Se.$$.fragment,e),v(ne.$$.fragment,e),v(qe.$$.fragment,e),v(Pe.$$.fragment,e),v(He.$$.fragment,e),v(Le.$$.fragment,e),v(Ae.$$.fragment,e),v(ie.$$.fragment,e),v(de.$$.fragment,e),bs=!1},d(e){e&&(t(T),t(u),t(y),t(j),t(Xt),t(W),t(Gt),t(ue),t(Et),t(ge),t(Ft),t(fe),t(Yt),t(q),t(St),t(_e),t(qt),t(be),t(Pt),t(ve),t(Ht),t(Me),t(Lt),t(V),t(At),t(we),t(Qt),t(Te),t(Kt),t(je),t(Ot),t(es),t(xe),t(ts),t(ss),t(Ie),t(os),t(ns),t(Ce),t(as),t(D),t(rs),t(ze),t(ls),t(N),t(is),t(k),t(ds),t(B),t(cs),t(Z),t(ps),t(X),t(ms),t(G),t(hs),t(E),t(us),t(w),t(gs),t(F),t(fs),t(z),t(_s),t(Rt)),t(c),M(me),M(he),M(ye),M(Je,e),M(ke,e),M(Ue,e),M(Ze),M($e),M(Re),M(A),M(We),M(Ve),M(De),M(Ne),M(Be),M(Xe),M(Ge),M(Ee),M(Fe),M(Ye),M(oe),M(Se),M(ne),M(qe),M(Pe),M(He),M(Le),M(Ae),M(ie),M(de)}}}const Un={local:"donut",sections:[{local:"overview",title:"Overview"},{local:"inference",title:"Inference"},{local:"training",title:"Training"},{local:"transformers.DonutSwinConfig",title:"DonutSwinConfig"},{local:"transformers.DonutImageProcessor",title:"DonutImageProcessor"},{local:"transformers.DonutFeatureExtractor",title:"DonutFeatureExtractor"},{local:"transformers.DonutProcessor",title:"DonutProcessor"},{local:"transformers.DonutSwinModel",title:"DonutSwinModel"}],title:"Donut"};function Cn(U){return vn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nn extends Mn{constructor(c){super(),yn(this,c,Cn,In,_n,{})}}export{Nn as component};
