import{s as pt,o as ht,n as ye}from"../chunks/scheduler.01eeda35.js";import{S as ut,i as ft,g as h,s as r,r as M,A as gt,h as u,f as d,c as s,j as ie,u as b,x as y,k as de,y as l,a as p,v as T,d as w,t as J,w as Z}from"../chunks/index.6dd51b66.js";import{T as ot}from"../chunks/Tip.de9bae2b.js";import{D as _e}from"../chunks/Docstring.76e6b3cf.js";import{C as me}from"../chunks/CodeBlock.864da1b0.js";import{F as _t,M as at}from"../chunks/Markdown.3138439e.js";import{E as xe}from"../chunks/ExampleCodeBlock.6a36fb6b.js";import{H as ge,E as yt}from"../chunks/EditOnGithub.7faefd25.js";function Mt(W){let n,f="Examples:",t,a,g;return a=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBFbmNvZGVyRGVjb2RlckNvbmZpZyUyQyUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwQkVSVCUyMGdvb2dsZS1iZXJ0JTJGYmVydC1iYXNlLXVuY2FzZWQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWdfZW5jb2RlciUyMCUzRCUyMEJlcnRDb25maWcoKSUwQWNvbmZpZ19kZWNvZGVyJTIwJTNEJTIwQmVydENvbmZpZygpJTBBJTBBY29uZmlnJTIwJTNEJTIwRW5jb2RlckRlY29kZXJDb25maWcuZnJvbV9lbmNvZGVyX2RlY29kZXJfY29uZmlncyhjb25maWdfZW5jb2RlciUyQyUyMGNvbmZpZ19kZWNvZGVyKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBCZXJ0MkJlcnQlMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbnMlMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwoY29uZmlnJTNEY29uZmlnKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ19lbmNvZGVyJTIwJTNEJTIwbW9kZWwuY29uZmlnLmVuY29kZXIlMEFjb25maWdfZGVjb2RlciUyMCUzRCUyMG1vZGVsLmNvbmZpZy5kZWNvZGVyJTBBJTIzJTIwc2V0JTIwZGVjb2RlciUyMGNvbmZpZyUyMHRvJTIwY2F1c2FsJTIwbG0lMEFjb25maWdfZGVjb2Rlci5pc19kZWNvZGVyJTIwJTNEJTIwVHJ1ZSUwQWNvbmZpZ19kZWNvZGVyLmFkZF9jcm9zc19hdHRlbnRpb24lMjAlM0QlMjBUcnVlJTBBJTBBJTIzJTIwU2F2aW5nJTIwdGhlJTIwbW9kZWwlMkMlMjBpbmNsdWRpbmclMjBpdHMlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMm15LW1vZGVsJTIyKSUwQSUwQSUyMyUyMGxvYWRpbmclMjBtb2RlbCUyMGFuZCUyMGNvbmZpZyUyMGZyb20lMjBwcmV0cmFpbmVkJTIwZm9sZGVyJTBBZW5jb2Rlcl9kZWNvZGVyX2NvbmZpZyUyMCUzRCUyMEVuY29kZXJEZWNvZGVyQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjJteS1tb2RlbCUyMiklMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMm15LW1vZGVsJTIyJTJDJTIwY29uZmlnJTNEZW5jb2Rlcl9kZWNvZGVyX2NvbmZpZyk=",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 google-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 (with random weights) from the google-bert/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)`,wrap:!1}}),{c(){n=h("p"),n.textContent=f,t=r(),M(a.$$.fragment)},l(o){n=u(o,"P",{"data-svelte-h":!0}),y(n)!=="svelte-kvfsh7"&&(n.textContent=f),t=s(o),b(a.$$.fragment,o)},m(o,v){p(o,n,v),p(o,t,v),T(a,o,v),g=!0},p:ye,i(o){g||(w(a.$$.fragment,o),g=!0)},o(o){J(a.$$.fragment,o),g=!1},d(o){o&&(d(n),d(t)),Z(a,o)}}}function bt(W){let n,f=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){n=h("p"),n.innerHTML=f},l(t){n=u(t,"P",{"data-svelte-h":!0}),y(n)!=="svelte-fincs2"&&(n.innerHTML=f)},m(t,a){p(t,n,a)},p:ye,d(t){t&&d(n)}}}function Tt(W){let n,f="Examples:",t,a,g;return a=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMkMlMjBCZXJ0VG9rZW5pemVyJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBCZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQW1vZGVsJTIwJTNEJTIwRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX2VuY29kZXJfZGVjb2Rlcl9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmdvb2dsZS1iZXJ0JTJGYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjAlMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS11bmNhc2VkJTIyJTBBKSUyMCUyMCUyMyUyMGluaXRpYWxpemUlMjBCZXJ0MkJlcnQlMjBmcm9tJTIwcHJlLXRyYWluZWQlMjBjaGVja3BvaW50cyUwQSUwQSUyMyUyMHRyYWluaW5nJTBBbW9kZWwuY29uZmlnLmRlY29kZXJfc3RhcnRfdG9rZW5faWQlMjAlM0QlMjB0b2tlbml6ZXIuY2xzX3Rva2VuX2lkJTBBbW9kZWwuY29uZmlnLnBhZF90b2tlbl9pZCUyMCUzRCUyMHRva2VuaXplci5wYWRfdG9rZW5faWQlMEFtb2RlbC5jb25maWcudm9jYWJfc2l6ZSUyMCUzRCUyMG1vZGVsLmNvbmZpZy5kZWNvZGVyLnZvY2FiX3NpemUlMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyVGhpcyUyMGlzJTIwYSUyMHJlYWxseSUyMGxvbmclMjB0ZXh0JTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikuaW5wdXRfaWRzJTBBbGFiZWxzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoaXMlMjBpcyUyMHRoZSUyMGNvcnJlc3BvbmRpbmclMjBzdW1tYXJ5JTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikuaW5wdXRfaWRzJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGxhYmVscyUzRGxhYmVscyklMEFsb3NzJTJDJTIwbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTJDJTIwb3V0cHV0cy5sb2dpdHMlMEElMEElMjMlMjBzYXZlJTIwYW5kJTIwbG9hZCUyMGZyb20lMjBwcmV0cmFpbmVkJTBBbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmJlcnQyYmVydCUyMiklMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQyYmVydCUyMiklMEElMEElMjMlMjBnZW5lcmF0aW9uJTBBZ2VuZXJhdGVkJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzKQ==",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;google-bert/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;google-bert/bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;google-bert/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)`,wrap:!1}}),{c(){n=h("p"),n.textContent=f,t=r(),M(a.$$.fragment)},l(o){n=u(o,"P",{"data-svelte-h":!0}),y(n)!=="svelte-kvfsh7"&&(n.textContent=f),t=s(o),b(a.$$.fragment,o)},m(o,v){p(o,n,v),p(o,t,v),T(a,o,v),g=!0},p:ye,i(o){g||(w(a.$$.fragment,o),g=!0)},o(o){J(a.$$.fragment,o),g=!1},d(o){o&&(d(n),d(t)),Z(a,o)}}}function wt(W){let n,f="Example:",t,a,g;return a=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBpbml0aWFsaXplJTIwYSUyMGJlcnQyYmVydCUyMGZyb20lMjB0d28lMjBwcmV0cmFpbmVkJTIwQkVSVCUyMG1vZGVscy4lMjBOb3RlJTIwdGhhdCUyMHRoZSUyMGNyb3NzLWF0dGVudGlvbiUyMGxheWVycyUyMHdpbGwlMjBiZSUyMHJhbmRvbWx5JTIwaW5pdGlhbGl6ZWQlMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEElMjMlMjBzYXZpbmclMjBtb2RlbCUyMGFmdGVyJTIwZmluZS10dW5pbmclMEFtb2RlbC5zYXZlX3ByZXRyYWluZWQoJTIyLiUyRmJlcnQyYmVydCUyMiklMEElMjMlMjBsb2FkJTIwZmluZS10dW5lZCUyMG1vZGVsJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjIuJTJGYmVydDJiZXJ0JTIyKQ==",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;google-bert/bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;google-bert/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>)`,wrap:!1}}),{c(){n=h("p"),n.textContent=f,t=r(),M(a.$$.fragment)},l(o){n=u(o,"P",{"data-svelte-h":!0}),y(n)!=="svelte-11lpom8"&&(n.textContent=f),t=s(o),b(a.$$.fragment,o)},m(o,v){p(o,n,v),p(o,t,v),T(a,o,v),g=!0},p:ye,i(o){g||(w(a.$$.fragment,o),g=!0)},o(o){J(a.$$.fragment,o),g=!1},d(o){o&&(d(n),d(t)),Z(a,o)}}}function Jt(W){let n,f,t,a,g,o,v=`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
<a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a> function and the decoder is loaded via <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a>
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`,se,F,Q=`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in <a href="https://arxiv.org/abs/1907.12461" rel="nofollow">Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks</a> by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`,P,V,pe=`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).`,A,x,he=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,O,C,ue=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,K,z,fe=`<a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> 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<em>~transformers.AutoModel.from_pretrained</em> class method for the encoder and
:meth<em>~transformers.AutoModelForCausalLM.from_pretrained</em> class method for the decoder.`,ee,k,R,D,X,le='The <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> forward method, overrides the <code>__call__</code> special method.',H,E,Y,$,q,U,B,S,N,te=`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`,ne,G,ae=`The model is set in evaluation mode by default using <code>model.eval()</code> (Dropout modules are deactivated). To train
the model, you need to first set it back in training mode with <code>model.train()</code>.`,i,c,I;return n=new ge({props:{title:"EncoderDecoderModel",local:"transformers.EncoderDecoderModel",headingTag:"h2"}}),a=new _e({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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L169"}}),R=new _e({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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></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/main/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L544",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/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/main/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) — 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>) — 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>) — 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>) — 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>) — 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>) — 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’s 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),E=new ot({props:{$$slots:{default:[bt]},$$scope:{ctx:W}}}),$=new xe({props:{anchor:"transformers.EncoderDecoderModel.forward.example",$$slots:{default:[Tt]},$$scope:{ctx:W}}}),B=new _e({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.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/main/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.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/main/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/main/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L398"}}),c=new xe({props:{anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[wt]},$$scope:{ctx:W}}}),{c(){M(n.$$.fragment),f=r(),t=h("div"),M(a.$$.fragment),g=r(),o=h("p"),o.innerHTML=v,se=r(),F=h("p"),F.innerHTML=Q,P=r(),V=h("p"),V.textContent=pe,A=r(),x=h("p"),x.innerHTML=he,O=r(),C=h("p"),C.innerHTML=ue,K=r(),z=h("p"),z.innerHTML=fe,ee=r(),k=h("div"),M(R.$$.fragment),D=r(),X=h("p"),X.innerHTML=le,H=r(),M(E.$$.fragment),Y=r(),M($.$$.fragment),q=r(),U=h("div"),M(B.$$.fragment),S=r(),N=h("p"),N.textContent=te,ne=r(),G=h("p"),G.innerHTML=ae,i=r(),M(c.$$.fragment),this.h()},l(_){b(n.$$.fragment,_),f=s(_),t=u(_,"DIV",{class:!0});var j=ie(t);b(a.$$.fragment,j),g=s(j),o=u(j,"P",{"data-svelte-h":!0}),y(o)!=="svelte-kwk1yp"&&(o.innerHTML=v),se=s(j),F=u(j,"P",{"data-svelte-h":!0}),y(F)!=="svelte-1faerbf"&&(F.innerHTML=Q),P=s(j),V=u(j,"P",{"data-svelte-h":!0}),y(V)!=="svelte-1ttu6yo"&&(V.textContent=pe),A=s(j),x=u(j,"P",{"data-svelte-h":!0}),y(x)!=="svelte-6pahdo"&&(x.innerHTML=he),O=s(j),C=u(j,"P",{"data-svelte-h":!0}),y(C)!=="svelte-hswkmf"&&(C.innerHTML=ue),K=s(j),z=u(j,"P",{"data-svelte-h":!0}),y(z)!=="svelte-t13a6m"&&(z.innerHTML=fe),ee=s(j),k=u(j,"DIV",{class:!0});var oe=ie(k);b(R.$$.fragment,oe),D=s(oe),X=u(oe,"P",{"data-svelte-h":!0}),y(X)!=="svelte-1qr2v4y"&&(X.innerHTML=le),H=s(oe),b(E.$$.fragment,oe),Y=s(oe),b($.$$.fragment,oe),oe.forEach(d),q=s(j),U=u(j,"DIV",{class:!0});var L=ie(U);b(B.$$.fragment,L),S=s(L),N=u(L,"P",{"data-svelte-h":!0}),y(N)!=="svelte-n4p3zm"&&(N.textContent=te),ne=s(L),G=u(L,"P",{"data-svelte-h":!0}),y(G)!=="svelte-ce5sus"&&(G.innerHTML=ae),i=s(L),b(c.$$.fragment,L),L.forEach(d),j.forEach(d),this.h()},h(){de(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),de(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),de(t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(_,j){T(n,_,j),p(_,f,j),p(_,t,j),T(a,t,null),l(t,g),l(t,o),l(t,se),l(t,F),l(t,P),l(t,V),l(t,A),l(t,x),l(t,O),l(t,C),l(t,K),l(t,z),l(t,ee),l(t,k),T(R,k,null),l(k,D),l(k,X),l(k,H),T(E,k,null),l(k,Y),T($,k,null),l(t,q),l(t,U),T(B,U,null),l(U,S),l(U,N),l(U,ne),l(U,G),l(U,i),T(c,U,null),I=!0},p(_,j){const oe={};j&2&&(oe.$$scope={dirty:j,ctx:_}),E.$set(oe);const L={};j&2&&(L.$$scope={dirty:j,ctx:_}),$.$set(L);const we={};j&2&&(we.$$scope={dirty:j,ctx:_}),c.$set(we)},i(_){I||(w(n.$$.fragment,_),w(a.$$.fragment,_),w(R.$$.fragment,_),w(E.$$.fragment,_),w($.$$.fragment,_),w(B.$$.fragment,_),w(c.$$.fragment,_),I=!0)},o(_){J(n.$$.fragment,_),J(a.$$.fragment,_),J(R.$$.fragment,_),J(E.$$.fragment,_),J($.$$.fragment,_),J(B.$$.fragment,_),J(c.$$.fragment,_),I=!1},d(_){_&&(d(f),d(t)),Z(n,_),Z(a),Z(R),Z(E),Z($),Z(B),Z(c)}}}function Zt(W){let n,f;return n=new at({props:{$$slots:{default:[Jt]},$$scope:{ctx:W}}}),{c(){M(n.$$.fragment)},l(t){b(n.$$.fragment,t)},m(t,a){T(n,t,a),f=!0},p(t,a){const g={};a&2&&(g.$$scope={dirty:a,ctx:t}),n.$set(g)},i(t){f||(w(n.$$.fragment,t),f=!0)},o(t){J(n.$$.fragment,t),f=!1},d(t){Z(n,t)}}}function kt(W){let n,f=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){n=h("p"),n.innerHTML=f},l(t){n=u(t,"P",{"data-svelte-h":!0}),y(n)!=="svelte-fincs2"&&(n.innerHTML=f)},m(t,a){p(t,n,a)},p:ye,d(t){t&&d(n)}}}function vt(W){let n,f="Examples:",t,a,g;return a=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMEElMEElMjMlMjBpbml0aWFsaXplJTIwYSUyMGJlcnQyZ3B0MiUyMGZyb20lMjBhJTIwcHJldHJhaW5lZCUyMEJFUlQlMjBhbmQlMjBHUFQyJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwVEZFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtY2FzZWQlMjIlMkMlMjAlMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBCZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS1jYXNlZCUyMiklMEElMEElMjMlMjBmb3J3YXJkJTBBaW5wdXRfaWRzJTIwJTNEJTIwdG9rZW5pemVyLmVuY29kZSglMEElMjAlMjAlMjAlMjAlMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIlMEEpJTIwJTIwJTIzJTIwQmF0Y2glMjBzaXplJTIwMSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChpbnB1dF9pZHMlM0RpbnB1dF9pZHMlMkMlMjBkZWNvZGVyX2lucHV0X2lkcyUzRGlucHV0X2lkcyklMEElMEElMjMlMjB0cmFpbmluZyUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChpbnB1dF9pZHMlM0RpbnB1dF9pZHMlMkMlMjBkZWNvZGVyX2lucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGxhYmVscyUzRGlucHV0X2lkcyklMEFsb3NzJTJDJTIwbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTJDJTIwb3V0cHV0cy5sb2dpdHMlMEElMEElMjMlMjBzYXZlJTIwYW5kJTIwbG9hZCUyMGZyb20lMjBwcmV0cmFpbmVkJTBBbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmJlcnQyZ3B0MiUyMiklMEFtb2RlbCUyMCUzRCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyYmVydDJncHQyJTIyKSUwQSUwQSUyMyUyMGdlbmVyYXRpb24lMEFnZW5lcmF0ZWQlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShpbnB1dF9pZHMlMkMlMjBkZWNvZGVyX3N0YXJ0X3Rva2VuX2lkJTNEbW9kZWwuY29uZmlnLmRlY29kZXIuYm9zX3Rva2VuX2lkKQ==",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;google-bert/bert-base-cased&quot;</span>, <span class="hljs-string">&quot;openai-community/gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;google-bert/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)`,wrap:!1}}),{c(){n=h("p"),n.textContent=f,t=r(),M(a.$$.fragment)},l(o){n=u(o,"P",{"data-svelte-h":!0}),y(n)!=="svelte-kvfsh7"&&(n.textContent=f),t=s(o),b(a.$$.fragment,o)},m(o,v){p(o,n,v),p(o,t,v),T(a,o,v),g=!0},p:ye,i(o){g||(w(a.$$.fragment,o),g=!0)},o(o){J(a.$$.fragment,o),g=!1},d(o){o&&(d(n),d(t)),Z(a,o)}}}function jt(W){let n,f="Example:",t,a,g;return a=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbCUwQSUwQSUyMyUyMGluaXRpYWxpemUlMjBhJTIwYmVydDJncHQyJTIwZnJvbSUyMHR3byUyMHByZXRyYWluZWQlMjBCRVJUJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwVEZFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMCUyMm9wZW5haS1jb21tdW5pdHklMkZncHQyJTIyKSUwQSUyMyUyMHNhdmluZyUyMG1vZGVsJTIwYWZ0ZXIlMjBmaW5lLXR1bmluZyUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyLiUyRmJlcnQyZ3B0MiUyMik=",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;google-bert/bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;openai-community/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>)`,wrap:!1}}),{c(){n=h("p"),n.textContent=f,t=r(),M(a.$$.fragment)},l(o){n=u(o,"P",{"data-svelte-h":!0}),y(n)!=="svelte-11lpom8"&&(n.textContent=f),t=s(o),b(a.$$.fragment,o)},m(o,v){p(o,n,v),p(o,t,v),T(a,o,v),g=!0},p:ye,i(o){g||(w(a.$$.fragment,o),g=!0)},o(o){J(a.$$.fragment,o),g=!1},d(o){o&&(d(n),d(t)),Z(a,o)}}}function Ut(W){let n,f,t,a,g,o,v=`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
<a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a> function and the decoder is loaded via <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a>
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`,se,F,Q=`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in <a href="https://arxiv.org/abs/1907.12461" rel="nofollow">Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks</a> by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`,P,V,pe=`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).`,A,x,he=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,O,C,ue=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">keras.Model</a> 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.`,K,z,fe=`<a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.TFEncoderDecoderModel">TFEncoderDecoderModel</a> 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
<a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a> class method for the encoder and <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a> class
method for the decoder.`,ee,k,R,D,X,le='The <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.TFEncoderDecoderModel">TFEncoderDecoderModel</a> forward method, overrides the <code>__call__</code> special method.',H,E,Y,$,q,U,B,S,N,te=`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`,ne,G,ae;return n=new ge({props:{title:"TFEncoderDecoderModel",local:"transformers.TFEncoderDecoderModel",headingTag:"h2"}}),a=new _e({props:{name:"class transformers.TFEncoderDecoderModel",anchor:"transformers.TFEncoderDecoderModel",parameters:[{name:"config",val:": Optional[PretrainedConfig] = None"},{name:"encoder",val:": Optional[TFPreTrainedModel] = None"},{name:"decoder",val:": Optional[TFPreTrainedModel] = None"}],parametersDescription:[{anchor:"transformers.TFEncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L192"}}),R=new _e({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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for
details.`,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/main/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L454",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/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/main/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) — 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>) — 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>) — 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>) — 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>) — 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>) — 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’s 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFSeq2SeqLMOutput"
>transformers.modeling_tf_outputs.TFSeq2SeqLMOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),E=new ot({props:{$$slots:{default:[kt]},$$scope:{ctx:W}}}),$=new xe({props:{anchor:"transformers.TFEncoderDecoderModel.call.example",$$slots:{default:[vt]},$$scope:{ctx:W}}}),B=new _e({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.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/main/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.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/main/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/main/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L311"}}),G=new xe({props:{anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[jt]},$$scope:{ctx:W}}}),{c(){M(n.$$.fragment),f=r(),t=h("div"),M(a.$$.fragment),g=r(),o=h("p"),o.innerHTML=v,se=r(),F=h("p"),F.innerHTML=Q,P=r(),V=h("p"),V.textContent=pe,A=r(),x=h("p"),x.innerHTML=he,O=r(),C=h("p"),C.innerHTML=ue,K=r(),z=h("p"),z.innerHTML=fe,ee=r(),k=h("div"),M(R.$$.fragment),D=r(),X=h("p"),X.innerHTML=le,H=r(),M(E.$$.fragment),Y=r(),M($.$$.fragment),q=r(),U=h("div"),M(B.$$.fragment),S=r(),N=h("p"),N.textContent=te,ne=r(),M(G.$$.fragment),this.h()},l(i){b(n.$$.fragment,i),f=s(i),t=u(i,"DIV",{class:!0});var c=ie(t);b(a.$$.fragment,c),g=s(c),o=u(c,"P",{"data-svelte-h":!0}),y(o)!=="svelte-kwk1yp"&&(o.innerHTML=v),se=s(c),F=u(c,"P",{"data-svelte-h":!0}),y(F)!=="svelte-1faerbf"&&(F.innerHTML=Q),P=s(c),V=u(c,"P",{"data-svelte-h":!0}),y(V)!=="svelte-1ttu6yo"&&(V.textContent=pe),A=s(c),x=u(c,"P",{"data-svelte-h":!0}),y(x)!=="svelte-1qaxm70"&&(x.innerHTML=he),O=s(c),C=u(c,"P",{"data-svelte-h":!0}),y(C)!=="svelte-1be7e3c"&&(C.innerHTML=ue),K=s(c),z=u(c,"P",{"data-svelte-h":!0}),y(z)!=="svelte-qmgutt"&&(z.innerHTML=fe),ee=s(c),k=u(c,"DIV",{class:!0});var I=ie(k);b(R.$$.fragment,I),D=s(I),X=u(I,"P",{"data-svelte-h":!0}),y(X)!=="svelte-16w6i4y"&&(X.innerHTML=le),H=s(I),b(E.$$.fragment,I),Y=s(I),b($.$$.fragment,I),I.forEach(d),q=s(c),U=u(c,"DIV",{class:!0});var _=ie(U);b(B.$$.fragment,_),S=s(_),N=u(_,"P",{"data-svelte-h":!0}),y(N)!=="svelte-n4p3zm"&&(N.textContent=te),ne=s(_),b(G.$$.fragment,_),_.forEach(d),c.forEach(d),this.h()},h(){de(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),de(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),de(t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(i,c){T(n,i,c),p(i,f,c),p(i,t,c),T(a,t,null),l(t,g),l(t,o),l(t,se),l(t,F),l(t,P),l(t,V),l(t,A),l(t,x),l(t,O),l(t,C),l(t,K),l(t,z),l(t,ee),l(t,k),T(R,k,null),l(k,D),l(k,X),l(k,H),T(E,k,null),l(k,Y),T($,k,null),l(t,q),l(t,U),T(B,U,null),l(U,S),l(U,N),l(U,ne),T(G,U,null),ae=!0},p(i,c){const I={};c&2&&(I.$$scope={dirty:c,ctx:i}),E.$set(I);const _={};c&2&&(_.$$scope={dirty:c,ctx:i}),$.$set(_);const j={};c&2&&(j.$$scope={dirty:c,ctx:i}),G.$set(j)},i(i){ae||(w(n.$$.fragment,i),w(a.$$.fragment,i),w(R.$$.fragment,i),w(E.$$.fragment,i),w($.$$.fragment,i),w(B.$$.fragment,i),w(G.$$.fragment,i),ae=!0)},o(i){J(n.$$.fragment,i),J(a.$$.fragment,i),J(R.$$.fragment,i),J(E.$$.fragment,i),J($.$$.fragment,i),J(B.$$.fragment,i),J(G.$$.fragment,i),ae=!1},d(i){i&&(d(f),d(t)),Z(n,i),Z(a),Z(R),Z(E),Z($),Z(B),Z(G)}}}function Wt(W){let n,f;return n=new at({props:{$$slots:{default:[Ut]},$$scope:{ctx:W}}}),{c(){M(n.$$.fragment)},l(t){b(n.$$.fragment,t)},m(t,a){T(n,t,a),f=!0},p(t,a){const g={};a&2&&(g.$$scope={dirty:a,ctx:t}),n.$set(g)},i(t){f||(w(n.$$.fragment,t),f=!0)},o(t){J(n.$$.fragment,t),f=!1},d(t){Z(n,t)}}}function Gt(W){let n,f=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){n=h("p"),n.innerHTML=f},l(t){n=u(t,"P",{"data-svelte-h":!0}),y(n)!=="svelte-fincs2"&&(n.innerHTML=f)},m(t,a){p(t,n,a)},p:ye,d(t){t&&d(n)}}}function Et(W){let n,f="Examples:",t,a,g;return a=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsJTJDJTIwQmVydFRva2VuaXplciUyQyUyMEdQVDJUb2tlbml6ZXIlMEElMEElMjMlMjBsb2FkJTIwYSUyMGZpbmUtdHVuZWQlMjBiZXJ0MmdwdDIlMjBtb2RlbCUwQW1vZGVsJTIwJTNEJTIwRmxheEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdHJpY2t2b25wbGF0ZW4lMkZiZXJ0MmdwdDItY25uX2RhaWx5bWFpbC1mcDE2JTIyKSUwQSUyMyUyMGxvYWQlMjBpbnB1dCUyMCUyNiUyMG91dHB1dCUyMHRva2VuaXplciUwQXRva2VuaXplcl9pbnB1dCUyMCUzRCUyMEJlcnRUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZS1iZXJ0JTJGYmVydC1iYXNlLWNhc2VkJTIyKSUwQXRva2VuaXplcl9vdXRwdXQlMjAlM0QlMjBHUFQyVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEElMEFhcnRpY2xlJTIwJTNEJTIwJycnU2lnbWElMjBBbHBoYSUyMEVwc2lsb24lMjBpcyUyMHVuZGVyJTIwZmlyZSUyMGZvciUyMGElMjB2aWRlbyUyMHNob3dpbmclMjBwYXJ0eS1ib3VuZCUyMGZyYXRlcm5pdHklMjBtZW1iZXJzJTBBc2luZ2luZyUyMGElMjByYWNpc3QlMjBjaGFudC4lMjBTQUUncyUyMG5hdGlvbmFsJTIwY2hhcHRlciUyMHN1c3BlbmRlZCUyMHRoZSUyMHN0dWRlbnRzJTJDJTBBYnV0JTIwVW5pdmVyc2l0eSUyMG9mJTIwT2tsYWhvbWElMjBQcmVzaWRlbnQlMjBEYXZpZCUyMEJvcmVuJTIwdG9vayUyMGl0JTIwYSUyMHN0ZXAlMjBmdXJ0aGVyJTJDJTBBc2F5aW5nJTIwdGhlJTIwdW5pdmVyc2l0eSdzJTIwYWZmaWxpYXRpb24lMjB3aXRoJTIwdGhlJTIwZnJhdGVybml0eSUyMGlzJTIwcGVybWFuZW50bHklMjBkb25lLicnJyUwQSUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplcl9pbnB1dChhcnRpY2xlJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIybnAlMjIpLmlucHV0X2lkcyUwQSUwQSUyMyUyMHVzZSUyMEdQVDIncyUyMGVvc190b2tlbiUyMGFzJTIwdGhlJTIwcGFkJTIwYXMlMjB3ZWxsJTIwYXMlMjBlb3MlMjB0b2tlbiUwQW1vZGVsLmNvbmZpZy5lb3NfdG9rZW5faWQlMjAlM0QlMjBtb2RlbC5jb25maWcuZGVjb2Rlci5lb3NfdG9rZW5faWQlMEFtb2RlbC5jb25maWcucGFkX3Rva2VuX2lkJTIwJTNEJTIwbW9kZWwuY29uZmlnLmVvc190b2tlbl9pZCUwQSUwQXNlcXVlbmNlcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0X2lkcyUyQyUyMG51bV9iZWFtcyUzRDQlMkMlMjBtYXhfbGVuZ3RoJTNEMTIpLnNlcXVlbmNlcyUwQSUwQXN1bW1hcnklMjAlM0QlMjB0b2tlbml6ZXJfb3V0cHV0LmJhdGNoX2RlY29kZShzZXF1ZW5jZXMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklNUIwJTVEJTBBYXNzZXJ0JTIwc3VtbWFyeSUyMCUzRCUzRCUyMCUyMlNBUyUyMEFscGhhJTIwRXBzaWxvbiUyMHN1c3BlbmRlZCUyMFNpZ21hJTIwQWxwaGElMjBFcHNpbG9uJTIwbWVtYmVycyUyMg==",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;google-bert/bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer_output = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;openai-community/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>`,wrap:!1}}),{c(){n=h("p"),n.textContent=f,t=r(),M(a.$$.fragment)},l(o){n=u(o,"P",{"data-svelte-h":!0}),y(n)!=="svelte-kvfsh7"&&(n.textContent=f),t=s(o),b(a.$$.fragment,o)},m(o,v){p(o,n,v),p(o,t,v),T(a,o,v),g=!0},p:ye,i(o){g||(w(a.$$.fragment,o),g=!0)},o(o){J(a.$$.fragment,o),g=!1},d(o){o&&(d(n),d(t)),Z(a,o)}}}function $t(W){let n,f="Example:",t,a,g;return a=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMGElMjBiZXJ0MmdwdDIlMjBmcm9tJTIwcHJldHJhaW5lZCUyMEJFUlQlMjBhbmQlMjBHUFQyJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwRmxheEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMCUyMm9wZW5haS1jb21tdW5pdHklMkZncHQyJTIyKSUwQSUyMyUyMHNhdmluZyUyMG1vZGVsJTIwYWZ0ZXIlMjBmaW5lLXR1bmluZyUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKQ==",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;google-bert/bert-base-cased&quot;</span>, <span class="hljs-string">&quot;openai-community/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>)`,wrap:!1}}),{c(){n=h("p"),n.textContent=f,t=r(),M(a.$$.fragment)},l(o){n=u(o,"P",{"data-svelte-h":!0}),y(n)!=="svelte-11lpom8"&&(n.textContent=f),t=s(o),b(a.$$.fragment,o)},m(o,v){p(o,n,v),p(o,t,v),T(a,o,v),g=!0},p:ye,i(o){g||(w(a.$$.fragment,o),g=!0)},o(o){J(a.$$.fragment,o),g=!1},d(o){o&&(d(n),d(t)),Z(a,o)}}}function It(W){let n,f,t,a,g,o,v=`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
<a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a> function and the decoder is loaded via <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel.from_pretrained">from_pretrained()</a>
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`,se,F,Q=`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in <a href="https://arxiv.org/abs/1907.12461" rel="nofollow">Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks</a> by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`,P,V,pe=`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).`,A,x,he=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel">FlaxPreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,O,C,ue=`This model is also a Flax Linen
<a href="https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html" rel="nofollow">flax.nn.Module</a> subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`,K,z,fe=`<a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.FlaxEncoderDecoderModel">FlaxEncoderDecoderModel</a> 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<em>~transformers.FlaxAutoModel.from_pretrained</em> class method for the
encoder and :meth<em>~transformers.FlaxAutoModelForCausalLM.from_pretrained</em> class method for the decoder.`,ee,k,R,D,X,le='The <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.FlaxEncoderDecoderModel">FlaxEncoderDecoderModel</a> forward method, overrides the <code>__call__</code> special method.',H,E,Y,$,q,U,B,S,N,te=`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`,ne,G,ae;return n=new ge({props:{title:"FlaxEncoderDecoderModel",local:"transformers.FlaxEncoderDecoderModel",headingTag:"h2"}}),a=new _e({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/main/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/main/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/main/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L300"}}),R=new _e({props:{name:"__call__",anchor:"transformers.FlaxEncoderDecoderModel.__call__",parameters:[{name:"input_ids",val:": Array"},{name:"attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"decoder_input_ids",val:": typing.Optional[jax.Array] = None"},{name:"decoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"position_ids",val:": typing.Optional[jax.Array] = None"},{name:"decoder_position_ids",val:": typing.Optional[jax.Array] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"train",val:": bool = False"},{name:"params",val:": dict = None"},{name:"dropout_rng",val:": <function PRNGKey at 0x7f2709968700> = 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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#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/main/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L627",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/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/main/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>) — 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>) — 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>) — 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>) — 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>) — 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’s 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput"
>transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),E=new ot({props:{$$slots:{default:[Gt]},$$scope:{ctx:W}}}),$=new xe({props:{anchor:"transformers.FlaxEncoderDecoderModel.__call__.example",$$slots:{default:[Et]},$$scope:{ctx:W}}}),B=new _e({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.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/main/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.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/main/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/main/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L759"}}),G=new xe({props:{anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[$t]},$$scope:{ctx:W}}}),{c(){M(n.$$.fragment),f=r(),t=h("div"),M(a.$$.fragment),g=r(),o=h("p"),o.innerHTML=v,se=r(),F=h("p"),F.innerHTML=Q,P=r(),V=h("p"),V.textContent=pe,A=r(),x=h("p"),x.innerHTML=he,O=r(),C=h("p"),C.innerHTML=ue,K=r(),z=h("p"),z.innerHTML=fe,ee=r(),k=h("div"),M(R.$$.fragment),D=r(),X=h("p"),X.innerHTML=le,H=r(),M(E.$$.fragment),Y=r(),M($.$$.fragment),q=r(),U=h("div"),M(B.$$.fragment),S=r(),N=h("p"),N.textContent=te,ne=r(),M(G.$$.fragment),this.h()},l(i){b(n.$$.fragment,i),f=s(i),t=u(i,"DIV",{class:!0});var c=ie(t);b(a.$$.fragment,c),g=s(c),o=u(c,"P",{"data-svelte-h":!0}),y(o)!=="svelte-kwk1yp"&&(o.innerHTML=v),se=s(c),F=u(c,"P",{"data-svelte-h":!0}),y(F)!=="svelte-1faerbf"&&(F.innerHTML=Q),P=s(c),V=u(c,"P",{"data-svelte-h":!0}),y(V)!=="svelte-1ttu6yo"&&(V.textContent=pe),A=s(c),x=u(c,"P",{"data-svelte-h":!0}),y(x)!=="svelte-18ki9f4"&&(x.innerHTML=he),O=s(c),C=u(c,"P",{"data-svelte-h":!0}),y(C)!=="svelte-idybz1"&&(C.innerHTML=ue),K=s(c),z=u(c,"P",{"data-svelte-h":!0}),y(z)!=="svelte-zufxty"&&(z.innerHTML=fe),ee=s(c),k=u(c,"DIV",{class:!0});var I=ie(k);b(R.$$.fragment,I),D=s(I),X=u(I,"P",{"data-svelte-h":!0}),y(X)!=="svelte-vra0um"&&(X.innerHTML=le),H=s(I),b(E.$$.fragment,I),Y=s(I),b($.$$.fragment,I),I.forEach(d),q=s(c),U=u(c,"DIV",{class:!0});var _=ie(U);b(B.$$.fragment,_),S=s(_),N=u(_,"P",{"data-svelte-h":!0}),y(N)!=="svelte-n4p3zm"&&(N.textContent=te),ne=s(_),b(G.$$.fragment,_),_.forEach(d),c.forEach(d),this.h()},h(){de(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),de(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),de(t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(i,c){T(n,i,c),p(i,f,c),p(i,t,c),T(a,t,null),l(t,g),l(t,o),l(t,se),l(t,F),l(t,P),l(t,V),l(t,A),l(t,x),l(t,O),l(t,C),l(t,K),l(t,z),l(t,ee),l(t,k),T(R,k,null),l(k,D),l(k,X),l(k,H),T(E,k,null),l(k,Y),T($,k,null),l(t,q),l(t,U),T(B,U,null),l(U,S),l(U,N),l(U,ne),T(G,U,null),ae=!0},p(i,c){const I={};c&2&&(I.$$scope={dirty:c,ctx:i}),E.$set(I);const _={};c&2&&(_.$$scope={dirty:c,ctx:i}),$.$set(_);const j={};c&2&&(j.$$scope={dirty:c,ctx:i}),G.$set(j)},i(i){ae||(w(n.$$.fragment,i),w(a.$$.fragment,i),w(R.$$.fragment,i),w(E.$$.fragment,i),w($.$$.fragment,i),w(B.$$.fragment,i),w(G.$$.fragment,i),ae=!0)},o(i){J(n.$$.fragment,i),J(a.$$.fragment,i),J(R.$$.fragment,i),J(E.$$.fragment,i),J($.$$.fragment,i),J(B.$$.fragment,i),J(G.$$.fragment,i),ae=!1},d(i){i&&(d(f),d(t)),Z(n,i),Z(a),Z(R),Z(E),Z($),Z(B),Z(G)}}}function Vt(W){let n,f;return n=new at({props:{$$slots:{default:[It]},$$scope:{ctx:W}}}),{c(){M(n.$$.fragment)},l(t){b(n.$$.fragment,t)},m(t,a){T(n,t,a),f=!0},p(t,a){const g={};a&2&&(g.$$scope={dirty:a,ctx:t}),n.$set(g)},i(t){f||(w(n.$$.fragment,t),f=!0)},o(t){J(n.$$.fragment,t),f=!1},d(t){Z(n,t)}}}function xt(W){let n,f,t,a,g,o,v,se=`<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/> <img alt="TensorFlow" src="https://img.shields.io/badge/TensorFlow-FF6F00?style=flat&amp;logo=tensorflow&amp;logoColor=white"/> <img alt="Flax" src="https://img.shields.io/badge/Flax-29a79b.svg?style=flat&amp;logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtCAMAAAANxBKoAAAC7lBMVEUAAADg5vYHPVgAoJH+/v76+v39/f9JbLP///9+AIgAnY3///+mcqzt8fXy9fgkXa3Ax9709fr+///9/f8qXq49qp5AaLGMwrv8/P0eW60VWawxYq8yqJzG2dytt9Wyu9elzci519Lf3O3S2efY3OrY0+Xp7PT///////+dqNCexMc6Z7AGpJeGvbenstPZ5ejQ1OfJzOLa7ejh4+/r8fT29vpccbklWK8PVa0AS6ghW63O498vYa+lsdKz1NDRt9Kw1c672tbD3tnAxt7R6OHp5vDe7OrDyuDn6vLl6/EAQKak0MgATakkppo3ZK/Bz9y8w9yzu9jey97axdvHzeG21NHH4trTwthKZrVGZLSUSpuPQJiGAI+GAI8SWKydycLL4d7f2OTi1+S9xNzL0ePT6OLGzeEAo5U0qJw/aLEAo5JFa7JBabEAp5Y4qZ2QxLyKmsm3kL2xoMOehrRNb7RIbbOZgrGre68AUqwAqZqNN5aKJ5N/lMq+qsd8kMa4pcWzh7muhLMEV69juq2kbKqgUaOTR5uMMZWLLZSGAI5VAIdEAH+ovNDHuNCnxcy3qcaYx8K8msGplrx+wLahjbYdXrV6vbMvYK9DrZ8QrZ8tqJuFms+Sos6sw8ecy8RffsNVeMCvmb43aLltv7Q4Y7EZWK4QWa1gt6meZKUdr6GOAZVeA4xPAISyveLUwtivxtKTpNJ2jcqfvcltiMiwwcfAoMVxhL+Kx7xjdrqTe60tsaNQs6KaRKACrJ6UTZwkqpqTL5pkHY4AloSgsd2ptNXPvNOOncuxxsqFl8lmg8apt8FJcr9EbryGxLqlkrkrY7dRa7ZGZLQ5t6iXUZ6PPpgVpZeJCJFKAIGareTa0+KJod3H0deY2M+esM25usmYu8d2zsJOdcBVvrCLbqcAOaaHaKQAMaScWqKBXqCXMJ2RHpiLF5NmJZAdAHN2kta11dKu1M+DkcZLdb+Mcql3TppyRJdzQ5ZtNZNlIY+DF4+voCOQAAAAZ3RSTlMABAT+MEEJ/RH+/TP+Zlv+pUo6Ifz8+fco/fz6+evr39S9nJmOilQaF/7+/f38+smmoYp6b1T+/v7++vj189zU0tDJxsGzsrKSfv34+Pf27dDOysG9t6+n/vv6+vr59uzr1tG+tZ6Qg9Ym3QAABR5JREFUSMeNlVVUG1EQhpcuxEspXqS0SKEtxQp1d3d332STTRpIQhIISQgJhODu7lAoDoUCpe7u7u7+1puGpqnCPOyZvffbOXPm/PsP9JfQgyCC+tmTABTOcbxDz/heENS7/1F+9nhvkHePG0wNDLbGWwdXL+rbLWvpmZHXD8+gMfBjTh+aSe6Gnn7lwQIOTR0c8wfX3PWgv7avbdKwf/ZoBp1Gp/PvuvXW3vw5ib7emnTW4OR+3D4jB9vjNJ/7gNvfWWeH/TO/JyYrsiKCRjVEZA3UB+96kON+DxOQ/NLE8PE5iUYgIXjFnCOlxEQMaSGVxjg4gxOnEycGz8bptuNjVx08LscIgrzH3umcn+KKtiBIyvzOO2O99aAdR8cF19oZalnCtvREUw79tCd5sow1g1UKM6kXqUx4T8wsi3sTjJ3yzDmmhenLXLpo8u45eG5y4Vvbk6kkC4LLtJMowkSQxmk4ggVJEG+7c6QpHT8vvW9X7/o7+3ELmiJi2mEzZJiz8cT6TBlanBk70cB5GGIGC1gRDdZ00yADLW1FL6gqhtvNXNG5S9gdSrk4M1qu7JAsmYshzDS4peoMrU/gT7qQdqYGZaYhxZmVbGJAm/CS/HloWyhRUlknQ9KYcExTwS80d3VNOxUZJpITYyspl0LbhArhpZCD9cRWEQuhYkNGMHToQ/2Cs6swJlb39CsllxdXX6IUKh/H5jbnSsPKjgmoaFQ1f8wRLR0UnGE/RcDEjj2jXG1WVTwUs8+zxfcrVO+vSsuOpVKxCfYZiQ0/aPKuxQbQ8lIz+DClxC8u+snlcJ7Yr1z1JPqUH0V+GDXbOwAib931Y4Imaq0NTIXPXY+N5L18GJ37SVWu+hwXff8l72Ds9XuwYIBaXPq6Shm4l+Vl/5QiOlV+uTk6YR9PxKsI9xNJny31ygK1e+nIRC1N97EGkFPI+jCpiHe5PCEy7oWqWSwRrpOvhFzcbTWMbm3ZJAOn1rUKpYIt/lDhW/5RHHteeWFN60qo98YJuoq1nK3uW5AabyspC1BcIEpOhft+SZAShYoLSvnmSfnYADUERP5jJn2h5XtsgCRuhYQqAvwTwn33+YWEKUI72HX5AtfSAZDe8F2DtPPm77afhl0EkthzuCQU0BWApgQIH9+KB0JhopMM7bJrdTRoleM2JAVNMyPF+wdoaz+XJpGoVAQ7WXUkcV7gT3oUZyi/ISIJAVKhgNp+4b4veCFhYVJw4locdSjZCp9cPUhLF9EZ3KKzURepMEtCDPP3VcWFx4UIiZIklIpFNfHpdEafIF2aRmOcrUmjohbT2WUllbmRvgfbythbQO3222fpDJoufaQPncYYuqoGtUEsCJZL6/3PR5b4syeSjZMQG/T2maGANlXT2v8S4AULWaUkCxfLyW8iW4kdka+nEMjxpL2NCwsYNBp+Q61PF43zyDg9Bm9+3NNySn78jMZUUkumqE4Gp7JmFOdP1vc8PpRrzj9+wPinCy8K1PiJ4aYbnTYpCCbDkBSbzhu2QJ1Gd82t8jI8TH51+OzvXoWbnXUOBkNW+0mWFwGcGOUVpU81/n3TOHb5oMt2FgYGjzau0Nif0Ss7Q3XB33hjjQHjHA5E5aOyIQc8CBrLdQSs3j92VG+3nNEjbkbdbBr9zm04ruvw37vh0QKOdeGIkckc80fX3KH/h7PT4BOjgCty8VZ5ux1MoO5Cf5naca2LAsEgehI+drX8o/0Nu+W0m6K/I9gGPd/dfx/EN/wN62AhsBWuAAAAAElFTkSuQmCC
"/> <img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/>`,F,Q,P,V,pe=`The <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> 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.`,A,x,he=`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation tasks
was shown in <a href="https://arxiv.org/abs/1907.12461" rel="nofollow">Leveraging Pre-trained Checkpoints for Sequence Generation Tasks</a> by
Sascha Rothe, Shashi Narayan, Aliaksei Severyn.`,O,C,ue=`After such an <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> has been trained/fine-tuned, it can be saved/loaded just like
any other models (see the examples for more information).`,K,z,fe=`An application of this architecture could be to leverage two pretrained <a href="/docs/transformers/main/en/model_doc/bert#transformers.BertModel">BertModel</a> as the encoder
and decoder for a summarization model as was shown in: <a href="https://arxiv.org/abs/1908.08345" rel="nofollow">Text Summarization with Pretrained Encoders</a> by Yang Liu and Mirella Lapata.`,ee,k,R,D,X='<a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> can be randomly initialized from an encoder and a decoder config. In the following example, we show how to do this using the default <a href="/docs/transformers/main/en/model_doc/bert#transformers.BertModel">BertModel</a> configuration for the encoder and the default <code>BertForCausalLM</code> configuration for the decoder.',le,H,E,Y,$,q,U=`<a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained auto-encoding model, <em>e.g.</em> BERT, can serve as the encoder and both pretrained auto-encoding models, <em>e.g.</em> BERT, pretrained causal language models, <em>e.g.</em> GPT2, as well as the pretrained decoder part of sequence-to-sequence models, <em>e.g.</em> 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 <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> from a pretrained encoder and decoder checkpoint requires the model to be fine-tuned on a downstream task, as has been shown in <a href="https://huggingface.co/blog/warm-starting-encoder-decoder" rel="nofollow">the <em>Warm-starting-encoder-decoder blog post</em></a>.
To do so, the <code>EncoderDecoderModel</code> class provides a <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel.from_encoder_decoder_pretrained">EncoderDecoderModel.from_encoder_decoder_pretrained()</a> method.`,B,S,N,te,ne,G,ae='To load fine-tuned checkpoints of the <code>EncoderDecoderModel</code> class, <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a> provides the <code>from_pretrained(...)</code> method just like any other model architecture in Transformers.',i,c,I="To perform inference, one uses the <code>generate</code> method, which allows to autoregressively generate text. This method supports various forms of decoding, such as greedy, beam search and multinomial sampling.",_,j,oe,L,we,Je,rt=`<a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">TFEncoderDecoderModel.from_pretrained()</a> currently doesn’t support initializing the model from a
pytorch checkpoint. Passing <code>from_pt=True</code> to this method will throw an exception. If there are only pytorch
checkpoints for a particular encoder-decoder model, a workaround is:`,Fe,Ze,Ne,ke,Xe,ve,st=`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: <code>input_ids</code> (which are the
<code>input_ids</code> of the encoded input sequence) and <code>labels</code> (which are the <code>input_ids</code> of the encoded
target sequence).`,De,je,He,Ue,dt='Detailed <a href="https://colab.research.google.com/drive/1WIk2bxglElfZewOHboPFNj8H44_VAyKE?usp=sharing#scrollTo=ZwQIEhKOrJpl" rel="nofollow">colab</a> for training.',Ye,We,lt=`This model was contributed by <a href="https://github.com/thomwolf" rel="nofollow">thomwolf</a>. This model’s TensorFlow and Flax versions
were contributed by <a href="https://github.com/ydshieh" rel="nofollow">ydshieh</a>.`,qe,Ge,Se,re,Ee,Oe,Ce,ct=`<a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig">EncoderDecoderConfig</a> is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel">EncoderDecoderModel</a>. It is
used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder
configs.`,Ke,ze,it=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,et,Me,tt,be,$e,nt,Re,mt=`Instantiate a <a href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig">EncoderDecoderConfig</a> (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`,Le,Te,Qe,Ie,Pe,Be,Ae;return g=new ge({props:{title:"Encoder Decoder Models",local:"encoder-decoder-models",headingTag:"h1"}}),Q=new ge({props:{title:"Overview",local:"overview",headingTag:"h2"}}),k=new ge({props:{title:"Randomly initializing EncoderDecoderModel from model configurations.",local:"randomly-initializing-encoderdecodermodel-from-model-configurations",headingTag:"h2"}}),H=new me({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)`,wrap:!1}}),Y=new ge({props:{title:"Initialising EncoderDecoderModel from a pretrained encoder and a pretrained decoder.",local:"initialising-encoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder",headingTag:"h2"}}),S=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMkMlMjBCZXJ0VG9rZW5pemVyJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQmVydFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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;google-bert/bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>)`,wrap:!1}}),te=new ge({props:{title:"Loading an existing EncoderDecoderModel checkpoint and perform inference.",local:"loading-an-existing-encoderdecodermodel-checkpoint-and-perform-inference",headingTag:"h2"}}),j=new me({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.`,wrap:!1}}),L=new ge({props:{title:"Loading a PyTorch checkpoint into TFEncoderDecoderModel .",local:"loading-a-pytorch-checkpoint-into-tfencoderdecodermodel-",headingTag:"h2"}}),Ze=new me({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`,wrap:!1}}),ke=new ge({props:{title:"Training",local:"training",headingTag:"h2"}}),je=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRUb2tlbml6ZXIlMkMlMjBFbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQmVydFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEElMEFtb2RlbC5jb25maWcuZGVjb2Rlcl9zdGFydF90b2tlbl9pZCUyMCUzRCUyMHRva2VuaXplci5jbHNfdG9rZW5faWQlMEFtb2RlbC5jb25maWcucGFkX3Rva2VuX2lkJTIwJTNEJTIwdG9rZW5pemVyLnBhZF90b2tlbl9pZCUwQSUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjAlMjJUaGUlMjB0b3dlciUyMGlzJTIwMzI0JTIwbWV0cmVzJTIwKDElMkMwNjMlMjBmdCklMjB0YWxsJTJDJTIwYWJvdXQlMjB0aGUlMjBzYW1lJTIwaGVpZ2h0JTIwYXMlMjBhbiUyMDgxLXN0b3JleSUyMGJ1aWxkaW5nJTJDJTIwYW5kJTIwdGhlJTIwdGFsbGVzdCUyMHN0cnVjdHVyZSUyMGluJTIwUGFyaXMuJTIwSXRzJTIwYmFzZSUyMGlzJTIwc3F1YXJlJTJDJTIwbWVhc3VyaW5nJTIwMTI1JTIwbWV0cmVzJTIwKDQxMCUyMGZ0KSUyMG9uJTIwZWFjaCUyMHNpZGUuRHVyaW5nJTIwaXRzJTIwY29uc3RydWN0aW9uJTJDJTIwdGhlJTIwRWlmZmVsJTIwVG93ZXIlMjBzdXJwYXNzZWQlMjB0aGUlMjBXYXNoaW5ndG9uJTIwTW9udW1lbnQlMjB0byUyMGJlY29tZSUyMHRoZSUyMHRhbGxlc3QlMjBtYW4tbWFkZSUyMHN0cnVjdHVyZSUyMGluJTIwdGhlJTIwd29ybGQlMkMlMjBhJTIwdGl0bGUlMjBpdCUyMGhlbGQlMjBmb3IlMjA0MSUyMHllYXJzJTIwdW50aWwlMjB0aGUlMjBDaHJ5c2xlciUyMEJ1aWxkaW5nJTIwaW4lMjBOZXclMjBZb3JrJTIwQ2l0eSUyMHdhcyUyMCUyMGZpbmlzaGVkJTIwaW4lMjAxOTMwLiUyMEl0JTIwd2FzJTIwdGhlJTIwZmlyc3QlMjBzdHJ1Y3R1cmUlMjB0byUyMHJlYWNoJTIwYSUyMGhlaWdodCUyMG9mJTIwMzAwJTIwbWV0cmVzLiUyMER1ZSUyMHRvJTIwdGhlJTIwYWRkaXRpb24lMjBvZiUyMGElMjBicm9hZGNhc3RpbmclMjBhZXJpYWwlMjBhdCUyMHRoZSUyMHRvcCUyMG9mJTIwdGhlJTIwdG93ZXIlMjBpbiUyMDE5NTclMkMlMjBpdCUyMGlzJTIwbm93JTIwdGFsbGVyJTIwdGhhbiUyMHRoZSUyMENocnlzbGVyJTIwQnVpbGRpbmclMjBieSUyMDUuMiUyMG1ldHJlcyUyMCgxNyUyMGZ0KS5FeGNsdWRpbmclMjB0cmFuc21pdHRlcnMlMkMlMjB0aGUlMjBFaWZmZWwlMjBUb3dlciUyMGlzJTIwdGhlJTIwc2Vjb25kJTIwdGFsbGVzdCUyMGZyZWUtc3RhbmRpbmclMjBzdHJ1Y3R1cmUlMjBpbiUyMEZyYW5jZSUyMGFmdGVyJTIwdGhlJTIwTWlsbGF1JTIwVmlhZHVjdC4lMjIlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBKS5pbnB1dF9pZHMlMEElMEFsYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTIydGhlJTIwZWlmZmVsJTIwdG93ZXIlMjBzdXJwYXNzZWQlMjB0aGUlMjB3YXNoaW5ndG9uJTIwbW9udW1lbnQlMjB0byUyMGJlY29tZSUyMHRoZSUyMHRhbGxlc3QlMjBzdHJ1Y3R1cmUlMjBpbiUyMHRoZSUyMHdvcmxkLiUyMGl0JTIwd2FzJTIwdGhlJTIwZmlyc3QlMjBzdHJ1Y3R1cmUlMjB0byUyMHJlYWNoJTIwYSUyMGhlaWdodCUyMG9mJTIwMzAwJTIwbWV0cmVzJTIwaW4lMjBwYXJpcyUyMGluJTIwMTkzMC4lMjBpdCUyMGlzJTIwbm93JTIwdGFsbGVyJTIwdGhhbiUyMHRoZSUyMGNocnlzbGVyJTIwYnVpbGRpbmclMjBieSUyMDUuJTIwMiUyMG1ldHJlcyUyMCglMjAxNyUyMGZ0JTIwKSUyMGFuZCUyMGlzJTIwdGhlJTIwc2Vjb25kJTIwdGFsbGVzdCUyMGZyZWUlMjAtJTIwc3RhbmRpbmclMjBzdHJ1Y3R1cmUlMjBpbiUyMHBhcmlzLiUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMkMlMEEpLmlucHV0X2lkcyUwQSUwQSUyMyUyMHRoZSUyMGZvcndhcmQlMjBmdW5jdGlvbiUyMGF1dG9tYXRpY2FsbHklMjBjcmVhdGVzJTIwdGhlJTIwY29ycmVjdCUyMGRlY29kZXJfaW5wdXRfaWRzJTBBbG9zcyUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",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;google-bert/bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;google-bert/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`,wrap:!1}}),Ge=new ge({props:{title:"EncoderDecoderConfig",local:"transformers.EncoderDecoderConfig",headingTag:"h2"}}),Ee=new _e({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/main/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/main/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/main/src/transformers/models/encoder_decoder/configuration_encoder_decoder.py#L26"}}),Me=new xe({props:{anchor:"transformers.EncoderDecoderConfig.example",$$slots:{default:[Mt]},$$scope:{ctx:W}}}),$e=new _e({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/main/src/transformers/models/encoder_decoder/configuration_encoder_decoder.py#L93",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>An instance of a configuration object</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</a></p>
`}}),Te=new _t({props:{pytorch:!0,tensorflow:!0,jax:!0,$$slots:{jax:[Vt],tensorflow:[Wt],pytorch:[Zt]},$$scope:{ctx:W}}}),Ie=new yt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/encoder-decoder.md"}}),{c(){n=h("meta"),f=r(),t=h("p"),a=r(),M(g.$$.fragment),o=r(),v=h("div"),v.innerHTML=se,F=r(),M(Q.$$.fragment),P=r(),V=h("p"),V.innerHTML=pe,A=r(),x=h("p"),x.innerHTML=he,O=r(),C=h("p"),C.innerHTML=ue,K=r(),z=h("p"),z.innerHTML=fe,ee=r(),M(k.$$.fragment),R=r(),D=h("p"),D.innerHTML=X,le=r(),M(H.$$.fragment),E=r(),M(Y.$$.fragment),$=r(),q=h("p"),q.innerHTML=U,B=r(),M(S.$$.fragment),N=r(),M(te.$$.fragment),ne=r(),G=h("p"),G.innerHTML=ae,i=r(),c=h("p"),c.innerHTML=I,_=r(),M(j.$$.fragment),oe=r(),M(L.$$.fragment),we=r(),Je=h("p"),Je.innerHTML=rt,Fe=r(),M(Ze.$$.fragment),Ne=r(),M(ke.$$.fragment),Xe=r(),ve=h("p"),ve.innerHTML=st,De=r(),M(je.$$.fragment),He=r(),Ue=h("p"),Ue.innerHTML=dt,Ye=r(),We=h("p"),We.innerHTML=lt,qe=r(),M(Ge.$$.fragment),Se=r(),re=h("div"),M(Ee.$$.fragment),Oe=r(),Ce=h("p"),Ce.innerHTML=ct,Ke=r(),ze=h("p"),ze.innerHTML=it,et=r(),M(Me.$$.fragment),tt=r(),be=h("div"),M($e.$$.fragment),nt=r(),Re=h("p"),Re.innerHTML=mt,Le=r(),M(Te.$$.fragment),Qe=r(),M(Ie.$$.fragment),Pe=r(),Be=h("p"),this.h()},l(e){const m=gt("svelte-u9bgzb",document.head);n=u(m,"META",{name:!0,content:!0}),m.forEach(d),f=s(e),t=u(e,"P",{}),ie(t).forEach(d),a=s(e),b(g.$$.fragment,e),o=s(e),v=u(e,"DIV",{class:!0,"data-svelte-h":!0}),y(v)!=="svelte-174uc6q"&&(v.innerHTML=se),F=s(e),b(Q.$$.fragment,e),P=s(e),V=u(e,"P",{"data-svelte-h":!0}),y(V)!=="svelte-iu7uz4"&&(V.innerHTML=pe),A=s(e),x=u(e,"P",{"data-svelte-h":!0}),y(x)!=="svelte-1ixwj5c"&&(x.innerHTML=he),O=s(e),C=u(e,"P",{"data-svelte-h":!0}),y(C)!=="svelte-14hvfjv"&&(C.innerHTML=ue),K=s(e),z=u(e,"P",{"data-svelte-h":!0}),y(z)!=="svelte-k7jqu9"&&(z.innerHTML=fe),ee=s(e),b(k.$$.fragment,e),R=s(e),D=u(e,"P",{"data-svelte-h":!0}),y(D)!=="svelte-1bj3mo8"&&(D.innerHTML=X),le=s(e),b(H.$$.fragment,e),E=s(e),b(Y.$$.fragment,e),$=s(e),q=u(e,"P",{"data-svelte-h":!0}),y(q)!=="svelte-ptmmv2"&&(q.innerHTML=U),B=s(e),b(S.$$.fragment,e),N=s(e),b(te.$$.fragment,e),ne=s(e),G=u(e,"P",{"data-svelte-h":!0}),y(G)!=="svelte-zyhggo"&&(G.innerHTML=ae),i=s(e),c=u(e,"P",{"data-svelte-h":!0}),y(c)!=="svelte-otiwkm"&&(c.innerHTML=I),_=s(e),b(j.$$.fragment,e),oe=s(e),b(L.$$.fragment,e),we=s(e),Je=u(e,"P",{"data-svelte-h":!0}),y(Je)!=="svelte-bn96sq"&&(Je.innerHTML=rt),Fe=s(e),b(Ze.$$.fragment,e),Ne=s(e),b(ke.$$.fragment,e),Xe=s(e),ve=u(e,"P",{"data-svelte-h":!0}),y(ve)!=="svelte-19ghpfb"&&(ve.innerHTML=st),De=s(e),b(je.$$.fragment,e),He=s(e),Ue=u(e,"P",{"data-svelte-h":!0}),y(Ue)!=="svelte-1u37y7z"&&(Ue.innerHTML=dt),Ye=s(e),We=u(e,"P",{"data-svelte-h":!0}),y(We)!=="svelte-18ug1u"&&(We.innerHTML=lt),qe=s(e),b(Ge.$$.fragment,e),Se=s(e),re=u(e,"DIV",{class:!0});var ce=ie(re);b(Ee.$$.fragment,ce),Oe=s(ce),Ce=u(ce,"P",{"data-svelte-h":!0}),y(Ce)!=="svelte-suz89u"&&(Ce.innerHTML=ct),Ke=s(ce),ze=u(ce,"P",{"data-svelte-h":!0}),y(ze)!=="svelte-o55m63"&&(ze.innerHTML=it),et=s(ce),b(Me.$$.fragment,ce),tt=s(ce),be=u(ce,"DIV",{class:!0});var Ve=ie(be);b($e.$$.fragment,Ve),nt=s(Ve),Re=u(Ve,"P",{"data-svelte-h":!0}),y(Re)!=="svelte-dl71c6"&&(Re.innerHTML=mt),Ve.forEach(d),ce.forEach(d),Le=s(e),b(Te.$$.fragment,e),Qe=s(e),b(Ie.$$.fragment,e),Pe=s(e),Be=u(e,"P",{}),ie(Be).forEach(d),this.h()},h(){de(n,"name","hf:doc:metadata"),de(n,"content",Ct),de(v,"class","flex flex-wrap space-x-1"),de(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),de(re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,m){l(document.head,n),p(e,f,m),p(e,t,m),p(e,a,m),T(g,e,m),p(e,o,m),p(e,v,m),p(e,F,m),T(Q,e,m),p(e,P,m),p(e,V,m),p(e,A,m),p(e,x,m),p(e,O,m),p(e,C,m),p(e,K,m),p(e,z,m),p(e,ee,m),T(k,e,m),p(e,R,m),p(e,D,m),p(e,le,m),T(H,e,m),p(e,E,m),T(Y,e,m),p(e,$,m),p(e,q,m),p(e,B,m),T(S,e,m),p(e,N,m),T(te,e,m),p(e,ne,m),p(e,G,m),p(e,i,m),p(e,c,m),p(e,_,m),T(j,e,m),p(e,oe,m),T(L,e,m),p(e,we,m),p(e,Je,m),p(e,Fe,m),T(Ze,e,m),p(e,Ne,m),T(ke,e,m),p(e,Xe,m),p(e,ve,m),p(e,De,m),T(je,e,m),p(e,He,m),p(e,Ue,m),p(e,Ye,m),p(e,We,m),p(e,qe,m),T(Ge,e,m),p(e,Se,m),p(e,re,m),T(Ee,re,null),l(re,Oe),l(re,Ce),l(re,Ke),l(re,ze),l(re,et),T(Me,re,null),l(re,tt),l(re,be),T($e,be,null),l(be,nt),l(be,Re),p(e,Le,m),T(Te,e,m),p(e,Qe,m),T(Ie,e,m),p(e,Pe,m),p(e,Be,m),Ae=!0},p(e,[m]){const ce={};m&2&&(ce.$$scope={dirty:m,ctx:e}),Me.$set(ce);const Ve={};m&2&&(Ve.$$scope={dirty:m,ctx:e}),Te.$set(Ve)},i(e){Ae||(w(g.$$.fragment,e),w(Q.$$.fragment,e),w(k.$$.fragment,e),w(H.$$.fragment,e),w(Y.$$.fragment,e),w(S.$$.fragment,e),w(te.$$.fragment,e),w(j.$$.fragment,e),w(L.$$.fragment,e),w(Ze.$$.fragment,e),w(ke.$$.fragment,e),w(je.$$.fragment,e),w(Ge.$$.fragment,e),w(Ee.$$.fragment,e),w(Me.$$.fragment,e),w($e.$$.fragment,e),w(Te.$$.fragment,e),w(Ie.$$.fragment,e),Ae=!0)},o(e){J(g.$$.fragment,e),J(Q.$$.fragment,e),J(k.$$.fragment,e),J(H.$$.fragment,e),J(Y.$$.fragment,e),J(S.$$.fragment,e),J(te.$$.fragment,e),J(j.$$.fragment,e),J(L.$$.fragment,e),J(Ze.$$.fragment,e),J(ke.$$.fragment,e),J(je.$$.fragment,e),J(Ge.$$.fragment,e),J(Ee.$$.fragment,e),J(Me.$$.fragment,e),J($e.$$.fragment,e),J(Te.$$.fragment,e),J(Ie.$$.fragment,e),Ae=!1},d(e){e&&(d(f),d(t),d(a),d(o),d(v),d(F),d(P),d(V),d(A),d(x),d(O),d(C),d(K),d(z),d(ee),d(R),d(D),d(le),d(E),d($),d(q),d(B),d(N),d(ne),d(G),d(i),d(c),d(_),d(oe),d(we),d(Je),d(Fe),d(Ne),d(Xe),d(ve),d(De),d(He),d(Ue),d(Ye),d(We),d(qe),d(Se),d(re),d(Le),d(Qe),d(Pe),d(Be)),d(n),Z(g,e),Z(Q,e),Z(k,e),Z(H,e),Z(Y,e),Z(S,e),Z(te,e),Z(j,e),Z(L,e),Z(Ze,e),Z(ke,e),Z(je,e),Z(Ge,e),Z(Ee),Z(Me),Z($e),Z(Te,e),Z(Ie,e)}}}const Ct='{"title":"Encoder Decoder Models","local":"encoder-decoder-models","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Randomly initializing EncoderDecoderModel from model configurations.","local":"randomly-initializing-encoderdecodermodel-from-model-configurations","sections":[],"depth":2},{"title":"Initialising EncoderDecoderModel from a pretrained encoder and a pretrained decoder.","local":"initialising-encoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder","sections":[],"depth":2},{"title":"Loading an existing EncoderDecoderModel checkpoint and perform inference.","local":"loading-an-existing-encoderdecodermodel-checkpoint-and-perform-inference","sections":[],"depth":2},{"title":"Loading a PyTorch checkpoint into TFEncoderDecoderModel .","local":"loading-a-pytorch-checkpoint-into-tfencoderdecodermodel-","sections":[],"depth":2},{"title":"Training","local":"training","sections":[],"depth":2},{"title":"EncoderDecoderConfig","local":"transformers.EncoderDecoderConfig","sections":[],"depth":2},{"title":"EncoderDecoderModel","local":"transformers.EncoderDecoderModel","sections":[],"depth":2},{"title":"TFEncoderDecoderModel","local":"transformers.TFEncoderDecoderModel","sections":[],"depth":2},{"title":"FlaxEncoderDecoderModel","local":"transformers.FlaxEncoderDecoderModel","sections":[],"depth":2}],"depth":1}';function zt(W){return ht(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qt extends ut{constructor(n){super(),ft(this,n,zt,xt,pt,{})}}export{qt as component};
