import{S as Xp,i as Sp,s as Yp,e as a,k as i,w as b,t as n,M as Ap,c as s,d as t,m as p,a as d,x as M,h as r,b as c,G as e,g as u,y as v,q as w,o as T,B as k,v as Hp,L as ct}from"../../chunks/vendor-hf-doc-builder.js";import{T as Qc}from"../../chunks/Tip-hf-doc-builder.js";import{D as X}from"../../chunks/Docstring-hf-doc-builder.js";import{C as S}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as A}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as lt}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Pp(W){let h,J,_,f,y;return f=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBFbmNvZGVyRGVjb2RlckNvbmZpZyUyQyUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwQkVSVCUyMGJlcnQtYmFzZS11bmNhc2VkJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlnX2VuY29kZXIlMjAlM0QlMjBCZXJ0Q29uZmlnKCklMEFjb25maWdfZGVjb2RlciUyMCUzRCUyMEJlcnRDb25maWcoKSUwQSUwQWNvbmZpZyUyMCUzRCUyMEVuY29kZXJEZWNvZGVyQ29uZmlnLmZyb21fZW5jb2Rlcl9kZWNvZGVyX2NvbmZpZ3MoY29uZmlnX2VuY29kZXIlMkMlMjBjb25maWdfZGVjb2RlciklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwQmVydDJCZXJ0JTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwYmVydC1iYXNlLXVuY2FzZWQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb25zJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsKGNvbmZpZyUzRGNvbmZpZyklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWdfZW5jb2RlciUyMCUzRCUyMG1vZGVsLmNvbmZpZy5lbmNvZGVyJTBBY29uZmlnX2RlY29kZXIlMjAlM0QlMjBtb2RlbC5jb25maWcuZGVjb2RlciUwQSUyMyUyMHNldCUyMGRlY29kZXIlMjBjb25maWclMjB0byUyMGNhdXNhbCUyMGxtJTBBY29uZmlnX2RlY29kZXIuaXNfZGVjb2RlciUyMCUzRCUyMFRydWUlMEFjb25maWdfZGVjb2Rlci5hZGRfY3Jvc3NfYXR0ZW50aW9uJTIwJTNEJTIwVHJ1ZSUwQSUwQSUyMyUyMFNhdmluZyUyMHRoZSUyMG1vZGVsJTJDJTIwaW5jbHVkaW5nJTIwaXRzJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJteS1tb2RlbCUyMiklMEElMEElMjMlMjBsb2FkaW5nJTIwbW9kZWwlMjBhbmQlMjBjb25maWclMjBmcm9tJTIwcHJldHJhaW5lZCUyMGZvbGRlciUwQWVuY29kZXJfZGVjb2Rlcl9jb25maWclMjAlM0QlMjBFbmNvZGVyRGVjb2RlckNvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIybXktbW9kZWwlMjIpJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJteS1tb2RlbCUyMiUyQyUyMGNvbmZpZyUzRGVuY29kZXJfZGVjb2Rlcl9jb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, EncoderDecoderConfig, EncoderDecoderModel

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

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Bert2Bert model from the bert-base-uncased style configurations</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel(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 = EncoderDecoderConfig.from_pretrained(<span class="hljs-string">&quot;my-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;my-model&quot;</span>, config=encoder_decoder_config)`}}),{c(){h=a("p"),J=n("Examples:"),_=i(),b(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);J=r(g,"Examples:"),g.forEach(t),_=p(l),M(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,J),u(l,_,g),v(f,l,g),y=!0},p:ct,i(l){y||(w(f.$$.fragment,l),y=!0)},o(l){T(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Qp(W){let h,J,_,f,y;return{c(){h=a("p"),J=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=a("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);J=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var R=d(_);f=r(R,"Module"),R.forEach(t),y=r(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,J),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function Lp(W){let h,J,_,f,y;return f=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMkMlMjBCZXJ0VG9rZW5pemVyJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBCZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyJTBBKSUyMCUyMCUyMyUyMGluaXRpYWxpemUlMjBCZXJ0MkJlcnQlMjBmcm9tJTIwcHJlLXRyYWluZWQlMjBjaGVja3BvaW50cyUwQSUwQSUyMyUyMHRyYWluaW5nJTBBbW9kZWwuY29uZmlnLmRlY29kZXJfc3RhcnRfdG9rZW5faWQlMjAlM0QlMjB0b2tlbml6ZXIuY2xzX3Rva2VuX2lkJTBBbW9kZWwuY29uZmlnLnBhZF90b2tlbl9pZCUyMCUzRCUyMHRva2VuaXplci5wYWRfdG9rZW5faWQlMEFtb2RlbC5jb25maWcudm9jYWJfc2l6ZSUyMCUzRCUyMG1vZGVsLmNvbmZpZy5kZWNvZGVyLnZvY2FiX3NpemUlMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyVGhpcyUyMGlzJTIwYSUyMHJlYWxseSUyMGxvbmclMjB0ZXh0JTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikuaW5wdXRfaWRzJTBBbGFiZWxzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoaXMlMjBpcyUyMHRoZSUyMGNvcnJlc3BvbmRpbmclMjBzdW1tYXJ5JTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikuaW5wdXRfaWRzJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGxhYmVscyUzRGxhYmVscyklMEFsb3NzJTJDJTIwbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTJDJTIwb3V0cHV0cy5sb2dpdHMlMEElMEElMjMlMjBzYXZlJTIwYW5kJTIwbG9hZCUyMGZyb20lMjBwcmV0cmFpbmVkJTBBbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmJlcnQyYmVydCUyMiklMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQyYmVydCUyMiklMEElMEElMjMlMjBnZW5lcmF0aW9uJTBBZ2VuZXJhdGVkJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> EncoderDecoderModel, BertTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<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 = EncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># initialize Bert2Bert from pre-trained checkpoints</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 = 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>model.config.vocab_size = model.config.decoder.vocab_size

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(<span class="hljs-string">&quot;This is a really long text&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(<span class="hljs-string">&quot;This is the corresponding summary&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, labels=labels)
<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;bert2bert&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;bert2bert&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(input_ids)`}}),{c(){h=a("p"),J=n("Examples:"),_=i(),b(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);J=r(g,"Examples:"),g.forEach(t),_=p(l),M(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,J),u(l,_,g),v(f,l,g),y=!0},p:ct,i(l){y||(w(f.$$.fragment,l),y=!0)},o(l){T(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Op(W){let h,J,_,f,y;return f=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBpbml0aWFsaXplJTIwYSUyMGJlcnQyYmVydCUyMGZyb20lMjB0d28lMjBwcmV0cmFpbmVkJTIwQkVSVCUyMG1vZGVscy4lMjBOb3RlJTIwdGhhdCUyMHRoZSUyMGNyb3NzLWF0dGVudGlvbiUyMGxheWVycyUyMHdpbGwlMjBiZSUyMHJhbmRvbWx5JTIwaW5pdGlhbGl6ZWQlMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQSUyMyUyMHNhdmluZyUyMG1vZGVsJTIwYWZ0ZXIlMjBmaW5lLXR1bmluZyUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGYmVydDJiZXJ0JTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMi4lMkZiZXJ0MmJlcnQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> EncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a bert2bert from two pretrained BERT models. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</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;./bert2bert&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 = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./bert2bert&quot;</span>)`}}),{c(){h=a("p"),J=n("Example:"),_=i(),b(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);J=r(g,"Example:"),g.forEach(t),_=p(l),M(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,J),u(l,_,g),v(f,l,g),y=!0},p:ct,i(l){y||(w(f.$$.fragment,l),y=!0)},o(l){T(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function Kp(W){let h,J,_,f,y;return{c(){h=a("p"),J=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=a("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);J=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var R=d(_);f=r(R,"Module"),R.forEach(t),y=r(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,J),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function em(W){let h,J,_,f,y;return f=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMEElMEElMjMlMjBpbml0aWFsaXplJTIwYSUyMGJlcnQyZ3B0MiUyMGZyb20lMjBhJTIwcHJldHJhaW5lZCUyMEJFUlQlMjBhbmQlMjBHUFQyJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwVEZFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLWNhc2VkJTIyJTJDJTIwJTIyZ3B0MiUyMiklMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBCZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTBBJTIzJTIwZm9yd2FyZCUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplci5lbmNvZGUoJTBBJTIwJTIwJTIwJTIwJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMGFkZF9zcGVjaWFsX3Rva2VucyUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyJTBBKSUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUyMDElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RpbnB1dF9pZHMpJTBBJTBBJTIzJTIwdHJhaW5pbmclMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RpbnB1dF9pZHMlMkMlMjBsYWJlbHMlM0RpbnB1dF9pZHMpJTBBbG9zcyUyQyUyMGxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9zcyUyQyUyMG91dHB1dHMubG9naXRzJTBBJTBBJTIzJTIwc2F2ZSUyMGFuZCUyMGxvYWQlMjBmcm9tJTIwcHJldHJhaW5lZCUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJiZXJ0MmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBURkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQyZ3B0MiUyMiklMEElMEElMjMlMjBnZW5lcmF0aW9uJTBBZ2VuZXJhdGVkJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzJTJDJTIwZGVjb2Rlcl9zdGFydF90b2tlbl9pZCUzRG1vZGVsLmNvbmZpZy5kZWNvZGVyLmJvc190b2tlbl9pZCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFEncoderDecoderModel, BertTokenizer

<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 = TFEncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer.encode(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, add_special_tokens=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, decoder_input_ids=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(input_ids=input_ids, decoder_input_ids=input_ids, labels=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;bert2gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;bert2gpt2&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(input_ids, decoder_start_token_id=model.config.decoder.bos_token_id)`}}),{c(){h=a("p"),J=n("Examples:"),_=i(),b(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);J=r(g,"Examples:"),g.forEach(t),_=p(l),M(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,J),u(l,_,g),v(f,l,g),y=!0},p:ct,i(l){y||(w(f.$$.fragment,l),y=!0)},o(l){T(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function om(W){let h,J,_,f,y;return f=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbCUwQSUwQSUyMyUyMGluaXRpYWxpemUlMjBhJTIwYmVydDJncHQyJTIwZnJvbSUyMHR3byUyMHByZXRyYWluZWQlMjBCRVJUJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwVEZFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjAlMjJncHQyJTIyKSUwQSUyMyUyMHNhdmluZyUyMG1vZGVsJTIwYWZ0ZXIlMjBmaW5lLXR1bmluZyUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyLiUyRmJlcnQyZ3B0MiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a bert2gpt2 from two pretrained BERT models. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFEncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</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;./bert2gpt2&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 = TFEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./bert2gpt2&quot;</span>)`}}),{c(){h=a("p"),J=n("Example:"),_=i(),b(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);J=r(g,"Example:"),g.forEach(t),_=p(l),M(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,J),u(l,_,g),v(f,l,g),y=!0},p:ct,i(l){y||(w(f.$$.fragment,l),y=!0)},o(l){T(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function tm(W){let h,J,_,f,y;return{c(){h=a("p"),J=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=a("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);J=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var R=d(_);f=r(R,"Module"),R.forEach(t),y=r(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,J),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function nm(W){let h,J,_,f,y;return f=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsJTJDJTIwQmVydFRva2VuaXplciUyQyUyMEdQVDJUb2tlbml6ZXIlMEElMEElMjMlMjBsb2FkJTIwYSUyMGZpbmUtdHVuZWQlMjBiZXJ0MmdwdDIlMjBtb2RlbCUwQW1vZGVsJTIwJTNEJTIwRmxheEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdHJpY2t2b25wbGF0ZW4lMkZiZXJ0MmdwdDItY25uX2RhaWx5bWFpbC1mcDE2JTIyKSUwQSUyMyUyMGxvYWQlMjBpbnB1dCUyMCUyNiUyMG91dHB1dCUyMHRva2VuaXplciUwQXRva2VuaXplcl9pbnB1dCUyMCUzRCUyMEJlcnRUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiklMEF0b2tlbml6ZXJfb3V0cHV0JTIwJTNEJTIwR1BUMlRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEElMEFhcnRpY2xlJTIwJTNEJTIwJycnU2lnbWElMjBBbHBoYSUyMEVwc2lsb24lMjBpcyUyMHVuZGVyJTIwZmlyZSUyMGZvciUyMGElMjB2aWRlbyUyMHNob3dpbmclMjBwYXJ0eS1ib3VuZCUyMGZyYXRlcm5pdHklMjBtZW1iZXJzJTBBc2luZ2luZyUyMGElMjByYWNpc3QlMjBjaGFudC4lMjBTQUUncyUyMG5hdGlvbmFsJTIwY2hhcHRlciUyMHN1c3BlbmRlZCUyMHRoZSUyMHN0dWRlbnRzJTJDJTBBYnV0JTIwVW5pdmVyc2l0eSUyMG9mJTIwT2tsYWhvbWElMjBQcmVzaWRlbnQlMjBEYXZpZCUyMEJvcmVuJTIwdG9vayUyMGl0JTIwYSUyMHN0ZXAlMjBmdXJ0aGVyJTJDJTBBc2F5aW5nJTIwdGhlJTIwdW5pdmVyc2l0eSdzJTIwYWZmaWxpYXRpb24lMjB3aXRoJTIwdGhlJTIwZnJhdGVybml0eSUyMGlzJTIwcGVybWFuZW50bHklMjBkb25lLicnJyUwQSUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplcl9pbnB1dChhcnRpY2xlJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIybnAlMjIpLmlucHV0X2lkcyUwQSUwQSUyMyUyMHVzZSUyMEdQVDIncyUyMGVvc190b2tlbiUyMGFzJTIwdGhlJTIwcGFkJTIwYXMlMjB3ZWxsJTIwYXMlMjBlb3MlMjB0b2tlbiUwQW1vZGVsLmNvbmZpZy5lb3NfdG9rZW5faWQlMjAlM0QlMjBtb2RlbC5jb25maWcuZGVjb2Rlci5lb3NfdG9rZW5faWQlMEFtb2RlbC5jb25maWcucGFkX3Rva2VuX2lkJTIwJTNEJTIwbW9kZWwuY29uZmlnLmVvc190b2tlbl9pZCUwQSUwQXNlcXVlbmNlcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0X2lkcyUyQyUyMG51bV9iZWFtcyUzRDQlMkMlMjBtYXhfbGVuZ3RoJTNEMTIpLnNlcXVlbmNlcyUwQSUwQXN1bW1hcnklMjAlM0QlMjB0b2tlbml6ZXJfb3V0cHV0LmJhdGNoX2RlY29kZShzZXF1ZW5jZXMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklNUIwJTVEJTBBYXNzZXJ0JTIwc3VtbWFyeSUyMCUzRCUzRCUyMCUyMlNBUyUyMEFscGhhJTIwRXBzaWxvbiUyMHN1c3BlbmRlZCUyMFNpZ21hJTIwQWxwaGElMjBFcHNpbG9uJTIwbWVtYmVycyUyMg==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxEncoderDecoderModel, BertTokenizer, GPT2Tokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load a fine-tuned bert2gpt2 model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;patrickvonplaten/bert2gpt2-cnn_dailymail-fp16&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load input &amp; output tokenizer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer_input = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer_output = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>article = <span class="hljs-string">&#x27;&#x27;&#x27;Sigma Alpha Epsilon is under fire for a video showing party-bound fraternity members
<span class="hljs-meta">&gt;&gt;&gt; </span>singing a racist chant. SAE&#x27;s national chapter suspended the students,
<span class="hljs-meta">&gt;&gt;&gt; </span>but University of Oklahoma President David Boren took it a step further,
<span class="hljs-meta">&gt;&gt;&gt; </span>saying the university&#x27;s affiliation with the fraternity is permanently done.&#x27;&#x27;&#x27;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer_input(article, add_special_tokens=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;np&quot;</span>).input_ids

<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>sequences = model.generate(input_ids, 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>summary = tokenizer_output.batch_decode(sequences, 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-keyword">assert</span> summary == <span class="hljs-string">&quot;SAS Alpha Epsilon suspended Sigma Alpha Epsilon members&quot;</span>`}}),{c(){h=a("p"),J=n("Examples:"),_=i(),b(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);J=r(g,"Examples:"),g.forEach(t),_=p(l),M(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,J),u(l,_,g),v(f,l,g),y=!0},p:ct,i(l){y||(w(f.$$.fragment,l),y=!0)},o(l){T(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function rm(W){let h,J,_,f,y;return f=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMGElMjBiZXJ0MmdwdDIlMjBmcm9tJTIwcHJldHJhaW5lZCUyMEJFUlQlMjBhbmQlMjBHUFQyJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwRmxheEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIlMkMlMjAlMjJncHQyJTIyKSUwQSUyMyUyMHNhdmluZyUyMG1vZGVsJTIwYWZ0ZXIlMjBmaW5lLXR1bmluZyUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a bert2gpt2 from 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 = FlaxEncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</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;./bert2gpt2&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 = FlaxEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./bert2gpt2&quot;</span>)`}}),{c(){h=a("p"),J=n("Example:"),_=i(),b(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);J=r(g,"Example:"),g.forEach(t),_=p(l),M(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,J),u(l,_,g),v(f,l,g),y=!0},p:ct,i(l){y||(w(f.$$.fragment,l),y=!0)},o(l){T(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),k(f,l)}}}function am(W){let h,J,_,f,y,l,g,R,ga,cr,te,we,en,to,_a,on,ya,ir,Te,ba,it,Ma,va,pr,ke,wa,no,Ta,ka,mr,Je,Ja,pt,Ea,ja,hr,H,Za,mt,Ua,Wa,ro,Ga,Ia,fr,ne,Ee,tn,ao,za,so,Va,nn,$a,Ra,ur,Y,ht,Ba,Fa,ft,Ca,xa,rn,Da,Na,gr,lo,_r,re,je,an,co,qa,io,Xa,sn,Sa,Ya,yr,E,ut,Aa,Ha,dn,Pa,Qa,ln,La,Oa,cn,Ka,es,pn,os,ts,gt,ns,rs,Ze,as,mn,ss,ds,hn,ls,cs,_t,is,ps,br,po,Mr,ae,Ue,fn,mo,ms,ho,hs,un,fs,us,vr,F,gs,gn,_s,ys,yt,bs,Ms,_n,vs,ws,wr,We,Ts,yn,ks,Js,Tr,fo,kr,se,Ge,bn,uo,Es,go,js,Mn,Zs,Us,Jr,de,vn,Ws,Gs,wn,Is,zs,Er,_o,jr,le,Ie,Tn,yo,Vs,kn,$s,Zr,B,Rs,Jn,Bs,Fs,En,Cs,xs,jn,Ds,Ns,Zn,qs,Xs,Ur,bo,Wr,ze,Ss,Mo,Ys,As,Gr,P,Hs,vo,Ps,Qs,wo,Ls,Os,Ir,ce,Ve,Un,To,Ks,Wn,ed,zr,$,ko,od,$e,bt,td,nd,Mt,rd,ad,sd,ie,dd,vt,ld,cd,wt,id,pd,md,Re,hd,Be,Jo,fd,Eo,ud,Tt,gd,_d,yd,Fe,jo,bd,pe,Md,Gn,vd,wd,In,Td,kd,Vr,me,Ce,zn,Zo,Jd,Vn,Ed,$r,j,Uo,jd,he,Zd,kt,Ud,Wd,Jt,Gd,Id,zd,Wo,Vd,Go,$d,Rd,Bd,$n,Fd,Cd,Io,xd,Et,Dd,Nd,qd,zo,Xd,Vo,Sd,Yd,Ad,Q,jt,Hd,Pd,Rn,Qd,Ld,Bn,Od,Kd,el,C,$o,ol,fe,tl,Zt,nl,rl,Fn,al,sl,dl,xe,ll,De,cl,x,Ro,il,Cn,pl,ml,ue,hl,xn,fl,ul,Dn,gl,_l,yl,Ne,Rr,ge,qe,Nn,Bo,bl,qn,Ml,Br,Z,Fo,vl,_e,wl,Ut,Tl,kl,Wt,Jl,El,jl,Co,Zl,xo,Ul,Wl,Gl,Xn,Il,zl,Do,Vl,Gt,$l,Rl,Bl,No,Fl,qo,Cl,xl,Dl,L,It,Nl,ql,zt,Xl,Sl,Vt,Yl,Al,Hl,D,Xo,Pl,ye,Ql,$t,Ll,Ol,Sn,Kl,ec,oc,Xe,tc,Se,nc,O,So,rc,Yn,ac,sc,Ye,Fr,be,Ae,An,Yo,dc,Hn,lc,Cr,U,Ao,cc,Me,ic,Rt,pc,mc,Bt,hc,fc,uc,Ho,gc,Po,_c,yc,bc,Pn,Mc,vc,Qo,wc,Ft,Tc,kc,Jc,Lo,Ec,Oo,jc,Zc,Uc,K,Ct,Wc,Gc,Qn,Ic,zc,Ln,Vc,$c,Rc,N,Ko,Bc,ve,Fc,xt,Cc,xc,On,Dc,Nc,qc,He,Xc,Pe,Sc,ee,et,Yc,Kn,Ac,Hc,Qe,xr;return l=new A({}),to=new A({}),ao=new A({}),lo=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBFbmNvZGVyRGVjb2RlckNvbmZpZyUyQyUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEFjb25maWdfZW5jb2RlciUyMCUzRCUyMEJlcnRDb25maWcoKSUwQWNvbmZpZ19kZWNvZGVyJTIwJTNEJTIwQmVydENvbmZpZygpJTBBJTBBY29uZmlnJTIwJTNEJTIwRW5jb2RlckRlY29kZXJDb25maWcuZnJvbV9lbmNvZGVyX2RlY29kZXJfY29uZmlncyhjb25maWdfZW5jb2RlciUyQyUyMGNvbmZpZ19kZWNvZGVyKSUwQW1vZGVsJTIwJTNEJTIwRW5jb2RlckRlY29kZXJNb2RlbChjb25maWclM0Rjb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, EncoderDecoderConfig, EncoderDecoderModel

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

<span class="hljs-meta">&gt;&gt;&gt; </span>config = EncoderDecoderConfig.from_encoder_decoder_configs(config_encoder, config_decoder)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel(config=config)`}}),co=new A({}),po=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMkMlMjBCZXJ0VG9rZW5pemVyJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQmVydFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> EncoderDecoderModel, BertTokenizer

