import{s as Vl,o as Ql,n as qt}from"../chunks/scheduler.9bc65507.js";import{S as El,i as Hl,g as o,s as n,r as c,A as zl,h as i,f as l,c as a,j as Yl,u as m,x as r,k as Gl,y as Fl,a as s,v as d,d as y,t as u,w as f}from"../chunks/index.707bf1b6.js";import{T as Lt}from"../chunks/Tip.c2ecdbf4.js";import{C as J}from"../chunks/CodeBlock.54a9f38d.js";import{H as We}from"../chunks/Heading.342b1fa6.js";function Sl(b){let M,T="If your model is very similar to a model inside the library, you can re-use the same configuration as this model.";return{c(){M=o("p"),M.textContent=T},l(p){M=i(p,"P",{"data-svelte-h":!0}),r(M)!=="svelte-alg4p1"&&(M.textContent=T)},m(p,h){s(p,M,h)},p:qt,d(p){p&&l(M)}}}function Ll(b){let M,T="This API is experimental and may have some slight breaking changes in the next releases.";return{c(){M=o("p"),M.textContent=T},l(p){M=i(p,"P",{"data-svelte-h":!0}),r(M)!=="svelte-15rpg4"&&(M.textContent=T)},m(p,h){s(p,M,h)},p:qt,d(p){p&&l(M)}}}function ql(b){let M,T=`If copying a modeling files from the library, you will need to replace all the relative imports at the top of the file
to import from the <code>transformers</code> package.`;return{c(){M=o("p"),M.innerHTML=T},l(p){M=i(p,"P",{"data-svelte-h":!0}),r(M)!=="svelte-1816fmc"&&(M.innerHTML=T)},m(p,h){s(p,M,h)},p:qt,d(p){p&&l(M)}}}function Pl(b){let M,T=`Use <code>register_for_auto_class()</code> if you want the code files to be copied. If you instead prefer to use code on the Hub from another repo,
you don’t need to call it. In cases where there’s more than one auto class, you can modify the <code>config.json</code> directly using the
following structure:`,p,h,j;return h=new J({props:{code:"JTIyYXV0b19tYXAlMjIlM0ElMjAlN0IlMjAlMjAlMjAlMjAlMjAlMEElMDklMjJBdXRvQ29uZmlnJTIyJTNBJTIwJTIyJTNDeW91ci1yZXBvLW5hbWUlM0UtLSUzQ2NvbmZpZy1uYW1lJTNFJTIyJTJDJTIwJTIwJTIwJTIwJTIwJTBBJTA5JTIyQXV0b01vZGVsJTIyJTNBJTIwJTIyJTNDeW91ci1yZXBvLW5hbWUlM0UtLSUzQ2NvbmZpZy1uYW1lJTNFJTIyJTJDJTBBJTA5JTIyQXV0b01vZGVsRm9yJTNDVGFzayUzRSUyMiUzQSUyMCUyMiUzQ3lvdXItcmVwby1uYW1lJTNFLS0lM0Njb25maWctbmFtZSUzRSUyMiUyQyUyMCUyMCUyMCUyMCUwQSU3RCUyQw==",highlighted:`<span class="hljs-attr">&quot;auto_map&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>     
	<span class="hljs-attr">&quot;AutoConfig&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;&lt;your-repo-name&gt;--&lt;config-name&gt;&quot;</span><span class="hljs-punctuation">,</span>     
	<span class="hljs-attr">&quot;AutoModel&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;&lt;your-repo-name&gt;--&lt;config-name&gt;&quot;</span><span class="hljs-punctuation">,</span>
	<span class="hljs-attr">&quot;AutoModelFor&lt;Task&gt;&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;&lt;your-repo-name&gt;--&lt;config-name&gt;&quot;</span><span class="hljs-punctuation">,</span>    
<span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>`,wrap:!1}}),{c(){M=o("p"),M.innerHTML=T,p=n(),c(h.$$.fragment)},l(w){M=i(w,"P",{"data-svelte-h":!0}),r(M)!=="svelte-1rexmhi"&&(M.innerHTML=T),p=a(w),m(h.$$.fragment,w)},m(w,U){s(w,M,U),s(w,p,U),d(h,w,U),j=!0},p:qt,i(w){j||(y(h.$$.fragment,w),j=!0)},o(w){u(h.$$.fragment,w),j=!1},d(w){w&&(l(M),l(p)),f(h,w)}}}function Dl(b){let M,T,p,h,j,w,U,Pt=`The 🤗 Transformers library is designed to be easily extensible. Every model is fully coded in a given subfolder
of the repository with no abstraction, so you can easily copy a modeling file and tweak it to your needs.`,Re,Z,Dt=`If you are writing a brand new model, it might be easier to start from scratch. In this tutorial, we will show you
how to write a custom model and its configuration so it can be used inside Transformers, and how you can share it
with the community (with the code it relies on) so that anyone can use it, even if it’s not present in the 🤗
Transformers library. We’ll see how to build upon transformers and extend the framework with your hooks and
custom code.`,Xe,$,Kt=`We will illustrate all of this on a ResNet model, by wrapping the ResNet class of the
<a href="https://github.com/rwightman/pytorch-image-models" rel="nofollow">timm library</a> into a <a href="/docs/transformers/v4.36.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>.`,xe,A,Ye,v,Ot=`Before we dive into the model, let’s first write its configuration. The configuration of a model is an object that
will contain all the necessary information to build the model. As we will see in the next section, the model can only
take a <code>config</code> to be initialized, so we really need that object to be as complete as possible.`,Ge,k,el=`In our example, we will take a couple of arguments of the ResNet class that we might want to tweak. Different
configurations will then give us the different types of ResNets that are possible. We then just store those arguments,
after checking the validity of a few of them.`,Ve,N,Qe,W,tl="The three important things to remember when writing you own configuration are the following:",Ee,B,ll="<li>you have to inherit from <code>PretrainedConfig</code>,</li> <li>the <code>__init__</code> of your <code>PretrainedConfig</code> must accept any kwargs,</li> <li>those <code>kwargs</code> need to be passed to the superclass <code>__init__</code>.</li>",He,R,sl=`The inheritance is to make sure you get all the functionality from the 🤗 Transformers library, while the two other
constraints come from the fact a <code>PretrainedConfig</code> has more fields than the ones you are setting. When reloading a
config with the <code>from_pretrained</code> method, those fields need to be accepted by your config and then sent to the
superclass.`,ze,X,nl=`Defining a <code>model_type</code> for your configuration (here <code>model_type=&quot;resnet&quot;</code>) is not mandatory, unless you want to
register your model with the auto classes (see last section).`,Fe,x,al=`With this done, you can easily create and save your configuration like you would do with any other model config of the
library. Here is how we can create a resnet50d config and save it:`,Se,Y,Le,G,ol=`This will save a file named <code>config.json</code> inside the folder <code>custom-resnet</code>. You can then reload your config with the
<code>from_pretrained</code> method:`,qe,V,Pe,Q,il=`You can also use any other method of the <a href="/docs/transformers/v4.36.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> class, like <a href="/docs/transformers/v4.36.0/en/main_classes/processors#transformers.ProcessorMixin.push_to_hub">push_to_hub()</a> to
directly upload your config to the Hub.`,De,E,Ke,H,rl=`Now that we have our ResNet configuration, we can go on writing the model. We will actually write two: one that
extracts the hidden features from a batch of images (like <a href="/docs/transformers/v4.36.0/en/model_doc/bert#transformers.BertModel">BertModel</a>) and one that is suitable for image
classification (like <a href="/docs/transformers/v4.36.0/en/model_doc/bert#transformers.BertForSequenceClassification">BertForSequenceClassification</a>).`,Oe,z,Ml=`As we mentioned before, we’ll only write a loose wrapper of the model to keep it simple for this example. The only
thing we need to do before writing this class is a map between the block types and actual block classes. Then the
model is defined from the configuration by passing everything to the <code>ResNet</code> class:`,et,F,tt,S,pl="For the model that will classify images, we just change the forward method:",lt,L,st,q,cl=`In both cases, notice how we inherit from <code>PreTrainedModel</code> and call the superclass initialization with the <code>config</code>
(a bit like when you write a regular <code>torch.nn.Module</code>). The line that sets the <code>config_class</code> is not mandatory, unless
you want to register your model with the auto classes (see last section).`,nt,C,at,P,ml=`You can have your model return anything you want, but returning a dictionary like we did for
<code>ResnetModelForImageClassification</code>, with the loss included when labels are passed, will make your model directly
usable inside the <a href="/docs/transformers/v4.36.0/en/main_classes/trainer#transformers.Trainer">Trainer</a> class. Using another output format is fine as long as you are planning on using your own
training loop or another library for training.`,ot,D,dl="Now that we have our model class, let’s create one:",it,K,rt,O,yl=`Again, you can use any of the methods of <a href="/docs/transformers/v4.36.0/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>, like <a href="/docs/transformers/v4.36.0/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a> or
<a href="/docs/transformers/v4.36.0/en/main_classes/processors#transformers.ProcessorMixin.push_to_hub">push_to_hub()</a>. We will use the second in the next section, and see how to push the model weights
with the code of our model. But first, let’s load some pretrained weights inside our model.`,Mt,ee,ul=`In your own use case, you will probably be training your custom model on your own data. To go fast for this tutorial,
we will use the pretrained version of the resnet50d. Since our model is just a wrapper around it, it’s going to be
easy to transfer those weights:`,pt,te,ct,le,fl=`Now let’s see how to make sure that when we do <a href="/docs/transformers/v4.36.0/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a> or <a href="/docs/transformers/v4.36.0/en/main_classes/processors#transformers.ProcessorMixin.push_to_hub">push_to_hub()</a>, the
code of the model is saved.`,mt,se,dt,ne,wl=`If you are writing a library that extends 🤗 Transformers, you may want to extend the auto classes to include your own
model. This is different from pushing the code to the Hub in the sense that users will need to import your library to
get the custom models (contrarily to automatically downloading the model code from the Hub).`,yt,ae,hl=`As long as your config has a <code>model_type</code> attribute that is different from existing model types, and that your model
classes have the right <code>config_class</code> attributes, you can just add them to the auto classes like this:`,ut,oe,ft,ie,Jl=`Note that the first argument used when registering your custom config to <a href="/docs/transformers/v4.36.0/en/model_doc/auto#transformers.AutoConfig">AutoConfig</a> needs to match the <code>model_type</code>
of your custom config, and the first argument used when registering your custom models to any auto model class needs
to match the <code>config_class</code> of those models.`,wt,re,ht,g,Jt,Me,Tl=`First, make sure your model is fully defined in a <code>.py</code> file. It can rely on relative imports to some other files as
long as all the files are in the same directory (we don’t support submodules for this feature yet). For our example,
we’ll define a <code>modeling_resnet.py</code> file and a <code>configuration_resnet.py</code> file in a folder of the current working
directory named <code>resnet_model</code>. The configuration file contains the code for <code>ResnetConfig</code> and the modeling file
contains the code of <code>ResnetModel</code> and <code>ResnetModelForImageClassification</code>.`,Tt,pe,jt,ce,jl="The <code>__init__.py</code> can be empty, it’s just there so that Python detects <code>resnet_model</code> can be use as a module.",Ut,I,bt,me,Ul="Note that you can re-use (or subclass) an existing configuration/model.",Ct,de,bl=`To share your model with the community, follow those steps: first import the ResNet model and config from the newly
created files:`,gt,ye,It,ue,Cl=`Then you have to tell the library you want to copy the code files of those objects when using the <code>save_pretrained</code>
method and properly register them with a given Auto class (especially for models), just run:`,_t,fe,Zt,we,gl=`Note that there is no need to specify an auto class for the configuration (there is only one auto class for them,
<a href="/docs/transformers/v4.36.0/en/model_doc/auto#transformers.AutoConfig">AutoConfig</a>) but it’s different for models. Your custom model could be suitable for many different tasks, so you
have to specify which one of the auto classes is the correct one for your model.`,$t,_,At,he,Il="Next, let’s create the config and models as we did before:",vt,Je,kt,Te,_l="Now to send the model to the Hub, make sure you are logged in. Either run in your terminal:",Nt,je,Wt,Ue,Zl="or from a notebook:",Bt,be,Rt,Ce,$l="You can then push to your own namespace (or an organization you are a member of) like this:",Xt,ge,xt,Ie,Al=`On top of the modeling weights and the configuration in json format, this also copied the modeling and
configuration <code>.py</code> files in the folder <code>custom-resnet50d</code> and uploaded the result to the Hub. You can check the result
in this <a href="https://huggingface.co/sgugger/custom-resnet50d" rel="nofollow">model repo</a>.`,Yt,_e,vl='See the <a href="model_sharing">sharing tutorial</a> for more information on the push to Hub method.',Gt,Ze,Vt,$e,kl=`You can use any configuration, model or tokenizer with custom code files in its repository with the auto-classes and
the <code>from_pretrained</code> method. All files and code uploaded to the Hub are scanned for malware (refer to the <a href="https://huggingface.co/docs/hub/security#malware-scanning" rel="nofollow">Hub security</a> documentation for more information), but you should still
review the model code and author to avoid executing malicious code on your machine. Set <code>trust_remote_code=True</code> to use
a model with custom code:`,Qt,Ae,Et,ve,Nl=`It is also strongly encouraged to pass a commit hash as a <code>revision</code> to make sure the author of the models did not
update the code with some malicious new lines (unless you fully trust the authors of the models).`,Ht,ke,zt,Ne,Wl=`Note that when browsing the commit history of the model repo on the Hub, there is a button to easily copy the commit
hash of any commit.`,Ft,Be,St;return j=new We({props:{title:"Building custom models",local:"building-custom-models",headingTag:"h1"}}),A=new We({props:{title:"Writing a custom configuration",local:"writing-a-custom-configuration",headingTag:"h2"}}),N=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFByZXRyYWluZWRDb25maWclMEFmcm9tJTIwdHlwaW5nJTIwaW1wb3J0JTIwTGlzdCUwQSUwQSUwQWNsYXNzJTIwUmVzbmV0Q29uZmlnKFByZXRyYWluZWRDb25maW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jYXJkaW5hbGl0eSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNlbGYuYmFzZV93aWR0aCUyMCUzRCUyMGJhc2Vfd2lkdGglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzZWxmLnN0ZW1fd2lkdGglMjAlM0QlMjBzdGVtX3dpZHRoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2VsZi5zdGVtX3R5cGUlMjAlM0QlMjBzdGVtX3R5cGUlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzZWxmLmF2Z19kb3duJTIwJTNEJTIwYXZnX2Rvd24lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzdXBlcigpLl9faW5pdF9fKCoqa3dhcmdzKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> PretrainedConfig
<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">List</span>


<span class="hljs-keyword">class</span> <span class="hljs-title class_">ResnetConfig</span>(<span class="hljs-title class_ inherited__">PretrainedConfig</span>):
    model_type = <span class="hljs-string">&quot;resnet&quot;</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">
        self,
        block_type=<span class="hljs-string">&quot;bottleneck&quot;</span>,
        layers: <span class="hljs-type">List</span>[<span class="hljs-built_in">int</span>] = [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">6</span>, <span class="hljs-number">3</span>],
        num_classes: <span class="hljs-built_in">int</span> = <span class="hljs-number">1000</span>,
        input_channels: <span class="hljs-built_in">int</span> = <span class="hljs-number">3</span>,
        cardinality: <span class="hljs-built_in">int</span> = <span class="hljs-number">1</span>,
        base_width: <span class="hljs-built_in">int</span> = <span class="hljs-number">64</span>,
        stem_width: <span class="hljs-built_in">int</span> = <span class="hljs-number">64</span>,
        stem_type: <span class="hljs-built_in">str</span> = <span class="hljs-string">&quot;&quot;</span>,
        avg_down: <span class="hljs-built_in">bool</span> = <span class="hljs-literal">False</span>,
        **kwargs,
    </span>):
        <span class="hljs-keyword">if</span> block_type <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">&quot;basic&quot;</span>, <span class="hljs-string">&quot;bottleneck&quot;</span>]:
            <span class="hljs-keyword">raise</span> ValueError(<span class="hljs-string">f&quot;\`block_type\` must be &#x27;basic&#x27; or bottleneck&#x27;, got <span class="hljs-subst">{block_type}</span>.&quot;</span>)
        <span class="hljs-keyword">if</span> stem_type <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">&quot;&quot;</span>, <span class="hljs-string">&quot;deep&quot;</span>, <span class="hljs-string">&quot;deep-tiered&quot;</span>]:
            <span class="hljs-keyword">raise</span> ValueError(<span class="hljs-string">f&quot;\`stem_type\` must be &#x27;&#x27;, &#x27;deep&#x27; or &#x27;deep-tiered&#x27;, got <span class="hljs-subst">{stem_type}</span>.&quot;</span>)

        self.block_type = block_type
        self.layers = layers
        self.num_classes = num_classes
        self.input_channels = input_channels
        self.cardinality = cardinality
        self.base_width = base_width
        self.stem_width = stem_width
        self.stem_type = stem_type
        self.avg_down = avg_down
        <span class="hljs-built_in">super</span>().__init__(**kwargs)`,wrap:!1}}),Y=new J({props:{code:"cmVzbmV0NTBkX2NvbmZpZyUyMCUzRCUyMFJlc25ldENvbmZpZyhibG9ja190eXBlJTNEJTIyYm90dGxlbmVjayUyMiUyQyUyMHN0ZW1fd2lkdGglM0QzMiUyQyUyMHN0ZW1fdHlwZSUzRCUyMmRlZXAlMjIlMkMlMjBhdmdfZG93biUzRFRydWUpJTBBcmVzbmV0NTBkX2NvbmZpZy5zYXZlX3ByZXRyYWluZWQoJTIyY3VzdG9tLXJlc25ldCUyMik=",highlighted:`resnet50d_config = ResnetConfig(block_type=<span class="hljs-string">&quot;bottleneck&quot;</span>, stem_width=<span class="hljs-number">32</span>, stem_type=<span class="hljs-string">&quot;deep&quot;</span>, avg_down=<span class="hljs-literal">True</span>)
resnet50d_config.save_pretrained(<span class="hljs-string">&quot;custom-resnet&quot;</span>)`,wrap:!1}}),V=new J({props:{code:"cmVzbmV0NTBkX2NvbmZpZyUyMCUzRCUyMFJlc25ldENvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIyY3VzdG9tLXJlc25ldCUyMik=",highlighted:'resnet50d_config = ResnetConfig.from_pretrained(<span class="hljs-string">&quot;custom-resnet&quot;</span>)',wrap:!1}}),E=new We({props:{title:"Writing a custom model",local:"writing-a-custom-model",headingTag:"h2"}}),F=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFByZVRyYWluZWRNb2RlbCUwQWZyb20lMjB0aW1tLm1vZGVscy5yZXNuZXQlMjBpbXBvcnQlMjBCYXNpY0Jsb2NrJTJDJTIwQm90dGxlbmVjayUyQyUyMFJlc05ldCUwQWZyb20lMjAuY29uZmlndXJhdGlvbl9yZXNuZXQlMjBpbXBvcnQlMjBSZXNuZXRDb25maWclMEElMEElMEFCTE9DS19NQVBQSU5HJTIwJTNEJTIwJTdCJTIyYmFzaWMlMjIlM0ElMjBCYXNpY0Jsb2NrJTJDJTIwJTIyYm90dGxlbmVjayUyMiUzQSUyMEJvdHRsZW5lY2slN0QlMEElMEElMEFjbGFzcyUyMFJlc25ldE1vZGVsKFByZVRyYWluZWRNb2RlbCklM0ElMEElMjAlMjAlMjAlMjBjb25maWdfY2xhc3MlMjAlM0QlMjBSZXNuZXRDb25maWclMEElMEElMjAlMjAlMjAlMjBkZWYlMjBfX2luaXRfXyhzZWxmJTJDJTIwY29uZmlnKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN1cGVyKCkuX19pbml0X18oY29uZmlnKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJsb2NrX2xheWVyJTIwJTNEJTIwQkxPQ0tfTUFQUElORyU1QmNvbmZpZy5ibG9ja190eXBlJTVEJTBBJTIwJTIwJ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0dXJlcyh0ZW5zb3Ip",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> PreTrainedModel
<span class="hljs-keyword">from</span> timm.models.resnet <span class="hljs-keyword">import</span> BasicBlock, Bottleneck, ResNet
<span class="hljs-keyword">from</span> .configuration_resnet <span class="hljs-keyword">import</span> ResnetConfig


