"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[132],{5242:function(e,t,n){n.d(t,{$Bv:function(){return AutoModelForSemanticSegmentation},$Sz:function(){return AutoModel},DcG:function(){return AutoModelForDocumentQuestionAnswering},ENH:function(){return AutoModelForCTC},En$:function(){return AutoModelForImageClassification},Hqk:function(){return AutoModelForCausalLM},K2m:function(){return AutoModelForAudioClassification},Kf0:function(){return AutoModelForSeq2SeqLM},LdW:function(){return AutoModelForZeroShotObjectDetection},OjJ:function(){return AutoModelForTokenClassification},S2d:function(){return AutoModelForImageToImage},U$$:function(){return AutoModelForImageSegmentation},Zn:function(){return AutoModelForObjectDetection},hY6:function(){return AutoModelForDepthEstimation},hZO:function(){return AutoModelForSpeechSeq2Seq},lbf:function(){return AutoModelForTextToSpectrogram},o$X:function(){return AutoModelForSequenceClassification},t78:function(){return AutoModelForMaskedLM},tLj:function(){return AutoModelForVision2Seq},v3$:function(){return CLIPTextModelWithProjection},wiU:function(){return AutoModelForQuestionAnswering},z6E:function(){return AutoModelForTextToWaveform}});var s=n(9252),r=n(1802),a=n(4320),i=n(2013),o=n(6001),d=n(6577),l=n(7582);let{InferenceSession:c,Tensor:u,env:_}=d.ONNX,M={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4,MaskGeneration:5},h=new Map,m=new Map,p=new Map;async function constructSession(e,t,n){let s=`onnx/${t}${n.quantized?"_quantized":""}.onnx`,r=await (0,a.st)(e,s,!0,n);try{return await c.create(r,{executionProviders:d.p})}catch(e){if(1===d.p.length&&"wasm"===d.p[0])throw e;return console.warn(e),console.warn("Something went wrong during model construction (most likely a missing operation). Using `wasm` as a fallback. "),await c.create(r,{executionProviders:["wasm"]})}}async function sessionRun(e,t){let n=function(e,t){let n=Object.create(null),s=[];for(let r of e.inputNames){let e=t[r];if(!(e instanceof o.es)){s.push(r);continue}n[r]=_.wasm.proxy?e.clone():e}if(s.length>0)throw Error(`An error occurred during model execution: "Missing the following inputs: ${s.join(", ")}.`);let r=Object.keys(t).length,a=e.inputNames.length;if(r>a){let n=Object.keys(t).filter(t=>!e.inputNames.includes(t));console.warn(`WARNING: Too many inputs were provided (${r} > ${a}). The following inputs will be ignored: "${n.join(", ")}".`)}return n}(e,t);try{let t=await e.run(n);return t=function replaceTensors(e){for(let t in e)e[t]instanceof u?e[t]=new o.es(e[t]):"object"==typeof e[t]&&replaceTensors(e[t]);return e}(t)}catch(e){throw console.error(`An error occurred during model execution: "${e}".`),console.error("Inputs given to model:",n),e}}function prepareAttentionMask(e,t){let n=e.config.pad_token_id??null,s=e.config.eos_token_id??null;(0,r.Wy)(s)&&(s=[s]);let a=-1!==t.indexOf(n),i=null===s||!s.includes(n);if(!a||!i)return(0,o.r6)(t);{let e=BigInt64Array.from(t.data.map(e=>e!=n));return new o.es("int64",e,t.dims)}}function preparePositionIds(e,t,n){if(!e.inputNames.includes("position_ids"))return;let s=new BigInt64Array(t.attention_mask.data.length);for(let e=0;eBigInt(e))),[1,e.length]);if(e.some(t=>t.length!==e[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new o.es("int64",BigInt64Array.from(e.flat().map(e=>BigInt(e))),[e.length,e[0].length])}(s),encoder_outputs:t.encoder_outputs,past_key_values:t.prev_model_outputs?.past_key_values};t.attention_mask&&(r.attention_mask=t.attention_mask);let a=await e.forward(r);return t.prev_model_outputs=a,t.encoder_outputs=a.encoder_outputs,a}function seq2seqUpdatebeam(e,t){e.output_token_ids=[...e.output_token_ids,t]}async function encoderForward(e,t){let n=Object.create(null);for(let s of e.session.inputNames)n[s]=t[s];return e.session.inputNames.includes("token_type_ids")&&!n.token_type_ids&&(n.token_type_ids=new o.es("int64",new BigInt64Array(n.input_ids.data.length),n.input_ids.dims)),await sessionRun(e.session,n)}async function decoderForward(e,t){let{input_ids:n,past_key_values:s,attention_mask:r}=t,a={input_ids:n,attention_mask:r??prepareAttentionMask(e,n)},i=!!s;e.session.inputNames.includes("use_cache_branch")&&(a.use_cache_branch=boolTensor(i)),preparePositionIds(e.session,a,i),e.addPastKeyValues(a,s);let o=await sessionRun(e.session,a);return{logits:o.logits,past_key_values:s=e.getPastKeyValues(o,s)}}function decoderStartBeams(e,t,n,s,r){let a=[],i=0;for(let n of t){let t,o=n.tolist().map(Number);n.dims=[1,...n.dims],r?(t=r[i]).dims=[1,...t.dims]:t=prepareAttentionMask(e,n);let d={input:n,model_input_ids:n,attention_mask:t,prev_model_outputs:null,output_token_ids:o,num_output_tokens:s,done:!1,score:0,id:i++};a.push(d)}return a}async function decoderRunBeam(e,t){let n=new BigInt64Array(t.output_token_ids.length).fill(1n),s={input_ids:t.model_input_ids,attention_mask:new o.es("int64",n,[1,n.length]),past_key_values:t.prev_model_outputs?.past_key_values},r=await e.forward(s);return t.prev_model_outputs=r,r}function decoderUpdatebeam(e,t){e.output_token_ids=[...e.output_token_ids,t],e.model_input_ids=new o.es("int64",[BigInt(t)],[1,1])}let PreTrainedModel=class PreTrainedModel extends r.Ag{main_input_name="input_ids";constructor(e,t){super(),this.config=e,this.session=t;let n=p.get(this.constructor),s=h.get(n);this.can_generate=!1,this._runBeam=null,this._getStartBeams=null,this._updateBeam=null,this._forward=null,s===M.DecoderOnly?(this.can_generate=!0,this._runBeam=decoderRunBeam,this._getStartBeams=decoderStartBeams,this._updateBeam=decoderUpdatebeam,this._forward=decoderForward):s===M.Seq2Seq||s===M.Vision2Seq?(this.can_generate=!0,this._runBeam=seq2seqRunBeam,this._getStartBeams=seq2seqStartBeams,this._updateBeam=seq2seqUpdatebeam,this._forward=seq2seqForward):(M.EncoderDecoder,this._forward=encoderForward)}async dispose(){let e=[];for(let t of Object.keys(this)){let n=this[t];n instanceof c&&e.push(n.handler.dispose())}return await Promise.all(e)}static async from_pretrained(e,{quantized:t=!0,progress_callback:n=null,config:r=null,cache_dir:i=null,local_files_only:o=!1,revision:d="main",model_file_name:l=null}={}){let c,u={quantized:t,progress_callback:n,config:r,cache_dir:i,local_files_only:o,revision:d,model_file_name:l},_=p.get(this),m=h.get(_);return m===M.DecoderOnly?c=await Promise.all([s.z.from_pretrained(e,u),constructSession(e,u.model_file_name??"decoder_model_merged",u),(0,a.yM)(e,"generation_config.json",!1,u)]):m===M.Seq2Seq||m===M.Vision2Seq?c=await Promise.all([s.z.from_pretrained(e,u),constructSession(e,"encoder_model",u),constructSession(e,"decoder_model_merged",u),(0,a.yM)(e,"generation_config.json",!1,u)]):m===M.MaskGeneration?c=await Promise.all([s.z.from_pretrained(e,u),constructSession(e,"vision_encoder",u),constructSession(e,"prompt_encoder_mask_decoder",u)]):m===M.EncoderDecoder?c=await Promise.all([s.z.from_pretrained(e,u),constructSession(e,"encoder_model",u),constructSession(e,"decoder_model_merged",u)]):(m!==M.EncoderOnly&&console.warn(`Model type for '${_}' not found, assuming encoder-only architecture. Please report this at https://github.com/xenova/transformers.js/issues/new/choose.`),c=await Promise.all([s.z.from_pretrained(e,u),constructSession(e,u.model_file_name??"model",u)])),new this(...c)}async _call(e){return await this.forward(e)}async forward(e){return await this._forward(this,e)}_get_logits_processor(e,t,n=null){let s=new i.Jm;if(null!==e.repetition_penalty&&1!==e.repetition_penalty&&s.push(new i.Jj(e.repetition_penalty)),null!==e.no_repeat_ngram_size&&e.no_repeat_ngram_size>0&&s.push(new i.jF(e.no_repeat_ngram_size)),null!==e.bad_words_ids&&s.push(new i.AE(e.bad_words_ids,e.eos_token_id)),null!==e.min_length&&null!==e.eos_token_id&&e.min_length>0&&s.push(new i.ez(e.min_length,e.eos_token_id)),null!==e.min_new_tokens&&null!==e.eos_token_id&&e.min_new_tokens>0&&s.push(new i.CJ(t,e.min_new_tokens,e.eos_token_id)),null!==e.forced_bos_token_id&&s.push(new i.C9(e.forced_bos_token_id)),null!==e.forced_eos_token_id&&s.push(new i.dZ(e.max_length,e.forced_eos_token_id)),null!==e.begin_suppress_tokens){let n=t>1||null===e.forced_bos_token_id?t:t+1;null!==e.forced_decoder_ids&&(n+=e.forced_decoder_ids[e.forced_decoder_ids.length-1][0]),s.push(new i.GU(e.begin_suppress_tokens,n))}return null!==e.forced_decoder_ids&&s.push(new i.E(e.forced_decoder_ids)),null!==n&&s.extend(n),s}_get_generation_config(e){let t=new i.aP(this.config);return"generation_config"in this&&Object.assign(t,this.generation_config),null!==e&&Object.assign(t,e),t}async generate(e,t=null,n=null,{inputs_attention_mask:s=null}={}){let a;if(!this.can_generate){let e=p.get(this.constructor),t=`The current model class (${e}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`,n=this.config.model_type,s=S.get(n)??k.get(n)??T.get(n)??v.get(n);throw s&&(t+=` Please use the following class instead: '${s[0]}'`),Error(t)}if(!(e instanceof o.es)&&!(0,r.fU)(e)&&!Array.isArray(e))throw Error(`\`inputs\` must be a Tensor, TypedArray, or Array, but is "${e.constructor.name}".`);if(this.config.is_encoder_decoder)a=0;else if(0===(a=e instanceof o.es?e.dims.at(-1):e.length))throw Error("Must supply a non-empty array of input token ids.");t=this._get_generation_config(t),n=n??new i.Jm,n=this._get_logits_processor(t,a,n);let d=t.eos_token_id;null===d||Array.isArray(d)||(d=[d]);let l=1,c=l+(t.max_new_tokens??1/0),u=Number.isInteger(t.max_length)&&(t.max_new_tokens??null)===null,_=i.Z4.getSampler(t),M=this.getStartBeams(e,t,l,s);for(;M.some(e=>!e.done)&&l=t.max_length){s.done=!0,e.push(s);continue}let r=await this.runBeam(s);t.output_attentions&&this.addAttentionsToBeam(s,r),t.output_scores;let a=r.logits.slice(null,-1,null);for(let[t,r]of(n(s.output_token_ids,a),_(a))){let n={...s};this.updateBeam(n,t),n.score+=r,d&&d.includes(t)&&(n.done=!0),e.push(n)}}++l,M=(e=this.groupBeams(e).map(e=>e.sort((e,t)=>t.score-e.score).slice(0,t.num_beams))).flat(),t.callback_function&&t.callback_function(M)}let h=this.groupBeams(M),getFlattened=e=>h.map(n=>t.num_return_sequences>1?n.slice(0,t.num_return_sequences).map(t=>t[e]):[n[0][e]]).flat(),m=getFlattened("output_token_ids");if(!t.return_dict_in_generate)return m;{let e=getFlattened("decoder_attentions"),t=getFlattened("cross_attentions");return{sequences:m,decoder_attentions:e,cross_attentions:t}}}addAttentionsToBeam(e,t){if(this.config.is_encoder_decoder){if(!t.cross_attentions||0===t.cross_attentions.length)throw Error("`output_attentions` is true, but the model did not produce cross-attentions. This is most likely because the model was not exported with `output_attentions=True`.");e.cross_attentions||(e.cross_attentions=[]),e.cross_attentions.push(t.cross_attentions)}if(!t.decoder_attentions||0===t.decoder_attentions.length)throw Error("`output_attentions` is true, but the model did not produce decoder-attentions. This is most likely because the model was not exported with `output_attentions=True`.");e.decoder_attentions||(e.decoder_attentions=[]),e.decoder_attentions.push(t.decoder_attentions)}groupBeams(e){let t=Object.create(null);for(let n of e)void 0===t[n.id]?t[n.id]=[n]:t[n.id].push(n);return Object.values(t)}getPastKeyValues(e,t){let n=Object.create(null);for(let s in e)if(s.startsWith("present")){let r=s.replace("present","past_key_values");t&&s.includes("encoder")?n[r]=t[r]:n[r]=e[s]}return n}getAttentions(e){let t=Object.create(null);for(let n of["cross_attentions","decoder_attentions"]){let s=[];for(let t in e)if(t.startsWith(n)){let n=t.split(".").pop();s[n]=e[t]}t[n]=s}return t}addPastKeyValues(e,t){if(t)Object.assign(e,t);else if(this.config.is_encoder_decoder&&(this.add_encoder_pkv??!0)){let t=[1,this.num_encoder_heads,0,this.encoder_dim_kv],n=[1,this.num_decoder_heads,0,this.decoder_dim_kv];for(let s=0;s{let s=Array.from({length:this.config.decoder_layers},(t,n)=>(0,o.d3)(e.map(e=>e[n]),2)),r=(0,o.kn)(t.map(([e,t])=>n?s[e].slice(null,t,null,[0,n]):s[e].slice(null,t)));r=r.transpose(1,0,2,3);let[i,d]=(0,o.f3)(r,-2,0,!0),c=r.clone();for(let e=0;en[t+1]-n[t]),l=(0,r.eG)([1],d).map(e=>!!e),u=[];for(let e=0;e=u&&(Array.from(r.data).filter(e=>e>=n).length>0||p>=c))break}let f=(0,o.d3)(M),{waveform:g}=await sessionRun(a.session,{spectrogram:f});return{spectrogram:f,waveform:g}}}]]]),x=new Map([["vits",["VitsModel",VitsModel]]]),y=new Map([["bert",["BertForSequenceClassification",class extends BertPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["roformer",["RoFormerForSequenceClassification",class extends RoFormerPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["electra",["ElectraForSequenceClassification",class extends ElectraPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["esm",["EsmForSequenceClassification",class extends EsmPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["convbert",["ConvBertForSequenceClassification",class extends ConvBertPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["camembert",["CamembertForSequenceClassification",class extends CamembertPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["deberta",["DebertaForSequenceClassification",class extends DebertaPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["deberta-v2",["DebertaV2ForSequenceClassification",class extends DebertaV2PreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["mpnet",["MPNetForSequenceClassification",class extends MPNetPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["albert",["AlbertForSequenceClassification",class extends AlbertPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["distilbert",["DistilBertForSequenceClassification",class extends DistilBertPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["roberta",["RobertaForSequenceClassification",class extends RobertaPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["xlm",["XLMForSequenceClassification",class extends XLMPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["xlm-roberta",["XLMRobertaForSequenceClassification",class extends XLMRobertaPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["bart",["BartForSequenceClassification",class extends BartPretrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["mbart",["MBartForSequenceClassification",class extends MBartPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["mobilebert",["MobileBertForSequenceClassification",class extends MobileBertPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["squeezebert",["SqueezeBertForSequenceClassification",class extends SqueezeBertPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]]]),b=new Map([["bert",["BertForTokenClassification",class extends BertPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["roformer",["RoFormerForTokenClassification",class extends RoFormerPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["electra",["ElectraForTokenClassification",class extends ElectraPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["esm",["EsmForTokenClassification",class extends EsmPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["convbert",["ConvBertForTokenClassification",class extends ConvBertPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["camembert",["CamembertForTokenClassification",class extends CamembertPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["deberta",["DebertaForTokenClassification",class extends DebertaPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["deberta-v2",["DebertaV2ForTokenClassification",class extends DebertaV2PreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["mpnet",["MPNetForTokenClassification",class extends MPNetPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["distilbert",["DistilBertForTokenClassification",class extends DistilBertPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["roberta",["RobertaForTokenClassification",class extends RobertaPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["xlm",["XLMForTokenClassification",class extends XLMPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]],["xlm-roberta",["XLMRobertaForTokenClassification",class extends XLMRobertaPreTrainedModel{async _call(e){return new TokenClassifierOutput(await super._call(e))}}]]]),k=new Map([["t5",["T5ForConditionalGeneration",class extends T5PreTrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.num_decoder_layers,this.num_decoder_heads=this.config.num_heads,this.decoder_dim_kv=this.config.d_kv,this.num_encoder_layers=this.config.num_layers,this.num_encoder_heads=this.config.num_heads,this.encoder_dim_kv=this.config.d_kv}}]],["longt5",["LongT5ForConditionalGeneration",class extends LongT5PreTrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.num_decoder_layers,this.num_decoder_heads=this.config.num_heads,this.decoder_dim_kv=this.config.d_kv,this.num_encoder_layers=this.config.num_layers,this.num_encoder_heads=this.config.num_heads,this.encoder_dim_kv=this.config.d_kv}}]],["mt5",["MT5ForConditionalGeneration",class extends MT5PreTrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.num_decoder_layers,this.num_decoder_heads=this.config.num_heads,this.decoder_dim_kv=this.config.d_kv,this.num_encoder_layers=this.config.num_layers,this.num_encoder_heads=this.config.num_heads,this.encoder_dim_kv=this.config.d_kv}}]],["bart",["BartForConditionalGeneration",class extends BartPretrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}]],["mbart",["MBartForConditionalGeneration",class extends MBartPreTrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}]],["marian",["MarianMTModel",class extends MarianPreTrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}]],["m2m_100",["M2M100ForConditionalGeneration",class extends M2M100PreTrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}]],["blenderbot",["BlenderbotForConditionalGeneration",class extends BlenderbotPreTrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}]],["blenderbot-small",["BlenderbotSmallForConditionalGeneration",class extends BlenderbotSmallPreTrainedModel{constructor(e,t,n,s){super(e,t),this.decoder_merged_session=n,this.generation_config=s,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}]]]),S=new Map([["bloom",["BloomForCausalLM",class extends BloomPreTrainedModel{}]],["gpt2",["GPT2LMHeadModel",class extends GPT2PreTrainedModel{}]],["gptj",["GPTJForCausalLM",class extends GPTJPreTrainedModel{}]],["gpt_bigcode",["GPTBigCodeForCausalLM",class extends GPTBigCodePreTrainedModel{}]],["gpt_neo",["GPTNeoForCausalLM",class extends GPTNeoPreTrainedModel{}]],["gpt_neox",["GPTNeoXForCausalLM",class extends GPTNeoXPreTrainedModel{}]],["codegen",["CodeGenForCausalLM",class extends CodeGenPreTrainedModel{}]],["llama",["LlamaForCausalLM",class extends LlamaPreTrainedModel{}]],["phi",["PhiForCausalLM",class extends PhiPreTrainedModel{}]],["mpt",["MptForCausalLM",class extends MptPreTrainedModel{}]],["opt",["OPTForCausalLM",class extends OPTPreTrainedModel{}]],["mbart",["MBartForCausalLM",class extends MBartPreTrainedModel{constructor(e,t,n){super(e,t),this.generation_config=n,this.num_decoder_layers=this.config.decoder_layers,this.num_decoder_heads=this.config.decoder_attention_heads,this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads,this.num_encoder_layers=this.config.encoder_layers,this.num_encoder_heads=this.config.encoder_attention_heads,this.encoder_dim_kv=this.config.d_model/this.num_encoder_heads}}]],["mistral",["MistralForCausalLM",class extends MistralPreTrainedModel{}]],["falcon",["FalconForCausalLM",class extends FalconPreTrainedModel{}]],["trocr",["TrOCRForCausalLM",class extends TrOCRPreTrainedModel{}]]]),C=new Map([["bert",["BertForMaskedLM",class extends BertPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["roformer",["RoFormerForMaskedLM",class extends RoFormerPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["electra",["ElectraForMaskedLM",class extends ElectraPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["esm",["EsmForMaskedLM",class extends EsmPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["convbert",["ConvBertForMaskedLM",class extends ConvBertPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["camembert",["CamembertForMaskedLM",class extends CamembertPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["deberta",["DebertaForMaskedLM",class extends DebertaPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["deberta-v2",["DebertaV2ForMaskedLM",class extends DebertaV2PreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["mpnet",["MPNetForMaskedLM",class extends MPNetPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["albert",["AlbertForMaskedLM",class extends AlbertPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["distilbert",["DistilBertForMaskedLM",class extends DistilBertPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["roberta",["RobertaForMaskedLM",class extends RobertaPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["xlm",["XLMWithLMHeadModel",class extends XLMPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["xlm-roberta",["XLMRobertaForMaskedLM",class extends XLMRobertaPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["mobilebert",["MobileBertForMaskedLM",class extends MobileBertPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]],["squeezebert",["SqueezeBertForMaskedLM",class extends SqueezeBertPreTrainedModel{async _call(e){return new MaskedLMOutput(await super._call(e))}}]]]),O=new Map([["bert",["BertForQuestionAnswering",class extends BertPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["roformer",["RoFormerForQuestionAnswering",class extends RoFormerPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["electra",["ElectraForQuestionAnswering",class extends ElectraPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["convbert",["ConvBertForQuestionAnswering",class extends ConvBertPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["camembert",["CamembertForQuestionAnswering",class extends CamembertPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["deberta",["DebertaForQuestionAnswering",class extends DebertaPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["deberta-v2",["DebertaV2ForQuestionAnswering",class extends DebertaV2PreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["mpnet",["MPNetForQuestionAnswering",class extends MPNetPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["albert",["AlbertForQuestionAnswering",class extends AlbertPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["distilbert",["DistilBertForQuestionAnswering",class extends DistilBertPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["roberta",["RobertaForQuestionAnswering",class extends RobertaPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["xlm",["XLMForQuestionAnswering",class extends XLMPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["xlm-roberta",["XLMRobertaForQuestionAnswering",class extends XLMRobertaPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["mobilebert",["MobileBertForQuestionAnswering",class extends MobileBertPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]],["squeezebert",["SqueezeBertForQuestionAnswering",class extends SqueezeBertPreTrainedModel{async _call(e){return new QuestionAnsweringModelOutput(await super._call(e))}}]]]),v=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",VisionEncoderDecoderModel]]]),F=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",VisionEncoderDecoderModel]]]),A=new Map([["vit",["ViTForImageClassification",class extends ViTPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["mobilevit",["MobileViTForImageClassification",class extends MobileViTPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["beit",["BeitForImageClassification",class extends BeitPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["deit",["DeiTForImageClassification",class extends DeiTPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["convnext",["ConvNextForImageClassification",class extends ConvNextPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["convnextv2",["ConvNextV2ForImageClassification",class extends ConvNextV2PreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["dinov2",["Dinov2ForImageClassification",class extends Dinov2PreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["resnet",["ResNetForImageClassification",class extends ResNetPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["swin",["SwinForImageClassification",class extends SwinPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["segformer",["SegformerForImageClassification",class extends SegformerPreTrainedModel{}]]]),L=new Map([["detr",["DetrForObjectDetection",class extends DetrPreTrainedModel{async _call(e){return new DetrObjectDetectionOutput(await super._call(e))}}]],["table-transformer",["TableTransformerForObjectDetection",class extends TableTransformerPreTrainedModel{async _call(e){return new TableTransformerObjectDetectionOutput(await super._call(e))}}]],["yolos",["YolosForObjectDetection",class extends YolosPreTrainedModel{async _call(e){return new YolosObjectDetectionOutput(await super._call(e))}}]]]),B=new Map([["owlvit",["OwlViTForObjectDetection",class extends OwlViTPreTrainedModel{}]]]),q=new Map([["detr",["DetrForSegmentation",class extends DetrPreTrainedModel{async _call(e){return new DetrSegmentationOutput(await super._call(e))}}]],["clipseg",["CLIPSegForImageSegmentation",class extends CLIPSegPreTrainedModel{}]]]),D=new Map([["segformer",["SegformerForSemanticSegmentation",class extends SegformerPreTrainedModel{}]]]),E=new Map([["sam",["SamModel",class extends SamPreTrainedModel{constructor(e,t,n){super(e,t),this.prompt_encoder_mask_decoder=n}async get_image_embeddings({pixel_values:e}){return await encoderForward(this,{pixel_values:e})}async forward(e){if(e.image_embeddings&&e.image_positional_embeddings||(e={...e,...await this.get_image_embeddings(e)}),!e.input_labels){let t=e.input_points.dims.slice(0,-1),n=t.reduce((e,t)=>e*t,1);e.input_labels=new o.es("int64",new BigInt64Array(n).fill(1n),t)}return await sessionRun(this.prompt_encoder_mask_decoder,{input_points:e.input_points,input_labels:e.input_labels,image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings})}async _call(e){return new SamImageSegmentationOutput(await super._call(e))}}]]]),I=new Map([["wav2vec2",["Wav2Vec2ForCTC",class extends Wav2Vec2PreTrainedModel{async _call(e){return new CausalLMOutput(await super._call(e))}}]],["wavlm",["WavLMForCTC",class extends WavLMPreTrainedModel{async _call(e){return new CausalLMOutput(await super._call(e))}}]],["hubert",["HubertForCTC",class extends Wav2Vec2PreTrainedModel{async _call(e){return new CausalLMOutput(await super._call(e))}}]]]),N=new Map([["wav2vec2",["Wav2Vec2ForSequenceClassification",class extends Wav2Vec2PreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["wavlm",["WavLMForSequenceClassification",class extends WavLMPreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["hubert",["HubertForSequenceClassification",class extends Wav2Vec2PreTrainedModel{async _call(e){return new SequenceClassifierOutput(await super._call(e))}}]],["audio-spectrogram-transformer",["ASTForAudioClassification",class extends ASTPreTrainedModel{}]]]),G=new Map([["vitmatte",["VitMatteForImageMatting",class extends VitMattePreTrainedModel{async _call(e){return new ImageMattingOutput(await super._call(e))}}]]]),V=new Map([["swin2sr",["Swin2SRForImageSuperResolution",class extends Swin2SRPreTrainedModel{}]]]),R=new Map([["dpt",["DPTForDepthEstimation",class extends DPTPreTrainedModel{}]],["glpn",["GLPNForDepthEstimation",class extends GLPNPreTrainedModel{}]]]),j=[[f,M.EncoderOnly],[g,M.EncoderDecoder],[P,M.DecoderOnly],[y,M.EncoderOnly],[b,M.EncoderOnly],[k,M.Seq2Seq],[T,M.Seq2Seq],[S,M.DecoderOnly],[C,M.EncoderOnly],[O,M.EncoderOnly],[v,M.Vision2Seq],[A,M.EncoderOnly],[q,M.EncoderOnly],[D,M.EncoderOnly],[G,M.EncoderOnly],[V,M.EncoderOnly],[R,M.EncoderOnly],[L,M.EncoderOnly],[B,M.EncoderOnly],[E,M.MaskGeneration],[I,M.EncoderOnly],[N,M.EncoderOnly],[w,M.Seq2Seq],[x,M.EncoderOnly]];for(let[e,t]of j)for(let[n,s]of e.values())h.set(n,t),p.set(s,n),m.set(n,s);let z=[["CLIPTextModelWithProjection",CLIPTextModelWithProjection,M.EncoderOnly],["CLIPVisionModelWithProjection",class extends CLIPPreTrainedModel{static async from_pretrained(e,t={}){return t.model_file_name??="vision_model",super.from_pretrained(e,t)}},M.EncoderOnly],["SiglipTextModel",class extends SiglipPreTrainedModel{static async from_pretrained(e,t={}){return t.model_file_name??="text_model",super.from_pretrained(e,t)}},M.EncoderOnly],["SiglipVisionModel",class extends CLIPPreTrainedModel{static async from_pretrained(e,t={}){return t.model_file_name??="vision_model",super.from_pretrained(e,t)}},M.EncoderOnly],["ClapTextModelWithProjection",class extends ClapPreTrainedModel{static async from_pretrained(e,t={}){return t.model_file_name??="text_model",super.from_pretrained(e,t)}},M.EncoderOnly],["ClapAudioModelWithProjection",class extends ClapPreTrainedModel{static async from_pretrained(e,t={}){return t.model_file_name??="audio_model",super.from_pretrained(e,t)}},M.EncoderOnly]];for(let[e,t,n]of z)h.set(e,n),p.set(t,e),m.set(e,t);let AutoModel=class AutoModel extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=j.map(e=>e[0]);static BASE_IF_FAIL=!0};let AutoModelForSequenceClassification=class AutoModelForSequenceClassification extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[y]};let AutoModelForTokenClassification=class AutoModelForTokenClassification extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[b]};let AutoModelForSeq2SeqLM=class AutoModelForSeq2SeqLM extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[k]};let AutoModelForSpeechSeq2Seq=class AutoModelForSpeechSeq2Seq extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[T]};let AutoModelForTextToSpectrogram=class AutoModelForTextToSpectrogram extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[w]};let AutoModelForTextToWaveform=class AutoModelForTextToWaveform extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[x]};let AutoModelForCausalLM=class AutoModelForCausalLM extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[S]};let AutoModelForMaskedLM=class AutoModelForMaskedLM extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[C]};let AutoModelForQuestionAnswering=class AutoModelForQuestionAnswering extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[O]};let AutoModelForVision2Seq=class AutoModelForVision2Seq extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[v]};let AutoModelForImageClassification=class AutoModelForImageClassification extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[A]};let AutoModelForImageSegmentation=class AutoModelForImageSegmentation extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[q]};let AutoModelForSemanticSegmentation=class AutoModelForSemanticSegmentation extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[D]};let AutoModelForObjectDetection=class AutoModelForObjectDetection extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[L]};let AutoModelForZeroShotObjectDetection=class AutoModelForZeroShotObjectDetection extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[B]};let AutoModelForCTC=class AutoModelForCTC extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[I]};let AutoModelForAudioClassification=class AutoModelForAudioClassification extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[N]};let AutoModelForDocumentQuestionAnswering=class AutoModelForDocumentQuestionAnswering extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[F]};let AutoModelForImageToImage=class AutoModelForImageToImage extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[V]};let AutoModelForDepthEstimation=class AutoModelForDepthEstimation extends PretrainedMixin{static MODEL_CLASS_MAPPINGS=[R]};let Seq2SeqLMOutput=class Seq2SeqLMOutput extends ModelOutput{constructor({logits:e,past_key_values:t,encoder_outputs:n,decoder_attentions:s=null,cross_attentions:r=null}){super(),this.logits=e,this.past_key_values=t,this.encoder_outputs=n,this.decoder_attentions=s,this.cross_attentions=r}};let SequenceClassifierOutput=class SequenceClassifierOutput extends ModelOutput{constructor({logits:e}){super(),this.logits=e}};let TokenClassifierOutput=class TokenClassifierOutput extends ModelOutput{constructor({logits:e}){super(),this.logits=e}};let MaskedLMOutput=class MaskedLMOutput extends ModelOutput{constructor({logits:e}){super(),this.logits=e}};let QuestionAnsweringModelOutput=class QuestionAnsweringModelOutput extends ModelOutput{constructor({start_logits:e,end_logits:t}){super(),this.start_logits=e,this.end_logits=t}};let CausalLMOutput=class CausalLMOutput extends ModelOutput{constructor({logits:e}){super(),this.logits=e}};let ImageMattingOutput=class ImageMattingOutput extends ModelOutput{constructor({alphas:e}){super(),this.alphas=e}};let VitsModelOutput=class VitsModelOutput extends ModelOutput{constructor({waveform:e,spectrogram:t}){super(),this.waveform=e,this.spectrogram=t}}}}]);