<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 = EncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>)`}}),mo=new A({}),fo=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBFbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBJTIzJTIwbG9hZCUyMGElMjBmaW5lLXR1bmVkJTIwc2VxMnNlcSUyMG1vZGVsJTIwYW5kJTIwY29ycmVzcG9uZGluZyUyMHRva2VuaXplciUwQW1vZGVsJTIwJTNEJTIwRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIycGF0cmlja3ZvbnBsYXRlbiUyRmJlcnQyYmVydF9jbm5fZGFpbHlfbWFpbCUyMiklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJwYXRyaWNrdm9ucGxhdGVuJTJGYmVydDJiZXJ0X2Nubl9kYWlseV9tYWlsJTIyKSUwQSUwQSUyMyUyMGxldCdzJTIwcGVyZm9ybSUyMGluZmVyZW5jZSUyMG9uJTIwYSUyMGxvbmclMjBwaWVjZSUyMG9mJTIwdGV4dCUwQUFSVElDTEVfVE9fU1VNTUFSSVpFJTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMlBHJTI2RSUyMHN0YXRlZCUyMGl0JTIwc2NoZWR1bGVkJTIwdGhlJTIwYmxhY2tvdXRzJTIwaW4lMjByZXNwb25zZSUyMHRvJTIwZm9yZWNhc3RzJTIwZm9yJTIwaGlnaCUyMHdpbmRzJTIwJTIyJTBBJTIwJTIwJTIwJTIwJTIyYW1pZCUyMGRyeSUyMGNvbmRpdGlvbnMuJTIwVGhlJTIwYWltJTIwaXMlMjB0byUyMHJlZHVjZSUyMHRoZSUyMHJpc2slMjBvZiUyMHdpbGRmaXJlcy4lMjBOZWFybHklMjA4MDAlMjB0aG91c2FuZCUyMGN1c3RvbWVycyUyMHdlcmUlMjAlMjIlMEElMjAlMjAlMjAlMjAlMjJzY2hlZHVsZWQlMjB0byUyMGJlJTIwYWZmZWN0ZWQlMjBieSUyMHRoZSUyMHNodXRvZmZzJTIwd2hpY2glMjB3ZXJlJTIwZXhwZWN0ZWQlMjB0byUyMGxhc3QlMjB0aHJvdWdoJTIwYXQlMjBsZWFzdCUyMG1pZGRheSUyMHRvbW9ycm93LiUyMiUwQSklMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIoQVJUSUNMRV9UT19TVU1NQVJJWkUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5pbnB1dF9pZHMlMEElMEElMjMlMjBhdXRvcmVncmVzc2l2ZWx5JTIwZ2VuZXJhdGUlMjBzdW1tYXJ5JTIwKHVzZXMlMjBncmVlZHklMjBkZWNvZGluZyUyMGJ5JTIwZGVmYXVsdCklMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzKSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwdG9rZW5pemVyLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RCUwQXByaW50KGdlbmVyYXRlZF90ZXh0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, EncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load a fine-tuned seq2seq model and corresponding tokenizer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;patrickvonplaten/bert2bert_cnn_daily_mail&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;patrickvonplaten/bert2bert_cnn_daily_mail&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># let&#x27;s perform inference on a long piece of text</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>ARTICLE_TO_SUMMARIZE = (
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;PG&amp;E stated it scheduled the blackouts in response to forecasts for high winds &quot;</span>
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were &quot;</span>
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(ARTICLE_TO_SUMMARIZE, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># autoregressively generate summary (uses greedy decoding by default)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(input_ids)
<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)
nearly <span class="hljs-number">800</span> thousand customers were affected by the shutoffs. the aim <span class="hljs-keyword">is</span> to reduce the risk of wildfires. nearly <span class="hljs-number">800</span>, <span class="hljs-number">000</span> customers were expected to be affected by high winds amid dry conditions. pg &amp; e said it scheduled the blackouts to last through at least midday tomorrow.`}}),uo=new A({}),_o=new S({props:{code:"JTIzJTIwYSUyMHdvcmthcm91bmQlMjB0byUyMGxvYWQlMjBmcm9tJTIwcHl0b3JjaCUyMGNoZWNrcG9pbnQlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwRW5jb2RlckRlY29kZXJNb2RlbCUyQyUyMFRGRW5jb2RlckRlY29kZXJNb2RlbCUwQSUwQV9tb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdHJpY2t2b25wbGF0ZW4lMkZiZXJ0MmJlcnQtY25uX2RhaWx5bWFpbC1mcDE2JTIyKSUwQSUwQV9tb2RlbC5lbmNvZGVyLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGZW5jb2RlciUyMiklMEFfbW9kZWwuZGVjb2Rlci5zYXZlX3ByZXRyYWluZWQoJTIyLiUyRmRlY29kZXIlMjIpJTBBJTBBbW9kZWwlMjAlM0QlMjBURkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjIuJTJGZW5jb2RlciUyMiUyQyUyMCUyMi4lMkZkZWNvZGVyJTIyJTJDJTIwZW5jb2Rlcl9mcm9tX3B0JTNEVHJ1ZSUyQyUyMGRlY29kZXJfZnJvbV9wdCUzRFRydWUlMEEpJTBBJTIzJTIwVGhpcyUyMGlzJTIwb25seSUyMGZvciUyMGNvcHlpbmclMjBzb21lJTIwc3BlY2lmaWMlMjBhdHRyaWJ1dGVzJTIwb2YlMjB0aGlzJTIwcGFydGljdWxhciUyMG1vZGVsLiUwQW1vZGVsLmNvbmZpZyUyMCUzRCUyMF9tb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># a workaround to load from pytorch checkpoint</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> EncoderDecoderModel, TFEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span>_model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;patrickvonplaten/bert2bert-cnn_dailymail-fp16&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 = TFEncoderDecoderModel.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`}}),yo=new A({}),bo=new S({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRUb2tlbml6ZXIlMkMlMjBFbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQmVydFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEElMEFtb2RlbC5jb25maWcuZGVjb2Rlcl9zdGFydF90b2tlbl9pZCUyMCUzRCUyMHRva2VuaXplci5jbHNfdG9rZW5faWQlMEFtb2RlbC5jb25maWcucGFkX3Rva2VuX2lkJTIwJTNEJTIwdG9rZW5pemVyLnBhZF90b2tlbl9pZCUwQSUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjAlMjJUaGUlMjB0b3dlciUyMGlzJTIwMzI0JTIwbWV0cmVzJTIwKDElMkMwNjMlMjBmdCklMjB0YWxsJTJDJTIwYWJvdXQlMjB0aGUlMjBzYW1lJTIwaGVpZ2h0JTIwYXMlMjBhbiUyMDgxLXN0b3JleSUyMGJ1aWxkaW5nJTJDJTIwYW5kJTIwdGhlJTIwdGFsbGVzdCUyMHN0cnVjdHVyZSUyMGluJTIwUGFyaXMuJTIwSXRzJTIwYmFzZSUyMGlzJTIwc3F1YXJlJTJDJTIwbWVhc3VyaW5nJTIwMTI1JTIwbWV0cmVzJTIwKDQxMCUyMGZ0KSUyMG9uJTIwZWFjaCUyMHNpZGUuRHVyaW5nJTIwaXRzJTIwY29uc3RydWN0aW9uJTJDJTIwdGhlJTIwRWlmZmVsJTIwVG93ZXIlMjBzdXJwYXNzZWQlMjB0aGUlMjBXYXNoaW5ndG9uJTIwTW9udW1lbnQlMjB0byUyMGJlY29tZSUyMHRoZSUyMHRhbGxlc3QlMjBtYW4tbWFkZSUyMHN0cnVjdHVyZSUyMGluJTIwdGhlJTIwd29ybGQlMkMlMjBhJTIwdGl0bGUlMjBpdCUyMGhlbGQlMjBmb3IlMjA0MSUyMHllYXJzJTIwdW50aWwlMjB0aGUlMjBDaHJ5c2xlciUyMEJ1aWxkaW5nJTIwaW4lMjBOZXclMjBZb3JrJTIwQ2l0eSUyMHdhcyUyMCUyMGZpbmlzaGVkJTIwaW4lMjAxOTMwLiUyMEl0JTIwd2FzJTIwdGhlJTIwZmlyc3QlMjBzdHJ1Y3R1cmUlMjB0byUyMHJlYWNoJTIwYSUyMGhlaWdodCUyMG9mJTIwMzAwJTIwbWV0cmVzLiUyMER1ZSUyMHRvJTIwdGhlJTIwYWRkaXRpb24lMjBvZiUyMGElMjBicm9hZGNhc3RpbmclMjBhZXJpYWwlMjBhdCUyMHRoZSUyMHRvcCUyMG9mJTIwdGhlJTIwdG93ZXIlMjBpbiUyMDE5NTclMkMlMjBpdCUyMGlzJTIwbm93JTIwdGFsbGVyJTIwdGhhbiUyMHRoZSUyMENocnlzbGVyJTIwQnVpbGRpbmclMjBieSUyMDUuMiUyMG1ldHJlcyUyMCgxNyUyMGZ0KS5FeGNsdWRpbmclMjB0cmFuc21pdHRlcnMlMkMlMjB0aGUlMjBFaWZmZWwlMjBUb3dlciUyMGlzJTIwdGhlJTIwc2Vjb25kJTIwdGFsbGVzdCUyMGZyZWUtc3RhbmRpbmclMjBzdHJ1Y3R1cmUlMjBpbiUyMEZyYW5jZSUyMGFmdGVyJTIwdGhlJTIwTWlsbGF1JTIwVmlhZHVjdC4lMjIlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBKS5pbnB1dF9pZHMlMEElMEFsYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTIydGhlJTIwZWlmZmVsJTIwdG93ZXIlMjBzdXJwYXNzZWQlMjB0aGUlMjB3YXNoaW5ndG9uJTIwbW9udW1lbnQlMjB0byUyMGJlY29tZSUyMHRoZSUyMHRhbGxlc3QlMjBzdHJ1Y3R1cmUlMjBpbiUyMHRoZSUyMHdvcmxkLiUyMGl0JTIwd2FzJTIwdGhlJTIwZmlyc3QlMjBzdHJ1Y3R1cmUlMjB0byUyMHJlYWNoJTIwYSUyMGhlaWdodCUyMG9mJTIwMzAwJTIwbWV0cmVzJTIwaW4lMjBwYXJpcyUyMGluJTIwMTkzMC4lMjBpdCUyMGlzJTIwbm93JTIwdGFsbGVyJTIwdGhhbiUyMHRoZSUyMGNocnlzbGVyJTIwYnVpbGRpbmclMjBieSUyMDUuJTIwMiUyMG1ldHJlcyUyMCglMjAxNyUyMGZ0JTIwKSUyMGFuZCUyMGlzJTIwdGhlJTIwc2Vjb25kJTIwdGFsbGVzdCUyMGZyZWUlMjAtJTIwc3RhbmRpbmclMjBzdHJ1Y3R1cmUlMjBpbiUyMHBhcmlzLiUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMkMlMEEpLmlucHV0X2lkcyUwQSUwQSUyMyUyMHRoZSUyMGZvcndhcmQlMjBmdW5jdGlvbiUyMGF1dG9tYXRpY2FsbHklMjBjcmVhdGVzJTIwdGhlJTIwY29ycmVjdCUyMGRlY29kZXJfaW5wdXRfaWRzJTBBbG9zcyUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, EncoderDecoderModel

<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 = EncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</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>input_ids = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side.During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was  finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft).Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.&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>labels = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;the eiffel tower surpassed the washington monument to become the tallest structure in the world. it was the first structure to reach a height of 300 metres in paris in 1930. it is now taller than the chrysler building by 5. 2 metres ( 17 ft ) and is the second tallest free - standing structure in paris.&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(input_ids=input_ids, labels=labels).loss`}}),To=new A({}),ko=new X({props:{name:"class transformers.EncoderDecoderConfig",anchor:"transformers.EncoderDecoderConfig",parameters:[{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.EncoderDecoderConfig.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.30.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.30.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.30.0/src/transformers/models/encoder_decoder/configuration_encoder_decoder.py#L26"}}),Re=new lt({props:{anchor:"transformers.EncoderDecoderConfig.example",$$slots:{default:[Pp]},$$scope:{ctx:W}}}),Jo=new X({props:{name:"from_encoder_decoder_configs",anchor:"transformers.EncoderDecoderConfig.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.30.0/src/transformers/models/encoder_decoder/configuration_encoder_decoder.py#L91",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</a></p>
`}}),jo=new X({props:{name:"to_dict",anchor:"transformers.EncoderDecoderConfig.to_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/encoder_decoder/configuration_encoder_decoder.py#L108",returnDescription:`
<p>Dictionary of all the attributes that make up this configuration instance,</p>
`,returnType:`
<p><code>Dict[str, any]</code></p>
`}}),Zo=new A({}),Uo=new X({props:{name:"class transformers.EncoderDecoderModel",anchor:"transformers.EncoderDecoderModel",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.EncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig">EncoderDecoderConfig</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.30.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.30.0/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L170"}}),$o=new X({props:{name:"forward",anchor:"transformers.EncoderDecoderModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",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.Tuple[typing.Tuple[torch.FloatTensor]] = None"},{name:"inputs_embeds",val:": typing.Optional[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.EncoderDecoderModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.EncoderDecoderModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.EncoderDecoderModel.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.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__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.EncoderDecoderModel.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.EncoderDecoderModel.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.EncoderDecoderModel.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.EncoderDecoderModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.EncoderDecoderModel.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.EncoderDecoderModel.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.EncoderDecoderModel.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.EncoderDecoderModel.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.EncoderDecoderModel.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.EncoderDecoderModel.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.EncoderDecoderModel.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.30.0/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L539",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</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.30.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),xe=new Qc({props:{$$slots:{default:[Qp]},$$scope:{ctx:W}}}),De=new lt({props:{anchor:"transformers.EncoderDecoderModel.forward.example",$$slots:{default:[Lp]},$$scope:{ctx:W}}}),Ro=new X({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.EncoderDecoderModel.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.EncoderDecoderModel.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.
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.30.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.EncoderDecoderModel.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 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.30.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.EncoderDecoderModel.from_encoder_decoder_pretrained.model_args",description:`<strong>model_args</strong> (remaining positional arguments, <em>optional</em>) &#x2014;
All remaining positional arguments will be passed to the underlying model&#x2019;s <code>__init__</code> method.`,name:"model_args"},{anchor:"transformers.EncoderDecoderModel.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.30.0/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L389"}}),Ne=new lt({props:{anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Op]},$$scope:{ctx:W}}}),Bo=new A({}),Fo=new X({props:{name:"class transformers.TFEncoderDecoderModel",anchor:"transformers.TFEncoderDecoderModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFEncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig">EncoderDecoderConfig</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.30.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.30.0/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L193"}}),Xo=new X({props:{name:"call",anchor:"transformers.TFEncoderDecoderModel.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"attention_mask",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:": np.ndarray | tf.Tensor | None = None"},{name:"past_key_values",val:": Tuple[Tuple[tf.Tensor]] | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = 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.TFEncoderDecoderModel.call.input_ids",description:`<strong>input_ids</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, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFEncoderDecoderModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFEncoderDecoderModel.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.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__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.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and <a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for
details.`,name:"decoder_input_ids"},{anchor:"transformers.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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 \`**decoder_kwargs&#x201C; for the decoder forward function.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L469",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</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.30.0/en/main_classes/output#transformers.modeling_tf_outputs.TFSeq2SeqLMOutput"
>transformers.modeling_tf_outputs.TFSeq2SeqLMOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Xe=new Qc({props:{$$slots:{default:[Kp]},$$scope:{ctx:W}}}),Se=new lt({props:{anchor:"transformers.TFEncoderDecoderModel.call.example",$$slots:{default:[em]},$$scope:{ctx:W}}}),So=new X({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.
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.30.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.TFEncoderDecoderModel.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 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.30.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.TFEncoderDecoderModel.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.TFEncoderDecoderModel.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.30.0/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L322"}}),Ye=new lt({props:{anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[om]},$$scope:{ctx:W}}}),Yo=new A({}),Ao=new X({props:{name:"class transformers.FlaxEncoderDecoderModel",anchor:"transformers.FlaxEncoderDecoderModel",parameters:[{name:"config",val:": EncoderDecoderConfig"},{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.FlaxEncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig">EncoderDecoderConfig</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.30.0/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.FlaxEncoderDecoderModel.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.30.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/v4.30.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L302"}}),Ko=new X({props:{name:"__call__",anchor:"transformers.FlaxEncoderDecoderModel.__call__",parameters:[{name:"input_ids",val:": ndarray"},{name:"attention_mask",val:": typing.Optional[jax._src.numpy.ndarray.ndarray] = None"},{name:"decoder_input_ids",val:": typing.Optional[jax._src.numpy.ndarray.ndarray] = None"},{name:"decoder_attention_mask",val:": typing.Optional[jax._src.numpy.ndarray.ndarray] = None"},{name:"position_ids",val:": typing.Optional[jax._src.numpy.ndarray.ndarray] = None"},{name:"decoder_position_ids",val:": typing.Optional[jax._src.numpy.ndarray.ndarray] = 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.FlaxEncoderDecoderModel.__call__.input_ids",description:`<strong>input_ids</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.attention_mask",description:`<strong>attention_mask</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.FlaxEncoderDecoderModel.__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.30.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.30.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.30.0/en/model_doc/speecht5#transformers.SpeechT5Tokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a></p>
<p>For sequence to sequence training, <code>decoder_input_ids</code> should be provided. <code>decoder_input_ids</code> should be
created outside of 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.FlaxEncoderDecoderModel.__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.FlaxEncoderDecoderModel.__call__.position_ids",description:`<strong>position_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.encoder.max_position_embeddings - 1]</code>.`,name:"position_ids"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.decoder_position_ids",description:`<strong>decoder_position_ids</strong> (<code>numpy.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.FlaxEncoderDecoderModel.__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.FlaxEncoderDecoderModel.__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.FlaxEncoderDecoderModel.__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.30.0/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L627",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.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.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</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.30.0/en/main_classes/output#transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput"
>transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),He=new Qc({props:{$$slots:{default:[tm]},$$scope:{ctx:W}}}),Pe=new lt({props:{anchor:"transformers.FlaxEncoderDecoderModel.__call__.example",$$slots:{default:[nm]},$$scope:{ctx:W}}}),et=new X({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.FlaxEncoderDecoderModel.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.FlaxEncoderDecoderModel.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.
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.30.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.FlaxEncoderDecoderModel.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.30.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.FlaxEncoderDecoderModel.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.FlaxEncoderDecoderModel.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.30.0/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L759"}}),Qe=new lt({props:{anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[rm]},$$scope:{ctx:W}}}),{c(){h=a("meta"),J=i(),_=a("h1"),f=a("a"),y=a("span"),b(l.$$.fragment),g=i(),R=a("span"),ga=n("Encoder Decoder Models"),cr=i(),te=a("h2"),we=a("a"),en=a("span"),b(to.$$.fragment),_a=i(),on=a("span"),ya=n("Overview"),ir=i(),Te=a("p"),ba=n("The "),it=a("a"),Ma=n("EncoderDecoderModel"),va=n(` can be used to initialize a sequence-to-sequence model with any
pretrained autoencoding model as the encoder and any pretrained autoregressive model as the decoder.`),pr=i(),ke=a("p"),wa=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation tasks
was shown in `),no=a("a"),Ta=n("Leveraging Pre-trained Checkpoints for Sequence Generation Tasks"),ka=n(` by
Sascha Rothe, Shashi Narayan, Aliaksei Severyn.`),mr=i(),Je=a("p"),Ja=n("After such an "),pt=a("a"),Ea=n("EncoderDecoderModel"),ja=n(` has been trained/fine-tuned, it can be saved/loaded just like
any other models (see the examples for more information).`),hr=i(),H=a("p"),Za=n("An application of this architecture could be to leverage two pretrained "),mt=a("a"),Ua=n("BertModel"),Wa=n(` as the encoder
and decoder for a summarization model as was shown in: `),ro=a("a"),Ga=n("Text Summarization with Pretrained Encoders"),Ia=n(" by Yang Liu and Mirella Lapata."),fr=i(),ne=a("h2"),Ee=a("a"),tn=a("span"),b(ao.$$.fragment),za=i(),so=a("span"),Va=n("Randomly initializing "),nn=a("code"),$a=n("EncoderDecoderModel"),Ra=n(" from model configurations."),ur=i(),Y=a("p"),ht=a("a"),Ba=n("EncoderDecoderModel"),Fa=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 "),ft=a("a"),Ca=n("BertModel"),xa=n(" configuration for the encoder and the default "),rn=a("code"),Da=n("BertForCausalLM"),Na=n(" configuration for the decoder."),gr=i(),b(lo.$$.fragment),_r=i(),re=a("h2"),je=a("a"),an=a("span"),b(co.$$.fragment),qa=i(),io=a("span"),Xa=n("Initialising "),sn=a("code"),Sa=n("EncoderDecoderModel"),Ya=n(" from a pretrained encoder and a pretrained decoder."),yr=i(),E=a("p"),ut=a("a"),Aa=n("EncoderDecoderModel"),Ha=n(" can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained auto-encoding model, "),dn=a("em"),Pa=n("e.g."),Qa=n(" BERT, can serve as the encoder and both pretrained auto-encoding models, "),ln=a("em"),La=n("e.g."),Oa=n(" BERT, pretrained causal language models, "),cn=a("em"),Ka=n("e.g."),es=n(" GPT2, as well as the pretrained decoder part of sequence-to-sequence models, "),pn=a("em"),os=n("e.g."),ts=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 `),gt=a("a"),ns=n("EncoderDecoderModel"),rs=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=a("a"),as=n("the "),mn=a("em"),ss=n("Warm-starting-encoder-decoder blog post"),ds=n(`.
To do so, the `),hn=a("code"),ls=n("EncoderDecoderModel"),cs=n(" class provides a "),_t=a("a"),is=n("EncoderDecoderModel.from_encoder_decoder_pretrained()"),ps=n(" method."),br=i(),b(po.$$.fragment),Mr=i(),ae=a("h2"),Ue=a("a"),fn=a("span"),b(mo.$$.fragment),ms=i(),ho=a("span"),hs=n("Loading an existing "),un=a("code"),fs=n("EncoderDecoderModel"),us=n(" checkpoint and perform inference."),vr=i(),F=a("p"),gs=n("To load fine-tuned checkpoints of the "),gn=a("code"),_s=n("EncoderDecoderModel"),ys=n(" class, "),yt=a("a"),bs=n("EncoderDecoderModel"),Ms=n(" provides the "),_n=a("code"),vs=n("from_pretrained(...)"),ws=n(" method just like any other model architecture in Transformers."),wr=i(),We=a("p"),Ts=n("To perform inference, one uses the "),yn=a("code"),ks=n("generate"),Js=n(" method, which allows to autoregressively generate text. This method supports various forms of decoding, such as greedy, beam search and multinomial sampling."),Tr=i(),b(fo.$$.fragment),kr=i(),se=a("h2"),Ge=a("a"),bn=a("span"),b(uo.$$.fragment),Es=i(),go=a("span"),js=n("Loading a PyTorch checkpoint into "),Mn=a("code"),Zs=n("TFEncoderDecoderModel"),Us=n("."),Jr=i(),de=a("p"),vn=a("code"),Ws=n("TFEncoderDecoderModel.from_pretrained()"),Gs=n(` currently doesn\u2019t support initializing the model from a
pytorch checkpoint. Passing `),wn=a("code"),Is=n("from_pt=True"),zs=n(` to this method will throw an exception. If there are only pytorch
checkpoints for a particular encoder-decoder model, a workaround is:`),Er=i(),b(_o.$$.fragment),jr=i(),le=a("h2"),Ie=a("a"),Tn=a("span"),b(yo.$$.fragment),Vs=i(),kn=a("span"),$s=n("Training"),Zr=i(),B=a("p"),Rs=n(`Once the model is created, it can be fine-tuned similar to BART, T5 or any other encoder-decoder model.
As you can see, only 2 inputs are required for the model in order to compute a loss: `),Jn=a("code"),Bs=n("input_ids"),Fs=n(` (which are the
`),En=a("code"),Cs=n("input_ids"),xs=n(" of the encoded input sequence) and "),jn=a("code"),Ds=n("labels"),Ns=n(" (which are the "),Zn=a("code"),qs=n("input_ids"),Xs=n(` of the encoded
target sequence).`),Ur=i(),b(bo.$$.fragment),Wr=i(),ze=a("p"),Ss=n("Detailed "),Mo=a("a"),Ys=n("colab"),As=n(" for training."),Gr=i(),P=a("p"),Hs=n("This model was contributed by "),vo=a("a"),Ps=n("thomwolf"),Qs=n(`. This model\u2019s TensorFlow and Flax versions
were contributed by `),wo=a("a"),Ls=n("ydshieh"),Os=n("."),Ir=i(),ce=a("h2"),Ve=a("a"),Un=a("span"),b(To.$$.fragment),Ks=i(),Wn=a("span"),ed=n("EncoderDecoderConfig"),zr=i(),$=a("div"),b(ko.$$.fragment),od=i(),$e=a("p"),bt=a("a"),td=n("EncoderDecoderConfig"),nd=n(" is the configuration class to store the configuration of a "),Mt=a("a"),rd=n("EncoderDecoderModel"),ad=n(`. It is
used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder
configs.`),sd=i(),ie=a("p"),dd=n("Configuration objects inherit from "),vt=a("a"),ld=n("PretrainedConfig"),cd=n(` and can be used to control the model outputs. Read the
documentation from `),wt=a("a"),id=n("PretrainedConfig"),pd=n(" for more information."),md=i(),b(Re.$$.fragment),hd=i(),Be=a("div"),b(Jo.$$.fragment),fd=i(),Eo=a("p"),ud=n("Instantiate a "),Tt=a("a"),gd=n("EncoderDecoderConfig"),_d=n(` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),yd=i(),Fe=a("div"),b(jo.$$.fragment),bd=i(),pe=a("p"),Md=n("Serializes this instance to a Python dictionary. Override the default "),Gn=a("em"),vd=n("to_dict()"),wd=n(" from "),In=a("em"),Td=n("PretrainedConfig"),kd=n("."),Vr=i(),me=a("h2"),Ce=a("a"),zn=a("span"),b(Zo.$$.fragment),Jd=i(),Vn=a("span"),Ed=n("EncoderDecoderModel"),$r=i(),j=a("div"),b(Uo.$$.fragment),jd=i(),he=a("p"),Zd=n(`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),kt=a("a"),Ud=n("from_pretrained()"),Wd=n(" function and the decoder is loaded via "),Jt=a("a"),Gd=n("from_pretrained()"),Id=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),zd=i(),Wo=a("p"),Vd=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Go=a("a"),$d=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),Rd=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),Bd=i(),$n=a("p"),Fd=n(`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),Cd=i(),Io=a("p"),xd=n("This model inherits from "),Et=a("a"),Dd=n("PreTrainedModel"),Nd=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.)`),qd=i(),zo=a("p"),Xd=n("This model is also a PyTorch "),Vo=a("a"),Sd=n("torch.nn.Module"),Yd=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ad=i(),Q=a("p"),jt=a("a"),Hd=n("EncoderDecoderModel"),Pd=n(` is a generic model class that will be instantiated as a transformer architecture with one
of the base model classes of the library as encoder and another one as decoder when created with the
:meth`),Rn=a("em"),Qd=n("~transformers.AutoModel.from_pretrained"),Ld=n(` class method for the encoder and
:meth`),Bn=a("em"),Od=n("~transformers.AutoModelForCausalLM.from_pretrained"),Kd=n(" class method for the decoder."),el=i(),C=a("div"),b($o.$$.fragment),ol=i(),fe=a("p"),tl=n("The "),Zt=a("a"),nl=n("EncoderDecoderModel"),rl=n(" forward method, overrides the "),Fn=a("code"),al=n("__call__"),sl=n(" special method."),dl=i(),b(xe.$$.fragment),ll=i(),b(De.$$.fragment),cl=i(),x=a("div"),b(Ro.$$.fragment),il=i(),Cn=a("p"),pl=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),ml=i(),ue=a("p"),hl=n("The model is set in evaluation mode by default using "),xn=a("code"),fl=n("model.eval()"),ul=n(` (Dropout modules are deactivated). To train
the model, you need to first set it back in training mode with `),Dn=a("code"),gl=n("model.train()"),_l=n("."),yl=i(),b(Ne.$$.fragment),Rr=i(),ge=a("h2"),qe=a("a"),Nn=a("span"),b(Bo.$$.fragment),bl=i(),qn=a("span"),Ml=n("TFEncoderDecoderModel"),Br=i(),Z=a("div"),b(Fo.$$.fragment),vl=i(),_e=a("p"),wl=n(`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),Ut=a("a"),Tl=n("from_pretrained()"),kl=n(" function and the decoder is loaded via "),Wt=a("a"),Jl=n("from_pretrained()"),El=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),jl=i(),Co=a("p"),Zl=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),xo=a("a"),Ul=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),Wl=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),Gl=i(),Xn=a("p"),Il=n(`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),zl=i(),Do=a("p"),Vl=n("This model inherits from "),Gt=a("a"),$l=n("TFPreTrainedModel"),Rl=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.)`),Bl=i(),No=a("p"),Fl=n("This model is also a "),qo=a("a"),Cl=n("tf.keras.Model"),xl=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.`),Dl=i(),L=a("p"),It=a("a"),Nl=n("TFEncoderDecoderModel"),ql=n(` is a generic model class that will be instantiated as a transformer architecture with one
of the base model classes of the library as encoder and another one as decoder when created with the
`),zt=a("a"),Xl=n("from_pretrained()"),Sl=n(" class method for the encoder and "),Vt=a("a"),Yl=n("from_pretrained()"),Al=n(` class
method for the decoder.`),Hl=i(),D=a("div"),b(Xo.$$.fragment),Pl=i(),ye=a("p"),Ql=n("The "),$t=a("a"),Ll=n("TFEncoderDecoderModel"),Ol=n(" forward method, overrides the "),Sn=a("code"),Kl=n("__call__"),ec=n(" special method."),oc=i(),b(Xe.$$.fragment),tc=i(),b(Se.$$.fragment),nc=i(),O=a("div"),b(So.$$.fragment),rc=i(),Yn=a("p"),ac=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),sc=i(),b(Ye.$$.fragment),Fr=i(),be=a("h2"),Ae=a("a"),An=a("span"),b(Yo.$$.fragment),dc=i(),Hn=a("span"),lc=n("FlaxEncoderDecoderModel"),Cr=i(),U=a("div"),b(Ao.$$.fragment),cc=i(),Me=a("p"),ic=n(`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),Rt=a("a"),pc=n("from_pretrained()"),mc=n(" function and the decoder is loaded via "),Bt=a("a"),hc=n("from_pretrained()"),fc=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),uc=i(),Ho=a("p"),gc=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Po=a("a"),_c=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),yc=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),bc=i(),Pn=a("p"),Mc=n(`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),vc=i(),Qo=a("p"),wc=n("This model inherits from "),Ft=a("a"),Tc=n("FlaxPreTrainedModel"),kc=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.)`),Jc=i(),Lo=a("p"),Ec=n(`This model is also a Flax Linen
`),Oo=a("a"),jc=n("flax.nn.Module"),Zc=n(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),Uc=i(),K=a("p"),Ct=a("a"),Wc=n("FlaxEncoderDecoderModel"),Gc=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 model classes of the library as encoder module and another one as
decoder module when created with the :meth`),Qn=a("em"),Ic=n("~transformers.FlaxAutoModel.from_pretrained"),zc=n(` class method for the
encoder and :meth`),Ln=a("em"),Vc=n("~transformers.FlaxAutoModelForCausalLM.from_pretrained"),$c=n(" class method for the decoder."),Rc=i(),N=a("div"),b(Ko.$$.fragment),Bc=i(),ve=a("p"),Fc=n("The "),xt=a("a"),Cc=n("FlaxEncoderDecoderModel"),xc=n(" forward method, overrides the "),On=a("code"),Dc=n("__call__"),Nc=n(" special method."),qc=i(),b(He.$$.fragment),Xc=i(),b(Pe.$$.fragment),Sc=i(),ee=a("div"),b(et.$$.fragment),Yc=i(),Kn=a("p"),Ac=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Hc=i(),b(Qe.$$.fragment),this.h()},l(o){const m=Ap('[data-svelte="svelte-1phssyn"]',document.head);h=s(m,"META",{name:!0,content:!0}),m.forEach(t),J=p(o),_=s(o,"H1",{class:!0});var ot=d(_);f=s(ot,"A",{id:!0,class:!0,href:!0});var er=d(f);y=s(er,"SPAN",{});var or=d(y);M(l.$$.fragment,or),or.forEach(t),er.forEach(t),g=p(ot),R=s(ot,"SPAN",{});var tr=d(R);ga=r(tr,"Encoder Decoder Models"),tr.forEach(t),ot.forEach(t),cr=p(o),te=s(o,"H2",{class:!0});var tt=d(te);we=s(tt,"A",{id:!0,class:!0,href:!0});var nr=d(we);en=s(nr,"SPAN",{});var rr=d(en);M(to.$$.fragment,rr),rr.forEach(t),nr.forEach(t),_a=p(tt),on=s(tt,"SPAN",{});var ar=d(on);ya=r(ar,"Overview"),ar.forEach(t),tt.forEach(t),ir=p(o),Te=s(o,"P",{});var nt=d(Te);ba=r(nt,"The "),it=s(nt,"A",{href:!0});var sr=d(it);Ma=r(sr,"EncoderDecoderModel"),sr.forEach(t),va=r(nt,` can be used to initialize a sequence-to-sequence model with any
pretrained autoencoding model as the encoder and any pretrained autoregressive model as the decoder.`),nt.forEach(t),pr=p(o),ke=s(o,"P",{});var Dr=d(ke);wa=r(Dr,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation tasks
was shown in `),no=s(Dr,"A",{href:!0,rel:!0});var Lc=d(no);Ta=r(Lc,"Leveraging Pre-trained Checkpoints for Sequence Generation Tasks"),Lc.forEach(t),ka=r(Dr,` by
Sascha Rothe, Shashi Narayan, Aliaksei Severyn.`),Dr.forEach(t),mr=p(o),Je=s(o,"P",{});var Nr=d(Je);Ja=r(Nr,"After such an "),pt=s(Nr,"A",{href:!0});var Oc=d(pt);Ea=r(Oc,"EncoderDecoderModel"),Oc.forEach(t),ja=r(Nr,` has been trained/fine-tuned, it can be saved/loaded just like
any other models (see the examples for more information).`),Nr.forEach(t),hr=p(o),H=s(o,"P",{});var Dt=d(H);Za=r(Dt,"An application of this architecture could be to leverage two pretrained "),mt=s(Dt,"A",{href:!0});var Kc=d(mt);Ua=r(Kc,"BertModel"),Kc.forEach(t),Wa=r(Dt,` as the encoder
and decoder for a summarization model as was shown in: `),ro=s(Dt,"A",{href:!0,rel:!0});var ei=d(ro);Ga=r(ei,"Text Summarization with Pretrained Encoders"),ei.forEach(t),Ia=r(Dt," by Yang Liu and Mirella Lapata."),Dt.forEach(t),fr=p(o),ne=s(o,"H2",{class:!0});var qr=d(ne);Ee=s(qr,"A",{id:!0,class:!0,href:!0});var oi=d(Ee);tn=s(oi,"SPAN",{});var ti=d(tn);M(ao.$$.fragment,ti),ti.forEach(t),oi.forEach(t),za=p(qr),so=s(qr,"SPAN",{});var Xr=d(so);Va=r(Xr,"Randomly initializing "),nn=s(Xr,"CODE",{});var ni=d(nn);$a=r(ni,"EncoderDecoderModel"),ni.forEach(t),Ra=r(Xr," from model configurations."),Xr.forEach(t),qr.forEach(t),ur=p(o),Y=s(o,"P",{});var rt=d(Y);ht=s(rt,"A",{href:!0});var ri=d(ht);Ba=r(ri,"EncoderDecoderModel"),ri.forEach(t),Fa=r(rt," can be randomly initialized from an encoder and a decoder config. In the following example, we show how to do this using the default "),ft=s(rt,"A",{href:!0});var ai=d(ft);Ca=r(ai,"BertModel"),ai.forEach(t),xa=r(rt," configuration for the encoder and the default "),rn=s(rt,"CODE",{});var si=d(rn);Da=r(si,"BertForCausalLM"),si.forEach(t),Na=r(rt," configuration for the decoder."),rt.forEach(t),gr=p(o),M(lo.$$.fragment,o),_r=p(o),re=s(o,"H2",{class:!0});var Sr=d(re);je=s(Sr,"A",{id:!0,class:!0,href:!0});var di=d(je);an=s(di,"SPAN",{});var li=d(an);M(co.$$.fragment,li),li.forEach(t),di.forEach(t),qa=p(Sr),io=s(Sr,"SPAN",{});var Yr=d(io);Xa=r(Yr,"Initialising "),sn=s(Yr,"CODE",{});var ci=d(sn);Sa=r(ci,"EncoderDecoderModel"),ci.forEach(t),Ya=r(Yr," from a pretrained encoder and a pretrained decoder."),Yr.forEach(t),Sr.forEach(t),yr=p(o),E=s(o,"P",{});var G=d(E);ut=s(G,"A",{href:!0});var ii=d(ut);Aa=r(ii,"EncoderDecoderModel"),ii.forEach(t),Ha=r(G," can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained auto-encoding model, "),dn=s(G,"EM",{});var pi=d(dn);Pa=r(pi,"e.g."),pi.forEach(t),Qa=r(G," BERT, can serve as the encoder and both pretrained auto-encoding models, "),ln=s(G,"EM",{});var mi=d(ln);La=r(mi,"e.g."),mi.forEach(t),Oa=r(G," BERT, pretrained causal language models, "),cn=s(G,"EM",{});var hi=d(cn);Ka=r(hi,"e.g."),hi.forEach(t),es=r(G," GPT2, as well as the pretrained decoder part of sequence-to-sequence models, "),pn=s(G,"EM",{});var fi=d(pn);os=r(fi,"e.g."),fi.forEach(t),ts=r(G,` 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 `),gt=s(G,"A",{href:!0});var ui=d(gt);ns=r(ui,"EncoderDecoderModel"),ui.forEach(t),rs=r(G," 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(G,"A",{href:!0,rel:!0});var Pc=d(Ze);as=r(Pc,"the "),mn=s(Pc,"EM",{});var gi=d(mn);ss=r(gi,"Warm-starting-encoder-decoder blog post"),gi.forEach(t),Pc.forEach(t),ds=r(G,`.
To do so, the `),hn=s(G,"CODE",{});var _i=d(hn);ls=r(_i,"EncoderDecoderModel"),_i.forEach(t),cs=r(G," class provides a "),_t=s(G,"A",{href:!0});var yi=d(_t);is=r(yi,"EncoderDecoderModel.from_encoder_decoder_pretrained()"),yi.forEach(t),ps=r(G," method."),G.forEach(t),br=p(o),M(po.$$.fragment,o),Mr=p(o),ae=s(o,"H2",{class:!0});var Ar=d(ae);Ue=s(Ar,"A",{id:!0,class:!0,href:!0});var bi=d(Ue);fn=s(bi,"SPAN",{});var Mi=d(fn);M(mo.$$.fragment,Mi),Mi.forEach(t),bi.forEach(t),ms=p(Ar),ho=s(Ar,"SPAN",{});var Hr=d(ho);hs=r(Hr,"Loading an existing "),un=s(Hr,"CODE",{});var vi=d(un);fs=r(vi,"EncoderDecoderModel"),vi.forEach(t),us=r(Hr," checkpoint and perform inference."),Hr.forEach(t),Ar.forEach(t),vr=p(o),F=s(o,"P",{});var Le=d(F);gs=r(Le,"To load fine-tuned checkpoints of the "),gn=s(Le,"CODE",{});var wi=d(gn);_s=r(wi,"EncoderDecoderModel"),wi.forEach(t),ys=r(Le," class, "),yt=s(Le,"A",{href:!0});var Ti=d(yt);bs=r(Ti,"EncoderDecoderModel"),Ti.forEach(t),Ms=r(Le," provides the "),_n=s(Le,"CODE",{});var ki=d(_n);vs=r(ki,"from_pretrained(...)"),ki.forEach(t),ws=r(Le," method just like any other model architecture in Transformers."),Le.forEach(t),wr=p(o),We=s(o,"P",{});var Pr=d(We);Ts=r(Pr,"To perform inference, one uses the "),yn=s(Pr,"CODE",{});var Ji=d(yn);ks=r(Ji,"generate"),Ji.forEach(t),Js=r(Pr," method, which allows to autoregressively generate text. This method supports various forms of decoding, such as greedy, beam search and multinomial sampling."),Pr.forEach(t),Tr=p(o),M(fo.$$.fragment,o),kr=p(o),se=s(o,"H2",{class:!0});var Qr=d(se);Ge=s(Qr,"A",{id:!0,class:!0,href:!0});var Ei=d(Ge);bn=s(Ei,"SPAN",{});var ji=d(bn);M(uo.$$.fragment,ji),ji.forEach(t),Ei.forEach(t),Es=p(Qr),go=s(Qr,"SPAN",{});var Lr=d(go);js=r(Lr,"Loading a PyTorch checkpoint into "),Mn=s(Lr,"CODE",{});var Zi=d(Mn);Zs=r(Zi,"TFEncoderDecoderModel"),Zi.forEach(t),Us=r(Lr,"."),Lr.forEach(t),Qr.forEach(t),Jr=p(o),de=s(o,"P",{});var dr=d(de);vn=s(dr,"CODE",{});var Ui=d(vn);Ws=r(Ui,"TFEncoderDecoderModel.from_pretrained()"),Ui.forEach(t),Gs=r(dr,` currently doesn\u2019t support initializing the model from a
pytorch checkpoint. Passing `),wn=s(dr,"CODE",{});var Wi=d(wn);Is=r(Wi,"from_pt=True"),Wi.forEach(t),zs=r(dr,` to this method will throw an exception. If there are only pytorch
checkpoints for a particular encoder-decoder model, a workaround is:`),dr.forEach(t),Er=p(o),M(_o.$$.fragment,o),jr=p(o),le=s(o,"H2",{class:!0});var Or=d(le);Ie=s(Or,"A",{id:!0,class:!0,href:!0});var Gi=d(Ie);Tn=s(Gi,"SPAN",{});var Ii=d(Tn);M(yo.$$.fragment,Ii),Ii.forEach(t),Gi.forEach(t),Vs=p(Or),kn=s(Or,"SPAN",{});var zi=d(kn);$s=r(zi,"Training"),zi.forEach(t),Or.forEach(t),Zr=p(o),B=s(o,"P",{});var oe=d(B);Rs=r(oe,`Once the model is created, it can be fine-tuned similar to BART, T5 or any other encoder-decoder model.
As you can see, only 2 inputs are required for the model in order to compute a loss: `),Jn=s(oe,"CODE",{});var Vi=d(Jn);Bs=r(Vi,"input_ids"),Vi.forEach(t),Fs=r(oe,` (which are the
`),En=s(oe,"CODE",{});var $i=d(En);Cs=r($i,"input_ids"),$i.forEach(t),xs=r(oe," of the encoded input sequence) and "),jn=s(oe,"CODE",{});var Ri=d(jn);Ds=r(Ri,"labels"),Ri.forEach(t),Ns=r(oe," (which are the "),Zn=s(oe,"CODE",{});var Bi=d(Zn);qs=r(Bi,"input_ids"),Bi.forEach(t),Xs=r(oe,` of the encoded
target sequence).`),oe.forEach(t),Ur=p(o),M(bo.$$.fragment,o),Wr=p(o),ze=s(o,"P",{});var Kr=d(ze);Ss=r(Kr,"Detailed "),Mo=s(Kr,"A",{href:!0,rel:!0});var Fi=d(Mo);Ys=r(Fi,"colab"),Fi.forEach(t),As=r(Kr," for training."),Kr.forEach(t),Gr=p(o),P=s(o,"P",{});var Nt=d(P);Hs=r(Nt,"This model was contributed by "),vo=s(Nt,"A",{href:!0,rel:!0});var Ci=d(vo);Ps=r(Ci,"thomwolf"),Ci.forEach(t),Qs=r(Nt,`. This model\u2019s TensorFlow and Flax versions
were contributed by `),wo=s(Nt,"A",{href:!0,rel:!0});var xi=d(wo);Ls=r(xi,"ydshieh"),xi.forEach(t),Os=r(Nt,"."),Nt.forEach(t),Ir=p(o),ce=s(o,"H2",{class:!0});var ea=d(ce);Ve=s(ea,"A",{id:!0,class:!0,href:!0});var Di=d(Ve);Un=s(Di,"SPAN",{});var Ni=d(Un);M(To.$$.fragment,Ni),Ni.forEach(t),Di.forEach(t),Ks=p(ea),Wn=s(ea,"SPAN",{});var qi=d(Wn);ed=r(qi,"EncoderDecoderConfig"),qi.forEach(t),ea.forEach(t),zr=p(o),$=s(o,"DIV",{class:!0});var q=d($);M(ko.$$.fragment,q),od=p(q),$e=s(q,"P",{});var lr=d($e);bt=s(lr,"A",{href:!0});var Xi=d(bt);td=r(Xi,"EncoderDecoderConfig"),Xi.forEach(t),nd=r(lr," is the configuration class to store the configuration of a "),Mt=s(lr,"A",{href:!0});var Si=d(Mt);rd=r(Si,"EncoderDecoderModel"),Si.forEach(t),ad=r(lr,`. It is
used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder
configs.`),lr.forEach(t),sd=p(q),ie=s(q,"P",{});var qt=d(ie);dd=r(qt,"Configuration objects inherit from "),vt=s(qt,"A",{href:!0});var Yi=d(vt);ld=r(Yi,"PretrainedConfig"),Yi.forEach(t),cd=r(qt,` and can be used to control the model outputs. Read the
documentation from `),wt=s(qt,"A",{href:!0});var Ai=d(wt);id=r(Ai,"PretrainedConfig"),Ai.forEach(t),pd=r(qt," for more information."),qt.forEach(t),md=p(q),M(Re.$$.fragment,q),hd=p(q),Be=s(q,"DIV",{class:!0});var oa=d(Be);M(Jo.$$.fragment,oa),fd=p(oa),Eo=s(oa,"P",{});var ta=d(Eo);ud=r(ta,"Instantiate a "),Tt=s(ta,"A",{href:!0});var Hi=d(Tt);gd=r(Hi,"EncoderDecoderConfig"),Hi.forEach(t),_d=r(ta,` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),ta.forEach(t),oa.forEach(t),yd=p(q),Fe=s(q,"DIV",{class:!0});var na=d(Fe);M(jo.$$.fragment,na),bd=p(na),pe=s(na,"P",{});var Xt=d(pe);Md=r(Xt,"Serializes this instance to a Python dictionary. Override the default "),Gn=s(Xt,"EM",{});var Pi=d(Gn);vd=r(Pi,"to_dict()"),Pi.forEach(t),wd=r(Xt," from "),In=s(Xt,"EM",{});var Qi=d(In);Td=r(Qi,"PretrainedConfig"),Qi.forEach(t),kd=r(Xt,"."),Xt.forEach(t),na.forEach(t),q.forEach(t),Vr=p(o),me=s(o,"H2",{class:!0});var ra=d(me);Ce=s(ra,"A",{id:!0,class:!0,href:!0});var Li=d(Ce);zn=s(Li,"SPAN",{});var Oi=d(zn);M(Zo.$$.fragment,Oi),Oi.forEach(t),Li.forEach(t),Jd=p(ra),Vn=s(ra,"SPAN",{});var Ki=d(Vn);Ed=r(Ki,"EncoderDecoderModel"),Ki.forEach(t),ra.forEach(t),$r=p(o),j=s(o,"DIV",{class:!0});var I=d(j);M(Uo.$$.fragment,I),jd=p(I),he=s(I,"P",{});var St=d(he);Zd=r(St,`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),kt=s(St,"A",{href:!0});var ep=d(kt);Ud=r(ep,"from_pretrained()"),ep.forEach(t),Wd=r(St," function and the decoder is loaded via "),Jt=s(St,"A",{href:!0});var op=d(Jt);Gd=r(op,"from_pretrained()"),op.forEach(t),Id=r(St,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),St.forEach(t),zd=p(I),Wo=s(I,"P",{});var aa=d(Wo);Vd=r(aa,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Go=s(aa,"A",{href:!0,rel:!0});var tp=d(Go);$d=r(tp,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),tp.forEach(t),Rd=r(aa,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),aa.forEach(t),Bd=p(I),$n=s(I,"P",{});var np=d($n);Fd=r(np,`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),np.forEach(t),Cd=p(I),Io=s(I,"P",{});var sa=d(Io);xd=r(sa,"This model inherits from "),Et=s(sa,"A",{href:!0});var rp=d(Et);Dd=r(rp,"PreTrainedModel"),rp.forEach(t),Nd=r(sa,`. 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.)`),sa.forEach(t),qd=p(I),zo=s(I,"P",{});var da=d(zo);Xd=r(da,"This model is also a PyTorch "),Vo=s(da,"A",{href:!0,rel:!0});var ap=d(Vo);Sd=r(ap,"torch.nn.Module"),ap.forEach(t),Yd=r(da,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),da.forEach(t),Ad=p(I),Q=s(I,"P",{});var at=d(Q);jt=s(at,"A",{href:!0});var sp=d(jt);Hd=r(sp,"EncoderDecoderModel"),sp.forEach(t),Pd=r(at,` is a generic model class that will be instantiated as a transformer architecture with one
of the base model classes of the library as encoder and another one as decoder when created with the
:meth`),Rn=s(at,"EM",{});var dp=d(Rn);Qd=r(dp,"~transformers.AutoModel.from_pretrained"),dp.forEach(t),Ld=r(at,` class method for the encoder and
:meth`),Bn=s(at,"EM",{});var lp=d(Bn);Od=r(lp,"~transformers.AutoModelForCausalLM.from_pretrained"),lp.forEach(t),Kd=r(at," class method for the decoder."),at.forEach(t),el=p(I),C=s(I,"DIV",{class:!0});var Oe=d(C);M($o.$$.fragment,Oe),ol=p(Oe),fe=s(Oe,"P",{});var Yt=d(fe);tl=r(Yt,"The "),Zt=s(Yt,"A",{href:!0});var cp=d(Zt);nl=r(cp,"EncoderDecoderModel"),cp.forEach(t),rl=r(Yt," forward method, overrides the "),Fn=s(Yt,"CODE",{});var ip=d(Fn);al=r(ip,"__call__"),ip.forEach(t),sl=r(Yt," special method."),Yt.forEach(t),dl=p(Oe),M(xe.$$.fragment,Oe),ll=p(Oe),M(De.$$.fragment,Oe),Oe.forEach(t),cl=p(I),x=s(I,"DIV",{class:!0});var Ke=d(x);M(Ro.$$.fragment,Ke),il=p(Ke),Cn=s(Ke,"P",{});var pp=d(Cn);pl=r(pp,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),pp.forEach(t),ml=p(Ke),ue=s(Ke,"P",{});var At=d(ue);hl=r(At,"The model is set in evaluation mode by default using "),xn=s(At,"CODE",{});var mp=d(xn);fl=r(mp,"model.eval()"),mp.forEach(t),ul=r(At,` (Dropout modules are deactivated). To train
the model, you need to first set it back in training mode with `),Dn=s(At,"CODE",{});var hp=d(Dn);gl=r(hp,"model.train()"),hp.forEach(t),_l=r(At,"."),At.forEach(t),yl=p(Ke),M(Ne.$$.fragment,Ke),Ke.forEach(t),I.forEach(t),Rr=p(o),ge=s(o,"H2",{class:!0});var la=d(ge);qe=s(la,"A",{id:!0,class:!0,href:!0});var fp=d(qe);Nn=s(fp,"SPAN",{});var up=d(Nn);M(Bo.$$.fragment,up),up.forEach(t),fp.forEach(t),bl=p(la),qn=s(la,"SPAN",{});var gp=d(qn);Ml=r(gp,"TFEncoderDecoderModel"),gp.forEach(t),la.forEach(t),Br=p(o),Z=s(o,"DIV",{class:!0});var z=d(Z);M(Fo.$$.fragment,z),vl=p(z),_e=s(z,"P",{});var Ht=d(_e);wl=r(Ht,`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),Ut=s(Ht,"A",{href:!0});var _p=d(Ut);Tl=r(_p,"from_pretrained()"),_p.forEach(t),kl=r(Ht," function and the decoder is loaded via "),Wt=s(Ht,"A",{href:!0});var yp=d(Wt);Jl=r(yp,"from_pretrained()"),yp.forEach(t),El=r(Ht,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),Ht.forEach(t),jl=p(z),Co=s(z,"P",{});var ca=d(Co);Zl=r(ca,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),xo=s(ca,"A",{href:!0,rel:!0});var bp=d(xo);Ul=r(bp,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),bp.forEach(t),Wl=r(ca,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),ca.forEach(t),Gl=p(z),Xn=s(z,"P",{});var Mp=d(Xn);Il=r(Mp,`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),Mp.forEach(t),zl=p(z),Do=s(z,"P",{});var ia=d(Do);Vl=r(ia,"This model inherits from "),Gt=s(ia,"A",{href:!0});var vp=d(Gt);$l=r(vp,"TFPreTrainedModel"),vp.forEach(t),Rl=r(ia,`. 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.)`),ia.forEach(t),Bl=p(z),No=s(z,"P",{});var pa=d(No);Fl=r(pa,"This model is also a "),qo=s(pa,"A",{href:!0,rel:!0});var wp=d(qo);Cl=r(wp,"tf.keras.Model"),wp.forEach(t),xl=r(pa,` 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.`),pa.forEach(t),Dl=p(z),L=s(z,"P",{});var st=d(L);It=s(st,"A",{href:!0});var Tp=d(It);Nl=r(Tp,"TFEncoderDecoderModel"),Tp.forEach(t),ql=r(st,` is a generic model class that will be instantiated as a transformer architecture with one
of the base model classes of the library as encoder and another one as decoder when created with the
`),zt=s(st,"A",{href:!0});var kp=d(zt);Xl=r(kp,"from_pretrained()"),kp.forEach(t),Sl=r(st," class method for the encoder and "),Vt=s(st,"A",{href:!0});var Jp=d(Vt);Yl=r(Jp,"from_pretrained()"),Jp.forEach(t),Al=r(st,` class
method for the decoder.`),st.forEach(t),Hl=p(z),D=s(z,"DIV",{class:!0});var eo=d(D);M(Xo.$$.fragment,eo),Pl=p(eo),ye=s(eo,"P",{});var Pt=d(ye);Ql=r(Pt,"The "),$t=s(Pt,"A",{href:!0});var Ep=d($t);Ll=r(Ep,"TFEncoderDecoderModel"),Ep.forEach(t),Ol=r(Pt," forward method, overrides the "),Sn=s(Pt,"CODE",{});var jp=d(Sn);Kl=r(jp,"__call__"),jp.forEach(t),ec=r(Pt," special method."),Pt.forEach(t),oc=p(eo),M(Xe.$$.fragment,eo),tc=p(eo),M(Se.$$.fragment,eo),eo.forEach(t),nc=p(z),O=s(z,"DIV",{class:!0});var Qt=d(O);M(So.$$.fragment,Qt),rc=p(Qt),Yn=s(Qt,"P",{});var Zp=d(Yn);ac=r(Zp,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Zp.forEach(t),sc=p(Qt),M(Ye.$$.fragment,Qt),Qt.forEach(t),z.forEach(t),Fr=p(o),be=s(o,"H2",{class:!0});var ma=d(be);Ae=s(ma,"A",{id:!0,class:!0,href:!0});var Up=d(Ae);An=s(Up,"SPAN",{});var Wp=d(An);M(Yo.$$.fragment,Wp),Wp.forEach(t),Up.forEach(t),dc=p(ma),Hn=s(ma,"SPAN",{});var Gp=d(Hn);lc=r(Gp,"FlaxEncoderDecoderModel"),Gp.forEach(t),ma.forEach(t),Cr=p(o),U=s(o,"DIV",{class:!0});var V=d(U);M(Ao.$$.fragment,V),cc=p(V),Me=s(V,"P",{});var Lt=d(Me);ic=r(Lt,`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),Rt=s(Lt,"A",{href:!0});var Ip=d(Rt);pc=r(Ip,"from_pretrained()"),Ip.forEach(t),mc=r(Lt," function and the decoder is loaded via "),Bt=s(Lt,"A",{href:!0});var zp=d(Bt);hc=r(zp,"from_pretrained()"),zp.forEach(t),fc=r(Lt,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),Lt.forEach(t),uc=p(V),Ho=s(V,"P",{});var ha=d(Ho);gc=r(ha,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Po=s(ha,"A",{href:!0,rel:!0});var Vp=d(Po);_c=r(Vp,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),Vp.forEach(t),yc=r(ha,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),ha.forEach(t),bc=p(V),Pn=s(V,"P",{});var $p=d(Pn);Mc=r($p,`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),$p.forEach(t),vc=p(V),Qo=s(V,"P",{});var fa=d(Qo);wc=r(fa,"This model inherits from "),Ft=s(fa,"A",{href:!0});var Rp=d(Ft);Tc=r(Rp,"FlaxPreTrainedModel"),Rp.forEach(t),kc=r(fa,`. 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.)`),fa.forEach(t),Jc=p(V),Lo=s(V,"P",{});var ua=d(Lo);Ec=r(ua,`This model is also a Flax Linen
`),Oo=s(ua,"A",{href:!0,rel:!0});var Bp=d(Oo);jc=r(Bp,"flax.nn.Module"),Bp.forEach(t),Zc=r(ua,` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),ua.forEach(t),Uc=p(V),K=s(V,"P",{});var dt=d(K);Ct=s(dt,"A",{href:!0});var Fp=d(Ct);Wc=r(Fp,"FlaxEncoderDecoderModel"),Fp.forEach(t),Gc=r(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 model classes of the library as encoder module and another one as
decoder module when created with the :meth`),Qn=s(dt,"EM",{});var Cp=d(Qn);Ic=r(Cp,"~transformers.FlaxAutoModel.from_pretrained"),Cp.forEach(t),zc=r(dt,` class method for the
encoder and :meth`),Ln=s(dt,"EM",{});var xp=d(Ln);Vc=r(xp,"~transformers.FlaxAutoModelForCausalLM.from_pretrained"),xp.forEach(t),$c=r(dt," class method for the decoder."),dt.forEach(t),Rc=p(V),N=s(V,"DIV",{class:!0});var oo=d(N);M(Ko.$$.fragment,oo),Bc=p(oo),ve=s(oo,"P",{});var Ot=d(ve);Fc=r(Ot,"The "),xt=s(Ot,"A",{href:!0});var Dp=d(xt);Cc=r(Dp,"FlaxEncoderDecoderModel"),Dp.forEach(t),xc=r(Ot," forward method, overrides the "),On=s(Ot,"CODE",{});var Np=d(On);Dc=r(Np,"__call__"),Np.forEach(t),Nc=r(Ot," special method."),Ot.forEach(t),qc=p(oo),M(He.$$.fragment,oo),Xc=p(oo),M(Pe.$$.fragment,oo),oo.forEach(t),Sc=p(V),ee=s(V,"DIV",{class:!0});var Kt=d(ee);M(et.$$.fragment,Kt),Yc=p(Kt),Kn=s(Kt,"P",{});var qp=d(Kn);Ac=r(qp,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),qp.forEach(t),Hc=p(Kt),M(Qe.$$.fragment,Kt),Kt.forEach(t),V.forEach(t),this.h()},h(){c(h,"name","hf:doc:metadata"),c(h,"content",JSON.stringify(sm)),c(f,"id","encoder-decoder-models"),c(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"),c(f,"href","#encoder-decoder-models"),c(_,"class","relative group"),c(we,"id","overview"),c(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"),c(we,"href","#overview"),c(te,"class","relative group"),c(it,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(no,"href","https://arxiv.org/abs/1907.12461"),c(no,"rel","nofollow"),c(pt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(mt,"href","/docs/transformers/v4.30.0/en/model_doc/bert#transformers.BertModel"),c(ro,"href","https://arxiv.org/abs/1908.08345"),c(ro,"rel","nofollow"),c(Ee,"id","randomly-initializing-encoderdecodermodel-from-model-configurations"),c(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"),c(Ee,"href","#randomly-initializing-encoderdecodermodel-from-model-configurations"),c(ne,"class","relative group"),c(ht,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(ft,"href","/docs/transformers/v4.30.0/en/model_doc/bert#transformers.BertModel"),c(je,"id","initialising-encoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder"),c(je,"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"),c(je,"href","#initialising-encoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder"),c(re,"class","relative group"),c(ut,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(gt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(Ze,"href","https://huggingface.co/blog/warm-starting-encoder-decoder"),c(Ze,"rel","nofollow"),c(_t,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel.from_encoder_decoder_pretrained"),c(Ue,"id","loading-an-existing-encoderdecodermodel-checkpoint-and-perform-inference"),c(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"),c(Ue,"href","#loading-an-existing-encoderdecodermodel-checkpoint-and-perform-inference"),c(ae,"class","relative group"),c(yt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(Ge,"id","loading-a-pytorch-checkpoint-into-tfencoderdecodermodel"),c(Ge,"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"),c(Ge,"href","#loading-a-pytorch-checkpoint-into-tfencoderdecodermodel"),c(se,"class","relative group"),c(Ie,"id","training"),c(Ie,"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"),c(Ie,"href","#training"),c(le,"class","relative group"),c(Mo,"href","https://colab.research.google.com/drive/1WIk2bxglElfZewOHboPFNj8H44_VAyKE?usp=sharing#scrollTo=ZwQIEhKOrJpl"),c(Mo,"rel","nofollow"),c(vo,"href","https://github.com/thomwolf"),c(vo,"rel","nofollow"),c(wo,"href","https://github.com/ydshieh"),c(wo,"rel","nofollow"),c(Ve,"id","transformers.EncoderDecoderConfig"),c(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"),c(Ve,"href","#transformers.EncoderDecoderConfig"),c(ce,"class","relative group"),c(bt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"),c(Mt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(vt,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(wt,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(Tt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"),c(Be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ce,"id","transformers.EncoderDecoderModel"),c(Ce,"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"),c(Ce,"href","#transformers.EncoderDecoderModel"),c(me,"class","relative group"),c(kt,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Jt,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Go,"href","https://arxiv.org/abs/1907.12461"),c(Go,"rel","nofollow"),c(Et,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),c(Vo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Vo,"rel","nofollow"),c(jt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(Zt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(qe,"id","transformers.TFEncoderDecoderModel"),c(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"),c(qe,"href","#transformers.TFEncoderDecoderModel"),c(ge,"class","relative group"),c(Ut,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Wt,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(xo,"href","https://arxiv.org/abs/1907.12461"),c(xo,"rel","nofollow"),c(Gt,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.TFPreTrainedModel"),c(qo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),c(qo,"rel","nofollow"),c(It,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.TFEncoderDecoderModel"),c(zt,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Vt,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c($t,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.TFEncoderDecoderModel"),c(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Ae,"id","transformers.FlaxEncoderDecoderModel"),c(Ae,"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"),c(Ae,"href","#transformers.FlaxEncoderDecoderModel"),c(be,"class","relative group"),c(Rt,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Bt,"href","/docs/transformers/v4.30.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Po,"href","https://arxiv.org/abs/1907.12461"),c(Po,"rel","nofollow"),c(Ft,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.FlaxPreTrainedModel"),c(Oo,"href","https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html"),c(Oo,"rel","nofollow"),c(Ct,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.FlaxEncoderDecoderModel"),c(xt,"href","/docs/transformers/v4.30.0/en/model_doc/encoder-decoder#transformers.FlaxEncoderDecoderModel"),c(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(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,J,m),u(o,_,m),e(_,f),e(f,y),v(l,y,null),e(_,g),e(_,R),e(R,ga),u(o,cr,m),u(o,te,m),e(te,we),e(we,en),v(to,en,null),e(te,_a),e(te,on),e(on,ya),u(o,ir,m),u(o,Te,m),e(Te,ba),e(Te,it),e(it,Ma),e(Te,va),u(o,pr,m),u(o,ke,m),e(ke,wa),e(ke,no),e(no,Ta),e(ke,ka),u(o,mr,m),u(o,Je,m),e(Je,Ja),e(Je,pt),e(pt,Ea),e(Je,ja),u(o,hr,m),u(o,H,m),e(H,Za),e(H,mt),e(mt,Ua),e(H,Wa),e(H,ro),e(ro,Ga),e(H,Ia),u(o,fr,m),u(o,ne,m),e(ne,Ee),e(Ee,tn),v(ao,tn,null),e(ne,za),e(ne,so),e(so,Va),e(so,nn),e(nn,$a),e(so,Ra),u(o,ur,m),u(o,Y,m),e(Y,ht),e(ht,Ba),e(Y,Fa),e(Y,ft),e(ft,Ca),e(Y,xa),e(Y,rn),e(rn,Da),e(Y,Na),u(o,gr,m),v(lo,o,m),u(o,_r,m),u(o,re,m),e(re,je),e(je,an),v(co,an,null),e(re,qa),e(re,io),e(io,Xa),e(io,sn),e(sn,Sa),e(io,Ya),u(o,yr,m),u(o,E,m),e(E,ut),e(ut,Aa),e(E,Ha),e(E,dn),e(dn,Pa),e(E,Qa),e(E,ln),e(ln,La),e(E,Oa),e(E,cn),e(cn,Ka),e(E,es),e(E,pn),e(pn,os),e(E,ts),e(E,gt),e(gt,ns),e(E,rs),e(E,Ze),e(Ze,as),e(Ze,mn),e(mn,ss),e(E,ds),e(E,hn),e(hn,ls),e(E,cs),e(E,_t),e(_t,is),e(E,ps),u(o,br,m),v(po,o,m),u(o,Mr,m),u(o,ae,m),e(ae,Ue),e(Ue,fn),v(mo,fn,null),e(ae,ms),e(ae,ho),e(ho,hs),e(ho,un),e(un,fs),e(ho,us),u(o,vr,m),u(o,F,m),e(F,gs),e(F,gn),e(gn,_s),e(F,ys),e(F,yt),e(yt,bs),e(F,Ms),e(F,_n),e(_n,vs),e(F,ws),u(o,wr,m),u(o,We,m),e(We,Ts),e(We,yn),e(yn,ks),e(We,Js),u(o,Tr,m),v(fo,o,m),u(o,kr,m),u(o,se,m),e(se,Ge),e(Ge,bn),v(uo,bn,null),e(se,Es),e(se,go),e(go,js),e(go,Mn),e(Mn,Zs),e(go,Us),u(o,Jr,m),u(o,de,m),e(de,vn),e(vn,Ws),e(de,Gs),e(de,wn),e(wn,Is),e(de,zs),u(o,Er,m),v(_o,o,m),u(o,jr,m),u(o,le,m),e(le,Ie),e(Ie,Tn),v(yo,Tn,null),e(le,Vs),e(le,kn),e(kn,$s),u(o,Zr,m),u(o,B,m),e(B,Rs),e(B,Jn),e(Jn,Bs),e(B,Fs),e(B,En),e(En,Cs),e(B,xs),e(B,jn),e(jn,Ds),e(B,Ns),e(B,Zn),e(Zn,qs),e(B,Xs),u(o,Ur,m),v(bo,o,m),u(o,Wr,m),u(o,ze,m),e(ze,Ss),e(ze,Mo),e(Mo,Ys),e(ze,As),u(o,Gr,m),u(o,P,m),e(P,Hs),e(P,vo),e(vo,Ps),e(P,Qs),e(P,wo),e(wo,Ls),e(P,Os),u(o,Ir,m),u(o,ce,m),e(ce,Ve),e(Ve,Un),v(To,Un,null),e(ce,Ks),e(ce,Wn),e(Wn,ed),u(o,zr,m),u(o,$,m),v(ko,$,null),e($,od),e($,$e),e($e,bt),e(bt,td),e($e,nd),e($e,Mt),e(Mt,rd),e($e,ad),e($,sd),e($,ie),e(ie,dd),e(ie,vt),e(vt,ld),e(ie,cd),e(ie,wt),e(wt,id),e(ie,pd),e($,md),v(Re,$,null),e($,hd),e($,Be),v(Jo,Be,null),e(Be,fd),e(Be,Eo),e(Eo,ud),e(Eo,Tt),e(Tt,gd),e(Eo,_d),e($,yd),e($,Fe),v(jo,Fe,null),e(Fe,bd),e(Fe,pe),e(pe,Md),e(pe,Gn),e(Gn,vd),e(pe,wd),e(pe,In),e(In,Td),e(pe,kd),u(o,Vr,m),u(o,me,m),e(me,Ce),e(Ce,zn),v(Zo,zn,null),e(me,Jd),e(me,Vn),e(Vn,Ed),u(o,$r,m),u(o,j,m),v(Uo,j,null),e(j,jd),e(j,he),e(he,Zd),e(he,kt),e(kt,Ud),e(he,Wd),e(he,Jt),e(Jt,Gd),e(he,Id),e(j,zd),e(j,Wo),e(Wo,Vd),e(Wo,Go),e(Go,$d),e(Wo,Rd),e(j,Bd),e(j,$n),e($n,Fd),e(j,Cd),e(j,Io),e(Io,xd),e(Io,Et),e(Et,Dd),e(Io,Nd),e(j,qd),e(j,zo),e(zo,Xd),e(zo,Vo),e(Vo,Sd),e(zo,Yd),e(j,Ad),e(j,Q),e(Q,jt),e(jt,Hd),e(Q,Pd),e(Q,Rn),e(Rn,Qd),e(Q,Ld),e(Q,Bn),e(Bn,Od),e(Q,Kd),e(j,el),e(j,C),v($o,C,null),e(C,ol),e(C,fe),e(fe,tl),e(fe,Zt),e(Zt,nl),e(fe,rl),e(fe,Fn),e(Fn,al),e(fe,sl),e(C,dl),v(xe,C,null),e(C,ll),v(De,C,null),e(j,cl),e(j,x),v(Ro,x,null),e(x,il),e(x,Cn),e(Cn,pl),e(x,ml),e(x,ue),e(ue,hl),e(ue,xn),e(xn,fl),e(ue,ul),e(ue,Dn),e(Dn,gl),e(ue,_l),e(x,yl),v(Ne,x,null),u(o,Rr,m),u(o,ge,m),e(ge,qe),e(qe,Nn),v(Bo,Nn,null),e(ge,bl),e(ge,qn),e(qn,Ml),u(o,Br,m),u(o,Z,m),v(Fo,Z,null),e(Z,vl),e(Z,_e),e(_e,wl),e(_e,Ut),e(Ut,Tl),e(_e,kl),e(_e,Wt),e(Wt,Jl),e(_e,El),e(Z,jl),e(Z,Co),e(Co,Zl),e(Co,xo),e(xo,Ul),e(Co,Wl),e(Z,Gl),e(Z,Xn),e(Xn,Il),e(Z,zl),e(Z,Do),e(Do,Vl),e(Do,Gt),e(Gt,$l),e(Do,Rl),e(Z,Bl),e(Z,No),e(No,Fl),e(No,qo),e(qo,Cl),e(No,xl),e(Z,Dl),e(Z,L),e(L,It),e(It,Nl),e(L,ql),e(L,zt),e(zt,Xl),e(L,Sl),e(L,Vt),e(Vt,Yl),e(L,Al),e(Z,Hl),e(Z,D),v(Xo,D,null),e(D,Pl),e(D,ye),e(ye,Ql),e(ye,$t),e($t,Ll),e(ye,Ol),e(ye,Sn),e(Sn,Kl),e(ye,ec),e(D,oc),v(Xe,D,null),e(D,tc),v(Se,D,null),e(Z,nc),e(Z,O),v(So,O,null),e(O,rc),e(O,Yn),e(Yn,ac),e(O,sc),v(Ye,O,null),u(o,Fr,m),u(o,be,m),e(be,Ae),e(Ae,An),v(Yo,An,null),e(be,dc),e(be,Hn),e(Hn,lc),u(o,Cr,m),u(o,U,m),v(Ao,U,null),e(U,cc),e(U,Me),e(Me,ic),e(Me,Rt),e(Rt,pc),e(Me,mc),e(Me,Bt),e(Bt,hc),e(Me,fc),e(U,uc),e(U,Ho),e(Ho,gc),e(Ho,Po),e(Po,_c),e(Ho,yc),e(U,bc),e(U,Pn),e(Pn,Mc),e(U,vc),e(U,Qo),e(Qo,wc),e(Qo,Ft),e(Ft,Tc),e(Qo,kc),e(U,Jc),e(U,Lo),e(Lo,Ec),e(Lo,Oo),e(Oo,jc),e(Lo,Zc),e(U,Uc),e(U,K),e(K,Ct),e(Ct,Wc),e(K,Gc),e(K,Qn),e(Qn,Ic),e(K,zc),e(K,Ln),e(Ln,Vc),e(K,$c),e(U,Rc),e(U,N),v(Ko,N,null),e(N,Bc),e(N,ve),e(ve,Fc),e(ve,xt),e(xt,Cc),e(ve,xc),e(ve,On),e(On,Dc),e(ve,Nc),e(N,qc),v(He,N,null),e(N,Xc),v(Pe,N,null),e(U,Sc),e(U,ee),v(et,ee,null),e(ee,Yc),e(ee,Kn),e(Kn,Ac),e(ee,Hc),v(Qe,ee,null),xr=!0},p(o,[m]){const ot={};m&2&&(ot.$$scope={dirty:m,ctx:o}),Re.$set(ot);const er={};m&2&&(er.$$scope={dirty:m,ctx:o}),xe.$set(er);const or={};m&2&&(or.$$scope={dirty:m,ctx:o}),De.$set(or);const tr={};m&2&&(tr.$$scope={dirty:m,ctx:o}),Ne.$set(tr);const tt={};m&2&&(tt.$$scope={dirty:m,ctx:o}),Xe.$set(tt);const nr={};m&2&&(nr.$$scope={dirty:m,ctx:o}),Se.$set(nr);const rr={};m&2&&(rr.$$scope={dirty:m,ctx:o}),Ye.$set(rr);const ar={};m&2&&(ar.$$scope={dirty:m,ctx:o}),He.$set(ar);const nt={};m&2&&(nt.$$scope={dirty:m,ctx:o}),Pe.$set(nt);const sr={};m&2&&(sr.$$scope={dirty:m,ctx:o}),Qe.$set(sr)},i(o){xr||(w(l.$$.fragment,o),w(to.$$.fragment,o),w(ao.$$.fragment,o),w(lo.$$.fragment,o),w(co.$$.fragment,o),w(po.$$.fragment,o),w(mo.$$.fragment,o),w(fo.$$.fragment,o),w(uo.$$.fragment,o),w(_o.$$.fragment,o),w(yo.$$.fragment,o),w(bo.$$.fragment,o),w(To.$$.fragment,o),w(ko.$$.fragment,o),w(Re.$$.fragment,o),w(Jo.$$.fragment,o),w(jo.$$.fragment,o),w(Zo.$$.fragment,o),w(Uo.$$.fragment,o),w($o.$$.fragment,o),w(xe.$$.fragment,o),w(De.$$.fragment,o),w(Ro.$$.fragment,o),w(Ne.$$.fragment,o),w(Bo.$$.fragment,o),w(Fo.$$.fragment,o),w(Xo.$$.fragment,o),w(Xe.$$.fragment,o),w(Se.$$.fragment,o),w(So.$$.fragment,o),w(Ye.$$.fragment,o),w(Yo.$$.fragment,o),w(Ao.$$.fragment,o),w(Ko.$$.fragment,o),w(He.$$.fragment,o),w(Pe.$$.fragment,o),w(et.$$.fragment,o),w(Qe.$$.fragment,o),xr=!0)},o(o){T(l.$$.fragment,o),T(to.$$.fragment,o),T(ao.$$.fragment,o),T(lo.$$.fragment,o),T(co.$$.fragment,o),T(po.$$.fragment,o),T(mo.$$.fragment,o),T(fo.$$.fragment,o),T(uo.$$.fragment,o),T(_o.$$.fragment,o),T(yo.$$.fragment,o),T(bo.$$.fragment,o),T(To.$$.fragment,o),T(ko.$$.fragment,o),T(Re.$$.fragment,o),T(Jo.$$.fragment,o),T(jo.$$.fragment,o),T(Zo.$$.fragment,o),T(Uo.$$.fragment,o),T($o.$$.fragment,o),T(xe.$$.fragment,o),T(De.$$.fragment,o),T(Ro.$$.fragment,o),T(Ne.$$.fragment,o),T(Bo.$$.fragment,o),T(Fo.$$.fragment,o),T(Xo.$$.fragment,o),T(Xe.$$.fragment,o),T(Se.$$.fragment,o),T(So.$$.fragment,o),T(Ye.$$.fragment,o),T(Yo.$$.fragment,o),T(Ao.$$.fragment,o),T(Ko.$$.fragment,o),T(He.$$.fragment,o),T(Pe.$$.fragment,o),T(et.$$.fragment,o),T(Qe.$$.fragment,o),xr=!1},d(o){t(h),o&&t(J),o&&t(_),k(l),o&&t(cr),o&&t(te),k(to),o&&t(ir),o&&t(Te),o&&t(pr),o&&t(ke),o&&t(mr),o&&t(Je),o&&t(hr),o&&t(H),o&&t(fr),o&&t(ne),k(ao),o&&t(ur),o&&t(Y),o&&t(gr),k(lo,o),o&&t(_r),o&&t(re),k(co),o&&t(yr),o&&t(E),o&&t(br),k(po,o),o&&t(Mr),o&&t(ae),k(mo),o&&t(vr),o&&t(F),o&&t(wr),o&&t(We),o&&t(Tr),k(fo,o),o&&t(kr),o&&t(se),k(uo),o&&t(Jr),o&&t(de),o&&t(Er),k(_o,o),o&&t(jr),o&&t(le),k(yo),o&&t(Zr),o&&t(B),o&&t(Ur),k(bo,o),o&&t(Wr),o&&t(ze),o&&t(Gr),o&&t(P),o&&t(Ir),o&&t(ce),k(To),o&&t(zr),o&&t($),k(ko),k(Re),k(Jo),k(jo),o&&t(Vr),o&&t(me),k(Zo),o&&t($r),o&&t(j),k(Uo),k($o),k(xe),k(De),k(Ro),k(Ne),o&&t(Rr),o&&t(ge),k(Bo),o&&t(Br),o&&t(Z),k(Fo),k(Xo),k(Xe),k(Se),k(So),k(Ye),o&&t(Fr),o&&t(be),k(Yo),o&&t(Cr),o&&t(U),k(Ao),k(Ko),k(He),k(Pe),k(et),k(Qe)}}}const sm={local:"encoder-decoder-models",sections:[{local:"overview",title:"Overview"},{local:"randomly-initializing-encoderdecodermodel-from-model-configurations",title:"Randomly initializing `EncoderDecoderModel` from model configurations."},{local:"initialising-encoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder",title:"Initialising `EncoderDecoderModel` from a pretrained encoder and a pretrained decoder."},{local:"loading-an-existing-encoderdecodermodel-checkpoint-and-perform-inference",title:"Loading an existing `EncoderDecoderModel` checkpoint and perform inference."},{local:"loading-a-pytorch-checkpoint-into-tfencoderdecodermodel",title:"Loading a PyTorch checkpoint into `TFEncoderDecoderModel`."},{local:"training",title:"Training"},{local:"transformers.EncoderDecoderConfig",title:"EncoderDecoderConfig"},{local:"transformers.EncoderDecoderModel",title:"EncoderDecoderModel"},{local:"transformers.TFEncoderDecoderModel",title:"TFEncoderDecoderModel"},{local:"transformers.FlaxEncoderDecoderModel",title:"FlaxEncoderDecoderModel"}],title:"Encoder Decoder Models"};function dm(W){return Hp(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fm extends Xp{constructor(h){super();Sp(this,h,dm,am,Yp,{})}}export{fm as default,sm as metadata};