BLOCK_MAPPING = {<span class="hljs-string">&quot;basic&quot;</span>: BasicBlock, <span class="hljs-string">&quot;bottleneck&quot;</span>: Bottleneck}


<span class="hljs-keyword">class</span> <span class="hljs-title class_">ResnetModel</span>(<span class="hljs-title class_ inherited__">PreTrainedModel</span>):
    config_class = ResnetConfig

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, config</span>):
        <span class="hljs-built_in">super</span>().__init__(config)
        block_layer = BLOCK_MAPPING[config.block_type]
        self.model = ResNet(
            block_layer,
            config.layers,
            num_classes=config.num_classes,
            in_chans=config.input_channels,
            cardinality=config.cardinality,
            base_width=config.base_width,
            stem_width=config.stem_width,
            stem_type=config.stem_type,
            avg_down=config.avg_down,
        )

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, tensor</span>):
        <span class="hljs-keyword">return</span> self.model.forward_features(tensor)`,wrap:!1}}),L=new J({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEElMEFjbGFzcyUyMFJlc25ldE1vZGVsRm9ySW1hZ2VDbGFzc2lmaWNhdGlvbihQcmVUcmFpbmVkTW9kZWwpJTNBJTBBJTIwJTIwJTIwJTIwY29uZmlnX2NsYXNzJTIwJTNEJTIwUmVzbmV0Q29uZmlnJTBBJTBBJTIwJTIwJTIwJTIwZGVmJTIwX19pbml0X18oc2VsZiUyQyUyMGNvbmZpZyklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzdXBlcigpLl9faW5pdF9fKGNvbmZpZyklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBibG9ja19sYXllciUyMC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QyUyMGxhYmVscyUzRE5vbmUpJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwc2VsZi5tb2RlbCh0ZW5zb3IpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWYlMjBsYWJlbHMlMjBpcyUyMG5vdCUyME5vbmUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwdG9yY2gubm4uY3Jvc3NfZW50cm9weShsb2dpdHMlMkMlMjBsYWJlbHMpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTdCJTIybG9zcyUyMiUzQSUyMGxvc3MlMkMlMjAlMjJsb2dpdHMlMjIlM0ElMjBsb2dpdHMlN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjAlN0IlMjJsb2dpdHMlMjIlM0ElMjBsb2dpdHMlN0Q=",highlighted:`<span class="hljs-keyword">import</span> torch


