import{S as I2,i as L2,s as U2,e as r,k as l,w as u,t as s,M as O2,c as a,d as t,m as d,a as n,x as g,h as i,b as m,G as e,g as w,y as _,q as b,o as v,B as y,v as N2,L as Ue}from"../../chunks/vendor-hf-doc-builder.js";import{T as td}from"../../chunks/Tip-hf-doc-builder.js";import{D as P}from"../../chunks/Docstring-hf-doc-builder.js";import{C as U}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ie}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Le}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function B2(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import AutoModel

model = AutoModel.from_pretrained("bert-base-cased")

# Push the model to your namespace with the name "my-finetuned-bert" and have a local clone in the
# *my-finetuned-bert* folder.
model.push_to_hub("my-finetuned-bert")

# Push the model to your namespace with the name "my-finetuned-bert" with no local clone.
model.push_to_hub("my-finetuned-bert", use_temp_dir=True)

# Push the model to an organization with the name "my-finetuned-bert" and have a local clone in the
# *my-finetuned-bert* folder.
model.push_to_hub("my-finetuned-bert", organization="huggingface")

# Make a change to an existing repo that has been cloned locally in *my-finetuned-bert*.
model.push_to_hub("my-finetuned-bert", repo_url="https://huggingface.co/sgugger/my-finetuned-bert")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel

model = AutoModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)

<span class="hljs-comment"># Push the model to your namespace with the name &quot;my-finetuned-bert&quot; and have a local clone in the</span>
<span class="hljs-comment"># *my-finetuned-bert* folder.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>)

<span class="hljs-comment"># Push the model to your namespace with the name &quot;my-finetuned-bert&quot; with no local clone.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, use_temp_dir=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># Push the model to an organization with the name &quot;my-finetuned-bert&quot; and have a local clone in the</span>
<span class="hljs-comment"># *my-finetuned-bert* folder.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, organization=<span class="hljs-string">&quot;huggingface&quot;</span>)

<span class="hljs-comment"># Make a change to an existing repo that has been cloned locally in *my-finetuned-bert*.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, repo_url=<span class="hljs-string">&quot;https://huggingface.co/sgugger/my-finetuned-bert&quot;</span>)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function S2(D){let p,T;return{c(){p=r("p"),T=s("Passing `use_auth_token=True\u201C is required when you want to use a private model.")},l($){p=a($,"P",{});var f=n(p);T=i(f,"Passing `use_auth_token=True\u201C is required when you want to use a private model."),f.forEach(t)},m($,f){w($,p,f),e(p,T)},d($){$&&t(p)}}}function X2(D){let p,T,$,f,k;return{c(){p=r("p"),T=s("Activate the special "),$=r("a"),f=s("\u201Coffline-mode\u201D"),k=s(` to
use this method in a firewalled environment.`),this.h()},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Activate the special "),$=a(x,"A",{href:!0,rel:!0});var re=n($);f=i(re,"\u201Coffline-mode\u201D"),re.forEach(t),k=i(x,` to
use this method in a firewalled environment.`),x.forEach(t),this.h()},h(){m($,"href","https://huggingface.co/transformers/installation.html#offline-mode"),m($,"rel","nofollow")},m(c,x){w(c,p,x),e(p,T),e(p,$),e($,f),e(p,k)},d(c){c&&t(p)}}}function V2(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import BertConfig, BertModel

# Download model and configuration from huggingface.co and cache.
model = BertModel.from_pretrained("bert-base-uncased")
# Model was saved using *save_pretrained('./test/saved_model/')* (for example purposes, not runnable).
model = BertModel.from_pretrained("./test/saved_model/")
# Update configuration during loading.
model = BertModel.from_pretrained("bert-base-uncased", output_attentions=True)
assert model.config.output_attentions == True
# Loading from a TF checkpoint file instead of a PyTorch model (slower, for example purposes, not runnable).
config = BertConfig.from_json_file("./tf_model/my_tf_model_config.json")
model = BertModel.from_pretrained("./tf_model/my_tf_checkpoint.ckpt.index", from_tf=True, config=config)
# Loading from a Flax checkpoint file instead of a PyTorch model (slower)
model = BertModel.from_pretrained("bert-base-uncased", from_flax=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, BertModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Download model and configuration from huggingface.co and cache.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = BertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Model was saved using *save_pretrained(&#x27;./test/saved_model/&#x27;)* (for example purposes, not runnable).</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = BertModel.from_pretrained(<span class="hljs-string">&quot;./test/saved_model/&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Update configuration during loading.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = BertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, output_attentions=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">assert</span> model.config.output_attentions == <span class="hljs-literal">True</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Loading from a TF checkpoint file instead of a PyTorch model (slower, for example purposes, not runnable).</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config = BertConfig.from_json_file(<span class="hljs-string">&quot;./tf_model/my_tf_model_config.json&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = BertModel.from_pretrained(<span class="hljs-string">&quot;./tf_model/my_tf_checkpoint.ckpt.index&quot;</span>, from_tf=<span class="hljs-literal">True</span>, config=config)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Loading from a Flax checkpoint file instead of a PyTorch model (slower)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = BertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, from_flax=<span class="hljs-literal">True</span>)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function W2(D){let p,T;return{c(){p=r("p"),T=s("This API is experimental and may have some slight breaking changes in the next releases.")},l($){p=a($,"P",{});var f=n(p);T=i(f,"This API is experimental and may have some slight breaking changes in the next releases."),f.forEach(t)},m($,f){w($,p,f),e(p,T)},d($){$&&t(p)}}}function H2(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import TFAutoModel

model = TFAutoModel.from_pretrained("bert-base-cased")

# Push the model to your namespace with the name "my-finetuned-bert" and have a local clone in the
# *my-finetuned-bert* folder.
model.push_to_hub("my-finetuned-bert")

# Push the model to your namespace with the name "my-finetuned-bert" with no local clone.
model.push_to_hub("my-finetuned-bert", use_temp_dir=True)

# Push the model to an organization with the name "my-finetuned-bert" and have a local clone in the
# *my-finetuned-bert* folder.
model.push_to_hub("my-finetuned-bert", organization="huggingface")

# Make a change to an existing repo that has been cloned locally in *my-finetuned-bert*.
model.push_to_hub("my-finetuned-bert", repo_url="https://huggingface.co/sgugger/my-finetuned-bert")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModel

model = TFAutoModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)

<span class="hljs-comment"># Push the model to your namespace with the name &quot;my-finetuned-bert&quot; and have a local clone in the</span>
<span class="hljs-comment"># *my-finetuned-bert* folder.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>)

<span class="hljs-comment"># Push the model to your namespace with the name &quot;my-finetuned-bert&quot; with no local clone.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, use_temp_dir=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># Push the model to an organization with the name &quot;my-finetuned-bert&quot; and have a local clone in the</span>
<span class="hljs-comment"># *my-finetuned-bert* folder.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, organization=<span class="hljs-string">&quot;huggingface&quot;</span>)

<span class="hljs-comment"># Make a change to an existing repo that has been cloned locally in *my-finetuned-bert*.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, repo_url=<span class="hljs-string">&quot;https://huggingface.co/sgugger/my-finetuned-bert&quot;</span>)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function R2(D){let p,T,$,f,k;return{c(){p=r("p"),T=s("Passing "),$=r("code"),f=s("use_auth_token=True"),k=s(" is required when you want to use a private model.")},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Passing "),$=a(x,"CODE",{});var re=n($);f=i(re,"use_auth_token=True"),re.forEach(t),k=i(x," is required when you want to use a private model."),x.forEach(t)},m(c,x){w(c,p,x),e(p,T),e(p,$),e($,f),e(p,k)},d(c){c&&t(p)}}}function G2(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import BertConfig, TFBertModel

# Download model and configuration from huggingface.co and cache.
model = TFBertModel.from_pretrained("bert-base-uncased")
# Model was saved using *save_pretrained('./test/saved_model/')* (for example purposes, not runnable).
model = TFBertModel.from_pretrained("./test/saved_model/")
# Update configuration during loading.
model = TFBertModel.from_pretrained("bert-base-uncased", output_attentions=True)
assert model.config.output_attentions == True
# Loading from a Pytorch model file instead of a TensorFlow checkpoint (slower, for example purposes, not runnable).
config = BertConfig.from_json_file("./pt_model/my_pt_model_config.json")
model = TFBertModel.from_pretrained("./pt_model/my_pytorch_model.bin", from_pt=True, config=config)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, TFBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Download model and configuration from huggingface.co and cache.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Model was saved using *save_pretrained(&#x27;./test/saved_model/&#x27;)* (for example purposes, not runnable).</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFBertModel.from_pretrained(<span class="hljs-string">&quot;./test/saved_model/&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Update configuration during loading.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, output_attentions=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">assert</span> model.config.output_attentions == <span class="hljs-literal">True</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Loading from a Pytorch model file instead of a TensorFlow checkpoint (slower, for example purposes, not runnable).</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config = BertConfig.from_json_file(<span class="hljs-string">&quot;./pt_model/my_pt_model_config.json&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFBertModel.from_pretrained(<span class="hljs-string">&quot;./pt_model/my_pytorch_model.bin&quot;</span>, from_pt=<span class="hljs-literal">True</span>, config=config)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function Y2(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import FlaxAutoModel

model = FlaxAutoModel.from_pretrained("bert-base-cased")

# Push the model to your namespace with the name "my-finetuned-bert" and have a local clone in the
# *my-finetuned-bert* folder.
model.push_to_hub("my-finetuned-bert")

# Push the model to your namespace with the name "my-finetuned-bert" with no local clone.
model.push_to_hub("my-finetuned-bert", use_temp_dir=True)

# Push the model to an organization with the name "my-finetuned-bert" and have a local clone in the
# *my-finetuned-bert* folder.
model.push_to_hub("my-finetuned-bert", organization="huggingface")

# Make a change to an existing repo that has been cloned locally in *my-finetuned-bert*.
model.push_to_hub("my-finetuned-bert", repo_url="https://huggingface.co/sgugger/my-finetuned-bert")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxAutoModel

model = FlaxAutoModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)

<span class="hljs-comment"># Push the model to your namespace with the name &quot;my-finetuned-bert&quot; and have a local clone in the</span>
<span class="hljs-comment"># *my-finetuned-bert* folder.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>)

<span class="hljs-comment"># Push the model to your namespace with the name &quot;my-finetuned-bert&quot; with no local clone.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, use_temp_dir=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># Push the model to an organization with the name &quot;my-finetuned-bert&quot; and have a local clone in the</span>
<span class="hljs-comment"># *my-finetuned-bert* folder.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, organization=<span class="hljs-string">&quot;huggingface&quot;</span>)

<span class="hljs-comment"># Make a change to an existing repo that has been cloned locally in *my-finetuned-bert*.</span>
model.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, repo_url=<span class="hljs-string">&quot;https://huggingface.co/sgugger/my-finetuned-bert&quot;</span>)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function J2(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import BertConfig, FlaxBertModel

# Download model and configuration from huggingface.co and cache.
model = FlaxBertModel.from_pretrained("bert-base-cased")
# Model was saved using *save_pretrained('./test/saved_model/')* (for example purposes, not runnable).
model = FlaxBertModel.from_pretrained("./test/saved_model/")
# Loading from a PyTorch checkpoint file instead of a PyTorch model (slower, for example purposes, not runnable).
config = BertConfig.from_json_file("./pt_model/config.json")
model = FlaxBertModel.from_pretrained("./pt_model/pytorch_model.bin", from_pt=True, config=config)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, FlaxBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Download model and configuration from huggingface.co and cache.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Model was saved using *save_pretrained(&#x27;./test/saved_model/&#x27;)* (for example purposes, not runnable).</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxBertModel.from_pretrained(<span class="hljs-string">&quot;./test/saved_model/&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Loading from a PyTorch checkpoint file instead of a PyTorch model (slower, for example purposes, not runnable).</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config = BertConfig.from_json_file(<span class="hljs-string">&quot;./pt_model/config.json&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxBertModel.from_pretrained(<span class="hljs-string">&quot;./pt_model/pytorch_model.bin&quot;</span>, from_pt=<span class="hljs-literal">True</span>, config=config)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function K2(D){let p,T;return{c(){p=r("p"),T=s("This API is experimental and may have some slight breaking changes in the next releases.")},l($){p=a($,"P",{});var f=n(p);T=i(f,"This API is experimental and may have some slight breaking changes in the next releases."),f.forEach(t)},m($,f){w($,p,f),e(p,T)},d($){$&&t(p)}}}function Z2(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import FlaxBertModel

# load model
model = FlaxBertModel.from_pretrained("bert-base-cased")
# By default, the model parameters will be in fp32 precision, to cast these to bfloat16 precision
model.params = model.to_bf16(model.params)
# If you want don't want to cast certain parameters (for example layer norm bias and scale)
# then pass the mask as follows
from flax import traverse_util

model = FlaxBertModel.from_pretrained("bert-base-cased")
flat_params = traverse_util.flatten_dict(model.params)
mask = {
    path: (path[-2] != ("LayerNorm", "bias") and path[-2:] != ("LayerNorm", "scale"))
    for path in flat_params
}
mask = traverse_util.unflatten_dict(mask)
model.params = model.to_bf16(model.params, mask)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># By default, the model parameters will be in fp32 precision, to cast these to bfloat16 precision</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.params = model.to_bf16(model.params)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># If you want don&#x27;t want to cast certain parameters (for example layer norm bias and scale)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># then pass the mask as follows</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> flax <span class="hljs-keyword">import</span> traverse_util

<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>flat_params = traverse_util.flatten_dict(model.params)
<span class="hljs-meta">&gt;&gt;&gt; </span>mask = {
<span class="hljs-meta">... </span>    path: (path[-<span class="hljs-number">2</span>] != (<span class="hljs-string">&quot;LayerNorm&quot;</span>, <span class="hljs-string">&quot;bias&quot;</span>) <span class="hljs-keyword">and</span> path[-<span class="hljs-number">2</span>:] != (<span class="hljs-string">&quot;LayerNorm&quot;</span>, <span class="hljs-string">&quot;scale&quot;</span>))
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> path <span class="hljs-keyword">in</span> flat_params
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>mask = traverse_util.unflatten_dict(mask)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.params = model.to_bf16(model.params, mask)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function Q2(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import FlaxBertModel

# load model
model = FlaxBertModel.from_pretrained("bert-base-cased")
# By default, the model params will be in fp32, to cast these to float16
model.params = model.to_fp16(model.params)
# If you want don't want to cast certain parameters (for example layer norm bias and scale)
# then pass the mask as follows
from flax import traverse_util

model = FlaxBertModel.from_pretrained("bert-base-cased")
flat_params = traverse_util.flatten_dict(model.params)
mask = {
    path: (path[-2] != ("LayerNorm", "bias") and path[-2:] != ("LayerNorm", "scale"))
    for path in flat_params
}
mask = traverse_util.unflatten_dict(mask)
model.params = model.to_fp16(model.params, mask)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># By default, the model params will be in fp32, to cast these to float16</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.params = model.to_fp16(model.params)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># If you want don&#x27;t want to cast certain parameters (for example layer norm bias and scale)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># then pass the mask as follows</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> flax <span class="hljs-keyword">import</span> traverse_util

<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>flat_params = traverse_util.flatten_dict(model.params)
<span class="hljs-meta">&gt;&gt;&gt; </span>mask = {
<span class="hljs-meta">... </span>    path: (path[-<span class="hljs-number">2</span>] != (<span class="hljs-string">&quot;LayerNorm&quot;</span>, <span class="hljs-string">&quot;bias&quot;</span>) <span class="hljs-keyword">and</span> path[-<span class="hljs-number">2</span>:] != (<span class="hljs-string">&quot;LayerNorm&quot;</span>, <span class="hljs-string">&quot;scale&quot;</span>))
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> path <span class="hljs-keyword">in</span> flat_params
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>mask = traverse_util.unflatten_dict(mask)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.params = model.to_fp16(model.params, mask)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function ex(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import FlaxBertModel

# Download model and configuration from huggingface.co
model = FlaxBertModel.from_pretrained("bert-base-cased")
# By default, the model params will be in fp32, to illustrate the use of this method,
# we'll first cast to fp16 and back to fp32
model.params = model.to_f16(model.params)
# now cast back to fp32
model.params = model.to_fp32(model.params)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Download model and configuration from huggingface.co</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># By default, the model params will be in fp32, to illustrate the use of this method,</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># we&#x27;ll first cast to fp16 and back to fp32</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.params = model.to_f16(model.params)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># now cast back to fp32</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.params = model.to_fp32(model.params)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function tx(D){let p,T,$,f,k;return f=new U({props:{code:`from transformers import {object_class}

{object} = {object_class}.from_pretrained("bert-base-cased")

# Push the {object} to your namespace with the name "my-finetuned-bert" and have a local clone in the
# *my-finetuned-bert* folder.
{object}.push_to_hub("my-finetuned-bert")

# Push the {object} to your namespace with the name "my-finetuned-bert" with no local clone.
{object}.push_to_hub("my-finetuned-bert", use_temp_dir=True)

# Push the {object} to an organization with the name "my-finetuned-bert" and have a local clone in the
# *my-finetuned-bert* folder.
{object}.push_to_hub("my-finetuned-bert", organization="huggingface")

# Make a change to an existing repo that has been cloned locally in *my-finetuned-bert*.
{object}.push_to_hub("my-finetuned-bert", repo_url="https://huggingface.co/sgugger/my-finetuned-bert")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> {object_class}

{<span class="hljs-built_in">object</span>} = {object_class}.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)

<span class="hljs-comment"># Push the {object} to your namespace with the name &quot;my-finetuned-bert&quot; and have a local clone in the</span>
<span class="hljs-comment"># *my-finetuned-bert* folder.</span>
{<span class="hljs-built_in">object</span>}.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>)

<span class="hljs-comment"># Push the {object} to your namespace with the name &quot;my-finetuned-bert&quot; with no local clone.</span>
{<span class="hljs-built_in">object</span>}.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, use_temp_dir=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># Push the {object} to an organization with the name &quot;my-finetuned-bert&quot; and have a local clone in the</span>
<span class="hljs-comment"># *my-finetuned-bert* folder.</span>
{<span class="hljs-built_in">object</span>}.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, organization=<span class="hljs-string">&quot;huggingface&quot;</span>)

