import{S as Wm,i as Um,s as xm,e as r,k as c,w as M,t as n,M as Fm,c as s,d as t,m as p,a as d,x as v,h as a,b as i,G as e,g as u,y as w,q as T,o as j,B as k,v as $m,L as it}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ec}from"../../chunks/Tip-hf-doc-builder.js";import{D as S}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Y}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as P}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as lt}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Rm(x){let h,b,_,f,y;return f=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBWaVRDb25maWclMkMlMjBWaXNpb25FbmNvZGVyRGVjb2RlckNvbmZpZyUyQyUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwVmlUJTIwJTI2JTIwQkVSVCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ19lbmNvZGVyJTIwJTNEJTIwVmlUQ29uZmlnKCklMEFjb25maWdfZGVjb2RlciUyMCUzRCUyMEJlcnRDb25maWcoKSUwQSUwQWNvbmZpZyUyMCUzRCUyMFZpc2lvbkVuY29kZXJEZWNvZGVyQ29uZmlnLmZyb21fZW5jb2Rlcl9kZWNvZGVyX2NvbmZpZ3MoY29uZmlnX2VuY29kZXIlMkMlMjBjb25maWdfZGVjb2RlciklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwVmlUQmVydCUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjBhJTIwVmlUJTIwJTI2JTIwYmVydC1iYXNlLXVuY2FzZWQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb25zJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsKGNvbmZpZyUzRGNvbmZpZyklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWdfZW5jb2RlciUyMCUzRCUyMG1vZGVsLmNvbmZpZy5lbmNvZGVyJTBBY29uZmlnX2RlY29kZXIlMjAlM0QlMjBtb2RlbC5jb25maWcuZGVjb2RlciUwQSUyMyUyMHNldCUyMGRlY29kZXIlMjBjb25maWclMjB0byUyMGNhdXNhbCUyMGxtJTBBY29uZmlnX2RlY29kZXIuaXNfZGVjb2RlciUyMCUzRCUyMFRydWUlMEFjb25maWdfZGVjb2Rlci5hZGRfY3Jvc3NfYXR0ZW50aW9uJTIwJTNEJTIwVHJ1ZSUwQSUwQSUyMyUyMFNhdmluZyUyMHRoZSUyMG1vZGVsJTJDJTIwaW5jbHVkaW5nJTIwaXRzJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJteS1tb2RlbCUyMiklMEElMEElMjMlMjBsb2FkaW5nJTIwbW9kZWwlMjBhbmQlMjBjb25maWclMjBmcm9tJTIwcHJldHJhaW5lZCUyMGZvbGRlciUwQWVuY29kZXJfZGVjb2Rlcl9jb25maWclMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2RlckNvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIybXktbW9kZWwlMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJteS1tb2RlbCUyMiUyQyUyMGNvbmZpZyUzRGVuY29kZXJfZGVjb2Rlcl9jb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, ViTConfig, VisionEncoderDecoderConfig, VisionEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a ViT &amp; BERT style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config_encoder = ViTConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder = BertConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span>config = VisionEncoderDecoderConfig.from_encoder_decoder_configs(config_encoder, config_decoder)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a ViTBert model (with random weights) from a ViT &amp; bert-base-uncased style configurations</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel(config=config)

<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>config_encoder = model.config.encoder
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder = model.config.decoder
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># set decoder config to causal lm</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder.is_decoder = <span class="hljs-literal">True</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder.add_cross_attention = <span class="hljs-literal">True</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Saving the model, including its configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;my-model&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># loading model and config from pretrained folder</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_decoder_config = VisionEncoderDecoderConfig.from_pretrained(<span class="hljs-string">&quot;my-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;my-model&quot;</span>, config=encoder_decoder_config)`}}),{c(){h=r("p"),b=n("Examples:"),_=c(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Examples:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:it,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){j(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Bm(x){let h,b,_,f,y;return{c(){h=r("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r("code"),f=n("Module"),y=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var C=d(_);f=a(C,"Module"),C.forEach(t),y=a(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(l,g){u(l,h,g),e(h,b),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function Im(x){let h,b,_,f,y;return f=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMkMlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9Qcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnRyb2NyLWJhc2UtaGFuZHdyaXR0ZW4lMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZ0cm9jci1iYXNlLWhhbmR3cml0dGVuJTIyKSUwQSUwQSUyMyUyMGxvYWQlMjBpbWFnZSUyMGZyb20lMjB0aGUlMjBJQU0lMjBkYXRhc2V0JTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZma2kudGljLmhlaWEtZnIuY2glMkZzdGF0aWMlMkZpbWclMkZhMDEtMTIyLTAyLmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KS5jb252ZXJ0KCUyMlJHQiUyMiklMEElMEElMjMlMjB0cmFpbmluZyUwQW1vZGVsLmNvbmZpZy5kZWNvZGVyX3N0YXJ0X3Rva2VuX2lkJTIwJTNEJTIwcHJvY2Vzc29yLnRva2VuaXplci5jbHNfdG9rZW5faWQlMEFtb2RlbC5jb25maWcucGFkX3Rva2VuX2lkJTIwJTNEJTIwcHJvY2Vzc29yLnRva2VuaXplci5wYWRfdG9rZW5faWQlMEFtb2RlbC5jb25maWcudm9jYWJfc2l6ZSUyMCUzRCUyMG1vZGVsLmNvbmZpZy5kZWNvZGVyLnZvY2FiX3NpemUlMEElMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5waXhlbF92YWx1ZXMlMEF0ZXh0JTIwJTNEJTIwJTIyaGVsbG8lMjB3b3JsZCUyMiUwQWxhYmVscyUyMCUzRCUyMHByb2Nlc3Nvci50b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLmlucHV0X2lkcyUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChwaXhlbF92YWx1ZXMlM0RwaXhlbF92YWx1ZXMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpJTBBbG9zcyUyMCUzRCUyMG91dHB1dHMubG9zcyUwQSUwQSUyMyUyMGluZmVyZW5jZSUyMChnZW5lcmF0aW9uKSUwQWdlbmVyYXRlZF9pZHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShwaXhlbF92YWx1ZXMpJTBBZ2VuZXJhdGVkX3RleHQlMjAlM0QlMjBwcm9jZXNzb3IuYmF0Y2hfZGVjb2RlKGdlbmVyYXRlZF9pZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, 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><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.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><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>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;hello world&quot;</span>
<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=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-comment"># inference (generation)</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>]`}}),{c(){h=r("p"),b=n("Examples:"),_=c(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Examples:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:it,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){j(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Cm(x){let h,b,_,f,y;return f=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBpbml0aWFsaXplJTIwYSUyMHZpdC1iZXJ0JTIwZnJvbSUyMGElMjBwcmV0cmFpbmVkJTIwVmlUJTIwYW5kJTIwYSUyMHByZXRyYWluZWQlMjBCRVJUJTIwbW9kZWwuJTIwTm90ZSUyMHRoYXQlMjB0aGUlMjBjcm9zcy1hdHRlbnRpb24lMjBsYXllcnMlMjB3aWxsJTIwYmUlMjByYW5kb21seSUyMGluaXRpYWxpemVkJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQtaW4yMWslMjIlMkMlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUwQSklMEElMjMlMjBzYXZpbmclMjBtb2RlbCUyMGFmdGVyJTIwZmluZS10dW5pbmclMEFtb2RlbC5zYXZlX3ByZXRyYWluZWQoJTIyLiUyRnZpdC1iZXJ0JTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMi4lMkZ2aXQtYmVydCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VisionEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a vit-bert from a pretrained ViT and a pretrained BERT model. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># saving model after fine-tuning</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;./vit-bert&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load fine-tuned model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./vit-bert&quot;</span>)`}}),{c(){h=r("p"),b=n("Example:"),_=c(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Example:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:it,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){j(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Gm(x){let h,b,_,f,y;return{c(){h=r("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r("code"),f=n("Module"),y=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var C=d(_);f=a(C,"Module"),C.forEach(t),y=a(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(l,g){u(l,h,g),e(h,b),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function zm(x){let h,b,_,f,y;return f=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURlZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQtaW4yMWslMjIpJTBBZGVjb2Rlcl90b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQSUwQSUyMyUyMGluaXRpYWxpemUlMjBhJTIwYmVydDJncHQyJTIwZnJvbSUyMGElMjBwcmV0cmFpbmVkJTIwQkVSVCUyMGFuZCUyMEdQVDIlMjBtb2RlbHMuJTIwTm90ZSUyMHRoYXQlMjB0aGUlMjBjcm9zcy1hdHRlbnRpb24lMjBsYXllcnMlMjB3aWxsJTIwYmUlMjByYW5kb21seSUyMGluaXRpYWxpemVkJTBBbW9kZWwlMjAlM0QlMjBURlZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNC1pbjIxayUyMiUyQyUyMCUyMmdwdDIlMjIlMEEpJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltZyUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMEElMjMlMjBmb3J3YXJkJTBBcGl4ZWxfdmFsdWVzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlcyUzRGltZyUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpLnBpeGVsX3ZhbHVlcyUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUyMDElMEFkZWNvZGVyX2lucHV0X2lkcyUyMCUzRCUyMGRlY29kZXJfdG9rZW5pemVyKCUyMkxpbmRhJTIwRGF2aXMlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKS5pbnB1dF9pZHMlMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlMjAxJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKHBpeGVsX3ZhbHVlcyUzRHBpeGVsX3ZhbHVlcyUyQyUyMGRlY29kZXJfaW5wdXRfaWRzJTNEZGVjb2Rlcl9pbnB1dF9pZHMpJTBBJTBBJTIzJTIwdHJhaW5pbmclMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwocGl4ZWxfdmFsdWVzJTNEcGl4ZWxfdmFsdWVzJTJDJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RkZWNvZGVyX2lucHV0X2lkcyUyQyUyMGxhYmVscyUzRGRlY29kZXJfaW5wdXRfaWRzKSUwQWxvc3MlMkMlMjBsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvc3MlMkMlMjBvdXRwdXRzLmxvZ2l0cyUwQSUwQSUyMyUyMHNhdmUlMjBhbmQlMjBsb2FkJTIwZnJvbSUyMHByZXRyYWluZWQlMEFtb2RlbC5zYXZlX3ByZXRyYWluZWQoJTIydml0LWdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBURlZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnZpdC1ncHQyJTIyKSUwQSUwQSUyMyUyMGdlbmVyYXRpb24lMEFnZW5lcmF0ZWQlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShwaXhlbF92YWx1ZXMlMkMlMjBkZWNvZGVyX3N0YXJ0X3Rva2VuX2lkJTNEbW9kZWwuY29uZmlnLmRlY29kZXIuYm9zX3Rva2VuX2lkKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, AutoTokenizer, TFVisionEncoderDecoderModel
<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-keyword">import</span> requests

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a bert2gpt2 from a pretrained BERT and GPT2 models. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>img = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = image_processor(images=img, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>).pixel_values  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>decoder_input_ids = decoder_tokenizer(<span class="hljs-string">&quot;Linda Davis&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>).input_ids  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(pixel_values=pixel_values, decoder_input_ids=decoder_input_ids)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># training</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(pixel_values=pixel_values, decoder_input_ids=decoder_input_ids, labels=decoder_input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss, logits = outputs.loss, outputs.logits

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># save and load from pretrained</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;vit-gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFVisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;vit-gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated = model.generate(pixel_values, decoder_start_token_id=model.config.decoder.bos_token_id)`}}),{c(){h=r("p"),b=n("Examples:"),_=c(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Examples:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:it,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){j(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Dm(x){let h,b,_,f,y;return f=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbCUwQSUwQSUyMyUyMGluaXRpYWxpemUlMjBhJTIwdml0LWJlcnQlMjBmcm9tJTIwYSUyMHByZXRyYWluZWQlMjBWaVQlMjBhbmQlMjBhJTIwcHJldHJhaW5lZCUyMEJFUlQlMjBtb2RlbC4lMjBOb3RlJTIwdGhhdCUyMHRoZSUyMGNyb3NzLWF0dGVudGlvbiUyMGxheWVycyUyMHdpbGwlMjBiZSUyMHJhbmRvbWx5JTIwaW5pdGlhbGl6ZWQlMEFtb2RlbCUyMCUzRCUyMFRGVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX2VuY29kZXJfZGVjb2Rlcl9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmdvb2dsZSUyRnZpdC1iYXNlLXBhdGNoMTYtMjI0LWluMjFrJTIyJTJDJTIwJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMEEpJTBBJTIzJTIwc2F2aW5nJTIwbW9kZWwlMjBhZnRlciUyMGZpbmUtdHVuaW5nJTBBbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMi4lMkZ2aXQtYmVydCUyMiklMEElMjMlMjBsb2FkJTIwZmluZS10dW5lZCUyMG1vZGVsJTBBbW9kZWwlMjAlM0QlMjBURlZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMi4lMkZ2aXQtYmVydCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFVisionEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a vit-bert from a pretrained ViT and a pretrained BERT model. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># saving model after fine-tuning</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;./vit-bert&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load fine-tuned model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFVisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./vit-bert&quot;</span>)`}}),{c(){h=r("p"),b=n("Example:"),_=c(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Example:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:it,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){j(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Xm(x){let h,b,_,f,y;return{c(){h=r("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r("code"),f=n("Module"),y=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var C=d(_);f=a(C,"Module"),C.forEach(t),y=a(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(l,g){u(l,h,g),e(h,b),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function Nm(x){let h,b,_,f,y;return f=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsYXhWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsJTJDJTIwQXV0b0ltYWdlUHJvY2Vzc29yJTJDJTIwQXV0b1Rva2VuaXplciUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWltcG9ydCUyMHJlcXVlc3RzJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQtaW4yMWslMjIpJTBBJTBBJTIzJTIwbG9hZCUyMG91dHB1dCUyMHRva2VuaXplciUwQXRva2VuaXplcl9vdXRwdXQlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQSUwQSUyMyUyMGluaXRpYWxpemUlMjBhJTIwdml0LWdwdDIlMjBmcm9tJTIwcHJldHJhaW5lZCUyMFZpVCUyMGFuZCUyMEdQVDIlMjBtb2RlbHMuJTIwTm90ZSUyMHRoYXQlMjB0aGUlMjBjcm9zcy1hdHRlbnRpb24lMjBsYXllcnMlMjB3aWxsJTIwYmUlMjByYW5kb21seSUyMGluaXRpYWxpemVkJTBBbW9kZWwlMjAlM0QlMjBGbGF4VmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX2VuY29kZXJfZGVjb2Rlcl9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmdvb2dsZSUyRnZpdC1iYXNlLXBhdGNoMTYtMjI0LWluMjFrJTIyJTJDJTIwJTIyZ3B0MiUyMiUwQSklMEElMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMm5wJTIyKS5waXhlbF92YWx1ZXMlMEElMEElMjMlMjB1c2UlMjBHUFQyJ3MlMjBlb3NfdG9rZW4lMjBhcyUyMHRoZSUyMHBhZCUyMGFzJTIwd2VsbCUyMGFzJTIwZW9zJTIwdG9rZW4lMEFtb2RlbC5jb25maWcuZW9zX3Rva2VuX2lkJTIwJTNEJTIwbW9kZWwuY29uZmlnLmRlY29kZXIuZW9zX3Rva2VuX2lkJTBBbW9kZWwuY29uZmlnLnBhZF90b2tlbl9pZCUyMCUzRCUyMG1vZGVsLmNvbmZpZy5lb3NfdG9rZW5faWQlMEElMEElMjMlMjBnZW5lcmF0aW9uJTBBc2VxdWVuY2VzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUocGl4ZWxfdmFsdWVzJTJDJTIwbnVtX2JlYW1zJTNENCUyQyUyMG1heF9sZW5ndGglM0QxMikuc2VxdWVuY2VzJTBBJTBBY2FwdGlvbnMlMjAlM0QlMjB0b2tlbml6ZXJfb3V0cHV0LmJhdGNoX2RlY29kZShzZXF1ZW5jZXMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxVisionEncoderDecoderModel, AutoImageProcessor, AutoTokenizer
<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-keyword">import</span> requests

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.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)

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load output tokenizer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer_output = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a vit-gpt2 from pretrained ViT and GPT2 models. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = image_processor(images=image, return_tensors=<span class="hljs-string">&quot;np&quot;</span>).pixel_values

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># use GPT2&#x27;s eos_token as the pad as well as eos token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.eos_token_id = model.config.decoder.eos_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = model.config.eos_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>sequences = model.generate(pixel_values, num_beams=<span class="hljs-number">4</span>, max_length=<span class="hljs-number">12</span>).sequences

<span class="hljs-meta">&gt;&gt;&gt; </span>captions = tokenizer_output.batch_decode(sequences, skip_special_tokens=<span class="hljs-literal">True</span>)`}}),{c(){h=r("p"),b=n("Examples:"),_=c(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Examples:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:it,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){j(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function qm(x){let h,b,_,f,y;return f=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsYXhWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMGElMjB2aXQtZ3B0MiUyMGZyb20lMjBhJTIwcHJldHJhaW5lZCUyMFZpVCUyMGFuZCUyMGElMjBwcmV0cmFpbmVkJTIwR1BUMiUyMG1vZGVsLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwRmxheFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNC1pbjIxayUyMiUyQyUyMCUyMmdwdDIlMjIlMEEpJTBBJTIzJTIwc2F2aW5nJTIwbW9kZWwlMjBhZnRlciUyMGZpbmUtdHVuaW5nJTBBbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMi4lMkZ2aXQtZ3B0MiUyMiklMEElMjMlMjBsb2FkJTIwZmluZS10dW5lZCUyMG1vZGVsJTBBbW9kZWwlMjAlM0QlMjBGbGF4VmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyLiUyRnZpdC1ncHQyJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxVisionEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a vit-gpt2 from a pretrained ViT and a pretrained GPT2 model. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># saving model after fine-tuning</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;./vit-gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load fine-tuned model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxVisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./vit-gpt2&quot;</span>)`}}),{c(){h=r("p"),b=n("Example:"),_=c(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Example:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:it,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){j(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Ym(x){let h,b,_,f,y,l,g,C,jr,_a,ne,we,cn,eo,kr,pn,Er,ya,E,Zr,ct,Vr,Jr,mn,Wr,Ur,pt,xr,Fr,mt,$r,Rr,ht,Br,Ir,ft,Cr,Gr,hn,zr,Dr,ut,Xr,Nr,gt,qr,Yr,_t,Ar,Sr,yt,Pr,Qr,ba,Te,Hr,oo,Lr,Or,Ma,je,Kr,bt,es,os,va,Q,ts,Mt,ns,as,vt,rs,ss,wa,ae,ke,fn,to,ds,no,ls,un,is,cs,Ta,A,wt,ps,ms,Tt,hs,fs,gn,us,gs,ja,ao,ka,re,Ee,_n,ro,_s,so,ys,yn,bs,Ms,Ea,V,jt,vs,ws,bn,Ts,js,kt,ks,Es,Mn,Zs,Vs,vn,Js,Ws,wn,Us,xs,Et,Fs,$s,Ze,Rs,Tn,Bs,Is,jn,Cs,Gs,Zt,zs,Ds,Za,lo,Va,se,Ve,kn,io,Xs,co,Ns,En,qs,Ys,Ja,G,As,Zn,Ss,Ps,Vt,Qs,Hs,Vn,Ls,Os,Wa,Je,Ks,Jn,ed,od,Ua,po,xa,de,We,Wn,mo,td,ho,nd,Un,ad,rd,Fa,le,xn,sd,dd,Fn,ld,id,$a,fo,Ra,ie,Ue,$n,uo,cd,Rn,pd,Ba,z,md,Bn,hd,fd,In,ud,gd,Cn,_d,yd,Ia,go,Ca,H,bd,_o,Md,vd,yo,wd,Td,Ga,ce,xe,Gn,bo,jd,zn,kd,za,I,Mo,Ed,Fe,Jt,Zd,Vd,Wt,Jd,Wd,Ud,pe,xd,Ut,Fd,$d,xt,Rd,Bd,Id,$e,Cd,Re,vo,Gd,wo,zd,Ft,Dd,Xd,Da,me,Be,Dn,To,Nd,Xn,qd,Xa,J,jo,Yd,he,Ad,$t,Sd,Pd,Rt,Qd,Hd,Ld,ko,Od,Eo,Kd,el,ol,Zo,tl,Vo,nl,al,rl,Nn,sl,dl,Jo,ll,Bt,il,cl,pl,Wo,ml,Uo,hl,fl,ul,L,It,gl,_l,qn,yl,bl,Yn,Ml,vl,wl,D,xo,Tl,fe,jl,Ct,kl,El,An,Zl,Vl,Jl,Ie,Wl,Ce,Ul,X,Fo,xl,Sn,Fl,$l,ue,Rl,Pn,Bl,Il,Qn,Cl,Gl,zl,Ge,Na,ge,ze,Hn,$o,Dl,Ln,Xl,qa,W,Ro,Nl,_e,ql,Gt,Yl,Al,zt,Sl,Pl,Ql,Bo,Hl,Io,Ll,Ol,Kl,Co,ei,Go,oi,ti,ni,On,ai,ri,zo,si,Dt,di,li,ii,Do,ci,Xo,pi,mi,hi,O,Xt,fi,ui,Nt,gi,_i,qt,yi,bi,Mi,N,No,vi,ye,wi,Yt,Ti,ji,Kn,ki,Ei,Zi,De,Vi,Xe,Ji,K,qo,Wi,ea,Ui,xi,Ne,Ya,be,qe,oa,Yo,Fi,ta,$i,Aa,U,Ao,Ri,Me,Bi,At,Ii,Ci,St,Gi,zi,Di,So,Xi,Po,Ni,qi,Yi,Qo,Ai,Ho,Si,Pi,Qi,na,Hi,Li,Lo,Oi,Pt,Ki,ec,oc,Oo,tc,Ko,nc,ac,rc,ee,Qt,sc,dc,aa,lc,ic,ra,cc,pc,mc,q,et,hc,ve,fc,Ht,uc,gc,sa,_c,yc,bc,Ye,Mc,Ae,vc,oe,ot,wc,da,Tc,jc,Se,Sa;return l=new P({}),eo=new P({}),to=new P({}),ao=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBWaVRDb25maWclMkMlMjBWaXNpb25FbmNvZGVyRGVjb2RlckNvbmZpZyUyQyUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEFjb25maWdfZW5jb2RlciUyMCUzRCUyMFZpVENvbmZpZygpJTBBY29uZmlnX2RlY29kZXIlMjAlM0QlMjBCZXJ0Q29uZmlnKCklMEElMEFjb25maWclMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2RlckNvbmZpZy5mcm9tX2VuY29kZXJfZGVjb2Rlcl9jb25maWdzKGNvbmZpZ19lbmNvZGVyJTJDJTIwY29uZmlnX2RlY29kZXIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsKGNvbmZpZyUzRGNvbmZpZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, ViTConfig, VisionEncoderDecoderConfig, VisionEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span>config_encoder = ViTConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder = BertConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span>config = VisionEncoderDecoderConfig.from_encoder_decoder_configs(config_encoder, config_decoder)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel(config=config)`}}),ro=new P({}),lo=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEFtb2RlbCUyMCUzRCUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJtaWNyb3NvZnQlMkZzd2luLWJhc2UtcGF0Y2g0LXdpbmRvdzctMjI0LWluMjJrJTIyJTJDJTIwJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VisionEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;microsoft/swin-base-patch4-window7-224-in22k&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
<span class="hljs-meta">... </span>)`}}),io=new P({}),po=new Y({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwR1BUMlRva2VuaXplckZhc3QlMkMlMjBWaVRJbWFnZVByb2Nlc3NvciUyQyUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBsb2FkJTIwYSUyMGZpbmUtdHVuZWQlMjBpbWFnZSUyMGNhcHRpb25pbmclMjBtb2RlbCUyMGFuZCUyMGNvcnJlc3BvbmRpbmclMjB0b2tlbml6ZXIlMjBhbmQlMjBpbWFnZSUyMHByb2Nlc3NvciUwQW1vZGVsJTIwJTNEJTIwVmlzaW9uRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIybmxwY29ubmVjdCUyRnZpdC1ncHQyLWltYWdlLWNhcHRpb25pbmclMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwR1BUMlRva2VuaXplckZhc3QuZnJvbV9wcmV0cmFpbmVkKCUyMm5scGNvbm5lY3QlMkZ2aXQtZ3B0Mi1pbWFnZS1jYXB0aW9uaW5nJTIyKSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMFZpVEltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJubHBjb25uZWN0JTJGdml0LWdwdDItaW1hZ2UtY2FwdGlvbmluZyUyMiklMEElMEElMjMlMjBsZXQncyUyMHBlcmZvcm0lMjBpbmZlcmVuY2UlMjBvbiUyMGFuJTIwaW1hZ2UlMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBcGl4ZWxfdmFsdWVzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikucGl4ZWxfdmFsdWVzJTBBJTBBJTIzJTIwYXV0b3JlZ3Jlc3NpdmVseSUyMGdlbmVyYXRlJTIwY2FwdGlvbiUyMCh1c2VzJTIwZ3JlZWR5JTIwZGVjb2RpbmclMjBieSUyMGRlZmF1bHQpJTBBZ2VuZXJhdGVkX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKHBpeGVsX3ZhbHVlcyklMEFnZW5lcmF0ZWRfdGV4dCUyMCUzRCUyMHRva2VuaXplci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVkX2lkcyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQlMEFwcmludChnZW5lcmF0ZWRfdGV4dCk=",highlighted:`<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-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2TokenizerFast, ViTImageProcessor, VisionEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load a fine-tuned image captioning model and corresponding tokenizer and image processor</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;nlpconnect/vit-gpt2-image-captioning&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2TokenizerFast.from_pretrained(<span class="hljs-string">&quot;nlpconnect/vit-gpt2-image-captioning&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = ViTImageProcessor.from_pretrained(<span class="hljs-string">&quot;nlpconnect/vit-gpt2-image-captioning&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># let&#x27;s perform inference on an image</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.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)
<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = image_processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># autoregressively generate caption (uses greedy decoding by default)</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 = tokenizer.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><span class="hljs-built_in">print</span>(generated_text)
a cat laying on a blanket <span class="hljs-built_in">next</span> to a cat laying on a bed`}}),mo=new P({}),fo=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMkMlMjBURlZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEFfbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJubHBjb25uZWN0JTJGdml0LWdwdDItaW1hZ2UtY2FwdGlvbmluZyUyMiklMEElMEFfbW9kZWwuZW5jb2Rlci5zYXZlX3ByZXRyYWluZWQoJTIyLiUyRmVuY29kZXIlMjIpJTBBX21vZGVsLmRlY29kZXIuc2F2ZV9wcmV0cmFpbmVkKCUyMi4lMkZkZWNvZGVyJTIyKSUwQSUwQW1vZGVsJTIwJTNEJTIwVEZWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyLiUyRmVuY29kZXIlMjIlMkMlMjAlMjIuJTJGZGVjb2RlciUyMiUyQyUyMGVuY29kZXJfZnJvbV9wdCUzRFRydWUlMkMlMjBkZWNvZGVyX2Zyb21fcHQlM0RUcnVlJTBBKSUwQSUyMyUyMFRoaXMlMjBpcyUyMG9ubHklMjBmb3IlMjBjb3B5aW5nJTIwc29tZSUyMHNwZWNpZmljJTIwYXR0cmlidXRlcyUyMG9mJTIwdGhpcyUyMHBhcnRpY3VsYXIlMjBtb2RlbC4lMEFtb2RlbC5jb25maWclMjAlM0QlMjBfbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VisionEncoderDecoderModel, TFVisionEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span>_model = VisionEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;nlpconnect/vit-gpt2-image-captioning&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>_model.encoder.save_pretrained(<span class="hljs-string">&quot;./encoder&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>_model.decoder.save_pretrained(<span class="hljs-string">&quot;./decoder&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;./encoder&quot;</span>, <span class="hljs-string">&quot;./decoder&quot;</span>, encoder_from_pt=<span class="hljs-literal">True</span>, decoder_from_pt=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># This is only for copying some specific attributes of this particular model.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config = _model.config`}}),uo=new P({}),go=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpVEltYWdlUHJvY2Vzc29yJTJDJTIwQmVydFRva2VuaXplciUyQyUyMFZpc2lvbkVuY29kZXJEZWNvZGVyTW9kZWwlMEFmcm9tJTIwZGF0YXNldHMlMjBpbXBvcnQlMjBsb2FkX2RhdGFzZXQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBWaVRJbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQtaW4yMWslMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQmVydFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBbW9kZWwlMjAlM0QlMjBWaXNpb25FbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQtaW4yMWslMjIlMkMlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUwQSklMEElMEFtb2RlbC5jb25maWcuZGVjb2Rlcl9zdGFydF90b2tlbl9pZCUyMCUzRCUyMHRva2VuaXplci5jbHNfdG9rZW5faWQlMEFtb2RlbC5jb25maWcucGFkX3Rva2VuX2lkJTIwJTNEJTIwdG9rZW5pemVyLnBhZF90b2tlbl9pZCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5waXhlbF92YWx1ZXMlMEElMEFsYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTIyYW4lMjBpbWFnZSUyMG9mJTIwdHdvJTIwY2F0cyUyMGNoaWxsaW5nJTIwb24lMjBhJTIwY291Y2glMjIlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBKS5pbnB1dF9pZHMlMEElMEElMjMlMjB0aGUlMjBmb3J3YXJkJTIwZnVuY3Rpb24lMjBhdXRvbWF0aWNhbGx5JTIwY3JlYXRlcyUyMHRoZSUyMGNvcnJlY3QlMjBkZWNvZGVyX2lucHV0X2lkcyUwQWxvc3MlMjAlM0QlMjBtb2RlbChwaXhlbF92YWx1ZXMlM0RwaXhlbF92YWx1ZXMlMkMlMjBsYWJlbHMlM0RsYWJlbHMpLmxvc3M=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ViTImageProcessor, BertTokenizer, 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>image_processor = ViTImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VisionEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.decoder_start_token_id = tokenizer.cls_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = tokenizer.pad_token_id

<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>pixel_values = image_processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;an image of two cats chilling on a couch&quot;</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the forward function automatically creates the correct decoder_input_ids</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(pixel_values=pixel_values, labels=labels).loss`}}),bo=new P({}),Mo=new S({props:{name:"class transformers.VisionEncoderDecoderConfig",anchor:"transformers.VisionEncoderDecoderConfig",parameters:[{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VisionEncoderDecoderConfig.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments. Notably:</p>
<ul>
<li><strong>encoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>, <em>optional</em>) &#x2014; An instance of a configuration object that defines
the encoder config.</li>
<li><strong>decoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>, <em>optional</em>) &#x2014; An instance of a configuration object that defines
the decoder config.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/configuration_vision_encoder_decoder.py#L33"}}),$e=new lt({props:{anchor:"transformers.VisionEncoderDecoderConfig.example",$$slots:{default:[Rm]},$$scope:{ctx:x}}}),vo=new S({props:{name:"from_encoder_decoder_configs",anchor:"transformers.VisionEncoderDecoderConfig.from_encoder_decoder_configs",parameters:[{name:"encoder_config",val:": PretrainedConfig"},{name:"decoder_config",val:": PretrainedConfig"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/configuration_vision_encoder_decoder.py#L99",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig"
>VisionEncoderDecoderConfig</a></p>
`}}),To=new P({}),jo=new S({props:{name:"class transformers.VisionEncoderDecoderModel",anchor:"transformers.VisionEncoderDecoderModel",parameters:[{name:"config",val:": typing.Optional[transformers.configuration_utils.PretrainedConfig] = None"},{name:"encoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"decoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"}],parametersDescription:[{anchor:"transformers.VisionEncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig">VisionEncoderDecoderConfig</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.33.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.33.0/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py#L151"}}),xo=new S({props:{name:"forward",anchor:"transformers.VisionEncoderDecoderModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"decoder_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"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VisionEncoderDecoderModel.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 an image processor (e.g. if you use ViT as the encoder,
you should use <a href="/docs/transformers/v4.33.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>). See <a href="/docs/transformers/v4.33.0/en/model_doc/donut#transformers.DonutFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.VisionEncoderDecoderModel.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>For training, <code>decoder_input_ids</code> are automatically created by the model by shifting the <code>labels</code> to the
right, replacing -100 by the <code>pad_token_id</code> and prepending them with the <code>decoder_start_token_id</code>.`,name:"decoder_input_ids"},{anchor:"transformers.VisionEncoderDecoderModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.VisionEncoderDecoderModel.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
This tuple must consist of (<code>last_hidden_state</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>)
<code>last_hidden_state</code> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) is a tensor
of hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the
decoder.`,name:"encoder_outputs"},{anchor:"transformers.VisionEncoderDecoderModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up 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.VisionEncoderDecoderModel.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. This is useful if you want more control over how to convert <code>decoder_input_ids</code> indices
into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"decoder_inputs_embeds"},{anchor:"transformers.VisionEncoderDecoderModel.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 for the decoder. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (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.VisionEncoderDecoderModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.VisionEncoderDecoderModel.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.VisionEncoderDecoderModel.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.VisionEncoderDecoderModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <code>~utils.Seq2SeqLMOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.VisionEncoderDecoderModel.forward.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014; Remaining dictionary of keyword arguments. Keyword arguments come in two flavors:</p>
<ul>
<li>Without a prefix which will be input as <code>**encoder_kwargs</code> for the encoder forward function.</li>
<li>With a <em>decoder_</em> prefix which will be input as <code>**decoder_kwargs</code> for the decoder forward function.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py#L519",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</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.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig"
>VisionEncoderDecoderConfig</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) \u2014 Language modeling loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</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>) \u2014 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>.</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>
</li>
<li>
<p><strong>decoder_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>) \u2014 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 decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_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>) \u2014 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 of the decoder, 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>) \u2014 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 of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_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>) \u2014 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 encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_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>) \u2014 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 of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ie=new Ec({props:{$$slots:{default:[Bm]},$$scope:{ctx:x}}}),Ce=new lt({props:{anchor:"transformers.VisionEncoderDecoderModel.forward.example",$$slots:{default:[Im]},$$scope:{ctx:x}}}),Fo=new S({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.VisionEncoderDecoderModel.from_encoder_decoder_pretrained",parameters:[{name:"encoder_pretrained_model_name_or_path",val:": str = None"},{name:"decoder_pretrained_model_name_or_path",val:": str = None"},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VisionEncoderDecoderModel.from_encoder_decoder_pretrained.encoder_pretrained_model_name_or_path",description:`<strong>encoder_pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Information necessary to initiate the image encoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co. An
example is <code>google/vit-base-patch16-224-in21k</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>tensorflow index checkpoint file</em> (e.g, <code>./tf_model/model.ckpt.index</code>). In
this case, <code>from_tf</code> should be set to <code>True</code> and a configuration object should be provided as
<code>config</code> argument. This loading path is slower than converting the TensorFlow checkpoint in a
PyTorch model using the provided conversion scripts and loading the PyTorch model afterwards.</li>
</ul>`,name:"encoder_pretrained_model_name_or_path"},{anchor:"transformers.VisionEncoderDecoderModel.from_encoder_decoder_pretrained.decoder_pretrained_model_name_or_path",description:`<strong>decoder_pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Information necessary to initiate the text decoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model 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 model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>tensorflow index checkpoint file</em> (e.g, <code>./tf_model/model.ckpt.index</code>). In
this case, <code>from_tf</code> should be set to <code>True</code> and a configuration object should be provided as
<code>config</code> argument. This loading path is slower than converting the TensorFlow checkpoint in a
PyTorch model using the provided conversion scripts and loading the PyTorch model afterwards.</li>
</ul>`,name:"decoder_pretrained_model_name_or_path"},{anchor:"transformers.VisionEncoderDecoderModel.from_encoder_decoder_pretrained.model_args",description:`<strong>model_args</strong> (remaining positional arguments, <em>optional</em>) &#x2014;
All remaning positional arguments will be passed to the underlying model&#x2019;s <code>__init__</code> method.`,name:"model_args"},{anchor:"transformers.VisionEncoderDecoderModel.from_encoder_decoder_pretrained.kwargs",description:`<strong>kwargs</strong> (remaining dictionary of keyword arguments, <em>optional</em>) &#x2014;
Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
<code>output_attentions=True</code>).</p>
<ul>
<li>To update the encoder configuration, use the prefix <em>encoder_</em> for each configuration parameter.</li>
<li>To update the decoder configuration, use the prefix <em>decoder_</em> for each configuration parameter.</li>
<li>To update the parent model configuration, do not use a prefix for each configuration parameter.</li>
</ul>
<p>Behaves differently depending on whether a <code>config</code> is provided or automatically loaded.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py#L365"}}),Ge=new lt({props:{anchor:"transformers.VisionEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Cm]},$$scope:{ctx:x}}}),$o=new P({}),Ro=new S({props:{name:"class transformers.TFVisionEncoderDecoderModel",anchor:"transformers.TFVisionEncoderDecoderModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFVisionEncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig">VisionEncoderDecoderConfig</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.33.0/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py#L176"}}),No=new S({props:{name:"call",anchor:"transformers.TFVisionEncoderDecoderModel.call",parameters:[{name:"pixel_values",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_input_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_outputs",val:": Optional[Union[Tuple, TFBaseModelOutput]] = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"decoder_inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": Optional[bool] = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFVisionEncoderDecoderModel.call.pixel_values",description:`<strong>pixel_values</strong> (<code>np.ndarray</code>, <code>tf.Tensor</code>, <code>List[tf.Tensor]</code> \`<code>Dict[str, tf.Tensor]</code> or <code>Dict[str, np.ndarray]</code> and each example must have the shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using the vision&#x2019;s model&#x2019;s image processor. For example, using
<a href="/docs/transformers/v4.33.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/v4.33.0/en/model_doc/donut#transformers.DonutFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.TFVisionEncoderDecoderModel.call.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>Provide for sequence to sequence training to the decoder. Indices can be obtained using
<a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for
details.`,name:"decoder_input_ids"},{anchor:"transformers.TFVisionEncoderDecoderModel.call.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.TFVisionEncoderDecoderModel.call.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(tf.Tensor)</code>, <em>optional</em>) &#x2014;
This tuple must consist of (<code>last_hidden_state</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>)
<code>last_hidden_state</code> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) is a tensor of hidden-states at the output
of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.TFVisionEncoderDecoderModel.call.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(tf.Tensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up 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.TFVisionEncoderDecoderModel.call.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. This is useful if you want more control over how to convert <code>decoder_input_ids</code> indices
into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"decoder_inputs_embeds"},{anchor:"transformers.TFVisionEncoderDecoderModel.call.labels",description:`<strong>labels</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss for the decoder. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (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.TFVisionEncoderDecoderModel.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TFVisionEncoderDecoderModel.call.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.TFVisionEncoderDecoderModel.call.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.TFVisionEncoderDecoderModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <code>~utils.Seq2SeqLMOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFVisionEncoderDecoderModel.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFVisionEncoderDecoderModel.call.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014; Remaining dictionary of keyword arguments. Keyword arguments come in two flavors:</p>
<ul>
<li>Without a prefix which will be input as <code>**encoder_kwargs</code> for the encoder forward function.</li>
<li>With a <em>decoder_</em> prefix which will be input as <code>**decoder_kwargs</code> for the decoder forward function.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py#L486",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_tf_outputs.TFSeq2SeqLMOutput"
>transformers.modeling_tf_outputs.TFSeq2SeqLMOutput</a> or a tuple of <code>tf.Tensor</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.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig"
>VisionEncoderDecoderConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(n,)</code>, <em>optional</em>, where n is the number of non-masked labels, returned when <code>labels</code> is provided) \u2014 Language modeling loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, 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(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_tf_outputs.TFSeq2SeqLMOutput"
>transformers.modeling_tf_outputs.TFSeq2SeqLMOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),De=new Ec({props:{$$slots:{default:[Gm]},$$scope:{ctx:x}}}),Xe=new lt({props:{anchor:"transformers.TFVisionEncoderDecoderModel.call.example",$$slots:{default:[zm]},$$scope:{ctx:x}}}),qo=new S({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained",parameters:[{name:"encoder_pretrained_model_name_or_path",val:": str = None"},{name:"decoder_pretrained_model_name_or_path",val:": str = None"},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained.encoder_pretrained_model_name_or_path",description:`<strong>encoder_pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Information necessary to initiate the encoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co. An
example is <code>google/vit-base-patch16-224-in21k</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>pytorch index checkpoint file</em> (e.g, <code>./pt_model/</code>). In this case,
<code>encoder_from_pt</code> should be set to <code>True</code>.</li>
</ul>`,name:"encoder_pretrained_model_name_or_path"},{anchor:"transformers.TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained.decoder_pretrained_model_name_or_path",description:`<strong>decoder_pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>, defaults to <em>None</em>) &#x2014;
Information necessary to initiate the decoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model 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 model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>pytorch checkpoint file</em> (e.g, <code>./pt_model/</code>). In this case,
<code>decoder_from_pt</code> should be set to <code>True</code>.</li>
</ul>`,name:"decoder_pretrained_model_name_or_path"},{anchor:"transformers.TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained.model_args",description:`<strong>model_args</strong> (remaining positional arguments, <em>optional</em>) &#x2014;
All remaning positional arguments will be passed to the underlying model&#x2019;s <code>__init__</code> method.`,name:"model_args"},{anchor:"transformers.TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained.kwargs",description:`<strong>kwargs</strong> (remaining dictionary of keyword arguments, <em>optional</em>) &#x2014;
Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
<code>output_attentions=True</code>).</p>
<ul>
<li>To update the encoder configuration, use the prefix <em>encoder_</em> for each configuration parameter.</li>
<li>To update the decoder configuration, use the prefix <em>decoder_</em> for each configuration parameter.</li>
<li>To update the parent model configuration, do not use a prefix for each configuration parameter.</li>
</ul>
<p>Behaves differently depending on whether a <code>config</code> is provided or automatically loaded.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py#L338"}}),Ne=new lt({props:{anchor:"transformers.TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Dm]},$$scope:{ctx:x}}}),Yo=new P({}),Ao=new S({props:{name:"class transformers.FlaxVisionEncoderDecoderModel",anchor:"transformers.FlaxVisionEncoderDecoderModel",parameters:[{name:"config",val:": VisionEncoderDecoderConfig"},{name:"input_shape",val:": typing.Optional[typing.Tuple] = None"},{name:"seed",val:": int = 0"},{name:"dtype",val:": dtype = <class 'jax.numpy.float32'>"},{name:"_do_init",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxVisionEncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig">VisionEncoderDecoderConfig</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.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.FlaxVisionEncoderDecoderModel.dtype",description:`<strong>dtype</strong> (<code>jax.numpy.dtype</code>, <em>optional</em>, defaults to <code>jax.numpy.float32</code>) &#x2014;
The data type of the computation. Can be one of <code>jax.numpy.float32</code>, <code>jax.numpy.float16</code> (on GPUs) and
<code>jax.numpy.bfloat16</code> (on TPUs).</p>
<p>This can be used to enable mixed-precision training or half-precision inference on GPUs or TPUs. If
specified all the computation will be performed with the given <code>dtype</code>.</p>
<p><strong>Note that this only specifies the dtype of the computation and does not influence the dtype of model
parameters.</strong></p>
<p>If you wish to change the dtype of the model parameters, see <a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py#L268"}}),et=new S({props:{name:"__call__",anchor:"transformers.FlaxVisionEncoderDecoderModel.__call__",parameters:[{name:"pixel_values",val:": Array"},{name:"decoder_input_ids",val:": typing.Optional[jax.Array] = None"},{name:"decoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"decoder_position_ids",val:": typing.Optional[jax.Array] = 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"},{name:"train",val:": bool = False"},{name:"params",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"}],parametersDescription:[{anchor:"transformers.FlaxVisionEncoderDecoderModel.__call__.pixel_values",description:`<strong>pixel_values</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using the vision model&#x2019;s image processor. For example, using
<a href="/docs/transformers/v4.33.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/v4.33.0/en/model_doc/donut#transformers.DonutFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.FlaxVisionEncoderDecoderModel.__call__.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a>`,name:"decoder_input_ids"},{anchor:"transformers.FlaxVisionEncoderDecoderModel.__call__.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.FlaxVisionEncoderDecoderModel.__call__.decoder_position_ids",description:`<strong>decoder_position_ids</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each decoder input sequence tokens in the position embeddings. Selected in the
range <code>[0, config.decoder.max_position_embeddings - 1]</code>.`,name:"decoder_position_ids"},{anchor:"transformers.FlaxVisionEncoderDecoderModel.__call__.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.FlaxVisionEncoderDecoderModel.__call__.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.FlaxVisionEncoderDecoderModel.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <code>~utils.FlaxSeq2SeqLMOutput</code> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py#L598",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput"
>transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput</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.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig"
>VisionEncoderDecoderConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>logits</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(jnp.ndarray))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(jnp.ndarray)</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>.</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>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, 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(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput"
>transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ye=new Ec({props:{$$slots:{default:[Xm]},$$scope:{ctx:x}}}),Ae=new lt({props:{anchor:"transformers.FlaxVisionEncoderDecoderModel.__call__.example",$$slots:{default:[Nm]},$$scope:{ctx:x}}}),ot=new S({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained",parameters:[{name:"encoder_pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"decoder_pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained.encoder_pretrained_model_name_or_path",description:`<strong>encoder_pretrained_model_name_or_path</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Information necessary to initiate the encoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co. An
example is <code>google/vit-base-patch16-224-in21k</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
</ul>`,name:"encoder_pretrained_model_name_or_path"},{anchor:"transformers.FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained.decoder_pretrained_model_name_or_path",description:`<strong>decoder_pretrained_model_name_or_path</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Information necessary to initiate the decoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model 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 model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
</ul>`,name:"decoder_pretrained_model_name_or_path"},{anchor:"transformers.FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained.model_args",description:`<strong>model_args</strong> (remaining positional arguments, <em>optional</em>) &#x2014;
All remaning positional arguments will be passed to the underlying model&#x2019;s <code>__init__</code> method.`,name:"model_args"},{anchor:"transformers.FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained.kwargs",description:`<strong>kwargs</strong> (remaining dictionary of keyword arguments, <em>optional</em>) &#x2014;
Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
<code>output_attentions=True</code>).</p>
<ul>
<li>To update the encoder configuration, use the prefix <em>encoder_</em> for each configuration parameter.</li>
<li>To update the decoder configuration, use the prefix <em>decoder_</em> for each configuration parameter.</li>
<li>To update the parent model configuration, do not use a prefix for each configuration parameter.</li>
</ul>
<p>Behaves differently depending on whether a <code>config</code> is provided or automatically loaded.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py#L723"}}),Se=new lt({props:{anchor:"transformers.FlaxVisionEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[qm]},$$scope:{ctx:x}}}),{c(){h=r("meta"),b=c(),_=r("h1"),f=r("a"),y=r("span"),M(l.$$.fragment),g=c(),C=r("span"),jr=n("Vision Encoder Decoder Models"),_a=c(),ne=r("h2"),we=r("a"),cn=r("span"),M(eo.$$.fragment),kr=c(),pn=r("span"),Er=n("Overview"),ya=c(),E=r("p"),Zr=n("The "),ct=r("a"),Vr=n("VisionEncoderDecoderModel"),Jr=n(` can be used to initialize an image-to-text model with any
pretrained Transformer-based vision model as the encoder (`),mn=r("em"),Wr=n("e.g."),Ur=c(),pt=r("a"),xr=n("ViT"),Fr=n(", "),mt=r("a"),$r=n("BEiT"),Rr=n(", "),ht=r("a"),Br=n("DeiT"),Ir=n(", "),ft=r("a"),Cr=n("Swin"),Gr=n(`)
and any pretrained language model as the decoder (`),hn=r("em"),zr=n("e.g."),Dr=c(),ut=r("a"),Xr=n("RoBERTa"),Nr=n(", "),gt=r("a"),qr=n("GPT2"),Yr=n(", "),_t=r("a"),Ar=n("BERT"),Sr=n(", "),yt=r("a"),Pr=n("DistilBERT"),Qr=n(")."),ba=c(),Te=r("p"),Hr=n(`The effectiveness of initializing image-to-text-sequence models with pretrained checkpoints has been shown in (for
example) `),oo=r("a"),Lr=n("TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models"),Or=n(` by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang,
Zhoujun Li, Furu Wei.`),Ma=c(),je=r("p"),Kr=n("After such a "),bt=r("a"),es=n("VisionEncoderDecoderModel"),os=n(` has been trained/fine-tuned, it can be saved/loaded just like any other models (see the examples below
for more information).`),va=c(),Q=r("p"),ts=n(`An example application is image captioning, in which the encoder is used to encode the image, after which an autoregressive language model generates
the caption. Another example is optical character recognition. Refer to `),Mt=r("a"),ns=n("TrOCR"),as=n(", which is an instance of "),vt=r("a"),rs=n("VisionEncoderDecoderModel"),ss=n("."),wa=c(),ae=r("h2"),ke=r("a"),fn=r("span"),M(to.$$.fragment),ds=c(),no=r("span"),ls=n("Randomly initializing "),un=r("code"),is=n("VisionEncoderDecoderModel"),cs=n(" from model configurations."),Ta=c(),A=r("p"),wt=r("a"),ps=n("VisionEncoderDecoderModel"),ms=n(" can be randomly initialized from an encoder and a decoder config. In the following example, we show how to do this using the default "),Tt=r("a"),hs=n("ViTModel"),fs=n(` configuration for the encoder
and the default `),gn=r("code"),us=n("BertForCausalLM"),gs=n(" configuration for the decoder."),ja=c(),M(ao.$$.fragment),ka=c(),re=r("h2"),Ee=r("a"),_n=r("span"),M(ro.$$.fragment),_s=c(),so=r("span"),ys=n("Initialising "),yn=r("code"),bs=n("VisionEncoderDecoderModel"),Ms=n(" from a pretrained encoder and a pretrained decoder."),Ea=c(),V=r("p"),jt=r("a"),vs=n("VisionEncoderDecoderModel"),ws=n(" can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained Transformer-based vision model, "),bn=r("em"),Ts=n("e.g."),js=c(),kt=r("a"),ks=n("Swin"),Es=n(", can serve as the encoder and both pretrained auto-encoding models, "),Mn=r("em"),Zs=n("e.g."),Vs=n(" BERT, pretrained causal language models, "),vn=r("em"),Js=n("e.g."),Ws=n(" GPT2, as well as the pretrained decoder part of sequence-to-sequence models, "),wn=r("em"),Us=n("e.g."),xs=n(` decoder of BART, can be used as the decoder.
Depending on which architecture you choose as the decoder, the cross-attention layers might be randomly initialized.
Initializing `),Et=r("a"),Fs=n("VisionEncoderDecoderModel"),$s=n(" from a pretrained encoder and decoder checkpoint requires the model to be fine-tuned on a downstream task, as has been shown in "),Ze=r("a"),Rs=n("the "),Tn=r("em"),Bs=n("Warm-starting-encoder-decoder blog post"),Is=n(`.
To do so, the `),jn=r("code"),Cs=n("VisionEncoderDecoderModel"),Gs=n(" class provides a "),Zt=r("a"),zs=n("VisionEncoderDecoderModel.from_encoder_decoder_pretrained()"),Ds=n(" method."),Za=c(),M(lo.$$.fragment),Va=c(),se=r("h2"),Ve=r("a"),kn=r("span"),M(io.$$.fragment),Xs=c(),co=r("span"),Ns=n("Loading an existing "),En=r("code"),qs=n("VisionEncoderDecoderModel"),Ys=n(" checkpoint and perform inference."),Ja=c(),G=r("p"),As=n("To load fine-tuned checkpoints of the "),Zn=r("code"),Ss=n("VisionEncoderDecoderModel"),Ps=n(" class, "),Vt=r("a"),Qs=n("VisionEncoderDecoderModel"),Hs=n(" provides the "),Vn=r("code"),Ls=n("from_pretrained(...)"),Os=n(" method just like any other model architecture in Transformers."),Wa=c(),Je=r("p"),Ks=n("To perform inference, one uses the "),Jn=r("code"),ed=n("generate"),od=n(" method, which allows to autoregressively generate text. This method supports various forms of decoding, such as greedy, beam search and multinomial sampling."),Ua=c(),M(po.$$.fragment),xa=c(),de=r("h2"),We=r("a"),Wn=r("span"),M(mo.$$.fragment),td=c(),ho=r("span"),nd=n("Loading a PyTorch checkpoint into "),Un=r("code"),ad=n("TFVisionEncoderDecoderModel"),rd=n("."),Fa=c(),le=r("p"),xn=r("code"),sd=n("TFVisionEncoderDecoderModel.from_pretrained()"),dd=n(` currently doesn\u2019t support initializing the model from a
PyTorch checkpoint. Passing `),Fn=r("code"),ld=n("from_pt=True"),id=n(` to this method will throw an exception. If there are only PyTorch
checkpoints for a particular vision encoder-decoder model, a workaround is:`),$a=c(),M(fo.$$.fragment),Ra=c(),ie=r("h2"),Ue=r("a"),$n=r("span"),M(uo.$$.fragment),cd=c(),Rn=r("span"),pd=n("Training"),Ba=c(),z=r("p"),md=n(`Once the model is created, it can be fine-tuned similar to BART, T5 or any other encoder-decoder model on a dataset of (image, text) pairs.
As you can see, only 2 inputs are required for the model in order to compute a loss: `),Bn=r("code"),hd=n("pixel_values"),fd=n(` (which are the
images) and `),In=r("code"),ud=n("labels"),gd=n(" (which are the "),Cn=r("code"),_d=n("input_ids"),yd=n(" of the encoded target sequence)."),Ia=c(),M(go.$$.fragment),Ca=c(),H=r("p"),bd=n("This model was contributed by "),_o=r("a"),Md=n("nielsr"),vd=n(`. This model\u2019s TensorFlow and Flax versions
were contributed by `),yo=r("a"),wd=n("ydshieh"),Td=n("."),Ga=c(),ce=r("h2"),xe=r("a"),Gn=r("span"),M(bo.$$.fragment),jd=c(),zn=r("span"),kd=n("VisionEncoderDecoderConfig"),za=c(),I=r("div"),M(Mo.$$.fragment),Ed=c(),Fe=r("p"),Jt=r("a"),Zd=n("VisionEncoderDecoderConfig"),Vd=n(` is the configuration class to store the configuration of a
`),Wt=r("a"),Jd=n("VisionEncoderDecoderModel"),Wd=n(`. It is used to instantiate a Vision-Encoder-Text-Decoder model according to the
specified arguments, defining the encoder and decoder configs.`),Ud=c(),pe=r("p"),xd=n("Configuration objects inherit from "),Ut=r("a"),Fd=n("PretrainedConfig"),$d=n(` and can be used to control the model outputs. Read the
documentation from `),xt=r("a"),Rd=n("PretrainedConfig"),Bd=n(" for more information."),Id=c(),M($e.$$.fragment),Cd=c(),Re=r("div"),M(vo.$$.fragment),Gd=c(),wo=r("p"),zd=n("Instantiate a "),Ft=r("a"),Dd=n("VisionEncoderDecoderConfig"),Xd=n(` (or a derived class) from a pre-trained encoder model
configuration and decoder model configuration.`),Da=c(),me=r("h2"),Be=r("a"),Dn=r("span"),M(To.$$.fragment),Nd=c(),Xn=r("span"),qd=n("VisionEncoderDecoderModel"),Xa=c(),J=r("div"),M(jo.$$.fragment),Yd=c(),he=r("p"),Ad=n(`This class can be used to initialize an image-to-text-sequence model with any pretrained vision autoencoding model
as the encoder and any pretrained text autoregressive model as the decoder. The encoder is loaded via
`),$t=r("a"),Sd=n("from_pretrained()"),Pd=n(" function and the decoder is loaded via "),Rt=r("a"),Qd=n("from_pretrained()"),Hd=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like image captioning.`),Ld=c(),ko=r("p"),Od=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Eo=r("a"),Kd=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),el=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),ol=c(),Zo=r("p"),tl=n("Additionally, in "),Vo=r("a"),nl=n(`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),al=n(` it is shown how leveraging large pretrained vision models for optical
character recognition (OCR) yields a significant performance improvement.`),rl=c(),Nn=r("p"),sl=n(`After such a Vision-Encoder-Text-Decoder model has been trained/fine-tuned, it can be saved/loaded just like any
other models (see the examples for more information).`),dl=c(),Jo=r("p"),ll=n("This model inherits from "),Bt=r("a"),il=n("PreTrainedModel"),cl=n(`. 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.)`),pl=c(),Wo=r("p"),ml=n("This model is also a PyTorch "),Uo=r("a"),hl=n("torch.nn.Module"),fl=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ul=c(),L=r("p"),It=r("a"),gl=n("VisionEncoderDecoderModel"),_l=n(` is a generic model class that will be instantiated as a transformer architecture with
one of the base vision model classes of the library as encoder and another one as decoder when created with the
:meth`),qn=r("em"),yl=n("~transformers.AutoModel.from_pretrained"),bl=n(` class method for the encoder and
:meth`),Yn=r("em"),Ml=n("~transformers.AutoModelForCausalLM.from_pretrained"),vl=n(" class method for the decoder."),wl=c(),D=r("div"),M(xo.$$.fragment),Tl=c(),fe=r("p"),jl=n("The "),Ct=r("a"),kl=n("VisionEncoderDecoderModel"),El=n(" forward method, overrides the "),An=r("code"),Zl=n("__call__"),Vl=n(" special method."),Jl=c(),M(Ie.$$.fragment),Wl=c(),M(Ce.$$.fragment),Ul=c(),X=r("div"),M(Fo.$$.fragment),xl=c(),Sn=r("p"),Fl=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),$l=c(),ue=r("p"),Rl=n("The model is set in evaluation mode by default using "),Pn=r("code"),Bl=n("model.eval()"),Il=n(` (Dropout modules are deactivated). To train
the model, you need to first set it back in training mode with `),Qn=r("code"),Cl=n("model.train()"),Gl=n("."),zl=c(),M(Ge.$$.fragment),Na=c(),ge=r("h2"),ze=r("a"),Hn=r("span"),M($o.$$.fragment),Dl=c(),Ln=r("span"),Xl=n("TFVisionEncoderDecoderModel"),qa=c(),W=r("div"),M(Ro.$$.fragment),Nl=c(),_e=r("p"),ql=n(`This class can be used to initialize an image-to-text-sequence model with any pretrained vision autoencoding model
as the encoder and any pretrained text autoregressive model as the decoder. The encoder is loaded via
`),Gt=r("a"),Yl=n("from_pretrained()"),Al=n(" function and the decoder is loaded via "),zt=r("a"),Sl=n("from_pretrained()"),Pl=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like image captioning.`),Ql=c(),Bo=r("p"),Hl=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Io=r("a"),Ll=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),Ol=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),Kl=c(),Co=r("p"),ei=n("Additionally, in "),Go=r("a"),oi=n(`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),ti=n(` it is shown how leveraging large pretrained vision models for optical
character recognition (OCR) yields a significant performance improvement.`),ni=c(),On=r("p"),ai=n(`After such a Vision-Encoder-Text-Decoder model has been trained/fine-tuned, it can be saved/loaded just like any
other models (see the examples for more information).`),ri=c(),zo=r("p"),si=n("This model inherits from "),Dt=r("a"),di=n("TFPreTrainedModel"),li=n(`. 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.)`),ii=c(),Do=r("p"),ci=n("This model is also a "),Xo=r("a"),pi=n("tf.keras.Model"),mi=n(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),hi=c(),O=r("p"),Xt=r("a"),fi=n("TFVisionEncoderDecoderModel"),ui=n(` is a generic model class that will be instantiated as a transformer architecture
with one of the base vision model classes of the library as encoder and another one of the base model classes as
decoder when created with the `),Nt=r("a"),gi=n("from_pretrained()"),_i=n(` class method for the encoder and
`),qt=r("a"),yi=n("from_pretrained()"),bi=n(" class method for the decoder."),Mi=c(),N=r("div"),M(No.$$.fragment),vi=c(),ye=r("p"),wi=n("The "),Yt=r("a"),Ti=n("TFVisionEncoderDecoderModel"),ji=n(" forward method, overrides the "),Kn=r("code"),ki=n("__call__"),Ei=n(" special method."),Zi=c(),M(De.$$.fragment),Vi=c(),M(Xe.$$.fragment),Ji=c(),K=r("div"),M(qo.$$.fragment),Wi=c(),ea=r("p"),Ui=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),xi=c(),M(Ne.$$.fragment),Ya=c(),be=r("h2"),qe=r("a"),oa=r("span"),M(Yo.$$.fragment),Fi=c(),ta=r("span"),$i=n("FlaxVisionEncoderDecoderModel"),Aa=c(),U=r("div"),M(Ao.$$.fragment),Ri=c(),Me=r("p"),Bi=n(`This class can be used to initialize an image-to-text-sequence model with any pretrained vision autoencoding model
as the encoder and any pretrained text autoregressive model as the decoder. The encoder is loaded via
`),At=r("a"),Ii=n("from_pretrained()"),Ci=n(" function and the decoder is loaded via "),St=r("a"),Gi=n("from_pretrained()"),zi=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like image captioning.`),Di=c(),So=r("p"),Xi=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Po=r("a"),Ni=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),qi=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),Yi=c(),Qo=r("p"),Ai=n("Additionally, in "),Ho=r("a"),Si=n(`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),Pi=n(` it is shown how leveraging large pretrained vision models for optical
character recognition (OCR) yields a significant performance improvement.`),Qi=c(),na=r("p"),Hi=n(`After such a Vision-Encoder-Text-Decoder model has been trained/fine-tuned, it can be saved/loaded just like any
other models (see the examples for more information).`),Li=c(),Lo=r("p"),Oi=n("This model inherits from "),Pt=r("a"),Ki=n("FlaxPreTrainedModel"),ec=n(`. 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.)`),oc=c(),Oo=r("p"),tc=n(`This model is also a Flax Linen
`),Ko=r("a"),nc=n("flax.nn.Module"),ac=n(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),rc=c(),ee=r("p"),Qt=r("a"),sc=n("FlaxVisionEncoderDecoderModel"),dc=n(` is a generic model class that will be instantiated as a transformer architecture
with the module (flax.nn.Module) of one of the base vision model classes of the library as encoder module and
another one as decoder module when created with the :meth`),aa=r("em"),lc=n("~transformers.FlaxAutoModel.from_pretrained"),ic=n(` class method
for the encoder and :meth`),ra=r("em"),cc=n("~transformers.FlaxAutoModelForCausalLM.from_pretrained"),pc=n(" class method for the decoder."),mc=c(),q=r("div"),M(et.$$.fragment),hc=c(),ve=r("p"),fc=n("The "),Ht=r("a"),uc=n("FlaxVisionEncoderDecoderModel"),gc=n(" forward method, overrides the "),sa=r("code"),_c=n("__call__"),yc=n(" special method."),bc=c(),M(Ye.$$.fragment),Mc=c(),M(Ae.$$.fragment),vc=c(),oe=r("div"),M(ot.$$.fragment),wc=c(),da=r("p"),Tc=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),jc=c(),M(Se.$$.fragment),this.h()},l(o){const m=Fm('[data-svelte="svelte-1phssyn"]',document.head);h=s(m,"META",{name:!0,content:!0}),m.forEach(t),b=p(o),_=s(o,"H1",{class:!0});var tt=d(_);f=s(tt,"A",{id:!0,class:!0,href:!0});var la=d(f);y=s(la,"SPAN",{});var ia=d(y);v(l.$$.fragment,ia),ia.forEach(t),la.forEach(t),g=p(tt),C=s(tt,"SPAN",{});var ca=d(C);jr=a(ca,"Vision Encoder Decoder Models"),ca.forEach(t),tt.forEach(t),_a=p(o),ne=s(o,"H2",{class:!0});var nt=d(ne);we=s(nt,"A",{id:!0,class:!0,href:!0});var pa=d(we);cn=s(pa,"SPAN",{});var ma=d(cn);v(eo.$$.fragment,ma),ma.forEach(t),pa.forEach(t),kr=p(nt),pn=s(nt,"SPAN",{});var ha=d(pn);Er=a(ha,"Overview"),ha.forEach(t),nt.forEach(t),ya=p(o),E=s(o,"P",{});var Z=d(E);Zr=a(Z,"The "),ct=s(Z,"A",{href:!0});var fa=d(ct);Vr=a(fa,"VisionEncoderDecoderModel"),fa.forEach(t),Jr=a(Z,` can be used to initialize an image-to-text model with any
pretrained Transformer-based vision model as the encoder (`),mn=s(Z,"EM",{});var Zc=d(mn);Wr=a(Zc,"e.g."),Zc.forEach(t),Ur=p(Z),pt=s(Z,"A",{href:!0});var Vc=d(pt);xr=a(Vc,"ViT"),Vc.forEach(t),Fr=a(Z,", "),mt=s(Z,"A",{href:!0});var Jc=d(mt);$r=a(Jc,"BEiT"),Jc.forEach(t),Rr=a(Z,", "),ht=s(Z,"A",{href:!0});var Wc=d(ht);Br=a(Wc,"DeiT"),Wc.forEach(t),Ir=a(Z,", "),ft=s(Z,"A",{href:!0});var Uc=d(ft);Cr=a(Uc,"Swin"),Uc.forEach(t),Gr=a(Z,`)
and any pretrained language model as the decoder (`),hn=s(Z,"EM",{});var xc=d(hn);zr=a(xc,"e.g."),xc.forEach(t),Dr=p(Z),ut=s(Z,"A",{href:!0});var Fc=d(ut);Xr=a(Fc,"RoBERTa"),Fc.forEach(t),Nr=a(Z,", "),gt=s(Z,"A",{href:!0});var $c=d(gt);qr=a($c,"GPT2"),$c.forEach(t),Yr=a(Z,", "),_t=s(Z,"A",{href:!0});var Rc=d(_t);Ar=a(Rc,"BERT"),Rc.forEach(t),Sr=a(Z,", "),yt=s(Z,"A",{href:!0});var Bc=d(yt);Pr=a(Bc,"DistilBERT"),Bc.forEach(t),Qr=a(Z,")."),Z.forEach(t),ba=p(o),Te=s(o,"P",{});var Pa=d(Te);Hr=a(Pa,`The effectiveness of initializing image-to-text-sequence models with pretrained checkpoints has been shown in (for
example) `),oo=s(Pa,"A",{href:!0,rel:!0});var Ic=d(oo);Lr=a(Ic,"TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models"),Ic.forEach(t),Or=a(Pa,` by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang,
Zhoujun Li, Furu Wei.`),Pa.forEach(t),Ma=p(o),je=s(o,"P",{});var Qa=d(je);Kr=a(Qa,"After such a "),bt=s(Qa,"A",{href:!0});var Cc=d(bt);es=a(Cc,"VisionEncoderDecoderModel"),Cc.forEach(t),os=a(Qa,` has been trained/fine-tuned, it can be saved/loaded just like any other models (see the examples below
for more information).`),Qa.forEach(t),va=p(o),Q=s(o,"P",{});var Lt=d(Q);ts=a(Lt,`An example application is image captioning, in which the encoder is used to encode the image, after which an autoregressive language model generates
the caption. Another example is optical character recognition. Refer to `),Mt=s(Lt,"A",{href:!0});var Gc=d(Mt);ns=a(Gc,"TrOCR"),Gc.forEach(t),as=a(Lt,", which is an instance of "),vt=s(Lt,"A",{href:!0});var zc=d(vt);rs=a(zc,"VisionEncoderDecoderModel"),zc.forEach(t),ss=a(Lt,"."),Lt.forEach(t),wa=p(o),ae=s(o,"H2",{class:!0});var Ha=d(ae);ke=s(Ha,"A",{id:!0,class:!0,href:!0});var Dc=d(ke);fn=s(Dc,"SPAN",{});var Xc=d(fn);v(to.$$.fragment,Xc),Xc.forEach(t),Dc.forEach(t),ds=p(Ha),no=s(Ha,"SPAN",{});var La=d(no);ls=a(La,"Randomly initializing "),un=s(La,"CODE",{});var Nc=d(un);is=a(Nc,"VisionEncoderDecoderModel"),Nc.forEach(t),cs=a(La," from model configurations."),La.forEach(t),Ha.forEach(t),Ta=p(o),A=s(o,"P",{});var at=d(A);wt=s(at,"A",{href:!0});var qc=d(wt);ps=a(qc,"VisionEncoderDecoderModel"),qc.forEach(t),ms=a(at," can be randomly initialized from an encoder and a decoder config. In the following example, we show how to do this using the default "),Tt=s(at,"A",{href:!0});var Yc=d(Tt);hs=a(Yc,"ViTModel"),Yc.forEach(t),fs=a(at,` configuration for the encoder
and the default `),gn=s(at,"CODE",{});var Ac=d(gn);us=a(Ac,"BertForCausalLM"),Ac.forEach(t),gs=a(at," configuration for the decoder."),at.forEach(t),ja=p(o),v(ao.$$.fragment,o),ka=p(o),re=s(o,"H2",{class:!0});var Oa=d(re);Ee=s(Oa,"A",{id:!0,class:!0,href:!0});var Sc=d(Ee);_n=s(Sc,"SPAN",{});var Pc=d(_n);v(ro.$$.fragment,Pc),Pc.forEach(t),Sc.forEach(t),_s=p(Oa),so=s(Oa,"SPAN",{});var Ka=d(so);ys=a(Ka,"Initialising "),yn=s(Ka,"CODE",{});var Qc=d(yn);bs=a(Qc,"VisionEncoderDecoderModel"),Qc.forEach(t),Ms=a(Ka," from a pretrained encoder and a pretrained decoder."),Ka.forEach(t),Oa.forEach(t),Ea=p(o),V=s(o,"P",{});var F=d(V);jt=s(F,"A",{href:!0});var Hc=d(jt);vs=a(Hc,"VisionEncoderDecoderModel"),Hc.forEach(t),ws=a(F," can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained Transformer-based vision model, "),bn=s(F,"EM",{});var Lc=d(bn);Ts=a(Lc,"e.g."),Lc.forEach(t),js=p(F),kt=s(F,"A",{href:!0});var Oc=d(kt);ks=a(Oc,"Swin"),Oc.forEach(t),Es=a(F,", can serve as the encoder and both pretrained auto-encoding models, "),Mn=s(F,"EM",{});var Kc=d(Mn);Zs=a(Kc,"e.g."),Kc.forEach(t),Vs=a(F," BERT, pretrained causal language models, "),vn=s(F,"EM",{});var ep=d(vn);Js=a(ep,"e.g."),ep.forEach(t),Ws=a(F," GPT2, as well as the pretrained decoder part of sequence-to-sequence models, "),wn=s(F,"EM",{});var op=d(wn);Us=a(op,"e.g."),op.forEach(t),xs=a(F,` decoder of BART, can be used as the decoder.
Depending on which architecture you choose as the decoder, the cross-attention layers might be randomly initialized.
Initializing `),Et=s(F,"A",{href:!0});var tp=d(Et);Fs=a(tp,"VisionEncoderDecoderModel"),tp.forEach(t),$s=a(F," from a pretrained encoder and decoder checkpoint requires the model to be fine-tuned on a downstream task, as has been shown in "),Ze=s(F,"A",{href:!0,rel:!0});var kc=d(Ze);Rs=a(kc,"the "),Tn=s(kc,"EM",{});var np=d(Tn);Bs=a(np,"Warm-starting-encoder-decoder blog post"),np.forEach(t),kc.forEach(t),Is=a(F,`.
To do so, the `),jn=s(F,"CODE",{});var ap=d(jn);Cs=a(ap,"VisionEncoderDecoderModel"),ap.forEach(t),Gs=a(F," class provides a "),Zt=s(F,"A",{href:!0});var rp=d(Zt);zs=a(rp,"VisionEncoderDecoderModel.from_encoder_decoder_pretrained()"),rp.forEach(t),Ds=a(F," method."),F.forEach(t),Za=p(o),v(lo.$$.fragment,o),Va=p(o),se=s(o,"H2",{class:!0});var er=d(se);Ve=s(er,"A",{id:!0,class:!0,href:!0});var sp=d(Ve);kn=s(sp,"SPAN",{});var dp=d(kn);v(io.$$.fragment,dp),dp.forEach(t),sp.forEach(t),Xs=p(er),co=s(er,"SPAN",{});var or=d(co);Ns=a(or,"Loading an existing "),En=s(or,"CODE",{});var lp=d(En);qs=a(lp,"VisionEncoderDecoderModel"),lp.forEach(t),Ys=a(or," checkpoint and perform inference."),or.forEach(t),er.forEach(t),Ja=p(o),G=s(o,"P",{});var Pe=d(G);As=a(Pe,"To load fine-tuned checkpoints of the "),Zn=s(Pe,"CODE",{});var ip=d(Zn);Ss=a(ip,"VisionEncoderDecoderModel"),ip.forEach(t),Ps=a(Pe," class, "),Vt=s(Pe,"A",{href:!0});var cp=d(Vt);Qs=a(cp,"VisionEncoderDecoderModel"),cp.forEach(t),Hs=a(Pe," provides the "),Vn=s(Pe,"CODE",{});var pp=d(Vn);Ls=a(pp,"from_pretrained(...)"),pp.forEach(t),Os=a(Pe," method just like any other model architecture in Transformers."),Pe.forEach(t),Wa=p(o),Je=s(o,"P",{});var tr=d(Je);Ks=a(tr,"To perform inference, one uses the "),Jn=s(tr,"CODE",{});var mp=d(Jn);ed=a(mp,"generate"),mp.forEach(t),od=a(tr," method, which allows to autoregressively generate text. This method supports various forms of decoding, such as greedy, beam search and multinomial sampling."),tr.forEach(t),Ua=p(o),v(po.$$.fragment,o),xa=p(o),de=s(o,"H2",{class:!0});var nr=d(de);We=s(nr,"A",{id:!0,class:!0,href:!0});var hp=d(We);Wn=s(hp,"SPAN",{});var fp=d(Wn);v(mo.$$.fragment,fp),fp.forEach(t),hp.forEach(t),td=p(nr),ho=s(nr,"SPAN",{});var ar=d(ho);nd=a(ar,"Loading a PyTorch checkpoint into "),Un=s(ar,"CODE",{});var up=d(Un);ad=a(up,"TFVisionEncoderDecoderModel"),up.forEach(t),rd=a(ar,"."),ar.forEach(t),nr.forEach(t),Fa=p(o),le=s(o,"P",{});var ua=d(le);xn=s(ua,"CODE",{});var gp=d(xn);sd=a(gp,"TFVisionEncoderDecoderModel.from_pretrained()"),gp.forEach(t),dd=a(ua,` currently doesn\u2019t support initializing the model from a
PyTorch checkpoint. Passing `),Fn=s(ua,"CODE",{});var _p=d(Fn);ld=a(_p,"from_pt=True"),_p.forEach(t),id=a(ua,` to this method will throw an exception. If there are only PyTorch
checkpoints for a particular vision encoder-decoder model, a workaround is:`),ua.forEach(t),$a=p(o),v(fo.$$.fragment,o),Ra=p(o),ie=s(o,"H2",{class:!0});var rr=d(ie);Ue=s(rr,"A",{id:!0,class:!0,href:!0});var yp=d(Ue);$n=s(yp,"SPAN",{});var bp=d($n);v(uo.$$.fragment,bp),bp.forEach(t),yp.forEach(t),cd=p(rr),Rn=s(rr,"SPAN",{});var Mp=d(Rn);pd=a(Mp,"Training"),Mp.forEach(t),rr.forEach(t),Ba=p(o),z=s(o,"P",{});var Qe=d(z);md=a(Qe,`Once the model is created, it can be fine-tuned similar to BART, T5 or any other encoder-decoder model on a dataset of (image, text) pairs.
As you can see, only 2 inputs are required for the model in order to compute a loss: `),Bn=s(Qe,"CODE",{});var vp=d(Bn);hd=a(vp,"pixel_values"),vp.forEach(t),fd=a(Qe,` (which are the
images) and `),In=s(Qe,"CODE",{});var wp=d(In);ud=a(wp,"labels"),wp.forEach(t),gd=a(Qe," (which are the "),Cn=s(Qe,"CODE",{});var Tp=d(Cn);_d=a(Tp,"input_ids"),Tp.forEach(t),yd=a(Qe," of the encoded target sequence)."),Qe.forEach(t),Ia=p(o),v(go.$$.fragment,o),Ca=p(o),H=s(o,"P",{});var Ot=d(H);bd=a(Ot,"This model was contributed by "),_o=s(Ot,"A",{href:!0,rel:!0});var jp=d(_o);Md=a(jp,"nielsr"),jp.forEach(t),vd=a(Ot,`. This model\u2019s TensorFlow and Flax versions
were contributed by `),yo=s(Ot,"A",{href:!0,rel:!0});var kp=d(yo);wd=a(kp,"ydshieh"),kp.forEach(t),Td=a(Ot,"."),Ot.forEach(t),Ga=p(o),ce=s(o,"H2",{class:!0});var sr=d(ce);xe=s(sr,"A",{id:!0,class:!0,href:!0});var Ep=d(xe);Gn=s(Ep,"SPAN",{});var Zp=d(Gn);v(bo.$$.fragment,Zp),Zp.forEach(t),Ep.forEach(t),jd=p(sr),zn=s(sr,"SPAN",{});var Vp=d(zn);kd=a(Vp,"VisionEncoderDecoderConfig"),Vp.forEach(t),sr.forEach(t),za=p(o),I=s(o,"DIV",{class:!0});var te=d(I);v(Mo.$$.fragment,te),Ed=p(te),Fe=s(te,"P",{});var ga=d(Fe);Jt=s(ga,"A",{href:!0});var Jp=d(Jt);Zd=a(Jp,"VisionEncoderDecoderConfig"),Jp.forEach(t),Vd=a(ga,` is the configuration class to store the configuration of a
`),Wt=s(ga,"A",{href:!0});var Wp=d(Wt);Jd=a(Wp,"VisionEncoderDecoderModel"),Wp.forEach(t),Wd=a(ga,`. It is used to instantiate a Vision-Encoder-Text-Decoder model according to the
specified arguments, defining the encoder and decoder configs.`),ga.forEach(t),Ud=p(te),pe=s(te,"P",{});var Kt=d(pe);xd=a(Kt,"Configuration objects inherit from "),Ut=s(Kt,"A",{href:!0});var Up=d(Ut);Fd=a(Up,"PretrainedConfig"),Up.forEach(t),$d=a(Kt,` and can be used to control the model outputs. Read the
documentation from `),xt=s(Kt,"A",{href:!0});var xp=d(xt);Rd=a(xp,"PretrainedConfig"),xp.forEach(t),Bd=a(Kt," for more information."),Kt.forEach(t),Id=p(te),v($e.$$.fragment,te),Cd=p(te),Re=s(te,"DIV",{class:!0});var dr=d(Re);v(vo.$$.fragment,dr),Gd=p(dr),wo=s(dr,"P",{});var lr=d(wo);zd=a(lr,"Instantiate a "),Ft=s(lr,"A",{href:!0});var Fp=d(Ft);Dd=a(Fp,"VisionEncoderDecoderConfig"),Fp.forEach(t),Xd=a(lr,` (or a derived class) from a pre-trained encoder model
configuration and decoder model configuration.`),lr.forEach(t),dr.forEach(t),te.forEach(t),Da=p(o),me=s(o,"H2",{class:!0});var ir=d(me);Be=s(ir,"A",{id:!0,class:!0,href:!0});var $p=d(Be);Dn=s($p,"SPAN",{});var Rp=d(Dn);v(To.$$.fragment,Rp),Rp.forEach(t),$p.forEach(t),Nd=p(ir),Xn=s(ir,"SPAN",{});var Bp=d(Xn);qd=a(Bp,"VisionEncoderDecoderModel"),Bp.forEach(t),ir.forEach(t),Xa=p(o),J=s(o,"DIV",{class:!0});var $=d(J);v(jo.$$.fragment,$),Yd=p($),he=s($,"P",{});var en=d(he);Ad=a(en,`This class can be used to initialize an image-to-text-sequence model with any pretrained vision autoencoding model
as the encoder and any pretrained text autoregressive model as the decoder. The encoder is loaded via
`),$t=s(en,"A",{href:!0});var Ip=d($t);Sd=a(Ip,"from_pretrained()"),Ip.forEach(t),Pd=a(en," function and the decoder is loaded via "),Rt=s(en,"A",{href:!0});var Cp=d(Rt);Qd=a(Cp,"from_pretrained()"),Cp.forEach(t),Hd=a(en,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like image captioning.`),en.forEach(t),Ld=p($),ko=s($,"P",{});var cr=d(ko);Od=a(cr,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Eo=s(cr,"A",{href:!0,rel:!0});var Gp=d(Eo);Kd=a(Gp,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),Gp.forEach(t),el=a(cr,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),cr.forEach(t),ol=p($),Zo=s($,"P",{});var pr=d(Zo);tl=a(pr,"Additionally, in "),Vo=s(pr,"A",{href:!0,rel:!0});var zp=d(Vo);nl=a(zp,`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),zp.forEach(t),al=a(pr,` it is shown how leveraging large pretrained vision models for optical
character recognition (OCR) yields a significant performance improvement.`),pr.forEach(t),rl=p($),Nn=s($,"P",{});var Dp=d(Nn);sl=a(Dp,`After such a Vision-Encoder-Text-Decoder model has been trained/fine-tuned, it can be saved/loaded just like any
other models (see the examples for more information).`),Dp.forEach(t),dl=p($),Jo=s($,"P",{});var mr=d(Jo);ll=a(mr,"This model inherits from "),Bt=s(mr,"A",{href:!0});var Xp=d(Bt);il=a(Xp,"PreTrainedModel"),Xp.forEach(t),cl=a(mr,`. 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.)`),mr.forEach(t),pl=p($),Wo=s($,"P",{});var hr=d(Wo);ml=a(hr,"This model is also a PyTorch "),Uo=s(hr,"A",{href:!0,rel:!0});var Np=d(Uo);hl=a(Np,"torch.nn.Module"),Np.forEach(t),fl=a(hr,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),hr.forEach(t),ul=p($),L=s($,"P",{});var rt=d(L);It=s(rt,"A",{href:!0});var qp=d(It);gl=a(qp,"VisionEncoderDecoderModel"),qp.forEach(t),_l=a(rt,` is a generic model class that will be instantiated as a transformer architecture with
one of the base vision model classes of the library as encoder and another one as decoder when created with the
:meth`),qn=s(rt,"EM",{});var Yp=d(qn);yl=a(Yp,"~transformers.AutoModel.from_pretrained"),Yp.forEach(t),bl=a(rt,` class method for the encoder and
:meth`),Yn=s(rt,"EM",{});var Ap=d(Yn);Ml=a(Ap,"~transformers.AutoModelForCausalLM.from_pretrained"),Ap.forEach(t),vl=a(rt," class method for the decoder."),rt.forEach(t),wl=p($),D=s($,"DIV",{class:!0});var He=d(D);v(xo.$$.fragment,He),Tl=p(He),fe=s(He,"P",{});var on=d(fe);jl=a(on,"The "),Ct=s(on,"A",{href:!0});var Sp=d(Ct);kl=a(Sp,"VisionEncoderDecoderModel"),Sp.forEach(t),El=a(on," forward method, overrides the "),An=s(on,"CODE",{});var Pp=d(An);Zl=a(Pp,"__call__"),Pp.forEach(t),Vl=a(on," special method."),on.forEach(t),Jl=p(He),v(Ie.$$.fragment,He),Wl=p(He),v(Ce.$$.fragment,He),He.forEach(t),Ul=p($),X=s($,"DIV",{class:!0});var Le=d(X);v(Fo.$$.fragment,Le),xl=p(Le),Sn=s(Le,"P",{});var Qp=d(Sn);Fl=a(Qp,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Qp.forEach(t),$l=p(Le),ue=s(Le,"P",{});var tn=d(ue);Rl=a(tn,"The model is set in evaluation mode by default using "),Pn=s(tn,"CODE",{});var Hp=d(Pn);Bl=a(Hp,"model.eval()"),Hp.forEach(t),Il=a(tn,` (Dropout modules are deactivated). To train
the model, you need to first set it back in training mode with `),Qn=s(tn,"CODE",{});var Lp=d(Qn);Cl=a(Lp,"model.train()"),Lp.forEach(t),Gl=a(tn,"."),tn.forEach(t),zl=p(Le),v(Ge.$$.fragment,Le),Le.forEach(t),$.forEach(t),Na=p(o),ge=s(o,"H2",{class:!0});var fr=d(ge);ze=s(fr,"A",{id:!0,class:!0,href:!0});var Op=d(ze);Hn=s(Op,"SPAN",{});var Kp=d(Hn);v($o.$$.fragment,Kp),Kp.forEach(t),Op.forEach(t),Dl=p(fr),Ln=s(fr,"SPAN",{});var em=d(Ln);Xl=a(em,"TFVisionEncoderDecoderModel"),em.forEach(t),fr.forEach(t),qa=p(o),W=s(o,"DIV",{class:!0});var R=d(W);v(Ro.$$.fragment,R),Nl=p(R),_e=s(R,"P",{});var nn=d(_e);ql=a(nn,`This class can be used to initialize an image-to-text-sequence model with any pretrained vision autoencoding model
as the encoder and any pretrained text autoregressive model as the decoder. The encoder is loaded via
`),Gt=s(nn,"A",{href:!0});var om=d(Gt);Yl=a(om,"from_pretrained()"),om.forEach(t),Al=a(nn," function and the decoder is loaded via "),zt=s(nn,"A",{href:!0});var tm=d(zt);Sl=a(tm,"from_pretrained()"),tm.forEach(t),Pl=a(nn,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like image captioning.`),nn.forEach(t),Ql=p(R),Bo=s(R,"P",{});var ur=d(Bo);Hl=a(ur,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Io=s(ur,"A",{href:!0,rel:!0});var nm=d(Io);Ll=a(nm,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),nm.forEach(t),Ol=a(ur,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),ur.forEach(t),Kl=p(R),Co=s(R,"P",{});var gr=d(Co);ei=a(gr,"Additionally, in "),Go=s(gr,"A",{href:!0,rel:!0});var am=d(Go);oi=a(am,`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),am.forEach(t),ti=a(gr,` it is shown how leveraging large pretrained vision models for optical
character recognition (OCR) yields a significant performance improvement.`),gr.forEach(t),ni=p(R),On=s(R,"P",{});var rm=d(On);ai=a(rm,`After such a Vision-Encoder-Text-Decoder model has been trained/fine-tuned, it can be saved/loaded just like any
other models (see the examples for more information).`),rm.forEach(t),ri=p(R),zo=s(R,"P",{});var _r=d(zo);si=a(_r,"This model inherits from "),Dt=s(_r,"A",{href:!0});var sm=d(Dt);di=a(sm,"TFPreTrainedModel"),sm.forEach(t),li=a(_r,`. 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.)`),_r.forEach(t),ii=p(R),Do=s(R,"P",{});var yr=d(Do);ci=a(yr,"This model is also a "),Xo=s(yr,"A",{href:!0,rel:!0});var dm=d(Xo);pi=a(dm,"tf.keras.Model"),dm.forEach(t),mi=a(yr,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),yr.forEach(t),hi=p(R),O=s(R,"P",{});var st=d(O);Xt=s(st,"A",{href:!0});var lm=d(Xt);fi=a(lm,"TFVisionEncoderDecoderModel"),lm.forEach(t),ui=a(st,` is a generic model class that will be instantiated as a transformer architecture
with one of the base vision model classes of the library as encoder and another one of the base model classes as
decoder when created with the `),Nt=s(st,"A",{href:!0});var im=d(Nt);gi=a(im,"from_pretrained()"),im.forEach(t),_i=a(st,` class method for the encoder and
`),qt=s(st,"A",{href:!0});var cm=d(qt);yi=a(cm,"from_pretrained()"),cm.forEach(t),bi=a(st," class method for the decoder."),st.forEach(t),Mi=p(R),N=s(R,"DIV",{class:!0});var Oe=d(N);v(No.$$.fragment,Oe),vi=p(Oe),ye=s(Oe,"P",{});var an=d(ye);wi=a(an,"The "),Yt=s(an,"A",{href:!0});var pm=d(Yt);Ti=a(pm,"TFVisionEncoderDecoderModel"),pm.forEach(t),ji=a(an," forward method, overrides the "),Kn=s(an,"CODE",{});var mm=d(Kn);ki=a(mm,"__call__"),mm.forEach(t),Ei=a(an," special method."),an.forEach(t),Zi=p(Oe),v(De.$$.fragment,Oe),Vi=p(Oe),v(Xe.$$.fragment,Oe),Oe.forEach(t),Ji=p(R),K=s(R,"DIV",{class:!0});var rn=d(K);v(qo.$$.fragment,rn),Wi=p(rn),ea=s(rn,"P",{});var hm=d(ea);Ui=a(hm,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),hm.forEach(t),xi=p(rn),v(Ne.$$.fragment,rn),rn.forEach(t),R.forEach(t),Ya=p(o),be=s(o,"H2",{class:!0});var br=d(be);qe=s(br,"A",{id:!0,class:!0,href:!0});var fm=d(qe);oa=s(fm,"SPAN",{});var um=d(oa);v(Yo.$$.fragment,um),um.forEach(t),fm.forEach(t),Fi=p(br),ta=s(br,"SPAN",{});var gm=d(ta);$i=a(gm,"FlaxVisionEncoderDecoderModel"),gm.forEach(t),br.forEach(t),Aa=p(o),U=s(o,"DIV",{class:!0});var B=d(U);v(Ao.$$.fragment,B),Ri=p(B),Me=s(B,"P",{});var sn=d(Me);Bi=a(sn,`This class can be used to initialize an image-to-text-sequence model with any pretrained vision autoencoding model
as the encoder and any pretrained text autoregressive model as the decoder. The encoder is loaded via
`),At=s(sn,"A",{href:!0});var _m=d(At);Ii=a(_m,"from_pretrained()"),_m.forEach(t),Ci=a(sn," function and the decoder is loaded via "),St=s(sn,"A",{href:!0});var ym=d(St);Gi=a(ym,"from_pretrained()"),ym.forEach(t),zi=a(sn,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like image captioning.`),sn.forEach(t),Di=p(B),So=s(B,"P",{});var Mr=d(So);Xi=a(Mr,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Po=s(Mr,"A",{href:!0,rel:!0});var bm=d(Po);Ni=a(bm,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),bm.forEach(t),qi=a(Mr,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),Mr.forEach(t),Yi=p(B),Qo=s(B,"P",{});var vr=d(Qo);Ai=a(vr,"Additionally, in "),Ho=s(vr,"A",{href:!0,rel:!0});var Mm=d(Ho);Si=a(Mm,`TrOCR: Transformer-based Optical Character Recognition with Pre-trained
Models`),Mm.forEach(t),Pi=a(vr,` it is shown how leveraging large pretrained vision models for optical
character recognition (OCR) yields a significant performance improvement.`),vr.forEach(t),Qi=p(B),na=s(B,"P",{});var vm=d(na);Hi=a(vm,`After such a Vision-Encoder-Text-Decoder model has been trained/fine-tuned, it can be saved/loaded just like any
other models (see the examples for more information).`),vm.forEach(t),Li=p(B),Lo=s(B,"P",{});var wr=d(Lo);Oi=a(wr,"This model inherits from "),Pt=s(wr,"A",{href:!0});var wm=d(Pt);Ki=a(wm,"FlaxPreTrainedModel"),wm.forEach(t),ec=a(wr,`. 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.)`),wr.forEach(t),oc=p(B),Oo=s(B,"P",{});var Tr=d(Oo);tc=a(Tr,`This model is also a Flax Linen
`),Ko=s(Tr,"A",{href:!0,rel:!0});var Tm=d(Ko);nc=a(Tm,"flax.nn.Module"),Tm.forEach(t),ac=a(Tr,` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),Tr.forEach(t),rc=p(B),ee=s(B,"P",{});var dt=d(ee);Qt=s(dt,"A",{href:!0});var jm=d(Qt);sc=a(jm,"FlaxVisionEncoderDecoderModel"),jm.forEach(t),dc=a(dt,` is a generic model class that will be instantiated as a transformer architecture
with the module (flax.nn.Module) of one of the base vision model classes of the library as encoder module and
another one as decoder module when created with the :meth`),aa=s(dt,"EM",{});var km=d(aa);lc=a(km,"~transformers.FlaxAutoModel.from_pretrained"),km.forEach(t),ic=a(dt,` class method
for the encoder and :meth`),ra=s(dt,"EM",{});var Em=d(ra);cc=a(Em,"~transformers.FlaxAutoModelForCausalLM.from_pretrained"),Em.forEach(t),pc=a(dt," class method for the decoder."),dt.forEach(t),mc=p(B),q=s(B,"DIV",{class:!0});var Ke=d(q);v(et.$$.fragment,Ke),hc=p(Ke),ve=s(Ke,"P",{});var dn=d(ve);fc=a(dn,"The "),Ht=s(dn,"A",{href:!0});var Zm=d(Ht);uc=a(Zm,"FlaxVisionEncoderDecoderModel"),Zm.forEach(t),gc=a(dn," forward method, overrides the "),sa=s(dn,"CODE",{});var Vm=d(sa);_c=a(Vm,"__call__"),Vm.forEach(t),yc=a(dn," special method."),dn.forEach(t),bc=p(Ke),v(Ye.$$.fragment,Ke),Mc=p(Ke),v(Ae.$$.fragment,Ke),Ke.forEach(t),vc=p(B),oe=s(B,"DIV",{class:!0});var ln=d(oe);v(ot.$$.fragment,ln),wc=p(ln),da=s(ln,"P",{});var Jm=d(da);Tc=a(Jm,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Jm.forEach(t),jc=p(ln),v(Se.$$.fragment,ln),ln.forEach(t),B.forEach(t),this.h()},h(){i(h,"name","hf:doc:metadata"),i(h,"content",JSON.stringify(Am)),i(f,"id","vision-encoder-decoder-models"),i(f,"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"),i(f,"href","#vision-encoder-decoder-models"),i(_,"class","relative group"),i(we,"id","overview"),i(we,"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"),i(we,"href","#overview"),i(ne,"class","relative group"),i(ct,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(pt,"href","vit"),i(mt,"href","beit"),i(ht,"href","deit"),i(ft,"href","swin"),i(ut,"href","roberta"),i(gt,"href","gpt2"),i(_t,"href","bert"),i(yt,"href","distilbert"),i(oo,"href","https://arxiv.org/abs/2109.10282"),i(oo,"rel","nofollow"),i(bt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(Mt,"href","trocr"),i(vt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(ke,"id","randomly-initializing-visionencoderdecodermodel-from-model-configurations"),i(ke,"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"),i(ke,"href","#randomly-initializing-visionencoderdecodermodel-from-model-configurations"),i(ae,"class","relative group"),i(wt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(Tt,"href","/docs/transformers/v4.33.0/en/model_doc/vit#transformers.ViTModel"),i(Ee,"id","initialising-visionencoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder"),i(Ee,"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"),i(Ee,"href","#initialising-visionencoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder"),i(re,"class","relative group"),i(jt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(kt,"href","swin"),i(Et,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(Ze,"href","https://huggingface.co/blog/warm-starting-encoder-decoder"),i(Ze,"rel","nofollow"),i(Zt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel.from_encoder_decoder_pretrained"),i(Ve,"id","loading-an-existing-visionencoderdecodermodel-checkpoint-and-perform-inference"),i(Ve,"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"),i(Ve,"href","#loading-an-existing-visionencoderdecodermodel-checkpoint-and-perform-inference"),i(se,"class","relative group"),i(Vt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(We,"id","loading-a-pytorch-checkpoint-into-tfvisionencoderdecodermodel"),i(We,"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"),i(We,"href","#loading-a-pytorch-checkpoint-into-tfvisionencoderdecodermodel"),i(de,"class","relative group"),i(Ue,"id","training"),i(Ue,"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"),i(Ue,"href","#training"),i(ie,"class","relative group"),i(_o,"href","https://github.com/nielsrogge"),i(_o,"rel","nofollow"),i(yo,"href","https://github.com/ydshieh"),i(yo,"rel","nofollow"),i(xe,"id","transformers.VisionEncoderDecoderConfig"),i(xe,"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"),i(xe,"href","#transformers.VisionEncoderDecoderConfig"),i(ce,"class","relative group"),i(Jt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig"),i(Wt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(Ut,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),i(xt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),i(Ft,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderConfig"),i(Re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Be,"id","transformers.VisionEncoderDecoderModel"),i(Be,"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"),i(Be,"href","#transformers.VisionEncoderDecoderModel"),i(me,"class","relative group"),i($t,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),i(Rt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),i(Eo,"href","https://arxiv.org/abs/1907.12461"),i(Eo,"rel","nofollow"),i(Vo,"href","https://arxiv.org/abs/2109.10282"),i(Vo,"rel","nofollow"),i(Bt,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel"),i(Uo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),i(Uo,"rel","nofollow"),i(It,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(Ct,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.VisionEncoderDecoderModel"),i(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(ze,"id","transformers.TFVisionEncoderDecoderModel"),i(ze,"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"),i(ze,"href","#transformers.TFVisionEncoderDecoderModel"),i(ge,"class","relative group"),i(Gt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),i(zt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),i(Io,"href","https://arxiv.org/abs/1907.12461"),i(Io,"rel","nofollow"),i(Go,"href","https://arxiv.org/abs/2109.10282"),i(Go,"rel","nofollow"),i(Dt,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel"),i(Xo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),i(Xo,"rel","nofollow"),i(Xt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.TFVisionEncoderDecoderModel"),i(Nt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),i(qt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),i(Yt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.TFVisionEncoderDecoderModel"),i(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(qe,"id","transformers.FlaxVisionEncoderDecoderModel"),i(qe,"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"),i(qe,"href","#transformers.FlaxVisionEncoderDecoderModel"),i(be,"class","relative group"),i(At,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),i(St,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),i(Po,"href","https://arxiv.org/abs/1907.12461"),i(Po,"rel","nofollow"),i(Ho,"href","https://arxiv.org/abs/2109.10282"),i(Ho,"rel","nofollow"),i(Pt,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel"),i(Ko,"href","https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html"),i(Ko,"rel","nofollow"),i(Qt,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.FlaxVisionEncoderDecoderModel"),i(Ht,"href","/docs/transformers/v4.33.0/en/model_doc/vision-encoder-decoder#transformers.FlaxVisionEncoderDecoderModel"),i(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,m){e(document.head,h),u(o,b,m),u(o,_,m),e(_,f),e(f,y),w(l,y,null),e(_,g),e(_,C),e(C,jr),u(o,_a,m),u(o,ne,m),e(ne,we),e(we,cn),w(eo,cn,null),e(ne,kr),e(ne,pn),e(pn,Er),u(o,ya,m),u(o,E,m),e(E,Zr),e(E,ct),e(ct,Vr),e(E,Jr),e(E,mn),e(mn,Wr),e(E,Ur),e(E,pt),e(pt,xr),e(E,Fr),e(E,mt),e(mt,$r),e(E,Rr),e(E,ht),e(ht,Br),e(E,Ir),e(E,ft),e(ft,Cr),e(E,Gr),e(E,hn),e(hn,zr),e(E,Dr),e(E,ut),e(ut,Xr),e(E,Nr),e(E,gt),e(gt,qr),e(E,Yr),e(E,_t),e(_t,Ar),e(E,Sr),e(E,yt),e(yt,Pr),e(E,Qr),u(o,ba,m),u(o,Te,m),e(Te,Hr),e(Te,oo),e(oo,Lr),e(Te,Or),u(o,Ma,m),u(o,je,m),e(je,Kr),e(je,bt),e(bt,es),e(je,os),u(o,va,m),u(o,Q,m),e(Q,ts),e(Q,Mt),e(Mt,ns),e(Q,as),e(Q,vt),e(vt,rs),e(Q,ss),u(o,wa,m),u(o,ae,m),e(ae,ke),e(ke,fn),w(to,fn,null),e(ae,ds),e(ae,no),e(no,ls),e(no,un),e(un,is),e(no,cs),u(o,Ta,m),u(o,A,m),e(A,wt),e(wt,ps),e(A,ms),e(A,Tt),e(Tt,hs),e(A,fs),e(A,gn),e(gn,us),e(A,gs),u(o,ja,m),w(ao,o,m),u(o,ka,m),u(o,re,m),e(re,Ee),e(Ee,_n),w(ro,_n,null),e(re,_s),e(re,so),e(so,ys),e(so,yn),e(yn,bs),e(so,Ms),u(o,Ea,m),u(o,V,m),e(V,jt),e(jt,vs),e(V,ws),e(V,bn),e(bn,Ts),e(V,js),e(V,kt),e(kt,ks),e(V,Es),e(V,Mn),e(Mn,Zs),e(V,Vs),e(V,vn),e(vn,Js),e(V,Ws),e(V,wn),e(wn,Us),e(V,xs),e(V,Et),e(Et,Fs),e(V,$s),e(V,Ze),e(Ze,Rs),e(Ze,Tn),e(Tn,Bs),e(V,Is),e(V,jn),e(jn,Cs),e(V,Gs),e(V,Zt),e(Zt,zs),e(V,Ds),u(o,Za,m),w(lo,o,m),u(o,Va,m),u(o,se,m),e(se,Ve),e(Ve,kn),w(io,kn,null),e(se,Xs),e(se,co),e(co,Ns),e(co,En),e(En,qs),e(co,Ys),u(o,Ja,m),u(o,G,m),e(G,As),e(G,Zn),e(Zn,Ss),e(G,Ps),e(G,Vt),e(Vt,Qs),e(G,Hs),e(G,Vn),e(Vn,Ls),e(G,Os),u(o,Wa,m),u(o,Je,m),e(Je,Ks),e(Je,Jn),e(Jn,ed),e(Je,od),u(o,Ua,m),w(po,o,m),u(o,xa,m),u(o,de,m),e(de,We),e(We,Wn),w(mo,Wn,null),e(de,td),e(de,ho),e(ho,nd),e(ho,Un),e(Un,ad),e(ho,rd),u(o,Fa,m),u(o,le,m),e(le,xn),e(xn,sd),e(le,dd),e(le,Fn),e(Fn,ld),e(le,id),u(o,$a,m),w(fo,o,m),u(o,Ra,m),u(o,ie,m),e(ie,Ue),e(Ue,$n),w(uo,$n,null),e(ie,cd),e(ie,Rn),e(Rn,pd),u(o,Ba,m),u(o,z,m),e(z,md),e(z,Bn),e(Bn,hd),e(z,fd),e(z,In),e(In,ud),e(z,gd),e(z,Cn),e(Cn,_d),e(z,yd),u(o,Ia,m),w(go,o,m),u(o,Ca,m),u(o,H,m),e(H,bd),e(H,_o),e(_o,Md),e(H,vd),e(H,yo),e(yo,wd),e(H,Td),u(o,Ga,m),u(o,ce,m),e(ce,xe),e(xe,Gn),w(bo,Gn,null),e(ce,jd),e(ce,zn),e(zn,kd),u(o,za,m),u(o,I,m),w(Mo,I,null),e(I,Ed),e(I,Fe),e(Fe,Jt),e(Jt,Zd),e(Fe,Vd),e(Fe,Wt),e(Wt,Jd),e(Fe,Wd),e(I,Ud),e(I,pe),e(pe,xd),e(pe,Ut),e(Ut,Fd),e(pe,$d),e(pe,xt),e(xt,Rd),e(pe,Bd),e(I,Id),w($e,I,null),e(I,Cd),e(I,Re),w(vo,Re,null),e(Re,Gd),e(Re,wo),e(wo,zd),e(wo,Ft),e(Ft,Dd),e(wo,Xd),u(o,Da,m),u(o,me,m),e(me,Be),e(Be,Dn),w(To,Dn,null),e(me,Nd),e(me,Xn),e(Xn,qd),u(o,Xa,m),u(o,J,m),w(jo,J,null),e(J,Yd),e(J,he),e(he,Ad),e(he,$t),e($t,Sd),e(he,Pd),e(he,Rt),e(Rt,Qd),e(he,Hd),e(J,Ld),e(J,ko),e(ko,Od),e(ko,Eo),e(Eo,Kd),e(ko,el),e(J,ol),e(J,Zo),e(Zo,tl),e(Zo,Vo),e(Vo,nl),e(Zo,al),e(J,rl),e(J,Nn),e(Nn,sl),e(J,dl),e(J,Jo),e(Jo,ll),e(Jo,Bt),e(Bt,il),e(Jo,cl),e(J,pl),e(J,Wo),e(Wo,ml),e(Wo,Uo),e(Uo,hl),e(Wo,fl),e(J,ul),e(J,L),e(L,It),e(It,gl),e(L,_l),e(L,qn),e(qn,yl),e(L,bl),e(L,Yn),e(Yn,Ml),e(L,vl),e(J,wl),e(J,D),w(xo,D,null),e(D,Tl),e(D,fe),e(fe,jl),e(fe,Ct),e(Ct,kl),e(fe,El),e(fe,An),e(An,Zl),e(fe,Vl),e(D,Jl),w(Ie,D,null),e(D,Wl),w(Ce,D,null),e(J,Ul),e(J,X),w(Fo,X,null),e(X,xl),e(X,Sn),e(Sn,Fl),e(X,$l),e(X,ue),e(ue,Rl),e(ue,Pn),e(Pn,Bl),e(ue,Il),e(ue,Qn),e(Qn,Cl),e(ue,Gl),e(X,zl),w(Ge,X,null),u(o,Na,m),u(o,ge,m),e(ge,ze),e(ze,Hn),w($o,Hn,null),e(ge,Dl),e(ge,Ln),e(Ln,Xl),u(o,qa,m),u(o,W,m),w(Ro,W,null),e(W,Nl),e(W,_e),e(_e,ql),e(_e,Gt),e(Gt,Yl),e(_e,Al),e(_e,zt),e(zt,Sl),e(_e,Pl),e(W,Ql),e(W,Bo),e(Bo,Hl),e(Bo,Io),e(Io,Ll),e(Bo,Ol),e(W,Kl),e(W,Co),e(Co,ei),e(Co,Go),e(Go,oi),e(Co,ti),e(W,ni),e(W,On),e(On,ai),e(W,ri),e(W,zo),e(zo,si),e(zo,Dt),e(Dt,di),e(zo,li),e(W,ii),e(W,Do),e(Do,ci),e(Do,Xo),e(Xo,pi),e(Do,mi),e(W,hi),e(W,O),e(O,Xt),e(Xt,fi),e(O,ui),e(O,Nt),e(Nt,gi),e(O,_i),e(O,qt),e(qt,yi),e(O,bi),e(W,Mi),e(W,N),w(No,N,null),e(N,vi),e(N,ye),e(ye,wi),e(ye,Yt),e(Yt,Ti),e(ye,ji),e(ye,Kn),e(Kn,ki),e(ye,Ei),e(N,Zi),w(De,N,null),e(N,Vi),w(Xe,N,null),e(W,Ji),e(W,K),w(qo,K,null),e(K,Wi),e(K,ea),e(ea,Ui),e(K,xi),w(Ne,K,null),u(o,Ya,m),u(o,be,m),e(be,qe),e(qe,oa),w(Yo,oa,null),e(be,Fi),e(be,ta),e(ta,$i),u(o,Aa,m),u(o,U,m),w(Ao,U,null),e(U,Ri),e(U,Me),e(Me,Bi),e(Me,At),e(At,Ii),e(Me,Ci),e(Me,St),e(St,Gi),e(Me,zi),e(U,Di),e(U,So),e(So,Xi),e(So,Po),e(Po,Ni),e(So,qi),e(U,Yi),e(U,Qo),e(Qo,Ai),e(Qo,Ho),e(Ho,Si),e(Qo,Pi),e(U,Qi),e(U,na),e(na,Hi),e(U,Li),e(U,Lo),e(Lo,Oi),e(Lo,Pt),e(Pt,Ki),e(Lo,ec),e(U,oc),e(U,Oo),e(Oo,tc),e(Oo,Ko),e(Ko,nc),e(Oo,ac),e(U,rc),e(U,ee),e(ee,Qt),e(Qt,sc),e(ee,dc),e(ee,aa),e(aa,lc),e(ee,ic),e(ee,ra),e(ra,cc),e(ee,pc),e(U,mc),e(U,q),w(et,q,null),e(q,hc),e(q,ve),e(ve,fc),e(ve,Ht),e(Ht,uc),e(ve,gc),e(ve,sa),e(sa,_c),e(ve,yc),e(q,bc),w(Ye,q,null),e(q,Mc),w(Ae,q,null),e(U,vc),e(U,oe),w(ot,oe,null),e(oe,wc),e(oe,da),e(da,Tc),e(oe,jc),w(Se,oe,null),Sa=!0},p(o,[m]){const tt={};m&2&&(tt.$$scope={dirty:m,ctx:o}),$e.$set(tt);const la={};m&2&&(la.$$scope={dirty:m,ctx:o}),Ie.$set(la);const ia={};m&2&&(ia.$$scope={dirty:m,ctx:o}),Ce.$set(ia);const ca={};m&2&&(ca.$$scope={dirty:m,ctx:o}),Ge.$set(ca);const nt={};m&2&&(nt.$$scope={dirty:m,ctx:o}),De.$set(nt);const pa={};m&2&&(pa.$$scope={dirty:m,ctx:o}),Xe.$set(pa);const ma={};m&2&&(ma.$$scope={dirty:m,ctx:o}),Ne.$set(ma);const ha={};m&2&&(ha.$$scope={dirty:m,ctx:o}),Ye.$set(ha);const Z={};m&2&&(Z.$$scope={dirty:m,ctx:o}),Ae.$set(Z);const fa={};m&2&&(fa.$$scope={dirty:m,ctx:o}),Se.$set(fa)},i(o){Sa||(T(l.$$.fragment,o),T(eo.$$.fragment,o),T(to.$$.fragment,o),T(ao.$$.fragment,o),T(ro.$$.fragment,o),T(lo.$$.fragment,o),T(io.$$.fragment,o),T(po.$$.fragment,o),T(mo.$$.fragment,o),T(fo.$$.fragment,o),T(uo.$$.fragment,o),T(go.$$.fragment,o),T(bo.$$.fragment,o),T(Mo.$$.fragment,o),T($e.$$.fragment,o),T(vo.$$.fragment,o),T(To.$$.fragment,o),T(jo.$$.fragment,o),T(xo.$$.fragment,o),T(Ie.$$.fragment,o),T(Ce.$$.fragment,o),T(Fo.$$.fragment,o),T(Ge.$$.fragment,o),T($o.$$.fragment,o),T(Ro.$$.fragment,o),T(No.$$.fragment,o),T(De.$$.fragment,o),T(Xe.$$.fragment,o),T(qo.$$.fragment,o),T(Ne.$$.fragment,o),T(Yo.$$.fragment,o),T(Ao.$$.fragment,o),T(et.$$.fragment,o),T(Ye.$$.fragment,o),T(Ae.$$.fragment,o),T(ot.$$.fragment,o),T(Se.$$.fragment,o),Sa=!0)},o(o){j(l.$$.fragment,o),j(eo.$$.fragment,o),j(to.$$.fragment,o),j(ao.$$.fragment,o),j(ro.$$.fragment,o),j(lo.$$.fragment,o),j(io.$$.fragment,o),j(po.$$.fragment,o),j(mo.$$.fragment,o),j(fo.$$.fragment,o),j(uo.$$.fragment,o),j(go.$$.fragment,o),j(bo.$$.fragment,o),j(Mo.$$.fragment,o),j($e.$$.fragment,o),j(vo.$$.fragment,o),j(To.$$.fragment,o),j(jo.$$.fragment,o),j(xo.$$.fragment,o),j(Ie.$$.fragment,o),j(Ce.$$.fragment,o),j(Fo.$$.fragment,o),j(Ge.$$.fragment,o),j($o.$$.fragment,o),j(Ro.$$.fragment,o),j(No.$$.fragment,o),j(De.$$.fragment,o),j(Xe.$$.fragment,o),j(qo.$$.fragment,o),j(Ne.$$.fragment,o),j(Yo.$$.fragment,o),j(Ao.$$.fragment,o),j(et.$$.fragment,o),j(Ye.$$.fragment,o),j(Ae.$$.fragment,o),j(ot.$$.fragment,o),j(Se.$$.fragment,o),Sa=!1},d(o){t(h),o&&t(b),o&&t(_),k(l),o&&t(_a),o&&t(ne),k(eo),o&&t(ya),o&&t(E),o&&t(ba),o&&t(Te),o&&t(Ma),o&&t(je),o&&t(va),o&&t(Q),o&&t(wa),o&&t(ae),k(to),o&&t(Ta),o&&t(A),o&&t(ja),k(ao,o),o&&t(ka),o&&t(re),k(ro),o&&t(Ea),o&&t(V),o&&t(Za),k(lo,o),o&&t(Va),o&&t(se),k(io),o&&t(Ja),o&&t(G),o&&t(Wa),o&&t(Je),o&&t(Ua),k(po,o),o&&t(xa),o&&t(de),k(mo),o&&t(Fa),o&&t(le),o&&t($a),k(fo,o),o&&t(Ra),o&&t(ie),k(uo),o&&t(Ba),o&&t(z),o&&t(Ia),k(go,o),o&&t(Ca),o&&t(H),o&&t(Ga),o&&t(ce),k(bo),o&&t(za),o&&t(I),k(Mo),k($e),k(vo),o&&t(Da),o&&t(me),k(To),o&&t(Xa),o&&t(J),k(jo),k(xo),k(Ie),k(Ce),k(Fo),k(Ge),o&&t(Na),o&&t(ge),k($o),o&&t(qa),o&&t(W),k(Ro),k(No),k(De),k(Xe),k(qo),k(Ne),o&&t(Ya),o&&t(be),k(Yo),o&&t(Aa),o&&t(U),k(Ao),k(et),k(Ye),k(Ae),k(ot),k(Se)}}}const Am={local:"vision-encoder-decoder-models",sections:[{local:"overview",title:"Overview"},{local:"randomly-initializing-visionencoderdecodermodel-from-model-configurations",title:"Randomly initializing `VisionEncoderDecoderModel` from model configurations."},{local:"initialising-visionencoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder",title:"Initialising `VisionEncoderDecoderModel` from a pretrained encoder and a pretrained decoder."},{local:"loading-an-existing-visionencoderdecodermodel-checkpoint-and-perform-inference",title:"Loading an existing `VisionEncoderDecoderModel` checkpoint and perform inference."},{local:"loading-a-pytorch-checkpoint-into-tfvisionencoderdecodermodel",title:"Loading a PyTorch checkpoint into `TFVisionEncoderDecoderModel`."},{local:"training",title:"Training"},{local:"transformers.VisionEncoderDecoderConfig",title:"VisionEncoderDecoderConfig"},{local:"transformers.VisionEncoderDecoderModel",title:"VisionEncoderDecoderModel"},{local:"transformers.TFVisionEncoderDecoderModel",title:"TFVisionEncoderDecoderModel"},{local:"transformers.FlaxVisionEncoderDecoderModel",title:"FlaxVisionEncoderDecoderModel"}],title:"Vision Encoder Decoder Models"};function Sm(x){return $m(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class eh extends Wm{constructor(h){super();Um(this,h,Sm,Ym,xm,{})}}export{eh as default,Am as metadata};