<span class="hljs-keyword">class</span> <span class="hljs-title class_">ResnetModelForImageClassification</span>(<span class="hljs-title class_ inherited__">PreTrainedModel</span>):
    config_class = ResnetConfig

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, config</span>):
        <span class="hljs-built_in">super</span>().__init__(config)
        block_layer = BLOCK_MAPPING[config.block_type]
        self.model = ResNet(
            block_layer,
            config.layers,
            num_classes=config.num_classes,
            in_chans=config.input_channels,
            cardinality=config.cardinality,
            base_width=config.base_width,
            stem_width=config.stem_width,
            stem_type=config.stem_type,
            avg_down=config.avg_down,
        )

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, tensor, labels=<span class="hljs-literal">None</span></span>):
        logits = self.model(tensor)
        <span class="hljs-keyword">if</span> labels <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">None</span>:
            loss = torch.nn.cross_entropy(logits, labels)
            <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;loss&quot;</span>: loss, <span class="hljs-string">&quot;logits&quot;</span>: logits}
        <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;logits&quot;</span>: logits}`,wrap:!1}}),C=new Lt({props:{$$slots:{default:[Sl]},$$scope:{ctx:b}}}),K=new J({props:{code:"cmVzbmV0NTBkJTIwJTNEJTIwUmVzbmV0TW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uKHJlc25ldDUwZF9jb25maWcp",highlighted:"resnet50d = ResnetModelForImageClassification(resnet50d_config)",wrap:!1}}),te=new J({props:{code:"aW1wb3J0JTIwdGltbSUwQSUwQXByZXRyYWluZWRfbW9kZWwlMjAlM0QlMjB0aW1tLmNyZWF0ZV9tb2RlbCglMjJyZXNuZXQ1MGQlMjIlMkMlMjBwcmV0cmFpbmVkJTNEVHJ1ZSklMEFyZXNuZXQ1MGQubW9kZWwubG9hZF9zdGF0ZV9kaWN0KHByZXRyYWluZWRfbW9kZWwuc3RhdGVfZGljdCgpKQ==",highlighted:`<span class="hljs-keyword">import</span> timm