<span class="hljs-comment"># Make a change to an existing repo that has been cloned locally in *my-finetuned-bert*.</span>
{<span class="hljs-built_in">object</span>}.push_to_hub(<span class="hljs-string">&quot;my-finetuned-bert&quot;</span>, repo_url=<span class="hljs-string">&quot;https://huggingface.co/sgugger/my-finetuned-bert&quot;</span>)`}}),{c(){p=r("p"),T=s("Examples:"),$=l(),u(f.$$.fragment)},l(c){p=a(c,"P",{});var x=n(p);T=i(x,"Examples:"),x.forEach(t),$=d(c),g(f.$$.fragment,c)},m(c,x){w(c,p,x),e(p,T),w(c,$,x),_(f,c,x),k=!0},p:Ue,i(c){k||(b(f.$$.fragment,c),k=!0)},o(c){v(f.$$.fragment,c),k=!1},d(c){c&&t(p),c&&t($),y(f,c)}}}function ox(D){let p,T,$,f,k,c,x,re,lm,od,K,dm,Pa,cm,mm,Ma,pm,hm,Ea,fm,um,rd,Oe,ja,gm,_m,Fa,bm,vm,ad,ot,Mn,ym,wm,En,$m,nd,O,xm,Da,Tm,km,jn,Pm,Mm,qa,Em,jm,Aa,Fm,Dm,za,qm,Am,sd,Ne,rt,Fn,To,zm,Dn,Cm,id,j,ko,Im,qn,Lm,Um,Ca,Ia,Om,Nm,Bm,Po,An,Sm,Xm,zn,Vm,Wm,Cn,Hm,Rm,H,In,me,Ln,Gm,Ym,La,Jm,Km,Ua,Zm,Qm,ep,Mo,pe,Un,tp,op,On,rp,ap,Nn,np,sp,ip,Be,at,Bn,lp,dp,Oa,cp,mp,pp,nt,Sn,hp,fp,Xn,up,gp,_p,st,Vn,bp,vp,Wn,yp,wp,$p,Hn,it,Rn,xp,Tp,Gn,kp,Pp,Mp,Yn,lt,Jn,Ep,jp,Kn,Fp,Dp,qp,Zn,S,Qn,Ap,zp,es,Cp,Ip,ts,Lp,Up,os,Op,Np,rs,Bp,Sp,Xp,he,Eo,Vp,jo,Wp,as,Hp,Rp,Gp,dt,Yp,q,Fo,Jp,ns,Kp,Zp,Se,Qp,ss,eh,th,is,oh,rh,ah,Do,nh,ls,sh,ih,lh,qo,dh,ds,ch,mh,ph,ct,hh,mt,fh,pt,uh,cs,Na,ms,gh,_h,bh,ps,vh,yh,hs,wh,$h,R,fs,xh,Th,us,kh,Ph,gs,Mh,Eh,_s,jh,Fh,bs,Dh,qh,vs,Ah,zh,ht,Ao,Ch,ys,Ih,Lh,ft,zo,Uh,ws,Oh,Nh,fe,Co,Bh,$s,Sh,Xh,xs,Vh,Wh,ue,Io,Hh,Ts,Rh,Gh,ks,Yh,Jh,ut,Lo,Kh,Ps,Zh,Qh,gt,Uo,ef,Ms,tf,of,_t,Oo,rf,Es,af,nf,ge,No,sf,js,lf,df,bt,cf,_e,Bo,mf,So,pf,Fs,hf,ff,uf,Xo,gf,Ds,_f,bf,vf,vt,Vo,yf,Wo,wf,qs,$f,xf,Tf,yt,Ho,kf,As,Pf,Mf,be,Ro,Ef,zs,jf,Ff,Go,Df,Cs,qf,Af,ld,Ba,dd,Xe,wt,Is,Yo,zf,Ls,Cf,cd,ve,If,Sa,Lf,Uf,Jo,Of,Nf,md,$t,Bf,Us,Sf,Xf,pd,Ko,hd,xt,Vf,Os,Wf,Hf,fd,Z,Rf,Ns,Gf,Yf,Bs,Jf,Kf,Ss,Zf,Qf,ud,Zo,gd,Tt,eu,Xs,tu,ou,_d,Qo,bd,er,vd,Xa,ru,yd,tr,wd,kt,au,Vs,nu,su,$d,Ve,Pt,Ws,or,iu,Hs,lu,xd,Q,du,Rs,cu,mu,Gs,pu,hu,Ys,fu,uu,Td,rr,kd,ye,gu,Js,_u,bu,Ks,vu,yu,Pd,ar,Md,Mt,wu,Zs,$u,xu,Ed,nr,jd,Va,Tu,Fd,We,Et,Qs,sr,ku,ei,Pu,Dd,C,ir,Mu,lr,Eu,ti,ju,Fu,Du,we,dr,qu,oi,Au,zu,He,Cu,ri,Iu,Lu,ai,Uu,Ou,Nu,jt,cr,Bu,ni,Su,Xu,Ft,mr,Vu,Re,Wu,si,Hu,Ru,pr,Gu,Yu,Ju,Dt,hr,Ku,ii,Zu,Qu,qt,fr,eg,li,tg,og,At,ur,rg,di,ag,ng,zt,gr,sg,ci,ig,lg,Ct,_r,dg,Ge,cg,mi,mg,pg,Wa,hg,fg,qd,Ye,It,pi,br,ug,hi,gg,Ad,M,vr,_g,fi,bg,vg,Ha,Ra,yg,wg,$g,yr,ui,xg,Tg,gi,kg,Pg,_i,Mg,Eg,Je,$e,bi,jg,Fg,Ga,Dg,qg,Ya,Ag,zg,Cg,Lt,vi,Ig,Lg,yi,Ug,Og,Ng,X,wi,Bg,Sg,$i,Xg,Vg,xi,Wg,Hg,Ti,Rg,Gg,ki,Yg,Jg,Kg,xe,wr,Zg,$r,Qg,Pi,e_,t_,o_,Ut,r_,Ot,xr,a_,Mi,n_,s_,N,Tr,i_,Ei,l_,d_,kr,c_,ji,m_,p_,h_,Pr,f_,Fi,u_,g_,__,Nt,b_,Bt,v_,St,Mr,y_,Di,w_,$_,Xt,Er,x_,qi,T_,k_,Vt,jr,P_,Ai,M_,E_,Wt,Fr,j_,zi,F_,D_,Ht,Dr,q_,Ci,A_,z_,Rt,qr,C_,Ii,I_,L_,Gt,Ar,U_,Li,O_,N_,Yt,zr,B_,Ui,S_,X_,Te,Cr,V_,Ir,W_,Oi,H_,R_,G_,Lr,Y_,Ni,J_,K_,Z_,Jt,Ur,Q_,Or,eb,Ja,tb,ob,rb,Kt,Nr,ab,Bi,nb,sb,Zt,Br,ib,Si,lb,db,Qt,Sr,cb,Xi,mb,pb,eo,Xr,hb,Vi,fb,ub,to,Vr,gb,Wi,_b,bb,oo,Wr,vb,Hr,yb,Hi,wb,$b,xb,ro,Rr,Tb,Gr,kb,Ri,Pb,Mb,zd,Ke,ao,Gi,Yr,Eb,Yi,jb,Cd,ae,Jr,Fb,Kr,Db,Ji,qb,Ab,zb,no,Zr,Cb,Ki,Ib,Id,Ze,so,Zi,Qr,Lb,Qi,Ub,Ld,A,ea,Ob,el,Nb,Bb,Ka,Za,Sb,Xb,Vb,tl,Wb,Hb,Qe,ke,ol,Rb,Gb,Qa,Yb,Jb,en,Kb,Zb,Qb,io,rl,ev,tv,al,ov,rv,av,V,nl,nv,sv,sl,iv,lv,il,dv,cv,ll,mv,pv,dl,hv,fv,uv,Pe,ta,gv,oa,_v,cl,bv,vv,yv,lo,wv,W,ra,$v,ml,xv,Tv,aa,kv,pl,Pv,Mv,Ev,na,jv,hl,Fv,Dv,qv,co,Av,Me,sa,zv,fl,Cv,Iv,mo,Lv,po,ia,Uv,la,Ov,ul,Nv,Bv,Sv,ee,da,Xv,G,Vv,gl,Wv,Hv,_l,Rv,Gv,bl,Yv,Jv,vl,Kv,Zv,Qv,yl,ey,ty,ho,oy,te,ca,ry,Y,ay,wl,ny,sy,$l,iy,ly,xl,dy,cy,Tl,my,py,hy,kl,fy,uy,fo,gy,Ee,ma,_y,J,by,Pl,vy,yy,Ml,wy,$y,El,xy,Ty,jl,ky,Py,My,uo,Ud,et,go,Fl,pa,Ey,Dl,jy,Od,ne,ha,Fy,ql,Dy,qy,je,fa,Ay,ua,zy,Al,Cy,Iy,Ly,_o,Nd,tt,bo,zl,ga,Uy,Cl,Oy,Bd,se,_a,Ny,ba,By,va,Il,Sy,Xy,Vy,Ll,Wy,Sd;return c=new Ie({}),To=new Ie({}),ko=new P({props:{name:"class transformers.PreTrainedModel",anchor:"transformers.PreTrainedModel",parameters:[{name:"config",val:": PretrainedConfig"},{name:"*inputs",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L897"}}),Eo=new P({props:{name:"push_to_hub",anchor:"transformers.PreTrainedModel.push_to_hub",parameters:[{name:"repo_path_or_name",val:": typing.Optional[str] = None"},{name:"repo_url",val:": typing.Optional[str] = None"},{name:"use_temp_dir",val:": bool = False"},{name:"commit_message",val:": str = 'add model'"},{name:"organization",val:": typing.Optional[str] = None"},{name:"private",val:": typing.Optional[bool] = None"},{name:"use_auth_token",val:": typing.Union[bool, str, NoneType] = None"},{name:"max_shard_size",val:": typing.Union[int, str] = '10GB'"},{name:"**model_card_kwargs",val:""}],parametersDescription:[{anchor:"transformers.PreTrainedModel.push_to_hub.repo_path_or_name",description:`<strong>repo_path_or_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Can either be a repository name for your model in the Hub or a path to a local folder (in which case
the repository will have the name of that local folder). If not specified, will default to the name
given by <code>repo_url</code> and a local directory with that name will be created.`,name:"repo_path_or_name"},{anchor:"transformers.PreTrainedModel.push_to_hub.repo_url",description:`<strong>repo_url</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Specify this in case you want to push to an existing repository in the hub. If unspecified, a new
repository will be created in your namespace (unless you specify an <code>organization</code>) with <code>repo_name</code>.`,name:"repo_url"},{anchor:"transformers.PreTrainedModel.push_to_hub.use_temp_dir",description:`<strong>use_temp_dir</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to clone the distant repo in a temporary directory or in <code>repo_path_or_name</code> inside the
current working directory. This will slow things down if you are making changes in an existing repo
since you will need to clone the repo before every push.`,name:"use_temp_dir"},{anchor:"transformers.PreTrainedModel.push_to_hub.commit_message",description:`<strong>commit_message</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;add model&quot;</code>) &#x2014;
Message to commit while pushing.`,name:"commit_message"},{anchor:"transformers.PreTrainedModel.push_to_hub.organization",description:`<strong>organization</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Organization in which you want to push your {object} (you must be a member of this organization).`,name:"organization"},{anchor:"transformers.PreTrainedModel.push_to_hub.private",description:`<strong>private</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not the repository created should be private (requires a paying subscription).`,name:"private"},{anchor:"transformers.PreTrainedModel.push_to_hub.use_auth_token",description:`<strong>use_auth_token</strong> (<code>bool</code> or <code>str</code>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>transformers-cli login</code> (stored in <code>~/.huggingface</code>). Will default to <code>True</code> if
<code>repo_url</code> is not specified.`,name:"use_auth_token"},{anchor:"transformers.PreTrainedModel.push_to_hub.max_shard_size",description:`<strong>max_shard_size</strong> (<code>int</code> or <code>str</code>, <em>optional</em>, defaults to <code>&quot;10GB&quot;</code>) &#x2014;
The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size
lower than this size. If expressed as a string, needs to be digits followed by a unit (like <code>&quot;5MB&quot;</code>).</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>If a single weight of the model is bigger than <code>max_shard_size</code>, it will be in its own checkpoint shard
which will be bigger than <code>max_shard_size</code>.</p>

					</div>`,name:"max_shard_size"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L2525",returnDescription:`
<p>The url of the commit of your {object} in the given repository.</p>
`,returnType:`
<p><code>str</code></p>
`}}),dt=new Le({props:{anchor:"transformers.PreTrainedModel.push_to_hub.example",$$slots:{default:[B2]},$$scope:{ctx:D}}}),Fo=new P({props:{name:"from_pretrained",anchor:"transformers.PreTrainedModel.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike, NoneType]"},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.PreTrainedModel.from_pretrained.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) &#x2014;
Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/pr_17548/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>
<li>A path or url to a model folder containing a <em>flax checkpoint file</em> in <em>.msgpack</em> format (e.g,
<code>./flax_model/</code> containing <code>flax_model.msgpack</code>). In this case, <code>from_flax</code> should be set to
<code>True</code>.</li>
<li><code>None</code> if you are both providing the configuration and state dictionary (resp. with keyword
arguments <code>config</code> and <code>state_dict</code>).</li>
</ul>`,name:"pretrained_model_name_or_path"},{anchor:"transformers.PreTrainedModel.from_pretrained.model_args",description:`<strong>model_args</strong> (sequence of 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.PreTrainedModel.from_pretrained.config",description:`<strong>config</strong> (<code>Union[PretrainedConfig, str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Can be either:</p>
<ul>
<li>an instance of a class derived from <a href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>,</li>
<li>a string or path valid as input to <a href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig.from_pretrained">from_pretrained()</a>.</li>
</ul>
<p>Configuration for the model to use instead of an automatically loaded configuration. Configuration can
be automatically loaded when:</p>
<ul>
<li>The model is a model provided by the library (loaded with the <em>model id</em> string of a pretrained
model).</li>
<li>The model was saved using <a href="/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a> and is reloaded by supplying the
save directory.</li>
<li>The model is loaded by supplying a local directory as <code>pretrained_model_name_or_path</code> and a
configuration JSON file named <em>config.json</em> is found in the directory.</li>
</ul>`,name:"config"},{anchor:"transformers.PreTrainedModel.from_pretrained.state_dict",description:`<strong>state_dict</strong> (<code>Dict[str, torch.Tensor]</code>, <em>optional</em>) &#x2014;
A state dictionary to use instead of a state dictionary loaded from saved weights file.</p>
<p>This option can be used if you want to create a model from a pretrained configuration but load your own
weights. In this case though, you should check if using <a href="/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a> and
<a href="/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> is not a simpler option.`,name:"state_dict"},{anchor:"transformers.PreTrainedModel.from_pretrained.cache_dir",description:`<strong>cache_dir</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Path to a directory in which a downloaded pretrained model configuration should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"transformers.PreTrainedModel.from_pretrained.from_tf",description:`<strong>from_tf</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Load the model weights from a TensorFlow checkpoint save file (see docstring of
<code>pretrained_model_name_or_path</code> argument).`,name:"from_tf"},{anchor:"transformers.PreTrainedModel.from_pretrained.from_flax",description:`<strong>from_flax</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Load the model weights from a Flax checkpoint save file (see docstring of
<code>pretrained_model_name_or_path</code> argument).`,name:"from_flax"},{anchor:"transformers.PreTrainedModel.from_pretrained.ignore_mismatched_sizes",description:`<strong>ignore_mismatched_sizes</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to raise an error if some of the weights from the checkpoint do not have the same size
as the weights of the model (if for instance, you are instantiating a model with 10 labels from a
checkpoint with 3 labels).`,name:"ignore_mismatched_sizes"},{anchor:"transformers.PreTrainedModel.from_pretrained.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"transformers.PreTrainedModel.from_pretrained.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to delete incompletely received files. Will attempt to resume the download if such a
file exists.`,name:"resume_download"},{anchor:"transformers.PreTrainedModel.from_pretrained.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, e.g., <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}</code>. The proxies are used on each request.`,name:"proxies"},{anchor:"transformers.PreTrainedModel.from_pretrained.output_loading_info(bool,",description:`<strong>output_loading_info(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether ot not to also return a dictionary containing missing keys, unexpected keys and error messages.`,name:"output_loading_info(bool,"},{anchor:"transformers.PreTrainedModel.from_pretrained.local_files_only(bool,",description:`<strong>local_files_only(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to only look at local files (i.e., do not try to download the model).`,name:"local_files_only(bool,"},{anchor:"transformers.PreTrainedModel.from_pretrained.use_auth_token",description:`<strong>use_auth_token</strong> (<code>str</code> or <em>bool</em>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>transformers-cli login</code> (stored in <code>~/.huggingface</code>).`,name:"use_auth_token"},{anchor:"transformers.PreTrainedModel.from_pretrained.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so <code>revision</code> can be any
identifier allowed by git.`,name:"revision"},{anchor:"transformers.PreTrainedModel.from_pretrained.mirror",description:`<strong>mirror</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Mirror source to accelerate downloads in China. If you are from China and have an accessibility
problem, you can set this option to resolve it. Note that we do not guarantee the timeliness or safety.
Please refer to the mirror site for more information.`,name:"mirror"},{anchor:"transformers.PreTrainedModel.from_pretrained._fast_init(bool,",description:`<strong>_fast_init(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to disable fast initialization.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>One should only disable <em>_fast_init</em> to ensure backwards compatibility with <code>transformers.__version__ &lt; 4.6.0</code> for seeded model initialization. This argument will be removed at the next major version. See
<a href="https://github.com/huggingface/transformers/pull/11471" rel="nofollow">pull request 11471</a> for more information.</p>

					</div>`,name:"_fast_init(bool,"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1619",parameterGroups:[{title:"Parameters for big model inference",parametersDescription:`
<ul>
<li>
<p><strong>low_cpu_mem_usage(<code>bool</code>,</strong> <em>optional</em>) \u2014
Tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model.
This is an experimental feature and a subject to change at any moment.</p>
</li>
<li>
<p><strong>torch_dtype</strong> (<code>str</code> or <code>torch.dtype</code>, <em>optional</em>) \u2014
Override the default <code>torch.dtype</code> and load the model under this dtype. If <code>"auto"</code> is passed the dtype
will be automatically derived from the model\u2019s weights.</p>
</li>
<li>
<p><strong>device_map</strong> (<code>str</code> or <code>Dict[str, Union[int, str, torch.device]]</code>, <em>optional</em>) \u2014
A map that specifies where each submodule should go. It doesn\u2019t need to be refined to each
parameter/buffer name, once a given module name is inside, every submodule of it will be sent to the
same device.</p>
<p>To have Accelerate compute the most optimized <code>device_map</code> automatically, set <code>device_map="auto"</code>.</p>
</li>
<li>
<p><strong>max_memory</strong> (<code>Dict</code>, <em>optional</em>) \u2014
A dictionary device identifier to maximum memory. Will default to the maximum memory available for each
GPU and the available CPU RAM if unset.</p>
</li>
<li>
<p><strong>offload_folder</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) \u2014
If the <code>device_map</code> contains any value <code>"disk"</code>, the folder where we will offload weights.</p>
</li>
<li>
<p><strong>offload_state_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) \u2014
If <code>True</code>, will temporarily offload the CPU state dict to the hard drive to avoid getting out of CPU
RAM if the weight of the CPU state dict + the biggest shard of the checkpoint does not fit.</p>
</li>
<li>
<p><strong>kwargs</strong> (remaining dictionary of keyword arguments, <em>optional</em>) \u2014
Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
<code>output_attentions=True</code>). Behaves differently depending on whether a <code>config</code> is provided or
automatically loaded:</p>
<ul>
<li>If a configuration is provided with <code>config</code>, <code>**kwargs</code> will be directly passed to the
underlying model\u2019s <code>__init__</code> method (we assume all relevant updates to the configuration have
already been done)</li>
<li>If a configuration is not provided, <code>kwargs</code> will be first passed to the configuration class
initialization function (<a
  href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig.from_pretrained"
>from_pretrained()</a>). Each key of <code>kwargs</code> that
corresponds to a configuration attribute will be used to override said attribute with the
supplied <code>kwargs</code> value. Remaining keys that do not correspond to any configuration attribute
will be passed to the underlying model\u2019s <code>__init__</code> function.</li>
</ul>
</li>
</ul>
`}]}}),ct=new td({props:{$$slots:{default:[S2]},$$scope:{ctx:D}}}),mt=new td({props:{$$slots:{default:[X2]},$$scope:{ctx:D}}}),pt=new Le({props:{anchor:"transformers.PreTrainedModel.from_pretrained.example",$$slots:{default:[V2]},$$scope:{ctx:D}}}),Ao=new P({props:{name:"get_input_embeddings",anchor:"transformers.PreTrainedModel.get_input_embeddings",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1052",returnDescription:`
<p>A torch module mapping vocabulary to hidden states.</p>
`,returnType:`
<p><code>nn.Module</code></p>
`}}),zo=new P({props:{name:"get_output_embeddings",anchor:"transformers.PreTrainedModel.get_output_embeddings",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1078",returnDescription:`
<p>A torch module mapping hidden states to vocabulary.</p>
`,returnType:`
<p><code>nn.Module</code></p>
`}}),Co=new P({props:{name:"gradient_checkpointing_disable",anchor:"transformers.PreTrainedModel.gradient_checkpointing_disable",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1462"}}),Io=new P({props:{name:"gradient_checkpointing_enable",anchor:"transformers.PreTrainedModel.gradient_checkpointing_enable",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1451"}}),Lo=new P({props:{name:"init_weights",anchor:"transformers.PreTrainedModel.init_weights",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1418"}}),Uo=new P({props:{name:"post_init",anchor:"transformers.PreTrainedModel.post_init",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L971"}}),Oo=new P({props:{name:"prune_heads",anchor:"transformers.PreTrainedModel.prune_heads",parameters:[{name:"heads_to_prune",val:": typing.Dict[int, typing.List[int]]"}],parametersDescription:[{anchor:"transformers.PreTrainedModel.prune_heads.heads_to_prune",description:`<strong>heads_to_prune</strong> (<code>Dict[int, List[int]]</code>) &#x2014;
Dictionary with keys being selected layer indices (<code>int</code>) and associated values being the list of heads
to prune in said layer (list of <code>int</code>). For instance {1: [0, 2], 2: [2, 3]} will prune heads 0 and 2 on
layer 1 and heads 2 and 3 on layer 2.`,name:"heads_to_prune"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1434"}}),No=new P({props:{name:"register_for_auto_class",anchor:"transformers.PreTrainedModel.register_for_auto_class",parameters:[{name:"auto_class",val:" = 'AutoModel'"}],parametersDescription:[{anchor:"transformers.PreTrainedModel.register_for_auto_class.auto_class",description:`<strong>auto_class</strong> (<code>str</code> or <code>type</code>, <em>optional</em>, defaults to <code>&quot;AutoModel&quot;</code>) &#x2014;
The auto class to register this new model with.`,name:"auto_class"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L2499"}}),bt=new td({props:{warning:!0,$$slots:{default:[W2]},$$scope:{ctx:D}}}),Bo=new P({props:{name:"resize_token_embeddings",anchor:"transformers.PreTrainedModel.resize_token_embeddings",parameters:[{name:"new_num_tokens",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"transformers.PreTrainedModel.resize_token_embeddings.new_num_tokens",description:`<strong>new_num_tokens</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of new tokens in the embedding matrix. Increasing the size will add newly initialized
vectors at the end. Reducing the size will remove vectors from the end. If not provided or <code>None</code>, just
returns a pointer to the input tokens <code>torch.nn.Embedding</code> module of the model without doing anything.`,name:"new_num_tokens"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1209",returnDescription:`
<p>Pointer to the input tokens Embeddings Module of the model.</p>
`,returnType:`
<p><code>torch.nn.Embedding</code></p>
`}}),Vo=new P({props:{name:"save_pretrained",anchor:"transformers.PreTrainedModel.save_pretrained",parameters:[{name:"save_directory",val:": typing.Union[str, os.PathLike]"},{name:"is_main_process",val:": bool = True"},{name:"state_dict",val:": typing.Optional[dict] = None"},{name:"save_function",val:": typing.Callable = <function save at 0x7fabe1731430>"},{name:"push_to_hub",val:": bool = False"},{name:"max_shard_size",val:": typing.Union[int, str] = '10GB'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.PreTrainedModel.save_pretrained.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory to which to save. Will be created if it doesn&#x2019;t exist.`,name:"save_directory"},{anchor:"transformers.PreTrainedModel.save_pretrained.is_main_process",description:`<strong>is_main_process</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether the process calling this is the main process or not. Useful when in distributed training like
TPUs and need to call this function on all processes. In this case, set <code>is_main_process=True</code> only on
the main process to avoid race conditions.`,name:"is_main_process"},{anchor:"transformers.PreTrainedModel.save_pretrained.state_dict",description:`<strong>state_dict</strong> (nested dictionary of <code>torch.Tensor</code>) &#x2014;
The state dictionary of the model to save. Will default to <code>self.state_dict()</code>, but can be used to only
save parts of the model or if special precautions need to be taken when recovering the state dictionary
of a model (like when using model parallelism).`,name:"state_dict"},{anchor:"transformers.PreTrainedModel.save_pretrained.save_function",description:`<strong>save_function</strong> (<code>Callable</code>) &#x2014;
The function to use to save the state dictionary. Useful on distributed training like TPUs when one
need to replace <code>torch.save</code> by another method.`,name:"save_function"},{anchor:"transformers.PreTrainedModel.save_pretrained.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push your model to the Hugging Face model hub after saving it.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>Using <code>push_to_hub=True</code> will synchronize the repository you are pushing to with <code>save_directory</code>,
which requires <code>save_directory</code> to be a local clone of the repo you are pushing to if it&#x2019;s an existing
folder. Pass along <code>temp_dir=True</code> to use a temporary directory instead.</p>

					</div>`,name:"push_to_hub"},{anchor:"transformers.PreTrainedModel.save_pretrained.max_shard_size",description:`<strong>max_shard_size</strong> (<code>int</code> or <code>str</code>, <em>optional</em>, defaults to <code>&quot;10GB&quot;</code>) &#x2014;
The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size
lower than this size. If expressed as a string, needs to be digits followed by a unit (like <code>&quot;5MB&quot;</code>).</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>If a single weight of the model is bigger than <code>max_shard_size</code>, it will be in its own checkpoint shard
which will be bigger than <code>max_shard_size</code>.</p>

					</div>
<p>kwargs &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/pr_17548/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method.`,name:"max_shard_size"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1482"}}),Ho=new P({props:{name:"set_input_embeddings",anchor:"transformers.PreTrainedModel.set_input_embeddings",parameters:[{name:"value",val:": Module"}],parametersDescription:[{anchor:"transformers.PreTrainedModel.set_input_embeddings.value",description:"<strong>value</strong> (<code>nn.Module</code>) &#x2014; A module mapping vocabulary to hidden states.",name:"value"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1065"}}),Ro=new P({props:{name:"tie_weights",anchor:"transformers.PreTrainedModel.tie_weights",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L1093"}}),Yo=new Ie({}),Ko=new U({props:{code:`from transformers import AutoModelForSeq2SeqLM

t0pp = AutoModelForSeq2SeqLM.from_pretrained("bigscience/T0pp", low_cpu_mem_usage=True)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM

t0pp = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;bigscience/T0pp&quot;</span>, low_cpu_mem_usage=<span class="hljs-literal">True</span>)`}}),Zo=new U({props:{code:`from transformers import AutoModelForSeq2SeqLM

t0pp = AutoModelForSeq2SeqLM.from_pretrained("bigscience/T0pp", device_map="auto")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM

t0pp = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;bigscience/T0pp&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)`}}),Qo=new U({props:{code:"t0pp.hf_device_map",highlighted:"t0pp.hf_device_map"}}),er=new U({props:{code:`{'shared': 0,
 'decoder.embed_tokens': 0,
 'encoder': 0,
 'decoder.block.0': 0,
 'decoder.block.1': 1,
 'decoder.block.2': 1,
 'decoder.block.3': 1,
 'decoder.block.4': 1,
 'decoder.block.5': 1,
 'decoder.block.6': 1,
 'decoder.block.7': 1,
 'decoder.block.8': 1,
 'decoder.block.9': 1,
 'decoder.block.10': 1,
 'decoder.block.11': 1,
 'decoder.block.12': 1,
 'decoder.block.13': 1,
 'decoder.block.14': 1,
 'decoder.block.15': 1,
 'decoder.block.16': 1,
 'decoder.block.17': 1,
 'decoder.block.18': 1,
 'decoder.block.19': 1,
 'decoder.block.20': 1,
 'decoder.block.21': 1,
 'decoder.block.22': 'cpu',
 'decoder.block.23': 'cpu',
 'decoder.final_layer_norm': 'cpu',
 'decoder.dropout': 'cpu',
 'lm_head': 'cpu'}`,highlighted:`{<span class="hljs-string">&#x27;shared&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;decoder.embed_tokens&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;encoder&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;decoder.block.0&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;decoder.block.1&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.2&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.3&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.4&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.5&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.6&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.7&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.8&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.9&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.10&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.11&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.12&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.13&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.14&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.15&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.16&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.17&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.18&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.19&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.20&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.21&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;decoder.block.22&#x27;</span>: <span class="hljs-string">&#x27;cpu&#x27;</span>,
 <span class="hljs-string">&#x27;decoder.block.23&#x27;</span>: <span class="hljs-string">&#x27;cpu&#x27;</span>,
 <span class="hljs-string">&#x27;decoder.final_layer_norm&#x27;</span>: <span class="hljs-string">&#x27;cpu&#x27;</span>,
 <span class="hljs-string">&#x27;decoder.dropout&#x27;</span>: <span class="hljs-string">&#x27;cpu&#x27;</span>,
 <span class="hljs-string">&#x27;lm_head&#x27;</span>: <span class="hljs-string">&#x27;cpu&#x27;</span>}`}}),tr=new U({props:{code:'device_map = {"shared": 0, "encoder": 0, "decoder": 1, "lm_head": 1}',highlighted:'device_map = {<span class="hljs-string">&quot;shared&quot;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&quot;encoder&quot;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&quot;decoder&quot;</span>: <span class="hljs-number">1</span>, <span class="hljs-string">&quot;lm_head&quot;</span>: <span class="hljs-number">1</span>}'}}),or=new Ie({}),rr=new U({props:{code:'model = T5ForConditionalGeneration.from_pretrained("t5", torch_dtype=torch.float16)',highlighted:'model = T5ForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;t5&quot;</span>, torch_dtype=torch.float16)'}}),ar=new U({props:{code:'model = T5ForConditionalGeneration.from_pretrained("t5", torch_dtype="auto")',highlighted:'model = T5ForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;t5&quot;</span>, torch_dtype=<span class="hljs-string">&quot;auto&quot;</span>)'}}),nr=new U({props:{code:`config = T5Config.from_pretrained("t5")
model = AutoModel.from_config(config)`,highlighted:`config = T5Config.from_pretrained(<span class="hljs-string">&quot;t5&quot;</span>)
model = AutoModel.from_config(config)`}}),sr=new Ie({}),ir=new P({props:{name:"class transformers.modeling_utils.ModuleUtilsMixin",anchor:"transformers.modeling_utils.ModuleUtilsMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L609"}}),dr=new P({props:{name:"add_memory_hooks",anchor:"transformers.modeling_utils.ModuleUtilsMixin.add_memory_hooks",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L640"}}),cr=new P({props:{name:"estimate_tokens",anchor:"transformers.modeling_utils.ModuleUtilsMixin.estimate_tokens",parameters:[{name:"input_dict",val:": typing.Dict[str, typing.Union[torch.Tensor, typing.Any]]"}],parametersDescription:[{anchor:"transformers.modeling_utils.ModuleUtilsMixin.estimate_tokens.inputs",description:"<strong>inputs</strong> (<code>dict</code>) &#x2014; The model inputs.",name:"inputs"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L849",returnDescription:`
<p>The total number of tokens.</p>
`,returnType:`
<p><code>int</code></p>
`}}),mr=new P({props:{name:"floating_point_ops",anchor:"transformers.modeling_utils.ModuleUtilsMixin.floating_point_ops",parameters:[{name:"input_dict",val:": typing.Dict[str, typing.Union[torch.Tensor, typing.Any]]"},{name:"exclude_embeddings",val:": bool = True"}],parametersDescription:[{anchor:"transformers.modeling_utils.ModuleUtilsMixin.floating_point_ops.batch_size",description:`<strong>batch_size</strong> (<code>int</code>) &#x2014;
The batch size for the forward pass.`,name:"batch_size"},{anchor:"transformers.modeling_utils.ModuleUtilsMixin.floating_point_ops.sequence_length",description:`<strong>sequence_length</strong> (<code>int</code>) &#x2014;
The number of tokens in each line of the batch.`,name:"sequence_length"},{anchor:"transformers.modeling_utils.ModuleUtilsMixin.floating_point_ops.exclude_embeddings",description:`<strong>exclude_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to count embedding and softmax operations.`,name:"exclude_embeddings"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L870",returnDescription:`
<p>The number of floating-point operations.</p>
`,returnType:`
<p><code>int</code></p>
`}}),hr=new P({props:{name:"get_extended_attention_mask",anchor:"transformers.modeling_utils.ModuleUtilsMixin.get_extended_attention_mask",parameters:[{name:"attention_mask",val:": Tensor"},{name:"input_shape",val:": typing.Tuple[int]"},{name:"device",val:": <property object at 0x7fab78a8c220> = None"}],parametersDescription:[{anchor:"transformers.modeling_utils.ModuleUtilsMixin.get_extended_attention_mask.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code>) &#x2014;
Mask with ones indicating tokens to attend to, zeros for tokens to ignore.`,name:"attention_mask"},{anchor:"transformers.modeling_utils.ModuleUtilsMixin.get_extended_attention_mask.input_shape",description:`<strong>input_shape</strong> (<code>Tuple[int]</code>) &#x2014;
The shape of the input to the model.`,name:"input_shape"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L736",returnDescription:`
<p><code>torch.Tensor</code> The extended attention mask, with a the same dtype as <code>attention_mask.dtype</code>.</p>
`}}),fr=new P({props:{name:"get_head_mask",anchor:"transformers.modeling_utils.ModuleUtilsMixin.get_head_mask",parameters:[{name:"head_mask",val:": typing.Optional[torch.Tensor]"},{name:"num_hidden_layers",val:": int"},{name:"is_attention_chunked",val:": bool = False"}],parametersDescription:[{anchor:"transformers.modeling_utils.ModuleUtilsMixin.get_head_mask.head_mask",description:`<strong>head_mask</strong> (<code>torch.Tensor</code> with shape <code>[num_heads]</code> or <code>[num_hidden_layers x num_heads]</code>, <em>optional</em>) &#x2014;
The mask indicating if we should keep the heads or not (1.0 for keep, 0.0 for discard).`,name:"head_mask"},{anchor:"transformers.modeling_utils.ModuleUtilsMixin.get_head_mask.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>) &#x2014;
The number of hidden layers in the model.
is_attention_chunked &#x2014; (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>):
Whether or not the attentions scores are computed by chunks or not.`,name:"num_hidden_layers"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L785",returnDescription:`
<p><code>torch.Tensor</code> with shape <code>[num_hidden_layers x batch x num_heads x seq_length x seq_length]</code> or list with
<code>[None]</code> for each layer.</p>
`}}),ur=new P({props:{name:"invert_attention_mask",anchor:"transformers.modeling_utils.ModuleUtilsMixin.invert_attention_mask",parameters:[{name:"encoder_attention_mask",val:": Tensor"}],parametersDescription:[{anchor:"transformers.modeling_utils.ModuleUtilsMixin.invert_attention_mask.encoder_attention_mask",description:"<strong>encoder_attention_mask</strong> (<code>torch.Tensor</code>) &#x2014; An attention mask.",name:"encoder_attention_mask"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L676",returnDescription:`
<p>The inverted attention mask.</p>
`,returnType:`
<p><code>torch.Tensor</code></p>
`}}),gr=new P({props:{name:"num_parameters",anchor:"transformers.modeling_utils.ModuleUtilsMixin.num_parameters",parameters:[{name:"only_trainable",val:": bool = False"},{name:"exclude_embeddings",val:": bool = False"}],parametersDescription:[{anchor:"transformers.modeling_utils.ModuleUtilsMixin.num_parameters.only_trainable",description:`<strong>only_trainable</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return only the number of trainable parameters`,name:"only_trainable"},{anchor:"transformers.modeling_utils.ModuleUtilsMixin.num_parameters.exclude_embeddings",description:`<strong>exclude_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return only the number of non-embeddings parameters`,name:"exclude_embeddings"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L823",returnDescription:`
<p>The number of parameters.</p>
`,returnType:`
<p><code>int</code></p>
`}}),_r=new P({props:{name:"reset_memory_hooks_state",anchor:"transformers.modeling_utils.ModuleUtilsMixin.reset_memory_hooks_state",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L652"}}),br=new Ie({}),vr=new P({props:{name:"class transformers.TFPreTrainedModel",anchor:"transformers.TFPreTrainedModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L702"}}),wr=new P({props:{name:"push_to_hub",anchor:"transformers.TFPreTrainedModel.push_to_hub",parameters:[{name:"repo_path_or_name",val:": typing.Optional[str] = None"},{name:"repo_url",val:": typing.Optional[str] = None"},{name:"use_temp_dir",val:": bool = False"},{name:"commit_message",val:": typing.Optional[str] = None"},{name:"organization",val:": typing.Optional[str] = None"},{name:"private",val:": typing.Optional[bool] = None"},{name:"use_auth_token",val:": typing.Union[bool, str, NoneType] = None"},{name:"**model_card_kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.push_to_hub.repo_path_or_name",description:`<strong>repo_path_or_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Can either be a repository name for your model in the Hub or a path to a local folder (in which case
the repository will have the name of that local folder). If not specified, will default to the name
given by <code>repo_url</code> and a local directory with that name will be created.`,name:"repo_path_or_name"},{anchor:"transformers.TFPreTrainedModel.push_to_hub.repo_url",description:`<strong>repo_url</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Specify this in case you want to push to an existing repository in the hub. If unspecified, a new
repository will be created in your namespace (unless you specify an <code>organization</code>) with <code>repo_name</code>.`,name:"repo_url"},{anchor:"transformers.TFPreTrainedModel.push_to_hub.use_temp_dir",description:`<strong>use_temp_dir</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to clone the distant repo in a temporary directory or in <code>repo_path_or_name</code> inside the
current working directory. This will slow things down if you are making changes in an existing repo
since you will need to clone the repo before every push.`,name:"use_temp_dir"},{anchor:"transformers.TFPreTrainedModel.push_to_hub.commit_message",description:`<strong>commit_message</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Message to commit while pushing. Will default to <code>&quot;add model&quot;</code>.`,name:"commit_message"},{anchor:"transformers.TFPreTrainedModel.push_to_hub.organization",description:`<strong>organization</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Organization in which you want to push your model (you must be a member of this organization).`,name:"organization"},{anchor:"transformers.TFPreTrainedModel.push_to_hub.private",description:`<strong>private</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not the repository created should be private (requires a paying subscription).`,name:"private"},{anchor:"transformers.TFPreTrainedModel.push_to_hub.use_auth_token",description:`<strong>use_auth_token</strong> (<code>bool</code> or <code>str</code>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>transformers-cli login</code> (stored in <code>~/.huggingface</code>). Will default to <code>True</code> if
<code>repo_url</code> is not specified.`,name:"use_auth_token"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/utils/hub.py#L846",returnDescription:`
<p>The url of the commit of your model in the given repository.</p>
`,returnType:`
<p><code>str</code></p>
`}}),Ut=new Le({props:{anchor:"transformers.TFPreTrainedModel.push_to_hub.example",$$slots:{default:[H2]},$$scope:{ctx:D}}}),xr=new P({props:{name:"compile",anchor:"transformers.TFPreTrainedModel.compile",parameters:[{name:"optimizer",val:" = 'rmsprop'"},{name:"loss",val:" = 'passthrough'"},{name:"metrics",val:" = None"},{name:"loss_weights",val:" = None"},{name:"weighted_metrics",val:" = None"},{name:"run_eagerly",val:" = None"},{name:"steps_per_execution",val:" = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L895"}}),Tr=new P({props:{name:"from_pretrained",anchor:"transformers.TFPreTrainedModel.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:""},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.from_pretrained.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/pr_17548/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 state_dict save file</em> (e.g, <code>./pt_model/pytorch_model.bin</code>). In this
case, <code>from_pt</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 PyTorch model in a TensorFlow model
using the provided conversion scripts and loading the TensorFlow model afterwards.</li>
<li><code>None</code> if you are both providing the configuration and state dictionary (resp. with keyword
arguments <code>config</code> and <code>state_dict</code>).</li>
</ul>`,name:"pretrained_model_name_or_path"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.model_args",description:`<strong>model_args</strong> (sequence of 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.TFPreTrainedModel.from_pretrained.config",description:`<strong>config</strong> (<code>Union[PretrainedConfig, str]</code>, <em>optional</em>) &#x2014;
Can be either:</p>
<ul>
<li>an instance of a class derived from <a href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>,</li>
<li>a string valid as input to <a href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig.from_pretrained">from_pretrained()</a>.</li>
</ul>
<p>Configuration for the model to use instead of an automatically loaded configuration. Configuration can
be automatically loaded when:</p>
<ul>
<li>The model is a model provided by the library (loaded with the <em>model id</em> string of a pretrained
model).</li>
<li>The model was saved using <a href="/docs/transformers/pr_17548/en/main_classes/model#transformers.TFPreTrainedModel.save_pretrained">save_pretrained()</a> and is reloaded by supplying the
save directory.</li>
<li>The model is loaded by supplying a local directory as <code>pretrained_model_name_or_path</code> and a
configuration JSON file named <em>config.json</em> is found in the directory.
from_pt &#x2014; (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>):
Load the model weights from a PyTorch state_dict save file (see docstring of
<code>pretrained_model_name_or_path</code> argument).</li>
</ul>`,name:"config"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.ignore_mismatched_sizes",description:`<strong>ignore_mismatched_sizes</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to raise an error if some of the weights from the checkpoint do not have the same size
as the weights of the model (if for instance, you are instantiating a model with 10 labels from a
checkpoint with 3 labels).`,name:"ignore_mismatched_sizes"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.cache_dir",description:`<strong>cache_dir</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Path to a directory in which a downloaded pretrained model configuration should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to delete incompletely received files. Will attempt to resume the download if such a
file exists.
proxies &#x2014;
(<code>Dict[str, str], </code>optional<code>): A dictionary of proxy servers to use by protocol or endpoint, e.g., </code>{&#x2018;http&#x2019;: &#x2018;foo.bar:3128&#x2019;, &#x2018;http://hostname&#x2019;: &#x2018;foo.bar:4012&#x2019;}<code>. The proxies are used on each request. output_loading_info(</code>bool<code>, *optional*, defaults to </code>False\`): Whether ot not to also return a
dictionary containing missing keys, unexpected keys and error messages.`,name:"resume_download"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.local_files_only(bool,",description:`<strong>local_files_only(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to only look at local files (e.g., not try doanloading the model).`,name:"local_files_only(bool,"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.use_auth_token",description:`<strong>use_auth_token</strong> (<code>str</code> or <em>bool</em>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>transformers-cli login</code> (stored in <code>~/.huggingface</code>).`,name:"use_auth_token"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so <code>revision</code> can be any
identifier allowed by git.`,name:"revision"},{anchor:"transformers.TFPreTrainedModel.from_pretrained.mirror",description:`<strong>mirror</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Mirror source to accelerate downloads in China. If you are from China and have an accessibility
problem, you can set this option to resolve it. Note that we do not guarantee the timeliness or safety.
Please refer to the mirror site for more information.`,name:"mirror"},{anchor:"transformers.TFPreTrainedModel.from_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>). Behaves differently depending on whether a <code>config</code> is provided or
automatically loaded:</p>
<ul>
<li>If a configuration is provided with <code>config</code>, <code>**kwargs</code> will be directly passed to the
underlying model&#x2019;s <code>__init__</code> method (we assume all relevant updates to the configuration have
already been done)</li>
<li>If a configuration is not provided, <code>kwargs</code> will be first passed to the configuration class
initialization function (<a href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig.from_pretrained">from_pretrained()</a>). Each key of <code>kwargs</code> that
corresponds to a configuration attribute will be used to override said attribute with the
supplied <code>kwargs</code> value. Remaining keys that do not correspond to any configuration attribute
will be passed to the underlying model&#x2019;s <code>__init__</code> function.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1595"}}),Nt=new td({props:{$$slots:{default:[R2]},$$scope:{ctx:D}}}),Bt=new Le({props:{anchor:"transformers.TFPreTrainedModel.from_pretrained.example",$$slots:{default:[G2]},$$scope:{ctx:D}}}),Mr=new P({props:{name:"get_bias",anchor:"transformers.TFPreTrainedModel.get_bias",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1279",returnDescription:`
<p>The weights representing the bias, None if not an LM model.</p>
`,returnType:`
<p><code>tf.Variable</code></p>
`}}),Er=new P({props:{name:"get_input_embeddings",anchor:"transformers.TFPreTrainedModel.get_input_embeddings",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L814",returnDescription:`
<p>The embeddings layer mapping vocabulary to hidden states.</p>
`,returnType:`
<p><code>tf.Variable</code></p>
`}}),jr=new P({props:{name:"get_lm_head",anchor:"transformers.TFPreTrainedModel.get_lm_head",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1312",returnDescription:`
<p>The LM head layer if the model has one, None if not.</p>
`,returnType:`
<p><code>tf.keras.layers.Layer</code></p>
`}}),Fr=new P({props:{name:"get_output_embeddings",anchor:"transformers.TFPreTrainedModel.get_output_embeddings",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1219",returnDescription:`
<p>The new weights mapping vocabulary to hidden states.</p>
`,returnType:`
<p><code>tf.Variable</code></p>
`}}),Dr=new P({props:{name:"get_output_layer_with_bias",anchor:"transformers.TFPreTrainedModel.get_output_layer_with_bias",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1256",returnDescription:`
<p>The layer that handles the bias, None if not an LM model.</p>
`,returnType:`
<p><code>tf.keras.layers.Layer</code></p>
`}}),qr=new P({props:{name:"get_prefix_bias_name",anchor:"transformers.TFPreTrainedModel.get_prefix_bias_name",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1269",returnDescription:`
<p>The _prefix name of the bias.</p>
`,returnType:`
<p><code>str</code></p>
`}}),Ar=new P({props:{name:"load_repo_checkpoint",anchor:"transformers.TFPreTrainedModel.load_repo_checkpoint",parameters:[{name:"repo_path_or_name",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.load_repo_checkpoint.repo_path_or_name",description:`<strong>repo_path_or_name</strong> (<code>str</code>) &#x2014;
Can either be a repository name for your {object} in the Hub or a path to a local folder (in which case
the repository will have the name of that local folder).`,name:"repo_path_or_name"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L841",returnDescription:`
<p>A dictionary of extra metadata from the checkpoint, most commonly an \u201Cepoch\u201D count.</p>
`,returnType:`
<p><code>dict</code></p>
`}}),zr=new P({props:{name:"prune_heads",anchor:"transformers.TFPreTrainedModel.prune_heads",parameters:[{name:"heads_to_prune",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.prune_heads.heads_to_prune",description:`<strong>heads_to_prune</strong> (<code>Dict[int, List[int]]</code>) &#x2014;
Dictionary with keys being selected layer indices (<code>int</code>) and associated values being the list of heads
to prune in said layer (list of <code>int</code>). For instance {1: [0, 2], 2: [2, 3]} will prune heads 0 and 2 on
layer 1 and heads 2 and 3 on layer 2.`,name:"heads_to_prune"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1521"}}),Cr=new P({props:{name:"resize_token_embeddings",anchor:"transformers.TFPreTrainedModel.resize_token_embeddings",parameters:[{name:"new_num_tokens",val:" = None"}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.resize_token_embeddings.new_num_tokens",description:`<strong>new_num_tokens</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of new tokens in the embedding matrix. Increasing the size will add newly initialized
vectors at the end. Reducing the size will remove vectors from the end. If not provided or <code>None</code>, just
returns a pointer to the input tokens <code>tf.Variable</code> module of the model without doing anything.`,name:"new_num_tokens"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1321",returnDescription:`
<p>Pointer to the input tokens Embeddings Module of the model.</p>
`,returnType:`
<p><code>tf.Variable</code></p>
`}}),Ur=new P({props:{name:"save_pretrained",anchor:"transformers.TFPreTrainedModel.save_pretrained",parameters:[{name:"save_directory",val:""},{name:"saved_model",val:" = False"},{name:"version",val:" = 1"},{name:"push_to_hub",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.save_pretrained.save_directory",description:`<strong>save_directory</strong> (<code>str</code>) &#x2014;
Directory to which to save. Will be created if it doesn&#x2019;t exist.`,name:"save_directory"},{anchor:"transformers.TFPreTrainedModel.save_pretrained.saved_model",description:`<strong>saved_model</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If the model has to be saved in saved model format as well or not.`,name:"saved_model"},{anchor:"transformers.TFPreTrainedModel.save_pretrained.version",description:`<strong>version</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The version of the saved model. A saved model needs to be versioned in order to be properly loaded by
TensorFlow Serving as detailed in the official documentation
<a href="https://www.tensorflow.org/tfx/serving/serving_basic" rel="nofollow">https://www.tensorflow.org/tfx/serving/serving_basic</a>`,name:"version"},{anchor:"transformers.TFPreTrainedModel.save_pretrained.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push your model to the Hugging Face model hub after saving it.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>Using <code>push_to_hub=True</code> will synchronize the repository you are pushing to with <code>save_directory</code>,
which requires <code>save_directory</code> to be a local clone of the repo you are pushing to if it&#x2019;s an existing
folder. Pass along <code>temp_dir=True</code> to use a temporary directory instead.</p>

					</div>
<p>kwargs &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/pr_17548/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method.`,name:"push_to_hub"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1533"}}),Nr=new P({props:{name:"serving",anchor:"transformers.TFPreTrainedModel.serving",parameters:[{name:"inputs",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.serving.inputs",description:`<strong>inputs</strong> (<code>Dict[str, tf.Tensor]</code>) &#x2014;
The input of the saved model as a dictionary of tensors.`,name:"inputs"}]}}),Br=new P({props:{name:"serving_output",anchor:"transformers.TFPreTrainedModel.serving_output",parameters:[{name:"output",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.serving_output.output",description:`<strong>output</strong> (<code>TFBaseModelOutput</code>) &#x2014;
The output returned by the model.`,name:"output"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L804"}}),Sr=new P({props:{name:"set_bias",anchor:"transformers.TFPreTrainedModel.set_bias",parameters:[{name:"value",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.set_bias.value",description:`<strong>value</strong> (<code>Dict[tf.Variable]</code>) &#x2014;
All the new bias attached to an LM head.`,name:"value"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1296"}}),Xr=new P({props:{name:"set_input_embeddings",anchor:"transformers.TFPreTrainedModel.set_input_embeddings",parameters:[{name:"value",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.set_input_embeddings.value",description:`<strong>value</strong> (<code>tf.Variable</code>) &#x2014;
The new weights mapping hidden states to vocabulary.`,name:"value"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1199"}}),Vr=new P({props:{name:"set_output_embeddings",anchor:"transformers.TFPreTrainedModel.set_output_embeddings",parameters:[{name:"value",val:""}],parametersDescription:[{anchor:"transformers.TFPreTrainedModel.set_output_embeddings.value",description:`<strong>value</strong> (<code>tf.Variable</code>) &#x2014;
The new weights mapping hidden states to vocabulary.`,name:"value"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1239"}}),Wr=new P({props:{name:"test_step",anchor:"transformers.TFPreTrainedModel.test_step",parameters:[{name:"data",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L1073"}}),Rr=new P({props:{name:"train_step",anchor:"transformers.TFPreTrainedModel.train_step",parameters:[{name:"data",val:""}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L975"}}),Yr=new Ie({}),Jr=new P({props:{name:"class transformers.modeling_tf_utils.TFModelUtilsMixin",anchor:"transformers.modeling_tf_utils.TFModelUtilsMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L84"}}),Zr=new P({props:{name:"num_parameters",anchor:"transformers.modeling_tf_utils.TFModelUtilsMixin.num_parameters",parameters:[{name:"only_trainable",val:": bool = False"}],parametersDescription:[{anchor:"transformers.modeling_tf_utils.TFModelUtilsMixin.num_parameters.only_trainable",description:`<strong>only_trainable</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return only the number of trainable parameters`,name:"only_trainable"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_tf_utils.py#L89",returnDescription:`
<p>The number of parameters.</p>
`,returnType:`
<p><code>int</code></p>
`}}),Qr=new Ie({}),ea=new P({props:{name:"class transformers.FlaxPreTrainedModel",anchor:"transformers.FlaxPreTrainedModel",parameters:[{name:"config",val:": PretrainedConfig"},{name:"module",val:": Module"},{name:"input_shape",val:": typing.Tuple = (1, 1)"},{name:"seed",val:": int = 0"},{name:"dtype",val:": dtype = <class 'jax._src.numpy.lax_numpy.float32'>"},{name:"_do_init",val:": bool = True"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_flax_utils.py#L73"}}),ta=new P({props:{name:"push_to_hub",anchor:"transformers.FlaxPreTrainedModel.push_to_hub",parameters:[{name:"repo_path_or_name",val:": typing.Optional[str] = None"},{name:"repo_url",val:": typing.Optional[str] = None"},{name:"use_temp_dir",val:": bool = False"},{name:"commit_message",val:": typing.Optional[str] = None"},{name:"organization",val:": typing.Optional[str] = None"},{name:"private",val:": typing.Optional[bool] = None"},{name:"use_auth_token",val:": typing.Union[bool, str, NoneType] = None"},{name:"**model_card_kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxPreTrainedModel.push_to_hub.repo_path_or_name",description:`<strong>repo_path_or_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Can either be a repository name for your model in the Hub or a path to a local folder (in which case
the repository will have the name of that local folder). If not specified, will default to the name
given by <code>repo_url</code> and a local directory with that name will be created.`,name:"repo_path_or_name"},{anchor:"transformers.FlaxPreTrainedModel.push_to_hub.repo_url",description:`<strong>repo_url</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Specify this in case you want to push to an existing repository in the hub. If unspecified, a new
repository will be created in your namespace (unless you specify an <code>organization</code>) with <code>repo_name</code>.`,name:"repo_url"},{anchor:"transformers.FlaxPreTrainedModel.push_to_hub.use_temp_dir",description:`<strong>use_temp_dir</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to clone the distant repo in a temporary directory or in <code>repo_path_or_name</code> inside the
current working directory. This will slow things down if you are making changes in an existing repo
since you will need to clone the repo before every push.`,name:"use_temp_dir"},{anchor:"transformers.FlaxPreTrainedModel.push_to_hub.commit_message",description:`<strong>commit_message</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Message to commit while pushing. Will default to <code>&quot;add model&quot;</code>.`,name:"commit_message"},{anchor:"transformers.FlaxPreTrainedModel.push_to_hub.organization",description:`<strong>organization</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Organization in which you want to push your model (you must be a member of this organization).`,name:"organization"},{anchor:"transformers.FlaxPreTrainedModel.push_to_hub.private",description:`<strong>private</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not the repository created should be private (requires a paying subscription).`,name:"private"},{anchor:"transformers.FlaxPreTrainedModel.push_to_hub.use_auth_token",description:`<strong>use_auth_token</strong> (<code>bool</code> or <code>str</code>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>transformers-cli login</code> (stored in <code>~/.huggingface</code>). Will default to <code>True</code> if
<code>repo_url</code> is not specified.`,name:"use_auth_token"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/utils/hub.py#L846",returnDescription:`
<p>The url of the commit of your model in the given repository.</p>
`,returnType:`
<p><code>str</code></p>
`}}),lo=new Le({props:{anchor:"transformers.FlaxPreTrainedModel.push_to_hub.example",$$slots:{default:[Y2]},$$scope:{ctx:D}}}),ra=new P({props:{name:"from_pretrained",anchor:"transformers.FlaxPreTrainedModel.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike]"},{name:"dtype",val:": dtype = <class 'jax._src.numpy.lax_numpy.float32'>"},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/pr_17548/en/main_classes/model#transformers.FlaxPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>pt index checkpoint file</em> (e.g, <code>./tf_model/model.ckpt.index</code>). In this case,
<code>from_pt</code> should be set to <code>True</code>.</li>
</ul>`,name:"pretrained_model_name_or_path"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.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/pr_17548/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/pr_17548/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.model_args",description:`<strong>model_args</strong> (sequence of 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.FlaxPreTrainedModel.from_pretrained.config",description:`<strong>config</strong> (<code>Union[PretrainedConfig, str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Can be either:</p>
<ul>
<li>an instance of a class derived from <a href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>,</li>
<li>a string or path valid as input to <a href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig.from_pretrained">from_pretrained()</a>.</li>
</ul>
<p>Configuration for the model to use instead of an automatically loaded configuration. Configuration can
be automatically loaded when:</p>
<ul>
<li>The model is a model provided by the library (loaded with the <em>model id</em> string of a pretrained
model).</li>
<li>The model was saved using <a href="/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a> and is reloaded by supplying the
save directory.</li>
<li>The model is loaded by supplying a local directory as <code>pretrained_model_name_or_path</code> and a
configuration JSON file named <em>config.json</em> is found in the directory.</li>
</ul>`,name:"config"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.cache_dir",description:`<strong>cache_dir</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Path to a directory in which a downloaded pretrained model configuration should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.from_pt",description:`<strong>from_pt</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Load the model weights from a PyTorch checkpoint save file (see docstring of
<code>pretrained_model_name_or_path</code> argument).`,name:"from_pt"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.ignore_mismatched_sizes",description:`<strong>ignore_mismatched_sizes</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to raise an error if some of the weights from the checkpoint do not have the same size
as the weights of the model (if for instance, you are instantiating a model with 10 labels from a
checkpoint with 3 labels).`,name:"ignore_mismatched_sizes"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to delete incompletely received files. Will attempt to resume the download if such a
file exists.`,name:"resume_download"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, e.g., <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}</code>. The proxies are used on each request.`,name:"proxies"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.local_files_only(bool,",description:`<strong>local_files_only(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to only look at local files (i.e., do not try to download the model).`,name:"local_files_only(bool,"},{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so <code>revision</code> can be any
identifier allowed by git.`,name:"revision"},{anchor:"transformers.FlaxPreTrainedModel.from_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>). Behaves differently depending on whether a <code>config</code> is provided or
automatically loaded:</p>
<ul>
<li>If a configuration is provided with <code>config</code>, <code>**kwargs</code> will be directly passed to the
underlying model&#x2019;s <code>__init__</code> method (we assume all relevant updates to the configuration have
already been done)</li>
<li>If a configuration is not provided, <code>kwargs</code> will be first passed to the configuration class
initialization function (<a href="/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig.from_pretrained">from_pretrained()</a>). Each key of <code>kwargs</code> that
corresponds to a configuration attribute will be used to override said attribute with the
supplied <code>kwargs</code> value. Remaining keys that do not correspond to any configuration attribute
will be passed to the underlying model&#x2019;s <code>__init__</code> function.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_flax_utils.py#L336"}}),co=new Le({props:{anchor:"transformers.FlaxPreTrainedModel.from_pretrained.example",$$slots:{default:[J2]},$$scope:{ctx:D}}}),sa=new P({props:{name:"register_for_auto_class",anchor:"transformers.FlaxPreTrainedModel.register_for_auto_class",parameters:[{name:"auto_class",val:" = 'FlaxAutoModel'"}],parametersDescription:[{anchor:"transformers.FlaxPreTrainedModel.register_for_auto_class.auto_class",description:`<strong>auto_class</strong> (<code>str</code> or <code>type</code>, <em>optional</em>, defaults to <code>&quot;FlaxAutoModel&quot;</code>) &#x2014;
The auto class to register this new model with.`,name:"auto_class"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_flax_utils.py#L802"}}),mo=new td({props:{warning:!0,$$slots:{default:[K2]},$$scope:{ctx:D}}}),ia=new P({props:{name:"save_pretrained",anchor:"transformers.FlaxPreTrainedModel.save_pretrained",parameters:[{name:"save_directory",val:": typing.Union[str, os.PathLike]"},{name:"params",val:" = None"},{name:"push_to_hub",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxPreTrainedModel.save_pretrained.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory to which to save. Will be created if it doesn&#x2019;t exist.`,name:"save_directory"},{anchor:"transformers.FlaxPreTrainedModel.save_pretrained.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push your model to the Hugging Face model hub after saving it.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>Using <code>push_to_hub=True</code> will synchronize the repository you are pushing to with <code>save_directory</code>,
which requires <code>save_directory</code> to be a local clone of the repo you are pushing to if it&#x2019;s an existing
folder. Pass along <code>temp_dir=True</code> to use a temporary directory instead.</p>

					</div>
<p>kwargs &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/pr_17548/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method.`,name:"push_to_hub"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_flax_utils.py#L745"}}),da=new P({props:{name:"to_bf16",anchor:"transformers.FlaxPreTrainedModel.to_bf16",parameters:[{name:"params",val:": typing.Union[typing.Dict, flax.core.frozen_dict.FrozenDict]"},{name:"mask",val:": typing.Any = None"}],parametersDescription:[{anchor:"transformers.FlaxPreTrainedModel.to_bf16.params",description:`<strong>params</strong> (<code>Union[Dict, FrozenDict]</code>) &#x2014;
A <code>PyTree</code> of model parameters.`,name:"params"},{anchor:"transformers.FlaxPreTrainedModel.to_bf16.mask",description:`<strong>mask</strong> (<code>Union[Dict, FrozenDict]</code>) &#x2014;
A <code>PyTree</code> with same structure as the <code>params</code> tree. The leaves should be booleans, <code>True</code> for params
you want to cast, and should be <code>False</code> for those you want to skip.`,name:"mask"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_flax_utils.py#L231"}}),ho=new Le({props:{anchor:"transformers.FlaxPreTrainedModel.to_bf16.example",$$slots:{default:[Z2]},$$scope:{ctx:D}}}),ca=new P({props:{name:"to_fp16",anchor:"transformers.FlaxPreTrainedModel.to_fp16",parameters:[{name:"params",val:": typing.Union[typing.Dict, flax.core.frozen_dict.FrozenDict]"},{name:"mask",val:": typing.Any = None"}],parametersDescription:[{anchor:"transformers.FlaxPreTrainedModel.to_fp16.params",description:`<strong>params</strong> (<code>Union[Dict, FrozenDict]</code>) &#x2014;
A <code>PyTree</code> of model parameters.`,name:"params"},{anchor:"transformers.FlaxPreTrainedModel.to_fp16.mask",description:`<strong>mask</strong> (<code>Union[Dict, FrozenDict]</code>) &#x2014;
A <code>PyTree</code> with same structure as the <code>params</code> tree. The leaves should be booleans, <code>True</code> for params
you want to cast, and should be <code>False</code> for those you want to skip`,name:"mask"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_flax_utils.py#L297"}}),fo=new Le({props:{anchor:"transformers.FlaxPreTrainedModel.to_fp16.example",$$slots:{default:[Q2]},$$scope:{ctx:D}}}),ma=new P({props:{name:"to_fp32",anchor:"transformers.FlaxPreTrainedModel.to_fp32",parameters:[{name:"params",val:": typing.Union[typing.Dict, flax.core.frozen_dict.FrozenDict]"},{name:"mask",val:": typing.Any = None"}],parametersDescription:[{anchor:"transformers.FlaxPreTrainedModel.to_fp32.params",description:`<strong>params</strong> (<code>Union[Dict, FrozenDict]</code>) &#x2014;
A <code>PyTree</code> of model parameters.`,name:"params"},{anchor:"transformers.FlaxPreTrainedModel.to_fp32.mask",description:`<strong>mask</strong> (<code>Union[Dict, FrozenDict]</code>) &#x2014;
A <code>PyTree</code> with same structure as the <code>params</code> tree. The leaves should be booleans, <code>True</code> for params
you want to cast, and should be <code>False</code> for those you want to skip`,name:"mask"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_flax_utils.py#L270"}}),uo=new Le({props:{anchor:"transformers.FlaxPreTrainedModel.to_fp32.example",$$slots:{default:[ex]},$$scope:{ctx:D}}}),pa=new Ie({}),ha=new P({props:{name:"class transformers.utils.PushToHubMixin",anchor:"transformers.utils.PushToHubMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/utils/hub.py#L841"}}),fa=new P({props:{name:"push_to_hub",anchor:"transformers.utils.PushToHubMixin.push_to_hub",parameters:[{name:"repo_path_or_name",val:": typing.Optional[str] = None"},{name:"repo_url",val:": typing.Optional[str] = None"},{name:"use_temp_dir",val:": bool = False"},{name:"commit_message",val:": typing.Optional[str] = None"},{name:"organization",val:": typing.Optional[str] = None"},{name:"private",val:": typing.Optional[bool] = None"},{name:"use_auth_token",val:": typing.Union[bool, str, NoneType] = None"},{name:"**model_card_kwargs",val:""}],parametersDescription:[{anchor:"transformers.utils.PushToHubMixin.push_to_hub.repo_path_or_name",description:`<strong>repo_path_or_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Can either be a repository name for your {object} in the Hub or a path to a local folder (in which case
the repository will have the name of that local folder). If not specified, will default to the name
given by <code>repo_url</code> and a local directory with that name will be created.`,name:"repo_path_or_name"},{anchor:"transformers.utils.PushToHubMixin.push_to_hub.repo_url",description:`<strong>repo_url</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Specify this in case you want to push to an existing repository in the hub. If unspecified, a new
repository will be created in your namespace (unless you specify an <code>organization</code>) with <code>repo_name</code>.`,name:"repo_url"},{anchor:"transformers.utils.PushToHubMixin.push_to_hub.use_temp_dir",description:`<strong>use_temp_dir</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to clone the distant repo in a temporary directory or in <code>repo_path_or_name</code> inside the
current working directory. This will slow things down if you are making changes in an existing repo
since you will need to clone the repo before every push.`,name:"use_temp_dir"},{anchor:"transformers.utils.PushToHubMixin.push_to_hub.commit_message",description:`<strong>commit_message</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Message to commit while pushing. Will default to <code>&quot;add {object}&quot;</code>.`,name:"commit_message"},{anchor:"transformers.utils.PushToHubMixin.push_to_hub.organization",description:`<strong>organization</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Organization in which you want to push your {object} (you must be a member of this organization).`,name:"organization"},{anchor:"transformers.utils.PushToHubMixin.push_to_hub.private",description:`<strong>private</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not the repository created should be private (requires a paying subscription).`,name:"private"},{anchor:"transformers.utils.PushToHubMixin.push_to_hub.use_auth_token",description:`<strong>use_auth_token</strong> (<code>bool</code> or <code>str</code>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>transformers-cli login</code> (stored in <code>~/.huggingface</code>). Will default to <code>True</code> if
<code>repo_url</code> is not specified.`,name:"use_auth_token"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/utils/hub.py#L846",returnDescription:`
<p>The url of the commit of your {object} in the given repository.</p>
`,returnType:`
<p><code>str</code></p>
`}}),_o=new Le({props:{anchor:"transformers.utils.PushToHubMixin.push_to_hub.example",$$slots:{default:[tx]},$$scope:{ctx:D}}}),ga=new Ie({}),_a=new P({props:{name:"transformers.modeling_utils.load_sharded_checkpoint",anchor:"transformers.modeling_utils.load_sharded_checkpoint",parameters:[{name:"model",val:""},{name:"folder",val:""},{name:"strict",val:" = True"}],parametersDescription:[{anchor:"transformers.modeling_utils.load_sharded_checkpoint.model",description:"<strong>model</strong> (<code>torch.nn.Module</code>) &#x2014; The model in which to load the checkpoint.",name:"model"},{anchor:"transformers.modeling_utils.load_sharded_checkpoint.folder",description:"<strong>folder</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014; A path to a folder containing the sharded checkpoint.",name:"folder"},{anchor:"transformers.modeling_utils.load_sharded_checkpoint.strict",description:"<strong>strict</strong> (<code>bool</code>, *optional<code>, defaults to </code>True`) &#x2014;\nWhether to strictly enforce that the keys in the model state dict match the keys in the sharded checkpoint.",name:"strict"}],source:"https://github.com/huggingface/transformers/blob/vr_17548/src/transformers/modeling_utils.py#L341",returnDescription:`
<p>A named tuple with <code>missing_keys</code> and <code>unexpected_keys</code> fields</p>
<ul>
<li><code>missing_keys</code> is a list of str containing the missing keys</li>
<li><code>unexpected_keys</code> is a list of str containing the unexpected keys</li>
</ul>
`,returnType:`
<p><code>NamedTuple</code></p>
`}}),{c(){p=r("meta"),T=l(),$=r("h1"),f=r("a"),k=r("span"),u(c.$$.fragment),x=l(),re=r("span"),lm=s("Models"),od=l(),K=r("p"),dm=s("The base classes "),Pa=r("a"),cm=s("PreTrainedModel"),mm=s(", "),Ma=r("a"),pm=s("TFPreTrainedModel"),hm=s(`, and
`),Ea=r("a"),fm=s("FlaxPreTrainedModel"),um=s(` implement the common methods for loading/saving a model either from a local
file or directory, or from a pretrained model configuration provided by the library (downloaded from HuggingFace\u2019s AWS
S3 repository).`),rd=l(),Oe=r("p"),ja=r("a"),gm=s("PreTrainedModel"),_m=s(" and "),Fa=r("a"),bm=s("TFPreTrainedModel"),vm=s(` also implement a few methods which
are common among all the models to:`),ad=l(),ot=r("ul"),Mn=r("li"),ym=s("resize the input token embeddings when new tokens are added to the vocabulary"),wm=l(),En=r("li"),$m=s("prune the attention heads of the model."),nd=l(),O=r("p"),xm=s("The other methods that are common to each model are defined in "),Da=r("a"),Tm=s("ModuleUtilsMixin"),km=s(`
(for the PyTorch models) and `),jn=r("code"),Pm=s("TFModuleUtilsMixin"),Mm=s(` (for the TensorFlow models) or
for text generation, `),qa=r("a"),Em=s("GenerationMixin"),jm=s(` (for the PyTorch models),
`),Aa=r("a"),Fm=s("TFGenerationMixin"),Dm=s(` (for the TensorFlow models) and
`),za=r("a"),qm=s("FlaxGenerationMixin"),Am=s(" (for the Flax/JAX models)."),sd=l(),Ne=r("h2"),rt=r("a"),Fn=r("span"),u(To.$$.fragment),zm=l(),Dn=r("span"),Cm=s("PreTrainedModel"),id=l(),j=r("div"),u(ko.$$.fragment),Im=l(),qn=r("p"),Lm=s("Base class for all models."),Um=l(),Ca=r("p"),Ia=r("a"),Om=s("PreTrainedModel"),Nm=s(` takes care of storing the configuration of the models and handles methods for loading,
downloading and saving models as well as a few methods common to all models to:`),Bm=l(),Po=r("ul"),An=r("li"),Sm=s("resize the input embeddings,"),Xm=l(),zn=r("li"),Vm=s("prune heads in the self-attention heads."),Wm=l(),Cn=r("p"),Hm=s("Class attributes (overridden by derived classes):"),Rm=l(),H=r("ul"),In=r("li"),me=r("p"),Ln=r("strong"),Gm=s("config_class"),Ym=s(" ("),La=r("a"),Jm=s("PretrainedConfig"),Km=s(") \u2014 A subclass of "),Ua=r("a"),Zm=s("PretrainedConfig"),Qm=s(` to use as configuration class
for this model architecture.`),ep=l(),Mo=r("li"),pe=r("p"),Un=r("strong"),tp=s("load_tf_weights"),op=s(" ("),On=r("code"),rp=s("Callable"),ap=s(") \u2014 A python "),Nn=r("em"),np=s("method"),sp=s(` for loading a TensorFlow checkpoint in a PyTorch model,
taking as arguments:`),ip=l(),Be=r("ul"),at=r("li"),Bn=r("strong"),lp=s("model"),dp=s(" ("),Oa=r("a"),cp=s("PreTrainedModel"),mp=s(") \u2014 An instance of the model on which to load the TensorFlow checkpoint."),pp=l(),nt=r("li"),Sn=r("strong"),hp=s("config"),fp=s(" ("),Xn=r("code"),up=s("PreTrainedConfig"),gp=s(") \u2014 An instance of the configuration associated to the model."),_p=l(),st=r("li"),Vn=r("strong"),bp=s("path"),vp=s(" ("),Wn=r("code"),yp=s("str"),wp=s(") \u2014 A path to the TensorFlow checkpoint."),$p=l(),Hn=r("li"),it=r("p"),Rn=r("strong"),xp=s("base_model_prefix"),Tp=s(" ("),Gn=r("code"),kp=s("str"),Pp=s(`) \u2014 A string indicating the attribute associated to the base model in derived
classes of the same architecture adding modules on top of the base model.`),Mp=l(),Yn=r("li"),lt=r("p"),Jn=r("strong"),Ep=s("is_parallelizable"),jp=s(" ("),Kn=r("code"),Fp=s("bool"),Dp=s(") \u2014 A flag indicating whether this model supports model parallelization."),qp=l(),Zn=r("li"),S=r("p"),Qn=r("strong"),Ap=s("main_input_name"),zp=s(" ("),es=r("code"),Cp=s("str"),Ip=s(") \u2014 The name of the principal input to the model (often "),ts=r("code"),Lp=s("input_ids"),Up=s(` for NLP
models, `),os=r("code"),Op=s("pixel_values"),Np=s(" for vision models and "),rs=r("code"),Bp=s("input_values"),Sp=s(" for speech models)."),Xp=l(),he=r("div"),u(Eo.$$.fragment),Vp=l(),jo=r("p"),Wp=s("Upload the model files to the \u{1F917} Model Hub while synchronizing a local clone of the repo in "),as=r("code"),Hp=s("repo_path_or_name"),Rp=s("."),Gp=l(),u(dt.$$.fragment),Yp=l(),q=r("div"),u(Fo.$$.fragment),Jp=l(),ns=r("p"),Kp=s("Instantiate a pretrained pytorch model from a pre-trained model configuration."),Zp=l(),Se=r("p"),Qp=s("The model is set in evaluation mode by default using "),ss=r("code"),eh=s("model.eval()"),th=s(` (Dropout modules are deactivated). To train
the model, you should first set it back in training mode with `),is=r("code"),oh=s("model.train()"),rh=s("."),ah=l(),Do=r("p"),nh=s("The warning "),ls=r("em"),sh=s("Weights from XXX not initialized from pretrained model"),ih=s(` means that the weights of XXX do not come
pretrained with the rest of the model. It is up to you to train those weights with a downstream fine-tuning
task.`),lh=l(),qo=r("p"),dh=s("The warning "),ds=r("em"),ch=s("Weights from XXX not used in YYY"),mh=s(` means that the layer XXX is not used by YYY, therefore those
weights are discarded.`),ph=l(),u(ct.$$.fragment),hh=l(),u(mt.$$.fragment),fh=l(),u(pt.$$.fragment),uh=l(),cs=r("ul"),Na=r("li"),ms=r("code"),gh=s("low_cpu_mem_usage"),_h=s(" algorithm:"),bh=l(),ps=r("p"),vh=s("This is an experimental function that loads the model using ~1x model size CPU memory"),yh=l(),hs=r("p"),wh=s("Here is how it works:"),$h=l(),R=r("ol"),fs=r("li"),xh=s("save which state_dict keys we have"),Th=l(),us=r("li"),kh=s("drop state_dict before the model is created, since the latter takes 1x model size CPU memory"),Ph=l(),gs=r("li"),Mh=s(`after the model has been instantiated switch to the meta device all params/buffers that
are going to be replaced from the loaded state_dict`),Eh=l(),_s=r("li"),jh=s("load state_dict 2nd time"),Fh=l(),bs=r("li"),Dh=s("replace the params/buffers from the state_dict"),qh=l(),vs=r("p"),Ah=s("Currently, it can\u2019t handle deepspeed ZeRO stage 3 and ignores loading errors"),zh=l(),ht=r("div"),u(Ao.$$.fragment),Ch=l(),ys=r("p"),Ih=s("Returns the model\u2019s input embeddings."),Lh=l(),ft=r("div"),u(zo.$$.fragment),Uh=l(),ws=r("p"),Oh=s("Returns the model\u2019s output embeddings."),Nh=l(),fe=r("div"),u(Co.$$.fragment),Bh=l(),$s=r("p"),Sh=s("Deactivates gradient checkpointing for the current model."),Xh=l(),xs=r("p"),Vh=s(`Note that in other frameworks this feature can be referred to as \u201Cactivation checkpointing\u201D or \u201Ccheckpoint
activations\u201D.`),Wh=l(),ue=r("div"),u(Io.$$.fragment),Hh=l(),Ts=r("p"),Rh=s("Activates gradient checkpointing for the current model."),Gh=l(),ks=r("p"),Yh=s(`Note that in other frameworks this feature can be referred to as \u201Cactivation checkpointing\u201D or \u201Ccheckpoint
activations\u201D.`),Jh=l(),ut=r("div"),u(Lo.$$.fragment),Kh=l(),Ps=r("p"),Zh=s("If needed prunes and maybe initializes weights."),Qh=l(),gt=r("div"),u(Uo.$$.fragment),ef=l(),Ms=r("p"),tf=s(`A method executed at the end of each Transformer model initialization, to execute code that needs the model\u2019s
modules properly initialized (such as weight initialization).`),of=l(),_t=r("div"),u(Oo.$$.fragment),rf=l(),Es=r("p"),af=s("Prunes heads of the base model."),nf=l(),ge=r("div"),u(No.$$.fragment),sf=l(),js=r("p"),lf=s(`Register this class with a given auto class. This should only be used for custom models as the ones in the
library are already mapped with an auto class.`),df=l(),u(bt.$$.fragment),cf=l(),_e=r("div"),u(Bo.$$.fragment),mf=l(),So=r("p"),pf=s("Resizes input token embeddings matrix of the model if "),Fs=r("code"),hf=s("new_num_tokens != config.vocab_size"),ff=s("."),uf=l(),Xo=r("p"),gf=s("Takes care of tying weights embeddings afterwards if the model class has a "),Ds=r("code"),_f=s("tie_weights()"),bf=s(" method."),vf=l(),vt=r("div"),u(Vo.$$.fragment),yf=l(),Wo=r("p"),wf=s(`Save a model and its configuration file to a directory, so that it can be re-loaded using the
`),qs=r("code"),$f=s("[from_pretrained()](/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel.from_pretrained)"),xf=s(" class method."),Tf=l(),yt=r("div"),u(Ho.$$.fragment),kf=l(),As=r("p"),Pf=s("Set model\u2019s input embeddings."),Mf=l(),be=r("div"),u(Ro.$$.fragment),Ef=l(),zs=r("p"),jf=s("Tie the weights between the input embeddings and the output embeddings."),Ff=l(),Go=r("p"),Df=s("If the "),Cs=r("code"),qf=s("torchscript"),Af=s(` flag is set in the configuration, can\u2019t handle parameter sharing so we are cloning the
weights instead.`),ld=l(),Ba=r("a"),dd=l(),Xe=r("h3"),wt=r("a"),Is=r("span"),u(Yo.$$.fragment),zf=l(),Ls=r("span"),Cf=s("Large model loading"),cd=l(),ve=r("p"),If=s("In Transformers 4.20.0, the "),Sa=r("a"),Lf=s("from_pretrained()"),Uf=s(" method has been reworked to accommodate large models using "),Jo=r("a"),Of=s("Accelerate"),Nf=s(". This requires Accelerate >= 0.9.0 and PyTorch >= 1.9.0. Instead of creating the full model, then loading the pretrained weights inside it (which takes twice the size of the model in RAM, one for the randomly initialized model, one for the weights), there is an option to create the model as an empty shell, then only materialize its parameters when the pretrained weights are loaded."),md=l(),$t=r("p"),Bf=s("This option can be activated with "),Us=r("code"),Sf=s("low_cpu_mem_usage=True"),Xf=s(". The model is first created on the Meta device (with empty weights) and the state dict is then loaded inside it (shard by shard in the case of a sharded checkpoint). This way the maximum RAM used is the full size of the model only."),pd=l(),u(Ko.$$.fragment),hd=l(),xt=r("p"),Vf=s("Moreover, you can directly place the model on different devices if it doesn\u2019t fully fit in RAM (only works for inference for now). With "),Os=r("code"),Wf=s('device_map="auto"'),Hf=s(", Accelerate will determine where to put each layer to maximize the use of your fastest devices (GPUs) and offload the rest on the CPU, or even the hard drive if you don\u2019t have enough GPU RAM (or CPU RAM). Even if the model is split across several devices, it will run as you would normally expect."),fd=l(),Z=r("p"),Rf=s("When passing a "),Ns=r("code"),Gf=s("device_map"),Yf=s(", "),Bs=r("code"),Jf=s("low_cpu_mem_usage"),Kf=s(" is automatically set to "),Ss=r("code"),Zf=s("True"),Qf=s(", so you don\u2019t need to specify it:"),ud=l(),u(Zo.$$.fragment),gd=l(),Tt=r("p"),eu=s("You can inspect how the model was split across devices by looking at its "),Xs=r("code"),tu=s("hf_device_map"),ou=s(" attribute:"),_d=l(),u(Qo.$$.fragment),bd=l(),u(er.$$.fragment),vd=l(),Xa=r("p"),ru=s("You can also write your own device map following the same format (a dictionary layer name to device). It should map all parameters of the model to a given device, but you don\u2019t have to detail where all the submosules of one layer go if that layer is entirely on the same device. For instance, the following device map would work properly for T0pp (as long as you have the GPU memory):"),yd=l(),u(tr.$$.fragment),wd=l(),kt=r("p"),au=s("Another way to minimize the memory impact of your model is to instantiate it at a lower precision dtype (like "),Vs=r("code"),nu=s("torch.float16"),su=s(")."),$d=l(),Ve=r("h3"),Pt=r("a"),Ws=r("span"),u(or.$$.fragment),iu=l(),Hs=r("span"),lu=s("Model Instantiation dtype"),xd=l(),Q=r("p"),du=s("Under Pytorch a model normally gets instantiated with "),Rs=r("code"),cu=s("torch.float32"),mu=s(` format. This can be an issue if one tries to
load a model whose weights are in fp16, since it\u2019d require twice as much memory. To overcome this limitation, you can
either explicitly pass the desired `),Gs=r("code"),pu=s("dtype"),hu=s(" using "),Ys=r("code"),fu=s("torch_dtype"),uu=s(" argument:"),Td=l(),u(rr.$$.fragment),kd=l(),ye=r("p"),gu=s("or, if you want the model to always load in the most optimal memory pattern, you can use the special value "),Js=r("code"),_u=s('"auto"'),bu=s(`,
and then `),Ks=r("code"),vu=s("dtype"),yu=s(" will be automatically derived from the model\u2019s weights:"),Pd=l(),u(ar.$$.fragment),Md=l(),Mt=r("p"),wu=s("Models instantiated from scratch can also be told which "),Zs=r("code"),$u=s("dtype"),xu=s(" to use with:"),Ed=l(),u(nr.$$.fragment),jd=l(),Va=r("p"),Tu=s("Due to Pytorch design, this functionality is only available for floating dtypes."),Fd=l(),We=r("h2"),Et=r("a"),Qs=r("span"),u(sr.$$.fragment),ku=l(),ei=r("span"),Pu=s("ModuleUtilsMixin"),Dd=l(),C=r("div"),u(ir.$$.fragment),Mu=l(),lr=r("p"),Eu=s("A few utilities for "),ti=r("code"),ju=s("torch.nn.Modules"),Fu=s(", to be used as a mixin."),Du=l(),we=r("div"),u(dr.$$.fragment),qu=l(),oi=r("p"),Au=s("Add a memory hook before and after each sub-module forward pass to record increase in memory consumption."),zu=l(),He=r("p"),Cu=s("Increase in memory consumption is stored in a "),ri=r("code"),Iu=s("mem_rss_diff"),Lu=s(` attribute for each module and can be reset to zero
with `),ai=r("code"),Uu=s("model.reset_memory_hooks_state()"),Ou=s("."),Nu=l(),jt=r("div"),u(cr.$$.fragment),Bu=l(),ni=r("p"),Su=s("Helper function to estimate the total number of tokens from the model inputs."),Xu=l(),Ft=r("div"),u(mr.$$.fragment),Vu=l(),Re=r("p"),Wu=s(`Get number of (optionally, non-embeddings) floating-point operations for the forward and backward passes of a
batch with this transformer model. Default approximation neglects the quadratic dependency on the number of
tokens (valid if `),si=r("code"),Hu=s("12 * d_model << sequence_length"),Ru=s(") as laid out in "),pr=r("a"),Gu=s(`this
paper`),Yu=s(` section 2.1. Should be overridden for transformers with parameter
re-use e.g. Albert or Universal Transformers, or if doing long-range modeling with very high sequence lengths.`),Ju=l(),Dt=r("div"),u(hr.$$.fragment),Ku=l(),ii=r("p"),Zu=s("Makes broadcastable attention and causal masks so that future and masked tokens are ignored."),Qu=l(),qt=r("div"),u(fr.$$.fragment),eg=l(),li=r("p"),tg=s("Prepare the head mask if needed."),og=l(),At=r("div"),u(ur.$$.fragment),rg=l(),di=r("p"),ag=s("Invert an attention mask (e.g., switches 0. and 1.)."),ng=l(),zt=r("div"),u(gr.$$.fragment),sg=l(),ci=r("p"),ig=s("Get number of (optionally, trainable or non-embeddings) parameters in the module."),lg=l(),Ct=r("div"),u(_r.$$.fragment),dg=l(),Ge=r("p"),cg=s("Reset the "),mi=r("code"),mg=s("mem_rss_diff"),pg=s(" attribute of each module (see "),Wa=r("a"),hg=s("add_memory_hooks()"),fg=s(")."),qd=l(),Ye=r("h2"),It=r("a"),pi=r("span"),u(br.$$.fragment),ug=l(),hi=r("span"),gg=s("TFPreTrainedModel"),Ad=l(),M=r("div"),u(vr.$$.fragment),_g=l(),fi=r("p"),bg=s("Base class for all TF models."),vg=l(),Ha=r("p"),Ra=r("a"),yg=s("TFPreTrainedModel"),wg=s(` takes care of storing the configuration of the models and handles methods for loading,
downloading and saving models as well as a few methods common to all models to:`),$g=l(),yr=r("ul"),ui=r("li"),xg=s("resize the input embeddings,"),Tg=l(),gi=r("li"),kg=s("prune heads in the self-attention heads."),Pg=l(),_i=r("p"),Mg=s("Class attributes (overridden by derived classes):"),Eg=l(),Je=r("ul"),$e=r("li"),bi=r("strong"),jg=s("config_class"),Fg=s(" ("),Ga=r("a"),Dg=s("PretrainedConfig"),qg=s(") \u2014 A subclass of "),Ya=r("a"),Ag=s("PretrainedConfig"),zg=s(` to use as configuration class
for this model architecture.`),Cg=l(),Lt=r("li"),vi=r("strong"),Ig=s("base_model_prefix"),Lg=s(" ("),yi=r("code"),Ug=s("str"),Og=s(`) \u2014 A string indicating the attribute associated to the base model in derived
classes of the same architecture adding modules on top of the base model.`),Ng=l(),X=r("li"),wi=r("strong"),Bg=s("main_input_name"),Sg=s(" ("),$i=r("code"),Xg=s("str"),Vg=s(") \u2014 The name of the principal input to the model (often "),xi=r("code"),Wg=s("input_ids"),Hg=s(` for NLP
models, `),Ti=r("code"),Rg=s("pixel_values"),Gg=s(" for vision models and "),ki=r("code"),Yg=s("input_values"),Jg=s(" for speech models)."),Kg=l(),xe=r("div"),u(wr.$$.fragment),Zg=l(),$r=r("p"),Qg=s(`Upload the model checkpoint to the \u{1F917} Model Hub while synchronizing a local clone of the repo in
`),Pi=r("code"),e_=s("repo_path_or_name"),t_=s("."),o_=l(),u(Ut.$$.fragment),r_=l(),Ot=r("div"),u(xr.$$.fragment),a_=l(),Mi=r("p"),n_=s(`This is a thin wrapper that sets the model\u2019s loss output head as the loss if the user does not specify a loss
function themselves.`),s_=l(),N=r("div"),u(Tr.$$.fragment),i_=l(),Ei=r("p"),l_=s("Instantiate a pretrained TF 2.0 model from a pre-trained model configuration."),d_=l(),kr=r("p"),c_=s("The warning "),ji=r("em"),m_=s("Weights from XXX not initialized from pretrained model"),p_=s(` means that the weights of XXX do not come
pretrained with the rest of the model. It is up to you to train those weights with a downstream fine-tuning
task.`),h_=l(),Pr=r("p"),f_=s("The warning "),Fi=r("em"),u_=s("Weights from XXX not used in YYY"),g_=s(` means that the layer XXX is not used by YYY, therefore those
weights are discarded.`),__=l(),u(Nt.$$.fragment),b_=l(),u(Bt.$$.fragment),v_=l(),St=r("div"),u(Mr.$$.fragment),y_=l(),Di=r("p"),w_=s("Dict of bias attached to an LM head. The key represents the name of the bias attribute."),$_=l(),Xt=r("div"),u(Er.$$.fragment),x_=l(),qi=r("p"),T_=s("Returns the model\u2019s input embeddings layer."),k_=l(),Vt=r("div"),u(jr.$$.fragment),P_=l(),Ai=r("p"),M_=s("The LM Head layer. This method must be overwritten by all the models that have a lm head."),E_=l(),Wt=r("div"),u(Fr.$$.fragment),j_=l(),zi=r("p"),F_=s("Returns the model\u2019s output embeddings"),D_=l(),Ht=r("div"),u(Dr.$$.fragment),q_=l(),Ci=r("p"),A_=s(`Get the layer that handles a bias attribute in case the model has an LM head with weights tied to the
embeddings`),z_=l(),Rt=r("div"),u(qr.$$.fragment),C_=l(),Ii=r("p"),I_=s("Get the concatenated _prefix name of the bias from the model name to the parent layer"),L_=l(),Gt=r("div"),u(Ar.$$.fragment),U_=l(),Li=r("p"),O_=s(`Loads a saved checkpoint (model weights and optimizer state) from a repo. Returns the current epoch count when
the checkpoint was made.`),N_=l(),Yt=r("div"),u(zr.$$.fragment),B_=l(),Ui=r("p"),S_=s("Prunes heads of the base model."),X_=l(),Te=r("div"),u(Cr.$$.fragment),V_=l(),Ir=r("p"),W_=s("Resizes input token embeddings matrix of the model if "),Oi=r("code"),H_=s("new_num_tokens != config.vocab_size"),R_=s("."),G_=l(),Lr=r("p"),Y_=s("Takes care of tying weights embeddings afterwards if the model class has a "),Ni=r("code"),J_=s("tie_weights()"),K_=s(" method."),Z_=l(),Jt=r("div"),u(Ur.$$.fragment),Q_=l(),Or=r("p"),eb=s(`Save a model and its configuration file to a directory, so that it can be re-loaded using the
`),Ja=r("a"),tb=s("from_pretrained()"),ob=s(" class method."),rb=l(),Kt=r("div"),u(Nr.$$.fragment),ab=l(),Bi=r("p"),nb=s("Method used for serving the model."),sb=l(),Zt=r("div"),u(Br.$$.fragment),ib=l(),Si=r("p"),lb=s("Prepare the output of the saved model. Each model must implement this function."),db=l(),Qt=r("div"),u(Sr.$$.fragment),cb=l(),Xi=r("p"),mb=s("Set all the bias in the LM head."),pb=l(),eo=r("div"),u(Xr.$$.fragment),hb=l(),Vi=r("p"),fb=s("Set model\u2019s input embeddings"),ub=l(),to=r("div"),u(Vr.$$.fragment),gb=l(),Wi=r("p"),_b=s("Set model\u2019s output embeddings"),bb=l(),oo=r("div"),u(Wr.$$.fragment),vb=l(),Hr=r("p"),yb=s("A modification of Keras\u2019s default "),Hi=r("code"),wb=s("train_step"),$b=s(` that correctly handles matching outputs to labels for our models
and supports directly training on the loss output head. In addition, it ensures input keys are copied to the
labels where appropriate. It will also copy label keys into the input dict when using the dummy loss, to ensure
that they are available to the model during the forward pass.`),xb=l(),ro=r("div"),u(Rr.$$.fragment),Tb=l(),Gr=r("p"),kb=s("A modification of Keras\u2019s default "),Ri=r("code"),Pb=s("train_step"),Mb=s(` that correctly handles matching outputs to labels for our models
and supports directly training on the loss output head. In addition, it ensures input keys are copied to the
labels where appropriate. It will also copy label keys into the input dict when using the dummy loss, to ensure
that they are available to the model during the forward pass.`),zd=l(),Ke=r("h2"),ao=r("a"),Gi=r("span"),u(Yr.$$.fragment),Eb=l(),Yi=r("span"),jb=s("TFModelUtilsMixin"),Cd=l(),ae=r("div"),u(Jr.$$.fragment),Fb=l(),Kr=r("p"),Db=s("A few utilities for "),Ji=r("code"),qb=s("tf.keras.Model"),Ab=s(", to be used as a mixin."),zb=l(),no=r("div"),u(Zr.$$.fragment),Cb=l(),Ki=r("p"),Ib=s("Get the number of (optionally, trainable) parameters in the model."),Id=l(),Ze=r("h2"),so=r("a"),Zi=r("span"),u(Qr.$$.fragment),Lb=l(),Qi=r("span"),Ub=s("FlaxPreTrainedModel"),Ld=l(),A=r("div"),u(ea.$$.fragment),Ob=l(),el=r("p"),Nb=s("Base class for all models."),Bb=l(),Ka=r("p"),Za=r("a"),Sb=s("FlaxPreTrainedModel"),Xb=s(` takes care of storing the configuration of the models and handles methods for loading,
downloading and saving models.`),Vb=l(),tl=r("p"),Wb=s("Class attributes (overridden by derived classes):"),Hb=l(),Qe=r("ul"),ke=r("li"),ol=r("strong"),Rb=s("config_class"),Gb=s(" ("),Qa=r("a"),Yb=s("PretrainedConfig"),Jb=s(") \u2014 A subclass of "),en=r("a"),Kb=s("PretrainedConfig"),Zb=s(` to use as configuration class
for this model architecture.`),Qb=l(),io=r("li"),rl=r("strong"),ev=s("base_model_prefix"),tv=s(" ("),al=r("code"),ov=s("str"),rv=s(`) \u2014 A string indicating the attribute associated to the base model in derived
classes of the same architecture adding modules on top of the base model.`),av=l(),V=r("li"),nl=r("strong"),nv=s("main_input_name"),sv=s(" ("),sl=r("code"),iv=s("str"),lv=s(") \u2014 The name of the principal input to the model (often "),il=r("code"),dv=s("input_ids"),cv=s(` for NLP
models, `),ll=r("code"),mv=s("pixel_values"),pv=s(" for vision models and "),dl=r("code"),hv=s("input_values"),fv=s(" for speech models)."),uv=l(),Pe=r("div"),u(ta.$$.fragment),gv=l(),oa=r("p"),_v=s(`Upload the model checkpoint to the \u{1F917} Model Hub while synchronizing a local clone of the repo in
`),cl=r("code"),bv=s("repo_path_or_name"),vv=s("."),yv=l(),u(lo.$$.fragment),wv=l(),W=r("div"),u(ra.$$.fragment),$v=l(),ml=r("p"),xv=s("Instantiate a pretrained flax model from a pre-trained model configuration."),Tv=l(),aa=r("p"),kv=s("The warning "),pl=r("em"),Pv=s("Weights from XXX not initialized from pretrained model"),Mv=s(` means that the weights of XXX do not come
pretrained with the rest of the model. It is up to you to train those weights with a downstream fine-tuning
task.`),Ev=l(),na=r("p"),jv=s("The warning "),hl=r("em"),Fv=s("Weights from XXX not used in YYY"),Dv=s(` means that the layer XXX is not used by YYY, therefore those
weights are discarded.`),qv=l(),u(co.$$.fragment),Av=l(),Me=r("div"),u(sa.$$.fragment),zv=l(),fl=r("p"),Cv=s(`Register this class with a given auto class. This should only be used for custom models as the ones in the
library are already mapped with an auto class.`),Iv=l(),u(mo.$$.fragment),Lv=l(),po=r("div"),u(ia.$$.fragment),Uv=l(),la=r("p"),Ov=s(`Save a model and its configuration file to a directory, so that it can be re-loaded using the
`),ul=r("code"),Nv=s("[from_pretrained()](/docs/transformers/pr_17548/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained)"),Bv=s(" class method"),Sv=l(),ee=r("div"),u(da.$$.fragment),Xv=l(),G=r("p"),Vv=s("Cast the floating-point "),gl=r("code"),Wv=s("params"),Hv=s(" to "),_l=r("code"),Rv=s("jax.numpy.bfloat16"),Gv=s(". This returns a new "),bl=r("code"),Yv=s("params"),Jv=s(` tree and does not cast
the `),vl=r("code"),Kv=s("params"),Zv=s(" in place."),Qv=l(),yl=r("p"),ey=s(`This method can be used on TPU to explicitly convert the model parameters to bfloat16 precision to do full
half-precision training or to save weights in bfloat16 for inference in order to save memory and improve speed.`),ty=l(),u(ho.$$.fragment),oy=l(),te=r("div"),u(ca.$$.fragment),ry=l(),Y=r("p"),ay=s("Cast the floating-point "),wl=r("code"),ny=s("parmas"),sy=s(" to "),$l=r("code"),iy=s("jax.numpy.float16"),ly=s(". This returns a new "),xl=r("code"),dy=s("params"),cy=s(` tree and does not cast the
`),Tl=r("code"),my=s("params"),py=s(" in place."),hy=l(),kl=r("p"),fy=s(`This method can be used on GPU to explicitly convert the model parameters to float16 precision to do full
half-precision training or to save weights in float16 for inference in order to save memory and improve speed.`),uy=l(),u(fo.$$.fragment),gy=l(),Ee=r("div"),u(ma.$$.fragment),_y=l(),J=r("p"),by=s("Cast the floating-point "),Pl=r("code"),vy=s("parmas"),yy=s(" to "),Ml=r("code"),wy=s("jax.numpy.float32"),$y=s(`. This method can be used to explicitly convert the
model parameters to fp32 precision. This returns a new `),El=r("code"),xy=s("params"),Ty=s(" tree and does not cast the "),jl=r("code"),ky=s("params"),Py=s(" in place."),My=l(),u(uo.$$.fragment),Ud=l(),et=r("h2"),go=r("a"),Fl=r("span"),u(pa.$$.fragment),Ey=l(),Dl=r("span"),jy=s("Pushing to the Hub"),Od=l(),ne=r("div"),u(ha.$$.fragment),Fy=l(),ql=r("p"),Dy=s("A Mixin containing the functionality to push a model or tokenizer to the hub."),qy=l(),je=r("div"),u(fa.$$.fragment),Ay=l(),ua=r("p"),zy=s(`Upload the {object_files} to the \u{1F917} Model Hub while synchronizing a local clone of the repo in
`),Al=r("code"),Cy=s("repo_path_or_name"),Iy=s("."),Ly=l(),u(_o.$$.fragment),Nd=l(),tt=r("h2"),bo=r("a"),zl=r("span"),u(ga.$$.fragment),Uy=l(),Cl=r("span"),Oy=s("Sharded checkpoints"),Bd=l(),se=r("div"),u(_a.$$.fragment),Ny=l(),ba=r("p"),By=s(`This is the same as
`),va=r("a"),Il=r("code"),Sy=s("torch.nn.Module.load_state_dict"),Xy=s(`
but for a sharded checkpoint.`),Vy=l(),Ll=r("p"),Wy=s(`This load is performed efficiently: each checkpoint shard is loaded one by one in RAM and deleted after being
loaded in the model.`),this.h()},l(o){const h=O2('[data-svelte="svelte-1phssyn"]',document.head);p=a(h,"META",{name:!0,content:!0}),h.forEach(t),T=d(o),$=a(o,"H1",{class:!0});var ya=n($);f=a(ya,"A",{id:!0,class:!0,href:!0});var Ul=n(f);k=a(Ul,"SPAN",{});var Ol=n(k);g(c.$$.fragment,Ol),Ol.forEach(t),Ul.forEach(t),x=d(ya),re=a(ya,"SPAN",{});var Nl=n(re);lm=i(Nl,"Models"),Nl.forEach(t),ya.forEach(t),od=d(o),K=a(o,"P",{});var ie=n(K);dm=i(ie,"The base classes "),Pa=a(ie,"A",{href:!0});var Bl=n(Pa);cm=i(Bl,"PreTrainedModel"),Bl.forEach(t),mm=i(ie,", "),Ma=a(ie,"A",{href:!0});var Sl=n(Ma);pm=i(Sl,"TFPreTrainedModel"),Sl.forEach(t),hm=i(ie,`, and
`),Ea=a(ie,"A",{href:!0});var Xl=n(Ea);fm=i(Xl,"FlaxPreTrainedModel"),Xl.forEach(t),um=i(ie,` implement the common methods for loading/saving a model either from a local
file or directory, or from a pretrained model configuration provided by the library (downloaded from HuggingFace\u2019s AWS
S3 repository).`),ie.forEach(t),rd=d(o),Oe=a(o,"P",{});var vo=n(Oe);ja=a(vo,"A",{href:!0});var Vl=n(ja);gm=i(Vl,"PreTrainedModel"),Vl.forEach(t),_m=i(vo," and "),Fa=a(vo,"A",{href:!0});var Wl=n(Fa);bm=i(Wl,"TFPreTrainedModel"),Wl.forEach(t),vm=i(vo,` also implement a few methods which
are common among all the models to:`),vo.forEach(t),ad=d(o),ot=a(o,"UL",{});var wa=n(ot);Mn=a(wa,"LI",{});var Hl=n(Mn);ym=i(Hl,"resize the input token embeddings when new tokens are added to the vocabulary"),Hl.forEach(t),wm=d(wa),En=a(wa,"LI",{});var Rl=n(En);$m=i(Rl,"prune the attention heads of the model."),Rl.forEach(t),wa.forEach(t),nd=d(o),O=a(o,"P",{});var B=n(O);xm=i(B,"The other methods that are common to each model are defined in "),Da=a(B,"A",{href:!0});var Jy=n(Da);Tm=i(Jy,"ModuleUtilsMixin"),Jy.forEach(t),km=i(B,`
(for the PyTorch models) and `),jn=a(B,"CODE",{});var Ky=n(jn);Pm=i(Ky,"TFModuleUtilsMixin"),Ky.forEach(t),Mm=i(B,` (for the TensorFlow models) or
for text generation, `),qa=a(B,"A",{href:!0});var Zy=n(qa);Em=i(Zy,"GenerationMixin"),Zy.forEach(t),jm=i(B,` (for the PyTorch models),
`),Aa=a(B,"A",{href:!0});var Qy=n(Aa);Fm=i(Qy,"TFGenerationMixin"),Qy.forEach(t),Dm=i(B,` (for the TensorFlow models) and
`),za=a(B,"A",{href:!0});var e1=n(za);qm=i(e1,"FlaxGenerationMixin"),e1.forEach(t),Am=i(B," (for the Flax/JAX models)."),B.forEach(t),sd=d(o),Ne=a(o,"H2",{class:!0});var Xd=n(Ne);rt=a(Xd,"A",{id:!0,class:!0,href:!0});var t1=n(rt);Fn=a(t1,"SPAN",{});var o1=n(Fn);g(To.$$.fragment,o1),o1.forEach(t),t1.forEach(t),zm=d(Xd),Dn=a(Xd,"SPAN",{});var r1=n(Dn);Cm=i(r1,"PreTrainedModel"),r1.forEach(t),Xd.forEach(t),id=d(o),j=a(o,"DIV",{class:!0});var F=n(j);g(ko.$$.fragment,F),Im=d(F),qn=a(F,"P",{});var a1=n(qn);Lm=i(a1,"Base class for all models."),a1.forEach(t),Um=d(F),Ca=a(F,"P",{});var Hy=n(Ca);Ia=a(Hy,"A",{href:!0});var n1=n(Ia);Om=i(n1,"PreTrainedModel"),n1.forEach(t),Nm=i(Hy,` takes care of storing the configuration of the models and handles methods for loading,
downloading and saving models as well as a few methods common to all models to:`),Hy.forEach(t),Bm=d(F),Po=a(F,"UL",{});var Vd=n(Po);An=a(Vd,"LI",{});var s1=n(An);Sm=i(s1,"resize the input embeddings,"),s1.forEach(t),Xm=d(Vd),zn=a(Vd,"LI",{});var i1=n(zn);Vm=i(i1,"prune heads in the self-attention heads."),i1.forEach(t),Vd.forEach(t),Wm=d(F),Cn=a(F,"P",{});var l1=n(Cn);Hm=i(l1,"Class attributes (overridden by derived classes):"),l1.forEach(t),Rm=d(F),H=a(F,"UL",{});var Fe=n(H);In=a(Fe,"LI",{});var d1=n(In);me=a(d1,"P",{});var $a=n(me);Ln=a($a,"STRONG",{});var c1=n(Ln);Gm=i(c1,"config_class"),c1.forEach(t),Ym=i($a," ("),La=a($a,"A",{href:!0});var m1=n(La);Jm=i(m1,"PretrainedConfig"),m1.forEach(t),Km=i($a,") \u2014 A subclass of "),Ua=a($a,"A",{href:!0});var p1=n(Ua);Zm=i(p1,"PretrainedConfig"),p1.forEach(t),Qm=i($a,` to use as configuration class
for this model architecture.`),$a.forEach(t),d1.forEach(t),ep=d(Fe),Mo=a(Fe,"LI",{});var Wd=n(Mo);pe=a(Wd,"P",{});var xa=n(pe);Un=a(xa,"STRONG",{});var h1=n(Un);tp=i(h1,"load_tf_weights"),h1.forEach(t),op=i(xa," ("),On=a(xa,"CODE",{});var f1=n(On);rp=i(f1,"Callable"),f1.forEach(t),ap=i(xa,") \u2014 A python "),Nn=a(xa,"EM",{});var u1=n(Nn);np=i(u1,"method"),u1.forEach(t),sp=i(xa,` for loading a TensorFlow checkpoint in a PyTorch model,
taking as arguments:`),xa.forEach(t),ip=d(Wd),Be=a(Wd,"UL",{});var tn=n(Be);at=a(tn,"LI",{});var Gl=n(at);Bn=a(Gl,"STRONG",{});var g1=n(Bn);lp=i(g1,"model"),g1.forEach(t),dp=i(Gl," ("),Oa=a(Gl,"A",{href:!0});var _1=n(Oa);cp=i(_1,"PreTrainedModel"),_1.forEach(t),mp=i(Gl,") \u2014 An instance of the model on which to load the TensorFlow checkpoint."),Gl.forEach(t),pp=d(tn),nt=a(tn,"LI",{});var Yl=n(nt);Sn=a(Yl,"STRONG",{});var b1=n(Sn);hp=i(b1,"config"),b1.forEach(t),fp=i(Yl," ("),Xn=a(Yl,"CODE",{});var v1=n(Xn);up=i(v1,"PreTrainedConfig"),v1.forEach(t),gp=i(Yl,") \u2014 An instance of the configuration associated to the model."),Yl.forEach(t),_p=d(tn),st=a(tn,"LI",{});var Jl=n(st);Vn=a(Jl,"STRONG",{});var y1=n(Vn);bp=i(y1,"path"),y1.forEach(t),vp=i(Jl," ("),Wn=a(Jl,"CODE",{});var w1=n(Wn);yp=i(w1,"str"),w1.forEach(t),wp=i(Jl,") \u2014 A path to the TensorFlow checkpoint."),Jl.forEach(t),tn.forEach(t),Wd.forEach(t),$p=d(Fe),Hn=a(Fe,"LI",{});var $1=n(Hn);it=a($1,"P",{});var Kl=n(it);Rn=a(Kl,"STRONG",{});var x1=n(Rn);xp=i(x1,"base_model_prefix"),x1.forEach(t),Tp=i(Kl," ("),Gn=a(Kl,"CODE",{});var T1=n(Gn);kp=i(T1,"str"),T1.forEach(t),Pp=i(Kl,`) \u2014 A string indicating the attribute associated to the base model in derived
classes of the same architecture adding modules on top of the base model.`),Kl.forEach(t),$1.forEach(t),Mp=d(Fe),Yn=a(Fe,"LI",{});var k1=n(Yn);lt=a(k1,"P",{});var Zl=n(lt);Jn=a(Zl,"STRONG",{});var P1=n(Jn);Ep=i(P1,"is_parallelizable"),P1.forEach(t),jp=i(Zl," ("),Kn=a(Zl,"CODE",{});var M1=n(Kn);Fp=i(M1,"bool"),M1.forEach(t),Dp=i(Zl,") \u2014 A flag indicating whether this model supports model parallelization."),Zl.forEach(t),k1.forEach(t),qp=d(Fe),Zn=a(Fe,"LI",{});var E1=n(Zn);S=a(E1,"P",{});var le=n(S);Qn=a(le,"STRONG",{});var j1=n(Qn);Ap=i(j1,"main_input_name"),j1.forEach(t),zp=i(le," ("),es=a(le,"CODE",{});var F1=n(es);Cp=i(F1,"str"),F1.forEach(t),Ip=i(le,") \u2014 The name of the principal input to the model (often "),ts=a(le,"CODE",{});var D1=n(ts);Lp=i(D1,"input_ids"),D1.forEach(t),Up=i(le,` for NLP
models, `),os=a(le,"CODE",{});var q1=n(os);Op=i(q1,"pixel_values"),q1.forEach(t),Np=i(le," for vision models and "),rs=a(le,"CODE",{});var A1=n(rs);Bp=i(A1,"input_values"),A1.forEach(t),Sp=i(le," for speech models)."),le.forEach(t),E1.forEach(t),Fe.forEach(t),Xp=d(F),he=a(F,"DIV",{class:!0});var on=n(he);g(Eo.$$.fragment,on),Vp=d(on),jo=a(on,"P",{});var Hd=n(jo);Wp=i(Hd,"Upload the model files to the \u{1F917} Model Hub while synchronizing a local clone of the repo in "),as=a(Hd,"CODE",{});var z1=n(as);Hp=i(z1,"repo_path_or_name"),z1.forEach(t),Rp=i(Hd,"."),Hd.forEach(t),Gp=d(on),g(dt.$$.fragment,on),on.forEach(t),Yp=d(F),q=a(F,"DIV",{class:!0});var z=n(q);g(Fo.$$.fragment,z),Jp=d(z),ns=a(z,"P",{});var C1=n(ns);Kp=i(C1,"Instantiate a pretrained pytorch model from a pre-trained model configuration."),C1.forEach(t),Zp=d(z),Se=a(z,"P",{});var rn=n(Se);Qp=i(rn,"The model is set in evaluation mode by default using "),ss=a(rn,"CODE",{});var I1=n(ss);eh=i(I1,"model.eval()"),I1.forEach(t),th=i(rn,` (Dropout modules are deactivated). To train
the model, you should first set it back in training mode with `),is=a(rn,"CODE",{});var L1=n(is);oh=i(L1,"model.train()"),L1.forEach(t),rh=i(rn,"."),rn.forEach(t),ah=d(z),Do=a(z,"P",{});var Rd=n(Do);nh=i(Rd,"The warning "),ls=a(Rd,"EM",{});var U1=n(ls);sh=i(U1,"Weights from XXX not initialized from pretrained model"),U1.forEach(t),ih=i(Rd,` means that the weights of XXX do not come
pretrained with the rest of the model. It is up to you to train those weights with a downstream fine-tuning
task.`),Rd.forEach(t),lh=d(z),qo=a(z,"P",{});var Gd=n(qo);dh=i(Gd,"The warning "),ds=a(Gd,"EM",{});var O1=n(ds);ch=i(O1,"Weights from XXX not used in YYY"),O1.forEach(t),mh=i(Gd,` means that the layer XXX is not used by YYY, therefore those
weights are discarded.`),Gd.forEach(t),ph=d(z),g(ct.$$.fragment,z),hh=d(z),g(mt.$$.fragment,z),fh=d(z),g(pt.$$.fragment,z),uh=d(z),cs=a(z,"UL",{});var N1=n(cs);Na=a(N1,"LI",{});var Ry=n(Na);ms=a(Ry,"CODE",{});var B1=n(ms);gh=i(B1,"low_cpu_mem_usage"),B1.forEach(t),_h=i(Ry," algorithm:"),Ry.forEach(t),N1.forEach(t),bh=d(z),ps=a(z,"P",{});var S1=n(ps);vh=i(S1,"This is an experimental function that loads the model using ~1x model size CPU memory"),S1.forEach(t),yh=d(z),hs=a(z,"P",{});var X1=n(hs);wh=i(X1,"Here is how it works:"),X1.forEach(t),$h=d(z),R=a(z,"OL",{});var De=n(R);fs=a(De,"LI",{});var V1=n(fs);xh=i(V1,"save which state_dict keys we have"),V1.forEach(t),Th=d(De),us=a(De,"LI",{});var W1=n(us);kh=i(W1,"drop state_dict before the model is created, since the latter takes 1x model size CPU memory"),W1.forEach(t),Ph=d(De),gs=a(De,"LI",{});var H1=n(gs);Mh=i(H1,`after the model has been instantiated switch to the meta device all params/buffers that
are going to be replaced from the loaded state_dict`),H1.forEach(t),Eh=d(De),_s=a(De,"LI",{});var R1=n(_s);jh=i(R1,"load state_dict 2nd time"),R1.forEach(t),Fh=d(De),bs=a(De,"LI",{});var G1=n(bs);Dh=i(G1,"replace the params/buffers from the state_dict"),G1.forEach(t),De.forEach(t),qh=d(z),vs=a(z,"P",{});var Y1=n(vs);Ah=i(Y1,"Currently, it can\u2019t handle deepspeed ZeRO stage 3 and ignores loading errors"),Y1.forEach(t),z.forEach(t),zh=d(F),ht=a(F,"DIV",{class:!0});var Yd=n(ht);g(Ao.$$.fragment,Yd),Ch=d(Yd),ys=a(Yd,"P",{});var J1=n(ys);Ih=i(J1,"Returns the model\u2019s input embeddings."),J1.forEach(t),Yd.forEach(t),Lh=d(F),ft=a(F,"DIV",{class:!0});var Jd=n(ft);g(zo.$$.fragment,Jd),Uh=d(Jd),ws=a(Jd,"P",{});var K1=n(ws);Oh=i(K1,"Returns the model\u2019s output embeddings."),K1.forEach(t),Jd.forEach(t),Nh=d(F),fe=a(F,"DIV",{class:!0});var an=n(fe);g(Co.$$.fragment,an),Bh=d(an),$s=a(an,"P",{});var Z1=n($s);Sh=i(Z1,"Deactivates gradient checkpointing for the current model."),Z1.forEach(t),Xh=d(an),xs=a(an,"P",{});var Q1=n(xs);Vh=i(Q1,`Note that in other frameworks this feature can be referred to as \u201Cactivation checkpointing\u201D or \u201Ccheckpoint
activations\u201D.`),Q1.forEach(t),an.forEach(t),Wh=d(F),ue=a(F,"DIV",{class:!0});var nn=n(ue);g(Io.$$.fragment,nn),Hh=d(nn),Ts=a(nn,"P",{});var ew=n(Ts);Rh=i(ew,"Activates gradient checkpointing for the current model."),ew.forEach(t),Gh=d(nn),ks=a(nn,"P",{});var tw=n(ks);Yh=i(tw,`Note that in other frameworks this feature can be referred to as \u201Cactivation checkpointing\u201D or \u201Ccheckpoint
activations\u201D.`),tw.forEach(t),nn.forEach(t),Jh=d(F),ut=a(F,"DIV",{class:!0});var Kd=n(ut);g(Lo.$$.fragment,Kd),Kh=d(Kd),Ps=a(Kd,"P",{});var ow=n(Ps);Zh=i(ow,"If needed prunes and maybe initializes weights."),ow.forEach(t),Kd.forEach(t),Qh=d(F),gt=a(F,"DIV",{class:!0});var Zd=n(gt);g(Uo.$$.fragment,Zd),ef=d(Zd),Ms=a(Zd,"P",{});var rw=n(Ms);tf=i(rw,`A method executed at the end of each Transformer model initialization, to execute code that needs the model\u2019s
modules properly initialized (such as weight initialization).`),rw.forEach(t),Zd.forEach(t),of=d(F),_t=a(F,"DIV",{class:!0});var Qd=n(_t);g(Oo.$$.fragment,Qd),rf=d(Qd),Es=a(Qd,"P",{});var aw=n(Es);af=i(aw,"Prunes heads of the base model."),aw.forEach(t),Qd.forEach(t),nf=d(F),ge=a(F,"DIV",{class:!0});var sn=n(ge);g(No.$$.fragment,sn),sf=d(sn),js=a(sn,"P",{});var nw=n(js);lf=i(nw,`Register this class with a given auto class. This should only be used for custom models as the ones in the
library are already mapped with an auto class.`),nw.forEach(t),df=d(sn),g(bt.$$.fragment,sn),sn.forEach(t),cf=d(F),_e=a(F,"DIV",{class:!0});var ln=n(_e);g(Bo.$$.fragment,ln),mf=d(ln),So=a(ln,"P",{});var ec=n(So);pf=i(ec,"Resizes input token embeddings matrix of the model if "),Fs=a(ec,"CODE",{});var sw=n(Fs);hf=i(sw,"new_num_tokens != config.vocab_size"),sw.forEach(t),ff=i(ec,"."),ec.forEach(t),uf=d(ln),Xo=a(ln,"P",{});var tc=n(Xo);gf=i(tc,"Takes care of tying weights embeddings afterwards if the model class has a "),Ds=a(tc,"CODE",{});var iw=n(Ds);_f=i(iw,"tie_weights()"),iw.forEach(t),bf=i(tc," method."),tc.forEach(t),ln.forEach(t),vf=d(F),vt=a(F,"DIV",{class:!0});var oc=n(vt);g(Vo.$$.fragment,oc),yf=d(oc),Wo=a(oc,"P",{});var rc=n(Wo);wf=i(rc,`Save a model and its configuration file to a directory, so that it can be re-loaded using the
`),qs=a(rc,"CODE",{});var lw=n(qs);$f=i(lw,"[from_pretrained()](/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel.from_pretrained)"),lw.forEach(t),xf=i(rc," class method."),rc.forEach(t),oc.forEach(t),Tf=d(F),yt=a(F,"DIV",{class:!0});var ac=n(yt);g(Ho.$$.fragment,ac),kf=d(ac),As=a(ac,"P",{});var dw=n(As);Pf=i(dw,"Set model\u2019s input embeddings."),dw.forEach(t),ac.forEach(t),Mf=d(F),be=a(F,"DIV",{class:!0});var dn=n(be);g(Ro.$$.fragment,dn),Ef=d(dn),zs=a(dn,"P",{});var cw=n(zs);jf=i(cw,"Tie the weights between the input embeddings and the output embeddings."),cw.forEach(t),Ff=d(dn),Go=a(dn,"P",{});var nc=n(Go);Df=i(nc,"If the "),Cs=a(nc,"CODE",{});var mw=n(Cs);qf=i(mw,"torchscript"),mw.forEach(t),Af=i(nc,` flag is set in the configuration, can\u2019t handle parameter sharing so we are cloning the
weights instead.`),nc.forEach(t),dn.forEach(t),F.forEach(t),ld=d(o),Ba=a(o,"A",{id:!0}),n(Ba).forEach(t),dd=d(o),Xe=a(o,"H3",{class:!0});var sc=n(Xe);wt=a(sc,"A",{id:!0,class:!0,href:!0});var pw=n(wt);Is=a(pw,"SPAN",{});var hw=n(Is);g(Yo.$$.fragment,hw),hw.forEach(t),pw.forEach(t),zf=d(sc),Ls=a(sc,"SPAN",{});var fw=n(Ls);Cf=i(fw,"Large model loading"),fw.forEach(t),sc.forEach(t),cd=d(o),ve=a(o,"P",{});var cn=n(ve);If=i(cn,"In Transformers 4.20.0, the "),Sa=a(cn,"A",{href:!0});var uw=n(Sa);Lf=i(uw,"from_pretrained()"),uw.forEach(t),Uf=i(cn," method has been reworked to accommodate large models using "),Jo=a(cn,"A",{href:!0,rel:!0});var gw=n(Jo);Of=i(gw,"Accelerate"),gw.forEach(t),Nf=i(cn,". This requires Accelerate >= 0.9.0 and PyTorch >= 1.9.0. Instead of creating the full model, then loading the pretrained weights inside it (which takes twice the size of the model in RAM, one for the randomly initialized model, one for the weights), there is an option to create the model as an empty shell, then only materialize its parameters when the pretrained weights are loaded."),cn.forEach(t),md=d(o),$t=a(o,"P",{});var ic=n($t);Bf=i(ic,"This option can be activated with "),Us=a(ic,"CODE",{});var _w=n(Us);Sf=i(_w,"low_cpu_mem_usage=True"),_w.forEach(t),Xf=i(ic,". The model is first created on the Meta device (with empty weights) and the state dict is then loaded inside it (shard by shard in the case of a sharded checkpoint). This way the maximum RAM used is the full size of the model only."),ic.forEach(t),pd=d(o),g(Ko.$$.fragment,o),hd=d(o),xt=a(o,"P",{});var lc=n(xt);Vf=i(lc,"Moreover, you can directly place the model on different devices if it doesn\u2019t fully fit in RAM (only works for inference for now). With "),Os=a(lc,"CODE",{});var bw=n(Os);Wf=i(bw,'device_map="auto"'),bw.forEach(t),Hf=i(lc,", Accelerate will determine where to put each layer to maximize the use of your fastest devices (GPUs) and offload the rest on the CPU, or even the hard drive if you don\u2019t have enough GPU RAM (or CPU RAM). Even if the model is split across several devices, it will run as you would normally expect."),lc.forEach(t),fd=d(o),Z=a(o,"P",{});var yo=n(Z);Rf=i(yo,"When passing a "),Ns=a(yo,"CODE",{});var vw=n(Ns);Gf=i(vw,"device_map"),vw.forEach(t),Yf=i(yo,", "),Bs=a(yo,"CODE",{});var yw=n(Bs);Jf=i(yw,"low_cpu_mem_usage"),yw.forEach(t),Kf=i(yo," is automatically set to "),Ss=a(yo,"CODE",{});var ww=n(Ss);Zf=i(ww,"True"),ww.forEach(t),Qf=i(yo,", so you don\u2019t need to specify it:"),yo.forEach(t),ud=d(o),g(Zo.$$.fragment,o),gd=d(o),Tt=a(o,"P",{});var dc=n(Tt);eu=i(dc,"You can inspect how the model was split across devices by looking at its "),Xs=a(dc,"CODE",{});var $w=n(Xs);tu=i($w,"hf_device_map"),$w.forEach(t),ou=i(dc," attribute:"),dc.forEach(t),_d=d(o),g(Qo.$$.fragment,o),bd=d(o),g(er.$$.fragment,o),vd=d(o),Xa=a(o,"P",{});var xw=n(Xa);ru=i(xw,"You can also write your own device map following the same format (a dictionary layer name to device). It should map all parameters of the model to a given device, but you don\u2019t have to detail where all the submosules of one layer go if that layer is entirely on the same device. For instance, the following device map would work properly for T0pp (as long as you have the GPU memory):"),xw.forEach(t),yd=d(o),g(tr.$$.fragment,o),wd=d(o),kt=a(o,"P",{});var cc=n(kt);au=i(cc,"Another way to minimize the memory impact of your model is to instantiate it at a lower precision dtype (like "),Vs=a(cc,"CODE",{});var Tw=n(Vs);nu=i(Tw,"torch.float16"),Tw.forEach(t),su=i(cc,")."),cc.forEach(t),$d=d(o),Ve=a(o,"H3",{class:!0});var mc=n(Ve);Pt=a(mc,"A",{id:!0,class:!0,href:!0});var kw=n(Pt);Ws=a(kw,"SPAN",{});var Pw=n(Ws);g(or.$$.fragment,Pw),Pw.forEach(t),kw.forEach(t),iu=d(mc),Hs=a(mc,"SPAN",{});var Mw=n(Hs);lu=i(Mw,"Model Instantiation dtype"),Mw.forEach(t),mc.forEach(t),xd=d(o),Q=a(o,"P",{});var wo=n(Q);du=i(wo,"Under Pytorch a model normally gets instantiated with "),Rs=a(wo,"CODE",{});var Ew=n(Rs);cu=i(Ew,"torch.float32"),Ew.forEach(t),mu=i(wo,` format. This can be an issue if one tries to
load a model whose weights are in fp16, since it\u2019d require twice as much memory. To overcome this limitation, you can
either explicitly pass the desired `),Gs=a(wo,"CODE",{});var jw=n(Gs);pu=i(jw,"dtype"),jw.forEach(t),hu=i(wo," using "),Ys=a(wo,"CODE",{});var Fw=n(Ys);fu=i(Fw,"torch_dtype"),Fw.forEach(t),uu=i(wo," argument:"),wo.forEach(t),Td=d(o),g(rr.$$.fragment,o),kd=d(o),ye=a(o,"P",{});var mn=n(ye);gu=i(mn,"or, if you want the model to always load in the most optimal memory pattern, you can use the special value "),Js=a(mn,"CODE",{});var Dw=n(Js);_u=i(Dw,'"auto"'),Dw.forEach(t),bu=i(mn,`,
and then `),Ks=a(mn,"CODE",{});var qw=n(Ks);vu=i(qw,"dtype"),qw.forEach(t),yu=i(mn," will be automatically derived from the model\u2019s weights:"),mn.forEach(t),Pd=d(o),g(ar.$$.fragment,o),Md=d(o),Mt=a(o,"P",{});var pc=n(Mt);wu=i(pc,"Models instantiated from scratch can also be told which "),Zs=a(pc,"CODE",{});var Aw=n(Zs);$u=i(Aw,"dtype"),Aw.forEach(t),xu=i(pc," to use with:"),pc.forEach(t),Ed=d(o),g(nr.$$.fragment,o),jd=d(o),Va=a(o,"P",{});var zw=n(Va);Tu=i(zw,"Due to Pytorch design, this functionality is only available for floating dtypes."),zw.forEach(t),Fd=d(o),We=a(o,"H2",{class:!0});var hc=n(We);Et=a(hc,"A",{id:!0,class:!0,href:!0});var Cw=n(Et);Qs=a(Cw,"SPAN",{});var Iw=n(Qs);g(sr.$$.fragment,Iw),Iw.forEach(t),Cw.forEach(t),ku=d(hc),ei=a(hc,"SPAN",{});var Lw=n(ei);Pu=i(Lw,"ModuleUtilsMixin"),Lw.forEach(t),hc.forEach(t),Dd=d(o),C=a(o,"DIV",{class:!0});var L=n(C);g(ir.$$.fragment,L),Mu=d(L),lr=a(L,"P",{});var fc=n(lr);Eu=i(fc,"A few utilities for "),ti=a(fc,"CODE",{});var Uw=n(ti);ju=i(Uw,"torch.nn.Modules"),Uw.forEach(t),Fu=i(fc,", to be used as a mixin."),fc.forEach(t),Du=d(L),we=a(L,"DIV",{class:!0});var pn=n(we);g(dr.$$.fragment,pn),qu=d(pn),oi=a(pn,"P",{});var Ow=n(oi);Au=i(Ow,"Add a memory hook before and after each sub-module forward pass to record increase in memory consumption."),Ow.forEach(t),zu=d(pn),He=a(pn,"P",{});var hn=n(He);Cu=i(hn,"Increase in memory consumption is stored in a "),ri=a(hn,"CODE",{});var Nw=n(ri);Iu=i(Nw,"mem_rss_diff"),Nw.forEach(t),Lu=i(hn,` attribute for each module and can be reset to zero
with `),ai=a(hn,"CODE",{});var Bw=n(ai);Uu=i(Bw,"model.reset_memory_hooks_state()"),Bw.forEach(t),Ou=i(hn,"."),hn.forEach(t),pn.forEach(t),Nu=d(L),jt=a(L,"DIV",{class:!0});var uc=n(jt);g(cr.$$.fragment,uc),Bu=d(uc),ni=a(uc,"P",{});var Sw=n(ni);Su=i(Sw,"Helper function to estimate the total number of tokens from the model inputs."),Sw.forEach(t),uc.forEach(t),Xu=d(L),Ft=a(L,"DIV",{class:!0});var gc=n(Ft);g(mr.$$.fragment,gc),Vu=d(gc),Re=a(gc,"P",{});var fn=n(Re);Wu=i(fn,`Get number of (optionally, non-embeddings) floating-point operations for the forward and backward passes of a
batch with this transformer model. Default approximation neglects the quadratic dependency on the number of
tokens (valid if `),si=a(fn,"CODE",{});var Xw=n(si);Hu=i(Xw,"12 * d_model << sequence_length"),Xw.forEach(t),Ru=i(fn,") as laid out in "),pr=a(fn,"A",{href:!0,rel:!0});var Vw=n(pr);Gu=i(Vw,`this
paper`),Vw.forEach(t),Yu=i(fn,` section 2.1. Should be overridden for transformers with parameter
re-use e.g. Albert or Universal Transformers, or if doing long-range modeling with very high sequence lengths.`),fn.forEach(t),gc.forEach(t),Ju=d(L),Dt=a(L,"DIV",{class:!0});var _c=n(Dt);g(hr.$$.fragment,_c),Ku=d(_c),ii=a(_c,"P",{});var Ww=n(ii);Zu=i(Ww,"Makes broadcastable attention and causal masks so that future and masked tokens are ignored."),Ww.forEach(t),_c.forEach(t),Qu=d(L),qt=a(L,"DIV",{class:!0});var bc=n(qt);g(fr.$$.fragment,bc),eg=d(bc),li=a(bc,"P",{});var Hw=n(li);tg=i(Hw,"Prepare the head mask if needed."),Hw.forEach(t),bc.forEach(t),og=d(L),At=a(L,"DIV",{class:!0});var vc=n(At);g(ur.$$.fragment,vc),rg=d(vc),di=a(vc,"P",{});var Rw=n(di);ag=i(Rw,"Invert an attention mask (e.g., switches 0. and 1.)."),Rw.forEach(t),vc.forEach(t),ng=d(L),zt=a(L,"DIV",{class:!0});var yc=n(zt);g(gr.$$.fragment,yc),sg=d(yc),ci=a(yc,"P",{});var Gw=n(ci);ig=i(Gw,"Get number of (optionally, trainable or non-embeddings) parameters in the module."),Gw.forEach(t),yc.forEach(t),lg=d(L),Ct=a(L,"DIV",{class:!0});var wc=n(Ct);g(_r.$$.fragment,wc),dg=d(wc),Ge=a(wc,"P",{});var un=n(Ge);cg=i(un,"Reset the "),mi=a(un,"CODE",{});var Yw=n(mi);mg=i(Yw,"mem_rss_diff"),Yw.forEach(t),pg=i(un," attribute of each module (see "),Wa=a(un,"A",{href:!0});var Jw=n(Wa);hg=i(Jw,"add_memory_hooks()"),Jw.forEach(t),fg=i(un,")."),un.forEach(t),wc.forEach(t),L.forEach(t),qd=d(o),Ye=a(o,"H2",{class:!0});var $c=n(Ye);It=a($c,"A",{id:!0,class:!0,href:!0});var Kw=n(It);pi=a(Kw,"SPAN",{});var Zw=n(pi);g(br.$$.fragment,Zw),Zw.forEach(t),Kw.forEach(t),ug=d($c),hi=a($c,"SPAN",{});var Qw=n(hi);gg=i(Qw,"TFPreTrainedModel"),Qw.forEach(t),$c.forEach(t),Ad=d(o),M=a(o,"DIV",{class:!0});var E=n(M);g(vr.$$.fragment,E),_g=d(E),fi=a(E,"P",{});var e$=n(fi);bg=i(e$,"Base class for all TF models."),e$.forEach(t),vg=d(E),Ha=a(E,"P",{});var Gy=n(Ha);Ra=a(Gy,"A",{href:!0});var t$=n(Ra);yg=i(t$,"TFPreTrainedModel"),t$.forEach(t),wg=i(Gy,` takes care of storing the configuration of the models and handles methods for loading,
downloading and saving models as well as a few methods common to all models to:`),Gy.forEach(t),$g=d(E),yr=a(E,"UL",{});var xc=n(yr);ui=a(xc,"LI",{});var o$=n(ui);xg=i(o$,"resize the input embeddings,"),o$.forEach(t),Tg=d(xc),gi=a(xc,"LI",{});var r$=n(gi);kg=i(r$,"prune heads in the self-attention heads."),r$.forEach(t),xc.forEach(t),Pg=d(E),_i=a(E,"P",{});var a$=n(_i);Mg=i(a$,"Class attributes (overridden by derived classes):"),a$.forEach(t),Eg=d(E),Je=a(E,"UL",{});var gn=n(Je);$e=a(gn,"LI",{});var Ta=n($e);bi=a(Ta,"STRONG",{});var n$=n(bi);jg=i(n$,"config_class"),n$.forEach(t),Fg=i(Ta," ("),Ga=a(Ta,"A",{href:!0});var s$=n(Ga);Dg=i(s$,"PretrainedConfig"),s$.forEach(t),qg=i(Ta,") \u2014 A subclass of "),Ya=a(Ta,"A",{href:!0});var i$=n(Ya);Ag=i(i$,"PretrainedConfig"),i$.forEach(t),zg=i(Ta,` to use as configuration class
for this model architecture.`),Ta.forEach(t),Cg=d(gn),Lt=a(gn,"LI",{});var Ql=n(Lt);vi=a(Ql,"STRONG",{});var l$=n(vi);Ig=i(l$,"base_model_prefix"),l$.forEach(t),Lg=i(Ql," ("),yi=a(Ql,"CODE",{});var d$=n(yi);Ug=i(d$,"str"),d$.forEach(t),Og=i(Ql,`) \u2014 A string indicating the attribute associated to the base model in derived
classes of the same architecture adding modules on top of the base model.`),Ql.forEach(t),Ng=d(gn),X=a(gn,"LI",{});var de=n(X);wi=a(de,"STRONG",{});var c$=n(wi);Bg=i(c$,"main_input_name"),c$.forEach(t),Sg=i(de," ("),$i=a(de,"CODE",{});var m$=n($i);Xg=i(m$,"str"),m$.forEach(t),Vg=i(de,") \u2014 The name of the principal input to the model (often "),xi=a(de,"CODE",{});var p$=n(xi);Wg=i(p$,"input_ids"),p$.forEach(t),Hg=i(de,` for NLP
models, `),Ti=a(de,"CODE",{});var h$=n(Ti);Rg=i(h$,"pixel_values"),h$.forEach(t),Gg=i(de," for vision models and "),ki=a(de,"CODE",{});var f$=n(ki);Yg=i(f$,"input_values"),f$.forEach(t),Jg=i(de," for speech models)."),de.forEach(t),gn.forEach(t),Kg=d(E),xe=a(E,"DIV",{class:!0});var _n=n(xe);g(wr.$$.fragment,_n),Zg=d(_n),$r=a(_n,"P",{});var Tc=n($r);Qg=i(Tc,`Upload the model checkpoint to the \u{1F917} Model Hub while synchronizing a local clone of the repo in
`),Pi=a(Tc,"CODE",{});var u$=n(Pi);e_=i(u$,"repo_path_or_name"),u$.forEach(t),t_=i(Tc,"."),Tc.forEach(t),o_=d(_n),g(Ut.$$.fragment,_n),_n.forEach(t),r_=d(E),Ot=a(E,"DIV",{class:!0});var kc=n(Ot);g(xr.$$.fragment,kc),a_=d(kc),Mi=a(kc,"P",{});var g$=n(Mi);n_=i(g$,`This is a thin wrapper that sets the model\u2019s loss output head as the loss if the user does not specify a loss
function themselves.`),g$.forEach(t),kc.forEach(t),s_=d(E),N=a(E,"DIV",{class:!0});var oe=n(N);g(Tr.$$.fragment,oe),i_=d(oe),Ei=a(oe,"P",{});var _$=n(Ei);l_=i(_$,"Instantiate a pretrained TF 2.0 model from a pre-trained model configuration."),_$.forEach(t),d_=d(oe),kr=a(oe,"P",{});var Pc=n(kr);c_=i(Pc,"The warning "),ji=a(Pc,"EM",{});var b$=n(ji);m_=i(b$,"Weights from XXX not initialized from pretrained model"),b$.forEach(t),p_=i(Pc,` means that the weights of XXX do not come
pretrained with the rest of the model. It is up to you to train those weights with a downstream fine-tuning
task.`),Pc.forEach(t),h_=d(oe),Pr=a(oe,"P",{});var Mc=n(Pr);f_=i(Mc,"The warning "),Fi=a(Mc,"EM",{});var v$=n(Fi);u_=i(v$,"Weights from XXX not used in YYY"),v$.forEach(t),g_=i(Mc,` means that the layer XXX is not used by YYY, therefore those
weights are discarded.`),Mc.forEach(t),__=d(oe),g(Nt.$$.fragment,oe),b_=d(oe),g(Bt.$$.fragment,oe),oe.forEach(t),v_=d(E),St=a(E,"DIV",{class:!0});var Ec=n(St);g(Mr.$$.fragment,Ec),y_=d(Ec),Di=a(Ec,"P",{});var y$=n(Di);w_=i(y$,"Dict of bias attached to an LM head. The key represents the name of the bias attribute."),y$.forEach(t),Ec.forEach(t),$_=d(E),Xt=a(E,"DIV",{class:!0});var jc=n(Xt);g(Er.$$.fragment,jc),x_=d(jc),qi=a(jc,"P",{});var w$=n(qi);T_=i(w$,"Returns the model\u2019s input embeddings layer."),w$.forEach(t),jc.forEach(t),k_=d(E),Vt=a(E,"DIV",{class:!0});var Fc=n(Vt);g(jr.$$.fragment,Fc),P_=d(Fc),Ai=a(Fc,"P",{});var $$=n(Ai);M_=i($$,"The LM Head layer. This method must be overwritten by all the models that have a lm head."),$$.forEach(t),Fc.forEach(t),E_=d(E),Wt=a(E,"DIV",{class:!0});var Dc=n(Wt);g(Fr.$$.fragment,Dc),j_=d(Dc),zi=a(Dc,"P",{});var x$=n(zi);F_=i(x$,"Returns the model\u2019s output embeddings"),x$.forEach(t),Dc.forEach(t),D_=d(E),Ht=a(E,"DIV",{class:!0});var qc=n(Ht);g(Dr.$$.fragment,qc),q_=d(qc),Ci=a(qc,"P",{});var T$=n(Ci);A_=i(T$,`Get the layer that handles a bias attribute in case the model has an LM head with weights tied to the
embeddings`),T$.forEach(t),qc.forEach(t),z_=d(E),Rt=a(E,"DIV",{class:!0});var Ac=n(Rt);g(qr.$$.fragment,Ac),C_=d(Ac),Ii=a(Ac,"P",{});var k$=n(Ii);I_=i(k$,"Get the concatenated _prefix name of the bias from the model name to the parent layer"),k$.forEach(t),Ac.forEach(t),L_=d(E),Gt=a(E,"DIV",{class:!0});var zc=n(Gt);g(Ar.$$.fragment,zc),U_=d(zc),Li=a(zc,"P",{});var P$=n(Li);O_=i(P$,`Loads a saved checkpoint (model weights and optimizer state) from a repo. Returns the current epoch count when
the checkpoint was made.`),P$.forEach(t),zc.forEach(t),N_=d(E),Yt=a(E,"DIV",{class:!0});var Cc=n(Yt);g(zr.$$.fragment,Cc),B_=d(Cc),Ui=a(Cc,"P",{});var M$=n(Ui);S_=i(M$,"Prunes heads of the base model."),M$.forEach(t),Cc.forEach(t),X_=d(E),Te=a(E,"DIV",{class:!0});var bn=n(Te);g(Cr.$$.fragment,bn),V_=d(bn),Ir=a(bn,"P",{});var Ic=n(Ir);W_=i(Ic,"Resizes input token embeddings matrix of the model if "),Oi=a(Ic,"CODE",{});var E$=n(Oi);H_=i(E$,"new_num_tokens != config.vocab_size"),E$.forEach(t),R_=i(Ic,"."),Ic.forEach(t),G_=d(bn),Lr=a(bn,"P",{});var Lc=n(Lr);Y_=i(Lc,"Takes care of tying weights embeddings afterwards if the model class has a "),Ni=a(Lc,"CODE",{});var j$=n(Ni);J_=i(j$,"tie_weights()"),j$.forEach(t),K_=i(Lc," method."),Lc.forEach(t),bn.forEach(t),Z_=d(E),Jt=a(E,"DIV",{class:!0});var Uc=n(Jt);g(Ur.$$.fragment,Uc),Q_=d(Uc),Or=a(Uc,"P",{});var Oc=n(Or);eb=i(Oc,`Save a model and its configuration file to a directory, so that it can be re-loaded using the
`),Ja=a(Oc,"A",{href:!0});var F$=n(Ja);tb=i(F$,"from_pretrained()"),F$.forEach(t),ob=i(Oc," class method."),Oc.forEach(t),Uc.forEach(t),rb=d(E),Kt=a(E,"DIV",{class:!0});var Nc=n(Kt);g(Nr.$$.fragment,Nc),ab=d(Nc),Bi=a(Nc,"P",{});var D$=n(Bi);nb=i(D$,"Method used for serving the model."),D$.forEach(t),Nc.forEach(t),sb=d(E),Zt=a(E,"DIV",{class:!0});var Bc=n(Zt);g(Br.$$.fragment,Bc),ib=d(Bc),Si=a(Bc,"P",{});var q$=n(Si);lb=i(q$,"Prepare the output of the saved model. Each model must implement this function."),q$.forEach(t),Bc.forEach(t),db=d(E),Qt=a(E,"DIV",{class:!0});var Sc=n(Qt);g(Sr.$$.fragment,Sc),cb=d(Sc),Xi=a(Sc,"P",{});var A$=n(Xi);mb=i(A$,"Set all the bias in the LM head."),A$.forEach(t),Sc.forEach(t),pb=d(E),eo=a(E,"DIV",{class:!0});var Xc=n(eo);g(Xr.$$.fragment,Xc),hb=d(Xc),Vi=a(Xc,"P",{});var z$=n(Vi);fb=i(z$,"Set model\u2019s input embeddings"),z$.forEach(t),Xc.forEach(t),ub=d(E),to=a(E,"DIV",{class:!0});var Vc=n(to);g(Vr.$$.fragment,Vc),gb=d(Vc),Wi=a(Vc,"P",{});var C$=n(Wi);_b=i(C$,"Set model\u2019s output embeddings"),C$.forEach(t),Vc.forEach(t),bb=d(E),oo=a(E,"DIV",{class:!0});var Wc=n(oo);g(Wr.$$.fragment,Wc),vb=d(Wc),Hr=a(Wc,"P",{});var Hc=n(Hr);yb=i(Hc,"A modification of Keras\u2019s default "),Hi=a(Hc,"CODE",{});var I$=n(Hi);wb=i(I$,"train_step"),I$.forEach(t),$b=i(Hc,` that correctly handles matching outputs to labels for our models
and supports directly training on the loss output head. In addition, it ensures input keys are copied to the
labels where appropriate. It will also copy label keys into the input dict when using the dummy loss, to ensure
that they are available to the model during the forward pass.`),Hc.forEach(t),Wc.forEach(t),xb=d(E),ro=a(E,"DIV",{class:!0});var Rc=n(ro);g(Rr.$$.fragment,Rc),Tb=d(Rc),Gr=a(Rc,"P",{});var Gc=n(Gr);kb=i(Gc,"A modification of Keras\u2019s default "),Ri=a(Gc,"CODE",{});var L$=n(Ri);Pb=i(L$,"train_step"),L$.forEach(t),Mb=i(Gc,` that correctly handles matching outputs to labels for our models
and supports directly training on the loss output head. In addition, it ensures input keys are copied to the
labels where appropriate. It will also copy label keys into the input dict when using the dummy loss, to ensure
that they are available to the model during the forward pass.`),Gc.forEach(t),Rc.forEach(t),E.forEach(t),zd=d(o),Ke=a(o,"H2",{class:!0});var Yc=n(Ke);ao=a(Yc,"A",{id:!0,class:!0,href:!0});var U$=n(ao);Gi=a(U$,"SPAN",{});var O$=n(Gi);g(Yr.$$.fragment,O$),O$.forEach(t),U$.forEach(t),Eb=d(Yc),Yi=a(Yc,"SPAN",{});var N$=n(Yi);jb=i(N$,"TFModelUtilsMixin"),N$.forEach(t),Yc.forEach(t),Cd=d(o),ae=a(o,"DIV",{class:!0});var vn=n(ae);g(Jr.$$.fragment,vn),Fb=d(vn),Kr=a(vn,"P",{});var Jc=n(Kr);Db=i(Jc,"A few utilities for "),Ji=a(Jc,"CODE",{});var B$=n(Ji);qb=i(B$,"tf.keras.Model"),B$.forEach(t),Ab=i(Jc,", to be used as a mixin."),Jc.forEach(t),zb=d(vn),no=a(vn,"DIV",{class:!0});var Kc=n(no);g(Zr.$$.fragment,Kc),Cb=d(Kc),Ki=a(Kc,"P",{});var S$=n(Ki);Ib=i(S$,"Get the number of (optionally, trainable) parameters in the model."),S$.forEach(t),Kc.forEach(t),vn.forEach(t),Id=d(o),Ze=a(o,"H2",{class:!0});var Zc=n(Ze);so=a(Zc,"A",{id:!0,class:!0,href:!0});var X$=n(so);Zi=a(X$,"SPAN",{});var V$=n(Zi);g(Qr.$$.fragment,V$),V$.forEach(t),X$.forEach(t),Lb=d(Zc),Qi=a(Zc,"SPAN",{});var W$=n(Qi);Ub=i(W$,"FlaxPreTrainedModel"),W$.forEach(t),Zc.forEach(t),Ld=d(o),A=a(o,"DIV",{class:!0});var I=n(A);g(ea.$$.fragment,I),Ob=d(I),el=a(I,"P",{});var H$=n(el);Nb=i(H$,"Base class for all models."),H$.forEach(t),Bb=d(I),Ka=a(I,"P",{});var Yy=n(Ka);Za=a(Yy,"A",{href:!0});var R$=n(Za);Sb=i(R$,"FlaxPreTrainedModel"),R$.forEach(t),Xb=i(Yy,` takes care of storing the configuration of the models and handles methods for loading,
downloading and saving models.`),Yy.forEach(t),Vb=d(I),tl=a(I,"P",{});var G$=n(tl);Wb=i(G$,"Class attributes (overridden by derived classes):"),G$.forEach(t),Hb=d(I),Qe=a(I,"UL",{});var yn=n(Qe);ke=a(yn,"LI",{});var ka=n(ke);ol=a(ka,"STRONG",{});var Y$=n(ol);Rb=i(Y$,"config_class"),Y$.forEach(t),Gb=i(ka," ("),Qa=a(ka,"A",{href:!0});var J$=n(Qa);Yb=i(J$,"PretrainedConfig"),J$.forEach(t),Jb=i(ka,") \u2014 A subclass of "),en=a(ka,"A",{href:!0});var K$=n(en);Kb=i(K$,"PretrainedConfig"),K$.forEach(t),Zb=i(ka,` to use as configuration class
for this model architecture.`),ka.forEach(t),Qb=d(yn),io=a(yn,"LI",{});var ed=n(io);rl=a(ed,"STRONG",{});var Z$=n(rl);ev=i(Z$,"base_model_prefix"),Z$.forEach(t),tv=i(ed," ("),al=a(ed,"CODE",{});var Q$=n(al);ov=i(Q$,"str"),Q$.forEach(t),rv=i(ed,`) \u2014 A string indicating the attribute associated to the base model in derived
classes of the same architecture adding modules on top of the base model.`),ed.forEach(t),av=d(yn),V=a(yn,"LI",{});var ce=n(V);nl=a(ce,"STRONG",{});var e2=n(nl);nv=i(e2,"main_input_name"),e2.forEach(t),sv=i(ce," ("),sl=a(ce,"CODE",{});var t2=n(sl);iv=i(t2,"str"),t2.forEach(t),lv=i(ce,") \u2014 The name of the principal input to the model (often "),il=a(ce,"CODE",{});var o2=n(il);dv=i(o2,"input_ids"),o2.forEach(t),cv=i(ce,` for NLP
models, `),ll=a(ce,"CODE",{});var r2=n(ll);mv=i(r2,"pixel_values"),r2.forEach(t),pv=i(ce," for vision models and "),dl=a(ce,"CODE",{});var a2=n(dl);hv=i(a2,"input_values"),a2.forEach(t),fv=i(ce," for speech models)."),ce.forEach(t),yn.forEach(t),uv=d(I),Pe=a(I,"DIV",{class:!0});var wn=n(Pe);g(ta.$$.fragment,wn),gv=d(wn),oa=a(wn,"P",{});var Qc=n(oa);_v=i(Qc,`Upload the model checkpoint to the \u{1F917} Model Hub while synchronizing a local clone of the repo in
`),cl=a(Qc,"CODE",{});var n2=n(cl);bv=i(n2,"repo_path_or_name"),n2.forEach(t),vv=i(Qc,"."),Qc.forEach(t),yv=d(wn),g(lo.$$.fragment,wn),wn.forEach(t),wv=d(I),W=a(I,"DIV",{class:!0});var qe=n(W);g(ra.$$.fragment,qe),$v=d(qe),ml=a(qe,"P",{});var s2=n(ml);xv=i(s2,"Instantiate a pretrained flax model from a pre-trained model configuration."),s2.forEach(t),Tv=d(qe),aa=a(qe,"P",{});var em=n(aa);kv=i(em,"The warning "),pl=a(em,"EM",{});var i2=n(pl);Pv=i(i2,"Weights from XXX not initialized from pretrained model"),i2.forEach(t),Mv=i(em,` means that the weights of XXX do not come
pretrained with the rest of the model. It is up to you to train those weights with a downstream fine-tuning
task.`),em.forEach(t),Ev=d(qe),na=a(qe,"P",{});var tm=n(na);jv=i(tm,"The warning "),hl=a(tm,"EM",{});var l2=n(hl);Fv=i(l2,"Weights from XXX not used in YYY"),l2.forEach(t),Dv=i(tm,` means that the layer XXX is not used by YYY, therefore those
weights are discarded.`),tm.forEach(t),qv=d(qe),g(co.$$.fragment,qe),qe.forEach(t),Av=d(I),Me=a(I,"DIV",{class:!0});var $n=n(Me);g(sa.$$.fragment,$n),zv=d($n),fl=a($n,"P",{});var d2=n(fl);Cv=i(d2,`Register this class with a given auto class. This should only be used for custom models as the ones in the
library are already mapped with an auto class.`),d2.forEach(t),Iv=d($n),g(mo.$$.fragment,$n),$n.forEach(t),Lv=d(I),po=a(I,"DIV",{class:!0});var om=n(po);g(ia.$$.fragment,om),Uv=d(om),la=a(om,"P",{});var rm=n(la);Ov=i(rm,`Save a model and its configuration file to a directory, so that it can be re-loaded using the
`),ul=a(rm,"CODE",{});var c2=n(ul);Nv=i(c2,"[from_pretrained()](/docs/transformers/pr_17548/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained)"),c2.forEach(t),Bv=i(rm," class method"),rm.forEach(t),om.forEach(t),Sv=d(I),ee=a(I,"DIV",{class:!0});var $o=n(ee);g(da.$$.fragment,$o),Xv=d($o),G=a($o,"P",{});var Ae=n(G);Vv=i(Ae,"Cast the floating-point "),gl=a(Ae,"CODE",{});var m2=n(gl);Wv=i(m2,"params"),m2.forEach(t),Hv=i(Ae," to "),_l=a(Ae,"CODE",{});var p2=n(_l);Rv=i(p2,"jax.numpy.bfloat16"),p2.forEach(t),Gv=i(Ae,". This returns a new "),bl=a(Ae,"CODE",{});var h2=n(bl);Yv=i(h2,"params"),h2.forEach(t),Jv=i(Ae,` tree and does not cast
the `),vl=a(Ae,"CODE",{});var f2=n(vl);Kv=i(f2,"params"),f2.forEach(t),Zv=i(Ae," in place."),Ae.forEach(t),Qv=d($o),yl=a($o,"P",{});var u2=n(yl);ey=i(u2,`This method can be used on TPU to explicitly convert the model parameters to bfloat16 precision to do full
half-precision training or to save weights in bfloat16 for inference in order to save memory and improve speed.`),u2.forEach(t),ty=d($o),g(ho.$$.fragment,$o),$o.forEach(t),oy=d(I),te=a(I,"DIV",{class:!0});var xo=n(te);g(ca.$$.fragment,xo),ry=d(xo),Y=a(xo,"P",{});var ze=n(Y);ay=i(ze,"Cast the floating-point "),wl=a(ze,"CODE",{});var g2=n(wl);ny=i(g2,"parmas"),g2.forEach(t),sy=i(ze," to "),$l=a(ze,"CODE",{});var _2=n($l);iy=i(_2,"jax.numpy.float16"),_2.forEach(t),ly=i(ze,". This returns a new "),xl=a(ze,"CODE",{});var b2=n(xl);dy=i(b2,"params"),b2.forEach(t),cy=i(ze,` tree and does not cast the
`),Tl=a(ze,"CODE",{});var v2=n(Tl);my=i(v2,"params"),v2.forEach(t),py=i(ze," in place."),ze.forEach(t),hy=d(xo),kl=a(xo,"P",{});var y2=n(kl);fy=i(y2,`This method can be used on GPU to explicitly convert the model parameters to float16 precision to do full
half-precision training or to save weights in float16 for inference in order to save memory and improve speed.`),y2.forEach(t),uy=d(xo),g(fo.$$.fragment,xo),xo.forEach(t),gy=d(I),Ee=a(I,"DIV",{class:!0});var xn=n(Ee);g(ma.$$.fragment,xn),_y=d(xn),J=a(xn,"P",{});var Ce=n(J);by=i(Ce,"Cast the floating-point "),Pl=a(Ce,"CODE",{});var w2=n(Pl);vy=i(w2,"parmas"),w2.forEach(t),yy=i(Ce," to "),Ml=a(Ce,"CODE",{});var $2=n(Ml);wy=i($2,"jax.numpy.float32"),$2.forEach(t),$y=i(Ce,`. This method can be used to explicitly convert the
model parameters to fp32 precision. This returns a new `),El=a(Ce,"CODE",{});var x2=n(El);xy=i(x2,"params"),x2.forEach(t),Ty=i(Ce," tree and does not cast the "),jl=a(Ce,"CODE",{});var T2=n(jl);ky=i(T2,"params"),T2.forEach(t),Py=i(Ce," in place."),Ce.forEach(t),My=d(xn),g(uo.$$.fragment,xn),xn.forEach(t),I.forEach(t),Ud=d(o),et=a(o,"H2",{class:!0});var am=n(et);go=a(am,"A",{id:!0,class:!0,href:!0});var k2=n(go);Fl=a(k2,"SPAN",{});var P2=n(Fl);g(pa.$$.fragment,P2),P2.forEach(t),k2.forEach(t),Ey=d(am),Dl=a(am,"SPAN",{});var M2=n(Dl);jy=i(M2,"Pushing to the Hub"),M2.forEach(t),am.forEach(t),Od=d(o),ne=a(o,"DIV",{class:!0});var Tn=n(ne);g(ha.$$.fragment,Tn),Fy=d(Tn),ql=a(Tn,"P",{});var E2=n(ql);Dy=i(E2,"A Mixin containing the functionality to push a model or tokenizer to the hub."),E2.forEach(t),qy=d(Tn),je=a(Tn,"DIV",{class:!0});var kn=n(je);g(fa.$$.fragment,kn),Ay=d(kn),ua=a(kn,"P",{});var nm=n(ua);zy=i(nm,`Upload the {object_files} to the \u{1F917} Model Hub while synchronizing a local clone of the repo in
`),Al=a(nm,"CODE",{});var j2=n(Al);Cy=i(j2,"repo_path_or_name"),j2.forEach(t),Iy=i(nm,"."),nm.forEach(t),Ly=d(kn),g(_o.$$.fragment,kn),kn.forEach(t),Tn.forEach(t),Nd=d(o),tt=a(o,"H2",{class:!0});var sm=n(tt);bo=a(sm,"A",{id:!0,class:!0,href:!0});var F2=n(bo);zl=a(F2,"SPAN",{});var D2=n(zl);g(ga.$$.fragment,D2),D2.forEach(t),F2.forEach(t),Uy=d(sm),Cl=a(sm,"SPAN",{});var q2=n(Cl);Oy=i(q2,"Sharded checkpoints"),q2.forEach(t),sm.forEach(t),Bd=d(o),se=a(o,"DIV",{class:!0});var Pn=n(se);g(_a.$$.fragment,Pn),Ny=d(Pn),ba=a(Pn,"P",{});var im=n(ba);By=i(im,`This is the same as
`),va=a(im,"A",{href:!0,rel:!0});var A2=n(va);Il=a(A2,"CODE",{});var z2=n(Il);Sy=i(z2,"torch.nn.Module.load_state_dict"),z2.forEach(t),A2.forEach(t),Xy=i(im,`
but for a sharded checkpoint.`),im.forEach(t),Vy=d(Pn),Ll=a(Pn,"P",{});var C2=n(Ll);Wy=i(C2,`This load is performed efficiently: each checkpoint shard is loaded one by one in RAM and deleted after being
loaded in the model.`),C2.forEach(t),Pn.forEach(t),this.h()},h(){m(p,"name","hf:doc:metadata"),m(p,"content",JSON.stringify(rx)),m(f,"id","models"),m(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(f,"href","#models"),m($,"class","relative group"),m(Pa,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel"),m(Ma,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.TFPreTrainedModel"),m(Ea,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.FlaxPreTrainedModel"),m(ja,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel"),m(Fa,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.TFPreTrainedModel"),m(Da,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.modeling_utils.ModuleUtilsMixin"),m(qa,"href","/docs/transformers/pr_17548/en/main_classes/text_generation#transformers.generation_utils.GenerationMixin"),m(Aa,"href","/docs/transformers/pr_17548/en/main_classes/text_generation#transformers.generation_tf_utils.TFGenerationMixin"),m(za,"href","/docs/transformers/pr_17548/en/main_classes/text_generation#transformers.generation_flax_utils.FlaxGenerationMixin"),m(rt,"id","transformers.PreTrainedModel"),m(rt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(rt,"href","#transformers.PreTrainedModel"),m(Ne,"class","relative group"),m(Ia,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel"),m(La,"href","/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig"),m(Ua,"href","/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig"),m(Oa,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel"),m(he,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ht,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ft,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ut,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(gt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(_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(ge,"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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(vt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(yt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(be,"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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ba,"id","from_pretrained-torch-dtype"),m(wt,"id","large-model-loading"),m(wt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(wt,"href","#large-model-loading"),m(Xe,"class","relative group"),m(Sa,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.PreTrainedModel.from_pretrained"),m(Jo,"href","https://huggingface.co/docs/accelerate/big_modeling"),m(Jo,"rel","nofollow"),m(Pt,"id","model-instantiation-dtype"),m(Pt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Pt,"href","#model-instantiation-dtype"),m(Ve,"class","relative group"),m(Et,"id","transformers.modeling_utils.ModuleUtilsMixin"),m(Et,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Et,"href","#transformers.modeling_utils.ModuleUtilsMixin"),m(We,"class","relative group"),m(we,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(jt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(pr,"href","https://arxiv.org/pdf/2001.08361.pdf"),m(pr,"rel","nofollow"),m(Ft,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Dt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(qt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(At,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(zt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Wa,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.modeling_utils.ModuleUtilsMixin.add_memory_hooks"),m(Ct,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(It,"id","transformers.TFPreTrainedModel"),m(It,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(It,"href","#transformers.TFPreTrainedModel"),m(Ye,"class","relative group"),m(Ra,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.TFPreTrainedModel"),m(Ga,"href","/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig"),m(Ya,"href","/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig"),m(xe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ot,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(St,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Xt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Vt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Wt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ht,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Rt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Gt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Yt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ja,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained"),m(Jt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Kt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Zt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Qt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(eo,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(to,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(oo,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ro,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ao,"id","transformers.modeling_tf_utils.TFModelUtilsMixin"),m(ao,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ao,"href","#transformers.modeling_tf_utils.TFModelUtilsMixin"),m(Ke,"class","relative group"),m(no,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(so,"id","transformers.FlaxPreTrainedModel"),m(so,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(so,"href","#transformers.FlaxPreTrainedModel"),m(Ze,"class","relative group"),m(Za,"href","/docs/transformers/pr_17548/en/main_classes/model#transformers.FlaxPreTrainedModel"),m(Qa,"href","/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig"),m(en,"href","/docs/transformers/pr_17548/en/main_classes/configuration#transformers.PretrainedConfig"),m(Pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(po,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(go,"id","transformers.utils.PushToHubMixin"),m(go,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(go,"href","#transformers.utils.PushToHubMixin"),m(et,"class","relative group"),m(je,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(bo,"id","transformers.modeling_utils.load_sharded_checkpoint"),m(bo,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(bo,"href","#transformers.modeling_utils.load_sharded_checkpoint"),m(tt,"class","relative group"),m(va,"href","https://pytorch.org/docs/stable/generated/torch.nn.Module.html?highlight=load_state_dict#torch.nn.Module.load_state_dict"),m(va,"rel","nofollow"),m(se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,h){e(document.head,p),w(o,T,h),w(o,$,h),e($,f),e(f,k),_(c,k,null),e($,x),e($,re),e(re,lm),w(o,od,h),w(o,K,h),e(K,dm),e(K,Pa),e(Pa,cm),e(K,mm),e(K,Ma),e(Ma,pm),e(K,hm),e(K,Ea),e(Ea,fm),e(K,um),w(o,rd,h),w(o,Oe,h),e(Oe,ja),e(ja,gm),e(Oe,_m),e(Oe,Fa),e(Fa,bm),e(Oe,vm),w(o,ad,h),w(o,ot,h),e(ot,Mn),e(Mn,ym),e(ot,wm),e(ot,En),e(En,$m),w(o,nd,h),w(o,O,h),e(O,xm),e(O,Da),e(Da,Tm),e(O,km),e(O,jn),e(jn,Pm),e(O,Mm),e(O,qa),e(qa,Em),e(O,jm),e(O,Aa),e(Aa,Fm),e(O,Dm),e(O,za),e(za,qm),e(O,Am),w(o,sd,h),w(o,Ne,h),e(Ne,rt),e(rt,Fn),_(To,Fn,null),e(Ne,zm),e(Ne,Dn),e(Dn,Cm),w(o,id,h),w(o,j,h),_(ko,j,null),e(j,Im),e(j,qn),e(qn,Lm),e(j,Um),e(j,Ca),e(Ca,Ia),e(Ia,Om),e(Ca,Nm),e(j,Bm),e(j,Po),e(Po,An),e(An,Sm),e(Po,Xm),e(Po,zn),e(zn,Vm),e(j,Wm),e(j,Cn),e(Cn,Hm),e(j,Rm),e(j,H),e(H,In),e(In,me),e(me,Ln),e(Ln,Gm),e(me,Ym),e(me,La),e(La,Jm),e(me,Km),e(me,Ua),e(Ua,Zm),e(me,Qm),e(H,ep),e(H,Mo),e(Mo,pe),e(pe,Un),e(Un,tp),e(pe,op),e(pe,On),e(On,rp),e(pe,ap),e(pe,Nn),e(Nn,np),e(pe,sp),e(Mo,ip),e(Mo,Be),e(Be,at),e(at,Bn),e(Bn,lp),e(at,dp),e(at,Oa),e(Oa,cp),e(at,mp),e(Be,pp),e(Be,nt),e(nt,Sn),e(Sn,hp),e(nt,fp),e(nt,Xn),e(Xn,up),e(nt,gp),e(Be,_p),e(Be,st),e(st,Vn),e(Vn,bp),e(st,vp),e(st,Wn),e(Wn,yp),e(st,wp),e(H,$p),e(H,Hn),e(Hn,it),e(it,Rn),e(Rn,xp),e(it,Tp),e(it,Gn),e(Gn,kp),e(it,Pp),e(H,Mp),e(H,Yn),e(Yn,lt),e(lt,Jn),e(Jn,Ep),e(lt,jp),e(lt,Kn),e(Kn,Fp),e(lt,Dp),e(H,qp),e(H,Zn),e(Zn,S),e(S,Qn),e(Qn,Ap),e(S,zp),e(S,es),e(es,Cp),e(S,Ip),e(S,ts),e(ts,Lp),e(S,Up),e(S,os),e(os,Op),e(S,Np),e(S,rs),e(rs,Bp),e(S,Sp),e(j,Xp),e(j,he),_(Eo,he,null),e(he,Vp),e(he,jo),e(jo,Wp),e(jo,as),e(as,Hp),e(jo,Rp),e(he,Gp),_(dt,he,null),e(j,Yp),e(j,q),_(Fo,q,null),e(q,Jp),e(q,ns),e(ns,Kp),e(q,Zp),e(q,Se),e(Se,Qp),e(Se,ss),e(ss,eh),e(Se,th),e(Se,is),e(is,oh),e(Se,rh),e(q,ah),e(q,Do),e(Do,nh),e(Do,ls),e(ls,sh),e(Do,ih),e(q,lh),e(q,qo),e(qo,dh),e(qo,ds),e(ds,ch),e(qo,mh),e(q,ph),_(ct,q,null),e(q,hh),_(mt,q,null),e(q,fh),_(pt,q,null),e(q,uh),e(q,cs),e(cs,Na),e(Na,ms),e(ms,gh),e(Na,_h),e(q,bh),e(q,ps),e(ps,vh),e(q,yh),e(q,hs),e(hs,wh),e(q,$h),e(q,R),e(R,fs),e(fs,xh),e(R,Th),e(R,us),e(us,kh),e(R,Ph),e(R,gs),e(gs,Mh),e(R,Eh),e(R,_s),e(_s,jh),e(R,Fh),e(R,bs),e(bs,Dh),e(q,qh),e(q,vs),e(vs,Ah),e(j,zh),e(j,ht),_(Ao,ht,null),e(ht,Ch),e(ht,ys),e(ys,Ih),e(j,Lh),e(j,ft),_(zo,ft,null),e(ft,Uh),e(ft,ws),e(ws,Oh),e(j,Nh),e(j,fe),_(Co,fe,null),e(fe,Bh),e(fe,$s),e($s,Sh),e(fe,Xh),e(fe,xs),e(xs,Vh),e(j,Wh),e(j,ue),_(Io,ue,null),e(ue,Hh),e(ue,Ts),e(Ts,Rh),e(ue,Gh),e(ue,ks),e(ks,Yh),e(j,Jh),e(j,ut),_(Lo,ut,null),e(ut,Kh),e(ut,Ps),e(Ps,Zh),e(j,Qh),e(j,gt),_(Uo,gt,null),e(gt,ef),e(gt,Ms),e(Ms,tf),e(j,of),e(j,_t),_(Oo,_t,null),e(_t,rf),e(_t,Es),e(Es,af),e(j,nf),e(j,ge),_(No,ge,null),e(ge,sf),e(ge,js),e(js,lf),e(ge,df),_(bt,ge,null),e(j,cf),e(j,_e),_(Bo,_e,null),e(_e,mf),e(_e,So),e(So,pf),e(So,Fs),e(Fs,hf),e(So,ff),e(_e,uf),e(_e,Xo),e(Xo,gf),e(Xo,Ds),e(Ds,_f),e(Xo,bf),e(j,vf),e(j,vt),_(Vo,vt,null),e(vt,yf),e(vt,Wo),e(Wo,wf),e(Wo,qs),e(qs,$f),e(Wo,xf),e(j,Tf),e(j,yt),_(Ho,yt,null),e(yt,kf),e(yt,As),e(As,Pf),e(j,Mf),e(j,be),_(Ro,be,null),e(be,Ef),e(be,zs),e(zs,jf),e(be,Ff),e(be,Go),e(Go,Df),e(Go,Cs),e(Cs,qf),e(Go,Af),w(o,ld,h),w(o,Ba,h),w(o,dd,h),w(o,Xe,h),e(Xe,wt),e(wt,Is),_(Yo,Is,null),e(Xe,zf),e(Xe,Ls),e(Ls,Cf),w(o,cd,h),w(o,ve,h),e(ve,If),e(ve,Sa),e(Sa,Lf),e(ve,Uf),e(ve,Jo),e(Jo,Of),e(ve,Nf),w(o,md,h),w(o,$t,h),e($t,Bf),e($t,Us),e(Us,Sf),e($t,Xf),w(o,pd,h),_(Ko,o,h),w(o,hd,h),w(o,xt,h),e(xt,Vf),e(xt,Os),e(Os,Wf),e(xt,Hf),w(o,fd,h),w(o,Z,h),e(Z,Rf),e(Z,Ns),e(Ns,Gf),e(Z,Yf),e(Z,Bs),e(Bs,Jf),e(Z,Kf),e(Z,Ss),e(Ss,Zf),e(Z,Qf),w(o,ud,h),_(Zo,o,h),w(o,gd,h),w(o,Tt,h),e(Tt,eu),e(Tt,Xs),e(Xs,tu),e(Tt,ou),w(o,_d,h),_(Qo,o,h),w(o,bd,h),_(er,o,h),w(o,vd,h),w(o,Xa,h),e(Xa,ru),w(o,yd,h),_(tr,o,h),w(o,wd,h),w(o,kt,h),e(kt,au),e(kt,Vs),e(Vs,nu),e(kt,su),w(o,$d,h),w(o,Ve,h),e(Ve,Pt),e(Pt,Ws),_(or,Ws,null),e(Ve,iu),e(Ve,Hs),e(Hs,lu),w(o,xd,h),w(o,Q,h),e(Q,du),e(Q,Rs),e(Rs,cu),e(Q,mu),e(Q,Gs),e(Gs,pu),e(Q,hu),e(Q,Ys),e(Ys,fu),e(Q,uu),w(o,Td,h),_(rr,o,h),w(o,kd,h),w(o,ye,h),e(ye,gu),e(ye,Js),e(Js,_u),e(ye,bu),e(ye,Ks),e(Ks,vu),e(ye,yu),w(o,Pd,h),_(ar,o,h),w(o,Md,h),w(o,Mt,h),e(Mt,wu),e(Mt,Zs),e(Zs,$u),e(Mt,xu),w(o,Ed,h),_(nr,o,h),w(o,jd,h),w(o,Va,h),e(Va,Tu),w(o,Fd,h),w(o,We,h),e(We,Et),e(Et,Qs),_(sr,Qs,null),e(We,ku),e(We,ei),e(ei,Pu),w(o,Dd,h),w(o,C,h),_(ir,C,null),e(C,Mu),e(C,lr),e(lr,Eu),e(lr,ti),e(ti,ju),e(lr,Fu),e(C,Du),e(C,we),_(dr,we,null),e(we,qu),e(we,oi),e(oi,Au),e(we,zu),e(we,He),e(He,Cu),e(He,ri),e(ri,Iu),e(He,Lu),e(He,ai),e(ai,Uu),e(He,Ou),e(C,Nu),e(C,jt),_(cr,jt,null),e(jt,Bu),e(jt,ni),e(ni,Su),e(C,Xu),e(C,Ft),_(mr,Ft,null),e(Ft,Vu),e(Ft,Re),e(Re,Wu),e(Re,si),e(si,Hu),e(Re,Ru),e(Re,pr),e(pr,Gu),e(Re,Yu),e(C,Ju),e(C,Dt),_(hr,Dt,null),e(Dt,Ku),e(Dt,ii),e(ii,Zu),e(C,Qu),e(C,qt),_(fr,qt,null),e(qt,eg),e(qt,li),e(li,tg),e(C,og),e(C,At),_(ur,At,null),e(At,rg),e(At,di),e(di,ag),e(C,ng),e(C,zt),_(gr,zt,null),e(zt,sg),e(zt,ci),e(ci,ig),e(C,lg),e(C,Ct),_(_r,Ct,null),e(Ct,dg),e(Ct,Ge),e(Ge,cg),e(Ge,mi),e(mi,mg),e(Ge,pg),e(Ge,Wa),e(Wa,hg),e(Ge,fg),w(o,qd,h),w(o,Ye,h),e(Ye,It),e(It,pi),_(br,pi,null),e(Ye,ug),e(Ye,hi),e(hi,gg),w(o,Ad,h),w(o,M,h),_(vr,M,null),e(M,_g),e(M,fi),e(fi,bg),e(M,vg),e(M,Ha),e(Ha,Ra),e(Ra,yg),e(Ha,wg),e(M,$g),e(M,yr),e(yr,ui),e(ui,xg),e(yr,Tg),e(yr,gi),e(gi,kg),e(M,Pg),e(M,_i),e(_i,Mg),e(M,Eg),e(M,Je),e(Je,$e),e($e,bi),e(bi,jg),e($e,Fg),e($e,Ga),e(Ga,Dg),e($e,qg),e($e,Ya),e(Ya,Ag),e($e,zg),e(Je,Cg),e(Je,Lt),e(Lt,vi),e(vi,Ig),e(Lt,Lg),e(Lt,yi),e(yi,Ug),e(Lt,Og),e(Je,Ng),e(Je,X),e(X,wi),e(wi,Bg),e(X,Sg),e(X,$i),e($i,Xg),e(X,Vg),e(X,xi),e(xi,Wg),e(X,Hg),e(X,Ti),e(Ti,Rg),e(X,Gg),e(X,ki),e(ki,Yg),e(X,Jg),e(M,Kg),e(M,xe),_(wr,xe,null),e(xe,Zg),e(xe,$r),e($r,Qg),e($r,Pi),e(Pi,e_),e($r,t_),e(xe,o_),_(Ut,xe,null),e(M,r_),e(M,Ot),_(xr,Ot,null),e(Ot,a_),e(Ot,Mi),e(Mi,n_),e(M,s_),e(M,N),_(Tr,N,null),e(N,i_),e(N,Ei),e(Ei,l_),e(N,d_),e(N,kr),e(kr,c_),e(kr,ji),e(ji,m_),e(kr,p_),e(N,h_),e(N,Pr),e(Pr,f_),e(Pr,Fi),e(Fi,u_),e(Pr,g_),e(N,__),_(Nt,N,null),e(N,b_),_(Bt,N,null),e(M,v_),e(M,St),_(Mr,St,null),e(St,y_),e(St,Di),e(Di,w_),e(M,$_),e(M,Xt),_(Er,Xt,null),e(Xt,x_),e(Xt,qi),e(qi,T_),e(M,k_),e(M,Vt),_(jr,Vt,null),e(Vt,P_),e(Vt,Ai),e(Ai,M_),e(M,E_),e(M,Wt),_(Fr,Wt,null),e(Wt,j_),e(Wt,zi),e(zi,F_),e(M,D_),e(M,Ht),_(Dr,Ht,null),e(Ht,q_),e(Ht,Ci),e(Ci,A_),e(M,z_),e(M,Rt),_(qr,Rt,null),e(Rt,C_),e(Rt,Ii),e(Ii,I_),e(M,L_),e(M,Gt),_(Ar,Gt,null),e(Gt,U_),e(Gt,Li),e(Li,O_),e(M,N_),e(M,Yt),_(zr,Yt,null),e(Yt,B_),e(Yt,Ui),e(Ui,S_),e(M,X_),e(M,Te),_(Cr,Te,null),e(Te,V_),e(Te,Ir),e(Ir,W_),e(Ir,Oi),e(Oi,H_),e(Ir,R_),e(Te,G_),e(Te,Lr),e(Lr,Y_),e(Lr,Ni),e(Ni,J_),e(Lr,K_),e(M,Z_),e(M,Jt),_(Ur,Jt,null),e(Jt,Q_),e(Jt,Or),e(Or,eb),e(Or,Ja),e(Ja,tb),e(Or,ob),e(M,rb),e(M,Kt),_(Nr,Kt,null),e(Kt,ab),e(Kt,Bi),e(Bi,nb),e(M,sb),e(M,Zt),_(Br,Zt,null),e(Zt,ib),e(Zt,Si),e(Si,lb),e(M,db),e(M,Qt),_(Sr,Qt,null),e(Qt,cb),e(Qt,Xi),e(Xi,mb),e(M,pb),e(M,eo),_(Xr,eo,null),e(eo,hb),e(eo,Vi),e(Vi,fb),e(M,ub),e(M,to),_(Vr,to,null),e(to,gb),e(to,Wi),e(Wi,_b),e(M,bb),e(M,oo),_(Wr,oo,null),e(oo,vb),e(oo,Hr),e(Hr,yb),e(Hr,Hi),e(Hi,wb),e(Hr,$b),e(M,xb),e(M,ro),_(Rr,ro,null),e(ro,Tb),e(ro,Gr),e(Gr,kb),e(Gr,Ri),e(Ri,Pb),e(Gr,Mb),w(o,zd,h),w(o,Ke,h),e(Ke,ao),e(ao,Gi),_(Yr,Gi,null),e(Ke,Eb),e(Ke,Yi),e(Yi,jb),w(o,Cd,h),w(o,ae,h),_(Jr,ae,null),e(ae,Fb),e(ae,Kr),e(Kr,Db),e(Kr,Ji),e(Ji,qb),e(Kr,Ab),e(ae,zb),e(ae,no),_(Zr,no,null),e(no,Cb),e(no,Ki),e(Ki,Ib),w(o,Id,h),w(o,Ze,h),e(Ze,so),e(so,Zi),_(Qr,Zi,null),e(Ze,Lb),e(Ze,Qi),e(Qi,Ub),w(o,Ld,h),w(o,A,h),_(ea,A,null),e(A,Ob),e(A,el),e(el,Nb),e(A,Bb),e(A,Ka),e(Ka,Za),e(Za,Sb),e(Ka,Xb),e(A,Vb),e(A,tl),e(tl,Wb),e(A,Hb),e(A,Qe),e(Qe,ke),e(ke,ol),e(ol,Rb),e(ke,Gb),e(ke,Qa),e(Qa,Yb),e(ke,Jb),e(ke,en),e(en,Kb),e(ke,Zb),e(Qe,Qb),e(Qe,io),e(io,rl),e(rl,ev),e(io,tv),e(io,al),e(al,ov),e(io,rv),e(Qe,av),e(Qe,V),e(V,nl),e(nl,nv),e(V,sv),e(V,sl),e(sl,iv),e(V,lv),e(V,il),e(il,dv),e(V,cv),e(V,ll),e(ll,mv),e(V,pv),e(V,dl),e(dl,hv),e(V,fv),e(A,uv),e(A,Pe),_(ta,Pe,null),e(Pe,gv),e(Pe,oa),e(oa,_v),e(oa,cl),e(cl,bv),e(oa,vv),e(Pe,yv),_(lo,Pe,null),e(A,wv),e(A,W),_(ra,W,null),e(W,$v),e(W,ml),e(ml,xv),e(W,Tv),e(W,aa),e(aa,kv),e(aa,pl),e(pl,Pv),e(aa,Mv),e(W,Ev),e(W,na),e(na,jv),e(na,hl),e(hl,Fv),e(na,Dv),e(W,qv),_(co,W,null),e(A,Av),e(A,Me),_(sa,Me,null),e(Me,zv),e(Me,fl),e(fl,Cv),e(Me,Iv),_(mo,Me,null),e(A,Lv),e(A,po),_(ia,po,null),e(po,Uv),e(po,la),e(la,Ov),e(la,ul),e(ul,Nv),e(la,Bv),e(A,Sv),e(A,ee),_(da,ee,null),e(ee,Xv),e(ee,G),e(G,Vv),e(G,gl),e(gl,Wv),e(G,Hv),e(G,_l),e(_l,Rv),e(G,Gv),e(G,bl),e(bl,Yv),e(G,Jv),e(G,vl),e(vl,Kv),e(G,Zv),e(ee,Qv),e(ee,yl),e(yl,ey),e(ee,ty),_(ho,ee,null),e(A,oy),e(A,te),_(ca,te,null),e(te,ry),e(te,Y),e(Y,ay),e(Y,wl),e(wl,ny),e(Y,sy),e(Y,$l),e($l,iy),e(Y,ly),e(Y,xl),e(xl,dy),e(Y,cy),e(Y,Tl),e(Tl,my),e(Y,py),e(te,hy),e(te,kl),e(kl,fy),e(te,uy),_(fo,te,null),e(A,gy),e(A,Ee),_(ma,Ee,null),e(Ee,_y),e(Ee,J),e(J,by),e(J,Pl),e(Pl,vy),e(J,yy),e(J,Ml),e(Ml,wy),e(J,$y),e(J,El),e(El,xy),e(J,Ty),e(J,jl),e(jl,ky),e(J,Py),e(Ee,My),_(uo,Ee,null),w(o,Ud,h),w(o,et,h),e(et,go),e(go,Fl),_(pa,Fl,null),e(et,Ey),e(et,Dl),e(Dl,jy),w(o,Od,h),w(o,ne,h),_(ha,ne,null),e(ne,Fy),e(ne,ql),e(ql,Dy),e(ne,qy),e(ne,je),_(fa,je,null),e(je,Ay),e(je,ua),e(ua,zy),e(ua,Al),e(Al,Cy),e(ua,Iy),e(je,Ly),_(_o,je,null),w(o,Nd,h),w(o,tt,h),e(tt,bo),e(bo,zl),_(ga,zl,null),e(tt,Uy),e(tt,Cl),e(Cl,Oy),w(o,Bd,h),w(o,se,h),_(_a,se,null),e(se,Ny),e(se,ba),e(ba,By),e(ba,va),e(va,Il),e(Il,Sy),e(ba,Xy),e(se,Vy),e(se,Ll),e(Ll,Wy),Sd=!0},p(o,[h]){const ya={};h&2&&(ya.$$scope={dirty:h,ctx:o}),dt.$set(ya);const Ul={};h&2&&(Ul.$$scope={dirty:h,ctx:o}),ct.$set(Ul);const Ol={};h&2&&(Ol.$$scope={dirty:h,ctx:o}),mt.$set(Ol);const Nl={};h&2&&(Nl.$$scope={dirty:h,ctx:o}),pt.$set(Nl);const ie={};h&2&&(ie.$$scope={dirty:h,ctx:o}),bt.$set(ie);const Bl={};h&2&&(Bl.$$scope={dirty:h,ctx:o}),Ut.$set(Bl);const Sl={};h&2&&(Sl.$$scope={dirty:h,ctx:o}),Nt.$set(Sl);const Xl={};h&2&&(Xl.$$scope={dirty:h,ctx:o}),Bt.$set(Xl);const vo={};h&2&&(vo.$$scope={dirty:h,ctx:o}),lo.$set(vo);const Vl={};h&2&&(Vl.$$scope={dirty:h,ctx:o}),co.$set(Vl);const Wl={};h&2&&(Wl.$$scope={dirty:h,ctx:o}),mo.$set(Wl);const wa={};h&2&&(wa.$$scope={dirty:h,ctx:o}),ho.$set(wa);const Hl={};h&2&&(Hl.$$scope={dirty:h,ctx:o}),fo.$set(Hl);const Rl={};h&2&&(Rl.$$scope={dirty:h,ctx:o}),uo.$set(Rl);const B={};h&2&&(B.$$scope={dirty:h,ctx:o}),_o.$set(B)},i(o){Sd||(b(c.$$.fragment,o),b(To.$$.fragment,o),b(ko.$$.fragment,o),b(Eo.$$.fragment,o),b(dt.$$.fragment,o),b(Fo.$$.fragment,o),b(ct.$$.fragment,o),b(mt.$$.fragment,o),b(pt.$$.fragment,o),b(Ao.$$.fragment,o),b(zo.$$.fragment,o),b(Co.$$.fragment,o),b(Io.$$.fragment,o),b(Lo.$$.fragment,o),b(Uo.$$.fragment,o),b(Oo.$$.fragment,o),b(No.$$.fragment,o),b(bt.$$.fragment,o),b(Bo.$$.fragment,o),b(Vo.$$.fragment,o),b(Ho.$$.fragment,o),b(Ro.$$.fragment,o),b(Yo.$$.fragment,o),b(Ko.$$.fragment,o),b(Zo.$$.fragment,o),b(Qo.$$.fragment,o),b(er.$$.fragment,o),b(tr.$$.fragment,o),b(or.$$.fragment,o),b(rr.$$.fragment,o),b(ar.$$.fragment,o),b(nr.$$.fragment,o),b(sr.$$.fragment,o),b(ir.$$.fragment,o),b(dr.$$.fragment,o),b(cr.$$.fragment,o),b(mr.$$.fragment,o),b(hr.$$.fragment,o),b(fr.$$.fragment,o),b(ur.$$.fragment,o),b(gr.$$.fragment,o),b(_r.$$.fragment,o),b(br.$$.fragment,o),b(vr.$$.fragment,o),b(wr.$$.fragment,o),b(Ut.$$.fragment,o),b(xr.$$.fragment,o),b(Tr.$$.fragment,o),b(Nt.$$.fragment,o),b(Bt.$$.fragment,o),b(Mr.$$.fragment,o),b(Er.$$.fragment,o),b(jr.$$.fragment,o),b(Fr.$$.fragment,o),b(Dr.$$.fragment,o),b(qr.$$.fragment,o),b(Ar.$$.fragment,o),b(zr.$$.fragment,o),b(Cr.$$.fragment,o),b(Ur.$$.fragment,o),b(Nr.$$.fragment,o),b(Br.$$.fragment,o),b(Sr.$$.fragment,o),b(Xr.$$.fragment,o),b(Vr.$$.fragment,o),b(Wr.$$.fragment,o),b(Rr.$$.fragment,o),b(Yr.$$.fragment,o),b(Jr.$$.fragment,o),b(Zr.$$.fragment,o),b(Qr.$$.fragment,o),b(ea.$$.fragment,o),b(ta.$$.fragment,o),b(lo.$$.fragment,o),b(ra.$$.fragment,o),b(co.$$.fragment,o),b(sa.$$.fragment,o),b(mo.$$.fragment,o),b(ia.$$.fragment,o),b(da.$$.fragment,o),b(ho.$$.fragment,o),b(ca.$$.fragment,o),b(fo.$$.fragment,o),b(ma.$$.fragment,o),b(uo.$$.fragment,o),b(pa.$$.fragment,o),b(ha.$$.fragment,o),b(fa.$$.fragment,o),b(_o.$$.fragment,o),b(ga.$$.fragment,o),b(_a.$$.fragment,o),Sd=!0)},o(o){v(c.$$.fragment,o),v(To.$$.fragment,o),v(ko.$$.fragment,o),v(Eo.$$.fragment,o),v(dt.$$.fragment,o),v(Fo.$$.fragment,o),v(ct.$$.fragment,o),v(mt.$$.fragment,o),v(pt.$$.fragment,o),v(Ao.$$.fragment,o),v(zo.$$.fragment,o),v(Co.$$.fragment,o),v(Io.$$.fragment,o),v(Lo.$$.fragment,o),v(Uo.$$.fragment,o),v(Oo.$$.fragment,o),v(No.$$.fragment,o),v(bt.$$.fragment,o),v(Bo.$$.fragment,o),v(Vo.$$.fragment,o),v(Ho.$$.fragment,o),v(Ro.$$.fragment,o),v(Yo.$$.fragment,o),v(Ko.$$.fragment,o),v(Zo.$$.fragment,o),v(Qo.$$.fragment,o),v(er.$$.fragment,o),v(tr.$$.fragment,o),v(or.$$.fragment,o),v(rr.$$.fragment,o),v(ar.$$.fragment,o),v(nr.$$.fragment,o),v(sr.$$.fragment,o),v(ir.$$.fragment,o),v(dr.$$.fragment,o),v(cr.$$.fragment,o),v(mr.$$.fragment,o),v(hr.$$.fragment,o),v(fr.$$.fragment,o),v(ur.$$.fragment,o),v(gr.$$.fragment,o),v(_r.$$.fragment,o),v(br.$$.fragment,o),v(vr.$$.fragment,o),v(wr.$$.fragment,o),v(Ut.$$.fragment,o),v(xr.$$.fragment,o),v(Tr.$$.fragment,o),v(Nt.$$.fragment,o),v(Bt.$$.fragment,o),v(Mr.$$.fragment,o),v(Er.$$.fragment,o),v(jr.$$.fragment,o),v(Fr.$$.fragment,o),v(Dr.$$.fragment,o),v(qr.$$.fragment,o),v(Ar.$$.fragment,o),v(zr.$$.fragment,o),v(Cr.$$.fragment,o),v(Ur.$$.fragment,o),v(Nr.$$.fragment,o),v(Br.$$.fragment,o),v(Sr.$$.fragment,o),v(Xr.$$.fragment,o),v(Vr.$$.fragment,o),v(Wr.$$.fragment,o),v(Rr.$$.fragment,o),v(Yr.$$.fragment,o),v(Jr.$$.fragment,o),v(Zr.$$.fragment,o),v(Qr.$$.fragment,o),v(ea.$$.fragment,o),v(ta.$$.fragment,o),v(lo.$$.fragment,o),v(ra.$$.fragment,o),v(co.$$.fragment,o),v(sa.$$.fragment,o),v(mo.$$.fragment,o),v(ia.$$.fragment,o),v(da.$$.fragment,o),v(ho.$$.fragment,o),v(ca.$$.fragment,o),v(fo.$$.fragment,o),v(ma.$$.fragment,o),v(uo.$$.fragment,o),v(pa.$$.fragment,o),v(ha.$$.fragment,o),v(fa.$$.fragment,o),v(_o.$$.fragment,o),v(ga.$$.fragment,o),v(_a.$$.fragment,o),Sd=!1},d(o){t(p),o&&t(T),o&&t($),y(c),o&&t(od),o&&t(K),o&&t(rd),o&&t(Oe),o&&t(ad),o&&t(ot),o&&t(nd),o&&t(O),o&&t(sd),o&&t(Ne),y(To),o&&t(id),o&&t(j),y(ko),y(Eo),y(dt),y(Fo),y(ct),y(mt),y(pt),y(Ao),y(zo),y(Co),y(Io),y(Lo),y(Uo),y(Oo),y(No),y(bt),y(Bo),y(Vo),y(Ho),y(Ro),o&&t(ld),o&&t(Ba),o&&t(dd),o&&t(Xe),y(Yo),o&&t(cd),o&&t(ve),o&&t(md),o&&t($t),o&&t(pd),y(Ko,o),o&&t(hd),o&&t(xt),o&&t(fd),o&&t(Z),o&&t(ud),y(Zo,o),o&&t(gd),o&&t(Tt),o&&t(_d),y(Qo,o),o&&t(bd),y(er,o),o&&t(vd),o&&t(Xa),o&&t(yd),y(tr,o),o&&t(wd),o&&t(kt),o&&t($d),o&&t(Ve),y(or),o&&t(xd),o&&t(Q),o&&t(Td),y(rr,o),o&&t(kd),o&&t(ye),o&&t(Pd),y(ar,o),o&&t(Md),o&&t(Mt),o&&t(Ed),y(nr,o),o&&t(jd),o&&t(Va),o&&t(Fd),o&&t(We),y(sr),o&&t(Dd),o&&t(C),y(ir),y(dr),y(cr),y(mr),y(hr),y(fr),y(ur),y(gr),y(_r),o&&t(qd),o&&t(Ye),y(br),o&&t(Ad),o&&t(M),y(vr),y(wr),y(Ut),y(xr),y(Tr),y(Nt),y(Bt),y(Mr),y(Er),y(jr),y(Fr),y(Dr),y(qr),y(Ar),y(zr),y(Cr),y(Ur),y(Nr),y(Br),y(Sr),y(Xr),y(Vr),y(Wr),y(Rr),o&&t(zd),o&&t(Ke),y(Yr),o&&t(Cd),o&&t(ae),y(Jr),y(Zr),o&&t(Id),o&&t(Ze),y(Qr),o&&t(Ld),o&&t(A),y(ea),y(ta),y(lo),y(ra),y(co),y(sa),y(mo),y(ia),y(da),y(ho),y(ca),y(fo),y(ma),y(uo),o&&t(Ud),o&&t(et),y(pa),o&&t(Od),o&&t(ne),y(ha),y(fa),y(_o),o&&t(Nd),o&&t(tt),y(ga),o&&t(Bd),o&&t(se),y(_a)}}}const rx={local:"models",sections:[{local:"transformers.PreTrainedModel",sections:[{local:"large-model-loading",title:"Large model loading"},{local:"model-instantiation-dtype",title:"Model Instantiation dtype"}],title:"PreTrainedModel"},{local:"transformers.modeling_utils.ModuleUtilsMixin",title:"ModuleUtilsMixin"},{local:"transformers.TFPreTrainedModel",title:"TFPreTrainedModel"},{local:"transformers.modeling_tf_utils.TFModelUtilsMixin",title:"TFModelUtilsMixin"},{local:"transformers.FlaxPreTrainedModel",title:"FlaxPreTrainedModel"},{local:"transformers.utils.PushToHubMixin",title:"Pushing to the Hub"},{local:"transformers.modeling_utils.load_sharded_checkpoint",title:"Sharded checkpoints"}],title:"Models"};function ax(D){return N2(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class mx extends I2{constructor(p){super();L2(this,p,ax,ox,U2,{})}}export{mx as default,rx as metadata};