pretrained_model = timm.create_model(<span class="hljs-string">&quot;resnet50d&quot;</span>, pretrained=<span class="hljs-literal">True</span>)
resnet50d.model.load_state_dict(pretrained_model.state_dict())`,wrap:!1}}),se=new We({props:{title:"Registering a model with custom code to the auto classes",local:"registering-a-model-with-custom-code-to-the-auto-classes",headingTag:"h2"}}),oe=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMkMlMjBBdXRvTW9kZWwlMkMlMjBBdXRvTW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uJTBBJTBBQXV0b0NvbmZpZy5yZWdpc3RlciglMjJyZXNuZXQlMjIlMkMlMjBSZXNuZXRDb25maWcpJTBBQXV0b01vZGVsLnJlZ2lzdGVyKFJlc25ldENvbmZpZyUyQyUyMFJlc25ldE1vZGVsKSUwQUF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24ucmVnaXN0ZXIoUmVzbmV0Q29uZmlnJTJDJTIwUmVzbmV0TW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig, AutoModel, AutoModelForImageClassification

AutoConfig.register(<span class="hljs-string">&quot;resnet&quot;</span>, ResnetConfig)
AutoModel.register(ResnetConfig, ResnetModel)
AutoModelForImageClassification.register(ResnetConfig, ResnetModelForImageClassification)`,wrap:!1}}),re=new We({props:{title:"Sending the code to the Hub",local:"sending-the-code-to-the-hub",headingTag:"h2"}}),g=new Lt({props:{warning:!0,$$slots:{default:[Ll]},$$scope:{ctx:b}}}),pe=new J({props:{code:"LiUwQSVFMiU5NCU5NCVFMiU5NCU4MCVFMiU5NCU4MCUyMHJlc25ldF9tb2RlbCUwQSUyMCUyMCUyMCUyMCVFMiU5NCU5QyVFMiU5NCU4MCVFMiU5NCU4MCUyMF9faW5pdF9fLnB5JTBBJTIwJTIwJTIwJTIwJUUyJTk0JTlDJUUyJTk0JTgwJUUyJTk0JTgwJTIwY29uZmlndXJhdGlvbl9yZXNuZXQucHklMEElMjAlMjAlMjAlMjAlRTIlOTQlOTQlRTIlOTQlODAlRTIlOTQlODAlMjBtb2RlbGluZ19yZXNuZXQucHk=",highlighted:`.
└── resnet_model
    ├── __init__.<span class="hljs-keyword">py</span>
    ├── configuration_resnet.<span class="hljs-keyword">py</span>
    └── modeling_resnet.<span class="hljs-keyword">py</span>`,wrap:!1}}),I=new Lt({props:{warning:!0,$$slots:{default:[ql]},$$scope:{ctx:b}}}),ye=new J({props:{code:"ZnJvbSUyMHJlc25ldF9tb2RlbC5jb25maWd1cmF0aW9uX3Jlc25ldCUyMGltcG9ydCUyMFJlc25ldENvbmZpZyUwQWZyb20lMjByZXNuZXRfbW9kZWwubW9kZWxpbmdfcmVzbmV0JTIwaW1wb3J0JTIwUmVzbmV0TW9kZWwlMkMlMjBSZXNuZXRNb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24=",highlighted:`<span class="hljs-keyword">from</span> resnet_model.configuration_resnet <span class="hljs-keyword">import</span> ResnetConfig
<span class="hljs-keyword">from</span> resnet_model.modeling_resnet <span class="hljs-keyword">import</span> ResnetModel, ResnetModelForImageClassification`,wrap:!1}}),fe=new J({props:{code:"UmVzbmV0Q29uZmlnLnJlZ2lzdGVyX2Zvcl9hdXRvX2NsYXNzKCklMEFSZXNuZXRNb2RlbC5yZWdpc3Rlcl9mb3JfYXV0b19jbGFzcyglMjJBdXRvTW9kZWwlMjIpJTBBUmVzbmV0TW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLnJlZ2lzdGVyX2Zvcl9hdXRvX2NsYXNzKCUyMkF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24lMjIp",highlighted:`ResnetConfig.register_for_auto_class()
ResnetModel.register_for_auto_class(<span class="hljs-string">&quot;AutoModel&quot;</span>)
ResnetModelForImageClassification.register_for_auto_class(<span class="hljs-string">&quot;AutoModelForImageClassification&quot;</span>)`,wrap:!1}}),_=new Lt({props:{$$slots:{default:[Pl]},$$scope:{ctx:b}}}),Je=new J({props:{code:"cmVzbmV0NTBkX2NvbmZpZyUyMCUzRCUyMFJlc25ldENvbmZpZyhibG9ja190eXBlJTNEJTIyYm90dGxlbmVjayUyMiUyQyUyMHN0ZW1fd2lkdGglM0QzMiUyQyUyMHN0ZW1fdHlwZSUzRCUyMmRlZXAlMjIlMkMlMjBhdmdfZG93biUzRFRydWUpJTBBcmVzbmV0NTBkJTIwJTNEJTIwUmVzbmV0TW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uKHJlc25ldDUwZF9jb25maWcpJTBBJTBBcHJldHJhaW5lZF9tb2RlbCUyMCUzRCUyMHRpbW0uY3JlYXRlX21vZGVsKCUyMnJlc25ldDUwZCUyMiUyQyUyMHByZXRyYWluZWQlM0RUcnVlKSUwQXJlc25ldDUwZC5tb2RlbC5sb2FkX3N0YXRlX2RpY3QocHJldHJhaW5lZF9tb2RlbC5zdGF0ZV9kaWN0KCkp",highlighted:`resnet50d_config = ResnetConfig(block_type=<span class="hljs-string">&quot;bottleneck&quot;</span>, stem_width=<span class="hljs-number">32</span>, stem_type=<span class="hljs-string">&quot;deep&quot;</span>, avg_down=<span class="hljs-literal">True</span>)
resnet50d = ResnetModelForImageClassification(resnet50d_config)

pretrained_model = timm.create_model(<span class="hljs-string">&quot;resnet50d&quot;</span>, pretrained=<span class="hljs-literal">True</span>)
resnet50d.model.load_state_dict(pretrained_model.state_dict())`,wrap:!1}}),je=new J({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:"huggingface-cli login",wrap:!1}}),be=new J({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

notebook_login()`,wrap:!1}}),ge=new J({props:{code:"cmVzbmV0NTBkLnB1c2hfdG9faHViKCUyMmN1c3RvbS1yZXNuZXQ1MGQlMjIp",highlighted:'resnet50d.push_to_hub(<span class="hljs-string">&quot;custom-resnet50d&quot;</span>)',wrap:!1}}),Ze=new We({props:{title:"Using a model with custom code",local:"using-a-model-with-custom-code",headingTag:"h2"}}),Ae=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMnNndWdnZXIlMkZjdXN0b20tcmVzbmV0NTBkJTIyJTJDJTIwdHJ1c3RfcmVtb3RlX2NvZGUlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForImageClassification

model = AutoModelForImageClassification.from_pretrained(<span class="hljs-string">&quot;sgugger/custom-resnet50d&quot;</span>, trust_remote_code=<span class="hljs-literal">True</span>)`,wrap:!1}}),ke=new J({props:{code:"Y29tbWl0X2hhc2glMjAlM0QlMjAlMjJlZDk0YTdjNjI0N2Q4YWVkY2U0NjQ3ZjAwZjIwZGU2ODc1YjViMjkyJTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzZ3VnZ2VyJTJGY3VzdG9tLXJlc25ldDUwZCUyMiUyQyUyMHRydXN0X3JlbW90ZV9jb2RlJTNEVHJ1ZSUyQyUyMHJldmlzaW9uJTNEY29tbWl0X2hhc2glMEEp",highlighted:`commit_hash = <span class="hljs-string">&quot;ed94a7c6247d8aedce4647f00f20de6875b5b292&quot;</span>
model = AutoModelForImageClassification.from_pretrained(
    <span class="hljs-string">&quot;sgugger/custom-resnet50d&quot;</span>, trust_remote_code=<span class="hljs-literal">True</span>, revision=commit_hash
)`,wrap:!1}}),{c(){M=o("meta"),T=n(),p=o("p"),h=n(),c(j.$$.fragment),w=n(),U=o("p"),U.textContent=Pt,Re=n(),Z=o("p"),Z.textContent=Dt,Xe=n(),$=o("p"),$.innerHTML=Kt,xe=n(),c(A.$$.fragment),Ye=n(),v=o("p"),v.innerHTML=Ot,Ge=n(),k=o("p"),k.textContent=el,Ve=n(),c(N.$$.fragment),Qe=n(),W=o("p"),W.textContent=tl,Ee=n(),B=o("ul"),B.innerHTML=ll,He=n(),R=o("p"),R.innerHTML=sl,ze=n(),X=o("p"),X.innerHTML=nl,Fe=n(),x=o("p"),x.textContent=al,Se=n(),c(Y.$$.fragment),Le=n(),G=o("p"),G.innerHTML=ol,qe=n(),c(V.$$.fragment),Pe=n(),Q=o("p"),Q.innerHTML=il,De=n(),c(E.$$.fragment),Ke=n(),H=o("p"),H.innerHTML=rl,Oe=n(),z=o("p"),z.innerHTML=Ml,et=n(),c(F.$$.fragment),tt=n(),S=o("p"),S.textContent=pl,lt=n(),c(L.$$.fragment),st=n(),q=o("p"),q.innerHTML=cl,nt=n(),c(C.$$.fragment),at=n(),P=o("p"),P.innerHTML=ml,ot=n(),D=o("p"),D.textContent=dl,it=n(),c(K.$$.fragment),rt=n(),O=o("p"),O.innerHTML=yl,Mt=n(),ee=o("p"),ee.textContent=ul,pt=n(),c(te.$$.fragment),ct=n(),le=o("p"),le.innerHTML=fl,mt=n(),c(se.$$.fragment),dt=n(),ne=o("p"),ne.textContent=wl,yt=n(),ae=o("p"),ae.innerHTML=hl,ut=n(),c(oe.$$.fragment),ft=n(),ie=o("p"),ie.innerHTML=Jl,wt=n(),c(re.$$.fragment),ht=n(),c(g.$$.fragment),Jt=n(),Me=o("p"),Me.innerHTML=Tl,Tt=n(),c(pe.$$.fragment),jt=n(),ce=o("p"),ce.innerHTML=jl,Ut=n(),c(I.$$.fragment),bt=n(),me=o("p"),me.textContent=Ul,Ct=n(),de=o("p"),de.textContent=bl,gt=n(),c(ye.$$.fragment),It=n(),ue=o("p"),ue.innerHTML=Cl,_t=n(),c(fe.$$.fragment),Zt=n(),we=o("p"),we.innerHTML=gl,$t=n(),c(_.$$.fragment),At=n(),he=o("p"),he.textContent=Il,vt=n(),c(Je.$$.fragment),kt=n(),Te=o("p"),Te.textContent=_l,Nt=n(),c(je.$$.fragment),Wt=n(),Ue=o("p"),Ue.textContent=Zl,Bt=n(),c(be.$$.fragment),Rt=n(),Ce=o("p"),Ce.textContent=$l,Xt=n(),c(ge.$$.fragment),xt=n(),Ie=o("p"),Ie.innerHTML=Al,Yt=n(),_e=o("p"),_e.innerHTML=vl,Gt=n(),c(Ze.$$.fragment),Vt=n(),$e=o("p"),$e.innerHTML=kl,Qt=n(),c(Ae.$$.fragment),Et=n(),ve=o("p"),ve.innerHTML=Nl,Ht=n(),c(ke.$$.fragment),zt=n(),Ne=o("p"),Ne.textContent=Wl,Ft=n(),Be=o("p"),this.h()},l(e){const t=zl("svelte-u9bgzb",document.head);M=i(t,"META",{name:!0,content:!0}),t.forEach(l),T=a(e),p=i(e,"P",{}),Yl(p).forEach(l),h=a(e),m(j.$$.fragment,e),w=a(e),U=i(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1bvx2nz"&&(U.textContent=Pt),Re=a(e),Z=i(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-12q72ch"&&(Z.textContent=Dt),Xe=a(e),$=i(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-17b7y0c"&&($.innerHTML=Kt),xe=a(e),m(A.$$.fragment,e),Ye=a(e),v=i(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-15o85x"&&(v.innerHTML=Ot),Ge=a(e),k=i(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-1u8fbq1"&&(k.textContent=el),Ve=a(e),m(N.$$.fragment,e),Qe=a(e),W=i(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-9tm0xv"&&(W.textContent=tl),Ee=a(e),B=i(e,"UL",{"data-svelte-h":!0}),r(B)!=="svelte-1l985bz"&&(B.innerHTML=ll),He=a(e),R=i(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-ttxucl"&&(R.innerHTML=sl),ze=a(e),X=i(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-9uxjnq"&&(X.innerHTML=nl),Fe=a(e),x=i(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-1229zpx"&&(x.textContent=al),Se=a(e),m(Y.$$.fragment,e),Le=a(e),G=i(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-1hshoid"&&(G.innerHTML=ol),qe=a(e),m(V.$$.fragment,e),Pe=a(e),Q=i(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-5sqnde"&&(Q.innerHTML=il),De=a(e),m(E.$$.fragment,e),Ke=a(e),H=i(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-mbmasb"&&(H.innerHTML=rl),Oe=a(e),z=i(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-13oyc7x"&&(z.innerHTML=Ml),et=a(e),m(F.$$.fragment,e),tt=a(e),S=i(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-85b6xb"&&(S.textContent=pl),lt=a(e),m(L.$$.fragment,e),st=a(e),q=i(e,"P",{"data-svelte-h":!0}),r(q)!=="svelte-1vktyut"&&(q.innerHTML=cl),nt=a(e),m(C.$$.fragment,e),at=a(e),P=i(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-8wtek1"&&(P.innerHTML=ml),ot=a(e),D=i(e,"P",{"data-svelte-h":!0}),r(D)!=="svelte-zsjn9b"&&(D.textContent=dl),it=a(e),m(K.$$.fragment,e),rt=a(e),O=i(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-1ri8mf1"&&(O.innerHTML=yl),Mt=a(e),ee=i(e,"P",{"data-svelte-h":!0}),r(ee)!=="svelte-kn8bw1"&&(ee.textContent=ul),pt=a(e),m(te.$$.fragment,e),ct=a(e),le=i(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-fcscht"&&(le.innerHTML=fl),mt=a(e),m(se.$$.fragment,e),dt=a(e),ne=i(e,"P",{"data-svelte-h":!0}),r(ne)!=="svelte-bccbz6"&&(ne.textContent=wl),yt=a(e),ae=i(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-uijzdg"&&(ae.innerHTML=hl),ut=a(e),m(oe.$$.fragment,e),ft=a(e),ie=i(e,"P",{"data-svelte-h":!0}),r(ie)!=="svelte-1hx1b8y"&&(ie.innerHTML=Jl),wt=a(e),m(re.$$.fragment,e),ht=a(e),m(g.$$.fragment,e),Jt=a(e),Me=i(e,"P",{"data-svelte-h":!0}),r(Me)!=="svelte-w79o0g"&&(Me.innerHTML=Tl),Tt=a(e),m(pe.$$.fragment,e),jt=a(e),ce=i(e,"P",{"data-svelte-h":!0}),r(ce)!=="svelte-1orsl60"&&(ce.innerHTML=jl),Ut=a(e),m(I.$$.fragment,e),bt=a(e),me=i(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-miae0j"&&(me.textContent=Ul),Ct=a(e),de=i(e,"P",{"data-svelte-h":!0}),r(de)!=="svelte-1kyhtnz"&&(de.textContent=bl),gt=a(e),m(ye.$$.fragment,e),It=a(e),ue=i(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-1ce24vd"&&(ue.innerHTML=Cl),_t=a(e),m(fe.$$.fragment,e),Zt=a(e),we=i(e,"P",{"data-svelte-h":!0}),r(we)!=="svelte-12wrf3"&&(we.innerHTML=gl),$t=a(e),m(_.$$.fragment,e),At=a(e),he=i(e,"P",{"data-svelte-h":!0}),r(he)!=="svelte-19txhag"&&(he.textContent=Il),vt=a(e),m(Je.$$.fragment,e),kt=a(e),Te=i(e,"P",{"data-svelte-h":!0}),r(Te)!=="svelte-1w2dqml"&&(Te.textContent=_l),Nt=a(e),m(je.$$.fragment,e),Wt=a(e),Ue=i(e,"P",{"data-svelte-h":!0}),r(Ue)!=="svelte-11lw65d"&&(Ue.textContent=Zl),Bt=a(e),m(be.$$.fragment,e),Rt=a(e),Ce=i(e,"P",{"data-svelte-h":!0}),r(Ce)!=="svelte-1c2397x"&&(Ce.textContent=$l),Xt=a(e),m(ge.$$.fragment,e),xt=a(e),Ie=i(e,"P",{"data-svelte-h":!0}),r(Ie)!=="svelte-djed3h"&&(Ie.innerHTML=Al),Yt=a(e),_e=i(e,"P",{"data-svelte-h":!0}),r(_e)!=="svelte-1sdq6eg"&&(_e.innerHTML=vl),Gt=a(e),m(Ze.$$.fragment,e),Vt=a(e),$e=i(e,"P",{"data-svelte-h":!0}),r($e)!=="svelte-nao5c0"&&($e.innerHTML=kl),Qt=a(e),m(Ae.$$.fragment,e),Et=a(e),ve=i(e,"P",{"data-svelte-h":!0}),r(ve)!=="svelte-1i8vto1"&&(ve.innerHTML=Nl),Ht=a(e),m(ke.$$.fragment,e),zt=a(e),Ne=i(e,"P",{"data-svelte-h":!0}),r(Ne)!=="svelte-1y2zx54"&&(Ne.textContent=Wl),Ft=a(e),Be=i(e,"P",{}),Yl(Be).forEach(l),this.h()},h(){Gl(M,"name","hf:doc:metadata"),Gl(M,"content",Kl)},m(e,t){Fl(document.head,M),s(e,T,t),s(e,p,t),s(e,h,t),d(j,e,t),s(e,w,t),s(e,U,t),s(e,Re,t),s(e,Z,t),s(e,Xe,t),s(e,$,t),s(e,xe,t),d(A,e,t),s(e,Ye,t),s(e,v,t),s(e,Ge,t),s(e,k,t),s(e,Ve,t),d(N,e,t),s(e,Qe,t),s(e,W,t),s(e,Ee,t),s(e,B,t),s(e,He,t),s(e,R,t),s(e,ze,t),s(e,X,t),s(e,Fe,t),s(e,x,t),s(e,Se,t),d(Y,e,t),s(e,Le,t),s(e,G,t),s(e,qe,t),d(V,e,t),s(e,Pe,t),s(e,Q,t),s(e,De,t),d(E,e,t),s(e,Ke,t),s(e,H,t),s(e,Oe,t),s(e,z,t),s(e,et,t),d(F,e,t),s(e,tt,t),s(e,S,t),s(e,lt,t),d(L,e,t),s(e,st,t),s(e,q,t),s(e,nt,t),d(C,e,t),s(e,at,t),s(e,P,t),s(e,ot,t),s(e,D,t),s(e,it,t),d(K,e,t),s(e,rt,t),s(e,O,t),s(e,Mt,t),s(e,ee,t),s(e,pt,t),d(te,e,t),s(e,ct,t),s(e,le,t),s(e,mt,t),d(se,e,t),s(e,dt,t),s(e,ne,t),s(e,yt,t),s(e,ae,t),s(e,ut,t),d(oe,e,t),s(e,ft,t),s(e,ie,t),s(e,wt,t),d(re,e,t),s(e,ht,t),d(g,e,t),s(e,Jt,t),s(e,Me,t),s(e,Tt,t),d(pe,e,t),s(e,jt,t),s(e,ce,t),s(e,Ut,t),d(I,e,t),s(e,bt,t),s(e,me,t),s(e,Ct,t),s(e,de,t),s(e,gt,t),d(ye,e,t),s(e,It,t),s(e,ue,t),s(e,_t,t),d(fe,e,t),s(e,Zt,t),s(e,we,t),s(e,$t,t),d(_,e,t),s(e,At,t),s(e,he,t),s(e,vt,t),d(Je,e,t),s(e,kt,t),s(e,Te,t),s(e,Nt,t),d(je,e,t),s(e,Wt,t),s(e,Ue,t),s(e,Bt,t),d(be,e,t),s(e,Rt,t),s(e,Ce,t),s(e,Xt,t),d(ge,e,t),s(e,xt,t),s(e,Ie,t),s(e,Yt,t),s(e,_e,t),s(e,Gt,t),d(Ze,e,t),s(e,Vt,t),s(e,$e,t),s(e,Qt,t),d(Ae,e,t),s(e,Et,t),s(e,ve,t),s(e,Ht,t),d(ke,e,t),s(e,zt,t),s(e,Ne,t),s(e,Ft,t),s(e,Be,t),St=!0},p(e,[t]){const Bl={};t&2&&(Bl.$$scope={dirty:t,ctx:e}),C.$set(Bl);const Rl={};t&2&&(Rl.$$scope={dirty:t,ctx:e}),g.$set(Rl);const Xl={};t&2&&(Xl.$$scope={dirty:t,ctx:e}),I.$set(Xl);const xl={};t&2&&(xl.$$scope={dirty:t,ctx:e}),_.$set(xl)},i(e){St||(y(j.$$.fragment,e),y(A.$$.fragment,e),y(N.$$.fragment,e),y(Y.$$.fragment,e),y(V.$$.fragment,e),y(E.$$.fragment,e),y(F.$$.fragment,e),y(L.$$.fragment,e),y(C.$$.fragment,e),y(K.$$.fragment,e),y(te.$$.fragment,e),y(se.$$.fragment,e),y(oe.$$.fragment,e),y(re.$$.fragment,e),y(g.$$.fragment,e),y(pe.$$.fragment,e),y(I.$$.fragment,e),y(ye.$$.fragment,e),y(fe.$$.fragment,e),y(_.$$.fragment,e),y(Je.$$.fragment,e),y(je.$$.fragment,e),y(be.$$.fragment,e),y(ge.$$.fragment,e),y(Ze.$$.fragment,e),y(Ae.$$.fragment,e),y(ke.$$.fragment,e),St=!0)},o(e){u(j.$$.fragment,e),u(A.$$.fragment,e),u(N.$$.fragment,e),u(Y.$$.fragment,e),u(V.$$.fragment,e),u(E.$$.fragment,e),u(F.$$.fragment,e),u(L.$$.fragment,e),u(C.$$.fragment,e),u(K.$$.fragment,e),u(te.$$.fragment,e),u(se.$$.fragment,e),u(oe.$$.fragment,e),u(re.$$.fragment,e),u(g.$$.fragment,e),u(pe.$$.fragment,e),u(I.$$.fragment,e),u(ye.$$.fragment,e),u(fe.$$.fragment,e),u(_.$$.fragment,e),u(Je.$$.fragment,e),u(je.$$.fragment,e),u(be.$$.fragment,e),u(ge.$$.fragment,e),u(Ze.$$.fragment,e),u(Ae.$$.fragment,e),u(ke.$$.fragment,e),St=!1},d(e){e&&(l(T),l(p),l(h),l(w),l(U),l(Re),l(Z),l(Xe),l($),l(xe),l(Ye),l(v),l(Ge),l(k),l(Ve),l(Qe),l(W),l(Ee),l(B),l(He),l(R),l(ze),l(X),l(Fe),l(x),l(Se),l(Le),l(G),l(qe),l(Pe),l(Q),l(De),l(Ke),l(H),l(Oe),l(z),l(et),l(tt),l(S),l(lt),l(st),l(q),l(nt),l(at),l(P),l(ot),l(D),l(it),l(rt),l(O),l(Mt),l(ee),l(pt),l(ct),l(le),l(mt),l(dt),l(ne),l(yt),l(ae),l(ut),l(ft),l(ie),l(wt),l(ht),l(Jt),l(Me),l(Tt),l(jt),l(ce),l(Ut),l(bt),l(me),l(Ct),l(de),l(gt),l(It),l(ue),l(_t),l(Zt),l(we),l($t),l(At),l(he),l(vt),l(kt),l(Te),l(Nt),l(Wt),l(Ue),l(Bt),l(Rt),l(Ce),l(Xt),l(xt),l(Ie),l(Yt),l(_e),l(Gt),l(Vt),l($e),l(Qt),l(Et),l(ve),l(Ht),l(zt),l(Ne),l(Ft),l(Be)),l(M),f(j,e),f(A,e),f(N,e),f(Y,e),f(V,e),f(E,e),f(F,e),f(L,e),f(C,e),f(K,e),f(te,e),f(se,e),f(oe,e),f(re,e),f(g,e),f(pe,e),f(I,e),f(ye,e),f(fe,e),f(_,e),f(Je,e),f(je,e),f(be,e),f(ge,e),f(Ze,e),f(Ae,e),f(ke,e)}}}const Kl='{"title":"Building custom models","local":"building-custom-models","sections":[{"title":"Writing a custom configuration","local":"writing-a-custom-configuration","sections":[],"depth":2},{"title":"Writing a custom model","local":"writing-a-custom-model","sections":[],"depth":2},{"title":"Registering a model with custom code to the auto classes","local":"registering-a-model-with-custom-code-to-the-auto-classes","sections":[],"depth":2},{"title":"Sending the code to the Hub","local":"sending-the-code-to-the-hub","sections":[],"depth":2},{"title":"Using a model with custom code","local":"using-a-model-with-custom-code","sections":[],"depth":2}],"depth":1}';function Ol(b){return Ql(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class as extends El{constructor(M){super(),Hl(this,M,Ol,Dl,Vl,{})}}export{as as component};
