1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[36089],{36:(e,t,r)=>{"use strict";r.d(t,{H:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({acos_:function(e){let t=(0,s.YT)(e,"x","acos");return n.T2.runKernel(a.Vvy,{x:t})}})},294:(e,t,r)=>{"use strict";function n(e){let{inputs:t,backend:r}=e,{x:n}=t;return r.incRef(n.dataId),{dataId:n.dataId,shape:n.shape,dtype:n.dtype}}r.d(t,{D:()=>n,F:()=>a});let a={kernelName:r(45720).lzr,backendName:"cpu",kernelFunc:n}},466:(e,t,r)=>{"use strict";r.d(t,{M:()=>function e(t,r){if(null==t)return null;if("string"==typeof t)return n.uc(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){let n=[],s=t.length;for(let i=0;i<s;++i){let s=t[i];a(r,i,s)?n.push(s):n.push(e(s,r))}return n}{let r={};for(let a of Object.keys(t)){let s=t[a],i=n.uc(a);("name"===a||"className"===a)&&"string"==typeof s?r[i]=s:r[i]=e(s,a)}return r}},w:()=>function e(t,r){if(null===t)return null;if("string"==typeof t)return n.Cb(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){let n=[],s=t.length;for(let i=0;i<s;++i){let s=t[i];a(r,i,s)?n.push(s):n.push(e(s,r))}return n}{let r={};for(let a of Object.keys(t)){let s=t[a];if("name"===a&&"string"==typeof s)r[a]=s;else{let t=n.Cb(a);r[t]=e(s,t)}}return r}}});var n=r(95971);function a(e,t,r){return("inboundNodes"===e||"outputLayers"===e||"inputLayers"===e)&&0===t&&"string"==typeof r}},590:(e,t,r)=>{"use strict";r.d(t,{L:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({round_:function(e){let t=(0,s.YT)(e,"x","round");return n.T2.runKernel(a.hVg,{x:t})}})},1056:(e,t,r)=>{"use strict";r.d(t,{V:()=>f});var n=r(54463),a=r(75681),s=r(44769),i=r(64256),o=r(29573),l=r(78412),u=r(39616),h=r(18875),p=r(86036),d=r(68396),c=r(79625);let f=(0,h.op)({logSumExp_:function(e,t=null,r=!1){let h=(0,n.YT)(e,"x","logSumExp"),f=(0,a.Y6)(t,h.shape),m=(0,u.T)(h,f,!0),g=(0,d.j)(h,m),y=(0,o.o)(g),b=(0,c.c)(y,f),x=(0,l.R)(b),v=(0,s.W)((0,p.t)(m,x.shape),x);if(r){let e=(0,i.SM)(v.shape,f);return(0,p.t)(v,e)}return v}})},1272:(e,t,r)=>{"use strict";r.d(t,{O:()=>p,c:()=>c});var n=r(45720),a=r(54868),s=r(63537),i=r(61237),o=r(95971),l=r(52326);function u(e,t){let r,a;r=t.xs,a=t.ys,n.ZSL.assert(null!=r&&null!=a,()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${t}`);let s=h("input",e.inputNames,r),i=h("output",e.outputNames,a),o=s[0].shape[0];n.ZSL.assert(s.length===e.inputs.length,()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${s.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`),n.ZSL.assert(i.length===e.outputs.length,()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${i.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`);for(let t=0;t<s.length;t++)n.ZSL.assert(s[t].shape[0]===o,()=>`Batch size mismatch: input ${e.inputNames[t]} has ${s[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`);for(let t=0;t<i.length;t++)n.ZSL.assert(i[t].shape[0]===o,()=>`Batch size mismatch: output ${e.outputNames[t]} has ${i[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`);return{xs:s,ys:i}}function h(e,t,r){if(r instanceof n.qYS)return[r];if(Array.isArray(r))return n.ZSL.assert(r.length===t.length,()=>`Received an array of ${r.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`),r;{let n=[];for(let a of t){if(null==r[a])throw new s.Qp(`The feature data generated by the dataset lacks the required ${e} key '${a}'.`);n.push(r[a])}return n}}async function p(e,t,r){let h=null!=r.batchesPerEpoch;if(n.ZSL.assert(null!=e.optimizer,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),n.ZSL.assert(null!=r,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),n.ZSL.assert(null!=r.epochs&&r.epochs>0&&Number.isInteger(r.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${r.epochs}`),n.ZSL.assert(!h||r.batchesPerEpoch>0&&Number.isInteger(r.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${r.batchesPerEpoch}`),n.ZSL.assert(null==r.validationSplit,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),e.isTraining)throw Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;try{var p,c;let f,m,g,y,b=null!=r.validationData;if(b)if(d(r.validationData))n.ZSL.assert(null==r.validationBatches||r.validationBatches>
10&&Number.isInteger(r.validationBatches),()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${r.validationBatches}`);else{let e=function(e){if(3===e.length)throw new s.EH("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}(r.validationData);f=e.xs,m=e.ys}let x=e.makeTrainFunction(),v=e.getDedupedMetricsNames();g=b?v.slice().concat(v.map(e=>"val_"+e)):v.slice();let w=(0,a.Eq)(r.callbacks,r.yieldEvery),T=null==r.verbose?1:r.verbose,{callbackList:S,history:N}=(0,a.dY)(w,T,r.epochs,null,null,(p=t,c=r,y=null,null!=c.batchesPerEpoch?y=c.batchesPerEpoch:Number.isFinite(p.size)&&(y=p.size),y),null,b,g);S.setModel(e),e.history=N,await S.onTrainBegin(),e.stopTraining_=!1;let k=null==r.initialEpoch?0:r.initialEpoch,I=await t.iterator();for(;k<r.epochs;){let a={};await S.onEpochBegin(k);let s=0,p=0;for(h||(I=await t.iterator());!h||s<r.batchesPerEpoch;){let t=await I.next();if(h&&t.done){console.warn(`You provided \`batchesPerEpoch\` as ${r.batchesPerEpoch}, but your dataset iterator ran out of data after ${s} batches; interrupting training. Make sure that your dataset can generate at least \`batchesPerEpoch * epochs\` batches (in this case, ${r.batchesPerEpoch*r.epochs} batches). You may need to use the repeat() function when building your dataset.`);break}if(null!=t.value){let{xs:a,ys:o}=u(e,t.value),h={};h.batch=p,h.size=a[0].shape[0],await S.onBatchBegin(p,h);let d=[];if(null!=r.classWeight){let t=(0,l.zO)(r.classWeight,e.outputNames);for(let e=0;e<t.length;++e)d.push(await (0,l.tP)(o[e],null,t[e]))}let c=a.concat(o).concat(d),f=x(c);n.ASo(c);for(let e=0;e<v.length;++e){let t=v[e],r=f[e];h[t]=r,n.aCs(r)}await S.onBatchEnd(p,h),(0,i.i)(h),p++,s++}if(h?s>=r.batchesPerEpoch:t.done){if(b){let t;t=d(r.validationData)?(0,o.st)(await e.evaluateDataset(r.validationData,{batches:r.validationBatches})):(0,o.st)(e.evaluate(f,m,{batchSize:null==r.validationBatchSize?32:r.validationBatchSize,verbose:0}));for(let r=0;r<e.metricsNames.length;++r)a[`val_${e.metricsNames[r]}`]=t[r]}break}if(e.stopTraining_)break}if(await S.onEpochEnd(k,a),k++,e.stopTraining_)break}return await S.onTrainEnd(),await e.history.syncData(),e.history}finally{e.isTraining=!1}}function d(e){return"function"==typeof e.iterator}async function c(e,t,r){let a=null!=(r=r||{}).batches,i=e.testFunction,l=[];if(r.verbose>0)throw new s.EH("Verbose mode is not implemented yet.");n.ZSL.assert(!a||r.batches>0&&Number.isInteger(r.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(r.batches)}`);let h="function"==typeof t.next?t:await t.iterator(),p=0,d=0;for(;!a||d<r.batches;){let t=await h.next();if(l=n.DZQ(()=>{if(t.value){let{xs:r,ys:a}=u(e,t.value),s=r.concat(a),o=n.DZQ(()=>i(s));if(n.ASo(s),0===d)for(let e=0;e<o.length;++e)l.push((0,n.d_2)(0));let h=s[0].shape[0];for(let e=0;e<o.length;++e){let t=o[e],r=l[e];l[e]=n.DZQ(()=>n.WQq(l[e],n.lKK(h,t))),d>0&&n.ASo(r)}n.ASo(o),p+=h,++d}return l}),t.done){a&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${r.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let e=0;e<l.length;++e){let t=l[e];l[e]=n.y4m(l[e],p),n.ASo(t)}return(0,o.wL)(l)}},1275:(e,t,r)=>{"use strict";r.d(t,{f:()=>a});var n=r(45720);function a(e,t){let r=n.ZSL.getArrayFromDType("int32",e.length);for(let a=0;a<e.length;++a)r[a]=n.ZSL.fingerPrint64(e[a]).modulo(t).getLowBitsUnsigned();return r}},1357:(e,t,r)=>{"use strict";r.d(t,{bU:()=>function e(t,r){if(!(t in a)||null!=r){let e=function(e,t){if(1!==e&&2!==e)throw Error("Cannot get WebGL rendering context, WebGL is disabled.");let r=null==t?function(e){if(!(0,n._K2)().getBool("IS_SAFARI")&&"undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw Error("Cannot create a canvas in this context")}(e):t;return(r.addEventListener("webglcontextlost",t=>{t.preventDefault(),delete a[e]},!1),(0,n._K2)().getBool("SOFTWARE_WEBGL_ENABLED")&&(s.failIfMajorPerformanceCaveat=!1),1===e)?r.getContext("webgl",s)||r.getContext("experimental-webgl",s):r.getContext("webgl2",s)}(t,r);if(null===e)return console.log("Could not get context for WebGL version",t),null;a[t]=e}let i=a[t];return null==i||i.isContextLost()?(delete a[t],e(t)):(i.disable(i.DEPTH_TEST),i.disable(i.STENCIL_TEST),i.disable(i.BLEND),i.disable(i.DITHER),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SAMPLE_COVERAGE),i.enable(i.SCISSOR_TEST),i.enable(i.CULL_FACE),i.cullFace(i.BACK),a[t])},lj:()=>i});var n=r(45720);let a={},s={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function i(e,t){a[e]=t}},1888:(e,t,r)=>{"use strict";r.d(t,{dH:()=>s,lO:()=>i});var n=r(45720),a=r(60072);function s(e){let t=new Float32Array(e.length);for(let r=0;r<e.length;++r)t[r]=Math.abs(e[r]);return t}let i={kernelName:n.ljI,backendName:"cpu",kernelFunc:e=>{let{x:t}=e.inputs,r=e.backend;(0,a.C)(t,"abs");
1let i=new Float32Array(n.ZSL.sizeFromShape(t.shape));return i=s(r.data.get(t.dataId).values),r.makeOutput(i,t.shape,t.dtype)}}},2498:(e,t,r)=>{"use strict";r.d(t,{Hc:()=>l,vS:()=>i});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)(e=>Math.floor(e)),o=(0,s.F)(n.ZgB,i),l={kernelName:n.ZgB,backendName:"cpu",kernelFunc:o}},2536:(e,t,r)=>{"use strict";r.r(t),r.d(t,{calculateShapes:()=>i,validateInput:()=>s,validateUpdateShape:()=>a});var n=r(75681);function a(e,t,r){let n=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,s=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${r.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${n}, and batchDim: ${a}.`;if(r.rank<a)throw Error(s+` update.rank < ${a}. `);if(e.length<n+(r.rank-a))throw Error(s+` Output shape length < ${n+(r.rank-a)}`);if(r.rank!==a+e.length-n)throw Error(s+` update.rank != ${a+e.length-n}`);for(let e=0;e<a;++e)if(r.shape[e]!==t.shape[e])throw Error(s+` updates.shape[${e}] (${r.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`);for(let t=0;t<r.rank-a;++t)if(r.shape[t+a]!==e[t+n])throw Error(s+` updates.shape[${t+a}] (${r.shape[t+a]}) != shape[${t+a}] (${e[t+a]})`)}function s(e,t,r){if(t.rank<1)throw Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==t.dtype)throw Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(r.length<1)throw Error(`Output rank must be greater or equal to 1, but got shape: ${r}`);if(0===r.length){if(0===t.size)throw Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(0===e.size)throw Error(`Updates specified for empty output. updates shape: ${e.shape}`)}a(r,t,e)}function i(e,t,r){let a=t.shape.length,s=a>1?t.shape[a-1]:1,i=r.length,o=1;for(let e=s;e<i;++e)o*=r[e];let l=s<1?1:s,u=(0,n.Ze)(t.shape)/l,h=[...(0,n.Ur)(r.slice(0,s)),1];return{sliceRank:s,numUpdates:u,sliceSize:o,strides:h,outputSize:(0,n.Ze)(r)}}},2632:(e,t,r)=>{"use strict";r.d(t,{B:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({reverse_:function(e,t){let r=(0,s.YT)(e,"x","reverse");return n.T2.runKernel(a.D7i,{x:r},{dims:t})}})},2748:(e,t,r)=>{"use strict";r.d(t,{Ar:()=>c,Wd:()=>y,X6:()=>function e(t,r,n){if((null==r||null!=n&&n>0)&&(r=t.sourceLayer,n=t.nodeIndex),0===r.inboundNodes.length)return[t];{let t=r.inboundNodes[n];if(0===t.inboundLayers.length)return t.inputTensors;{let r=[];for(let n=0;n<t.inboundLayers.length;n++){let a=t.inputTensors[n];for(let s of e(a,t.inboundLayers[n],t.nodeIndices[n]))-1===r.indexOf(s)&&r.push(s)}return r}}},bP:()=>m,eO:()=>d});var n=r(45720),a=r(38180),s=r(48671),i=r(63537),o=r(42290),l=r(95971),u=r(21131),h=r(50186),p=r(17031);class d{constructor(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class c{constructor(e,t,r,n,i,o,l){this.dtype=e,this.shape=t,this.sourceLayer=r,this.inputs=n,this.callArgs=i,this.outputTensorIndex=l,this.id=(0,a.j)(),null!=o&&(this.originalName=(0,s.BC)(o),this.name=(0,s.Uc)(this.originalName)),this.rank=t.length}}let f=0;class m{constructor(e,t){for(let r of(this.callArgs=t,this.id=f++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes,e.inboundLayers))null!=r&&r.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){let e=[];for(let t of this.inboundLayers)null!=t?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let g=0;class y extends n.JFn.Serializable{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=g++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){let e=this.getClassName();t=l.uc(e)+"_"+(0,a.v)(e)}if(this.name=t,this.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){let t;if(null!=e.batchInputShape)t=e.batchInputShape;else if(null!=e.inputShape){let r=null;null!=e.batchSize&&(r=e.batchSize),t=[r].concat(e.inputShape)}this.batchInputShape=t;let r=e.dtype;null==r&&(r=e.inputDType),null==r&&(r="float32"),this.dtype=r}null!=e.weights?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}
1static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(0===this.inboundNodes.length)throw new i.bu(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new i.Qp(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return l.wL(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return l.wL(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new i.l7(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new i.l7(`Layer ${this.name} is not connected, no input to return.`);return l.wL(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new i.l7(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new i.l7(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return l.wL(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map(e=>e())}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach(t=>t.trainable=e),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter(e=>e.trainable):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter(e=>!e.trainable).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){let t=l.st(e);if(null==this.inputSpec||0===this.inputSpec.length)return;let r=l.st(this.inputSpec);if(t.length!==r.length)throw new i.Qp(`Layer ${this.name} expects ${r.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`);for(let e=0;e<t.length;e++){let n=t[e],a=r[e];if(null==a)continue;let s=n.rank;if(null!=a.ndim&&s!==a.ndim)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected ndim=${a.ndim}, found ndim=${s}`);if(null!=a.maxNDim&&s>a.maxNDim)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected max_ndim=${a.maxNDim}, found ndim=${s}`);if(null!=a.minNDim&&s<a.minNDim)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected min_ndim=${a.minNDim}, found ndim=${s}.`);if(null!=a.dtype&&n.dtype!==a.dtype)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name} : expected dtype=${a.dtype}, found dtype=${n.dtype}.`);if(a.axes){let t=n.shape;for(let r in a.axes){let n=Number(r),s=a.axes[r],o=n>=0?t[n]:t[t.length+n];if(null!=s&&-1===[s,null].indexOf(o))throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected axis ${n} of input shape to have value ${s} but got shape ${t}.`)}}if(null!=a.shape)for(let t=0;t<a.shape.length;++t){let r=a.shape[t],s=n.shape[t];if(null!=r&&null!=s&&r!==s)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected shape=${a.shape}, found shape=${n.shape}.`)}}}call(e,t){return e}invokeCallHook(e,t){null!=this._callHook&&this._callHook(e,t)}setCallHook(e){this._callHook=e}clearCallHook(){this._callHook=null}apply(e,t){t=t||{},this.assertNotDisposed();let r=l.st(e),n=function(e){let t=!0;for(let r of l.st(e))if(!(r instanceof c)){t=!1;break}return t}(e),a=function(e){let t=!0;for(let r of l.st(e))if(r instanceof c){t=!1;break}return t}(e);if(n===a)throw new i.Qp("Arguments to apply() must be all SymbolicTensors or all Tensors");return(0,s.IU)(this.name,()=>{if(!this.built){this.assertInputCompatibility(e);let t=[];for(let r of l.st(e))t.push(r.shape);this.build(l.wL(t)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&a&&(this._refCount=1)}if(this.assertInputCompatibility(e),a){let n=this.call(e,t);this.supportsMasking&&this.setMaskMetadata(e,n);let a=l.st(n),s=[];for(let e of a)-1!==r.indexOf(e)&&(e=e.clone()),s.push(e);if(n=l.wL(s),null!=this.activityRegularizer)throw new i.EH("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return n}{let r,n=function(e){e=l.st(e);let t=[];for(let r of e)t.push(r.shape);return l.wL(t)}(e),a=this.computeOutputShape(n),s="float32";if(this.warnOnIncompatibleInputShape(Array.isArray(e)?n[0]:n),r=null!=a&&a.length>0&&Array.isArray(a[0])?a.map((r,n)=>new c(s,r,this,l.st(e),t,this.name,n)):new c(s,a,this,l.st(e),t,this.name),this.addInboundNode(e,r,null,null,n,a,t),this._refCount++,null!=this.activityRegularizer)throw new i.EH("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return r}})}warnOnIncompatibleInputShape(e){if(null!=this.batchInputShape)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach((r,n)=>{null!=r&&null!=e[n]&&e[n]!==r&&(t=!0)}),t&&console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}
1get outputShape(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new i.l7(`The layer ${this.name} has never been called and thus has no defined output shape.`);let e=[];for(let t of this.inboundNodes){let r=JSON.stringify(t.outputShapes);-1===e.indexOf(r)&&e.push(r)}if(1===e.length){let e=this.inboundNodes[0].outputShapes;return Array.isArray(e)&&Array.isArray(e[0])&&1===e.length?e[0]:e}throw new i.l7(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new i.bu(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return h.Y(this.weights)}build(e){this.built=!0}getWeights(e=!1){return(0,p.ex)(e?this.trainableWeights:this.weights)}setWeights(e){(0,n.DZQ)(()=>{let t=this.weights;if(t.length!==e.length)throw new i.Qp(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`);if(0===t.length)return;let r=[],a=(0,p.ex)(t);for(let s=0;s<a.length;++s){let o=a[s],l=t[s],u=e[s];if(!n.ZSL.arraysEqual(o.shape,u.shape))throw new i.Qp(`Layer weight shape ${o.shape} not compatible with provided weight shape ${u.shape}`);r.push([l,u])}(0,p.UM)(r)})}addWeight(e,t,r,n,a,s,l,u){if(-1!==this._addedWeightNames.indexOf(e))throw new i.Qp(`Duplicate weight name ${e} for layer ${this.name}`);this._addedWeightNames.push(e),null==r&&(r="float32"),this.fastWeightInitDuringBuild&&(n=null!=u?u():(0,o.Fe)("zeros"));let h=n.apply(t,r),d=new p.eR(h,r,e,s,l);return h.dispose(),null!=a&&this.addLoss(()=>a.apply(d.read())),null==s&&(s=!0),s?this._trainableWeights.push(d):this._nonTrainableWeights.push(d),d}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){null==e||Array.isArray(e)&&0===e.length||(e=l.st(e),void 0!==this._losses&&null!==this._losses&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(null!=t)if(Array.isArray(t))t.forEach(e=>{if(null!=e)throw TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return t}setMaskMetadata(e,t,r){if(!this.supportsMasking)return;let n=this.computeMask(e,r),a=l.st(t),s=l.st(n);if(a.length!==s.length)throw Error(`${this.name} outputs ${a.length} tensors but ${a.length} masks for those tensors`);for(let e=0;e<a.length;e++)a[e].kerasMask=s[e]}addInboundNode(e,t,r,n,a,s,i=null){let o=l.st(e);t=l.st(t),r=l.st(r),n=l.st(n),a=u.FS(a),s=u.FS(s);let h=[],p=[],d=[];for(let e of o)h.push(e.sourceLayer),p.push(e.nodeIndex),d.push(e.tensorIndex);new m({outboundLayer:this,inboundLayers:h,nodeIndices:p,tensorIndices:d,inputTensors:o,outputTensors:t,inputMasks:r,outputMasks:n,inputShapes:a,outputShapes:s},i);for(let e=0;e<t.length;e++)t[e].sourceLayer=this,t[e].nodeIndex=this.inboundNodes.length-1,t[e].tensorIndex=e}getConfig(){let e={name:this.name,trainable:this.trainable};return null!=this.batchInputShape&&(e.batchInputShape=this.batchInputShape),null!=this.dtype&&(e.dtype=this.dtype),e}disposeWeights(){return this.weights.forEach(e=>e.dispose()),this.weights.length}assertNotDisposed(){if(0===this._refCount)throw Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(null===this._refCount)throw Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return 0==--this._refCount&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}},3117:(e,t,r)=>{"use strict";r.d(t,{Hq:()=>d,Nb:()=>h,UC:()=>p,X0:()=>l,X8:()=>u,_Q:()=>i,dR:()=>s,hE:()=>a,pd:()=>o});var n=r(71490);class a{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length),this.userCode=` 2 float unaryOperation(float x) { 3 ${t} 4 } 5 6 void main() { 7 float x = getAAtOutCoords(); 8 float y = unaryOperation(x); 9 10 setOutput(y); 11 } 12 `}}let s="if (isnan(x)) return x;",i="return x;",o="return abs(x);",l="return (x >= 0.0) ? x : (exp(x) - 1.0);",u=s+` 13 return (x < 0.0) ? 0.0 : x; 14`,h=s+` 15 return (x < 0.0) ? 0.0 : min(6.0, x); 16`,p="return x;",d="return 1.0 / (1.0 + exp(-1.0 * x));"},3282:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(46519),a=r(71490),s=r(15768);class i{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];let r=(0,n.B)();this.outputShape=e,this.enableShapeUniforms=(0,a.ik)(this.outputShape.length);let i="",o="result";t&&(o="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){let a=2*t+n;i+=` 17 localCoords = coords; 18 if(localCoords[2] + ${n} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) { 19 localCoords[2] += ${n}; 20 if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) { 21 localCoords[1] += ${t}; 22 23 flatIndex = getFlatIndex(localCoords); 24 offset = imod(flatIndex, 4); 25 26 flatIndex = idiv(flatIndex, 4, 1.); 27 28 int r = flatIndex / texShape[1]; 29 int c = imod(flatIndex, texShape[1]); 30 vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); 31 values = ${r.texture2D}(A, uv); 32 33 if (offset == 0) { 34 result[${a}] = values[0]; 35 } else if (offset == 1) { 36 result[${a}] = values[1]; 37 } else if (offset == 2) { 38 result[${a}] = values[2]; 39 } else { 40 result[${a}] = values[3]; 41 } 42 } 43 } 44 `}this.userCode=` 45 ${this.enableShapeUniforms?s.Od():s.fM(e)} 46 47 void main() { 48 ivec3 coords = getOutputCoords(); 49 50 vec4 result = vec4(0.); 51 int flatIndex, r, c, offset; 52 ivec3 localCoords; 53 vec2 uv; 54 vec4 values; 55 56 ${i} 57 58 ${r.output} = ${o}; 59 } 60 `}}},3344:(e,t,r)=>{"use strict";r.d(t,{V:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({relu_:function(e){let t=(0,s.YT)(e,"x","relu");return n.T2.runKernel(a.fUj,{x:t})}})},3535:(e,t,r)=>{"use strict";r.d(t,{K:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({unstack_:function(e,t=0){let r=(0,s.YT)(e,"x","unstack","string_or_numeric");return i.vA(t>=-r.shape.length&&t<r.shape.length,()=>`Axis = ${t} is not in [-${r.shape.length}, ${r.shape.length})`),n.T2.runKernel(a.dXR,{value:r},{axis:t})}})},3824:(e,t,r)=>{"use strict";r.d(t,{P:()=>u});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990),l=r(13797);let u=(0,r(18875).op)({maximum_:function(e,t){let r=(0,i.YT)(e,"a","maximum"),u=(0,i.YT)(t,"b","maximum");[r,u]=(0,s.makeTypesMatch)(r,u),"bool"===r.dtype&&(r=(0,l.w)(r,"int32"),u=(0,l.w)(u,"int32")),(0,o.assertAndGetBroadcastShape)(r.shape,u.shape);let h={a:r,b:u};return n.T2.runKernel(a.LDN,h)}})},4006:(e,t,r)=>{"use strict";r.d(t,{t:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({abs_:function(e){let t=(0,s.YT)(e,"x","abs");return"complex64"===t.dtype?n.T2.runKernel(a.$zE,{x:t}):n.T2.runKernel(a.ljI,{x:t})}})},4047:(e,t,r)=>{"use strict";r.d(t,{S:()=>function e(t,r="float32"){if((0,a.SA)(t),"complex64"===r){let r=e(t,"float32"),n=(0,i.U)(t,"float32");return(0,s.f)(r,n)}let o=(0,a.FZ)((0,a.Ze)(t),r);return n.T2.makeTensor(o,t,r)}});var n=r(5287),a=r(75681),s=r(47802),i=r(45921)},4087:(e,t,r)=>{"use strict";r.d(t,{o:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({clone_:function(e){let t=(0,s.YT)(e,"x","clone","string_or_numeric");return n.T2.runKernel(a.lzr,{x:t})}})},4768:(e,t,r)=>{"use strict";r.d(t,{LC:()=>o,RY:()=>l,z3:()=>i});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>+(e===t)),o=(0,s.j)(n.BRl,i,null,"bool"),l={kernelName:n.BRl,backendName:"cpu",kernelFunc:o}},5185:(e,t,r)=>{"use strict";r.d(t,{c:()=>l});var n=r(2748),a=r(45720),s=r(21131),i=r(63537),o=r(40693);class l extends n.Wd{constructor(e){super(e),this.numTokens=e.numTokens,e.outputMode?this.outputMode=e.outputMode:this.outputMode="multiHot"}getConfig(){let e={numTokens:this.numTokens,outputMode:this.outputMode};return Object.assign(e,super.getConfig()),e}computeOutputShape(e){return null==(e=(0,s.U$)(e))?[this.numTokens]:("oneHot"===this.outputMode&&1!==e[e.length-1]?e.push(this.numTokens):e[e.length-1]=this.numTokens,e)}call(e,t){return(0,a.DZQ)(()=>{let r;if("int32"!==(e=(0,s.un)(e)).dtype&&(e=o.wg(e,"int32")),void 0!==t.countWeights){if("count"!==this.outputMode)throw new i.Qp(`countWeights is not used when outputMode !== count. 61 Received countWeights=${t.countWeights}`);r=(0,s.un)(t.countWeights)}let n=(0,a.T9B)(e),l=(0,a.jkA)(e),u=(0,a.rhj)(this.numTokens,n).bufferSync().get(0),h=(0,a.DQN)(l,0).bufferSync().get(0);if(!(u&&h))throw new i.Qp(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);return function(e,t,r,n){let l,u=(0,s.un)(e);if("int32"!==u.dtype&&(u=o.wg(u,"int32")),"int"===t)return u;let h=u.shape;if(0===u.rank&&(u=(0,a.UG6)(u,-1)),"oneHot"===t&&1!==u.shape[u.shape.length-1]&&(u=(0,a.UG6)(u,-1)),u.rank>2)throw new i.Qp(`When outputMode is not int, maximum output rank is 2 Received outputMode ${t} and input shape ${h}
61 which would result in output rank ${u.rank}.`);let p=["multiHot","oneHot"].includes(t),d=u;if(l=void 0!==n&&"count"===t?(0,a.aOp)(d,n,r,p):(0,a.aOp)(d,[],r,p),"tfIdf"!==t)return l;if(n)return(0,a.lKK)(l,n);throw new i.Qp("When outputMode is 'tfIdf', weights must be provided.")}(e,this.outputMode,this.numTokens,r)})}}l.className="CategoryEncoding",a.JFn.registerClass(l)},5232:(e,t,r)=>{"use strict";r.d(t,{E:()=>l});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990);let l=(0,r(18875).op)({notEqual_:function(e,t){let r=(0,i.YT)(e,"a","notEqual","string_or_numeric"),l=(0,i.YT)(t,"b","notEqual","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.ylV,u)}})},5287:(e,t,r)=>{"use strict";r.d(t,{T2:()=>x,Ye:()=>b});var n=r(61325),a=r(67984),s=r(90945),i=r(96609),o=r(22548),l=r(5663),u=r(22700),h=r(75681);class p{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new d)}profileKernel(e,t,r){let n,s,i=()=>{n=r()},o=u.now();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(i);else{for(let e of(i(),n))e.dataSync();s=Promise.resolve({kernelMs:u.now()-o})}if((0,a._K)().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<n.length;t++){let r=n[t];r.data().then(t=>{!function(e,t,r){if("float32"===t)for(let t=0;t<e.length;t++){let n=e[t];if(isNaN(n)||!isFinite(n))return console.warn(`Found ${n} in the result of '${r}'`),!0}}(t,r.dtype,e)})}return{kernelName:e,outputs:n,inputs:t,timeMs:s.then(e=>e.kernelMs),extraInfo:s.then(e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:r,timeMs:n,inputs:a,extraInfo:s}=e;r.forEach(e=>{Promise.all([e.data(),n,s]).then(r=>{this.logger.logKernelProfile(t,e,r[0],r[1],a,r[2])})})}}class d{logKernelProfile(e,t,r,n,a,s){let i="number"==typeof n?h.av(`${n}ms`,9):n.error,o=h.av(e,25),l=t.rank,u=t.size,p=h.av(t.shape.toString(),14),d="";for(let e in a){let r=a[e];if(null!=r){let n=r.shape||t.shape,a=n.length;d+=`${e}: ${a}D ${a>0?n:""} `}}console.log(`%c${o} %c${i} %c${l}D ${p} %c${u} %c${d} %c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}var c=r(94708),f=r(72155);function m(e){return null!=e.kernelName}class g{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map(e=>e.name)))}}}dispose(){for(let e in this.registeredVariables)this.registeredVariables[e].dispose()}}class y{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new g}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then(()=>{});if(null!=this.backendInstance)return;let e=this.getSortedBackends();for(let t=0;t<e.length;t++){let r=e[t];if(await this.initializeBackend(r).success)return void await this.setBackend(r)}throw Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){let{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry))if(!(e in this.registryFactory))return null;else{let{asyncInit:t}=this.initializeBackend(e);if(t)return null}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,r=1){return e in this.registryFactory?(l.i(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:r},!0)}async setBackend(e){if(null==this.registryFactory[e])throw Error(`Backend name '${e}' not found in registry`);
61if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;let{success:t,asyncInit:r}=this.initializeBackend(e);if(!(r?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new p(this.backendInstance),!0}setupRegisteredKernels(){(0,o.Op)(this.backendName).forEach(e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){(0,o.Op)(e).forEach(t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])})}initializeBackend(e){let t=this.registryFactory[e];if(null==t)throw Error(`Cannot initialize backend ${e}, no registration found.`);try{let r=t.factory();if(!r||r instanceof n.uI||"function"!=typeof r.then)return this.registry[e]=r,{success:!0,asyncInit:!1};{let t=++this.pendingBackendInitId,n=r.then(r=>!(t<this.pendingBackendInitId)&&(this.registry[e]=r,this.pendingBackendInit=null,!0)).catch(r=>!(t<this.pendingBackendInitId)&&(this.pendingBackendInit=null,l.i(`Initialization of backend ${e} failed`),l.i(r.stack||r.message),!1));return this.pendingBackendInit=n,{success:n,asyncInit:!0}}}catch(t){return l.i(`Initialization of backend ${e} failed`),l.i(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){let e=this.getSortedBackends();for(let t=0;t<e.length;t++){let r=e[t],{success:n,asyncInit:a}=this.initializeBackend(r);if(a||n)return{name:r,asyncInit:a}}throw Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){let r=this.state.tensorInfo.get(t),n=r.backend,a=this.readSync(t),s=n.refCount(t);n.disposeData(t,!0),r.backend=e,e.move(t,a,r.shape,r.dtype,s),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let r,n=null;if(null==t){if("function"!=typeof e)throw Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw Error("When calling with two arguments, the 2nd argument to tidy() must be a function");n=e}return this.scopedRun(()=>this.startScope(n),()=>this.endScope(r),()=>((r=t())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),r))}scopedRun(e,t,r){e();try{let e=r();return t(),e}catch(e){throw t(),e}}nextTensorId(){return y.nextTensorId++}nextVariableId(){return y.nextVariableId++}clone(e){let t=x.runKernel(i.lzr,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],e=>({x:()=>x.runKernel(i.KXH,{x:e},{dtype:"float32"})}),[],{}),t}runKernel(e,t,r){if(null==this.backendName&&this.backend,null==(0,o._5)(e,this.backendName))throw Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:r})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,r){let n=this.backend.numDataIds(),a=0;r.forEach(e=>{a+="complex64"===e.dtype?3:1});let s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=n-t-a-s;if(i>0)throw Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,r,n,a,s=[],i=this.isTapeOn(),l=this.state.numBytes,u=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;let p=m(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(m(e)){let{kernelName:t,inputs:a,attrs:l}=e;null==this.backendName&&this.backend;let u=(0,o._5)(t,this.backendName);h.vA(null!=u,()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`),r=()=>{let e=this.backend.numDataIds(),r=Array.isArray(n=u.kernelFunc({input
61s:a,attrs:l,backend:this.backend}))?n:[n];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,r);let o=r.map(e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e));if(i){let e=this.getTensorsForGradient(t,a,o);s=this.saveTensorsForBackwardMode(e)}return o}}else{let{forwardFunc:t}=e,a=e=>{i&&(s=e.map(e=>this.keep(this.clone(e))))};r=()=>{let e=this.backend.numDataIds(),r=Array.isArray(n=this.tidy(()=>t(this.backend,a)))?n:[n];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(p,e,r),r}}let{inputs:d,attrs:c}=e,f=m(e)?null:e.backwardsFunc;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(a=this.profiler.profileKernel(p,d,()=>r()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(a),t=a.outputs):t=r()}),i&&this.addTapeNode(p,d,t,f,s,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:p,bytesAdded:this.state.numBytes-l,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-u,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(d).map(e=>null!=d[e]?d[e].shape:null),outputShapes:t.map(e=>e.shape),kernelTimeMs:a.timeMs,extraInfo:a.extraInfo}),Array.isArray(n)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(e=>this.keep(this.clone(e)))}getTensorsForGradient(e,t,r){let n=(0,o.vQ)(e);if(null!=n){let e,a=n.inputsToSave||[],s=n.outputsToSave||[];n.saveAllInputs?(h.vA(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),e=Object.keys(t).map(e=>t[e])):e=a.map(e=>t[e]);let i=r.filter((e,t)=>s[t]);return e.concat(i)}return[]}makeTensor(e,t,r,n){if(null==e)throw Error("Values passed to engine.makeTensor() are null");r=r||"float32",n=n||this.backend;let a=e;"string"===r&&h.Kg(e[0])&&(a=e.map(e=>u.encodeString(e)));let s=n.write(a,t,r),i=new c.qY(t,r,s,this.nextTensorId());if(this.trackTensor(i,n),"string"===r){let e=this.state.tensorInfo.get(s),t=(0,h.SL)(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return i}makeTensorFromDataId(e,t,r,n){let a={dataId:e,shape:t,dtype:r=r||"float32"};return this.makeTensorFromTensorInfo(a,n)}makeTensorFromTensorInfo(e,t){let{dataId:r,shape:n,dtype:a}=e,s=new c.qY(n,a,r,this.nextTensorId());return this.trackTensor(s,t),s}makeVariable(e,t=!0,r,n){r=r||this.nextVariableId().toString(),null!=n&&n!==e.dtype&&(e=e.cast(n));let a=new c.rT(e,t,r,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let r=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(r=e.size*h.jv(e.dtype)),this.state.numBytes+=r,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:r})),e instanceof c.rT||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;let t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){let t=e.size*h.jv(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(let e in this.state.registeredVariables){let t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){let e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;let t=this.state.numBytes,r=this.state.numTensors;for(let n of(this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(e=>e.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-r,this.state.activeProfile.kernels))n.kernelTimeMs=await n.kernelTimeMs,n.extraInfo=await n.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>
610&&0===this.state.kernelDepth}addTapeNode(e,t,r,n,a,s){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:r,saved:a},l=(0,o.vQ)(e);null!=l&&(n=l.gradFunc),null!=n&&(i.gradient=e=>(e=e.map((e,t)=>{if(null==e){let e=r[t],n=h.Ty(e.size,e.dtype);return this.makeTensor(n,e.shape,e.dtype)}return e}),n(e.length>1?e:e[0],a,s))),this.state.activeTape.push(i)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){let t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){let t=(0,f.getTensorsInContainer)(e),r=new Set(t.map(e=>e.id));for(let e=0;e<this.state.activeScope.track.length;e++){let t=this.state.activeScope.track[e];t.kept||r.has(t.id)||t.dispose()}let n=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(e=>{e.kept||e.scopeId!==n.id||this.track(e)})}gradients(e,t,r,n=!1){if(h.vA(t.length>0,()=>"gradients() received an empty list of xs."),null!=r&&"float32"!==r.dtype)throw Error(`dy must have 'float32' dtype, but has '${r.dtype}'`);let a=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));h.vA(a instanceof c.qY,()=>"The result y returned by f() must be a tensor.");let s=function(e,t,r){let n={},a={};for(let e=0;e<t.length;e++)n[t[e].id]=!0;for(let r=0;r<e.length;r++){let s=e[r],i=s.inputs;for(let e in i){let r=i[e],o=!1;for(let e=0;e<t.length;e++)if(n[r.id]){s.outputs.forEach(e=>n[e.id]=!0),o=!0,a[s.id]=!0;break}if(o)break}}let s={};s[r.id]=!0;let i={};for(let t=e.length-1;t>=0;t--){let r=e[t],n=r.inputs;for(let e=0;e<r.outputs.length;e++)if(s[r.outputs[e].id]){for(let e in n)s[n[e].id]=!0,i[r.id]=!0;break}}let o=[];for(let t=0;t<e.length;t++){let r=e[t];if(a[r.id]&&i[r.id]){let e={};for(let t in r.inputs){let a=r.inputs[t];n[a.id]&&(e[t]=a)}let t=Object.assign({},r);t.inputs=e,t.outputs=r.outputs,o.push(t)}}return o}(this.state.activeTape,t,a);if(!n&&0===s.length&&t.length>0)throw Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",()=>{let e={};e[a.id]=null==r?function(e){let t=(0,h.FZ)((0,h.Ze)(e),"float32");return x.makeTensor(t,e,"float32")}(a.shape):r,function(e,t,r,n){for(let a=t.length-1;a>=0;a--){let s=t[a],i=[];if(s.outputs.forEach(t=>{let r=e[t.id];null!=r?i.push(r):i.push(null)}),null==s.gradient)throw Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);let o=s.gradient(i);for(let t in s.inputs){if(!(t in o))throw Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);let a=r(()=>o[t]());if("float32"!==a.dtype)throw Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);let i=s.inputs[t];if(!h.r1(a.shape,i.shape))throw Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${i.shape}'`);if(null==e[i.id])e[i.id]=a;else{let t=e[i.id];e[i.id]=n(t,a),t.dispose()}}}}(e,s,e=>this.tidy(e),v);let n=t.map(t=>e[t.id]);return 0===this.state.gradientDepth&&(this.state.activeTape.forEach(e=>{for(let t of e.saved)t.dispose()}),this.state.activeTape=null),{value:a,grads:n}})}customGrad(e){return h.vA(h.Tn(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{let r;h.vA(t.every(e=>e instanceof c.qY),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n={};return t.forEach((e,t)=>{n[t]=e}),this.runKernelFunc({forwardFunc:(n,a)=>(r=e(...t,a),h.vA(r.value instanceof c.qY,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),h.vA(h.Tn(r.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),r.value),backwardsFunc:(e,n)=>{let a=r.gradFunc(e,n),s=Array.isArray(a)?a:[a];h.vA(s.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),h.vA(s.every(e=>e instanceof c.qY),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let i={};
61return s.forEach((e,t)=>{i[t]=()=>e}),i},inputs:n})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){let t=(0,u.now)(),r=await this.backend.time(e);return r.wallMs=(0,u.now)()-t,r}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){for(let e in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new g,this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function b(){let e=(0,s.L)();if(null==e._tfengine){let t=new a.OH(e);e._tfengine=new y(t)}return(0,a.tj)(e._tfengine.ENV),(0,c.qP)(()=>e._tfengine),e._tfengine}y.nextTensorId=0,y.nextVariableId=0;let x=b();function v(e,t){return x.runKernel(i.OMN,{a:e,b:t})}},5512:(e,t,r)=>{"use strict";function n(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}r.d(t,{Y:()=>n})},5663:(e,t,r)=>{"use strict";r.d(t,{R:()=>s,i:()=>a});var n=r(67984);function a(...e){(0,n._K)().getBool("IS_TEST")||(0,n._K)().getBool("PROD")||console.warn(...e)}function s(...e){(0,n._K)().getBool("IS_TEST")||(0,n._K)().getBool("PROD")||console.log(...e)}},7907:(e,t,r)=>{"use strict";r.d(t,{H:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({leakyRelu_:function(e,t=.2){let r=(0,s.YT)(e,"x","leakyRelu");return n.T2.runKernel(a.X0$,{x:r},{alpha:t})}})},8046:(e,t,r)=>{"use strict";r.d(t,{z:()=>l});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(41891);let l=(0,r(18875).op)({clipByValue_:function(e,t,r){let l=(0,s.YT)(e,"x","clipByValue");return(i.vA(t<=r,()=>`Error in clip: min (${t}) must be less than or equal to max (${r}).`),t===r)?(0,o.G)(l.shape,t,l.dtype):n.T2.runKernel(a.vaV,{x:l},{clipValueMin:t,clipValueMax:r})}})},8202:(e,t,r)=>{"use strict";r.d(t,{B:()=>l,j:()=>o});var n=r(45720),a=r(60072),s=r(13419),i=r(83772);function o(e,t,r,o){return null==r?({inputs:r,backend:s})=>{let{a:i,b:l}=r;(0,a.C)([i,l],e);let u=s.data.get(i.dataId).values,h=s.data.get(l.dataId).values,p="string"===i.dtype?n.C0T.fromUint8ToStringArray(u):u,d="string"===i.dtype?n.C0T.fromUint8ToStringArray(h):h,c=o||i.dtype,[f,m]=t(i.shape,l.shape,p,d,c);return s.makeTensorInfo(m,c,f)}:({inputs:e,backend:n})=>{let{a,b:l}=e;if("complex64"===a.dtype||"complex64"===l.dtype){let e=(0,s.wg)({inputs:{x:a},backend:n,attrs:{dtype:"complex64"}}),t=n.data.get(e.dataId),o=t.complexTensorInfos.real,u=t.complexTensorInfos.imag,h=n.data.get(o.dataId).values,p=n.data.get(u.dataId).values,d=(0,s.wg)({inputs:{x:l},backend:n,attrs:{dtype:"complex64"}}),c=n.data.get(d.dataId),f=c.complexTensorInfos.real,m=c.complexTensorInfos.imag,g=n.data.get(f.dataId).values,y=n.data.get(m.dataId).values,[b,x,v]=r(a.shape,l.shape,h,p,g,y),w=n.makeTensorInfo(v,"float32",b),T=n.makeTensorInfo(v,"float32",x),S=(0,i.f)({inputs:{real:w,imag:T},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(T),S}{let e=n.data.get(a.dataId).values,r=n.data.get(l.dataId).values,s=o||a.dtype,[i,u]=t(a.shape,l.shape,e,r,s);return n.makeTensorInfo(u,s,i)}}}function l(e){return(t,r,a,s,i,o)=>{let l=n.C0T.assertAndGetBroadcastShape(t,r),u=n.ZSL.sizeFromShape(l),h=l.length,p=n.ZSL.computeStrides(l),d=n.ZSL.getTypedArrayFromDType("float32",u),c=n.ZSL.getTypedArrayFromDType("float32",u),f=n.C0T.getBroadcastDims(t,l),m=n.C0T.getBroadcastDims(r,l),g=n.C0T.mergeRealAndImagArrays(a,s),y=n.C0T.mergeRealAndImagArrays(i,o),b=t.length,x=n.ZSL.computeStrides(t),v=r.length,w=n.ZSL.computeStrides(r);if(f.length+m.length===0)for(let t=0;t<d.length;t++){let r=t%g.length,n=t%y.length,a=e(g[2*r],g[2*r+1],y[2*n],y[2*n+1]);d[t]=a.real,c[t]=a.imag}else for(let t=0;t<d.length;t++){let r=n.ZSL.indexToLoc(t,h,p),a=r.slice(-b);
61f.forEach(e=>a[e]=0);let s=n.ZSL.locToIndex(a,b,x),i=r.slice(-v);m.forEach(e=>i[e]=0);let o=n.ZSL.locToIndex(i,v,w),l=e(g[2*s],g[2*s+1],y[2*o],y[2*o+1]);d[t]=l.real,c[t]=l.imag}return[d,c,l]}}},8750:(e,t,r)=>{"use strict";r.d(t,{R:()=>s});var n=r(71490),a=r(15768);class s{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length);let r="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),r+=` 62 ${t} 63 ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""} 64 int flatIndex = getFlatIndex(thisRC); 65 66 ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex); 67 vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z)); 68 69 result[${e}] = 70 getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims); 71 ${e>0?"}":""} 72 `}this.userCode=` 73 ${function(e,t){let r=t?a.TN(["r","c","d"],"inputShape"):a.UG(["r","c","d"],e);return` 74 ivec3 inputCoordsFromReshapedOutCoords(int index) { 75 ${r} 76 return ivec3(r, c, d); 77 } 78 `}(t,this.enableShapeUniforms)} 79 ${this.enableShapeUniforms?a.Od():a.fM(e)} 80 81 void main() { 82 ivec3 rc = getOutputCoords(); 83 84 vec4 result = vec4(0.); 85 86 ivec3 thisRC; 87 int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]}; 88 int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]}; 89 90 ${r} 91 92 setOutput(result); 93 } 94 `}}},11983:(e,t,r)=>{"use strict";r.d(t,{E:()=>s});var n=r(5287),a=r(54463);let s=(0,r(18875).op)({square_:function(e){let t=(0,a.YT)(e,"x","square");return n.T2.runKernel("Square",{x:t},{})}})},12223:(e,t,r)=>{"use strict";r.d(t,{i:()=>s});var n=r(45720),a=r(95971);function s(e,t={},r=!1){return(0,a.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"layer",r)}},12575:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({onesLike_:function(e){let t=(0,s.YT)(e,"x","onesLike");return n.T2.runKernel(a.LWX,{x:t})}})},13219:(e,t,r)=>{"use strict";r.d(t,{_:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({sign_:function(e){let t=(0,s.YT)(e,"x","sign");return n.T2.runKernel(a.YVe,{x:t})}})},13419:(e,t,r)=>{"use strict";r.d(t,{Ml:()=>p,ct:()=>u,wg:()=>h});var n=r(45720),a=r(16879),s=r(81963),i=r(83772),o=r(294),l=r(71604);function u(e,t,r,s){if("int32"===s)return[t,"int32",Int32Array.from(e)];if("bool"===s){let s=n.ZSL.toTypedArray([0],r),[i,o]=(0,a.Z)((e,t)=>+(e!==t))(t,[],e,s,"bool");return[o,"bool",i]}throw Error(`Error in Cast: failed to cast ${r} to ${s}`)}function h(e){let{inputs:t,backend:r,attrs:a}=e,{x:p}=t,{dtype:d}=a;if("complex64"===d){if("complex64"===p.dtype)return(0,o.D)({inputs:{x:p},backend:r});let e=(0,s.U)(r,p.shape,p.dtype),t=h({inputs:{x:p},backend:r,attrs:{dtype:"float32"}}),n=(0,i.f)({inputs:{real:t,imag:e},backend:r});return r.disposeIntermediateTensorInfo(e),r.disposeIntermediateTensorInfo(t),n}if("complex64"===p.dtype){let e=(0,l.x)({inputs:{input:p},backend:r}),t=h({inputs:{x:e},backend:r,attrs:{dtype:d}});return r.disposeIntermediateTensorInfo(e),t}if(!n.ZSL.hasEncodingLoss(p.dtype,d)){let e=(0,o.D)({inputs:{x:p},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:d}}let[c,f,m]=u(r.data.get(p.dataId).values,p.shape,p.dtype,d);return r.makeTensorInfo(c,f,m)}let p={kernelName:n.KXH,backendName:"cpu",kernelFunc:h}},13649:(e,t,r)=>{"use strict";r.d(t,{AS:()=>g,DZ:()=>m,Gc:()=>v,Hi:()=>d,Hs:()=>I,IS:()=>u,ME:()=>f,Ok:()=>C,Sm:()=>o,W4:()=>N,aC:()=>y,fL:()=>h,gJ:()=>k,gY:()=>l,go:()=>S,jh:()=>x,jz:()=>w,kB:()=>b,m1:()=>c,rE:()=>T,rm:()=>p});var n=r(5287),a=r(67984),s=r(94708),i=r(72155);function o(){(0,a._K)().set("PROD",!0)}function l(){(0,a._K)().set("DEBUG",!0)}function u(){(0,a._K)().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function h(e){(0,a._K)().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function p(){n.T2.disposeVariables()}function d(){return n.T2}function c(){return n.T2.memory()}function f(e){return n.T2.profile(e)}function m(e,t){return n.T2.tidy(e,t)}
94function g(e){(0,i.getTensorsInContainer)(e).forEach(e=>e.dispose())}function y(e){return n.T2.keep(e)}function b(e){return n.T2.time(e)}function x(e){return n.T2.setBackend(e)}function v(){return n.T2.ready()}function w(){return n.T2.backendName}function T(e){n.T2.removeBackend(e)}function S(e){return n.T2.findBackend(e)}function N(e){return n.T2.findBackendFactory(e)}function k(e,t,r=1){return n.T2.registerBackend(e,t,r)}function I(){return n.T2.backend}function C(e,t){(0,a._K)().setPlatform(e,t)}(0,s.B4)(h)},13797:(e,t,r)=>{"use strict";r.d(t,{w:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({cast_:function(e,t){let r=(0,s.YT)(e,"x","cast");if(!i.xn(t))throw Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==r.dtype||"string"!==t&&"string"===r.dtype)throw Error("Only strings can be casted to strings");return n.T2.runKernel(a.KXH,{x:r},{dtype:t})}})},13905:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,a=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-0x61c88647,t.d=0x517cc1b7,e===Math.floor(e)?(t.a=e/0x100000000|0,t.b=0|e):r+=e;for(var n=0;n<r.length+20;n++)t.b^=r.charCodeAt(n),t.next()}function o(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function l(e,t){var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&("object"==typeof n&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.tychei=l}(0,e=r.nmd(e),r.amdD)},14612:(e,t,r)=>{"use strict";r.r(t),r.d(t,{bindVertexProgramAttributeStreams:()=>w,createBufferFromOutputTexture:()=>N,createFloat16MatrixTexture:()=>f,createFloat16PackedMatrixTexture:()=>v,createFloat32MatrixTexture:()=>d,createIndexBuffer:()=>u,createPackedMatrixTexture:()=>b,createUnsignedBytesMatrixTexture:()=>g,createVertexBuffer:()=>l,createVertexShader:()=>o,downloadByteEncodedFloatMatrixFromOutputTexture:()=>I,downloadFloat32MatrixFromBuffer:()=>k,downloadMatrixFromPackedOutputTexture:()=>E,downloadPackedMatrixFromBuffer:()=>C,getInternalFormatForFloat16MatrixTexture:()=>c,getInternalFormatForFloat16PackedMatrixTexture:()=>x,getInternalFormatForFloat32MatrixTexture:()=>p,getInternalFormatForPackedMatrixTexture:()=>y,getInternalFormatForUnsignedBytesMatrixTexture:()=>m,uploadDenseMatrixToTexture:()=>T,uploadPixelDataToTexture:()=>S});var n=r(45720),a=r(46519),s=r(27738),i=r(91090);function o(e){let t=(0,a.B)(),r=`${t.version} 95 precision highp float; 96 ${t.attribute} vec3 clipSpacePos; 97 ${t.attribute} vec2 uv; 98 ${t.varyingVs} vec2 resultUV; 99 100 void main() { 101 gl_Position = vec4(clipSpacePos, 1); 102 resultUV = uv; 103 }`;return i.createVertexShader(e,r)}function l(e){let t=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return i.createStaticVertexBuffer(e,t)}function u(e){let t=new Uint16Array([0,1,2,2,1,3]);return i.createStaticIndexBuffer(e,t)}function h(e,t,r,a,s,o){i.validateTextureSize(t,r);let l=i.createTexture(e),u=e.TEXTURE_2D;return i.callAndCheck(e,()=>e.bindTexture(u,l)),i.callAndCheck(e,()=>e.texParameteri(u,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),i.callAndCheck(e,()=>e.texParameteri(u,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),i.callAndCheck(e,()=>e.texParameteri(u,e.TEXTURE_MIN_FILTER,e.NEAREST)),i.callAndCheck(e,()=>e.texParameteri(u,e.TEXTURE_MAG_FILTER,e.NEAREST)),1===(0,n._K2)().getNumber("WEBGL_VERSION")?i.callAndCheck(e,()=>e.texImage2D(u,0,a,t,r,0,s,o,null)):i.callAndCheck(e,()=>e.texStorage2D(u,1,a,t,r)),i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,null)),{texture:l,texShape:[r,t]}}function p(e){return e.internalFormatFloat}function d(e,t,r,n){let[a,i]=s.Qn(t,r);return h(e,a,i,p(n),n.textureFormatFloat,e.FLOAT)}function c(e){return e.internalFormatHalfFloat}function f(e,t,r,n){let[a,i]=s.Qn(t,r);return h(e,a,i,c(n),n.textureFormatFloat,n.textureTypeHalfFloat)}function m(e){return e.downloadTextureFormat}function g(e,t,r,n){let[a,i]=s.Qn(t,r);return h(e,a,i,m(n),e.RGBA,e.UNSIGNED_BYTE)}function y(e){return e.internalFormatPackedFloat}function b(e,t,r,n){let[a,i]=s.NO(t,r);return h(e,a,i,y(n),e.RGBA,e.FLOAT)}function x(e){return e.internalFormatPackedHalfFloat}function v(e,t,r,n){let[a,i]=s.NO(t,r);return h(e,a,i,x(n),e.RGBA,n.textureTypeHalfFloat)}function w(e,t,r){return i.callAndCheck(e,()=>e.bindBuffer(e.ARRAY_BUFFER,r)),i.bindVertexBufferToProgramAttribute(e,t,"clipSpacePos",r,3,20,0)&&i.bindVertexBufferToProgramAttribute(e,t,"uv",r,2,20,12)}function T(e,t,r,a,s,o){let l,u,h;i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,t)),s instanceof Uint8Array?(l=new Uint8Array(r*a*4),u=e.UNSIGNED_BYTE,h=e.RGBA):(l=new Float32Array(r*a*4),u=e.FLOAT,h=o.internalFormatPackedFloat),l.set(s),2===(0,n._K2)().getNumber("WEBGL_VERSION")?i.callAndCheck(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,r,a,e.RGBA,u,l)):i.callAndCheck(e,()=>e.texImage2D(e.TEXTURE_2D,0,h,r,a,0,e.RGBA,u,l)),i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function S(e,t,r){i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,t)),r.data instanceof Uint8Array?2===(0,n._K2)().getNumber("WEBGL_VERSION")?i.callAndCheck(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,e.RGBA,e.UNSIGNED_BYTE,r.data)):i.callAndCheck(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,r.width,r.height,0,e.RGBA,e.UNSIGNED_BYTE,r.data)):2===(0,n._K2)().getNumber("WEBGL_VERSION")?i.callAndCheck(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,r)):i.callAndCheck(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r)),i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function N(e,t,r,n){let a=e.createBuffer();i.callAndCheck(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a));let s=16*t*r;return i.callAndCheck(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,s,e.STREAM_READ)),i.callAndCheck(e,()=>e.readPixels(0,0,r,t,e.RGBA,e.FLOAT,0)),i.callAndCheck(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null)),a}function k(e,t,r){let n=new Float32Array(r);return e.bindBuffer(e.PIXEL_PACK_BUFFER,t),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,n),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),n}function I(e,t,r,n){let[a,o]=s.Qn(t,r),l=new Uint8Array(s.EX(t*r,4));return i.callAndCheck(e,()=>e.readPixels(0,0,a,o,n.downloadTextureFormat,e.UNSIGNED_BYTE,l)),new Float32Array(l.buffer)}function C(e,t,r,n,a,i,o,l){let u=new Float32Array(s.PM(i,o));return e.bindBuffer(e.PIXEL_PACK_BUFFER,t),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,u),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),u}function E(e,t,r){let n=new Float32Array(t*r*4);return i.callAndCheck(e,()=>e.readPixels(0,0,r,t,e.RGBA,e.FLOAT,n)),n}},14732:(e,t,r)=>{"use strict";r.d(t,{L:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({cumprod_:function(e,t=0,r=!1,i=!1){let o=(0,s.YT)(e,"x","cumprod");return n.T2.runKernel(a.jj_,{x:o},{axis:t,exclusive:r,reverse:i}
103)}})},15101:(e,t,r)=>{"use strict";r.d(t,{Qu:()=>u,UB:()=>o,nV:()=>l});var n=r(45720),a=r(40693),s=r(2748),i=r(21131);class o extends s.Wd{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={stddev:this.stddev};return Object.assign(t,e),t}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,i.un)(e),s=()=>(0,n.WQq)(a.FE(r.shape,0,this.stddev),r);return a.Ls(s,()=>r,t.training||!1)})}}o.className="GaussianNoise",n.JFn.registerClass(o);class l extends s.Wd{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,i.un)(e);if(this.rate>0&&this.rate<1){let e=()=>{let e=Math.sqrt(this.rate/(1-this.rate));return(0,n.lKK)(r,a.FE(r.shape,1,e))};return a.Ls(e,()=>r,t.training||!1)}return r})}}l.className="GaussianDropout",n.JFn.registerClass(l);class u extends s.Wd{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||(0,i.un)(e).shape}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return(0,n.DZQ)(()=>{if(this.rate<1&&this.rate>0){let r=this._getNoiseShape(e),s=()=>{let t=(0,i.un)(e),s=(0,n.DQN)((0,n.YeY)(r),this.rate);s=a.wg(s,"float32");let o=((1-this.rate)*(1+3.09091329228798*this.rate))**-.5,l=-(-1.7580993408473766*o)*this.rate,u=(0,n.WQq)((0,n.lKK)(t,s),(0,n.lKK)((0,n.WQq)(s,-1),-1.7580993408473766));return(0,n.WQq)((0,n.lKK)(u,o),l)};return a.Ls(s,()=>(0,i.un)(e),t.training||!1)}return e})}}u.className="AlphaDropout",n.JFn.registerClass(u)},15299:(e,t,r)=>{"use strict";r.d(t,{z:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(89990);let o=(0,r(18875).op)({logicalOr_:function(e,t){let r=(0,s.YT)(e,"a","logicalOr","bool"),o=(0,s.YT)(t,"b","logicalOr","bool");return(0,i.assertAndGetBroadcastShape)(r.shape,o.shape),n.T2.runKernel(a.LXA,{a:r,b:o})}})},15385:(e,t,r)=>{"use strict";r.d(t,{l:()=>a});var n=r(45720);function a(e,t,r,a,s){let i=n.ZSL.sizeFromShape(a),o=t[0],l=s.length,u=[],h=1,p=-1;for(let e=0;e<l;++e){let t=s[e];if(-1===t){if(-1!==p)throw Error(n.C0T.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(p,e));p=e,u.push(1)}else{if(t<0)throw Error(n.C0T.getSparseReshapeNegativeOutputDimErrorMessage(e,t));h*=t,u.push(t)}}if(-1!==p){if(h<=0)throw Error(n.C0T.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage());let e=Math.trunc(i/h);if(h*e!==i)throw Error(n.C0T.getSparseReshapeInputOutputMultipleErrorMessage(a,u));u[p]=e}if(n.ZSL.sizeFromShape(u)!==i)throw Error(n.C0T.getSparseReshapeInputOutputMismatchErrorMessage(a,u));let d=a.length,c=[];if(d>0){c[d-1]=1;for(let e=d-2;e>=0;--e)c[e]=c[e+1]*a[e+1]}let f=[];if(l>0){f[l-1]=1;for(let e=l-2;e>=0;--e)f[e]=f[e+1]*u[e+1]}let m=n.ZSL.getArrayFromDType(r,o*l);for(let t=0;t<o;++t){let r=0;for(let n=0;n<d;++n)r+=e[t*d+n]*c[n];for(let e=0;e<l;++e)m[t*l+e]=Math.trunc(r/f[e]),r%=f[e]}return[m,[o,l],u]}},15510:(e,t,r)=>{"use strict";r.d(t,{z:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({unsortedSegmentSum_:function(e,t,r){let o=(0,s.YT)(e,"x","unsortedSegmentSum"),l=(0,s.YT)(t,"segmentIds","unsortedSegmentSum","int32");return(0,i.vA)((0,i.E6)(r),()=>"numSegments must be of dtype int"),n.T2.runKernel(a.pPe,{x:o,segmentIds:l},{numSegments:r})}})},15768:(e,t,r)=>{"use strict";r.d(t,{G2:()=>u,Od:()=>l,TN:()=>i,UG:()=>a,WA:()=>s,fM:()=>o});var n=r(45720);function a(e,t,r="index"){let s=n.ZSL.computeStrides(t);return s.map((t,n)=>{let a=`int ${e[n]} = ${r} / ${t}`,i=n===s.length-1?`int ${e[n+1]} = ${r} - ${e[n]} * ${t}`:`index -= ${e[n]} * ${t}`;return`${a}; ${i};`}).join("")}function s(e,t,r="index"){let a=n.ZSL.computeStrides(t);return a.map((t,n)=>{let s=`int ${e[n]} = ${r} / outShapeStrides[${n}]`,i=n===a.length-1?`int ${e[n+1]} = ${r} - ${e[n]} * outShapeStrides[${n}]`:`index -= ${e[n]} * outShapeStrides[${n}]`;return`${s}; ${i};`}).join("")}function i(e,t,r="index"){let n=function(e,t){let r=e.length,n=e.map(e=>`${t}[${e}]`),a=Array(r-1);a[r-2]=n[r-1];for(let e=r-3;e>=0;--e)a[e]=`(${a[e+1]} * ${n[e+1]})`;return a}(e.map((e,t)=>t),t);return n.map((t,a)=>{let s=`int ${e[a]} = ${r} / ${n[a]}`,i=a===n.length-1?`int ${e[a+1]} = ${r} - ${e[a]} * ${n[a]}`:`index -= ${e[a]} * ${n[a]}`;return`${s}; ${i};`}).join("")}function o(e){let t=n.ZSL.computeStrides(e).map(e=>e.toString());return` 104 int getFlatIndex(ivec3 coords) { 105 return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z; 106 } 107`}function l(){return` 108 int getFlatIndex(ivec3 coords) { 109 return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z; 110 } 111`}let u=` 112 const float FLOAT_MAX = 1.70141184e38; 113 const float FLOAT_MIN = 1.17549435e-38; 114 115 lowp vec4 encode_float(highp float v) { 116 if (isnan(v)) { 117 return vec4(255, 255, 255, 255); 118 } 119 120 highp float av = abs(v); 121 122 if(av < FLOAT_MIN) { 123 return vec4(0.0, 0.0, 0.0, 0.0); 124 } else if(v > FLOAT_MAX) { 125 return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; 126 } else if(v < -FLOAT_MAX) { 127 return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; 128 } 129 130 highp vec4 c = vec4(0,0,0,0); 131 132 highp float e = floor(log2(av)); 133 highp float m = exp2(fract(log2(av))) - 1.0; 134 135 c[2] = floor(128.0 * m); 136 m -= c[2] / 128.0; 137 c[1] = floor(32768.0 * m); 138 m -= c[1] / 32768.0; 139 c[0] = floor(8388608.0 * m); 140 141 highp float ebias = e + 127.0; 142 c[3] = floor(ebias / 2.0); 143 ebias -= c[3] * 2.0; 144 c[2] += floor(ebias) * 128.0; 145 146 c[3] += 128.0 * step(0.0, -v); 147 148 return c / 255.0; 149 } 150`},16015:(e,t,r)=>{"use strict";r.d(t,{p:()=>i});var n=r(45720),a=r(14612),s=r(27738);class i{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}acquireTexture(e,t,r){let n,a=l(t,r),i=u(e,a,r);i in this.freeTextures||(this.freeTextures[i]=[]),i in this.usedTextures||(this.usedTextures[i]=[]);let h=o(e,a,this.gpgpu.gl,this.gpgpu.textureConfig,r);
150if(this.freeTextures[i].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=h,this.log();let e=this.freeTextures[i].pop();return this.usedTextures[i].push(e),e}return a===s.j.PACKED_2X2_FLOAT32?n=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):a===s.j.PACKED_2X2_FLOAT16?n=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):a===s.j.UNPACKED_FLOAT32?n=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):a===s.j.UNPACKED_FLOAT16?n=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):a===s.j.PACKED_4X1_UNSIGNED_BYTE&&(n=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[i].push(n),this.numUsedTextures++,this._numBytesAllocated+=h,this.log(),n}releaseTexture(e,t,r,a){if(null==this.freeTextures)return;let s=l(r,a),i=u(t,s,a);i in this.freeTextures||(this.freeTextures[i]=[]);let h=o(t,s,this.gpgpu.gl,this.gpgpu.textureConfig,a),p=(0,n._K2)().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==p&&this._numBytesAllocated>p?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=h):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=h),this.numUsedTextures--;let d=this.usedTextures[i],c=d&&d.indexOf(e);if(null==c||c<0)throw Error("Cannot release a texture that was never provided by this texture manager");d[c]=d[d.length-1],d.pop(),this.log()}log(){if(!this.logEnabled)return;let e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);let t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(let e in this.freeTextures)this.freeTextures[e].forEach(e=>{this.gpgpu.deleteMatrixTexture(e.texture)});for(let e in this.usedTextures)this.usedTextures[e].forEach(e=>{this.gpgpu.deleteMatrixTexture(e.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function o(e,t,r,n,i){let o,l=function(e,t){switch(e){case s.j.PACKED_2X2_FLOAT32:return(0,a.getInternalFormatForPackedMatrixTexture)(t);case s.j.PACKED_2X2_FLOAT16:return(0,a.getInternalFormatForFloat16PackedMatrixTexture)(t);case s.j.UNPACKED_FLOAT32:return(0,a.getInternalFormatForFloat32MatrixTexture)(t);case s.j.UNPACKED_FLOAT16:return(0,a.getInternalFormatForFloat16MatrixTexture)(t);case s.j.PACKED_4X1_UNSIGNED_BYTE:return(0,a.getInternalFormatForUnsignedBytesMatrixTexture)(t);default:throw Error(`Unknown physical texture type ${e}`)}}(t,n);if(i){let[t,r]=(0,s.NO)(e[0],e[1]);o=t*r}else{let[t,r]=(0,s.Qn)(e[0],e[1]);o=t*r}return o*function(e,t){if(t===e.R32F)return 4;if(t===e.R16F)return 2;if(t===e.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===e.RGBA16F)return 8;else if(t===e.RGBA8)return 4;throw Error(`Unknown internal format ${t}`)}(r,l)}function l(e,t){if(e===s.tT.UPLOAD)return s.j.PACKED_2X2_FLOAT32;if(e===s.tT.RENDER||null==e)return(0,n._K2)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?s.j.PACKED_2X2_FLOAT32:s.j.UNPACKED_FLOAT32:t?s.j.PACKED_2X2_FLOAT16:s.j.UNPACKED_FLOAT16;if(e===s.tT.DOWNLOAD||e===s.tT.PIXELS)return s.j.PACKED_4X1_UNSIGNED_BYTE;throw Error(`Unknown logical texture type ${e}`)}function u(e,t,r){return`${e[0]}_${e[1]}_${t}_${r}`}},16263:(e,t,r)=>{"use strict";r.d(t,{_:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(13797);let o=(0,r(18875).op)({prod_:function(e,t=null,r=!1){let o=(0,s.YT)(e,"x","prod");"bool"===o.dtype&&(o=(0,i.w)(o,"int32"));let l={x:o};return n.T2.runKernel(a.kdj,l,{axis:t,keepDims:r})}})},16289:(e,t,r)=>{"use strict";r.d(t,{k:()=>u});var n=r(54463),a=r(75681),s=r(61630),i=r(46866),o=r(18875),l=r(86036);let u=(0,o.op)({conv1d_:function(e,t,r,o,u="NWC",h=1,p){let d=(0,n.YT)(e,"x","conv1d"),c=(0,n.YT)(t,"filter","conv1d"),f=d,m=!1;2===d.rank&&(m=!0,f=(0,l.t)(d,[1,d.shape[0],d.shape[1]])),a.vA(3===f.rank,()=>`Error in conv1d: input must be rank 3, but got rank ${f.rank}.`),a.vA(3===c.rank,()=>`Error in conv1d: filter must be rank 3, but got rank ${c.rank}
150.`),i.s_("conv1d",o,p),a.vA(f.shape[2]===c.shape[1],()=>`Error in conv1d: depth of input (${f.shape[2]}) must match input depth for filter ${c.shape[1]}.`),a.vA(i.G0(r,h),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${r} and dilation '${h}'`),a.vA(i.qk(h),()=>"Error in conv1D: Dilated rates should be larger than 0."),a.vA(i.qk(r),()=>"Error in conv1D: Stride should be larger than 0."),a.vA("NWC"===u,()=>`Error in conv1d: got dataFormat of ${u} but only NWC is currently supported.`);let g=(0,l.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]]),y=(0,l.t)(f,[f.shape[0],1,f.shape[1],f.shape[2]]),b=(0,s.X)(y,g,[1,r],o,"NHWC",[1,h],p);return m?(0,l.t)(b,[b.shape[2],b.shape[3]]):(0,l.t)(b,[b.shape[0],b.shape[2],b.shape[3]])}})},16311:(e,t,r)=>{"use strict";r.d(t,{n:()=>h});var n=r(46568),a=r(54463),s=r(54256),i=r(86032),o=r(18875),l=r(89510),u=r(62958);let h=(0,o.op)({logSigmoid_:function(e){let t=(0,a.YT)(e,"x","logSigmoid");return(0,n._X)(e=>({value:(0,i.H)((0,u.l)((0,i.H)(e))),gradFunc:t=>(0,s.l)(t,(0,l.r)((0,i.H)(e)))}))(t)}})},16439:(e,t,r)=>{"use strict";r.d(t,{K:()=>o});var n=r(46519),a=r(71490),s=r(15768),i=r(27738);class o{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=i.BB.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=(0,n.B)();this.outputShape=e,this.enableShapeUniforms=(0,a.ik)(this.outputShape.length),this.userCode=` 151 ivec3 outCoordsFromFlatIndex(int index) { 152 ${this.enableShapeUniforms?s.WA(["r","c","d"],e):s.UG(["r","c","d"],e)} 153 return ivec3(r, c, d); 154 } 155 156 void main() { 157 ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); 158 int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); 159 160 vec4 result = vec4(0.); 161 162 for (int i=0; i<4; i++) { 163 int flatIndex = index + i; 164 ivec3 rc = outCoordsFromFlatIndex(flatIndex); 165 result[i] = getA(rc.x, rc.y, rc.z); 166 } 167 168 ${t.output} = result; 169 } 170 `}}},16496:(e,t,r)=>{"use strict";r.d(t,{Y:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({stridedSlice_:function(e,t,r,i,o=0,l=0,u=0,h=0,p=0){let d=(0,s.YT)(e,"x","stridedSlice","string_or_numeric");return n.T2.runKernel(a.UcO,{x:d},{begin:t,end:r,strides:i,beginMask:o,endMask:l,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:p})}})},16530:(e,t,r)=>{"use strict";r.d(t,{X:()=>a,j:()=>n});let n=1.7580993408473768,a=1.0507009873554805},16592:(e,t,r)=>{"use strict";r.d(t,{LY:()=>l,f6:()=>i});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>e&t),o=(0,s.j)(n.HNs,i),l={kernelName:n.HNs,backendName:"cpu",kernelFunc:o}},16879:(e,t,r)=>{"use strict";r.d(t,{Z:()=>a});var n=r(45720);function a(e){return(t,r,a,s,i)=>{let o=n.C0T.assertAndGetBroadcastShape(t,r),l=o.length,u=n.ZSL.computeStrides(o),h=n.ZSL.sizeFromShape(o),p=n.ZSL.getTypedArrayFromDType(i,h),d=t.length,c=r.length,f=n.ZSL.computeStrides(t),m=n.ZSL.computeStrides(r),g=n.C0T.getBroadcastDims(t,o),y=n.C0T.getBroadcastDims(r,o);if(g.length+y.length===0)for(let t=0;t<p.length;++t)p[t]=e(a[t%a.length],s[t%s.length]);else for(let t=0;t<p.length;++t){let r=n.ZSL.indexToLoc(t,l,u),i=r.slice(-d);g.forEach(e=>i[e]=0);let o=n.ZSL.locToIndex(i,d,f),h=r.slice(-c);y.forEach(e=>h[e]=0);let b=n.ZSL.locToIndex(h,c,m);p[t]=e(a[o],s[b])}return[p,o]}}},17031:(e,t,r)=>{"use strict";r.d(t,{UM:()=>u,eR:()=>o,ex:()=>l});var n=r(45720),a=r(38180),s=r(48671);r(63537);let i="Variable";class o{constructor(e,t="float32",r=i,o=!0,l=null){this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=(0,a.j)(),r=null==r?i:r,this.originalName=(0,s.BC)(r),this.name=(0,s.Uc)(this.originalName),this.trainable_=o,this.constraint=l,this.val=n.bvq(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}
170assertNotDisposed(){if(this.val.isDisposed)throw Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function l(e){return e.map(e=>e.read())}function u(e){e.forEach(e=>{e[0].write(e[1])})}},17096:(e,t,r)=>{"use strict";r.d(t,{F:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({acosh_:function(e){let t=(0,s.YT)(e,"x","acosh");return n.T2.runKernel(a.PH8,{x:t})}})},17392:(e,t,r)=>{"use strict";r.d(t,{n:()=>o});var n=r(5287),a=r(96609),s=r(72155),i=r(54463);let o=(0,r(18875).op)({pow_:function(e,t){let r=(0,i.YT)(e,"base","pow"),o=(0,i.YT)(t,"exp","pow");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.pyJ,l)}})},17965:(e,t,r)=>{"use strict";r.d(t,{O:()=>l});var n=r(54463),a=r(75681),s=r(99309),i=r(18875),o=r(86036);let l=(0,i.op)({dot_:function(e,t){let r=(0,n.YT)(e,"t1","dot"),i=(0,n.YT)(t,"t2","dot");a.vA((1===r.rank||2===r.rank)&&(1===i.rank||2===i.rank),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${r.rank} and ${i.rank}.`);let l=1===r.rank?r.size:r.shape[1],u=1===i.rank?i.size:i.shape[0];if(a.vA(l===u,()=>`Error in dot: inner dimensions of inputs must match, but got ${l} and ${u}.`),1===r.rank&&1===i.rank){let e=(0,o.t)(r,[1,-1]),t=(0,o.t)(i,[-1,1]),n=(0,s.N)(e,t);return(0,o.t)(n,[])}if(1===r.rank&&2===i.rank){let e=(0,o.t)(r,[1,-1]),t=(0,o.t)(i,[i.shape[0],i.shape[1]]),n=(0,s.N)(e,t);return(0,o.t)(n,[n.size])}if(2===r.rank&&1===i.rank){let e=(0,o.t)(i,[-1,1]),t=(0,s.N)(r,e);return(0,o.t)(t,[t.size])}{let e=(0,o.t)(i,[i.shape[0],i.shape[1]]);return(0,s.N)(r,e)}}})},18200:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({atan_:function(e){let t=(0,s.YT)(e,"x","atan");return n.T2.runKernel(a.TyE,{x:t})}})},18405:(e,t,r)=>{"use strict";r.d(t,{$O:()=>H,AC:()=>v,BC:()=>O,BW:()=>y,CJ:()=>c,Dy:()=>S,E$:()=>p,G3:()=>F,G4:()=>A,Gs:()=>n,J3:()=>M,Kf:()=>o,LF:()=>W,M_:()=>q,Md:()=>l,Og:()=>E,Oy:()=>$,PA:()=>i,PP:()=>h,Q5:()=>Q,QM:()=>m,S6:()=>Z,SF:()=>d,Tm:()=>g,UC:()=>G,UF:()=>f,Xe:()=>k,ad:()=>C,cy:()=>U,dv:()=>u,f8:()=>L,fC:()=>D,fW:()=>j,h:()=>N,h0:()=>s,jm:()=>a,lL:()=>K,mo:()=>x,rI:()=>w,rQ:()=>I,rw:()=>T,sB:()=>P,tc:()=>_,uw:()=>b,vo:()=>z,we:()=>R,xt:()=>Y,yZ:()=>V,zN:()=>B});let{addImpl:n,bincountImpl:a,bincountReduceImpl:s,bitwiseAndImpl:i,castImpl:o,ceilImpl:l,concatImpl:u,equalImpl:h,expImpl:p,expm1Impl:d,floorImpl:c,gatherNdImpl:f,gatherV2Impl:m,greaterImpl:g,greaterEqualImpl:y,lessImpl:b,lessEqualImpl:x,linSpaceImpl:v,logImpl:w,maxImpl:T,maximumImpl:S,minimumImpl:N,multiplyImpl:k,negImpl:I,notEqualImpl:C,prodImpl:E,raggedGatherImpl:A,raggedRangeImpl:$,raggedTensorToTensorImpl:F,rangeImpl:R,rsqrtImpl:_,scatterImpl:D,sigmoidImpl:O,simpleAbsImpl:L,sliceImpl:M,sparseFillEmptyRowsImpl:P,sparseReshapeImpl:z,sparseSegmentReductionImpl:B,sqrtImpl:W,staticRegexReplaceImpl:V,stridedSliceImpl:U,stringNGramsImpl:G,stringSplitImpl:Z,stringToHashBucketFastImpl:j,subImpl:K,tileImpl:H,topKImpl:Y,transposeImpl:Q,uniqueImpl:q}=r(98722)},18875:(e,t,r)=>{"use strict";r.d(t,{B:()=>s,op:()=>i});var n=r(5287),a=r(75681);let s="__op";function i(e){let t=Object.keys(e);if(1!==t.length)throw Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let r=t[0],i=e[r];r.endsWith("_")&&(r=r.substring(0,r.length-1));let o=(...e)=>{n.T2.startScope(r);try{let t=i(...e);return(0,a.yL)(t)&&console.error("Cannot return a Promise inside of tidy."),n.T2.endScope(t),t}catch(e){throw n.T2.endScope(null),e}};return Object.defineProperty(o,"name",{value:r+=s,configurable:!0}),o}},19832:(e,t,r)=>{"use strict";r.d(t,{V:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({softmax_:function(e,t=-1){let r=(0,s.YT)(e,"logits","softmax","float32");if(-1===t&&(t=r.rank-1),t!==r.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${r.rank} and dim was ${t}`);let i={dim:t};return n.T2.runKernel(a.rFG,{logits:r},i)}})},20020:(e,t,r)=>{"use strict";r.d(t,{F:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({sin_:function(e){let t=(0,s.YT)(e,"x","sin","float32");return n.T2.runKernel(a.hql,{x:t})}})},20176:(e,t,r)=>{"use strict";r.d(t,{Nu:()=>l,hE:()=>i});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>Math.min(e,t)),o=(0,s.j)(n.LG0,i),l={kernelName:n.LG0,backendName:"cpu",kernelFunc:o}},20728:(e,t,r)=>{"use strict";var n,a,s,i,o;r.d(t,{Nw:()=>d,Oj:()=>p,Tu:()=>u,ch:()=>h,rg:()=>n}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(n||(n={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(a||(a={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(s||(s={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(i||(i={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(o||(o={}));
170let l={float32:i,int32:a,bool:s,complex64:o};function u(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw Error(`Can not upcast ${e} with ${t}`)}return l[e][t]}function h(e){return u(e,"int32")}function p(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function d(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}},21131:(e,t,r)=>{"use strict";r.d(t,{FS:()=>s,TT:()=>a,U$:()=>o,un:()=>i});var n=r(63537);function a(e){return Array.isArray(e)&&Array.isArray(e[0])}function s(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function i(e){let t;if(Array.isArray(e)){if(1!==e.length)throw new n.Qp(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function o(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))return e;if(1===e.length)return e[0];throw new n.Qp(`Expected exactly 1 Shape; got ${e.length}`)}},21419:(e,t,r)=>{"use strict";r.d(t,{M:()=>l});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990);let l=(0,r(18875).op)({less_:function(e,t){let r=(0,i.YT)(e,"a","less","string_or_numeric"),l=(0,i.YT)(t,"b","less","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.mIA,u)}})},21455:(e,t,r)=>{"use strict";r.d(t,{a:()=>l});var n=r(45720),a=r(2748),s=r(63537),i=r(21131);let o=new Set(["bilinear","nearest"]);class l extends a.Wd{constructor(e){if(super(e),this.height=e.height,this.width=e.width,e.interpolation)if(o.has(e.interpolation))this.interpolation=e.interpolation;else throw new s.Qp(`Invalid interpolation parameter: ${e.interpolation} is not implemented`);else this.interpolation="bilinear";this.cropToAspectRatio=!!e.cropToAspectRatio}computeOutputShape(e){let t=(e=(0,i.U$)(e))[2];return[this.height,this.width,t]}getConfig(){let e={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio};return Object.assign(e,super.getConfig()),e}call(e,t){return(0,n.DZQ)(()=>{let t=[this.height,this.width];if("bilinear"===this.interpolation)return n.Slp.resizeBilinear(e,t,!this.cropToAspectRatio);if("nearest"===this.interpolation)return n.Slp.resizeNearestNeighbor(e,t,!this.cropToAspectRatio);throw Error(`Interpolation is ${this.interpolation} but only ${[...o]} are supported`)})}}l.className="Resizing",n.JFn.registerClass(l)},22049:(e,t,r)=>{"use strict";r.d(t,{H:()=>m,j:()=>g});var n=r(45720),a=r(40693),s=r(48671),i=r(2748),o=r(63537),l=r(42290),u=r(72344),h=r(95971),p=r(21131),d=r(35721),c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)0>t.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};class f extends d.VS{constructor(e){if(e.unroll)throw new o.EH("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new o.EH("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new i.eO({ndim:5})]}call(e,t){return n.DZQ(()=>{if(null!=this.cell.dropoutMask&&(n.ASo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(n.ASo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new o.Qp("ConvRNN2D cell does not support constants");let r=null==t?null:t.mask,a=null==t?null:t.training,s=null==t?null:t.initialState;return super.call(e,{mask:r,training:a,initialState:s})})}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...[,,].fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return n.DZQ(()=>{let{stateSize:t}=this.cell,r=e.shape,a=this.computeSingleOutputShape(r),s=[a[0],...a.slice(2)],i=n.Ul9(s);return Array.isArray(t)?Array(t.length).fill(i):[i]})}resetStates(e,t=!1){n.DZQ(()=>{if(!this.stateful)throw new o.l7("Cannot call resetStates() on an RNN Layer that is not stateful.");let r=this.inputSpec[0].shape,a=this.computeSingleOutputShape(r),s=[a[0],...a.slice(2)];if(null==r[0])throw new o.Qp("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>n.Ul9(s)):this.states_=[n.Ul9(s)];else if(null==e)n.ASo(this.states_),null!=this.keptStates&&(n.ASo(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>n.Ul9(s)):this.states_[0]=n.Ul9(s);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new o.Qp(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):n.ASo(this.states_);for(let t=0;t<this.states_.length;++t){let r=e[t];if(!n.ZSL.arraysEqual(r.shape,s))throw new o.Qp(`State ${t} is incompatible with layer ${this.name}: expected shape=${s}, received shape=${r.shape}`);this.states_[t]=r}}this.states_=this.states_.map(e=>n.aCs(e.clone()))})}computeSingleOutputShape(e){let{dataFormat:t,filters:r,kernelSize:n,padding:a,strides:s,dilationRate:i}=this.cell,o="channelsFirst"===t,l=e[o?3:2],h=e[o?4:3],p=(0,u.Ol)(l,n[0],a,s[0],i[0]),d=(0,u.Ol)(h,n[1],a,s[1],i[1]);return[...e.slice(0,2),...o?[r,p,d]:[p,d,r]]}}f.className="ConvRNN2D";class m extends d.Tu{constructor(e){let{filters:t,kernelSize:r,strides:n,padding:a,dataFormat:i,dilationRate:o}=e;super(Object.assign(Object.assign({},e),{units:t})),this.filters=t,(0,h.oo)(this.filters,"filters"),this.kernelSize=(0,u.J)(r,2,"kernelSize"),this.kernelSize.forEach(e
170=>(0,h.oo)(e,"kernelSize")),this.strides=(0,u.J)(n||1,2,"strides"),this.strides.forEach(e=>(0,h.oo)(e,"strides")),this.padding=a||"valid",(0,s.tB)(this.padding),this.dataFormat=i||"channelsLast",(0,s.uM)(this.dataFormat),this.dilationRate=(0,u.J)(o||1,2,"dilationRate"),this.dilationRate.forEach(e=>(0,h.oo)(e,"dilationRate"))}build(e){var t;e=(0,p.U$)(e);let r="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[r])throw new o.Qp(`The channel dimension of the input should be defined. Found ${e[r]}`);let s=e[r],i=this.kernelSize.concat([s,4*this.filters]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);let u=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",u,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let e;if(this.unitForgetBias){let r=this.biasInitializer,s=this.filters;e=new((t=class extends l.H4{apply(e,t){let i=r.apply([s]),o=n.SaS([s]),l=r.apply([2*s]);return a.u1([i,o,l])}}).className="CustomInit",t)}else e=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,e,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return n.DZQ(()=>{if(3!==e.length)throw new o.Qp(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=t.training||!1,a=e[0],s=e[1],i=e[2];0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=(0,d.FW)({ones:()=>n.P61(a),rate:this.dropout,training:r,count:4,dropoutFunc:this.dropoutFunc}));let l=this.dropoutMask,u=(e,t,r)=>t&&t[r]?n.lKK(t[r],e):e,h=u(a,l,0),p=u(a,l,1),c=u(a,l,2),f=u(a,l,3);0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=(0,d.FW)({ones:()=>n.P61(s),rate:this.recurrentDropout,training:r,count:4,dropoutFunc:this.dropoutFunc}));let m=this.recurrentDropoutMask,g=u(s,m,0),y=u(s,m,1),b=u(s,m,2),x=u(s,m,3),[v,w,T,S]=n.lDo(this.kernel.read(),4,3),[N,k,I,C]=this.useBias?n.lDo(this.bias.read(),4):[null,null,null,null];h=this.inputConv(h,v,N,this.padding),p=this.inputConv(p,w,k,this.padding),c=this.inputConv(c,T,I,this.padding),f=this.inputConv(f,S,C,this.padding);let[E,A,$,F]=n.lDo(this.recurrentKernel.read(),4,3);g=this.recurrentConv(g,E),y=this.recurrentConv(y,A),b=this.recurrentConv(b,$),x=this.recurrentConv(x,F);let R=this.recurrentActivation.apply(n.WQq(h,g)),_=this.recurrentActivation.apply(n.WQq(p,y)),D=n.WQq(n.lKK(_,i),n.lKK(R,this.activation.apply(n.WQq(c,b)))),O=n.lKK(this.recurrentActivation.apply(n.WQq(f,x)),this.activation.apply(D));return[O,O,D]})}getConfig(){let e=super.getConfig(),{units:t}=e,r=c(e,["units"]),n={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},r),n)}inputConv(e,t,r,s){let i=n.Xtf(e,t,this.strides,s||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return r?a.ni(i,r,this.dataFormat):i}recurrentConv(e,t){return n.Xtf(e,t,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")}}m.className="ConvLSTM2DCell",n.JFn.registerClass(m);class g extends f{constructor(e){super(Object.assign(Object.assign({},e),{cell:new m(e)}))}static fromConfig(e,t){return new e(t)}}g.className="ConvLSTM2D",n.JFn.registerClass(g)},22313:(e,t,r)=>{"use strict";r.d(t,{h:()=>i});var n=r(5287),a=r(96609),s=r(75681);let i=(0,r(18875).op)({fft_:function(e){return(0,s.vA)("complex64"===e.dtype,()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`),n.T2.runKernel(a.rGP,{input:e})}})},22489:(e,t,r)=>{"use strict";r.d(t,{M:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({tan_:function(e){let t=(0,s.YT)(e,"x","tan","float32");return n.T2.runKernel(a.oFs,{x:t})}})},22492:(e,t,r)=>{"use strict";var n;r.d(t,{i:()=>n}),function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(n||(n={}))},22548:(e,t,r)=>{"use strict";r.d(t,{Cf:()=>m,Op:()=>h,_5:()=>l,iP:()=>c,kr:()=>d,rY:()=>f,tA:()=>p,vQ:()=>u});var n=r(67984),a=r(90945),s=r(5663);let i=(0,a.m)("kernelRegistry",()=>new Map),o=(0,a.m)("gradRegistry",()=>new Map);function l(e,t){let r=g(e,t);return i.get(r)}function u(e){return o.get(e)}function h(e){let t=i.entries(),r=[];for(;;){let{done:n,value:a}=t.next();if(n)break;let[s,i]=a,[o]=s.split("_");o===e&&r.push(i)}return r}function p(e){let{kernelName:t,backendName:r}=e,n=g(t,r);i.has(n)&&s.i(`The kernel '${t}' for backend '${r}' is already registered`),i.set(n,e)}function d(e){let{kernelName:t}=e;o.has(t)&&(0,n._K)().getBool("DEBUG")&&s.i(`Overriding the gradient for '${t}'`),o.set(t,e)}function c(e,t){let r=g(e,t);if(!i.has(r))throw Error(`The kernel '${e}' for backend '${t}' is not registered`);i.delete(r)}function f(e){if(!o.has(e))throw Error(`The gradient '${e}' for backend is not registered`);o.delete(e)}
170function m(e,t){h(e).forEach(e=>{p(Object.assign({},e,{backendName:t}))})}function g(e,t){return`${t}_${e}`}},22599:(e,t,r)=>{"use strict";r.d(t,{N:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({logicalNot_:function(e){let t=(0,s.YT)(e,"x","logicalNot","bool");return n.T2.runKernel(a.nZd,{x:t})}})},22700:(e,t,r)=>{"use strict";r.r(t),r.d(t,{arraysEqual:()=>s.r1,arraysEqualWithNull:()=>s.e_,assert:()=>s.vA,assertNonNegativeIntegerDimensions:()=>s.SA,assertNonNull:()=>s.HO,assertShapesMatch:()=>s.O3,bytesFromStringArray:()=>s.SL,bytesPerElement:()=>s.jv,checkConversionForErrors:()=>s.nd,clamp:()=>s.qE,computeStrides:()=>s.Ur,convertBackendValuesAndArrayBuffer:()=>s.o2,createScalarValue:()=>x,createShuffledIndices:()=>s.P8,decodeString:()=>N,distSquared:()=>s.oO,encodeString:()=>S,fetch:()=>T,fingerPrint64:()=>b,flatten:()=>I,getArrayFromDType:()=>s.Ab,getTypedArrayFromDType:()=>s.ce,hasEncodingLoss:()=>s.BE,hexToLong:()=>l,indexToLoc:()=>s._k,inferDtype:()=>s.X$,inferFromImplicitShape:()=>s.XT,isBoolean:()=>s.Lm,isFunction:()=>s.Tn,isInt:()=>s.E6,isNumber:()=>s.Et,isPromise:()=>s.yL,isScalarShape:()=>s.Sf,isString:()=>s.Kg,isTypedArray:()=>k,isValidDtype:()=>s.xn,locToIndex:()=>s.sX,makeOnesTypedArray:()=>s.FZ,makeZerosNestedTypedArray:()=>s.c7,makeZerosTypedArray:()=>s.Ty,nearestDivisor:()=>s.lK,nearestLargerEven:()=>s.eV,now:()=>w,parseAxisParam:()=>s.Y6,randUniform:()=>s.so,repeatedTry:()=>s._q,rightPad:()=>s.av,shuffle:()=>s.k4,shuffleCombo:()=>s.a0,sizeFromShape:()=>s.Ze,sizeToSquarishShape:()=>s.gS,squeezeShape:()=>s.gx,sum:()=>s.cz,swap:()=>s.wg,tanh:()=>s.ym,toNestedArray:()=>s.yw,toTypedArray:()=>v});var n=r(67984),a=r(5512),s=r(75681),i=r(51417);let o=r.n(i)()||i;function l(e){return o.fromString(e,!0,16)}let u=l("c3a5c85c97cb3127"),h=l("b492b66fbe98f273"),p=l("9ae16a3b2f90404f");function d(e){return e.xor(e.shru(47))}function c(e,t,r){let n=e.slice(t,t+r);return o.fromBytes(Array.from(n),!0,!0)}function f(e,t){return c(e,t,8)}function m(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function g(e,t,r=l("9ddfea08eb382d69")){let n=e.xor(t).mul(r);n=n.xor(n.shru(47));let a=t.xor(n).mul(r);return(a=a.xor(a.shru(47))).mul(r)}function y(e,t,r,n){return function(e,t,r,n,a,s){a=a.add(e),s=m(s.add(a).add(n),21);let i=a;return a=(a=a.add(t)).add(r),s=s.add(m(a,44)),[a.add(n),s.add(i)]}(f(e,t),f(e,t+8),f(e,t+16),f(e,t+24),r,n)}function b(e,t=e.length){let r=o.fromNumber(81,!0);if(t<=32)if(t<=16)return function(e,t=e.length){if(t>=8){let r=p.add(2*t),n=f(e,0).add(p),a=f(e,t-8);return g(m(a,37).mul(r).add(n),m(n,25).add(a).mul(r),r)}if(t>=4){let r=p.add(2*t);return g(c(e,0,4).shl(3).add(t),c(e,t-4,4),r)}if(t>0){let r=e[0],n=e[t>>1],a=e[t-1];return d(p.mul(r+(n<<8)).xor(u.mul(t+(a<<2)))).mul(p)}return p}(e,t);else return function(e,t=e.length){let r=p.add(2*t),n=f(e,0).mul(h),a=f(e,8),s=f(e,t-8).mul(r),i=f(e,t-16).mul(p);return g(m(n.add(a),43).add(m(s,30)).add(i),n.add(m(a.add(p),18)).add(s),r)}(e,t);if(t<=64)return function(e,t=e.length){let r=p.add(2*t),n=f(e,0).mul(p),a=f(e,8),s=f(e,t-8).mul(r),i=f(e,t-16).mul(p),o=m(n.add(a),43).add(m(s,30)).add(i),l=g(o,n.add(m(a.add(p),18)).add(s),r),u=f(e,16).mul(r),h=f(e,24),d=o.add(f(e,t-32)).mul(r),c=l.add(f(e,t-24)).mul(r);return g(m(u.add(h),43).add(m(d,30)).add(c),u.add(m(h.add(n),18)).add(d),r)}(e,t);let n=r,a=r.mul(h).add(113),s=d(a.mul(p).add(113)).mul(p),i=[o.UZERO,o.UZERO],l=[o.UZERO,o.UZERO];n=n.mul(p).add(f(e,0));let x=0,v=(t-1>>6)*64,w=v+(t-1&63)-63;do n=m(n.add(a).add(i[0]).add(f(e,x+8)),37).mul(h),a=m(a.add(i[1]).add(f(e,x+48)),42).mul(h),n=n.xor(l[1]),a=a.add(i[0]).add(f(e,x+40)),s=m(s.add(l[0]),33).mul(h),i=y(e,x,i[1].mul(h),n.add(l[0])),l=y(e,x+32,s.add(l[1]),a.add(f(e,x+16))),[s,n]=[n,s],x+=64;while(x!==v);let T=h.add(s.and(255).shl(1));return x=w,l[0]=l[0].add(t-1&63),i[0]=i[0].add(l[0]),l[0]=l[0].add(i[0]),n=m(n.add(a).add(i[0]).add(f(e,x+8)),37).mul(T),a=m(a.add(i[1]).add(f(e,x+48)),42).mul(T),n=n.xor(l[1].mul(9)),a=a.add(i[0].mul(9).add(f(e,x+40))),s=m(s.add(l[0]),33).mul(T),i=y(e,x,i[1].mul(T),n.add(l[0])),l=y(e,x+32,s.add(l[1]),a.add(f(e,x+16))),[s,n]=[n,s],g(g(i[0],l[0],T).add(d(a).mul(u)).add(s),g(i[1],l[1],T).add(n),T)}function x(e,t){return"string"===t?S(e):v([e],t)}function v(e,t){var r;if("string"===t)throw Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=I(e)),(0,n._K)().getBool("DEBUG")&&s.nd(e,t),(r=e)instanceof Float32Array&&"float32"===t||r instanceof Int32Array&&"int32"===t||r instanceof Uint8Array&&"bool"===t)return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){let t=new Uint8Array(e.length);for(let r=0;r<t.length;++r)0!==Math.round(e[r])&&(t[r]=1);return t}throw Error(`Unknown data type ${t}`)}function w(){return(0,n._K)().platform.now()}function T(e,t){return(0,n._K)().platform.fetch(e,t)}function S(e,t="utf-8"){return t=t||"utf-8",(0,n._K)().platform.encode(e,t)}function N(e,t="utf-8"){return t=t||"utf-8",(0,n._K)().platform.decode(e,t)}function k(e){return null!=(0,n._K)().platform.isTypedArray?(0,n._K)().platform.isTypedArray(e):(0,a.Y)(e)}function I(e,t=[],r=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||s.yL(e)||null==e||k(e)&&r)t.push(e);else if(Array.isArray(e)||k(e))for(let n=0;n<e.length;++n)I(e[n],t,r);else{let n=-1;for(let t of Object.keys(e))/^([1-9]+[0-9]*|0)$/.test(t)&&(n=Math.max(n,Number(t)));for(let a=0;a<=n;a++)I(e[a],t,r)}return t}},22864:(e,t,r)=>{"use strict";r.d(t,{N:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({prelu_:function(e,t){let r=(0,s.YT)(e,"x","prelu"),i=(0,s.YT)(t,"alpha","prelu");return n.T2.runKernel(a.Ncv,{x:r,alpha:i}
170)}})},23926:(e,t,r)=>{"use strict";r.d(t,{l:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({split_:function(e,t,r=0){let i=(0,s.YT)(e,"x","split");return n.T2.runKernel(a.Blb,{x:i},{numOrSizeSplits:t,axis:r})}})},24446:(e,t,r)=>{"use strict";r.d(t,{F:()=>o,v:()=>i});var n=r(45720),a=r(60072),s=r(64467);function i(e,t,r){return o(e,(0,s.o)(t),r)}function o(e,t,r){return({inputs:s,attrs:i,backend:o})=>{let l,{x:u}=s;(0,a.C)(u,e);let h=o.data.get(u.dataId).values;if("string"===u.dtype){if(!Array.isArray(h))throw Error("String tensor's value was not an instance of Array");l=n.C0T.fromUint8ToStringArray(h)}else l=h;let p=r||u.dtype,d=t(l,p,i);return o.makeTensorInfo(u.shape,p,d)}}},24602:(e,t,r)=>{"use strict";r.d(t,{g:()=>f});var n=r(45720),a=r(64630),s=r(40693),i=r(48671),o=r(40838),l=r(63537),u=r(42290),h=r(76915),p=r(72344),d=r(21131),c=r(31824);class f extends c.kO{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=(0,u.Fe)(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=(0,o.YZ)(e.depthwiseConstraint),this.depthwiseRegularizer=(0,h.Bm)(e.depthwiseRegularizer)}build(e){if((e=(0,d.U$)(e)).length<4)throw new l.Qp(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);let t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new l.Qp(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);let r=e[t],n=[this.kernelSize[0],this.kernelSize[1],r,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",n,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[r*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return(0,n.DZQ)(()=>{let t=function(e,t,r=[1,1],s="valid",o,u){return(0,n.DZQ)(()=>{null==o&&(o=(0,a.VI)()),(0,i.uM)(o);let u=(0,c.RK)(e,o);if(4!==e.rank)throw new l.Qp(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(4!==t.rank)throw new l.Qp(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return u=n.Gl3(u,t,r,"same"===s?"same":"valid","NHWC",null),"channelsFirst"===o&&(u=n.mgz(u,[0,3,1,2])),u})}(e=(0,d.un)(e),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,0);return this.useBias&&(t=s.ni(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),t})}computeOutputShape(e){e=(0,d.U$)(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],r="channelsFirst"===this.dataFormat?e[3]:e[2],n="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=(0,p.Ol)(t,this.kernelSize[0],this.padding,this.strides[0]),s=(0,p.Ol)(r,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],n,a,s]:[e[0],a,s,n]}getConfig(){let e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=(0,u.zo)(this.depthwiseInitializer),e.depthwiseRegularizer=(0,h.R9)(this.depthwiseRegularizer),e.depthwiseConstraint=(0,o.uH)(this.depthwiseRegularizer),e}}f.className="DepthwiseConv2D",n.JFn.registerClass(f)},24884:(e,t,r)=>{"use strict";r.d(t,{r:()=>s});var n=r(94708),a=r(75681);function s(e,t="float32",r){return t=t||"float32",a.SA(e),new n.yl(e,t,r)}},25435:(e,t,r)=>{"use strict";r.d(t,{F:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({mirrorPad_:function(e,t,r){i.vA("reflect"===r||"symmetric"===r,()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${r}.`);let o=(0,s.YT)(e,"x","mirrorPad");if(0===o.rank)throw Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");i.vA(t.length===o.rank,()=>`Padding doesn't match input. Must be ${o.rank}. Got ${t.length}.`);let l=+("reflect"===r);for(let e=0;e<o.rank;e++)i.vA(2===t[e].length,()=>"Invalid number of paddings. Must be length of 2 each."),i.vA(t[e][0]>=0&&t[e][0]<=o.shape[e]-l&&t[e][1]>=0&&t[e][1]<=o.shape[e]-l,()=>`Padding in dimension ${e} cannot be greater than or equal to ${o.shape[e]-l} or less than 0 for input of shape ${o.shape}`);return n.T2.runKernel(a.x7F,{x:o},{paddings:t,mode:r})}})},25550:(e,t,r)=>{"use strict";r.d(t,{_:()=>a});var n=r(45720);function a(e,t,r,a,s){let i=t.length,o=n.ZSL.sizeFromShape(t),l=n.ZSL.computeStrides(t),u=n.ZSL.computeStrides(s),h=n.ZSL.getTypedArrayFromDType(r,n.ZSL.sizeFromShape(s));for(let t=0;t<o;++t){let r=n.ZSL.indexToLoc(t,i,l),s=Array(r.length);for(let e=0;e<s.length;e++)s[e]=r[a[e]];h[n.ZSL.locToIndex(s,i,u)]=e[t]}return h}},26761:(e,t,r)=>{"use strict";r.d(t,{j:()=>a});var n=r(45720);function a(e,t,r,a){let s=n.ZSL.getTypedArrayFromDType(a,n.ZSL.sizeFromShape(r));for(let r=0;r<s.length;++r){let n=r*t,a=e[n];for(let r=0;r<t;++r){let t=e[n+r];(Number.isNaN(t)||t>a)&&(a=t)}s[r]=a}return s}},27674:(e,t,r)=>{"use strict";r.d(t,{Ez:()=>c,RX:()=>f});var n=r(45720),a=r(40838),s=r(2748),i=r(63537),o=r(42290),l=r(76915),u=r(95971),h=r(62376),p=r(21131);function d(e,t,r,a,s,o=.001){let l;if(2===e.rank)l=n.BFc(e,t,r,a,s,o);else if(3===e.rank)l=n.kSi(e,t,r,a,s,o);else if(4===e.rank)l=n.T5N(e,t,r,a,s,o);else throw new i.EH(`batchNormalization is not implemented for array of rank ${e.rank} yet`);return l}class c extends s.Wd{constructor(e){null==e&&(e={}),super(e),this.supportsMasking=!0,this.axis=null==e.axis?-1:e.axis,this.momentum=null==e.momentum?.99:e.momentum,this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=(0,o.Fe)(e.betaInitializer||"zeros"),this.gammaInitializer=(0,o.Fe)(e.gammaInitializer||"ones"),this.movingMeanInitializer=(0,o.Fe)(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=(0,o.Fe)(e.movingVarianceInitializer||"ones"),this.betaConstraint=(0,a.YZ)(e.betaConstraint),this.gammaConstraint=(0,a.YZ)(e.gammaConstraint),this.betaRegularizer=(0,l.Bm)(e.betaRegularizer),this.gammaRegularizer=(0,l.Bm)(e.gammaRegularizer)}build(e){e=(0,p.U$)(e);let t=this.axis>=0?this.axis:this.axis+e.length,r=e[t];if(null==r)throw new i.Qp(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new s.eO({ndim:e.length,axes:{[t]:r}})];let n=[r];this.scale&&(this.gamma=this.addWeight("gamma",n,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",n,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",n,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",n,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return(0,n.DZQ)(()=>{let r=null!=t.training&&t.training,a=(0,p.un)(e),s=a.shape,i=s.length,o=h.y1(0,i),l=this.axis>=0?this.axis:this.axis+i;o.splice(l,1);let c=u.fD(1,i);c[l]=s[l];let f=o.slice();f.sort();let m=!n.ZSL.arraysEqual(f,h.y1(0,i).slice(0,i-1)),g=()=>{if(!m)return d(a,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon);{let e=(0,n.tQQ)(this.movingMean.read(),c),t=(0,n.tQQ)(this.movingVariance.read(),c);return d(a,e,t,this.center?(0,n.tQQ)(this.beta.read(),c):null,this.scale?(0,n.tQQ)(this.gamma.read(),c):null,this.epsilon)}};if(!r)return g();let[y,b,x]=function(e,t,r,a,s=.001){return n.ZSL.arraysEqual(a.slice().sort(),h.y1(0,e.rank-1))?function(e,t,r,a,s=.001){return(0,n.DZQ)(()=>{let i=n.Clk(e,a),o=i.mean,l=i.variance;
170return[d(e,o,l,r,t,s),o,l]})}(e,t,r,a,s):function(e,t,r,a,s=.001){return(0,n.DZQ)(()=>{let i=n.Clk(e,a),o=i.mean,l=i.variance,u=[];for(let t of h.y1(0,e.rank))-1!==a.indexOf(t)?u.push(1):u.push(e.shape[t]);let p=(0,n.tQQ)(o,u),c=(0,n.tQQ)(l,u),f=null==t?null:(0,n.tQQ)(t,u);return[d(e,p,c,null==r?null:(0,n.tQQ)(r,u),f,s),o,l]})}(e,t,r,a,s)}(a,this.gamma.read(),this.beta.read(),o,this.epsilon),v=(e,t,r)=>{n.DZQ(()=>{let a=e.read(),s=n.lKK(n.jbE(a,t),1-r);e.write(n.jbE(a,s))})};return v(this.movingMean,b,this.momentum),v(this.movingVariance,x,this.momentum),y})}getConfig(){let e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:(0,o.zo)(this.betaInitializer),gammaInitializer:(0,o.zo)(this.gammaInitializer),movingMeanInitializer:(0,o.zo)(this.movingMeanInitializer),movingVarianceInitializer:(0,o.zo)(this.movingVarianceInitializer),betaRegularizer:(0,l.R9)(this.betaRegularizer),gammaRegularizer:(0,l.R9)(this.gammaRegularizer),betaConstraint:(0,a.uH)(this.betaConstraint),gammaConstraint:(0,a.uH)(this.gammaConstraint)};return Object.assign(e,super.getConfig()),e}}c.className="BatchNormalization",n.JFn.registerClass(c);class f extends s.Wd{constructor(e){if(null==e&&(e={}),super(e),this.axis=null==e.axis?-1:e.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(let e of this.axis)if(!Number.isInteger(e))throw Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=(0,o.Fe)(e.betaInitializer||"zeros"),this.gammaInitializer=(0,o.Fe)(e.gammaInitializer||"ones"),this.betaRegularizer=(0,l.Bm)(e.betaRegularizer),this.gammaRegularizer=(0,l.Bm)(e.gammaRegularizer),this.supportsMasking=!0}build(e){let t=(e=(0,p.U$)(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let e=0;e<this.axis.length;++e)this.axis[e]<0&&(this.axis[e]+=t);for(let e of this.axis)if(e<0||e>=t)throw Error(`Invalid axis: ${e}`);if(this.axis.length!==u.Am(this.axis).length)throw Error(`Found duplicate axes in: ${this.axis}`);let r=this.axis.map(t=>e[t]);this.scale?this.gamma=this.addWeight("gamma",r,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",r,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0}call(e,t){let r=(0,p.un)(e),a=r.shape,s=a.length;return(0,n.DZQ)(()=>{let{mean:e,variance:t}=(0,n.Clk)(r,this.axis,!0),i=u.fD(1,s);for(let e of this.axis)i[e]=a[e];let o=e=>null!=e&&e.shape.length!==s?n.tQQ(e,i):e,l=this.scale?o(this.gamma.read()):null,h=this.center?o(this.beta.read()):null,p=[],c=[];for(let e=0;e<s;++e)-1!==this.axis.indexOf(e)?(p.push(a[e]),c.push(1)):(p.push(1),c.push(a[e]));return e=n.Vsq(e,p),t=n.Vsq(t,p),null!=l&&(l=n.Vsq(l,c)),null!=h&&(h=n.Vsq(h,c)),d(r,e,t,h,l,this.epsilon)})}getConfig(){let e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:(0,o.zo)(this.betaInitializer),gammaInitializer:(0,o.zo)(this.gammaInitializer),betaRegularizer:(0,l.R9)(this.betaRegularizer),gammaRegularizer:(0,l.R9)(this.gammaRegularizer)};return Object.assign(e,super.getConfig()),e}}f.className="LayerNormalization",n.JFn.registerClass(f)},27738:(e,t,r)=>{"use strict";r.d(t,{BB:()=>n,EX:()=>l,EZ:()=>d,GM:()=>u,NO:()=>h,PM:()=>p,Qn:()=>o,j:()=>s,tT:()=>a});var n,a,s,i=r(45720);function o(e,t){return[t,e]}function l(e,t){return e*t}function u(e){let t=Math.ceil(i.ZSL.sizeFromShape(e)/4);return i.ZSL.sizeToSquarishShape(t)}function h(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function p(e,t){let[r,n]=h(e,t);return r*n*4}function d(e,t){let r,n,a,s,o,l,u,h,p,d;return 2===(0,i._K2)().getNumber("WEBGL_VERSION")?(r=e.R32F,n=e.R16F,a=e.RGBA16F,s=e.RGBA32F,o=e.RED,u=4,h=1,p=e.HA
170LF_FLOAT,d=e.FLOAT,l=e.RGBA8):(r=e.RGBA,n=e.RGBA,a=e.RGBA,s=e.RGBA,o=e.RGBA,u=4,h=4,p=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT,l=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:n,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:s,textureFormatFloat:o,downloadTextureFormat:l,downloadUnpackNumChannels:u,defaultNumChannels:h,textureTypeHalfFloat:p,textureTypeFloat:d}}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(n||(n={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(a||(a={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(s||(s={}))},28566:(e,t,r)=>{"use strict";r.d(t,{Fx:()=>l,px:()=>i});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)(e=>Math.log(e)),o=(0,s.F)(n.tG8,i),l={kernelName:n.tG8,backendName:"cpu",kernelFunc:o}},29337:(e,t,r)=>{"use strict";r.d(t,{y:()=>l});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(44691);let l=(0,r(18875).op)({div_:function(e,t){let r=(0,i.YT)(e,"a","div"),l=(0,i.YT)(t,"b","div");if([r,l]=(0,s.makeTypesMatch)(r,l),"int32"===r.dtype&&"int32"===l.dtype)return(0,o.w)(r,l);let u={a:r,b:l};return n.T2.runKernel(a.sDr,u,{})}})},29573:(e,t,r)=>{"use strict";r.d(t,{o:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({exp_:function(e){let t=(0,s.YT)(e,"x","exp");return n.T2.runKernel(a.ox3,{x:t})}})},29643:(e,t,r)=>{"use strict";r.d(t,{n:()=>l});var n=r(45720),a=r(1357),s=r(14612),i=r(27738),o=r(91090);class l{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];let t=(0,n._K2)().getNumber("WEBGL_VERSION");if(null!=e?(this.gl=e,(0,a.lj)(t,e)):this.gl=(0,a.bU)(t),e=this.gl,2===(0,n._K2)().getNumber("WEBGL_VERSION")){let t=e;this.createVertexArray=()=>o.callAndCheck(t,()=>t.createVertexArray()),this.bindVertexArray=e=>o.callAndCheck(t,()=>t.bindVertexArray(e)),this.deleteVertexArray=e=>o.callAndCheck(t,()=>t.deleteVertexArray(e)),this.getVertexArray=()=>o.callAndCheck(t,()=>t.getParameter(t.VERTEX_ARRAY_BINDING))}else if(null!=e){let t=e.getExtension("OES_vertex_array_object");if(null==t)throw Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>o.callAndCheck(e,()=>t.createVertexArrayOES()),this.bindVertexArray=r=>o.callAndCheck(e,()=>t.bindVertexArrayOES(r)),this.deleteVertexArray=r=>o.callAndCheck(e,()=>t.deleteVertexArrayOES(r)),this.getVertexArray=()=>o.callAndCheck(e,()=>e.getParameter(t.VERTEX_ARRAY_BINDING_OES))}let r="WEBGL_color_buffer_float",l="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===(0,n._K2)().getNumber("WEBGL_VERSION")){let e="OES_texture_half_float";if(this.textureFloatExtension=o.getExtensionOrThrow(this.gl,"OES_texture_float"),o.hasExtension(this.gl,e))this.textureHalfFloatExtension=o.getExtensionOrThrow(this.gl,e);else if((0,n._K2)().get("WEBGL_FORCE_F16_TEXTURES"))throw Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(r),o.hasExtension(this.gl,l))this.colorBufferHalfFloatExtension=o.getExtensionOrThrow(this.gl,l);else if((0,n._K2)().get("WEBGL_FORCE_F16_TEXTURES"))throw Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(r="EXT_color_buffer_float",o.hasExtension(this.gl,r))this.colorBufferFloatExtension=this.gl.getExtension(r);else if(o.hasExtension(this.gl,l))this.colorBufferHalfFloatExtension=this.gl.getExtension(l);else throw Error("GL context does not support color renderable floats");this.vertexBuffer=s.createVertexBuffer(this.gl),this.indexBuffer=s.createIndexBuffer(this.gl),this.framebuffer=o.createFramebuffer(this.gl),this.textureConfig=i.EZ(this.gl,this.textureHalfFloatExtension)}get debug(){return(0,n._K2)().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");let e=this.gl;o.callAndCheck(e,()=>e.finish()),o.callAndCheck(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),o.callAndCheck(e,()=>e.deleteFramebuffer(this.framebuffer)),o.callAndCheck(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),o.callAndCheck(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),o.callAndCheck(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),s.createFloat32MatrixTexture(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),s.createFloat16MatrixTexture(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),s.createUnsignedBytesMatrixTexture(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),s.uploadPixelDataToTexture(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,r,n){this.throwIfDisposed(),s.uploadDenseMatrixToTexture(this.gl,e,t,r,n,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),s.createFloat16PackedMatrixTexture(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),s.createPackedMatrixTexture(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(o.unbindColorTextureFromFramebuffer(this.gl,this.framebuffer),this.outputTexture=null),o.callAndCheck(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,r){return this.downloadMatrixDriver(e,()=>s.downloadByteEncodedFloatMatrixFromOutputTexture(this.gl,t,r,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,r,n,a,i){return s.downloadPackedMatrixFromBuffer(this.gl,e,t,r,n,a,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return s.downloadFloat32MatrixFromBuffer(this.gl,e,t)}createBufferFromTexture(e,t,r){this.bindTextureToFrameBuffer(e);let n=s.createBufferFromOutputTexture(this.gl,t,r,this.textureConfig);return this.unbindTextureToFrameBuffer(),n}createAndWaitForFence(){let e=this.createFence(this.gl);
170return this.pollFence(e)}createFence(e){let t,r;if((0,n._K2)().getBool("WEBGL_FENCE_API_ENABLED")){let n=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),r=()=>{let t=e.clientWaitSync(n,0,0);return t===e.ALREADY_SIGNALED||t===e.CONDITION_SATISFIED},t=n}else(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),r=()=>this.isQueryAvailable(t,(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):r=()=>!0;return{query:t,isFencePassed:r}}downloadMatrixFromPackedTexture(e,t,r){return this.downloadMatrixDriver(e,()=>s.downloadMatrixFromPackedOutputTexture(this.gl,t,r))}createProgram(e){this.throwIfDisposed();let t=this.gl;null==this.vertexShader&&(this.vertexShader=s.createVertexShader(t));let r=o.createProgram(t);o.callAndCheck(t,()=>t.attachShader(r,this.vertexShader)),o.callAndCheck(t,()=>t.attachShader(r,e)),o.linkProgram(t,r);let n=Object.assign(r,{vao:this.createVertexArray()});return this.debug&&o.validateProgram(t,n),n}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);let t=this.gl;o.callAndCheck(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),s.bindVertexProgramAttributeStreams(t,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&(o.callAndCheck(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&o.validateProgram(this.gl,this.program),o.callAndCheck(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,r=!0){return(this.throwIfDisposed(),r)?o.getProgramUniformLocationOrThrow(this.gl,e,t):o.getProgramUniformLocation(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),o.callAndCheck(this.gl,()=>this.gl.getAttribLocation(e,t))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,r){this.throwIfDisposed(),this.throwIfNoProgram(),o.bindTextureToProgramUniformSampler(this.gl,e,t,r)}setOutputMatrixTexture(e,t,r){this.setOutputMatrixTextureDriver(e,r,t)}setOutputPackedMatrixTexture(e,t,r){this.throwIfDisposed();let[n,a]=i.NO(t,r);this.setOutputMatrixTextureDriver(e,n,a)}setOutputMatrixWriteRegion(e,t,r,n){this.setOutputMatrixWriteRegionDriver(r,e,n,t)}setOutputPackedMatrixWriteRegion(e,t,r,n){throw Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&o.validateProgram(this.gl,this.program),o.validateFramebuffer(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();let e=this.gl;this.debug&&(console.assert(this.getVertexArray()===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()),o.callAndCheck(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),o.callAndCheck(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=o.getExtensionOrThrow(this.gl,2===(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){let e=this.gl,t=this.getQueryTimerExtensionWebGL2(),r=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,r),r}let e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){let e=this.gl,t=this.getQueryTimerExtensionWebGL2();e.endQuery(t.TIME_ELAPSED_EXT);return}let e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await n.ZSL.repeatedTry(()=>this.disposed||this.isQueryAvailable(e,(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){let t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{let t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;
170if(2===t){let t=this.gl,r=this.getQueryTimerExtensionWebGL2(),n=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),n&&!this.disjoint}{let t=this.getQueryTimerExtensionWebGL1(),r=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),r&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){let e=function(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}(this.itemsToPoll.map(e=>e.isDoneFn));for(let t=0;t<=e;++t){let{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){let r;this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||("setTimeoutCustom"in(0,n._K2)().platform&&(r=(0,n._K2)().platform.setTimeoutCustom.bind((0,n._K2)().platform)),n.ZSL.repeatedTry(()=>(this.pollItems(),0===this.itemsToPoll.length),()=>0,null,r))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),o.bindColorTextureToFramebuffer(this.gl,e,this.framebuffer),this.debug&&o.validateFramebuffer(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(o.bindColorTextureToFramebuffer(this.gl,this.outputTexture,this.framebuffer),this.debug&&o.validateFramebuffer(this.gl)):o.unbindColorTextureFromFramebuffer(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);let r=t();return this.unbindTextureToFrameBuffer(),r}setOutputMatrixTextureDriver(e,t,r){this.throwIfDisposed();let n=this.gl;o.bindColorTextureToFramebuffer(n,e,this.framebuffer),this.debug&&o.validateFramebuffer(n),this.outputTexture=e,o.callAndCheck(n,()=>n.viewport(0,0,t,r)),o.callAndCheck(n,()=>n.scissor(0,0,t,r))}setOutputMatrixWriteRegionDriver(e,t,r,n){this.throwIfDisposed(),o.callAndCheck(this.gl,()=>this.gl.scissor(e,t,r,n))}throwIfDisposed(){if(this.disposed)throw Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw Error("No GPU program is currently set.")}}},30823:(e,t,r)=>{"use strict";r.d(t,{AL:()=>l,cl:()=>i});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>+(e!==t)),o=(0,s.j)(n.ylV,i,null,"bool"),l={kernelName:n.ylV,backendName:"cpu",kernelFunc:o}},31479:(e,t,r)=>{"use strict";r.d(t,{Bu:()=>S,b_:()=>k,rF:()=>y});var n=r(45720),a=r(40693),s=r(95971);class i extends n.JFn.Serializable{getConfig(){return{}}}class o extends i{apply(e,t=1){return a.Pq(e,t)}}o.className="elu",n.JFn.registerClass(o);class l extends i{apply(e){return n.WfX(e)}}l.className="selu",n.JFn.registerClass(l);class u extends i{apply(e){return n.VVh(e)}}u.className="relu",n.JFn.registerClass(u);class h extends i{apply(e){return(0,n.DZQ)(()=>n.BpO(6,n.VVh(e)))}}h.className="relu6",n.JFn.registerClass(h);class p extends i{apply(e){return e}}p.className="linear",n.JFn.registerClass(p);class d extends i{apply(e){return n.ry7(e)}}d.className="sigmoid",n.JFn.registerClass(d);class c extends i{apply(e){return a.KK(e)}}c.className="hardSigmoid",n.JFn.registerClass(c);class f extends i{apply(e){return n.lw0(e)}}f.className="softplus",n.JFn.registerClass(f);class m extends i{apply(e){return a.aY(e)}}m.className="softsign",n.JFn.registerClass(m);class g extends i{apply(e){return n.ymU(e)}}g.className="tanh",n.JFn.registerClass(g);class y extends i{apply(e,t=-1){return n.Vs9(e,t)}}y.className="softmax",n.JFn.registerClass(y);class b extends i{apply(e,t=-1){return n.HPB(e,t)}}b.className="logSoftmax",n.JFn.registerClass(b);class x extends i{apply(e){return(0,n.DZQ)(()=>n.DZQ(()=>{let t=Math.sqrt(2),r=n.lKK(.5,n.WQq(1,n.Y12(n.y4m(e,t))));return n.lKK(e,r)}))}}x.className="gelu",n.JFn.registerClass(x);class v extends i{apply(e){return(0,n.DZQ)(()=>n.lKK(.5,n.lKK(e,n.WQq(1,n.ymU(n.lKK(n.RZD(n.y4m(2,Math.PI)),n.WQq(e,n.lKK(.044715,n.n7C(e,3)))))))))}}v.className="gelu_new",n.JFn.registerClass(v);class w extends i{apply(e){return(0,n.DZQ)(()=>n.lKK(e,n.ymU(n.lw0(e))))}}w.className="mish",n.JFn.registerClass(w);class T extends i{apply(e,t=1){return(0,n.DZQ)(()=>n.lKK(n.ry7(n.lKK(e,t)),e))}}function S(e){return e.getClassName()}function N(e,t={}){return(0,s.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"activation")}function k(e){if(null==e){let e={};return e.className="linear",e.config={},N(e)}if("string"==typeof e){let t={};return t.className=e,t.config={},N(t)}return e instanceof i?e:N(e)}T.className="swish",n.JFn.registerClass(T)},31519:(e,t,r)=>{"use strict";r.d(t,{I:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({expm1_:function(e){let t=(0,s.YT)(e,"x","expm1");return n.T2.runKernel(a.ybj,{x:t})}})},32021:(e,t,r)=>{"use strict";r.d(t,{m:()=>c});var n=r(5287),a=r(13649),s=r(96609),i=r(54463),o=r(75681),l=r(47802),u=r(98308),h=r(86032),p=r(18875),d=r(43578);let c=(0,p.op)({transpose_:function(e,t,r){let p=(0,i.YT)(e,"x","transpose");if(null==t&&(t=p.shape.map((e,t)=>t).reverse()),o.vA(p.rank===t.length,()=>`Error in transpose: rank of input ${p.rank} must match length of perm ${t}
170.`),t.forEach(e=>{o.vA(e>=0&&e<p.rank,()=>`All entries in 'perm' must be between 0 and ${p.rank-1} but got ${t}`)}),p.rank<=1)return p.clone();let c={perm:t};return"complex64"===p.dtype?(0,a.DZ)(()=>{let e=(0,d.x)(p),t=(0,u.n)(p);return e=n.T2.runKernel(s.wx0,{x:e},c),t=n.T2.runKernel(s.wx0,{x:t},c),r&&(t=(0,h.H)(t)),(0,l.f)(e,t)}):n.T2.runKernel(s.wx0,{x:p},c)}})},32266:(e,t,r)=>{"use strict";r.d(t,{B:()=>u});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990),l=r(13797);let u=(0,r(18875).op)({minimum_:function(e,t){let r=(0,i.YT)(e,"a","minimum"),u=(0,i.YT)(t,"b","minimum");[r,u]=(0,s.makeTypesMatch)(r,u),"bool"===r.dtype&&(r=(0,l.w)(r,"int32"),u=(0,l.w)(u,"int32")),(0,o.assertAndGetBroadcastShape)(r.shape,u.shape);let h={a:r,b:u};return n.T2.runKernel(a.LG0,h)}})},32280:(e,t,r)=>{"use strict";r.d(t,{Gx:()=>g,O0:()=>f,U3:()=>c});var n=r(45720),a=r(38180),s=r(91533),i=r(2748),o=r(32655),l=r(63537),u=r(12223),h=r(95971),p=r(466),d=r(21131);async function c(e,t){"modelTopology"in e||(e={modelTopology:e});let r=e.modelTopology;null!=r.model_config&&(r=r.model_config);let a=(0,p.w)(r),s=(0,u.i)(a,t);if(null!=e.weightsManifest){let t=await n.io.loadWeights(e.weightsManifest,e.pathPrefix,s.weights.map(e=>e.originalName)),r={};for(let e of s.weights)r[e.originalName]=t[e.originalName];s.loadWeights(r),(0,n.ASo)(t)}return s}async function f(e,t){if(null==t&&(t={}),"string"==typeof e){let r=n.io.getLoadHandlers(e,t);if(0===r.length)r.push(n.io.browserHTTPRequest(e,t));else if(r.length>1)throw new l.Qp(`Found more than one (${r.length}) load handlers for URL '${e}'`);e=r[0]}return m(e,void 0,t)}async function m(e,t,r){if(null==r&&(r={}),null==e.load)throw new l.Qp("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");let a=await e.load(),s=a.modelTopology;null!=s.model_config&&(s=s.model_config);let i=null==r.strict||r.strict,o=null!=a.weightData&&null!=a.weightSpecs&&i,h=(0,u.i)((0,p.w)(s),t,o),d=a.trainingConfig;if(null!=d&&h.loadTrainingConfig(d),null!=a.userDefinedMetadata&&h.setUserDefinedMetadata(a.userDefinedMetadata),null!=a.weightData){if(null==a.weightSpecs)throw new l.Qp("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");let{modelWeights:e,optimizerWeights:t}=function(e,t){let r=n.io.decodeWeights(e,t),a={},s=[];return t.forEach(e=>{"optimizer"===e.group?s.push({name:e.name,tensor:r[e.name]}):a[e.name]=r[e.name]}),{modelWeights:a,optimizerWeights:s}}(a.weightData,a.weightSpecs);h.loadWeights(e,i),null!=h.optimizer&&t.length>0&&await h.optimizer.setWeights(t),(0,n.ASo)(e),(0,n.ASo)(t.map(e=>e.tensor))}return h}class g extends o.Gw{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=null!=e.name?e.name:(0,a.v)("sequential_"),null!=e.layers)for(let t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(e=>e<0))throw new l.Qp(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){let t,r=e instanceof g||e instanceof o.Gw;if(r){if(1!==(t=e).outputs.length)throw new l.Qp("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==t.inputs.length)throw new l.Qp("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===e.inboundNodes.length){if(null==e.batchInputShape)throw new l.Qp("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");let t=(0,s.p)({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(t)}if(r)this.outputs=t.outputs,this.inputs=t.inputs;else{if(1!==e.inboundNodes.length)throw new l.Qp(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`);if(1!==e.inboundNodes[0].outputTensors.length)throw new l.Qp("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=(0,i.X6)(this.outputs[0])}this.inboundNodes=[],new i.bP({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:h.fD(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(e=>e.shape),outputShapes:this.outputs[0].shape})}else{let t=e.apply(this.outputs[0]);if(Array.isArray(t))throw TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[t],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(0===this.layers.length)throw TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{let e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(e,t){return null==this.model&&this.build(),this.model.call(e,t)}build(e){if((0,d.U$)(e),0===this.inputs.length||0===this.outputs.length)throw TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new o.Gw({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supp
170ortsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(e,t,r=console.log){this.built||this.build(),super.summary(e,t,r)}setWeights(e){null==this.model&&this.build(),this.model.setWeights(e)}evaluate(e,t,r={}){if(!this.built)throw new l.bu("The model needs to be compiled before being used.");return this.model.evaluate(e,t,r)}async evaluateDataset(e,t){if(!this.built)throw new l.bu("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return null==this.model&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return null==this.model&&this.build(),this.model.predictOnBatch(e)}compile(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return null==this.model?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,r={}){if(!this.built)throw new l.bu("The model needs to be compiled before being used.");return this.model.fit(e,t,r)}async fitDataset(e,t){if(!this.built)throw new l.bu("The model needs to be compiled before being used.");return this.model.fitDataset(e,t)}async trainOnBatch(e,t){return this.model.trainOnBatch(e,t)}static fromConfig(e,t,r={},a=!1){let s,i={};if(t instanceof Array){if(null==t[0].className||"Merge"===t[0].className)throw new l.Qp("Legacy serialization format not supported yet.");s=t}else n.ZSL.assert(null!=t.layers,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),s=t.layers,delete t.layers,i=t;let o=new e(i);if(!(o instanceof g))throw new l.EH(`Sequential.fromConfig called on non-Sequential input: ${o}`);for(let e of s){let t=void 0,r=(0,u.i)(e,t,a);a&&r.setFastWeightInitDuringBuild(!0),o.add(r)}return o}set stopTraining(e){if(null==this.model)throw new l.Qp("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(null==this.model)throw new l.Qp("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){let e=[];for(let t of this.layers){let r={};r.className=t.getClassName(),r.config=t.getConfig(),e.push(r)}return{name:this.name,layers:e}}}g.className="Sequential",n.JFn.registerClass(g)},32382:(e,t,r)=>{"use strict";r.d(t,{E:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({isInf_:function(e){let t=(0,s.YT)(e,"x","isInf");return n.T2.runKernel(a.E3$,{x:t})}})},32515:(e,t,r)=>{"use strict";r.d(t,{W:()=>o,m:()=>i});var n=r(45720),a=r(60072),s=r(25550);function i(e){let{inputs:t,attrs:r,backend:n}=e,{x:i}=t,{perm:o}=r;(0,a.C)(i,"transpose");let l=Array(i.shape.length);for(let e=0;e<l.length;e++)l[e]=i.shape[o[e]];let u=n.data.get(i.dataId).values,h=(0,s._)(u,i.shape,i.dtype,o,l);return{dataId:n.write(h,l,i.dtype),shape:l,dtype:i.dtype}}let o={kernelName:n.wx0,backendName:"cpu",kernelFunc:i}},32593:(e,t,r)=>{"use strict";r.d(t,{Jc:()=>c,Jt:()=>g,Ol:()=>p,Pg:()=>f,SO:()=>m,VW:()=>h,Xv:()=>u,Yq:()=>o,bt:()=>l,qp:()=>d});var n=r(45720),a=r(64630),s=r(40693),i=r(63537);function o(e,t){return(0,n.DZQ)(()=>{"float32"!==e.dtype&&(e=n.wgE(e,"float32"));let r=n.czq(s.Ew(e),t,!0),i=n.GSj(r.shape,(0,a.Ni)()),o=n.RZD(n.PhQ(r,i));return n.y4m(e,o)})}function l(e,t){return(0,n.DZQ)(()=>n.i2o(s.Ew(n.jbE(t,e)),-1))}function u(e,t){return(0,n.DZQ)(()=>n.i2o(n.tnl(n.jbE(t,e)),-1))}function h(e,t){return(0,n.DZQ)(()=>{let r=n.jbE(e,t),s=n.zQh(n.tnl(e),(0,a.Ni)(),Number.MAX_VALUE),i=n.tnl(n.y4m(r,
170s));return n.lKK(100,n.i2o(i,-1))})}function p(e,t,r=!1){return(0,n.DZQ)(()=>{if(r)t=n.Vs9(t);else{let e=n.czq(t,t.shape.length-1,!0);t=n.y4m(t,e)}return t=n.zQh(t,(0,a.Ni)(),1-(0,a.Ni)()),n.HZy(n.czq(n.lKK(n.wgE(e,"float32"),n.Rm2(t)),t.shape.length-1))})}function d(e,t,r=!1){return(0,n.DZQ)(()=>{let i=n.wgE(n.RIf(s.Bq(e)),"int32"),o=(t=n.zQh(t,(0,a.Ni)(),1-(0,a.Ni)())).shape;return p(n.tQQ(n.Mw0(i,o[o.length-1]),o),t,r)})}function c(e,t){return(0,n.DZQ)(()=>{let r;return r=n.zQh(t,(0,a.Ni)(),1-(0,a.Ni)()),r=n.Rm2(n.y4m(r,n.jbE(1,r))),n.i2o(function(e,t){if(!n.ZSL.arraysEqual(e.shape,t.shape))throw new i.Qp(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return(0,n.DZQ)(()=>{let r=n.VVh(t),a=n.HZy(n.tnl(t));return n.WQq(n.jbE(r,n.lKK(t,e)),n.Kko(n.oNF(a)))})}(e,r),-1)})}function f(e,t){return(0,n.DZQ)(()=>{let r=o(e,-1),a=o(t,-1),s=n.lKK(r,a);return n.HZy(n.czq(s,-1))})}let m={meanSquaredError:l,meanAbsoluteError:u,meanAbsolutePercentageError:h,meanSquaredLogarithmicError:function(e,t){return(0,n.DZQ)(()=>{let r=n.zQh(t,(0,a.Ni)(),Number.MAX_VALUE),i=n.Rm2(n.WQq(1,r)),o=n.zQh(e,(0,a.Ni)(),Number.MAX_VALUE),l=n.Rm2(n.WQq(1,o));return n.i2o(s.Ew(n.jbE(i,l)),-1)})},squaredHinge:function(e,t){return(0,n.DZQ)(()=>{let r=n.PhQ(0,n.jbE(1,n.lKK(e,t)));return n.i2o(s.Ew(r),-1)})},hinge:function(e,t){return(0,n.DZQ)(()=>{let r=n.PhQ(0,n.jbE(1,n.lKK(e,t)));return n.i2o(r,-1)})},categoricalHinge:function(e,t){return(0,n.DZQ)(()=>{let r=n.czq(n.lKK(e,t),-1),a=n.T9B(n.lKK(n.jbE(1,e),t),-1);return n.PhQ(0,n.WQq(1,n.jbE(a,r)))})},logcosh:function(e,t){return(0,n.DZQ)(()=>{let r=Math.log(2),a=n.jbE(t,e),s=n.jbE(n.WQq(a,n.lw0(n.lKK(-2,a))),r);return n.i2o(s,-1)})},categoricalCrossentropy:p,sparseCategoricalCrossentropy:d,binaryCrossentropy:c,kullbackLeiblerDivergence:function(e,t){return(0,n.DZQ)(()=>{let r=n.zQh(e,(0,a.Ni)(),1),s=n.zQh(t,(0,a.Ni)(),1);return n.czq(n.lKK(e,n.Rm2(n.y4m(r,s))),-1)})},poisson:function(e,t){return(0,n.DZQ)(()=>{let r=n.Rm2(n.WQq((0,a.Ni)(),t));return n.i2o(n.jbE(t,n.lKK(e,r)),-1)})},cosineProximity:f};function g(e){if("string"!=typeof e)return e;{if(e in m)return m[e];let t=`Unknown loss ${e}`;throw e.toLowerCase().includes("softmaxcrossentropy")&&(t=`Unknown loss ${e}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new i.Qp(t)}}},32999:(e,t,r)=>{"use strict";r.d(t,{F:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({argMax_:function(e,t=0){let r=(0,s.YT)(e,"x","argMax");return n.T2.runKernel(a.Jp_,{x:r},{axis:t})}})},33202:(e,t,r)=>{"use strict";r.d(t,{V:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({reciprocal_:function(e){let t=(0,s.YT)(e,"x","reciprocal");return n.T2.runKernel(a.huO,{x:t})}})},33235:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^(e^e<<1))|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=r.charCodeAt(n),n==r.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function o(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function l(e,t){var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&("object"==typeof n&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.xorwow=l}(0,e=r.nmd(e),r.amdD)},33282:(e,t,r)=>{"use strict";r.d(t,{e:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({spaceToBatchND_:function(e,t,r){let o=(0,s.YT)(e,"x","spaceToBatchND");return i.vA(o.rank>=1+t.length,()=>`input rank ${o.rank} should be > than [blockShape] ${t.length}`),i.vA(r.length===t.length,()=>`paddings.shape[0] ${r.length} must be equal to [blockShape] ${t.length}`),i.vA(o.shape.reduce((e,n,a)=>a>0&&a<=t.length?e&&(n+r[a-1][0]+r[a-1][1])%t[a-1]==0:e,!0),()=>`input spatial dimensions ${o.shape.slice(1)} with paddings ${r.toString()} must be divisible by blockShapes ${t.toString()}`),n.T2.runKernel(a.A8B,{x:o},{blockShape:t,paddings:r})}})},35199:(e,t,r)=>{"use strict";r.d(t,{h:()=>h});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(4087),l=r(18875),u=r(86036);let h=(0,l.op)({broadcastTo_:function(e,t){let r=(0,s.YT)(e,"broadcastTo","x"),l=r.shape;if((0,i.SA)(t),t.length<r.rank)throw Error(`broadcastTo(): shape.length=${t.length} < input.rank=${r.rank}.`);if(t.length>r.rank){let e=r.shape.slice();for(;e.length<t.length;)e.unshift(1);r=(0,u.t)(r,e)}let h=r.shape,p=Array.from(t);for(let e=t.length-1;e>=0;e--)if(h[e]===t[e])p[e]=1;else if(1!==r.shape[e])throw Error(`broadcastTo(): [${l}] cannot be broadcast to [${t}].`);if(0===p.map((e,t)=>e>1?t:-1).filter(e=>e>=0).length)return(0,o.o)(r);let d={x:r};return n.T2.runKernel(a.FAs,d,{reps:p})}})},35508:function(e,t,r){var n;!function(e,a,s){function i(e){var t,r=this,n=(t=0xefc8249d,function(e){e=String(e);for(var r=0;r<e.length;r++){var n=.02519603282416938*(t+=e.charCodeAt(r));t=n>>>0,n-=t,n*=t,t=n>>>0,n-=t,t+=0x100000000*n}return(t>>>0)*23283064365386963e-26});r.next=function(){var e=2091639*r.s0+23283064365386963e-26*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1)}function o(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function l(e,t){var r=new i(e),n=t&&t.state,a=r.next;return a.int32=function(){return 0x100000000*r.next()|0},a.double=function(){return a()+(2097152*a()|0)*11102230246251565e-32},a.quick=a,n&&("object"==typeof n&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.alea=l}(0,e=r.nmd(e),r.amdD)},35643:(e,t,r)=>{"use strict";r.d(t,{C:()=>o});var n=r(46519),a=r(71490),s=r(15768);let i={R:0,G:1,B:2,A:3};class o{constructor(e,t=!1,r="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];let o=(0,n.B)();this.outputShape=e,this.enableShapeUniforms=(0,a.ik)(this.outputShape.length);let l="result";t&&(l="floor(result * 255. + 0.5)");let u="";for(let e=0;e<r.length;e++){let t=r[e];u+=` 171 if(offset == ${e}) { 172 result = values[${i[t]}]; 173 }`}this.userCode=` 174 ${this.enableShapeUniforms?s.Od():s.fM(e)} 175 176 void main() { 177 ivec3 coords = getOutputCoords(); 178 int flatIndex = getFlatIndex(coords); 179 float result = 0.; 180 int offset = imod(flatIndex, ${r.length}); 181 182 flatIndex = idiv(flatIndex, ${r.length}, 1.); 183 184 int r = flatIndex / texShape[1];
185 if (r < texShape[0]) { 186 int c = imod(flatIndex, texShape[1]); 187 vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); 188 vec4 values = ${o.texture2D}(A, uv); 189 ${u} 190 } 191 ${o.output} = vec4(${l}, 0., 0., 0.); 192 } 193 `}}},37953:(e,t,r)=>{"use strict";r.d(t,{Y:()=>l});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(13797);let l=(0,r(18875).op)({erf_:function(e){let t=(0,s.YT)(e,"x","erf");i.vA("int32"===t.dtype||"float32"===t.dtype,()=>"Input dtype must be `int32` or `float32`."),"int32"===t.dtype&&(t=(0,o.w)(t,"float32"));let r={x:t};return n.T2.runKernel(a._s9,r)}})},38180:(e,t,r)=>{"use strict";r.d(t,{j:()=>a,v:()=>i});let n=0;function a(){return n++}let s={};function i(e=""){return e in s||(s[e]=0),s[e]+=1,e+s[e].toString()}},38193:(e,t,r)=>{"use strict";r.d(t,{Yp:()=>l,uM:()=>i});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)(e=>Math.expm1(e)),o=(0,s.F)(n.ybj,i),l={kernelName:n.ybj,backendName:"cpu",kernelFunc:o}},38579:(e,t,r)=>{"use strict";r.d(t,{e:()=>h});var n=r(72155),a=r(54463),s=r(29337),i=r(96414),o=r(18875),l=r(77833),u=r(61997);let h=(0,o.op)({divNoNan_:function(e,t){let r=(0,a.YT)(e,"a","div"),o=(0,a.YT)(t,"b","div");[r,o]=(0,n.makeTypesMatch)(r,o);let h=(0,s.y)(r,o),p=(0,u.P)(h),d=(0,i.L)(o,p);return(0,l._)(d,p,h)}})},39316:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({atanh_:function(e){let t=(0,s.YT)(e,"x","atanh");return n.T2.runKernel(a.zP9,{x:t})}})},39533:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({unique_:function(e,t=0){let r=(0,s.YT)(e,"x","unique","string_or_numeric");(0,i.vA)(r.rank>0,()=>"The input tensor must be at least 1D");let[o,l]=n.T2.runKernel(a.EwU,{x:r},{axis:t});return{values:o,indices:l}}})},39616:(e,t,r)=>{"use strict";r.d(t,{T:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({max_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","max");return n.T2.runKernel(a.VAI,{x:i},{reductionIndices:t,keepDims:r})}})},39754:(e,t,r)=>{"use strict";r.d(t,{DE:()=>function e(t,r){return n.DZQ(()=>null==t?null:Array.isArray(t)?t.map(t=>e(t,r)):(0,a.kg)(t,"int32"===r.dtype?r:n.wgE(r,"int32")))},Ec:()=>u,Pe:()=>i,XX:()=>o,n4:()=>l,yy:()=>s});var n=r(45720),a=r(40693);function s(e){n.ZSL.assert(e>0&&Number.isInteger(e),()=>`batchSize is required to be a positive integer, but got ${e}`)}function i(e,t,r){return null==e?[null]:Array.isArray(e)?e.map(e=>(0,a.Dh)(e,t,r-t)):(0,a.Dh)(e,t,r-t)}function o(e,t){let r=[],n=0,a=null;for(;n<e;)(a=n+t)>=e&&(a=e),r.push([n,a]),n=a;return r}function l(e){let t=[];e instanceof n.qYS&&(e=[e]);for(let r=0;r<e.length;++r){let n=e[r];if(1===n.rank)t.push((0,a.UG)(n,1));else if(0===n.rank)throw Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");else t.push(n)}return t}function u(e,t){if(null==e)return;let r=[];if(t instanceof n.qYS)r.push(t.id);else if(Array.isArray(t))t.forEach(e=>r.push(e.id));else if(null!=t)for(let e in t){let n=t[e];r.push(n.id)}let a=[];if(e instanceof n.qYS)-1===r.indexOf(e.id)&&a.push(e);else if(Array.isArray(e))e.forEach(e=>{-1===r.indexOf(e.id)&&a.push(e)});else if(null!=e)for(let t in e){let n=e[t];-1===r.indexOf(n.id)&&a.push(n)}a.forEach(e=>{e.isDisposed||e.dispose()})}},39868:(e,t,r)=>{"use strict";r.d(t,{Hq:()=>l,Nb:()=>o,X0:()=>s,X8:()=>i,_Q:()=>a,rf:()=>u});var n=r(71490);let a="return x;",s=` 194 vec4 result; 195 196 result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); 197 result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); 198 result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); 199 result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); 200 201 return result; 202`,i=` 203 vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); 204 bvec4 isNaN = isnan(x); 205 206 result.r = isNaN.r ? x.r : result.r; 207 result.g = isNaN.g ? x.g : result.g; 208 result.b = isNaN.b ? x.b : result.b; 209 result.a = isNaN.a ? x.a : result.a; 210 211 return result; 212`,o=` 213 vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); 214 bvec4 isNaN = isnan(x); 215 216 result.r = isNaN.r ? x.r : result.r; 217 result.g = isNaN.g ? x.g : result.g; 218 result.b = isNaN.b ? x.b : result.b; 219 result.a = isNaN.a ? x.a : result.a; 220 221 return result; 222`,l="return 1.0 / (1.0 + exp(-1.0 * x));";class u{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length),this.userCode=` 223 vec4 unaryOperation(vec4 x) { 224 ${t} 225 } 226 227 void main() { 228 vec4 x = getAAtOutCoords(); 229 vec4 y = unaryOperation(x); 230 231 setOutput(y); 232 } 233 `}}},40030:(e,t,r)=>{"use strict";r.d(t,{t:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({stack_:function(e,t=0){let r=(0,s.j1)(e,"tensors","stack","string_or_numeric");return i.vA(r.length>=1,()=>"Pass at least one tensor to tf.stack"),r.length>0&&i.vA(t<=r[0].rank,()=>"Axis must be <= rank of the tensor"),n.T2.runKernel(a.mM$,r,{axis:t})}})},40091:(e,t,r)=>{"use strict";r.d(t,{O:()=>s});var n=r(54463),a=r(77969);function s(e,t,r){let s=(0,n.MZ)(e,r);return(0,a.Q)(e,t,s,r)}},40693:(e,t,r)=>{"use strict";r.d(t,{Bq:()=>p,Dh:()=>c,EZ:()=>C,Ew:()=>T,FE:()=>x,KK:()=>E,Ls:()=>A,Om:()=>v,PS:()=>d,Pq:()=>k,UG:()=>u,Vs:()=>b,aY:()=>I,kg:()=>w,ly:()=>y,ni:()=>N,r0:()=>m,u1:()=>g,ux:()=>h,wg:()=>l});var n=r(45720),a=r(48671),s=r(63537),i=r(62376),o=r(64630);function l(e,t){return n.wgE(e,t)}function u(e,t=-1){let r=e.shape.slice();return t<0&&(t=r.length+t+1),r.splice(t,0,1),n.tQQ(e,r)}function h(e,t){return(0,n.DZQ)(()=>
233{if(2!==e.shape.length)throw new s.Qp(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);return b(u(e,1),[1,t,1])})}function p(e){let t=[i.no(e.shape)];return n.tQQ(e,t)}function d(e){if(e.rank<=1)throw new s.Qp(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);let t=[e.shape[0],i.no(e.shape,1)];return n.tQQ(e,t)}function c(e,t,r){return(0,n.DZQ)(()=>{switch(e.rank){case 1:return n.Q$M(e,t,r);case 2:return n.zAd(e,[t,0],[r,e.shape[1]]);case 3:return n.wck(e,[t,0,0],[r,e.shape[1],e.shape[2]]);case 4:return n.R0O(e,[t,0,0,0],[r,e.shape[1],e.shape[2],e.shape[3]]);case 5:return n.dik(e,[t,0,0,0,0],[r,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return n.dik(e,[t,0,0,0,0,0],[r,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new s.Qp(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}})}function f(e,t,r){return(0,n.DZQ)(()=>{switch(e.rank){case 1:return n.Q$M(e,t,r);case 2:return n.zAd(e,[0,t],[e.shape[0],r]);case 3:return n.wck(e,[0,0,t],[e.shape[0],e.shape[1],r]);case 4:return n.R0O(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],r]);default:throw new s.Qp(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function m(e,t,r,a){return(0,n.DZQ)(()=>{switch(e.rank){case 1:return n.Q$M(e,t,r);case 2:switch(a){case 1:return c(e,t,r);case 2:return f(e,t,r);default:throw new s.Qp(`The axis is not within the rank of the tensor ${a}`)}case 3:switch(a){case 1:return c(e,t,r);case 2:return n.wck(e,[0,t,0],[e.shape[0],r,e.shape[2]]);case 3:return f(e,t,r);default:throw new s.Qp(`The axis is not within the rank of the tensor ${a}`)}case 4:switch(a){case 1:return c(e,t,r);case 2:return n.R0O(e,[0,t,0,0],[e.shape[0],r,e.shape[2],e.shape[3]]);case 3:return n.R0O(e,[0,0,t,0],[e.shape[0],e.shape[1],r,e.shape[3]]);case 4:return f(e,t,r);default:throw new s.Qp(`The axis is not within the rank of the tensor ${a}`)}default:throw new s.Qp(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function g(e,t=-1){let r;return t<0&&(t=0!==(r=e[0].rank)?r:0),t===e[0].rank&&(t=-1),n.xWs(e,t)}function y(e,t){switch(e.rank){case 1:return n.I1m([e,t]);case 2:return n.RPU([e,t],0);case 3:return n.O5O([e,t],0);case 4:return n.P1l([e,t],0);default:throw new s.Qp(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function b(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new s.Qp(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return n.Vsq(e,t)}function x(e,t=0,r=1,a,s){return n.FE$(e,t,r,a,s)}function v(e,t,r,a){if(e.rank<2||t.rank<2)throw new s.EH(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`);if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new s.EH(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${t.shape}`);if(2===e.rank&&2===t.rank)return n.cZk.matMul({a:e,b:t,transposeA:!1,transposeB:!1,bias:a?S(e.rank,a,(0,o.VI)()):null,activation:r});{let s=e.shape.slice(),i=s.pop();e=n.tQQ(e,[-1,i]);let l=t.shape.slice(),u=l.pop(),h=l.pop(),p=[...l,u],d=Array.from({length:t.rank},(e,r)=>0===r?t.rank-2:r<=t.rank-2?r-1:r);t=n.tQQ(n.mgz(t,d),[h,-1]);let c=[...s,...p];return n.tQQ(n.cZk.matMul({a:e,b:t,transposeA:!1,transposeB:!1,bias:a?S(e.rank,a,(0,o.VI)()):null,activation:r}),c)}}function w(e,t,r){return(0,n.DZQ)(()=>(t=Array.isArray(t)?(0,n.tGX)(t,"int32"):n.wgE(t,"int32"),n.kgh(e,t,r)))}function T(e){return n.lKK(e,e)}function S(e,t,r){let a=t.shape;if(1!==t.rank&&t.rank!==e)throw new s.Qp(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`);if(5===e){if("channelsFirst"===r)if(1===a.length)return n.tQQ(t,[1,a[0],1,1,1]);else return n.tQQ(t,[1,a[3],a[0],a[1],a[2]]);else if("channelsLast"===r)if(1===a.length)return n.tQQ(t,[1,1,1,1,a[0]]);else return n.tQQ(t,[1].concat(a))}else if(4===e){if("channelsFirst"===r)if(1===a.length)return n.tQQ(t,[1,a[0],1,1]);else return n.tQQ(t,[1,a[2],a[0],a[1]]);else if("channelsLast"===r)if(1===a.length)return n.tQQ(t,[1,1,1,a[0]]);else return n.tQQ(t,[1].concat(a))}else if(3===e){if("channelsFirst"===r)if(1===a.length)return n.tQQ(t,[1,a[0],1]);else return n.tQQ(t,[1,a[1],a[0]]);else if("channelsLast"===r)if(1===a.length)return n.tQQ(t,[1,1,a[0]]);else return n.tQQ(t,[1].concat(a))}else if(e<3)return t;throw new s.Qp(`Unsupported input rank by biasAdd: ${t.rank}`)}function N(e,t,r){return(0,n.DZQ)(()=>(null==r&&(r=(0,o.VI)()),(0,a.uM)(r),n.WQq(e,S(e.rank,t,r))))}function k(e,t=1){if(1!==t)throw new s.EH(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return n.Pqc(e)}function I(e){return(0,n.DZQ)(()=>n.y4m(e,n.WQq(n.tnl(e),1)))}function C(e,t,r,a){return(0,n.DZQ)(()=>n.EZY(e,t,r,a))}function E(e){return(0,n.DZQ)(()=>{let t=n.WQq(.5,n.lKK(.2,e));return n.zQh(t,0,1)})}function A(e,t,r=!1){return r?e():t()}},40838:(e,t,r)=>{"use strict";r.d(t,{DE:()=>l,YZ:()=>m,sQ:()=>h,uH:()=>c,vJ:()=>p,xS:()=>u});var n=r(45720),a=r(64630),s=r(95971);function i(e,t){return(0,n.DZQ)(()=>
233n.RZD(n.czq(n.lKK(e,e),t,!0)))}class o extends n.JFn.Serializable{getConfig(){return{}}}class l extends o{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return(0,n.DZQ)(()=>{let t=i(e,this.axis),r=n.zQh(t,0,this.maxValue);return n.lKK(e,n.y4m(r,n.WQq((0,a.Ni)(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}l.className="MaxNorm",n.JFn.registerClass(l);class u extends o{constructor(e){super(),this.defaultAxis=0,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return(0,n.DZQ)(()=>n.y4m(e,n.WQq((0,a.Ni)(),i(e,this.axis))))}getConfig(){return{axis:this.axis}}}u.className="UnitNorm",n.JFn.registerClass(u);class h extends o{apply(e){return n.VVh(e)}}h.className="NonNeg",n.JFn.registerClass(h);class p extends o{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=e.minValue?e.minValue:this.defaultMinValue,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.rate=null!=e.rate?e.rate:this.defaultRate,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return(0,n.DZQ)(()=>{let t=i(e,this.axis),r=n.WQq(n.lKK(this.rate,n.zQh(t,this.minValue,this.maxValue)),n.lKK(1-this.rate,t));return n.lKK(e,n.y4m(r,n.WQq((0,a.Ni)(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}p.className="MinMaxNorm",n.JFn.registerClass(p);let d={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function c(e){return(0,s.k4)(e)}function f(e,t={}){return(0,s.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"constraint")}function m(e){return null==e?null:"string"==typeof e?f({className:e in d?d[e]:e,config:{}}):e instanceof o?e:f(e)}},41891:(e,t,r)=>{"use strict";r.d(t,{G:()=>i});var n=r(5287),a=r(96609),s=r(75681);function i(e,t,r){(0,s.SA)(e),r=r||(0,s.X$)(t);let i={shape:e,value:t,dtype:r};return n.T2.runKernel(a.SQl,{},i)}},42153:(e,t,r)=>{"use strict";r.d(t,{z:()=>m});var n=r(75681),a=r(47802),s=r(76110),i=r(98308),o=r(18875),l=r(43578),u=r(86036),h=r(61324),p=r(23926),d=r(45921),c=r(61997),f=r(22313);let m=(0,o.op)({rfft_:function(e,t){let r;(0,n.vA)("float32"===e.dtype,()=>`The dtype for rfft() must be real value but got ${e.dtype}`);let o=e.shape[e.shape.length-1],m=e.size/o;if(null!=t&&t<o){let n=e.shape.map(e=>0),a=e.shape.map(e=>e);a[e.shape.length-1]=t,r=(0,h.d)(e,n,a),o=t}else if(null!=t&&t>o){let n=e.shape.map(e=>e);n[e.shape.length-1]=t-o,r=(0,s.x)([e,(0,d.U)(n)],e.shape.length-1),o=t}else r=e;let g=(0,c.P)(r),y=(0,u.t)((0,a.f)(r,g),[m,o]),b=(0,f.h)(y),x=Math.floor(o/2)+1,v=(0,l.x)(b),w=(0,i.n)(b),T=(0,p.l)(v,[x,o-x],v.shape.length-1),S=(0,p.l)(w,[x,o-x],w.shape.length-1),N=r.shape.slice();return N[r.shape.length-1]=x,(0,u.t)((0,a.f)(T[0],S[0]),N)}})},42290:(e,t,r)=>{"use strict";r.d(t,{h8:()=>f,xd:()=>w,Ux:()=>v,bL:()=>T,KJ:()=>S,lz:()=>b,H4:()=>p,TO:()=>N,Gs:()=>k,sN:()=>c,iv:()=>I,rZ:()=>g,m9:()=>m,EE:()=>y,Lm:()=>x,_c:()=>d,Fe:()=>$,zo:()=>A});var n=r(45720),a=r(40693),s=r(48671),i=r(63537);let o=["fanIn","fanOut","fanAvg"],l=["normal","uniform","truncatedNormal"];var u=r(95971),h=r(62376);class p extends n.JFn.Serializable{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class d extends p{apply(e,t){return(0,n.Ul9)(e,t)}}d.className="Zeros",n.JFn.registerClass(d);class c extends p{apply(e,t){return(0,n.SaS)(e,t)}}c.className="Ones",n.JFn.registerClass(c);class f extends p{constructor(e){if(super(),"object"!=typeof e)throw new i.Qp(`Expected argument of type ConstantConfig but got ${e}`);if(void 0===e.value)throw new i.Qp(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return(0,n.DZQ)(()=>(0,n.lKK)((0,n.d_2)(this.value),(0,n.SaS)(e,t)))}getConfig(){return{value:this.value}}}f.className="Constant",n.JFn.registerClass(f);class m extends p{constructor(e){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=e.minval||this.DEFAULT_MINVAL,this.maxval=e.maxval||this.DEFAULT_MAXVAL,this.seed=e.seed}apply(e,t){return(0,n.YeY)(e,this.minval,this.maxval,t,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}m.className="RandomUniform",n.JFn.registerClass(m);class g extends p{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new i.EH(`randomNormal does not support dType ${t}.`);return a.FE(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}g.className="RandomNormal",n.JFn.registerClass(g);class y extends p{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new i.EH(`truncatedNormal does not support dType ${t}.`);
233return(0,n.efE)(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}y.className="TruncatedNormal",n.JFn.registerClass(y);class b extends p{constructor(e){super(),this.gain=null!=e.gain?e.gain:1}apply(e,t){return(0,n.DZQ)(()=>{if(2===e.length&&e[0]===e[1])return(0,n.lKK)(this.gain,(0,n.y5U)(e[0]));throw new i.Qp("Identity matrix initializer can only be used for 2D square matrices.")})}getConfig(){return{gain:this.gain}}}b.className="Identity",n.JFn.registerClass(b);class x extends p{constructor(e){var t,r;if(super(),e.scale<0)throw new i.Qp(`scale must be a positive float. Got: ${e.scale}`);this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t=this.mode,(0,u.E6)(o,"FanMode",t),this.distribution=null==e.distribution?"normal":e.distribution,r=this.distribution,(0,u.E6)(l,"Distribution",r),this.seed=e.seed}apply(e,t){let r=function(e,t="channelsLast"){let r,n;if((0,s.uM)(t),2===e.length)r=e[0],n=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){let t=(0,h.no)(e,2);r=e[1]*t,n=e[0]*t}else if("channelsLast"===t){let t=(0,h.no)(e,0,e.length-2);r=e[e.length-2]*t,n=e[e.length-1]*t}}else{let t=(0,h.no)(e);r=Math.sqrt(t),n=Math.sqrt(t)}return[r,n]}(e),a=r[0],o=r[1],l=this.scale;if("fanIn"===this.mode?l/=Math.max(1,a):"fanOut"===this.mode?l/=Math.max(1,o):l/=Math.max(1,(a+o)/2),"normal"===this.distribution){let r=Math.sqrt(l);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new i.EH(`${this.getClassName()} does not support dType ${t}.`);
233return(0,n.efE)(e,0,r,t,this.seed)}{let r=Math.sqrt(3*l);return(0,n.YeY)(e,-r,r,t,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}x.className="VarianceScaling",n.JFn.registerClass(x);class v extends x{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return x.className}}v.className="GlorotUniform",n.JFn.registerClass(v);class w extends x{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return x.className}}w.className="GlorotNormal",n.JFn.registerClass(w);class T extends x{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return x.className}}T.className="HeNormal",n.JFn.registerClass(T);class S extends x{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return x.className}}S.className="HeUniform",n.JFn.registerClass(S);class N extends x{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return x.className}}N.className="LeCunNormal",n.JFn.registerClass(N);class k extends x{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return x.className}}k.className="LeCunUniform",n.JFn.registerClass(k);class I extends p{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=null==e.gain?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,t){return(0,n.DZQ)(()=>{if(e.length<2)throw new i.EH("Shape must be at least 2D.");if("int32"!==t&&"float32"!==t&&void 0!==t)throw TypeError(`Unsupported data type ${t}.`);let r=n.ZSL.sizeFromShape(e.slice(0,-1)),s=e[e.length-1],o=r*s;o>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${o}) elements: Slowness may result.`);let l=[Math.max(s,r),Math.min(s,r)],u=a.FE(l,0,1,t,this.seed),h=n.mPL.qr(u,!1),p=h[0],d=h[1].flatten().stridedSlice([0],[Math.min(s,r)*Math.min(s,r)],[Math.min(s,r)+1]);return p=(0,n.lKK)(p,d.sign()),r<s&&(p=p.transpose()),(0,n.lKK)((0,n.d_2)(this.gain),p.reshape(e))})}getConfig(){return{gain:this.gain,seed:this.seed}}}I.className="Orthogonal",n.JFn.registerClass(I);let C={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function E(e,t={}){return(0,u.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"initializer")}function A(e){return(0,u.k4)(e)}function $(e){if("string"==typeof e){let t=e in C?C[e]:e;if("GlorotNormal"===t)return new w;{if("GlorotUniform"===t)return new v;if("HeNormal"===t)return new T;if("HeUniform"===t)return new S;if("LeCunNormal"===t)return new N;if("LeCunUniform"===t)return new k;let e={};return e.className=t,e.config={},E(e)}}return e instanceof p?e:E(e)}},42635:(e,t,r)=>{"use strict";r.d(t,{LD:()=>m,LG:()=>g,OM:()=>d,Sb:()=>y,Yb:()=>f,cL:()=>x,xu:()=>c});var n=r(45720),a=r(40693),s=r(2748),i=r(63537),o=r(32593),l=r(95971),u=r(62376),h=r(21131);class p extends s.Wd{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new i.EH}computeElementwiseOpOutputShape(e,t){if(null==e||null==t)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(0===t.length)return e;let r=e.slice(0,e.length-t.length);for(let n=0;n<t.length;++n){let a=e[e.length-t.length+n],s=t[n];if(null==a||null==s||a<0||s<0)r.push(null);else if(1===a)r.push(s);else if(1===s)r.push(a);else{if(a!==s)throw new i.Qp("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));r.push(a)}}return r}build(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[(0,h.U$)(e)]),e.length<2)throw new i.Qp(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`);let t=[];for(let r of e)null!=r&&null!==r[0]&&t.push(r[0]);if((t=l.Am(t)).length>1)throw new i.Qp(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let r=null==e[0]?null:e[0].slice(1);for(let t=1;t<e.length;++t){let n=null==e[t]?null:e[t].slice(1);r=this.computeElementwiseOpOutputShape(r,n)}let n=e.map(e=>e.length);-1===e.indexOf(null)&&1===l.Am(n).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return(0,n.DZQ)(()=>
233{if(!this.reshapeRequired)return this.mergeFunction(e);{let t=[],r=e.map(e=>e.rank);if(-1===r.indexOf(null)){let n=u.T9(r);for(let r of e){let e=r.rank;for(let t=0;t<n-e;++t)r=a.UG(r,1);t.push(r)}return this.mergeFunction(t)}{let r=!1;for(let a of e){let e=a.rank;if(null==e){let e=a.shape,s=e[0],i=e.slice(1).concat([s]),o=n.tQQ(a,[s].concat(u.no(e.slice(1))));o=n.mgz(o,[1,0]),o=n.tQQ(o,i),t.push(o),r=!0}else if(e>1){let s=u.y1(1,e).concat([0]);t.push(n.mgz(a,s)),r=!0}else t.push(a)}let a=this.mergeFunction(t),s=a.rank;if(r){if(null==s){let e=a.shape,t=e.length,r=e[t-1],s=[r].concat(e.slice(0,e.length-1));a=n.tQQ(n.mgz(n.tQQ(a,[-1,r]),[1,0]),s)}else if(s>1){let e=[s-1].concat(u.y1(0,s-1));a=n.mgz(a,e)}}return a}}})}computeOutputShape(e){let t;t=null==e[0]?null:e[0].slice(1);for(let r=1;r<e.length;++r){let n=null==e[r]?null:e[r].slice(1);t=this.computeElementwiseOpOutputShape(t,n)}let r=[];for(let t of e)null!=t&&null!==t[0]&&r.push(t[0]);return 1===(r=l.Am(r)).length?r.concat(t):[null].concat(t)}computeMask(e,t){return n.DZQ(()=>{if(null==t)return null;if(!Array.isArray(t))throw new i.Qp("`mask` should be an Array");if(!Array.isArray(e))throw new i.Qp("`inputs` should be an Array");if(t.length!==e.length)throw new i.Qp(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every(e=>null==e))return null;let r=(t=t.map(e=>null==e?e:n.UG6(e,0)))[0];for(let e=1;e<t.length-1;++e)r=n.n76(r,t[e]);return r})}}class d extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=n.WQq(t,e[r]);return t})}}d.className="Add",n.JFn.registerClass(d);class c extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=n.lKK(t,e[r]);return t})}}c.className="Multiply",n.JFn.registerClass(c);class f extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=n.WQq(t,e[r]);return n.lKK(1/e.length,t)})}}f.className="Average",n.JFn.registerClass(f);class m extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0];for(let r=1;r<e.length;++r)t=n.PhQ(t,e[r]);return t})}}m.className="Maximum",n.JFn.registerClass(m);class g extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0];for(let r=1;r<e.length;++r)t=n.BpO(t,e[r]);return t})}}g.className="Minimum",n.JFn.registerClass(g);class y extends p{constructor(e){super(e),this.DEFAULT_AXIS=-1,null==e&&(e={}),this.axis=null==e.axis?this.DEFAULT_AXIS:e.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){if(!(Array.isArray(e)&&Array.isArray(e[0]))||1===e.length)throw new i.Qp("A `Concatenate` layer should be called on a list of at least 2 inputs");let t=!0;for(let r of e)if(null!=r){t=!1;break}if(t)return;let r=[];for(let t=0;t<e.length;++t){let a=e[t].slice();a.splice(this.axis,1);let s=!1;for(let e of r)if(n.ZSL.arraysEqual(e,a)){s=!0;break}s||r.push(a)}if(r.length>1)throw new i.Qp("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return(0,n.DZQ)(()=>a.u1(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new i.Qp("A `Concatenate` layer should be called on a list of inputs.");let t=e[0].slice(),r=this.axis<0?t.length+this.axis:this.axis;for(let n of e.slice(1)){if(null==t[r]||null==n[r]){t[r]=null;break}t[r]+=n[r]}return t}computeMask(e,t){if(null==t)return null;if(!Array.isArray(t))throw new i.Qp("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new i.Qp("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new i.Qp(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return n.DZQ(()=>{let r=!0;if(t.forEach(e=>{if(null!=e){r=!1;return}}),r)return null;let a=[];for(let r=0;r<e.length;++r)null==t[r]?a.push(n.wgE(n.P61(e[r]),"bool")):t[r].rank<e[r].rank?a.push(n.UG6(t[r],-1)):a.push(t[r]);let s=n.xWs(a,this.axis);return n.Q7R(s,-1,!1)})}getConfig(){let e={axis:this.axis};return Object.assign(e,super.getConfig()),e}}function b(e,t){for(;e<0;)e+=t;return e}y.className="Concatenate",n.JFn.registerClass(y);class x extends p{constructor(e){super(e),this.axes=e.axes,this.normalize=null!=e.normalize&&e.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){n.ZSL.assert(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");let t=e[0],r=e[1];if(t.length>3||r.length>3)throw new i.EH("Dot layer does not support tensors of 4D or higher rank yet.");let a=this.interpretAxes(t,r);if(t[a[0]]!==r[a[1]])throw new i.Qp(`Dimension incompatibility: ${t[a[0]]} !== ${r[a[1]]}`)}mergeFunction(e){let t;if(2!==e.length)throw new i.Qp(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let r=e[0],a=e[1];t=Array.isArray(this.axes)?this.axes.map((t,r)=>b(t,e[r].shape.length)):[b(this.axes,r.shape.length),b(this.axes,a.shape.length)],this.normalize&&(r=(0,o.Yq)(r,t[0]),a=(0,o.Yq)(a,t[1]));var s=r,l=a,u=t;if(s.shape.length>3||l.shape.length>3)throw new i.EH("batchDot is not implemented for tensors of 4D or higher rank yet");if(n.ZSL.assert(s.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${s.shape.length}`),n.ZSL.assert(s.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${l.shape.length}`),"number"==typeof u&&(u=[u,u]),"complex64"===s.dtype||"complex64"===l.dtype)throw new i.EH("batchDot is not implemented for complex64-type Tensors yet.");let h=s.shape.length,p=l.shape.length;null==u&&(u=[h-1,p-2]);let d=u;return n.DZQ(()=>{let e,t;if(h>p){e=h-p;let t=[];for(let r=0;r<e;++r)t.push(1);l=n.tQQ(l,l.shape.concat(t))}else if(p>h){e=p-h;let t=[];for(let r=0;r<e;++r)t.push(1);s=n.tQQ(s,s.shape.concat(t))}else e=0;if(2===s.shape.length&&2===l.shape.length)t=d[0]===d[1]?n.czq(n.lKK(s,l),d[0]):n.czq(n.lKK(n.mgz(s,[1,0]),l),d[1]);else{let e=d[0]!==s.shape.length-1,r=d[1]===l.shape.length-1;t=n.NoW(s,l,e,r)}if(e>0){let r;r=h>p?h+p-3:h-1;let a=[];for(let t=r;t<r+e;++t)a.push(t);t=n.r2V(t,a)}return 1===t.shape.length&&(t=n.UG6(t,1)),t})}interpretAxes(e,t){return Array.isArray(this.axes)?this.axes:[b(this.axes,e.length),b(this.axes,t.length)]}computeOutputShape(e){n.ZSL.assert(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");let t=e[0].slice(),r=e[1].slice();if(t.length>3||r.length>3)throw new i.EH("Dot layer does not support tensors of 4D or higher rank yet.");let a=this.interpretAxes(t,r);t.splice(a[0],1),r.splice(a[1],1),r.splice(0,1);let s=t.concat(r);return 1===s.length&&s.push(1),s}computeMask(e,t){return null}getConfig(){let e={axes:this.axes,normalize:this.normalize};return Object.assign(e,super.getConfig()),e}}x.className="Dot",n.JFn.registerClass(x)},42926:(e,t,r)=>{"use strict";r.d(t,{M:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({oneHot_:function(e,t,r=1,i=0,o="int32"){if(t<2)throw Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let l=(0,s.YT)(e,"indices","oneHot","int32");return n.T2.runKernel(a.urI,{indices:l},{dtype:o,depth:t,onValue:r,offValue:i})}})},43137:(e,t,r)=>{"use strict";r.d(t,{H:()=>c});var n=r(46568),a=r(54463),s=r(13797),i=r(29573),o=r(78412),l=r(39616),u=r(54256),h=r(18875),p=r(68396),d=r(79625);let c=(0,h.op)({logSoftmax_:function(e,t=-1){let r=(0,a.YT)(e,"logits","logSoftmax");if(-1===t&&(t=r.rank-1),t!==r.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${r.rank} and axis was ${t}`);return(0,n._X)((e,r)=>{let n=(0,l.T)(e,t,!0),a=(0,p.j)(e,n),h=(0,p.j)((0,s.w)(a,"float32"),(0,o.R)((0,d.c)((0,i.o)(a),t,!0)));return r([h]),{value:h,gradFunc:(e,r)=>
233{let[n]=r,a=(0,i.o)(n);return(0,p.j)(e,(0,u.l)((0,d.c)(e,t,!0),a))}}})(r)}})},43578:(e,t,r)=>{"use strict";r.d(t,{x:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({real_:function(e){let t=(0,s.YT)(e,"input","real");return n.T2.runKernel(a.LRy,{input:t})}})},43667:(e,t,r)=>{"use strict";r.d(t,{H:()=>u});var n=r(5287),a=r(96609),s=r(75681),i=r(46866),o=r(18875),l=r(86036);let u=(0,o.op)({conv2DBackpropFilter_:function(e,t,r,o,u,h="NHWC",p){let d=e;3===e.rank&&(d=(0,l.t)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let c=t;3===c.rank&&(c=(0,l.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]])),s.vA(4===d.rank,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${d.shape}.`),s.vA(4===c.rank,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${c.shape}.`),s.vA(4===r.length,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${r}.`);let f="NHWC"===h?d.shape[3]:d.shape[1],m="NHWC"===h?c.shape[3]:c.shape[1];s.vA(f===r[2],()=>`Error in conv2dDerFilter: depth of input ${f}) must match input depth in filter (${r[2]}.`),s.vA(m===r[3],()=>`Error in conv2dDerFilter: depth of dy (${m}) must match output depth for filter (${r[3]}).`),i.s_("conv2dDerFilter",u,p);let g={x:d,dy:c};return n.T2.runKernel(a.rFm,g,{strides:o,pad:u,dataFormat:h,dimRoundingMode:p,filterShape:r})}})},44691:(e,t,r)=>{"use strict";r.d(t,{w:()=>o});var n=r(5287),a=r(96609),s=r(72155),i=r(54463);let o=(0,r(18875).op)({floorDiv_:function(e,t){let r=(0,i.YT)(e,"a","floorDiv"),o=(0,i.YT)(t,"b","floorDiv");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.ElG,l)}})},44769:(e,t,r)=>{"use strict";r.d(t,{W:()=>o});var n=r(5287),a=r(96609),s=r(72155),i=r(54463);let o=(0,r(18875).op)({add_:function(e,t){let r=(0,i.YT)(e,"a","add"),o=(0,i.YT)(t,"b","add");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.OMN,l)}})},45073:(e,t,r)=>{"use strict";r.d(t,{Q:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({all_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","all","bool");return n.T2.runKernel(a.u8Z,{x:i},{axis:t,keepDims:r})}})},45720:(e,t,r)=>{"use strict";let n,a,s;r.d(t,{ljI:()=>tn.ljI,Vvy:()=>tn.Vvy,PH8:()=>tn.PH8,K$F:()=>eC,ah4:()=>eA,FYc:()=>eR,oC7:()=>eO,OMN:()=>tn.OMN,EkD:()=>tn.EkD,u8Z:()=>tn.u8Z,FSt:()=>tn.FSt,Jp_:()=>tn.Jp_,p_m:()=>tn.p_m,QKF:()=>tn.QKF,epO:()=>tn.epO,TyE:()=>tn.TyE,lxb:()=>tn.lxb,zP9:()=>tn.zP9,ho8:()=>tn.ho8,cS:()=>tn.cS,wwC:()=>tn.wwC,VCH:()=>tn.VCH,jAQ:()=>tn.jAQ,Ik2:()=>tn.Ik2,N4F:()=>tn.N4F,HNs:()=>tn.HNs,vj7:()=>tn.vj7,LB5:()=>tn.LB5,KXH:()=>tn.KXH,QDP:()=>tn.QDP,vaV:()=>tn.vaV,pr3:()=>tn.pr3,$zE:()=>tn.$zE,$dB:()=>tn.$dB,p2J:()=>tn.p2J,rFm:()=>tn.rFm,jfg:()=>tn.jfg,A1h:()=>tn.A1h,iGz:()=>tn.iGz,gC7:()=>tn.gC7,Mn0:()=>tn.Mn0,MnK:()=>tn.MnK,MRQ:()=>tn.MRQ,jj_:()=>tn.jj_,nY8:()=>tn.nY8,GJx:()=>r_.GJ,wNW:()=>tn.wNW,TMz:()=>tn.TMz,tGH:()=>tn.tGH,X$8:()=>tn.X$8,nVu:()=>tn.nVu,ORI:()=>tn.ORI,jxD:()=>tn.jxD,pk0:()=>tn.pk0,bP9:()=>tn.bP9,XmO:()=>tn.XmO,Kmu:()=>w.Km,Qgm:()=>tn.Qgm,Pah:()=>tn.Pah,rsH:()=>tn.rsH,OH$:()=>w.OH,BRl:()=>tn.BRl,_s9:()=>tn._s9,ox3:()=>tn.ox3,ybN:()=>tn.ybN,ybj:()=>tn.ybj,rGP:()=>tn.rGP,SQl:()=>tn.SQl,BxF:()=>tn.BxF,ZgB:()=>tn.ZgB,ElG:()=>tn.ElG,awo:()=>tn.awo,i5R:()=>tn.i5R,aAr:()=>tn.aAr,T7M:()=>tn.T7M,O4G:()=>tn.O4G,mxL:()=>tn.mxL,XhZ:()=>tn.XhZ,lLS:()=>tn.lLS,OAQ:()=>tn.OAQ,lzr:()=>tn.lzr,dv8:()=>tn.dv8,gIW:()=>tn.gIW,E3$:()=>tn.E3$,iPs:()=>tn.iPs,uI_:()=>r_.uI,jM4:()=>tn.jM4,ToN:()=>tn.ToN,X0$:()=>tn.X0$,mIA:()=>tn.mIA,CwD:()=>tn.CwD,mnI:()=>tn.mnI,tG8:()=>tn.tG8,Cg$:()=>tn.Cg$,zfU:()=>tn.zfU,RUm:()=>tn.RUm,nZd:()=>tn.nZd,LXA:()=>tn.LXA,RW8:()=>tn.RW8,yPW:()=>tn.yPW,WRv:()=>tn.WRv,VAI:()=>tn.VAI,t3d:()=>tn.t3d,ySp:()=>tn.ySp,cHb:()=>tn.cHb,RXX:()=>tn.RXX,TL8:()=>tn.TL8,LDN:()=>tn.LDN,g5A:()=>tn.g5A,lNG:()=>tn.lNG,LG0:()=>tn.LG0,x7F:()=>tn.x7F,BLA:()=>tn.BLA,Qu_:()=>eM,WT3:()=>tn.WT3,xu7:()=>tn.xu7,l0G:()=>tn.l0G,SDM:()=>tn.SDM,Zl4:()=>tn.Zl4,e0f:()=>tn.e0f,ylV:()=>tn.ylV,BTT:()=>t_.BTT,urI:()=>tn.urI,LWX:()=>tn.LWX,ELo:()=>eI,L5p:()=>tF,mM$:()=>tn.mM$,ODT:()=>tn.ODT,bCz:()=>tn.bCz,pyJ:()=>tn.pyJ,Ncv:()=>tn.Ncv,kdj:()=>tn.kdj,PS5:()=>eP,oJ2:()=>tn.oJ2,CQC:()=>tn.CQC,mH5:()=>tn.mH5,Q6t:()=>tn.Q6t,rgM:()=>tR.rg,LRy:()=>tn.LRy,sDr:()=>tn.sDr,huO:()=>tn.huO,iDl:()=>tD.i,fUj:()=>tn.fUj,P_L:()=>tn.P_L,R23:()=>tn.R23,hgw:()=>tn.hgw,FCQ:()=>tn.FCQ,jOE:()=>tn.jOE,XQy:()=>tn.XQy,D7i:()=>tn.D7i,BK4:()=>tn.BK4,hVg:()=>tn.hVg,TOR:()=>tn.TOR,SYI:()=>eL,pJc:()=>tn.pJc,uWl:()=>tn.uWl,l6P:()=>tn.l6P,u$b:()=>tn.u$b,vI1:()=>tn.vI1,YVe:()=>tn.YVe,hql:()=>tn.hql,J3C:()=>tn.J3C,JiE:()=>tn.JiE,rFG:()=>tn.rFG,Fin:()=>tn.Fin,A8B:()=>tn.A8B,C8s:()=>tn.C8s,BoJ:()=>tn.BoJ,L6G:()=>tn.L6G,DvZ:()=>tn.DvZ,jgd:()=>tn.jgd,Blb:()=>tn.Blb,dFH:()=>tn.dFH,M6A:()=>tn.M6A,Ddj:()=>tn.Ddj,GZp:()=>tn.GZp,pnw:()=>tn.pnw,UcO:()=>tn.UcO,YAb:()=>tn.YAb,iW0:()=>tn.iW0,$jE:()=>tn.$jE,PbM:()=>tn.PbM,WuN:()=>tn.WuN,oFs:()=>tn.oFs,iuW:()=>tn.iuW,qYS:()=>eu.qY,ylz:()=>eu.yl,X4r:()=>tn.X4r,FAs:()=>tn.FAs,TBb:()=>tn.TBb,dLy:()=>tn.dLy,wx0:()=>tn.wx0,EwU:()=>tn.EwU,dXR:()=>tn.dXR,pPe:()=>tn.pPe,RMm:()=>tn.RMm,rTt:()=>eu.rT,xJ3:()=>tn.xJ3,Dr:()=>tn.Dr,tnl:()=>t_.tnl,HQu:()=>t_.HQu,FqL:()=>t_.FqL,WQq:()=>t_.WQq,QiD:()=>t_.QiD,Q7R:()=>t_.Q7R,bzn:()=>t_.bzn,FLi:()=>t_.FLi,XRg:()=>t_.XRg,qRo:()=>t_.qRo,yHs:()=>t_.yHs,rYl:()=>t_.rYl,FPz:()=>t_.FPz,rfv:()=>t_.rfv,$jT:()=>t_.$jT,sub:()=>t_.sub,Hs:()=>ep.Hs,C0T:()=>m,lZX:()=>t_.lZX,$v7:()=>t_.$v7,BFc:()=>t_.BFc,kSi:()=>t_.kSi,T5N:()=>t_.T5N,GTe:()=>t_.GTe,HbZ:()=>t_.HbZ,vjT:()=>t_.vjT,ftb:()=>t_.ftb,ROE:()=>t_.ROE,hOW:()=>t_.hOW,ZEY:()=>tr,TaL:()=>p,ra8:()=>t_.ra8,wgE:()=>t_.wgE,mkO:()=>t_.mkO,zQh:()=>t_.zQh,o8B:()=>t_.o8B,faB:()=>t_.faB,xWs:()=>t_.xWs,I1m:()=>t_.I1m,RPU:()=>t_.RPU,O5O:()=>t_.O5O,P1l:()=>t_.P1l,kA9:()=>t_.kA9,Xtf:()=>t_.Xtf,wX9:()=>t_.wX9,IPL:()=>t_.IPL,jIJ:()=>t_.jIJ,Cfv:()=>ta.Cf,gnS:()=>t_.gnS,yIG:()=>t_.yIG,_jP:()=>t_._jP,Lp0:()=>t_.Lp0,rCv:()=>t_.rCv,_Xg:()=>
233eb._X,aOp:()=>t_.aOp,fLc:()=>ep.fL,Rj8:()=>t_.Rj8,Gl3:()=>t_.Gl3,eMq:()=>o,smy:()=>t_.smy,X7t:()=>t_.X7t,ISJ:()=>ep.IS,ASo:()=>ep.AS,rm6:()=>ep.rm,y4m:()=>t_.y4m,ek5:()=>t_.ek5,Omf:()=>t_.Omf,EZY:()=>t_.EZY,_3C:()=>t_._3C,Pqc:()=>t_.Pqc,gYU:()=>ep.gY,SmG:()=>ep.Sm,FJY:()=>t_.FJY,Hi9:()=>ep.Hi,QP2:()=>t_.QP2,_K2:()=>w._K,LCg:()=>t_.LCg,Y12:()=>t_.Y12,p4S:()=>t_.p4S,oNF:()=>t_.oNF,UG6:()=>t_.UG6,IYd:()=>t_.IYd,y5U:()=>t_.y5U,hVP:()=>t_.hVP,GSj:()=>t_.GSj,goy:()=>ep.go,W4C:()=>ep.W4,RIf:()=>t_.RIf,wh_:()=>t_.wh_,cZk:()=>t_.cZk,kgh:()=>t_.kgh,SY9:()=>t_.SY9,FJy:()=>d,jz4:()=>ep.jz,vQR:()=>ta.vQ,_5H:()=>ta._5,OpK:()=>ta.Op,Dvk:()=>eb.Dv,ok9:()=>eb.ok,rhj:()=>t_.rhj,DQN:()=>t_.DQN,KGM:()=>t_.KGM,ngS:()=>t_.ngS,Slp:()=>t_.Slp,U4u:()=>t_.U4u,io:()=>u,ggX:()=>t_.ggX,MIs:()=>t_.MIs,EN4:()=>t_.EN4,yrW:()=>t_.yrW,aCs:()=>ep.aC,kpo:()=>g,H8d:()=>t_.H8d,M7h:()=>t_.M7h,InN:()=>t_.InN,mPL:()=>t_.mPL,mT8:()=>t_.mT8,Kgs:()=>t_.Kgs,Rm2:()=>t_.Rm2,Kko:()=>t_.Kko,nqI:()=>t_.nqI,HPB:()=>t_.HPB,VZ:()=>t_.VZ,n76:()=>t_.n76,NSZ:()=>t_.NSZ,ztW:()=>t_.ztW,rxB:()=>t_.rxB,YYh:()=>t_.YYh,yzS:()=>t_.yzS,NoW:()=>t_.NoW,DyF:()=>h,T9B:()=>t_.T9B,jgi:()=>t_.jgi,NYV:()=>t_.NYV,RO:()=>t_.RO,PhQ:()=>t_.PhQ,i2o:()=>t_.i2o,m1Z:()=>ep.m1,OYQ:()=>t_.OYQ,jkA:()=>t_.jkA,BpO:()=>t_.BpO,FFZ:()=>t_.FFZ,ziu:()=>t_.ziu,Clk:()=>t_.Clk,CRk:()=>t_.CRk,lKK:()=>t_.lKK,YDF:()=>t_.YDF,OjQ:()=>t_.OjQ,HZy:()=>t_.HZy,dA1:()=>tM,xbf:()=>t_.xbf,Ec:()=>t_.Ec,Mw0:()=>t_.Mw0,SaS:()=>t_.SaS,P61:()=>t_.P61,op:()=>t_.op,X4o:()=>t_.X4o,eVF:()=>t_.eVF,BZs:()=>t_.BZs,grY:()=>t_.grY,XHu:()=>t_.XHu,WLX:()=>t_.WLX,dzn:()=>t_.dzn,n7C:()=>t_.n7C,NsG:()=>t_.NsG,yyV:()=>t_.yyV,_eU:()=>t_._eU,MEE:()=>ep.ME,whe:()=>t_.whe,iyU:()=>t_.iyU,Q0_:()=>t_.Q0_,_9M:()=>t_._9M,pR9:()=>t_.pR9,FE$:()=>t_.FE$,m0H:()=>t_.m0H,YeY:()=>t_.YeY,HYA:()=>t_.HYA,y17:()=>t_.y17,Gc4:()=>ep.Gc,xav:()=>t_.xav,VOZ:()=>t_.VOZ,gJX:()=>ep.gJ,krJ:()=>ta.kr,tAK:()=>ta.tA,VVh:()=>t_.VVh,j__:()=>t_.j__,rEj:()=>ep.rE,tQQ:()=>t_.tQQ,BEg:()=>t_.BEg,QD2:()=>t_.QD2,LMr:()=>t_.LMr,I2l:()=>t_.I2l,JYU:()=>t_.JYU,z8$:()=>t_.z8$,LIG:()=>t_.LIG,Z$r:()=>t_.Z$r,d_2:()=>t_.d_2,NFr:()=>t_.NFr,g23:()=>tf,sZg:()=>t_.sZg,WfX:()=>t_.WfX,wdz:()=>t_.wdz,JFn:()=>l,jh6:()=>ep.jh,OkC:()=>ep.Ok,F12:()=>t_.F12,ry7:()=>t_.ry7,_SZ:()=>t_._SZ,vPA:()=>t_.vPA,F8e:()=>t_.F8e,L0l:()=>t_.L0l,dik:()=>t_.dik,Q$M:()=>t_.Q$M,zAd:()=>t_.zAd,wck:()=>t_.wck,R0O:()=>t_.R0O,Kro:()=>tm,Vs9:()=>t_.Vs9,lw0:()=>t_.lw0,eDJ:()=>t_.eDJ,lMo:()=>t_.lMo,Zhr:()=>t_.Zhr,lOn:()=>t_.lOn,lDo:()=>t_.lDo,RZD:()=>t_.RZD,EwI:()=>t_.EwI,Pbu:()=>t_.Pbu,r2V:()=>t_.r2V,t$z:()=>t_.t$z,PMw:()=>t_.PMw,Ym9:()=>t_.Ym9,YjP:()=>t_.YjP,jbE:()=>t_.jbE,czq:()=>t_.czq,chL:()=>tR.ch,Mlm:()=>t_.Mlm,ymU:()=>t_.ymU,OEK:()=>t_.OEK,tGX:()=>t_.tGX,KtR:()=>t_.KtR,$_$:()=>t_.$_$,g9W:()=>t_.g9W,Lpo:()=>t_.Lpo,yxw:()=>t_.yxw,NNh:()=>t_.NNh,d_S:()=>tg,Obs:()=>c,DZQ:()=>ep.DZ,Vsq:()=>t_.Vsq,kBw:()=>ep.kB,rfw:()=>t_.rfw,BaG:()=>tO,mgz:()=>t_.mgz,efE:()=>t_.efE,AmM:()=>t_.AmM,rYx:()=>ta.rY,iPt:()=>ta.iP,zAU:()=>t_.zAU,K$i:()=>t_.K$i,TuY:()=>tR.Tu,rni:()=>t_.rni,ZSL:()=>ty,jYt:()=>eb.jY,muS:()=>eb.mu,bvq:()=>t_.bvq,y7e:()=>eb.y7,bgA:()=>t$,_M9:()=>t_._M9,YJN:()=>t_.YJN,Ul9:()=>t_.Ul9,POl:()=>t_.POl});var i,o={};r.r(o),r.d(o,{isBrowser:()=>v,isMobile:()=>x,mockIsMobile:()=>b});var l={};r.r(l),r.d(l,{Serializable:()=>eT,SerializationMap:()=>eS,getRegisteredName:()=>ek,registerClass:()=>eN});var u={};r.r(u),r.d(u,{CompositeArrayBuffer:()=>$.D,browserFiles:()=>eV,browserHTTPRequest:()=>eX,concatenateArrayBuffers:()=>N.AQ,copyModel:()=>X,decodeWeights:()=>N.CY,decodeWeightsStream:()=>N.s5,encodeWeights:()=>N.aG,fromMemory:()=>e2,fromMemorySync:()=>e3,getLoadHandlers:()=>A,getModelArtifactsForJSON:()=>N.Ej,getModelArtifactsForJSONSync:()=>N.Rl,getModelArtifactsInfoForJSON:()=>N.oR,getSaveHandlers:()=>E,getWeightSpecs:()=>N.Xf,http:()=>eq,isHTTPScheme:()=>eY,listModels:()=>Q,loadWeights:()=>ej,moveModel:()=>J,registerLoadRouter:()=>C,registerSaveRouter:()=>I,removeModel:()=>q,weightsLoaderFactory:()=>eK,withSaveHandler:()=>e4,withSaveHandlerSync:()=>e6});var h={};r.r(h),r.d(h,{confusionMatrix:()=>tt});var p={};r.r(p),r.d(p,{draw:()=>tp,fromPixels:()=>td,fromPixelsAsync:()=>tl,toPixels:()=>th});var d={};r.r(d),r.d(d,{prepareAndValidate:()=>tc});var c={};r.r(c),r.d(c,{TEST_EPSILON_FLOAT16:()=>tb,createVideoElement:()=>tE,encodeStrings:()=>function e(t){for(let r=0;r<t.length;r++){let n=t[r];Array.isArray(n)?e(n):t[r]=(0,ty.encodeString)(n)}return t},expectArrayBuffersEqual:()=>tC,expectArraysClose:()=>tx,expectArraysEqual:()=>tS,expectNumbersClose:()=>tN,expectPromiseToFail:()=>tT,expectValuesInRange:()=>tI,play:()=>tA,testEpsilon:()=>tv});var f={};r.r(f),r.d(f,{collectGatherOpShapeInfo:()=>rE,computeOutShape:()=>rC,segOpComputeOptimalWindowSize:()=>rI});var m={};r.r(m),r.d(m,{ERF_A1:()=>t3,ERF_A2:()=>t4,ERF_A3:()=>t6,ERF_A4:()=>t5,ERF_A5:()=>t8,ERF_P:()=>t2,PARALLELIZE_THRESHOLD:()=>tK,RowPartitionType:()=>i,SELU_SCALE:()=>t1.X,SELU_SCALEALPHA:()=>t1.j,applyActivation:()=>tV.f2,assertAndGetBroadcastShape:()=>tr.assertAndGetBroadcastShape,assertAxesAreInnerMostDims:()=>tP.WC,assertParamsConsistent:()=>tz,assignToTypedArray:()=>ra,axesAreInnerMostDims:()=>tP.WH,calculateShapes:()=>tf.calculateShapes,checkEinsumDimSizes:()=>rh,checkPadOnDimRoundingMode:()=>tW.s_,combineLocations:()=>
233tP.aF,combineRaggedTensorToTensorShapes:()=>tU,complexWithEvenIndex:()=>rt,complexWithOddIndex:()=>rr,computeConv2DInfo:()=>tW.uf,computeConv3DInfo:()=>tW.p$,computeDefaultPad:()=>tW.G8,computeDilation2DInfo:()=>tW.YQ,computeOptimalWindowSize:()=>tH,computeOutAndReduceShapes:()=>tP.lb,computeOutShape:()=>tB,computePool2DInfo:()=>tW.E6,computePool3DInfo:()=>tW.l5,convertConv2DDataFormat:()=>tW.$Q,decodeEinsumEquation:()=>rl,eitherStridesOrDilationsAreOne:()=>tW.G0,expandShapeToKeepDim:()=>tP.SM,exponent:()=>ri,exponents:()=>rs,fromStringArrayToUint8:()=>r$,fromUint8ToStringArray:()=>rA,getAxesPermutation:()=>tP.Em,getBroadcastDims:()=>tr.getBroadcastDims,getComplexWithIndex:()=>rn,getEinsumComputePath:()=>rp,getEinsumPermutation:()=>ru,getFusedBiasGradient:()=>tV.Do,getFusedDyActivation:()=>tV.XB,getImageCenter:()=>tY,getInnerMostAxes:()=>tP.fK,getPermuted:()=>tq,getRaggedRank:()=>tZ,getReductionAxes:()=>tr.getReductionAxes,getReshaped:()=>tQ,getReshapedPermuted:()=>tX,getRowPartitionTypesHelper:()=>tG,getSliceBeginCoords:()=>tJ,getSliceSize:()=>t0,getSparseFillEmptyRowsIndicesDenseShapeMismatch:()=>rf,getSparseFillEmptyRowsNegativeIndexErrorMessage:()=>rm,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:()=>rg,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:()=>rx,getSparseReshapeInputOutputMismatchErrorMessage:()=>rw,getSparseReshapeInputOutputMultipleErrorMessage:()=>rv,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:()=>ry,getSparseReshapeNegativeOutputDimErrorMessage:()=>rb,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:()=>rk,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:()=>rT,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:()=>rS,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:()=>rN,getUndoAxesPermutation:()=>tP.gx,isIdentityPermutation:()=>rd,log:()=>t7.R,mergeRealAndImagArrays:()=>t9,prepareAndValidate:()=>tc,prepareSplitSize:()=>rc,segment_util:()=>f,shouldFuse:()=>tV.zE,slice_util:()=>tm,splitRealAndImagArrays:()=>re,stridesOrDilationsArePositive:()=>tW.qk,tupleValuesAreOne:()=>tW.Dh,upcastType:()=>tR.Tu,validateDefaultValueShape:()=>tj,validateInput:()=>tf.validateInput,validateUpdateShape:()=>tf.validateUpdateShape,warn:()=>t7.i});var g={};r.r(g),r.d(g,{nonMaxSuppressionV3Impl:()=>rF.c7,nonMaxSuppressionV4Impl:()=>rF.ZS,nonMaxSuppressionV5Impl:()=>rF.ut,whereImpl:()=>rR.Y});var y=r(5287);function b(e){n=e}function x(e){if(void 0!==n)return n;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;let t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){let t=e;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
233sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function v(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var w=r(67984),T=r(95704);let S=(0,w._K)();S.registerFlag("DEBUG",()=>!1,e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")}),S.registerFlag("IS_BROWSER",()=>v()),S.registerFlag("IS_NODE",()=>void 0!==T&&void 0!==T.versions&&void 0!==T.versions.node),S.registerFlag("IS_CHROME",()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)),S.registerFlag("IS_SAFARI",()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),S.registerFlag("PROD",()=>!1),S.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>S.getBool("DEBUG")),S.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0),S.registerFlag("IS_TEST",()=>!1),S.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>S.getBool("DEBUG")),S.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1),S.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",()=>!1),S.registerFlag("USE_SETTIMEOUTCUSTOM",()=>!1);var N=r(51874);class k{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==k.instance&&(k.instance=new k),k.instance}static registerSaveRouter(e){k.getInstance().saveRouters.push(e)}static registerLoadRouter(e){k.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return k.getHandlers(e,"save")}static getLoadHandlers(e,t){return k.getHandlers(e,"load",t)}static getHandlers(e,t,r){let n=[];return("load"===t?k.getInstance().loadRouters:k.getInstance().saveRouters).forEach(t=>{let a=t(e,r);null!==a&&n.push(a)}),n}}let I=e=>k.registerSaveRouter(e),C=e=>k.registerLoadRouter(e),E=e=>k.getSaveHandlers(e),A=(e,t)=>
233k.getLoadHandlers(e,t);var $=r(89972);let F="tensorflowjs",R="models_store",_="model_info_store";function D(){if(!(0,w._K)().getBool("IS_BROWSER"))throw Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");let e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw Error("The current browser does not appear to support IndexedDB.");return t}function O(e){let t=e.result;t.createObjectStore(R,{keyPath:"modelPath"}),t.createObjectStore(_,{keyPath:"modelPath"})}class L{constructor(e){if(this.indexedDB=D(),null==e||!e)throw Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((e,r)=>{let n=this.indexedDB.open(F,1);n.onupgradeneeded=()=>O(n),n.onsuccess=()=>{let a=n.result;if(null==t){let t=a.transaction(R,"readonly"),n=t.objectStore(R).get(this.modelPath);n.onsuccess=()=>{if(null==n.result)return a.close(),r(Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(n.result.modelArtifacts)},n.onerror=e=>(a.close(),r(n.error)),t.oncomplete=()=>a.close()}else{let n,s;t.weightData=$.D.join(t.weightData);let i=(0,N.oR)(t),o=a.transaction(_,"readwrite"),l=o.objectStore(_);try{n=l.put({modelPath:this.modelPath,modelArtifactsInfo:i})}catch(e){return r(e)}n.onsuccess=()=>{let n,u=(s=a.transaction(R,"readwrite")).objectStore(R);try{n=u.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i})}catch(e){return r(e)}n.onsuccess=()=>e({modelArtifactsInfo:i}),n.onerror=e=>{let t=(l=o.objectStore(_)).delete(this.modelPath);t.onsuccess=()=>(a.close(),r(n.error)),t.onerror=e=>(a.close(),r(n.error))}},n.onerror=e=>(a.close(),r(n.error)),o.oncomplete=()=>{null==s?a.close():s.oncomplete=()=>a.close()}}},n.onerror=e=>r(n.error)})}}L.URL_SCHEME="indexeddb://";let M=e=>{var t;return(0,w._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(L.URL_SCHEME)?(t=e.slice(L.URL_SCHEME.length),new L(t)):null};k.registerSaveRouter(M),k.registerLoadRouter(M);class P{constructor(){this.indexedDB=D()}async listModels(){return new Promise((e,t)=>{let r=this.indexedDB.open(F,1);r.onupgradeneeded=()=>O(r),r.onsuccess=()=>{let n=r.result,a=n.transaction(_,"readonly"),s=a.objectStore(_).getAll();s.onsuccess=()=>{let t={};for(let e of s.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},s.onerror=e=>(n.close(),t(s.error)),a.oncomplete=()=>n.close()},r.onerror=e=>t(r.error)})}async removeModel(e){var t;return e=(t=e).startsWith(L.URL_SCHEME)?t.slice(L.URL_SCHEME.length):t,new Promise((t,r)=>{let n=this.indexedDB.open(F,1);n.onupgradeneeded=()=>O(n),n.onsuccess=()=>{let a,s=n.result,i=s.transaction(_,"readwrite"),o=i.objectStore(_),l=o.get(e);l.onsuccess=()=>{if(null==l.result)return s.close(),r(Error(`Cannot find model with path '${e}' in IndexedDB.`));{let n=o.delete(e),i=()=>{let n=(a=s.transaction(R,"readwrite")).objectStore(R).delete(e);n.onsuccess=()=>t(l.result.modelArtifactsInfo),n.onerror=e=>r(l.error)};n.onsuccess=i,n.onerror=e=>(i(),s.close(),r(l.error))}},l.onerror=e=>(s.close(),r(l.error)),i.oncomplete=()=>{null==a?s.close():a.oncomplete=()=>s.close()}},n.onerror=e=>r(n.error)})}}var z=r(75681);let B="tensorflowjs_models",W="info";function V(e){return{info:[B,e,W].join("/"),topology:[B,e,"model_topology"].join("/"),weightSpecs:[B,e,"weight_specs"].join("/"),weightData:[B,e,"weight_data"].join("/"),modelMetadata:[B,e,"model_metadata"].join("/")}}function U(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}class G{constructor(e){if(!(0,w._K)().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=V(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{let t=JSON.stringify(e.modelTopology),r=JSON.stringify(e.weightSpecs),n=(0,N.oR)(e),a=$.D.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(n)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,(0,N.l3)(a));let s={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,initializerSignature:null!=e.initializerSignature?e.initializerSignature:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(s)),{modelArtifactsInfo:n}}catch(e){throw U(this.keys),Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${n.modelTopologyBytes}, weightSpecsBytes=${n.weightSpecsBytes}, weightDataBytes=${n.weightDataBytes}.`)}}}async load(){let e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");let t={},r=JSON.parse(this.LS.getItem(this.keys.topology));if(null==r)throw Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=r;let n=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==n)throw Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=n;let a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){let e=JSON.parse(a);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(t.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}let s=this.LS.getItem(this.keys.weightData);if(null==s)throw Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=(0,N.jf)(s),t}}G.URL_SCHEME="localstorage://";let Z=e=>{var t;
233return(0,w._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(G.URL_SCHEME)?(t=e.slice(G.URL_SCHEME.length),new G(t)):null};k.registerSaveRouter(Z),k.registerLoadRouter(Z);class j{constructor(){(0,z.vA)((0,w._K)().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),(0,z.vA)("undefined"==typeof window||void 0!==window.localStorage,()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=B+"/",r="/"+W;for(let n=0;n<this.LS.length;++n){let a=this.LS.key(n);a.startsWith(t)&&a.endsWith(r)&&(e[function(e){let t=e.split("/");if(t.length<3)throw Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join("/")}(a)]=JSON.parse(this.LS.getItem(a)))}return e}async removeModel(e){var t;let r=V(e=(t=e).startsWith(G.URL_SCHEME)?t.slice(G.URL_SCHEME.length):t);if(null==this.LS.getItem(r.info))throw Error(`Cannot find model at path '${e}'`);let n=JSON.parse(this.LS.getItem(r.info));return U(r),n}}class K{constructor(){this.managers={}}static getInstance(){return null==K.instance&&(K.instance=new K),K.instance}static registerManager(e,t){(0,z.vA)(null!=e,()=>"scheme must not be undefined or null."),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),(0,z.vA)(e.length>0,()=>"scheme must not be an empty string.");let r=K.getInstance();(0,z.vA)(null==r.managers[e],()=>`A model store manager is already registered for scheme '${e}'.`),r.managers[e]=t}static getManager(e){let t=K.getInstance().managers[e];if(null==t)throw Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(K.getInstance().managers)}}function H(e){if(-1===e.indexOf("://"))throw Error(`The url string provided does not contain a scheme. Supported schemes are: ${K.getSchemes().join(",")}`);return{scheme:e.split("://")[0],path:e.split("://")[1]}}async function Y(e,t,r=!1){(0,z.vA)(e!==t,()=>`Old path and new path are the same: '${e}'`);let n=k.getLoadHandlers(e);(0,z.vA)(n.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),(0,z.vA)(n.length<2,()=>`Copying failed because more than one (${n.length}) load handlers for source URL ${e}.`);let a=n[0],s=k.getSaveHandlers(t);(0,z.vA)(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),(0,z.vA)(s.length<2,()=>`Copying failed because more than one (${n.length}) save handlers for destination URL ${t}.`);let i=s[0],o=H(e).scheme,l=H(e).path,u=o===H(e).scheme,h=await a.load();r&&u&&await K.getManager(o).removeModel(l);let p=await i.save(h);return r&&!u&&await K.getManager(o).removeModel(l),p.modelArtifactsInfo}async function Q(){let e=K.getSchemes(),t={};for(let r of e){let e=await K.getManager(r).listModels();for(let n in e)t[r+"://"+n]=e[n]}return t}async function q(e){let t=H(e);return K.getManager(t.scheme).removeModel(t.path)}async function X(e,t){return Y(e,t,!1)}async function J(e,t){return Y(e,t,!0)}var ee=r(5512);class et{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}setTimeoutCustom(e,t){if("undefined"==typeof window||!(0,w._K)().getBool("USE_SETTIMEOUTCUSTOM"))return void setTimeout(e,t);this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",e=>{e.source===window&&e.data.name===this.messageName&&(e.stopPropagation(),(0,this.functionRefs[e.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0))},!0))}isTypedArray(e){return(0,ee.Y)(e)}}if((0,w._K)().get("IS_BROWSER")){(0,w._K)().setPlatform("browser",new et);try{K.registerManager(G.URL_SCHEME,new j)}catch(e){}try{K.registerManager(L.URL_SCHEME,new P)}catch(e){}}var er=r(95704);let en={importFetch:()=>r(85817)};class ea{constructor(){this.util=r(18590),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=(0,w._K)().global.fetch?(0,w._K)().global.fetch(e,t):(null==a&&(a=en.importFetch()),a(e,t))}now(){let e=er.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}
233(0,w._K)().get("IS_NODE")&&!(0,w._K)().get("IS_BROWSER")&&(0,w._K)().setPlatform("node",new ea);var es=r(24884),ei=r(13797),eo=r(4087),el=r(65261),eu=r(94708);(0,y.Ye)();let eh={buffer:es.r,cast:ei.w,clone:eo.o,print:el.y};(0,eu.Q5)(eh);var ep=r(13649),ed=r(44769),ec=r(29337),ef=r(54256),em=r(53744),eg=r(11983),ey=r(61997),eb=r(46568),ex=r(57610);let ev=new Map,ew=new Map;class eT{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class eS{constructor(){this.classNameMap={}}static getMap(){return null==eS.instance&&(eS.instance=new eS),eS.instance}static register(e){eS.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function eN(e,t,r){(0,z.vA)(null!=e.className,()=>"Class being registered does not have the static className property defined."),(0,z.vA)("string"==typeof e.className,()=>"className is required to be a string, but got type "+typeof e.className),(0,z.vA)(e.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),void 0===t&&(t="Custom"),void 0===r&&(r=e.className);let n=t+">"+r;return eS.register(e),ev.set(n,e),ew.set(e,n),e}function ek(e){return ew.has(e)?ew.get(e):e.className}class eI extends eT{minimize(e,t=!1,r){let{value:n,grads:a}=this.computeGradients(e,r);if(null!=r){let e=r.map(e=>({name:e.name,tensor:a[e.name]}));this.applyGradients(e)}else this.applyGradients(a);return((0,ep.AS)(a),t)?n:(n.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return(0,eb.y7)(e,t)}dispose(){null!=this.iterations_&&(0,ep.AS)(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:(0,ex.d)(this.iterations_,"int32")}}async getWeights(){throw Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(eI,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class eC extends eI{static get className(){return"Adadelta"}constructor(e,t,r=null){super(),this.learningRate=e,this.rho=t,this.epsilon=r,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==r&&(this.epsilon=y.T2.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(e=>e.name):Object.keys(e)).forEach((t,r)=>{let n=y.T2.registeredVariables[t];null==this.accumulatedGrads[r]&&(this.accumulatedGrads[r]={originalName:`${t}/accum_grad`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))}),null==this.accumulatedUpdates[r]&&(this.accumulatedUpdates[r]={originalName:`${t}/accum_var`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))});let a=Array.isArray(e)?e[r].tensor:e[t];if(null==a)return;let s=this.accumulatedGrads[r].variable,i=this.accumulatedUpdates[r].variable;(0,ep.DZ)(()=>{let e=(0,ed.W)((0,ef.l)(s,this.rho),(0,ef.l)((0,eg.E)(a),1-this.rho)),t=(0,ef.l)((0,ec.y)((0,em.R)((0,ed.W)(i,this.epsilon)),(0,em.R)((0,ed.W)(s,this.epsilon))),a),r=(0,ed.W)((0,ef.l)(i,this.rho),(0,ef.l)((0,eg.E)(t),1-this.rho));s.assign(e),i.assign(r);let o=(0,ed.W)((0,ef.l)(t,-this.learningRate),n);n.assign(o)})}),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&((0,ep.AS)(this.accumulatedGrads.map(e=>e.variable)),(0,ep.AS)(this.accumulatedUpdates.map(e=>e.variable)))}async getWeights(){let e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){let t=(e=await this.extractIterations(e)).length/2;this.accumulatedGrads=e.slice(0,t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})),this.accumulatedUpdates=e.slice(t,2*t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}var eE=r(41891);class eA extends eI{static get className(){return"Adagrad"}constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(e=>
233e.name):Object.keys(e)).forEach((t,r)=>{let n=y.T2.registeredVariables[t];null==this.accumulatedGrads[r]&&(this.accumulatedGrads[r]={originalName:`${t}/accumulator`,variable:(0,ep.DZ)(()=>(0,eE.G)(n.shape,this.initialAccumulatorValue).variable(!1))});let a=Array.isArray(e)?e[r].tensor:e[t];if(null==a)return;let s=this.accumulatedGrads[r].variable;(0,ep.DZ)(()=>{let e=(0,ed.W)(s,(0,eg.E)(a));s.assign(e);let t=(0,ed.W)((0,ef.l)((0,ec.y)(a,(0,em.R)((0,ed.W)(e,y.T2.backend.epsilon()))),-this.learningRate),n);n.assign(t)})}),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&(0,ep.AS)(this.accumulatedGrads.map(e=>e.variable))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e),this.accumulatedGrads=e.map(e=>({originalName:e.name,variable:e.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}var e$=r(17392),eF=r(68396);class eR extends eI{static get className(){return"Adam"}constructor(e,t,r,n=null){super(),this.learningRate=e,this.beta1=t,this.beta2=r,this.epsilon=n,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],(0,ep.DZ)(()=>{this.accBeta1=(0,ex.d)(t).variable(),this.accBeta2=(0,ex.d)(r).variable()}),null==n&&(this.epsilon=y.T2.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(e=>e.name):Object.keys(e);(0,ep.DZ)(()=>{let r=(0,eF.j)(1,this.accBeta1),n=(0,eF.j)(1,this.accBeta2);t.forEach((t,a)=>{let s=y.T2.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:(0,ep.DZ)(()=>(0,ey.P)(s).variable(!1))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:(0,ep.DZ)(()=>(0,ey.P)(s).variable(!1))});let i=Array.isArray(e)?e[a].tensor:e[t];if(null==i)return;let o=this.accumulatedFirstMoment[a].variable,l=this.accumulatedSecondMoment[a].variable,u=(0,ed.W)((0,ef.l)(o,this.beta1),(0,ef.l)(i,1-this.beta1)),h=(0,ed.W)((0,ef.l)(l,this.beta2),(0,ef.l)((0,eg.E)(i),1-this.beta2)),p=(0,ec.y)(u,r),d=(0,ec.y)(h,n);o.assign(u),l.assign(h);let c=(0,ed.W)((0,ef.l)((0,ec.y)(p,(0,ed.W)((0,em.R)(d),this.epsilon)),-this.learningRate),s);s.assign(c)}),this.accBeta1.assign((0,ef.l)(this.accBeta1,this.beta1)),this.accBeta2.assign((0,ef.l)(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&(0,ep.AS)(this.accumulatedFirstMoment.map(e=>e.variable)),null!=this.accumulatedSecondMoment&&(0,ep.AS)(this.accumulatedSecondMoment.map(e=>e.variable))}async getWeights(){let e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e),(0,ep.DZ)(()=>{this.accBeta1.assign((0,e$.n)(this.beta1,this.iterations_+1)),this.accBeta2.assign((0,e$.n)(this.beta2,this.iterations_+1))});let t=e.length/2;this.accumulatedFirstMoment=e.slice(0,t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})),this.accumulatedSecondMoment=e.slice(t,2*t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}var e_=r(4006),eD=r(3824);class eO extends eI{static get className(){return"Adamax"}constructor(e,t,r,n=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=r,this.epsilon=n,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],(0,ep.DZ)(()=>{this.iteration=(0,ex.d)(0).variable(),this.accBeta1=(0,ex.d)(t).variable()}),null==n&&(this.epsilon=y.T2.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(e=>e.name):Object.keys(e);(0,ep.DZ)(()=>{let r=(0,eF.j)(1,this.accBeta1),n=(0,ec.y)(-this.learningRate,(0,ed.W)((0,ef.l)(this.iteration,this.decay),1));t.forEach((t,a)=>{let s=y.T2.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:(0,ey.P)(s).variable(!1)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:(0,ey.P)(s).variable(!1)});let i=Array.isArray(e)?e[a].tensor:e[t];if(null==i)return;let o=this.accumulatedFirstMoment[a].variable,l=this.accumulatedWeightedInfNorm[a].variable,u=(0,ed.W)((0,ef.l)(o,this.beta1),(0,ef.l)(i,1-this.beta1)),h=(0,ef.l)(l,this.beta2),p=(0,e_.t)(i),d=(0,eD.P)(h,p);o.assign(u),l.assign(d);let c=(0,ed.W)((0,ef.l)((0,ec.y)(n,r),(0,ec.y)(u,(0,ed.W)(d,this.epsilon))),s);s.assign(c)}),this.iteration.assign((0,ed.W)(this.iteration,1)),this.accBeta1.assign((0,ef.l)(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&(0,ep.AS)(this.accumulatedFirstMoment.map(e=>e.variable)),null!=this.accumulatedWeightedInfNorm&&(0,ep.AS)(this.accumulatedWeightedInfNorm.map(e=>e.variable))}async getWeights(){throw Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}class eL extends eI{static get className(){return"SGD"}constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}
233applyGradients(e){(Array.isArray(e)?e.map(e=>e.name):Object.keys(e)).forEach((t,r)=>{let n=Array.isArray(e)?e[r].tensor:e[t];if(null==n)return;let a=y.T2.registeredVariables[t];(0,ep.DZ)(()=>{let e=(0,ed.W)((0,ef.l)(this.c,n),a);a.assign(e)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(0,ep.aC)((0,ex.d)(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(0!==(e=await this.extractIterations(e)).length)throw Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}class eM extends eL{static get className(){return"Momentum"}constructor(e,t,r=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=r,this.accumulations=[],this.m=(0,ex.d)(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(e=>e.name):Object.keys(e)).forEach((t,r)=>{let n=y.T2.registeredVariables[t];null==this.accumulations[r]&&(this.accumulations[r]={originalName:`${t}/momentum`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))});let a=this.accumulations[r].variable,s=Array.isArray(e)?e[r].tensor:e[t];null!=s&&(0,ep.DZ)(()=>{let e,t=(0,ed.W)((0,ef.l)(this.m,a),s);e=this.useNesterov?(0,ed.W)((0,ef.l)(this.c,(0,ed.W)(s,(0,ef.l)(t,this.m))),n):(0,ed.W)((0,ef.l)(this.c,t),n),a.assign(t),n.assign(e)})}),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&(0,ep.AS)(this.accumulations.map(e=>e.variable))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e),this.accumulations=e.map(e=>({originalName:e.name,variable:e.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}class eP extends eI{static get className(){return"RMSProp"}constructor(e,t=.9,r=0,n=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=r,this.epsilon=n,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==n&&(this.epsilon=y.T2.backend.epsilon()),null==e)throw Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(e=>e.name):Object.keys(e)).forEach((t,r)=>{let n=y.T2.registeredVariables[t];null==this.accumulatedMeanSquares[r]&&(this.accumulatedMeanSquares[r]={originalName:`${t}/rms`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))}),null==this.accumulatedMoments[r]&&(this.accumulatedMoments[r]={originalName:`${t}/momentum`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))}),null==this.accumulatedMeanGrads[r]&&this.centered&&(this.accumulatedMeanGrads[r]={originalName:`${t}/mg`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))});let a=Array.isArray(e)?e[r].tensor:e[t];if(null==a)return;let s=this.accumulatedMeanSquares[r].variable,i=this.accumulatedMoments[r].variable;(0,ep.DZ)(()=>{let e=(0,ed.W)((0,ef.l)(s,this.decay),(0,ef.l)((0,eg.E)(a),1-this.decay));if(this.centered){let t=this.accumulatedMeanGrads[r].variable,o=(0,ed.W)((0,ef.l)(t,this.decay),(0,ef.l)(a,1-this.decay)),l=(0,ec.y)((0,ef.l)(a,this.learningRate),(0,em.R)((0,eF.j)(e,(0,ed.W)((0,eg.E)(o),this.epsilon)))),u=(0,ed.W)((0,ef.l)(i,this.momentum),l);s.assign(e),t.assign(o),i.assign(u);let h=(0,eF.j)(n,u);n.assign(h)}else{let e=(0,ed.W)((0,ef.l)(s,this.decay),(0,ef.l)((0,eg.E)(a),1-this.decay)),t=(0,ed.W)((0,ef.l)(i,this.momentum),(0,ec.y)((0,ef.l)(a,this.learningRate),(0,em.R)((0,ed.W)(e,this.epsilon))));s.assign(e),i.assign(t);let r=(0,eF.j)(n,t);n.assign(r)}})}),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&(0,ep.AS)(this.accumulatedMeanSquares.map(e=>e.variable)),null!=this.accumulatedMeanGrads&&this.centered&&(0,ep.AS)(this.accumulatedMeanGrads.map(e=>e.variable)),null!=this.accumulatedMoments&&(0,ep.AS)(this.accumulatedMoments.map(e=>e.variable))}async getWeights(){let e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map(e=>({name:e.originalName,tensor:e.variable}
233)))}async setWeights(e){e=await this.extractIterations(e);let t=this.centered?e.length/3:e.length/2;this.accumulatedMeanSquares=e.slice(0,t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})),this.accumulatedMoments=e.slice(t,2*t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}function ez(e){return new Promise(e=>setTimeout(e)).then(e)}class eB{constructor(e){if(!(0,w._K)().getBool("IS_BROWSER"))throw Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(eB.URL_SCHEME)&&(e=e.slice(eB.URL_SCHEME.length)),(null==e||0===e.length)&&(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw Error("Browser downloads are not supported in this environment since `document` is not present");let t=$.D.join(e.weightData),r=window.URL.createObjectURL(new Blob([t],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{let t=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],n=(0,N.zV)(e,t),a=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),s=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(s.download=this.modelJsonFileName,s.href=a,await ez(()=>s.dispatchEvent(new MouseEvent("click"))),null!=e.weightData){let e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=r,await ez(()=>e.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:(0,N.oR)(e)}}}}eB.URL_SCHEME="downloads://";class eW{constructor(e){if(null==e||e.length<1)throw Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise((e,t)=>{let r=new FileReader;r.onload=r=>{let n=JSON.parse(r.target.result),a=n.modelTopology;return null==a?void t(Error(`modelTopology field is missing from file ${this.jsonFile.name}`)):null==n.weightsManifest?void t(Error(`weightManifest field is missing from file ${this.jsonFile.name}`)):0===this.weightsFiles.length?void e({modelTopology:a}):void e((0,N.Ej)(n,e=>this.loadWeights(e)))},r.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),r.readAsText(this.jsonFile)})}loadWeights(e){let t=[],r=[];for(let n of e)t.push(...n.weights),r.push(...n.paths);let n=this.checkManifestAndWeightFiles(e);return Promise.all(r.map(e=>this.loadWeightsFile(e,n[e]))).then(e=>[t,e])}loadWeightsFile(e,t){return new Promise((r,n)=>{let a=new FileReader;a.onload=e=>{r(e.target.result)},a.onerror=t=>n(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],r=this.weightsFiles.map(e=>(0,N.P8)(e.name)),n={};for(let a of e)a.paths.forEach(e=>{let a=(0,N.P8)(e);if(-1!==t.indexOf(a))throw Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===r.indexOf(a))throw Error(`Weight file with basename '${a}' is not provided.`);n[e]=this.weightsFiles[r.indexOf(a)]});if(t.length!==this.weightsFiles.length)throw Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return n}}function eV(e){return new eW(e)}function eU(e,t,r,n){var a,s,i;a=e,(0,z.vA)(null!=a&&Array.isArray(a)&&a.length>0,()=>"promises must be a none empty array"),s=r=null==r?0:r,i=n=null==n?1:n,(0,z.vA)(s>=0&&s<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${s}
233`),(0,z.vA)(i>=0&&i<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${i}`),(0,z.vA)(i>=s,()=>`startFraction must be no more than endFraction, but got startFraction ${s} and endFraction ${i}`);let o=0;return Promise.all(e.map(a=>(a.then(a=>(t(r+ ++o/e.length*(n-r)),a)),a)))}k.registerSaveRouter(e=>(0,w._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(eB.URL_SCHEME)?function(e="model"){return new eB(e)}(e.slice(eB.URL_SCHEME.length)):null);var eG=r(91941);async function eZ(e,t){null==t&&(t={});let r=null==t.fetchFunc?(0,w._K)().platform.fetch:t.fetchFunc,n=e.map(e=>r(e,t.requestInit,{isBinary:!0})),a=(null==t.onProgress?await Promise.all(n):await eU(n,t.onProgress,0,.5)).map(e=>e.arrayBuffer());return null==t.onProgress?await Promise.all(a):await eU(a,t.onProgress,.5,1)}async function ej(e,t="",r,n){return eK(e=>eZ(e,{requestInit:n}))(e,t,r)}function eK(e){return async(t,r="",n)=>{let a=t.map(()=>!1),s={},i=null!=n?n.map(()=>!1):[],o=[];if(t.forEach((e,t)=>{let r=0;e.weights.forEach(e=>{let l="quantization"in e?e.quantization.dtype:e.dtype,u=eG.i[l]*z.Ze(e.shape),h=()=>{a[t]=!0,null==s[t]&&(s[t]=[]),s[t].push({manifestEntry:e,groupOffset:r,sizeBytes:u})};null!=n?n.forEach((t,r)=>{t===e.name&&(h(),i[r]=!0)}):h(),o.push(e.name),r+=u})}),!i.every(e=>e)){let e=n.filter((e,t)=>!i[t]);throw Error(`Could not find weights in manifest with names: ${e.join(", ")}. 234Manifest JSON has weights with names: ${o.join(", ")}.`)}let l=a.reduce((e,t,r)=>(t&&e.push(r),e),[]),u=[];l.forEach(e=>{t[e].paths.forEach(e=>{let t=r+(r.endsWith("/")?"":"/")+e;u.push(t)})});let h=await e(u),p={},d=0;return l.forEach(e=>{let r=t[e].paths.length,n=new $.D(h.slice(d,d+r));s[e].forEach(e=>{let t=n.slice(e.groupOffset,e.groupOffset+e.sizeBytes),r=(0,N.CY)(t,[e.manifestEntry]);for(let e in r)p[e]=r[e]}),d+=r}),p}}class eH{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?((0,z.vA)("function"==typeof t.fetchFunc,()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=t.fetchFunc):this.fetch=(0,w._K)().platform.fetch,(0,z.vA)(null!=e&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&(0,z.vA)(2===e.length,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{},this.loadOptions=t}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");let t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;let r=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],n=(0,N.zV)(e,r);if(t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData){let r=$.D.join(e.weightData);t.body.append("model.weights.bin",new Blob([r],{type:"application/octet-stream"}),"model.weights.bin")}let a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:(0,N.oR)(e),responses:[a]};throw Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${a.status}.`)}async loadModelJSON(){let e,t=await this.fetch(this.path,this.requestInit);if(!t.ok)throw Error(`Request to ${this.path} failed with status code ${t.status}. Please verify this URL points to the model JSON of the model to load.`);try{e=await t.json()}catch(t){let e=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?e+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":e+=" Please make sure the server is serving valid JSON for this request.",Error(e)}let r=e.modelTopology,n=e.weightsManifest;if(null==r&&null==n)throw Error(`The JSON from HTTP path ${this.path}
234 contains neither model topology or manifest for weights.`);return e}async load(){if(this.loadOptions.streamWeights)return this.loadStream();let e=await this.loadModelJSON();return(0,N.Ej)(e,e=>this.loadWeights(e))}async loadStream(){let e=await this.loadModelJSON(),t=await this.getWeightUrls(e.weightsManifest),r=(0,N.Xf)(e.weightsManifest),n=()=>(function(e,t){var r;let n,a=null==t.fetchFunc?(0,w._K)().platform.fetch:t.fetchFunc,s=0;return null==(r=t.onProgress)||r.call(t,0),new ReadableStream({pull:async r=>{for(var i;s<e.length;){n||(n=(await a(e[s],t.requestInit,{isBinary:!0})).body.getReader());let{done:o,value:l}=await n.read();if(o){s++,n=void 0,null==(i=t.onProgress)||i.call(t,s/e.length);continue}r.enqueue(l);return}r.close()}})})(t,this.loadOptions);return Object.assign(Object.assign({},e),{weightSpecs:r,getWeightStream:n})}async getWeightUrls(e){let[t,r]=function(e){let t=e.lastIndexOf("/"),r=e.lastIndexOf("?");return[e.substring(0,t)+"/",r>t?e.substring(r):""]}(Array.isArray(this.path)?this.path[1]:this.path),n=this.weightPathPrefix||t,a=[],s=[];for(let t of e)for(let e of t.paths)null!=this.weightUrlConverter?s.push(this.weightUrlConverter(e)):a.push(n+e+r);return this.weightUrlConverter&&a.push(...await Promise.all(s)),a}async loadWeights(e){let t=await this.getWeightUrls(e);return[(0,N.Xf)(e),await eZ(t,this.loadOptions)]}}function eY(e){return null!=e.match(eH.URL_SCHEME_REGEX)}eH.URL_SCHEME_REGEX=/^https?:\/\//;let eQ=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc));else if(Array.isArray(e)?e.every(e=>eY(e)):eY(e))return eq(e,t);return null};function eq(e,t){return new eH(e,t)}function eX(e,t){return eq(e,t)}k.registerSaveRouter(eQ),k.registerLoadRouter(eQ);class eJ{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class e0{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class e1{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function e2(e,t,r,n){let a=arguments;return new e1(e3(...a))}function e3(e,t,r,n){return 1!=arguments.length?(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new eJ({modelTopology:e,weightSpecs:t,weightData:r,trainingConfig:n})):null!=e.modelTopology||null!=e.weightSpecs?new eJ(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new eJ({modelTopology:e}))}function e4(e){return new e0(e)}function e6(e){return new e0(e)}var e5=r(54463),e8=r(99309),e7=r(42926),e9=r(18875),te=r(32021);let tt=(0,e9.op)({confusionMatrix_:function(e,t,r){let n=(0,e5.YT)(e,"labels","confusionMatrix"),a=(0,e5.YT)(t,"predictions","confusionMatrix");z.vA(null==r||r>0&&Number.isInteger(r),()=>`If provided, numClasses must be a positive integer, but got ${r}`),z.vA(1===n.rank,()=>`Expected the rank of labels to be 1, but got ${n.rank}`),z.vA(1===a.rank,()=>`Expected the rank of predictions to be 1, but got ${a.rank}`),z.vA(n.shape[0]===a.shape[0],()=>`Mismatch in the number of examples: ${n.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`),z.vA(r>0&&Number.isInteger(r),()=>`numClasses is required to be a positive integer, but got ${r}`);let s=(0,e7.M)((0,ei.w)(n,"int32"),r),i=(0,e7.M)((0,ei.w)(a,"int32"),r),o=(0,te.m)(s),l=(0,e8.N)(o,i);return(0,ei.w)(l,"int32")}});var tr=r(89990),tn=r(96609),ta=r(22548),ts=r(73888);let ti=!1;function to(e,t=3){let r,n;if(t>4)throw Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw Error("pixels passed to tf.browser.fromPixels() can not be null");let a=!1,i=!1,o=!1,l=!1,u=!1,h=!1;if(e.data instanceof Uint8Array)a=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)i=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)o=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)l=!0;else if(null!=e.getContext)u=!0;else if("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)h=!0;else throw Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`);if(null!=(0,ta._5)(tn.awo,y.T2.backendName))return y.T2.runKernel(tn.awo,{pixels:e},{numChannels:t});let[p,d]=o?[e.videoWidth,e.videoHeight]:[e.width,e.height];if(u)r=e.getContext("2d").getImageData(0,0,p,d).data;else if(i||a)r=e.data;else if(l||o||h){if(null==s)if("undefined"==typeof document)if("undefined"!=typeof OffscreenCanvas&&"undefined"!=typeof OffscreenCanvasRenderingContext2D)s=new OffscreenCanvas(1,1).getContext("2d");else throw Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");else s=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});s.canvas.width=p,s.canvas.height=d,s.drawImage(e,0,0,p,d),r=s.getImageData(0,0,p,d).data}if(4===t)n=new Int32Array(r);else{let e=p*d;n=new Int32Array(e*t);for(let a=0;a<e;a++)for(let e=0;e<t;++e)n[a*t+e]=r[4*a+e]}let c=[d,p,t];return(0,ts.$)(n,c,"int32")}async function tl(e,t=3){var r;let n=null;if((0,w._K)().getBool("WRAP_TO_IMAGEBITMAP")&&"undefined"!=typeof window&&"undefined"!=typeof ImageBitmap&&window.hasOwnProperty("createImageBitmap")&&!(e instanceof ImageBitmap)&&null!=(r=e)&&0!==r.width&&0!==r.height&&!(null!=e&&e.data instanceof Uint8Array)){let t;try{t=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch(e){t=null}n=null!=t&&t.width===e.width&&t.height===e.height?t:e}else n=e;return to(n,t)}
234function tu(e){if(2!==e.rank&&3!==e.rank)throw Error(`toPixels only supports rank 2 or 3 tensors, got rank ${e.rank}.`);let t=2===e.rank?1:e.shape[2];if(t>4||2===t)throw Error(`toPixels only supports depth of size 1, 3 or 4 but got ${t}`);if("float32"!==e.dtype&&"int32"!==e.dtype)throw Error(`Unsupported type for toPixels: ${e.dtype}. Please use float32 or int32 tensors.`)}async function th(e,t){let r=(0,e5.YT)(e,"img","toPixels");if(!(e instanceof eu.qY)){let e=r;r=(0,ei.w)(e,"int32"),e.dispose()}tu(r);let[n,a]=r.shape.slice(0,2),s=2===r.rank?1:r.shape[2],i=await r.data(),o="float32"===r.dtype?255:1,l=new Uint8ClampedArray(a*n*4);for(let e=0;e<n*a;++e){let t=[0,0,0,255];for(let n=0;n<s;n++){let a=i[e*s+n];if("float32"===r.dtype){if(a<0||a>1)throw Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${a}.`)}else if("int32"===r.dtype&&(a<0||a>255))throw Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${a}.`);1===s?(t[0]=a*o,t[1]=a*o,t[2]=a*o):t[n]=a*o}let n=4*e;l[n+0]=Math.round(t[0]),l[n+1]=Math.round(t[1]),l[n+2]=Math.round(t[2]),l[n+3]=Math.round(t[3])}if(null!=t){ti||null!=(0,ta._5)(tn.XmO,y.T2.backendName)&&(console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."),ti=!0),t.width=a,t.height=n;let e=t.getContext("2d"),r=new ImageData(l,a,n);e.putImageData(r,0,0)}return r!==e&&r.dispose(),l}function tp(e,t,r){let n=(0,e5.YT)(e,"img","draw");if(!(e instanceof eu.qY)){let e=n;n=(0,ei.w)(e,"int32"),e.dispose()}tu(n);var a=null==r?void 0:r.imageOptions;let s=(null==a?void 0:a.alpha)||1;if(s>1||s<0)throw Error(`Alpha value ${s} is suppoed to be in range [0 - 1].`);let i={image:n};y.T2.runKernel(tn.XmO,i,{canvas:t,options:r})}let td=(0,e9.op)({fromPixels_:to});function tc(e,t){let r=e.shape.length,n=t.shape.length;if(r<1)throw Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${r}.`);if(n<1)throw Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${n}.`);if("int32"!==t.dtype)throw Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[n-1]>r)throw Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[n-1]} vs. ${r}`);if(0===(0,z.Ze)(e.shape))throw Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);let a=t.shape,s=a[a.length-1],i=1;for(let e=0;e<a.length-1;++e)i*=a[e];let o=e.shape,l=a.slice();l.pop();let u=1;for(let e=s;e<r;++e)u*=o[e],l.push(o[e]);let h=[...(0,z.Ur)(e.shape).map(e=>e/u),1].slice(0,s);return[l,i,u,h]}var tf=r(2536),tm=r(75521),tg=r(72155),ty=r(22700);let tb=.1;function tx(e,t,r){return null==r&&(r=tv()),tw(e,t,(e,t)=>tk(e,t,r))}function tv(){return 32===y.T2.backend.floatPrecision()?.001:tb}function tw(e,t,r){let n=!0;if(((0,ty.isTypedArray)(e)||(0,ty.isTypedArray)(t))&&(n=!1),(0,ty.isTypedArray)(e)&&(0,ty.isTypedArray)(t)&&(n=!0),n){let r=e.constructor.name,n=t.constructor.name;if(r!==n)throw Error(`Arrays are of different type. Actual: ${r}. Expected: ${n}`)}if(Array.isArray(e)&&Array.isArray(t)){let r=(0,e5.MZ)(e),n=(0,e5.MZ)(t);if(!(0,z.r1)(r,n))throw Error(`Arrays have different shapes. Actual: [${r}]. Expected: [${n}]`)}let a=(0,ty.isTypedArray)(e)?e:(0,ty.flatten)(e),s=(0,ty.isTypedArray)(t)?t:(0,ty.flatten)(t);if(a.length!==s.length)throw Error(`Arrays have different lengths actual: ${a.length} vs expected: ${s.length}. 235Actual: ${a}. 236Expected: ${s}.`);for(let e=0;e<s.length;++e){let t=a[e],n=s[e];if(!r(t,n))throw Error(`Arrays differ: actual[${e}] = ${t}, expected[${e}] = ${n}. 237Actual: ${a}. 238Expected: ${s}.`)}"undefined"!=typeof expect&&expect().nothing()}function tT(e,t){e().then(()=>t.fail(),()=>t()),"undefined"!=typeof expect&&expect().nothing()}function tS(e,t){let r="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return(0,z.Kg)(e)||(0,z.Kg)(e[0])||(0,z.Kg)(t)||(0,z.Kg)(t[0])?tw(e,r,(e,t)=>e==t):tw(e,t,(e,t)=>tk(e,t,0))}function tN(e,t,r){if(null==r&&(r=tv()),!tk(e,t,r))throw Error(`Numbers differ: actual === ${e}, expected === ${t}`);"undefined"!=typeof expect&&expect().nothing()}function tk(e,t,r){return!(isFinite(e)||isFinite(t))||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>r)}function tI(e,t,r){for(let n=0;n<e.length;n++)if(e[n]<t||e[n]>r)throw Error(`Value out of range:${e[n]} low: ${t}, high: ${r}`)}function tC(e,t){let r=new Float32Array(e),n=new Float32Array(t);if(r.length!==n.length)throw Error(`Expected ArrayBuffer to be of length ${n.length}, but it was ${r.length}`);for(let e=0;e<n.length;e++)if(r[e]!==n[e])throw Error(`Expected ArrayBuffer value at ${e} to be ${n[e]} but got ${r[e]} instead`)}function tE(e){let t=document.createElement("video");
238return"playsInline"in t&&(t.playsInline=!0),t.muted=!0,t.loop=!0,t.style.position="fixed",t.style.left="0px",t.style.top="0px",t.preload="auto",t.appendChild(e),new Promise(e=>{t.addEventListener("loadeddata",r=>e(t)),t.load()})}async function tA(e){await e.play(),"requestVideoFrameCallback"in e&&await new Promise(t=>{e.requestVideoFrameCallback(t)})}let t$="4.22.0";class tF{static sgd(e){return new eL(e)}static momentum(e,t,r=!1){return new eM(e,t,r)}static rmsprop(e,t=.9,r=0,n=null,a=!1){return new eP(e,t,r,n,a)}static adam(e=.001,t=.9,r=.999,n=null){return new eR(e,t,r,n)}static adadelta(e=.001,t=.95,r=null){return new eC(e,t,r)}static adamax(e=.002,t=.9,r=.999,n=null,a=0){return new eO(e,t,r,n,a)}static adagrad(e,t=.1){return new eA(e,t)}}var tR=r(20728),t_=r(98503),tD=r(22492);let tO=tF,tL="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function tM(){return new Promise(e=>tL(()=>e()))}var tP=r(64256);function tz(e,t){let r=e[0].length;e.forEach((e,t)=>{z.vA(e.length===r,()=>`Error in concat${r}D: rank of tensors[${t}] must be the same as the rank of the rest (${r})`)}),z.vA(t>=0&&t<r,()=>`Error in concat${r}D: axis must be between 0 and ${r-1}.`);let n=e[0];e.forEach((e,a)=>{for(let s=0;s<r;s++)z.vA(s===t||e[s]===n[s],()=>`Error in concat${r}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${n}) along the non-concatenated axis ${a}.`)})}function tB(e,t){let r=e[0].slice();for(let n=1;n<e.length;n++)r[t]+=e[n][t];return r}var tW=r(46866),tV=r(94494);function tU(e,t,r){let n=[];if(null==r&&null==t)return n;if(null==t)for(;n.length<e+r.length;)n.push(-1);else n=t.slice();if(null==r)return n;if(e+r.length!==n.length)throw Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e+r.length}, but shape.rank = ${n.length}`);for(let a=1;a<r.length;++a){let s=r[a],i=n[n.length-r.length+a],o=n[i];if(s>=0)if(o>=0){if(o!==s)throw Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${a+e}] = ${s} but shape[${a+e}] = ${o}`)}else n[i]=s}return n}function tG(e){let t={FIRST_DIM_SIZE:i.FIRST_DIM_SIZE,VALUE_ROWIDS:i.VALUE_ROWIDS,ROW_LENGTHS:i.ROW_LENGTHS,ROW_SPLITS:i.ROW_SPLITS,ROW_LIMITS:i.ROW_LIMITS,ROW_STARTS:i.ROW_STARTS},r=[];for(let n of e)if(n in t)r.push(t[n]);else break;return r}function tZ(e){return 0===e.length?0:e[0]===i.FIRST_DIM_SIZE?e.length-1:e.length}function tj(e,t){if(null==e||null==t)return;let r=e.length,n=t.length;if(r>=n)throw Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${r} must be less than ragged tensor input flatValues.rank = ${n})`);for(let a=0;a<Math.min(r,n-1);++a){let r=e[a],n=t[a+1];if(r>=0&&n>=0&&1!==r&&r!==n)throw Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${a-e.length}] = ${r} but ragged tensor input.flatValues.shape[${a-e.length}] = ${n}`)}}!function(e){e[e.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",e[e.VALUE_ROWIDS=1]="VALUE_ROWIDS",e[e.ROW_LENGTHS=2]="ROW_LENGTHS",e[e.ROW_SPLITS=3]="ROW_SPLITS",e[e.ROW_LIMITS=4]="ROW_LIMITS",e[e.ROW_STARTS=5]="ROW_STARTS"}(i||(i={}));let tK=30;function tH(e){return e<=tK?e:(0,z.lK)(e,Math.floor(Math.sqrt(e)))}function tY(e,t,r){return[r*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}function tQ(e,t,r,n=!0){let a=[];if(n)(a=a.concat(t.slice(0))).push(e[0]/r),a=a.concat(e.slice(1));else{a=a.concat(e[0]);let r=t.length;for(let n=0;n<r;++n)a=a.concat([e[n+1]/t[n],t[n]]);a=a.concat(e.slice(r+1))}return a}function tq(e,t,r=!0){let n=[];if(r){n.push(t);for(let r=t+1;r<e;++r)r<=2*t?(n.push(r),n.push(r-(t+1))):n.push(r)}else{let r=[],a=[];for(let n=1;n<e;++n)n>=2*t+1||n%2==1?a.push(n):r.push(n);n.push(...r),n.push(0),n.push(...a)}return n}function tX(e,t,r,n=!0){let a=[];n?a.push(e[0]/r):a.push(e[0]*r);for(let r=1;r<e.length;++r)r<=t.length?n?a.push(t[r-1]*e[r]):a.push(e[r]/t[r-1]):a.push(e[r]);return a}function tJ(e,t){let r=[0];for(let n=0;n<t;++n)r.push(e[n][0]);return r}function t0(e,t,r){let n=e.slice(0,1);for(let a=0;a<r;++a)n.push(e[a+1]-t[a][0]-t[a][1]);return n}var t1=r(16530);let t2=.3275911,t3=.254829592,t4=-.284496736,t6=1.421413741,t5=-1.453152027,t8=1.061405429;var t7=r(5663);function t9(e,t){if(e.length!==t.length)throw Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);let r=new Float32Array(2*e.length);for(let n=0;n<r.length;n+=2)r[n]=e[n/2],r[n+1]=t[n/2];return r}function re(e){let t=new Float32Array(e.length/2),r=new Float32Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=e[n],r[n/2]=e[n+1];return{real:t,imag:r}}function rt(e){let t=Math.ceil(e.length/4),r=new Float32Array(t),n=new Float32Array(t);for(let t=0;t<e.length;t+=4)r[Math.floor(t/4)]=e[t],n[Math.floor(t/4)]=e[t+1];return{real:r,imag:n}}function rr(e){let t=Math.floor(e.length/4),r=new Float32Array(t),n=new Float32Array(t);for(let t=2;t<e.length;t+=4)r[Math.floor(t/4)]=e[t],n[Math.floor(t/4)]=e[t+1];return{real:r,imag:n}}function rn(e,t){return{real:e[2*t],imag:e[2*t+1]}}function ra(e,t,r,n){e[2*n]=t,e[2*n+1]=r}function rs(e,t){let r=new Float32Array(e/2),n=new Float32Array(e/2);for(let a=0;a<Math.ceil(e/2);a++){let s=(t?2:-2)*Math.PI*(a/e);r[a]=Math.cos(s),n[a]=Math.sin(s)}return{real:r,imag:n}}function ri(e,t,r){let n=(r?2:-2)*Math.PI*(e/t);return{real:Math.cos(n),imag:Math.sin(n)}}let ro=/->/g;function rl(e,t){let r=((e=e.replace(/\s/g,"")).length-e.replace(ro,"").length)/2;if(r<1)throw Error("Equations without an arrow are not supported.");
238if(r>1)throw Error('Equation must contain exactly one arrow ("->").');let[n,a]=e.split("->");(0,z.vA)(-1===n.indexOf("..."),()=>'The ellipsis notation ("...") is not supported yet.');let s=n.split(","),i=s.length;if(t!==i)throw Error(`Expected ${i} input tensors, received ${t}`);if(i>2)throw Error("Support for more than 2 input tensors is not implemented yet.");let o=[];for(let e=0;e<a.length;++e){let t=a[e];if(!s.some(e=>-1!==e.indexOf(t)))throw Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===o.indexOf(t)&&o.push(t)}for(let e=0;e<n.length;++e){let t=n[e];-1===o.indexOf(t)&&","!==t&&o.push(t)}let l=Array(s.length);for(let e=0;e<i;++e){if(new Set(s[e].split("")).size!==s[e].length)throw Error(`Found duplicate axes in input component ${s[e]}. Support for duplicate axes in input is not implemented yet.`);l[e]=[];for(let t=0;t<s[e].length;++t)l[e].push(o.indexOf(s[e][t]))}let u=o.length,h=a.length,p=[];for(let e=h;e<u;++e)p.push(e);return{allDims:o,summedDims:p,idDims:l}}function ru(e,t){let r=Array(e);r.fill(-1);for(let e=0;e<t.length;++e)r[t[e]]=e;let n=[];for(let t=0;t<e;++t)-1===r[t]&&n.push(t);return{permutationIndices:r=r.filter(e=>-1!==e),expandDims:n}}function rh(e,t,r){let n=Array(e);for(let e=0;e<r.length;++e){let a=r[e].shape;for(let r=0;r<t[e].length;++r)void 0===n[t[e][r]]?n[t[e][r]]=a[r]:(0,z.vA)(n[t[e][r]]===a[r],()=>`Expected dimension ${n[t[e][r]]} at axis ${r} of input shaped ${JSON.stringify(a)}, but got dimension ${a[r]}`)}}function rp(e,t){let r=[],n=0;0===e.length&&e.push(-1),n=e.length+1;for(let e=0;e<n;++e)r.push([]);let a=[];for(let n=0;n<e.length;++n)for(let s of function(e,t){let r=[];for(let n=0;n<e.length;++n)(0===e[n].length||-1!==e[n].indexOf(t)||-1===t)&&r.push(n);return r}(t,e[n]))-1===a.indexOf(s)&&(r[n].push(s),a.push(s));return{path:e,steps:r}}function rd(e){return e.every((e,t)=>e===t)}function rc(e,t,r=0){let n=[];if("number"==typeof t)(0,z.vA)(e.shape[r]%t==0,()=>"Number of splits must evenly divide the axis."),n=Array(t).fill(e.shape[r]/t);else{let a=t.reduce((e,t)=>(-1===t&&(e+=1),e),0);(0,z.vA)(a<=1,()=>"There should be only one negative value in split array.");let s=t.indexOf(-1);if(-1!==s){let n=t.reduce((e,t)=>t>0?e+t:e);t[s]=e.shape[r]-n}(0,z.vA)(e.shape[r]===t.reduce((e,t)=>e+t),()=>"The sum of sizes must match the size of the axis dimension."),n=t}return n}function rf(e){return`Received SparseTensor with denseShape[0] = 0 but 239 indices.shape[0] = ${e}`}function rm(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function rg(e,t,r){return`indices(${e}, 0) is invalid: ${t} >= ${r}`}function ry(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function rb(e,t){return`size ${e} must be non-negative, not ${t}`}function rx(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function rv(e,t){let r=(0,z.Ze)(e),n=(0,z.Ze)(t);return`Input to reshape is a SparseTensor with ${r} 240 dense values, but the requested shape requires a multiple of ${n}. inputShape=${e} outputShape= ${t}`}function rw(e,t){let r=(0,z.Ze)(e),n=(0,z.Ze)(t);return`Input to reshape is a tensor with ${r} dense values, but the requested shape has ${n}. inputShape=${e} outputShape=${t}`}function rT(){return"segment ids must be >= 0"}function rS(){return"segment ids are not increasing"}function rN(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function rk(e,t,r){return`Bad: indices[${e}] == ${t} out of range [0, ${r})`}function rI(e,t){let r,n=!1;for(e<=tK?(r=e,n=!0):r=(0,z.lK)(e,Math.floor(Math.sqrt(e)));!n;)r>t||r===e?n=!0:r=(0,z.lK)(e,r+1);return r}function rC(e,t,r){let n=[],a=e.length;for(let s=0;s<a;s++)s!==t?n.push(e[s]):n.push(r);return n}function rE(e,t,r,n){let a=t.shape.length,s=e.shape.length;if(0!==n&&(n<-a||n>a))throw Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${n}`);if(n<0&&(n+=a),n>s)throw Error(`batchDims (${n}) must be less than rank(x) ( 241 ${s}).`);if(r<n)throw Error(`batchDims (${n}) must be less than or equal to axis (${r}).`);for(let r=0;r<n;++r)if(e.shape[r]!==t.shape[r])throw Error(`x.shape[${r}]: ${e.shape[r]} should be equal to indices.shape[${r}]: ${t.shape[r]}.`);let i=e.shape[r],o=[],l=1,u=1,h=1;for(let t=0;t<n;++t)o.push(e.shape[t]),l*=e.shape[t];for(let t=n;t<r;t++)o.push(e.shape[t]),u*=e.shape[t];for(let e=n;e<a;e++)o.push(t.shape[e]);for(let t=r+1;t<s;t++)o.push(e.shape[t]),h*=e.shape[t];return{batchSize:l,sliceSize:h,outerSize:u,dimSize:i,outputShape:o}}function rA(e){try{return e.map(e=>(0,ty.decodeString)(e))}catch(e){throw Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function r$(e){return e.map(e=>(0,ty.encodeString)(e))}var rF=r(71446),rR=r(74709),r_=r(61325);for(let e of[eC,eA,eR,eO,eM,eP,eL])eN(e)},45770:(e,t,r)=>{"use strict";r.d(t,{X:()=>u});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(18875),l=r(86036);let u=(0,o.op)({dilation2d_:function(e,t,r,o,u=[1,1],h="NHWC"){let p=(0,s.YT)(e,"x","dilation2d"),d=(0,s.YT)(t,"filter","dilation2d");i.vA(3===p.rank||4===p.rank,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${p.rank}.`),i.vA(3===d.rank,()=>`Error in dilation2d: filter must be rank 3, but got rank ${d.rank}.`),i.vA("NHWC"===h,()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${h}`);let c=p,f=!1;3===p.rank&&(c=(0,l.t)(p,[1,p.shape[0],p.shape[1],p.shape[2]]),f=!0),i.vA(c.shape[3]===d.shape[2],()=>`Error in dilation2d: input and filter must have the same depth: ${c.shape[3]} vs ${d.shape[2]}`);let m={x:c,filter:d}
241,g=n.T2.runKernel(a.jxD,m,{strides:r,pad:o,dilations:u});return f?(0,l.t)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}})},45921:(e,t,r)=>{"use strict";r.d(t,{U:()=>function e(t,r="float32"){if((0,a.SA)(t),"complex64"===r){let r=e(t,"float32"),n=e(t,"float32");return(0,s.f)(r,n)}let i=(0,a.Ty)((0,a.Ze)(t),r);return n.T2.makeTensor(i,t,r)}});var n=r(5287),a=r(75681),s=r(47802)},45923:(e,t,r)=>{"use strict";r.d(t,{D:()=>l});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990);let l=(0,r(18875).op)({greaterEqual_:function(e,t){let r=(0,i.YT)(e,"a","greaterEqual","string_or_numeric"),l=(0,i.YT)(t,"b","greaterEqual","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.lLS,u)}})},46519:(e,t,r)=>{"use strict";r.d(t,{B:()=>a});var n=r(45720);function a(){let e,t,r,a,s,i,o,l,u,h;return 2===(0,n._K2)().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",r="out",a="in",s="texture",i="outputColor",o="out vec4 outputColor;",l=(0,n._K2)().getBool("WEBGL2_ISNAN_CUSTOM")?` 242 bool isnan_custom(float val) { 243 uint floatToUint = floatBitsToUint(val); 244 return (floatToUint & 0x7fffffffu) > 0x7f800000u; 245 } 246 247 bvec4 isnan_custom(vec4 val) { 248 return bvec4(isnan_custom(val.x), 249 isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w)); 250 } 251 252 #define isnan(value) isnan_custom(value) 253 `:"",u="",h=` 254 #define round(value) newRound(value) 255 int newRound(float value) { 256 return int(floor(value + 0.5)); 257 } 258 259 ivec4 newRound(vec4 value) { 260 return ivec4(floor(value + vec4(0.5))); 261 } 262 `):(e="",t="attribute",r="varying",a="varying",s="texture2D",i="gl_FragColor",o="",l=` 263 #define isnan(value) isnan_custom(value) 264 bool isnan_custom(float val) { 265 return (val > 0. || val < 1. || val == 0.) ? false : true; 266 } 267 bvec4 isnan_custom(vec4 val) { 268 return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w)); 269 } 270 `,u=` 271 uniform float INFINITY; 272 273 bool isinf(float val) { 274 return abs(val) == INFINITY; 275 } 276 bvec4 isinf(vec4 val) { 277 return equal(abs(val), vec4(INFINITY)); 278 } 279 `,h=` 280 int round(float value) { 281 return int(floor(value + 0.5)); 282 } 283 284 ivec4 round(vec4 value) { 285 return ivec4(floor(value + vec4(0.5))); 286 } 287 `),{version:e,attribute:t,varyingVs:r,varyingFs:a,texture2D:s,output:i,defineOutput:o,defineSpecialNaN:l,defineSpecialInf:u,defineRound:h}}},46568:(e,t,r)=>{"use strict";r.d(t,{Dv:()=>o,_X:()=>d,jY:()=>u,mu:()=>h,ok:()=>l,y7:()=>p});var n=r(5287),a=r(94708),s=r(54463),i=r(75681);function o(e){return i.vA(i.Tn(e),()=>"The f passed in grad(f) must be a function"),(t,r)=>{let a=(0,s.YT)(t,"x","tf.grad","string_or_numeric"),o=null!=r?(0,s.YT)(r,"dy","tf.grad"):null;return n.T2.tidy(()=>{let{value:t,grads:r}=n.T2.gradients(()=>e(a),[a],o);return null!=o&&i.O3(t.shape,o.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),c(r),r[0]})}}function l(e){return i.vA(i.Tn(e),()=>"The f passed in grads(f) must be a function"),(t,r)=>{i.vA(Array.isArray(t),()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");let a=(0,s.j1)(t,"args","tf.grads","string_or_numeric"),o=null!=r?(0,s.YT)(r,"dy","tf.grads"):null;return n.T2.tidy(()=>{let{value:t,grads:r}=n.T2.gradients(()=>e(...a),a,o);return null!=o&&i.O3(t.shape,o.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),c(r),r})}}function u(e){return i.vA(i.Tn(e),()=>"The f passed in valueAndGrad(f) must be a function"),(t,r)=>{i.vA(t instanceof a.qY,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),i.vA(null==r||r instanceof a.qY,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:s,value:o}=n.T2.gradients(()=>e(t),[t],r);return c(s),{grad:s[0],value:o}}}function h(e){return i.vA(i.Tn(e),()=>"The f passed in valueAndGrads(f) must be a function"),(t,r)=>{i.vA(Array.isArray(t)&&t.every(e=>e instanceof a.qY),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),i.vA(null==r||r instanceof a.qY,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let s=n.T2.gradients(()=>e(...t),t,r);return null!=r&&i.O3(s.value.shape,r.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),c(s.grads),s}}function p(e,t){i.vA(i.Tn(e),()=>"The f passed in variableGrads(f) must be a function"),i.vA(null==t||Array.isArray(t)&&t.every(e=>e instanceof a.rT),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let r=null!=t;if(!r)for(let e in t=[],n.T2.registeredVariables)t.push(n.T2.registeredVariables[e]);let s=r?t.filter(e=>!e.trainable):null,o=t.length;t=t.filter(e=>e.trainable),i.vA(t.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${o} variables is trainable.`);let{value:l,grads:u}=n.T2.gradients(e,t,null,!0);i.vA(u.some(e=>null!=e),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),i.vA(0===l.rank,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${l.rank} tensor`);let h={};return t.forEach((e,t)=>{null!=u[t]&&(h[e.name]=u[t])}
287),null!=s&&s.forEach(e=>h[e.name]=null),{value:l,grads:h}}function d(e){return n.T2.customGrad(e)}function c(e){if(e.filter(e=>null==e).length>0)throw Error(`Cannot compute gradient of y=f(x) with respect to x. Make sure that 288 the f you passed encloses all operations that lead from x to y.`)}},46866:(e,t,r)=>{"use strict";r.d(t,{$Q:()=>y,Dh:()=>f,E6:()=>s,G0:()=>m,G8:()=>u,YQ:()=>a,l5:()=>i,p$:()=>l,qk:()=>g,s_:()=>b,uf:()=>o});var n=r(75681);function a(e,t,r,n,s="NHWC",i){let l=[...t,e[3]];return o(e,l,r,i,n,null,null,y(s))}function s(e,t,r,n,a,i,l="channelsLast"){let u,[p,d]=h(t);if("channelsLast"===l)u=[p,d,e[3],e[3]];else if("channelsFirst"===l)u=[p,d,e[1],e[1]];else throw Error(`Unknown dataFormat ${l}`);return o(e,u,r,n,a,i,!1,l)}function i(e,t,r,n,a,s,o="NDHWC"){let u,h,[d,c,f]=p(t);if("NDHWC"===o)h="channelsLast",u=[d,c,f,e[4],e[4]];else if("NCDHW"===o)h="channelsFirst",u=[d,c,f,e[1],e[1]];else throw Error(`Unknown dataFormat ${o}`);return l(e,u,r,n,a,!1,h,s)}function o(e,t,r,n,a,s,i=!1,l="channelsLast"){let p,[f,m,g,y]=[-1,-1,-1,-1];if("channelsLast"===l)[f,m,g,y]=e;else if("channelsFirst"===l)[f,y,m,g]=e;else throw Error(`Unknown dataFormat ${l}`);let[b,x,,v]=t,[w,T]=h(r),[S,N]=h(n),k=d(b,S),I=d(x,N),{padInfo:C,outHeight:E,outWidth:A}=function(e,t,r,n,a,s,i,o,l){let h,p,d;if("number"==typeof e){let a=0===e?"VALID":"NUMBER";h={top:e,bottom:e,left:e,right:e,type:a};let i=function(e,t,r,n,a){null==n&&(n=u(e,t,r));let s=e[0],i=e[1];return[c((s-t+2*n)/r+1,a),c((i-t+2*n)/r+1,a)]}([t,r],s,n,e,o);p=i[0],d=i[1]}else if("same"===e){let e=Math.max(0,((p=Math.ceil(t/n))-1)*n+s-t),o=Math.max(0,((d=Math.ceil(r/a))-1)*a+i-r),l=Math.floor(e/2),u=Math.floor(o/2);h={top:l,bottom:e-l,left:u,right:o-u,type:"SAME"}}else if("valid"===e)h={top:0,bottom:0,left:0,right:0,type:"VALID"},p=Math.ceil((t-s+1)/n),d=Math.ceil((r-i+1)/a);else if("object"==typeof e){let u="channelsLast"===l?e[1][0]:e[2][0],f="channelsLast"===l?e[1][1]:e[2][1],m="channelsLast"===l?e[2][0]:e[3][0],g="channelsLast"===l?e[2][1]:e[3][1];h={top:u,bottom:f,left:m,right:g,type:0===u&&0===f&&0===m&&0===g?"VALID":"EXPLICIT"},p=c((t-s+u+f)/n+1,o),d=c((r-i+m+g)/a+1,o)}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:h,outHeight:p,outWidth:d}}(a,m,g,w,T,k,I,s,l),$=i?v*y:v;return"channelsFirst"===l?p=[f,$,E,A]:"channelsLast"===l&&(p=[f,E,A,$]),{batchSize:f,dataFormat:l,inHeight:m,inWidth:g,inChannels:y,outHeight:E,outWidth:A,outChannels:$,padInfo:C,strideHeight:w,strideWidth:T,filterHeight:b,filterWidth:x,effectiveFilterHeight:k,effectiveFilterWidth:I,dilationHeight:S,dilationWidth:N,inShape:e,outShape:p,filterShape:t}}function l(e,t,r,n,a,s=!1,i="channelsLast",o){let h,[f,m,g,y,b]=[-1,-1,-1,-1,-1];if("channelsLast"===i)[f,m,g,y,b]=e;else if("channelsFirst"===i)[f,b,m,g,y]=e;else throw Error(`Unknown dataFormat ${i}`);let[x,v,w,,T]=t,[S,N,k]=p(r),[I,C,E]=p(n),A=d(x,I),$=d(v,C),F=d(w,E),{padInfo:R,outDepth:_,outHeight:D,outWidth:O}=function(e,t,r,n,a,s,i,o,l,h,p){let d,f,m,g;if("valid"===e&&(e=0),"number"==typeof e){let y=0===e?"VALID":"NUMBER";d={top:e,bottom:e,left:e,right:e,front:e,back:e,type:y};let b=function(e,t,r,n,a,s){null==a&&(a=u(e,t[0],n[0]));let i=[0,0,0,1];for(let r=0;r<3;r++)e[r]+2*a>=t[r]&&(i[r]=c((e[r]-t[r]+2*a)/n[r]+1,s));return i}([t,r,n,1],[o,l,h],0,[a,s,i],e,p);f=b[0],m=b[1],g=b[2]}else if("same"===e){let e=((f=Math.ceil(t/a))-1)*a+o-t,u=((m=Math.ceil(r/s))-1)*s+l-r,p=((g=Math.ceil(n/i))-1)*i+h-n,c=Math.floor(e/2),y=Math.floor(u/2),b=Math.floor(p/2);d={top:y,bottom:u-y,left:b,right:p-b,front:c,back:e-c,type:"SAME"}}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:d,outDepth:f,outHeight:m,outWidth:g}}(a,m,g,y,S,N,k,A,$,F,o),L=s?T*b:T;return"channelsFirst"===i?h=[f,L,_,D,O]:"channelsLast"===i&&(h=[f,_,D,O,L]),{batchSize:f,dataFormat:i,inDepth:m,inHeight:g,inWidth:y,inChannels:b,outDepth:_,outHeight:D,outWidth:O,outChannels:L,padInfo:R,strideDepth:S,strideHeight:N,strideWidth:k,filterDepth:x,filterHeight:v,filterWidth:w,effectiveFilterDepth:A,effectiveFilterHeight:$,effectiveFilterWidth:F,dilationDepth:I,dilationHeight:C,dilationWidth:E,inShape:e,outShape:h,filterShape:t}}
288function u(e,t,r,n=1){let a=d(t,n);return Math.floor((e[0]*(r-1)-r+a)/2)}function h(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function p(e){return"number"==typeof e?[e,e,e]:e}function d(e,t){return t<=1?e:e+(e-1)*(t-1)}function c(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw Error(`Unknown roundingMode ${t}`)}}function f(e){let[t,r,n]=h(e);return 1===t&&1===r&&1===n}function m(e,t){return f(e)||f(t)}function g(e){return h(e).every(e=>e>0)}function y(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw Error(`Unknown dataFormat ${e}`)}function b(e,t,r){if(null!=r)if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${r} but got pad ${t}.`);else if("number"==typeof t)n.vA(n.E6(t),()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${r} but got pad ${t}.`);else if("object"==typeof t)t.forEach(t=>{t.forEach(t=>{n.vA(n.E6(t),()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${r} but got pad ${t}.`)})});else throw Error(`Error in ${e}: Unknown padding parameter: ${t}`)}},46921:(e,t,r)=>{"use strict";r.d(t,{v:()=>u});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(18875),l=r(86036);let u=(0,o.op)({resizeBilinear_:function(e,t,r=!1,o=!1){let u=(0,s.YT)(e,"images","resizeBilinear");i.vA(3===u.rank||4===u.rank,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${u.rank}.`),i.vA(2===t.length,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`),i.vA(!1===o||!1===r,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let h=u,p=!1;3===u.rank&&(p=!0,h=(0,l.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]]));let[]=t,d={images:h},c=n.T2.runKernel(a.hgw,d,{alignCorners:r,halfPixelCenters:o,size:t});return p?(0,l.t)(c,[c.shape[1],c.shape[2],c.shape[3]]):c}})},46978:(e,t,r)=>{"use strict";r.d(t,{e:()=>a});var n=r(45720);function a(e,t,r,a){let s=(0,n.ra8)(e,t.dtype);for(let e=0;e<s.size;e++){let n=s.indexToLoc(e),i=Array(n.length);for(let e=0;e<i.length;e++)i[e]=n[e]*r[e]+a[e];s.set(t.get(...i),...n)}return s}},47045:(e,t,r)=>{"use strict";r.d(t,{S3:()=>o,_B:()=>i});var n=r(45720),a=r(60072),s=r(32515);function i(e,t,r,a){let[s,i]=n.C0T.computeOutAndReduceShapes(e,a),o=(0,n.TuY)(t,"int32"),l=n.ZSL.makeZerosTypedArray(n.ZSL.sizeFromShape(s),o),u=n.ZSL.sizeFromShape(i);for(let e=0;e<l.length;++e){let t=e*u,n=1;for(let e=0;e<u;++e)n*=r[t+e];l[e]=n}return{outVals:l,outShape:s,outDtype:o}}let o={kernelName:n.kdj,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:o}=e,{x:l}=t,{axis:u,keepDims:h}=o;(0,a.C)(l,"prod");let p=l.shape.length,d=n.ZSL.parseAxisParam(u,l.shape),c=n.C0T.getAxesPermutation(d,p),f=d,m=l,g=[];null!=c&&(g.push(m=(0,s.m)({inputs:{x:l},backend:r,attrs:{perm:c}})),f=n.C0T.getInnerMostAxes(f.length,p));let y=r.data.get(m.dataId).values,{outVals:b,outShape:x,outDtype:v}=i(m.shape,m.dtype,y,f),w=x;return h&&(w=n.C0T.expandShapeToKeepDim(x,d)),g.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.makeTensorInfo(w,v,b)}}},47270:(e,t,r)=>{"use strict";r.d(t,{Ol:()=>l});var n=r(45720),a=r(64630),s=r(2748),i=r(63537),o=r(21131);class l extends s.Wd{constructor(e){if(null==e&&(e={}),super(e),this.dataFormat=null==e.dataFormat?(0,a.VI)():e.dataFormat,null==e.padding)this.padding=[[1,1],[1,1]];else if("number"==typeof e.padding)this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{let t,r;if(e.padding=e.padding,2!==e.padding.length)throw new i.Qp(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);if("number"==typeof e.padding[0])t=[e.padding[0],e.padding[0]],r=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,2!==e.padding[0].length)throw new i.Qp(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],2!==e.padding[1].length)throw new i.Qp(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);r=e.padding[1]}this.padding=[t,r]}this.inputSpec=[new s.eO({ndim:4})]}computeOutputShape(e){let t,r;return(e=(0,o.U$)(e),"channelsFirst"===this.dataFormat)?(t=null!=e[2]&&e[2]>=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,r=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,r]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,r=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,r,e[3]])}call(e,t){return(0,n.DZQ)(()=>{var t,r,s;return t=(0,o.un)(e),r=this.padding,s=this.dataFormat,(0,n.DZQ)(()=>{let e;if(4!==t.rank)throw new i.Qp(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(null==r&&(r=[[1,1],[1,1]]),2!==r.length||2!==r[0].length||2!==r[1].length)throw new i.Qp("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==s&&(s=(0,a.VI)()),"channelsLast"!==s&&"channelsFirst"!==s)throw new i.Qp(`Unknown data format: ${s}. Supported data formats are 'channelsLast' and 'channelsFirst.`);return e="channelsFirst"===s?[[0,0],[0,0],r[0],r[1]]:[[0,0],r[0],r[1],[0,0]],n.eVF(t,e)})})}getConfig(){let e={padding:this.padding,dataFormat:this.dataFormat};return Object.assign(e,super.getConfig()),e}}l.className="ZeroPadding2D",n.JFn.registerClass(l)},47802:(e,t,r)=>{"use strict";r.d(t,{f:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({complex_:function(e,t){let r=(0,s.YT)(e,"real","complex"),o=(0,s.YT)(t,"imag","complex");return i.O3(r.shape,o.shape,`real and imag shapes, ${r.shape} and ${o.shape}, must match in call to tf.complex().`),n.T2.runKernel(a.pr3,{real:r,imag:o})}})},47820:(e,t,r)=>{"use strict";r.d(t,{q:()=>a});var n=r(45720);function a(e,t,r,a,s,i,o,l,u){let h=(0,n.ra8)([a,i],r);for(let r=0;r<a;r++){let n=[],a=0;for(let t=0;t<s;t++){let i=e[r*s+t];a+=i*o[t],n.push(i)}
288if(a<0||a>=u/i)throw Error(`Invalid indices: ${n} does not index into ${l}`);for(let e=0;e<i;e++)h.values[r*i+e]=t.get(...t.indexToLoc(a*i+e))}return h}},47871:(e,t,r)=>{"use strict";r.d(t,{D:()=>a});var n=r(45720);function a(e,t){let r=Array(e.rank);for(let n=0;n<r.length;n++)r[n]=e.shape[n]*t[n];let a=(0,n.ra8)(r,e.dtype);for(let t=0;t<a.values.length;++t){let r=a.indexToLoc(t),n=Array(e.rank);for(let t=0;t<n.length;t++)n[t]=r[t]%e.shape[t];let s=e.locToIndex(n);a.values[t]=e.values[s]}return a}},48066:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({elu_:function(e){let t=(0,s.YT)(e,"x","elu","float32");return n.T2.runKernel(a.Pah,{x:t})}})},48138:(e,t,r)=>{"use strict";r.d(t,{F:()=>o});var n=r(5287),a=r(96609),s=r(72155),i=r(54463);let o=(0,r(18875).op)({atan2_:function(e,t){let r=(0,i.YT)(e,"a","atan2"),o=(0,i.YT)(t,"b","atan2");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.lxb,l)}})},48319:(e,t,r)=>{"use strict";r.d(t,{N:()=>s,X:()=>a});var n=r(45720);function a(e,t,r,a,s){let i=n.ZSL.sizeFromShape(a),o=n.ZSL.makeZerosTypedArray(s,r);for(let r=0;r<e.length;r++){let n=e[r];if(n<0)throw Error("Input x must be non-negative!");n>=s||(i>0?o[n]+=t[r]:o[n]+=1)}return o}function s(e,t,r,a=!1){let i=e.shape[0],o=e.shape[1],l=(0,n.ra8)([i,r],t.dtype);for(let n=0;n<i;n++)for(let s=0;s<o;s++){let i=e.get(n,s);if(i<0)throw Error("Input x must be non-negative!");i>=r||(a?l.set(1,n,i):t.size>0?l.set(l.get(n,i)+t.get(n,s),n,i):l.set(l.get(n,i)+1,n,i))}return l}},48374:(e,t,r)=>{"use strict";r.d(t,{VM:()=>l,lg:()=>i});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>+(e>=t)),o=(0,s.j)(n.lLS,i,null,"bool"),l={kernelName:n.lLS,backendName:"cpu",kernelFunc:o}},48671:(e,t,r)=>{"use strict";r.d(t,{BC:()=>d,IU:()=>p,Kx:()=>u,Uc:()=>c,tB:()=>l,uM:()=>i,uU:()=>o});var n=r(81538),a=r(95971);let s=new Map;function i(e){(0,a.E6)(n.To,"DataFormat",e)}function o(e){(0,a.E6)(n.ft,"InterpolationFormat",e)}function l(e){(0,a.E6)(n.EY,"PaddingMode",e)}function u(e){(0,a.E6)(n.bb,"PoolMode",e)}let h=[];function p(e,t){h.push(e);try{let e=t();return h.pop(),e}catch(e){throw h.pop(),e}}function d(e){if(!m(e))throw Error("Not a valid tensor name: '"+e+"'");return(0===h.length?"":h.join("/")+"/")+e}function c(e){if(!m(e))throw Error("Not a valid tensor name: '"+e+"'");s.has(e)||s.set(e,0);let t=s.get(e);if(s.set(e,s.get(e)+1),!(t>0))return e;{let r=`${e}_${t}`;return s.set(r,1),r}}let f=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function m(e){return!!e.match(f)}},49335:(e,t,r)=>{"use strict";r.d(t,{AC:()=>l,oN:()=>o,sG:()=>i});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)(e=>Math.exp(e)),o=(0,s.F)(n.ox3,i,"float32"),l={kernelName:n.ox3,backendName:"cpu",kernelFunc:o}},50186:(e,t,r)=>{"use strict";function n(e){let t=0;for(let r of e)0===r.shape.length?t+=1:t+=r.shape.reduce((e,t)=>e*t);return t}r.d(t,{Y:()=>n})},50206:(e,t,r)=>{"use strict";r.d(t,{K:()=>l});var n=r(45720),a=n.C0T.RowPartitionType;class s{constructor(e,t,r,a,s,i,o,l,u,h){this.shape=e,this.shapeShape=t,this.values=r,this.valuesShape=a,this.valuesDType=s,this.defaultValue=i,this.defaultValueShape=o,this.rowPartitionValues=l,this.rowPartitionValuesShapes=u,this.rowPartitionTypes=n.C0T.getRowPartitionTypesHelper(h),this.raggedRank=n.C0T.getRaggedRank(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===a.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===a.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){let t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case a.VALUE_ROWIDS:return s.getMaxWidthValueRowID(t);case a.ROW_SPLITS:return s.getMaxWidthRowSplit(t);default:throw Error(`Cannot handle partition type ${a[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){let t=e.length;if(0===t||1===t)return 0;let r=0;for(let n=0;n<t-1;++n){let t=e[n+1]-e[n];t>r&&(r=t)}return r}static getMaxWidthValueRowID(e){let t=e.length;if(0===t)return 0;let r=0,n=e[0],a=0;for(let s=1;s<t;++s){let t=e[s];t!==n&&(n=t,a=Math.max(s-r,a),r=s)}return Math.max(t-r,a)}tensorShapeFromTensor(e,t,r=!0){if(0===t.length){if(-1===e[0])return[];throw Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return o(e,r)}calculateOutputSize(e){let t=this.valuesShape,r=this.defaultValueShape;n.C0T.validateDefaultValueShape(r,t);let a=this.tensorShapeFromTensor(this.shape,this.shapeShape),s=n.C0T.comb
288ineRaggedTensorToTensorShapes(this.raggedRank,a,t);s[0]<0&&(s[0]=e);for(let e=1;e<=this.raggedRank;++e)s[e]<0&&(s[e]=this.getMaxWidth(e));return s}calculateFirstParentOutputIndex(e,t,r){let a=Math.min(e,r),s=[],i=0;for(let e=0;e<a;++e,i+=t)s.push(i);for(let t=a;t<e;++t)s.push(-1);return n.ZSL.assert(s.length===e,()=>"Final length of result must be equal to firstDimension."),s}calculateOutputIndexRowSplit(e,t,r,n){let a=e.length,s=[];for(let i=0;i<a-1;++i){let a=e[i+1]-e[i],o=Math.min(n,a),l=t[i];-1===l&&(o=0);for(let e=0;e<o;++e)s.push(l),l+=r;for(let e=0;e<a-o;++e)s.push(-1)}if(a>0&&s.length!==e[a-1])throw Error("Invalid row split size.");return s}calculateOutputIndexValueRowID(e,t,r,n){let a=e.length,s=[];if(0===a)return[];let i=0,o=e[0];if(o>=t.length)throw Error(`Got currentValueRowId=${o}, which is not less than ${t.length}`);let l=t[o];s.push(l);for(let u=1;u<a;++u){let a=e[u];if(a===o)l>=0&&(++i<n?l+=r:l=-1);else{if(i=0,o=a,a>=t.length)throw Error(`Got nextValueRowId=${a} which is not less than ${t.length}`);l=t[a]}s.push(l)}if(s.length!==e.length)throw Error("Invalid row ids.");return s}calculateOutputIndex(e,t,r,n){let s=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case a.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(s,t,r,n);case a.ROW_SPLITS:if(s.length-1>t.length)throw Error(`Row partition size is greater than output size: ${s.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(s,t,r,n);default:throw Error(`Unsupported partition type: ${a[i]}`)}}getFirstDimensionSize(){let e=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw Error("No row_partition_types given.");let t=this.rowPartitionTypes[0];switch(t){case a.FIRST_DIM_SIZE:return e[0];case a.VALUE_ROWIDS:throw Error("Cannot handle VALUE_ROWIDS in first dimension.");case a.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw Error(`Cannot handle type ${a[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw Error("Invalid first partition input. Tensor requires at least one element.");let e=this.getFirstDimensionSize(),t=this.calculateOutputSize(e),r=Array(this.raggedRank+1);r[r.length-1]=1;for(let e=r.length-2;e>=0;--e)r[e]=r[e+1]*t[e+1];let a=o(t,!1),s=n.ZSL.getArrayFromDType(this.valuesDType,n.ZSL.sizeFromShape(a));if(r[0]*t[0]>0){let n=this.calculateFirstParentOutputIndex(e,r[0],t[0]);for(let e=1;e<=this.raggedRank;++e)n=this.calculateOutputIndex(e-1,n,r[e],t[e]);this.setOutput(this.raggedRank,n,s,a)}return[a,s]}setOutput(e,t,r,a){if(0===r.length)return;let s=this.values,o=a.slice();o=o.slice(e+1);let l=n.ZSL.sizeFromShape(o),u=t.length,h=this.defaultValue;if(h.length!==l&&1!==h.length){let e=this.defaultValueShape;(0,n.DZQ)(()=>{let t=(0,n.tQQ)(h,e);h=(0,n.hOW)(t,o).dataSync()})}let p=0,d=0,c=0;for(let e=0;e<=u;++e){let n=e<u?t[e]:-1;if(n===c){++c;continue}if(d<c){let e=s.subarray(p*l);i(r.subarray(d*l),e,(c-d)*l)}if(e>=u&&(n=Math.floor(r.length/l)),n>c)if(1===this.defaultValue.length)r.subarray(c*l,n*l).fill(this.defaultValue[0]),c=n;else for(;n>c;)i(r.slice(c*l),h,l),++c;n<0?(p=e+1,d=c):(p=e,c=(d=c)+1)}}}function i(e,t,r){for(let n=0;n<r;n++)e[n]=t[n]}function o(e,t){let r=[];for(let n of e){if(n<0){if(!t)throw Error(`Dimension ${n} must be >= 0`);if(n<-1)throw Error(`Dimension ${n} must be >= -1`);n=-1}r.push(n)}return r}function l(e,t,r,n,a,i,o,l,u,h){return new s(e,t,r,n,a,i,o,l,u,h).compute()}},51417:e=>{e.exports=r;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function r(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function n(e){return!0===(e&&e.__isLong__)}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=n;var a={},s={};function i(e,t){var r,n,i;if(t)return(e>>>=0,(i=0<=e&&e<256)&&(n=s[e]))?n:(r=l(e,(0|e)<0?-1:0,!0),i&&(s[e]=r),r);return(e|=0,(i=-128<=e&&e<128)&&(n=a[e]))?n:(r=l(e,e<0?-1:0,!1),i&&(a[e]=r),r)}function o(e,t){if(isNaN(e))return t?y:g;if(t){if(e<0)return y;if(e>=c)return T}else{if(e<=-f)return S;if(e+1>=f)return w}return e<0?o(-e,t).neg():l(e%d|0,e/d|0,t)}function l(e,t,n){return new r(e,t,n)}r.fromInt=i,r.fromNumber=o,r.fromBits=l;var u=Math.pow;function h(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||36<r)throw RangeError("radix");if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return h(e.substring(1),t,r).neg();for(var n,a=o(u(r,8)),s=g,i=0;i<e.length;i+=8){var l=Math.min(8,e.length-i),p=parseInt(e.substring(i,i+l),r);if(l<8){var d=o(u(r,l));s=s.mul(d).add(o(p))}else s=(s=s.mul(a)).add(o(p))}return s.unsigned=t,s}function p(e,t){return"number"==typeof e?o(e,t):"string"==typeof e?h(e,t):l(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}r.fromString=h,r.fromValue=p;var d=0x100000000,c=0xffffffffffffffff,f=0x8000000000000000,m=i(0x1000000),g=i(0);r.ZERO=g;var y=i(0,!0);r.UZERO=y;var b=i(1);r.ONE=b;var x=i(1,!0);r.UONE=x;var v=i(-1);r.NEG_ONE=v;var w=l(-1,0x7fffffff,!1);r.MAX_VALUE=w;var T=l(-1,-1,!0);r.MAX_UNSIGNED_VALUE=T;var S=l(0,-0x80000000,!1);r.MIN_VALUE=S;var N=r.prototype;N.toInt=function(){return this.unsigned?this.low>>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},N.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(!this.eq(S))return"-"+this.neg().toString(e);else{var t=o(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}for(var a=o(u(e,6),this.unsigned),s=this,i="";;
288){var l=s.div(a),h=(s.sub(l.mul(a)).toInt()>>>0).toString(e);if((s=l).isZero())return h+i;for(;h.length<6;)h="0"+h;i=""+h+i}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(S)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&(e&1<<t)==0;t--);return 0!=this.high?t+33:t+1},N.isZero=function(){return 0===this.high&&0===this.low},N.eqz=N.isZero,N.isNegative=function(){return!this.unsigned&&this.high<0},N.isPositive=function(){return this.unsigned||this.high>=0},N.isOdd=function(){return(1&this.low)==1},N.isEven=function(){return(1&this.low)==0},N.equals=function(e){return n(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},N.eq=N.equals,N.notEquals=function(e){return!this.eq(e)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(e){return 0>this.comp(e)},N.lt=N.lessThan,N.lessThanOrEqual=function(e){return 0>=this.comp(e)},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(e){return this.comp(e)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(e){return this.comp(e)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.compare=function(e){if(n(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(S)?S:this.not().add(b)},N.neg=N.negate,N.add=function(e){n(e)||(e=p(e));var t,r,a=this.high>>>16,s=65535&this.high,i=this.low>>>16,o=65535&this.low,u=e.high>>>16,h=65535&e.high,d=e.low>>>16,c=65535&e.low,f=0,m=0;return t=0+((r=0+(o+c))>>>16),r&=65535,t+=i+d,m+=t>>>16,t&=65535,m+=s+h,f+=m>>>16,m&=65535,f+=a+u,l(t<<16|r,(f&=65535)<<16|m,this.unsigned)},N.subtract=function(e){return n(e)||(e=p(e)),this.add(e.neg())},N.sub=N.subtract,N.multiply=function(e){if(this.isZero())return g;if(n(e)||(e=p(e)),t)return l(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(S))return e.isOdd()?S:g;if(e.eq(S))return this.isOdd()?S:g;if(this.isNegative())if(e.isNegative())return this.neg().mul(e.neg());else return this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(m)&&e.lt(m))return o(this.toNumber()*e.toNumber(),this.unsigned);var r,a,s=this.high>>>16,i=65535&this.high,u=this.low>>>16,h=65535&this.low,d=e.high>>>16,c=65535&e.high,f=e.low>>>16,y=65535&e.low,b=0,x=0;return r=0+((a=0+h*y)>>>16),a&=65535,r+=u*y,x+=r>>>16,r&=65535,r+=h*f,x+=r>>>16,r&=65535,x+=i*y,b+=x>>>16,x&=65535,x+=u*f,b+=x>>>16,x&=65535,x+=h*c,b+=x>>>16,x&=65535,b+=s*y+i*f+u*c+h*d,l(r<<16|a,(b&=65535)<<16|x,this.unsigned)},N.mul=N.multiply,N.divide=function(e){if(n(e)||(e=p(e)),e.isZero())throw Error("division by zero");if(t){var r,a,s;return this.unsigned||-0x80000000!==this.high||-1!==e.low||-1!==e.high?l((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this}if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return y;if(e.gt(this.shru(1)))return x;s=y}else{if(this.eq(S))if(e.eq(b)||e.eq(v))return S;else return e.eq(S)?b:(r=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?b:v:(a=this.sub(e.mul(r)),s=r.add(a.div(e)));if(e.eq(S))return this.unsigned?y:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=g}for(a=this;a.gte(e);){for(var i=Math.ceil(Math.log(r=Math.max(1,Math.floor(a.toNumber()/e.toNumber())))/Math.LN2),h=i<=48?1:u(2,i-48),d=o(r),c=d.mul(e);c.isNegative()||c.gt(a);)r-=h,c=(d=o(r,this.unsigned)).mul(e);d.isZero()&&(d=b),s=s.add(d),a=a.sub(c)}return s},N.div=N.divide,N.modulo=function(e){return(n(e)||(e=p(e)),t)?l((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return l(~this.low,~this.high,this.unsigned)},N.and=function(e){return n(e)||(e=p(e)),l(this.low&e.low,this.high&e.high,this.unsigned)},N.or=function(e){return n(e)||(e=p(e)),l(this.low|e.low,this.high|e.high,this.unsigned)},N.xor=function(e){return n(e)||(e=p(e)),l(this.low^e.low,this.high^e.high,this.unsigned)},N.shiftLeft=function(e){return(n(e)&&(e=e.toInt()),0==(e&=63))?this:e<32?l(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):l(0,this.low<<e-32,this.unsigned)},N.shl=N.shiftLeft,N.shiftRight=function(e){return(n(e)&&(e=e.toInt()),0==(e&=63))?this:e<32?l(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):l(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?l(this.low>>>e|t<<32-e,t>>>e,this.unsigned):32===e?l(t,0,this.unsigned):l(t>>>e-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},N.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},N.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},N.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},r.fromBytes=function(e,t,n){return n?r.fromBytesLE(e,t):r.fromBytesBE(e,t)},r.fromBytesLE=function(e,t){return new r(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},r.fromBytesBE=function(e,t){return new r(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},51781:(e,t,r)=>{"use strict";r.d(t,{NH:()=>m,P:()=>d,X0:()=>f,b0:()=>p,rF:()=>g,vD:()=>c});
288var n=r(45720),a=r(31479),s=r(40838),i=r(2748),o=r(63537),l=r(42290),u=r(76915),h=r(21131);class p extends i.Wd{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e&&(this.maxValue=e.maxValue)}call(e,t){e=(0,h.un)(e);let r=(0,n.VVh)(e);return null!=this.maxValue&&(r=(0,n.zQh)(r,0,this.maxValue)),r}computeOutputShape(e){return e}getConfig(){let e={maxValue:this.maxValue};return Object.assign(e,super.getConfig()),e}}p.className="ReLU",n.JFn.registerClass(p);class d extends i.Wd{constructor(e){super(null==e?{}:e),this.DEFAULT_ALPHA=.3,null==e&&(e={}),this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){let r=(0,h.un)(e);return(0,n.H8d)(r,this.alpha)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha};return Object.assign(e,super.getConfig()),e}}d.className="LeakyReLU",n.JFn.registerClass(d);class c extends i.Wd{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),this.supportsMasking=!0,this.alphaInitializer=(0,l.Fe)(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=(0,u.Bm)(e.alphaRegularizer),this.alphaConstraint=(0,s.YZ)(e.alphaConstraint),null==e.sharedAxes)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else if("number"==typeof e.sharedAxes)this.sharedAxes=[e.sharedAxes];else throw new o.Qp(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){let t=(e=(0,h.U$)(e)).slice(1);if(null!=this.sharedAxes)for(let e of this.sharedAxes)t[e-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);let r={};if(null!=this.sharedAxes)for(let t=1;t<e.length;++t)r[t]=e[t];this.inputSpec=[new i.eO({ndim:e.length,axes:r})],this.built=!0}call(e,t){return e=(0,h.un)(e),(0,n.NsG)(e,this.alpha.read())}getConfig(){let e={alphaInitializer:(0,l.zo)(this.alphaInitializer),alphaRegularizer:(0,u.R9)(this.alphaRegularizer),alphaConstraint:(0,s.uH)(this.alphaConstraint),sharedAxes:this.sharedAxes};return Object.assign(e,super.getConfig()),e}}c.className="PReLU",n.JFn.registerClass(c);class f extends i.Wd{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA=1,null==e&&(e={}),null!=e.alpha&&e.alpha!==this.DEFAULT_ALPHA)throw new o.EH(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`);this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){let r=(0,h.un)(e);return(0,n.Pqc)(r)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha};return Object.assign(e,super.getConfig()),e}}f.className="ELU",n.JFn.registerClass(f);class m extends i.Wd{constructor(e){super(null==e?{}:e),this.DEFAULT_THETA=1,null==e&&(e={}),this.theta=null==e.theta?this.DEFAULT_THETA:e.theta}call(e,t){let r=(0,h.un)(e);return(0,n.lKK)(r,(0,n.wgE)((0,n.rhj)(r,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){let e={theta:this.theta};return Object.assign(e,super.getConfig()),e}}m.className="ThresholdedReLU",n.JFn.registerClass(m);class g extends i.Wd{constructor(e){super(null==e?{}:e),this.DEFAULT_AXIS=1,null==e&&(e={}),this.softmax=new a.rF().apply,this.axis=null==e.axis?this.DEFAULT_AXIS:e.axis}call(e,t){return(0,n.DZQ)(()=>{let r=(0,h.un)(e),a=t.mask;if(null!=a){let e=(0,n.lKK)((0,n.jbE)((0,n.SaS)(r.shape),(0,n.wgE)(a,r.dtype)),(0,n.d_2)(-1e9));r=(0,n.WQq)(r,e)}if(this.axis instanceof Array)if(this.axis.length>1)return(0,n.oNF)((0,n.jbE)(r,(0,n.VZ)(r,this.axis,!0)));else return this.softmax(r,this.axis[0]);return this.softmax(r,this.axis)})}computeOutputShape(e){return e}getConfig(){let e={axis:this.axis};return Object.assign(e,super.getConfig()),e}}g.className="Softmax",n.JFn.registerClass(g)},51855:(e,t,r)=>{"use strict";r.d(t,{K:()=>u});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(18875),l=r(86036);let u=(0,o.op)({localResponseNormalization_:function(e,t=5,r=1,o=1,u=.5){let h=(0,s.YT)(e,"x","localResponseNormalization");i.vA(4===h.rank||3===h.rank,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got 289 rank ${h.rank}.`),i.vA(i.E6(t),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);let p=h,d=!1;3===h.rank&&(d=!0,p=(0,l.t)(h,[1,h.shape[0],h.shape[1],h.shape[2]]));let c={x:p},f=n.T2.runKernel(a.jM4,c,{depthRadius:t,bias:r,alpha:o,beta:u});return d?(0,l.t)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}})},51874:(e,t,r)=>{"use strict";r.d(t,{AQ:()=>w,CY:()=>d,Ej:()=>k,P8:()=>T,Rl:()=>N,Xf:()=>C,aG:()=>p,jf:()=>v,l3:()=>x,oR:()=>I,s5:()=>g,zV:()=>S});var n=r(47802),a=r(40091),s=r(75681),i=r(91941),o=r(89972),l=r(13649),u=r(67984),h=r(15376).Buffer;async function p(e,t){let r=[],n=[],a=Array.isArray(e)?e.map(e=>e.name):Object.keys(e);for(let s=0;s<a.length;++s){let i=a[s],o=Array.isArray(e)?e[s].tensor:e[i];if("float32"!==o.dtype&&"int32"!==o.dtype&&"bool"!==o.dtype&&"string"!==o.dtype&&"complex64"!==o.dtype)throw Error(`Unsupported dtype in weight '${i}': ${o.dtype}`);
289let l={name:i,shape:o.shape,dtype:o.dtype};if("string"===o.dtype){let e=new Promise(async e=>{let t=await o.bytes(),r=new Uint8Array(t.reduce((e,t)=>e+t.length,0)+4*t.length),n=0;for(let e=0;e<t.length;e++){let a=t[e],s=new Uint8Array(new Uint32Array([a.length]).buffer);r.set(s,n),n+=4,r.set(a,n),n+=a.length}e(r)});n.push(e)}else n.push(o.data());null!=t&&(l.group=t),r.push(l)}return{data:function(e){if(null===e)throw Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0,r=[];e.forEach(e=>{if(t+=e.byteLength,r.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)});let n=new Uint8Array(t),a=0;return r.forEach(e=>{n.set(new Uint8Array(e.buffer),a),a+=e.byteLength}),n.buffer}(await Promise.all(n)),specs:r}}function d(e,t){let r=new o.D(e),n={},a=0;for(let e of t){let t=function(e,t){let r,n=(0,s.Ze)(e.shape);if("quantization"in e){let t=e.quantization;r=i.i[t.dtype]}else if("string"===e.dtype){let e=0;for(let r=0;r<n;r++)e+=4+new Uint32Array(t(e,e+4))[0];return e}else r=i.i[e.dtype];return n*r}(e,(e,t)=>r.slice(a+e,a+t));n[e.name]=f(e,r.slice(a,a+t)),a+=t}return n}async function c(e,t){let r,n=(0,s.Ze)(e.shape);if("quantization"in e){let t=e.quantization;r=i.i[t.dtype]}else if("string"===e.dtype){let e=0;for(let r=0;r<n;r++)e+=4+new Uint32Array(await t(e,e+4))[0];return e}else r=i.i[e.dtype];return n*r}function f(e,t){let r,o=e.name,l=e.dtype,u=e.shape,h=(0,s.Ze)(u),p=0;if("quantization"in e){let n=e.quantization;if("uint8"===n.dtype||"uint16"===n.dtype){if(!("min"in n&&"scale"in n))throw Error(`Weight ${e.name} with quantization ${n.dtype} doesn't have corresponding metadata min and scale.`)}else if("float16"===n.dtype){if("float32"!==l)throw Error(`Weight ${e.name} is quantized with ${n.dtype} which only supports weights of type float32 not ${l}.`)}else throw Error(`Weight ${e.name} has unknown quantization dtype ${n.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);let a=i.i[n.dtype],s="uint8"===n.dtype?new Uint8Array(t):new Uint16Array(t);if("float32"===l)if("uint8"===n.dtype||"uint16"===n.dtype){r=new Float32Array(s.length);for(let e=0;e<s.length;e++){let t=s[e];r[e]=t*n.scale+n.min}}else if("float16"===n.dtype)r=(function(){let e=function(){let e=e=>{let t=e<<13,r=0;for(;(8388608&t)==0;)r-=8388608,t<<=1;return(t&=-8388609)|(r+=0x38800000)},t=new Uint32Array(2048);t[0]=0;for(let r=1;r<1024;r++)t[r]=e(r);for(let e=1024;e<2048;e++)t[e]=0x38000000+(e-1024<<13);return t}(),t=function(){let e=new Uint32Array(64);e[0]=0,e[31]=0x47800000,e[32]=0x80000000,e[63]=0xc7800000;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=0x80000000+(t-32<<23);return e}(),r=function(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return n=>{let a=new ArrayBuffer(4*n.length),s=new Uint32Array(a);for(let a=0;a<n.length;a++){let i=n[a],o=e[r[i>>10]+(1023&i)]+t[i>>10];s[a]=o}return new Float32Array(a)}})()(s);else throw Error(`Unsupported quantization type ${n.dtype} for weight type float32.`);else if("int32"===l){if("uint8"!==n.dtype&&"uint16"!==n.dtype)throw Error(`Unsupported quantization type ${n.dtype} for weight type int32.`);r=new Int32Array(s.length);for(let e=0;e<s.length;e++){let t=s[e];r[e]=Math.round(t*n.scale+n.min)}}else throw Error(`Unsupported dtype in weight '${o}': ${l}`);p+=h*a}else if("string"===l){let n=(0,s.Ze)(e.shape);r=[];for(let e=0;e<n;e++){let e=new Uint32Array(t.slice(p,p+4))[0];p+=4;let n=new Uint8Array(t.slice(p,p+e));r.push(n),p+=e}}else{let e=i.i[l];if("float32"===l)r=new Float32Array(t);else if("int32"===l)r=new Int32Array(t);else if("bool"===l)r=new Uint8Array(t);else if("complex64"===l){r=new Float32Array(t);let e=new Float32Array(r.length/2),s=new Float32Array(r.length/2);for(let t=0;t<e.length;t++)e[t]=r[2*t],s[t]=r[2*t+1];let i=(0,a.O)(e,u,"float32"),o=(0,a.O)(s,u,"float32"),l=(0,n.f)(i,o);return i.dispose(),o.dispose(),l}else throw Error(`Unsupported dtype in weight '${o}': ${l}`);p+=h*e}return(0,a.O)(r,u,l)}async function m(e,t,r){let n=new Uint8Array(t);for(;n.byteLength<r;){let{done:t,value:a}=await e.read();if(t&&null==a){let e=r-n.byteLength;throw Error(`Reader is done but ${e} bytes are still expected`)}let s=new Uint8Array(n.length+a.byteLength);s.set(n,0),s.set(new Uint8Array(a),n.length),n=s}return n.buffer}async function g(e,t){let r={},n=e.getReader(),a=new ArrayBuffer(0);for(let e of t){let t=await c(e,async(e,t)=>(a=await m(n,a,t)).slice(e,t)),i=(a=await m(n,a,t)).slice(0,t);a=a.slice(t);let o=f(e,i);if(r[e.name]=o,"webgpu"===(0,l.jz)()){let e=(0,l.Hs)();"uploadToGPU"in e&&(0,s.Ze)(o.shape)>=(0,u._K)().get("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD")&&e.uploadToGPU(o.dataId)}}return r}let y=void 0!==h&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function b(e){return y?h.byteLength(e,"utf8"):new Blob([e]).size}function x(e){if(y)return h.from(e).toString("base64");let t=new Uint8Array(e),r="";for(let e=0,n=t.length;e<n;e++)r+=String.fromCharCode(t[e]);return btoa(r)}function v(e){if(y){let t=h.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r.set([t.charCodeAt(e)],e);return r.buffer}function w(e){return o.D.join(e)}function T(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);let t=e.split("/");return t[t.length-1]}function S(e,t){let r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(r.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(r.trainingConfig=e.trainingConfig),r}function N(e,t,r){let n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw Error("modelJSON has weightsManifest but weightSpecs is null");if(!r)throw Error("modelJSON has weightsManifest but weightData is null");n.weightSpecs=t,n.weightData=r}return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(n.initializerSignature=e.initializerSignature),n}async function k(e,t){let r,n;return null!=e.weightsManifest&&([r,n]=await t(e.weightsManifest)),N(e,r,n)}function I(e){if(e.modelTopology instanceof ArrayBuffer)throw Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:b(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:b(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new o.D(e.weightData).byteLength}}function C(e){let t=[];for(let r of e)t.push(...r.weights);return t}},51982:(e,t,r)=>{"use strict";r.d(t,{Zl:()=>u,dl:()=>i,jb:()=>l});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>e-t),o=(0,s.B)((e,t,r,n)=>({real:e-r,imag:t-n})),l=(0,s.j)(n.PbM,i,o),u={kernelName:n.PbM,backendName:"cpu",kernelFunc:l}},52310:(e,t,r)=>{"use strict";r.d(t,{Fu:()=>l,x6:()=>i});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)(e=>Math.sqrt(e)),o=(0,s.v)(n.dFH,e=>Math.sqrt(e)),l={kernelName:n.dFH,backendName:"cpu",kernelFunc:o}},52326:(e,t,r)=>{"use strict";r.d(t,{M5:()=>i,tP:()=>s,zO:()=>a});var n=r(45720);function a(e,t){var r="classWeight";let n=t.length;if(null==e||Array.isArray(e)&&0===e.length)return t.map(e=>null);if(1===n)if(Array.isArray(e)&&1===e.length)return e;else if("object"==typeof e&&t[0]in e)return[e[t[0]]];else return[e];if(Array.isArray(e)){if(e.length!==n)throw Error(`Provided ${r} is an array of ${e.length} element(s), but the model has ${n} outputs. Make sure a set of weights is provided for each model output.`);return e}if("object"==typeof e&&Object.keys(e).length>0&&"object"==typeof e[Object.keys(e)[0]]){let r=[];return t.forEach(t=>{t in e?r.push(e[t]):r.push(null)}),r}throw Error(`The model has multiple (${n}) outputs, so ${r} must be either an array with ${n} elements or an object with ${t} keys. Provided ${r} not understood: ${JSON.stringify(e)}`)}async function s(e,t,r,a){if(null!=t||null!=a)throw Error("Support sampleWeight is not implemented yet");if(null==r)return null;{let t=(0,n.DZQ)(()=>
289{if(1===e.shape.length)return(0,n.o8B)(e);if(2===e.shape.length)if(e.shape[1]>1)return(0,n.FLi)(e,1);else if(1===e.shape[1])return(0,n.tQQ)(e,[e.shape[0]]);else throw Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`);throw Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),a=Array.from(await t.data());(0,n.ASo)(t);let s=[];return a.forEach(e=>{if(null==r[e])throw Error(`classWeight must contain all classes in the training data. The class ${e} exists in the data but not in classWeight`);s.push(r[e])}),(0,n.tGX)(s,"float32")}}function i(e,t){return(0,n.lKK)(e,t)}},52585:(e,t,r)=>{"use strict";r.d(t,{V2:()=>f,ai:()=>m});var n=r(45720),a=r(40693),s=r(48671),i=r(2748),o=r(63537),l=r(81538),u=r(95971),h=r(21131),p=r(35721),d=r(12223);class c extends i.Wd{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(e){null!=this.layer&&(this.layer.trainable=e)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(e){this.layer.setWeights(e)}getConfig(){let e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}};return Object.assign(e,super.getConfig()),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,r={}){let n=t.layer,a=(0,d.i)(n,r);delete t.layer;let s={layer:a};return Object.assign(s,t),new e(s)}}class f extends c{constructor(e){super(e),this.supportsMasking=!0}build(e){if((e=(0,h.U$)(e)).length<3)throw new o.Qp(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];let t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),super.build(e)}computeOutputShape(e){let t=[(e=(0,h.U$)(e))[0]].concat(e.slice(2)),r=this.layer.computeOutputShape(t),n=e[1];return[r[0],n].concat(r.slice(1))}call(e,t){return(0,n.DZQ)(()=>{e=(0,h.un)(e);let r=(e,r)=>[(0,h.un)(this.layer.call(e,t)),[]];return(0,p.L7)(r,e,[],!1,null,null,!1,!0)[1]})}}f.className="TimeDistributed",n.JFn.registerClass(f);class m extends c{constructor(e){var t;super(e);let r=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=r,this.forwardLayer=(0,d.i)(n),r.goBackwards=!0!==r.goBackwards;let a={};if(a.className=e.layer.getClassName(),a.config=r,this.backwardLayer=(0,d.i)(a),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===e.mergeMode?"concat":e.mergeMode,t=this.mergeMode,u.E6(l.r$,"BidirectionalMergeMode",t),e.weights)throw new o.EH("weights support is not implemented for Bidirectional layer yet.");this._stateful=e.layer.stateful,this.returnSequences=e.layer.returnSequences,this.returnState=e.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=e.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(e){this._trainable=e,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){let t=Math.floor(e.length/2);this.forwardLayer.setWeights(e.slice(0,t)),this.backwardLayer.setWeights(e.slice(t))}computeOutputShape(e){let t,r,n,a=this.forwardLayer.computeOutputShape(e);return(Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),this.returnState&&(n=a.slice(1)),t=a[0],"concat"===this.mergeMode?(t[t.length-1]*=2,r=[t]):r=null==this.mergeMode?[t,t.slice()]:[t],this.returnState)?null==this.mergeMode?r.concat(n).concat(n.slice()):[t].concat(n).concat(n.slice()):u.wL(r)}apply(e,t){let r=null==t?null:t.initialState,n=null==t?null:t.constants;null==t&&(t={});let a=(0,p.tL)(e,r,n,this.numConstants);if(e=a.inputs,r=a.initialState,n=a.constants,Array.isArray(e)&&(r=e.slice(1),e=e[0]),(null==r||0===r.length)&&null==n)return super.apply(e,t);let s=[],l=[];
289if(null!=r){let e=r.length;if(e%2>0)throw new o.Qp("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=r,s.push(...r);let n=r.map(e=>new i.eO({shape:e.shape}));this.forwardLayer.stateSpec=n.slice(0,e/2),this.backwardLayer.stateSpec=n.slice(e/2),l.push(...n)}if(null!=n)throw new o.EH("Support for constants in Bidirectional layers is not implemented yet.");let u=s[0]instanceof i.Ar;for(let e of s)if(e instanceof i.Ar!==u)throw new o.Qp("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(!u)return super.apply(e,t);{let r=[e].concat(s),n=this.inputSpec.concat(l),a=this.inputSpec;this.inputSpec=n;let i=super.apply(r,t);return this.inputSpec=a,i}}call(e,t){return(0,n.DZQ)(()=>{let r,s,i,o,l=t.initialState;if(null==l)r=this.forwardLayer.call(e,t),s=this.backwardLayer.call(e,t);else{let n=l.slice(0,l.length/2),a=l.slice(l.length/2);r=this.forwardLayer.call(e,Object.assign(t,{initialState:n})),s=this.backwardLayer.call(e,Object.assign(t,{initialState:a}))}return(this.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(s.slice(1))),r=r[0],s=s[0]),this.returnSequences&&(s=n.BEg(s,1)),"concat"===this.mergeMode?o=a.u1([r,s]):"sum"===this.mergeMode?o=n.WQq(r,s):"ave"===this.mergeMode?o=n.lKK(.5,n.WQq(r,s)):"mul"===this.mergeMode?o=n.lKK(r,s):null==this.mergeMode&&(o=[r,s]),this.returnState)?null==this.mergeMode?o.concat(i):[o].concat(i):o})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){(0,s.IU)(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),(0,s.IU)(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,t){let r;if(Array.isArray(t)&&(t=t[0]),r=this.returnSequences?null==this.mergeMode?[t,t]:t:null==this.mergeMode?[null,null]:null,!this.returnState)return r;{let e=this.forwardLayer.states.map(e=>null);return Array.isArray(r)?r.concat(e).concat(e):[r].concat(e).concat(e)}}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(e),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){let e={mergeMode:this.mergeMode};return Object.assign(e,super.getConfig()),e}static fromConfig(e,t){let r=(0,d.i)(t.layer);if(delete t.layer,null!=t.numConstants)throw new o.EH("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");return t.layer=r,new e(t)}}m.className="Bidirectional",n.JFn.registerClass(m)},52829:(e,t,r)=>{"use strict";r.d(t,{k:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({gather_:function(e,t,r=0,i=0){let o=(0,s.YT)(e,"x","gather"),l=(0,s.YT)(t,"indices","gather","int32");return n.T2.runKernel(a.mxL,{x:o,indices:l},{axis:r,batchDims:i})}})},52899:(e,t,r)=>{"use strict";r.d(t,{j:()=>h});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(46866),l=r(18875),u=r(86036);let h=(0,l.op)({maxPool_:function(e,t,r,l,h){let p=(0,s.YT)(e,"x","maxPool"),d=p,c=!1;3===p.rank&&(c=!0,d=(0,u.t)(p,[1,p.shape[0],p.shape[1],p.shape[2]])),i.vA(4===d.rank,()=>`Error in maxPool: input must be rank 4 but got rank ${d.rank}.`),i.vA(o.G0(r,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '1'`),o.s_("maxPool",l,h);let f={x:d},m=n.T2.runKernel(a.t3d,f,{filterSize:t,strides:r,pad:l,dimRoundingMode:h});return c?(0,u.t)(m,[m.shape[1],m.shape[2],m.shape[3]]):m}})},52985:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this;t.next=function(){var e,r,n=t.x,a=t.i;return e=n[a],e^=e>>>7,r=e^e<<24^((e=n[a+1&7])^e>>>10)^((e=n[a+3&7])^e>>>3)^((e=n[a+4&7])^e<<7),e=n[a+7&7],e^=e<<13,r^=e^e<<9,n[a]=r,t.i=a+1&7,r};var r,n=e,a=[];if(n===(0|n))a[0]=n;else for(r=0,n=""+n;r<n.length;
289++r)a[7&r]=a[7&r]<<15^n.charCodeAt(r)+a[r+1&7]<<13;for(;a.length<8;)a.push(0);for(r=0;r<8&&0===a[r];++r);for(8==r?a[7]=-1:a[r],t.x=a,t.i=0,r=256;r>0;--r)t.next()}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function l(e,t){null==e&&(e=+new Date);var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&(n.x&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.xorshift7=l}(0,e=r.nmd(e),r.amdD)},53227:(e,t,r)=>{"use strict";r.d(t,{Fz:()=>p,GT:()=>C,I9:()=>d,Jc:()=>c,Jt:()=>I,Ol:()=>T,ZY:()=>m,qp:()=>N,qv:()=>f,xM:()=>l,yP:()=>u});var n=r(45720),a=r(40693),s=r(63537),i=r(32593),o=r(95971);function l(e,t){return(0,n.DZQ)(()=>{let r=n.lKK(.5,n.P61(t)),s=a.wg(n.rhj(t,r),e.dtype);return n.i2o(n.LCg(e,s),-1)})}function u(e,t){return(0,n.DZQ)(()=>a.wg(n.LCg(n.FLi(e,-1),n.FLi(t,-1)),"float32"))}function h(e,t){return(0,n.DZQ)(()=>n.wgE(n.czq(n.n76(n.LCg(e,1),n.LCg(t,1))),"float32"))}function p(e,t){return(0,n.DZQ)(()=>{let r=h(e,t),a=(0,n.DZQ)(()=>n.wgE(n.czq(n.n76(n.LCg(e,0),n.LCg(t,1))),"float32")),s=n.WQq(r,a);return n.wgE(n._M9(n.rhj(s,0),n.y4m(r,s),0),"float32")})}function d(e,t){return(0,n.DZQ)(()=>{let r=h(e,t),a=(0,n.DZQ)(()=>n.wgE(n.czq(n.n76(n.LCg(e,1),n.LCg(t,0))),"float32")),s=n.WQq(r,a);return n.wgE(n._M9(n.rhj(s,0),n.y4m(r,s),0),"float32")})}function c(e,t){return(0,i.Jc)(e,t)}function f(e,t){return e.rank===t.rank&&(e=n.r2V(e,[e.rank-1])),(t=n.FLi(t,-1)).dtype!==e.dtype&&(t=n.wgE(t,e.dtype)),n.wgE(n.LCg(e,t),"float32")}function m(e,t){return(0,n.DZQ)(()=>{let r=e.sub(t).square().sum(),a=e.sub(e.mean()).square().sum();return n.d_2(1).sub(r.div(a))})}let g=i.bt,y=i.bt,b=i.Xv,x=i.Xv,v=i.VW,w=i.VW,T=i.Ol,S=i.Pg,N=i.qp,k={binaryAccuracy:l,categoricalAccuracy:u,precision:p,categoricalCrossentropy:T,sparseCategoricalCrossentropy:N,mse:g,MSE:y,mae:b,MAE:x,mape:v,MAPE:w,cosine:S};function I(e){if("string"==typeof e&&e in k)return k[e];if("string"!=typeof e&&null!=e)return e;throw new s.Qp(`Unknown metric ${e}`)}function C(e){if(o.vA(null!==e,`Unknown LossOrMetricFn ${e}`),"string"==typeof e)return e;{let t;for(let r of Object.keys(i.SO))if(i.SO[r]===e){t=r;break}if(void 0!==t)return t;for(let r of Object.keys(k))if(k[r]===e){t=r;break}return void 0!==t?t:e.name}}},53553:(e,t,r)=>{"use strict";r.d(t,{WR:()=>i,YW:()=>l});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>+(e<t)),o=(0,s.j)(n.mIA,i,null,"bool"),l={kernelName:n.mIA,backendName:"cpu",kernelFunc:o}},53744:(e,t,r)=>{"use strict";r.d(t,{R:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({sqrt_:function(e){let t=(0,s.YT)(e,"x","sqrt","float32");return n.T2.runKernel(a.dFH,{x:t})}})},53784:(e,t,r)=>{"use strict";r.d(t,{r:()=>l});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990);let l=(0,r(18875).op)({greater_:function(e,t){let r=(0,i.YT)(e,"a","greater","string_or_numeric"),l=(0,i.YT)(t,"b","greater","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.XhZ,u)}})},54203:(e,t,r)=>{"use strict";r.d(t,{s:()=>d});var n=r(45720),a=r(40693),s=r(40838),i=r(2748),o=r(63537),l=r(42290),u=r(76915),h=r(95971),p=r(21131);class d extends i.Wd{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){let t=null;null!=e.batchSize&&(t=e.batchSize),null==e.inputLength?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(h.st(e.inputLength))}this.inputDim=e.inputDim,h.oo(this.inputDim,"inputDim"),this.outputDim=e.outputDim,h.oo(this.outputDim,"outputDim"),this.embeddingsInitializer=(0,l.Fe)(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=(0,u.Bm)(e.embeddingsRegularizer),this.activityRegularizer=(0,u.Bm)(e.activityRegularizer),this.embeddingsConstraint=(0,s.YZ)(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return(0,n.DZQ)(()=>this.maskZero?(e=(0,p.un)(e),(0,n.Ec)(e,(0,n.POl)(e))):null)}computeOutputShape(e){if(e=(0,p.U$)(e),null==this.inputLength)return[...e,this.outputDim];let t=h.st(this.inputLength);if(t.length!==e.length-1)throw new o.Qp(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let r=0;for(let n=0;n<t.length;++n){let a=t[n],s=e[n+1];if(null!=a&&null!=s&&a!==s)throw new o.Qp(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);null==a&&(t[r]=s),r++}}return[e[0],...t,this.outputDim]}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,p.un)(e);"int32"!==r.dtype&&(r=a.wg(r,"int32"));let s=a.kg(this.embeddings.read(),(0,n.tQQ)(r,[r.size]));return(0,n.tQQ)(s,(0,p.U$)(this.computeOutputShape(r.shape)))})}
289getConfig(){let e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:(0,l.zo)(this.embeddingsInitializer),embeddingsRegularizer:(0,u.R9)(this.embeddingsRegularizer),activityRegularizer:(0,u.R9)(this.activityRegularizer),embeddingsConstraint:(0,s.uH)(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength};return Object.assign(e,super.getConfig()),e}}d.className="Embedding",n.JFn.registerClass(d)},54256:(e,t,r)=>{"use strict";r.d(t,{l:()=>o});var n=r(5287),a=r(96609),s=r(72155),i=r(54463);let o=(0,r(18875).op)({mul_:function(e,t){let r=(0,i.YT)(e,"a","mul"),o=(0,i.YT)(t,"b","mul");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.xu7,l)}})},54283:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({tanh_:function(e){let t=(0,s.YT)(e,"x","tanh","float32");return n.T2.runKernel(a.iuW,{x:t})}})},54402:(e,t,r)=>{"use strict";r.d(t,{l:()=>o});var n=r(5287),a=r(96609),s=r(18875),i=r(86036);let o=(0,s.op)({depthwiseConv2dNativeBackpropInput_:function(e,t,r,s,o,l=[1,1],u){let h=t,p=!1;3===t.rank&&(p=!0,h=(0,i.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let d={dy:h,filter:r},c=n.T2.runKernel(a.nVu,d,{strides:s,pad:o,dimRoundingMode:u,dilations:l,inputShape:e});return p?(0,i.t)(c,[c.shape[1],c.shape[2],c.shape[3]]):c}})},54463:(e,t,r)=>{"use strict";r.d(t,{MZ:()=>u,YT:()=>p,j1:()=>d});var n=r(5287),a=r(67984),s=r(94708),i=r(20728),o=r(22700),l=r(75681);function u(e,t){let r=e;if((0,o.isTypedArray)(e))return"string"===t?[]:[e.length];if((0,i.Oj)(e)){let t=e.channels||"RGBA";return[e.height,e.width*t.length]}if((0,i.Nw)(e))return[e.buffer.size/(null==t?4:(0,l.jv)(t))];if(!Array.isArray(e))return[];let n=[];for(;Array.isArray(r)||(0,o.isTypedArray)(r)&&"string"!==t;)n.push(r.length),r=r[0];return Array.isArray(e)&&(0,a._K)().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function e(t,r,n){if(n=n||[],!Array.isArray(t)&&!(0,o.isTypedArray)(t))return void(0,l.vA)(0===r.length,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${r[0]} elements`);(0,l.vA)(r.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${t.length} elements`),(0,l.vA)(t.length===r[0],()=>`Element arr[${n.join("][")}] should have ${r[0]} elements, but has ${t.length} elements`);let a=r.slice(1);for(let r=0;r<t.length;++r)e(t[r],a,n.concat(r))}(e,n,[]),n}function h(e,t,r,n){if("string_or_numeric"!==e){if(null==e)throw Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw Error(`Argument '${r}' passed to '${n}' must be ${e} tensor, but got ${t} tensor`)}}function p(e,t,r,a="numeric"){if(e instanceof(0,s.tp)())return h(a,e.dtype,t,r),e;let i=(0,l.X$)(e);if("string"!==i&&["bool","int32","float32"].indexOf(a)>=0&&(i=a),h(a,i,t,r),null==e||!(0,o.isTypedArray)(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){let n=null==e?"null":e.constructor.name;throw Error(`Argument '${t}' passed to '${r}' must be a Tensor or TensorLike, but got '${n}'`)}let d=u(e,i);(0,o.isTypedArray)(e)||Array.isArray(e)||(e=[e]);let c="string"!==i?(0,o.toTypedArray)(e,i):(0,o.flatten)(e,[],!0);return n.T2.makeTensor(c,d,i)}function d(e,t,r,n="numeric"){if(!Array.isArray(e))throw Error(`Argument ${t} passed to ${r} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((e,a)=>p(e,`${t}[${a}]`,r,n))}},54574:(e,t,r)=>{"use strict";r.d(t,{G:()=>s});var n=r(45720);class a{constructor(e,t,r,a,s,i){this.separator=n.ZSL.encodeString(e),this.nGramWidths=t,this.leftPad=n.ZSL.encodeString(r),this.rightPad=n.ZSL.encodeString(a),this.padWidth=s,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){return Math.max(0,e+2*this.getPadWidth(t)-t+1)}createNGrams(e,t,r,n,a,s){for(let i=0;i<a;++i){let o,l=this.getPadWidth(s),u=Math.max(0,l-i),h=Math.max(0,l-(a-(i+1))),p=s-(u+h),d=t+(u>0?0:i-l);o=0+u*this.leftPad.length;for(let t=0;t<p;++t)o+=e[d+t].length;o+=h*this.rightPad.length,o+=(u+h+p-1)*this.separator.length,r[n+i]=new Uint8Array(o);let c=r[n+i],f=0,m=e=>
289e.forEach(e=>c[f++]=e);for(let e=0;e<u;++e)m(this.leftPad),m(this.separator);for(let t=0;t<p-1;++t)m(e[d+t]),m(this.separator);if(p>0){m(e[d+p-1]);for(let e=0;e<h;++e)m(this.separator),m(this.rightPad)}else{for(let e=0;e<h-1;++e)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(e,t){let r=e.length,a=t.length;if(a>0){let e=t[0];if(0!==e)throw Error(`First split value must be 0, got ${e}`);for(let n=1;n<a;++n){let a=t[n]>=e;if(!(a=a&&t[n]<=r))throw Error(`Invalid split value ${t[n]}, must be in [${e}, ${r}]`);e=t[n]}if(e!==r)throw Error(`Last split value must be data size. Expected ${r}, got ${e}`)}let s=a-1,i=n.ZSL.getArrayFromDType("int32",a);if(0===r||0===a){let e=Array(r);for(let e=0;e<=s;++e)i[e]=0;return[e,i]}i[0]=0;for(let e=1;e<=s;++e){let r=t[e]-t[e-1],n=0;this.nGramWidths.forEach(e=>{n+=this.getNumNGrams(r,e)}),this.preserveShort&&r>0&&0===n&&(n=1),i[e]=i[e-1]+n}let o=Array(i[s]);for(let r=0;r<s;++r){let n=t[r],a=i[r];if(this.nGramWidths.forEach(s=>{let i=t[r+1]-t[r],l=this.getNumNGrams(i,s);this.createNGrams(e,n,o,a,l,s),a+=l}),this.preserveShort&&a===i[r]){let s=t[r+1]-t[r];if(0===s)continue;let i=s+2*this.padWidth;this.createNGrams(e,n,o,a,1,i)}}return[o,i]}}function s(e,t,r,n,s,i,o,l){return new a(r,n,s,i,o,l).compute(e,t)}},54658:(e,t,r)=>{"use strict";r.d(t,{G:()=>a});var n=r(45720);function a(e,t,r){let a=(0,n.ra8)(r,e.dtype);for(let r=0;r<a.size;++r){let n=a.indexToLoc(r).slice(),s=n[0],i=n[2],o=t.locToIndex([s,i]);n[2]=t.values[o];let l=e.locToIndex(n);0<=l&&l<e.values.length&&(a.values[r]=e.values[l])}return a}},54868:(e,t,r)=>{"use strict";r.d(t,{BZ:()=>p,Eq:()=>c,H7:()=>d,J5:()=>l,dY:()=>m,g:()=>u,t6:()=>f});var n,a=r(45720),s=r(63537),i=r(61237),o=r(95971);!function(e){e[e.SILENT=0]="SILENT",e[e.VERBOSE=1]="VERBOSE"}(n||(n={}));class l{constructor(){this.validationData=null}setParams(e){this.params=e}async onEpochBegin(e,t){}async onEpochEnd(e,t){}async onBatchBegin(e,t){}async onBatchEnd(e,t){}async onTrainBegin(e){}async onTrainEnd(e){}setModel(e){}}class u{constructor(e,t=10){null==e&&(e=[]),this.callbacks=e,this.queueLength=t}append(e){this.callbacks.push(e)}setParams(e){for(let t of this.callbacks)t.setParams(e)}setModel(e){for(let t of this.callbacks)t.setModel(e)}async onEpochBegin(e,t){for(let r of(null==t&&(t={}),this.callbacks))await r.onEpochBegin(e,t)}async onEpochEnd(e,t){for(let r of(null==t&&(t={}),this.callbacks))await r.onEpochEnd(e,t)}async onBatchBegin(e,t){for(let r of(null==t&&(t={}),this.callbacks))await r.onBatchBegin(e,t)}async onBatchEnd(e,t){for(let r of(null==t&&(t={}),this.callbacks))await r.onBatchEnd(e,t)}async onTrainBegin(e){for(let t of(null==e&&(e={}),this.callbacks))await t.onTrainBegin(e)}async onTrainEnd(e){for(let t of(null==e&&(e={}),this.callbacks))await t.onTrainEnd(e)}}class h extends l{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,t){null==t&&(t={});let r=null==t.size?0:t.size;
289for(let e in this.seen+=r,t){let n=t[e];if("number"==typeof n)this.totals.hasOwnProperty(e)||(this.totals[e]=0),this.totals[e]=this.totals[e]+n*r;else{let t;e in this.totals?t=this.totals[e]:this.totals[e]=0;let s=(0,a.DZQ)(()=>(0,a.WQq)(this.totals[e],(0,a.lKK)(n,r)));this.totals[e]=s,null!=t&&t.dispose()}}}async onEpochEnd(e,t){if(null!=t)for(let e of this.params.metrics)null!=this.totals[e]&&("number"==typeof this.totals[e]?t[e]=this.totals[e]/this.seen:(0,a.DZQ)(()=>{let r=(0,a.lKK)((0,a.y4m)(1,this.seen),this.totals[e]);t[e]=r,this.totals[e].dispose(),(0,a.aCs)(t[e])}))}}class p extends l{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){for(let r in null==t&&(t={}),this.epoch.push(e),t)null==this.history[r]&&(this.history[r]=[]),this.history[r].push(t[r])}async syncData(){let e=[],t=[],r=[];for(let n in this.history){let a=this.history[n];for(let s=0;s<a.length;++s)if("number"!=typeof a[s]){let i=a[s];e.push(i.data()),t.push(n),r.push(s)}}let n=await Promise.all(e);for(let e=0;e<n.length;++e)this.history[t[e]][r[e]].dispose(),this.history[t[e]][r[e]]=n[e][0]}}class d extends l{constructor(e,t){if(super(),this.currentEpoch=0,this.nowFunc=e.nowFunc,this.nextFrameFunc=e.nextFrameFunc||a.dA1,this.yieldEvery=t||"auto","auto"===this.yieldEvery&&(this.yieldEvery=125),"never"===this.yieldEvery&&null!=e.onYield)throw Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");a.ZSL.isNumber(this.yieldEvery)&&(this.maybeWait=o.sg(this.maybeWait.bind(this),this.yieldEvery,this.nowFunc)),this.trainBegin=e.onTrainBegin,this.trainEnd=e.onTrainEnd,this.epochBegin=e.onEpochBegin,this.epochEnd=e.onEpochEnd,this.batchBegin=e.onBatchBegin,this.batchEnd=e.onBatchEnd,this.yield=e.onYield}async maybeWait(e,t,r){let n=[];null!=this.yield&&(await (0,i.I)(r),n.push(this.yield(e,t,r))),n.push(this.nextFrameFunc()),await Promise.all(n)}async onEpochBegin(e,t){this.currentEpoch=e,null!=this.epochBegin&&(await (0,i.I)(t),await this.epochBegin(e,t))}async onEpochEnd(e,t){let r=[];null!=this.epochEnd&&(await (0,i.I)(t),r.push(this.epochEnd(e,t))),"epoch"===this.yieldEvery&&r.push(this.nextFrameFunc()),await Promise.all(r)}async onBatchBegin(e,t){null!=this.batchBegin&&(await (0,i.I)(t),await this.batchBegin(e,t))}async onBatchEnd(e,t){let r=[];null!=this.batchEnd&&(await (0,i.I)(t),r.push(this.batchEnd(e,t))),"batch"===this.yieldEvery?r.push(this.nextFrameFunc()):a.ZSL.isNumber(this.yieldEvery)&&r.push(this.maybeWait(this.currentEpoch,e,t)),await Promise.all(r)}async onTrainBegin(e){null!=this.trainBegin&&(await (0,i.I)(e),await this.trainBegin(e))}async onTrainEnd(e){null!=this.trainEnd&&(await (0,i.I)(e),await this.trainEnd(e))}}function c(e,t){return(null==e&&(e={}),e instanceof l)?[e]:Array.isArray(e)&&e[0]instanceof l?e:o.st(e).map(e=>new d(e,t))}class f{constructor(){}static registerCallbackConstructor(e,t){a.ZSL.assert(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),f.checkForDuplicate(t),null==f.constructors[e]&&(f.constructors[e]=[]),f.constructors[e].push(t)}static checkForDuplicate(e){for(let t in f.constructors)f.constructors[+t].forEach(t=>{if(t===e)throw new s.Qp("Duplicate callback constructor.")})}static clear(){f.constructors={}}static createCallbacks(e){let t=[];for(let r in f.constructors){let n=+r;e>=n&&t.push(...f.constructors[n])}return t.map(e=>new e)}}function m(e,t,r,n,a,s,i,o,l){let d=new p,c=[new h,...f.createCallbacks(t)];null!=e&&c.push(...e),c.push(d);let m=new u(c);return m.setParams({epochs:r,initialEpoch:n,samples:a,steps:s,batchSize:i,verbose:t,doValidation:o,metrics:l}),{callbackList:m,history:d}}f.constructors={}},54921:(e,t,r)=>{"use strict";function n(e,t,r=!1){if(null==e||"object"!=typeof e||Object.getPrototypeOf(e)!==Object.prototype||!function e(t){if(null===t)return!0;if("object"==typeof t)if(Object.getPrototypeOf(t)===Object.prototype){for(let r of Object.keys(t))if("string"!=typeof r||!e(t[r]))return!1;return!0}else{if(!Array.isArray(t))return!1;for(let r of t)if(!e(r))return!1;return!0}{let e=typeof t;return"string"===e||"number"===e||"boolean"===e}}(e))throw Error("User-defined metadata is expected to be a JSON object, but is not.");if(r){let r=JSON.stringify(e);r.length>1048576&&console.warn(`User-defined metadata of model "${t}" is too large in size (length=${r.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`)}}r.d(t,{Yl:()=>n})},55107:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({cosh_:function(e){let t=(0,s.YT)(e,"x","cosh","float32");return n.T2.runKernel(a.MnK,{x:t})}})},55285:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=r.charCodeAt(n),t.next()}function o(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function l(e,t){var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&("object"==typeof n&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.xor128=l}(0,e=r.nmd(e),r.amdD)},55501:(e,t,r)=>{"use strict";let n;r.r(t),r.d(t,{AbortError:()=>P,default:()=>y4,getPatchesFromImage:()=>eg,getUpscaler:()=>eT});var a,s,i,o,l={};r.r(l),r.d(l,{maxNorm:()=>aN,minMaxNorm:()=>aC,nonNeg:()=>aI,unitNorm:()=>ak});var u={};
289r.r(u),r.d(u,{constant:()=>aF,glorotNormal:()=>aP,glorotUniform:()=>aM,heNormal:()=>az,heUniform:()=>aB,identity:()=>aO,leCunNormal:()=>aW,leCunUniform:()=>aV,ones:()=>a$,orthogonal:()=>aU,randomNormal:()=>a_,randomUniform:()=>aR,truncatedNormal:()=>aD,varianceScaling:()=>aL,zeros:()=>aA});var h={};r.r(h),r.d(h,{MAPE:()=>a3,MSE:()=>a5,binaryAccuracy:()=>aK,binaryCrossentropy:()=>aH,categoricalAccuracy:()=>aQ,categoricalCrossentropy:()=>aq,cosineProximity:()=>a0,mape:()=>a4,meanAbsoluteError:()=>a1,meanAbsolutePercentageError:()=>a2,meanSquaredError:()=>a6,mse:()=>a8,precision:()=>aX,r2Score:()=>a7,recall:()=>aJ,sparseCategoricalAccuracy:()=>aY});var p={};r.r(p),r.d(p,{modelFromJSON:()=>a9.U3});var d={};r.r(d),r.d(d,{l1:()=>sr,l1l2:()=>st,l2:()=>sn});var c={};r.r(c),r.d(c,{json:()=>sA});var f={};r.r(f),r.d(f,{json:()=>s$});var m={};r.r(m),r.d(m,{json:()=>sF});var g={};r.r(g),r.d(g,{json:()=>sR});var y={};r.r(y),r.d(y,{json:()=>s_});var b={};r.r(b),r.d(b,{json:()=>sD});var x={};r.r(x),r.d(x,{json:()=>sO});var v={};r.r(v),r.d(v,{json:()=>sL});var w={};r.r(w),r.d(w,{json:()=>sM});var T={};r.r(T),r.d(T,{json:()=>sP});var S={};r.r(S),r.d(S,{json:()=>sz});var N={};r.r(N),r.d(N,{json:()=>sB});var k={};r.r(k),r.d(k,{json:()=>sW});var I={};r.r(I),r.d(I,{json:()=>sV});var C={};r.r(C),r.d(C,{json:()=>sU});var E={};r.r(E),r.d(E,{json:()=>sG});var A={};r.r(A),r.d(A,{json:()=>sZ});var $={};r.r($),r.d($,{json:()=>sj});var F={};r.r(F),r.d(F,{json:()=>sK});var R={};r.r(R),r.d(R,{OP_SCOPE_SUFFIX:()=>it.BTT,abs:()=>it.tnl,acos:()=>it.HQu,acosh:()=>it.FqL,add:()=>it.WQq,addN:()=>it.QiD,all:()=>it.Q7R,any:()=>it.bzn,argMax:()=>it.FLi,argMin:()=>it.XRg,asin:()=>it.qRo,asinh:()=>it.yHs,atan:()=>it.rYl,atan2:()=>it.FPz,atanh:()=>it.rfv,avgPool:()=>it.$jT,avgPool3d:()=>it.sub,basicLSTMCell:()=>it.lZX,batchNorm:()=>it.$v7,batchNorm2d:()=>it.BFc,batchNorm3d:()=>it.kSi,batchNorm4d:()=>it.T5N,batchToSpaceND:()=>it.GTe,bincount:()=>it.HbZ,bitwiseAnd:()=>it.vjT,booleanMaskAsync:()=>it.ftb,broadcastArgs:()=>it.ROE,broadcastTo:()=>it.hOW,buffer:()=>it.ra8,cast:()=>it.wgE,ceil:()=>it.mkO,clipByValue:()=>it.zQh,clone:()=>it.o8B,complex:()=>it.faB,concat:()=>it.xWs,concat1d:()=>it.I1m,concat2d:()=>it.RPU,concat3d:()=>it.O5O,concat4d:()=>it.P1l,conv1d:()=>it.kA9,conv2d:()=>it.Xtf,conv2dTranspose:()=>it.wX9,conv3d:()=>it.IPL,conv3dTranspose:()=>it.jIJ,cos:()=>it.gnS,cosh:()=>it.yIG,cosineWindow:()=>it._jP,cumprod:()=>it.Lp0,cumsum:()=>it.rCv,denseBincount:()=>it.aOp,depthToSpace:()=>it.Rj8,depthwiseConv2d:()=>it.Gl3,diag:()=>it.smy,dilation2d:()=>it.X7t,div:()=>it.y4m,divNoNan:()=>it.ek5,dot:()=>it.Omf,dropout:()=>it.EZY,einsum:()=>it._3C,elu:()=>it.Pqc,enclosingPowerOfTwo:()=>it.FJY,ensureShape:()=>it.QP2,equal:()=>it.LCg,erf:()=>it.Y12,euclideanNorm:()=>it.p4S,exp:()=>it.oNF,expandDims:()=>it.UG6,expm1:()=>it.IYd,eye:()=>it.y5U,fft:()=>it.hVP,fill:()=>it.GSj,floor:()=>it.RIf,floorDiv:()=>it.wh_,fused:()=>it.cZk,gather:()=>it.kgh,gatherND:()=>it.SY9,greater:()=>it.rhj,greaterEqual:()=>it.DQN,ifft:()=>it.KGM,imag:()=>it.ngS,image:()=>it.Slp,inTopKAsync:()=>it.U4u,irfft:()=>it.ggX,isFinite:()=>it.MIs,isInf:()=>it.EN4,isNaN:()=>it.yrW,leakyRelu:()=>it.H8d,less:()=>it.M7h,lessEqual:()=>it.InN,linalg:()=>it.mPL,linspace:()=>it.mT8,localResponseNormalization:()=>it.Kgs,log:()=>it.Rm2,log1p:()=>it.Kko,logSigmoid:()=>it.nqI,logSoftmax:()=>it.HPB,logSumExp:()=>it.VZ,logicalAnd:()=>it.n76,logicalNot:()=>it.NSZ,logicalOr:()=>it.ztW,logicalXor:()=>it.rxB,losses:()=>it.YYh,lowerBound:()=>it.yzS,matMul:()=>it.NoW,max:()=>it.T9B,maxPool:()=>it.jgi,maxPool3d:()=>it.NYV,maxPoolWithArgmax:()=>it.RO,maximum:()=>it.PhQ,mean:()=>it.i2o,meshgrid:()=>it.OYQ,min:()=>it.jkA,minimum:()=>it.BpO,mirrorPad:()=>it.FFZ,mod:()=>it.ziu,moments:()=>it.Clk,movingAverage:()=>it.CRk,mul:()=>it.lKK,multiRNNCell:()=>it.YDF,multinomial:()=>it.OjQ,neg:()=>it.HZy,norm:()=>it.xbf,notEqual:()=>it.Ec,oneHot:()=>it.Mw0,ones:()=>it.SaS,onesLike:()=>it.P61,op:()=>it.op,outerProduct:()=>it.X4o,pad:()=>it.eVF,pad1d:()=>it.BZs,pad2d:()=>it.grY,pad3d:()=>it.XHu,pad4d:()=>it.WLX,pool:()=>it.dzn,pow:()=>it.n7C,prelu:()=>it.NsG,print:()=>it.yyV,prod:()=>it._eU,raggedGather:()=>it.whe,raggedRange:()=>it.iyU,raggedTensorToTensor:()=>it.Q0_,rand:()=>it._9M,randomGamma:()=>it.pR9,randomNormal:()=>it.FE$,randomStandardNormal:()=>it.m0H,randomUniform:()=>it.YeY,randomUniformInt:()=>it.HYA,range:()=>it.y17,real:()=>it.xav,reciprocal:()=>it.VOZ,relu:()=>it.VVh,relu6:()=>it.j__,reshape:()=>it.tQQ,reverse:()=>it.BEg,reverse1d:()=>it.QD2,reverse2d:()=>it.LMr,reverse3d:()=>it.I2l,reverse4d:()=>it.JYU,rfft:()=>it.z8$,round:()=>it.LIG,rsqrt:()=>it.Z$r,scalar:()=>it.d_2,scatterND:()=>it.NFr,searchSorted:()=>it.sZg,selu:()=>it.WfX,separableConv2d:()=>it.wdz,setdiff1dAsync:()=>it.F12,sigmoid:()=>it.ry7,sign:()=>it._SZ,signal:()=>it.vPA,sin:()=>it.F8e,sinh:()=>it.L0l,slice:()=>it.dik,slice1d:()=>it.Q$M,slice2d:()=>it.zAd,slice3d:()=>it.wck,slice4d:()=>it.R0O,softmax:()=>it.Vs9,softplus:()=>it.lw0,spaceToBatchND:()=>it.eDJ,sparse:()=>it.lMo,sparseToDense:()=>it.Zhr,spectral:()=>it.lOn,split:()=>it.lDo,sqrt:()=>it.RZD,square:()=>it.EwI,squaredDifference:()=>it.Pbu,squeeze:()=>it.r2V,stack:()=>it.t$z,step:()=>it.PMw,stridedSlice:()=>it.Ym9,string:()=>it.YjP,sub:()=>it.jbE,sum:()=>it.czq,tan:()=>it.Mlm,tanh:()=>it.ymU,tensor:()=>it.OEK,tensor1d:()=>it.tGX,tensor2d:()=>it.KtR,tensor3d:()=>it.$_$,tensor4d:()=>it.g9W,tensor5d:()=>it.Lpo,tensor6d:()=>it.yxw,tensorScatterUpdate:()=>it.NNh,tile:()=>it.Vsq,topk:()=>it.rfw,transpose:()=>it.mgz,truncatedNormal:()=>it.efE,unique:()=>it.AmM,unsortedSegmentSum:()=>it.zAU,unstack:()=>it.K$i,upperBound:()=>it.rni,variable:()=>it.bvq,where:()=>it._M9,whereAsync:()=>it.YJN,zeros:()=>it.Ul9,zerosLike:()=>it.POl});var _={};r.r(_),r.d(_,{CSVDataset:()=>on,Dataset:()=>i2,FileDataSource:()=>ob,TextLineDataset:()=>i8,URLDataSource:()=>ox,array:()=>i4,csv:()=>ov,func:()=>ow,generator:()=>oT,microphone:()=>oN,version_data:()=>ok,webcam:()=>oS,zip:()=>i6});var D={};r.r(D),r.d(D,{Abs:()=>W.ljI,Acos:()=>W.Vvy,Acosh:()=>W.PH8,AdadeltaOptimizer:()=>W.K$F,AdagradOptimizer:()=>W.ah4,AdamOptimizer:()=>W.FYc,AdamaxOptimizer:()=>W.oC7,Add:()=>W.OMN,AddN:()=>W.EkD,All:()=>W.u8Z,Any:()=>W.FSt,ArgMax:()=>W.Jp_,ArgMin:()=>W.p_m,Asin:()=>W.QKF,Asinh:()=>W.epO,Atan:()=>W.TyE,Atan2:()=>W.lxb,Atanh:()=>W.zP9,AvgPool:()=>W.ho8,AvgPool3D:()=>W.cS,AvgPool3DGrad:()=>W.wwC,AvgPoolGrad:()=>W.VCH,BatchMatMul:()=>W.jAQ,BatchToSpaceND:()=>W.Ik2,Bincount:()=>W.N4F,BitwiseAnd:()=>W.HNs,BroadcastArgs:()=>W.vj7,BroadcastTo:()=>W.LB5,Callback:()=>sl,CallbackList:()=>sa.g,Cast:()=>W.KXH,Ceil:()=>W.QDP,ClipByValue:()=>W.vaV,Complex:()=>W.pr3,ComplexAbs:()=>W.$zE,Concat:()=>W.$dB,Conv2D:()=>W.p2J,Conv2DBackpropFilter:()=>W.rFm,Conv2DBackpropInput:()=>W.jfg,Conv3D:()=>W.A1h,Conv3DBackpropFilterV2:()=>W.iGz,Conv3DBackpropInputV2:()=>W.gC7,Cos:()=>W.Mn0,Cosh:()=>W.MnK,CropAndResize:()=>W.MRQ,Cumprod:()=>W.jj_,Cumsum:()=>W.nY8,CustomCallback:()=>sa.H7,DataStorage:()=>W.GJx,DenseBincount:()=>W.wNW,DepthToSpace:()=>W.TMz,DepthwiseConv2dNative:()=>W.tGH,DepthwiseConv2dNativeBackpropFilter:()=>W.X$8,DepthwiseConv2dNativeBackpropInput:()=>W.nVu,Diag:()=>W.ORI,Dilation2D:()=>W.jxD,Dilation2DBackpropFilter:()=>W.pk0,Dilation2DBackpropInput:()=>W.bP9,Draw:()=>W.XmO,ENV:()=>W.Kmu,EarlyStopping:()=>sp,Einsum:()=>W.Qgm,Elu:()=>W.Pah,EluGrad:()=>W.rsH,Environment:()=>W.OH$,Equal:()=>W.BRl,Erf:()=>W._s9,Exp:()=>W.ox3,ExpandDims:()=>W.ybN,Expm1:()=>W.ybj,FFT:()=>W.rGP,Fill:()=>W.SQl,FlipLeftRight:()=>W.BxF,Floor:()=>W.ZgB,FloorDiv:()=>W.ElG,FromPixels:()=>W.awo,FusedBatchNorm:()=>W.i5R,FusedConv2D:()=>W.aAr,FusedDepthwiseConv2D:()=>W.T7M,GPGPUContext:()=>pJ.n,GatherNd:()=>W.O4G,GatherV2:()=>W.mxL,GraphModel:()=>iC,Greater:()=>W.XhZ,GreaterEqual:()=>W.lLS,History:()=>sa.BZ,IFFT:()=>W.OAQ,Identity:()=>W.lzr,Imag:()=>W.dv8,InputSpec:()=>sc.eO,IsFinite:()=>W.gIW,IsInf:()=>W.E3$,IsNan:()=>W.iPs,KernelBackend:()=>W.uI_,LRN:()=>W.jM4,LRNGrad:()=>W.ToN,LayerVariable:()=>sg.eR,LayersModel:()=>ss.Gw,LeakyRelu:()=>W.X0$,Less:()=>W.mIA,LessEqual:()=>W.CwD,LinSpace:()=>W.mnI,Log:()=>W.tG8,Log1p:()=>W.Cg$,LogSoftmax:()=>W.zfU,LogicalAnd:()=>W.RUm,LogicalNot:()=>W.nZd,LogicalOr:()=>W.LXA,LogicalXor:()=>W.RW8,LowerBound:()=>
289W.yPW,MathBackendCPU:()=>oE,MathBackendWebGL:()=>pH.Q6,MatrixBandPart:()=>W.WRv,Max:()=>W.VAI,MaxPool:()=>W.t3d,MaxPool3D:()=>W.ySp,MaxPool3DGrad:()=>W.cHb,MaxPoolGrad:()=>W.RXX,MaxPoolWithArgmax:()=>W.TL8,Maximum:()=>W.LDN,Mean:()=>W.g5A,Min:()=>W.lNG,Minimum:()=>W.LG0,MirrorPad:()=>W.x7F,Mod:()=>W.BLA,MomentumOptimizer:()=>W.Qu_,Multinomial:()=>W.WT3,Multiply:()=>W.xu7,Neg:()=>W.l0G,NonMaxSuppressionV3:()=>W.SDM,NonMaxSuppressionV4:()=>W.Zl4,NonMaxSuppressionV5:()=>W.e0f,NotEqual:()=>W.ylV,OP_SCOPE_SUFFIX:()=>W.BTT,OneHot:()=>W.urI,OnesLike:()=>W.LWX,Optimizer:()=>W.ELo,OptimizerConstructors:()=>W.L5p,Pack:()=>W.mM$,PadV2:()=>W.ODT,Pool:()=>W.bCz,Pow:()=>W.pyJ,Prelu:()=>W.Ncv,Prod:()=>W.kdj,RMSPropOptimizer:()=>W.PS5,RNN:()=>sm.VS,RaggedGather:()=>W.oJ2,RaggedRange:()=>W.CQC,RaggedTensorToTensor:()=>W.mH5,Range:()=>W.Q6t,Rank:()=>W.rgM,Real:()=>W.LRy,RealDiv:()=>W.sDr,Reciprocal:()=>W.huO,Reduction:()=>W.iDl,Relu:()=>W.fUj,Relu6:()=>W.P_L,Reshape:()=>W.R23,ResizeBilinear:()=>W.hgw,ResizeBilinearGrad:()=>W.FCQ,ResizeNearestNeighbor:()=>W.jOE,ResizeNearestNeighborGrad:()=>W.XQy,Reverse:()=>W.D7i,RotateWithOffset:()=>W.BK4,Round:()=>W.hVg,Rsqrt:()=>W.TOR,SGDOptimizer:()=>W.SYI,ScatterNd:()=>W.pJc,SearchSorted:()=>W.uWl,Select:()=>W.l6P,Selu:()=>W.u$b,Sequential:()=>a9.Gx,Sigmoid:()=>W.vI1,Sign:()=>W.YVe,Sin:()=>W.hql,Sinh:()=>W.J3C,Slice:()=>W.JiE,Softmax:()=>W.rFG,Softplus:()=>W.Fin,SpaceToBatchND:()=>W.A8B,SparseFillEmptyRows:()=>W.C8s,SparseReshape:()=>W.BoJ,SparseSegmentMean:()=>W.L6G,SparseSegmentSum:()=>W.DvZ,SparseToDense:()=>W.jgd,SplitV:()=>W.Blb,Sqrt:()=>W.dFH,Square:()=>W.M6A,SquaredDifference:()=>W.Ddj,StaticRegexReplace:()=>W.GZp,Step:()=>W.pnw,StridedSlice:()=>W.UcO,StringNGrams:()=>W.YAb,StringSplit:()=>W.iW0,StringToHashBucketFast:()=>W.$jE,Sub:()=>W.PbM,Sum:()=>W.WuN,SymbolicTensor:()=>sc.Ar,Tan:()=>W.oFs,Tanh:()=>W.iuW,Tensor:()=>W.qYS,TensorBuffer:()=>W.ylz,TensorScatterUpdate:()=>W.X4r,Tile:()=>W.FAs,TopK:()=>W.TBb,Transform:()=>W.dLy,Transpose:()=>W.wx0,Unique:()=>W.EwU,Unpack:()=>W.dXR,UnsortedSegmentSum:()=>W.pPe,UpperBound:()=>W.RMm,Variable:()=>W.rTt,ZerosLike:()=>W.xJ3,_FusedMatMul:()=>W.Dr,abs:()=>W.tnl,acos:()=>W.HQu,acosh:()=>W.FqL,add:()=>W.WQq,addN:()=>W.QiD,all:()=>W.Q7R,any:()=>W.bzn,argMax:()=>W.FLi,argMin:()=>W.XRg,asin:()=>W.qRo,asinh:()=>W.yHs,atan:()=>W.rYl,atan2:()=>W.FPz,atanh:()=>W.rfv,avgPool:()=>W.$jT,avgPool3d:()=>W.sub,backend:()=>W.Hs,backend_util:()=>W.C0T,basicLSTMCell:()=>W.lZX,batchNorm:()=>W.$v7,batchNorm2d:()=>W.BFc,batchNorm3d:()=>W.kSi,batchNorm4d:()=>W.T5N,batchToSpaceND:()=>W.GTe,bincount:()=>W.HbZ,bitwiseAnd:()=>W.vjT,booleanMaskAsync:()=>W.ftb,broadcastArgs:()=>W.ROE,broadcastTo:()=>W.hOW,broadcast_util:()=>W.ZEY,browser:()=>W.TaL,buffer:()=>W.ra8,callbacks:()=>sd,cast:()=>W.wgE,ceil:()=>W.mkO,clipByValue:()=>W.zQh,clone:()=>W.o8B,complex:()=>W.faB,concat:()=>W.xWs,concat1d:()=>W.I1m,concat2d:()=>W.RPU,concat3d:()=>W.O5O,concat4d:()=>W.P1l,constraints:()=>l,conv1d:()=>W.kA9,conv2d:()=>W.Xtf,conv2dTranspose:()=>W.wX9,conv3d:()=>W.IPL,conv3dTranspose:()=>W.jIJ,copyRegisteredKernels:()=>W.Cfv,cos:()=>W.gnS,cosh:()=>W.yIG,cosineWindow:()=>W._jP,cumprod:()=>W.Lp0,cumsum:()=>W.rCv,customGrad:()=>W._Xg,data:()=>_,denseBincount:()=>W.aOp,deprecationWarn:()=>W.fLc,depthToSpace:()=>W.Rj8,depthwiseConv2d:()=>W.Gl3,deregisterOp:()=>sv,device_util:()=>W.eMq,diag:()=>W.smy,dilation2d:()=>W.X7t,disableDeprecationWarnings:()=>
289W.ISJ,dispose:()=>W.ASo,disposeVariables:()=>W.rm6,div:()=>W.y4m,divNoNan:()=>W.ek5,dot:()=>W.Omf,dropout:()=>W.EZY,einsum:()=>W._3C,elu:()=>W.Pqc,enableDebugMode:()=>W.gYU,enableProdMode:()=>W.SmG,enclosingPowerOfTwo:()=>W.FJY,engine:()=>W.Hi9,ensureShape:()=>W.QP2,env:()=>W._K2,equal:()=>W.LCg,erf:()=>W.Y12,euclideanNorm:()=>W.p4S,exp:()=>W.oNF,expandDims:()=>W.UG6,expm1:()=>W.IYd,eye:()=>W.y5U,fft:()=>W.hVP,fill:()=>W.GSj,findBackend:()=>W.goy,findBackendFactory:()=>W.W4C,floor:()=>W.RIf,floorDiv:()=>W.wh_,forceHalfFloat:()=>p0,fused:()=>W.cZk,gather:()=>W.kgh,gatherND:()=>W.SY9,gather_util:()=>W.FJy,getBackend:()=>W.jz4,getGradient:()=>W.vQR,getKernel:()=>W._5H,getKernelsForBackend:()=>W.OpK,gpgpu_util:()=>pQ,grad:()=>W.Dvk,grads:()=>W.ok9,greater:()=>W.rhj,greaterEqual:()=>W.DQN,ifft:()=>W.KGM,imag:()=>W.ngS,image:()=>W.Slp,inTopKAsync:()=>W.U4u,initializers:()=>u,input:()=>sf.hF,io:()=>W.io,irfft:()=>W.ggX,isFinite:()=>W.MIs,isInf:()=>W.EN4,isNaN:()=>W.yrW,keep:()=>W.aCs,kernel_impls:()=>W.kpo,layers:()=>aG,leakyRelu:()=>W.H8d,less:()=>W.M7h,lessEqual:()=>W.InN,linalg:()=>W.mPL,linspace:()=>W.mT8,loadGraphModel:()=>iE,loadGraphModelSync:()=>iA,loadLayersModel:()=>sf.O0,localResponseNormalization:()=>W.Kgs,log:()=>W.Rm2,log1p:()=>W.Kko,logSigmoid:()=>W.nqI,logSoftmax:()=>W.HPB,logSumExp:()=>W.VZ,logicalAnd:()=>W.n76,logicalNot:()=>W.NSZ,logicalOr:()=>W.ztW,logicalXor:()=>W.rxB,losses:()=>W.YYh,lowerBound:()=>W.yzS,matMul:()=>W.NoW,math:()=>W.DyF,max:()=>W.T9B,maxPool:()=>W.jgi,maxPool3d:()=>W.NYV,maxPoolWithArgmax:()=>W.RO,maximum:()=>W.PhQ,mean:()=>W.i2o,memory:()=>W.m1Z,meshgrid:()=>W.OYQ,metrics:()=>h,min:()=>W.jkA,minimum:()=>W.BpO,mirrorPad:()=>W.FFZ,mod:()=>W.ziu,model:()=>sf.ge,models:()=>p,moments:()=>W.Clk,movingAverage:()=>W.CRk,mul:()=>W.lKK,multiRNNCell:()=>W.YDF,multinomial:()=>W.OjQ,neg:()=>W.HZy,nextFrame:()=>W.dA1,norm:()=>W.xbf,notEqual:()=>W.Ec,oneHot:()=>W.Mw0,ones:()=>W.SaS,onesLike:()=>W.P61,op:()=>W.op,outerProduct:()=>W.X4o,pad:()=>W.eVF,pad1d:()=>W.BZs,pad2d:()=>W.grY,pad3d:()=>W.XHu,pad4d:()=>W.WLX,pool:()=>W.dzn,pow:()=>W.n7C,prelu:()=>W.NsG,print:()=>W.yyV,prod:()=>W._eU,profile:()=>W.MEE,raggedGather:()=>W.whe,raggedRange:()=>W.iyU,raggedTensorToTensor:()=>W.Q0_,rand:()=>W._9M,randomGamma:()=>W.pR9,randomNormal:()=>W.FE$,randomStandardNormal:()=>W.m0H,randomUniform:()=>W.YeY,randomUniformInt:()=>W.HYA,range:()=>W.y17,ready:()=>W.Gc4,real:()=>W.xav,reciprocal:()=>W.VOZ,registerBackend:()=>W.gJX,registerCallbackConstructor:()=>sf.ZS,registerGradient:()=>W.krJ,registerKernel:()=>W.tAK,registerOp:()=>sx,regularizers:()=>d,relu:()=>W.VVh,relu6:()=>W.j__,removeBackend:()=>W.rEj,reshape:()=>W.tQQ,reverse:()=>W.BEg,reverse1d:()=>W.QD2,reverse2d:()=>W.LMr,reverse3d:()=>W.I2l,reverse4d:()=>W.JYU,rfft:()=>W.z8$,round:()=>W.LIG,rsqrt:()=>W.Z$r,scalar:()=>W.d_2,scatterND:()=>W.NFr,scatter_util:()=>W.g23,searchSorted:()=>W.sZg,selu:()=>W.WfX,separableConv2d:()=>W.wdz,sequential:()=>sf.il,serialization:()=>W.JFn,setBackend:()=>W.jh6,setPlatform:()=>W.OkC,setWebGLContext:()=>pX.lj,setdiff1dAsync:()=>W.F12,shared:()=>oA,sigmoid:()=>W.ry7,sign:()=>W._SZ,signal:()=>W.vPA,sin:()=>W.F8e,sinh:()=>W.L0l,slice:()=>W.dik,slice1d:()=>W.Q$M,slice2d:()=>W.zAd,slice3d:()=>W.wck,slice4d:()=>W.R0O,slice_util:()=>W.Kro,softmax:()=>W.Vs9,softplus:()=>W.lw0,spaceToBatchND:()=>W.eDJ,sparse:()=>W.lMo,sparseToDense:()=>W.Zhr,spectral:()=>W.lOn,split:()=>W.lDo,sqrt:()=>W.RZD,square:()=>W.EwI,squaredDifference:()=>W.Pbu,squeeze:()=>W.r2V,stack:()=>W.t$z,step:()=>W.PMw,stridedSlice:()=>W.Ym9,string:()=>W.YjP,sub:()=>W.jbE,sum:()=>W.czq,sumOutType:()=>W.chL,tan:()=>W.Mlm,tanh:()=>W.ymU,tensor:()=>W.OEK,tensor1d:()=>W.tGX,tensor2d:()=>W.KtR,tensor3d:()=>W.$_$,tensor4d:()=>W.g9W,tensor5d:()=>W.Lpo,tensor6d:()=>W.yxw,tensorScatterUpdate:()=>W.NNh,tensor_util:()=>W.d_S,test_util:()=>W.Obs,tidy:()=>W.DZQ,tile:()=>W.Vsq,time:()=>W.kBw,topk:()=>W.rfw,train:()=>W.BaG,transpose:()=>W.mgz,truncatedNormal:()=>W.efE,unique:()=>W.AmM,unregisterGradient:()=>W.rYx,unregisterKernel:()=>W.iPt,unsortedSegmentSum:()=>W.zAU,unstack:()=>W.K$i,upcastType:()=>W.TuY,upperBound:()=>W.rni,util:()=>W.ZSL,valueAndGrad:()=>W.jYt,valueAndGrads:()=>W.muS,variable:()=>W.bvq,variableGrads:()=>W.y7e,version:()=>yH,version_converter:()=>i$,version_core:()=>W.bgA,version_cpu:()=>o$,version_layers:()=>
289sy.r,version_webgl:()=>pY,webgl:()=>p1,webgl_util:()=>pq,where:()=>W._M9,whereAsync:()=>W.YJN,zeros:()=>W.Ul9,zerosLike:()=>W.POl});let O=e=>Array.isArray(e)?e[0]:e,L=(({scale:e,name:t,version:r,meta:{architecture:n,...a},path:s})=>{let i=s||`models/x${e}/model.json`;return"rdn"===n?{scale:e,modelType:"layers",_internals:{path:i,name:t,version:r},meta:{architecture:n,...a},inputRange:[0,255],outputRange:[0,255]}:{setup:t=>{let r=t.layers.Layer;class n extends r{beta;constructor(){super({}),this.beta=.2}call(e){return t.mul(O(e),this.beta)}static className="MultiplyBeta"}[n,(n=>{class a extends r{scale=n;constructor(){super({})}computeOutputShape(e){return[e[0],e[1],e[2],3]}call(e){return t.depthToSpace(O(e),this.scale,"NHWC")}static className=`PixelShuffle${e}x`}return a})(e)].forEach(e=>{t.serialization.registerClass(e)})},scale:e,modelType:"layers",_internals:{path:i,name:t,version:r},meta:{architecture:n,...a},inputRange:[0,1],outputRange:[0,1]}})({scale:2,name:"@upscalerjs/default-model",version:"1.0.0",path:"models/model.json",meta:{C:1,D:2,G:4,G0:64,T:10,architecture:"rdn",patchSize:128,size:"slim",artifactReducing:!1,sharpening:!1,dataset:"div2k",modelFileName:"rdn-C1-D2-G4-G064-T10-x2-patchsize128-compress100-sharpen0-datadiv2k-vary_cFalse_best-val_loss_epoch494"}}),M=Error("No defined tensors were passed to concatTensors");class P extends Error{message="The upscale request received an abort signal"}let z=Error("An undefined model was provided to UpscalerJS"),B=Error("Model input sizes must be square. If you are using a model with a non-square input size and would like to request support, please file a feature request at https://github.com/thekevinscott/upscalerjs");var W=r(45720);let V=e=>!!e&&!!Array.isArray(e)&&4===e.length&&e.every(e=>null===e||"number"==typeof e),U=e=>V(e)&&null!==e[1]&&null!==e[2]&&e[1]>0&&e[2]>0;function G(e){return function(t){try{return t.shape.length===e}catch(e){}return!1}}let Z=G(4),j=G(3),K=e=>e instanceof W.qYS,H=e=>"number"==typeof e,Y=e=>Array.isArray(e)&&2===e.length&&e.every(H),Q=e=>{console.warn(Array.isArray(e)?e.join("\n"):e)};function q(e){return void 0!==e&&"function"==typeof e}let X=(e,t,r)=>!!q(e)&&!(e.length<=1)&&(void 0===r&&"tensor"===t||"tensor"===r);async function J(e,t){let r;for(r=await e.next();!r.done;r=await e.next())t&&await t(r.value);return r.value}function ee(e){return null!=e}function et(e,t,...r){let n=r.filter(ee);if(n.length){let r=e.tidy(()=>n.reduce((e,t)=>t(e),t));return t.isDisposed||t===r||t.dispose(),r}return t}let er=(e,t,r)=>async n=>{if(r&&await e.nextFrame(),(e=>!!e&&e.aborted)(t))throw Array.isArray(n)?n.forEach(e=>e?.dispose()):K(n)&&n.dispose(),new P},en=e=>!!e&&"object"==typeof e&&"patchSize"in e&&"number"==typeof e.patchSize,ea=e=>!!e&&"number"==typeof e&&e>0,es=e=>Error(["Invalid value passed to warmup in warmupSizes:",JSON.stringify(e),"For more information, see https://upscalerjs.com/documentation/troubleshooting#invalid-warmup-value."].join("\n")),ei=e=>{if(en(e)){let{patchSize:t}=e;return t}return e};async function*eo(e,t,r){let{model:n,modelDefinition:a}=await t;for(let t of r){if(!en(t)&&!ea(t))throw es(t);let r=ei(t),s=e.zeros([1,r,r,3]);for(let t of(yield[s],[a.preprocess,e=>n.predict(e),a.postprocess].filter(Boolean)))s=et(e,s,t),yield[s];s.dispose(),yield}}let el=async(e,t,r,{signal:n,awaitNextFrame:a=!1}={},s)=>{let i=er(e,n||s.signal,a);await i(),await J(eo(e,t,(e=>{if(Array.isArray(e)){for(let t of e)if(!en(t)&&!ea(t))throw es(e);return e}if(en(e)||ea(e))return[e];throw es(e)})(r)),i)};async function eu(e,t){var r,n;let a=(r=e,"function"==typeof(n=t)?(Q("Passing a model definition as a function is deprecated and will be removed in a future version. To leverage model lifecycle methods, use the setup and teardown methods. For more information, see https://upscalerjs.com/documentation/troubleshooting#deprecated-model-definition-function."),n(r)):n);return a.setup&&await a.setup(e),a}function eh(e,t,r){return"graph"===r?e.loadGraphModel(t):e.loadLayersModel(t)}let ep=(e,t)=>Math.ceil(t/e)*e,ed=(e,t,r)=>n=>{let a=t[1]*r,s=t[2]*r;return a<n.shape[1]||s<n.shape[2]?e.tidy(()=>e.slice(n,[0,0,0],[1,a,s,3])):n},ec=e=>t=>{let r=Y(e)?e[1]:255;return t.clipByValue(0,r).mul(1===r?255:1)};function ef(e,t,r=0){let n=t.filter(ee);if(0===n.length)throw M;let a=e.concat(n,r);
289return t.forEach(e=>e?.dispose()),a}let em=(e,t,r,n)=>{let a=t,s=0===t||r===e?0:n,i=a+r>e,o=i?r-(e-a):0,l=i||r===e?0:n,u=i?0:s,h=r-(i?o:0);return i&&(a=e-r),{pre:{origin:a-=u,size:r},post:{origin:o+=u,size:h-=u+l},increment:r>e?e:r-s-l}},eg=([e,t],r,n)=>{let a=[],s=0,i=0;for(;i<t;){let{pre:{origin:o,size:l},post:{origin:u,size:h},increment:p}=em(t,i,Math.min(r,t),n),d=[];for(;s<e;){let{pre:{origin:t,size:a},post:{origin:i,size:p},increment:c}=em(e,s,Math.min(r,e),n);d.push({pre:{origin:[o,t],size:[l,a]},post:{origin:[u,i],size:[h,p]}}),s+=c}a.push(d),s=0,i+=p}return a},ey=(e,t,r,n)=>(e*r+t+1)/n,eb=(e,t)=>{let r,n=e.predict(t);if(!K(n))throw Error("The model output was not a valid tensor. UpscalerJS only supports models returning valid tensors. This is likely an error with the model itself, not UpscalerJS. For more information, see https://upscalerjs.com/documentation/troubleshooting#invalid-model-prediction.");if(Z(n))return n;throw Error((r=n.shape,`The tensor returned by the model was not a valid rank-4 tensor. It's shape is ${JSON.stringify(r)}.} UpscalerJS only supports models returning valid image-like data in four dimensional form. For more information, see https://upscalerjs.com/documentation/troubleshooting#invalid-predicted-tensor.`))};async function*ex(e,t,{output:r,progress:n,progressOutput:a},s,{originalImageSize:i,patchSize:o,padding:l=0},{tensorAsBase64:u}){let{model:h,modelDefinition:p}=s,d=p.scale??1;if(o){let s,[c,f]=t.shape.slice(1),m=eg([f,c],o,l);yield;let g=m.length*m[0].length;for(let i=0;i<m.length;i++){let o,l=m[i],c=l.length;yield[o,s];for(let f=0;f<c;f++){let{pre:m,post:y}=l[f];yield[s,o];let b=t.slice([0,...m.origin],[-1,...m.size]);yield[s,o,b];let x=eb(h,b);b.dispose(),yield[s,o,x];let v=[0,y.origin[0]*d,y.origin[1]*d],w=[-1,y.size[0]*d,y.size[1]*d],T=x.slice(v,w);x.dispose(),yield[s,o,T];let S=et(e,T,p.postprocess,ec(p.outputRange));if(yield[s,o,S],void 0!==n&&q(n)){let t=ey(i,f,c,g);if(q(n)&&n.length<=1)n(t);else{let s=S.squeeze(),o={row:i,col:f,patchCoordinates:{pre:m,post:y}};if(X(n,r,a))n(t,s,o);else{let r=u(e,s);s.dispose(),n(t,r,o)}}}yield[s,o,S],o=ef(e,[o,S],2),S.dispose(),yield[s,o]}s=ef(e,[s,o],1),o.dispose(),yield[s]}let y=et(e,s.clone(),ed(e,i,d));s?.dispose(),yield[y];let b=y.squeeze();return y.dispose(),b}n&&Q('The "progress" callback was provided but "patchSize" was not defined. Without a "patchSize", the "progress" callback will never be called. For more information, see https://upscalerjs.com/documentation/troubleshooting#progress-specified-without-patch-size.');let c=eb(h,t);yield[c];let f=et(e,c.clone(),p.postprocess,ec(p.outputRange),ed(e,i,d));c.dispose(),yield[f];let m=f.squeeze();return f.dispose(),m}async function*ev(e,t,r,n,{getImageAsTensor:a,tensorAsBase64:s}){let i,o=K(t)?t.clone():t,l=await a(e,o);yield l;let u=l.shape,{patchSize:h,padding:p,modelInputShape:d}=((e,t,{patchSize:r,padding:n},a)=>{let s=((e,{model:t})=>{let r,n,a=(r=e,(n=t)instanceof r.LayersModel?n.layers[0].batchInputShape:n.inputs[0].shape);if(!V(a))throw Error(`Expected model to have a rank-4 compatible input shape. Instead got: ${JSON.stringify(a)}. For more information, see https://upscalerjs.com/documentation/troubleshooting#error-with-model-input-shape.`);return a})(e,t);if(void 0!==r){if(r<=0)throw Error(`Invalid patch size: ${r}. Patch size must be greater than 0.`);if(void 0!==n&&2*n>=r)throw Error(`Invalid patch size and padding: ${r} and ${n}. Patch size must be greater than padding * 2.`)}if(U(s)){if(void 0!==r&&Q("You have provided a patchSize, but the model definition already includes an input size. Your patchSize will be ignored. For more information, see https://upscalerjs.com/documentation/troubleshooting#input-size-and-patch-size."),s[1]!==s[2])throw B;return{patchSize:s[1],padding:n,modelInputShape:s}}void 0!==r&&void 0===n&&Q('"padding" is undefined, but "patchSize" is explicitly defined. Without padding, patches of images often have visible artifacting at the seams. Defining an explicit padding will resolve the artifacting. For more information, see https://upscalerjs.com/documentation/troubleshooting#padding-is-undefined. To hide this warning, pass an explicit padding of "0".');let{divisibilityFactor:i}=t.modelDefinition;if(void 0!==i){if(void 0!==r){let e=ep(i,r);return e!==r&&Q(`Invalid patch size: ${r}. The model has a defined divibility factor of ${i} and patch size must be a multiple of this number. Patch size has been scaled up to ${e}. 290For more information, see https://upscalerjs.com/documentation/troubleshooting#patch-size-indivisible-by-divisibility-factor.`),{patchSize:e,padding:n,modelInputShape:[null,e,e,3]}}return{patchSize:void 0,padding:void 0,modelInputShape:[null,ep(i,a[1]),ep(i,a[2]),3]}}return{patchSize:r,padding:n,modelInputShape:void 0}})(e,n,r,u),c=et(e,l,n.modelDefinition.preprocess,(i=n.modelDefinition.inputRange,t=>Y(i)&&1===i[1]?e.mul(t,1/255):t),d?t=>{let r=t.shape[1],n=t.shape[2];return U(d)&&(d[1]>r||d[2]>n)?e.tidy(()=>{let a=Math.max(r,d[1]),s=Math.max(n,d[2]),i=e.zeros([1,r,s-n,3]),o=e.zeros([1,a-r,s,3]),l=e.concat([t,i],2);return e.concat([l,o],1)}):t}:void 0);yield c;let f=ex(e,c,{output:r.output,progressOutput:r.progressOutput,progress:r.progress},n,{originalImageSize:u,patchSize:h,padding:p},{tensorAsBase64:s}),m=await f.next();for(yield m.value;!m.done;)Array.isArray((m=await f.next()).value)?yield[...m.value,c]:K(m.value)?yield[m.value,c]:yield c;c.dispose();let g=m.value;if("tensor"===r.output)return g;let y=s(e,g);return g.dispose(),y}async function ew(e,t,{signal:r,awaitNextFrame:n,...a},s,{checkValidEnvironment:i,...o}){i(t,{output:a.output,progressOutput:a.progressOutput});let l=er(e,r||s.signal,n);await l();let u=await J(ev(e,t,a,s,o),l);return await l(),u}function eT({tf:e,getUpscaleOptions:t,checkValidEnvironment:r,getImageAsTensor:n,tensorAsBase64:a,loadModel:s}){class i{_opts;_model;ready;_abortController=new AbortController;constructor(t={}){this._opts={...t},this._model=s(e,eu(e,this._opts.model||L)),this.ready=new Promise((t,r)=>{this._model.then(()=>el(e,this._model,this._opts.warmupSizes||[],void 0,{signal:this._abortController.signal}
290)).then(t).catch(r)})}async execute(s,i){await this.ready;let o=await this._model;return ew(e,s,t(i),{...o,signal:this._abortController.signal},{checkValidEnvironment:r,getImageAsTensor:n,tensorAsBase64:a})}upscale=this.execute.bind(this);warmup=async(t=[],r)=>(await this.ready,el(e,this._model,t,r,{signal:this._abortController.signal}));abort=()=>{this._abortController.abort(),this._abortController=new AbortController};dispose=async()=>{await this.ready;let{model:t,modelDefinition:r}=await this._model;r.teardown&&await r.teardown(e),t.dispose()};getModel=()=>this._model}return i}var eS=r(96609),eN=r(13797),ek=r(54256),eI=r(87260);let eC={kernelName:eS.ljI,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)(e,(0,eI.P)((0,eN.w)(r,"float32"),-1))}}};var eE=r(29337),eA=r(86032),e$=r(57610),eF=r(53744),eR=r(11983),e_=r(68396);let eD={kernelName:eS.Vvy,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>{let t=(0,eR.E)((0,eN.w)(r,"float32")),n=(0,eF.R)((0,e_.j)((0,e$.d)(1),t));return(0,eA.H)((0,eE.y)(e,n))}}}},eO={kernelName:eS.PH8,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>{let t=(0,eF.R)((0,e_.j)((0,eR.E)((0,eN.w)(r,"float32")),1));return(0,eE.y)(e,t)}}}};var eL=r(89990),eM=r(86036),eP=r(79625);let ez={kernelName:eS.OMN,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=eL.assertAndGetBroadcastShape(r.shape,n.shape);return{a:()=>{let t=e,n=eL.getReductionAxes(r.shape,a);return n.length>0&&(t=(0,eP.c)(t,n)),(0,eM.t)(t,r.shape)},b:()=>{let t=e,r=eL.getReductionAxes(n.shape,a);return r.length>0&&(t=(0,eP.c)(t,r)),(0,eM.t)(t,n.shape)}}}},eB={kernelName:eS.EkD,saveAllInputs:!0,gradFunc:(e,t)=>{let r={};return t.forEach((t,n)=>{r[n]=()=>e.clone()}),r}};var eW=r(61997);let eV={kernelName:eS.Jp_,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eW.P)(r)}}},eU={kernelName:eS.p_m,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eW.P)(r)}}},eG={kernelName:eS.QKF,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eE.y)(e,(0,eF.R)((0,e_.j)((0,e$.d)(1),(0,eR.E)((0,eN.w)(r,"float32")))))}}};var eZ=r(44769);let ej={kernelName:eS.epO,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>{let t=(0,eF.R)((0,eZ.W)((0,e$.d)(1),(0,eR.E)((0,eN.w)(r,"float32"))));return(0,eE.y)(e,t)}}}},eK={kernelName:eS.lxb,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,eL.assertAndGetBroadcastShape)(r.shape,n.shape);return{a:()=>{let t=(0,eZ.W)((0,eR.E)(r),(0,eR.E)(n)),s=(0,ek.l)(e,(0,eE.y)(n,t)),i=(0,eL.getReductionAxes)(r.shape,a);return i.length>0&&(s=(0,eP.c)(s,i)),(0,eM.t)(s,r.shape)},b:()=>{let t=(0,eZ.W)((0,eR.E)(r),(0,eR.E)(n)),s=(0,eA.H)((0,ek.l)(e,(0,eE.y)(r,t))),i=(0,eL.getReductionAxes)(n.shape,a);return i.length>0&&(s=(0,eP.c)(s,i)),(0,eM.t)(s,n.shape)}}}},eH={kernelName:eS.TyE,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eE.y)(e,(0,eZ.W)((0,eR.E)((0,eN.w)(r,"float32")),1))}}},eY={kernelName:eS.zP9,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eE.y)(e,(0,e_.j)((0,e$.d)(1),(0,eR.E)((0,eN.w)(r,"float32"))))}}};var eQ=r(5287),eq=r(54463),eX=r(75681),eJ=r(46866),e0=r(18875);let e1=(0,e0.op)({avgPool3dGrad_:function(e,t,r,n,a,s){let i=(0,eq.YT)(e,"dy","avgPool3dGrad"),o=(0,eq.YT)(t,"input","avgPool3dGrad"),l=i,u=o,h=!1;4===o.rank&&(h=!0,l=(0,eM.t)(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),u=(0,eM.t)(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),eX.vA(5===l.rank,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),eX.vA(5===u.rank,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${u.rank}.`),(0,eJ.s_)("avgPool3dGrad",a,s);let p={dy:l,input:u},d=eQ.T2.runKernel(eS.wwC,p,{filterSize:r,strides:n,pad:a,dimRoundingMode:s});return h?(0,eM.t)(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),e2={kernelName:eS.cS,inputsToSave:["x"],gradFunc:(e,t,r)=>
290{let[n]=t,{filterSize:a,strides:s,pad:i,dimRoundingMode:o}=r;return{x:()=>e1(e,n,a,s,i,o)}}},e3=(0,e0.op)({avgPoolGrad_:function(e,t,r,n,a){let s=(0,eq.YT)(e,"dy","avgPoolGrad"),i=(0,eq.YT)(t,"input","avgPoolGrad");eX.vA(i.rank===s.rank,()=>`Rank of input (${i.rank}) does not match rank of dy (${s.rank})`);let o=i,l=s,u=!1;3===i.rank&&(u=!0,o=(0,eM.t)(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=(0,eM.t)(s,[1,s.shape[0],s.shape[1],s.shape[2]])),eX.vA(4===l.rank,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),eX.vA(4===o.rank,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`);let h={dy:l,input:o},p=eQ.T2.runKernel(eS.VCH,h,{filterSize:r,strides:n,pad:a});return u?(0,eM.t)(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),e4={kernelName:eS.ho8,inputsToSave:["x"],gradFunc:(e,t,r)=>{let[n]=t,{filterSize:a,strides:s,pad:i}=r;return{x:()=>e3(e,n,a,s,i)}}};var e6=r(99309);let e5={kernelName:eS.jAQ,inputsToSave:["a","b"],gradFunc:(e,t,r)=>{let[n,a]=t,{transposeA:s,transposeB:i}=r;return s||i?!s&&i?{a:()=>(0,e6.N)(e,a,!1,!1),b:()=>(0,e6.N)(e,n,!0,!1)}:s&&!i?{a:()=>(0,e6.N)(a,e,!1,!0),b:()=>(0,e6.N)(n,e,!1,!1)}:{a:()=>(0,e6.N)(a,e,!0,!0),b:()=>(0,e6.N)(e,n,!0,!0)}:{a:()=>(0,e6.N)(e,a,!1,!0),b:()=>(0,e6.N)(n,e,!0,!1)}}};var e8=r(33282);let e7={kernelName:eS.Ik2,gradFunc:(e,t,r)=>{let{blockShape:n,crops:a}=r;return{x:()=>(0,e8.e)(e,n,a)}}},e9={kernelName:eS.LB5,gradFunc:(e,t,r)=>{let n=r.inputShape,a=r.shape,s=Array.from(a);for(let e=n.length-1;e>=0;e--)if(n[e]===a[e])s[e]=1;else if(1!==n[e])throw Error(`broadcastTo(): [${n}] cannot be broadcast to [${a}].`);let i=[];for(let e=0;e<s.length;e++)s[e]>1&&i.push(e);return{x:()=>(0,eP.c)(e,i,!0)}}},te={kernelName:eS.KXH,gradFunc:e=>({x:()=>e.clone()})}
290,tt={kernelName:eS.QDP,gradFunc:e=>({x:()=>(0,eW.P)(e)})};var tr=r(45923),tn=r(91784),ta=r(75127),ts=r(77833);let ti={kernelName:eS.vaV,inputsToSave:["x"],gradFunc:(e,t,r)=>{let[n]=t,{clipValueMin:a,clipValueMax:s}=r;return{x:()=>(0,ts._)((0,ta.n)((0,tr.D)(n,a),(0,tn.I)(n,s)),e,(0,eW.P)(e))}}},to={kernelName:eS.$zE,inputsToSave:["x"],gradFunc:eC.gradFunc};var tl=r(23926);let tu={kernelName:eS.$dB,saveAllInputs:!0,gradFunc:(e,t,r)=>{let n=t.map(e=>e.shape),{axis:a}=r,s=(0,eX.Y6)(a,t[0].shape)[0],i=n.map(e=>e[s]);return(0,tl.l)(e,i,s).map(e=>()=>e)}};var th=r(43667),tp=r(84198);let td={kernelName:eS.p2J,inputsToSave:["x","filter"],gradFunc:(e,t,r)=>{let[n,a]=t,{dilations:s,strides:i,pad:o,dataFormat:l}=r;return eX.vA(eJ.Dh(s),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`),{x:()=>(0,tp.v)(n.shape,e,a,i,o,l),filter:()=>(0,th.H)(n,e,a.shape,i,o,l)}}};var tc=r(61630);let tf={kernelName:eS.jfg,inputsToSave:["dy","filter"],gradFunc:(e,t,r)=>{let[n,a]=t,{strides:s,pad:i,dataFormat:o,dimRoundingMode:l}=r;return{dy:()=>(0,tc.X)(e,a,s,i,o,1,l),filter:()=>(0,th.H)(e,n,a.shape,s,i,o,l)}}},tm=(0,e0.op)({conv3DBackpropFilter_:function(e,t,r,n,a){let s=e;4===e.rank&&(s=(0,eM.t)(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let i=t;4===i.rank&&(i=(0,eM.t)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),eX.vA(5===s.rank,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${s.shape}.`),eX.vA(5===i.rank,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${i.shape}.`),eX.vA(5===r.length,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${r}.`),eX.vA(s.shape[4]===r[3],()=>`Error in conv3dDerFilter: depth of input ${s.shape[4]}) must match input depth in filter (${r[3]}.`),eX.vA(i.shape[4]===r[4],()=>`Error in conv3dDerFilter: depth of dy (${i.shape[4]}) must match output depth for filter (${r[4]}).`);let o={x:s,dy:i};return eQ.T2.runKernel(eS.iGz,o,{strides:n,pad:a,filterShape:r})}});var tg=r(85133);let ty={kernelName:eS.A1h,inputsToSave:["x","filter"],gradFunc:(e,t,r)=>{let{dilations:n,strides:a,pad:s}=r;eX.vA((0,eJ.Dh)(n),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${n}'`);let[i,o]=t;return{x:()=>(0,tg.c)(i.shape,e,o,a,s),filter:()=>tm(i,e,o.shape,a,s)}}};var tb=r(20020);let tx={kernelName:eS.Mn0,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)((0,eA.H)((0,tb.F)((0,eN.w)(r,"float32"))),e)}}};var tv=r(77688);let tw={kernelName:eS.MnK,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)((0,tv.L)((0,eN.w)(r,"float32")),e)}}};var tT=r(64256),tS=r(75104),tN=r(32021);let tk={kernelName:eS.nY8,inputsToSave:["x"],gradFunc:(e,t,r)=>
290{let[n]=t,{axis:a,exclusive:s,reverse:i}=r;return{x:()=>{let t=(0,tT.Em)([a],n.rank),r=(0,tS.r)(e,a,s,!i);return null!=t&&(r=(0,tN.m)(r,t)),r}}}};var tI=r(67532),tC=r(54402);let tE={kernelName:eS.tGH,inputsToSave:["x","filter"],gradFunc:(e,t,r)=>{let{dilations:n,strides:a,pad:s,dimRoundingMode:i}=r,o=null==n?[1,1]:n;eX.vA(eJ.Dh(o),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`);let[l,u]=t;return eX.vA(4===l.rank,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),eX.vA(4===u.rank,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${u.rank}.`),eX.vA(l.shape[3]===u.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${u.shape[2]}.`),eX.vA(eJ.G0(a,o),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${o}'.`),eJ.s_("depthwiseConv2d",s,i),{x:()=>(0,tC.l)(l.shape,e,u,a,s,o,i),filter:()=>(0,tI.x)(l,e,u.shape,a,s,o,i)}}},tA={kernelName:eS.jxD,inputsToSave:["x","filter"],gradFunc:(e,t,r)=>
290{let[n,a]=t,s={x:n,filter:a,dy:e},i={x:n,filter:a,dy:e};return{x:()=>eQ.T2.runKernel(eS.bP9,s,r),filter:()=>eQ.T2.runKernel(eS.pk0,i,r)}}},t$={kernelName:eS.Pah,outputsToSave:[!0],gradFunc:(e,t)=>{let[r]=t,n={dy:e,y:r};return{x:()=>eQ.T2.runKernel(eS.rsH,n)}}};var tF=r(29573);let tR={kernelName:eS._s9,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t,n=(0,ek.l)((0,tF.o)((0,eA.H)((0,eR.E)(r))),2/Math.sqrt(Math.PI));return{x:()=>(0,ek.l)(e,n)}}},t_={kernelName:eS.ox3,outputsToSave:[!0],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)(e,r)}}},tD={kernelName:eS.ybN,inputsToSave:["input"],gradFunc:(e,t)=>{let[r]=t;return{input:()=>(0,eM.t)(e,r.shape)}}},tO={kernelName:eS.ybj,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)(e,(0,tF.o)(r))}}},tL={kernelName:eS.ZgB,gradFunc:e=>({x:()=>(0,eW.P)(e)})},tM={kernelName:eS.ElG,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,eL.assertAndGetBroadcastShape)(r.shape,n.shape);return{a:()=>{let t=(0,eE.y)(e,(0,eN.w)(n,"float32")),s=(0,eL.getReductionAxes)(r.shape,a);return s.length>0?(0,eM.t)((0,eP.c)(t,s),r.shape):t},b:()=>{let t=(0,ek.l)(e,(0,eN.w)(r,"float32")),s=(0,eL.getReductionAxes)(n.shape,a);s.length>0&&(t=(0,eM.t)((0,eP.c)(t,s),n.shape));let i=(0,eR.E)(n);return(0,eA.H)((0,eE.y)(t,(0,eN.w)(i,"float32")))}}}};var tP=r(99858),tz=r(70818);let tB={kernelName:eS.i5R,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,r)=>{let{varianceEpsilon:n}=r,[a,s,i,o]=t,l=null==o?(0,e$.d)(1):o,u=(0,eL.getReductionAxes)(s.shape,a.shape),h=[];if(1===s.rank){for(let e=0;e<a.shape.length-1;++e)h.push(a.shape[e]);h.push(1)}let p=(0,e_.j)(a,s),d=(0,ek.l)(e,l),c=(0,tP.Z)((0,eZ.W)(i,(0,e$.d)(n))),f=(0,ek.l)((0,ek.l)((0,ek.l)(c,c),c),(0,e$.d)(-.5));return{x:()=>1===s.rank?(0,eM.t)((0,ek.l)((0,ek.l)(e,(0,tz.V)((0,eM.t)(c,[1,1,1,s.shape[0]]),h)),l),a.shape):(0,eM.t)((0,ek.l)((0,ek.l)(e,c),l),a.shape),mean:()=>{let e=(0,ek.l)((0,ek.l)(c,(0,e$.d)(-1)),d);return 1===s.rank&&(e=(0,eP.c)(e,u)),(0,eM.t)(e,s.shape)},variance:()=>{let e=(0,ek.l)((0,ek.l)(f,p),d);return 1===s.rank&&(e=(0,eP.c)(e,u)),(0,eM.t)(e,s.shape)},scale:()=>{let t=(0,ek.l)(p,c),r=(0,ek.l)(e,t);return 1===s.rank&&(r=(0,eP.c)(r,u)),(0,eM.t)(r,s.shape)},offset:()=>{let t=e;return 1===s.rank&&(t=(0,eP.c)(t,u)),(0,eM.t)(t,s.shape)}}}};var tW=r(40030),tV=r(15510);let tU={kernelName:eS.mxL,inputsToSave:["x","indices"],gradFunc:(e,t,r)=>
290{let[n,a]=t,{axis:s,batchDims:i}=r,o=(0,eX.Y6)(s,n.shape)[0],l=(e,t,r)=>()=>{let n=e.shape,a=t.size,i=n.slice(0,o),l=i.length,u=n.slice(s,n.length).slice(1),h=u.length,p=tG(0,l),d=tG(l+1,l+1+h),c=tZ([i,[a],u]),f=(0,eM.t)(r,c),m=(0,eM.t)(t,[a]),g=tZ([[l],p,d]),y=(0,tN.m)(f,g),b=(0,tV.z)(y,m,e.shape[o]),x=(0,tT.gx)(g);return(0,tN.m)(b,x)};if(1!==i)return{x:l(n,a,e),indices:()=>a};{let t=n.shape[0],r=n.split(t,0);return{x:()=>(0,tW.t)(r.map((t,r)=>l(t,a.slice(r,1),e.slice(r,1))())).reshape(n.shape),indices:()=>a}}}};function tG(e,t){let r=[];for(let n=e;n<t;++n)r.push(n);return r}function tZ(e){let t=[];for(let r=0;r<e.length;++r)for(let n=0;n<e[r].length;++n)t.push(e[r][n]);return t}let tj={kernelName:eS.lLS,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t;return{a:()=>(0,eW.P)(r),b:()=>(0,eW.P)(n)}}},tK={kernelName:eS.lzr,gradFunc:e=>({x:()=>(0,eN.w)(e,"float32")})},tH={kernelName:eS.gIW,gradFunc:e=>({x:()=>(0,eW.P)(e)})},tY={kernelName:eS.E3$,gradFunc:e=>({x:()=>(0,eW.P)(e)})},tQ={kernelName:eS.iPs,gradFunc:e=>({x:()=>(0,eW.P)(e)})};var tq=r(53784);let tX={kernelName:eS.X0$,inputsToSave:["x"],gradFunc:(e,t,r)=>
290{let[n]=t,{alpha:a}=r,s=(0,tq.r)(n,0);return{x:()=>(0,ts._)(s,e,(0,ek.l)(e,a))}}},tJ={kernelName:eS.Cg$,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eE.y)(e,(0,eZ.W)(r,1))}}},t0={kernelName:eS.tG8,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eE.y)(e,(0,eN.w)(r,"float32"))}}},t1={kernelName:eS.zfU,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,r)=>{let[n]=t,{axis:a}=r;return{logits:()=>{let t=(0,tF.o)(n);return(0,e_.j)(e,(0,ek.l)((0,eP.c)(e,a,!0),t))}}}},t2=(0,e0.op)({localResponseNormalizationBackprop_:function(e,t,r,n=5,a=1,s=1,i=.5){return eQ.T2.runKernel(eS.ToN,{x:e,y:t,dy:r},{depthRadius:n,bias:a,alpha:s,beta:i})}}),t3={kernelName:eS.jM4,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>{let[n,a]=t,{depthRadius:s,bias:i,alpha:o,beta:l}=r;return{x:()=>t2(n,a,e,s,i,o,l)}}};var t4=r(96414);function t6(e,t,r,n){return t.rank<r.rank&&(t=(0,eM.t)(t,tT.SM(t.shape,n))),e.rank<r.rank&&(e=(0,eM.t)(e,tT.SM(e.shape,n))),{x:()=>(0,ek.l)(e,(0,eN.w)((0,t4.L)(r,t),e.dtype))}}let t5={kernelName:eS.VAI,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>{let{reductionIndices:n}=r,a=t[0],s=t[1],i=eX.Y6(n,a.shape),o=t6(e,s,a,i);return{x:()=>o.x()}}};var t8=r(21419);let t7={kernelName:eS.LDN,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t;return{a:()=>(0,ek.l)(e,(0,eN.w)((0,tr.D)(r,n),"float32")),b:()=>(0,ek.l)(e,(0,eN.w)((0,t8.M)(r,n),"float32"))}}},t9=(0,e0.op)({maxPool3dGrad_:function(e,t,r,n,a,s,i){let o=(0,eq.YT)(e,"dy","maxPool3dGrad"),l=(0,eq.YT)(t,"input","maxPool3dGrad"),u=(0,eq.YT)(r,"output","maxPool3dGrad"),h=o,p=l,d=u,c=!1;4===l.rank&&(c=!0,h=(0,eM.t)(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=(0,eM.t)(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),d=(0,eM.t)(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),eX.vA(5===h.rank,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${h.rank}.`),eX.vA(5===p.rank,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`),eX.vA(5===d.rank,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`),(0,eJ.s_)("maxPool3dGrad",s,i);let f={dy:h,input:p,output:d},m=eQ.T2.runKernel(eS.cHb,f,{filterSize:n,strides:a,pad:s,dimRoundingMode:i});return c?(0,eM.t)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}}),re={kernelName:eS.ySp,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>
290{let[n,a]=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=r;return{x:()=>t9(e,n,a,s,i,o,l)}}},rt=(0,e0.op)({maxPoolGrad_:function(e,t,r,n,a,s,i){let o=(0,eq.YT)(e,"dy","maxPoolGrad"),l=(0,eq.YT)(t,"input","maxPoolGrad"),u=(0,eq.YT)(r,"output","maxPoolGrad");return eX.vA(l.rank===o.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${o.rank})`),eX.vA(4===o.rank,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`),eX.vA(4===l.rank,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),eJ.s_("maxPoolGrad",s,i),eQ.T2.runKernel(eS.RXX,{dy:o,input:l,output:u},{filterSize:n,strides:a,pad:s,dimRoundingMode:i})}}),rr={kernelName:eS.t3d,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>{let[n,a]=t,{filterSize:s,strides:i,pad:o}=r;return{x:()=>rt(e,n,a,s,i,o)}}};var rn=r(4047);let ra={kernelName:eS.g5A,inputsToSave:["x"],gradFunc:(e,t,r)=>{let[n]=t,{axis:a}=r,s=eX.Y6(a,n.shape),i=(0,tT.lb)(n.shape,s)[1],o=eX.Ze(i);return{x:()=>{let t=n.shape.slice();s.forEach(e=>{t[e]=1});let r=(0,eM.t)(e,t);return(0,eE.y)((0,ek.l)(r,(0,rn.S)(n.shape,"float32")),o)}}}},rs={kernelName:eS.lNG,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>{let{axis:n}=r,[a,s]=t,i=eX.Y6(n,a.shape),o=t6(e,s,a,i);return{x:()=>o.x()}}},ri={kernelName:eS.LG0,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t;return{a:()=>(0,ek.l)(e,(0,eN.w)((0,tn.I)(r,n),"float32")),b:()=>(0,ek.l)(e,(0,eN.w)((0,tq.r)(r,n),"float32"))}}};var ro=r(61324);let rl={kernelName:eS.x7F,inputsToSave:["x"],gradFunc:(e,t,r)=>{let n=t[0],{paddings:a}=r,s=a.map(e=>e[0]);return{x:()=>(0,ro.d)(e,s,n.shape)}}};var ru=r(70168);let rh={kernelName:eS.BLA,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,eL.assertAndGetBroadcastShape)(r.shape,n.shape);return{a:()=>{let t=(0,eL.getReductionAxes)(r.shape,a);return t.length>0?(0,eM.t)((0,eP.c)(e,t),r.shape):e},b:()=>{let t=(0,ek.l)(e,(0,eA.H)((0,ru.R)((0,eE.y)(r,n)))),s=(0,eL.getReductionAxes)(n.shape,a);return s.length>0?(0,eM.t)((0,eP.c)(t,s),n.shape):t}}}},rp={kernelName:eS.xu7,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,eL.assertAndGetBroadcastShape)(r.shape,n.shape);return{a:()=>{let t=(0,ek.l)(e,(0,eN.w)(n,"float32")),s=(0,eL.getReductionAxes)(r.shape,a);return s.length>0?(0,eM.t)((0,eP.c)(t,s),r.shape):t},b:()=>{let t=(0,ek.l)(e,(0,eN.w)(r,"float32")),s=(0,eL.getReductionAxes)(n.shape,a);return s.length>0?(0,eM.t)((0,eP.c)(t,s),n.shape):t}}}}
290,rd={kernelName:eS.l0G,gradFunc:e=>({x:()=>(0,eA.H)(e)})};var rc=r(45921);let rf={kernelName:eS.urI,inputsToSave:["indices"],gradFunc:(e,t)=>{let r=t[0];return{indices:()=>(0,rc.U)(r.shape,"float32")}}},rm={kernelName:eS.LWX,gradFunc:e=>({x:()=>(0,eW.P)(e)})};var rg=r(3535);let ry={kernelName:eS.mM$,saveAllInputs:!0,gradFunc:(e,t,r)=>{let{axis:n}=r;return(0,rg.K)(e,n).map(e=>()=>e)}},rb={kernelName:eS.ODT,inputsToSave:["x"],gradFunc:(e,t,r)=>{let n=t[0],{paddings:a}=r,s=a.map(e=>e[0]);return{x:()=>(0,ro.d)(e,s,n.shape)}}};var rx=r(78412),rv=r(17392);let rw={kernelName:eS.pyJ,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{let[r,n,a]=t,s=eL.assertAndGetBroadcastShape(r.shape,n.shape);return{a:()=>{let t=(0,eN.w)(n,"float32"),a=(0,ek.l)(e,(0,ek.l)(t,(0,rv.n)(r,(0,e_.j)(t,(0,e$.d)(1))))),i=eL.getReductionAxes(r.shape,s);return i.length>0&&(a=(0,eP.c)(a,i)),(0,eM.t)(a,r.shape)},b:()=>{let t=(0,tq.r)(r,0),i=(0,ts._)(t,(0,rx.R)(r),(0,eW.P)(r)),o=(0,ek.l)(e,(0,ek.l)(a,i)),l=eL.getReductionAxes(n.shape,s);return l.length>0&&(o=(0,eP.c)(o,l)),(0,eM.t)(o,n.shape)}}}},rT={kernelName:eS.Ncv,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,tq.r)(r,0);return{x:()=>(0,ts._)(a,e,(0,ek.l)(e,n)),alpha:()=>{let t=(0,ts._)(a,(0,eW.P)(e),(0,ek.l)(e,r)),s=(0,eL.getReductionAxes)(n.shape,e.shape);return s.length>0&&(t=(0,eP.c)(t,s)),(0,eM.t)(t,n.shape)}}}};var rS=r(14732);let rN={kernelName:eS.kdj,inputsToSave:["x"],gradFunc:(e,t,r)=>
290{let[n]=t,{axis:a}=r,s=[];return s=null==a?n.shape.map((e,t)=>t):"number"==typeof a?[a]:a,{x:()=>(function(e,t,r){let n=e.shape.length,a=n-r.length,s=tT.Em(r,n),i=e;null!=s&&(i=(0,tN.m)(e,s));let o=i.shape.slice(),l=o.splice(n-r.length,r.length).reduce((e,t)=>e*t,1);o.push(l);let u=function(e,t,r){let n=e.shape.slice();n[r]=1;let a=(0,eM.t)(t,n),s=(0,rS.L)(e,r,!0,!1),i=(0,rS.L)(e,r,!0,!0),o=(0,ek.l)(s,i);return(0,ek.l)(a,o)}(i.reshape(o),t,a);if(u=u.reshape(i.shape),null!=s){let e=tT.gx(s);u=(0,tN.m)(u,e)}return u})(n,e,s)}}},rk={kernelName:eS.sDr,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=eL.assertAndGetBroadcastShape(r.shape,n.shape);return{a:()=>{let t=(0,eE.y)(e,(0,eN.w)(n,"float32")),s=eL.getReductionAxes(r.shape,a);return s.length>0?(0,eM.t)((0,eP.c)(t,s),r.shape):t},b:()=>{let t=(0,ek.l)(e,(0,eN.w)(r,"float32")),s=eL.getReductionAxes(n.shape,a);s.length>0&&(t=(0,eM.t)((0,eP.c)(t,s),n.shape));let i=(0,eR.E)(n);return(0,eA.H)((0,eE.y)(t,(0,eN.w)(i,"float32")))}}}},rI={kernelName:eS.huO,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eE.y)(e,(0,eA.H)((0,eR.E)(r)))}}},rC={kernelName:eS.P_L,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t,n=(0,ek.l)((0,tn.I)(r,6),(0,eI.P)(r));return{x:()=>(0,ek.l)(e,(0,eN.w)(n,"float32"))}}},rE={kernelName:eS.fUj,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)(e,(0,eN.w)((0,eI.P)(r),"float32"))}}},rA={kernelName:eS.R23,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eM.t)(e,r.shape)}}},r$={kernelName:eS.hgw,inputsToSave:["images"],gradFunc:(e,t,r)=>
290{let[n]=t,a={dy:e,images:n};return{images:()=>eQ.T2.runKernel(eS.FCQ,a,r)}}},rF={kernelName:eS.jOE,inputsToSave:["images"],gradFunc:(e,t,r)=>{let[n]=t,a={dy:e,images:n};return{images:()=>eQ.T2.runKernel(eS.XQy,a,r)}}};var rR=r(2632);let r_={kernelName:eS.D7i,gradFunc:(e,t,r)=>{let{dims:n}=r,a=(0,eX.Y6)(n,e.shape);return{x:()=>(0,rR.B)(e,a)}}},rD={kernelName:eS.hVg,gradFunc:e=>({x:()=>(0,eW.P)(e)})},rO={kernelName:eS.TOR,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eA.H)((0,eE.y)(e,(0,ek.l)((0,rv.n)(r,1.5),2)))}}};var rL=r(22599);let rM={kernelName:eS.l6P,inputsToSave:["condition"],gradFunc:(e,t)=>{let[r]=t;return{condition:()=>(0,eN.w)((0,eW.P)(r),"float32"),t:()=>(0,ek.l)(e,(0,eN.w)(r,e.dtype)),e:()=>(0,ek.l)(e,(0,eN.w)((0,rL.N)(r),e.dtype))}}};var rP=r(16530);let rz={kernelName:eS.u$b,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>{let t=(0,tq.r)(r,(0,e$.d)(0)),n=(0,e$.d)(rP.j),a=(0,e$.d)(rP.X),s=(0,ek.l)(e,a),i=(0,ek.l)((0,ek.l)(e,n),(0,tF.o)((0,eN.w)(r,"float32")));return(0,ts._)(t,s,i)}}}},rB={kernelName:eS.vI1,outputsToSave:[!0],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)(e,(0,ek.l)(r,(0,e_.j)((0,e$.d)(1),r)))}}},rW={kernelName:eS.YVe,gradFunc:e=>({x:()=>(0,eW.P)(e)})};var rV=r(67633);let rU={kernelName:eS.hql,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)((0,rV.g)((0,eN.w)(r,"float32")),e)}}};var rG=r(55107);let rZ={kernelName:eS.J3C,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)((0,rG.y)((0,eN.w)(r,"float32")),e)}}};var rj=r(89967),rK=r(75521);let rH={kernelName:eS.JiE,inputsToSave:["x"],gradFunc:(e,t,r)=>
290{let[n]=t,{begin:a,size:s}=r,i=n.shape,[o,l]=(0,rK.parseSliceParams)(n,a,s),u=[];for(let t=0;t<e.rank;t++)u.push([o[t],i[t]-o[t]-l[t]]);return{x:()=>(0,rj.e)(e,u)}}},rY={kernelName:eS.rFG,outputsToSave:[!0],gradFunc:(e,t,r)=>{let[n]=t,{dim:a}=r,s=(0,ek.l)(e,n);return{logits:()=>(0,e_.j)(s,(0,ek.l)((0,eP.c)(s,[a],!0),n))}}};var rQ=r(89510);let rq={kernelName:eS.Fin,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)(e,(0,rQ.r)(r))}}};var rX=r(71550);let rJ={kernelName:eS.A8B,gradFunc:(e,t,r)=>{let{blockShape:n,paddings:a}=r;return{x:()=>(0,rX.G)(e,n,a)}}};var r0=r(76110);let r1={kernelName:eS.Blb,gradFunc:(e,t,r)=>{let{axis:n}=r;return{x:()=>(0,r0.x)(e,n)}}},r2={kernelName:eS.dFH,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eE.y)(e,(0,ek.l)((0,eF.R)((0,eN.w)(r,"float32")),2))}}},r3={kernelName:eS.M6A,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)(e,(0,ek.l)((0,eN.w)(r,"float32"),2))}}},r4={kernelName:eS.Ddj,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,e$.d)(2);return{a:()=>(0,ek.l)(e,(0,ek.l)(a,(0,e_.j)(r,n))),b:()=>(0,ek.l)(e,(0,ek.l)(a,(0,e_.j)(n,r)))}}},r6={kernelName:eS.pnw,gradFunc:e=>({x:()=>(0,eW.P)(e)})},r5={kernelName:eS.PbM,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=eL.assertAndGetBroadcastShape(r.shape,n.shape);return{a:()=>{let t=e,n=eL.getReductionAxes(r.shape,a);return n.length>0&&(t=(0,eP.c)(t,n)),(0,eM.t)(t,r.shape)},b:()=>{let t=e,r=eL.getReductionAxes(n.shape,a);return r.length>0&&(t=(0,eP.c)(t,r)),(0,eM.t)((0,eA.H)(t),n.shape)}}}},r8={kernelName:eS.WuN,inputsToSave:["x"],gradFunc:(e,t,r)=>
290{let[n]=t,a=n.shape.slice(),{axis:s}=r;(0,eX.Y6)(s,n.shape).forEach(e=>{a[e]=1});let i=(0,eM.t)(e,a),o=(0,ek.l)(i,(0,rn.S)(n.shape,"float32"));return{x:()=>o}}},r7={kernelName:eS.oFs,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,eE.y)(e,(0,eR.E)((0,rV.g)(r)))}}},r9={kernelName:eS.iuW,outputsToSave:[!0],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,ek.l)((0,e_.j)((0,e$.d)(1),(0,eR.E)(r)),e)}}},ne={kernelName:eS.FAs,inputsToSave:["x"],gradFunc:(e,t,r)=>{let[n]=t,{reps:a}=r;return{x:()=>{let t=(0,eW.P)(n);if(1===n.rank)for(let r=0;r<a[0];++r)t=(0,eZ.W)(t,(0,ro.d)(e,[r*n.shape[0]],[n.shape[0]]));else if(2===n.rank)for(let r=0;r<a[0];++r)for(let s=0;s<a[1];++s)t=(0,eZ.W)(t,(0,ro.d)(e,[r*n.shape[0],s*n.shape[1]],[n.shape[0],n.shape[1]]));else if(3===n.rank)for(let r=0;r<a[0];++r)for(let s=0;s<a[1];++s)for(let i=0;i<a[2];++i)t=(0,eZ.W)(t,(0,ro.d)(e,[r*n.shape[0],s*n.shape[1],i*n.shape[2]],[n.shape[0],n.shape[1],n.shape[2]]));else if(4===n.rank)for(let r=0;r<a[0];++r)for(let s=0;s<a[1];++s)for(let i=0;i<a[2];++i)for(let o=0;o<a[3];++o)t=(0,eZ.W)(t,(0,ro.d)(e,[r*n.shape[0],s*n.shape[1],i*n.shape[2],o*n.shape[3]],[n.shape[0],n.shape[1],n.shape[2],n.shape[3]]));else throw Error(`Gradient for tile operation is not implemented for rank-${n.rank} tensors yet.`);return t}}}},nt={kernelName:eS.wx0,gradFunc:(e,t,r)=>{let{perm:n}=r,a=tT.gx(n);return{x:()=>(0,tN.m)(e,a)}}},nr={kernelName:eS.dXR,gradFunc:(e,t,r)=>{let{axis:n}=r;return{value:()=>(0,tW.t)(e,n)}}};var nn=r(56992),na=r(52829),ns=r(3824);let ni={kernelName:eS.pPe,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(function(e,t){let r=(0,ns.P)(t,(0,eW.P)(t)),n=(0,na.k)(e,r),a=(0,tr.D)(t,(0,e$.d)(0,"int32")),s=n.rank-a.rank;for(let e=0;e<s;++e)a=(0,nn.U)(a,e+1);a=(0,ta.n)(a,(0,rn.S)(n.shape,"bool"));let i=(0,eW.P)(n);return(0,ts._)(a,n,i)})(e,r)}}}
290,no={kernelName:eS.xJ3,gradFunc:e=>({x:()=>(0,eW.P)(e)})};var nl=r(22548);for(let e of[eC,eD,eO,ez,eB,eV,eU,eG,ej,eK,eH,eY,e2,e4,e5,e7,e9,te,tt,ti,to,tu,tf,td,ty,tx,tw,tk,tE,tA,rk,t$,tR,t_,tD,tO,tM,tL,tB,tU,tj,tK,tH,tY,tQ,tX,tJ,t0,t1,t3,t5,t5,t7,re,rr,ra,rs,ri,rl,rh,rp,rd,rf,rm,ry,rb,rb,rw,rT,rN,rI,rC,rE,rA,r$,rF,r_,rD,rO,rM,rz,rB,rW,rU,rZ,rH,rY,rq,rJ,rJ,r1,r1,r2,r4,r3,r6,r5,r8,r7,r9,ne,nt,nr,ni,no])(0,nl.kr)(e);var nu=r(4006),nh=r(94708);(0,nh.tp)().prototype.abs=function(){return this.throwIfDisposed(),(0,nu.t)(this)};var np=r(36);(0,nh.tp)().prototype.acos=function(){return this.throwIfDisposed(),(0,np.H)(this)};var nd=r(17096);(0,nh.tp)().prototype.acosh=function(){return this.throwIfDisposed(),(0,nd.F)(this)},(0,nh.tp)().prototype.add=function(e){return this.throwIfDisposed(),(0,eZ.W)(this,e)};var nc=r(45073);(0,nh.tp)().prototype.all=function(e,t){return this.throwIfDisposed(),(0,nc.Q)(this,e,t)};var nf=r(84996);(0,nh.tp)().prototype.any=function(e,t){return this.throwIfDisposed(),(0,nf.b)(this,e,t)};var nm=r(32999);(0,nh.tp)().prototype.argMax=function(e){return this.throwIfDisposed(),(0,nm.F)(this,e)};var ng=r(82065);(0,nh.tp)().prototype.argMin=function(e){return this.throwIfDisposed(),(0,ng.X)(this,e)},(0,nh.tp)().prototype.asScalar=function(){return this.throwIfDisposed(),(0,eX.vA)(1===this.size,()=>"The array must have only 1 element."),(0,eM.t)(this,[])},(0,nh.tp)().prototype.asType=function(e){return this.throwIfDisposed(),(0,eN.w)(this,e)},(0,nh.tp)().prototype.as1D=function(){return this.throwIfDisposed(),(0,eM.t)(this,[this.size])},(0,nh.tp)().prototype.as2D=function(e,t){return this.throwIfDisposed(),(0,eM.t)(this,[e,t])},(0,nh.tp)().prototype.as3D=function(e,t,r){return this.throwIfDisposed(),(0,eM.t)(this,[e,t,r])},(0,nh.tp)().prototype.as4D=function(e,t,r,n){return this.throwIfDisposed(),(0,eM.t)(this,[e,t,r,n])},(0,nh.tp)().prototype.as5D=function(e,t,r,n,a){return this.throwIfDisposed(),(0,eM.t)(this,[e,t,r,n,a])};var ny=r(76565);(0,nh.tp)().prototype.asin=function(){return this.throwIfDisposed(),(0,ny.q)(this)};var nb=r(72655);(0,nh.tp)().prototype.asinh=function(){return this.throwIfDisposed(),(0,nb.y)(this)};var nx=r(18200);(0,nh.tp)().prototype.atan=function(){return this.throwIfDisposed(),(0,nx.r)(this)};var nv=r(48138);(0,nh.tp)().prototype.atan2=function(e){return this.throwIfDisposed(),(0,nv.F)(this,e)};var nw=r(39316);(0,nh.tp)().prototype.atanh=function(){return this.throwIfDisposed(),(0,nw.r)(this)};var nT=r(86049);(0,nh.tp)().prototype.avgPool=function(e,t,r,n){return this.throwIfDisposed(),(0,nT.$)(this,e,t,r,n)},(0,nh.tp)().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),(0,rX.G)(this,e,t)};var nS=r(66287);(0,nh.tp)().prototype.batchNorm=function(e,t,r,n,a){return this.throwIfDisposed(),(0,nS.$)(this,e,t,r,n,a)};var nN=r(35199);(0,nh.tp)().prototype.broadcastTo=function(e){return this.throwIfDisposed(),(0,nN.h)(this,e)},(0,nh.tp)().prototype.cast=function(e){return this.throwIfDisposed(),(0,eN.w)(this,e)};var nk=r(89827);(0,nh.tp)().prototype.ceil=function(){return this.throwIfDisposed(),(0,nk.m)(this)};var nI=r(8046);(0,nh.tp)().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),(0,nI.z)(this,e,t)},(0,nh.tp)().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof nh.qY&&(e=[e]),(0,r0.x)([this,...e],t)};var nC=r(16289);(0,nh.tp)().prototype.conv1d=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,nC.k)(this,e,t,r,n,a,s)};var nE=r(57238);(0,nh.tp)().prototype.conv2dTranspose=function(e,t,r,n,a){return this.throwIfDisposed(),(0,nE.w)(this,e,t,r,n,a)},(0,nh.tp)().prototype.conv2d=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,tc.X)(this,e,t,r,n,a,s)},(0,nh.tp)().prototype.cos=function(){return this.throwIfDisposed(),(0,rV.g)(this)},(0,nh.tp)().prototype.cosh=function(){return this.throwIfDisposed(),(0,rG.y)(this)},(0,nh.tp)().prototype.cumprod=function(e,t,r){return this.throwIfDisposed(),(0,rS.L)(this,e,t,r)},(0,nh.tp)().prototype.cumsum=function(e,t,r){return this.throwIfDisposed(),(0,tS.r)(this,e,t,r)};var nA=r(93620);(0,nh.tp)().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),(0,nA.R)(this,e,t)};var n$=r(55756);(0,nh.tp)().prototype.depthwiseConv2d=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,n$.G)(this,e,t,r,n,a,s)};var nF=r(45770);(0,nh.tp)().prototype.dilation2d=function(e,t,r,n,a){return this.throwIfDisposed(),(0,nF.X)(this,e,t,r,n,a)};var nR=r(38579);(0,nh.tp)().prototype.divNoNan=function(e){return this.throwIfDisposed(),(0,nR.e)(this,e)},(0,nh.tp)().prototype.div=function(e){return this.throwIfDisposed(),(0,eE.y)(this,e)};var n_=r(17965);(0,nh.tp)().prototype.dot=function(e){return this.throwIfDisposed(),(0,n_.O)(this,e)};var nD=r(48066);(0,nh.tp)().prototype.elu=function(){return this.throwIfDisposed(),(0,nD.P)(this)},(0,nh.tp)().prototype.equal=function(e){return this.throwIfDisposed(),(0,t4.L)(this,e)};var nO=r(37953);(0,nh.tp)().prototype.erf=function(){return this.throwIfDisposed(),(0,nO.Y)(this)};var nL=r(75429);(0,nh.tp)().prototype.euclideanNorm=function(e,t){return this.throwIfDisposed(),(0,nL.p)(this,e,t)},(0,nh.tp)().prototype.exp=function(){return this.throwIfDisposed(),(0,tF.o)(this)},(0,nh.tp)().prototype.expandDims=function(e){return this.throwIfDisposed(),(0,nn.U)(this,e)};var nM=r(31519);(0,nh.tp)().prototype.expm1=function(){return this.throwIfDisposed(),(0,nM.I)(this)};var nP=r(22313);(0,nh.tp)().prototype.fft=function(){return this.throwIfDisposed(),(0,nP.h)(this)},(0,nh.tp)().prototype.flatten=function(){return this.throwIfDisposed(),(0,eM.t)(this,[this.size])},(0,nh.tp)().prototype.floor=function(){return this.throwIfDisposed(),(0,ru.R)(this)};var nz=r(44691);(0,nh.tp)().prototype.floorDiv=function(e){return this.throwIfDisposed(),(0,nz.w)(this,e)},(0,nh.tp)().prototype.gather=function(e,t,r){return this.throwIfDisposed(),(0,na.k)(this,e,t,r)},(0,nh.tp)().prototype.greaterEqual=function(e){return this.throwIfDisposed(),(0,tr.D)(this,e)},(0,nh.tp)().prototype.greater=function(e){return this.throwIfDisposed(),(0,tq.r)(this,e)};
290var nB=r(74442);(0,nh.tp)().prototype.ifft=function(){return this.throwIfDisposed(),(0,nB.K)(this)};var nW=r(85648);(0,nh.tp)().prototype.irfft=function(){return this.throwIfDisposed(),(0,nW.g)(this)};var nV=r(68120);(0,nh.tp)().prototype.isFinite=function(){return this.throwIfDisposed(),(0,nV.M)(this)};var nU=r(32382);(0,nh.tp)().prototype.isInf=function(){return this.throwIfDisposed(),(0,nU.E)(this)};var nG=r(60676);(0,nh.tp)().prototype.isNaN=function(){return this.throwIfDisposed(),(0,nG.y)(this)};var nZ=r(7907);(0,nh.tp)().prototype.leakyRelu=function(e){return this.throwIfDisposed(),(0,nZ.H)(this,e)},(0,nh.tp)().prototype.lessEqual=function(e){return this.throwIfDisposed(),(0,tn.I)(this,e)},(0,nh.tp)().prototype.less=function(e){return this.throwIfDisposed(),(0,t8.M)(this,e)};var nj=r(51855);(0,nh.tp)().prototype.localResponseNormalization=function(e,t,r,n){return this.throwIfDisposed(),(0,nj.K)(this,e,t,r,n)};var nK=r(16311);(0,nh.tp)().prototype.logSigmoid=function(){return this.throwIfDisposed(),(0,nK.n)(this)};var nH=r(43137);(0,nh.tp)().prototype.logSoftmax=function(e){return this.throwIfDisposed(),(0,nH.H)(this,e)};var nY=r(1056);(0,nh.tp)().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),(0,nY.V)(this,e,t)},(0,nh.tp)().prototype.log=function(){return this.throwIfDisposed(),(0,rx.R)(this)};var nQ=r(61017);(0,nh.tp)().prototype.log1p=function(){return this.throwIfDisposed(),(0,nQ.K)(this)},(0,nh.tp)().prototype.logicalAnd=function(e){return this.throwIfDisposed(),(0,ta.n)(this,e)},(0,nh.tp)().prototype.logicalNot=function(){return this.throwIfDisposed(),(0,rL.N)(this)};var nq=r(15299);(0,nh.tp)().prototype.logicalOr=function(e){return this.throwIfDisposed(),(0,nq.z)(this,e)};var nX=r(93107);(0,nh.tp)().prototype.logicalXor=function(e){return this.throwIfDisposed(),(0,nX.r)(this,e)},(0,nh.tp)().prototype.matMul=function(e,t,r){return this.throwIfDisposed(),(0,e6.N)(this,e,t,r)};var nJ=r(52899);(0,nh.tp)().prototype.maxPool=function(e,t,r,n){return this.throwIfDisposed(),(0,nJ.j)(this,e,t,r,n)};var n0=r(39616);(0,nh.tp)().prototype.max=function(e,t){return this.throwIfDisposed(),(0,n0.T)(this,e,t)},(0,nh.tp)().prototype.maximum=function(e){return this.throwIfDisposed(),(0,ns.P)(this,e)};var n1=r(70995);(0,nh.tp)().prototype.mean=function(e,t){return this.throwIfDisposed(),(0,n1.i)(this,e,t)};var n2=r(67146);(0,nh.tp)().prototype.min=function(e,t){return this.throwIfDisposed(),(0,n2.
290j)(this,e,t)};var n3=r(32266);(0,nh.tp)().prototype.minimum=function(e){return this.throwIfDisposed(),(0,n3.B)(this,e)};var n4=r(25435);(0,nh.tp)().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),(0,n4.F)(this,e,t)};var n6=r(69314);(0,nh.tp)().prototype.mod=function(e){return this.throwIfDisposed(),(0,n6.z)(this,e)},(0,nh.tp)().prototype.mul=function(e){return this.throwIfDisposed(),(0,ek.l)(this,e)},(0,nh.tp)().prototype.neg=function(){return this.throwIfDisposed(),(0,eA.H)(this)};var n5=r(75904);(0,nh.tp)().prototype.norm=function(e,t,r){return this.throwIfDisposed(),(0,n5.x)(this,e,t,r)};var n8=r(5232);(0,nh.tp)().prototype.notEqual=function(e){return this.throwIfDisposed(),(0,n8.E)(this,e)};var n7=r(42926);(0,nh.tp)().prototype.oneHot=function(e,t=1,r=0){return this.throwIfDisposed(),(0,n7.M)(this,e,t,r)};var n9=r(12575);(0,nh.tp)().prototype.onesLike=function(){return this.throwIfDisposed(),(0,n9.P)(this)},(0,nh.tp)().prototype.pad=function(e,t){return this.throwIfDisposed(),(0,rj.e)(this,e,t)};var ae=r(89200);(0,nh.tp)().prototype.pool=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,ae.d)(this,e,t,r,n,a,s)},(0,nh.tp)().prototype.pow=function(e){return this.throwIfDisposed(),(0,rv.n)(this,e)};var at=r(22864);(0,nh.tp)().prototype.prelu=function(e){return this.throwIfDisposed(),(0,at.N)(this,e)};var ar=r(16263);(0,nh.tp)().prototype.prod=function(e,t){return this.throwIfDisposed(),(0,ar._)(this,e,t)};var an=r(33202);(0,nh.tp)().prototype.reciprocal=function(){return this.throwIfDisposed(),(0,an.V)(this)};var aa=r(3344);(0,nh.tp)().prototype.relu=function(){return this.throwIfDisposed(),(0,aa.V)(this)};var as=r(93406);(0,nh.tp)().prototype.relu6=function(){return this.throwIfDisposed(),(0,as.j)(this)},(0,nh.tp)().prototype.reshapeAs=function(e){return this.throwIfDisposed(),(0,eM.t)(this,e.shape)},(0,nh.tp)().prototype.reshape=function(e){return this.throwIfDisposed(),(0,eM.t)(this,e)};var ai=r(46921);(0,nh.tp)().prototype.resizeBilinear=function(e,t,r){return this.throwIfDisposed(),(0,ai.v)(this,e,t,r)};var ao=r(94715);(0,nh.tp)().prototype.resizeNearestNeighbor=function(e,t,r){return this.throwIfDisposed(),(0,ao.b)(this,e,t,r)},(0,nh.tp)().prototype.reverse=function(e){return this.throwIfDisposed(),(0,rR.B)(this,e)};var al=r(42153);(0,nh.tp)().prototype.rfft=function(){return this.throwIfDisposed(),(0,al.z)(this)};var au=r(590);(0,nh.tp)().prototype.round=function(){return this.throwIfDisposed(),(0,au.L)(this)},(0,nh.tp)().prototype.rsqrt=function(){return this.throwIfDisposed(),(0,tP.Z)(this)};var ah=r(79069);(0,nh.tp)().prototype.selu=function(){return this.throwIfDisposed(),(0,ah.W)(this)};var ap=r(82178);(0,nh.tp)().prototype.separableConv2d=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,ap.w)(this,e,t,r,n,a,s)},(0,nh.tp)().prototype.sigmoid=function(){return this.throwIfDisposed(),(0,rQ.r)(this)};var ad=r(13219);(0,nh.tp)().prototype.sign=function(){return this.throwIfDisposed(),(0,ad._)(this)},(0,nh.tp)().prototype.sin=function(){return this.throwIfDisposed(),(0,tb.F)(this)},(0,nh.tp)().prototype.sinh=function(){return this.throwIfDisposed(),(0,tv.L)(this)},(0,nh.tp)().prototype.slice=function(e,t){return this.throwIfDisposed(),(0,ro.d)(this,e,t)};var ac=r(19832);(0,nh.tp)().prototype.softmax=function(e){return this.throwIfDisposed(),(0,ac.V)(this,e)};var af=r(62958);(0,nh.tp)().prototype.softplus=function(){return this.throwIfDisposed(),(0,af.l)(this)},(0,nh.tp)().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),(0,e8.e)(this,e,t)},(0,nh.tp)().prototype.split=function(e,t){return this.throwIfDisposed(),(0,tl.l)(this,e,t)},(0,nh.tp)().prototype.sqrt=function(){return this.throwIfDisposed(),(0,eF.R)(this)},(0,nh.tp)().prototype.square=function(){return this.throwIfDisposed(),(0,eR.E)(this)};var am=r(62131);(0,nh.tp)().prototype.squaredDifference=function(e){return this.throwIfDisposed(),(0,am.P)(this,e)};var ag=r(74338);(0,nh.tp)().prototype.squeeze=function(e){return this.throwIfDisposed(),(0,ag.r)(this,e)},(0,nh.tp)().prototype.stack=function(e,t){this.throwIfDisposed();let r=e instanceof nh.qY?[this,e]:[this,...e];return(0,tW.t)(r,t)},(0,nh.tp)().prototype.step=function(e){return this.throwIfDisposed(),(0,eI.P)(this,e)};var ay=r(16496);(0,nh.tp)().prototype.stridedSlice=function(e,t,r,n,a,s,i,o){return this.throwIfDisposed(),(0,ay.Y)(this,e,t,r,n,a,s,i,o)},(0,nh.tp)().prototype.sub=function(e){return this.throwIfDisposed(),(0,e_.j)(this,e)},(0,nh.tp)().prototype.sum=function(e,t){return this.throwIfDisposed(),(0,eP.c)(this,e,t)};var ab=r(22489);(0,nh.tp)().prototype.tan=function(){return this.throwIfDisposed(),(0,ab.M)(this)};var ax=r(54283);(0,nh.tp)().prototype.tanh=function(){return this.throwIfDisposed(),(0,ax.y)(this)},(0,nh.tp)().prototype.tile=function(e){return this.throwIfDisposed(),(0,tz.V)(this,e)},(0,nh.tp)().prototype.toBool=function(){return this.throwIfDisposed(),(0,eN.w)(this,"bool")},(0,nh.tp)().prototype.toFloat=function(){return this.throwIfDisposed(),(0,eN.w)(this,"float32")},(0,nh.tp)().prototype.toInt=function(){return this.throwIfDisposed(),(0,eN.w)(this,"int32")};var av=r(82870);(0,nh.tp)().prototype.topk=function(e,t){return this.throwIfDisposed(),(0,av.r)(this,e,t)},(0,nh.tp)().prototype.transpose=function(e){return this.throwIfDisposed(),(0,tN.m)(this,e)};var aw=r(39533);(0,nh.tp)().prototype.unique=function(e){return this.throwIfDisposed(),(0,aw.A)(this,e)},(0,nh.tp)().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),(0,tV.z)(this,e,t)},(0,nh.tp)().prototype.unstack=function(e){return this.throwIfDisposed(),(0,rg.K)(this,e)},(0,nh.tp)().prototype.where=function(e,t){return this.throwIfDisposed(),(0,ts._)(e,this,t)},(0,nh.tp)().prototype.zerosLike=function(){return this.throwIfDisposed(),(0,eW.P)(this)};var aT=r(86376);(0,W._K2)().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",()=>100,aT.oR);var aS=r(40838);function aN(e){return new aS.DE(e)}function ak(e){return new aS.xS(e)}function aI(){return new aS.sQ}function aC(e){return new aS.vJ(e)}var aE=r(42290);function aA(){return new aE._c}function a$(){return new aE.sN}function aF(e){return new aE.h8(e)}function aR(e){return new aE.m9(e)}function a_(e){return new aE.rZ(e)}function aD(e){return new aE.EE(e)}function aO(e){return new aE.lz(e)}function aL(e){return new aE.Lm(e)}function aM(e){return new aE.Ux(e)}function aP(e){return new aE.xd(e)}function az(e){return new aE.bL(e)}function aB(e){return new aE.KJ(e)}function aW(e){return new aE.TO(e)}function aV(e){return new aE.Gs(e)}function aU(e){return new aE.iv(e)}var aG=r(35832),aZ=r(32593),aj=r(53227);function aK(e,t){return aj.xM(e,t)}function aH(e,t){return aj.Jc(e,t)}function aY(e,t){return aj.qv(e,t)}function aQ(e,t){return aj.yP(e,t)}function aq(e,t){return aj.Ol(e,t)}function aX(e,t){return aj.Fz(e,t)}function aJ(e,t){return aj.I9(e,t)}function a0(e,t){return aZ.Pg(e,t)}function a1(e,t){return aZ.Xv(e,t)}function a2(e,t){return aZ.VW(e,t)}function a3(e,t){return aZ.VW(e,t)}function a4(e,t){return aZ.VW(e,t)}function a6(e,t){return aZ.bt(e,t)}function a5(e,t){return aZ.bt(e,t)}function a8(e,t){return aZ.bt(e,t)}function a7(e,t){return aj.ZY(e,t)}var a9=r(32280),se=r(76915);function st(e){return new se.G2(e)}function sr(e){return se.l1(e)}function sn(e){return se.l2(e)}var sa=r(54868),ss=r(32655),si=r(63537),so=r(61237);class sl extends sa.J5{constructor(){super(...arguments),this.model=null}setModel(e){if(!(e instanceof ss.Gw))throw Error("model must be a LayersModel, not some other Container");this.model=e}}function su(e,t){return e<t}function sh(e,t){return e>t}class sp extends sl{constructor(e){if(super(),null==e&&(e={}),e.restoreBestWeights)throw new si.EH("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=e.monitor||"val_loss",this.minDelta=Math.abs(e.minDelta||0),this.patience=e.patience||0,this.verbose=e.verbose||0,this.mode=e.mode||"auto",this.baseline=e.baseline,-1===["auto","min","max"].indexOf(this.mode)&&(console.warn(`EarlyStopping mode '${this.mode}
290' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),"min"===this.mode?this.monitorFunc=su:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=sh:this.monitorFunc=su,this.monitorFunc===su&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===su?1/0:-1/0}async onEpochEnd(e,t){await (0,so.I)(t);let r=this.getMonitorValue(t);null!=r&&(this.monitorFunc(r-this.minDelta,this.best)?(this.best=r,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0)))}async onTrainEnd(e){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(e){null==e&&(e={});let t=e[this.monitor];return null==t&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`),t}}let sd={earlyStopping:function(e){return new sp(e)}};var sc=r(2748),sf=r(94865),sm=r(35721),sg=r(17031),sy=r(95390);(0,W._K2)().registerFlag("KEEP_INTERMEDIATE_TENSORS",()=>!1,e=>{e&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")}),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(a||(a={})),function(e){var t;(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2"}(s||(s={}));let sb={};function sx(e,t){sb[e]={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t}}function sv(e){delete sb[e]}function sw(e,t,r,n,a){let s=t.inputParams[e];if(s&&void 0!==s.inputIndexStart){let e=s.inputIndexStart,i=0===s.inputIndexEnd?void 0:void 0===s.inputIndexEnd?e+1:s.inputIndexEnd,o=e<0?t.inputNames.length+e:e;if("tensor"===s.type)return sT(t.inputNames[o],r,n,a);if("tensors"===s.type){let s=t.inputs.slice(e,i);return t.inputNames.slice(e,i).filter((e,t)=>{var r;return(null==(r=s[t])?void 0:r.op)!=="NoOp"}).map(e=>sT(e,r,n,a))}let l=sT(t.inputNames[o],r,n,a),u=l.dataSync();return"number"===s.type?u[0]:W.ZSL.toNestedArray(l.shape,u)}let i=t.attrParams[e];return i&&i.value}function sT(e,t,r,n){let[a,s]=sI(e,r);if(null!=n){let e=n.getHashTableHandleByName(a);if(null!=e)return e}let i=r.currentContextIds.find(e=>!!t[sk(a,e)]);return void 0!==i?t[sk(a,i)][s]:void 0}function sS(e,t,r){return t[sk(e,r.currentContextId)]}function sN(e,t){let[r,n,a]=sI(e,t);return[sk(r,t&&t.currentContextId),n,a]}function sk(e,t){return t?`${e}-${t}`:e}function sI(e,t){let r;if(""===e)return["",0,void 0];let n=null!=t&&null!=t.parseNodeNameCache;if(n){let r=t.parseNodeNameCache.get(e);if(null!=r)return r}let a=e.split(":");if(1===a.length)r=[e,0,void 0];else{let e=a[0],t=3===a.length?a[1]:void 0;r=[e,Number(a[a.length-1]),t]}return n&&t.parseNodeNameCache.set(e,r),r}function sC(e,t,r){let n=sw("pad",e,t,r);if("explicit"===n){n=sw("explicitPaddings",e,t,r);let a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=n[2*e],a[e][1]=n[2*e+1];return a}return n}function sE(e){return e.kept?e:(0,W.o8B)(e)}let sA=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
290]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],s$=
vendor: 6,808 bytes, line 290
290[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsFinite",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsInf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]
290,sF
vendor: 7,590 bytes, line 290
290=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],
vendor: 4,170 bytes, line 290
290sR=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}
290,{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],s_=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0}
290,{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniformInt",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number"},{tfName:"maxval",name:"maxval",type:"number"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],sD=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],sO=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],sL=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0}
290,{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],sM=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],sP=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}
290],sz=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BitwiseAnd",category:"logical",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}]}],sB=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"MatrixBandPart",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"numLower",type:"tensor"},{start:1,name:"numUpper",type:"tensor"}]}],sW=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}
290]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]}],sV=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],sU=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}
290]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]},{tfOpName:"TensorScatterUpdate",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],sG=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],sZ=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],sj=[{tfOpName:"StaticRegexReplace",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"pattern",name:"pattern",type:"string"},{tfName:"rewrite",name:"rewrite",type:"string"},{tfName:"replace_global",name:"replaceGlobal",type:"bool"}]},{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}
290],sK=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"EnsureShape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];var sH=r(15376).Buffer;class sY{static get Instance(){return this._instance||(this._instance=new this)}constructor(){let e=[].concat(...[c,f,m,g,y,b,x,v,w,T,S,N,k,I,C,E,A,$,F].map(e=>e.json));this.opMappers=e.reduce((e,t)=>(e[t.tfOpName]=t,e),{})}transformGraph(e,t={}){let r=e.node,n=[],a=[],s=[],i=r.reduce((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?n.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):(null==t.input||0===t.input.length)&&s.push(e[t.name]),e),{}),o=[],l=[],u={},h={};null!=t&&(u=this.mapSignatureEntries(t.inputs),h=this.mapSignatureEntries(t.outputs));let p=Object.keys(i);p.forEach(e=>{let t=i[e];t.inputNames.forEach((e,r)=>
290{let[n,,a]=sN(e),s=i[n];if(null!=s.outputs){let e=s.outputs.indexOf(a);if(-1!==e){let a=`${n}:${e}`;t.inputNames[r]=a}}t.inputs.push(s),s.children.push(t)})}),0===Object.keys(h).length?p.forEach(e=>{let t=i[e];0===t.children.length&&l.push(t)}):Object.keys(h).forEach(e=>{let[t]=sN(e),r=i[t];null!=r&&(r.signatureKey=h[e],l.push(r))}),Object.keys(u).length>0?Object.keys(u).forEach(e=>{let[t]=sN(e),r=i[t];r&&(r.signatureKey=u[e],o.push(r))}):o=n;let d={};null!=e.library&&null!=e.library.function&&(d=e.library.function.reduce((e,t)=>(e[t.signature.name]=this.mapFunction(t),e),{}));let c={nodes:i,inputs:o,outputs:l,weights:a,placeholders:n,signature:t,functions:d};return s.length>0&&(c.initNodes=s),c}mapSignatureEntries(e){return Object.keys(e||{}).reduce((t,r)=>(t[e[r].name]=r,t),{})}mapNode(e){let t=sb[e.op]||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});let r={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map(e=>e.startsWith("^")?e.slice(1):e),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(r.inputParams=t.inputs.reduce((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e),{})),null!=t.attrs&&(r.attrParams=t.attrs.reduce((t,r)=>{let n,a=r.type;switch(r.type){case"string":void 0===(n=sq(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sq(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"string[]":void 0===(n=s8(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=s8(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number":void 0===(n=sJ(e.attr,r.tfName,r.defaultValue||0))&&r.tfDeprecatedName&&(n=sJ(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number[]":void 0===(n=s5(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=s5(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool":void 0===(n=sX(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sX(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool[]":void 0===(n=s9(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=s9(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape":void 0===(n=s6(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=s6(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape[]":void 0===(n=s7(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=s7(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"dtype":void 0===(n=s2(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=s2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"dtype[]":void 0===(n=s3(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=s3(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"func":void 0===(n=s1(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=s1(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"tensor":case"tensors":break;default:throw Error(`Unsupported param type: ${r.type} for op: ${e.op}`)}return t[r.name]={value:n,type:a},t},{})),r}mapFunction(e){let t=e.nodeDef,r=[],n={};null!=t&&(n=t.reduce((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&r.push(e[t.name]),e),{}));let a=[],s=[];e.signature.inputArg.forEach(e=>{let[t]=sN(e.name),r={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:s0(e.type),type:"dtype"}},children:[]};r.signatureKey=e.name,a.push(r),n[t]=r}),Object.keys(n).forEach(e=>{let t=n[e];t.inputNames.forEach((e,r)=>{let[a,,s]=sN(e),i=n[a];if(null!=i.outputs){let e=i.outputs.indexOf(s);if(-1!==e){let n=`${a}:${e}`;t.inputNames[r]=n}}t.inputs.push(i),i.children.push(t)})});let i=e.ret;e.signature.outputArg.forEach(e=>{let[t,r]=sN(i[e.name]),a=n[t];null!=a&&(a.defaultOutput=r,s.push(a))});let o=this.mapArgsToSignature(e);return{nodes:n,inputs:a,outputs:s,weights:r,placeholders:[],signature:o}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e),{}),outputs:e.signature.outputArg.reduce((t,r)=>(t[r.name]=this.mapArgToTensorInfo(r,e.ret),t),{})}}mapArgToTensorInfo(e,t){let r=e.name;return null!=t&&(r=t[r]),{name:r,dtype:e.type}}}function sQ(e,t){let r=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){let t=(0,W._K2)().global;if(void 0!==t.atob)return t.atob(e);if(void 0!==sH)return new sH(e,"base64").toString();throw Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?r:r.toLowerCase()}function sq(e,t,r,n=!1){let a=e[t];return null!=a?sQ(a.s,n):r}function sX(e,t,r){let n=e[t];return n?n.b:r}function sJ(e,t,r){let n=e[t]||{},a=null!=n.i?n.i:null!=n.f?n.f:r;return"number"==typeof a?a:parseInt(a,10)}function s0(e){switch("string"==typeof e&&(e=a[e]),e){case a.DT_FLOAT:case a.DT_HALF:return"float32";case a.DT_INT32:case a.DT_INT64:case a.DT_INT8:case a.DT_UINT8:return"int32";case a.DT_BOOL:return"bool";case a.DT_DOUBLE:return"float32";case a.DT_STRING:return"string";case a.DT_COMPLEX64:case a.DT_COMPLEX128:return"complex64";default:return null}}function s1(e,t,r){let n=e[t];return n&&n.func?n.func.name:r}function s2(e,t,r){let n=e[t];return n&&n.type?s0(n.type):r}function s3(e,t,r){let n=e[t];return n&&n.list&&n.list.type?n.list.type.map(e=>s0(e)):r}function s4(e){if(!e.unknownRank)return null!=e.dim?e.dim.map(e=>"number"==typeof e.size?e.size:parseInt(e.size,10)):[]}function s6(e,t,r){let n=e[t];return n&&n.shape?s4(n.shape):r}function s5(e,t,r){let n=e[t];return n?((n.list.f&&n.list.f.length?n.list.f:n.list.i)||[]).map(e=>"number"==typeof e?e:parseInt(e,10)):r}function s8(e,t,r,n=!1){let a=e[t];return a&&a.list&&a.list.s?a.list.s.map(e=>sQ(e,n)):r}function s7(e,t,r){let n=e[t];return n&&n.list&&n.list.shape?n.list.shape.map(e=>s4(e)):r}function s9(e,t,r){let n=e[t];return n&&n.list&&n.list.b?n.list.b:r}class ie{constructor(e,t,r){this.node=e,this.tensorMap=t,this.context=r,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(e=>this.getInput(e)),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce((e,t)=>
290(e[t]=this.getAttr(t),e),{}))}getInput(e){return sT(e,this.tensorMap,this.context)}getAttr(e,t){let r=this.node.rawAttrs[e];if(null!=r.tensor)return sT(e,this.tensorMap,this.context);if(null!=r.i||null!=r.f)return sJ(this.node.rawAttrs,e,t);if(null!=r.s)return sq(this.node.rawAttrs,e,t);if(null!=r.b)return sX(this.node.rawAttrs,e,t);if(null!=r.shape)return s6(this.node.rawAttrs,e,t);if(null!=r.type)return s2(this.node.rawAttrs,e,t);if(null!=r.list){if(null!=r.list.i||null!=r.list.f)return s5(this.node.rawAttrs,e,t);if(null!=r.list.s)return s8(this.node.rawAttrs,e,t);if(null!=r.list.shape)return s7(this.node.rawAttrs,e,t);if(null!=r.list.b)return s9(this.node.rawAttrs,e,t);if(null!=r.list.type)return s3(this.node.rawAttrs,e,t)}return t}}var it=r(98503);function ir(e,t,r=""){if("number"!=typeof e&&"number"!=typeof t){W.ZSL.assert(e.length===t.length,()=>r+` Shapes ${e} and ${t} must match`);for(let n=0;n<e.length;n++){let a=e[n],s=t[n];W.ZSL.assert(a<0||s<0||a===s,()=>r+` Shapes ${e} and ${t} must match`)}}}function ia(e){return!("number"==typeof e||e.some(e=>e<0))}function is(e,t,r){let n=ii(e,r),a=!ia(n);if(a&&0===t.length)throw Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${n}`);if(a&&t.forEach(e=>{n=ii(e.shape,n)}),!ia(n))throw Error(`Non-fully-defined elementShape: ${n}`);return n}function ii(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw Error(`Incompatible ranks during merge: ${e} vs. ${t}`);let r=[];for(let n=0;n<e.length;++n){let a=e[n],s=t[n];if(a>=0&&s>=0&&a!==s)throw Error(`Incompatible shape during merge: ${e} vs. ${t}`);r[n]=a>=0?a:s}return r}class io{constructor(e,t,r,n,a,s,i){this.name=e,this.dtype=t,this.maxSize=r,this.elementShape=n,this.identicalElementShapes=a,this.dynamicSize=s,this.clearAfterRead=i,this.tensors=[],this.closed_=!1,this.idTensor=(0,W.d_2)(0),(0,W.aCs)(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach(t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()}),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);let t=this.tensors[e];if(t.cleared)throw Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map(e=>this.read(e))}write(e,t){if(this.closed_)throw Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);let r=this.tensors[e]||{};if(t.dtype!==this.dtype)throw Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, 291 because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0===this.size()&&(null==this.elementShape||0===this.elementShape.length)&&(this.elementShape=t.shape),ir(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),r.read)throw Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(r.written)throw Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);r.tensor=t,(0,W.aCs)(t),r.written=!0,this.tensors[e]=r}writeMany(e,t){if(e.length!==t.length)throw Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach((e,r)=>this.write(e,t[r]))}gather(e,t){if(t&&t!==this.dtype)throw Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t<this.size();t++)e.push(t)}if(0===e.length)return(0,W.OEK)([],[0].concat(this.elementShape));let r=this.readMany(e);return ir(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),(0,W.t$z)(r,0)}concat(e){if(e&&e!==this.dtype)throw Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`);if(0===this.size())return(0,W.OEK)([],[0].concat(this.elementShape));let t=[];for(let e=0;e<this.size();e++)t.push(e);let r=this.readMany(t);return ir(this.elementShape,r[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${r[0].shape})`),(0,W.xWs)(r,0)}scatter(e,t){if(t.dtype!==this.dtype)throw Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);if(e.length!==t.shape[0])throw Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);let r=Math.max(...e);if(!this.dynamicSize&&r>=this.maxSize)throw Error(`Max index must be < array size (${r} vs. ${this.maxSize})`);this.writeMany(e,(0,W.K$i)(t,0))}split(e,t){if(t.dtype!==this.dtype)throw Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let r=0,n=e.map(e=>r+=e);if(r!==t.shape[0])throw Error(`Expected sum of lengths to be equal to 292 tensor.shape[0], but sum of lengths is 293 ${r}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);let a=0===r?0:t.size/r,s=[];(0,W.DZQ)(()=>{t=(0,W.tQQ)(t,[1,r,a]);for(let r=0;r<e.length;++r){let i=[0,0===r?0:n[r-1],0],o=[1,e[r],a];s[r]=(0,W.tQQ)((0,W.dik)(t,i,o),this.elementShape)}return s});let i=[];for(let t=0;t<e.length;t++)i[t]=t;this.writeMany(i,s)}}class il{get id(){return this.idTensor.id}constructor(e,t,r,n=-1){this.tensors=e,this.elementShape=t,this.elementDtype=r,null!=e&&e.forEach(e
293=>{if(r!==e.dtype)throw Error(`Invalid data types; op elements ${r}, but list elements ${e.dtype}`);ir(t,e.shape,"TensorList shape mismatch: "),(0,W.aCs)(e)}),this.idTensor=(0,W.d_2)(0),this.maxNumElements=n,(0,W.aCs)(this.idTensor)}copy(){return new il([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach(t=>{null!=e&&e.has(t.id)||t.dispose()}),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,r=-1){if(t!==this.elementDtype)throw Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==r&&this.tensors.length!==r)throw Error(`Operation expected a list with ${r} elements but got a list with ${this.tensors.length} elements.`);ir(e,this.elementShape,"TensorList shape mismatch: ");let n=is(this.elementShape,this.tensors,e);return(0,W.DZQ)(()=>{let e=this.tensors.map(e=>(0,W.tQQ)(e,n));return(0,W.t$z)(e,0)})}popBack(e,t){if(t!==this.elementDtype)throw Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw Error("Trying to pop from an empty list.");let r=is(this.elementShape,this.tensors,e),n=this.tensors.pop();return n.kept=!1,ir(n.shape,e,"TensorList shape mismatch: "),(0,W.tQQ)(n,r)}pushBack(e){if(e.dtype!==this.elementDtype)throw Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(ir(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw Error("Trying to push element into a full list.");(0,W.aCs)(e),this.tensors.push(e)}resize(e){if(e<0)throw Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);let t=new il([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let r=0;r<Math.min(this.tensors.length,e);++r)t.tensors[r]=this.tensors[r];return t}getItem(e,t,r){if(r!==this.elementDtype)throw Error(`Invalid data types; op elements ${r}, but list elements ${this.elementDtype}`);if(e<0||e>this.tensors.length)throw Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw Error(`element at index ${e} is null.`);ir(this.tensors[e].shape,t,"TensorList shape mismatch: ");let n=is(this.elementShape,this.tensors,t);return(0,W.tQQ)(this.tensors[e],n)}setItem(e,t){if(t.dtype!==this.elementDtype)throw Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);ir(this.elementShape,t.shape,"TensorList shape mismatch: "),(0,W.aCs)(t),null!=this.tensors[e]&&(this.tensors[e].kept=!1),this.tensors[e]=t}gather(e,t,r){if(t!==this.elementDtype)throw Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);ir(this.elementShape,r,"TensorList shape mismatch: "),e=e.slice(0,this.size());let n=is(this.elementShape,this.tensors,r);return 0===e.length?(0,W.OEK)([],[0].concat(n)):(0,W.DZQ)(()=>{let t=e.map(e=>(0,W.tQQ)(this.tensors[e],n));return(0,W.t$z)(t,0)})}concat(e,t){if(e&&e!==this.elementDtype)throw Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);ir(this.elementShape,t,"TensorList shape mismatch: ");let r=is(this.elementShape,this.tensors,t);return 0===this.size()?(0,W.OEK)([],[0].concat(r)):(0,W.DZQ)(()=>{let e=this.tensors.map(e=>(0,W.tQQ)(e,r));return(0,W.xWs)(e,0)})}}let iu=async(e,t,r)=>{switch(e.op){case"If":case"StatelessIf":{let n=sw("thenBranch",e,t,r),a=sw("elseBranch",e,t,r),s=sw("cond",e,t,r),i=sw("args",e,t,r);if((await s.data())[0])return r.functionMap[n].executeFunctionAsync(i,r.tensorArrayMap,r.tensorListMap);return r.functionMap[a].executeFunctionAsync(i,r.tensorArrayMap,r.tensorListMap)}case"While":case"StatelessWhile":{let n=sw("body",e,t,r),a=sw("cond",e,t,r),s=sw("args",e,t,r),i=await r.functionMap[a].executeFunctionAsync(s,r.tensorArrayMap,r.tensorListMap),o=s.map(e=>e.id),l=await i[0].data();
293i.forEach(e=>{e.kept||-1!==o.indexOf(e.id)||e.dispose()});let u=s;for(;l[0];){let e=u,t=(u=await r.functionMap[n].executeFunctionAsync(u,r.tensorArrayMap,r.tensorListMap)).map(e=>e.id);e.forEach(e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()});let s=await r.functionMap[a].executeFunctionAsync(u,r.tensorArrayMap,r.tensorListMap);l=await s[0].data(),s.forEach(e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()})}return u}case"LoopCond":return[sE(sw("pred",e,t,r))];case"Switch":{let n=sw("pred",e,t,r),a=sw("data",e,t,r);return a.kept||(a=sE(a)),(await n.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{let n=e.inputNames.find(e=>void 0!==sT(e,t,r));if(n)return[sE(sT(n,t,r))];return}case"Enter":{let n=sw("frameName",e,t,r),a=sw("tensor",e,t,r);return r.enterFrame(n),[sE(a)]}case"Exit":{let n=sw("tensor",e,t,r);return r.exitFrame(),[sE(n)]}case"NextIteration":{let n=sw("tensor",e,t,r);return r.nextIteration(),[sE(n)]}case"TensorArrayV3":{let n=sw("size",e,t,r),a=sw("dtype",e,t,r),s=sw("elementShape",e,t,r),i=sw("dynamicSize",e,t,r),o=sw("clearAfterRead",e,t,r),l=sw("identicalElementShapes",e,t,r),u=new io(sw("name",e,t,r),a,n,s,l,i,o);return r.addTensorArray(u),[u.idTensor,(0,W.d_2)(1)]}case"TensorArrayWriteV3":{let n=sw("tensorArrayId",e,t,r),a=sw("index",e,t,r),s=sw("tensor",e,t,r),i=r.getTensorArray(n.id);return i.write(a,s),[i.idTensor]}case"TensorArrayReadV3":{let n=sw("tensorArrayId",e,t,r),a=sw("index",e,t,r);return[r.getTensorArray(n.id).read(a)]}case"TensorArrayGatherV3":{let n=sw("tensorArrayId",e,t,r),a=sw("indices",e,t,r),s=sw("dtype",e,t,r);return[r.getTensorArray(n.id).gather(a,s)]}case"TensorArrayScatterV3":{let n=sw("tensorArrayId",e,t,r),a=sw("indices",e,t,r),s=sw("tensor",e,t,r),i=r.getTensorArray(n.id);return i.scatter(a,s),[i.idTensor]}case"TensorArrayConcatV3":{let n=sw("tensorArrayId",e,t,r),a=r.getTensorArray(n.id),s=sw("dtype",e,t,r);return[a.concat(s)]}case"TensorArraySplitV3":{let n=sw("tensorArrayId",e,t,r),a=sw("tensor",e,t,r),s=sw("lengths",e,t,r),i=r.getTensorArray(n.id);return i.split(s,a),[i.idTensor]}case"TensorArraySizeV3":{let n=sw("tensorArrayId",e,t,r),a=r.getTensorArray(n.id);return[(0,W.d_2)(a.size(),"int32")]}case"TensorArrayCloseV3":{let n=sw("tensorArrayId",e,t,r),a=r.getTensorArray(n.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{let n=sw("tensorListId",e,t,r),a=sw("index",e,t,r),s=sw("tensor",e,t,r),i=r.getTensorList(n.id);return i.setItem(a,s),[i.idTensor]}case"TensorListGetItem":{let n=sw("tensorListId",e,t,r),a=sw("index",e,t,r),s=sw("elementShape",e,t,r),i=sw("elementDType",e,t,r);return[r.getTensorList(n.id).getItem(a,s,i)]}case"TensorListScatterV2":case"TensorListScatter":{let n=sw("indices",e,t,r),a=sw("tensor",e,t,r),s=function(e,t,r,n){if(t.length!==e.shape[0])throw Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);let a=Math.max(...t);if(null!=n&&-1!==n&&a>=n)throw Error(`Max index must be < array size (${a} vs. ${n})`);let s=new il([],r,e.dtype,n),i=(0,W.K$i)(e,0);return t.forEach((e,t)=>{s.setItem(e,i[t])}),s}(a,n,sw("elementShape",e,t,r),sw("numElements",e,t,r));return r.addTensorList(s),[s.idTensor]}case"TensorListReserve":case"EmptyTensorList":{let n=sw("elementShape",e,t,r),a=sw("elementDType",e,t,r),s=sw("TensorListReserve"===e.op?"numElements":"maxNumElements",e,t,r),i=new il([],n,a,"TensorListReserve"===e.op?-1:s);return r.addTensorList(i),[i.idTensor]}case"TensorListGather":{let n=sw("tensorListId",e,t,r),a=sw("indices",e,t,r),s=sw("elementShape",e,t,r),i=sw("elementDType",e,t,r);return[r.getTensorList(n.id).gather(a,i,s)]}case"TensorListStack":{let n=sw("tensorListId",e,t,r),a=sw("elementShape",e,t,r),s=sw("elementDType",e,t,r),i=sw("numElements",e,t,r);return[r.getTensorList(n.id).stack(a,s,i)]}case"TensorListFromTensor":{let n=sw("tensor",e,t,r),a=function(e,t,r){let n=e.dtype;if(e.shape.length<1)throw Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==r)throw Error(`Invalid data types; op elements ${e.dtype}, but list elements ${r}`);return ir(e.shape.slice(1),t,"TensorList shape mismatch: "),new il((0,W.K$i)(e),t,n)}(n,sw("elementShape",e,t,r),sw("elementDType",e,t,r));return r.addTensorList(a),[a.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{let n=sw("tensorListId",e,t,r),a=r.getTensorList(n.id),s=sw("dtype",e,t,r),i=sw("elementShape",e,t,r);return[a.concat(s,i)]}case"TensorListPushBack":{let n=sw("tensorListId",e,t,r),a=sw("tensor",e,t,r),s=r.getTensorList(n.id);return s.pushBack(a),[s.idTensor]}case"TensorListPopBack":{let n=sw("tensorListId",e,t,r),a=sw("elementShape",e,t,r),s=sw("elementDType",e,t,r);return[r.getTensorList(n.id).popBack(a,s)]}case"TensorListSplit":{let n=sw("tensor",e,t,r),a=sw("elementShape",e,t,r),s=function(e,t,r){let n=0,a=t.map(e=>n+=e);if(n!==e.shape[0])throw Error(`Expected sum of lengths to be equal to 294 tensor.shape[0], but sum of lengths is 295 ${n}, and tensor's shape is: ${e.shape}`);let s=ii(e.shape.slice(1),r),i=0===n?0:e.size/n,o=(0,W.DZQ)(()=>{let r=[];e=(0,W.tQQ)(e,[1,n,i]);for(let n=0;n<t.length;++n){let o=[0,0===n?0:a[n-1],0],l=[1,t[n],i];r[n]=(0,W.tQQ)((0,W.dik)(e,o,l),s)}return e.dispose(),r}),l=new il([],r,e.dtype,t.length);for(let e=0;e<o.length;e++)l.setItem(e,o[e]);return l}(n,sw("lengths",e,t,r),a);return r.addTensorList(s),[s.idTensor]}case"TensorListLength":{let n=sw("tensorListId",e,t,r),a=r.getTensorList(n.id);return[(0,W.d_2)(a.size(),"int32")]}case"TensorListResize":{let n=sw("tensorListId",e,t,r),a=sw("size",e,t,r),s=r.getTensorList(n.id).resize(a);return r.addTensorList(s),[s.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}};function ih(e,t,r){let[n,a]=sw("fusedOps",e,t,r),s="biasadd"===n,i="prelu"===a,o=sw("numArgs",e,t,r);if(s){if(i&&2!==o)throw Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&s&&1!==o)throw Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if("fusedbatchnorm"===n)throw Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");let l=sw("strides",e,t,r),u=sC(e,t,r),h=sw("dataFormat",e,t,r).toUpperCase(),p=sw("dilations",e,t,r),[d,c]=sw("args",e,t,r);return s||(c=d,d=void 0),{stride:l,pad:u,dataFormat:h,dilations:p,biasArg:d,preluArg:c,activationFunc:a,leakyreluAlpha:sw("leakyreluAlpha",e,t,r)}}function ip(e,t,r){let n=sw("boxes",e,t,r),a=sw("scores",e,t,r),s=sw("maxOutputSize",e,t,r),i=sw("iouThreshold",e,t,r);return{boxes:n,scores:a,maxOutputSize:s,iouThreshold:i,scoreThreshold:sw("scoreThreshold",e,t,r),softNmsSigma:sw("softNmsSigma",e,t,r)}}let id=async(e,t,r,n,a=R)=>{switch(e.op){case"NonMaxSuppressionV5":{let{boxes:n,scores:s,maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=ip(e,t,r),h=await a.image.nonMaxSuppressionWithScoreAsync(n,s,i,o,l,u);return[h.selectedIndices,h.selectedScores]}case"NonMaxSuppressionV4":{let{boxes:n,scores:s,maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=ip(e,t,r),u=sw("padToMaxOutputSize",e,t,r),h=await a.image.nonMaxSuppressionPaddedAsync(n,s,i,o,l,u);return[h.selectedIndices,h.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{let{boxes:n,scores:s,maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=ip(e,t,r);return[await a.image.nonMaxSuppressionAsync(n,s,i,o,l)]}case"Where":{let n=a.cast(sw("condition",e,t,r),"bool"),s=[await a.whereAsync(n)];return n.dispose(),s}case"ListDiff":return a.setdiff1dAsync(sw("x",e,t,r),sw("y",e,t,r));default:throw TypeError(`Node type ${e.op} is not implemented`)}};class ic{get id(){return this.handle.id}constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=(0,W.d_2)(0),this.tensorMap=new Map,(0,W.aCs)(this.handle)}
295clearAndClose(){this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return e$.d(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);let r=await e.data();return this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),(0,W.DZQ)(()=>{let e=(0,W.K$i)(t),n=r.length,a=e.length;W.ZSL.assert(n===a,()=>`The number of elements doesn't match, keys has ${n} elements, the values has ${a} elements.`);for(let t=0;t<n;t++){let n=r[t],a=e[t];(0,W.aCs)(a),this.tensorMap.set(n,a)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);let r=await e.data();return(0,W.DZQ)(()=>{let e=[];for(let n=0;n<r.length;n++){let a=r[n],s=this.findWithDefault(a,t);e.push(s)}return(0,W.t$z)(e)})}findWithDefault(e,t){let r=this.tensorMap.get(e);return null!=r?r:t}checkKeyAndValueTensor(e,t){if(e.dtype!==this.keyDType)throw Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);if(t.dtype!==this.valueDType)throw Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`)}}let im=async(e,t,r,n)=>{switch(e.op){case"HashTable":case"HashTableV2":{let a=n.getHashTableHandleByName(e.name);if(null!=a)return[a];{let a=new ic(sw("keyDType",e,t,r),sw("valueDType",e,t,r));return n.addHashTable(e.name,a),[a.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{let a=sw("tableHandle",e,t,r,n),s=sw("keys",e,t,r),i=sw("values",e,t,r),o=n.getHashTableById(a.id);return[await o.import(s,i)]}case"LookupTableFind":case"LookupTableFindV2":{let a=sw("tableHandle",e,t,r,n),s=sw("keys",e,t,r),i=sw("defaultValue",e,t,r),o=n.getHashTableById(a.id);return[await o.find(s,i)]}case"LookupTableSize":case"LookupTableSizeV2":{let a=sw("tableHandle",e,t,r,n);return[n.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}};function ig(e,t,r,n,a=W.DZQ){let s=((e,t,r)=>{switch(e.category){case"arithmetic":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[n.add(sw("a",e,t,r),sw("b",e,t,r))];case"AddN":return[n.addN(sw("tensors",e,t,r))];case"FloorMod":case"Mod":return[n.mod(sw("a",e,t,r),sw("b",e,t,r))];case"Mul":return[n.mul(sw("a",e,t,r),sw("b",e,t,r))];case"RealDiv":case"Div":return[n.div(sw("a",e,t,r),sw("b",e,t,r))];case"DivNoNan":return[n.divNoNan(sw("a",e,t,r),sw("b",e,t,r))];case"FloorDiv":return[n.floorDiv(sw("a",e,t,r),sw("b",e,t,r))];case"Sub":return[n.sub(sw("a",e,t,r),sw("b",e,t,r))];case"Minimum":return[n.minimum(sw("a",e,t,r),sw("b",e,t,r))];case"Maximum":return[n.maximum(sw("a",e,t,r),sw("b",e,t,r))];case"Pow":return[n.pow(sw("a",e,t,r),sw("b",e,t,r))];case"SquaredDifference":return[n.squaredDifference(sw("a",e,t,r),sw("b",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"basic_math":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"Abs":case"ComplexAbs":return[n.abs(sw("x",e,t,r))];case"Acos":return[n.acos(sw("x",e,t,r))];case"Acosh":return[n.acosh(sw("x",e,t,r))];case"Asin":return[n.asin(sw("x",e,t,r))];case"Asinh":return[n.asinh(sw("x",e,t,r))];case"Atan":return[n.atan(sw("x",e,t,r))];case"Atan2":return[n.atan2(sw("x",e,t,r),sw("y",e,t,r))];case"Atanh":return[n.atanh(sw("x",e,t,r))];case"Ceil":return[n.ceil(sw("x",e,t,r))];case"Complex":return[n.complex(sw("real",e,t,r),sw("imag",e,t,r))];case"Cos":return[n.cos(sw("x",e,t,r))];case"Cosh":return[n.cosh(sw("x",e,t,r))];case"Elu":return[n.elu(sw("x",e,t,r))];case"Erf":return[n.erf(sw("x",e,t,r))];case"Exp":return[n.exp(sw("x",e,t,r))];case"Expm1":return[n.expm1(sw("x",e,t,r))];case"Floor":return[n.floor(sw("x",e,t,r))];case"Log":return[n.log(sw("x",e,t,r))];case"Log1p":return[n.log1p(sw("x",e,t,r))];case"Imag":return[n.imag(sw("x",e,t,r))];case"Neg":return[n.neg(sw("x",e,t,r))];case"Reciprocal":return[n.reciprocal(sw("x",e,t,r))];case"Real":return[n.real(sw("x",e,t,r))];case"Relu":return[n.relu(sw("x",e,t,r))];case"Round":return[n.round(sw("x",e,t,r))];case"Selu":return[n.selu(sw("x",e,t,r))];case"Sigmoid":return[n.sigmoid(sw("x",e,t,r))];case"Sin":return[n.sin(sw("x",e,t,r))];case"Sign":return[n.sign(sw("x",e,t,r))];case"Sinh":return[n.sinh(sw("x",e,t,r))];case"Softplus":return[n.softplus(sw("x",e,t,r))];case"Sqrt":return[n.sqrt(sw("x",e,t,r))];case"Square":return[n.square(sw("x",e,t,r))];case"Tanh":return[n.tanh(sw("x",e,t,r))];case"Tan":return[n.tan(sw("x",e,t,r))];case"ClipByValue":return[n.clipByValue(sw("x",e,t,r),sw("clipValueMin",e,t,r),sw("clipValueMax",e,t,r))];case"Relu6":return[n.relu6(sw("x",e,t,r))];case"Rsqrt":return[n.rsqrt(sT(e.inputNames[0],t,r))];case"LeakyRelu":return[n.leakyRelu(sw("x",e,t,r),sw("alpha",e,t,r))];case"Prelu":return[n.prelu(sw("x",e,t,r),sw("alpha",e,t,r))];case"IsNan":return[n.isNaN(sT(e.inputNames[0],t,r))];case"IsInf":return[n.isInf(sT(e.inputNames[0],t,r))];case"IsFinite":return[n.isFinite(sT(e.inputNames[0],t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"control":return iu(e,t,r);case"convolution":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"Conv1D":{let a=sw("stride",e,t,r),s=sw("pad",e,t,r),i=sw("dataFormat",e,t,r).toUpperCase(),o=sw("dilation",e,t,r);return[n.conv1d(sw("x",e,t,r),sw("filter",e,t,r),a,s,i,o)]}case"Conv2D":{let a=sw("strides",e,t,r),s=sC(e,t,r),i=sw("dataFormat",e,t,r).toUpperCase(),o=sw("dilations",e,t,r);return[n.conv2d(sw("x",e,t,r),sw("filter",e,t,r),[a[1],a[2]],s,i,[o[1],o[2]])]}case"_FusedConv2D":{let{stride:a,pad:s,dataFormat:i,dilations:o,biasArg:l,preluArg:u,activationFunc:h,leakyreluAlpha:p}=ih(e,t,r);return[n.fused.conv2d({x:sw("x",e,t,r),filter:sw("filter",e,t,r),strides:[a[1],a[2]],pad:s,dataFormat:i,dilations:[o[1],o[2]],bias:l,activation:h,preluActivationWeights:u,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{let{stride:a,pad:s,dataFormat:i,dilations:o,biasArg:l,preluArg:u,activationFunc:h,leakyreluAlpha:p}=ih(e,t,r);return[n.fused.depthwiseConv2d({x:sw("x",e,t,r),filter:sw("filter",e,t,r),strides:[a[1],a[2]],pad:s,dataFormat:i,dilations:[o[1],o[2]],bias:l,activation:h,preluActivationWeights:u,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{let a=sw("outputShape",e,t,r),s=sw("strides",e,t,r),i=sC(e,t,r);return[n.conv2dTranspose(sw("x",e,t,r),sw("filter",e,t,r),a,[s[1],s[2]],i)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{let a=sw("strides",e,t,r),s=sC(e,t,r),i=sw("dilations",e,t,r),o=sw("dataFormat",e,t,r).toUpperCase();return[n.depthwiseConv2d(sw("input",e,t,r),sw("filter",e,t,r),[a[1],a[2]],s,o,[i[1],i[2]])]}case"Conv3D":{let a=sw("strides",e,t,r),s=sw("pad",e,t,r),i=sw("dataFormat",e,t,r).toUpperCase(),o=sw("dilations",e,t,r);return[n.conv3d(sw("x",e,t,r),sw("filter",e,t,r),[a[1],a[2],a[3]],s,i,[o[1],o[2],o[3]])]}case"AvgPool":{let a=sw("strides",e,t,r),s=sw("pad",e,t,r),i=sw("kernelSize",e,t,r);return[n.avgPool(sw("x",e,t,r),[i[1],i[2]],[a[1],a[2]],s)]}case"MaxPool":{let a=sw("strides",e,t,r),s=sw("pad",e,t,r),i=sw("kernelSize",e,t,r);return[n.maxPool(sw("x",e,t,r),[i[1],i[2]],[a[1],a[2]],s)]}case"MaxPoolWithArgmax":{let a=sw("strides",e,t,r),s=sw("pad",e,t,r),i=sw("kernelSize",e,t,r),o=sw("includeBatchInIndex",e,t,r),{result:l,indexes:u}=n.maxPoolWithArgmax(sw("x",e,t,r),[i[1],i[2]],[a[1],a[2]],s,o);return[l,u]}case"AvgPool3D":{let a=sw("strides",e,t,r),s=sw("pad",e,t,r),i=sw("kernelSize",e,t,r);return[n.avgPool3d(sw("x",e,t,r),[i[1],i[2],i[3]],[a[1],a[2],a[3]],s)]}case"MaxPool3D":{let a=sw("strides",e,t,r),s=sw("pad",e,t,r),i=sw("kernelSize",e,t,r);return[n.maxPool3d(sw("x",e,t,r),[i[1],i[2],i[3]],[a[1],a[2],a[3]],s)]}case"Dilation2D":{let a=sw("strides",e,t,r),s=sw("pad",e,t,r),i=sw("dilations",e,t,r),o=a[1],l=a[2],u=i[1],h=i[2];return[n.dilation2d(sw("x",e,t,r),sw("filter",e,t,r),[o,l],s,[u,h],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"creation":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"Fill":{let a=sw("shape",e,t,r),s=sw("dtype",e,t,r),i=sw("value",e,t,r);return[n.fill(a,i,s)]}case"LinSpace":{let a=sw("start",e,t,r),s=sw("stop",e,t,r),i=sw("num",e,t,r);return[n.linspace(a,s,i)]}case"Multinomial":{let a=sw("logits",e,t,r),s=sw("numSamples",e,t,r),i=sw("seed",e,t,r);return[n.multinomial(a,s,i)]}case"OneHot":{let a=sw("indices",e,t,r),s=sw("depth",e,t,r),i=sw("onValue",e,t,r),o=sw("offValue",e,t,r),l=sw("dtype",e,t,r);return[n.oneHot(a,s,i,o,l)]}case"Ones":return[n.ones(sw("shape",e,t,r),sw("dtype",e,t,r))];case"OnesLike":return[n.onesLike(sw("x",e,t,r))];case"RandomStandardNormal":return[n.randomStandardNormal(sw("shape",e,t,r),sw("dtype",e,t,r),sw("seed",e,t,r))];case"RandomUniform":return[n.randomUniform(sw("shape",e,t,r),sw("minval",e,t,r),sw("maxval",e,t,r),sw("dtype",e,t,r))];case"RandomUniformInt":return[n.randomUniformInt(sw("shape",e,t,r),sw("minval",e,t,r),sw("maxval",e,t,r),sw("seed",e,t,r))];case"Range":{let a=sw("start",e,t,r),s=sw("stop",e,t,r),i=sw("step",e,t,r);return[n.range(a,s,i,sw("dtype",e,t,r))]}case"TruncatedNormal":{let a=sw("shape",e,t,r),s=sw("mean",e,t,r),i=sw("stdDev",e,t,r),o=sw("seed",e,t,r);return[n.truncatedNormal(a,s,i,sw("dtype",e,t,r),o)]}case"Zeros":return[n.zeros(sw("shape",e,t,r),sw("dtype",e,t,r))];case"ZerosLike":return[n.zerosLike(sw("x",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"dynamic":return id(e,t,r);case"evaluation":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"LowerBound":{let a=sw("sortedSequence",e,t,r),s=sw("values",e,t,r);return[n.lowerBound(a,s)]}case"TopKV2":{let a=sw("x",e,t,r),s=sw("k",e,t,r),i=sw("sorted",e,t,r),o=n.topk(a,s,i);return[o.values,o.indices]}case"UpperBound":{let a=sw("sortedSequence",e,t,r),s=sw("values",e,t,r);return[n.upperBound(a,s)]}case"Unique":{let a=sw("x",e,t,r),s=n.unique(a);return[s.values,s.indices]}case"UniqueV2":{let a=sw("x",e,t,r),s=sw("axis",e,t,r),i=n.unique(a,s);return[i.values,i.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"image":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"ResizeBilinear":{let a=sw("images",e,t,r),s=sw("size",e,t,r),i=sw("alignCorners",e,t,r),o=sw("halfPixelCenters",e,t,r);return[n.image.resizeBilinear(a,[s[0],s[1]],i,o)]}case"ResizeNearestNeighbor":{let a=sw("images",e,t,r),s=sw("size",e,t,r),i=sw("alignCorners",e,t,r),o=sw("halfPixelCenters",e,t,r);return[n.image.resizeNearestNeighbor(a,[s[0],s[1]],i,o)]}case"CropAndResize":{let a=sw("image",e,t,r),s=sw("boxes",e,t,r),i=sw("boxInd",e,t,r),o=sw("cropSize",e,t,r),l=sw("method",e,t,r),u=sw("extrapolationValue",e,t,r);return[n.image.cropAndResize(a,s,i,o,l,u)]}case"ImageProjectiveTransformV3":{let a=sw("images",e,t,r),s=sw("transforms",e,t,r),i=sw("outputShape",e,t,r),o=sw("fillValue",e,t,r),l=sw("interpolation",e,t,r),u=sw("fillMode",e,t,r);return[n.image.transform(a,s,l.toLowerCase(),u.toLowerCase(),o,i)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"graph":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":let a=sw("default",e,t,r);return[sT(e.name,t,r)||a];case"Placeholder":return[sT(e.name,t,r)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[sE(sw("x",e,t,r))];case"IdentityN":return sw("x",e,t,r).map(e=>sE(e));case"Shape":return[n.tensor1d(sw("x",e,t,r).shape,"int32")];case"ShapeN":return sw("x",e,t,r).map(e=>n.tensor1d(e.shape));case"Size":return[n.scalar(sw("x",e,t,r).size,"int32")];case"Rank":return[n.scalar(sw("x",e,t,r).rank,"int32")];case"NoOp":return[n.scalar(1)];case"Print":let s=sw("x",e,t,r),i=sw("data",e,t,r),o=sw("message",e,t,r),l=sw("summarize",e,t,r);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let e=0;e<i.length;e++)console.log(Array.prototype.slice.call(i[e].dataSync()).slice(0,l));return[s];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"logical":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"Equal":return[n.equal(sw("a",e,t,r),sw("b",e,t,r))];case"NotEqual":return[n.notEqual(sw("a",e,t,r),sw("b",e,t,r))];case"Greater":return[n.greater(sw("a",e,t,r),sw("b",e,t,r))];case"GreaterEqual":return[n.greaterEqual(sw("a",e,t,r),sw("b",e,t,r))];case"Less":return[n.less(sw("a",e,t,r),sw("b",e,t,r))];case"LessEqual":return[n.lessEqual(sw("a",e,t,r),sw("b",e,t,r))];case"LogicalAnd":return[n.logicalAnd(sw("a",e,t,r),sw("b",e,t,r))];case"LogicalNot":return[n.logicalNot(sw("a",e,t,r))];case"LogicalOr":return[n.logicalOr(sw("a",e,t,r),sw("b",e,t,r))];case"Select":case"SelectV2":return[n.where(sw("condition",e,t,r),sw("a",e,t,r),sw("b",e,t,r))];case"BitwiseAnd":return[n.bitwiseAnd(sw("a",e,t,r),sw("b",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"matrices":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[n.matMul(sw("a",e,t,r),sw("b",e,t,r),sw("transposeA",e,t,r),sw("transposeB",e,t,r))];case"Einsum":return[n.einsum(sw("equation",e,t,r),...sw("tensors",e,t,r))];case"Transpose":return[n.transpose(sw("x",e,t,r),sw("perm",e,t,r))];case"_FusedMatMul":let[a,s]=sw("fusedOps",e,t,r),i="prelu"===s,o=sw("numArgs",e,t,r),l=sw("leakyreluAlpha",e,t,r);if("biasadd"===a){if(i&&2!==o)throw Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&1!==o)throw Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}let[u,h]=sw("args",e,t,r);return[n.fused.matMul({a:sw("a",e,t,r),b:sw("b",e,t,r),transposeA:sw("transposeA",e,t,r),transposeB:sw("transposeB",e,t,r),bias:u,activation:s,preluActivationWeights:h,leakyreluAlpha:l})];
vendor: 7,531 bytes, line 295
295case"MatrixBandPart":return[n.linalg.bandPart(sw("a",e,t,r),sw("numLower",e,t,r),sw("numUpper",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"normalization":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"EuclideanNorm":return[n.euclideanNorm(sw("x",e,t,r),sw("axis",e,t,r),sw("keepDims",e,t,r))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[n.batchNorm(sw("x",e,t,r),sw("mean",e,t,r),sw("variance",e,t,r),sw("offset",e,t,r),sw("scale",e,t,r),sw("epsilon",e,t,r))];case"LRN":return[n.localResponseNormalization(sw("x",e,t,r),sw("radius",e,t,r),sw("bias",e,t,r),sw("alpha",e,t,r),sw("beta",e,t,r))];case"Softmax":return[n.softmax(sw("x",e,t,r))];case"LogSoftmax":return[n.logSoftmax(sw("x",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"ragged":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"RaggedGather":{let{outputNestedSplits:a,outputDenseValues:s}=n.raggedGather(sw("paramsNestedSplits",e,t,r),sw("paramsDenseValues",e,t,r),sw("indices",e,t,r),sw("outputRaggedRank",e,t,r));return a.concat(s)}case"RaggedRange":{let{rtNestedSplits:a,rtDenseValues:s}=n.raggedRange(sw("starts",e,t,r),sw("limits",e,t,r),sw("splits",e,t,r));return[a,s]}case"RaggedTensorToTensor":return[n.raggedTensorToTensor(sw("shape",e,t,r),sw("values",e,t,r),sw("defaultValue",e,t,r),sw("rowPartitionTensors",e,t,r),sw("rowPartitionTypes",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"reduction":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"Max":{let a=sw("axis",e,t,r),s=sw("keepDims",e,t,r);return[n.max(sw("x",e,t,r),a,s)]}case"Mean":{let a=sw("axis",e,t,r),s=sw("keepDims",e,t,r);return[n.mean(sw("x",e,t,r),a,s)]}case"Min":{let a=sw("axis",e,t,r),s=sw("keepDims",e,t,r);return[n.min(sw("x",e,t,r),a,s)]}case"Sum":{let a=sw("axis",e,t,r),s=sw("keepDims",e,t,r);return[n.sum(sw("x",e,t,r),a,s)]}case"All":{let a=sw("axis",e,t,r),s=sw("keepDims",e,t,r);return[n.all(sw("x",e,t,r),a,s)]}case"Any":{let a=sw("axis",e,t,r),s=sw("keepDims",e,t,r);return[n.any(sw("x",e,t,r),a,s)]}case"ArgMax":{let a=sw("axis",e,t,r);return[n.argMax(sw("x",e,t,r),a)]}case"ArgMin":{let a=sw("axis",e,t,r);return[n.argMin(sw("x",e,t,r),a)]}case"Prod":{let a=sw("axis",e,t,r),s=sw("keepDims",e,t,r);return[n.prod(sw("x",e,t,r),a,s)]}case"Cumprod":{let a=sw("axis",e,t,r),s=sw("exclusive",e,t,r),i=sw("reverse",e,t,r);return[n.cumprod(sw("x",e,t,r),a,s,i)]}case"Cumsum":{let a=sw("axis",e,t,r),s=sw("exclusive",e,t,r),i=sw("reverse",e,t,r);return[n.cumsum(sw("x",e,t,r),a,s,i)]}case"Bincount":let a=sw("x",e,t,r),s=sw("weights",e,t,r),i=sw("size",e,t,r);return[n.bincount(a,s,i)];case"DenseBincount":{let a=sw("x",e,t,r),s=sw("weights",e,t,r),i=sw("size",e,t,r),o=sw("binaryOutput",e,t,r);return[n.denseBincount(a,s,i,o)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"slice_join":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"ConcatV2":case"Concat":{let a=sw("n",e,t,r),s=sw("axis",e,t,r),i=sw("tensors",e,t,r);return i=i.slice(0,a),[n.concat(i,s)]}case"Gather":{let a=sw("x",e,t,r),s=sw("indices",e,t,r);return[n.gather(a,n.cast(s,"int32"),0)]}case"GatherV2":{let a=sw("axis",e,t,r),s=sw("batchDims",e,t,r),i=sw("x",e,t,r),o=sw("indices",e,t,r);return[n.gather(i,n.cast(o,"int32"),a,s)]}case"Reverse":{let a=sw("dims",e,t,r),s=[];for(let e=0;e<a.length;e++)a[e]&&s.push(e);let i=sw("x",e,t,r);return[n.reverse(i,s)]}case"ReverseV2":{let a=sw("axis",e,t,r),s=sw("x",e,t,r);return[n.reverse(s,a)]}case"Slice":{let a=sw("begin",e,t,r),s=sw("size",e,t,r);return[n.slice(sw("x",e,t,r),a,s)]}case"StridedSlice":{let a=sw("begin",e,t,r),s=sw("end",e,t,r),i=sw("strides",e,t,r),o=sw("beginMask",e,t,r),l=sw("endMask",e,t,r),u=sw("ellipsisMask",e,t,r),h=sw("newAxisMask",e,t,r),p=sw("shrinkAxisMask",e,t,r),d=sw("x",e,t,r);return[n.stridedSlice(d,a,s,i,o,l,u,h,p)]}case"Pack":return(0,W.DZQ)(()=>{let a=sw("axis",e,t,r),s=sw("tensors",e,t,r),i=s[0].shape,o=n.squeeze(s[0]).shape,l=s.map(e=>{let t=W.ZSL.arraysEqual(e.shape,i);if(!t&&!W.ZSL.arraysEqual(n.squeeze(e).shape,o))throw Error("the input tensors shape does not match");return t?e:n.reshape(e,i)});return[n.stack(l,a)]});case"Unpack":{let a=sw("axis",e,t,r),s=sw("tensor",e,t,r);return n.unstack(s,a)}case"Tile":{let a=sw("reps",e,t,r);return[n.tile(sw("x",e,t,r),a)]}case"Split":case"SplitV":{let a=sw("axis",e,t,r),s=sw("numOrSizeSplits",e,t,r),i=sw("x",e,t,r);return n.split(i,s,a)}case"ScatterNd":{let a=sw("indices",e,t,r),s=sw("values",e,t,r),i=sw("shape",e,t,r);return[n.scatterND(a,s,i)]}case"GatherNd":{let a=sw("x",e,t,r),s=sw("indices",e,t,r);return[n.gatherND(a,s)]}case"SparseToDense":{let a=sw("sparseIndices",e,t,r),s=sw("outputShape",e,t,r),i=sw("sparseValues",e,t,r),o=sw("defaultValue",e,t,r);return[n.sparseToDense(a,i,s,i.dtype===o.dtype?o:n.cast(o,i.dtype))]}case"TensorScatterUpdate":{let a=sw("indices",e,t,r),s=sw("values",e,t,r),i=sw("tensor",e,t,r);return[n.tensorScatterUpdate(i,a,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"sparse":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"SparseFillEmptyRows":{let{outputIndices:a,outputValues:s,emptyRowIndicator:i,reverseIndexMap:o}=n.sparse.sparseFillEmptyRows(sw("indices",e,t,r),sw("values",e,t,r),sw("denseShape",e,t,r),sw("defaultValue",e,t,r));return[a,s,i,o]}case"SparseReshape":{let{outputIndices:a,outputShape:s}=n.sparse.sparseReshape(sw("inputIndices",e,t,r),sw("inputShape",e,t,r),sw("newShape",e,t,r));return[a,s]}case"SparseSegmentMean":return[n.sparse.sparseSegmentMean(sw("data",e,t,r),sw("indices",e,t,r),sw("segmentIds",e,t,r))];case"SparseSegmentSum":return[n.sparse.sparseSegmentSum(sw("data",e,t,r),sw("indices",e,t,r),sw("segmentIds",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"spectral":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"FFT":return[n.fft(sw("x",e,t,r))];case"IFFT":return[n.ifft(sw("x",e,t,r))];case"RFFT":return[n.rfft(sw("x",e,t,r))];case"IRFFT":return[n.irfft(sw("x",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"string":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"StaticRegexReplace":return[n.string.staticRegexReplace(sw("input",e,t,r),sw("pattern",e,t,r),sw("rewrite",e,t,r),sw("replaceGlobal",e,t,r))];case"StringNGrams":{let{nGrams:a,nGramsSplits:s}=n.string.stringNGrams(sw("data",e,t,r),sw("dataSplits",e,t,r),sw("separator",e,t,r),sw("nGramWidths",e,t,r),sw("leftPad",e,t,r),sw("rightPad",e,t,r),sw("padWidth",e,t,r),sw("preserveShortSequences",e,t,r));return[a,s]}case"StringSplit":{let{indices:a,values:s,shape:i}=n.string.stringSplit(sw("input",e,t,r),sw("delimiter",e,t,r),sw("skipEmpty",e,t,r));return[a,s,i]}case"StringToHashBucketFast":return[n.string.stringToHashBucketFast(sw("input",e,t,r),sw("numBuckets",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"transformation":return a(()=>((e,t,r,n=R)=>{switch(e.op){case"Cast":return[n.cast(sw("x",e,t,r),sw("dtype",e,t,r))];case"ExpandDims":{let a=sw("axis",e,t,r);return[n.expandDims(sw("x",e,t,r),a)]}case"Squeeze":{let a=sw("axis",e,t,r);return[n.squeeze(sw("x",e,t,r),a)]}case"Reshape":return[n.reshape(sw("x",e,t,r),sw("shape",e,t,r))];case"EnsureShape":return[n.ensureShape(sw("x",e,t,r),sw("shape",e,t,r))];case"MirrorPad":return[n.mirrorPad(sw("x",e,t,r),sw("padding",e,t,r),sw("mode",e,t,r))];case"PadV2":case"Pad":return[n.pad(sw("x",e,t,r),sw("padding",e,t,r),sw("constantValue",e,t,r))];
295case"SpaceToBatchND":{let a=sw("blockShape",e,t,r),s=sw("paddings",e,t,r);return[n.spaceToBatchND(sw("x",e,t,r),a,s)]}case"BatchToSpaceND":{let a=sw("blockShape",e,t,r),s=sw("crops",e,t,r);return[n.batchToSpaceND(sw("x",e,t,r),a,s)]}case"DepthToSpace":{let a=sw("blockSize",e,t,r),s=sw("dataFormat",e,t,r).toUpperCase();return[n.depthToSpace(sw("x",e,t,r),a,s)]}case"BroadcastTo":return[n.broadcastTo(sw("x",e,t,r),sw("shape",e,t,r))];case"BroadcastArgs":return[n.broadcastArgs(sw("s0",e,t,r),sw("s1",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,r));case"hash_table":return im(e,t,r,n);case"custom":let s=sb[e.op];if(s&&s.customExecutor)return s.customExecutor(new ie(e,t,r));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,r);return W.ZSL.isPromise(s)?s.then(e=>[].concat(e)):[].concat(s)}class iy{constructor(e={},t={},r={},n={},a){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=r,this.functionMap=n,this.parseNodeNameCache=a,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){let e=[];for(let t=0;t<this.contexts.length-1;t++){let r=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(r))}e.push(""),this._currentContextIds=e}contextIdforContexts(e){return e?e.map(e=>0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(this.contexts&&this.contexts.length>1)this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift();else throw Error("Cannot exit frame, the context is empty")}nextIteration(){if(this.contexts&&this.contexts.length>0){this.contexts=this.contexts.slice(),this.lastId++;let e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}else throw Error("Cannot increase frame iteration, the context is empty")}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(let t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(let t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function ib(e,t,r,n){let a=new Set,s=[],i=null,o=null,l=new Set,u=new Set(Object.keys(e).map(e=>sI(e)[0])),h=new Set((n=n||[]).map(e=>sI(e.name)[0])),p=[...t];for(;p.length>0;){var d,c;let e=p.pop();if((iS(e)||(d=e,iw.has(d.op))||(c=e,iT.has(c.op)))&&null==i&&(o=(i=e).children.map(e=>e.name).filter(e=>a.has(e))),a.add(e.name),!(null!=r[e.name]||u.has(e.name)||h.has(e.name))){if(0===e.inputs.length){s.push(e.name);continue}e.inputs.forEach(e=>{l.has(e.name)||(l.add(e.name),p.push(e))})}}return{inputs:e,outputs:t,usedNodes:a,missingInputs:s,dynamicNode:i,syncInputs:o}}class ix extends Error{constructor(e){super(`NodesExecutionOrderError: ${e}`)}}let iv=new Set(["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"]),iw=new Set(["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"]),iT=new Set(["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"]);function iS(e){return iv.has(e.op)}class iN{get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){let t=Object.keys(e).map(t=>e[t].map(e=>e.id));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map(e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}))}get outputs(){return this._outputs.map(e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}))}get inputNodes(){return this._inputs.map(e=>e.signatureKey||e.name)}get outputNodes(){return this._outputs.map(e=>{let t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t})}get functions(){return Object.keys(this._functions).reduce((e,t)=>
295(e[t]=this._functions[t].signature,e),{})}constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this.parseNodeNameCache=new Map,this._weightMap={},this.SEPARATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach(t=>{this._functionExecutorMap[t]=new iN(e.functions[t],this)})}getCompilationKey(e,t){let r=e.map(e=>e.name).sort(),n=t.map(e=>e.name).sort();return r.join(this.SEPARATOR)+"--"+n.join(this.SEPARATOR)}compile(e,t){let r=ib(e,t,this.weightMap,this._initNodes),{missingInputs:n,dynamicNode:a,syncInputs:s}=r;if(null!=a)throw Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${s}]`);if(n.length>0){let r=t.map(e=>e.name),a=Object.keys(e);throw Error(`Cannot compute the outputs [${r}] from the provided inputs [${a}]. Missing the following inputs: [${n}]`)}let i=function(e,t){let{usedNodes:r,inputs:n}=t,a=Object.keys(n).map(e=>sI(e)[0]).map(t=>e.nodes[t]),s=e.initNodes||[],i=e=>r.has("string"==typeof e?e:e.name);function o(e){return[...new Map(e.map(e=>[e.name,e])).values()]}let l=o([...a,...e.weights,...s]).filter(i),u=o([...l,...Object.values(e.nodes)]).filter(i),h=new Map(u.map(e=>[e.name,e])),p={};for(let e of u)for(let t of(p[e.name]=p[e.name]||0,e.children))i(t)||(p[t.name]=1/0),p[t.name]=(p[t.name]||0)+1;let d=Object.entries(p).filter(([,e])=>0===e).map(([e])=>e),c=[...d];for(;d.length>0;){let e=d.pop();for(let t of h.get(e).children.filter(i))0==--p[t.name]&&(c.push(t.name),d.push(t.name))}let f=function(e,t){let r=new Map(e.map(e=>[e.name,e])),n=t.map(e=>e.name),a=new Set(n);for(;n.length>0;){let e=n.pop();for(let t of r.get(e).children)!r.has(t.name)||a.has(t.name)||(a.add(t.name),n.push(t.name))}return e.filter(e=>a.has(e.name))}(c.map(e=>h.get(e)),l);return function(e,t){let r=new Map(e.map((e,t)=>[e.name,t])),n=new Set(t.map(e=>e.name)),a=e=>n.has("string"==typeof e?e:e.name),s=new Set(e.map(e=>e.name)),i=e=>s.has("string"==typeof e?e:e.name);for(let t of e){for(let e of t.children.filter(i)){if(!r.has(e.name))throw new ix(`Child ${e.name} of node ${t.name} is unreachable.`);if(r.get(t.name)>r.get(e.name))throw new ix(`Node ${t.name} is scheduled to run after its child ${e.name}.`)}if(!a(t))for(let e of t.inputs){if(!r.has(e.name))throw new ix(`Input ${e.name} of node ${t.name} is unreachable.`);if(r.get(e.name)>r.get(t.name))throw new ix(`Node ${t.name} is scheduled to run before its input ${e.name}.`)}}}(f,l),f}(this.graph,r),o=function(e){let t=new Map(e.map((e,t)=>[e.name,t])),r=Number.MAX_SAFE_INTEGER,n=e.map((e,t)=>iS(e)?r:t),a=e=>{let r=n[t.get(e.name)];return null==r?-1:r},s=e.map((e,t)=>e.children.map(a).reduce((e,t)=>Math.max(e,t),n[t])),i=new Map;for(let t=0;t<e.length;++t){let n=s[t];if(n===r)continue;let a=e[t],o=e[n];i.has(o.name)||i.set(o.name,[]),i.get(o.name).push(a)}return i}(i);return{orderedNodes:i,nodeLiveUntilMap:o}}cloneAndKeepTensor(e){if(null==e)return null;let t=e.clone();return(0,W.aCs)(t),t}cloneTensorList(e){return e?e.map(e=>this.cloneAndKeepTensor(e)):null}cloneTensorMap(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,this.cloneTensorList(t)]))}execute(e,t){this.disposeIntermediateTensors();let r=Object.keys(e=this.mapInputs(e)).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);let n=r.map(e=>this.graph.nodes[sI(e)[0]]),a=t.map(e=>sI(e)[0]),s=new Set(a),i=a.map(e=>this.graph.nodes[e]);0===i.length&&(i=this._outputs);let o=this.getCompilationKey(n,i),l=this.compiledMap.get(o);null==l&&(l=this.compile(e,i),this.compiledMap.set(o,l));try{this.keepIntermediateTensors=(0,W._K2)().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}let u={},h={};return(0,W.DZQ)(()=>{let r=new iy(this.weightMap,u,h,this.functionExecutorMap,this.parseNodeNameCache),n=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(e).forEach(t=>{let[a,s]=sI(t,r),i=[];i[s]=e[t],n[a]=i,this.keepIntermediateTensors&&(this.clonedTensorsMap[a]=this.cloneTensorList(i))});let a=this.getFrozenTensorIds(n),{orderedNodes:i,nodeLiveUntilMap:o}=l;for(let e of i){if(n[e.name])continue;let t=ig(e,n,r,this._resourceManager);if(W.ZSL.isPromise(t))throw Error(`The execution of the op '${e.op}' returned a promise. Please use model.executeAsync() instead.`);n[e.name]=t,this.keepIntermediateTensors&&(this.clonedTensorsMap[e.name]=this.cloneTensorList(t)),this.checkTensorForDisposalWithNodeLiveUntilInfo(e,n,r,a,s,o.get(e.name))}return null==this.parent&&r.dispose(a),t.map(e=>sT(e,n,r))})}getFrozenTensorIds(e){return new Set([].concat.apply([],Object.keys(e).map(t=>e[t]).map(e=>e.map(e=>e.id))))}checkTensorForDisposal(e,t,r,n,a,s,i){if(!(iS(t)||s.has(e))){for(let n of r[e])null!=n&&(i[n.id]=(i[n.id]||0)+t.children.length);
295for(let e of t.inputs){if(iS(e))continue;let t=sS(e.name,r,n);if(null!=t)for(let e of t){if(!e||e.kept||a.has(e.id))continue;let t=i[e.id];1===t?(e.dispose(),delete i[e.id]):null!=t&&i[e.id]--}}}}checkTensorForDisposalWithNodeLiveUntilInfo(e,t,r,n,a,s){if(!iS(e)&&null!=s){for(let e of s)if(!(iS(e)||a.has(e.name)))for(let a of sS(e.name,t,r))!a||a.kept||n.has(a.id)||a.dispose()}}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.clonedTensorsMap&&(Object.values(this.clonedTensorsMap).forEach(e=>{for(let t of e)t&&!t.isDisposed&&t.dispose()}),this.clonedTensorsMap=null)}getIntermediateTensors(){return this.clonedTensorsMap}async _executeAsync(e,t,r=!1,n={},a={}){this.disposeIntermediateTensors(),r||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepIntermediateTensors=(0,W._K2)().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}let s=new iy(this.weightMap,n,a,this.functionExecutorMap,this.parseNodeNameCache);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));let i=await this.executeWithControlFlow(e,s,t,r),o=t.map(e=>sT(e,i,s)),l=new Set([...o.map(e=>e.id),...Object.keys(e).map(t=>e[t].id),...this.weightIds]);return Object.values(i).forEach(e=>{e.forEach(e=>{!e||e.isDisposed||l.has(e.id)||e.dispose()})}),null==this.parent&&s.dispose(l),o}async executeFunctionAsync(e,t,r){let n=e.reduce((e,t,r)=>(e[this.inputs[r].name]=t,e),{});return this._executeAsync(n,this.outputNodes,!0,t,r)}async executeWithControlFlow(e,t,r,n){let a=Object.keys(e),s=a.map(e=>this.graph.nodes[sI(e)[0]]),i=r.map(e=>sI(e)[0]),o=new Set(i),l=i.map(e=>this.graph.nodes[e]);0===l.length&&(l=this._outputs);let{usedNodes:u,missingInputs:h,dynamicNode:p,syncInputs:d}=ib(e,l,this.weightMap,this._initNodes),c=[...s,...this.graph.weights,...this._initNodes||[]].map(e=>({node:e,contexts:t.currentContext})),f=Object.assign({},this.weightMap);Object.keys(e).forEach(t=>{let[r,n]=sI(t),a=[];a[n]=e[t],f[r]=a});let m={},g=this.getFrozenTensorIds(f),y={};for(;c.length>0;){let e=this.processStack(s,c,t,f,y,g,o,m,u);await Promise.all(e)}null!=p||n||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");let b=l.filter(e=>!iS(e)&&!sT(e.name,f,t)).map(e=>e.name);if(b.length>0){let e="";throw null!=p&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${d}]`),Error(`Cannot compute the outputs [${b}] from the provided inputs [${a}]. Consider providing the following inputs: [${h}]. ${e}`)}return f}processStack(e,t,r,n,a,s,i,o,l){let u=[];for(;t.length>0;){let e=t.pop();r.currentContext=e.contexts;let h="";if("Enter"===e.node.op&&sw("isConstant",e.node,n,r)&&([h]=sN(e.node.name,r)),null==n[e.node.name]){let p=ig(e.node,n,r,this._resourceManager);h||([h]=sN(e.node.name,r));let d=r.currentContext;W.ZSL.isPromise(p)?u.push(p.then(u=>(n[h]=u,this.keepIntermediateTensors&&(this.clonedTensorsMap[h]=this.cloneTensorList(u)),r.currentContext=d,this.checkTensorForDisposal(h,e.node,n,r,s,i,o),this.processChildNodes(e.node,t,r,n,a,l),u))):(n[h]=p,this.keepIntermediateTensors&&(this.clonedTensorsMap[h]=this.cloneTensorList(p)),this.checkTensorForDisposal(h,e.node,n,r,s,i,o),this.processChildNodes(e.node,t,r,n,a,l))}else this.processChildNodes(e.node,t,r,n,a,l)}return u}processChildNodes(e,t,r,n,a,s){e.children.forEach(e=>{let[i]=sN(e.name,r);!a[i]&&s.has(e.name)&&("Merge"===e.op?e.inputNames.some(e=>!!sT(e,n,r))&&(a[i]=!0,t.push({contexts:r.currentContext,node:e})):e.inputNames.every(e=>!!sT(e,n,r))&&(a[i]=!0,t.push({contexts:r.currentContext,node:e})))})}dispose(){Object.keys(this.weightMap).forEach(e=>this.weightMap[e].forEach(e=>e.dispose()))}checkInputShapeAndType(e){Object.keys(e).forEach(t=>{let r=e[t],[n]=sI(t),a=this.graph.nodes[n];if(a.attrParams.shape&&a.attrParams.shape.value){let e=a.attrParams.shape.value,t=e.length===r.shape.length&&r.shape.every((t,r)=>-1===e[r]||e[r]===t);W.ZSL.assert(t,()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${r.shape}]`)}a.attrParams.dtype&&a.attrParams.dtype.value&&W.ZSL.assert(r.dtype===a.attrParams.dtype.value,()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${r.dtype}`)})}mapInputs(e){var t,r;let n={};for(let a in e){let s=null==(r=null==(t=this._signature)?void 0:t.inputs)?void 0:r[a];null!=s?n[s.name]=e[a]:n[a]=e[a]}return n}checkInputs(e){let t=Object.keys(e).filter(e=>{let[t]=sI(e);return null==this.graph.nodes[t]});if(t.length>0)throw Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map(e=>{var t,r;let n=null==(r=null==(t=this._signature)?void 0:t.outputs)?void 0:r[e];return null!=n?n.name:e},{})}
295checkOutputs(e){e.forEach(e=>{let[t]=sI(e);if(!this.graph.nodes[t])throw Error(`The output '${e}' is not found in the graph`)})}}class ik{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(let e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(let e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}var iI=r(51874);class iC{get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}constructor(e,t={},r=W.io){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=r,null==t&&(this.loadOptions={}),this.resourceManager=new ik}findIOHandler(){let e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{let t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");let e=this.handler.load();return W.ZSL.isPromise(e)?e.then(e=>null==e.getWeightStream?this.loadSync(e):this.loadStreaming(e)):this.loadSync(e)}loadSync(e){let t=this.io.decodeWeights(e.weightData,e.weightSpecs);return this.loadWithWeightMap(e,t)}async loadStreaming(e){if(null==e.getWeightStream)throw Error("Model artifacts missing streamWeights function");let t=await (0,iI.s5)(e.getWeightStream(),e.weightSpecs);return this.loadWithWeightMap(e,t)}loadWithWeightMap(e,t){this.artifacts=e;let r=this.artifacts.modelTopology,n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){let e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}if(this.signature=n,this.version=`${r.versions.producer}.${r.versions.minConsumer}`,this.executor=new iN(sY.Instance.transformGraph(r,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(t),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){let t=sY.Instance.transformGraph(e.modelInitializer);this.initializer=new iN(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=e.initializerSignature}return!0}async save(e,t){if("string"==typeof e){let t=this.io.getSaveHandlers(e);if(0===t.length)throw Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}addStructuredOutputNames(e){if(this.structuredOutputKeys){let t=e instanceof W.qYS?[e]:e,r={};return t.forEach((e,t)=>r[this.structuredOutputKeys[t]]=e),r}return e}predict(e,t){let r=this.execute(e,this.outputNodes);return this.addStructuredOutputNames(r)}async predictAsync(e,t){let r=await this.executeAsync(e,this.outputNodes);return this.addStructuredOutputNames(r)}normalizeInputs(e){var t;if(!(e instanceof W.qYS)&&!Array.isArray(e)){let r=null==(t=this.signature)?void 0:t.inputs;if(null!=r)for(let t in r){let n=r[t];null!=n.resourceId&&(e[t]=this.resourceIdToCapturedInput[n.resourceId])}return e}e=Array.isArray(e)?e:[e];let r=Object.keys(this.resourceIdToCapturedInput).length;if(e.length+r!==this.inputNodes.length)throw Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-r} non-resource placeholders, while there are ${e.length} input tensors provided.`);let n=0;return this.inputNodes.reduce((t,r)=>{var a,s,i;let o=null==(i=null==(s=null==(a=this.signature)?void 0:a.inputs)?void 0:s[r])?void 0:i.resourceId;return null!=o?t[r]=this.resourceIdToCapturedInput[o]:t[r]=e[n++],t},{})}normalizeOutputs(e){return Array.isArray(e=e||this.outputNodes)?e:[e]}executeInitializerGraph(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))}async executeInitializerGraphAsync(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.executeAsync({},[]):this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs))}setResourceIdToCapturedInput(e){if(this.resourceIdToCapturedInput={},this.initializerSignature){let t=this.initializerSignature.outputs,r=Object.keys(t);for(let n=0;n<r.length;n++){let a=t[r[n]];this.resourceIdToCapturedInput[a.resourceId]=e[n]}}}execute(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);let r=this.executor.execute(e,t);return r.length>1?r:r[0]}async executeAsync(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);let r=await this.executor.executeAsync(e,t);return r.length>1?r:r[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce((t,r)=>(t[r]=[e[r]],t),{})}dispose(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&(0,W.ASo
295)(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function iE(e,t={},r=W.io){var n;if(null==e)throw Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&((n=e).endsWith("/")||(n+="/"),e=`${n}model.json?tfjs-format=file`);let a=new iC(e,t,r);return await a.load(),a}function iA(e){let t;if(null==e)throw Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model");if(e instanceof Array){let[r,n]=e;if(!r)throw Error("modelJSON must be the first element of the array");if(!n||!(n instanceof ArrayBuffer))throw Error("An ArrayBuffer of weights must be the second element of the array");if(!("modelTopology"in r))throw Error("Model JSON is missing 'modelTopology'");if(!("weightsManifest"in r))throw Error("Model JSON is missing 'weightsManifest'");let a=W.io.getWeightSpecs(r.weightsManifest),s=W.io.getModelArtifactsForJSONSync(r,a,n);t=W.io.fromMemorySync(s)}else if("load"in e)t=e;else if("modelTopology"in e&&"weightSpecs"in e&&"weightData"in e)t=W.io.fromMemorySync(e);else throw Error("Unknown model format");let r=new iC(t);return r.load(),r}let i$="4.22.0";var iF=r(68173);function iR(e,t,r=new Map,n=new Set){if(null==e)return null;if("function"==typeof Blob&&e instanceof Blob)return e.slice();if(n.has(e))throw Error("Circular references are not supported.");if(r.has(e))return r.get(e);let a=t(e);if(a.recurse&&null!==a.value)throw Error("A deep map function may not return both a value and recurse=true.");if(!a.recurse)return r.set(e,a.value),a.value;if(iO(e)){let a=Array.isArray(e)?[]:{};for(let s in n.add(e),e){let i=iR(e[s],t,r,n);a[s]=i}return n.delete(e),e.__proto__&&(a.__proto__=e.__proto__),a}throw Error(`Can't recurse into non-iterable type: ${e}`)}function i_(e){return null===e?null:iO(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function iD(e,t){let r=new Map;for(let n of(iR(e,t,r),Array.from(r.keys()))){let e=r.get(n);if(W.ZSL.isPromise(e)){let t=await e;r.set(n,t)}}return iR(e,t,r)}function iO(e){let t=!1;if(W._K2().get("IS_BROWSER"))t=e instanceof TextDecoder;else{let{StringDecoder:n}=r(80551);t=e instanceof n}return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof W.qYS)&&!(e instanceof Promise)&&!t)}function iL(e){return e instanceof W.qYS?{value:e.clone(),recurse:!1}:iO(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}class iM{constructor(e){if(this.capacity=e,this.begin=0,this.end=0,null==e)throw RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw RangeError("Can't create ring buffer of capacity < 1.");this.data=Array(e),this.doubledCapacity=2*e}wrap(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}get(e){if(e<0)throw RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}set(e,t){if(e<0)throw RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t}length(){let e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(e){if(this.isFull())throw RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)}pushAll(e){for(let t of e)this.push(t)}pop(){if(this.isEmpty())throw RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);let e=this.get(this.end);return this.set(this.end,void 0),e}unshift(e){if(this.isFull())throw RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}shift(){if(this.isEmpty())throw RangeError("Ring buffer is empty.");let e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e}shuffleExcise(e){if(this.isEmpty())throw RangeError("Ring buffer is empty.");let t=this.wrap(this.begin+e),r=this.get(t);return this.set(t,this.pop()),r}}class iP extends iM{constructor(){super(iP.INITIAL_CAPACITY)}isFull(){return!1}push(e){super.isFull()&&this.expand(),super.push(e)}unshift(e){super.isFull()&&this.expand(),super.unshift(e)}expand(){let e=2*this.capacity,t=Array(e),r=this.length();for(let e=0;e<r;e++)t[e]=this.get(this.wrap(this.begin+e));this.data=t,this.capacity=e,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=r}}iP.INITIAL_CAPACITY=32;class iz{async toArray(){let e=[],t=await this.next();for(;!t.done;)e.push(t.value),t=await this.next();return e}async toArrayForTest(){let e=this.prefetch(100),t=[],r=await e.next();for(;!r.done;)t.push(r.value),r=await e.next();return t}async resolveFully(){let e=await this.next();for(;!e.done;)e=await this.next()}async resolveWhile(e){let t=await this.next(),r=e(t.value);for(;!t.done&&r;)r=e((t=await this.next()).value)}handleErrors(e){return new iH(this,e)}filter(e){return new ij(this,e)}map(e){return new iK(this,e)}mapAsync(e){return new iY(this,e)}serialMapAsync(e){return new iY(this,e).serial()}flatmap(e){return new iq(this,e)}async forEachAsync(e){return this.map(e).resolveFully()}async serialForEach(e){return this.serialMapAsync(e).resolveWhile(e=>!0===e)}rowMajorBatch(e,t=!0){return new iZ(this,e,t)}columnMajorBatch(e,t=!0,r=i_){return this.rowMajorBatch(e,t).map(e=>(function(e,t=i_){return function e(t,r,n=new Set){let a=t[0];if(n.has(a))throw Error("Circular references are not supported.");let s=r(t);if(s.recurse&&null!==s.value)throw Error("A deep zip function may not return both a value and recurse=true.");if(!s.recurse)return s.value;if(iO(a)){let s=Array.isArray(a)?[]:{};for(let i in n.add(a),a){let a=e(t.map(e=>e[i]),r,n);s[i]=a}return n.delete(a),s}throw Error(`Can't recurse into non-iterable type: ${a}`)}(e,t)})(e,r))}concatenate(e,t){return new iX(new iB([this,e]),t)}take(e){return e<0||null==e?this:new iG(this,e)}skip(e){return e<0||null==e?this:new iU(this,e)}prefetch(e){return new i0(this,e)}shuffle(e,t){return new i1(this,e,t)}serial(){return new iV(this)}}class iB extends iz{constructor(e){super(),this.items=e,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};let e=this.items[this.trav];return this.trav++,{value:iR(e,iL),done:!1}}}class iW extends iz{constructor(e){super(),this.nextFn=e}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(e){throw e.message=`Error thrown while iterating through a dataset: ${e.message}`,e}}}class iV extends iz{constructor(e){super(),this.upstream=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){return this.upstream.next()}}class iU extends iz{constructor(e,t){super(),this.upstream=e,this.maxCount=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){let e=await this.upstream.next();if(e.done)return e;W.ASo(e.value)}return this.upstream.next()}}class iG extends iz{constructor(e,t){super(),this.upstream=e,this.maxCount=t,this.count=0}summary(){return`${this.upstream.summary()} -> Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class iZ extends iz{constructor(e,t,r=!0){super(),this.upstream=e,this.batchSize=t,this.enableSmallLastBatch=r,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){let e=[];for(;e.length<this.batchSize;){let t=await this.upstream.next();if(t.done){if(this.enableSmallLastBatch&&e.length>0)return{value:e,done:!1};return{value:null,done:!0}}e.push(t.value)}return{value:e,done:!1}}}class ij extends iz{constructor(e,t){super(),this.upstream=e,this.predicate=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;;){let e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;W.ASo(e.value)}}}class iK extends iz{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Map`}async next(){let e=await this.upstream.next();if(e.done)return{value:null,done:!0};let t=W.d_S.getTensorsInContainer(e.value),r=this.transform(e.value),n=W.d_S.getTensorsInContainer(r);for(let e of t)W.d_S.isTensorInList(e,n)||e.dispose();return{value:r,done:!1}}}class iH extends iz{constructor(e,t){super(),this.upstream=e,this.handler=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(e){if(!this.handler(e))return{value:null,done:!0}}}}class iY extends iz{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){let e=await this.upstream.next();if(e.done)return{value:null,done:!0};let t=W.d_S.getTensorsInContainer(e.value),r=await this.transform(e.value),n=W.d_S.getTensorsInContainer(r);for(let e of t)W.d_S.isTensorInList(e,n)||e.dispose();return{value:r,done:!1}}}class iQ extends iz{constructor(){super(),this.outputQueue=new iP,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class iq extends iQ{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){let e=await this.upstream.next();if(e.done)return!1;let t=W.d_S.getTensorsInContainer(e.value),r=this.transform(e.value),n=W.d_S.getTensorsInContainer(r);for(let e of(this.outputQueue.pushAll(r),t))W.d_S.isTensorInList(e,n)||e.dispose();return!0}}class iX extends iz{constructor(e,t){super(),this.baseErrorHandler=t,this.lastRead=null,this.iterator=null,this.moreIterators=e}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(e){if(await e,null==this.iterator){let e=await this.moreIterators.next();if(e.done)return{value:null,done:!0};this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}let t=await this.iterator.next();return t.done?(this.iterator=null,this.readFromChain(e)):t}}
295!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(i||(i={}));class iJ extends iz{constructor(e,t=i.FAIL){super(),this.iterators=e,this.mismatchMode=t,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(e){await e;let t=0,r=0,n=await iD(this.iterators,function(e){return e instanceof iz?{value:e.next().then(e=>(t++,e.done&&r++,e.value)),recurse:!1}:{value:null,recurse:!0}});if(t===r)return{value:null,done:!0};if(r>0)switch(this.mismatchMode){case i.FAIL:throw Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case i.SHORTEST:return{value:null,done:!0};case i.LONGEST:}return this.count++,{value:n,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class i0 extends iz{constructor(e,t){super(),this.upstream=e,this.bufferSize=t,this.buffer=new iM(t)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){let e=this.upstream.next();this.buffer.push(e)}}next(){return this.refill(),this.buffer.shift()}}class i1 extends i0{constructor(e,t,r){super(e,t),this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=iF.alea(r||W.ZSL.now().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}randomInt(e){return Math.floor(this.random()*e)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){let e=this.chooseIndex(),t=await this.buffer.shuffleExcise(e);if(!t.done)return this.refill(),t;this.upstreamExhausted=!0}return{value:null,done:!0}}}class i2{constructor(){this.size=null}batch(e,t=!0){let r=this;return W.ZSL.assert(e>0,()=>`batchSize needs to be positive, but it is 296 ${e}`),i3(async()=>(await r.iterator()).columnMajorBatch(e,t,i5),this.size===1/0||null==this.size?this.size:t?Math.ceil(this.size/e):Math.floor(this.size/e))}concatenate(e){let t=this;return i3(async()=>(await t.iterator()).concatenate(await e.iterator()),this.size===1/0||e.size===1/0?1/0:null!=this.size&&null!=e.size?this.size+e.size:null)}filter(e){let t=this;return i3(async()=>(await t.iterator()).filter(t=>W.DZQ(()=>e(t))),this.size===1/0?1/0:null)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){let t=this;return i3(async()=>(await t.iterator()).map(t=>W.DZQ(()=>e(t))),this.size)}mapAsync(e){let t=this;return i3(async()=>(await t.iterator()).mapAsync(e),this.size)}prefetch(e){if(null==e)throw RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");let t=this;return i3(async()=>(await t.iterator()).prefetch(e),this.size)}repeat(e){let t=this;return i3(async()=>new iX(new iW(async()=>({value:await t.iterator(),done:!1})).take(e),void 0),null!=this.size&&e>0?this.size*e:0===e?0:null!=this.size&&(void 0===e||e<0)?1/0:null)}skip(e){let t=this;return i3(async()=>(await t.iterator()).skip(e),null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size<e||void 0===e||e<0)?0:null)}shuffle(e,t,r=!0){if(null==e||e<0)if(null==this.size)throw RangeError("`Dataset.shuffle()` requires bufferSize to be specified.");else throw RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);let n=this,a=iF.alea(t||W.ZSL.now().toString());return i3(async()=>{let t=a.int32();return r&&(t+=a.int32()),(await n.iterator()).shuffle(e,t.toString())},this.size)}take(e){let t=this;return i3(async()=>(await t.iterator()).take(e),null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null)}async toArray(){if(this.size===1/0)throw Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function i3(e,t=null){return new class extends i2{constructor(){super(...arguments),this.size=t}async iterator(){return e()}}}function i4(e){return i3(async()=>new iB(e),e.length)}function i6(e){let t;if(!iO(e))throw Error("The argument to zip() must be an object or array.");if(Array.isArray(e))for(let r=0;r<e.length;r++)t=null==t?e[r].size:Math.min(t,e[r].size);else if(e instanceof Object)for(let r in e)t=null==t?e[r].size:Math.min(t,e[r].size);return i3(async()=>(function(e,t=i.FAIL){return new iJ(e,t)})(await iD(e,e=>{if(e instanceof i2)return{value:e.iterator(),recurse:!1};if(iO(e))return{value:null,recurse:!0};throw Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}),i.SHORTEST),t)}function i5(e){var t,r;if(null===e)return null;return null==(t=e[0])||null===(r=t)||"object"!=typeof r&&"function"!=typeof r||Array.isArray(t)||"object"==typeof t&&t instanceof W.qYS||W.ZSL.isTypedArray(t)?{value:function(e){if(0===e.length)throw Error("Can't make a batch of zero elements.");return e[0]instanceof W.qYS?W.t$z(e):W.OEK(e)}(e),recurse:!1}:{value:null,recurse:!0}}i2.MAX_BUFFER_SIZE=1e4;class i8 extends i2{constructor(e){super(),this.input=e}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map(e=>(e.endsWith("\r")&&(e=e.slice(0,-1)),e))}}let i7=Symbol("out"),i9=Symbol("field"),oe=Symbol("quote"),ot=Symbol("quoteafterquote"),or=Symbol("quoteinquote");class on extends i2{async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){let e=await this.maybeReadHeaderLine();if(this.fullColumnNames||e)this.fullColumnNames&&e&&W.ZSL.assert(e.length===this.fullColumnNames.length,()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+").");else throw Error("Column names must be provided if there is no header line.");this.fullColumnNames||(this.fullColumnNames=e);let t=this.fullColumnNames.reduce((e,t)=>
296(e[t]=e[t]+1||1,e),{}),r=Object.keys(t).filter(e=>t[e]>1);if(W.ZSL.assert(0===r.length,()=>"Duplicate column names found: "+r.toString()),this.columnConfigs){for(let e of Object.keys(this.columnConfigs))if(-1===this.fullColumnNames.indexOf(e))throw Error('The key "'+e+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(!this.hasHeader)return null;{let e=await this.base.iterator(),t=await e.next();if(t.done)throw Error("No data was found for CSV parsing.");let r=t.value;return this.parseRow(r,!1)}}constructor(e,t){super(),this.input=e,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new i8(e),t||(t={}),this.hasHeader=!1!==t.hasHeader,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(W.ZSL.assert(null==t.delimiter,()=>"Delimiter should not be provided when delimWhitespace is true."),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map(e=>this.makeDataElement(e))}makeDataElement(e){let t=this.parseRow(e),r={},n={};for(let a=0;a<this.fullColumnNames.length;a++){let s=this.fullColumnNames[a],i=this.columnConfigs?this.columnConfigs[s]:null;if(!this.configuredColumnsOnly||i){let o=t[a],l=null;if(""===o)if(i&&void 0!==i.default)l=i.default;else if(i&&(i.required||i.isLabel))throw Error(`Required column ${s} is empty in this line: ${e}`);else l=void 0;else{let e=Number(o);if(isNaN(e))l=i&&"bool"===i.dtype?this.getBoolean(o):o;else if(i&&i.dtype)switch(i.dtype){case"float32":default:l=e;break;case"int32":l=Math.floor(e);break;case"bool":l=this.getBoolean(o)}else l=e}i&&i.isLabel?n[s]=l:r[s]=l}}return 0===Object.keys(n).length?r:{xs:r,ys:n}}getBoolean(e){return+("1"===e||"true"===e.toLowerCase())}parseRow(e,t=!0){let r=[],n=0,a=e.length,s=i7;for(let t=0;t<a;t++)switch(s){case i7:switch(e.charAt(t)){case'"':n=t+1,s=oe;break;case this.delimiter:if(n=t+1," "===this.delimiter&&this.delimWhitespace)break;r.push(""),s=i7;break;default:s=i9,n=t}break;case i9:e.charAt(t)===this.delimiter&&(r.push(e.substring(n,t)),s=i7,n=t+1);break;case oe:'"'===e.charAt(t)&&(s=ot);break;case ot:switch(e.charAt(t)){case this.delimiter:r.push(e.substring(n,t-1)),s=i7,n=t+1;break;case'"':s=oe;break;default:s=or}break;case or:'"'===e.charAt(t)&&(s=oe)}if(s===ot?r.push(e.substring(n,a-1)):r.push(e.substring(n)),t&&r.length!==this.fullColumnNames.length)throw Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${r}`);return r}}class oa extends iz{constructor(e){super(),this.microphoneConfig=e,this.isClosed=!1,this.fftSize=e.fftSize||1024;let t=Math.log2(this.fftSize);if(this.fftSize<0||t<4||t>14||!Number.isInteger(t))throw Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=e.numFramesPerSpectrogram||43,this.sampleRateHz=e.sampleRateHz,this.columnTruncateLength=e.columnTruncateLength||this.fftSize,this.audioTrackConstraints=e.audioTrackConstraints,this.smoothingTimeConstant=e.smoothingTimeConstant||0,this.includeSpectrogram=!1!==e.includeSpectrogram,this.includeWaveform=!0===e.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(e={}){if(!(0,W._K2)().get("IS_BROWSER"))throw Error("microphone API is only supported in browser environment.");let t=new oa(e);return await t.start(),t}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(e){throw Error(`Error thrown while initializing video stream
296: ${e.message}`)}if(!this.stream)throw Error("Could not obtain audio from microphone.");let e=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new e,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;let t=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,t.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){let e,t;if(this.isClosed)return{value:null,done:!0};let r=await this.getAudioData();if(this.includeSpectrogram){let t=this.flattenQueue(r.freqDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){let e=this.flattenQueue(r.timeDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:e,waveform:t},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){let e=[],t=[],r=0;return new Promise(n=>{let a=setInterval(()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&n({freqDataQueue:e,timeDataQueue:t}),e.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),t.push(this.timeData.slice())),++r===this.numFrames&&(clearInterval(a),n({freqDataQueue:e,timeDataQueue:t}))},this.fftSize/this.sampleRateHz*1e3)})}stop(){!this.isClosed&&(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(e){let t=e[0].length,r=new Float32Array(e.length*t);return e.forEach((e,n)=>r.set(e,n*t)),r}getTensorFromAudioDataArray(e,t){let r=new Float32Array(W.ZSL.sizeFromShape(t));return r.set(e,r.length-e.length),(0,W.OEK)(r,t)}}class os extends iz{constructor(e,t){if(super(),this.webcamVideoElement=e,this.webcamConfig=t,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=(0,W.tGX)([0],"int32"),this.webcamConfig.centerCrop){let e=this.webcamConfig.resizeWidth/this.webcamVideoElement.width,t=this.webcamConfig.resizeHeight/this.webcamVideoElement.height,r=(1-e)/2,n=(1-t)/2;this.cropBox=(0,W.KtR)([n,r,t+n,r+e],[1,4])}else this.cropBox=(0,W.KtR)([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(!(0,W._K2)().get("IS_BROWSER"))throw Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!t.resizeWidth||!t.resizeHeight)throw Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");e.width=t.resizeWidth,e.height=t.resizeHeight}let r=new os(e,t);return await r.start(),r}async start(){this.webcamConfig.facingMode&&W.ZSL.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`);try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(e){throw e.message=`Error thrown while initializing video stream: ${e.message}`,e}if(!this.stream)throw Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(e){console.log(e),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise(e=>{this.webcamVideoElement.onloadedmetadata=()=>{e()}})}async next(){let e;if(this.isClosed)return{value:null,done:!0};try{e=W.TaL.fromPixels(this.webcamVideoElement)}
296catch(e){throw Error(`Error thrown converting video to pixels: ${JSON.stringify(e)}`)}if(!this.resize)return{value:e,done:!1};try{return{value:this.cropAndResizeFrame(e),done:!1}}catch(e){throw Error(`Error thrown cropping the video: ${e.message}`)}finally{e.dispose()}}needToResize(){return!!this.webcamConfig.resizeWidth&&!!this.webcamConfig.resizeHeight&&(this.webcamVideoElement.width!==this.webcamConfig.resizeWidth||this.webcamVideoElement.height!==this.webcamConfig.resizeHeight)}cropAndResizeFrame(e){return(0,W.DZQ)(()=>{let t,r=(0,W.UG6)((0,W.wgE)(e,"float32"),0),n=(t=W.Slp.cropAndResize(r,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear")).shape;return(0,W.tQQ)(t,n.slice(1))})}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach(e=>e.stop());try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw Error("Can not convert infinite video stream to array.")}}class oi{}class oo extends iz{split(e){return new ol(this,e)}}class ol extends oo{constructor(e,t){super(),this.upstream=e,this.impl=new ou(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class ou extends iQ{constructor(e,t){super(),this.upstream=e,this.separator=t,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){let e=await this.upstream.next();if(e.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);let t=e.value.split(this.separator);for(let e of(t[0]=this.carryover+t[0],t.slice(0,-1)))this.outputQueue.push(e);return this.carryover=t[t.length-1],!0}}var oh=r(15376).Buffer;class op extends iz{decodeUTF8(){return new od(this)}}class od extends oo{constructor(e){super(),this.upstream=e,this.impl=new oc(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class oc extends iQ{constructor(e){if(super(),this.upstream=e,(0,W._K2)().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{let{StringDecoder:e}=r(4530);this.decoder=new e("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){let e,t,r=await this.upstream.next();return!r.done&&(e=r.value,t=(0,W._K2)().get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(oh.from(e.buffer)),this.outputQueue.push(t),!0)}}class of extends op{constructor(e,t={}){super(),this.file=e,this.options=t,W.ZSL.assert(e instanceof Uint8Array||!!(0,W._K2)().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),()=>"FileChunkIterator only supports File, Blob and Uint8Array right now."),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};let e=new Promise((e,t)=>{let r=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)e(new Uint8Array(this.file.slice(this.offset,r)));else{let n=new FileReader;n.onload=r=>{let a=n.result;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),!(a instanceof Uint8Array))return t(TypeError("FileReader returned unknown type."));e(a)},n.onabort=e=>t(Error("Aborted")),n.onerror=e=>t(Error(e.type));let a=this.file.slice(this.offset,r);n.readAsArrayBuffer(a)}this.offset=r});return{value:await e,done:!1}}}async function om(e,t={},r){let n,a;"string"==typeof e?n=e:(n=e.url,a=og(e));let s=await (r||W.ZSL.fetch)(n,a);if(s.ok)return new of(new Uint8Array(await s.arrayBuffer()),t);throw Error(s.statusText)}let og=e=>({method:e.method,headers:e.headers,body:e.body,mode:e.mode,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity});function oy(e){return"string"==typeof e&&"file://"===e.slice(0,7)}class ob extends oi{constructor(e,t={}){super(),this.input=e,this.options=t}async iterator(){if(oy(this.input)&&(0,W._K2)().get("IS_NODE")){let e=r(8108);this.input=e.readFileSync(this.input.slice(7))}return new of(this.input,this.options)}}class ox extends oi{constructor(e,t={}){super(),this.url=e,this.fileOptions=t}async iterator(){return oy(this.url)?new ob(this.url,this.fileOptions).iterator():om(this.url,this.fileOptions)}}function ov(e,t={}){return new on(new ox(e),t)}function ow(e){let t=new iW(e);return i3(async()=>t)}
296function oT(e){return i3(async()=>{let t=await e();return new iW(()=>t.next())})}async function oS(e,t){return os.create(e,t)}async function oN(e){return oa.create(e)}let ok="4.22.0";var oI=r(60072);let oC=W.kpo.whereImpl;class oE extends W.uI_{nextDataId(){return oE.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new W.GJx(this,(0,W.Hi9)())}write(e,t,r){this.firstUse&&(this.firstUse=!1,(0,W._K2)().get("IS_NODE")&&W.C0T.warn("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));let n={id:this.nextDataId()};return this.data.set(n,{values:e,dtype:r,refCount:1}),n}makeTensorInfo(e,t,r){let n;if("string"===t&&null!=r&&r.length>0&&W.ZSL.isString(r[0])){let a=r.map(e=>W.ZSL.encodeString(e));n=this.write(a,e,t)}else n=this.write(r,e,t);return{dataId:n,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){let t=this.data.get(e);t.refCount++}decRef(e){if(this.data.has(e)){let t=this.data.get(e);t.refCount--}}move(e,t,r,n,a){this.data.set(e,{values:t,dtype:n,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){let{dtype:t,complexTensorInfos:r}=this.data.get(e);if("complex64"===t){let e=this.readSync(r.real.dataId),t=this.readSync(r.imag.dataId);return W.C0T.mergeRealAndImagArrays(e,t)}return W.ZSL.convertBackendValuesAndArrayBuffer(this.data.get(e).values,t)}bufferSync(e){let t=this.readSync(e.dataId);if("string"===e.dtype)try{let r=t.map(e=>W.ZSL.decodeString(e));return(0,W.ra8)(e.shape,e.dtype,r)}catch(e){throw Error("Failed to decode encoded string bytes into utf-8")}return(0,W.ra8)(e.shape,e.dtype,t)}makeOutput(e,t,r){return(0,W.Hi9)().makeTensorFromTensorInfo(this.makeTensorInfo(t,r,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;let{complexTensorInfos:r}=this.data.get(e);null!=r&&(this.disposeData(r.real.dataId,!0),this.disposeData(r.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){let t=W.ZSL.now();return e(),{kernelMs:W.ZSL.now()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){(0,oI.C)([e],"where");let t=this.readSync(e.dataId);return oC(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}oE.nextDataId=0;var oA=r(98722);let o$="4.22.0";(0,W.gJX)("cpu",()=>new oE,1);var oF=r(24446);let oR=(0,oF.v)(W.Pah,e=>e>=0?e:Math.exp(e)-1),o_={kernelName:W.Pah,backendName:"cpu",kernelFunc:oR};var oD=r(294);function oO(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{alpha:s}=n;(0,oI.C)([a],"leakyRelu");let i=W.ZSL.sizeFromShape(a.shape),o=r.data.get(a.dataId).values,l=W.ZSL.getTypedArrayFromDType("float32",i);for(let e=0;e<o.length;e++)l[e]=o[e]<0?s*o[e]:o[e];return r.makeTensorInfo(a.shape,"float32",l)}let oL={kernelName:W.X0$,backendName:"cpu",kernelFunc:oO};var oM=r(16879);let oP=(0,oM.Z)((e,t)=>e<0?t*e:e);function oz(e){let{inputs:t,backend:r}=e,{x:n,alpha:a}=t;(0,oI.C)([n,a],"prelu");let s=r.data.get(n.dataId).values,i=r.data.get(a.dataId).values,[o,l]=oP(n.shape,a.shape,s,i,"float32");return r.makeTensorInfo(l,"float32",o)}let oB={kernelName:W.Ncv,backendName:"cpu",kernelFunc:oz},oW=(0,oF.v)(W.fUj,e=>Math.max(0,e)),oV={kernelName:W.fUj,backendName:"cpu",kernelFunc:oW},oU=(0,oF.v)(W.P_L,e=>Math.min(Math.max(0,e),6)),oG={kernelName:W.P_L,backendName:"cpu",kernelFunc:oU};var oZ=r(93020);function oj(e,t,r,n,a){if("linear"===r)return(0,oD.D)({inputs:{x:t},backend:e});if("relu"===r)return oW({inputs:{x:t},backend:e});if("elu"===r)return oR({inputs:{x:t},backend:e});if("relu6"===r)return oU({inputs:{x:t},backend:e});if("prelu"===r)return oz({inputs:{x:t,alpha:n},backend:e});else if("leakyrelu"===r)return oO({inputs:{x:t},backend:e,attrs:{alpha:a}});else if("sigmoid"===r)return(0,oZ.ry)({inputs:{x:t},backend:e});throw Error(`Activation ${r} has not been implemented for the CPU backend.`)}var oK=r(58611);function oH(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{shape:s}=n,i=W.ZSL.sizeFromShape(a.shape),o=W.ZSL.inferFromImplicitShape(s,i),l=W.ZSL.sizeFromShape(o);W.ZSL.assert(i===l,()=>`The new shape (${o}) has ${l} elements and the old shape (${a.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`),r.incRef(a.dataId);let u=r.data.get(a.dataId);if(null!=u.complexTensorInfos){let e=u.complexTensorInfos.real,t=u.complexTensorInfos.imag;e.shape=o,t.shape=o}return{dataId:a.dataId,shape:o,dtype:a.dtype}}let oY={kernelName:W.R23,backendName:"cpu",kernelFunc:oH};function oQ(e){let{inputs:t,backend:r,attrs:n}=e,{a,b:s}=t,{transposeA:i,transposeB:o}=n;(0,oI.C)([a,s],"matMul");let l=a.shape.length,u=s.shape.length,h=i?a.shape[l-2]:a.shape[l-1],p=o?s.shape[u-1]:s.shape[u-2],d=i?a.shape[l-1]:a.shape[l-2],c=o?s.shape[u-2]:s.shape[u-1],f=a.shape.slice(0,-2),m=s.shape.slice(0,-2),g=W.ZSL.sizeFromShape(f),y=W.ZSL.sizeFromShape(m),b=W.ZEY.assertAndGetBroadcastShape(a.shape.slice(0,-2),s.shape.slice(0,-2)).c
296oncat([d,c]);W.ZSL.assert(h===p,()=>`Error in matMul: inner shapes (${h}) and (${p}) of Tensors with shapes ${a.shape} and ${s.shape} and transposeA=${i} and transposeB=${o} must match.`);let x=oH({inputs:{x:a},backend:r,attrs:{shape:i?[g,h,d]:[g,d,h]}}),v=oH({inputs:{x:s},backend:r,attrs:{shape:o?[y,c,p]:[y,p,c]}}),w=i?x.shape[1]:x.shape[2],T=i?x.shape[2]:x.shape[1],S=o?v.shape[1]:v.shape[2],N=Math.max(g,y),k=r.data.get(x.dataId).values,I=r.data.get(v.dataId).values,C=W.ZSL.computeStrides(x.shape),E=W.ZSL.computeStrides(v.shape),[A,$,F]=i?[C[0],1,C[1]]:[C[0],C[1],1],[R,_,D]=o?[1,E[1],E[0]]:[E[1],1,E[0]],O=T*S,L=(0,W.ra8)([N,T,S],x.dtype),M=L.values,P=r.blockSize;for(let e=0;e<N;e++){let t=e%g,r=e%y;for(let n=0;n<T;n+=P){let a=Math.min(n+P,T);for(let s=0;s<S;s+=P){let i=Math.min(s+P,S);for(let o=0;o<w;o+=P){let l=Math.min(o+P,w);for(let u=n;u<a;u++)for(let n=s;n<i;n++){let a=0;for(let e=o;e<l;e++)a+=k[t*A+u*$+e*F]*I[e*R+n*_+r*D];M[e*O+(u*S+n)]+=a}}}}}return r.disposeIntermediateTensorInfo(x),r.disposeIntermediateTensorInfo(v),r.makeTensorInfo(b,L.dtype,L.values)}let oq={kernelName:W.jAQ,backendName:"cpu",kernelFunc:oQ},oX={kernelName:W.Dr,backendName:"cpu",kernelFunc:function(e){let t,r,n,{inputs:a,backend:s,attrs:i}=e,{a:o,b:l,bias:u,preluActivationWeights:h}=a,{transposeA:p,transposeB:d,activation:c,leakyreluAlpha:f}=i,m=[];for(let e of(t=oQ({inputs:{a:o,b:l},attrs:{transposeA:p,transposeB:d},backend:s}),u&&(r=(0,oK.WQ)({inputs:{a:t,b:u},backend:s}),m.push(t),t=r),c&&(n=oj(s,t,c,h,f),m.push(t),t=n),m))s.disposeIntermediateTensorInfo(e);return t}};var oJ=r(1888);let o0=(0,oF.v)(W.Vvy,e=>Math.acos(e)),o1={kernelName:W.Vvy,backendName:"cpu",kernelFunc:o0},o2=(0,oF.v)(W.PH8,e=>Math.acosh(e)),o3={kernelName:W.PH8,backendName:"cpu",kernelFunc:o2},o4={kernelName:W.EkD,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e;(0,oI.C)(t,"addN");let n=t.map(e=>r.data.get(e.dataId).values),a=(0,W.ra8)(t[0].shape,t[0].dtype),s=a.values;for(let e=0;e<t.length;e++){let t=n[e];for(let e=0;e<s.length;e++)s[e]+=t[e]}return r.makeTensorInfo(a.shape,a.dtype,a.values)}};var o6=r(32515);let o5={kernelName:W.u8Z,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n;(0,oI.C)(a,"all");let o=W.ZSL.parseAxisParam(s,a.shape),l=o,u=W.C0T.getAxesPermutation(l,a.shape.length),h=a;null!=u&&(h=(0,o6.m)({inputs:{x:a},backend:r,attrs:{perm:u}}),l=W.C0T.getInnerMostAxes(l.length,a.shape.length)),W.C0T.assertAxesAreInnerMostDims("all",l,h.shape.length);let[p,d]=W.C0T.computeOutAndReduceShapes(h.shape,l),c=W.ZSL.sizeFromShape(d),f=W.ZSL.makeZerosTypedArray(W.ZSL.sizeFromShape(p),h.dtype),m=r.data.get(h.dataId).values;for(let e=0;e<f.length;++e){let t=e*c,r=m[t];for(let e=0;e<c;++e){let n=m[t+e];r=r&&n}f[e]=r}null!=u&&r.disposeIntermediateTensorInfo(h);let g=r.makeTensorInfo(p,h.dtype,f);if(i){let e=oH({inputs:{x:g},backend:r,attrs:{shape:W.C0T.expandShapeToKeepDim(p,o)}});return r.disposeIntermediateTensorInfo(g),e}return g}},o8={kernelName:W.FSt,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n;(0,oI.C)(a,"any");let o=W.ZSL.parseAxisParam(s,a.shape),l=o,u=W.C0T.getAxesPermutation(l,a.shape.length),h=a;null!=u&&(h=(0,o6.m)({inputs:{x:a},backend:r,attrs:{perm:u}}),l=W.C0T.getInnerMostAxes(l.length,a.shape.length)),W.C0T.assertAxesAreInnerMostDims("any",l,h.shape.length);let[p,d]=W.C0T.computeOutAndReduceShapes(h.shape,l),c=W.ZSL.sizeFromShape(d),f=W.ZSL.makeZerosTypedArray(W.ZSL.sizeFromShape(p),h.dtype),m=r.data.get(h.dataId).values;for(let e=0;e<f.length;++e){let t=e*c,r=m[t];for(let e=0;e<c;++e){let n=m[t+e];r=r||n}f[e]=r}null!=u&&r.disposeIntermediateTensorInfo(h);let g=r.makeTensorInfo(p,h.dtype,f);if(i){let e=oH({inputs:{x:g},backend:r,attrs:{shape:W.C0T.expandShapeToKeepDim(p,o)}});return r.disposeIntermediateTensorInfo(g),e}return g}},o7={kernelName:W.Jp_,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s}=n;(0,oI.C)(a,"argMax");let i=W.ZSL.parseAxisParam(s,a.shape),o=W.C0T.getAxesPermutation(i,a.shape.length),l=a,u=[];
296null!=o&&(u.push(l=(0,o6.m)({inputs:{x:a},backend:r,attrs:{perm:o}})),i=W.C0T.getInnerMostAxes(i.length,l.shape.length)),i=[i[0]],W.C0T.assertAxesAreInnerMostDims("argMax",i,l.shape.length);let[h,p]=W.C0T.computeOutAndReduceShapes(l.shape,i),d=W.ZSL.sizeFromShape(h),c=W.ZSL.makeZerosTypedArray(d,"int32"),f=W.ZSL.sizeFromShape(p),m=r.data.get(l.dataId).values;for(let e=0;e<c.length;++e){let t=e*f,r=m[t],n=0;for(let e=0;e<f;++e){let a=m[t+e];a>r&&(r=a,n=e)}c[e]=n}return u.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.makeTensorInfo(h,"int32",c)}},o9={kernelName:W.p_m,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s}=n;(0,oI.C)(a,"argMin");let i=W.ZSL.parseAxisParam(s,a.shape),o=W.C0T.getAxesPermutation(i,a.shape.length),l=a,u=[];null!=o&&(u.push(l=(0,o6.m)({inputs:{x:a},backend:r,attrs:{perm:o}})),i=W.C0T.getInnerMostAxes(i.length,l.shape.length)),i=[i[0]],W.C0T.assertAxesAreInnerMostDims("argMin",i,l.shape.length);let[h,p]=W.C0T.computeOutAndReduceShapes(l.shape,i),d=W.ZSL.sizeFromShape(h),c=W.ZSL.makeZerosTypedArray(d,"int32"),f=W.ZSL.sizeFromShape(p),m=r.data.get(l.dataId).values;for(let e=0;e<c.length;++e){let t=e*f,r=m[t],n=0;for(let e=0;e<f;++e){let a=m[t+e];a<r&&(r=a,n=e)}c[e]=n}return u.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.makeTensorInfo(h,"int32",c)}},le=(0,oF.v)(W.QKF,e=>Math.asin(e)),lt={kernelName:W.QKF,backendName:"cpu",kernelFunc:le},lr=(0,oF.v)(W.epO,e=>Math.asinh(e)),ln={kernelName:W.epO,backendName:"cpu",kernelFunc:lr},la=(0,oF.v)(W.TyE,e=>Math.atan(e)),ls={kernelName:W.TyE,backendName:"cpu",kernelFunc:la};var li=r(8202);let lo=(0,oM.Z)((e,t)=>Math.atan2(e,t)),ll=(0,li.j)(W.lxb,lo),lu={kernelName:W.lxb,backendName:"cpu",kernelFunc:ll},lh=(0,oF.v)(W.zP9,e=>Math.atanh(e)),lp={kernelName:W.zP9,backendName:"cpu",kernelFunc:lh};function ld(e,t,r,n,a,s){let i=a.strideHeight,o=a.strideWidth,l=a.dilationHeight,u=a.dilationWidth,h=a.effectiveFilterHeight,p=a.effectiveFilterWidth,d=a.padInfo.top,c=a.padInfo.left,f="max"===s?-1/0:1/0,m=(0,W.ra8)(a.outShape,r),g=m.values,y=a.outShape[1]*a.outShape[2]*a.outShape[3],b=a.outShape[2]*a.outShape[3],x=a.outShape[3];for(let t=0;t<a.batchSize;++t){let r=t*y,m=t*n[0];for(let t=0;t<a.inChannels;++t)for(let y=0;y<a.outHeight;++y){let v=y*i-d,w=Math.max(0,v),T=Math.min(a.inHeight,h+v),S=r+y*b;for(let r=0;r<a.outWidth;++r){let i=r*o-c,h=Math.max(0,i),d=Math.min(a.inWidth,p+i),y=f,b=0,v=0;for(let r=w;r<T;r+=l){let a=m+r*n[1];for(let r=h;r<d;r+=u){let i=e[a+r*n[2]+t];"max"===s&&i>y?y=i:"avg"===s&&(b+=i,v++)}if(isNaN(y))break}g[S+r*x+t]="avg"===s?b/v:y}}}return m}function lc(e,t,r,n,a=!1,s=!1){let i=(0,W.ra8)(n.outShape,"int32"),o=n.strideHeight,l=n.strideWidth,u=n.dilationHeight,h=n.dilationWidth,p=n.effectiveFilterHeight,d=n.effectiveFilterWidth,c=n.padInfo.top,f=n.padInfo.left,m=(0,W.ra8)(t,r,e);for(let e=0;e<n.batchSize;++e)for(let t=0;t<n.inChannels;++t)for(let r=0;r<n.outHeight;++r){let g=r*o-c,y=g;for(;y<0;)y+=u;let b=Math.min(n.inHeight,p+g);for(let o=0;o<n.outWidth;++o){let p=o*l-f,c=p;for(;c<0;)c+=h;let x=Math.min(n.inWidth,d+p),v=-1/0,w=-1;for(let r=y;r<b;r+=u){let i=r-g;for(let o=c;o<x;o+=h){let l=o-p,u=m.get(e,r,o,t);u>v&&(v=u,w=a?s?((e*n.inHeight+r)*n.inWidth+o)*n.inChannels+t:(r*n.inWidth+o)*n.inChannels+t:i*d+l)}}i.set(w,e,r,o,t)}}return i}function lf(e,t,r,n,a,s){let i=a.strideDepth,o=a.strideHeight,l=a.strideWidth,u=a.dilationDepth,h=a.dilationHeight,p=a.dilationWidth,d=a.effectiveFilterDepth,c=a.effectiveFilterHeight,f=a.effectiveFilterWidth,m=a.padInfo.front,g=a.padInfo.top,y=a.padInfo.left,b="max"===s?-1/0:1/0,x=(0,W.ra8)(a.outShape,r),v=x.values,w=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],T=a.outShape[2]*a.outShape[3]*a.outShape[4],S=a.outShape[3]*a.outShape[4],N=a.outShape[4];for(let t=0;t<a.batchSize;++t){let r=t*w,x=t*n[0];for(let t=0;t<a.inChannels;++t)for(let w=0;w<a.outDepth;++w){let k=w*i-m,I=k;for(;I<0;)I+=u;let C=Math.min(a.inDepth,d+k),E=r+w*T;for(let r=0;r<a.outHeight;++r){let i=r*o-g,d=i;for(;d<0;)d+=h;let m=Math.min(a.inHeight,c+i),w=E+r*S;for(let r=0;r<a.outWidth;++r){let i=r*l-y,o=i;for(;o<0;
296)o+=p;let c=Math.min(a.inWidth,f+i),g=w+r*N,T=b,S=0,k=0;for(let r=I;r<C;r+=u){let a=x+r*n[1];for(let r=d;r<m;r+=h){let i=a+r*n[2];for(let r=o;r<c;r+=p){let a=e[i+r*n[3]+t];if("max"===s&&a>T?T=a:"avg"===s&&(S+=a,k++),isNaN(T))break}if(isNaN(T))break}if(isNaN(T))break}v[g+t]="avg"===s?S/Math.max(k,1):T}}}}return x}let lm={kernelName:W.ho8,backendName:"cpu",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r;(0,oI.C)(s,"avgPool");let{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=a;W.ZSL.assert(W.C0T.eitherStridesOrDilationsAreOne(o,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`);let h=W.C0T.computePool2DInfo(s.shape,i,o,1,l,u);if(1===h.filterWidth&&1===h.filterHeight&&W.ZSL.arraysEqual(h.inShape,h.outShape))t=(0,oD.D)({inputs:{x:s},backend:n});else{let e=n.data.get(s.dataId).values,r=W.ZSL.computeStrides(s.shape),a=ld(e,s.shape,s.dtype,r,h,"avg");t=n.makeTensorInfo(h.outShape,s.dtype,a.values)}return t}},lg={kernelName:W.cS,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:u}=n;(0,oI.C)(a,"avgPool3d");let h=W.C0T.computePool3DInfo(a.shape,s,i,1,o,l,u),p=lf(r.data.get(a.dataId).values,a.shape,a.dtype,W.ZSL.computeStrides(a.shape),h,"avg");return r.makeTensorInfo(p.shape,"float32",p.values)}},ly={kernelName:W.wwC,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=n;(0,oI.C)([a,s],"avgPool3DGrad");let h=W.C0T.computePool3DInfo(s.shape,i,o,1,l,u),p=h.strideDepth,d=h.strideHeight,c=h.strideWidth,f=h.filterDepth,m=h.filterHeight,g=h.filterWidth,y=h.dilationDepth,b=h.dilationHeight,x=h.dilationWidth,v=h.effectiveFilterDepth,w=h.effectiveFilterHeight,T=h.effectiveFilterWidth,S=v-1-h.padInfo.front,N=T-1-h.padInfo.left,k=w-1-h.padInfo.top,I=(0,W.ra8)(s.shape,"float32"),C=1/(f*m*g),E=r.bufferSync(a);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let r=0;r<h.inDepth;++r)for(let n=0;n<h.inHeight;++n)for(let a=0;a<h.inWidth;++a){let s=r-S,i=n-k,o=a-N,l=0;for(let r=0;r<v;r+=y){let n=(s+r)/p;if(!(n<0)&&!(n>=h.outDepth)&&Math.floor(n)===n)for(let r=0;r<w;r+=b){let a=(i+r)/d;if(!(a<0)&&!(a>=h.outHeight)&&Math.floor(a)===a)for(let r=0;r<T;r+=x){let s=(o+r)/c;s<0||s>=h.outWidth||Math.floor(s)!==s||(l+=E.get(e,n,a,s,t))}}}I.set(l*C,e,r,n,a,t)}return r.makeTensorInfo(I.shape,I.dtype,I.values)}},lb={kernelName:W.VCH,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t;(0,oI.C)([a,s],"avgPoolGrad");let{filterSize:i,strides:o,pad:l}=n,u=W.C0T.computePool2DInfo(s.shape,i,o,1,l),h=u.strideHeight,p=u.strideWidth,d=u.filterHeight,c=u.filterWidth,f=u.dilationHeight,m=u.dilationWidth,g=u.effectiveFilterHeight,y=u.effectiveFilterWidth,b=y-1-u.padInfo.left,x=g-1-u.padInfo.top,v=(0,W.ra8)(s.shape,"float32"),w=1/(d*c),T=r.data.get(a.dataId).values,S=(0,W.ra8)(a.shape,"float32",T);for(let e=0;e<u.batchSize;++e)for(let t=0;t<u.inChannels;++t)for(let r=0;r<u.inHeight;++r)for(let n=0;n<u.inWidth;++n){let a=r-x,s=n-b,i=0;for(let r=0;r<g;r+=f){let n=(a+r)/h;if(!(n<0)&&!(n>=u.outHeight)&&Math.floor(n)===n)for(let r=0;r<y;r+=m){let a=(s+r)/p;a<0||a>=u.outWidth||Math.floor(a)!==a||(i+=S.get(e,n,a,t))}}v.set(i*w,e,r,n,t)}return r.makeTensorInfo(v.shape,v.dtype,v.values)}},lx={kernelName:W.i5R,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,scale:s,offset:i,mean:o,variance:l}=t;W.ZSL.assert(o.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),W.ZSL.assert(null==i||o.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),W.ZSL.assert(null==s||o.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),(0,oI.C)([a,o,l,s,i],"batchNorm");let{varianceEpsilon:u}=n;null==u&&(u=.001);let h=r.data.get(a.dataId).values,p=r.data.get(o.dataId).values,d=r.data.get(l.dataId).values,c=s?r.data.get(s.dataId).values:new Float32Array([1]),f=i?r.data.get(i.dataId).values:new Float32Array([0]),m=new Float32Array(h.length),g=f.length,y=c.length,b=d.length,x=p.length,v=0,w=0,T=0,S=0;for(let e=0;e<h.length;++e)m[e]=f[v++]+(h[e]-p[w++])*c[T++]/Math.sqrt(d[S++]+u),v>=g&&(v=0),w>=x&&(w=0),T>=y&&(T=0),S>=b&&(S=0);return r.makeTensorInfo(a.shape,a.dtype,m)}};var lv=r(69510);let lw={kernelName:W.Ik2,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}
296=t,{blockShape:s,crops:i}=n;(0,oI.C)([a],"batchToSpaceND");let o=s.reduce((e,t)=>e*t),l=W.C0T.getReshaped(a.shape,s,o),u=W.C0T.getPermuted(l.length,s.length),h=W.C0T.getReshapedPermuted(a.shape,s,o),p=W.C0T.getSliceBeginCoords(i,s.length),d=W.C0T.getSliceSize(h,i,s.length),c=oH({inputs:{x:a},backend:r,attrs:{shape:l}}),f=(0,o6.m)({inputs:{x:c},backend:r,attrs:{perm:u}}),m=oH({inputs:{x:f},backend:r,attrs:{shape:h}}),g=(0,lv.di)({inputs:{x:m},backend:r,attrs:{begin:p,size:d}});return r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(m),g}};var lT=r(48319);let lS={kernelName:W.N4F,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,weights:s}=t,{size:i}=n,o=r.data.get(a.dataId).values,l=r.data.get(s.dataId).values,u=(0,lT.X)(o,l,s.dtype,s.shape,i);return r.makeTensorInfo([i],s.dtype,u)}};var lN=r(16592);let lk={kernelName:W.vj7,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{s0:n,s1:a}=t,s=r.data.get(n.dataId).values,i=r.data.get(a.dataId).values,o=W.C0T.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return r.makeTensorInfo([o.length],"int32",Int32Array.from(o))}};var lI=r(13419),lC=r(89573);let lE=(0,oF.v)(W.vaV,(e,t)=>e>t.clipValueMax?t.clipValueMax:e<t.clipValueMin?t.clipValueMin:e),lA={kernelName:W.vaV,backendName:"cpu",kernelFunc:lE};var l$=r(83772);let lF={kernelName:W.$zE,backendName:"cpu",kernelFunc:e=>{let{x:t}=e.inputs,r=e.backend,n=new Float32Array(W.ZSL.sizeFromShape(t.shape)),a=r.data.get(t.dataId),s=a.complexTensorInfos.real,i=a.complexTensorInfos.imag,o=r.data.get(s.dataId).values,l=r.data.get(i.dataId).values;for(let e=0;e<o.length;e++){let t=o[e],r=l[e];n[e]=Math.hypot(t,r)}return r.makeOutput(n,t.shape,"float32")}};var lR=r(59635);function l_(e){let{inputs:t,backend:r}=e,{input:n}=t,a=r.data.get(n.dataId).complexTensorInfos.imag,s=r.data.get(a.dataId).values;return r.makeTensorInfo(a.shape,a.dtype,s)}let lD={kernelName:W.dv8,backendName:"cpu",kernelFunc:l_};var lO=r(71604);function lL(e){let{inputs:t,backend:r,attrs:n}=e,{axis:a}=n,s=W.ZSL.parseAxisParam(a,t[0].shape)[0],i=t.map(e=>e.shape);W.C0T.assertParamsConsistent(i,s);let o=W.C0T.computeOutShape(t.map(e=>e.shape),s);if(0===W.ZSL.sizeFromShape(o))return r.makeTensorInfo(o,t[0].dtype,[]);let l=t.filter(e=>W.ZSL.sizeFromShape(e.shape)>0);if(1===l.length)return(0,oD.D)({inputs:{x:l[0]},backend:r});if("complex64"===l[0].dtype){let e=l.map(e=>(0,lO.x)({inputs:{input:e},backend:r})),t=l.map(e=>l_({inputs:{input:e},backend:r})),n=lL({inputs:e,backend:r,attrs:{axis:s}}),a=lL({inputs:t,backend:r,attrs:{axis:s}}
296),i=(0,l$.f)({inputs:{real:n,imag:a},backend:r});return e.forEach(e=>r.disposeIntermediateTensorInfo(e)),t.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(a),i}let u=l.map(e=>{let t=W.ZSL.sizeFromShape(e.shape.slice(s));return oH({inputs:{x:e},backend:r,attrs:{shape:[-1,t]}})}),h=u.map(e=>({vals:r.data.get(e.dataId).values,shape:e.shape}));o=W.C0T.computeOutShape(u.map(e=>e.shape),1);let p=1===u[0].shape[0],d=(0,lR.h)(h,o,t[0].dtype,p),c=W.C0T.computeOutShape(l.map(e=>e.shape),s),f=r.makeTensorInfo(c,t[0].dtype,d);return u.forEach(e=>r.disposeIntermediateTensorInfo(e)),f}let lM={kernelName:W.$dB,backendName:"cpu",kernelFunc:lL};function lP(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s}=t,{strides:i,pad:o,dataFormat:l,dilations:u,dimRoundingMode:h}=n;(0,oI.C)([a,s],"conv2d");let p=W.C0T.convertConv2DDataFormat(l),d=W.C0T.computeConv2DInfo(a.shape,s.shape,i,u,o,h,!1,p),c=d.filterHeight,f=d.filterWidth,m=d.dilationHeight,g=d.dilationWidth,y=d.padInfo.left,b=d.padInfo.top,x="channelsLast"===d.dataFormat,v=new W.ylz(d.outShape,a.dtype),w=W.ZSL.computeStrides(a.shape),T=W.ZSL.computeStrides(s.shape),S=w[0],N=x?w[1]:w[2],k=x?w[2]:1,I=x?1:w[1],C=v.strides[0],E=x?v.strides[1]:v.strides[2],A=x?v.strides[2]:1,$=x?1:v.strides[1],F=r.data.get(a.dataId).values,R=r.data.get(s.dataId).values,_=v.values;for(let e=0;e<d.batchSize;++e){let t=e*S,r=e*C;for(let e=0;e<d.outHeight;++e){let n=r+e*E,a=e*d.strideHeight-b;for(let e=0;e<c;++e){let r=a+e*m;if(r<0||r>=d.inHeight)continue;let s=e*T[0],i=t+r*N;for(let e=0;e<d.outWidth;++e){let t=n+e*A,r=e*d.strideWidth-y;for(let e=0;e<f;++e){let n=r+e*g;if(n<0||n>=d.inWidth)continue;let a=s+e*T[1],o=i+n*k,l=a;for(let e=0;e<d.inChannels;++e){let r=F[o+e*I];for(let e=0;e<d.outChannels;++e)_[t+e*$]+=r*R[l+e];l+=d.outChannels}}}}}}return r.makeTensorInfo(v.shape,v.dtype,_)}let lz={kernelName:W.p2J,backendName:"cpu",kernelFunc:lP},lB={kernelName:W.rFm,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,pad:o,dataFormat:l,dimRoundingMode:u,filterShape:h}=n;(0,oI.C)([a,s],"conv2dBackpropFilter");let p=W.C0T.convertConv2DDataFormat(l),d=W.C0T.computeConv2DInfo(a.shape,h,i,1,o,u,!1,p),{strideHeight:c,strideWidth:f,filterHeight:m,filterWidth:g}=d,y="channelsLast"===d.dataFormat,b=new W.ylz(d.filterShape,"float32"),x=d.padInfo.left,v=d.padInfo.top,w=r.data.get(a.dataId).values,T=r.data.get(s.dataId).values,S=new W.ylz(a.shape,a.dtype,w),N=new W.ylz(s.shape,s.dtype,T);for(let e=0;e<m;++e){let t=Math.max(0,Math.ceil((v-e)/c)),r=Math.min(d.outHeight,(d.inHeight+v-e)/c);for(let n=0;n<g;++n){let a=Math.max(0,Math.ceil((x-n)/f)),s=Math.min(d.outWidth,(d.inWidth+x-n)/f);for(let i=0;i<d.inChannels;++i)for(let o=0;o<d.outChannels;++o){let l=0;for(let u=0;u<d.batchSize;++u)for(let h=t;h<r;++h){let t=e+h*c-v;for(let e=a;e<s;++e){let r=n+e*f-x;y?l+=S.get(u,t,r,i)*N.get(u,h,e,o):l+=S.get(u,i,t,r)*N.get(u,o,h,e)}}b.set(l,e,n,i,o)}}}return r.makeTensorInfo(b.shape,b.dtype,b.values)}},lW={kernelName:W.jfg,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{inputShape:i,strides:o,pad:l,dataFormat:u,dimRoundingMode:h}=n;(0,oI.C)([a,s],"conv2dBackpropInput");let p=W.ZSL.computeStrides(s.shape),d=W.ZSL.computeStrides(a.shape),c=W.C0T.convertConv2DDataFormat(u),f=W.C0T.computeConv2DInfo(i,s.shape,o,1,l,h,!1,c),m=new W.ylz(f.inShape,"float32"),g=m.values,y=r.data.get(a.dataId).values,b=r.data.get(s.dataId).values,[x,v,w]=p,{batchSize:T,filterHeight:S,filterWidth:N,inChannels:k,inHeight:I,inWidth:C,outChannels:E,outHeight:A,outWidth:$,strideHeight:F,strideWidth:R}=f;c=f.dataFormat;let _=S-1-f.padInfo.top,D=N-1-f.padInfo.left,O="channelsLast"===c,L=m.strides[0],M=O?m.strides[1]:m.strides[2],P=O?m.strides[2]:1,z=O?1:m.strides[1],B=d[0],V=O?d[1]:d[2],U=O?d[2]:1,G=O?1:d[1];for(let e=0;e<T;++e)for(let t=0;t<k;++t)for(let r=0;r<I;++r){let n=r-_,a=Math.max(0,Math.ceil(n/F)),s=Math.min(A,(S+n)/F);for(let i=0;i<C;++i){let o=i-D,l=Math.max(0,Math.ceil(o/R)),u=Math.min($,(N+o)/R),h=0;for(let r=a;r<s;++r){let a=r*F-n;for(let n=l;n<u;++n){let s=n*R-o,i=B*e+V*r+U*n,l=x*(S-1-a)+v*(N-1-s)+w*t;for(let e=0;e<E;++e)h+=y[i+G*e]*b[l+e]}}g[L*e+M*r+P*i+z*t]=h}}return r.makeTensorInfo(m.shape,m.dtype,m.values)}},lV={kernelName:W.A1h,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s}=t,{strides:i,pad:o,dilations:l}=n;(0,oI.C)([a,s],"conv3d");let u=W.C0T.computeConv3DInfo(a.shape,s.shape,i,l,o),{filterDepth:h,filterHeight:p,filterWidth:d,dilationDepth:c,dilationHeight:f,dilationWidth:m,padInfo:g}=u,y=g.front,b=g.left,x=g.top,v=new W.ylz(u.outShape,a.dtype),w=r.data.get(a.dataId).values,T=r.data.get(s.dataId).values,S=v.values,N=W.ZSL.computeStrides(a.shape),k=W.ZSL.computeStrides(s.shape);for(let e=0;e<u.batchSize;++e){let t=e*N[0],r=e*v.strides[0];for(let e=0;e<u.outDepth;++e){let n=r+e*v.strides[1],a=e*u.strideDepth-y;for(let e=0;e<h;++e){let r=a+e*c;if(r<0||r>=u.inDepth)continue;let s=e*k[0],i=t+r*N[1];for(let e=0;e<u.outHeight;++e){let t=n+e*v.strides[2],r=e*u.strideHeight-x;for(let e=0;e<p;++e){let n=r+e*f;if(n<0||n>=u.inHeight)continue;let a=s+e*k[1],o=i+n*N[2];for(let e=0;e<u.outWidth;++e){let r=t+e*u.outChannels,n=e*u.strideWidth-b;
296for(let e=0;e<d;++e){let t=n+e*m;if(t<0||t>=u.inWidth)continue;let s=a+e*k[2],i=o+t*u.inChannels,l=s;for(let e=0;e<u.inChannels;++e){let t=w[i+e];for(let e=0;e<u.outChannels;++e)S[r+e]+=t*T[l+e];l+=u.outChannels}}}}}}}}return r.makeTensorInfo(v.shape,v.dtype,v.values)}},lU={kernelName:W.iGz,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,pad:o,filterShape:l}=n;(0,oI.C)([a,s],"conv3dBackpropFilterV2");let u=W.ZSL.computeStrides(a.shape),h=W.ZSL.computeStrides(s.shape),p=W.C0T.computeConv3DInfo(a.shape,l,i,1,o),d=p.strideDepth,c=p.strideHeight,f=p.strideWidth,m=p.filterDepth,g=p.filterHeight,y=p.filterWidth,b=new W.ylz(p.filterShape,"float32"),x=b.values,[v,w,T,S]=b.strides,N=r.data.get(s.dataId).values,[k,I,C,E]=h,A=r.data.get(a.dataId).values,[$,F,R,_]=u,D=p.padInfo.front,O=p.padInfo.left,L=p.padInfo.top;for(let e=0;e<m;++e){let t=Math.max(0,Math.ceil((D-e)/d)),r=Math.min(p.outDepth,(p.inDepth+D-e)/d),n=e*v;for(let a=0;a<g;++a){let s=Math.max(0,Math.ceil((L-a)/c)),i=Math.min(p.outHeight,(p.inHeight+L-a)/c),o=a*w+n;for(let n=0;n<y;++n){let l=Math.max(0,Math.ceil((O-n)/f)),u=Math.min(p.outWidth,(p.inWidth+O-n)/f),h=n*T+o;for(let o=0;o<p.inChannels;++o){let m=o*S+h;for(let h=0;h<p.outChannels;++h){let g=0;for(let m=0;m<p.batchSize;++m){let p=m*$,y=m*k;for(let m=t;m<r;++m){let t=(e+m*d-D)*F+p,r=m*I+y;for(let e=s;e<i;++e){let s=(a+e*c-L)*R+t,i=e*C+r;for(let e=l;e<u;++e){let t=(n+e*f-O)*_+s,r=e*E+i;g+=A[t+o]*N[r+h]}}}}x[m+h]=g}}}}}return r.makeTensorInfo(b.shape,b.dtype,b.values)}},lG={kernelName:W.gC7,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{pad:i,strides:o,inputShape:l}=n;(0,oI.C)([a],"conv3dBackpropInputV2");let u=W.ZSL.computeStrides(a.shape),h=W.ZSL.computeStrides(s.shape),p=W.C0T.computeConv3DInfo(l,s.shape,o,1,i),d=new W.ylz(p.inShape,"float32"),c=d.values,[f,m,g,y]=d.strides,b=r.data.get(a.dataId).values,[x,v,w,T]=u,S=r.data.get(s.dataId).values,[N,k,I,C]=h,{batchSize:E,filterDepth:A,filterHeight:$,filterWidth:F,inChannels:R,inDepth:_,inHeight:D,inWidth:O,outChannels:L,outDepth:M,outHeight:P,outWidth:z,strideDepth:B,strideHeight:V,strideWidth:U}=p,G=A-1-p.padInfo.front,Z=$-1-p.padInfo.top,j=F-1-p.padInfo.left;for(let e=0;e<E;++e)for(let t=0;t<R;++t)for(let r=0;r<_;++r){let n=r-G,a=Math.max(0,Math.ceil(n/B)),s=Math.min(M,(A+n)/B);for(let i=0;i<D;++i){let o=i-Z,l=Math.max(0,Math.ceil(o/V)),u=Math.min(P,($+o)/V);for(let h=0;h<O;++h){let p=h-j,d=Math.max(0,Math.ceil(p/U)),E=Math.min(z,(F+p)/U),R=0;for(let r=a;r<s;++r){let a=r*B-n;for(let n=l;n<u;++n){let s=n*V-o;for(let i=d;i<E;++i){let o=i*U-p,l=x*e+v*r+w*n+T*i,u=N*(A-1-a)+k*($-1-s)+I*(F-1-o)+C*t;for(let e=0;e<L;++e)R+=b[l+e]*S[u+e]}}}c[f*e+m*r+g*i+y*h+t]=R}}}return r.makeTensorInfo(d.shape,d.dtype,d.values)}},lZ=(0,oF.v)(W.Mn0,e=>Math.cos(e)),lj={kernelName:W.Mn0,backendName:"cpu",kernelFunc:lZ},lK=(0,oF.v)(W.MnK,e=>Math.cosh(e)),lH={kernelName:W.MnK,backendName:"cpu",kernelFunc:lK},lY={kernelName:W.MRQ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{image:a,boxes:s,boxInd:i}=t,{cropSize:o,method:l,extrapolationValue:u}=n,[h,p,d,c]=a.shape,f=s.shape[0],[m,g]=o,y=(0,W.ra8)([f,m,g,c],"float32"),b=r.data.get(s.dataId).values,x=r.data.get(i.dataId).values,v=r.data.get(a.dataId).values,w=W.ZSL.computeStrides(a.shape),T=W.ZSL.computeStrides(y.shape);for(let e=0;e<f;e++){let t=4*e,r=b[t],n=b[t+1],a=b[t+2],s=b[t+3],i=x[e];if(i>=h)continue;let o=m>1?(a-r)*(p-1)/(m-1):0,f=g>1?(s-n)*(d-1)/(g-1):0;for(let t=0;t<m;t++){let h=m>1?r*(p-1)+t*o:.5*(r+a)*(p-1);if(h<0||h>p-1){for(let r=0;r<g;r++)for(let n=0;n<c;n++){let a=n+r*T[2]+t*T[1]+e*T[0];y.values[a]=u}continue}if("bilinear"===l){let r=Math.floor(h),a=Math.ceil(h),o=h-r;for(let l=0;l<g;l++){let h=g>1?n*(d-1)+l*f:.5*(n+s)*(d-1);if(h<0||h>d-1){for(let r=0;r<c;r++){let n=r+l*T[2]+t*T[1]+e*T[0];y.values[n]=u}continue}let p=Math.floor(h),m=Math.ceil(h),b=h-p;for(let n=0;n<c;n++){let s=n+p*w[2]+r*w[1]+i*w[0],u=v[s],h=v[s=n+m*w[2]+r*w[1]+i*w[0]],d=v[s=n+p*w[2]+a*w[1]+i*w[0]],c=v[s=n+m*w[2]+a*w[1]+i*w[0]],f=u+(h-u)*b,g=d+(c-d)*b;s=n+l*T[2]+t*T[1]+e*T[0],y.values[s]=f+(g-f)*o}}}else for(let r=0;r<g;++r){let a=g>1?n*(d-1)+r*f:.5*(n+s)*(d-1);if(a<0||a>d-1){for(let n=0;n<c;n++){let a=n+r*T[2]+t*T[1]+e*T[0];y.values[a]=u}continue}let o=Math.round(a),l=Math.round(h);for(let n=0;n<c;n++){let a=n+o*w[2]+l*w[1]+i*w[0],s=n+r*T[2]+t*T[1]+e*T[0];y.values[s]=v[a]}}}}return r.makeTensorInfo(y.shape,y.dtype,y.values)}},lQ={kernelName:W.jj_,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,exclusive:i,reverse:o}=n;(0,oI.C)(a,"cumprod");let l=W.C0T.getAxesPermutation([s],a.shape.length),u=a;
296null!=l&&(u=(0,o6.m)({inputs:{x:a},backend:r,attrs:{perm:l}}));let h=W.C0T.getInnerMostAxes(1,a.shape.length)[0];if(h!==u.shape.length-1)throw Error(`backend.cumprod in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${h}`);let p=(0,W.TuY)(u.dtype,"int32"),d=W.ZSL.makeOnesTypedArray(W.ZSL.sizeFromShape(u.shape),p),c=r.data.get(u.dataId).values,f=u.shape[u.shape.length-1],m=o?(e,t)=>e+f-t-1:(e,t)=>e+t;for(let e=0;e<c.length;e+=f)for(let t=0;t<f;t++){let r=m(e,t);if(0===t)d[r]=i?1:c[r];else{let n=m(e,t-1);d[r]=i?c[n]*d[n]:c[r]*d[n]}}let g=r.makeTensorInfo(u.shape,p,d);if(null!=l){let e=W.C0T.getUndoAxesPermutation(l),t=(0,o6.m)({inputs:{x:g},backend:r,attrs:{perm:e}});return r.disposeIntermediateTensorInfo(g),r.disposeIntermediateTensorInfo(u),t}return g}},lq={kernelName:W.nY8,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,exclusive:i,reverse:o}=n;(0,oI.C)(a,"cumsum");let l=W.C0T.getAxesPermutation([s],a.shape.length),u=a;null!=l&&(u=(0,o6.m)({inputs:{x:a},backend:r,attrs:{perm:l}}));let h=W.C0T.getInnerMostAxes(1,a.shape.length)[0];if(h!==u.shape.length-1)throw Error(`backend.cumsum in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${h}`);let p=(0,W.TuY)(u.dtype,"int32"),d=W.ZSL.makeZerosTypedArray(W.ZSL.sizeFromShape(u.shape),p),c=r.data.get(u.dataId).values,f=u.shape[u.shape.length-1],m=o?(e,t)=>e+f-t-1:(e,t)=>e+t;for(let e=0;e<c.length;e+=f)for(let t=0;t<f;t++){let r=m(e,t);if(0===t)d[r]=i?0:c[r];else{let n=m(e,t-1);d[r]=i?c[n]+d[n]:c[r]+d[n]}}let g=r.makeTensorInfo(u.shape,p,d);if(null!=l){let e=W.C0T.getUndoAxesPermutation(l),t=(0,o6.m)({inputs:{x:g},backend:r,attrs:{perm:e}});return r.disposeIntermediateTensorInfo(g),r.disposeIntermediateTensorInfo(u),t}return g}},lX={kernelName:W.wNW,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,weights:s}=t,{size:i,binaryOutput:o}=n;if(1===a.shape.length){let e=r.data.get(a.dataId).values,t=r.data.get(s.dataId).values,n=(0,lT.X)(e,t,s.dtype,s.shape,i);return r.makeTensorInfo([i],s.dtype,n)}if(2===a.shape.length){let e=r.bufferSync(a),t=r.bufferSync(s),n=(0,lT.N)(e,t,i,o);return r.makeTensorInfo(n.shape,s.dtype,n.values)}throw Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}},lJ={kernelName:W.TMz,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockSize:s,dataFormat:i}=n;W.ZSL.assert("NHWC"===i,()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`);let o=a.shape[0],l=a.shape[1],u=a.shape[2],h=a.shape[3],p=l*s,d=u*s,c=h/(s*s),f=r.data.get(a.dataId).values,m=new Float32Array(o*p*d*c),g=0;for(let e=0;e<o;++e)for(let t=0;t<p;++t){let r=Math.floor(t/s),n=t%s;for(let t=0;t<d;++t){let a=Math.floor(t/s),i=t%s,o=(n*s+i)*c;for(let t=0;t<c;++t){let n=t+o+h*(a+u*(r+l*e));m[g++]=f[n]}}}return r.makeTensorInfo([o,p,d,c],a.dtype,m)}};function l0(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s}=t,{strides:i,pad:o,dilations:l,dimRoundingMode:u}=n;(0,oI.C)([a,s],"depthwiseConv2DNative");let h=W.ZSL.computeStrides(a.shape),p=W.ZSL.computeStrides(s.shape),d=l;null==d&&(d=[1,1]),W.ZSL.assert(W.C0T.eitherStridesOrDilationsAreOne(i,d),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);let c=W.C0T.computeConv2DInfo(a.shape,s.shape,i,d,o,u,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=c,x=b.left,v=b.top,w=c.outChannels/c.inChannels,T=new W.ylz(c.outShape,a.dtype),S=r.data.get(a.dataId).values,N=r.data.get(s.dataId).values,k=T.values;for(let e=0;e<c.batchSize;++e){let t=e*h[0],r=e*T.strides[0];for(let e=0;e<c.outHeight;++e){let n=r+e*T.strides[1],a=e*c.strideHeight-v;for(let e=0;e<f;++e){let r=a+e*g;if(r<0||r>=c.inHeight)continue;let s=e*p[0],i=t+r*h[1];for(let e=0;e<c.outWidth;++e){let t=n+e*T.strides[2],r=e*c.strideWidth-x;for(let e=0;e<m;++e){let n=r+e*y;if(n<0||n>=c.inWidth)continue;let a=s+e*p[1],o=i+n*c.inChannels,l=t,u=a;for(let e=0;e<c.inChannels;++e){let t=S[o+e];for(let e=0;e<w;++e)k[l+e]+=t*N[u+e];l+=w,u+=w}}}}}}return r.makeTensorInfo(T.shape,T.dtype,T.values)}let l1={kernelName:W.tGH,backendName:"cpu",kernelFunc:l0},l2={kernelName:W.X$8,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:u,filterShape:h}=n;(0,oI.C)([a,s],"depthwiseConv2dNativeBackpropFilter");let p=W.C0T.computeConv2DInfo(a.shape,h,i,o,l,u,!0),{strideHeight:d,strideWidth:c,filterHeight:f,filterWidth:m}=p,g=new W.ylz(p.filterShape,"float32"),y=p.padInfo.left,b=p.padInfo.top,x=p.outChannels/p.inChannels,v=r.data.get(a.dataId).values,w=new W.ylz(a.shape,a.dtype,v),T=r.data.get(s.dataId).values,S=new W.ylz(s.shape,s.dtype,T);for(let e=0;e<f;++e){let t=Math.max(0,Math.ceil((b-e)/d)),r=Math.min(p.outHeight,(p.inHeight+b-e)/d);for(let n=0;n<m;++n){let a=Math.max(0,Math.ceil((y-n)/c)),s=Math.min(p.outWidth,(p.inWidth+y-n)/c);for(let i=0;i<p.outChannels;++i){let o=Math.trunc(i/x),l=i%x,u=0;for(let l=0;l<p.batchSize;++l)for(let h=t;h<r;++h){let t=e+h*d-b;for(let e=a;
296e<s;++e){let r=n+e*c-y;u+=w.get(l,t,r,o)*S.get(l,h,e,i)}}g.set(u,e,n,o,l)}}}return r.makeTensorInfo(g.shape,g.dtype,g.values)}},l3={kernelName:W.nVu,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:u,inputShape:h}=n;(0,oI.C)([a,s],"depthwiseConv2DNativeBackpropInput");let p=W.ZSL.computeStrides(a.shape),d=W.ZSL.computeStrides(s.shape),c=W.C0T.computeConv2DInfo(h,s.shape,i,o,l,u,!0),f=new W.ylz(c.inShape,"float32"),m=f.values,[g,y,b]=f.strides,x=r.data.get(a.dataId).values,[v,w,T]=p,S=r.data.get(s.dataId).values,[N,k,I]=d,{batchSize:C,filterHeight:E,filterWidth:A,inChannels:$,inHeight:F,inWidth:R,outChannels:_,outHeight:D,outWidth:O,strideHeight:L,strideWidth:M}=c,P=E-1-c.padInfo.top,z=A-1-c.padInfo.left,B=_/$;for(let e=0;e<C;++e)for(let t=0;t<$;++t)for(let r=0;r<F;++r){let n=r-P,a=Math.max(0,Math.ceil(n/L)),s=Math.min(D,(E+n)/L);for(let i=0;i<R;++i){let o=i-z,l=Math.max(0,Math.ceil(o/M)),u=Math.min(O,(A+o)/M),h=0;for(let r=a;r<s;++r){let a=r*L-n;for(let n=l;n<u;++n){let s=n*M-o,i=v*e+w*r+T*n,l=N*(E-1-a)+k*(A-1-s)+I*t;for(let e=0;e<B;++e)h+=x[i+(t*B+e)]*S[l+e]}}m[g*e+y*r+b*i+t]=h}}return r.makeTensorInfo(f.shape,f.dtype,f.values)}},l4={kernelName:W.ORI,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n}=t,a=W.ZSL.sizeFromShape(n.shape),s=r.data.get(n.dataId).values,i=(0,W.ra8)([a,a],n.dtype),o=i.values;for(let e=0;e<s.length;e++)o[e*a+e]=s[e];let l=[...n.shape,...n.shape];return r.makeTensorInfo(l,i.dtype,i.values)}},l6={kernelName:W.jxD,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n,filter:a}=e,{strides:s,pad:i,dilations:o}=r,l=t.data.get(n.dataId).values,u=n.shape.length,h=t.data.get(a.dataId).values,p=a.shape.length,{batchSize:d,inHeight:c,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:x,strideWidth:v,filterHeight:w,filterWidth:T,dilationHeight:S,dilationWidth:N,outShape:k}=W.C0T.computeDilation2DInfo(n.shape,a.shape,s,i,"NHWC",o),I=W.ZSL.sizeFromShape(k),C=k.length,E=W.ZSL.getArrayFromDType(n.dtype,I);for(let e=0;e<d;++e)for(let t=0;t<g;++t){let r=t*x-b.top;for(let s=0;s<y;++s){let i=s*v-b.left;for(let o=0;o<m;++o){let d=Number.MIN_SAFE_INTEGER;for(let t=0;t<w;++t){let s=r+t*S;if(s>=0&&s<c)for(let r=0;r<T;++r){let c=i+r*N;if(c>=0&&c<f){let i=W.ZSL.locToIndex([e,s,c,o],u,W.ZSL.computeStrides(n.shape)),f=W.ZSL.locToIndex([t,r,o],p,W.ZSL.computeStrides(a.shape)),m=l[i]+h[f];m>d&&(d=m)}}}E[W.ZSL.locToIndex([e,t,s,o],C,W.ZSL.computeStrides(k))]=d}}}return{dataId:t.write(W.ZSL.toTypedArray(E,n.dtype),k,n.dtype),shape:k,dtype:n.dtype}}},l5={kernelName:W.pk0,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n,filter:a,dy:s}=e,{strides:i,pad:o,dilations:l}=r,u=W.ZSL.toNestedArray(n.shape,t.data.get(n.dataId).values),h=W.ZSL.toNestedArray(a.shape,t.data.get(a.dataId).values),{batchSize:p,inHeight:d,inWidth:c,inChannels:f,outHeight:m,outWidth:g,padInfo:y,strideHeight:b,strideWidth:x,filterHeight:v,filterWidth:w,dilationHeight:T,dilationWidth:S,outShape:N}=W.C0T.computeDilation2DInfo(n.shape,a.shape,i,o,"NHWC",l);W.ZSL.assert(s.rank===N.length,()=>`Error in ${W.pk0}, dy must have the same rank as output ${N.length}, but got ${s.rank}`);let k=W.ZSL.toNestedArray(N,t.data.get(s.dataId).values),I=W.ZSL.makeZerosNestedTypedArray(a.shape,a.dtype);for(let e=0;e<p;++e)for(let t=0;t<m;++t){let r=t*b-y.top;for(let n=0;n<g;++n){let a=n*x-y.left;for(let s=0;s<f;++s){let i=Number.MIN_SAFE_INTEGER,o=0,l=0;for(let t=0;t<v;++t){let n=r+t*T;if(n>=0&&n<d)for(let r=0;r<w;++r){let p=a+r*S;if(p>=0&&p<c){let a=u[e][n][p][s]+h[t][r][s];a>i&&(i=a,o=t,l=r)}}}I[o][l][s]+=k[e][t][n][s]}}}return{dataId:t.write(W.ZSL.toTypedArray(I,n.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},l8={kernelName:W.bP9,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n,filter:a,dy:s}=e,{strides:i,pad:o,dilations:l}=r,u=W.ZSL.toNestedArray(n.shape,t.data.get(n.dataId).values),h=W.ZSL.toNestedArray(a.shape,t.data.get(a.dataId).values),{batchSize:p,inHeight:d,inWidth:c,inChannels:f,outHeight:m,outWidth:g,padInfo:y,strideHeight:b,strideWidth:x,filterHeight:v,filterWidth:w,dilationHeight:T,dilationWidth:S,outShape:N}=W.C0T.computeDilation2DInfo(n.shape,a.shape,i,o,"NHWC",l);W.ZSL.assert(s.rank===N.length,()=>`Error in ${W.bP9}, dy must have the same rank as output ${N.length}, but got ${s.rank}
296`);let k=W.ZSL.toNestedArray(N,t.data.get(s.dataId).values),I=W.ZSL.makeZerosNestedTypedArray(n.shape,n.dtype);for(let e=0;e<p;++e)for(let t=0;t<m;++t){let r=t*b-y.top;for(let n=0;n<g;++n){let a=n*x-y.left;for(let s=0;s<f;++s){let i=Number.MIN_SAFE_INTEGER,o=r<0?0:r,l=a<0?0:a;for(let t=0;t<v;++t){let n=r+t*T;if(n>=0&&n<d)for(let r=0;r<w;++r){let p=a+r*S;if(p>=0&&p<c){let a=u[e][n][p][s]+h[t][r][s];a>i&&(i=a,o=n,l=p)}}}I[e][o][l][s]+=k[e][t][n][s]}}}return{dataId:t.write(W.ZSL.toTypedArray(I,n.dtype),n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},l7={kernelName:W.XmO,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{image:a}=t,{canvas:s,options:i}=n,{contextOptions:o,imageOptions:l}=i||{},u=(null==l?void 0:l.alpha)||1,h=(null==o?void 0:o.contextType)||"2d";if("2d"!==h)throw Error(`Context type ${o.contextType} is not supported by the CPU backend.`);let p=s.getContext(h,(null==o?void 0:o.contextAttributes)||{});if(null==p)throw Error(`Could not get the context with ${h} type.`);let[d,c]=a.shape.slice(0,2),f=2===a.shape.length?1:a.shape[2],m=r.data.get(a.dataId).values,g="float32"===a.dtype?255:1,y=new Uint8ClampedArray(c*d*4);for(let e=0;e<d*c;++e){let t=[0,0,0,255*u];for(let r=0;r<f;r++){let n=m[e*f+r];if("float32"===a.dtype){if(n<0||n>1)throw Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${n}.`)}else if("int32"===a.dtype&&(n<0||n>255))throw Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${n}.`);1===f?(t[0]=n*g,t[1]=n*g,t[2]=n*g):t[r]=n*g}let r=4*e;y[r+0]=Math.round(t[0]),y[r+1]=Math.round(t[1]),y[r+2]=Math.round(t[2]),y[r+3]=Math.round(t[3])}s.width=c,s.height=d;let b=new ImageData(y,c,d);return p.putImageData(b,0,0),a}};var l9=r(82407),ue=r(81963);function ut(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{axis:i,keepDims:o}=a;(0,oI.C)(s,"sum");let l=(t="bool"===s.dtype?(0,lI.wg)({inputs:{x:s},backend:n,attrs:{dtype:"int32"}}):(0,oD.D)({inputs:{x:s},backend:n})).shape.length,u=W.ZSL.parseAxisParam(i,t.shape),h=W.C0T.getAxesPermutation(u,l),p=u,d=t;null!=h&&(d=(0,o6.m)({inputs:{x:t},backend:n,attrs:{perm:h}}),p=W.C0T.getInnerMostAxes(p.length,l)),W.C0T.assertAxesAreInnerMostDims("sum",p,d.shape.length);let[c,f]=W.C0T.computeOutAndReduceShapes(d.shape,p),m=W.C0T.upcastType(d.dtype,"int32"),g=(0,ue.U)(n,c,m),y=W.ZSL.sizeFromShape(f),b=n.data.get(g.dataId).values,x=n.data.get(d.dataId).values;for(let e=0;e<b.length;++e){let t=e*y,r=0;for(let e=0;e<y;++e)r+=x[t+e];b[e]=r}if(o){let e=W.C0T.expandShapeToKeepDim(g.shape,u),t=g;g=oH({inputs:{x:g},backend:n,attrs:{shape:e}}),n.disposeIntermediateTensorInfo(t)}return n.disposeIntermediateTensorInfo(t),null!=h&&n.disposeIntermediateTensorInfo(d),g}let ur={kernelName:W.WuN,backendName:"cpu",kernelFunc:ut},un={kernelName:W.Qgm,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{equation:a}=n,{allDims:s,summedDims:i,idDims:o}=W.C0T.decodeEinsumEquation(a,t.length);W.C0T.checkEinsumDimSizes(s.length,o,t);let{path:l,steps:u}=W.C0T.getEinsumComputePath(i,o),h=u.length,p=null,d=s.length,c=[];for(let e=0;e<h;++e){for(let n of u[e]){let e,{permutationIndices:a,expandDims:s}=W.C0T.getEinsumPermutation(d,o[n]);W.C0T.isIdentityPermutation(a)?e=t[n]:(e=(0,o6.m)({inputs:{x:t[n]},backend:r,attrs:{perm:a}}),c.push(e));let i=e.shape.slice();for(let e=0;e<s.length;++e)i.splice(s[e],0,1);W.ZSL.arraysEqual(e.shape,i)||(e=oH({inputs:{x:e},backend:r,attrs:{shape:i}}),c.push(e)),null===p?p=e:(p=(0,l9.lw)({inputs:{a:e,b:p},backend:r}),c.push(p))}e<h-1&&(l[e]>=0&&(p=ut({inputs:{x:p},backend:r,attrs:{axis:l[e]-(s.length-d),keepDims:!1}}),c.push(p)),d--)}for(let e of c)e!==p&&r.disposeIntermediateTensorInfo(e);return p}},ua={kernelName:W.rsH,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{dy:n,y:a}=t;(0,oI.C)([n,a],"eluGrad");let s=new Float32Array(W.ZSL.sizeFromShape(a.shape)),i=r.data.get(a.dataId).values,o=r.data.get(n.dataId).values;for(let e=0;e<i.length;++e){let t=i[e];t>=0?s[e]=o[e]:s[e]=o[e]*(t+1)}return r.makeTensorInfo(a.shape,"float32",s)}};var us=r(4768);let ui=W.C0T.ERF_P,uo=W.C0T.ERF_A1,ul=W.C0T.ERF_A2,uu=W.C0T.ERF_A3,uh=W.C0T.ERF_A4,up=W.C0T.ERF_A5,ud=(0,oF.v)(W._s9,e=>{let t=Math.sign(e),r=Math.abs(e),n=1/(1+ui*r);return t*(1-((((up*n+uh)*n+uu)*n+ul)*n+uo)*n*Math.exp(-r*r))}),uc={kernelName:W._s9,backendName:"cpu",kernelFunc:ud};var uf=r(49335);function um(e){let{inputs:t,backend:r,attrs:n}
296=e,{input:a}=t,{dim:s}=n,i=a.shape.length,o=a.shape.slice(),l=s;return s<0&&(W.ZSL.assert(-(i+1)<=s,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+s+1),o.splice(l,0,1),oH({inputs:{x:a},backend:r,attrs:{shape:o}})}let ug={kernelName:W.ybN,backendName:"cpu",kernelFunc:um};var uy=r(38193);let ub=(0,oM.Z)((e,t)=>e/t),ux=(0,li.j)(W.sDr,ub),uv={kernelName:W.sDr,backendName:"cpu",kernelFunc:ux};var uw=r(51982);function uT(e,t,r){let n=e.shape,a=n[0],s=n[1],i=r.data.get(e.dataId),o=i.complexTensorInfos.real,l=i.complexTensorInfos.imag,u=[a,s],h=W.ZSL.sizeFromShape(u),p=W.ZSL.getTypedArrayFromDType("float32",h),d=W.ZSL.getTypedArrayFromDType("float32",h);for(let e=0;e<a;e++){let n=(0,lv.di)({inputs:{x:o},backend:r,attrs:{begin:[e,0],size:[1,s]}}),a=(0,lv.di)({inputs:{x:l},backend:r,attrs:{begin:[e,0],size:[1,s]}}),i=(0,l$.f)({inputs:{real:n,imag:a},backend:r}),{real:u,imag:h}=function(e,t,r){var n;let a=W.ZSL.sizeFromShape(e.shape),s=r.data.get(e.dataId),i=r.data.get(s.complexTensorInfos.real.dataId).values,o=r.data.get(s.complexTensorInfos.imag.dataId).values;if(((n=a)&n-1)==0){let n=function e(t,r,n,a,s){if(1===n)return{real:t,imag:r};let i=W.C0T.mergeRealAndImagArrays(t,r),o=n/2,l=W.C0T.complexWithEvenIndex(i),u=l.real,h=l.imag,p=[u.length],d=s.makeTensorInfo(p,"float32",u),c=s.makeTensorInfo(p,"float32",h),f=(0,l$.f)({input
296s:{real:d,imag:c},backend:s}),m=W.C0T.complexWithOddIndex(i),g=m.real,y=m.imag,b=[g.length],x=s.makeTensorInfo(b,"float32",g),v=s.makeTensorInfo(b,"float32",y),w=(0,l$.f)({inputs:{real:x,imag:v},backend:s}),T=e(u,h,o,a,s),S=T.real,N=T.imag,k=[S.length],I=s.makeTensorInfo(k,"float32",S),C=s.makeTensorInfo(k,"float32",N),E=(0,l$.f)({inputs:{real:I,imag:C},backend:s}),A=e(g,y,o,a,s),$=A.real,F=A.imag,R=[$.length],_=s.makeTensorInfo(R,"float32",$),D=s.makeTensorInfo(R,"float32",F),O=(0,l$.f)({inputs:{real:_,imag:D},backend:s}),L=W.C0T.exponents(n,a),M=[L.real.length],P=s.makeTensorInfo(M,"float32",L.real),z=s.makeTensorInfo(M,"float32",L.imag),B=(0,l$.f)({inputs:{real:P,imag:z},backend:s}),V=(0,l9.lw)({inputs:{a:B,b:O},backend:s}),U=(0,oK.WQ)({inputs:{a:E,b:V},backend:s}),G=(0,uw.jb)({inputs:{a:E,b:V},backend:s}),Z=(0,lO.x)({inputs:{input:U},backend:s}),j=(0,lO.x)({inputs:{input:G},backend:s}),K=l_({inputs:{input:U},backend:s}),H=l_({inputs:{input:G},backend:s}),Y=lL({inputs:[Z,j],backend:s,attrs:{axis:0}}),Q=lL({inputs:[K,H],backend:s,attrs:{axis:0}}),q=s.data.get(Y.dataId).values,X=s.data.get(Q.dataId).values;return s.disposeIntermediateTensorInfo(d),s.disposeIntermediateTensorInfo(c),s.disposeIntermediateTensorInfo(f),s.disposeIntermediateTensorInfo(x),s.disposeIntermediateTensorInfo(v),s.disposeIntermediateTensorInfo(w),s.disposeIntermediateTensorInfo(I),s.disposeIntermediateTensorInfo(C),s.disposeIntermediateTensorInfo(E),s.disposeIntermediateTensorInfo(_),s.disposeIntermediateTensorInfo(D),s.disposeIntermediateTensorInfo(O),s.disposeIntermediateTensorInfo(P),s.disposeIntermediateTensorInfo(z),s.disposeIntermediateTensorInfo(B),s.disposeIntermediateTensorInfo(V),s.disposeIntermediateTensorInfo(U),s.disposeIntermediateTensorInfo(G),s.disposeIntermediateTensorInfo(Z),s.disposeIntermediateTensorInfo(K),s.disposeIntermediateTensorInfo(j),s.disposeIntermediateTensorInfo(H),s.disposeIntermediateTensorInfo(Y),s.disposeIntermediateTensorInfo(Q),{real:q,imag:X}}(i,o,a,t,r),s=[e.shape[0],e.shape[1]];if(t){let e=r.makeTensorInfo(s,"float32",n.real),t=r.makeTensorInfo(s,"float32",n.imag),i=r.makeTensorInfo([],"float32",W.ZSL.createScalarValue(a,"float32")),o=(0,oD.D)({inputs:{x:i},backend:r}),l=uv.kernelFunc({inputs:{a:e,b:i},backend:r}),u=uv.kernelFunc({inputs:{a:t,b:o},backend:r}),h=r.data.get(l.dataId).values,p=r.data.get(u.dataId).values;return r.disposeIntermediateTensorInfo(e),r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(l),r.disposeIntermediateTensorInfo(u),{real:h,imag:p}}return n}{let e=function(e,t,r){let n=new Float32Array(2*t);for(let a=0;a<t;a++){let s=0,i=0;for(let n=0;n<t;n++){let o=W.C0T.exponent(a*n,t,r),l=W.C0T.getComplexWithIndex(e,n);s+=l.real*o.real-l.imag*o.imag,i+=l.real*o.imag+l.imag*o.real}r&&(s/=t,i/=t),W.C0T.assignToTypedArray(n,s,i,a)}return n}(W.C0T.mergeRealAndImagArrays(i,o),a,t);return W.C0T.splitRealAndImagArrays(e)}}(i,t,r),c=W.C0T.mergeRealAndImagArrays(u,h);for(let t=0;t<s;t++){let r=W.C0T.getComplexWithIndex(c,t);p[e*s+t]=r.real,d[e*s+t]=r.imag}r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(i)}let c=r.makeTensorInfo(u,"float32",p),f=r.makeTensorInfo(u,"float32",d),m=(0,l$.f)({input
296s:{real:c,imag:f},backend:r});return r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),m}let uS={kernelName:W.rGP,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{input:n}=t,a=W.ZSL.sizeFromShape(n.shape),s=n.shape[n.shape.length-1],i=oH({inputs:{x:n},backend:r,attrs:{shape:[a/s,s]}}),o=uT(i,!1,r),l=oH({inputs:{x:o},backend:r,attrs:{shape:n.shape}});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),l}};function uN(e){var t,r;let{backend:n,attrs:a}=e,{shape:s,value:i,dtype:o}=a,l=o||W.ZSL.inferDtype(i),u=W.ZSL.getArrayFromDType(l,W.ZSL.sizeFromShape(s));return t=u,r=i,t.fill(r),n.makeTensorInfo(s,l,u)}let uk={kernelName:W.SQl,backendName:"cpu",kernelFunc:uN},uI={kernelName:W.BxF,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{image:n}=e,a=W.ZSL.getTypedArrayFromDType(n.dtype,W.ZSL.sizeFromShape(n.shape)),[s,i,o,l]=n.shape,u=r.data.get(n.dataId).values;for(let e=0;e<s;e++){let t=e*o*i*l;for(let e=0;e<i;e++){let r=o*l*e;for(let e=0;e<o;e++){let n=e*l;for(let s=0;s<l;s++){let i=Math.round(o-e-1),h=t+r+n+s,p=u[h];i>=0&&i<o&&(p=u[t+r+i*l+s]),a[h]=p}}}}return{dataId:r.write(a,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}};var uC=r(2498),uE=r(62637);let uA={kernelName:W.aAr,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d,activation:c,leakyreluAlpha:f}=n,m=lP({inputs:{x:a,filter:s},backend:r,attrs:{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d}});if(i){let e=m;if("NCHW"===h&&1===i.shape.length&&1!==i.shape[0]){let e=oH({inputs:{x:i},backend:r,attrs:{shape:[i.shape[0],1,1]}});m=(0,oK.WQ)({inputs:{a:m,b:e},backend:r}),r.disposeIntermediateTensorInfo(e)}else m=(0,oK.WQ)({inputs:{a:m,b:i},backend:r});r.disposeIntermediateTensorInfo(e)}if(c){let e=m;if("NCHW"===h&&"prelu"===c&&1===o.shape.length&&1!==o.shape[0]){let e=oH({inputs:{x:o},backend:r,attrs:{shape:[o.shape[0],1,1]}});m=oj(r,m,c,e,f),r.disposeIntermediateTensorInfo(e)}else m=oj(r,m,c,o,f);r.disposeIntermediateTensorInfo(e)}return m}},u$={kernelName:W.T7M,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d,activation:c,leakyreluAlpha:f}=n,m=l0({inputs:{x:a,filter:s},backend:r,attrs:{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d}});if(i){let e=m;m=(0,oK.WQ)({inputs:{a:m,b:i},backend:r}),r.disposeIntermediateTensorInfo(e)}if(c){let e=m;m=oj(r,m,c,o,f),r.disposeIntermediateTensorInfo(e)}return m}};var uF=r(47820);let uR={kernelName:W.O4G,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{params:n,indices:a}=t,s=W.ZSL.sizeFromShape(n.shape),i=a.shape,o=i[i.length-1],[l,u,h,p]=W.C0T.prepareAndValidate(n,a);if(0===u)return r.makeTensorInfo(l,n.dtype,[]);let d=r.data.get(a.dataId).values,c=r.bufferSync(n),f=(0,uF.q)(d,c,n.dtype,u,o,h,p,n.shape,s);return r.makeTensorInfo(l,n.dtype,f.values)}};var u_=r(54658);let uD={kernelName:W.mxL,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,indices:s}=t,{axis:i,batchDims:o}=n;(0,oI.C)([a,s],"gatherV2");let l=W.ZSL.parseAxisParam(i,a.shape)[0],u=r.data.get(s.dataId).values,h=a.shape[l];for(let e=0;e<u.length;++e){let t=u[e];W.ZSL.assert(t<=h-1&&t>=0,()=>`GatherV2: the index value ${t} is not in [0, ${h-1}]`)}let p=o;null==o&&(p=0);let d=W.ZSL.sizeFromShape(s.shape),c=W.C0T.segment_util.collectGatherOpShapeInfo(a,s,l,p),f=oH({inputs:{x:a},backend:r,attrs:{shape:[c.batchSize,c.outerSize,c.dimSize,c.sliceSize]}}),m=oH({inputs:{x:s},backend:r,attrs:{shape:[c.batchSize,d/c.batchSize]}}),g=[c.batchSize,c.outerSize,d/c.batchSize,c.sliceSize],y=r.bufferSync(m),b=r.bufferSync(f),x=(0,u_.G)(b,y,g);return r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(m),r.makeTensorInfo(c.outputShape,x.dtype,x.values)}};var uO=r(67934),uL=r(48374);let uM={kernelName:W.OAQ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}
296=e,{input:n}=t,a=W.ZSL.sizeFromShape(n.shape),s=n.shape[n.shape.length-1],i=oH({inputs:{x:n},backend:r,attrs:{shape:[a/s,s]}}),o=uT(i,!0,r),l=oH({inputs:{x:o},backend:r,attrs:{shape:n.shape}});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),l}},uP=(0,oF.v)(W.gIW,e=>+!!Number.isFinite(e),"bool"),uz={kernelName:W.gIW,backendName:"cpu",kernelFunc:uP},uB=(0,oF.v)(W.E3$,e=>+(Math.abs(e)===1/0),"bool"),uW={kernelName:W.E3$,backendName:"cpu",kernelFunc:uB},uV=(0,oF.v)(W.iPs,e=>+!!Number.isNaN(e),"bool"),uU={kernelName:W.iPs,backendName:"cpu",kernelFunc:uV};var uG=r(53553),uZ=r(71387),uj=r(66114);let uK={kernelName:W.mnI,backendName:"cpu",kernelFunc:function(e){let{backend:t,attrs:r}=e,{start:n,stop:a,num:s}=r,i=(0,uj.G)(n,a,s);return t.makeTensorInfo([i.length],"float32",i)}};var uH=r(28566);let uY=(0,oF.v)(W.Cg$,e=>Math.log1p(e)),uQ={kernelName:W.Cg$,backendName:"cpu",kernelFunc:uY},uq=(0,oM.Z)((e,t)=>e&&t),uX=(0,li.j)(W.RUm,uq,null,"bool"),uJ={kernelName:W.RUm,backendName:"cpu",kernelFunc:uX},u0=(0,oF.v)(W.nZd,e=>+!e,"bool"),u1={kernelName:W.nZd,backendName:"cpu",kernelFunc:u0},u2=(0,oM.Z)((e,t)=>e||t),u3=(0,li.j)(W.LXA,u2,null,"bool"),u4={kernelName:W.LXA,backendName:"cpu",kernelFunc:u3},u6={kernelName:W.jM4,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{depthRadius:s,bias:i,alpha:o,beta:l}=n;(0,oI.C)(a,"LRN");let u=a.shape[3],h=u-1,p=r.data.get(a.dataId).values,d=W.ZSL.sizeFromShape(a.shape),c=new Float32Array(d);for(let e=0;e<d;e++){let t=function(e){let t=e%u,r=e-t+Math.max(0,t-s),n=e-t+Math.min(t+s,h),a=0;for(;r<=n;r++){let e=p[r];a+=e*e}return a}(e),r=p[e]*Math.pow(i+o*t,-l);c[e]=r}return r.makeTensorInfo(a.shape,a.dtype,c)}},u5={kernelName:W.ToN,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,y:s,dy:i}=t,{depthRadius:o,bias:l,alpha:u,beta:h}=n;(0,oI.C)(i,"LRNGrad");let p=W.ZSL.sizeFromShape(i.shape),d=i.shape[3],c=r.data.get(i.dataId).values,f=r.data.get(a.dataId).values,m=r.data.get(s.dataId).values,g=new Float32Array(p);for(let e=0;e<p;e++){let t=e%d,r=e-t+Math.max(0,t-o),n=e-t+Math.min(d,t+o+1),a=0;for(let e=r;e<n;e++)a+=Math.pow(f[e],2);a=u*a+l;for(let t=r;t<n;t++){let r=-2*u*h*f[t]*m[e]/a;e===t&&(r+=Math.pow(a,-h)),r*=c[e],g[t]+=r}}return r.makeTensorInfo(i.shape,a.dtype,g)}};var u8=r(26761),u7=r(25550);function u9(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{reductionIndices:s,keepDims:i}=n,o=a.shape,l=o.length,u=W.ZSL.parseAxisParam(s,o),h=u,p=W.C0T.getAxesPermutation(h,l),d=r.data.get(a.dataId).values;if(null!=p){let e=Array(l);for(let t=0;t<e.length;t++)e[t]=o[p[t]];d=(0,u7._)(d,o,a.dtype,p,e),h=W.C0T.getInnerMostAxes(h.length,l),o=e}(0,oI.C)(a,"max"),W.C0T.assertAxesAreInnerMostDims("max",h,l);let[c,f]=W.C0T.computeOutAndReduceShapes(o,h),m=W.ZSL.sizeFromShape(f),g=(0,u8.j)(d,m,c,a.dtype),y=r.write(g,c,a.dtype),b=c;return i&&(b=W.C0T.expandShapeToKeepDim(c,u)),{dataId:y,shape:b,dtype:a.dtype}}let he={kernelName:W.VAI,backendName:"cpu",kernelFunc:u9};var ht=r(78522);let hr={kernelName:W.t3d,backendName:"cpu",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r;(0,oI.C)(s,"maxPool");let{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=a;W.ZSL.assert(W.C0T.eitherStridesOrDilationsAreOne(o,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`);let h=W.C0T.computePool2DInfo(s.shape,i,o,1,l,u);if(1===h.filterWidth&&1===h.filterHeight&&W.ZSL.arraysEqual(h.inShape,h.outShape))t=(0,oD.D)({inputs:{x:s},backend:n});else{let e=n.data.get(s.dataId).values,r=W.ZSL.computeStrides(s.shape),a=ld(e,s.shape,s.dtype,r,h,"max");t=n.makeTensorInfo(h.outShape,s.dtype,a.values)}return t}},hn={kernelName:W.ySp,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:u}=n;(0,oI.C)(a,"maxPool3d");let h=W.C0T.computePool3DInfo(a.shape,s,i,1,o,l,u),p=lf(r.data.get(a.dataId).values,a.shape,a.dtype,W.ZSL.computeStrides(a.shape),h,"max");return r.makeTensorInfo(p.shape,"float32",p.values)}},ha={kernelName:W.cHb,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=n;(0,oI.C)([a,s],"maxPool3DGrad");let h=W.C0T.computePool3DInfo(s.shape,i,o,1,l,u),p=function(e,t){let r=(0,W.ra8)(t.outShape,"int32"),n=t.strideDepth,a=t.strideHeight,s=t.strideWidth,i=t.dilationDepth,o=t.dilationHeight,l=t.dilationWidth,u=t.effectiveFilterDepth,h=t.effectiveFilterHeight,p=t.effectiveFilterWidth,d=t.padInfo.front,c=t.padInfo.top,f=t.padInfo.left;for(let m=0;m<t.batchSize;++m)for(let g=0;g<t.inChannels;++g)for(let y=0;y<t.outDepth;++y){let b=y*n-d,x=b;
296for(;x<0;)x+=i;let v=Math.min(t.inDepth,u+b);for(let n=0;n<t.outHeight;++n){let u=n*a-c,d=u;for(;d<0;)d+=o;let w=Math.min(t.inHeight,h+u);for(let a=0;a<t.outWidth;++a){let c=a*s-f,T=c;for(;T<0;)T+=l;let S=Math.min(t.inWidth,p+c),N=-1/0,k=-1;for(let t=x;t<v;t+=i){let r=t-b;for(let n=d;n<w;n+=o){let a=n-u;for(let s=T;s<S;s+=l){let i=s-c,o=e.get(m,t,n,s,g);o>=N&&(N=o,k=r*h*p+a*h+i)}}}r.set(k,m,y,n,a,g)}}}return r}(r.bufferSync(s),h),d=h.strideDepth,c=h.strideHeight,f=h.strideWidth,m=h.dilationDepth,g=h.dilationHeight,y=h.dilationWidth,b=h.effectiveFilterDepth,x=h.effectiveFilterHeight,v=h.effectiveFilterWidth,w=b-1-h.padInfo.front,T=v-1-h.padInfo.left,S=x-1-h.padInfo.top,N=(0,W.ra8)(s.shape,"float32"),k=r.bufferSync(a);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let r=0;r<h.inDepth;++r)for(let n=0;n<h.inHeight;++n)for(let a=0;a<h.inWidth;++a){let s=r-w,i=n-S,o=a-T,l=0;for(let r=0;r<b;r+=m){let n=(s+r)/d;if(!(n<0)&&!(n>=h.outDepth)&&Math.floor(n)===n)for(let a=0;a<x;a+=g){let s=(i+a)/c;if(!(s<0)&&!(s>=h.outHeight)&&Math.floor(s)===s)for(let i=0;i<v;i+=y){let u=(o+i)/f;if(u<0||u>=h.outWidth||Math.floor(u)!==u)continue;let d=+(b*x*v-1-p.get(e,n,s,u,t)===r*x*v+a*v+i);0!==d&&(l+=k.get(e,n,s,u,t)*d)}}}N.set(l,e,r,n,a,t)}return r.makeTensorInfo(N.shape,N.dtype,N.values)}},hs={kernelName:W.RXX,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s,output:i}=t;(0,oI.C)([s,i],"maxPoolGrad");let{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=n,p=W.C0T.computePool2DInfo(s.shape,o,l,1,u,h),d=r.data.get(s.dataId).values,c=(0,W.ra8)(p.outShape,s.dtype,lc(d,s.shape,s.dtype,p).values),f=p.strideHeight,m=p.strideWidth,g=p.dilationHeight,y=p.dilationWidth,b=p.effectiveFilterHeight,x=p.effectiveFilterWidth,v=x-1-p.padInfo.left,w=b-1-p.padInfo.top,T=(0,W.ra8)(s.shape,"float32"),S=r.data.get(a.dataId).values,N=(0,W.ra8)(a.shape,"float32",S);for(let e=0;e<p.batchSize;++e)for(let t=0;t<p.inChannels;++t)for(let r=0;r<p.inHeight;++r)for(let n=0;n<p.inWidth;++n){let a=r-w,s=n-v,i=0;for(let r=0;r<b;r+=g){let n=(a+r)/f;if(!(n<0)&&!(n>=p.outHeight)&&Math.floor(n)===n)for(let a=0;a<x;a+=y){let o=(s+a)/m;if(o<0||o>=p.outWidth||Math.floor(o)!==o)continue;let l=+(b*x-1-c.get(e,n,o,t)===r*x+a);0!==l&&(i+=N.get(e,n,o,t)*l)}}T.set(i,e,r,n,t)}return r.makeTensorInfo(T.shape,T.dtype,T.values)}},hi={kernelName:W.TL8,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{x:n}=e,{filterSize:a,strides:s,pad:i,includeBatchInIndex:o}=t;(0,oI.C)(n,"MaxPoolWithArgmax");let l=r.data.get(n.dataId).values,u=W.C0T.computePool2DInfo(n.shape,a,s,[1,1],i),[h,p]=function(e,t,r,n,a){let s=W.ZSL.computeStrides(t),i=ld(e,t,r,s,a,"max"),o=lc(e,t,r,a,!0,n);return[i.values,o.values]}(l,n.shape,n.dtype,o,u),d=r.write(h,u.outShape,n.dtype),c=r.write(p,u.outShape,n.dtype);return[{dataId:d,shape:u.outShape,dtype:n.dtype},{dataId:c,shape:u.outShape,dtype:"int32"}]}},ho={kernelName:W.g5A,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n,o=W.ZSL.parseAxisParam(s,a.shape),l=W.C0T.computeOutAndReduceShapes(a.shape,o)[1],u=W.ZSL.sizeFromShape(l),h=[],p=r.makeTensorInfo([],"float32",new Float32Array([u]));h.push(p);let d=(0,lI.wg)({inputs:{x:a},backend:r,attrs:{dtype:"float32"}});h.push(d);let c=ux({inputs:{a:d,b:p},backend:r});h.push(c);let f=ut({inputs:{x:c},backend:r,attrs:{axis:s,keepDims:i}});return h.forEach(e=>r.disposeIntermediateTensorInfo(e)),f}},hl={kernelName:W.lNG,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n;(0,oI.C)(a,"min");let o=W.ZSL.parseAxisParam(s,a.shape),l=o,u=W.C0T.getAxesPermutation(l,a.shape.length),h=a;null!=u&&(h=(0,o6.m)({inputs:{x:a},backend:r,attrs:{perm:u}}),l=W.C0T.getInnerMostAxes(l.length,a.shape.length)),W.C0T.assertAxesAreInnerMostDims("min",l,h.shape.length);let[p,d]=W.C0T.computeOutAndReduceShapes(h.shape,l),c=W.ZSL.sizeFromShape(d),f=W.ZSL.makeZerosTypedArray(W.ZSL.sizeFromShape(p),h.dtype),m=r.data.get(h.dataId).values;for(let e=0;e<f.length;++e){let t=e*c,r=m[t];for(let e=0;e<c;++e){let n=m[t+e];(Number.isNaN(n)||n<r)&&(r=n)}f[e]=r}null!=u&&r.disposeIntermediateTensorInfo(h);let g=r.makeTensorInfo(p,h.dtype,f);if(i){let e=oH({inputs:{x:g},backend:r,attrs:{shape:W.C0T.expandShapeToKeepDim(p,o)}});return r.disposeIntermediateTensorInfo(g),e}return g}};var hu=r(20176);let hh={kernelName:W.x7F,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{paddings:s,mode:i}=n;(0,oI.C)(a,"mirrorPad");let o=s.map((e,t)=>e[0]+a.shape[t]+e[1]),l=s.map(e=>e[0]),u=s.map((e,t)=>e[0]+a.shape[t]),h=+("reflect"!==i),p=r.data.get(a.dataId).values,d=a.shape.length,c=W.ZSL.computeStrides(a.shape),f=W.ZSL.sizeFromShape(o),m=o.length,g=W.ZSL.computeStrides(o),y=W.ZSL.getTypedArrayFromDType(a.dtype,f);for(let e=0;e<f;e++){let t=W.ZSL.indexToLoc(e,m,g);for(let e=0;e<m;e++)t[e]<l[e]?t[e]=2*l[e]-t[e]-h:t[e]>=u[e]&&(t[e]=(u[e]-1)*2-t[e]+h);t=t.map((e,t)=>e-l[t]);let r=W.ZSL.locToIndex(t,d,c);y[e]=p[r]}return{dataId:r.write(y,o,a.dtype),shape:o,dtype:a.dtype}}},hp=(0,oM.Z)((e,t)=>{let r=e%t;return e<0&&t<0||e>=0&&t>=0?r:(r+t)%t}),hd=(0,li.j)(W.BLA,hp),hc={kernelName:W.BLA,backendName:"cpu",kernelFunc:hd};function hf(e){let{inputs:t,backend:r,attrs:n}=e,{logits:a}=t,{dim:s}=n,i=a.shape.length,o=s;if(-1===o&&(o=i-1),o!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${o}`);let l=W.ZSL.parseAxisParam([o],a.shape),u=u9({inputs:{x:a},backend:r,attrs:{reductionIndices:l,keepDims:!1}}),h=W.C0T.expandShapeToKeepDim(u.shape,l),p=oH({inputs:{x:u},backend:r,attrs:{shape:h}}
296),d=(0,uw.jb)({inputs:{a:a,b:p},backend:r}),c=(0,uf.oN)({inputs:{x:d},backend:r}),f=ut({inputs:{x:c},backend:r,attrs:{axis:l,keepDims:!1}}),m=oH({inputs:{x:f},backend:r,attrs:{shape:h}}),g=ux({inputs:{a:c,b:m},backend:r});return r.disposeIntermediateTensorInfo(u),r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(m),g}let hm={kernelName:W.rFG,backendName:"cpu",kernelFunc:hf},hg={kernelName:W.WT3,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{logits:a}=t,{numSamples:s,seed:i,normalized:o}=n;(0,oI.C)(a,"multinomial");let l=o?a:hf({inputs:{logits:a},backend:r,attrs:{dim:-1}}),u=l.shape[0],h=l.shape[1],p=r.data.get(l.dataId).values,d=[u,s],c=W.ZSL.makeZerosTypedArray(W.ZSL.sizeFromShape(d),"int32");for(let e=0;e<u;++e){let t=e*h,r=new Float32Array(h-1);r[0]=p[t];for(let e=1;e<r.length;++e)r[e]=r[e-1]+p[t+e];let n=iF.alea(i.toString()),a=e*s;for(let e=0;e<s;++e){let t=n();c[a+e]=r.length;for(let n=0;n<r.length;n++)if(t<r[n]){c[a+e]=n;break}}}return o||r.disposeIntermediateTensorInfo(l),r.makeTensorInfo(d,"int32",c)}};var hy=r(76466);let hb=W.kpo.nonMaxSuppressionV3Impl,hx={kernelName:W.SDM,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=n;(0,oI.C)(a,"NonMaxSuppression");let{selectedIndices:u}=hb(r.data.get(a.dataId).values,r.data.get(s.dataId).values,i,o,l);return r.makeTensorInfo([u.length],"int32",new Int32Array(u))}},hv=W.kpo.nonMaxSuppressionV4Impl,hw={kernelName:W.Zl4,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:u}=n;(0,oI.C)(a,"NonMaxSuppressionPadded");let{selectedIndices:h,validOutputs:p}=hv(r.data.get(a.dataId).values,r.data.get(s.dataId).values,i,o,l,u);return[r.makeTensorInfo([h.length],"int32",new Int32Array(h)),r.makeTensorInfo([],"int32",new Int32Array([p]))]}},hT=W.kpo.nonMaxSuppressionV5Impl,hS={kernelName:W.e0f,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=n;(0,oI.C)(a,"NonMaxSuppressionWithScore");let h=r.data.get(a.dataId).values,{selectedIndices:p,selectedScores:d}=hT(h,r.data.get(s.dataId).values,i,o,l,u);return[r.makeTensorInfo([p.length],"int32",new Int32Array(p)),r.makeTensorInfo([d.length],"float32",new Float32Array(d))]}};var hN=r(30823);let hk={kernelName:W.urI,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{indices:a}=t,{dtype:s,depth:i,onValue:o,offValue:l}=n;(0,oI.C)(a,"oneHot");let u=W.ZSL.sizeFromShape(a.shape),h=new Float32Array(u*i);h.fill(l);let p=r.data.get(a.dataId).values;for(let e=0;e<u;++e)p[e]>=0&&p[e]<i&&(h[e*i+p[e]]=o);return r.makeTensorInfo([...a.shape,i],s,h)}};function hI(e){let{inputs:t,backend:r}=e,{x:n}=t;if("string"===n.dtype)throw Error("zerosLike is not supported for string tensors");if("complex64"!==n.dtype)return uN({backend:r,attrs:{shape:n.shape,value:0,dtype:n.dtype}});{let e=(0,lO.x)({inputs:{input:n},backend:r}),t=hI({inputs:{x:e},backend:r}),a=l_({inputs:{input:n},backend:r}),s=hI({inputs:{x:a},backend:r}
296),i=(0,l$.f)({inputs:{real:t,imag:s},backend:r});return r.disposeIntermediateTensorInfo(e),r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(s),i}}let hC={kernelName:W.xJ3,backendName:"cpu",kernelFunc:hI},hE={kernelName:W.LWX,backendName:"cpu",kernelFunc:function e(t){let{inputs:r,backend:n}=t,{x:a}=r;if("string"===a.dtype)throw Error("onesLike is not supported for string tensors");if("complex64"!==a.dtype)return uN({backend:n,attrs:{shape:a.shape,value:1,dtype:a.dtype}});{let t=(0,lO.x)({inputs:{input:a},backend:n}),r=e({inputs:{x:t},backend:n}),s=l_({inputs:{input:a},backend:n}),i=hI({inputs:{x:s},backend:n}),o=(0,l$.f)({inputs:{real:r,imag:i},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),o}}};function hA(e){let{inputs:t,backend:r,attrs:n}=e,{axis:a}=n;if(1===t.length)return um({inputs:{input:t[0]},backend:r,attrs:{dim:a}});let s=t[0].shape,i=t[0].dtype;t.forEach(e=>{W.ZSL.assertShapesMatch(s,e.shape,"All tensors passed to stack must have matching shapes"),W.ZSL.assert(i===e.dtype,()=>"All tensors passed to stack must have matching dtypes")});let o=[],l=lL({inputs:t.map(e=>{let t=um({inputs:{input:e},backend:r,attrs:{dim:a}});return o.push(t),t}),backend:r,attrs:{axis:a}});return o.forEach(e=>r.disposeIntermediateTensorInfo(e)),l}let h$={kernelName:W.mM$,backendName:"cpu",kernelFunc:hA},hF={kernelName:W.ODT,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{paddings:s,constantValue:i}=n;(0,oI.C)(a,"pad");let o=s.map((e,t)=>e[0]+a.shape[t]+e[1]),l=s.map(e=>e[0]),u=r.data.get(a.dataId).values,h=W.ZSL.sizeFromShape(a.shape),p=a.shape.length,d=W.ZSL.computeStrides(a.shape),c=W.ZSL.sizeFromShape(o),f=o.length,m=W.ZSL.computeStrides(o),g=W.ZSL.getTypedArrayFromDType(a.dtype,c);0!==i&&g.fill(i);for(let e=0;e<h;e++){let t=W.ZSL.indexToLoc(e,p,d).map((e,t)=>e+l[t]);g[W.ZSL.locToIndex(t,f,m)]=u[e]}return{dataId:r.write(g,o,a.dtype),shape:o,dtype:a.dtype}}},hR=(0,oM.Z)((e,t)=>Math.pow(e,t)),h_=(0,li.j)(W.pyJ,hR),hD={kernelName:W.pyJ,backendName:"cpu",kernelFunc:h_};var hO=r(47045),hL=r(92600);let hM={kernelName:W.oJ2,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{paramsNestedSplits:a,paramsDenseValues:s,indices:i}=t,{outputRaggedRank:o}=n,l=a.map(e=>r.data.get(e.dataId).values),u=a.map(e=>e.shape),h=r.data.get(s.dataId).values,p=r.data.get(i.dataId).values,[d,c,f]=(0,hL.u)(l,u,h,s.shape,s.dtype,p,i.shape,o),m=d.map(e=>r.makeTensorInfo([e.length],"int32",e)),g=r.makeTensorInfo(f,s.dtype,c);return m.concat([g])}};var hP=r(59802);let hz={kernelName:W.CQC,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{starts:n,limits:a,deltas:s}=t,i=r.data.get(n.dataId).values,o=r.data.get(a.dataId).values,l=r.data.get(s.dataId).values,[u,h]=(0,hP._)(i,n.shape,n.dtype,o,a.shape,l,s.shape);return[r.makeTensorInfo([u.length],"int32",u),r.makeTensorInfo([h.length],n.dtype,h)]}};var hB=r(50206);let hW={kernelName:W.mH5,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{shape:a,values:s,defaultValue:i,rowPartitionTensors:o}=t,{rowPartitionTypes:l}=n,u=r.data.get(a.dataId).values,h=r.data.get(s.dataId).values,p=r.data.get(i.dataId).values,d=o.map(e=>r.data.get(e.dataId).values),c=o.map(e=>e.shape),[f,m]=(0,hB.K)(u,a.shape,h,s.shape,s.dtype,p,i.shape,d,c,l);return r.makeTensorInfo(f,s.dtype,m)}};var hV=r(85656);let hU={kernelName:W.Q6t,backendName:"cpu",kernelFunc:function(e){let{backend:t,attrs:r}=e,{start:n,stop:a,dtype:s,step:i}=r,o=(0,hV.q)(n,a,i,s);return t.makeTensorInfo([o.length],s,o)}},hG=(0,oF.v)(W.huO,e=>1/e),hZ={kernelName:W.huO,backendName:"cpu",kernelFunc:hG},hj={kernelName:W.hgw,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a}=t,{alignCorners:s,halfPixelCenters:i,size:o}=n;(0,oI.C)(a,"resizeBilinear");let l=W.ZSL.computeStrides(a.shape),[u,h]=o,[p,d,c,f]=a.shape,m=r.data.get(a.dataId).values,g=new Float32Array(W.ZSL.sizeFromShape([p,u,h,f])),y=[s&&u>1?d-1:d,s&&h>1?c-1:c],b=[s&&u>1?u-1:u,s&&h>1?h-1:h],x=0,v=y[0]/b[0],w=y[1]/b[1];for(let e=0;e<p;e++)for(let t=0;t<u;t++){let r,n=Math.max(0,Math.floor(r=i?v*(t+.5)-.5:v*t)),a=r-n,s=Math.min(d-1,Math.ceil(r)),o=e*l[0]+n*l[1],u=e*l[0]+s*l[1];for(let e=0;e<h;e++){let t,r=Math.max(0,Math.floor(t=i?w*(e+.5)-.5:w*e)),n=t-r,s=Math.min(c-1,Math.ceil(t)),h=o+r*l[2],p=u+r*l[2],d=o+s*l[2],y=u+s*l[2];for(let e=0;e<f;e++){let t=m[h+e],r=m[p+e],s=m[d+e],i=m[y+e],o=t+(s-t)*n,l=o+(r+(i-r)*n-o)*a;g[x++]=l}}}return r.makeTensorInfo([p,u,h,f],"float32",g)}},hK={kernelName:W.FCQ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a,dy:s}=t,{alignCorners:i}=n;(0,oI.C)([s,a],"resizeBilinearGrad");
296let o=W.ZSL.computeStrides(a.shape),[l,u,h,p]=a.shape,[,d,c]=s.shape,f=new Float32Array(l*u*h*p),m=[i&&d>1?u-1:u,i&&c>1?h-1:h],g=[i&&d>1?d-1:d,i&&c>1?c-1:c],y=m[0]/g[0],b=m[1]/g[1],x=r.data.get(s.dataId).values,v=0;for(let e=0;e<l;e++){let t=e*o[0];for(let e=0;e<d;e++){let r=e*y,n=Math.floor(r),a=Math.min(Math.ceil(r),u-1),s=t+n*o[1],i=t+a*o[1],l=r-n,d=1-l;for(let e=0;e<c;e++){let t=e*b,r=Math.floor(t),n=Math.min(Math.ceil(t),h-1),a=t-r,u=1-a,c=s+r*o[2],m=s+n*o[2],g=i+r*o[2],y=i+n*o[2],w=d*u,T=d*a,S=l*u,N=l*a;for(let e=0;e<p;e++){let t=x[v++];f[c+e]+=t*w,f[m+e]+=t*T,f[g+e]+=t*S,f[y+e]+=t*N}}}}return r.makeTensorInfo([l,h,u,p],"float32",f)}},hH={kernelName:W.jOE,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a}=t,{alignCorners:s,halfPixelCenters:i,size:o}=n;(0,oI.C)(a,"resizeNearestNeighbor");let l=W.ZSL.computeStrides(a.shape),[u,h]=o,[p,d,c,f]=a.shape,m=r.data.get(a.dataId).values,g=new Float32Array(p*u*h*f),y=[s&&u>1?d-1:d,s&&h>1?c-1:c],b=[s&&u>1?u-1:u,s&&h>1?h-1:h],x=y[0]/b[0],v=y[1]/b[1],w=0;for(let e=0;e<p;e++){let t=e*l[0];for(let e=0;e<u;e++){let r=i?x*(e+.5):x*e,n=Math.min(d-1,s?Math.round(r):Math.floor(r));i&&(n=Math.max(0,n));let a=t+n*l[1];for(let e=0;e<h;e++){let t=i?v*(e+.5):v*e,r=Math.min(c-1,s?Math.round(t):Math.floor(t));i&&(r=Math.max(0,r));let n=a+r*l[2];for(let e=0;e<f;e++){let t=m[n+e];g[w++]=t}}}}return r.makeTensorInfo([p,u,h,f],a.dtype,g)}},hY={kernelName:W.XQy,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a,dy:s}=t,{alignCorners:i}=n;(0,oI.C)([s,a],"resizeNearestNeighborGrad");let o=W.ZSL.computeStrides(a.shape),l=W.ZSL.computeStrides(s.shape),[u,h,p,d]=a.shape,[,c,f]=s.shape,m=new Float32Array(u*h*p*d),g=r.data.get(s.dataId).values,y=[i&&c>1?h-1:h,i&&f>1?p-1:p],b=[i&&c>1?c-1:c,i&&f>1?f-1:f],x=y[0]/b[0],v=y[1]/b[1],w=1/x,T=1/v,S=2*Math.ceil(w)+2,N=2*Math.ceil(T)+2;for(let e=0;e<u;e++){let t=e*o[0];for(let e=0;e<h;e++){let r=t+e*o[1],n=Math.floor(Math.floor(e*w)-S/2);for(let a=0;a<p;a++){let s=r+a*o[2],u=Math.floor(Math.floor(a*T)-N/2);for(let r=0;r<d;r++){let o=0;for(let s=0;s<S;s++){let d=s+n;if(d<0||d>=c)continue;let m=t+d*l[1],y=d*x;if(e===Math.min(h-1,i?Math.round(y):Math.floor(y)))for(let e=0;e<N;e++){let t=e+u;if(t<0||t>=f)continue;let n=m+t*l[2],s=t*v;a===Math.min(p-1,i?Math.round(s):Math.floor(s))&&(o+=g[n+r])}}m[s+r]=o}}}}return r.makeTensorInfo(a.shape,a.dtype,m)}},hQ={kernelName:W.D7i,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{dims:s}=n;(0,oI.C)(a,"reverse");let i=a.shape.length,o=W.ZSL.parseAxisParam(s,a.shape);if(0===i)return(0,oD.D)({inputs:{x:a},backend:r});let l=new W.ylz(a.shape,a.dtype),u=r.bufferSync(a);for(let e=0;e<l.size;e++){let t=l.indexToLoc(e),r=t.slice();o.forEach(e=>r[e]=a.shape[e]-1-r[e]),l.set(u.get(...r),...t)}return r.makeTensorInfo(l.shape,l.dtype,l.values)}},hq={kernelName:W.BK4,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{image:n}
296=e,{radians:a,fillValue:s,center:i}=t,o=W.ZSL.getTypedArrayFromDType(n.dtype,W.ZSL.sizeFromShape(n.shape)),[l,u,h,p]=n.shape,[d,c]=W.C0T.getImageCenter(i,u,h),f=Math.sin(a),m=Math.cos(a),g=r.data.get(n.dataId).values;for(let e=0;e<l;e++){let t=e*h*u*p;for(let e=0;e<u;e++){let r=h*p*e;for(let n=0;n<h;n++){let a=n*p;for(let i=0;i<p;i++){let y=[l,e,n,i],b=y[2],x=y[1],v=(b-d)*m-(x-c)*f,w=(b-d)*f+(x-c)*m;v=Math.round(v+d),w=Math.round(w+c);let T=s;"number"!=typeof s&&(T=3===i?255:s[i]),v>=0&&v<h&&w>=0&&w<u&&(T=g[t+h*p*w+v*p+i]),o[t+r+a+i]=T}}}}return{dataId:r.write(o,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},hX=(0,oF.v)(W.hVg,e=>{let t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1}),hJ={kernelName:W.hVg,backendName:"cpu",kernelFunc:hX};var h0=r(81384),h1=r(87309);let h2={kernelName:W.pJc,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{indices:a,updates:s}=t,{shape:i}=n,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=W.C0T.calculateShapes(s,a,i),d=r.bufferSync(a),c=r.bufferSync(s),f=(0,h1.b)(d,c,i,p,u,l,o,h,0,!0);return r.makeTensorInfo(i,f.dtype,f.values)}},h3={kernelName:W.uWl,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{sortedSequence:a,values:s}=t,{side:i}=n,o=function(e,t,r,n,a,s){let i=W.ZSL.getArrayFromDType("int32",r*a);for(let o=0;o<r;++o){let r=e.slice(o*n,(o+1)*n),l=o*a;for(let e=0;e<a;++e)i[l+e]="left"===s?function(e,t){let r=0,n=e.length,a=0;for(;r<n;)e[a=Math.floor((r+n)/2)]<t?r=a+1:n=a;return n}(r,t[e+l]):function(e,t){let r=0,n=e.length,a=0;for(;r<n;)e[a=Math.floor((r+n)/2)]<=t?r=a+1:n=a;return n}(r,t[e+l])}return i}(r.data.get(a.dataId).values,r.data.get(s.dataId).values,a.shape[0],a.shape[1],s.shape[1],i);return r.makeTensorInfo(s.shape,"int32",o)}},h4={kernelName:W.l6P,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{condition:n,t:a,e:s}=t;(0,oI.C)([n,a,s],"select");let i=n.shape.length,o=r.data.get(n.dataId).values,l=r.data.get(a.dataId).values,u=r.data.get(s.dataId).values,h=(0,W.TuY)(a.dtype,s.dtype),p=W.ZSL.makeZerosTypedArray(W.ZSL.sizeFromShape(a.shape),h),d=0,c=0===i||i>1||1===a.shape.length?1:W.ZSL.sizeFromShape(a.shape.slice(1));for(let e=0;e<o.length;e++)for(let t=0;t<c;t++)1===o[e]?p[d++]=l[e]:p[d++]=u[e];return r.makeTensorInfo(a.shape,h,p)}},h6=W.C0T.SELU_SCALEALPHA,h5=W.C0T.SELU_SCALE,h8=(0,oF.v)(W.u$b,e=>e>=0?h5*e:h6*(Math.exp(e)-1)),h7={kernelName:W.u$b,backendName:"cpu",kernelFunc:h8},h9=(0,oF.v)(W.YVe,e=>e<0?-1:+(e>0)),pe={kernelName:W.YVe,backendName:"cpu",kernelFunc:h9},pt=(0,oF.v)(W.hql,e=>Math.sin(e)),pr={kernelName:W.hql,backendName:"cpu",kernelFunc:pt},pn=(0,oF.v)(W.J3C,e=>Math.sinh(e)),pa={kernelName:W.J3C,backendName:"cpu",kernelFunc:pn},ps=Math.log(11920928955078125e-23)+2,pi=(0,oF.v)(W.Fin,e=>{let t=Math.exp(e);return e<ps?t:e>-ps?e:Math.log(1+t)}),po={kernelName:W.Fin,backendName:"cpu",kernelFunc:pi},pl={kernelName:W.A8B,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockShape:s,paddings:i}=n;(0,oI.C)([a],"spaceToBatchND");let o=W.ZSL.sizeFromShape(s),l=[[0,0]];l.push(...i);for(let e=1+s.length;e<a.shape.length;++e)l.push([0,0]);let u=hF.kernelFunc({inputs:{x:a},backend:r,attrs:{paddings:l,constantValue:0}}),h=W.C0T.getReshaped(u.shape,s,o,!1),p=W.C0T.getPermuted(h.length,s.length,!1),d=W.C0T.getReshapedPermuted(u.shape,s,o,!1),c=oH({inputs:{x:u},backend:r,attrs:{shape:h}}),f=(0,o6.m)({inputs:{x:c},backend:r,attrs:{perm:p}}),m=oH({inputs:{x:f},backend:r,attrs:{shape:d}});return r.disposeIntermediateTensorInfo(u),r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),m}};var pu=r(65114);let ph={kernelName:W.C8s,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{indices:n,values:a,denseShape:s,defaultValue:i}=t;if(1!==s.shape.length)throw Error(`Dense shape must be a vector, saw: 297 ${s.shape}`);if(2!==n.shape.length)throw Error(`Indices must be a matrix, saw: 298 ${n.shape}`);if(1!==a.shape.length)throw Error(`Values must be a vector, saw: 299 ${a.shape}`);if(0!==i.shape.length)throw Error(`Default value must be a scalar, saw: 300 ${i.shape}`);let o=r.data.get(n.dataId).values,l=r.data.get(a.dataId).values,u=r.data.get(s.dataId).values,h=r.data.get(i.dataId).values[0],[p,d,c,f,m]=(0,pu.y)(o,n.shape,n.dtype,l,a.dtype,u,h);return[r.makeTensorInfo(d,n.dtype,p),r.makeTensorInfo([d[0]],a.dtype,c),r.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(e=>Number(e)))),r.makeTensorInfo([m.length],n.dtype,new Int32Array(m))]}};var pp=r(15385);let pd={kernelName:W.BoJ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{inputIndices:n,inputShape:a,newShape:s}=t;if(2!==n.shape.length)throw Error(`Input indices should be a matrix but received shape 301 ${n.shape}`);if(1!==a.shape.length)throw Error(`Input shape should be a vector but received shape 302 ${a.shape}`);if(1!==s.shape.length)throw Error(`Target shape should be a vector but received shape ${s.shape}`);let i=Array.from(r.data.get(a.dataId).values),o=r.data.get(n.dataId).values,l=Array.from(r.data.get(s.dataId).values),[u,h,p]=(0,pp.l)(o,n.shape,n.dtype,i,l);return[r.makeTensorInfo(h,n.dtype,u),r.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}};var pc=r(95853);let pf={kernelName:W.L6G,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{data:n,indices:a,segmentIds:s}=t;if(n.shape.length<1)throw Error("Data should be at least 1 dimensional but received scalar");
302if(1!==a.shape.length)throw Error(`Indices should be a vector but received shape 303 ${a.shape}`);if(1!==s.shape.length)throw Error(`Segment ids should be a vector but received shape 304 ${s.shape}`);if(a.shape[0]!==s.shape[0])throw Error("segmentIds and indices should have same size.");let i=r.data.get(n.dataId).values,o=r.data.get(a.dataId).values,l=r.data.get(s.dataId).values,[u,h]=(0,pc.z)(i,n.shape,n.dtype,o,l,!0);return r.makeTensorInfo(h,n.dtype,u)}},pm={kernelName:W.DvZ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{data:n,indices:a,segmentIds:s}=t;if(n.shape.length<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw Error(`Indices should be a vector but received shape 305 ${a.shape}`);if(1!==s.shape.length)throw Error(`Segment ids should be a vector but received shape 306 ${s.shape}`);if(a.shape[0]!==s.shape[0])throw Error("segmentIds and indices should have same size.");let i=r.data.get(n.dataId).values,o=r.data.get(a.dataId).values,l=r.data.get(s.dataId).values,[u,h]=(0,pc.z)(i,n.shape,n.dtype,o,l);return r.makeTensorInfo(h,n.dtype,u)}},pg={kernelName:W.jgd,backendName:"cpu",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{sparseIndices:s,sparseValues:i,defaultValue:o}=r,{outputShape:l}=a,{sliceRank:u,numUpdates:h,sliceSize:p,strides:d,outputSize:c}=W.C0T.calculateShapes(i,s,l),f=n.bufferSync(s);switch(i.dtype){case"bool":{let e=n.bufferSync(i),r=!!n.data.get(o.dataId).values[0];t=(0,h1.b)(f,e,l,c,p,h,u,d,r,!1);break}case"float32":{let e=n.bufferSync(i),r=n.data.get(o.dataId).values[0];t=(0,h1.b)(f,e,l,c,p,h,u,d,r,!1);break}case"int32":{let e=n.bufferSync(i),r=n.data.get(o.dataId).values[0];t=(0,h1.b)(f,e,l,c,p,h,u,d,r,!1);break}case"string":{let e=n.bufferSync(i),r=W.ZSL.decodeString(n.data.get(o.dataId).values[0]);t=(0,h1.b)(f,e,l,c,p,h,u,d,r,!1);break}default:throw Error(`Unsupported type ${i.dtype}`)}return n.makeTensorInfo(l,t.dtype,t.values)}},py={kernelName:W.Blb,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{numOrSizeSplits:s,axis:i}=n,o=W.ZSL.parseAxisParam(i,a.shape)[0],l=W.C0T.prepareSplitSize(a,s,o),u=Array(a.shape.length).fill(0),h=a.shape.slice();return l.map(e=>{let t=[...h];t[o]=e;let n=(0,lv.di)({inputs:{x:a},backend:r,attrs:{begin:u,size:t}});return u[o]+=e,n})}};var pb=r(52310);let px={kernelName:W.M6A,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{let{x:r}=e;(0,oI.C)(r,"square");let n=t.data.get(r.dataId).values,a=new Float32Array(n.length);for(let e=0;e<n.length;++e){let t=n[e];a[e]=t*t}return{dataId:t.write(a,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};var pv=r(83310),pw=r(92947);let pT=(0,oF.v)(W.pnw,(e,t)=>isNaN(e)?NaN:e>0?1:t.alpha),pS={kernelName:W.pnw,backendName:"cpu",kernelFunc:pT};var pN=r(46978);let pk={kernelName:W.UcO,backendName:"cpu",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{begin:i,end:o,strides:l,beginMask:u,endMask:h,ellipsisMask:p,newAxisMask:d,shrinkAxisMask:c}=a;(0,oI.C)(s,"stridedSlice");let{finalShapeSparse:f,finalShape:m,isIdentity:g,sliceDim0:y,isSimpleSlice:b,begin:x,end:v,strides:w}=W.Kro.sliceInfo(s.shape,i,o,l,u,h,p,d,c);if(g)t=oH({inputs:{x:s},backend:n,attrs:{shape:m}});else if(y||b){W.ZSL.assert(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);let e=W.Kro.computeOutShape(x,v,w),r=(0,lv.di)({inputs:{x:s},backend:n,attrs:{begin:x,size:e}});t=oH({inputs:{x:r},backend:n,attrs:{shape:m}}),n.disposeIntermediateTensorInfo(r)}else{let e=n.bufferSync(s),r=(0,pN.e)(f,e,w,x);t=n.makeTensorInfo(m,r.dtype,r.values)}return t}};var pI=r(54574);let pC={kernelName:W.YAb,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{separator:a,nGramWidths:s,leftPad:i,rightPad:o,padWidth:l,preserveShortSequences:u}=n,{data:h,dataSplits:p}=t,d=r.data.get(h.dataId).values,c=r.data.get(p.dataId).values,[f,m]=(0,pI.G)(d,c,a,s,i,o,l,u);return[r.makeTensorInfo([f.length],"string",f),r.makeTensorInfo(p.shape,"int32",m)]}};var pE=r(92982);let pA={kernelName:W.iW0,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{skipEmpty:a}=n,{input:s,delimiter:i}=t;if("string"!==s.dtype)throw Error("Input must be of datatype string");if(1!==s.shape.length)throw Error(`Input must be a vector, got shape: ${s.shape}`);if(0!==i.shape.length)throw Error(`Delimiter must be a scalar, got shape: ${i.shape}`);let o=r.data.get(s.dataId).values,l=r.data.get(i.dataId).values[0],[u,h,p]=(0,pE.S)(o,l,a),d=h.length;return[r.makeTensorInfo([d,2],"int32",u),r.makeTensorInfo([d],"string",h),r.makeTensorInfo([2],"int32",new Int32Array(p))]}};var p$=r(1275);let pF={kernelName:W.$jE,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{numBuckets:a}=n,{input:s}=t;if("string"!==s.dtype)throw Error("Input must be of datatype string");if(a<=0)throw Error("Number of buckets must be at least 1");let i=r.data.get(s.dataId).values,o=(0,p$.f)(i,a);return r.makeTensorInfo(s.shape,"int32",o)}},pR=(0,oF.v)(W.oFs,e=>
306Math.tan(e)),p_={kernelName:W.oFs,backendName:"cpu",kernelFunc:pR},pD=(0,oF.v)(W.iuW,e=>Math.tanh(e)),pO={kernelName:W.iuW,backendName:"cpu",kernelFunc:pD},pL={kernelName:W.X4r,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{tensor:n,indices:a,updates:s}=t,{sliceRank:i,numUpdates:o,sliceSize:l,strides:u,outputSize:h}=W.C0T.calculateShapes(s,a,n.shape),p=r.bufferSync(a),d=r.bufferSync(s),c=r.bufferSync(n),f=(0,h1.b)(p,d,n.shape,h,l,o,i,u,c,!1);return r.makeTensorInfo(n.shape,f.dtype,f.values)}};var pM=r(47871);let pP={kernelName:W.FAs,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{reps:s}=n;(0,oI.C)(a,"tile");let i=(0,pM.D)(r.bufferSync(a),s);return r.makeTensorInfo(i.shape,i.dtype,i.values)}};var pz=r(92427);let pB={kernelName:W.TBb,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{k:s,sorted:i}=n;(0,oI.C)(a,"topk");let o=r.data.get(a.dataId).values,[l,u]=(0,pz.x)(o,a.shape,a.dtype,s,i);return[r.makeTensorInfo(l.shape,l.dtype,l.values),r.makeTensorInfo(u.shape,u.dtype,u.values)]}},pW={kernelName:W.dLy,backendName:"cpu",kernelFunc:function(e){let{inputs:t,attrs:r,backend:n}=e,{image:a,transforms:s}=t,{interpolation:i,fillMode:o,fillValue:l,outputShape:u}=r,[h,p,d,c]=a.shape,[f,m]=null!=u?u:[p,d],g=[h,f,m,c],y=W.ZSL.computeStrides(a.shape),b=y[0],x=y[1],v=y[2],w=W.ZSL.computeStrides(g),T=w[0],S=w[1],N=w[2],k=W.ZSL.getTypedArrayFromDType(a.dtype,W.ZSL.sizeFromShape(g));k.fill(l);let I=n.data.get(a.dataId).values,C=n.data.get(s.dataId).values;for(let e=0;e<h;++e){let t=1===s.shape[0]?C:C.subarray(8*e,8*e+8);for(let r=0;r<f;++r)for(let n=0;n<m;++n)for(let a=0;a<c;++a){let s,u=t[6]*n+t[7]*r+1;if(0===u)continue;let h=(t[0]*n+t[1]*r+t[2])/u,c=(t[3]*n+t[4]*r+t[5])/u,f=pV(h,d,o),m=pV(c,p,o);switch(i){case"nearest":s=pU(I,p,d,b,x,v,e,Math.round(m),Math.round(f),a,l);break;case"bilinear":s=function(e,t,r,n,a,s,i,o,l,u,h){let p=Math.floor(o),d=Math.floor(l),c=p+1,f=d+1,m=(f-l)*pU(e,t,r,n,a,s,i,p,d,u,h)+(l-d)*pU(e,t,r,n,a,s,i,p,f,u,h),g=(f-l)*pU(e,t,r,n,a,s,i,c,d,u,h)+(l-d)*pU(e,t,r,n,a,s,i,c,f,u,h);return(c-o)*m+(o-p)*g}(I,p,d,b,x,v,e,m,f,a,l);break;default:throw Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${i}`)}k[e*T+r*S+n*N+a]=s}return n.makeTensorInfo(g,a.dtype,k)}return{dataId:n.write(k,g,a.dtype),shape:a.shape,dtype:a.dtype}}};function pV(e,t,r){switch(r){case"reflect":var n,a,s,i,o=e,l=t;let u=o;if(u<0)if(l<=1)u=0;else{let e=2*l;u<e&&(u=e*Math.trunc(-u/e)+u),u=u<-l?u+e:-u-1}else if(u>l-1)if(l<=1)u=0;else{let e=2*l;(u-=e*Math.trunc(u/e))>=l&&(u=e-u-1)}return W.ZSL.clamp(0,u,l-1);case"wrap":let h;return n=e,a=t,(h=n)<0?a<=1?h=0:h+=a*(Math.trunc(-h/(a-1))+1):h>a-1&&(a<=1?h=0:h-=a*Math.trunc(h/(a-1))),W.ZSL.clamp(0,h,a-1);case"nearest":return s=e,i=t,W.ZSL.clamp(0,s,i-1);default:return e}}function pU(e,t,r,n,a,s,i,o,l,u,h){return 0<=o&&o<t&&0<=l&&l<r?e[i*n+o*a+l*s+u]:h}var pG=r(92330);let pZ={kernelName:W.EwU,backendName:"cpu",kernelFunc:function(e){let{inputs:t,attrs:r,backend:n}=e,{axis:a}=r,{x:s}=t;(0,oI.C)(s,"unique");let i=n.data.get(s.dataId).values,{outputValues:o,outputShape:l,indices:u}=(0,pG.w)(i,a,s.shape,s.dtype);return[n.makeTensorInfo(l,s.dtype,o),n.makeTensorInfo([u.length],"int32",u)]}},pj={kernelName:W.dXR,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{value:a}=t,{axis:s}=n;s<0&&(s+=a.shape.length);let i=a.shape.length,o=a.shape[s],l=Array(i-1),u=0;for(let e=0;e<i;e++)e!==s&&(l[u++]=a.shape[e]);let h=Array(i).fill(0),p=a.shape.slice();p[s]=1;let d=Array(o);for(let e=0;e<d.length;e++){h[s]=e;let t=(0,lv.di)({inputs:{x:a},backend:r,attrs:{begin:h,size:p}});d[e]=oH({inputs:{x:t},backend:r,attrs:{shape:l}}),r.disposeIntermediateTensorInfo(t)}return d}},pK={kernelName:W.pPe,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,segmentIds:s}=t,{numSegments:i}=n;(0,oI.C)(a,"unsortedSegmentSum");let o=a.shape.length,l=s.shape.length,u=[],h=[],p=o-l,d=s;for(let e=0;e<p;++e){let t=um({inputs:{input:d},backend:r,attrs:{dim:e+1}});d=t,h.push(t)}for(let e=0;e<i;++e){let t=W.ZSL.createScalarValue(e,"int32"),n=r.makeTensorInfo([],"int32",t),s=(0,us.LC)({inputs:{a:n,b:d},backend:r}
306),i=(0,lI.wg)({inputs:{x:s},backend:r,attrs:{dtype:"float32"}}),o=(0,l9.lw)({inputs:{a:i,b:a},backend:r}),l=ut({inputs:{x:o},backend:r,attrs:{axis:0,keepDims:!1}});u.push(l),h.push(n),h.push(s),h.push(i),h.push(o),h.push(l)}let c=hA({inputs:u,backend:r,attrs:{axis:0}});return h.forEach(e=>r.disposeIntermediateTensorInfo(e)),c}};for(let e of[oX,oJ.lO,o1,o3,oK.UK,o4,o5,o8,o7,o9,lt,ln,ls,lu,lp,lm,lg,ly,lb,oq,lx,lw,lS,lN.LY,lk,lI.Ml,lC.uf,lA,l$.v,lF,lM,lz,lB,lW,lV,lU,lG,lj,lH,lY,lQ,lq,lX,lJ,l1,l2,l3,l4,l6,l5,l8,l7,un,o_,ua,us.RY,uc,uf.AC,ug,uy.Yp,uS,uk,uI,uC.Hc,uE.Uc,uA,u$,uR,uD,uO.xp,uL.VM,oD.F,uM,lD,uz,uW,uU,oL,uG.YW,uZ.Q,uK,uH.Fx,uQ,uJ,u1,u4,u6,u5,he,ht.l9,hr,hn,ha,hs,hi,ho,hl,hu.Nu,hh,hc,hg,l9.tJ,hy.hd,hx,hw,hS,hN.AL,hk,hE,h$,hF,hD,oB,hO.S3,hM,hz,hW,hU,lO.r,uv,hZ,oV,oG,oY,hj,hK,hH,hY,hQ,hq,hJ,h0.Lt,h2,h3,h4,h7,oZ.X3,pe,pr,pa,lv.lv,hm,po,pl,ph,pd,pf,pm,pg,py,pb.Fu,px,pv.b2,pw.C,pS,pk,pC,pA,pF,uw.Zl,ur,p_,pO,pL,pP,pB,pW,o6.W,pZ,pj,pK,hC])(0,W.tAK)(e);var pH=r(21454);let pY="4.22.0";var pQ=r(14612),pq=r(91090),pX=r(1357),pJ=r(29643);function p0(){(0,W._K2)().set("WEBGL_FORCE_F16_TEXTURES",!0)}W.eMq.isBrowser()&&(0,W.gJX)("webgl",()=>new pH.Q6,2);let p1={forceHalfFloat:p0};var p2=r(71490);let p3=` 307 if (isnan(a)) return a; 308 if (isnan(b)) return b; 309`;class p4{constructor(e,t,r){this.variableNames=["A","B"],this.outputShape=W.C0T.assertAndGetBroadcastShape(t,r),this.enableShapeUniforms=(0,p2.ik)(this.outputShape.length),this.userCode=` 310 float binaryOperation(float a, float b) { 311 ${e} 312 } 313 314 void main() { 315 float a = getAAtOutCoords(); 316 float b = getBAtOutCoords(); 317 setOutput(binaryOperation(a, b)); 318 } 319 `}}var p6=r(91076),p5=r(48683);let p8=` 320 result.r = isNaN.r ? NAN : result.r; 321 result.g = isNaN.g ? NAN : result.g; 322 result.b = isNaN.b ? NAN : result.b; 323 result.a = isNaN.a ? NAN : result.a; 324`;class p7{constructor(e,t,r,n=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=W.C0T.assertAndGetBroadcastShape(t,r);let a=this.outputShape.length;this.enableShapeUniforms=(0,p2.ik)(a);let s="";if(n)if(0===a||1===W.ZSL.sizeFromShape(this.outputShape))s=` 325 result.y = 0.; 326 result.z = 0.; 327 result.w = 0.; 328 `;else{let e=(0,p5.bf)(a);if(s=` 329 ${e} coords = getOutputCoords(); 330 `,1===a)this.enableShapeUniforms?s+=` 331 result.y = (coords + 1) >= outShape ? 0. : result.y; 332 result.z = 0.; 333 result.w = 0.; 334 `:s+=` 335 result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y; 336 result.z = 0.; 337 result.w = 0.; 338 `;else{let e=(0,p6.Jp)("coords",a);this.enableShapeUniforms?s+=` 339 bool nextRowOutOfBounds = 340 (${e[a-2]} + 1) >= outShape[${a} - 2]; 341 bool nextColOutOfBounds = 342 (${e[a-1]} + 1) >= outShape[${a} - 1]; 343 result.y = nextColOutOfBounds ? 0. : result.y; 344 result.z = nextRowOutOfBounds ? 0. : result.z; 345 result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; 346 `:s+=` 347 bool nextRowOutOfBounds = 348 (${e[a-2]} + 1) >= ${this.outputShape[a-2]}; 349 bool nextColOutOfBounds = 350 (${e[a-1]} + 1) >= ${this.outputShape[a-1]}; 351 result.y = nextColOutOfBounds ? 0. : result.y; 352 result.z = nextRowOutOfBounds ? 0. : result.z; 353 result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; 354 `}}this.userCode=` 355 vec4 binaryOperation(vec4 a, vec4 b) { 356 ${e} 357 } 358 359 void main() { 360 vec4 a = getAAtOutCoords(); 361 vec4 b = getBAtOutCoords(); 362 363 vec4 result = binaryOperation(a, b); 364 ${s} 365 366 setOutput(result); 367 } 368 `}}function p9(e){let{inputs:t,backend:r}=e,{x:n}=t;return r.incRef(n.dataId),{dataId:n.dataId,shape:n.shape,dtype:n.dtype}}let de={kernelName:W.lzr,backendName:"webgl",kernelFunc:p9};function dt(e){let{inputs:t,backend:r}=e,{real:n,imag:a}=t,s=r.makeTensorInfo(n.shape,"complex64"),i=r.texData.get(s.dataId);return i.complexTensorInfos={real:p9({inputs:{x:n},backend:r}),imag:p9({inputs:{x:a},backend:r})},s}let dr={kernelName:W.pr3,backendName:"webgl",kernelFunc:dt},dn="return (a < 0.) ? b * a : a;",da=` 369 vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
370 return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); 371`,ds={kernelName:W.X0$,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{alpha:s}=n,i=r.makeTensorInfo([],"float32",W.ZSL.createScalarValue(s,"float32")),o=(0,W._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new p7(da,a.shape,i.shape):new p4(dn,a.shape,i.shape),l=r.runWebGLProgram(o,[a,i],"float32");return r.disposeIntermediateTensorInfo(i),l}},di="return (a < 0.) ? b * a : a;",dl=` 372 vec4 aLessThanZero = vec4(lessThan(a, vec4(0.))); 373 return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); 374`,du={kernelName:W.Ncv,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n,alpha:a}=t,s=(0,W._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new p7(dl,n.shape,a.shape):new p4(di,n.shape,a.shape);return r.runWebGLProgram(s,[n,a],"float32")}};var dh=r(3117),dp=r(39868);let dd="if (isnan(x)) return x;";function dc({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:r,dtype:n}){return({inputs:a,backend:s})=>{let i,{x:o}=a,l=n||o.dtype;if(s.shouldExecuteOnCPU([o])&&null!=r){let e=r(s.texData.get(o.dataId).values,l);return s.makeTensorInfo(o.shape,l,e)}return i=(0,W._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new dp.rf(o.shape,t):new dh.hE(o.shape,e),s.runWebGLProgram(i,[o],l)}}function df({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:r=!1,supportsComplex:n=!1,cpuKernelImpl:a,dtype:s}){return({inputs:i,backend:o})=>{let l,{a:u,b:h}=i;if(n&&"complex64"===u.dtype){let t=o.texData.get(u.dataId),r=o.texData.get(h.dataId),[n,a]=[[t.complexTensorInfos.real,r.complexTensorInfos.real],[t.complexTensorInfos.imag,r.complexTensorInfos.imag]].map(t=>{let[r,n]=t,a={dataId:r.dataId,dtype:r.dtype,shape:u.shape},s={dataId:n.dataId,dtype:n.dtype,shape:h.shape},i=new p4(e,u.shape,h.shape);return o.runWebGLProgram(i,[a,s],(0,W.TuY)(r.dtype,n.dtype))}),s=dt({inputs:{real:n,imag:a},backend:o});return o.disposeIntermediateTensorInfo(n),o.disposeIntermediateTensorInfo(a),s}let p=s||(0,W.TuY)(u.dtype,h.dtype);if(("string"===u.dtype||"string"===h.dtype||o.shouldExecuteOnCPU([u,h]))&&null!=a){let e=o.texData.get(u.dataId).values,t=o.texData.get(h.dataId).values,r="string"===u.dtype?W.C0T.fromUint8ToStringArray(e):e,n="string"===u.dtype?W.C0T.fromUint8ToStringArray(t):t,[s,i]=a(u.shape,h.shape,r,n,p),l=o.makeTensorInfo(i,p);return o.texData.get(l.dataId).values=s,l}return l=(0,W._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new p7(t,u.shape,h.shape,r):new p4(e,u.shape,h.shape),o.runWebGLProgram(l,[u,h],p)}}function dm(e,t=!1){if("linear"===e)return t?dp._Q:dh._Q;if("relu"===e)return t?dp.X8:dh.X8;if("elu"===e)return t?dp.X0:dh.X0;if("relu6"===e)return t?dp.Nb:dh.Nb;if("prelu"===e)return t?dl:di;else if("leakyrelu"===e)return t?da:dn;else if("sigmoid"===e)return t?dp.Hq:dh.Hq;throw Error(`Activation ${e} has not been implemented for the WebGL backend.`)}class dg{constructor(e,t,r,n=!1,a=!1,s=!1,i=null,o=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r,this.enableShapeUniforms=(0,p2.ik)(this.outputShape.length);let u=Math.ceil((n?e[1]:e[2])/2),h=n?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],p=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],d="",c="";i&&(d=o?`vec4 activation(vec4 a) { 375 vec4 b = getPreluActivationWeightsAtOutCoords(); 376 ${i} 377 }`:l?`vec4 activation(vec4 a) { 378 vec4 b = getLeakyreluAlphaAtOutCoords(); 379 ${i} 380 }`:`vec4 activation(vec4 x) { 381 ${i} 382 }`,c="result = activation(result);"),s&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let f="rc.x",m="rc.x";e[0]<t[0]?f=`imod(rc.x, ${e[0]})`:t[0]<e[0]&&(m=`imod(rc.x, ${t[0]})`),this.userCode=` 383 ${d} 384 // Don't use uniform for sharedDimensionPacked for performance. 385 const float sharedDimension = ${u}.0; 386 387 vec4 dot2x2ARowBCol(ivec3 rc) { 388 vec4 result = vec4(0); 389 int batchA = ${f}; 390 int batchB = ${m}; 391 for (int i = 0; i < ${u}; i++) { 392 vec4 a = getMatrixA(batchA, ${n?"i * 2, rc.y":"rc.y, i * 2"}); 393 vec4 b = getMatrixB(batchB, ${a?"rc.z, i * 2":"i * 2, rc.z"}); 394 395 // These swizzled products need to be separately added.
396 // See: https://github.com/tensorflow/tfjs/issues/1735 397 result += (${h[0]} * ${p[0]}); 398 result += (${h[1]} * ${p[1]}); 399 } 400 return result; 401 } 402 403 void main() { 404 ivec3 rc = getOutputCoords(); 405 vec4 result = dot2x2ARowBCol(rc); 406 407 ${s?"result += getBiasAtOutCoords();":""} 408 409 ${c} 410 411 setOutput(result); 412 } 413 `}}let dy={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class db{constructor(e,t,r){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=W.C0T.assertAndGetBroadcastShape(t,r),this.userCode=` 414 float binaryOpComplex( 415 float areal, float aimag, float breal, float bimag) { 416 ${e} 417 } 418 419 void main() { 420 float areal = getARealAtOutCoords(); 421 float aimag = getAImagAtOutCoords(); 422 float breal = getBRealAtOutCoords(); 423 float bimag = getBImagAtOutCoords(); 424 setOutput(binaryOpComplex(areal, aimag, breal, bimag)); 425 } 426 `}}var dx=r(18405);let dv="return a * b;";function dw(e){let t,{inputs:r,backend:n}=e,{a,b:s}=r,i=W.C0T.upcastType(a.dtype,s.dtype);if("complex64"===a.dtype){let e=n.texData.get(a.dataId),t=n.texData.get(s.dataId),r=new db(dy.REAL,a.shape,s.shape),i=new db(dy.IMAG,a.shape,s.shape),o=[{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:a.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:a.shape},{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:s.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:s.shape}],l=n.runWebGLProgram(r,o,"float32"),u=n.runWebGLProgram(i,o,"float32"),h=dt({inputs:{real:l,imag:u},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(u),h}if(n.shouldExecuteOnCPU([a,s])){let e=n.texData.get(a.dataId),t=n.texData.get(s.dataId),[r,o]=(0,dx.Xe)(a.shape,s.shape,e.values,t.values,i),l=n.makeTensorInfo(o,i);return n.texData.get(l.dataId).values=r,l}return t=(0,W._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new p7(dv,a.shape,s.shape):new p4(dv,a.shape,s.shape),n.runWebGLProgram(t,[a,s],i)}let dT={kernelName:W.xu7,backendName:"webgl",kernelFunc:dw};var dS=r(8750);function dN(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{shape:s}=n,i=W.ZSL.sizeFromShape(a.shape),o=W.ZSL.inferFromImplicitShape(s,i),l=W.ZSL.sizeFromShape(o);W.ZSL.assert(i===l,()=>`The new shape (${o}) has ${l} elements and the old shape (${a.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);let u=r.texData.get(a.dataId);return!u.isPacked||(0,pq.isReshapeFree)(a.shape,o)||null!==u.texture&&(0,pq.isReshapeFree)(u.shape,o)?(r.incRef(a.dataId),{dataId:a.dataId,shape:o,dtype:a.dtype}):function(e,t,r){let n=[(0,pq.getBatchDim)(e.shape),...(0,pq.getRowsCols)(e.shape)],a={dtype:e.dtype,shape:n,dataId:e.dataId},s=[(0,pq.getBatchDim)(t),...(0,pq.getRowsCols)(t)],i=new dS.R(s,n),o=r.runWebGLProgram(i,[a],e.dtype,[n],!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}(a,o,r)}let dk={kernelName:W.R23,backendName:"webgl",kernelFunc:dN};class dI{constructor(e,t){this.variableNames=["x"];let{windowSize:r,batchSize:n,inSize:a,outSize:s}=e;this.outputShape=[n,s];let i=4*Math.floor(r/4),o=r%4,l="sumValue += dot(values, ones);";if(null!=t){let e=1/t;l=`sumValue += dot(values * ${W.ZSL.isInt(e)?e.toPrecision(2):e}, ones);`}let u="";a%r>0&&(u=` 427 if (inIdx < 0 || inIdx >= ${a}) { 428 return 0.0; 429 } 430 `),this.userCode=` 431 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 432 433 float getValue(int batch, int inIdx) { 434 ${u} 435 return getX(batch, inIdx); 436 } 437 438 void main() { 439 ivec2 coords = getOutputCoords(); 440 int batch = coords[0]; 441 int outIdx = coords[1]; 442 int inOffset = outIdx * ${r}; 443 444 float sumValue = 0.0; 445 446 for (int i = 0; i < ${i}; i += 4) { 447 int inIdx = inOffset + i; 448 vec4 values = vec4( 449 getValue(batch, inIdx), 450 getValue(batch, inIdx + 1), 451 getValue(batch, inIdx + 2), 452 getValue(batch, inIdx + 3) 453 ); 454 455 ${l} 456 } 457 458 int inIdx = inOffset + ${i}; 459 if (${1===o}) { 460 vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0); 461 462 ${l} 463 } else if (${2===o}) { 464 vec4 values = vec4( 465 getValue(batch, inIdx), 466 getValue(batch, inIdx + 1), 0.0, 0.0); 467 468 ${l} 469 } else if (${3===o}) { 470 vec4 values = vec4( 471 getValue(batch, inIdx), 472 getValue(batch, inIdx + 1), 473 getValue(batch, inIdx + 2), 0.0); 474 475 ${l} 476 } 477 setOutput(sumValue); 478 } 479 `}}class dC{constructor(e,t){this.variableNames=["x"];let{windowSize:r,batchSize:n,inSize:a,outSize:s}=e;this.outputShape=[n,s];let i="0.0",o="";"prod"===t?i="1.0":"min"===t?(i="1.0 / 1e-20",o="min"):"max"===t&&(i="-1.0 / 1e-20",o="max");let l=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?l="sumValue":"prod"===t?l="prodValue":"all"===t?l="allValue":"any"===t&&(l="anyValue");let u=4*Math.floor(r/4),h=r%4,p=` 480 if (${"sum"===t}) { 481 sumValue += dot(values, ones); 482 } else if (${"prod"===t}) { 483 vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]); 484 prodValue *= tmp[0] * tmp[1]; 485 } else { 486 minMaxValue = ${o}(values, minMaxValue); 487 if (${"min"===t} || ${"max"===t}) { 488 minMaxValue = ${o}(values, minMaxValue); 489 bvec4 isNaN = isnan(values); 490 if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) { 491 minMaxValue = vec4(NAN); 492 } 493 } 494 } 495 `,d="vec4";"all"===t?(i="1.0",p=` 496 bool reducedAllValue = all(values); 497 float floatedReducedAllValue = float(reducedAllValue); 498 allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0); 499 `,d="bvec4"):"any"===t&&(i="0.0",p=` 500 bool reducedAnyValue = any(values); 501 float floatedReducedAnyValue = float(reducedAnyValue); 502 anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0); 503 `,d="bvec4");let c="";a%r>0&&(c=` 504 if (inIdx < 0 || inIdx >= ${a}) { 505 return initializationValue; 506 } 507 `),this.userCode=` 508 const float initializationValue = ${i}; 509 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 510 511 float getValue(int batch, int inIdx) { 512 ${c} 513 return getX(batch, inIdx); 514 } 515 516 void main() { 517 ivec2 coords = getOutputCoords(); 518 int batch = coords[0]; 519 int outIdx = coords[1]; 520 int inOffset = outIdx * ${r}; 521 522 vec4 minMaxValue = vec4(${i}); 523 float prodValue = 1.0; 524 float sumValue = 0.0; 525 float allValue = 1.0; 526 float anyValue = 0.0; 527 528 for (int i = 0; i < ${u}; i += 4) { 529 int inIdx = inOffset + i; 530 ${d} values = ${d}( 531 getValue(batch, inIdx), 532 getValue(batch, inIdx + 1), 533 getValue(batch, inIdx + 2), 534 getValue(batch, inIdx + 3) 535 ); 536 537 ${p} 538 } 539 540 int inIdx = inOffset + ${u}; 541 if (${1===h}) { 542 ${d} values = ${d}( 543 getValue(batch, inIdx), 544 initializationValue, 545 initializationValue, 546 initializationValue 547 ); 548 549 ${p} 550 } else if (${2===h}) { 551 ${d} values = ${d}( 552 getValue(batch, inIdx), 553 getValue(batch, inIdx + 1), 554 initializationValue, 555 initializationValue 556 ); 557 558 ${p} 559 } else if (${3===h}) { 560 ${d} values = ${d}( 561 getValue(batch, inIdx), 562 getValue(batch, inIdx + 1), 563 getValue(batch, inIdx + 2), 564 initializationValue 565 ); 566 567 ${p} 568 } 569 setOutput(${l}); 570 } 571 `}}function dE(e,t,r,n){let a=function(e){let t=[];for(;0===t.length||1!==t[t.length-1].outSize;){let r=t.length?t[t.length-1].outSize:e[1],n=W.C0T.computeOptimalWindowSize(r);t.push({inSize:r,windowSize:n,outSize:Math.ceil(r/n)})}return t}(e.shape),s=e;for(let i=0;i<a.length;i++){let o,l,{inSize:u,windowSize:h,outSize:p}=a[i];o="mean"===r?0===i?new dI({windowSize:h,inSize:u,batchSize:e.shape[0],outSize:p},u):new dI({windowSize:h,inSize:u,batchSize:e.shape[0],outSize:p}):new dC({windowSize:h,inSize:u,batchSize:e.shape[0],outSize:p},r),l=s,s=n.runWebGLProgram(o,[s],t),l.dataId!==e.dataId&&n.disposeIntermediateTensorInfo(l)}return s}class dA{constructor(e,t){this.variableNames=["A"];let r=Array(e.length);for(let n=0;n<r.length;n++)r[n]=e[t[n]];this.outputShape=r,this.rank=r.length;let n=(0,p5.bf)(this.rank),a=function(e){let t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);let r=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],n=Array(t);for(let t=0;t<e.length;t++)n[e[t]]=r[t];return n.join()}(t);this.userCode=` 572 void main() { 573 ${n} resRC = getOutputCoords(); 574 setOutput(getA(${a})); 575 } 576 `}}class d${constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;let r=Array(e.length);for(let n=0;n<r.length;n++)r[n]=e[t[n]];if(this.outputShape=r,this.rank=r.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);let n=(0,p5.bf)(this.rank),a=(0,p6.Fd)("rc",this.rank),s=Array(this.rank);for(let e=0;e<t.length;e++)s[t[e]]=a[e];let i=`vec2(${s.slice(-2).join()})`,o=`++${a[this.rank-1]} < ${r[this.rank-1]}`,l=`getChannel(getA(${s.join()}), ${i})`;this.userCode=` 577 void main() { 578 ${n} rc = getOutputCoords(); 579 vec4 result = vec4(0.); 580 result[0] = ${l}; 581 if(${o}) { 582 result[1] = ${l}; 583 } 584 --${a[this.rank-1]}; 585 if(++${a[this.rank-2]} < ${r[this.rank-2]}) { 586 result[2] = ${l}; 587 if(${o}) { 588 result[3] = ${l}; 589 } 590 } 591 setOutput(result); 592 } 593 `}}function dF(e,t,r){let n=(0,W._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new d$(e.shape,t):new dA(e.shape,t);return r.runWebGLProgram(n,[e],e.dtype)}function dR(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n;return function(e,t,r,n){let a=e.shape.length,s=W.ZSL.parseAxisParam(t,e.shape),i=s,o=W.C0T.getAxesPermutation(i,a),l=null!=o,u=e;l&&(u=dF(e,o,n),i=W.C0T.getInnerMostAxes(i.length,a)),W.C0T.assertAxesAreInnerMostDims("sum",i,a);let[h,p]=W.C0T.computeOutAndReduceShapes(u.shape,i),d=h;
593r&&(d=W.C0T.expandShapeToKeepDim(h,s));let c=W.ZSL.sizeFromShape(p),f=dN({inputs:{x:u},attrs:{shape:[W.ZSL.sizeFromShape(e.shape)/c,c]},backend:n}),m=dE(f,(0,W.chL)(e.dtype),"sum",n),g=dN({inputs:{x:m},attrs:{shape:d},backend:n});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),l&&n.disposeIntermediateTensorInfo(u),g}(a,s,i,r)}let d_={kernelName:W.WuN,backendName:"webgl",kernelFunc:dR};function dD(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{perm:i}=a,o=Array(s.shape.length);for(let e=0;e<o.length;e++)o[e]=s.shape[i[e]];if(n.shouldExecuteOnCPU([s])){let e=n.texData.get(s.dataId).values,r=(0,dx.Q5)(e,s.shape,s.dtype,i,o);t=n.makeTensorInfo(o,s.dtype),n.texData.get(t.dataId).values=r}else t=dF(s,i,n);return t}let dO={kernelName:W.wx0,backendName:"webgl",kernelFunc:dD};function dL({a:e,b:t,transposeA:r,transposeB:n,backend:a,bias:s=null,preluActivationWeights:i=null,leakyreluAlpha:o=0,activation:l=null}){let u,h=e.shape.length,p=t.shape.length,d=r?e.shape[h-2]:e.shape[h-1],c=n?t.shape[p-1]:t.shape[p-2],f=r?e.shape[h-1]:e.shape[h-2],m=n?t.shape[p-2]:t.shape[p-1],g=e.shape.slice(0,-2),y=t.shape.slice(0,-2),b=W.ZSL.sizeFromShape(g),x=W.ZSL.sizeFromShape(y),v=W.ZEY.assertAndGetBroadcastShape(e.shape.slice(0,-2),t.shape.slice(0,-2)).concat([f,m]);W.ZSL.assert(d===c,()=>`Error in matMul: inner shapes (${d}) and (${c}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${r} and transposeB=${n} must match.`);let w=r?[b,d,f]:[b,f,d],T=n?[x,m,c]:[x,c,m],S=dN({inputs:{x:e},backend:a,attrs:{shape:w}}),N=dN({inputs:{x:t},backend:a,attrs:{shape:T}}),k=[S,N],I=Math.max(b,x),C=r?S.shape[1]:S.shape[2],E=null!=s,A=null!=i,$="leakyrelu"===l,F=null!=l?dm(l,!0):null,R=E||A||$||null!=F;if((1===f||1===m)&&C>1e3&&!1===R){let e=S,t=N;r&&(e=dD({inputs:{x:S},backend:a,attrs:{perm:[0,2,1]}}),k.push(e)),n&&(t=dD({inputs:{x:N},backend:a,attrs:{perm:[0,2,1]}}),k.push(t));let s=1!==m,i=1===m,o=e;s&&(o=dN({inputs:{x:e},backend:a,attrs:{shape:[I,C,1]}}),k.push(o));let l=t;i&&(l=dN({inputs:{x:t},backend:a,attrs:{shape:[I,1,C]}}),k.push(l));let h=dw({inputs:{a:o,b:l},backend:a});u=dR({inputs:{x:h},backend:a,attrs:{axis:1===m?2:1,keepDims:!0}}),k.push(h)}else{let l=(0,W.TuY)(e.dtype,t.dtype),h=new dg(w,T,[I,f,m],r,n,E,F,A,$),p=[S,N];if(null!=s&&p.push(s),A&&p.push(i),$){let e=a.makeTensorInfo([],"float32",W.ZSL.createScalarValue(o,"float32"));p.push(e),k.push(e)}u=a.runWebGLProgram(h,p,l)}let _=dN({inputs:{x:u},backend:a,attrs:{shape:v}});for(let e of(k.push(u),k))a.disposeIntermediateTensorInfo(e);return _}let dM={kernelName:W.Dr,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{a,b:s,bias:i,preluActivationWeights:o}=t,{transposeA:l,transposeB:u,activation:h,leakyreluAlpha:p}=n;return dL({a,b:s,transposeA:l,transposeB:u,backend:r,bias:i,preluActivationWeights:o,leakyreluAlpha:p,activation:h})}},dP="return abs(x);",dz={kernelName:W.ljI,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n}=e,{x:a}=r;if(n.shouldExecuteOnCPU([a])&&"complex64"!==a.dtype){let e=n.texData.get(a.dataId),t=(0,dx.f8)(e.values);return n.makeTensorInfo(a.shape,a.dtype,t)}return t=(0,W._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new dp.rf(a.shape,dP):new dh.hE(a.shape,dP),n.runWebGLProgram(t,[a],a.dtype)}},dB=dc({opSnippet:dh.dR+` 594 if (abs(x) > 1.) { 595 return NAN; 596 } 597 return acos(x); 598`}),dW={kernelName:W.Vvy,backendName:"webgl",kernelFunc:dB},dV=dc({opSnippet:dh.dR+` 599 if (x < 1.0) return NAN; 600return log(x + sqrt(x * x - 1.0));`}),dU={kernelName:W.PH8,backendName:"webgl",kernelFunc:dV},dG="return a + b;",dZ=df({opSnippet:dG,packedOpSnippet:dG,supportsComplex:!0,cpuKernelImpl:dx.Gs}),dj={kernelName:W.OMN,backendName:"webgl",kernelFunc:dZ};class dK{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((e,t)=>`T${t}`);let r=[];this.variableNames.forEach(e=>{r.push(`float v${e} = get${e}AtOutCoords();`)});let n=this.variableNames.map(e=>`v${e}`).join(" + ");this.userCode=` 601 void main() { 602 ${r.join("\n ")} 603 604 float result = ${n}; 605 setOutput(result); 606 } 607 `}}class dH{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((e,t)=>`T${t}`);let r=[];
607this.variableNames.forEach(e=>{r.push(`vec4 v${e} = get${e}AtOutCoords();`)});let n=this.variableNames.map(e=>`v${e}`).join(" + ");this.userCode=` 608 void main() { 609 ${r.join("\n ")} 610 611 vec4 result = ${n}; 612 setOutput(result); 613 } 614 `}}let dY={kernelName:W.EkD,backendName:"webgl",kernelFunc:function e(t){let{inputs:r,backend:n}=t;if(1===r.length)return p9({inputs:{x:r[0]},backend:n});if(r.length>(0,W._K2)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){let t=Math.floor(r.length/2),a=e({inputs:r.slice(0,t),backend:n}),s=e({inputs:r.slice(t),backend:n});return e({inputs:[a,s],backend:n})}let a=r.map(e=>e.dtype).reduce((e,t)=>(0,W.TuY)(e,t)),s=r.map(e=>e.shape),i=(0,W._K2)().getBool("WEBGL_PACK")?new dH(r[0].shape,s):new dK(r[0].shape,s);return n.runWebGLProgram(i,r,a)}},dQ={kernelName:W.u8Z,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{axis:i,keepDims:o}=a,l=s.shape.length,u=W.ZSL.parseAxisParam(i,s.shape),h=u,p=W.C0T.getAxesPermutation(h,l),d=s;null!=p&&(d=dD({inputs:{x:s},backend:n,attrs:{perm:p}}),h=W.C0T.getInnerMostAxes(h.length,l)),W.C0T.assertAxesAreInnerMostDims("all",h,l);let[c,f]=W.C0T.computeOutAndReduceShapes(d.shape,h),m=dN({inputs:{x:d},backend:n,attrs:{shape:[-1,W.ZSL.sizeFromShape(f)]}}),g=dE(m,m.dtype,"all",n);return t=o?dN({inputs:{x:g},backend:n,attrs:{shape:W.C0T.expandShapeToKeepDim(c,u)}}):dN({inputs:{x:g},backend:n,attrs:{shape:c}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),null!=p&&n.disposeIntermediateTensorInfo(d),t}},dq={kernelName:W.FSt,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{axis:i,keepDims:o}=a,l=s.shape.length,u=W.ZSL.parseAxisParam(i,s.shape),h=u,p=W.C0T.getAxesPermutation(h,l),d=s;null!=p&&(d=dD({inputs:{x:s},backend:n,attrs:{perm:p}}),h=W.C0T.getInnerMostAxes(h.length,l)),W.C0T.assertAxesAreInnerMostDims("any",h,l);let[c,f]=W.C0T.computeOutAndReduceShapes(d.shape,h),m=dN({inputs:{x:d},backend:n,attrs:{shape:[-1,W.ZSL.sizeFromShape(f)]}}),g=dE(m,m.dtype,"any",n);return t=o?dN({inputs:{x:g},backend:n,attrs:{shape:W.C0T.expandShapeToKeepDim(c,u)}}):dN({inputs:{x:g},backend:n,attrs:{shape:c}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),null!=p&&n.disposeIntermediateTensorInfo(d),t}};class dX{constructor(e,t,r){this.variableNames=["A"];let{windowSize:n,batchSize:a,outSize:s}=e;r||this.variableNames.push("bestIndicesA"),this.outputShape=[a,s],this.userCode=` 615 void main() { 616 ivec2 coords = getOutputCoords(); 617 int batch = coords[0]; 618 int outIdx = coords[1]; 619 int inOffset = outIdx * ${n}; 620 621 int bestIndex = inOffset; 622 float bestValue = getA(batch, bestIndex); 623 624 for (int i = 0; i < ${n}; i++) { 625 int inIdx = ${r?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));"}; 626 float candidate = getA(batch, inIdx); 627 if (candidate ${"max"===t?">":"<"} bestValue) { 628 bestValue = candidate; 629 bestIndex = inIdx; 630 } 631 } 632 setOutput(float(bestIndex)); 633 } 634 `}}class dJ{constructor(e,t,r,n){let a,s;this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,W.ZSL.assert(e.length>2,()=>`Packed arg${r.charAt(0).toUpperCase()+r.slice(1)} supports only inputs with rank above 2.`);let i=Math.ceil(e[e.length-1]/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),n||this.variableNames.push("bestIndicesA");let o=this.outputShape,l=o.length,u=(0,p5.bf)(l),h=(0,p6.Jp)("coords",l);if(1===i){s=l+1;let e=(0,p5.bf)(s);a=` 635 ${e} sourceLocR = ${e}(${h.join()}, 0); 636 ++${h[l-1]}; 637 ${e} sourceLocG = ${e}(${h.join()}, 0); 638 ++${h[l-2]}; 639 ${e} sourceLocA = ${e}(${h.join()}, 0); 640 --${h[l-1]}; 641 ${e} sourceLocB = ${e}(${h.join()}, 0); 642 --${h[l-2]};`}else s=l,a=` 643 ${u} sourceLocR = coords; 644 ++${h[l-1]}; 645 ${u} sourceLocG = coords; 646 ++${h[l-2]}; 647 ${u} sourceLocA = coords; 648 --${h[l-1]}; 649 ${u} sourceLocB = coords; 650 --${h[l-2]};`;let p=["x","y","z","w","u","v"].slice(0,s),d="."+p[s-1],c=p.map(e=>"int "+e),f=(0,p6.Jp)("sourceLocR",s-1).concat("inIdx.r"),m=(0,p6.Jp)("sourceLocG",s-1).concat("inIdx.g"),g=(0,p6.Jp)("sourceLocB",s-1).concat("inIdx.b"),y=(0,p6.Jp)("sourceLocA",s-1).concat("inIdx.a"),b="max"===r?"greaterThan":"lessThan",x=n?"":` 651 inIdx = round(vec4(getBestIndicesAChannel(${f.join()}), 652 getBestIndicesAChannel(${m.join()}), 653 getBestIndicesAChannel(${g.join()}), 654 getBestIndicesAChannel(${y.join()})));`,v=`vec4( 655 getAChannel(${f.join()}), 656 hasNextCol ? getAChannel(${m.join()}) : 0., 657 hasNextRow ? getAChannel(${g.join()}) : 0., 658 hasNextRow && hasNextCol ? getAChannel(${y.join()}
658) : 0.)`,w=n?"":` 659 float getBestIndicesAChannel(${c.join()}) { 660 return getChannel(getBestIndicesA(${p.join()}), 661 vec2(${p.slice(-2).join()})); 662 }`;this.userCode=` 663 float getAChannel(${c.join()}) { 664 return getChannel(getA(${p.join()}), 665 vec2(${p.slice(-2).join()})); 666 } 667 ${w} 668 void main() { 669 ${u} coords = getOutputCoords(); 670 bool hasNextCol = ${h[l-1]} < ${o[l-1]-1}; 671 bool hasNextRow = ${h[l-2]} < ${o[l-2]-1}; 672 ${a} 673 ivec4 srcIdx = ivec4(sourceLocR${d}, sourceLocG${d}, 674 sourceLocB${d}, sourceLocA${d}) * ${t}; 675 ivec4 inIdx = srcIdx; 676 vec4 bestIndex = vec4(inIdx); 677 vec4 bestValue = ${v}; 678 679 for (int i = 0; i < ${t}; i++) { 680 inIdx = srcIdx; 681 ${x} 682 vec4 candidate = ${v}; 683 bvec4 nan = isnan(candidate); 684 bvec4 replace = bvec4( 685 vec4(${b}(candidate, bestValue)) * (vec4(1.0) - vec4(nan))); 686 687 bestValue = vec4(replace.x ? candidate.x : bestValue.x, 688 replace.y ? candidate.y : bestValue.y, 689 replace.z ? candidate.z : bestValue.z, 690 replace.w ? candidate.w : bestValue.w); 691 bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace)); 692 srcIdx++; 693 } 694 setOutput(bestIndex); 695 } 696 `}}function d0(e,t,r,n){let a=[r];if(W.C0T.assertAxesAreInnerMostDims("arg"+n.charAt(0).toUpperCase()+n.slice(1),a,t.shape.length),!(0,W._K2)().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){let r=[],s=e.texData.get(t.dataId),i=null!==s&&s.isPacked,o=t;i&&r.push(o=e.unpackTensor(t));let[l,u]=W.C0T.computeOutAndReduceShapes(o.shape,a),h=dN({inputs:{x:o},backend:e,attrs:{shape:[-1,W.ZSL.sizeFromShape(u)]}});r.push(h);let p=function e(t,r,n,a=null){let s=r.shape[0],i=r.shape[1];null!=a&&(s=a.shape[0],i=a.shape[1]);let o=W.C0T.computeOptimalWindowSize(i),l=new dX({windowSize:o,inSize:i,batchSize:s,outSize:Math.ceil(i/o)},n,null==a),u=[r];null!=a&&u.push(a);let h=t.runWebGLProgram(l,u,"int32");if(1===h.shape[1])return h;let p=e(t,r,n,h);return t.disposeIntermediateTensorInfo(h),p}(e,h,n);r.push(p);let d=dN({inputs:{x:p},backend:e,attrs:{shape:l}});return r.forEach(t=>e.disposeIntermediateTensorInfo(t)),d}return function e(t,r,n,a=null){let s=null!=a?a.shape:r.shape,i=s[s.length-1],o=new dJ(s,W.C0T.computeOptimalWindowSize(i),n,null==a),l=null==a?[r]:[r,a],u=t.runWebGLProgram(o,l,"int32");if(u.shape.length===r.shape.length){let a=e(t,r,n,u);return t.disposeIntermediateTensorInfo(u),a}return u}(e,t,n)}let d1={kernelName:W.Jp_,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s}=n,i=W.ZSL.parseAxisParam(s,a.shape),o=W.C0T.getAxesPermutation(i,a.shape.length),l=a,u=[];null!=o&&(u.push(l=dD({inputs:{x:a},backend:r,attrs:{perm:o}})),i=W.C0T.getInnerMostAxes(i.length,l.shape.length)),W.C0T.assertAxesAreInnerMostDims("argMax",[i[0]],l.shape.length);let h=d0(r,l,i[0],"max");return u.forEach(e=>r.disposeIntermediateTensorInfo(e)),h}},d2={kernelName:W.p_m,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s}=n,i=W.ZSL.parseAxisParam(s,a.shape),o=W.C0T.getAxesPermutation(i,a.shape.length),l=a,u=[];null!=o&&(u.push(l=dD({inputs:{x:a},backend:r,attrs:{perm:o}})),i=W.C0T.getInnerMostAxes(i.length,l.shape.length)),W.C0T.assertAxesAreInnerMostDims("argMin",[i[0]],l.shape.length);let h=d0(r,l,i[0],"min");return u.forEach(e=>r.disposeIntermediateTensorInfo(e)),h}},d3=dc({opSnippet:dh.dR+` 697 if (abs(x) > 1.) { 698 return NAN; 699 } 700 return asin(x); 701`}),d4={kernelName:W.QKF,backendName:"webgl",kernelFunc:d3},d6=dc({opSnippet:dh.dR+"return log(x + sqrt(x * x + 1.0));"}),d5={kernelName:W.epO,backendName:"webgl",kernelFunc:d6},d8=dc({opSnippet:dh.dR+` 702 return atan(x); 703`}),d7={kernelName:W.TyE,backendName:"webgl",kernelFunc:d8},d9=df({opSnippet:p3+` 704 return atan(a, b); 705`,packedOpSnippet:` 706 vec4 result = atan(a, b); 707 bvec4 isNaNA = isnan(a); 708 bvec4 isNaNB = isnan(b); 709 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 710 `+p8+` 711 return result; 712`}),ce={kernelName:W.lxb,backendName:"webgl",kernelFunc:d9},ct=dc({opSnippet:dh.dR+` 713 if ((x < -1.0) || (x > 1.0)) return NAN;
714return (log(1.0 + x) - log(1.0 - x)) / 2.0;`}),cr={kernelName:W.zP9,backendName:"webgl",kernelFunc:ct};class cn{constructor(e,t,r,n=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&r)throw Error("Cannot compute positions for average pool.");let s=e.filterWidth,i=e.strideHeight,o=e.strideWidth,l=e.dilationHeight,u=e.dilationWidth,h=e.effectiveFilterHeight,p=e.effectiveFilterWidth,d=e.padInfo.top,c=e.padInfo.left;this.outputShape=e.outShape;let f="avg"===t,m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`,y="0.0";if(f||(y="-1.0 / 1e-20"),r){this.userCode=` 715 const ivec2 strides = ivec2(${i}, ${o}); 716 const ivec2 pads = ivec2(${d}, ${c}); 717 718 void main() { 719 ivec4 coords = getOutputCoords(); 720 int batch = coords[0]; 721 int d = coords[3]; 722 723 ivec2 xRCCorner = coords.yz * strides - pads; 724 int xRCorner = xRCCorner.x; 725 int xCCorner = xRCCorner.y; 726 727 // max/min x(?, ?, d) to get y(yR, yC, d). 728 // ? = to be determined 729 float minMaxValue = 0.0; 730 float minMaxValueFound = 0.0; 731 int minMaxPosition = 0; 732 float avgValue = 0.0; 733 734 for (int wR = 0; wR < ${h}; 735 wR += ${l}) { 736 int xR = xRCorner + wR; 737 738 if (xR < 0 || xR >= ${e.inHeight}) { 739 continue; 740 } 741 742 for (int wC = 0; wC < ${p}; 743 wC += ${u}) { 744 int xC = xCCorner + wC; 745 746 if (xC < 0 || xC >= ${e.inWidth}) { 747 continue; 748 } 749 750 float value = getX(batch, xR, xC, d); 751 752 // If a min / max value has already been found, use it. If not, 753 // use the current value. 754 float currMinMaxValue = mix( 755 value, minMaxValue, minMaxValueFound); 756 if (value >= currMinMaxValue) { 757 minMaxValue = value; 758 minMaxValueFound = 1.0; 759 minMaxPosition = ${n?a?m:g:`wR * ${p} + wC`}; 760 } 761 } 762 } 763 setOutput(float(minMaxPosition)); 764 } 765 `;return}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / max(count, 1.0)");let x=4*Math.floor(s/4),v=s%4,w=` 766 if (${f}) { 767 avgValue += dot(values, ones); 768 } else { 769 minMaxValue = max(values, minMaxValue); 770 } 771 `;this.userCode=` 772 const ivec2 strides = ivec2(${i}, ${o}); 773 const ivec2 pads = ivec2(${d}, ${c}); 774 const float initializationValue = ${y}; 775 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 776 777 float count = 0.0; 778 779 float getValue(int batch, int xR, int xC, int d) { 780 if (xC < 0 || xC >= ${e.inWidth}) { 781 return initializationValue; 782 } 783 count += 1.0; 784 return getX(batch, xR, xC, d); 785 } 786 787 void main() { 788 ivec4 coords = getOutputCoords(); 789 int batch = coords[0]; 790 int d = coords[3]; 791 792 ivec2 xRCCorner = coords.yz * strides - pads; 793 int xRCorner = xRCCorner.x; 794 int xCCorner = xRCCorner.y; 795 796 // max/min x(?, ?, d) to get y(yR, yC, d). 797 // ? = to be determined 798 vec4 minMaxValue = vec4(${y}); 799 float avgValue = 0.0; 800 count = 0.0; 801 802 for (int wR = 0; wR < ${h}; 803 wR += ${l}) { 804 int xR = xRCorner + wR; 805 806 if (xR < 0 || xR >= ${e.inHeight}) { 807 continue; 808 } 809 810 for (int wC = 0; wC < ${x}; wC += 4) { 811 int xC = xCCorner + wC * ${u}; 812 813 vec4 values = vec4( 814 getValue(batch, xR, xC, d), 815 getValue(batch, xR, xC + ${u}, d), 816 getValue(batch, xR, xC + 2 * ${u}, d), 817 getValue(batch, xR, xC + 3 * ${u}, d) 818 ); 819 820 ${w} 821 } 822 823 int xC = xCCorner + ${x}; 824 if (${1===v}) { 825 vec4 values = vec4( 826 getValue(batch, xR, xC, d), 827 initializationValue, 828 initializationValue, 829 initializationValue 830 ); 831 832 ${w} 833 } else if (${2===v}) { 834 vec4 values = vec4( 835 getValue(batch, xR, xC, d), 836 getValue(batch, xR, xC + ${u}, d), 837 initializationValue, 838 initializationValue 839 ); 840 841 ${w} 842 } else if (${3===v}) { 843 vec4 values = vec4( 844 getValue(batch, xR, xC, d), 845 getValue(batch, xR, xC + ${u}, d), 846 getValue(batch, xR, xC + 2 * ${u}, d), 847 initializationValue 848 ); 849 850 ${w} 851 } 852 } 853 setOutput(${b}); 854 } 855 `}}class ca{constructor(e,t,r,n=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&r)throw Error("Cannot compute positions for average pool.");let s=e.filterWidth,i=e.strideDepth,o=e.strideHeight,l=e.strideWidth,u=e.dilationDepth,h=e.dilationHeight,p=e.dilationWidth,d=e.effectiveFilterDepth,c=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;let b="avg"===t,x="0.0";if(b||(x="-1.0 / 1e-20"),r){this.userCode=` 856 const ivec3 strides = 857 ivec3(${i}, ${o}, ${l}); 858 const ivec3 pads = ivec3(${m}, ${g}, ${y}); 859 860 void main() { 861 ivec5 coords = getOutputCoords(); 862 int batch = coords.x; 863 int ch = coords.u; 864 865 ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 866 int xDCorner = xCorner.x; 867 int xRCorner = xCorner.y; 868 int xCCorner = xCorner.z; 869 870 // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch). 871 // ? = to be determined 872 float minMaxValue = 0.0; 873 float minMaxValueFound = 0.0; 874 int minMaxPosition = 0; 875 876 for (int wD = 0; wD < ${d}; 877 wD += ${u}) { 878 int xD = xDCorner + wD; 879 880 if (xD < 0 || xD >= ${e.inDepth}) { 881 continue; 882 } 883 884 for (int wR = 0; wR < ${c}; 885 wR += ${h}) { 886 int xR = xRCorner + wR; 887 888 if (xR < 0 || xR >= ${e.inHeight}) { 889 continue; 890 } 891 892 for (int wC = 0; wC < ${f}; 893 wC += ${p}) { 894 int xC = xCCorner + wC; 895 896 if (xC < 0 || xC >= ${e.inWidth}) { 897 continue; 898 } 899 900 float value = getX(batch, xD, xR, xC, ch); 901 902 // If a min / max value has already been found, use it. If not, 903 // use the current value. 904 float currMinMaxValue = mix( 905 value, minMaxValue, minMaxValueFound); 906 if (value >= currMinMaxValue) { 907 minMaxValue = value; 908 minMaxValueFound = 1.0; 909 minMaxPosition = ${n?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${c} * ${f} + 910 wR * ${f} + wC`}; 911 } 912 } 913 } 914 } 915 setOutput(float(minMaxPosition)); 916 } 917 `;return}let v=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(v="avgValue / max(count, 1.0)");let w=4*Math.floor(s/4),T=s%4,S=` 918 if (${b}) { 919 avgValue += dot(values, ones); 920 } else { 921 minMaxValue = max(values, minMaxValue); 922 } 923 `;this.userCode=` 924 const ivec3 strides = 925 ivec3(${i}, ${o}, ${l}); 926 const ivec3 pads = ivec3(${m}, ${g}, ${y}); 927 const float initializationValue = ${x}; 928 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 929 930 float count = 0.0; 931 932 float getValue(int batch, int xD, int xR, int xC, int ch) { 933 if (xC < 0 || xC >= ${e.inWidth}) { 934 return initializationValue; 935 } 936 count += 1.0; 937 return getX(batch, xD, xR, xC, ch); 938 } 939 940 void main() { 941 ivec5 coords = getOutputCoords(); 942 int batch = coords.x; 943 int ch = coords.u; 944 945 ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 946 int xDCorner = xCorner.x; 947 int xRCorner = xCorner.y; 948 int xCCorner = xCorner.z; 949 950 // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch). 951 // ? = to be determined 952 vec4 minMaxValue = vec4(${x}); 953 float avgValue = 0.0; 954 count = 0.0; 955 956 for (int wD = 0; wD < ${d}; 957 wD += ${u}) { 958 int xD = xDCorner + wD; 959 960 if (xD < 0 || xD >= ${e.inDepth}) { 961 continue; 962 } 963 964 for (int wR = 0; wR < ${c}; 965 wR += ${h}) { 966 int xR = xRCorner + wR; 967 968 if (xR < 0 || xR >= ${e.inHeight}) { 969 continue; 970 } 971 972 for (int wC = 0; wC < ${w}; wC += 4) { 973 int xC = xCCorner + wC * ${p}; 974 975 vec4 values = vec4( 976 getValue(batch, xD, xR, xC, ch), 977 getValue(batch, xD, xR, xC + ${p}, ch), 978 getValue(batch, xD, xR, xC + 2 * ${p}, ch), 979 getValue(batch, xD, xR, xC + 3 * ${p}, ch) 980 ); 981 982 ${S} 983 } 984 985 int xC = xCCorner + ${w}; 986 if (${1===T}) { 987 vec4 values = vec4( 988 getValue(batch, xD, xR, xC, ch), 989 initializationValue, 990 initializationValue, 991 initializationValue 992 ); 993 994 ${S} 995 } else if (${2===T}) { 996 vec4 values = vec4( 997 getValue(batch, xD, xR, xC, ch), 998 getValue(batch, xD, xR, xC + ${p}, ch), 999 initializationValue, 1000 initializationValue 1001 ); 1002 1003 ${S} 1004 } else if (${3===T}) { 1005 vec4 values = vec4( 1006 getValue(batch, xD, xR, xC, ch), 1007 getValue(batch, xD, xR, xC + ${p}, ch), 1008 getValue(batch, xD, xR, xC + 2 * ${p}, ch), 1009 initializationValue 1010 ); 1011 1012 ${S} 1013 } 1014 } 1015 } 1016 setOutput(${v}); 1017 } 1018 `}}let cs={kernelName:W.ho8,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t;(0,pq.assertNotComplex)(a,"avgPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=n;W.ZSL.assert(W.C0T.eitherStridesOrDilationsAreOne(i,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '1'`);let u=W.C0T.computePool2DInfo(a.shape,s,i,1,o,l);
1018if(1===u.filterWidth&&1===u.filterHeight&&W.ZSL.arraysEqual(u.inShape,u.outShape))return p9({inputs:{x:a},backend:r});let h=new cn(u,"avg",!1);return r.runWebGLProgram(h,[a],"float32")}},ci={kernelName:W.cS,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:u}=n,h=new ca(W.C0T.computePool3DInfo(a.shape,s,i,[1,1,1],o,l,u),"avg",!1);return r.runWebGLProgram(h,[a],"float32")}};class co{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterHeight,r=e.filterWidth,n=e.strideHeight,a=e.strideWidth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterHeight,l=e.effectiveFilterWidth,u=o-1-e.padInfo.top,h=l-1-e.padInfo.left;this.userCode=` 1019 const ivec2 pads = ivec2(${u}, ${h}); 1020 const float avgMultiplier = float(${1/(t*r)}); 1021 1022 void main() { 1023 ivec4 coords = getOutputCoords(); 1024 int b = coords[0]; 1025 int d = coords[3]; 1026 1027 ivec2 dyRCCorner = coords.yz - pads; 1028 int dyRCorner = dyRCCorner.x; 1029 int dyCCorner = dyRCCorner.y; 1030 1031 // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). 1032 // ? = to be determined. : = across all values in that axis. 1033 float dotProd = 0.0; 1034 for (int wR = 0; wR < ${o}; 1035 wR += ${s}) { 1036 float dyR = float(dyRCorner + wR) / ${n}.0; 1037 1038 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 1039 continue; 1040 } 1041 int idyR = int(dyR); 1042 1043 for (int wC = 0; wC < ${l}; 1044 wC+= ${i}) { 1045 float dyC = float(dyCCorner + wC) / ${a}.0; 1046 1047 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 1048 fract(dyC) > 0.0) { 1049 continue; 1050 } 1051 int idyC = int(dyC); 1052 1053 float dyValue = getDy(b, idyR, idyC, d); 1054 1055 dotProd += dyValue * avgMultiplier; 1056 } 1057 } 1058 setOutput(dotProd); 1059 } 1060 `}}class cl{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterDepth,r=e.filterHeight,n=e.filterWidth,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,h=e.effectiveFilterDepth,p=e.effectiveFilterHeight,d=e.effectiveFilterWidth,c=h-1-e.padInfo.front,f=p-1-e.padInfo.top,m=d-1-e.padInfo.left;this.userCode=` 1061 const ivec3 pads = ivec3(${c}, ${f}, ${m}); 1062 const float avgMultiplier = float(${1/(t*r*n)}); 1063 1064 void main() { 1065 ivec5 coords = getOutputCoords(); 1066 int batch = coords.x; 1067 int ch = coords.u; 1068 1069 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 1070 int dyDCorner = dyCorner.x; 1071 int dyRCorner = dyCorner.y; 1072 int dyCCorner = dyCorner.z; 1073 1074 // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get 1075 // dx(xD, xR, xC, ch). 1076 // ? = to be determined. : = across all values in that axis. 1077 float dotProd = 0.0; 1078 1079 for (int wD = 0; wD < ${h}; 1080 wD += ${o}) { 1081 float dyD = float(dyDCorner + wD) / ${a}.0; 1082 1083 if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) { 1084 continue; 1085 } 1086 int idyD = int(dyD); 1087 1088 for (int wR = 0; wR < ${p}; 1089 wR += ${l}) { 1090 float dyR = float(dyRCorner + wR) / ${s}.0; 1091 1092 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 1093 fract(dyR) > 0.0) { 1094 continue; 1095 } 1096 int idyR = int(dyR); 1097 1098 for (int wC = 0; wC < ${d}; 1099 wC += ${u}) { 1100 float dyC = float(dyCCorner + wC) / ${i}.0; 1101 1102 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 1103 fract(dyC) > 0.0) { 1104 continue; 1105 } 1106 int idyC = int(dyC); 1107 1108 float dyValue = getDy(batch, idyD, idyR, idyC, ch); 1109 1110 dotProd += dyValue * avgMultiplier; 1111 } 1112 } 1113 } 1114 setOutput(dotProd); 1115 } 1116 `}}let cu={kernelName:W.wwC,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=n,h=new cl(W.C0T.computePool3DInfo(s.shape,i,o,[1,1,1],l,u));return r.runWebGLProgram(h,[a],s.dtype)}},ch={kernelName:W.VCH,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t;(0,pq.assertNotComplex)([a,s],"avgPoolGrad");let{filterSize:i,strides:o,pad:l}=n,u=new co(W.C0T.computePool2DInfo(s.shape,i,o,1,l));return r.runWebGLProgram(u,[a],s.dtype)}},cp={kernelName:W.jAQ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{a,b:s}=t,{transposeA:i,transposeB:o}=n;return dL({a,b:s,transposeA:i,transposeB:o,backend:r})}};class cd{constructor(e,t,r,n,a,s){this.outputShape=[],this.variableNames=["x","mean","variance"],W.C0T.assertAndGetBroadcastShape(e,t),W.C0T.assertAndGetBroadcastShape(e,r);let i="0.0";null!=n&&(W.C0T.assertAndGetBroadcastShape(e,n),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let o="1.0";null!=a&&(W.C0T.assertAndGetBroadcastShape(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` 1117 void main() { 1118 float x = getXAtOutCoords(); 1119 float mean = getMeanAtOutCoords(); 1120 float variance = getVarianceAtOutCoords(); 1121 float offset = ${i}; 1122 float scale = ${o}; 1123 float inv = scale * inversesqrt(variance + float(${s})); 1124 setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1))); 1125 } 1126 `}}class cc{constructor(e,t,r,n,a,s){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],W.C0T.assertAndGetBroadcastShape(e,t),W.C0T.assertAndGetBroadcastShape(e,r);let i="vec4(0.0)";null!=n&&(W.C0T.assertAndGetBroadcastShape(e,n),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let o="vec4(1.0)";null!=a&&(W.C0T.assertAndGetBroadcastShape(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` 1127 void main() { 1128 vec4 offset = ${i}; 1129 vec4 scale = ${o}; 1130 1131 vec4 x = getXAtOutCoords(); 1132 vec4 mean = getMeanAtOutCoords(); 1133 vec4 variance = getVarianceAtOutCoords(); 1134 1135 vec4 inv = scale * inversesqrt(variance + vec4(${s})); 1136 1137 setOutput((x - mean) * inv + offset); 1138 } 1139 `}}
1139let cf={kernelName:W.i5R,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n,mean:a,variance:s,offset:i,scale:o}=e;W.ZSL.assert(a.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),W.ZSL.assert(null==i||a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),W.ZSL.assert(null==o||a.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=r;null==l&&(l=.001);let u=[n,a,s],h=null;null!=i&&(h=i.shape,u.push(i));let p=null;null!=o&&(p=o.shape,u.push(o));let d=(0,W._K2)().getBool("WEBGL_PACK_NORMALIZATION")?new cc(n.shape,a.shape,s.shape,h,p,l):new cd(n.shape,a.shape,s.shape,h,p,l);return t.runWebGLProgram(d,u,u[0].dtype)}};class cm{constructor(e){let t;this.variableNames=["source"],this.outputShape=e,this.rank=e.length;let r=(0,p5.bf)(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let n=function(e){if(1===e)return"sourceLoc";if(e<=6)return cg.slice(0,e).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank),a=e.map((e,t)=>`sourceLoc.${cg[t]} = start[${t}] + coords.${cg[t]};`);t=` 1140 ${r} sourceLoc; 1141 ${r} coords = getOutputCoords(); 1142 ${a.join("\n")} 1143 `,this.userCode=` 1144 void main() { 1145 ${t} 1146 setOutput(getSource(${n})); 1147 } 1148 `}}let cg=["x","y","z","w","u","v"];class cy{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let t=(0,p5.bf)(this.rank),r=(0,p6.Jp)("coords",this.rank),n=(0,p6.Jp)("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${n.slice(-2).join()})`,s=`getChannel(getSource(${n.join()}), ${a})`,i=` 1149 result.x = ${s}; 1150 if (++${r[this.rank-1]} < ${e[this.rank-1]}) { 1151 ++${n[this.rank-1]}; 1152 result.y = ${s}; 1153 --${n[this.rank-1]}; 1154 } 1155 `,o=1===this.rank?"":` 1156 --${r[this.rank-1]}; 1157 if (++${r[this.rank-2]} < ${e[this.rank-2]}) { 1158 ++${n[this.rank-2]}; 1159 result.z = ${s}; 1160 if (++${r[this.rank-1]} < ${e[this.rank-1]}) { 1161 ++${n[this.rank-1]}; 1162 result.w = ${s}; 1163 } 1164 } 1165 `,l=this.rank<=4?`sourceLoc = coords + 1166 ${t}(${e.map((e,t)=>`start[${t}]`).join()});`:e.map((e,t)=>`${n[t]} = ${r[t]} + start[${t}];`).join("\n");this.userCode=` 1167 void main() { 1168 ${t} coords = getOutputCoords(); 1169 ${t} sourceLoc; 1170 ${l} 1171 vec4 result = vec4(0.); 1172 ${i} 1173 ${o} 1174 setOutput(result); 1175 } 1176 `}}function cb(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{begin:s,size:i}=n,[o,l]=W.Kro.parseSliceParams(a,s,i);if(W.Kro.assertParamsValid(a,o,l),0===W.ZSL.sizeFromShape(l))return r.makeTensorInfo(l,a.dtype,[]);if(r.shouldExecuteOnCPU([a])||"string"===a.dtype){let e=r.texData.get(a.dataId),t=(0,dx.J3)(e.values,o,l,a.shape,a.dtype);return r.makeTensorInfo(l,a.dtype,t)}let{isPacked:u}=r.texData.get(a.dataId),h=W.Kro.isSliceContinous(a.shape,o,l);if(u||!h){let e=(0,W._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new cy(l):new cm(l),t=[o];return r.runWebGLProgram(e,[a],a.dtype,t)}return r.uploadToGPU(a.dataId),function(e,t,r,n){let a=n.texData.get(e.dataId),s=n.makeTensorInfo(r,e.dtype),i=n.texData.get(s.dataId);Object.assign(i,a),i.refCount=1,i.shape=r,i.dtype=e.dtype;let o=W.Kro.computeFlatOffset(t,W.ZSL.computeStrides(e.shape));a.slice&&(o+=a.slice.flatOffset),i.slice={flatOffset:o,origDataId:a.slice&&a.slice.origDataId||e.dataId};let l=n.dataRefCount.get(i.slice.origDataId)||1;return n.dataRefCount.set(i.slice.origDataId,l+1),s}(a,o,l,r)}let cx={kernelName:W.JiE,backendName:"webgl",kernelFunc:cb},cv={kernelName:W.Ik2,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockShape:s,crops:i}=n;W.ZSL.assert(a.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");let o=s.reduce((e,t)=>
1176e*t),l=W.C0T.getReshaped(a.shape,s,o),u=W.C0T.getPermuted(l.length,s.length),h=W.C0T.getReshapedPermuted(a.shape,s,o),p=W.C0T.getSliceBeginCoords(i,s.length),d=W.C0T.getSliceSize(h,i,s.length),c=[],f=dN({inputs:{x:a},backend:r,attrs:{shape:l}}),m=dD({inputs:{x:f},backend:r,attrs:{perm:u}}),g=dN({inputs:{x:m},backend:r,attrs:{shape:h}}),y=cb({inputs:{x:g},backend:r,attrs:{begin:p,size:d}});return c.push(f),c.push(m),c.push(g),c.forEach(e=>r.disposeIntermediateTensorInfo(e)),y}},cw={kernelName:W.N4F,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,weights:s}=t,{size:i}=n,o=r.readSync(a.dataId),l=r.readSync(s.dataId),u=(0,dx.jm)(o,l,s.dtype,s.shape,i);return r.makeTensorInfo([i],s.dtype,u)}},cT=` 1177 int r = int(a.r) & int(b.r); 1178 int g = int(a.g) & int(b.g); 1179 int rb = int(a.b) & int(b.b); 1180 int ra = int(a.a) & int(b.a); 1181 return vec4(r, g, rb, ra); 1182`,cS=` 1183 return float(int(a.r) & int(b.r)); 1184`,cN={kernelName:W.HNs,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n}=e,{a,b:s}=r,i=(0,W._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS"),o=(0,W._K2)().getNumber("WEBGL_VERSION");if(n.shouldExecuteOnCPU([a,s])||1===o){let e=n.texData.get(a.dataId).values,t=n.texData.get(s.dataId).values,[r,i]=(0,dx.PA)(a.shape,s.shape,e,t,a.dtype),o=n.makeTensorInfo(i,a.dtype);return n.texData.get(o.dataId).values=r,o}return t=i?new p7(cT,a.shape,s.shape,!1):new p4(cS,a.shape,s.shape),n.runWebGLProgram(t,[a,s],a.dtype)}},ck={kernelName:W.vj7,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{s0:n,s1:a}=t,s=r.readSync(n.dataId),i=r.readSync(a.dataId),o=W.C0T.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return r.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},cI=df({opSnippet:"return float(a != b);",cpuKernelImpl:dx.ad,dtype:"bool"}),cC={kernelName:W.ylV,backendName:"webgl",kernelFunc:cI};function cE(e){let{inputs:t,backend:r}=e,{input:n}=t;return p9({inputs:{x:r.texData.get(n.dataId).complexTensorInfos.real},backend:r})}let cA={kernelName:W.LRy,backendName:"webgl",kernelFunc:cE},c$={kernelName:W.KXH,backendName:"webgl",kernelFunc:function e(t){let{inputs:r,backend:n,attrs:a}=t,{x:s}=r,{dtype:i}=a;if("complex64"===i){if("complex64"===s.dtype)return p9({inputs:{x:s},backend:n});let t=W.Ul9(s.shape),r=e({inputs:{x:s},backend:n,attrs:{dtype:"float32"}}),a=dt({inputs:{real:r,imag:t},backend:n});return t.dispose(),n.disposeIntermediateTensorInfo(r),a}if("complex64"===s.dtype){let t=cE({inputs:{input:s},backend:n}),r=e({inputs:{x:t},backend:n,attrs:{dtype:i}});return n.disposeIntermediateTensorInfo(t),r}if(!W.ZSL.hasEncodingLoss(s.dtype,i)){let e=p9({inputs:{x:s},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:i}}if(n.shouldExecuteOnCPU([s])){let e=n.texData.get(s.dataId).values,[t,r,a]=(0,dx.Kf)(e,s.shape,s.dtype,i);return n.makeTensorInfo(t,r,a)}if("int32"===i){let e=new dh.hE(s.shape,"return float(int(x));"),t=n.runWebGLProgram(e,[s],"int32");return{dataId:t.dataId,shape:t.shape,dtype:t.dtype}}if("bool"===i){let e=n.makeTensorInfo([],"bool",W.ZSL.getTypedArrayFromDType("bool",1)),t=cI({inputs:{a:s,b:e},backend:n});return n.disposeIntermediateTensorInfo(e),t}throw Error(`Error in Cast: failed to cast ${s.dtype} to ${i}`)}},cF="return ceil(x);",cR=dc({opSnippet:cF,packedOpSnippet:cF,cpuKernelImpl:dx.Md}),c_={kernelName:W.QDP,backendName:"webgl",kernelFunc:cR};class cD{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` 1185 1186 void main() { 1187 float value = getAAtOutCoords(); 1188 if (isnan(value)) { 1189 setOutput(value); 1190 return; 1191 } 1192 1193 setOutput(clamp(value, minVal, maxVal)); 1194 } 1195 `}}class cO{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` 1196 void main() { 1197 vec4 value = getAAtOutCoords(); 1198 1199 if (any(isnan(value))) { 1200 setOutput(value); 1201 return; 1202 } 1203 1204 setOutput(clamp(value, vec4(minVal), vec4(maxVal))); 1205 } 1206 `}}let cL={kernelName:W.vaV,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{clipValueMin:i,clipValueMax:o}=a;return t=(0,W._K2)().getBool("WEBGL_PACK_CLIP")?new cO(s.shape):new cD(s.shape),n.runWebGLProgram(t,[s],s.dtype,[[i],[o]])}};class cM{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=` 1207 void main() { 1208 float re = abs(getRealAtOutCoords()); 1209 float im = abs(getImagAtOutCoords()); 1210 float mx = max(re, im); 1211 1212 // sadly the length function in glsl is not underflow-safe 1213 // (at least not on Intel GPUs). So the safe solution is 1214 // to ensure underflow-safety in all cases. 1215 setOutput( 1216 mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx)) 1217 ); 1218 } 1219 `}}function cP(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}let cz={kernelName:W.$zE,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n}=t,a=r.texData.get(n.dataId),s=new cM(n.shape),i=[cP(n,a.complexTensorInfos.real),cP(n,a.complexTensorInfos.imag)];return r.runWebGLProgram(s,i,i[0].dtype)}};
1219class cB{constructor(e){this.outputShape=[],this.outputShape=W.C0T.computeOutShape(e,1),this.variableNames=e.map((e,t)=>`T${t}`);let t=Array(e.length-1);t[0]=e[0][1];for(let r=1;r<t.length;r++)t[r]=t[r-1]+e[r][1];let r=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let e=1;e<t.length;e++){let n=t[e-1];r.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${n}));`)}let n=t.length,a=t[t.length-1];r.push(`else setOutput(getT${n}(yR, yC-${a}));`),this.userCode=` 1220 void main() { 1221 ivec2 coords = getOutputCoords(); 1222 int yR = coords.x; 1223 int yC = coords.y; 1224 1225 ${r.join("\n ")} 1226 } 1227 `}}class cW{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=W.C0T.computeOutShape(e,t);let r=this.outputShape,n=r.length,a=(0,p5.bf)(n),s=(0,p6.Jp)("coords",n),i=["x","y","z","w","u","v"].slice(0,n);this.variableNames=e.map((e,t)=>`T${t}`);let o=Array(e.length-1);o[0]=e[0][t];for(let r=1;r<o.length;r++)o[r]=o[r-1]+e[r][t];let l=i[t],u=i.slice(-2),h=i.join(),p=`if (${l} < ${o[0]}) { 1228 return getChannel( 1229 getT0(${h}), vec2(${u.join()})); 1230 }`;for(let e=1;e<o.length;e++){let t=o[e-1];p+=` 1231 if (${l} < ${o[e]} && ${l} >= ${o[e-1]}) { 1232 return getChannel( 1233 getT${e}(${cV(i,l,t)}), 1234 vec2(${cV(u,l,t)})); 1235 }`}let d=o.length,c=o[o.length-1];p+=` 1236 return getChannel( 1237 getT${d}(${cV(i,l,c)}), 1238 vec2(${cV(u,l,c)}));`,this.userCode=` 1239 float getValue(${i.map(e=>"int "+e)}) { 1240 ${p} 1241 } 1242 1243 void main() { 1244 ${a} coords = getOutputCoords(); 1245 vec4 result = vec4(getValue(${s}), 0., 0., 0.); 1246 1247 ${s[n-1]} = ${s[n-1]} + 1; 1248 if (${s[n-1]} < ${r[n-1]}) { 1249 result.g = getValue(${s}); 1250 } 1251 1252 ${s[n-2]} = ${s[n-2]} + 1; 1253 if (${s[n-2]} < ${r[n-2]}) { 1254 result.a = getValue(${s}); 1255 } 1256 1257 ${s[n-1]} = ${s[n-1]} - 1; 1258 if (${s[n-2]} < ${r[n-2]} && 1259 ${s[n-1]} < ${r[n-1]}) { 1260 result.b = getValue(${s}); 1261 } 1262 setOutput(result); 1263 } 1264 `}}function cV(e,t,r){let n=e.indexOf(t);return e.map((e,t)=>t===n?`${e} - ${r}`:e).join()}function cU(e){let{inputs:t,backend:r}=e,{input:n}=t;return p9({inputs:{x:r.texData.get(n.dataId).complexTensorInfos.imag},backend:r})}let cG={kernelName:W.dv8,backendName:"webgl",kernelFunc:cU};function cZ(e){let{inputs:t,backend:r,attrs:n}=e,{axis:a}=n,s=W.ZSL.parseAxisParam(a,t[0].shape)[0],i=t.map(e=>e.shape);W.C0T.assertParamsConsistent(i,s);let o=W.C0T.computeOutShape(t.map(e=>e.shape),s);if(0===W.ZSL.sizeFromShape(o))return r.makeTensorInfo(o,t[0].dtype,[]);let l=t.filter(e=>W.ZSL.sizeFromShape(e.shape)>0);return 1===l.length?p9({inputs:{x:l[0]},backend:r}):function e(t,r,n){let a=t[0].dtype;if("complex64"===a){let a=t.map(e=>cE({inputs:{input:e},backend:n})),s=t.map(e=>cU({inputs:{input:e},backend:n})),i=e(a,r,n),o=e(s,r,n),l=dt({inputs:{real:i,imag:o},backend:n});return a.forEach(e=>
1264n.disposeIntermediateTensorInfo(e)),s.forEach(e=>n.disposeIntermediateTensorInfo(e)),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}let s=n.shouldExecuteOnCPU(t);if("string"===a&&(s=!0),s){let e=t.map(e=>{let t=W.ZSL.sizeFromShape(e.shape.slice(r));return dN({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})}),s=e.map(e=>({vals:n.readSync(e.dataId),shape:e.shape})),i=W.C0T.computeOutShape(e.map(e=>e.shape),1),o=1===e[0].shape[0],l=(0,dx.dv)(s,i,a,o),u=W.C0T.computeOutShape(t.map(e=>e.shape),r),h=n.makeTensorInfo(u,a,l);return e.forEach(e=>n.disposeIntermediateTensorInfo(e)),h}let i=t.filter(e=>W.ZSL.sizeFromShape(e.shape)>0),o=(0,W._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&i[0].shape.length>1;if(1===i.length){let e=o?new dh.hE(t[0].shape,dh.UC):new dp.rf(t[0].shape,dh.UC);return n.runWebGLProgram(e,t,a)}let l=(0,W._K2)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(i.length>l){let t=[];for(let a=0;a<i.length;a+=l){let s=i.slice(a,a+l);t.push(e(s,r,n))}let a=e(t,r,n);for(let e of t)n.disposeIntermediateTensorInfo(e);return a}if(o){let e=new cW(i.map(e=>e.shape),r);return n.runWebGLProgram(e,i,a)}let{tensors2D:u,outShape:h}=function(e,t,r){let n=W.C0T.computeOutShape(e.map(e=>e.shape),t);return{tensors2D:e.map(e=>dN({inputs:{x:e},attrs:{shape:[-1,W.ZSL.sizeFromShape(e.shape.slice(t))]},backend:r})),outShape:n}}(i,r,n),p=new cB(u.map(e=>e.shape)),d=n.runWebGLProgram(p,u,a);u.forEach(e=>n.disposeIntermediateTensorInfo(e));let c=dN({inputs:{x:d},attrs:{shape:h},backend:n});return n.disposeIntermediateTensorInfo(d),c}(l,s,r)}let cj={kernelName:W.$dB,backendName:"webgl",kernelFunc:cZ};class cK{constructor(e,t=!1,r=null,n=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let s=e.padInfo.top,i=e.padInfo.left,o=e.strideHeight,l=e.strideWidth,u=e.dilationHeight,h=e.dilationWidth,p=e.filterHeight,d=e.filterWidth,c=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g="",y="";r&&(g=n?`float activation(float a) { 1265 float b = getPreluActivationWeightsAtOutCoords(); 1266 ${r} 1267 }`:a?`float activation(float a) { 1268 float b = getLeakyreluAlphaAtOutCoords(); 1269 ${r} 1270 }`:` 1271 float activation(float x) { 1272 ${r} 1273 } 1274 `,y="result = activation(result);"),t&&this.variableNames.push("bias"),n&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 1275 ${g} 1276 1277 const ivec2 strides = ivec2(${o}, ${l}); 1278 const ivec2 pads = ivec2(${s}, ${i}); 1279 1280 void main() { 1281 ivec4 coords = getOutputCoords(); 1282 int batch = coords[0]; 1283 int d2 = coords[${m?3:1}]; 1284 1285 ivec2 xRCCorner = 1286 ivec2(coords[${m?1:2}], coords[${m?2:3}]) * strides - pads; 1287 int xRCorner = xRCCorner.x; 1288 int xCCorner = xRCCorner.y; 1289 1290 // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2). 1291 // ? = to be determined. : = across all values in that axis. 1292 float dotProd = 0.0; 1293 for (int wR = 0; wR < ${p}; wR++) { 1294 int xR = xRCorner + wR * ${u}; 1295 1296 if (xR < 0 || xR >= ${e.inHeight}) { 1297 continue; 1298 } 1299 1300 for (int wC = 0; wC < ${d}; wC++) { 1301 int xC = xCCorner + wC * ${h}; 1302 1303 if (xC < 0 || xC >= ${e.inWidth}) { 1304 continue; 1305 } 1306 1307 for (int d1 = 0; d1 < ${c}; d1 += 4) { 1308 vec4 wValues = vec4( 1309 getW(wR, wC, d1, d2), 1310 getW(wR, wC, d1 + 1, d2), 1311 getW(wR, wC, d1 + 2, d2), 1312 getW(wR, wC, d1 + 3, d2) 1313 ); 1314 1315 if (${m}) { 1316 vec4 xValues = vec4( 1317 getX(batch, xR, xC, d1), 1318 getX(batch, xR, xC, d1 + 1), 1319 getX(batch, xR, xC, d1 + 2), 1320 getX(batch, xR, xC, d1 + 3) 1321 ); 1322 dotProd += dot(xValues, wValues); 1323 } else { 1324 vec4 xValues = vec4( 1325 getX(batch, d1, xR, xC), 1326 getX(batch, d1 + 1, xR, xC), 1327 getX(batch, d1 + 2, xR, xC), 1328 getX(batch, d1 + 3, xR, xC) 1329 ); 1330 dotProd += dot(xValues, wValues); 1331 } 1332 } 1333 1334 if (${1===f}) { 1335 1336 if (${m}) { 1337 dotProd += 1338 getX(batch, xR, xC, ${c}) * 1339 getW(wR, wC, ${c}, d2); 1340 } else { 1341 dotProd += 1342 getX(batch, ${c}, xR, xC) * 1343 getW(wR, wC, ${c}, d2); 1344 } 1345 1346 } else if (${2===f}) { 1347 vec2 wValues = vec2( 1348 getW(wR, wC, ${c}, d2), 1349 getW(wR, wC, ${c} + 1, d2) 1350 ); 1351 1352 if (${m}) { 1353 vec2 xValues = vec2( 1354 getX(batch, xR, xC, ${c}), 1355 getX(batch, xR, xC, ${c} + 1) 1356 ); 1357 dotProd += dot(xValues, wValues); 1358 } else { 1359 vec2 xValues = vec2( 1360 getX(batch, ${c}, xR, xC), 1361 getX(batch, ${c} + 1, xR, xC) 1362 ); 1363 dotProd += dot(xValues, wValues); 1364 } 1365 1366 } else if (${3===f}) { 1367 vec3 wValues = vec3( 1368 getW(wR, wC, ${c}, d2), 1369 getW(wR, wC, ${c} + 1, d2), 1370 getW(wR, wC, ${c} + 2, d2) 1371 ); 1372 1373 if (${m}) { 1374 vec3 xValues = vec3( 1375 getX(batch, xR, xC, ${c}), 1376 getX(batch, xR, xC, ${c} + 1), 1377 getX(batch, xR, xC, ${c} + 2) 1378 ); 1379 dotProd += dot(xValues, wValues); 1380 } else { 1381 vec3 xValues = vec3( 1382 getX(batch, ${c}, xR, xC), 1383 getX(batch, ${c} + 1, xR, xC), 1384 getX(batch, ${c} + 2, xR, xC) 1385 ); 1386 dotProd += dot(xValues, wValues); 1387 } 1388 1389 } 1390 } 1391 } 1392 1393 float result = dotProd; 1394 ${t?"result += getBiasAtOutCoords();":""} 1395 ${y} 1396 setOutput(result); 1397 } 1398 `}}class cH{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let t=e.padInfo.front,r=e.padInfo.top,n=e.padInfo.left,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,h=e.filterDepth,p=e.filterHeight,d=e.filterWidth,c=4*Math.floor(e.inChannels/4),f=e.inChannels%4;this.userCode=` 1399 const ivec3 strides = ivec3(${a}, ${s}, ${i}); 1400 const ivec3 pads = ivec3(${t}, ${r}, ${n}); 1401 1402 void main() { 1403 ivec5 coords = getOutputCoords(); 1404 int batch = coords.x; 1405 int d2 = coords.u; 1406 1407 ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 1408 int xFCorner = xFRCCorner.x; 1409 int xRCorner = xFRCCorner.y; 1410 int xCCorner = xFRCCorner.z; 1411 1412 // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get 1413 // y(yF, yR, yC, d2). ? = to be determined. : = across all 1414 // values in that axis. 1415 float dotProd = 0.0; 1416 for (int wF = 0; wF < ${h}; wF++) { 1417 int xF = xFCorner + wF * ${o}; 1418 1419 if (xF < 0 || xF >= ${e.inDepth}) { 1420 continue; 1421 } 1422 1423 for (int wR = 0; wR < ${p}; wR++) { 1424 int xR = xRCorner + wR * ${l}; 1425 1426 if (xR < 0 || xR >= ${e.inHeight}) { 1427 continue; 1428 } 1429 1430 for (int wC = 0; wC < ${d}; wC++) { 1431 int xC = xCCorner + wC * ${u}; 1432 1433 if (xC < 0 || xC >= ${e.inWidth}) { 1434 continue; 1435 } 1436 1437 for (int d1 = 0; d1 < ${c}; d1 += 4) { 1438 vec4 xValues = vec4( 1439 getX(batch, xF, xR, xC, d1), 1440 getX(batch, xF, xR, xC, d1 + 1), 1441 getX(batch, xF, xR, xC, d1 + 2), 1442 getX(batch, xF, xR, xC, d1 + 3) 1443 ); 1444 vec4 wValues = vec4( 1445 getW(wF, wR, wC, d1, d2), 1446 getW(wF, wR, wC, d1 + 1, d2), 1447 getW(wF, wR, wC, d1 + 2, d2), 1448 getW(wF, wR, wC, d1 + 3, d2) 1449 ); 1450 1451 dotProd += dot(xValues, wValues); 1452 } 1453 1454 if (${1===f}) { 1455 dotProd += 1456 getX(batch, xF, xR, xC, ${c}) * 1457 getW(wF, wR, wC, ${c}, d2); 1458 } else if (${2===f}) { 1459 vec2 xValues = vec2( 1460 getX(batch, xF, xR, xC, ${c}), 1461 getX(batch, xF, xR, xC, ${c} + 1) 1462 ); 1463 vec2 wValues = vec2( 1464 getW(wF, wR, wC, ${c}, d2), 1465 getW(wF, wR, wC, ${c} + 1, d2) 1466 ); 1467 dotProd += dot(xValues, wValues); 1468 } else if (${3===f}) { 1469 vec3 xValues = vec3( 1470 getX(batch, xF, xR, xC, ${c}), 1471 getX(batch, xF, xR, xC, ${c} + 1), 1472 getX(batch, xF, xR, xC, ${c} + 2) 1473 ); 1474 vec3 wValues = vec3( 1475 getW(wF, wR, wC, ${c}, d2), 1476 getW(wF, wR, wC, ${c} + 1, d2), 1477 getW(wF, wR, wC, ${c} + 2, d2) 1478 ); 1479 dotProd += dot(xValues, wValues); 1480 } 1481 } 1482 } 1483 } 1484 setOutput(dotProd); 1485 } 1486 `}}class cY{constructor(e,t=!1,r=null,n=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=(0,p2.ik)(this.outputShape.length);let s=e.padInfo.left,i=e.strideWidth,o=e.dilationWidth,l=e.filterHeight,u=e.filterWidth,h=` 1487 int xR; int xC; int xCOffset; 1488 vec4 wTexel; vec4 previous; vec4 final;`;for(let e=0;e<u;e++)h+=` 1489 vec4 xTexelC${2*e}; 1490 int xTexelC${2*e}Ready; 1491 vec4 xTexelC${2*e+1}; 1492 int xTexelC${2*e+1}Ready; 1493 vec4 xC${e};`;h+=` 1494 for (int r = 0; r < ${l}; r++) { 1495 for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) { 1496 `;
1496for(let e=0;e<u;e++)h+=` 1497 xTexelC${2*e} = vec4(0.0); 1498 xTexelC${2*e}Ready = 0; 1499 xTexelC${2*e+1} = vec4(0.0); 1500 xTexelC${2*e+1}Ready = 0; 1501 xC${e} = vec4(0.0);`;h+=` 1502 xR = xRCorner + r * dilations[0]; 1503 if (xR >=0 && xR < inDims[0]) { 1504 `;for(let t=0;t<(u+1)/2;t++){let r=2*t;if(h+=` 1505 xC = xCCorner + ${r*o}; 1506 `,1===i){if(r<u&&(s%2==1?(h+=` 1507 xCOffset = xC + 1; 1508 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r}Ready == 0) { 1509 xTexelC${r} = getX(batch, xR, xCOffset, d1); 1510 1511 // Need to manually clear unused channels in case 1512 // we're reading from recycled texture. 1513 if (xCOffset + 1 >= inDims[1]) { 1514 xTexelC${r}.zw = vec2(0.0); 1515 } 1516 xTexelC${r}Ready = 1; 1517 } 1518 `,1===o&&r>0?h+=` 1519 xC${r} = vec4(xTexelC${r-2}.zw, xTexelC${r}.xy); 1520 `:h+=` 1521 xCOffset = xC + 1 - 2; 1522 1523 if (xCOffset >= 0 && xCOffset < inDims[1]) { 1524 previous = getX(batch, xR, xCOffset, d1); 1525 1526 // Need to manually clear unused channels in case 1527 // we're reading from recycled texture. 1528 if (xCOffset + 1 >= inDims[1]) { 1529 previous.zw = vec2(0.0); 1530 } 1531 1532 xC${r} = vec4(previous.zw, xTexelC${r}.xy); 1533 } else { 1534 xC${r} = vec4(0.0, 0.0, xTexelC${r}.xy); 1535 } 1536 `):h+=` 1537 if (xC >= 0 && xC < inDims[1] && xTexelC${r}Ready == 0) { 1538 xTexelC${r} = getX(batch, xR, xC, d1); 1539 if (xC + 1 >= inDims[1]) { 1540 xTexelC${r}.zw = vec2(0.0); 1541 } 1542 xTexelC${r}Ready = 1; 1543 } 1544 1545 xC${r} = xTexelC${r}; 1546 `,r+1<u)){let e=s%2==0?W.ZSL.nearestLargerEven(o):o;o%2==0&&s%2==1||o%2!=0&&s%2!=1?(h+=` 1547 xCOffset = xC + imod(pads[1], 2) + ${e}; 1548 1549 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r+1}Ready == 0) { 1550 xTexelC${r+1} = getX(batch, xR, xCOffset, d1); 1551 1552 // Need to manually clear unused channels in case 1553 // we're reading from recycled texture. 1554 if (xCOffset + 1 >= inDims[1]) { 1555 xTexelC${r+1}.zw = vec2(0.0); 1556 } 1557 xTexelC${r+1}Ready = 1; 1558 } 1559 `,o>1?h+=` 1560 xCOffset -= 2; 1561 if (xCOffset >= 0 && xCOffset < inDims[1]) { 1562 previous = getX(batch, xR, xCOffset, d1); 1563 xC${r+1} = vec4(previous.zw, xTexelC${r+1}.xy); 1564 } else { 1565 xC${r+1} = vec4(0.0, 0.0, xTexelC${r+1}.xy); 1566 } 1567 `:h+=` 1568 xC${r+1} = vec4(xTexelC${r}.zw, xTexelC${r+1}.xy); 1569 `):1===e?h+=` 1570 xC${r+1} = xTexelC${r}; 1571 `:h+=` 1572 xCOffset = xC + ${e}; 1573 1574 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r+1}Ready == 0) { 1575 xTexelC${r+1} = getX(batch, xR, xCOffset, d1); 1576 if (xCOffset + 1 >= inDims[1]) { 1577 xTexelC${r+1}.zw = vec2(0.0); 1578 } 1579 xTexelC${r+1}Ready = 1; 1580 } 1581 1582 xC${r+1} = xTexelC${r+1}; 1583 `}}else r<u&&(s%2==1?(h+=` 1584 xCOffset = xC + 1 - strides[1]; 1585 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r}Ready == 0) { 1586 xTexelC${r} = getX(batch, xR, xCOffset, d1); 1587 // Need to manually clear unused channels in case 1588 // we're reading from recycled texture. 1589 if (xCOffset + 1 >= inDims[1]) { 1590 xTexelC${r}.zw = vec2(0.0); 1591 } 1592 xTexelC${r}Ready = 1; 1593 } 1594 1595 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${r+1}Ready == 0) { 1596 xTexelC${r+1} = getX(batch, xR, xC + 1, d1); 1597 // Need to manually clear unused channels in case 1598 // we're reading from recycled texture. 1599 if (xC + 2 >= inDims[1]) { 1600 xTexelC${r+1}.zw = vec2(0.0); 1601 } 1602 xTexelC${r+1}Ready = 1; 1603 } 1604 1605 xC${r} = vec4(xTexelC${r}.zw, xTexelC${r+1}.zw); 1606 `,r+1<u&&(h+=` 1607 final = vec4(0.0); 1608 xCOffset = xC + 1 + strides[1]; 1609 if(xCOffset >= 0 && xCOffset < inDims[1]) { 1610 final = getX(batch, xR, xCOffset, d1); 1611 } 1612 xC${r+1} = vec4(xTexelC${r+1}.xy, final.xy); 1613 `)):(h+=` 1614 if(xC >= 0 && xC < inDims[1] && xTexelC${r}Ready == 0) { 1615 xTexelC${r} = getX(batch, xR, xC, d1); 1616 if (xC + 1 >= inDims[1]) { 1617 xTexelC${r}.zw = vec2(0.0); 1618 } 1619 xTexelC${r}Ready = 1; 1620 } 1621 1622 xCOffset = xC + strides[1]; 1623 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r+1}Ready == 0) { 1624 xTexelC${r+1} = getX(batch, xR, xCOffset, d1); 1625 if (xCOffset + 1 >= inDims[1]) { 1626 xTexelC${r+1}.zw = vec2(0.); 1627 } 1628 xTexelC${r+1}Ready = 1; 1629 } 1630 1631 xC${r} = vec4( 1632 xTexelC${r}.xy, xTexelC${r+1}.xy); 1633 `,r+1<u&&(h+=` 1634 xC${r+1} = vec4(xTexelC${r}.zw, xTexelC${r+1}.zw); 1635 `)));r<u&&(h+=` 1636 wTexel = getW(r, ${r}, d1, d2); 1637 dotProd += xC${r}.xxzz * vec4(wTexel.xy, wTexel.xy); 1638 if(d1 + 1 < ${e.inChannels}) { 1639 dotProd += xC${r}.yyww * vec4(wTexel.zw, wTexel.zw); 1640 } 1641 `,r+1<u&&(h+=` 1642 wTexel = getW(r, ${r+1}, d1, d2); 1643 dotProd += xC${r+1}.xxzz * vec4(wTexel.xy, wTexel.xy); 1644 if(d1 + 1 < ${e.inChannels}) { 1645 dotProd += xC${r+1}.yyww * vec4(wTexel.zw, wTexel.zw); 1646 } 1647 `))}h+=` 1648 } 1649 1650 } 1651 1652 } 1653 `;let p="",d="";r&&(p=n?`vec4 activation(vec4 a) { 1654 vec4 b = getPreluActivationWeightsAtOutCoords(); 1655 ${r} 1656 }`:a?`vec4 activation(vec4 a) { 1657 vec4 b = getLeakyreluAlphaAtOutCoords(); 1658 ${r} 1659 }`:`vec4 activation(vec4 x) { 1660 ${r} 1661 }`,d="result = activation(result);"),t&&this.variableNames.push("bias"),n&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 1662 ${p} 1663 1664 void main() { 1665 ivec4 coords = getOutputCoords(); 1666 int batch = coords.x; 1667 ivec2 xRCCorner = coords.yz * strides - pads; 1668 int d2 = coords.w; 1669 int xRCorner = xRCCorner.x; 1670 int xCCorner = xRCCorner.y; 1671 1672 //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. 1673 vec4 dotProd = vec4(0.000000000000001); 1674 1675 ${h} 1676 1677 vec4 result = dotProd - vec4(0.000000000000001); 1678 ${t?"result += getBiasAtOutCoords();":""} 1679 ${d} 1680 setOutput(result); 1681 } 1682 `}}var cQ=r(46519);class cq{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=(0,p2.ik)(this.outputShape.length);let{dataFormat:r}=t,n=(0,cQ.B)(),a="channelsLast"===r,s=a?1:2,i=a?2:3,o=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`,l="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)l+=` 1683 blockIndex = rc.z + ${t}; 1684 pos = rc.y + ${e}; 1685 1686 ${o} 1687 offsetY = int(blockIndex / outWidth) * stride[0] - pad[0]; 1688 d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow); 1689 1690 if(d0 < inputShape[${s}] && d0 >= 0) { 1691 // Use custom imod instead mod. On Intel GPU, mod may generate 1692 // unexpected value. 1693 // https://github.com/tensorflow/tfjs/issues/5447 1694 offsetX = imod(blockIndex, outWidth) * stride[1] - pad[
16941]; 1695 d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) / 1696 inChannels); 1697 1698 if(d1 < inputShape[${i}] && d1 >= 0) { 1699 1700 ch = imod(pos, inChannels); 1701 1702 if (${a}) { 1703 innerDims = vec2(d1, ch); 1704 result[${2*e+t}] = getChannel( 1705 getA(rc.x, d0, int(innerDims.x), 1706 int(innerDims.y)), innerDims); 1707 } else { 1708 innerDims = vec2(d0, d1); 1709 result[${2*e+t}] = getChannel( 1710 getA(rc.x, ch, int(innerDims.x), 1711 int(innerDims.y)), innerDims); 1712 } 1713 } 1714 } 1715 } 1716 `;this.userCode=` 1717 void main() { 1718 ivec3 rc = getOutputCoords(); 1719 1720 vec4 result = vec4(0); 1721 1722 int blockIndex, pos, offsetY, d0, offsetX, d1, ch; 1723 vec2 innerDims; 1724 1725 ${l} 1726 1727 ${n.output} = result; 1728 } 1729 `}}function cX(e,t){let r=e.length;return r>=3?t?[...e.slice(0,-3),e[r-3]*e[r-2],e[r-1]]:[...e.slice(0,-3),e[r-3],e[r-2]*e[r-1]]:!t&&1===r&&e[0]>1?[e[0],1]:null}function cJ({x:e,filter:t,convInfo:r,backend:n,bias:a=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:o=null}){let l,u=e.shape,h=n.texData.get(e.dataId),p=r.inChannels,d=u[0]*u[1]*u[2],c=r.outChannels,f="channelsLast"===r.dataFormat,m=[];if(null!=s){let e=cX(s.shape,f);null!=e&&(s=dN({inputs:{x:s},backend:n,attrs:{shape:e}}),m.push(s))}if(null!=a){let e=cX(a.shape,f);null!=e&&(a=dN({inputs:{x:a},backend:n,attrs:{shape:e}}),m.push(a))}if(!((1===d||1===c)&&p>1e3)&&h.isPacked&&f&&null!=h.texture&&u[2]%2!=0&&W.ZSL.arraysEqual(h.shape.slice(-3),u.slice(-3))){let p=u[0]*u[1]*(u[2]+1),d={dataId:e.dataId,shape:[1,p,r.inChannels],dtype:e.dtype},c=h.shape;h.shape=h.shape.slice(),h.shape[h.shape.length-2]++,W.ZSL.assert(pq.isReshapeFree(h.shape,d.shape),()=>`packed reshape ${h.shape} to ${d.shape} isn't free`);let f=dN({inputs:{x:t},backend:n,attrs:{shape:[1,r.inChannels,r.outChannels]}});m.push(f);let g=dL({a:d,b:f,backend:n,transposeA:!1,transposeB:!1,bias:a,activation:o,preluActivationWeights:s,leakyreluAlpha:i}),y=n.texData.get(g.dataId);W.ZSL.assert(y.isPacked,()=>"batchMatMul result is expected to be packed"),h.shape=c,y.shape=r.outShape,(l=p9({inputs:{x:g},backend:n})).shape=r.outShape,m.push(g)}else{let u=r.outHeight*r.outWidth,h=dN({inputs:{x:e},backend:n,attrs:{shape:f?[r.batchSize,u,r.inChannels]:[r.batchSize,r.inChannels,u]}}),p=dN({inputs:{x:t},backend:n,attrs:{shape:[1,r.inChannels,r.outChannels]}}),d=dL({a:f?h:p,b:f?p:h,transposeA:!f,transposeB:!1,backend:n,bias:a,activation:o,preluActivationWeights:s,leakyreluAlpha:i});l=dN({inputs:{x:d},backend:n,attrs:{shape:r.outShape}}),m.push(h),m.push(p),m.push(d)}for(let e of m)n.disposeIntermediateTensorInfo(e);return l}function c0({x:e,filter:t,convInfo:r,backend:n,bias:a=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:o=null}){let{filterWidth:l,filterHeight:u,inChannels:h,outWidth:p,outHeight:d,dataFormat:c}=r,f="channelsLast"===c,m=l*u*h,g=d*p,y=[r.batchSize,m,g],b=[];if(null!=s){let e=cX(s.shape,f);null!=e&&(s=dN({inputs:{x:s},backend:n,attrs:{shape:e}}),b.push(s))}if(null!=a){let e=cX(a.shape,f);null!=e&&(a=dN({inputs:{x:a},backend:n,attrs:{shape:e}}),b.push(a))}let x=dN({inputs:{x:t},backend:n,attrs:{shape:[1,m,W.ZSL.sizeFromShape(t.shape)/m]}});b.push(x);let v=new cq(y,r),w=[e.shape,[r.padInfo.top,r.padInfo.left],[r.strideHeight,r.strideWidth],[r.dilationHeight,r.dilationWidth],[r.inChannels],[r.filterWidth*r.inChannels],[r.outWidth]],T=n.runWebGLProgram(v,[e],"float32",w),S=dN({inputs:{x:T},backend:n,attrs:{shape:y}});b.push(T),b.push(S);let N=null!=a,k=null!=s,I="leakyrelu"===o,C=o?dm(o,!0):null,E=new dg(f?S.shape:x.shape,f?x.shape:S.shape,f?[r.batchSize,g,r.outChannels]:[r.batchSize,r.outChannels,g],!0,!1,N,C,k,I),A=f?[S,x]:[x,S];if(a&&A.push(a),k&&A.push(s),I){let e=n.makeTensorInfo([],"float32",W.ZSL.createScalarValue(i,"float32"));A.push(e),b.push(e)}let $=n.runWebGLProgram(E,A,"float32"),F=dN({inputs:{x:$},backend:n,attrs:{shape:r.outShape}});for(let e of(b.push($),b))n.disposeIntermediateTensorInfo(e);return F}let c1={kernelName:W.p2J,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s,filter:i}=r,{strides:o,pad:l,dataFormat:u,dilations:h,dimRoundingMode:p}
1729=a,d=W.C0T.convertConv2DDataFormat(u),c=W.C0T.computeConv2DInfo(s.shape,i.shape,o,h,l,p,!1,d);if(1===c.filterHeight&&1===c.filterWidth&&1===c.dilationHeight&&1===c.dilationWidth&&1===c.strideHeight&&1===c.strideWidth&&("SAME"===c.padInfo.type||"VALID"===c.padInfo.type))t=cJ({x:s,filter:i,convInfo:c,backend:n});else if(c.strideWidth<=2&&"channelsLast"===d&&(0,W._K2)().getBool("WEBGL_EXP_CONV")){let e=new cY(c),r=[[c.padInfo.top,c.padInfo.left],[c.strideHeight,c.strideWidth],[c.dilationHeight,c.dilationWidth],[c.inHeight,c.inWidth]];t=n.runWebGLProgram(e,[s,i],"float32",r)}else if((0,W._K2)().getBool("WEBGL_CONV_IM2COL"))t=c0({x:s,filter:i,convInfo:c,backend:n});else{let e=new cK(c);t=n.runWebGLProgram(e,[s,i],"float32")}let f=dN({inputs:{x:t},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(t),f}};class c2{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,r=e.strideWidth,n=e.padInfo.top,a=e.padInfo.left,s="channelsLast"===e.dataFormat;this.userCode=` 1730 void main() { 1731 ivec4 coords = getOutputCoords(); 1732 int wR = coords.x; 1733 int wC = coords.y; 1734 int d1 = coords.z; 1735 int d2 = coords.w; 1736 1737 // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2). 1738 // ? = to be determined. : = across all values in that axis. 1739 float dotProd = 0.0; 1740 1741 for (int b = 0; b < ${e.batchSize}; b++) { 1742 for (int yR = 0; yR < ${e.outHeight}; yR++) { 1743 int xR = wR + yR * ${t} - ${n}; 1744 1745 if (xR < 0 || xR >= ${e.inHeight}) { 1746 continue; 1747 } 1748 1749 for (int yC = 0; yC < ${e.outWidth}; yC++) { 1750 int xC = wC + yC * ${r} - ${a}; 1751 1752 if (xC < 0 || xC >= ${e.inWidth}) { 1753 continue; 1754 } 1755 1756 ${s?`float dyValue = getDy(b, yR, yC, d2); 1757 float xValue = getX(b, xR, xC, d1); 1758 dotProd += (xValue * dyValue);`:`float dyValue = getDy(b, d2, yR, yC); 1759 float xValue = getX(b, d1, xR, xC); 1760 dotProd += (xValue * dyValue);`} 1761 } 1762 } 1763 } 1764 setOutput(dotProd); 1765 } 1766 `}}class c3{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,r=e.filterWidth,n=e.strideHeight,a=e.strideWidth,s="channelsLast"===e.dataFormat,i=t-1-e.padInfo.top,o=r-1-e.padInfo.left;this.userCode=` 1767 const ivec2 pads = ivec2(${i}, ${o}); 1768 1769 void main() { 1770 ivec4 coords = getOutputCoords(); 1771 int batch = coords[0]; 1772 int d1 = coords[${s?3:1}]; 1773 1774 ivec2 dyCorner = ivec2(coords[${s?1:2}], coords[${s?2:3}]) - pads; 1775 int dyRCorner = dyCorner.x; 1776 int dyCCorner = dyCorner.y; 1777 1778 // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1). 1779 // ? = to be determined. : = across all values in that axis. 1780 float dotProd = 0.0; 1781 for (int wR = 0; wR < ${t}; wR++) { 1782 float dyR = float(dyRCorner + wR) / ${n}.0; 1783 1784 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 1785 continue; 1786 } 1787 int idyR = int(dyR); 1788 1789 int wRPerm = ${t} - 1 - wR; 1790 1791 for (int wC = 0; wC < ${r}; wC++) { 1792 float dyC = float(dyCCorner + wC) / ${a}.0; 1793 1794 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 1795 fract(dyC) > 0.0) { 1796 continue; 1797 } 1798 int idyC = int(dyC); 1799 1800 int wCPerm = ${r} - 1 - wC; 1801 1802 for (int d2 = 0; d2 < ${e.outChannels}; d2++) { 1803 1804 if (${s}) { 1805 float xValue = getDy(batch, idyR, idyC, d2); 1806 float wValue = getW(wRPerm, wCPerm, d1, d2); 1807 dotProd += xValue * wValue; 1808 } else { 1809 float xValue = getDy(batch, d2, idyR, idyC); 1810 float wValue = getW(wRPerm, wCPerm, d1, d2); 1811 dotProd += xValue * wValue; 1812 } 1813 1814 } 1815 } 1816 } 1817 setOutput(dotProd); 1818 } 1819 `}}class c4{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideDepth,r=e.strideHeight,n=e.strideWidth,a=e.padInfo.front,s=e.padInfo.top,i=e.padInfo.left;this.userCode=` 1820 void main() { 1821 ivec5 coords = getOutputCoords(); 1822 int wF = coords.x; 1823 int wR = coords.y; 1824 int wC = coords.z; 1825 int d1 = coords.w; 1826 int d2 = coords.u; 1827 1828 float dotProd = 0.0; 1829 1830 for (int b = 0; b < ${e.batchSize}; b++) { 1831 for (int yF = 0; yF < ${e.outDepth}; yF++) { 1832 int xF = wF + yF * ${t} - ${a}; 1833 1834 if (xF < 0 || xF >= ${e.inDepth}) { 1835 continue; 1836 } 1837 1838 for (int yR = 0; yR < ${e.outHeight}; yR++) { 1839 int xR = wR + yR * ${r} - ${s}; 1840 1841 if (xR < 0 || xR >= ${e.inHeight}) { 1842 continue; 1843 } 1844 1845 for (int yC = 0; yC < ${e.outWidth}; yC++) { 1846 int xC = wC + yC * ${n} - ${i}; 1847 1848 if (xC < 0 || xC >= ${e.inWidth}) { 1849 continue; 1850 } 1851 1852 float dyValue = getDy(b, yF, yR, yC, d2); 1853 float xValue = getX(b, xF, xR, xC, d1); 1854 dotProd += (xValue * dyValue); 1855 } 1856 } 1857 } 1858 } 1859 setOutput(dotProd); 1860 } 1861 `}}class c6{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterDepth,r=e.filterHeight,n=e.filterWidth,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=t-1-e.padInfo.front,l=r-1-e.padInfo.top,u=n-1-e.padInfo.left;this.userCode=` 1862 const ivec3 pads = ivec3(${o}, ${l}, ${u}); 1863 1864 void main() { 1865 ivec5 coords = getOutputCoords(); 1866 int batch = coords.x; 1867 int d1 = coords.u; 1868 1869 1870 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 1871 int dyFCorner = dyCorner.x; 1872 int dyRCorner = dyCorner.y; 1873 int dyCCorner = dyCorner.z; 1874 1875 float dotProd = 0.0; 1876 for (int wF = 0; wF < ${t}; wF++) { 1877 float dyF = float(dyFCorner + wF) / ${a}.0; 1878 1879 if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) { 1880 continue; 1881 } 1882 int idyF = int(dyF); 1883 1884 int wFPerm = ${t} - 1 - wF; 1885 1886 for (int wR = 0; wR < ${r}; wR++) { 1887 float dyR = float(dyRCorner + wR) / ${s}.0; 1888 1889 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 1890 fract(dyR) > 0.0) { 1891 continue; 1892 } 1893 int idyR = int(dyR); 1894 1895 int wRPerm = ${r} - 1 - wR; 1896 1897 for (int wC = 0; wC < ${n}; wC++) { 1898 float dyC = float(dyCCorner + wC) / ${i}.0; 1899 1900 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 1901 fract(dyC) > 0.0) { 1902 continue; 1903 } 1904 int idyC = int(dyC); 1905 1906 int wCPerm = ${n} - 1 - wC; 1907 1908 for (int d2 = 0; d2 < ${e.outChannels}; d2++) { 1909 float xValue = getDy(batch, idyF, idyR, idyC, d2); 1910 float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2); 1911 dotProd += xValue * wValue; 1912 } 1913 } 1914 } 1915 } 1916 setOutput(dotProd); 1917 } 1918 `}}let c5={kernelName:W.rFm,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,pad:o,dataFormat:l,dimRoundingMode:u,filterShape:h}
1918=n,p=W.C0T.convertConv2DDataFormat(l),d=new c2(W.C0T.computeConv2DInfo(a.shape,h,i,1,o,u,!1,p));return r.runWebGLProgram(d,[a,s],"float32")}};class c8{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=(0,p2.ik)(this.outputShape.length);let t=e.filterHeight,r=e.filterWidth,n=t-1-e.padInfo.top,a=r-1-e.padInfo.left;this.userCode=` 1919 const ivec2 pads = ivec2(${n}, ${a}); 1920 1921 void main() { 1922 ivec4 coords = getOutputCoords(); 1923 int batch = coords[0]; 1924 int d1 = coords[3]; 1925 1926 ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads; 1927 int dyRCorner = dyCorner.x; 1928 int dyCCorner = dyCorner.y; 1929 1930 vec4 result = vec4(0.); 1931 for (int wR = 0; wR < ${t}; wR++) { 1932 float dyR = float(dyRCorner + wR) / strides[0]; 1933 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 1934 continue; 1935 } 1936 int idyR = int(dyR); 1937 int wRPerm = ${t} - 1 - wR; 1938 1939 for (int wC = 0; wC < ${r}; wC++) { 1940 int wCPerm = ${r} - 1 - wC; 1941 1942 float dyC = float(dyCCorner + wC) / strides[1]; 1943 bool idyCVal = (dyC >= 0.0) && (dyC < ${e.outWidth}.0) 1944 && (fract(dyC) == 0.0); 1945 int idyC = int(dyC); 1946 1947 float dyC2 = float(dyCCorner + wC + 1) / strides[1]; 1948 bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${e.outWidth}.0) 1949 && (fract(dyC2) == 0.0); 1950 int idyC2 = int(dyC2); 1951 1952 if (idyCVal && idyCVal2) { 1953 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 1954 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 1955 vec4 dySample = getDy(batch, idyR, idyC, d2); 1956 vec4 dySample2 = (idyC / 2 == idyC2 / 2) ? 1957 dySample : getDy(batch, idyR, idyC2, d2); 1958 1959 vec2 dyValue = mod(float(idyC), 2.) == 0. ? 1960 dySample.xy : dySample.zw; 1961 result.xy += vec2(dot(dyValue, wValue.xy), 1962 dot(dyValue, wValue.zw)); 1963 1964 dyValue = mod(float(idyC2), 2.) == 0. ? 1965 dySample2.xy : dySample2.zw; 1966 result.zw += vec2(dot(dyValue, wValue.xy), 1967 dot(dyValue, wValue.zw)); 1968 } 1969 } else if (idyCVal) { 1970 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 1971 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 1972 vec4 dySample = getDy(batch, idyR, idyC, d2); 1973 vec2 dyValue = mod(float(idyC), 2.) == 0. ? 1974 dySample.xy : dySample.zw; 1975 result.xy += vec2(dot(dyValue, wValue.xy), 1976 dot(dyValue, wValue.zw)); 1977 } 1978 } else if (idyCVal2) { 1979 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 1980 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 1981 vec4 dySample = getDy(batch, idyR, idyC2, d2); 1982 vec2 dyValue = mod(float(idyC2), 2.) == 0. ? 1983 dySample.xy : dySample.zw; 1984 result.zw += vec2(dot(dyValue, wValue.xy), 1985 dot(dyValue, wValue.zw)); 1986 } 1987 } 1988 } 1989 } 1990 setOutput(result); 1991 } 1992 `}}let c7={kernelName:W.jfg,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{inputShape:i,strides:o,pad:l,dataFormat:u,dimRoundingMode:h}=n,p=W.C0T.convertConv2DDataFormat(u),d=W.C0T.computeConv2DInfo(i,s.shape,o,1,l,h,!1,p);if((0,W._K2)().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&"channelsLast"===p){let e=[[d.strideHeight,d.strideWidth]],t=new c8(d);return r.runWebGLProgram(t,[a,s],"float32",e)}{let e=new c3(d);return r.runWebGLProgram(e,[a,s],"float32")}}},c9={kernelName:W.A1h,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s}=t,{strides:i,pad:o,dilations:l}=n,u=new cH(W.C0T.computeConv3DInfo(a.shape,s.shape,i,l,o));return r.runWebGLProgram(u,[a,s],"float32")}},fe={kernelName:W.iGz,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,pad:o,filterShape:l}=n,u=new c4(W.C0T.computeConv3DInfo(a.shape,l,i,1,o));return r.runWebGLProgram(u,[a,s],"float32")}}
1992,ft={kernelName:W.gC7,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{pad:i,strides:o,inputShape:l}=n,u=new c6(W.C0T.computeConv3DInfo(l,s.shape,o,1,i));return r.runWebGLProgram(u,[a,s],"float32")}},fr=dc({opSnippet:dd+` 1993 return cos(x); 1994`,packedOpSnippet:` 1995 vec4 result = cos(x); 1996 bvec4 isNaN = isnan(x); 1997 ${p8} 1998 return result; 1999`}),fn={kernelName:W.Mn0,backendName:"webgl",kernelFunc:fr},fa=dc({opSnippet:` 2000 float e2x = exp(-x); 2001 return (e2x + 1.0 / e2x) / 2.0; 2002`}),fs={kernelName:W.MnK,backendName:"webgl",kernelFunc:fa};class fi{constructor(e,t,r,n,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];let[s,i,o,l]=e,[u]=t,[h,p]=r;this.outputShape=[u,h,p,l];let[d,c]=[`${i-1}.0`,`${o-1}.0`],[f,m,g]=h>1?[`${(i-1)/(h-1)}`,"(y2-y1) * height_ratio",`y1*${d} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${d}`],[y,b,x]=p>1?[`${(o-1)/(p-1)}`,"(x2-x1) * width_ratio",`x1*${c} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${c}`];this.userCode=` 2003 const float height_ratio = float(${f}); 2004 const float width_ratio = float(${y}); 2005 void main() { 2006 ivec4 coords = getOutputCoords(); 2007 int b = coords[0]; 2008 int y = coords[1]; 2009 int x = coords[2]; 2010 int d = coords[3]; 2011 2012 // get box vals 2013 float y1 = getBoxes(b,0); 2014 float x1 = getBoxes(b,1); 2015 float y2 = getBoxes(b,2); 2016 float x2 = getBoxes(b,3); 2017 2018 // get image in batch index 2019 int bInd = round(getBoxInd(b)); 2020 if(bInd < 0 || bInd >= ${s}) { 2021 return; 2022 } 2023 2024 float height_scale = ${m}; 2025 float width_scale = ${b}; 2026 2027 float in_y = ${g}; 2028 if( in_y < 0.0 || in_y > ${d} ) { 2029 setOutput(float(${a})); 2030 return; 2031 } 2032 float in_x = ${x}; 2033 if( in_x < 0.0 || in_x > ${c} ) { 2034 setOutput(float(${a})); 2035 return; 2036 } 2037 2038 vec2 sourceFracIndexCR = vec2(in_x,in_y); 2039 if(${+("bilinear"===n)} == 1) { 2040 // Compute the four integer indices. 2041 ivec2 sourceFloorCR = ivec2(sourceFracIndexCR); 2042 ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR)); 2043 2044 float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d); 2045 float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d); 2046 float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d); 2047 float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d); 2048 2049 vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR); 2050 2051 float top = topLeft + (topRight - topLeft) * fracCR.x; 2052 float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x; 2053 float newValue = top + (bottom - top) * fracCR.y; 2054 setOutput(newValue); 2055 } else { 2056 // Compute the coordinators of nearest neighbor point. 2057 ivec2 sourceNearestCR = ivec2(floor( 2058 sourceFracIndexCR + vec2(0.5,0.5))); 2059 float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d); 2060 setOutput(newValue); 2061 } 2062 } 2063 `}}let fo={kernelName:W.MRQ,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{image:a,boxes:s,boxInd:i}=t,{cropSize:o,method:l,extrapolationValue:u}=n,h=new fi(a.shape,s.shape,o,l,u);return r.runWebGLProgram(h,[a,s,i],"float32")}};!function(e){e.Prod="*",e.Sum="+"}(o||(o={}));class fl{constructor(e,t,r,n){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];let a=this.outputShape.length,s=this.op===o.Prod?"1.0":"0.0",i=r?s:`getX(${fu(a,"coords",this.op)})`,l=this.outputShape[this.outputShape.length-1],u="",h="";r?(u=n?`end != ${l-1}`:"end != 0",h=n?"end + 1":"end - 1"):(u=n?`end + pow2 < ${l}`:"end >= pow2",h=n?"end + pow2":"end - pow2"),this.userCode=` 2064 void main() { 2065 ${(0,p5.bf)(a)} coords = getOutputCoords(); 2066 int end = ${fh(a,"coords",this.op)}; 2067 float val = ${i}; 2068 int pow2 = int(pow(2.0, index)); 2069 if (${u}) { 2070 int idx = ${h}; 2071 ${fh(a,"coords",this.op)} = idx; 2072 val ${this.op}= getX(${fu(a,"coords",this.op)}); 2073 } 2074 setOutput(val); 2075 } 2076 `}}function fu(e,t,r){if(1===e)return`${t}`;if(2===e)return`${t}.x, ${t}.y`;if(3===e)return`${t}.x, ${t}.y, ${t}.z`;if(4===e)return`${t}.x, ${t}.y, ${t}.z, ${t}.w`;throw Error(`Cumulative ${r} for rank ${e} is not yet supported`)}function fh(e,t,r){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw Error(`Cumulative ${r} for rank ${e} is not yet supported`)}function fp(e,t,r,n,a,s){let i=t.shape.length,o=W.C0T.getAxesPermutation([n],i),l=t;null!=o&&(l=dD({inputs:{x:t},backend:r,attrs:{perm:o}}));let u=W.C0T.getInnerMostAxes(1,i)[0];if(u!==i-1)throw Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length-1} but got axis=${n}`);let h=l.shape[u],p=p9({inputs:{x:l},backend:r});for(let t=0;t<=Math.ceil(Math.log2(h))-1;t++){let n=new fl(e,l.shape,!1,s),a=[[t]],i=p;p=r.runWebGLProgram(n,[p],p.dtype,a),r.disposeIntermediateTensorInfo(i)}if(a){let t=new fl(e,l.shape,a,s),n=p;p=r.runWebGLProgram(t,[p],p.dtype),r.disposeIntermediateTensorInfo(n)}if(null!=o){let e=dD({inputs:{x:p},backend:r,attrs:{perm:W.C0T.getUndoAxesPermutation(o)}});return r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(l),e}return p}let fd={kernelName:W.jj_,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,exclusive:i,reverse:l}=n;return fp(o.Prod,a,r,s,i,l)}},fc={kernelName:W.nY8,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,exclusive:i,reverse:l}=n;return fp(o.Sum,a,r,s,i,l)}},ff={kernelName:W.wNW,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,weights:s}=t,{size:i,binaryOutput:o}=n;
2076if(1===a.shape.length){let e=r.readSync(a.dataId),t=r.readSync(s.dataId),n=(0,dx.jm)(e,t,s.dtype,s.shape,i);return r.makeTensorInfo([i],s.dtype,n)}if(2===a.shape.length){let e=r.bufferSync(a),t=r.bufferSync(s),n=(0,dx.h0)(e,t,i,o);return r.makeTensorInfo(n.shape,s.dtype,n.values)}throw Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}};class fm{constructor(e,t,r){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=r,this.userCode=` 2077 void main() { 2078 ivec4 coords = getOutputCoords(); 2079 int b = coords[0]; 2080 int h = ${this.getHeightCoordString()}; 2081 int w = ${this.getWidthCoordString()}; 2082 int d = ${this.getDepthCoordString()}; 2083 2084 int in_h = h / ${t}; 2085 int offset_h = imod(h, ${t}); 2086 int in_w = w / ${t}; 2087 int offset_w = imod(w, ${t}); 2088 int offset_d = (offset_h * ${t} + offset_w) * 2089 ${this.getOutputDepthSize()}; 2090 int in_d = d + offset_d; 2091 2092 float result = ${this.getInputSamplingString()}; 2093 setOutput(result); 2094 } 2095 `}
2095getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}let fg={kernelName:W.TMz,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockSize:s,dataFormat:i}=n,o=a.shape[0],l="NHWC"===i?a.shape[1]:a.shape[2],u="NHWC"===i?a.shape[2]:a.shape[3],h="NHWC"===i?a.shape[3]:a.shape[1],p=l*s,d=u*s,c=h/(s*s),f=new fm("NHWC"===i?[o,p,d,c]:[o,c,p,d],s,i);return r.runWebGLProgram(f,[a],a.dtype)}};class fy{constructor(e,t=!1,r=null,n=!1,a=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=(0,p2.ik)(this.outputShape.length);let s=e.filterHeight,i=e.filterWidth,o=e.outChannels/e.inChannels,l="",u="";r&&(l=n?`float activation(float a) { 2096 float b = getPreluActivationWeightsAtOutCoords(); 2097 ${r} 2098 }`:a?`float activation(float a) { 2099 float b = getLeakyreluAlphaAtOutCoords(); 2100 ${r} 2101 }`:` 2102 float activation(float x) { 2103 ${r} 2104 } 2105 `,u="result = activation(result);"),t&&this.variableNames.push("bias"),n&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 2106 ${l} 2107 2108 void main() { 2109 ivec4 coords = getOutputCoords(); 2110 int batch = coords.x; 2111 ivec2 xRCCorner = coords.yz * strides - pads; 2112 int d2 = coords.w; 2113 int d1 = d2 / ${o}; 2114 int q = d2 - d1 * ${o}; 2115 2116 int xRCorner = xRCCorner.x; 2117 int xCCorner = xRCCorner.y; 2118 2119 // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2). 2120 // ? = to be determined. : = across all values in that axis. 2121 float dotProd = 0.0; 2122 // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations. 2123 for (int wR = 0; wR < ${s}; wR++) { 2124 int xR = xRCorner + wR * dilations[0]; 2125 2126 if (xR < 0 || xR >= inDims[0]) { 2127 continue; 2128 } 2129 2130 for (int wC = 0; wC < ${i}; wC++) { 2131 int xC = xCCorner + wC * dilations[1]; 2132 2133 if (xC < 0 || xC >= inDims[1]) { 2134 continue; 2135 } 2136 2137 float xVal = getX(batch, xR, xC, d1); 2138 float wVal = getW(wR, wC, d1, q); 2139 dotProd += xVal * wVal; 2140 } 2141 } 2142 2143 float result = dotProd; 2144 ${t?"result += getBiasAtOutCoords();":""} 2145 ${u} 2146 setOutput(result); 2147 } 2148 `}}class fb{constructor(e,t=!1,r=null,n=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=(0,p2.ik)(this.outputShape.length);let s=e.outChannels/e.inChannels,i=e.padInfo.left,o=e.strideWidth,l=e.dilationWidth,u=e.filterHeight,h=e.filterWidth,p=` 2149 int xR; int xC; int xCOffset; 2150 vec4 wTexel; vec4 previous; vec4 final;`;for(let e=0;e<h;e++)p+=` 2151 vec4 xTexelC${2*e}; 2152 int xTexelC${2*e}Ready; 2153 vec4 xTexelC${2*e+1}; 2154 int xTexelC${2*e+1}Ready; 2155 vec4 xC${e};`;p+=` 2156 for (int r = 0; r < ${u}; r++) { 2157 `;for(let e=0;e<h;e++)p+=` 2158 xTexelC${2*e} = vec4(0.0); 2159 xTexelC${2*e}Ready = 0; 2160 xTexelC${2*e+1} = vec4(0.0); 2161 xTexelC${2*e+1}Ready = 0; 2162 xC${e} = vec4(0.0);`;p+=` 2163 xR = xRCorner + r * dilations[0]; 2164 if (xR >=0 && xR < inDims[0]) { 2165 `;for(let e=0;e<(h+1)/2;e++){let t=2*e;if(p+=` 2166 xC = xCCorner + ${t*l}; 2167 `,1===o){if(t<h&&(i%2==1?(p+=` 2168 xCOffset = xC + 1; 2169 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) { 2170 xTexelC${t} = getX(batch, xR, xCOffset, d1); 2171 2172 // Need to manually clear unused channels in case 2173 // we're reading from recycled texture. 2174 if (xCOffset + 1 >= inDims[1]) { 2175 xTexelC${t}.zw = vec2(0.0); 2176 } 2177 xTexelC${t}Ready = 1; 2178 } 2179 `,1===l&&t>0?p+=` 2180 xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy); 2181 `:p+=` 2182 xCOffset = xC + 1 - 2; 2183 2184 if (xCOffset >= 0 && xCOffset < inDims[1]) { 2185 previous = getX(batch, xR, xCOffset, d1); 2186 2187 // Need to manually clear unused channels in case 2188 // we're reading from recycled texture. 2189 if (xCOffset + 1 >= inDims[1]) { 2190 previous.zw = vec2(0.0); 2191 } 2192 2193 xC${t} = vec4(previous.zw, xTexelC${t}.xy); 2194 } else { 2195 xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy); 2196 } 2197 `):p+=` 2198 if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) { 2199 xTexelC${t} = getX(batch, xR, xC, d1); 2200 if (xC + 1 >= inDims[1]) { 2201 xTexelC${t}.zw = vec2(0.0); 2202 } 2203 xTexelC${t}Ready = 1; 2204 } 2205 2206 xC${t} = xTexelC${t}; 2207 `,t+1<h)){let e=i%2==0?W.ZSL.nearestLargerEven(l):l;l%2==0&&i%2==1||l%2!=0&&i%2!=1?(p+=` 2208 xCOffset = xC + imod(pads[1], 2) + ${e}; 2209 2210 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) { 2211 xTexelC${t+1} = getX(batch, xR, xCOffset, d1); 2212 2213 // Need to manually clear unused channels in case 2214 // we're reading from recycled texture. 2215 if (xCOffset + 1 >= inDims[1]) { 2216 xTexelC${t+1}.zw = vec2(0.0); 2217 } 2218 xTexelC${t+1}Ready = 1; 2219 } 2220 `,l>1?p+=` 2221 xCOffset -= 2; 2222 if (xCOffset >= 0 && xCOffset < inDims[1]) { 2223 previous = getX(batch, xR, xCOffset, d1); 2224 xC${t+1} = vec4(previous.zw, xTexelC${t+1}.xy); 2225 } else { 2226 xC${t+1} = vec4(0.0, 0.0, xTexelC${t+1}.xy); 2227 } 2228 `:p+=` 2229 xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy); 2230 `):1===e?p+=` 2231 xC${t+1} = xTexelC${t}; 2232 `:p+=` 2233 xCOffset = xC + ${e}; 2234 2235 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) { 2236 xTexelC${t+1} = getX(batch, xR, xCOffset, d1); 2237 if (xCOffset + 1 >= inDims[1]) { 2238 xTexelC${t+1}.zw = vec2(0.0); 2239 } 2240 xTexelC${t+1}Ready = 1; 2241 } 2242 2243 xC${t+1} = xTexelC${t+1}; 2244 `}}else t<h&&(i%2==1?(p+=` 2245 xCOffset = xC + 1 - strides[1]; 2246 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) { 2247 xTexelC${t} = getX(batch, xR, xCOffset, d1); 2248 // Need to manually clear unused channels in case 2249 // we're reading from recycled texture. 2250 if (xCOffset + 1 >= inDims[1]) { 2251 xTexelC${t}.zw = vec2(0.0); 2252 } 2253 xTexelC${t}Ready = 1; 2254 } 2255 2256 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) { 2257 xTexelC${t+1} = getX(batch, xR, xC + 1, d1); 2258 // Need to manually clear unused channels in case 2259 // we're reading from recycled texture. 2260 if (xC + 2 >= inDims[1]) { 2261 xTexelC${t+1}.zw = vec2(0.0); 2262 } 2263 xTexelC${t+1}Ready = 1; 2264 } 2265 2266 xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw); 2267 `,t+1<h&&(p+=` 2268 final = vec4(0.0); 2269 xCOffset = xC + 1 + strides[1]; 2270 if(xCOffset >= 0 && xCOffset < inDims[1]) { 2271 final = getX(batch, xR, xCOffset, d1); 2272 } 2273 xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy); 2274 `)):(p+=` 2275 if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) { 2276 xTexelC${t} = getX(batch, xR, xC, d1); 2277 if (xC + 1 >= inDims[1]) { 2278 xTexelC${t}.zw = vec2(0.0); 2279 } 2280 xTexelC${t}Ready = 1; 2281 } 2282 2283 xCOffset = xC + strides[1]; 2284 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) { 2285 xTexelC${t+1} = getX(batch, xR, xCOffset, d1); 2286 if (xCOffset + 1 >= inDims[1]) { 2287 xTexelC${t+1}.zw = vec2(0.); 2288 } 2289 xTexelC${t+1}Ready = 1; 2290 } 2291 2292 xC${t} = vec4( 2293 xTexelC${t}.xy, xTexelC${t+1}.xy); 2294 `,t+1<h&&(p+=` 2295 xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw); 2296 `)));t<h&&(p+=` 2297 wTexel = getW(r, ${t}, d1, q); 2298 dotProd += xC${t} * vec4(wTexel.xz, wTexel.xz); 2299 `,t+1<h&&(p+=` 2300 wTexel = getW(r, ${t+1}, d1, q); 2301 dotProd += xC${t+1} * vec4(wTexel.xz, wTexel.xz); 2302 `))}p+=` 2303 } 2304 2305 } 2306 `;let d="",c="";r&&(d=n?`vec4 activation(vec4 a) { 2307 vec4 b = getPreluActivationWeightsAtOutCoords(); 2308 ${r} 2309 }`:a?`vec4 activation(vec4 a) { 2310 vec4 b = getLeakyreluAlphaAtOutCoords(); 2311 ${r} 2312 }`:`vec4 activation(vec4 x) { 2313 ${r} 2314 }`,c="result = activation(result);"),t&&this.variableNames.push("bias"),n&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 2315 ${d} 2316 2317 void main() { 2318 ivec4 coords = getOutputCoords(); 2319 int batch = coords.x; 2320 ivec2 xRCCorner = coords.yz * strides - pads; 2321 int d2 = coords.w; 2322 int d1 = d2 / ${s}; 2323 int q = d2 - d1 * ${s}; 2324 int xRCorner = xRCCorner.x; 2325 int xCCorner = xRCCorner.y; 2326 2327 //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. 2328 vec4 dotProd = vec4(0.000000000000001); 2329 2330 ${p} 2331 2332 vec4 result = dotProd - vec4(0.000000000000001); 2333 ${t?"result += getBiasAtOutCoords();":""} 2334 ${c} 2335 setOutput(result); 2336 } 2337 `}}let fx={kernelName:W.tGH,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s,filter:i}=r,{strides:o,pad:l,dilations:u,dimRoundingMode:h}=a,p=u;null==p&&(p=[1,1]),W.ZSL.assert(W.C0T.eitherStridesOrDilationsAreOne(o,p),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${p}'`);let d=W.C0T.computeConv2DInfo(s.shape,i.shape,o,p,l,h,!0);t=(0,W._K2)().getBool("WEBGL_PACK_DEPTHWISECONV")&&d.strideWidth<=2&&d.outChannels/d.inChannels==1?new fb(d):new fy(d);let c=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth
2337]];return n.runWebGLProgram(t,[s,i],"float32",c)}};class fv{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,r=e.strideWidth,n=e.padInfo.top,a=e.padInfo.left,s=e.outChannels/e.inChannels;this.userCode=` 2338 void main() { 2339 ivec4 coords = getOutputCoords(); 2340 int wR = coords.x; 2341 int wC = coords.y; 2342 int d1 = coords.z; 2343 int dm = coords.w; 2344 int d2 = d1 * ${s} + dm; 2345 2346 float dotProd = 0.0; 2347 2348 // TO DO: Vec4 over the batch size 2349 for (int b = 0; b < ${e.batchSize}; b++) { 2350 for (int yR = 0; yR < ${e.outHeight}; yR++) { 2351 int xR = wR + yR * ${t} - ${n}; 2352 2353 if (xR < 0 || xR >= ${e.inHeight}) { 2354 continue; 2355 } 2356 2357 for (int yC = 0; yC < ${e.outWidth}; yC++) { 2358 int xC = wC + yC * ${r} - ${a}; 2359 2360 if (xC < 0 || xC >= ${e.inWidth}) { 2361 continue; 2362 } 2363 2364 float dyValue = getDy(b, yR, yC, d2); 2365 float xValue = getX(b, xR, xC, d1); 2366 dotProd += (xValue * dyValue); 2367 } 2368 } 2369 } 2370 setOutput(dotProd); 2371 } 2372 `}}class fw{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,r=e.filterWidth,n=e.strideHeight,a=e.strideWidth,s=t-1-e.padInfo.top,i=r-1-e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=` 2373 const ivec2 pads = ivec2(${s}, ${i}); 2374 2375 void main() { 2376 ivec4 coords = getOutputCoords(); 2377 int batch = coords[0]; 2378 int d1 = coords[3]; 2379 ivec2 dyCorner = coords.yz - pads; 2380 int dyRCorner = dyCorner.x; 2381 int dyCCorner = dyCorner.y; 2382 2383 float dotProd = 0.0; 2384 2385 for (int wR = 0; wR < ${t}; wR++) { 2386 float dyR = float(dyRCorner + wR) / ${n}.0; 2387 2388 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 2389 continue; 2390 } 2391 int idyR = int(dyR); 2392 2393 int wRPerm = ${t} - 1 - wR; 2394 2395 for (int wC = 0; wC < ${r}; wC++) { 2396 float dyC = float(dyCCorner + wC) / ${a}.0; 2397 2398 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 2399 fract(dyC) > 0.0) { 2400 continue; 2401 } 2402 int idyC = int(dyC); 2403 2404 int wCPerm = ${r} - 1 - wC; 2405 2406 // TO DO: Vec4 over the channelMul 2407 for (int dm = 0; dm < ${o}; dm++) { 2408 int d2 = d1 * ${o} + dm; 2409 float xValue = getDy(batch, idyR, idyC, d2); 2410 float wValue = getW(wRPerm, wCPerm, d1, dm); 2411 dotProd += xValue * wValue; 2412 } 2413 } 2414 } 2415 setOutput(dotProd); 2416 } 2417 `}}let fT={kernelName:W.X$8,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:u,filterShape:h}=n,p=new fv(W.C0T.computeConv2DInfo(a.shape,h,i,o,l,u,!0));return r.runWebGLProgram(p,[a,s],"float32")}},fS={kernelName:W.nVu,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:u,inputShape:h}=n,p=new fw(W.C0T.computeConv2DInfo(h,s.shape,i,o,l,u,!0));return r.runWebGLProgram(p,[a,s],"float32")}};class fN{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=` 2418 void main() { 2419 ivec2 coords = getOutputCoords(); 2420 float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; 2421 setOutput(val); 2422 } 2423 `}}let fk={kernelName:W.ORI,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n}=t,a=[...n.shape,...n.shape],s=W.ZSL.sizeFromShape(n.shape),i=dN({inputs:{x:n},backend:r,attrs:{shape:[s]}}),o=new fN(s),l=r.runWebGLProgram(o,[i],i.dtype),u=dN({inputs:{x:l},backend:r,attrs:{shape:a}});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(l),u}};class fI{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let{inHeight:t,inWidth:r,padInfo:n,strideHeight:a,strideWidth:s,filterHeight:i,filterWidth:o,dilationHeight:l,dilationWidth:u}=e,{top:h,left:p}=n;this.userCode=` 2424 const ivec2 strides = ivec2(${a}, ${s}); 2425 const ivec2 pads = ivec2(${h}, ${p}); 2426 const float neg_infinity = -3.4e38; 2427 2428 void main() { 2429 ivec4 coords = getOutputCoords(); 2430 int batch = coords.x; 2431 int d1 = coords.w; 2432 ivec2 outTopLeftCorner = 2433 coords.yz * strides - pads; 2434 int hBeg = outTopLeftCorner.x; 2435 int wBeg = outTopLeftCorner.y; 2436 2437 float curVal = neg_infinity; 2438 for (int h = 0; h < ${i}; h++) { 2439 int hIn = hBeg + h * ${l}; 2440 2441 if (hIn >= 0 && hIn < ${t}) { 2442 for (int w = 0; w < ${o}; w++) { 2443 int wIn = wBeg + w * ${u}; 2444 2445 if (wIn >= 0 && wIn < ${r}) { 2446 float xVal = getX(batch, hIn, wIn, d1); 2447 float wVal = getW(h, w, d1); 2448 2449 float val = xVal + wVal; 2450 if (val > curVal) { 2451 curVal = val; 2452 } 2453 } 2454 } 2455 } 2456 } 2457 2458 float result = curVal; 2459 setOutput(result); 2460 } 2461 `}}let fC={kernelName:W.jxD,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s,filter:i}=r,{strides:o,pad:l,dilations:u}=a,h=W.C0T.computeDilation2DInfo(s.shape,i.shape,o,l,"NHWC",u),p=new fI(h),d=dN({input
2461s:{x:t=n.runWebGLProgram(p,[s,i],"float32")},backend:n,attrs:{shape:h.outShape}});return n.disposeIntermediateTensorInfo(t),d}},fE={kernelName:W.Qgm,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{equation:a}=n,{allDims:s,summedDims:i,idDims:o}=W.C0T.decodeEinsumEquation(a,t.length);W.C0T.checkEinsumDimSizes(s.length,o,t);let{path:l,steps:u}=W.C0T.getEinsumComputePath(i,o),h=u.length,p=null,d=s.length,c=[];for(let e=0;e<h;++e){for(let n of u[e]){let e,{permutationIndices:a,expandDims:s}=W.C0T.getEinsumPermutation(d,o[n]);W.C0T.isIdentityPermutation(a)?e=t[n]:(e=dD({inputs:{x:t[n]},backend:r,attrs:{perm:a}}),c.push(e));let i=e.shape.slice();for(let e=0;e<s.length;++e)i.splice(s[e],0,1);W.ZSL.arraysEqual(e.shape,i)||(e=dN({inputs:{x:e},backend:r,attrs:{shape:i}}),c.push(e)),null===p?p=e:(p=dw({inputs:{a:e,b:p},backend:r}),c.push(p))}e<h-1&&(l[e]>=0&&(p=dR({inputs:{x:p},backend:r,attrs:{axis:l[e]-(s.length-d),keepDims:!1}}),c.push(p)),d--)}for(let e of c)e!==p&&r.disposeIntermediateTensorInfo(e);return p}},fA=dc({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:` 2462 vec4 result; 2463 2464 result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); 2465 result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); 2466 result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); 2467 result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); 2468 2469 return result; 2470`}),f$={kernelName:W.Pah,backendName:"webgl",kernelFunc:fA},fF=` 2471 vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
2472 return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); 2473`,fR={kernelName:W.rsH,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r}=e,{dy:n,y:a}=t,s=(0,W._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new p7(fF,n.shape,a.shape):new p4("return (b >= 0.0) ? a : a * (b + 1.0);",n.shape,a.shape);return r.runWebGLProgram(s,[n,a],n.dtype)}},f_=df({opSnippet:"return float(a == b);",packedOpSnippet:` 2474 return vec4(equal(a, b)); 2475`,dtype:"bool",cpuKernelImpl:dx.PP}),fD={kernelName:W.BRl,backendName:"webgl",kernelFunc:f_},fO=dc({opSnippet:` 2476 // Error function is calculated approximately with elementary function. 2477 // See "Handbook of Mathematical Functions with Formulas, 2478 // Graphs, and Mathematical Tables", Abramowitz and Stegun. 2479 float p = ${W.C0T.ERF_P}; 2480 float a1 = ${W.C0T.ERF_A1}; 2481 float a2 = ${W.C0T.ERF_A2}; 2482 float a3 = ${W.C0T.ERF_A3}; 2483 float a4 = ${W.C0T.ERF_A4}; 2484 float a5 = ${W.C0T.ERF_A5}; 2485 2486 float sign = sign(x); 2487 x = abs(x); 2488 float t = 1.0 / (1.0 + p * x); 2489 return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); 2490`}),fL={kernelName:W._s9,backendName:"webgl",kernelFunc:fO},fM=dc({opSnippet:dd+` 2491 return exp(x); 2492`,packedOpSnippet:` 2493 vec4 result = exp(x); 2494 bvec4 isNaN = isnan(x); 2495 result.r = isNaN.r ? x.r : result.r; 2496 result.g = isNaN.g ? x.g : result.g; 2497 result.b = isNaN.b ? x.b : result.b; 2498 result.a = isNaN.a ? x.a : result.a; 2499 2500 return result; 2501`,cpuKernelImpl:dx.E$,dtype:"float32"}),fP={kernelName:W.ox3,backendName:"webgl",kernelFunc:fM};function fz(e){let{inputs:t,attrs:r,backend:n}=e,{dim:a}=r,{input:s}=t,i=s.shape.length,o=s.shape.slice(),l=a;return a<0&&(W.ZSL.assert(-(i+1)<=a,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+a+1),o.splice(l,0,1),dN({inputs:{x:s},backend:n,attrs:{shape:o}})}let fB={kernelName:W.ybN,backendName:"webgl",kernelFunc:fz},fW="return exp(x) - 1.0;",fV=dc({opSnippet:fW,packedOpSnippet:fW,cpuKernelImpl:dx.SF}),fU={kernelName:W.ybj,backendName:"webgl",kernelFunc:fV};class fG{constructor(e,t,r){let n;this.variableNames=["real","imag"];let a=t[1];this.outputShape=t;let s=r?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=r?`${a}.0`:"1.0";if("real"===e)n="return real * expR - imag * expI;";else if("imag"===e)n="return real * expI + imag * expR;";else throw Error(`FFT component must be either "real" or "imag", got ${e}.`);this.userCode=` 2502 const float exponentMultiplier = ${s}; 2503 2504 float unaryOpComplex(float real, float expR, float imag, float expI) { 2505 ${n} 2506 } 2507 2508 float mulMatDFT(int batch, int index) { 2509 float indexRatio = float(index) / float(${a}); 2510 float exponentMultiplierTimesIndexRatio = 2511 exponentMultiplier * indexRatio; 2512 2513 float result = 0.0; 2514 2515 for (int i = 0; i < ${a}; i++) { 2516 // x = (-2|2 * PI / N) * index * i; 2517 float x = exponentMultiplierTimesIndexRatio * float(i); 2518 float expR = cos(x); 2519 float expI = sin(x); 2520 float real = getReal(batch, i); 2521 float imag = getImag(batch, i); 2522 2523 result += 2524 unaryOpComplex(real, expR, imag, expI) / ${i}; 2525 } 2526 2527 return result; 2528 } 2529 2530 void main() { 2531 ivec2 coords = getOutputCoords(); 2532 setOutput(mulMatDFT(coords[0], coords[1])); 2533 } 2534 `}}function fZ(e,t,r){let n=r.texData.get(e.dataId),a=W.ZSL.sizeFromShape(e.shape),s=e.shape[e.shape.length-1],i=dN({inputs:{x:e},backend:r,attrs:{shape:[a/s,s]}}),o=i.shape,l=new fG("real",o,t),u=new fG("imag",o,t),h=[{dataId:n.complexTensorInfos.real.dataId,dtype:n.complexTensorInfos.real.dtype,shape:o},{dataId:n.complexTensorInfos.imag.dataId,dtype:n.complexTensorInfos.imag.dtype,shape:o}],p=r.runWebGLProgram(l,h,"float32"),d=r.runWebGLProgram(u,h,"float32"),c=dt({inputs:{real:p,imag:d},backend:r});r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(d);let f=dN({inputs:{x:c},backend:r,attrs:{shape:e.shape}});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(c),f}let fj={kernelName:W.rGP,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}
2534=e,{input:n}=t;return fZ(n,!1,r)}};class fK{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=` 2535 void main() { 2536 // Input can be obtained from uniform value. 2537 setOutput(value); 2538 } 2539 `}}function fH(e){let{backend:t,attrs:r}=e,{shape:n,value:a}=r,{dtype:s}=r;if("string"===(s=s||W.ZSL.inferDtype(a))){let e=W.ZSL.getArrayFromDType(s,W.ZSL.sizeFromShape(n));return e.fill(a),t.makeTensorInfo(n,s,e)}{let e=new fK(n,a),r=[[a]];return t.runWebGLProgram(e,[],s,r)}}let fY={kernelName:W.SQl,backendName:"webgl",kernelFunc:fH};class fQ{constructor(e){this.variableNames=["Image"],this.outputShape=[];let t=e[2];this.outputShape=e,this.userCode=` 2540 void main() { 2541 ivec4 coords = getOutputCoords(); 2542 int x = coords[2]; 2543 2544 int coordX = ${t} - x - 1; 2545 float outputValue; 2546 if(coordX >= 0 && coordX < ${t}) { 2547 outputValue = getImage(coords[0], coords[1], coordX, coords[3]); 2548 } else { 2549 outputValue = getImage(coords[0], coords[1], coords[2], coords[3]); 2550 } 2551 setOutput(outputValue); 2552 } 2553 `}}let fq={kernelName:W.BxF,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{let{image:r}=e,n=new fQ(r.shape);return t.runWebGLProgram(n,[r],r.dtype)}},fX="return floor(x);",fJ=dc({opSnippet:fX,packedOpSnippet:fX,cpuKernelImpl:dx.CJ}),f0={kernelName:W.ZgB,backendName:"webgl",kernelFunc:fJ},f1=df({opSnippet:` 2554 float s = sign(a) * sign(b); 2555 int ia = round(a); 2556 int ib = round(b); 2557 if (ib != 0) { 2558 // Windows (D3D) wants guaranteed non-zero int division at compile-time. 2559 return float(idiv(ia, ib, s)); 2560 } else { 2561 return NAN; 2562 } 2563`,packedOpSnippet:` 2564 ivec4 ia = round(a); 2565 ivec4 ib = round(b); 2566 bvec4 cond = notEqual(ib, ivec4(0)); 2567 ivec4 result = ivec4(0); 2568 vec4 s = sign(a) * sign(b); 2569 2570 // Windows (D3D) wants guaranteed non-zero int division at compile-time. 2571 if (cond[0]) { 2572 result[0] = idiv(ia[0], ib[0], s[0]); 2573 } 2574 if (cond[1]) { 2575 result[1] = idiv(ia[1], ib[1], s[1]); 2576 } 2577 if (cond[2]) { 2578 result[2] = idiv(ia[2], ib[2], s[2]); 2579 } 2580 if (cond[3]) { 2581 result[3] = idiv(ia[3], ib[3], s[3]); 2582 } 2583 return vec4(result); 2584`,dtype:"int32"}),f2={kernelName:W.ElG,backendName:"webgl",kernelFunc:f1};var f3=r(27738);class f4{constructor(e){this.variableNames=["A"];let t=(0,cQ.B)(),[r,n]=e;this.outputShape=e,this.userCode=` 2585 void main() { 2586 ivec3 coords = getOutputCoords(); 2587 int texR = coords[0]; 2588 int texC = coords[1]; 2589 int depth = coords[2]; 2590 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${n}.0, ${r}.0); 2591 2592 vec4 values = ${t.texture2D}(A, uv); 2593 float value; 2594 if (depth == 0) { 2595 value = values.r; 2596 } else if (depth == 1) { 2597 value = values.g; 2598 } else if (depth == 2) { 2599 value = values.b; 2600 } else if (depth == 3) { 2601 value = values.a; 2602 } 2603 2604 setOutput(floor(value * 255.0 + 0.5)); 2605 } 2606 `}}class f6{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let t=(0,cQ.B)(),[r,n]=e;this.outputShape=e,this.userCode=` 2607 void main() { 2608 ivec3 coords = getOutputCoords(); 2609 int texR = coords[0]; 2610 int texC = coords[1]; 2611 int depth = coords[2]; 2612 2613 vec4 result = vec4(0.); 2614 2615 for(int row=0; row<=1; row++) { 2616 for(int col=0; col<=1; col++) { 2617 texC = coords[1] + row; 2618 depth = coords[2] + col; 2619 2620 vec2 uv = (vec2(texC, texR) + halfCR) / 2621 vec2(${n}.0, ${r}.0); 2622 vec4 values = ${t.texture2D}(A, uv); 2623 float value; 2624 if (depth == 0) { 2625 value = values.r; 2626 } else if (depth == 1) { 2627 value = values.g; 2628 } else if (depth == 2) { 2629 value = values.b; 2630 } else if (depth == 3) { 2631 value = values.a; 2632 } 2633 2634 result[row * 2 + col] = floor(value * 255.0 + 0.5); 2635 } 2636 } 2637 2638 ${t.output} = result; 2639 } 2640 `}}let f5={kernelName:W.awo,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:a}=e,{pixels:s}=t,{numChannels:i}=a,o="undefined"!=typeof HTMLVideoElement&&s instanceof HTMLVideoElement,l="undefined"!=typeof HTMLImageElement&&s instanceof HTMLImageElement,[u,h]=o?[s.videoWidth,s.videoHeight]:[s.width,s.height],p=[h,u],d=[h,u,i];if(l||o){let e=(0,W._K2)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(null==n||e!==f8)&&(f8=e,n=document.createElement("canvas").getContext("2d",{willReadFrequently:f8})),n.canvas.width=u,n.canvas.height=h,n.drawImage(s,0,0,u,h),s=n.canvas}let c=r.makeTensorInfo(p,"int32");r.texData.get(c.dataId).usage=f3.tT.PIXELS,r.gpgpu.uploadPixelDataToTexture(r.getTexture(c.dataId),s);let f=(0,W._K2)().getBool("WEBGL_PACK")?new f6(d):new f4(d),m=r.runWebGLProgram(f,[c],"int32");return r.disposeData(c.dataId),m}},f8=(0,W._K2)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU"),f7={kernelName:W.aAr,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s,filter:i,bias:o,preluActivationWeights:l}=r,{strides:u,pad:h,dataFormat:p,dilations:d,dimRoundingMode:c,activation:f,leakyreluAlpha:m}
2640=a,g=W.C0T.convertConv2DDataFormat(p),y=W.C0T.computeConv2DInfo(s.shape,i.shape,u,d,h,c,!1,g),b=[],x=null!=o,v=null!=l,w="leakyrelu"===f,T=()=>{let e=[s,i],t=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){let t=dN({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return b.push(t),t}return e};if(x&&e.push(t(o,p)),v&&e.push(t(l,p)),w){let t=n.makeTensorInfo([],"float32",W.ZSL.createScalarValue(m,"float32"));e.push(t),b.push(t)}return e};if(1===y.filterHeight&&1===y.filterWidth&&1===y.dilationHeight&&1===y.dilationWidth&&1===y.strideHeight&&1===y.strideWidth&&("SAME"===y.padInfo.type||"VALID"===y.padInfo.type))t=cJ({x:s,filter:i,convInfo:y,backend:n,bias:o,activation:f,preluActivationWeights:l,leakyreluAlpha:m});else if(y.strideWidth<=2&&"channelsLast"===g&&(0,W._K2)().getBool("WEBGL_EXP_CONV")){let e=new cY(y,x,f?dm(f,!0):null,v,w),r=[[y.padInfo.top,y.padInfo.left],[y.strideHeight,y.strideWidth],[y.dilationHeight,y.dilationWidth],[y.inHeight,y.inWidth]],a=T();t=n.runWebGLProgram(e,a,"float32",r)}else if((0,W._K2)().getBool("WEBGL_CONV_IM2COL"))t=c0({x:s,filter:i,convInfo:y,backend:n,bias:o,activation:f,preluActivationWeights:l,leakyreluAlpha:m});else{let e=new cK(y,x,f?dm(f,!1):null,v,w),r=T();t=n.runWebGLProgram(e,r,"float32")}let S=dN({inputs:{x:t},backend:n,attrs:{shape:y.outShape}});return b.push(t),b.forEach(e=>n.disposeIntermediateTensorInfo(e)),S}},f9={kernelName:W.T7M,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s,filter:i,bias:o,preluActivationWeights:l}=r,{strides:u,pad:h,dilations:p,dimRoundingMode:d,activation:c,leakyreluAlpha:f}=a,m=[],g=p;null==g&&(g=[1,1]),W.ZSL.assert(W.C0T.eitherStridesOrDilationsAreOne(u,g),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${g}'`);let y=W.C0T.computeConv2DInfo(s.shape,i.shape,u,g,h,d,!0),b=(0,W._K2)().getBool("WEBGL_PACK_DEPTHWISECONV")&&y.strideWidth<=2&&y.outChannels/y.inChannels==1,x=c?dm(c,b):null,v=[s,i],w=null!=o,T=null!=l,S="leakyrelu"===c;if(w&&v.push(o),T&&v.push(l),S){let e=n.makeTensorInfo([],"float32",W.ZSL.createScalarValue(f,"float32"));v.push(e),m.push(e)}t=b?new fb(y,w,x,T,S):new fy(y,w,x,T,S);let N=[[y.padInfo.top,y.padInfo.left],[y.strideHeight,y.strideWidth],[y.dilationHeight,y.dilationWidth],[y.inHeight,y.inWidth]],k=n.runWebGLProgram(t,v,"float32",N);return m.forEach(e=>n.disposeIntermediateTensorInfo(e)),k}};class me{constructor(e,t,r,n){this.sliceDim=e,this.strides=t,this.paramsShape=n,this.variableNames=["x","indices"],this.outputShape=r;let a=(0,p5.bf)(r.length),s=` 2641 int index;`;for(let e=0;e<this.sliceDim;e++)s+=` 2642 index = round(getIndices(coords[0], ${e})); 2643 out_of_bounds = out_of_bounds || index < 0; 2644 out_of_bounds = out_of_bounds || index >= ${this.paramsShape[e]}; 2645 flattenIndex += index * ${this.strides[e]};`;this.userCode=` 2646 void main() { 2647 ${a} coords = getOutputCoords(); 2648 int flattenIndex = 0; 2649 bool out_of_bounds = false; 2650 2651 ${s} 2652 2653 setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1])); 2654 } 2655 `}}let mt={kernelName:W.O4G,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{params:n,indices:a}=t,s=a.shape,i=s[s.length-1],o=W.ZSL.sizeFromShape(n.shape),[l,u,h,p]=W.C0T.prepareAndValidate(n,a),d=dN({inputs:{x:a},backend:r,attrs:{shape:[u,i]}}),c=dN({inputs:{x:n},backend:r,attrs:{shape:[W.ZSL.sizeFromShape(n.shape)/h,h]}});if(r.shouldExecuteOnCPU([n,a])||"string"===n.dtype){let e=r.readSync(a.dataId),t=r.bufferSync(n),s=(0,dx.UF)(e,t,n.dtype,u,i,h,p,n.shape,o);return r.makeTensorInfo(l,n.dtype,s.values)}let f=new me(i,p,[u,h],n.shape),m=r.runWebGLProgram(f,[c,d],c.dtype),g=dN({inputs:{x:m},backend:r,attrs:{shape:l}});return r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(m),g}};class mr{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;let r=(0,p5.bf)(this.rank),n=function(e,t){let r=["resRC.x","resRC.y","resRC.z","resRC.w"],n=[];for(let t=0;t<e.length;t++)2===t?n.push("index"):n.push(`${r[t]}`);return n.join()}(e,0);this.userCode=` 2656 void main() { 2657 ${r} resRC = getOutputCoords(); 2658 int index = int(getIndices(resRC.x, resRC.z)); 2659 float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0; 2660 setOutput(inBounds * getA(${n})); 2661 } 2662 `}}function mn(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,indices:s}=t,{axis:i,batchDims:o}=n,l=W.ZSL.parseAxisParam(i,a.shape)[0];if((0,W._K2)().get("DEBUG")){let e=r.readSync(s.dataId),t=a.shape[l];for(let r=0;r<e.length;++r){let n=e[r];W.ZSL.assert(n<=t-1&&n>=0,()=>`GatherV2: the index value ${n} is not in [0, ${t-1}]`)}}let u=W.C0T.segment_util.collectGatherOpShapeInfo(a,s,l,o),h=W.ZSL.sizeFromShape(s.shape),p=[],d=dN({input
2662s:{x:a},backend:r,attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]}}),c=dN({inputs:{x:s},backend:r,attrs:{shape:[u.batchSize,h/u.batchSize]}});p.push(d),p.push(c);let f=[u.batchSize,u.outerSize,h/u.batchSize,u.sliceSize];if(r.shouldExecuteOnCPU([a,s])||"string"===a.dtype){let e=r.bufferSync(c),t=r.bufferSync(d),n=(0,dx.QM)(t,e,f);return p.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.makeTensorInfo(u.outputShape,n.dtype,n.values)}let m=new mr(d.shape,f),g=r.runWebGLProgram(m,[d,c],d.dtype);p.push(g);let y=dN({inputs:{x:g},backend:r,attrs:{shape:u.outputShape}});return p.forEach(e=>r.disposeIntermediateTensorInfo(e)),y}let ma={kernelName:W.mxL,backendName:"webgl",kernelFunc:mn},ms=df({opSnippet:"return float(a > b);",packedOpSnippet:` 2663 return vec4(greaterThan(a, b)); 2664`,cpuKernelImpl:dx.Tm,dtype:"bool"}),mi={kernelName:W.XhZ,backendName:"webgl",kernelFunc:ms},mo=df({opSnippet:"return float(a >= b);",packedOpSnippet:` 2665 return vec4(greaterThanEqual(a, b)); 2666`,dtype:"bool",cpuKernelImpl:dx.BW}),ml={kernelName:W.lLS,backendName:"webgl",kernelFunc:mo},mu={kernelName:W.OAQ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{input:n}=t;return fZ(n,!0,r)}},mh=dc({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),mp={kernelName:W.gIW,backendName:"webgl",kernelFunc:mh},md=dc({opSnippet:"return float(isinf(x));",dtype:"bool"}),mc={kernelName:W.E3$,backendName:"webgl",kernelFunc:md},mf=dc({opSnippet:"return float(isnan(x));",dtype:"bool"}),mm={kernelName:W.iPs,backendName:"webgl",kernelFunc:mf},mg=df({opSnippet:"return float(a < b);",packedOpSnippet:` 2667 return vec4(lessThan(a, b)); 2668`,cpuKernelImpl:dx.uw,dtype:"bool"}),my={kernelName:W.mIA,backendName:"webgl",kernelFunc:mg},mb=df({opSnippet:"return float(a <= b);",packedOpSnippet:` 2669 return vec4(lessThanEqual(a, b)); 2670`,cpuKernelImpl:dx.mo,dtype:"bool"}),mx={kernelName:W.CwD,backendName:"webgl",kernelFunc:mb},mv={kernelName:W.mnI,backendName:"webgl",kernelFunc:function(e){let{backend:t,attrs:r}=e,{start:n,stop:a,num:s}=r,i=(0,dx.AC)(n,a,s);return t.makeTensorInfo([i.length],"float32",i)}},mw=dc({opSnippet:dd+` 2671 return x < 0.0 ? 0./0. : log(x); 2672`,packedOpSnippet:` 2673 vec4 result = log(x); 2674 bvec4 isNaN = isnan(x); 2675 result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r); 2676 result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g); 2677 result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b); 2678 result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a); 2679 return result; 2680`,cpuKernelImpl:dx.rI}),mT={kernelName:W.tG8,backendName:"webgl",kernelFunc:mw},mS=dc({opSnippet:dd+` 2681 return log(1.0 + x); 2682`}),mN={kernelName:W.Cg$,backendName:"webgl",kernelFunc:mS},mk=df({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:` 2683 return vec4( 2684 vec4(greaterThanEqual(a, vec4(1.0))) * 2685 vec4(greaterThanEqual(b, vec4(1.0)))); 2686`,dtype:"bool"}),mI={kernelName:W.RUm,backendName:"webgl",kernelFunc:mk},mC=dc({opSnippet:"return float(!(x >= 1.0));"}),mE={kernelName:W.nZd,backendName:"webgl",kernelFunc:mC},mA=df({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:` 2687 return min( 2688 vec4(greaterThanEqual(a, vec4(1.0))) + 2689 vec4(greaterThanEqual(b, vec4(1.0))), 2690 vec4(1.0)); 2691`,dtype:"bool"}),m$={kernelName:W.LXA,backendName:"webgl",kernelFunc:mA};class mF{constructor(e,t,r,n,a){let s;this.variableNames=["x"],this.outputShape=[];let i=e[3]-1;this.outputShape=e;let o=`float(${r}) + float(${n}) * sum`;s=.5===a?`inversesqrt(${o})`:1===a?`1.0/(${o})`:`exp(log(${o}) * float(-${a}));`,this.userCode=` 2692 void main() { 2693 ivec4 coords = getOutputCoords(); 2694 int b = coords[0]; 2695 int r = coords[1]; 2696 int c = coords[2]; 2697 int d = coords[3]; 2698 float x = getX(b, r, c, d); 2699 float sum = 0.0; 2700 for (int j = -${t}; j <= ${t}; j++) { 2701 int idx = d + j; 2702 if (idx >= 0 && idx <= ${i}) { 2703 float z = getX(b, r, c, idx); 2704 sum += z * z; 2705 } 2706 } 2707 float val = x * ${s}; 2708 setOutput(val); 2709 } 2710 `}}class mR{constructor(e,t,r,n,a){let s;this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;let i=e[3]-1;this.outputShape=e;let o=`float(${r}) + float(${n}) * sum`;s=.5===a?`inversesqrt(${o})`:1===a?`1.0/(${o})`:`exp(log(${o}) * float(-${a}));`,this.userCode=` 2711 void main() { 2712 ivec4 coords = getOutputCoords(); 2713 int b = coords.x; 2714 int r = coords.y; 2715 int c = coords.z; 2716 int d = coords.w; 2717 2718 bool hasNextCol = d < ${this.outputShape[3]}; 2719 bool hasNextRow = c < ${this.outputShape[2]}; 2720 2721 vec4 sum = vec4(0.); 2722 vec4 xFragAtOutputCoords = getX(b, r, c, d); 2723 2724 vec4 xAtOutputCoords = vec4( 2725 getChannel(xFragAtOutputCoords, vec2(c, d)), 2726 hasNextCol ? 2727 getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0, 2728 hasNextRow ? 2729 getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0, 2730 (hasNextRow && hasNextCol) ? 2731 getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0 2732 ); 2733 2734 int firstChannel = d - ${t}; 2735 vec2 cache = vec2(0.); 2736 if(firstChannel >= 0){ 2737 vec4 firstChannelFrag = getX(b, r, c, firstChannel); 2738 cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel)); 2739 if(hasNextRow){ 2740 cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel)); 2741 } 2742 } 2743
2744 ivec2 depth = ivec2(d, d + 1); 2745 for (int j = - ${t}; j <= ${t}; j++) { 2746 ivec2 idx = depth + j; 2747 bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0)); 2748 bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${i})); 2749 2750 bool depthInRange = aboveLowerBound.x && belowUpperBound.x; 2751 bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y; 2752 2753 if(depthInRange || depthPlusOneInRange){ 2754 vec4 z = vec4(0.); 2755 vec4 xFragAtCurrentDepth; 2756 z.xz = cache.xy; 2757 if(depthPlusOneInRange && hasNextCol){ 2758 xFragAtCurrentDepth = idx.y != d ? 2759 getX(b, r, c, idx.y) : xFragAtOutputCoords; 2760 z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y)); 2761 if(hasNextRow){ 2762 z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y)); 2763 } 2764 } 2765 cache.xy = z.yw; 2766 sum += z * z; 2767 } 2768 } 2769 vec4 result = xAtOutputCoords * ${s}; 2770 setOutput(result); 2771 } 2772 `}}let m_={kernelName:W.jM4,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{depthRadius:s,bias:i,alpha:o,beta:l}=n,u=(0,W._K2)().getBool("WEBGL_PACK_NORMALIZATION")?new mR(a.shape,s,i,o,l):new mF(a.shape,s,i,o,l);return r.runWebGLProgram(u,[a],a.dtype)}};class mD{constructor(e,t,r,n,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=r,this.alpha=n,this.beta=a,this.userCode=` 2773 void main() { 2774 ivec4 coords = getOutputCoords(); 2775 int b = coords[0]; 2776 int r = coords[1]; 2777 int c = coords[2]; 2778 2779 float result = 0.0; 2780 for (int d = 0; d < ${this.depth}; ++d) { 2781 int depthBegin = int(max(0.0, float(d - ${t}))); 2782 int depthEnd = int(min(float(${this.depth}), 2783 float(d + ${t} + 1))); 2784 2785 const int MIN_DEPTH_BEGIN = 0; 2786 const int MAX_DEPTH_END = ${this.depth}; 2787 2788 float norm = 0.0; 2789 for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) { 2790 if (k < depthBegin){ 2791 continue; 2792 } 2793 else if (k >= depthBegin && k < depthEnd) { 2794 norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k); 2795 } 2796 else { 2797 break; 2798 } 2799 } 2800 2801 norm = float(${n}) * norm + float(${r}); 2802 2803 for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){ 2804 if (k < depthBegin){ 2805 continue; 2806 } 2807 else if (k >= depthBegin && k < depthEnd){ 2808 float dyi = -2.0 * float(${n}) 2809 * float(${a}) 2810 * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d) 2811 / norm; 2812 if (k == d) { 2813 dyi += pow(norm, -1.0 * ${a}); 2814 } 2815 if (k == coords[3]) { 2816 dyi *= getDy(b, r, c, d); 2817 result += dyi; 2818 } 2819 } 2820 else { 2821 break; 2822 } 2823 } 2824 } 2825 setOutput(result); 2826 } 2827 `}}let mO={kernelName:W.ToN,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a,y:s,dy:i}=t,{depthRadius:o,bias:l,alpha:u,beta:h}=n,p=new mD(a.shape,o,l,u,h);return r.runWebGLProgram(p,[a,s,i],a.dtype)}};function mL(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{reductionIndices:i,keepDims:o}=a,l=s.shape.length,u=W.ZSL.parseAxisParam(i,s.shape),h=u,p=W.C0T.getAxesPermutation(h,l),d=null!=p,c=n.shouldExecuteOnCPU([s]),f=s;if(d){if(c){let e=n.texData.get(f.dataId).values,t=Array(l);for(let e=0;e<t.length;e++)t[e]=s.shape[p[e]];let r=(0,dx.Q5)(e,s.shape,s.dtype,p,t);f=n.makeTensorInfo(t,s.dtype),n.texData.get(f.dataId).values=r}else f=dF(s,p,n);h=W.C0T.getInnerMostAxes(h.length,l)}W.C0T.assertAxesAreInnerMostDims("max",h,l);let[m,g]=W.C0T.computeOutAndReduceShapes(f.shape,h),y=m;
2827if(o&&(y=W.C0T.expandShapeToKeepDim(m,u)),c){let e=n.texData.get(f.dataId).values,r=(0,dx.rw)(e,W.ZSL.sizeFromShape(g),y,s.dtype);t=n.makeTensorInfo(y,s.dtype),n.texData.get(t.dataId).values=r}else t=function(e,t,r,n){let a=W.ZSL.sizeFromShape(t),s=W.ZSL.sizeFromShape(e.shape),i=dN({inputs:{x:e},attrs:{shape:[s/a,a]},backend:n}),o=dE(i,e.dtype,"max",n),l=dN({inputs:{x:o},attrs:{shape:r},backend:n});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}(f,g,y,n);return d&&n.disposeIntermediateTensorInfo(f),t}let mM={kernelName:W.VAI,backendName:"webgl",kernelFunc:mL},mP=df({opSnippet:p3+` 2828 return max(a, b); 2829`,packedOpSnippet:` 2830 vec4 result = vec4(max(a, b)); 2831 bvec4 isNaNA = isnan(a); 2832 bvec4 isNaNB = isnan(b); 2833 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 2834 `+p8+` 2835 return result; 2836`,cpuKernelImpl:dx.Dy}),mz={kernelName:W.LDN,backendName:"webgl",kernelFunc:mP},mB={kernelName:W.t3d,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t;(0,pq.assertNotComplex)(a,"maxPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=n;W.ZSL.assert(W.C0T.eitherStridesOrDilationsAreOne(i,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '1'`);let u=W.C0T.computePool2DInfo(a.shape,s,i,1,o,l);if(1===u.filterWidth&&1===u.filterHeight&&W.ZSL.arraysEqual(u.inShape,u.outShape))return p9({inputs:{x:a},backend:r});let h=new cn(u,"max",!1);return r.runWebGLProgram(h,[a],a.dtype)}},mW={kernelName:W.ySp,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{filterSize:s,strides:i,pad:o,dataFormat:l,dimRoundingMode:u}=n,h=new ca(W.C0T.computePool3DInfo(a.shape,s,i,[1,1,1],o,u,l),"max",!1);return r.runWebGLProgram(h,[a],a.dtype)}};class mV{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideHeight,r=e.strideWidth,n=e.dilationHeight,a=e.effectiveFilterHeight,s=e.effectiveFilterWidth,i=a-1-e.padInfo.top,o=s-1-e.padInfo.left;this.userCode=` 2837 const ivec2 pads = ivec2(${i}, ${o}); 2838 2839 void main() { 2840 ivec4 coords = getOutputCoords(); 2841 int b = coords[0]; 2842 int d = coords[3]; 2843 2844 ivec2 dyRCCorner = coords.yz - pads; 2845 int dyRCorner = dyRCCorner.x; 2846 int dyCCorner = dyRCCorner.y; 2847 2848 // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). 2849 // ? = to be determined. : = across all values in that axis. 2850 float dotProd = 0.0; 2851 for (int wR = 0; wR < ${a}; 2852 wR += ${n}) { 2853 float dyR = float(dyRCorner + wR) / ${t}.0; 2854 2855 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 2856 continue; 2857 } 2858 int idyR = int(dyR); 2859 2860 for (int wC = 0; wC < ${s}; wC++) { 2861 float dyC = float(dyCCorner + wC) / ${r}.0; 2862 2863 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 2864 fract(dyC) > 0.0) { 2865 continue; 2866 } 2867 int idyC = int(dyC); 2868 2869 float dyValue = getDy(b, idyR, idyC, d); 2870 int maxPosValue = ${a*s-1} - int(getMaxPos(b, idyR, idyC, d)); 2871 2872 // Get the current value, check it against the value from the 2873 // position matrix. 2874 int curPosValue = wR * ${s} + wC; 2875 float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); 2876 2877 dotProd += dyValue * mask; 2878 } 2879 } 2880 setOutput(dotProd); 2881 } 2882 `}}class mU{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideDepth,r=e.strideHeight,n=e.strideWidth,a=e.dilationDepth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterDepth,l=e.effectiveFilterHeight,u=e.effectiveFilterWidth,h=o-1-e.padInfo.front,p=l-1-e.padInfo.top,d=u-1-e.padInfo.left;this.userCode=` 2883 const ivec3 pads = ivec3(${h}, ${p}, ${d}); 2884 2885 void main() { 2886 ivec5 coords = getOutputCoords(); 2887 int batch = coords.x; 2888 int ch = coords.u; 2889 2890 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 2891 int dyDCorner = dyCorner.x; 2892 int dyRCorner = dyCorner.y; 2893 int dyCCorner = dyCorner.z; 2894 2895 // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get
2896 // dx(xD, xR, xC, ch). 2897 // ? = to be determined. : = across all values in that axis. 2898 float dotProd = 0.0; 2899 2900 for (int wD = 0; wD < ${o}; 2901 wD += ${a}) { 2902 float dyD = float(dyDCorner + wD) / ${t}.0; 2903 2904 if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) { 2905 continue; 2906 } 2907 int idyD = int(dyD); 2908 2909 for (int wR = 0; wR < ${l}; 2910 wR += ${s}) { 2911 float dyR = float(dyRCorner + wR) / ${r}.0; 2912 2913 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 2914 fract(dyR) > 0.0) { 2915 continue; 2916 } 2917 int idyR = int(dyR); 2918 2919 for (int wC = 0; wC < ${u}; 2920 wC += ${i}) { 2921 float dyC = float(dyCCorner + wC) / ${n}.0; 2922 2923 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 2924 fract(dyC) > 0.0) { 2925 continue; 2926 } 2927 int idyC = int(dyC); 2928 2929 float dyValue = getDy(batch, idyD, idyR, idyC, ch); 2930 int maxPosValue = ${o*l*u-1} - 2931 int(getMaxPos(batch, idyD, idyR, idyC, ch)); 2932 2933 // Get the current value, check it against the value from the 2934 // position matrix. 2935 int curPosValue = 2936 wD * ${l} * ${u} + 2937 wR * ${u} + wC; 2938 float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); 2939 2940 dotProd += dyValue * mask; 2941 } 2942 } 2943 } 2944 setOutput(dotProd); 2945 } 2946 `}}let mG={kernelName:W.cHb,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=n,h=W.C0T.computePool3DInfo(s.shape,i,o,[1,1,1],l,u),p=new ca(h,"max",!0),d=r.runWebGLProgram(p,[s],s.dtype),c=new mU(h),f=r.runWebGLProgram(c,[a,d],s.dtype);return r.disposeIntermediateTensorInfo(d),f}},mZ={kernelName:W.RXX,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s,output:i}=t;(0,pq.assertNotComplex)([s,i],"maxPoolGrad");let{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=n,p=W.C0T.computePool2DInfo(s.shape,o,l,1,u,h),d=new cn(p,"max",!0),c=r.runWebGLProgram(d,[s],s.dtype),f=new mV(p),m=r.runWebGLProgram(f,[a,c],s.dtype);return r.disposeIntermediateTensorInfo(c),m}},mj={kernelName:W.TL8,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{x:n}=e,{filterSize:a,strides:s,pad:i,includeBatchInIndex:o}=t;W.ZSL.assert(4===n.shape.length,()=>`Error in maxPool: input must be rank 4 but got rank ${n.shape.length}.`);let l=[1,1];W.ZSL.assert(W.C0T.eitherStridesOrDilationsAreOne(s,l),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '${l}'`);let u=W.C0T.computePool2DInfo(n.shape,a,s,l,i),[h,p]=function(e,t,r,n){let a=new cn(r,"max",!1),s=n.runWebGLProgram(a,[e],"float32");return a=new cn(r,"max",!0,!0,t),[s,n.runWebGLProgram(a,[e],"float32")]}(n,o,u,r);return[h,p]}},mK={kernelName:W.g5A,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{x:n}=e,{keepDims:a,axis:s}=t,i=n.shape.length,o=W.ZSL.parseAxisParam(s,n.shape),l=o,u=W.C0T.getAxesPermutation(l,i),h=null!=u,p=r.shouldExecuteOnCPU([n]),d=[],c=n;if(h){if(p){let e=r.texData.get(c.dataId).values,t=Array(i);for(let e=0;e<t.length;e++)t[e]=n.shape[u[e]];let a=(0,dx.Q5)(e,n.shape,n.dtype,u,t);c=r.makeTensorInfo(t,n.dtype),r.texData.get(c.dataId).values=a}else c=dF(n,u,r);d.push(c),l=W.C0T.getInnerMostAxes(l.length,i)}W.C0T.assertAxesAreInnerMostDims("sum",l,i);let[f,m]=W.C0T.computeOutAndReduceShapes(c.shape,l),g=f;a&&(g=W.C0T.expandShapeToKeepDim(f,o));let y=function(e,t,r,n){let a=W.ZSL.sizeFromShape(t),s=W.ZSL.sizeFromShape(e.shape),i=dN({inputs:{x:e},attrs:{shape:[s/a,a]},backend:n}),o=dE(i,"float32","mean",n),l=dN({inputs:{x:o},attrs:{shape:r},backend:n});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}(c,m,g,r);for(let e of d)r.disposeIntermediateTensorInfo(e);return y}},mH={kernelName:W.lNG,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{axis:i,keepDims:o}=a,l=s.shape.length,u=W.ZSL.parseAxisParam(i,s.shape),h=u,p=W.C0T.getAxesPermutation(h,l),d=s;null!=p&&(d=dD({inputs:{x:s},backend:n,attrs:{perm:p}}),h=W.C0T.getInnerMostAxes(h.length,s.shape.length)),W.C0T.assertAxesAreInnerMostDims("min",h,l);
2946let[c,f]=W.C0T.computeOutAndReduceShapes(d.shape,h),m=dN({inputs:{x:d},backend:n,attrs:{shape:[-1,W.ZSL.sizeFromShape(f)]}}),g=dE(m,m.dtype,"min",n);return t=o?dN({inputs:{x:g},backend:n,attrs:{shape:W.C0T.expandShapeToKeepDim(c,u)}}):dN({inputs:{x:g},backend:n,attrs:{shape:c}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),null!=p&&n.disposeIntermediateTensorInfo(d),t}},mY=df({opSnippet:p3+` 2947 return min(a, b); 2948`,packedOpSnippet:` 2949 vec4 result = vec4(min(a, b)); 2950 bvec4 isNaNA = isnan(a); 2951 bvec4 isNaNB = isnan(b); 2952 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 2953 `+p8+` 2954 return result; 2955`,cpuKernelImpl:dx.h}),mQ={kernelName:W.LG0,backendName:"webgl",kernelFunc:mY};class mq{constructor(e,t,r){this.variableNames=["x"],this.outputShape=t.map((t,r)=>t[0]+e[r]+t[1]);let n=e.length,a=(0,p5.bf)(n),s=t.map(e=>e[0]).join(","),i=t.map((t,r)=>t[0]+e[r]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,n),l=+("reflect"!==r);if(1===n){this.userCode=` 2956 int start = ${s}; 2957 int end = ${i}; 2958 2959 void main() { 2960 int outC = getOutputCoords(); 2961 if (outC < start) { 2962 outC = start * 2 - outC - ${l}; 2963 } else if(outC >= end) { 2964 outC = (end - 1) * 2 - outC + ${l}; 2965 } 2966 setOutput(getX(outC - start)); 2967 } 2968 `;return}this.userCode=` 2969 ${a} start = ${a}(${s}); 2970 ${a} end = ${a}(${i}); 2971 2972 void main() { 2973 ${a} outC = getOutputCoords(); 2974 for (int i = 0; i < ${n}; i++) { 2975 if (outC[i] < start[i]) { 2976 outC[i] = start[i] * 2 - outC[i] - ${l}; 2977 } else if(outC[i] >= end[i]) { 2978 outC[i] = (end[i] - 1) * 2 - outC[i] + ${l}; 2979 } 2980 } 2981 ${a} coords = outC - start; 2982 setOutput(getX(${o})); 2983 } 2984 `}}class mX{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((t,r)=>t[0]+e[r]+t[1]);let n=e.length,a=(0,p5.bf)(n),s=t.map(e=>e[0]).join(","),i=t.map((t,r)=>t[0]+e[r]).join(","),o=(0,p6.Jp)("rc",n),l=(0,p6.Jp)("source",n),u=`${o[n-1]} < ${this.outputShape[n-1]}`,h=1===n?"source":`vec2(${l.slice(-2).join()})`,p=+("reflect"!==r),d="";if(1===n){let e=` 2985 ${a} source = rc; 2986 if (source < start) { 2987 source = start * 2 - source - ${p}; 2988 } else if (source >= end) { 2989 source = (end - 1) * 2 - source + ${p}; 2990 } 2991 source -= start; 2992 `;d=` 2993 ${a} rc = outputLoc; 2994 ${e} 2995 result[0] = getChannel(getX(${l.join()}), ${h}); 2996 ${o[n-1]} += 1; 2997 if(${u}) { 2998 ${e} 2999 result[1] = getChannel(getX(${l.join()}), ${h}); 3000 } 3001 `}else{let e=` 3002 ${a} source = rc; 3003 ${a} lt = ${a}(lessThan(source, start)); 3004 ${a} gte = ${a}(greaterThanEqual(source, end)); 3005 ${a} orig = 1 - (lt + gte); 3006 source = orig * source + 3007 lt * (start * 2 - source - ${p}) + 3008 gte * ((end - 1) * 2 - source + ${p}); 3009 source -= start; 3010 `;d=` 3011 ${a} rc = outputLoc; 3012 ${e} 3013 result[0] = getChannel(getX(${l.join()}), ${h}); 3014 ${o[n-1]} += 1; 3015 if(${u}) { 3016 ${e} 3017 result[1] = getChannel(getX(${l.join()}), ${h}); 3018 } 3019 rc = outputLoc; 3020 ${o[n-2]} += 1; 3021 if(${o[n-2]} < ${this.outputShape[n-2]}) { 3022 ${e} 3023 result[2] = getChannel(getX(${l.join()}), ${h}); 3024 ${o[n-1]} += 1; 3025 if(${u}) { 3026 ${e} 3027 result[3] = getChannel(getX(${l.join()}), ${h}); 3028 } 3029 } 3030 `}this.userCode=` 3031 const ${a} start = ${a}(${s}); 3032 const ${a} end = ${a}(${i}); 3033 3034 void main() { 3035 ${a} outputLoc = getOutputCoords(); 3036 vec4 result = vec4(0.); 3037 ${d} 3038 setOutput(result); 3039 } 3040 `}}let mJ={kernelName:W.x7F,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n}=e,{paddings:a,mode:s}=r,i=(0,W._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new mX(n.shape,a,s):new mq
3040(n.shape,a,s);return t.runWebGLProgram(i,[n],n.dtype)}},m0=df({opSnippet:`if (b == 0.0) return NAN; 3041 return mod(a, b);`,packedOpSnippet:` 3042 vec4 result = mod(a, b); 3043 bvec4 isNaN = equal(b, vec4(0.0)); 3044 `+p8+` 3045 return result; 3046`}),m1={kernelName:W.BLA,backendName:"webgl",kernelFunc:m0};class m2{constructor(e,t,r){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,r],this.userCode=` 3047 void main() { 3048 ivec2 coords = getOutputCoords(); 3049 int batch = coords[0]; 3050 3051 float r = random(seed); 3052 float cdf = 0.0; 3053 3054 for (int i = 0; i < ${t-1}; i++) { 3055 cdf += getProbs(batch, i); 3056 3057 if (r < cdf) { 3058 setOutput(float(i)); 3059 return; 3060 } 3061 } 3062 3063 // If no other event happened, last event happened. 3064 setOutput(float(${t-1})); 3065 } 3066 `}}let m3=df({opSnippet:` 3067if (a == b) { 3068 return 1.0; 3069}; 3070return a / b;`,packedOpSnippet:` 3071 // vec4 one = vec4(equal(a, b)); 3072 // return one + (vec4(1.0) - one) * a / b; 3073 vec4 result = a / b; 3074 if(a.x == b.x) { 3075 result.x = 1.; 3076 } 3077 if(a.y == b.y) { 3078 result.y = 1.; 3079 } 3080 if(a.z == b.z) { 3081 result.z = 1.; 3082 } 3083 if(a.w == b.w) { 3084 result.w = 1.; 3085 } 3086 3087 return result; 3088`,checkOutOfBounds:!0}),m4={kernelName:W.sDr,backendName:"webgl",kernelFunc:m3},m6="return a - b;",m5=df({opSnippet:m6,packedOpSnippet:m6,supportsComplex:!0,cpuKernelImpl:dx.lL}),m8={kernelName:W.PbM,backendName:"webgl",kernelFunc:m5};function m7(e){let{inputs:t,backend:r,attrs:n}=e,{logits:a}=t,{dim:s}=n,i=W.ZSL.parseAxisParam([s],a.shape),o=mL({inputs:{x:a},backend:r,attrs:{reductionIndices:i,keepDims:!1}}),l=W.C0T.expandShapeToKeepDim(o.shape,i),u=dN({inputs:{x:o},backend:r,attrs:{shape:l}}),h=m5({inputs:{a:a,b:u},backend:r}),p=fM({inputs:{x:h},backend:r}),d=dR({inputs:{x:p},backend:r,attrs:{axis:i,keepDims:!1}}),c=dN({inputs:{x:d},backend:r,attrs:{shape:l}}),f=m3({inputs:{a:p,b:c},backend:r});return r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(u),r.disposeIntermediateTensorInfo(h),r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(c),f}let m9={kernelName:W.rFG,backendName:"webgl",kernelFunc:m7},ge={kernelName:W.WT3,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{logits:a}=t,{numSamples:s,seed:i,normalized:o}=n,l=o?a:m7({inputs:{logits:a},backend:r,attrs:{dim:a.shape.length-1}}),u=new m2(l.shape[0],l.shape[1],s),h=r.runWebGLProgram(u,[l],"int32",[[i]]);return o||r.disposeIntermediateTensorInfo(l),h}},gt=dh.dR+` 3089 return -x; 3090`,gr=` 3091 vec4 result = -x; 3092 bvec4 isNaN = isnan(x); 3093 3094 result.r = isNaN.r ? x.r : result.r; 3095 result.g = isNaN.g ? x.g : result.g; 3096 result.b = isNaN.b ? x.b : result.b; 3097 result.a = isNaN.a ? x.a : result.a; 3098 3099 return result; 3100`,gn={kernelName:W.l0G,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n}=e,{x:a}=r;if(n.shouldExecuteOnCPU([a])){let e=n.texData.get(a.dataId),[t,r]=(0,dx.rQ)(e.values,a.shape,a.dtype);return n.makeTensorInfo(r,a.dtype,t)}return t=(0,W._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new dp.rf(a.shape,gr):new dh.hE(a.shape,gt),n.runWebGLProgram(t,[a],a.dtype)}},ga=W.kpo.nonMaxSuppressionV3Impl,gs={kernelName:W.SDM,backendName:"webgl",kernelFunc:function(e){W.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=n,{selectedIndices:u}=ga(r.readSync(a.dataId),r.readSync(s.dataId),i,o,l);return r.makeTensorInfo([u.length],"int32",new Int32Array(u))}},gi=W.kpo.nonMaxSuppressionV4Impl,go={kernelName:W.Zl4,backendName:"webgl",kernelFunc:function(e){W.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:u}=n,{selectedIndices:h,validOutputs:p}=gi(r.readSync(a.dataId),r.readSync(s.dataId),i,o,l,u);return[r.makeTensorInfo([h.length],"int32",new Int32Array(h)),r.makeTensorInfo([],"int32",new Int32Array([p]))]}},gl=W.kpo.nonMaxSuppressionV5Impl,gu={kernelName:W.e0f,backendName:"webgl",kernelFunc:function(e){W.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=n,h=r.readSync(a.dataId),{selectedIndices:p,selectedScores:d}=gl(h,r.readSync(s.dataId),i,o,l,u);return[r.makeTensorInfo([p.length],"int32",new Int32Array(p)),r.makeTensorInfo([d.length],"float32",new Float32Array(d))]}};class gh{constructor(e,t,r,n){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=` 3101 void main() { 3102 ivec2 coords = getOutputCoords(); 3103 int index = round(getIndices(coords.x)); 3104 setOutput(mix(float(${n}), float(${r}), 3105 float(index == coords.y))); 3106 } 3107 `}}let gp={kernelName:W.urI,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{indices:a}=t,{dtype:s,depth:i,onValue:o,offValue:l}
3107=n,u=W.ZSL.sizeFromShape(a.shape),h=new gh(u,i,o,l),p=dN({inputs:{x:a},backend:r,attrs:{shape:[u]}}),d=r.runWebGLProgram(h,[p],s);r.disposeIntermediateTensorInfo(p);let c=dN({inputs:{x:d},backend:r,attrs:{shape:[...a.shape,i]}});return r.disposeIntermediateTensorInfo(d),c}};function gd(e){let{inputs:t,backend:r}=e,{x:n}=t;if("complex64"!==n.dtype)return fH({attrs:{shape:n.shape,dtype:n.dtype,value:"string"===n.dtype?"":0},backend:r});{let e=cE({inputs:{input:n},backend:r}),t=gd({inputs:{x:e},backend:r}),a=cU({inputs:{input:n},backend:r}),s=gd({inputs:{x:a},backend:r}),i=dt({inputs:{real:t,imag:s},backend:r});return r.disposeIntermediateTensorInfo(e),r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(s),i}}let gc={kernelName:W.xJ3,backendName:"webgl",kernelFunc:gd},gf={kernelName:W.LWX,backendName:"webgl",kernelFunc:function e(t){let{inputs:r,backend:n}=t,{x:a}=r;if("string"===a.dtype)throw Error("onesLike is not supported under string dtype");if("complex64"!==a.dtype)return fH({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:n});{let t=cE({inputs:{input:a},backend:n}),r=e({inputs:{x:t},backend:n}
3107),s=cU({inputs:{input:a},backend:n}),i=gd({inputs:{x:s},backend:n}),o=dt({inputs:{real:r,imag:i},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),o}}},gm={kernelName:W.mM$,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{axis:a}=n;if(1===t.length)return fz({inputs:{input:t[0]},backend:r,attrs:{dim:a}});let s=t[0].shape,i=t[0].dtype;t.forEach(e=>{W.ZSL.assertShapesMatch(s,e.shape,"All tensors passed to stack must have matching shapes"),W.ZSL.assert(i===e.dtype,()=>"All tensors passed to stack must have matching dtypes")});let o=[],l=cZ({inputs:t.map(e=>{let t=fz({inputs:{input:e},backend:r,attrs:{dim:a}});return o.push(t),t}),backend:r,attrs:{axis:a}});return o.forEach(e=>r.disposeIntermediateTensorInfo(e)),l}};class gg{constructor(e,t,r){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((t,r)=>t[0]+e[r]+t[1]);let n=e.length,a=(0,p5.bf)(n),s=t.map(e=>e[0]).join(","),i=t.map((t,r)=>t[0]+e[r]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,n);if(1===n){this.userCode=` 3108 int start = ${s}; 3109 int end = ${i}; 3110 3111 void main() { 3112 int outC = getOutputCoords(); 3113 if (outC < start || outC >= end) { 3114 setOutput(value); 3115 } else { 3116 setOutput(getX(outC - start)); 3117 } 3118 } 3119 `;return}this.userCode=` 3120 ${a} start = ${a}(${s}); 3121 ${a} end = ${a}(${i}); 3122 3123 void main() { 3124 ${a} outC = getOutputCoords(); 3125 if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) { 3126 setOutput(value); 3127 } else { 3128 ${a} coords = outC - start; 3129 setOutput(getX(${o})); 3130 } 3131 } 3132 `}}class gy{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((t,r)=>t[0]+e[r]+t[1]);let n=e.length,a=(0,p5.bf)(n),s=t.map(e=>e[0]).join(","),i=t.map((t,r)=>t[0]+e[r]).join(","),o=(0,p6.Jp)("rc",n),l=(0,p6.Jp)("source",n),u=`${o[n-1]} < ${this.outputShape[n-1]}`,h=1===n?"source":`vec2(${l.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${o[n-1]} += 1; 3133 if(${u}) { 3134 `,1===n?"":`} 3135 rc = outputLoc; 3136 ${o[n-2]} += 1; 3137 if(${o[n-2]} < ${this.outputShape[n-2]}) {`,1===n?"":` ${o[n-1]} += 1; 3138 if(${u}) {`],d=1===n?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",c="";for(let e=0,t=1===n?2:4;e<t;e++)c+=` 3139 ${p[e]} 3140 if (${d}) { 3141 result[${e}] = float(value); 3142 } else { 3143 ${a} source = rc - start; 3144 result[${e}] = getChannel(getX(${l.join()}), ${h}); 3145 } 3146 `;c+=1===n?"} ":"}}",this.userCode=` 3147 const ${a} start = ${a}(${s}); 3148 const ${a} end = ${a}(${i}); 3149 3150 void main() { 3151 ${a} outputLoc = getOutputCoords(); 3152 vec4 result = vec4(0.); 3153 ${c} 3154 setOutput(result); 3155 } 3156 `}}let gb=e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{paddings:s,constantValue:i}=n;if(0===W.ZSL.sizeFromShape(a.shape))return fH({backend:r,attrs:{shape:s.map((e,t)=>e[0]+a.shape[t]+e[1]),value:i,dtype:a.dtype}});let o=(0,W._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new gy(a.shape,s,i):new gg(a.shape,s,i),l=[[i]];return r.runWebGLProgram(o,[a],a.dtype,l)},gx={kernelName:W.ODT,backendName:"webgl",kernelFunc:gb},gv=df({opSnippet:` 3157 if(a < 0.0 && floor(b) < b){ 3158 return NAN; 3159 } 3160 if (b == 0.0) { 3161 return 1.0; 3162 } 3163 return (round(mod(b, 2.0)) != 1) ?
3164 pow(abs(a), b) : sign(a) * pow(abs(a), b); 3165`,packedOpSnippet:` 3166 // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise. 3167 vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1))); 3168 vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); 3169 vec4 result = multiplier * pow(abs(a), b); 3170 3171 // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS 3172 bvec4 isExpZero = equal(b, vec4(0.0)); 3173 result.r = isExpZero.r ? 1.0 : result.r; 3174 result.g = isExpZero.g ? 1.0 : result.g; 3175 result.b = isExpZero.b ? 1.0 : result.b; 3176 result.a = isExpZero.a ? 1.0 : result.a; 3177 3178 bvec4 isNaN1 = lessThan(a, vec4(0.0)); 3179 bvec4 isNaN2 = lessThan(floor(b), b); 3180 bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w); 3181 `+p8+` 3182 return result; 3183`}),gw={kernelName:W.pyJ,backendName:"webgl",kernelFunc:gv},gT={kernelName:W.kdj,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{axis:i,keepDims:o}=a,l=s.shape.length,u=[],h=W.ZSL.parseAxisParam(i,s.shape),p=h,d=W.C0T.getAxesPermutation(p,l),c=s;if(null!=d&&(c=dD({inputs:{x:s},backend:n,attrs:{perm:d}}),p=W.C0T.getInnerMostAxes(p.length,l),u.push(c)),W.C0T.assertAxesAreInnerMostDims("prod",p,l),n.shouldExecuteOnCPU([c])){let e=n.texData.get(c.dataId).values,{outVals:r,outShape:a,outDtype:s}=(0,dx.Og)(c.shape,c.dtype,e,p);t=n.makeTensorInfo(a,s,r)}else{let[e,r]=W.C0T.computeOutAndReduceShapes(c.shape,p),a=dN({inputs:{x:c},backend:n,attrs:{shape:[-1,W.ZSL.sizeFromShape(r)]}}),i=dE(a,(0,W.chL)(s.dtype),"prod",n);t=dN({inputs:{x:i},backend:n,attrs:{shape:e}}),u.push(a),u.push(i)}if(o){u.push(t);let e=W.C0T.expandShapeToKeepDim(t.shape,h);t=dN({inputs:{x:t},backend:n,attrs:{shape:e}})}return u.forEach(e=>n.disposeIntermediateTensorInfo(e)),t}},gS={kernelName:W.oJ2,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{paramsNestedSplits:a,paramsDenseValues:s,indices:i}=t,{outputRaggedRank:o}=n,l=a.map(e=>r.readSync(e.dataId)),u=a.map(e=>e.shape),h=r.readSync(s.dataId),p=r.readSync(i.dataId),[d,c,f]=(0,dx.G4)(l,u,h,s.shape,s.dtype,p,i.shape,o),m=d.map(e=>r.makeTensorInfo([e.length],"int32",e)),g=r.makeTensorInfo(f,s.dtype,c);return m.concat([g])}},gN={kernelName:W.CQC,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{starts:n,limits:a,deltas:s}=t,i=r.readSync(n.dataId),o=r.readSync(a.dataId),l=r.readSync(s.dataId),[u,h]=(0,dx.Oy)(i,n.shape,n.dtype,o,a.shape,l,s.shape);return[r.makeTensorInfo([u.length],"int32",u),r.makeTensorInfo([h.length],n.dtype,h)]}},gk={kernelName:W.mH5,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{shape:a,values:s,defaultValue:i,rowPartitionTensors:o}=t,{rowPartitionTypes:l}=n,u=r.readSync(a.dataId),h=r.readSync(s.dataId),p=r.readSync(i.dataId),d=o.map(e=>r.readSync(e.dataId)),c=o.map(e=>e.shape),[f,m]=(0,dx.G3)(u,a.shape,h,s.shape,s.dtype,p,i.shape,d,c,l);return r.makeTensorInfo(f,s.dtype,m)}},gI=e=>{let{backend:t,attrs:r}=e,{start:n,stop:a,step:s,dtype:i}=r,o=(0,dx.we)(n,a,s,i);return t.makeTensorInfo([o.length],i,o)},gC={kernelName:W.Q6t,backendName:"webgl",kernelFunc:gI},gE=dc({opSnippet:"return 1.0 / x;"}),gA={kernelName:W.huO,backendName:"webgl",kernelFunc:gE},g$=dc({opSnippet:dh.dR+` 3184 return (x < 0.0) ? 0.0 : x; 3185`,packedOpSnippet:` 3186 vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); 3187 bvec4 isNaN = isnan(x); 3188 3189 result.r = isNaN.r ? x.r : result.r; 3190 result.g = isNaN.g ? x.g : result.g; 3191 result.b = isNaN.b ? x.b : result.b; 3192 result.a = isNaN.a ? x.a : result.a; 3193 3194 return result; 3195`}),gF={kernelName:W.fUj,backendName:"webgl",kernelFunc:g$},gR=dc({opSnippet:dh.dR+` 3196 return (x < 0.0) ? 0.0 : min(6.0, x); 3197`,packedOpSnippet:` 3198 vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); 3199 bvec4 isNaN = isnan(x); 3200 3201 result.r = isNaN.r ? x.r : result.r; 3202 result.g = isNaN.g ? x.g : result.g; 3203 result.b = isNaN.b ? x.b : result.b; 3204 result.a = isNaN.a ? x.a : result.a; 3205 3206 return result; 3207`}),g_={kernelName:W.P_L,backendName:"webgl",kernelFunc:gR};class gD{constructor(e,t,r,n,a){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,r,l];let u=[n&&t>1?i-1:i,n&&r>1?o-1:o],h=[n&&t>1?t-1:t,n&&r>1?r-1:r];this.userCode=` 3208 const vec2 effectiveInputOverOutputRatioRC = vec2( 3209 ${u[0]/h[0]}, 3210 ${u[1]/h[1]}); 3211 const vec2 inputShapeRC = vec2(${i}.0, ${o}.0); 3212 3213 void main() { 3214 ivec4 coords = getOutputCoords(); 3215 int b = coords[0]; 3216 int d = coords[3]; 3217 ivec2 yRC = coords.yz; 3218 3219 // Fractional source index. 3220 vec2 sourceFracIndexRC = ${a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC"}; 3221 3222 // Compute the four integer indices. 3223 ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0))); 3224 ivec2 sourceCeilRC = ivec2( 3225 min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); 3226 3227 float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d); 3228 float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d); 3229 float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d); 3230 float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d); 3231 3232 vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC); 3233 3234 float top = topLeft + (topRight - topLeft) * fracRC.y; 3235 float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y; 3236 float newValue = top + (bottom - top) * fracRC.x; 3237 3238 setOutput(newValue); 3239 } 3240 `}}class gO{constructor(e,t,r,n,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,r,l];let u=[n&&t>1?i-1:i,n&&r>1?o-1:o],h=[n&&t>1?t-1:t,n&&r>1?r-1:r];this.userCode=` 3241 const vec3 effectiveInputOverOutputRatioRC = vec3( 3242 ${u[0]/h[0]}, 3243 ${u[1]/h[1]}, 3244 ${u[1]/h[1]}); 3245 const vec3 inputShapeRC = vec3(${i}.0, ${o}.0, 3246 ${o}.0); 3247 3248 float getAValue(int b, int r, int c, int d) { 3249 return getChannel(getA(b, r, c, d), vec2(c, d)); 3250 } 3251 3252 void main() { 3253 ivec4 coords = getOutputCoords(); 3254 int b = coords[0]; 3255 int d = coords[3]; 3256 // Calculate values for next column in yRC.z. 3257 ivec3 yRC = coords.yzz + ivec3(0, 0, 1); 3258 3259 // Fractional source index. 3260 vec3 sourceFracIndexRC = ${a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC"}; 3261 3262 // Compute the four integer indices. 3263 ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0))); 3264 ivec3 sourceCeilRC = ivec3( 3265 min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); 3266 3267 // Should we calculate next column and row elements in 2x2 packed cell. 3268 bool hasNextCol = d < ${l-1}; 3269 bool hasNextRow = coords.z < ${r-1}
vendor: 2,018 bytes, lines 3269-3317
3269; 3270 3271 // In parallel, construct four corners for all four components in 3272 // packed 2x2 cell. 3273 vec4 topLeft = vec4( 3274 getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d), 3275 hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1) 3276 : 0.0, 3277 hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d) 3278 : 0.0, 3279 (hasNextRow && hasNextCol) ? 3280 getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0); 3281 3282 vec4 bottomLeft = vec4( 3283 getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d), 3284 hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1) 3285 : 0.0, 3286 hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d) 3287 : 0.0, 3288 (hasNextRow && hasNextCol) ? 3289 getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0); 3290 3291 vec4 topRight = vec4( 3292 getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d), 3293 hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1) 3294 : 0.0, 3295 hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d) 3296 : 0.0, 3297 (hasNextRow && hasNextCol) ? 3298 getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0); 3299 3300 vec4 bottomRight = vec4( 3301 getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d), 3302 hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1) 3303 : 0.0, 3304 hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d) 3305 : 0.0, 3306 (hasNextRow && hasNextCol) ? 3307 getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0); 3308 3309 vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC); 3310 3311 vec4 top = mix(topLeft, topRight, fracRC.yyzz); 3312 vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz); 3313 vec4 newValue = mix(top, bottom, fracRC.x); 3314 3315 setOutput(newValue); 3316 } 3317 `}
3317}let gL={kernelName:W.hgw,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a}=t,{alignCorners:s,halfPixelCenters:i,size:o}=n,[l,u]=o,h=(0,W._K2)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new gO(a.shape,l,u,s,i):new gD(a.shape,l,u,s,i);return r.runWebGLProgram(h,[a],"float32")}};class gM{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,n,a]=t,[,s,i]=e,o=[r&&s>1?n-1:n,r&&i>1?a-1:a],l=[r&&s>1?s-1:s,r&&i>1?i-1:i],u=o[0]/l[0],h=o[1]/l[1],p=1/u,d=1/h,c=2*Math.ceil(p)+2,f=2*Math.ceil(d)+2;this.userCode=` 3318 void main() { 3319 ivec4 coords = getOutputCoords(); 3320 int b = coords[0]; 3321 int d = coords[3]; 3322 int r = coords[1]; 3323 int c = coords[2]; 3324 3325 float accumulator = 0.0; 3326 3327 const float heightScale = float(${u}); 3328 const float widthScale = float(${h}); 3329 3330 const float invHeightScale = float(${p}); 3331 const float invWidthScale = float(${d}); 3332 3333 const int winHeight = int(${c}); 3334 const int winWidth = int(${f}); 3335 3336 // Compute bounds for where in dy we will look 3337 float startRLerp = floor(float(r) * invHeightScale); 3338 int startDyR = int(startRLerp - float(winHeight / 2)); 3339 3340 float startCLerp = floor(float(c) * invWidthScale); 3341 int startDyC = int(startCLerp - float(winWidth / 2)); 3342 3343 // Loop over dy 3344 for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { 3345 int dyR = dyROffset + startDyR; 3346 3347 // Guard against the window exceeding the bounds of dy 3348 if (dyR < 0 || dyR >= ${s}) { 3349 continue; 3350 } 3351 3352 for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { 3353 int dyC = dyCOffset + startDyC; 3354 3355 // Guard against the window exceeding the bounds of dy 3356 if (dyC < 0 || dyC >= ${i}) { 3357 continue; 3358 } 3359 3360 float dxR = float(dyR) * heightScale; 3361 int topDxRIndex = int(floor(dxR)); 3362 int bottomDxRIndex = int(min(ceil(dxR), ${n-1}.0)); 3363 float dxRLerp = dxR - float(topDxRIndex); 3364 float inverseDxRLerp = 1.0 - dxRLerp; 3365 3366 float dxC = float(dyC) * widthScale; 3367 int leftDxCIndex = int(floor(dxC)); 3368 int rightDxCIndex = int(min(ceil(dxC), ${a-1}.0)); 3369 float dxCLerp = dxC - float(leftDxCIndex); 3370 float inverseDxCLerp = 1.0 - dxCLerp; 3371 3372 if (r == topDxRIndex && c == leftDxCIndex) { 3373 // topLeft 3374 accumulator += 3375 getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp; 3376 } 3377 3378 if (r == topDxRIndex && c == rightDxCIndex) { 3379 // topRight 3380 accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp; 3381 } 3382 3383 if (r == bottomDxRIndex && c == leftDxCIndex) { 3384 // bottomLeft 3385 accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp; 3386 } 3387 3388 if (r == bottomDxRIndex && c == rightDxCIndex) { 3389 // bottomRight 3390 accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp; 3391 } 3392 } 3393 } 3394 // End loop over dy 3395 3396 setOutput(accumulator); 3397 } 3398 `}}let gP={kernelName:W.FCQ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a,dy:s}=t,{alignCorners:i}=n,o=new gM(s.shape,a.shape,i);return r.runWebGLProgram(o,[s],s.dtype)}};class gz{constructor(e,t,r,n,a){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,r,l];let u=[n&&t>1?i-1:i,n&&r>1?o-1:o],h=[n&&t>1?t-1:t,n&&r>1?r-1:r];this.userCode=` 3399 const vec2 effectiveInputOverOutputRatioRC = vec2( 3400 ${u[0]/h[0]}, 3401 ${u[1]/h[1]}); 3402 const vec2 inputShapeRC = vec2(${i}.0, ${o}.0); 3403 3404 void main() { 3405 ivec4 coords = getOutputCoords(); 3406 int b = coords[0]; 3407 int d = coords[3]; 3408 ivec2 yRC = coords.yz; 3409 3410 // Fractional source index. 3411 vec2 sourceFracIndexRC = ${a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC"}; 3412 3413 // Compute the coordinators of nearest neighbor point. 3414 ivec2 sourceNearestRC = ivec2( 3415 min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${n?"0.5":"0.0"}))); 3416 float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d); 3417 3418 setOutput(newValue); 3419 } 3420 `}}class gB{constructor(e,t,r,n,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,r,l];let u=[n&&t>1?i-1:i,n&&r>1?o-1:o],h=[n&&t>1?t-1:t,n&&r>1?r-1:r];this.userCode=` 3421 const vec3 effectiveInputOverOutputRatioRC = vec3( 3422 ${u[0]/h[0]}, 3423 ${u[1]/h[1]}, 3424 ${u[1]/h[1]}); 3425 const vec3 inputShapeRC = vec3(${i}.0, ${o}.0, 3426 ${o}.0); 3427 3428 float getAValue(int b, int r, int c, int d) { 3429 return getChannel(getA(b, r, c, d), vec2(c, d)); 3430 } 3431 3432 void main() { 3433 ivec4 coords = getOutputCoords(); 3434 int b = coords[0]; 3435 int d = coords[3]; 3436 // Calculate values for next column in yRC.z. 3437 ivec3 yRC = coords.yzz + ivec3(0, 0, 1); 3438 3439 // Fractional source index. 3440 vec3 sourceFracIndexRC = ${a?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC"}; 3441 3442 // Compute the coordinators of nearest neighbor point. 3443 ivec3 sourceNearestRC = ivec3( 3444 min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${n?"0.5":"0.0"}))); 3445 3446 // Should we calculate next column and row elements in 2x2 packed cell. 3447 bool hasNextCol = d < ${l-1}; 3448 bool hasNextRow = coords.z < ${r-1}; 3449 3450 vec4 newValue = vec4(
3451 getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d), 3452 hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1) 3453 : 0.0, 3454 hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d) 3455 : 0.0, 3456 (hasNextRow && hasNextCol) ? 3457 getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0); 3458 3459 setOutput(newValue); 3460 } 3461 `}}let gW={kernelName:W.jOE,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a}=t,{alignCorners:s,halfPixelCenters:i,size:o}=n,[l,u]=o,h=(0,W._K2)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new gB(a.shape,l,u,s,i):new gz(a.shape,l,u,s,i);return r.runWebGLProgram(h,[a],a.dtype)}};class gV{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,n,a]=t,[,s,i]=e,o=[r&&s>1?n-1:n,r&&i>1?a-1:a],l=[r&&s>1?s-1:s,r&&i>1?i-1:i],u=o[0]/l[0],h=o[1]/l[1],p=1/u,d=1/h,c=2*Math.ceil(p)+2,f=2*Math.ceil(d)+2;this.userCode=` 3462 void main() { 3463 ivec4 coords = getOutputCoords(); 3464 int b = coords[0]; 3465 int d = coords[3]; 3466 int r = coords[1]; 3467 int c = coords[2]; 3468 3469 float accumulator = 0.0; 3470 3471 const float heightScale = float(${u}); 3472 const float widthScale = float(${h}); 3473 3474 const float invHeightScale = float(${p}); 3475 const float invWidthScale = float(${d}); 3476 3477 const int winHeight = int(${c}); 3478 const int winWidth = int(${f}); 3479 3480 // Compute bounds for where in dy we will look 3481 float startRLerp = floor(float(r) * invHeightScale); 3482 int startDyR = int(floor(startRLerp - float(winHeight / 2))); 3483 3484 float startCLerp = floor(float(c) * invWidthScale); 3485 int startDyC = int(floor(startCLerp - float(winWidth / 2))); 3486 3487 // Loop over dy 3488 for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { 3489 int dyR = dyROffset + startDyR; 3490 3491 // Guard against the window exceeding the bounds of dy 3492 if (dyR < 0 || dyR >= ${s}) { 3493 continue; 3494 } 3495 3496 for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { 3497 int dyC = dyCOffset + startDyC; 3498 3499 // Guard against the window exceeding the bounds of dy 3500 if (dyC < 0 || dyC >= ${i}) { 3501 continue; 3502 } 3503 3504 float sourceFracRow = 3505 float(${o[0]}) * 3506 (float(dyR) / float(${l[0]})); 3507 3508 float sourceFracCol = 3509 float(${o[1]}) * 3510 (float(dyC) / float(${l[1]})); 3511 3512 int sourceNearestRow = int(min( 3513 float(int(${n}) - 1), 3514 ${r} ? float(round(sourceFracRow)) : 3515 float(floor(sourceFracRow)))); 3516 3517 int sourceNearestCol = int(min( 3518 float(int(${a}) - 1), 3519 ${r} ? float(round(sourceFracCol)) : 3520 float(floor(sourceFracCol)))); 3521 3522 if (r == sourceNearestRow && c == sourceNearestCol) { 3523 accumulator += getDy(b, dyR, dyC, d); 3524 } 3525 } 3526 } 3527 // End loop over dy 3528 3529 setOutput(accumulator); 3530 } 3531 `}}let gU={kernelName:W.XQy,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a,dy:s}=t,{alignCorners:i}=n,o=new gV(s.shape,a.shape,i);return r.runWebGLProgram(o,[s],s.dtype)}};class gG{constructor(e,t){this.variableNames=["x"];let r=e.length;if(r>4)throw Error(`WebGL backend: Reverse of rank-${r} tensor is not yet supported`);if(this.outputShape=e,1===r){this.userCode=` 3532 void main() { 3533 int coord = getOutputCoords(); 3534 setOutput(getX(${e[0]} - coord - 1)); 3535 } 3536 `;return}let n=e.map((r,n)=>(r=>-1!==t.indexOf(r)&&1!==e[r]?`${e[r]} - coords[${r}] - 1`:`coords[${r}]`)(n)).join(","),a=(0,p5.bf)(r);this.userCode=` 3537 void main() { 3538 ${a} coords = getOutputCoords(); 3539 setOutput(getX(${n})); 3540 } 3541 `}}class gZ{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;let r=e.length;if(r>4)throw Error(`WebGL backend: Reverse of rank-${r} tensor is not yet supported`);this.outputShape=e;let n=(0,p6.Jp)("rc",r),a=`${n[r-1]} + 1 < ${this.outputShape[r-1]}`,s=`${n[r-2]} + 1 < ${this.outputShape[r-2]}`,i=(0,p5.bf)(r);function o(r){let n=e.map((n,a)=>{var s,i;return s=a,i=r,-1!==t.indexOf(s)&&1!==e[s]?`${e[s]} - ${i[s]} - 1`:`${i[s]}`}),a=n.join(","),s=n.slice(-2).join(",");return`getChannel(getX(${a}), vec2(${s}))`}1===r?this.userCode=` 3542 void main(){ 3543 int rc = getOutputCoords(); 3544 vec4 result = vec4(0.); 3545 result.r = getChannel(getX(${e[0]} - rc - 1), 3546 ${e[0]} - rc - 1); 3547 if(${a}){ 3548 result.g = getChannel(getX(${e[0]} - (rc + 1) - 1), 3549 ${e[0]} - (rc + 1) - 1); 3550 } 3551 setOutput(result); 3552 } 3553 `:this.userCode=` 3554 void main() { 3555 ${i} rc = getOutputCoords(); 3556 vec4 result = vec4(0.); 3557 result.r = ${o(n.slice())}; 3558 if(${a}){ 3559 result.g = ${function(e){return e[r-1]="("+e[r-1]+" + 1)",o(e)}(n.slice())}; 3560 } 3561 if(${s}) { 3562 result.b = ${function(e){return e[r-2]="("+e[r-2]+" + 1)",o(e)}(n.slice())}; 3563 if(${a}) { 3564 result.a = ${function(e){return e[r-1]="("+e[r-1]+" + 1)",e[r-2]="("+e[r-2]+" + 1)",o(e)}(n.slice())}; 3565 } 3566 } 3567 setOutput(result); 3568 } 3569 `}}let gj={kernelName:W.D7i,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{dims:s}=n,i=a.shape.length,o=W.ZSL.parseAxisParam(s,a.shape);if(0===i)return p9({inputs:{x:a},backend:r});let l=(0,W._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new gZ(a.shape,o):new gG(a.shape,o);return r.runWebGLProgram(l,[a],a.dtype)}};class gK{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];let r=e[1],n=e[2];this.outputShape=e;let a="";a="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:` 3570 vec3 fill = vec3(${t.join(",")}); 3571 float outputValue = fill[coords[3]];`,this.userCode=` 3572 void main() { 3573 ivec4 coords = getOutputCoords(); 3574 int x = coords[2]; 3575 int y = coords[1]; 3576 float coordXFloat = (float(x) - params[0]) * params[3] - 3577 (float(y) - params[1]) * params[2]; 3578 float coordYFloat = (float(x) - params[0]) * params[2] + 3579 (float(y) - params[1]) * params[3];
3580 int coordX = int(round(coordXFloat + params[0])); 3581 int coordY = int(round(coordYFloat + params[1])); 3582 ${a} 3583 if(coordX >= 0 && coordX < ${n} && coordY >= 0 && coordY < ${r}) { 3584 outputValue = getImage(coords[0], coordY, coordX, coords[3]); 3585 } 3586 setOutput(outputValue); 3587 } 3588 `}}let gH={kernelName:W.BK4,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{image:n}=e,{radians:a,fillValue:s,center:i}=t,o=new gK(n.shape,s),[l,u]=W.C0T.getImageCenter(i,n.shape[1],n.shape[2]),h=[[l,u,Math.sin(a),Math.cos(a)]];return r.runWebGLProgram(o,[n],n.dtype,h)}},gY=dc({opSnippet:` 3589 // OpenGL ES does not support round function. 3590 // The algorithm is based on banker's rounding. 3591 float base = floor(x); 3592 if ((x - base) < 0.5) { 3593 return floor(x); 3594 } else if ((x - base) > 0.5) { 3595 return ceil(x); 3596 } else { 3597 if (mod(base, 2.0) == 0.0) { 3598 return base; 3599 } else { 3600 return base + 1.0; 3601 } 3602 } 3603`}),gQ={kernelName:W.hVg,backendName:"webgl",kernelFunc:gY},gq=dc({opSnippet:"return inversesqrt(x);",cpuKernelImpl:dx.tc}),gX={kernelName:W.TOR,backendName:"webgl",kernelFunc:gq};class gJ{constructor(e,t,r,n,a,s,i=!0,o=!1){this.variableNames=["updates","indices","defaultValue"],this.outputShape=s;let l=(0,p5.bf)(a.length),u=(0,p5.bf)(s.length),h="";1===r?h="i":2===r&&(h="i, j");let p=`getIndices(${h})`,d="";1===n?d="i":2===n&&(d="i, coords[1]");let c=`getUpdates(${d})`,f="";o&&(f="coords[0], coords[1]");let m=`getDefaultValue(${f})`;this.userCode=` 3604 ${l} strides = ${l}(${a}); 3605 3606 void main() { 3607 ${u} coords = getOutputCoords(); 3608 float sum = 0.0; 3609 bool found = false; 3610 for (int i = 0; i < ${e}; i++) { 3611 int flattenedIndex = 0; 3612 for (int j = 0; j < ${t}; j++) { 3613 int index = round(${p}); 3614 flattenedIndex += index * ${t>1?"strides[j]":"strides"}; 3615 } 3616 if (flattenedIndex == coords[0]) { 3617 sum += ${c}; 3618 found = true; 3619 } 3620 } 3621 setOutput(mix(${m}, sum, float(found))); 3622 } 3623 `}}class g0{constructor(e,t,r,n,a,s,i=!0,o=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=s;let l=(0,p5.bf)(a.length),u=(0,p5.bf)(s.length),h="";1===r?h="i":2===r&&(h="i, j");let p=`getIndices(${h})`,d="";1===n?d="i":2===n&&(d="i, coords[1]");let c=`getUpdates(${d})`,f="";o&&(f="coords[0], coords[1]");let m=`getDefaultValue(${f})`;this.userCode=` 3624 ${l} strides = ${l}(${a}); 3625 3626 void main() { 3627 ${u} coords = getOutputCoords(); 3628 vec4 sum = vec4(0.); 3629 vec4 found = vec4(0.); 3630 for (int i = 0; i < ${e}; i+=2) { 3631 ivec2 flattenedIndex = ivec2(0); 3632 for (int j = 0; j < ${t}; j+=2) { 3633 ivec4 index = round(${p}); 3634 flattenedIndex += index.xz * ${t>1?"strides[j]":"strides"}; 3635 if (j + 1 < ${t}) { 3636 flattenedIndex += index.yw * ${t>1?"strides[j + 1]":"strides"}; 3637 } 3638 } 3639 if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] || 3640 flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) { 3641 vec4 updVals = ${c}; 3642 if (flattenedIndex[0] == coords[0]) { 3643 sum.xy += updVals.xy; 3644 found.xy = vec2(1.); 3645 } else if (flattenedIndex[0] == coords[0] + 1) { 3646 sum.zw += updVals.xy; 3647 found.zw = vec2(1.); 3648 } 3649 if (flattenedIndex[1] == coords[0]) { 3650 sum.xy += updVals.zw; 3651 found.xy = vec2(1.); 3652 } else if (flattenedIndex[1] == coords[0] + 1) { 3653 sum.zw += updVals.zw; 3654 found.zw = vec2(1.); 3655 } 3656 } 3657 } 3658 setOutput(mix(${m}, sum, found)); 3659 } 3660 `}}let g1={kernelName:W.pJc,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{indices:s,updates:i}=r,{shape:o}=a,{sliceRank:l,numUpdates:u,sliceSize:h,strides:p,outputSize:d}=W.C0T.calculateShapes(i,s,o),c=[d/h,h];if(0===d)return n.makeTensorInfo(o,s.dtype);
3660let f=dN({inputs:{x:s},backend:n,attrs:{shape:[u,l]}}),m=dN({inputs:{x:i},backend:n,attrs:{shape:[u,h]}}),g=n.makeTensorInfo([],"float32",new Float32Array([0]));t=(0,W._K2)().getBool("WEBGL_PACK")?new g0(u,l,f.shape.length,m.shape.length,p,c):new gJ(u,l,f.shape.length,m.shape.length,p,c);let y=n.runWebGLProgram(t,[m,f,g],m.dtype),b=dN({inputs:{x:y},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(g),b}};class g2{constructor(e,t,r,n){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,r];let a=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,s=2===(0,W._K2)().getNumber("WEBGL_VERSION")?"while (left < right) {":a;this.userCode=` 3661 int findBound(int batch, float value) { 3662 int left = 0; 3663 int right = numInputs; 3664 int mid; 3665 ${s} 3666 mid = (left + right) / 2; 3667 if (getSortedSequence(batch, mid) ${"left"===n?"<":"<="} value) { 3668 left = mid + 1; 3669 } else { 3670 right = mid; 3671 } 3672 } 3673 return right; 3674 } 3675 3676 void main() { 3677 ivec2 coords = getOutputCoords(); 3678 int batch = coords[0]; 3679 int valueIndex = coords[1]; 3680 3681 float value = getValues(batch, valueIndex); 3682 3683 setOutput(float(findBound(batch, value))); 3684 } 3685 `}}let g3={kernelName:W.uWl,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{sortedSequence:a,values:s}=t,{side:i}=n,o=new g2(a.shape[0],a.shape[1],s.shape[1],i),l=[[a.shape[1]]];return r.runWebGLProgram(o,[a,s],"int32",l)}};class g4{constructor(e,t,r){let n,a;if(this.variableNames=["c","a","b"],this.outputShape=t,r>4)throw Error(`Where for rank ${r} is not yet supported`);if(1===r)a="resRC",n="resRC";else{let r=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[],i=[];for(let n=0;n<t.length;n++)i.push(`${r[n]}`),n<e&&s.push(`${r[n]}`);n=s.join(),a=i.join()}let s=(0,p5.bf)(r);this.userCode=` 3686 void main() { 3687 ${s} resRC = getOutputCoords(); 3688 float cVal = getC(${n}); 3689 if (cVal >= 1.0) { 3690 setOutput(getA(${a})); 3691 } else { 3692 setOutput(getB(${a})); 3693 } 3694 } 3695 `}}let g6={kernelName:W.l6P,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{condition:n,t:a,e:s}=t,i=new g4(n.shape.length,a.shape,a.shape.length);return r.runWebGLProgram(i,[n,a,s],(0,W.TuY)(a.dtype,s.dtype))}},g5=dc({opSnippet:` 3696 // Stable and Attracting Fixed Point (0, 1) for Normalized Weights. 3697 // see: https://arxiv.org/abs/1706.02515 3698 float scaleAlpha = ${W.C0T.SELU_SCALEALPHA}; 3699 float scale = ${W.C0T.SELU_SCALE}; 3700 return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); 3701`}),g8={kernelName:W.u$b,backendName:"webgl",kernelFunc:g5},g7=dc({opSnippet:dd+` 3702 return 1.0 / (1.0 + exp(-1.0 * x)); 3703`,packedOpSnippet:` 3704 vec4 result = 1.0 / (1.0 + exp(-1.0 * x)); 3705 bvec4 isNaN = isnan(x); 3706 3707 result.r = isNaN.r ? x.r : result.r; 3708 result.g = isNaN.g ? x.g : result.g; 3709 result.b = isNaN.b ? x.b : result.b; 3710 result.a = isNaN.a ? x.a : result.a; 3711 3712 return result; 3713`,cpuKernelImpl:dx.BC}),g9={kernelName:W.vI1,backendName:"webgl",kernelFunc:g7},ye=dc({opSnippet:` 3714 if (isnan(x)) { return 0.0; } 3715 return sign(x); 3716`}),yt={kernelName:W.YVe,backendName:"webgl",kernelFunc:ye},yr=dc({opSnippet:dd+` 3717 return sin(x); 3718`,packedOpSnippet:` 3719 vec4 result = sin(x); 3720 bvec4 isNaN = isnan(x); 3721 ${p8} 3722 return result; 3723`}),yn={kernelName:W.hql,backendName:"webgl",kernelFunc:yr},ya=dc({opSnippet:` 3724 float e2x = exp(x); 3725 return (e2x - 1.0 / e2x) / 2.0; 3726`}),ys={kernelName:W.J3C,backendName:"webgl",kernelFunc:ya},yi=dc({opSnippet:` 3727 float epsilon = 1.1920928955078125e-7; 3728 float threshold = log(epsilon) + 2.0; 3729 3730 bool too_large = x > -threshold; 3731 bool too_small = x < threshold; 3732 3733 float result; 3734 float exp_x = exp(x); 3735 3736 if (too_large){ 3737 result = x; 3738 } 3739 else if (too_small){ 3740 result = exp_x; 3741 } 3742 else{ 3743 result = log(exp_x + 1.0); 3744 } 3745 return result; 3746`}),yo={kernelName:W.Fin,backendName:"webgl",kernelFunc:yi},yl={kernelName:W.A8B,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a}
3746=t,{blockShape:s,paddings:i}=n;W.ZSL.assert(a.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");let o=s.reduce((e,t)=>e*t),l=[[0,0]];l.push(...i);for(let e=1+s.length;e<a.shape.length;++e)l.push([0,0]);let u=[],h=gb({inputs:{x:a},backend:r,attrs:{paddings:l,constantValue:0}}),p=W.C0T.getReshaped(h.shape,s,o,!1),d=W.C0T.getPermuted(p.length,s.length,!1),c=W.C0T.getReshapedPermuted(h.shape,s,o,!1),f=dN({inputs:{x:h},backend:r,attrs:{shape:p}}),m=dD({inputs:{x:f},backend:r,attrs:{perm:d}}),g=dN({inputs:{x:m},backend:r,attrs:{shape:c}});return u.push(h),u.push(f),u.push(m),u.forEach(e=>r.disposeIntermediateTensorInfo(e)),g}},yu={kernelName:W.C8s,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{indices:n,values:a,denseShape:s,defaultValue:i}=t;if(1!==s.shape.length)throw Error(`Dense shape must be a vector, saw: 3747 ${s.shape}`);if(2!==n.shape.length)throw Error(`Indices must be a matrix, saw: 3748 ${n.shape}`);if(1!==a.shape.length)throw Error(`Values must be a vector, saw: 3749 ${a.shape}`);if(0!==i.shape.length)throw Error(`Default value must be a scalar, saw: 3750 ${i.shape}`);let o=r.readSync(n.dataId),l=r.readSync(a.dataId),u=r.readSync(s.dataId),h=r.readSync(i.dataId)[0],[p,d,c,f,m]=(0,dx.sB)(o,n.shape,n.dtype,l,a.dtype,u,h);return[r.makeTensorInfo(d,n.dtype,p),r.makeTensorInfo([d[0]],a.dtype,c),r.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(e=>Number(e)))),r.makeTensorInfo([m.length],n.dtype,new Int32Array(m))]}},yh={kernelName:W.BoJ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{inputIndices:n,inputShape:a,newShape:s}=t;if(2!==n.shape.length)throw Error(`Input indices should be a matrix but received shape ${n.shape}`);if(1!==a.shape.length)throw Error(`Input shape should be a vector but received shape ${a.shape}`);if(1!==s.shape.length)throw Error(`Target shape should be a vector but received shape ${s.shape}`);let i=Array.from(r.readSync(a.dataId)),o=r.readSync(n.dataId),l=Array.from(r.readSync(s.dataId)),[u,h,p]=(0,dx.vo)(o,n.shape,n.dtype,i,l);return[r.makeTensorInfo(h,n.dtype,u),r.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}},yp={kernelName:W.L6G,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{data:n,indices:a,segmentIds:s}=t;if(n.shape.length<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw Error(`Indices should be a vector but received shape 3751 ${a.shape}`);if(1!==s.shape.length)throw Error(`Segment ids should be a vector but received shape 3752 ${s.shape}`);let i=r.readSync(n.dataId),o=r.readSync(a.dataId),l=r.readSync(s.dataId),[u,h]=(0,dx.zN)(i,n.shape,n.dtype,o,l,!0);return r.makeTensorInfo(h,n.dtype,u)}},yd={kernelName:W.DvZ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{data:n,indices:a,segmentIds:s}=t;if(n.shape.length<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw Error(`Indices should be a vector but received shape 3753 ${a.shape}`);if(1!==s.shape.length)throw Error(`Segment ids should be a vector but received shape 3754 ${s.shape}`);let i=r.readSync(n.dataId),o=r.readSync(a.dataId),l=r.readSync(s.dataId),[u,h]=(0,dx.zN)(i,n.shape,n.dtype,o,l);return r.makeTensorInfo(h,n.dtype,u)}},yc={kernelName:W.jgd,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{sparseIndices:a,sparseValues:s,defaultValue:i}=t,{outputShape:o}=n,{sliceRank:l,numUpdates:u,sliceSize:h,strides:p,outputSize:d}=W.C0T.calculateShapes(s,a,o);if("string"===s.dtype){let e=r.bufferSync(a),t=r.bufferSync(s),n=W.ZSL.decodeString(r.readSync(i.dataId)[0]),c=(0,dx.fC)(e,t,o,d,h,u,l,p,n,!1);return r.makeTensorInfo(o,c.dtype,c.values)}let c=new gJ(u,l,a.shape.length,s.shape.length,p,[d,1],!1),f=r.runWebGLProgram(c,[s,a,i],s.dtype),m=dN({inputs:{x:f},backend:r,attrs:{shape:o}});return r.disposeIntermediateTensorInfo(f),m}},yf={kernelName:W.Blb,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{numOrSizeSplits:s,axis:i}=n,o=W.ZSL.parseAxisParam(i,a.shape)[0],l=W.C0T.prepareSplitSize(a,s,o),u=Array(a.shape.length).fill(0),h=a.shape.slice();return l.map(e=>{let t=[...h];t[o]=e;let n=cb({inputs:{x:a},backend:r,attrs:{begin:u,size:t}});return u[o]+=e,n})}},ym="return sqrt(x);",yg=dc({opSnippet:ym,packedOpSnippet:ym,cpuKernelImpl:dx.LF}),yy={kernelName:W.dFH,backendName:"webgl",kernelFunc:yg},yb=dc({opSnippet:"return x * x;"}),yx={kernelName:W.M6A,backendName:"webgl",kernelFunc:yb}
3754,yv="return (a - b) * (a - b);",yw=df({opSnippet:yv,packedOpSnippet:yv}),yT={kernelName:W.Ddj,backendName:"webgl",kernelFunc:yw},yS={kernelName:W.GZp,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t;if("string"!==a.dtype)throw Error("Input must be of datatype string");let s=r.readSync(a.dataId),i=W.C0T.fromUint8ToStringArray(s),o=(0,dx.yZ)(i,"string",n);return r.makeTensorInfo(a.shape,"string",o)}},yN={kernelName:W.pnw,backendName:"webgl",kernelFunc:function({inputs:e,attrs:t,backend:r}){let{x:n}=e,a=dh.dR+` 3755 return x > 0.0 ? 1.0 : float(${t.alpha}); 3756 `,s=new dh.hE(n.shape,a);return r.runWebGLProgram(s,[n],n.dtype)}};class yk{constructor(e,t,r){this.variableNames=["x"],this.outputShape=r;let n=r.length,a=(0,p5.bf)(r.length),s=(0,p5.bf)(r.length),i="";if(1===n)i="coords * strides + begin";else{let e=0;i=r.map((t,n)=>(e++,1===r.length?`coords * strides[${n}] + begin[${n}]`:`coords[${e-1}] * strides[${n}] + begin[${n}]`)).join(",")}this.userCode=` 3757 ${a} begin = ${a}(${e}); 3758 ${a} strides = ${a}(${t}); 3759 3760 void main() { 3761 ${s} coords = getOutputCoords(); 3762 setOutput(getX(${i})); 3763 } 3764 `}}let yI={kernelName:W.UcO,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{begin:i,end:o,strides:l,beginMask:u,endMask:h,ellipsisMask:p,newAxisMask:d,shrinkAxisMask:c}=a,{finalShapeSparse:f,finalShape:m,isIdentity:g,sliceDim0:y,isSimpleSlice:b,begin:x,end:v,strides:w}=W.Kro.sliceInfo(s.shape,i,o,l,u,h,p,d,c);if(g)t=dN({inputs:{x:s},backend:n,attrs:{shape:m}});else if(y||b){W.ZSL.assert(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);let e=W.Kro.computeOutShape(x,v,w),r=cb({inputs:{x:s},backend:n,attrs:{begin:x,size:e}});t=dN({inputs:{x:r},backend:n,attrs:{shape:m}}),n.disposeIntermediateTensorInfo(r)}else if(n.shouldExecuteOnCPU([s])){let e=n.readSync(s.dataId),r=(0,W.ra8)(s.shape,s.dtype,e),a=(0,dx.cy)(f,r,w,x);t=n.makeTensorInfo(m,s.dtype,a.values)}else{let e=new yk(x,w,f);t=n.runWebGLProgram(e,[s],s.dtype)}let T=dN({inputs:{x:t},backend:n,attrs:{shape:m}});return n.disposeIntermediateTensorInfo(t),T}},yC={kernelName:W.YAb,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{separator:a,nGramWidths:s,leftPad:i,rightPad:o,padWidth:l,preserveShortSequences:u}=n,{data:h,dataSplits:p}=t,d=r.readSync(h.dataId),c=r.readSync(p.dataId),[f,m]=(0,dx.UC)(d,c,a,s,i,o,l,u);return[r.makeTensorInfo([f.length],"string",f),r.makeTensorInfo(p.shape,"int32",m)]}},yE={kernelName:W.iW0,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{skipEmpty:a}=n,{input:s,delimiter:i}=t;if("string"!==s.dtype)throw Error("Input must be of datatype string");if(1!==s.shape.length)throw Error(`Input must be a vector, got shape: ${s.shape}`);if(0!==i.shape.length)throw Error(`Delimiter must be a scalar, got shape: ${i.shape}`);let o=r.readSync(s.dataId),l=r.readSync(i.dataId)[0],[u,h,p]=(0,dx.S6)(o,l,a),d=h.length;return[r.makeTensorInfo([d,2],"int32",u),r.makeTensorInfo([d],"string",h),r.makeTensorInfo([2],"int32",new Int32Array(p))]}},yA={kernelName:W.$jE,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{numBuckets:a}=n,{input:s}=t;if("string"!==s.dtype)throw Error("Input must be of datatype string");if(a<=0)throw Error("Number of buckets must be at least 1");let i=r.readSync(s.dataId),o=(0,dx.fW)(i,a);return r.makeTensorInfo(s.shape,"int32",o)}},y$=dc({opSnippet:"return tan(x);"}),yF={kernelName:W.oFs,backendName:"webgl",kernelFunc:y$},yR=dc({opSnippet:` 3765 float e2x = exp(-2.0 * abs(x)); 3766 return sign(x) * (1.0 - e2x) / (1.0 + e2x); 3767`}),y_={kernelName:W.iuW,backendName:"webgl",kernelFunc:yR},yD={kernelName:W.X4r,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{tensor:a,indices:s,updates:i}=t,{}=n,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=W.C0T.calculateShapes(i,s,a.shape),d=[p/u,u];if(0===p)return r.makeTensorInfo(a.shape,s.dtype);let c=dN({inputs:{x:s},backend:r,attrs:{shape:[l,o]}}),f=dN({inputs:{x:i},backend:r,attrs:{shape:[l,u]}}
3767),m=dN({inputs:{x:a},backend:r,attrs:{shape:d}}),g=new gJ(l,o,c.shape.length,f.shape.length,h,d,!1,!0),y=r.runWebGLProgram(g,[f,c,m],m.dtype),b=dN({inputs:{x:y},backend:r,attrs:{shape:a.shape}});return r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(m),r.disposeIntermediateTensorInfo(y),b}};class yO{constructor(e,t){this.variableNames=["A"];let r=Array(e.length);for(let n=0;n<r.length;n++)r[n]=e[n]*t[n];this.outputShape=r,this.rank=r.length;let n=(0,p5.bf)(this.rank),a=function(e){let t=e.length;if(t>5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;let r=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],n=[];for(let t=0;t<e.length;t++)n.push(`imod(${r[t]}, ${e[t]})`);return n.join()}(e);this.userCode=` 3768 void main() { 3769 ${n} resRC = getOutputCoords(); 3770 setOutput(getA(${a})); 3771 } 3772 `}}function yL(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{reps:s}=n;if("string"===a.dtype||a.shape.length>5){let e=r.readSync(a.dataId),t="string"===a.dtype?e.map(e=>W.ZSL.decodeString(e)):e,n=(0,W.ra8)(a.shape,a.dtype,t),i=(0,dx.$O)(n,s);return r.makeTensorInfo(i.shape,i.dtype,i.values)}let i=new yO(a.shape,s);return r.runWebGLProgram(i,[a],a.dtype)}let yM={kernelName:W.FAs,backendName:"webgl",kernelFunc:yL};class yP{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode=` 3773 void main() { 3774 ivec2 coords = getOutputCoords(); 3775 int batch = coords[0]; 3776 int elemIdx = coords[1]; 3777 3778 // We compare elements pair-wise within a group of size 2 * inc. 3779 // The comparing rule for each group alternates between ascending 3780 // and descending. Within each group, we compare each pair at 3781 // positions i and i+inc. To decide whether an element at position i 3782 // is x0 or x1, we mod it by 2 * inc, if the result is smaller than 3783 // inc, it is in the first half of the group, we denote it as x0, 3784 // otherwise we denote it as x1. 3785 // For example, as shown in the Bitonic top K paper referenced above, 3786 // Figure5(a) shows that element[1] is in the 3787 // second half of the group when group size is 2, but it is in the 3788 // first half of the group when group size is 4. 3789 3790 bool isFirstInPair = imod(elemIdx, 2 * inc) < inc; 3791 int i = isFirstInPair ? elemIdx : elemIdx - inc; 3792 3793 int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); 3794 int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc)); 3795 float x0 = i0 < n ? getX(batch, i0) : negativeInf; 3796 float x1 = i1 < n ? getX(batch, i1) : negativeInf; 3797 3798 // Denotes which direction indices are in (ascending or descending). 3799 bool reverse = imod(elemIdx, 2 * dir) >= dir; 3800 bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0); 3801 if (reverse == isGreater) { // Elements in opposite order of direction 3802 int iTemp = i0; 3803 i0 = i1; 3804 i1 = iTemp; 3805 } 3806 if (isFirstInPair) { 3807 setOutput(float(i0)); 3808 } else { 3809 setOutput(float(i1)); 3810 } 3811 } 3812 `}}class yz{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode=` 3813 void main() { 3814 // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ... 3815 ivec2 coords = getOutputCoords(); 3816 int batch = coords[0]; 3817 int elemIdx = coords[1]; 3818 3819 // The output size is half of the previous size. 3820 // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4), 3821 // we only need to output the indices at positions |, the indices at 3822 // positions _ can be thrown away, see Figure5(b) After Phase 2 3823 // (Merge phase) in the Bitonic Top K paper referenced above. 3824 // For example, the paper shows we only need to output the orange bars. 3825 // The output sequence should look like this | | | | | | | |. 3826 // Because the sequence is halved, to map the output index back 3827 // to the previous sequence to find the corresponding value, 3828 // we need to double the index. When we double the index, 3829 // we basically interpolate a position, so 2i looks like 3830 // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position 3831 // of each 2k positions by - elemIdx % k. E.g. for output at 3832 // index 4,5,6,7, we want to get the corresponding element at 3833 // original index 8,9,10,11, for output at index 8,9,10,11, 3834 // we want to get the corresponding element at original index 3835 // 16,17,18,19, so on and so forth. 3836 3837 int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k)); 3838 int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); 3839 int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k)); 3840 3841 float x0 = getX(batch, i0); 3842 float x1 = i1 < n ? getX(batch, i1) : x0; 3843 3844 setOutput(x0 >= x1 ? float(i0) : float(i1)); 3845 } 3846 `}}function yB(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function yW(e){let t=1;for(;t<e;)t*=2;return t}let yV={kernelName:W.TBb,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{k:s,sorted:i}=n,o=(0,W._K2)().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),l=(0,W._K2)().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),u=a.shape,h=u[u.length-1];if(r.shouldExecuteOnCPU([a])||h<o||s>l){let e=r.readSync(a.dataId),[t,n]=(0,dx.xt)(e,u,a.dtype,s,i);return[r.makeTensorInfo(t.shape,t.dtype,t.values),r.makeTensorInfo(n.shape,n.dtype,n.values)]}if(0===s)return u[u.length-1]=0,[r.makeTensorInfo(u,a.dtype,[]),r.makeTensorInfo(u,"int32",[])];if(1===h)return[a,fH({attrs:{shape:u,dtype:"int32",value:0},backend:r})];let p=r.texData.get(a.dataId),d=null!==p&&p.isPacked,c=d?r.unpackTensor(a):a,f=W.ZSL.sizeFromShape(u)/h,m=dN({input
3846s:{x:c},attrs:{shape:[f,h]},backend:r});d&&yB(r,c);let g=yW(s),y=yW(h),b=null,x=()=>null===b?[m,m]:[m,b],v=(e,t,n)=>{let a=x(),s=new yP(n),i=[[h],[+(null===b)],[-1/0],[e],[t]],o=b;b=r.runWebGLProgram(s,a,"int32",i),yB(r,o)};for(let e=1;e<g;e*=2){let t=2*e;for(let r=e;r>=1;r/=2)v(t,r,[f,y])}for(let e=y;e>g;e/=2){let t=x(),n=new yz([f,e/2]),a=[[h],[+(null===b)],[g]],s=b;b=r.runWebGLProgram(n,t,"int32",a),yB(r,s);let i=g/2,o=2*i;for(let e=i;e>=1;e/=2)v(o,e,b.shape)}let w=b;b=cb({inputs:{x:b},backend:r,attrs:{begin:0,size:[f,s]}}),yB(r,w);let T=mn({inputs:{x:m,indices:b},backend:r,attrs:{axis:1,batchDims:1}});yB(r,m);let S=u.slice(0,-1);S.push(s),w=b,b=dN({inputs:{x:b},attrs:{shape:S},backend:r}),yB(r,w);let N=T;return T=dN({inputs:{x:T},attrs:{shape:S},backend:r}),yB(r,N),[T,b]}};class yU{constructor(e,t,r,n,a,s){let i;switch(this.variableNames=["Image","Transforms"],this.outputShape=s,n){case"constant":default:i=1;break;case"reflect":i=2;break;case"wrap":i=3;break;case"nearest":i=4}this.userCode=` 3847 float mapCoord(float outCoord, float len) { 3848 float inCoord = outCoord; 3849 if(${i} == 2) { 3850 if (inCoord < 0.0) { 3851 if (len <= 1.0) { 3852 inCoord = 0.0; 3853 } else { 3854 float sz2 = 2.0 * len; 3855 if (inCoord < sz2) { 3856 inCoord = sz2 * float(int(float(-inCoord / sz2))) + 3857 inCoord; 3858 } 3859 inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0; 3860 } 3861 } else if (inCoord > len - 1.0) { 3862 if (len <= 1.0) { 3863 inCoord = 0.0; 3864 } else { 3865 float sz2 = 2.0 * len; 3866 inCoord -= sz2 * float(int(float(inCoord / sz2))); 3867 if (inCoord >= len) { 3868 inCoord = sz2 - inCoord - 1.0; 3869 } 3870 } 3871 } 3872 return clamp(inCoord, 0.0, len - 1.0); 3873 } else if (${i} == 3) { 3874 if (inCoord < 0.0) { 3875 if (len <= 1.0) { 3876 inCoord = 0.0; 3877 } else { 3878 float sz = len - 1.0; 3879 inCoord += len * (float(int(float(-inCoord / sz))) + 1.0); 3880 } 3881 } else if (inCoord > len - 1.0) { 3882 if (len <= 1.0) { 3883 inCoord = 0.0; 3884 } else { 3885 float sz = len - 1.0; 3886 inCoord -= len * float(int(float(inCoord / sz))); 3887 } 3888 } 3889 return clamp(inCoord, 0.0, len - 1.0); 3890 } else if (${i} == 4) { 3891 return clamp(outCoord, 0.0, len - 1.0); 3892 } else { 3893 return outCoord; 3894 } 3895 } 3896 3897 float readWithFillValue(int batch, int coordY, int coordX, 3898 int channel) { 3899 float outputValue; 3900 if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) { 3901 outputValue = getImage(batch, coordY, coordX, channel); 3902 } else { 3903 outputValue = float(${a}); 3904 } 3905 return outputValue; 3906 } 3907 3908 void main() { 3909 ivec4 coords = getOutputCoords(); 3910 float outputValue; 3911 int batch = coords[0]; 3912 int x = coords[2]; 3913 int y = coords[1]; 3914 int channel = coords[3]; 3915 float xf = float(x); 3916 float yf = float(y); 3917 float a1 = getTransforms(batch, 0); 3918 float a2 = getTransforms(batch, 1); 3919 float a3 = getTransforms(batch, 2); 3920 float b1 = getTransforms(batch, 3); 3921 float b2 = getTransforms(batch, 4); 3922 float b3 = getTransforms(batch, 5); 3923 float c1 = getTransforms(batch, 6); 3924 float c2 = getTransforms(batch, 7); 3925 float projection = c1 * xf + c2 * yf + 1.0; 3926 if (projection == 0.0) { 3927 outputValue = float(${a}); 3928 } else { 3929 float inX = (a1 * xf + a2 * yf + a3) / projection; 3930 float inY = (b1 * xf + b2 * yf + b3) / projection; 3931 float mapX = mapCoord(inX, float(${t})); 3932 float mapY = mapCoord(inY, float(${e})); 3933 3934 if (${"nearest"===r?1:2} == 1) {
3935 int coordY = int(round(mapY)); 3936 int coordX = int(round(mapX)); 3937 outputValue = readWithFillValue(batch, coordY, coordX, 3938 channel); 3939 } else { 3940 float yFloor = floor(mapY); 3941 float xFloor = floor(mapX); 3942 float yCeil = yFloor + 1.0; 3943 float xCeil = xFloor + 1.0; 3944 float valueYFloor = (xCeil - mapX) * 3945 readWithFillValue(batch, int(yFloor), int(xFloor), channel) + 3946 (mapX - xFloor) * 3947 readWithFillValue(batch, int(yFloor), int(xCeil), channel); 3948 float valueYCeil = (xCeil - mapX) * 3949 readWithFillValue(batch, int(yCeil), int(xFloor), channel) + 3950 (mapX - xFloor) * 3951 readWithFillValue(batch, int(yCeil), int(xCeil), channel); 3952 outputValue = (yCeil - mapY) * valueYFloor + 3953 (mapY - yFloor) * valueYCeil; 3954 } 3955 } 3956 setOutput(outputValue); 3957 } 3958 `}}let yG={kernelName:W.dLy,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{image:a,transforms:s}=t,{interpolation:i,fillMode:o,fillValue:l,outputShape:u}=n,[h,p,d,c]=a.shape,[f,m]=null!=u?u:[p,d],g=new yU(p,d,i,o,l,[h,f,m,c]);return r.runWebGLProgram(g,[a,s],"float32")}},yZ={kernelName:W.EwU,backendName:"webgl",kernelFunc:function(e){let{inputs:t,attrs:r,backend:n}=e,{axis:a}=r,{x:s}=t;(0,pq.assertNotComplex)(s,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");let i=n.readSync(s.dataId),{outputValues:o,outputShape:l,indices:u}=(0,dx.M_)(i,a,s.shape,s.dtype);return[n.makeTensorInfo(l,s.dtype,o),n.makeTensorInfo([u.length],"int32",u)]}},yj={kernelName:W.dXR,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{value:a}=t,{axis:s}=n;s<0&&(s+=a.shape.length);let i=a.shape.length,o=a.shape[s],l=Array(i-1),u=0;for(let e=0;e<i;e++)e!==s&&(l[u++]=a.shape[e]);let h=[],p=Array(i).fill(0),d=a.shape.slice();d[s]=1;let c=Array(o);for(let e=0;e<c.length;e++){p[s]=e;let t=cb({inputs:{x:a},backend:r,attrs:{begin:p,size:d}}),n=dN({inputs:{x:t},backend:r,attrs:{shape:l}});c[e]=n,h.push(t)}return h.forEach(e=>r.disposeIntermediateTensorInfo(e)),c}};class yK{constructor(e,t){this.variableNames=["x","segmentIds"];let r=e.windowSize,n=e.batchSize,a=e.inSize,s=e.numSegments,i=s*Math.ceil(a/r);this.outputShape=[n,i];let o=4*Math.floor(r/4),l=r%4,u=` 3959 sumValue += dot(values, segFilter); 3960 `,h="";a%r>0&&(h=` 3961 if (inIdx < 0 || inIdx >= ${a}) { 3962 return initializationValue; 3963 } 3964 `);let p="";a%r>0&&(p=` 3965 if (inIdx < 0 || inIdx >= ${a}) { 3966 return -1.0; 3967 } 3968 `),this.userCode=` 3969 const float initializationValue = 0.0; 3970 3971 float getValue(int batch, int inIdx) { 3972 ${h} 3973 return getX(batch, inIdx); 3974 } 3975 3976 float getSegmentIdAtIndex(int inIdx) { 3977 ${p} 3978 return getSegmentIds(inIdx); 3979 } 3980 3981 void main() { 3982 ivec2 coords = getOutputCoords(); 3983 int batch = coords[0]; 3984 int outIdx = coords[1]; 3985 int inOffset = int(floor(float(outIdx) / float( 3986 ${s})) * float(${r})); 3987 int currentSeg = int(mod(float(outIdx), float(${s}))); 3988 3989 float sumValue = 0.0; 3990 3991 for (int i = 0; i < ${o}; i += 4) { 3992 int inIdx = inOffset + i; 3993 vec4 values = vec4( 3994 getValue(batch, inIdx), 3995 getValue(batch, inIdx + 1), 3996 getValue(batch, inIdx + 2), 3997 getValue(batch, inIdx + 3) 3998 ); 3999 4000 vec4 segFilter = vec4( 4001 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 4002 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 4003 int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 4004 int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0 4005 ); 4006 4007 ${u} 4008 } 4009 4010 int inIdx = inOffset + ${o}; 4011 if (${1===l}) { 4012 vec4 values = vec4( 4013 getValue(batch, inIdx), 4014 initializationValue, 4015 initializationValue, 4016 initializationValue 4017 ); 4018 4019 int inIdxSeg = int(getSegmentIdAtIndex(inIdx)); 4020 4021 vec4 segFilter = vec4( 4022 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 4023 0, 4024 0, 4025 0 4026 ); 4027 4028 ${u} 4029 } else if (${2===l}) { 4030 vec4 values = vec4( 4031 getValue(batch, inIdx), 4032 getValue(batch, inIdx + 1), 4033 initializationValue, 4034 initializationValue 4035 ); 4036 4037 vec4 segFilter = vec4( 4038 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 4039 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 4040 0, 4041 0 4042 ); 4043 4044 ${u} 4045 } else if (${3===l}) { 4046 vec4 values = vec4( 4047 getValue(batch, inIdx), 4048 getValue(batch, inIdx + 1), 4049 getValue(batch, inIdx + 2), 4050 initializationValue 4051 ); 4052 4053 vec4 segFilter = vec4( 4054 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 4055 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 4056 int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 4057 0 4058 ); 4059 4060 ${u} 4061 } 4062 setOutput(sumValue); 4063 } 4064 `}}for(let e of[dM,dz,dW,dU,dj,dY,dQ,dq,d1,d2,d4,d5,d7,ce,cr,cs,ci,cu,ch,cp,cf,cv,cw,cN,ck,c$,c_,cL,dr,cz,cj,c1,c5,c7,c9,fe,ft,fn,fs,fo,fd,fc,ff,fg,fx,fT,fS,fk,fC,fE,f$,fR,fD,fL,fP,fB,fU,fj,fY,fq,f0,f2,f5,f7,f9,mt,ma,mi,ml,de,mu,cG,mp,mc,mm,ds,my,mx,mv,mT,mN,mI,mE,m$,m_,mO,mM,mz,mB,mW,mG,mZ,mj,mK,mH,mQ,mJ,m1,ge,dT,gn,gs,go,gu,cC,gp,gf,gm,gx,gw,du,gT,gS,gN,gk,gC,cA,m4,gA,gF,g_,dk,gL,gP,gW,gU,gj,gH,gQ,gX,g1,g3,g6,g8,g9,yt,yn,ys,cx,m9,yo,yl,yu,yh,yp,yd,yc,yf,yy,yx,yT,yS,yN,yI,yC,yE,yA,m8,d_,yF,y_,yD,yM,yV,yG,dO,yZ,yj,{kernelName:W.pPe,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,segmentIds:s}=t,{numSegments:i}=n,o=a.shape.length,l=[],u=0,h=W.C0T.getAxesPermutation([u],o),p=a;null!=h&&(p=dD({inputs:{x:a},backend:r,attrs:{perm:h}}),l.push(p),u=W.C0T.getInnerMostAxes(1,o)[0]);let d=W.C0T.segment_util.computeOutShape(p.shape,u,i),c=W.ZSL.sizeFromShape([p.shape[u]]),f=dN({input
4064s:{x:p},backend:r,attrs:{shape:[-1,c]}});l.push(f);let m=(0,W.chL)(a.dtype),g=(e,t,n,a,s)=>{let i=e.shape[0],o=e.shape[1],u=W.C0T.segment_util.segOpComputeOptimalWindowSize(o,s),h=new yK({windowSize:u,inSize:o,batchSize:i,numSegments:s},t),p=r.compileAndRun(h,[e,n],a);if(l.push(p),p.shape[1]===s)return p;let d=gI({backend:r,attrs:{start:0,stop:s,step:1,dtype:"float32"}}),c=yL({inputs:{x:d},backend:r,attrs:{reps:[o/u]}});return l.push(d),l.push(c),g(p,t,c,a,s)},y=dN({inputs:{x:g(f,"unsortedSegmentSum",s,m,i)},backend:r,attrs:{shape:d}}),b=y;return null!=h&&(l.push(y),b=dD({inputs:{x:b},backend:r,attrs:{perm:W.C0T.getUndoAxesPermutation(h)}})),l.forEach(e=>r.disposeIntermediateTensorInfo(e)),b}},gc])(0,W.tAK)(e);let yH={"tfjs-core":W.bgA,"tfjs-backend-cpu":o$,"tfjs-backend-webgl":pY,"tfjs-data":ok,"tfjs-layers":sy.r,"tfjs-converter":i$,tfjs:"4.22.0"},yY=e=>"tensor"===e?"tensor":"base64",yQ={jsdelivr:(e,t,r)=>`https://cdn.jsdelivr.net/npm/${e}@${t}/${r}`,unpkg:(e,t,r)=>`https://unpkg.com/${e}@${t}/${r}`},yq=["jsdelivr","unpkg"];async function yX(e,t){let r,{modelType:n,_internals:a,path:s}=t;if(s)return await eh(e,s,n);if(!a){let e;throw e="Missing internals",Error(`There is a bug with the upscaler code. Please report this. ${e?`Error: ${e}`:""}`.trim())}let i=[];for(let t of yq){let r=yQ[t];try{let t=r(a.name,a.version,a.path);return await eh(e,t,n)}catch(e){i.push([t,e instanceof Error?e:Error(`There was an unknown error: ${JSON.stringify(e)}`)])}}throw r=s||a.path,Error([`Could not resolve URL ${r} for package ${a?.name}@${a?.version}`,"Errors include:",...i.map(([e,t])=>`- ${e}: ${t.message}`)].join("\n"))}let yJ=()=>Error(`Environment does not support a string URL as an input format. 4065For more information, see https://upscalerjs.com/documentation/troubleshooting#environment-disallows-string-input.`),y0=()=>Error(`Environment does not support base64 as an output format. 4066For more information, see https://upscalerjs.com/documentation/troubleshooting#environment-disallows-base64.`),y1=e=>W.TaL.fromPixelsAsync(e),y2=async(e,t)=>{if(K(e))return e;if("string"==typeof e)return y1(await new Promise((t,r)=>{let n=new Image;n.src=e,n.crossOrigin="anonymous",n.onload=()=>t(n),n.onerror=()=>r(Error("Failed to load image"))}));return y1(e)},y3=e=>{try{if(new Image,"createElement"in document!=!0)throw e()}catch(t){throw e()}},y4=eT({tf:D,getUpscaleOptions:({output:e,progressOutput:t,...r}={})=>({...r,output:yY(e),progressOutput:yY(t||e)}),loadModel:async(e,t)=>{let r=await t;(e=>{if(void 0===e)throw z;if(!(e=>"string"==typeof e&&["layers","graph"].includes(e))(e.modelType??"layers"))throw`You've provided an invalid model type: ${JSON.stringify(e)}. Accepted types are "layers" and "graph". For more information, see https://upscalerjs.com/documentation/troubleshooting#invalid-model-type.`;if(!e.path&&!e._internals?.path)throw`Provided model configuration is missing both a "path" and "_internals". A valid path to a model JSON file must be provided. For more information, see https://upscalerjs.com/documentation/troubleshooting#missing-path-and-internals. The model configuration provided was: ${JSON.stringify(e)}`})(r);let n={...r};return{model:await yX(e,n),modelDefinition:n}},getImageAsTensor:async(e,t)=>{let r=await y2(t,e);if(j(r)){let e=r.expandDims(0);return r.dispose(),e}if(Z(r))return r;throw Error(`Unsupported dimensions for incoming pixels: ${r.shape.length}. 4067Only 3 or 4 rank tensors are supported.`)},tensorAsBase64:(e,t)=>{let r=((e,t)=>e.tidy(()=>{let[r,n]=t.shape,a=e.fill([r,n],255).expandDims(2);return t.clipByValue(0,255).concat([a],2).dataSync()}))(e,t),[n,a]=t.shape,s=new ImageData(a,n);s.data.set(r);let i=document.createElement("canvas");i.width=a,i.height=n;let o=i.getContext("2d");if(!o)throw Error("No context found");return o.putImageData(s,0,0),i.toDataURL()},checkValidEnvironment:(e,{output:t="base64",progressOutput:r})=>{"string"==typeof e&&y3(yJ),("base64"===r||"base64"===t)&&y3(y0)}})},55756:(e,t,r)=>{"use strict";r.d(t,{G:()=>h});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(46866),l=r(18875),u=r(86036);let h=(0,l.op)({depthwiseConv2d_:function(e,t,r,l,h="NHWC",p=[1,1],d){let c=(0,s.YT)(e,"x","depthwiseConv2d","float32"),f=(0,s.YT)(t,"filter","depthwiseConv2d","float32"),m=c,g=!1;3===c.rank&&(g=!0,m=(0,u.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]])),i.vA(4===m.rank,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${m.rank}.`),i.vA(4===f.rank,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${f.rank}.`);let y="NHWC"===h?m.shape[3]:m.shape[1];i.vA(y===f.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${y}) must match the inChannels dimension in filter ${f.shape[2]}.`),o.s_("depthwiseConv2d",l,d);let b={x:m,filter:f},x=n.T2.runKernel(a.tGH,b,{strides:r,pad:l,dataFormat:h,dilations:p,dimRoundingMode:d});return g?(0,u.t)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}})},56992:(e,t,r)=>{"use strict";r.d(t,{U:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({expandDims_:function(e,t=0){let r=(0,s.YT)(e,"x","expandDims","string_or_numeric");return i.vA(t<=r.rank,()=>"Axis must be <= rank of the tensor"),n.T2.runKernel(a.ybN,{input:r},{dim:t})}})},57238:(e,t,r)=>{"use strict";r.d(t,{w:()=>s});var n=r(54463),a=r(84198);let s=(0,r(18875).op)({conv2dTranspose_:function(e,t,r,s,i,o){let l=(0,n.YT)(e,"x","conv2dTranspose"),u=(0,n.YT)(t,"filter","conv2dTranspose");return(0,a.v)(r,l,u,s,i,"NHWC",o)}})},57610:(e,t,r)=>{"use strict";r.d(t,{d:()=>s});var n=r(22700),a=r(77969);function s(e,t){if(((0,n.isTypedArray)(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&(0,n.isTypedArray)(e)&&!(e instanceof Uint8Array))throw Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return(0,a.Q)(e,[],[],t)}},58286:(e,t,r)=>{"use strict";r.d(t,{S:()=>o});var n=r(46519),a=r(71490),s=r(15768),i=r(27738);class o{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=i.BB.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=(0,n.B)();this.outputShape=e,this.enableShapeUniforms=(0,a.ik)(this.outputShape.length),this.userCode=` 4068 ivec3 outCoordsFromFlatIndex(int index) { 4069 ${this.enableShapeUniforms?s.WA(["r","c","d"],e):s.UG(["r","c","d"],e)} 4070 return ivec3(r, c, d); 4071 } 4072 4073 void main() {
4074 ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); 4075 int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); 4076 4077 vec4 result = vec4(0.); 4078 4079 for (int i=0; i<4; i++) { 4080 int flatIndex = index + i; 4081 ivec3 rc = outCoordsFromFlatIndex(flatIndex); 4082 result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z)); 4083 } 4084 4085 ${t.output} = result; 4086 } 4087 `}}},58611:(e,t,r)=>{"use strict";r.d(t,{UK:()=>u,WQ:()=>l,mx:()=>i});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>e+t),o=(0,s.B)((e,t,r,n)=>({real:e+r,imag:t+n})),l=(0,s.j)(n.OMN,i,o),u={kernelName:n.OMN,backendName:"cpu",kernelFunc:l}},59635:(e,t,r)=>{"use strict";r.d(t,{h:()=>a});var n=r(45720);function a(e,t,r,a){let s=n.ZSL.getArrayFromDType(r,n.ZSL.sizeFromShape(t));if(a&&"string"!==r){let t=0;e.forEach(e=>{let r=n.ZSL.sizeFromShape(e.shape);s.set(e.vals,t),t+=r})}else{let a=0;e.forEach(e=>{let i="string"===r?n.C0T.fromUint8ToStringArray(e.vals):e.vals,o=0;for(let r=0;r<e.shape[0];++r){let n=r*t[1]+a;for(let t=0;t<e.shape[1];++t)s[n+t]=i[o++]}a+=e.shape[1]})}return s}},59802:(e,t,r)=>{"use strict";r.d(t,{_:()=>a});var n=r(45720);function a(e,t,r,a,s,i,o){if(t.length>1)throw Error("starts must be a scalar or vector");if(s.length>1)throw Error("limits must be a scalar or vector");if(o.length>1)throw Error("deltas must be a scalar or vector");let l=0===t.length,u=0===s.length,h=0===o.length,p=[];l||p.push(t[0]),u||p.push(s[0]),h||p.push(o[0]);for(let e=1;e<p.length;++e)if(p[e]!==p[e-1])throw Error("starts, limits, and deltas must have the same shape");let d=0===p.length?1:p[0],c=n.ZSL.getArrayFromDType("int32",d+1);c[0]=0;for(let t=0;t<d;++t){let r,n=l?e[0]:e[t],s=u?a[0]:a[t],o=h?i[0]:i[t];if(0===o)throw Error("Requires delta != 0");if(o>0&&s<n||o<0&&s>n)r=0;else if((r=Math.ceil(Math.abs((s-n)/o)))>0x7fffffff)throw Error("Requires ((limit - start) / delta) <= 2147483647");c[t+1]=c[t]+r}let f=c[d],m=n.ZSL.getArrayFromDType(r,f),g=0;for(let t=0;t<d;++t){let r=c[t+1]-c[t],n=l?e[0]:e[t],a=h?i[0]:i[t];for(let e=0;e<r;++e)m[g++]=n,n+=a}return[c,m]}},60072:(e,t,r)=>{"use strict";r.d(t,{C:()=>a});var n=r(45720);function a(e,t){Array.isArray(e)||(e=[e]),e.forEach(e=>{null!=e&&n.ZSL.assert("complex64"!==e.dtype,()=>`${t} does not support complex64 tensors in the CPU backend.`)})}},60247:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this;t.next=function(){var e,r,n=t.w,a=t.X,s=t.i;return t.w=n=n+0x61c88647|0,r=a[s+34&127],e=a[s=s+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=a[s]=r^e,t.i=s,r+(n^n>>>16)|0},!function(e,t){var r,n,a,s,i,o=[],l=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,l=Math.max(l,t.length)),a=0,s=-32;s<l;++s)t&&(n^=t.charCodeAt((s+32)%t.length)),0===s&&(i=n),n^=n<<10,n^=n>>>15,n^=n<<4,n^=n>>>13,s>=0&&(i=i+0x61c88647|0,a=0==(r=o[127&s]^=n+i)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,s=512;s>0;--s)n=o[a+34&127],r=o[a=a+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,o[a]=n^r;e.w=i,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function l(e,t){null==e&&(e=+new Date);var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&(n.X&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.xor4096=l}(0,e=r.nmd(e),r.amdD)},60676:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({isNaN_:function(e){let t=(0,s.YT)(e,"x","isNaN");return n.T2.runKernel(a.iPs,{x:t})}})},61017:(e,t,r)=>{"use strict";r.d(t,{K:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({log1p_:function(e){let t=(0,s.YT)(e,"x","log1p");return n.T2.runKernel(a.Cg$,{x:t})}})},61237:(e,t,r)=>{"use strict";r.d(t,{I:()=>a,i:()=>s});var n=r(45720);async function a(e){if(null==e)return;let t=[],r=[],a=[];for(let n in e){let s=e[n];"number"!=typeof s&&(t.push(s.data()),r.push(n),a.push(s))}if(t.length>0){let s=await Promise.all(t);for(let t=0;t<s.length;++t)e[r[t]]=s[t][0];(0,n.ASo)(a)}}function s(e){if(null!=e)for(let t in e){let r=e[t];"number"!=typeof r&&r.dispose()}}},61324:(e,t,r)=>{"use strict";r.d(t,{d:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({slice_:function(e,t,r){let i=(0,s.YT)(e,"x","slice","string_or_numeric");if(0===i.rank)throw Error("Slicing scalar is not possible");return n.T2.runKernel(a.JiE,{x:i},{begin:t,size:r})}})},61325:(e,t,r)=>{"use strict";r.d(t,{GJ:()=>n,uI:()=>a});
4087class n{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class a{refCount(e){return s("refCount")}incRef(e){return s("incRef")}timerAvailable(){return!0}time(e){return s("time")}read(e){return s("read")}readSync(e){return s("readSync")}readToGPU(e,t){return s("readToGPU")}numDataIds(){return s("numDataIds")}disposeData(e,t){return s("disposeData")}write(e,t,r){return s("write")}move(e,t,r,n,a){return s("move")}createTensorFromGPUData(e,t,r){return s("createTensorFromGPUData")}memory(){return s("memory")}floatPrecision(){return s("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return s("dispose")}}function s(e){throw Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}},61630:(e,t,r)=>{"use strict";r.d(t,{X:()=>h});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(46866),l=r(18875),u=r(86036);let h=(0,l.op)({conv2d_:function(e,t,r,l,h="NHWC",p=[1,1],d){let c=(0,s.YT)(e,"x","conv2d","float32"),f=(0,s.YT)(t,"filter","conv2d","float32"),m=c,g=!1;3===c.rank&&(g=!0,m=(0,u.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]])),i.vA(4===m.rank,()=>`Error in conv2d: input must be rank 4, but got rank ${m.rank}.`),i.vA(4===f.rank,()=>`Error in conv2d: filter must be rank 4, but got rank ${f.rank}.`),o.s_("conv2d",l,d);let y="NHWC"===h?m.shape[3]:m.shape[1];i.vA(y===f.shape[2],()=>`Error in conv2d: depth of input (${y}) must match input depth for filter ${f.shape[2]}.`),i.vA(o.G0(r,p),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${r} and dilations '${p}'`),i.vA(o.qk(p),()=>"Error in conv2D: Dilated rates should be larger than 0."),i.vA(o.qk(r),()=>"Error in conv2D: Strides should be larger than 0.");let b={x:m,filter:f},x=n.T2.runKernel(a.p2J,b,{strides:r,pad:l,dataFormat:h,dilations:p,dimRoundingMode:d});return g?(0,u.t)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}})},61857:(e,t,r)=>{"use strict";r.d(t,{N:()=>i});var n=r(46519),a=r(15768),s=r(27738);class i{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=s.tT.DOWNLOAD;let t=(0,n.B)();this.outputShape=e,this.userCode=` 4088 ${a.G2} 4089 4090 void main() { 4091 ivec3 coords = getOutputCoords(); 4092 float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z)); 4093 ${t.output} = encode_float(x); 4094 } 4095 `}}},61997:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({zerosLike_:function(e){let t=(0,s.YT)(e,"x","zerosLike");return n.T2.runKernel(a.xJ3,{x:t})}})},62131:(e,t,r)=>{"use strict";r.d(t,{P:()=>l});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990);let l=(0,r(18875).op)({squaredDifference_:function(e,t){let r=(0,i.YT)(e,"a","squaredDifference"),l=(0,i.YT)(t,"b","squaredDifference");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.Ddj,u,{})}})},62376:(e,t,r)=>{"use strict";r.d(t,{Fq:()=>a,T9:()=>o,jk:()=>i,no:()=>s,y1:()=>l});var n=r(63537);function a(e){return e===parseInt(e.toString(),10)}function s(e,t,r){null==t&&(t=0),null==r&&(r=e.length);let n=1;for(let a=t;a<r;++a)n*=e[a];return n}function i(e){if(0===e.length)return NaN;let t=1/0;for(let r=0;r<e.length;r++){let n=e[r];n<t&&(t=n)}return t}function o(e){if(0===e.length)return NaN;let t=-1/0;for(let r=0;r<e.length;r++){let n=e[r];n>t&&(t=n)}return t}function l(e,t){if(t<e)throw new n.Qp(`end (${t}) < begin (${e}) is forbidden.`);let r=[];for(let n=e;n<t;++n)r.push(n);return r}},62637:(e,t,r)=>{"use strict";r.d(t,{C1:()=>i,Uc:()=>l});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>Math.floor(e/t)),o=(0,s.j)(n.ElG,i,null,"int32"),l={kernelName:n.ElG,backendName:"cpu",kernelFunc:o}},62958:(e,t,r)=>{"use strict";r.d(t,{l:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({softplus_:function(e){let t=(0,s.YT)(e,"x","softplus");return n.T2.runKernel(a.Fin,{x:t})}})},63537:(e,t,r)=>{"use strict";r.d(t,{EH:()=>i,Qp:()=>s,bu:()=>a,l7:()=>n,pf:()=>o});
4095class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}}class a extends Error{constructor(e){super(e),Object.setPrototypeOf(this,a.prototype)}}class s extends Error{constructor(e){super(e),Object.setPrototypeOf(this,s.prototype)}}class i extends Error{constructor(e){super(e),Object.setPrototypeOf(this,i.prototype)}}class o extends Error{constructor(e){super(e),Object.setPrototypeOf(this,o.prototype)}}},64256:(e,t,r)=>{"use strict";r.d(t,{Em:()=>u,SM:()=>o,WC:()=>l,WH:()=>a,aF:()=>s,fK:()=>p,gx:()=>h,lb:()=>i});var n=r(75681);function a(e,t){for(let r=0;r<e.length;++r)if(e[e.length-r-1]!==t-1-r)return!1;return!0}function s(e,t,r){let n=e.length+t.length,a=[],s=0,i=0;for(let o=0;o<n;o++)-1===r.indexOf(o)?a.push(e[s++]):a.push(t[i++]);return a}function i(e,t){let r=[],n=e.length;for(let a=0;a<n;a++)-1===t.indexOf(a)&&r.push(e[a]);return[r,t.map(t=>e[t])]}function o(e,t){return s(e,t.map(e=>1),t)}function l(e,t,r){n.vA(a(t,r),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${r} input.`)}function u(e,t){if(a(e,t))return null;let r=[];for(let n=0;n<t;++n)-1===e.indexOf(n)&&r.push(n);return e.forEach(e=>r.push(e)),r}function h(e){return e.map((e,t)=>[t,e]).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}function p(e,t){let r=[];for(let n=t-e;n<t;++n)r.push(n);return r}},64467:(e,t,r)=>{"use strict";r.d(t,{o:()=>a});var n=r(45720);function a(e){return(t,r,a)=>{let s=n.ZSL.getArrayFromDType(r,t.length);for(let r=0;r<t.length;++r)s[r]=e(t[r],a);return s}}},64630:(e,t,r)=>{"use strict";let n;r.d(t,{Ni:()=>s,VI:()=>i});var a=r(45720);function s(){return null==n&&(n=(0,a.Hs)().epsilon()),n}function i(){return"channelsLast"}},65114:(e,t,r)=>{"use strict";r.d(t,{y:()=>a});var n=r(45720);function a(e,t,r,a,s,i,o){let l=t[0],u=i[0],h=Array(u),p=Array(l),d=t[1];if(0===u){if(0!==l)throw Error(n.C0T.getSparseFillEmptyRowsIndicesDenseShapeMismatch(l));return[n.ZSL.getArrayFromDType(r,0),[0,d],n.ZSL.getArrayFromDType(s,0),h,p]}let c=!0,f=0,m=Array(u).fill(0);for(let t=0;t<l;++t){let r=e[t*d];if(r<0)throw Error(n.C0T.getSparseFillEmptyRowsNegativeIndexErrorMessage(t,r));if(r>=u)throw Error(n.C0T.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(t,r,u));++m[r],c=c&&r>=f,f=r}let g=!0;for(let e=0;e<u;++e){let t=0===m[e];h[e]=t,g=g&&!t,m[e]=Math.max(m[e],1),e>0&&(m[e]+=m[e-1])}if(g&&c){for(let e=0;e<l;++e)p[e]=e;return[e,[l,d],a,h,p]}{let t=m[u-1],i=n.ZSL.getArrayFromDType(r,t*d),c=n.ZSL.getArrayFromDType(s,t),f=Array(u).fill(0);for(let t=0;t<l;++t){let r=e[t*d],n=f[r],s=(0===r?0:m[r-1])+n;f[r]++;for(let r=0;r<d;++r)i[s*d+r]=e[t*d+r];c[s]=a[t],p[t]=s}for(let e=0;e<u;++e)if(0===f[e]){let t=0===e?0:m[e-1];i[t*d+0]=e;for(let e=1;e<d;++e)i[t*d+e]=0;c[t]=o}return[i,[t,d],c,h,p]}}},65261:(e,t,r)=>{"use strict";function n(e,t=!1){console.log(e.toString(t))}r.d(t,{y:()=>n})},66114:(e,t,r)=>{"use strict";r.d(t,{G:()=>a});var n=r(45720);function a(e,t,r){let a=(t-e)/(r-1),s=n.ZSL.makeZerosTypedArray(r,"float32");s[0]=e;for(let e=1;e<s.length;e++)s[e]=s[e-1]+a;return s}},66287:(e,t,r)=>{"use strict";r.d(t,{$:()=>l});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(86036);let l=(0,r(18875).op)({batchNorm_:function(e,t,r,l,u,h){let p,d;null==h&&(h=.001);let c=(0,s.YT)(e,"x","batchNorm"),f=(0,s.YT)(t,"mean","batchNorm"),m=(0,s.YT)(r,"variance","batchNorm");null!=u&&(p=(0,s.YT)(u,"scale","batchNorm")),null!=l&&(d=(0,s.YT)(l,"offset","batchNorm")),i.vA(f.rank===m.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),i.vA(null==d||f.rank===d.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),i.vA(null==p||f.rank===p.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let g={x:0===c.rank||1===c.rank?(0,o.t)(c,[1,1,1,c.size]):2===c.rank?(0,o.t)(c,[1,1,c.shape[0],c.shape[1]]):3===c.rank?(0,o.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]]):c,scale:p,offset:d,mean:f,variance:m},y={varianceEpsilon:h},b=n.T2.runKernel(a.i5R,g,y);return(0,o.t)(b,c.shape)}})},67146:(e,t,r)=>{"use strict";r.d(t,{j:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({min_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","min");return n.T2.runKernel(a.lNG,{x:i},{axis:t,keepDims:r})}})},67532:(e,t,r)=>{"use strict";r.d(t,{x:()=>o});var n=r(5287),a=r(96609),s=r(18875),i=r(86036);let o=(0,s.op)({depthwiseConv2dNativeBackpropFilter_:function(e,t,r,s,o,l=[1,1],u){let h=e;3===e.rank&&(h=(0,i.t)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let p=t;3===p.rank&&(p=(0,i.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let d={x:h,dy:p};return n.T2.runKernel(a.X$8,d,{strides:s,pad:o,dimRoundingMode:u,dilations:l,filterShape:r})}})},67633:(e,t,r)=>{"use strict";r.d(t,{g:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({cos_:function(e){let t=(0,s.YT)(e,"x","cos","float32");return n.T2.runKernel(a.Mn0,{x:t})}})},67654:(e,t,r)=>{"use strict";r.d(t,{K:()=>i});var n=r(45720),a=r(64630),s=r(63537);function i(e){let t={Adagrad:()=>n.BaG.adagrad(.01),Adadelta:()=>n.BaG.adadelta(1,.95,(0,a.Ni)()),Adam:()=>n.BaG.adam(.001,.9,.999,(0,a.Ni)()),Adamax:()=>n.BaG.adamax(.002,.9,.999,(0,a.Ni)(),0),RMSProp:()=>n.BaG.rmsprop(.001,.9,0,(0,a.Ni)()),SGD:()=>n.BaG.sgd(.01)};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new s.Qp(`Unknown Optimizer ${e}`)}},67934:(e,t,r)=>{"use strict";r.d(t,{rq:()=>i,xp:()=>l});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>+(e>t)),o=(0,s.j)(n.XhZ,i,null,"bool"),l={kernelName:n.XhZ,backendName:"cpu",kernelFunc:o}},67984:(e,t,r)=>{"use strict";r.d(t,{Km:()=>l,OH:()=>s,_K:()=>o,tj:()=>u});var n=r(75681);let a="tfjsflags";class s{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=i,this.populateURLFlags()}setPlatform(e,t){null==this.platform||l.getBool("IS_TEST")||l.getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`),this.platformName=e,this.platform=t}registerFlag(e,t,r){if(this.flagRegistry[e]={evaluationFn:t,setHook:r},null!=this.urlFlags[e]){let t=this.urlFlags[e];l.getBool("IS_TEST")||l.getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];let t=this.evaluateFlag(e);if((0,n.yL)(t))throw Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getString(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;let e=this.getQueryParams(this.global.location.search);
4095a in e&&e[a].split(",").forEach(e=>{let[t,r]=e.split(":");this.urlFlags[t]=function(e,t){let r=t.toLowerCase();return"true"===r||"false"===r?"true"===r:`${+r}`===r?+r:t}(0,r)})}}function i(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(e,...r)=>{var n,a,s;return n=t,a=r[0],s=r[1],n[decodeURIComponent(a)]=decodeURIComponent(s||""),r.join("=")}),t}function o(){return l}let l=null;function u(e){l=e}},68063:(e,t,r)=>{"use strict";r.d(t,{o:()=>a});var n=r(50186);function a(e,t,r,i=console.log){var o;let l,u=function(e){let t=!0,r=[],n=[];for(let t in e.nodesByDepth)r.push(e.nodesByDepth[t]);for(let e of r){if(e.length>1||1===e.length&&e[0].inboundLayers.length>1){t=!1;break}n.push(...e)}if(t)for(let r of e.layers){let e=!1;for(let a of r.inboundNodes)if(-1!==n.indexOf(a))if(e){t=!1;break}else e=!0;if(!t)break}return t}(e),h=["Layer (type)","Input Shape","Output shape","Param #"];if(u?(t=t||90,r=r||[.32,.61,.89,1]):(t=t||115,r=r||[.24,.48,.7,.8,1]),r[r.length-1]<=1&&(r=r.map(e=>Math.floor(t*e))),!u)for(let t in h.push("Receives inputs"),l=[],e.nodesByDepth)l.push(...e.nodesByDepth[t]);i("_".repeat(t)),s(h,r,i),i("=".repeat(t));let p=e.layers;for(let e=0;e<p.length;++e)u?function(e,t,r){let n,a;try{a=e.inboundNodes.map(e=>JSON.stringify(e.inputShapes)).join(",")}catch(e){a="multiple"}try{n=JSON.stringify(e.outputShape)}catch(e){n="multiple"}let i=e.name,o=e.getClassName();s([`${i} (${o})`,a,n,e.countParams().toString()],t,r)}(p[e],r,i):function(e,t,r,n){let a,i;try{i=e.inboundNodes.map(e=>JSON.stringify(e.inputShapes)).join(",")}catch(e){i="multiple"}try{a=JSON.stringify(e.outputShape)}catch(e){a="multiple"}let o=[];for(let t of e.inboundNodes)if(null==r||!(r.length>0)||-1!==r.indexOf(t))for(let e=0;e<t.inboundLayers.length;++e){let r=t.inboundLayers[e].name,n=t.nodeIndices[e],a=t.tensorIndices[e];o.push(`${r}[${n}][${a}]`)}let l=e.name,u=e.getClassName(),h=0===o.length?"":o[0];s([`${l} (${u})`,i,a,e.countParams().toString(),h],t,n);for(let e=1;e<o.length;++e)s(["","","","",o[e]],t,n)}(p[e],r,l,i),i((e===p.length-1?"=":"_").repeat(t));e.checkTrainableWeightsConsistency();let d=null!=(o=e).collectedTrainableWeights?(0,n.Y)(o.collectedTrainableWeights):(0,n.Y)(o.trainableWeights),c=(0,n.Y)(e.nonTrainableWeights);i(`Total params: ${d+c}`),i(`Trainable params: ${d}`),i(`Non-trainable params: ${c}`),i("_".repeat(t))}function s(e,t,r=console.log){let n="";for(let r=0;r<e.length;++r)r>0&&(n=n.slice(0,n.length-1)+" "),n+=e[r],n=n.slice(0,t[r]),n+=" ".repeat(t[r]-n.length);r(n)}},68120:(e,t,r)=>{"use strict";r.d(t,{M:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({isFinite_:function(e){let t=(0,s.YT)(e,"x","isFinite");return n.T2.runKernel(a.gIW,{x:t})}})},68173:(e,t,r)=>{var n=r(35508),a=r(55285),s=r(33235),i=r(52985),o=r(60247),l=r(13905),u=r(95277);u.alea=n,u.xor128=a,u.xorwow=s,u.xorshift7=i,u.xor4096=o,u.tychei=l,e.exports=u},68396:(e,t,r)=>{"use strict";r.d(t,{j:()=>o});var n=r(5287),a=r(96609),s=r(72155),i=r(54463);let o=(0,r(18875).op)({sub_:function(e,t){let r=(0,i.YT)(e,"a","sub"),o=(0,i.YT)(t,"b","sub");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.PbM,l)}})},69314:(e,t,r)=>{"use strict";r.d(t,{z:()=>o});var n=r(5287),a=r(96609),s=r(72155),i=r(54463);let o=(0,r(18875).op)({mod_:function(e,t){let r=(0,i.YT)(e,"a","mod"),o=(0,i.YT)(t,"b","mod");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.BLA,l)}})},69510:(e,t,r)=>{"use strict";r.d(t,{HS:()=>s,di:()=>i,lv:()=>o});var n=r(45720),a=r(60072);function s(e,t,r,a,s){let i=n.Kro.isSliceContinous(a,t,r),o=n.ZSL.sizeFromShape(r),l=n.ZSL.computeStrides(a);if(i){let r=n.Kro.computeFlatOffset(t,l);return"string"===s?e.slice(r,r+o):e.subarray(r,r+o)}let u="string"===s?n.C0T.fromUint8ToStringArray(e):e,h=(0,n.ra8)(a,s,u),p=(0,n.ra8)(r,s);for(let e=0;e<p.size;++e){let r=p.indexToLoc(e),n=r.map((e,r)=>e+t[r]);p.set(h.get(...n),...r)}return"string"===s?n.C0T.fromStringArrayToUint8(p.values):p.values}function i(e){let{inputs:t,backend:r,attrs:i}=e,{x:o}=t,{begin:l,size:u}=i;(0,a.C)(o,"slice");let[h,p]=n.Kro.parseSliceParams(o,l,u);n.Kro.assertParamsValid(o,h,p);let d=s(r.data.get(o.dataId).values,h,p,o.shape,o.dtype);return r.makeTensorInfo(p,o.dtype,d)}let o={kernelName:n.JiE,backendName:"cpu",kernelFunc:i}},70168:(e,t,r)=>{"use strict";r.d(t,{R:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({floor_:function(e){let t=(0,s.YT)(e,"x","floor","float32");return n.T2.runKernel(a.ZgB,{x:t})}})},70818:(e,t,r)=>{"use strict";r.d(t,{V:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({tile_:function(e,t){let r=(0,s.YT)(e,"x","tile","string_or_numeric");return i.vA(r.rank===t.length,()=>`Error in transpose: rank of input ${r.rank} must match length of reps ${t}.`),n.T2.runKernel(a.FAs,{x:r},{reps:t})}})},70995:(e,t,r)=>{"use strict";r.d(t,{i:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({mean_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","mean");return n.T2.runKernel(a.g5A,{x:i},{axis:t,keepDims:r})}})},71387:(e,t,r)=>{"use strict";r.d(t,{Q:()=>l,cu:()=>i});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>+(e<=t)),o=(0,s.j)(n.CwD,i,null,"bool"),l={kernelName:n.CwD,backendName:"cpu",kernelFunc:o}},71446:(e,t,r)=>{"use strict";function n(e,t){return e>t?1:e<t?-1:0}function a(e,t,r,n,a){return o(e,t,r,n,a,0)}function s(e,t,r,n,a,s){return o(e,t,r,n,a,0,!1,s,!0)}function i(e,t,r,n,a,s){return o(e,t,r,n,a,s,!0)}function o(e,t,r,a,s,i,u=!1,h=!1,p=!1){let d=[];for(let e=0;e<t.length;e++)t[e]>s&&d.push({score:t[e],boxIndex:e,suppressBeginIndex:0});d.sort(l);let c=i>0?-.5/i:0,f=[],m=[];for(;f.length<r&&d.length>0;){let t=d.pop(),{score:r,boxIndex:i,suppressBeginIndex:o}=t;if(r<s)break;let u=!1;for(let r=f.length-1;r>=o;--r){let n=function(e,t,r){let n=e.subarray(4*t,4*t+4),a=e.subarray(4*r,4*r+4),s=Math.min(n[0],n[2]),i=Math.min(n[1],n[3]),o=Math.max(n[0],n[2]),l=Math.max(n[1],n[3]),u=Math.min(a[0],a[2]),h=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),d=Math.max(a[1],a[3]),c=(o-s)*(l-i),f=(p-u)*(d-h);if(c<=0||f<=0)return 0;let m=Math.max(Math.min(o,p)-Math.max(s,u),0)*Math.max(Math.min(l,d)-Math.max(i,h),0);return m/(c+f-m)}(e,i,f[r]);if(n>=a){u=!0;break}if(t.score=t.score*function(e,t,r){let n=Math.exp(t*r*r);return r<=e?n:0}(a,c,n),t.score<=s)break}t.suppressBeginIndex=f.length,!u&&(t.score===r?(f.push(i),m.push(t.score)):t.score>s&&function(e,t,r){let a=function(e,t,r){let n=0,a=e.length,s=0,i=!1;for(;n<a;
4095){let o=r(t,e[s=n+(a-n>>>1)]);o>0?n=s+1:(a=s,i=!o)}return i?n:-n-1}(e,t,r||n);e.splice(a<0?-(a+1):a,0,t)}(d,t,l))}let g=f.length,y=r-g;h&&y>0&&(f.push(...Array(y).fill(0)),m.push(...Array(y).fill(0)));let b={selectedIndices:f};return u&&(b.selectedScores=m),p&&(b.validOutputs=g),b}function l(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}r.d(t,{c7:()=>a,ZS:()=>s,ut:()=>i})},71490:(e,t,r)=>{"use strict";r.d(t,{Kz:()=>i,Tb:()=>h,Tw:()=>o,ik:()=>p,mB:()=>u});var n=r(45720),a=r(48683),s=r(91090);function i(e,t,r,i){let l=r.map((e,r)=>{let n={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(n.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[r],shapeInfo:n}}),u=l.map(e=>e.shapeInfo),h={logicalShape:i.shape,texShape:i.texData.texShape,isUniform:!1,isPacked:i.texData.isPacked,flatOffset:null},p=a.yr(l,h,t),d=(0,s.createFragmentShader)(e.gl,p),c=e.createProgram(d);return(0,n._K2)().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:d,source:p,webGLProgram:c,inShapeInfos:u,outShapeInfo:h,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(e.buildVao(c),Object.assign({program:t,fragmentShader:d,source:p,webGLProgram:c,inShapeInfos:u,outShapeInfo:h},o(e,t,c)))}function o(e,t,r){let a,s,i,o=[],l=[],u=null,h=null;for(let a of(h=e.getUniformLocation(r,"NAN",!1),1===(0,n._K2)().getNumber("WEBGL_VERSION")&&(u=e.getUniformLocation(r,"INFINITY",!1)),t.variableNames)){let n={name:a,uniform:e.getUniformLocation(r,a,!1),offset:e.getUniformLocation(r,`offset${a}`,!1)};t.enableShapeUniforms&&(n.shape=e.getUniformLocation(r,`${a}Shape`,!1),n.texShape=e.getUniformLocation(r,`${a}TexShape`,!1)),o.push(n)}if(t.enableShapeUniforms&&(a=e.getUniformLocation(r,"outShape",!1),i=e.getUniformLocation(r,"outShapeStrides",!1),s=e.getUniformLocation(r,"outTexShape",!1)),t.customUniforms)for(let n of t.customUniforms)l.push(e.getUniformLocation(r,n.name,!1));return{variablesLocations:o,customUniformLocations:l,infLoc:u,nanLoc:h,outShapeLocation:a,outShapeStridesLocation:i,outTexShapeLocation:s}}function l(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach((e,r)=>{let a=e.logicalShape,s=t[r],i=s.shape;if(!n.ZSL.arraysEqual(a,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${a} and ${i} must match`);if(e.isUniform&&s.isUniform)return;let o=e.texShape,l=s.isUniform?null:s.texData.texShape;if(!n.ZSL.arraysEqual(o,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${l} must match`)})}function u(e,t,r,s,i){t.program.enableShapeUniforms||(l(t.inShapeInfos,r),l([t.outShapeInfo],[s]));let o=s.texData.texture,u=s.texData.texShape;s.texData.isPacked?e.setOutputPackedMatrixTexture(o.texture,u[0],u[1]):e.setOutputMatrixTexture(o.texture,u[0],u[1]),e.setProgram(t.webGLProgram),e.bindVertexArray(t.webGLProgram.vao),1===(0,n._K2)().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN);for(let s=0;s<r.length;++s){let i=r[s],{uniform:o,offset:l,shape:u,texShape:h}=t.variablesLocations[s];if(u){let{uniformShape:r}=a.YE(t.program.packedInputs,i.shape,i.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(u,new Int32Array(r));break;case 2:e.gl.uniform2iv(u,new Int32Array(r));break;case 3:e.gl.uniform3iv(u,new Int32Array(r));break;case 4:e.gl.uniform4iv(u,new Int32Array(r))}}if(h&&e.gl.uniform2i(h,i.texData.texShape[0],i.texData.texShape[1]),null!=o){if(i.isUniform){if(2>n.ZSL.sizeFromShape(i.shape))e.gl.uniform1f(o,i.uniformValues[0]);else{let t=i.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(o,t)}continue}null!=i.texData.slice&&null!=l&&e.gl.uniform1i(l,i.texData.slice.flatOffset),e.setInputMatrixTexture(i.texData.texture.texture,o,s)}}let h=t.outShapeLocation;if(h)switch(s.shape.length){case 1:e.gl.uniform1iv(h,new Int32Array(s.shape));break;case 2:e.gl.uniform2iv(h,new Int32Array(s.shape));break;case 3:e.gl.uniform3iv(h,new Int32Array(s.shape));break;case 4:e.gl.uniform4iv(h,new Int32Array(s.shape))}if(t.outShapeStridesLocation){let r=n.ZSL.computeStrides(s.shape);switch(s.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(r));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(r));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(r))}}if(t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,s.texData.texShape[0],s.texData.texShape[1]),t.program.customUniforms&&i)for(let r=0;r<t.program.customUniforms.length;++r){let n=t.program.customUniforms[r],a=t.customUniformLocations[r],s=i[r];if("float"===n.type)e.gl.uniform1fv(a,s);else if("vec2"===n.type)e.gl.uniform2fv(a,s);else if("vec3"===n.type)e.gl.uniform3fv(a,s);else if("vec4"===n.type)e.gl.uniform4fv(a,s);else if("int"===n.type)e.gl.uniform1iv(a,s);else if("ivec2"===n.type)e.gl.uniform2iv(a,s);else if("ivec3"===n.type)e.gl.uniform3iv(a,s);else if("ivec4"===n.type)e.gl.uniform4iv(a,s);else throw Error(`uniform type ${n.type} is not supported yet.`)}e.executeProgram()}function h(e,t,r){let s="";t.concat(r).forEach(t=>{let i=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){let o=t.texData.texShape,{useSqueezeShape:l,uniformShape:u,keptDims:h}=a.YE(e.packedInputs,t.shape,o),p="",d="",c="";if(1===u.length&&e.packedInputs){let e=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];p=`${e[0]>1}_${e[1]>1}`}else if(2!==u.length||e.packedInputs){if(u.length>2&&!e.packedInputs){let e=n.ZSL.computeStrides(u);c=`${e[0]===o[1]}_${e[e.length-1]===o[1]}`}}else d=`${u[0]>1}_${u[1]>1}`;let f=t.shape.length,m=2===u.length&&n.ZSL.arraysEqual(t.shape,o),g=1===n.ZSL.sizeFromShape(t.
4095shape),y=n.C0T.getBroadcastDims(t.shape,r.shape),b=!e.packedInputs&&f===r.shape.length&&n.ZSL.arraysEqual(o,r.texData.texShape),x=e.packedInputs||u.length>2?"":`${o[0]>1}_${o[1]>1}`;s+=`${f}_${b}_${l?h:""}_${u.length}_${g}_${y}_${m}_${p}_${d}_${c}_${x}_${i}`}else{let e=t.isUniform?"uniform":t.texData.texShape;s+=`${t.shape}_${e}_${i}`}});let i=e.userCode,o=e.constructor.name;return o+("_"+s+"_"+i+`${(0,n._K2)().getNumber("WEBGL_VERSION")}`)}function p(e){return(0,n._K2)().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}},71550:(e,t,r)=>{"use strict";r.d(t,{G:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({batchToSpaceND_:function(e,t,r){let o=(0,s.YT)(e,"x","batchToSpaceND"),l=t.reduce((e,t)=>e*t);return i.vA(o.rank>=1+t.length,()=>`input rank is ${o.rank} but should be > than blockShape.length ${t.length}`),i.vA(r.length===t.length,()=>`crops.length is ${r.length} but should be equal to blockShape.length ${t.length}`),i.vA(o.shape[0]%l==0,()=>`input tensor batch is ${o.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${l}`),n.T2.runKernel(a.Ik2,{x:o},{blockShape:t,crops:r})}})},71604:(e,t,r)=>{"use strict";function n(e){let{inputs:t,backend:r}=e,{input:n}=t,a=r.data.get(n.dataId).complexTensorInfos.real,s=r.data.get(a.dataId).values;return r.makeTensorInfo(a.shape,a.dtype,s)}r.d(t,{r:()=>a,x:()=>n});let a={kernelName:r(45720).LRy,backendName:"cpu",kernelFunc:n}},72155:(e,t,r)=>{"use strict";r.r(t),r.d(t,{assertTypesMatch:()=>o,getTensorsInContainer:()=>u,isTensorInList:()=>l,makeTypesMatch:()=>i});var n=r(94708),a=r(20728),s=r(75681);function i(e,t){if(e.dtype===t.dtype)return[e,t];let r=(0,a.Tu)(e.dtype,t.dtype);return[e.cast(r),t.cast(r)]}function o(e,t){(0,s.vA)(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function l(e,t){return t.some(t=>t.id===e.id)}function u(e){let t=[];return function e(t,r,a){var s;if(null!=t){if(t instanceof n.qY)return void r.push(t);if(Array.isArray(s=t)||"object"==typeof s)for(let n in t){let s=t[n];a.has(s)||(a.add(s),e(s,r,a))}}}(e,t,new Set),t}},72344:(e,t,r)=>{"use strict";r.d(t,{J:()=>i,Ol:()=>o,mW:()=>l});var n=r(63537),a=r(95971),s=r(62376);function i(e,t,r){if("number"==typeof e)return(0,a.fD)(e,t);if(e.length!==t)throw new n.Qp(`The ${r} argument must be an integer or tuple of ${t} integers. Received: ${e.length} elements.`);for(let a=0;a<t;++a){let i=e[a];if(!(0,s.Fq)(i))throw new n.Qp(`The ${r} argument must be an integer or tuple of ${t} integers. Received: ${JSON.stringify(e)} including a non-integer number ${i}`)}return e}function o(e,t,r,n,a=1){return null==e?e:Math.floor((("same"===r?e:e-(t+(t-1)*(a-1))+1)+n-1)/n)}function l(e,t,r,a){if(null==e)return null;if("valid"===a)e=e*t+(0,s.T9)([r-t,0]);else if("same"===a)e*=t;else throw new n.Qp(`Unsupport padding mode: ${a}.`);return e}},72655:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({asinh_:function(e){let t=(0,s.YT)(e,"x","asinh");return n.T2.runKernel(a.epO,{x:t})}})},73888:(e,t,r)=>{"use strict";r.d(t,{$:()=>i});var n=r(54463),a=r(75681),s=r(77969);function i(e,t,r){if((0,a.HO)(e),null!=t&&3!==t.length)throw Error("tensor3d() requires shape to have three numbers");let i=(0,n.MZ)(e,r);if(3!==i.length&&1!==i.length)throw Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===i.length&&null==t)throw Error("tensor3d() requires shape to be provided when `values` are a flat array");return(0,s.Q)(e,t,i,r)}},74338:(e,t,r)=>{"use strict";r.d(t,{r:()=>o});var n=r(54463),a=r(75681),s=r(18875),i=r(86036);let o=(0,s.op)({squeeze_:function(e,t){let r=(0,n.YT)(e,"x","squeeze","string_or_numeric");return(0,i.t)(r,(0,a.gx)(r.shape,t).newShape)}})},74442:(e,t,r)=>{"use strict";r.d(t,{K:()=>i});var n=r(5287),a=r(96609),s=r(75681);let i=(0,r(18875).op)({ifft_:function(e){return(0,s.vA)("complex64"===e.dtype,()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`),n.T2.runKernel(a.OAQ,{input:e})}})},74709:(e,t,r)=>{"use strict";r.d(t,{Y:()=>a});var n=r(24884);function a(e,t){let r=[];for(let e=0;e<t.length;e++)t[e]&&r.push(e);let a=(0,n.r)(e,"int32"),s=(0,n.r)([r.length,e.length],"int32");for(let t=0;t<r.length;t++){let n=a.indexToLoc(r[t]),i=t*e.length;s.values.set(n,i)}return s.toTensor()}},75104:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({cumsum_:function(e,t=0,r=!1,i=!1){let o=(0,s.YT)(e,"x","cumsum");return n.T2.runKernel(a.nY8,{x:o},{axis:t,exclusive:r,reverse:i}
4095)}})},75127:(e,t,r)=>{"use strict";r.d(t,{n:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(89990);let o=(0,r(18875).op)({logicalAnd_:function(e,t){let r=(0,s.YT)(e,"a","logicalAnd","bool"),o=(0,s.YT)(t,"b","logicalAnd","bool");return(0,i.assertAndGetBroadcastShape)(r.shape,o.shape),n.T2.runKernel(a.RUm,{a:r,b:o})}})},75429:(e,t,r)=>{"use strict";r.d(t,{p:()=>a});var n=r(75904);let a=(0,r(18875).op)({euclideanNorm_:function(e,t=null,r=!1){return(0,n.x)(e,"euclidean",t,r)}})},75444:(e,t,r)=>{"use strict";r.d(t,{q:()=>h});var n=r(45720),a=r(21131),s=r(63537),i=r(2748);class o{constructor(e){this.seed=e}next(){if(void 0!==this.seed)return this.seed++}}o.className="RandomSeed";class l extends i.Wd{constructor(e){super(e),this.randomGenerator=new o(e.seed)}getConfig(){let e={seed:this.randomGenerator.seed};return Object.assign(e,super.getConfig()),e}}l.className="BaseRandomLayer";let u=new Set(["bilinear","nearest"]);class h extends l{constructor(e){super(e);let{factor:t,interpolation:r="bilinear"}=e;if(this.factor=t,Array.isArray(this.factor)&&2===this.factor.length)this.widthLower=this.factor[0],this.widthUpper=this.factor[1];else if(!Array.isArray(this.factor)&&this.factor>0)this.widthLower=-this.factor,this.widthUpper=this.factor;else throw new s.Qp(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);if(this.widthLower<-1||this.widthUpper<-1)throw new s.Qp(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper<this.widthLower)throw new s.Qp(`factor cannot have upper bound less than lower bound. 4096 Got upper bound: ${this.widthUpper}. 4097 Got lower bound: ${this.widthLower} 4098 `);if(r)if(u.has(r))this.interpolation=r;else throw new s.Qp(`Invalid interpolation parameter: ${r} is not implemented`)}getConfig(){let e={factor:this.factor,interpolation:this.interpolation};return Object.assign(e,super.getConfig()),e}computeOutputShape(e){let t=(e=(0,a.U$)(e))[2];return[this.imgHeight,-1,t]}call(e,t){return(0,n.DZQ)(()=>{let t=(0,a.un)(e);this.imgHeight=t.shape[t.shape.length-3];let r=t.shape[t.shape.length-2];this.widthFactor=(0,n.YeY)([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let s=this.widthFactor.dataSync()[0]*r;s=Math.round(s);let i=[this.imgHeight,s];switch(this.interpolation){case"bilinear":return n.Slp.resizeBilinear(e,i);case"nearest":return n.Slp.resizeNearestNeighbor(e,i);default:throw Error(`Interpolation is ${this.interpolation} 4099 but only ${[...u]} are supported`)}})}}h.className="RandomWidth",n.JFn.registerClass(h)},75521:(e,t,r)=>{"use strict";r.r(t),r.d(t,{assertParamsValid:()=>a,computeFlatOffset:()=>g,computeOutShape:()=>i,getNormalizedAxes:()=>u,isSliceContinous:()=>m,maskToAxes:()=>s,parseSliceParams:()=>y,sliceInfo:()=>b,startForAxis:()=>c,startIndicesWithElidedDims:()=>h,stopForAxis:()=>f,stopIndicesWithElidedDims:()=>p,stridesForAxis:()=>d,stridesWithElidedDims:()=>o});var n=r(75681);function a(e,t,r){let a=e.shape.length;n.vA(a===t.length,()=>`Error in slice${a}D: Length of begin ${t} must match the rank of the array (${a}).`),n.vA(a===r.length,()=>`Error in slice${a}D: Length of size ${r} must match the rank of the array (${a}).`);for(let s=0;s<a;++s)n.vA(t[s]+r[s]<=e.shape[s],()=>`Error in slice${a}D: begin[${s}] + size[${s}] (${t[s]+r[s]}) would overflow input.shape[${s}] (${e.shape[s]})`)}function s(e){let t=[],r=0;for(;e>0;)1&e&&t.push(r),e/=2,r++;return t}function i(e,t,r){let n=[];for(let a=0;a<e.length;a++)n[a]=Math.ceil((t[a]-e[a])/r[a]);return n}function o(e,t,r,n){let a=[...e];for(let e=a.length;e<n.length;e++)a.push(1);for(let e=0;e<r;e++)0===e?a[t]=1:(a.splice(t,0,1),a.pop());return a}function l(e,t){let r=[];for(let n=0;n<e;n++)r.push(t+n);return r}function u(e,t,r,n,a,s,i,l,u){let m=e.length,g=Array(m),y=Array(m),b=Array(m);if(t.length&&r>0){let u=t[0],d=r+1;g=h(i,u,d,n,e),y=p(l,u,d,a,e),b=o(s,u,d,e)}else for(let t=0;t<m;t++)g[t]=c(i,n,s,e,t,u),y[t]=f(l,a,s,e,t,u),b[t]=d(s,t,u);return{begin:g,end:y,strides:b}}function h(e,t,r,n,a){let s=[...a],i=l(r,t);for(let a=0;a<s.length;a++)if(i.indexOf(a)>-1)s[a]=0;else{var o,u,h;let i=(o=t,u=r,(h=a)<=o?h:h-(u-1)),l=n[i];e&1<<i&&(l=0),s[a]=l}return s}function p(e,t,r,a,s){let i=[...s],o=l(r,t);for(let n=0;n<i.length;n++)if(o.indexOf(n)>-1)i[n]=Number.MAX_SAFE_INTEGER;else{var u,h,p;let s=(u=t,h=r,(p=n)<=u?p:p-(h-1)),o=a[s];e&1<<s&&(o=Number.MAX_SAFE_INTEGER),i[n]=o}for(let e=0;e<i.length;e++){let t=s[e];i[e]<0&&(i[e]+=t),i[e]=n.qE(0,i[e],s[e])}return i}function d(e,t,r){let n=e[t];return(r&1<<t||null==n)&&(n=1),n}function c(e,t,r,a,s,i){let o=t[s],l=r[s]||1;(e&1<<s||i&1<<s||null==o)&&(o=l>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);let u=a[s];return o<0&&(o+=u),o=n.qE(0,o,u-1)}function f(e,t,r,a,s,i){let o=t[s],l=r[s]||1;(e&1<<s||i&1<<s||null==o)&&(o=l>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);let u=a[s];return o<0&&(o+=u),o=l>0?n.qE(0,o,u):n.qE(-1,o,u-1)}function m(e,t,r){let n=r.length;for(let e=0;e<r.length;e++)if(r[e]>1){n=e;break}for(let a=n+1;a<r.length;a++)if(t[a]>0||r[a]!==e[a])return!1;return!0}function g(e,t){let r=e.length>0?e[e.length-1]:1;for(let n=0;n<e.length-1;n++)r+=e[n]*t[n];return r}function y(e,t,r){let a,s,i=e.shape.length;return(a="number"==typeof t?[t,...Array(i-1).fill(0)]:t.length<i?t.concat(Array(i-t.length).fill(0)):t.slice()).forEac
4099h(e=>{n.vA(-1!==e,()=>"slice() does not support negative begin indexing.")}),s=(s=null==r?Array(i).fill(-1):"number"==typeof r?[r,...Array(i-1).fill(-1)]:r.length<i?r.concat(Array(i-r.length).fill(-1)):r).map((t,r)=>t>=0?t:(n.vA(-1===t,()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${r}.`),e.shape[r]-a[r])),[a,s]}function b(e,t,r,n,a,s,i,o,l){let u;if(null==n?(u=Array(t.length)).fill(1):u=n,null!=i&&(i&i-1)!=0)throw Error("Multiple ellipses in slice is not allowed.");let h=!1,p={dims:u.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:r.slice(),strides:u.slice(),beginMask:a,endMask:s,ellipsisMask:i,newAxisMask:o,shrinkAxisMask:l};for(let e=0;e<p.dims;e++)h&&(1<<e&o)!=0&&p.numAddAxisAfterEllipsis++,1<<e&i&&(h=!0);!h&&(p.ellipsisMask|=1<<p.dims,p.dims++);let d={dims:e.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};var c=p,f=d;f.beginMask=0,f.endMask=0,f.shrinkAxisMask=0;let m=0;f.beginValid=null!=c.begin,f.endValid=null!=c.end,f.begin=Array(f.dims),f.end=Array(f.dims),f.strides=Array(f.dims),f.finalShapeGatherIndices=[],f.finalShapeGatherIndicesSparse=[],f.inputShapeGatherIndicesSparse=Array(f.dims);for(let e=0;e<c.dims;e++)if(1<<e&c.ellipsisMask){let t=Math.min(f.dims-(c.dims-e)+1+c.numAddAxisAfterEllipsis,f.dims);for(;m<t;m++)f.begin[m]=0,f.end[m]=0,f.strides[m]=1,f.beginMask|=1<<m,f.endMask|=1<<m,f.finalShapeGatherIndices.push(m),f.finalShapeGatherIndicesSparse.push(-1),f.inputShapeGatherIndicesSparse[m]=e}else if(1<<e&c.newAxisMask)f.finalShapeGatherIndices.push(-2),f.finalShapeGatherIndicesSparse.push(-1);else{if(m===f.begin.length)throw Error(`Index out of range using input dim ${m}; input has only ${f.dims} dims, ${f.begin.length}.`);null!=c.begin&&(f.begin[m]=c.begin[e]),null!=c.end&&(f.end[m]=c.end[e]),f.strides[m]=c.strides[e],c.beginMask&1<<e&&(f.beginMask|=1<<m),c.endMask&1<<e&&(f.endMask|=1<<m),c.shrinkAxisMask&1<<e?(f.finalShapeGatherIndices.push(-1),f.finalShapeGatherIndicesSparse.push(-1),f.shrinkAxisMask|=1<<m):(f.finalShapeGatherIndices.push(m),f.finalShapeGatherIndicesSparse.push(e)),f.inputShapeGatherIndicesSparse[m]=e,m++}let g=!0,y=!0,b=!0,v=[],w=[];for(let t=0;t<e.length;++t){let r;if(0===d.strides[t])throw Error(`strides[${t}] must be non-zero`);let n=!!(d.shrinkAxisMask&1<<t),a=e[t];if(-1===a){v.push(n?1:-1);continue}let s=[d.beginMask&1<<t,d.endMask&1<<t],i=[d.strides[t]>0?0:-1,d.strides[t]>0?a:a-1];if(n&&d.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");b=b&&1===d.strides[t];let o=!!(d.beginMask&1<<t&&d.endMask&1<<t);if(d.beginValid&&d.endValid){if(n){let e=d.begin[t]<0?a+d.begin[t]:d.begin[t];if(d.begin[t]=e,d.end[t]=d.begin[t]+1,e<0||e>=a)throw Error(`slice index ${d.begin[t]} of dimension ${t} out of bounds.`)}else d.begin[t]=x(d.begin[t],0,d.strides[t],a,s,i),d.end[t]=x(d.end[t],1,d.strides[t],a,s,i);let e=1===d.strides[t]&&0===d.begin[t]&&d.end[t]===a;g=g&&e,y=y&&(0===t&&1===d.strides[t]||e)}else g=g&&1===d.strides[t]&&o,y=y&&(0===t&&1===d.strides[t]||o);let l=!1;if(d.beginValid&&d.endValid?(r=d.end[t]-d.begin[t],l=!0):n?(r=1,l=!0):o&&a>=0&&(r=d.strides[t]<0?-a:a,l=!0),l){let e;e=0===r||r<0!=d.strides[t]<0?0:Math.trunc(r/d.strides[t])+ +(r%d.strides[t]!=0),v.push(e)}else v.push(-1)}for(let e=0;e<d.finalShapeGatherIndices.length;++e){let t=d.finalShapeGatherIndices[e];t>=0?w.push(v[t]):-2===t&&w.push(1)}return{finalShapeSparse:w.filter((e,t)=>-2!==d.finalShapeGatherIndices[t]),finalShape:w,isIdentity:g,sliceDim0:y,isSimpleSlice:b,begin:d.begin,end:d.end,strides:d.strides}}function x(e,t,r,n,a,s){if(a[t])return r>0?s[t]:s[t+1&1];{let t=e<0?n+e:e;return t<s[0]?s[0]:t>s[1]?s[1]:t}}},75681:(e,t,r)=>{"use strict";function n(e){let t=e.length,r=0;for(;t>0;)r=Math.random()*t|0,o(e,--t,r)}function a(e,t){if(e.length!==t.length)throw Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let r=e.length,n=0;for(;r>0;)n=Math.random()*r|0,o(e,--r,n),o(t,r,n)}function s(e,t,r){return Math.max(e,Math.min(t,r))}function i(e){return e%2==0?e:e+1}function o(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function l(e){let t=0;for(let r=0;r<e.length;r++)t+=e[r];return t}function u(e,t){let r=Math.random();return t*r+(1-r)*e}function h(e,t){let r=0;for(let n=0;n<e.length;n++){let a=Number(e[n])-Number(t[n]);r+=a*a}return r}function p(e,t){if(!e)throw Error("string"==typeof t?t:t())}function d(e,t,r=""){p(y(e,t),()=>r+` Shapes ${e} and ${t} must match`)}function c(e){p(null!=e,()=>"The input to the tensor constructor must be a non-null value.")}function f(e){if(0===e.length)return 1;let t=e[0];for(let r=1;r<e.length;r++)t*=e[r];return t}function m(e){return 0===e.length}function g(e,t){if(e===t)return!0;
4099if(null==e||null==t||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(null!==e[r]&&null!==t[r]&&e[r]!==t[r])return!1;return!0}function y(e,t){if(e===t)return!0;if(null==e||null==t||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function b(e){return e%1==0}function x(e){if(null!=Math.tanh)return Math.tanh(e);if(e===1/0)return 1;{if(e===-1/0)return -1;let t=Math.exp(2*e);return(t-1)/(t+1)}}function v(e){let t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function w(e){let t=new Uint32Array(e);for(let r=0;r<e;++r)t[r]=r;return n(t),t}function T(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function S(e,t=e=>0,r,n){return new Promise((a,s)=>{let i=0,o=()=>{if(e())return void a();let l=t(++i);if(null!=r&&i>=r)return void s();null!=n?n(o,l):setTimeout(o,l)};o()})}function N(e,t){let r=1,n=-1;for(let t=0;t<e.length;++t)if(e[t]>=0)r*=e[t];else if(-1===e[t]){if(-1!==n)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${n} and dim ${t}`);n=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);
4099if(-1===n){if(t>0&&t!==r)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===r)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%r!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${r}`);let a=e.slice();return a[n]=t/r,a}function k(e,t){let r=t.length;return p((e=null==e?t.map((e,t)=>t):[].concat(e)).every(e=>e>=-r&&e<r),()=>`All values in axis param must be in range [-${r}, ${r}) but got axis ${e}`),p(e.every(e=>b(e)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(e=>e<0?r+e:e)}function I(e,t){let r=[],n=[],a=null!=t&&Array.isArray(t)&&0===t.length,s=null==t||a?null:k(t,e).sort(),i=0;for(let t=0;t<e.length;++t){if(null!=s){if(s[i]===t&&1!==e[t])throw Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==s[i]||s[i]>t)&&1===e[t]&&(r.push(e[t]),n.push(t)),s[i]<=t&&i++}1!==e[t]&&(r.push(e[t]),n.push(t))}return{newShape:r,keptDims:n}}function C(e,t){return E(e,t)}function E(e,t){let r=null;if(null==e||"float32"===e)r=new Float32Array(t);else if("int32"===e)r=new Int32Array(t);else if("bool"===e)r=new Uint8Array(t);else if("string"===e)r=Array(t);else throw Error(`Unknown data type ${e}`);return r}function A(e,t){for(let r=0;r<e.length;r++){let n=e[r];if(isNaN(n)||!isFinite(n))throw Error(`A tensor of type ${t} being uploaded contains ${n}.`)}}function $(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function F(e,t){return"complex64"!==t&&("float32"!==t||"complex64"===e)&&("int32"!==t||"float32"===e||"complex64"===e)&&("bool"!==t||"bool"!==e)}function R(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw Error(`Unknown dtype ${e}`)}function _(e){if(null==e)return 0;let t=0;return e.forEach(e=>t+=e.length),t}function D(e){return"string"==typeof e||e instanceof String}function O(e){return"boolean"==typeof e}function L(e){return"number"==typeof e}function M(e){return!!(e&&e.constructor&&e.call&&e.apply)}function P(e,t){for(let r=t;r<e;++r)if(e%r==0)return r;return e}function z(e){let t=e.length;if(t<2)return[];let r=Array(t-1);r[t-2]=e[t-1];for(let n=t-3;n>=0;--n)r[n]=r[n+1]*e[n+1];return r}function B(e,t,r=!1){if(0===e.length)return t[0];let n=e.reduce((e,t)=>e*t)*(r?2:1);if(0===n)return[];if(n!==t.length)throw Error(`[${e}] does not match the input size ${t.length}${r?" for a complex tensor":""}.`);return function e(t,r,n,a=!1){let s=[];if(1===r.length){let e=r[0]*(a?2:1);for(let r=0;r<e;r++)s[r]=n[t+r]}else{let i=r[0],o=r.slice(1),l=o.reduce((e,t)=>e*t)*(a?2:1);for(let r=0;r<i;r++)s[r]=e(t+r*l,o,n,a)}return s}(0,e,t,r)}function W(e,t){if(Array.isArray(e))return e;if("float32"===t)return e instanceof Float32Array?e:new Float32Array(e);if("int32"===t)return e instanceof Int32Array?e:new Int32Array(e);if("bool"===t||"string"===t)return Uint8Array.from(new Int32Array(e));throw Error(`Unknown dtype ${t}`)}function V(e,t){let r=U(e,t);for(let e=0;e<r.length;e++)r[e]=1;return r}function U(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw Error(`Unknown data type ${t}`)}function G(e,t){let r=e.reduce((e,t)=>e*t,1);if(null==t||"float32"===t)return B(e,new Float32Array(r));if("int32"===t)return B(e,new Int32Array(r));if("bool"===t)return B(e,new Uint8Array(r));throw Error(`Unknown data type ${t}`)}function Z(e){e.forEach(t=>{p(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function j(e,t,r){if(0===t)return 0;if(1===t)return e[0];let n=e[e.length-1];for(let t=0;t<e.length-1;++t)n+=r[t]*e[t];return n}function K(e,t,r){if(0===t)return[];if(1===t)return[e];let n=Array(t);for(let t=0;t<n.length-1;++t)n[t]=Math.floor(e/r[t]),e-=n[t]*r[t];return n[n.length-1]=e,n}function H(e){return e&&e.then&&"function"==typeof e.then}r.d(t,{Ab:()=>E,BE:()=>F,E6:()=>b,Et:()=>L,FZ:()=>V,HO:()=>c,Kg:()=>D,Lm:()=>O,O3:()=>d,P8:()=>w,SA:()=>Z,SL:()=>_,Sf:()=>m,Tn:()=>M,Ty:()=>U,Ur:()=>z,X$:()=>function e(t){if(Array.isArray(t))return e(t[0]);if(t instanceof Float32Array);else if(t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray)return"int32";else if(L(t));else if(D(t))return"string";else if(O(t))return"bool";return"float32"},XT:()=>N,Y6:()=>k,Ze:()=>f,_k:()=>K,_q:()=>S,a0:()=>a,av:()=>T,c7:()=>G,ce:()=>C,cz:()=>l,eV:()=>i,e_:()=>g,gS:()=>v,gx:()=>I,jv:()=>R,k4:()=>n,lK:()=>P,nd:()=>A,o2:()=>W,oO:()=>h,qE:()=>s,r1:()=>y,sX:()=>j,so:()=>u,vA:()=>p,wg:()=>o,xn:()=>$,yL:()=>H,ym:()=>x,yw:()=>B})},75904:(e,t,r)=>{"use strict";r.d(t,{x:()=>g});var n=r(54463),a=r(75681),s=r(4006),i=r(64256),o=r(39616),l=r(67146),u=r(18875),h=r(17392),p=r(86036),d=r(57610),c=r(53744),f=r(11983),m=r(79625);let g=(0,u.op)({norm_:function(e,t="euclidean",r=null,u=!1){let g=function e(t,r,n=null){if(0===t.rank)return(0,s.t)(t);if(1!==t.rank&&null===n)return e((0,p.t)(t,[-1]),r,n);if(1===t.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===r)return(0,m.c)((0,s.t)(t),n);if(r===1/0)return(0,o.T)((0,s.t)(t),n);if(r===-1/0)return(0,l.j)((0,s.t)(t),n);if("euclidean"===r||2===r)return(0,c.R)((0,m.c)((0,h.n)((0,s.t)(t),(0,d.d)(2,"int32")),n)
4099);throw Error(`Error in norm: invalid ord value: ${r}`)}if(Array.isArray(n)&&2===n.length){if(1===r)return(0,o.T)((0,m.c)((0,s.t)(t),n[0]),n[1]-1);if(r===1/0)return(0,o.T)((0,m.c)((0,s.t)(t),n[1]),n[0]);if(r===-1/0)return(0,l.j)((0,m.c)((0,s.t)(t),n[1]),n[0]);if("fro"===r||"euclidean"===r)return(0,c.R)((0,m.c)((0,f.E)(t),n));throw Error(`Error in norm: invalid ord value: ${r}`)}throw Error(`Error in norm: invalid axis: ${n}`)}(e=(0,n.YT)(e,"x","norm"),t,r),y=g.shape;if(u){let t=(0,a.Y6)(r,e.shape);y=i.SM(g.shape,t)}return(0,p.t)(g,y)}})},76110:(e,t,r)=>{"use strict";r.d(t,{x:()=>l});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(4087);let l=(0,r(18875).op)({concat_:function(e,t=0){(0,i.vA)(e.length>=1,()=>"Pass at least one tensor to concat");let r=(0,s.j1)(e,"tensors","concat","string_or_numeric");return("complex64"===r[0].dtype&&r.forEach(e=>{if("complex64"!==e.dtype)throw Error(`Cannot concatenate complex64 tensors with a tensor 4100 with dtype ${e.dtype}. `)}),1===r.length)?(0,o.o)(r[0]):n.T2.runKernel(a.$dB,r,{axis:t})}})},76466:(e,t,r)=>{"use strict";r.d(t,{Dk:()=>i,hd:()=>o});var n=r(45720),a=r(60072),s=r(82407);function i(e,t,r){let a=n.ZSL.createScalarValue(-1,r);return(0,s.BF)([],t,a,e,r)}let o={kernelName:n.l0G,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n}=t;(0,a.C)(n,"neg");let[s,o]=i(r.data.get(n.dataId).values,n.shape,n.dtype);return r.makeTensorInfo(o,n.dtype,s)}}},76565:(e,t,r)=>{"use strict";r.d(t,{q:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({asin_:function(e){let t=(0,s.YT)(e,"x","asin");return n.T2.runKernel(a.QKF,{x:t})}})},76915:(e,t,r)=>{"use strict";r.d(t,{Bm:()=>f,G2:()=>l,R9:()=>d,l1:()=>u,l2:()=>h});var n=r(45720),a=r(40693),s=r(95971);function i(e){if(null!=e&&"object"!=typeof e)throw Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`)}class o extends n.JFn.Serializable{}class l extends o{constructor(e){super(),i(e),this.l1=null==e||null==e.l1?.01:e.l1,this.l2=null==e||null==e.l2?.01:e.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(e){return(0,n.DZQ)(()=>{let t=(0,n.Ul9)([1]);return this.hasL1&&(t=(0,n.WQq)(t,(0,n.czq)(n.lKK(this.l1,(0,n.tnl)(e))))),this.hasL2&&(t=(0,n.WQq)(t,(0,n.czq)(n.lKK(this.l2,a.Ew(e))))),n.tQQ(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}function u(e){return i(e),new l({l1:null!=e?e.l1:null,l2:0})}function h(e){return i(e),new l({l2:null!=e?e.l2:null,l1:0})}l.className="L1L2",n.JFn.registerClass(l);let p={l1l2:"L1L2"};function d(e){return(0,s.k4)(e)}function c(e,t={}){return(0,s.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"regularizer")}function f(e){return null==e?null:"string"==typeof e?c({className:e in p?p[e]:e,config:{}}):e instanceof o?e:c(e)}},77298:(e,t,r)=>{"use strict";r.d(t,{$:()=>i});var n=r(46519),a=r(15768),s=r(27738);class i{constructor(e){this.variableNames=["A"],this.outTexUsage=s.tT.DOWNLOAD;let t=(0,n.B)();this.outputShape=e,this.userCode=` 4101 ${a.G2} 4102 4103 void main() { 4104 float x = getAAtOutCoords(); 4105 ${t.output} = encode_float(x); 4106 } 4107 `}}},77688:(e,t,r)=>{"use strict";r.d(t,{L:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({sinh_:function(e){let t=(0,s.YT)(e,"x","sinh");return n.T2.runKernel(a.J3C,{x:t})}})},77833:(e,t,r)=>{"use strict";r.d(t,{_:()=>l});var n=r(5287),a=r(96609),s=r(54463),i=r(35199),o=r(89990);let l=(0,r(18875).op)({where_:function(e,t,r){let l=(0,s.YT)(t,"a","where"),u=(0,s.YT)(r,"b","where"),h=(0,s.YT)(e,"condition","where","bool"),p=(0,o.assertAndGetBroadcastShape)((0,o.assertAndGetBroadcastShape)(h.shape,l.shape),u.shape),d=(0,i.h)(h,p),c=(0,i.h)(l,p),f=(0,i.h)(u,p);return n.T2.runKernel(a.l6P,{condition:d,t:c,e:f})}})},77969:(e,t,r)=>{"use strict";r.d(t,{Q:()=>o});var n=r(5287),a=r(20728),s=r(75681),i=r(22700);function o(e,t,r,o){if(null==o)o=(0,s.X$)(e);else if("complex64"===o)throw Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if((0,a.Nw)(e)||(0,a.Oj)(e)){if("float32"!==o&&"int32"!==o)throw Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${o}.`);return n.T2.backend.createTensorFromGPUData(e,t||r,o)}if(!(0,i.isTypedArray)(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){(0,s.SA)(t);let e=(0,s.Ze)(t),n=(0,s.Ze)(r);(0,s.vA)(e===n,()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${n}`);for(let e=0;e<r.length;++e){let n=r[e],a=e!==r.length-1||n!==(0,s.Ze)(t.slice(e));(0,s.vA)(r[e]===t[e]||!a,()=>`Error creating a new Tensor. Inferred shape (${r}) does not match the provided shape (${t}). `)}}return(0,i.isTypedArray)(e)||Array.isArray(e)||(e=[e]),t=t||r,e="string"!==o?(0,i.toTypedArray)(e,o):(0,i.flatten)(e,[],!0),n.T2.makeTensor(e,t,o)}},78059:(e,t,r)=>{"use strict";r.d(t,{z:()=>i});var n=r(71490),a=r(91076),s=r(48683);class i{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length);let t=e.length,r=(0,a.Jp)("rc",t),i=(0,s.bf)(t),o=(0,a.kp)(t,r),l=r.slice(-2),u=t<=1?"rc":`vec2(${l.join(",")})`;this.userCode=` 4108 void main() { 4109 ${i} rc = getOutputCoords(); 4110 vec4 packedInput = getA(${o}); 4111 4112 setOutput(getChannel(packedInput, ${u})); 4113 } 4114 `}}},78412:(e,t,r)=>{"use strict";r.d(t,{R:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({log_:function(e){let t=(0,s.YT)(e,"x","log","float32");return n.T2.runKernel(a.tG8,{x:t})}})},78522:(e,t,r)=>{"use strict";r.d(t,{He:()=>i,l9:()=>l});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>Math.max(e,t)),o=(0,s.j)(n.LDN,i),l={kernelName:n.LDN,backendName:"cpu",kernelFunc:o}},79069:(e,t,r)=>{"use strict";r.d(t,{W:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({selu_:function(e){let t=(0,s.YT)(e,"x","selu");return n.T2.runKernel(a.u$b,{x:t})}})},79625:(e,t,r)=>{"use strict";r.d(t,{c:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(13797);let o=(0,r(18875).op)({sum_:function(e,t=null,r=!1){let o=(0,s.YT)(e,"x","sum");"bool"===o.dtype&&(o=(0,i.w)(o,"int32"));let l={x:o};return n.T2.runKernel(a.WuN,l,{axis:t,keepDims:r})}})},80553:(e,t,r)=>{"use strict";r.d(t,{C2:()=>f,FA:()=>y,JW:()=>x,L:()=>T,R2:()=>v,XO:()=>m,Yv:()=>g,tg:()=>w,xq:()=>b});
4114var n=r(45720),a=r(31479),s=r(40693),i=r(40838),o=r(2748),l=r(63537),u=r(42290),h=r(76915),p=r(95971),d=r(62376),c=r(21131);class f extends o.Wd{constructor(e){super(e),this.rate=Math.max(Math.min(e.rate,1),0),this.noiseShape=e.noiseShape,this.seed=e.seed,this.supportsMasking=!0}getNoiseShape(e){if(null==this.noiseShape)return this.noiseShape;let t=e.shape,r=[];for(let e=0;e<this.noiseShape.length;++e)r.push(null==this.noiseShape[e]?t[e]:this.noiseShape[e]);return r}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e);if(0<this.rate&&this.rate<1){let e=null!=t.training&&t.training,n=this.getNoiseShape(r);return s.Ls(()=>s.EZ(r,this.rate,n,this.seed),()=>r,e)}return e})}getConfig(){let e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed};return Object.assign(e,super.getConfig()),e}dispose(){return super.dispose()}}f.className="Dropout",n.JFn.registerClass(f);class m extends f{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){let t=e.shape;return[t[0],1,t[2]]}}m.className="SpatialDropout1D",n.JFn.registerClass(m);class g extends o.Wd{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){let t=null;null!=e.batchSize&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,(0,p.oo)(this.units,"units"),this.activation=(0,a.b_)(e.activation),null!=e.useBias&&(this.useBias=e.useBias),this.kernelInitializer=(0,u.Fe)(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=(0,u.Fe)(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=(0,i.YZ)(e.kernelConstraint),this.biasConstraint=(0,i.YZ)(e.biasConstraint),this.kernelRegularizer=(0,h.Bm)(e.kernelRegularizer),this.biasRegularizer=(0,h.Bm)(e.biasRegularizer),this.activityRegularizer=(0,h.Bm)(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){let t=(e=(0,c.U$)(e))[e.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){let t=(e=(0,c.U$)(e)).slice();return t[t.length-1]=this.units,t}call(e,t){return(0,n.DZQ)(()=>{let r;this.invokeCallHook(e,t);let n=(0,c.un)(e),a=(0,p.Cd)(this.activation.getClassName());return null!=a?r=s.Om(n,this.kernel.read(),a,this.bias?this.bias.read():null):(r=s.Om(n,this.kernel.read()),null!=this.bias&&(r=s.ni(r,this.bias.read())),null!=this.activation&&(r=this.activation.apply(r))),r})}getConfig(){let e={units:this.units,activation:(0,a.Bu)(this.activation),useBias:this.useBias,kernelInitializer:(0,u.zo)(this.kernelInitializer),biasInitializer:(0,u.zo)(this.biasInitializer),kernelRegularizer:(0,h.R9)(this.kernelRegularizer),biasRegularizer:(0,h.R9)(this.biasRegularizer),activityRegularizer:(0,h.R9)(this.activityRegularizer),kernelConstraint:(0,i.uH)(this.kernelConstraint),biasConstraint:(0,i.uH)(this.biasConstraint)};return Object.assign(e,super.getConfig()),e}}g.className="Dense",n.JFn.registerClass(g);class y extends o.Wd{constructor(e){super(e=e||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){for(let t of(e=(0,c.U$)(e)).slice(1))if(null==t)throw new l.Qp(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],(0,d.no)(e,1)]}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e);if("channelsFirst"===this.dataFormat&&r.rank>1){let e=[0];for(let t=2;t<r.rank;++t)e.push(t);e.push(1),r=(0,n.mgz)(r,e)}return s.PS(r)})}getConfig(){let e={};return null!=this.dataFormat&&(e.dataFormat=this.dataFormat),Object.assign(e,super.getConfig()),e}}y.className="Flatten",n.JFn.registerClass(y);class b extends o.Wd{constructor(e){super(e),this.supportsMasking=!0,this.activation=(0,a.b_)(e.activation)}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e);return this.activation.apply(r)})}getConfig(){let e={activation:(0,a.Bu)(this.activation)};return Object.assign(e,super.getConfig()),e}}b.className="Activation",n.JFn.registerClass(b);class x extends o.Wd{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return(0,n.DZQ)(()=>(e=(0,c.un)(e),s.ux(e,this.n)))}getConfig(){let e={n:this.n};return Object.assign(e,super.getConfig()),e}}x.className="RepeatVector",n.JFn.registerClass(x);class v extends o.Wd{constructor(e){super(e),this.targetShape=e.targetShape;for(let e=0;e<this.targetShape.length;++e)this.isUnknown(this.targetShape[e])&&(this.targetShape[e]=null)}isUnknown(e){return e<0||null==e}fixUnknownDimension(e,t){let r="Total size of new array must be unchanged.",n=t.slice(),a=1,s=null;for(let e=0;e<n.length;++e){let t=n[e];if(this.isUnknown(t))if(null===s)s=e;else throw new l.Qp("Can only specifiy one unknown dimension.");else a*=t}let i=(0,d.no)(e);if(null!==s){if(0===a||i%a!=0)throw new l.Qp(r);n[s]=i/a}else if(i!==a)throw new l.Qp(r);return n}computeOutputShape(e){let t=!1;for(let r=0;r<e.length;++r)if(this.isUnknown(e[r])){t=!0;break}return t?e.slice(0,1).concat(this.targetShape):e.slice(0,1).concat(this.fixUnknownDimension(e.slice(1),this.targetShape))}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e),a=r.shape,s=a.slice(0,1).concat(this.fixUnknownDimension(a.slice(1),this.targetShape));return(0,n.tQQ)(r,s)})}getConfig(){let e={targetShape:this.targetShape};return Object.assign(e,super.getConfig()),e}}v.className="Reshape",n.JFn.registerClass(v);class w extends o.Wd{constructor(e){if(super(e),null==e.dims)throw Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);let t=(0,d.y1)(1,e.dims.length+1);if(!n.ZSL.arraysEqual(e.dims.slice().sort(),t))throw Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new o.eO({ndim:this.dims.length+1})]}computeOutputShape(e){let t=(e=(0,c.U$)(e)).slice();
4114return this.dims.forEach((r,n)=>{t[n+1]=e[r]}),t}call(e,t){return(0,n.mgz)((0,c.un)(e),this.dimsIncludingBatch)}getConfig(){let e={dims:this.dims};return Object.assign(e,super.getConfig()),e}}w.className="Permute",n.JFn.registerClass(w);class T extends o.Wd{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e?this.maskValue=null==e.maskValue?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){let r=(0,c.un)(e);return(0,n.bzn)((0,n.Ec)(r,this.maskValue),-1)}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e),a=(0,n.bzn)((0,n.Ec)(r,this.maskValue),-1,!0);return(0,n.lKK)(r,(0,n.wgE)(a,r.dtype))})}}T.className="Masking",n.JFn.registerClass(T)},81384:(e,t,r)=>{"use strict";r.d(t,{Lt:()=>l,Zy:()=>i});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)(e=>1/Math.sqrt(e)),o=(0,s.F)(n.TOR,i),l={kernelName:n.TOR,backendName:"cpu",kernelFunc:o}},81538:(e,t,r)=>{"use strict";r.d(t,{EY:()=>s,To:()=>n,bb:()=>i,ft:()=>a,r$:()=>o});let n=["channelsFirst","channelsLast"],a=["nearest","bilinear"],s=["valid","same","causal"],i=["max","avg"],o=["sum","mul","concat","ave"]},81963:(e,t,r)=>{"use strict";r.d(t,{U:()=>function e(t,r,s="float32"){if("complex64"===s){let n=e(t,r,"float32"),s=e(t,r,"float32");return(0,a.f)({inputs:{real:n,imag:s},backend:t})}let i=n.ZSL.makeZerosTypedArray(n.ZSL.sizeFromShape(r),s);return t.makeTensorInfo(r,s,i)}});var n=r(45720),a=r(83772)},82065:(e,t,r)=>{"use strict";r.d(t,{X:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({argMin_:function(e,t=0){let r=(0,s.YT)(e,"x","argMin");return n.T2.runKernel(a.p_m,{x:r},{axis:t})}})},82178:(e,t,r)=>{"use strict";r.d(t,{w:()=>u});var n=r(54463),a=r(75681),s=r(61630),i=r(55756),o=r(18875),l=r(86036);let u=(0,o.op)({separableConv2d_:function(e,t,r,o,u,h=[1,1],p="NHWC"){let d=(0,n.YT)(e,"x","separableConv2d"),c=(0,n.YT)(t,"depthwiseFilter","separableConv2d"),f=(0,n.YT)(r,"pointwiseFilter","separableConv2d"),m=d,g=!1;if(3===d.rank&&(g=!0,m=(0,l.t)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),"NCHW"===p)throw Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");a.vA(4===m.rank,()=>`Error in separableConv2d: input must be rank 4, but got rank ${m.rank}.`),a.vA(4===c.rank,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${c.rank}.`),a.vA(4===f.rank,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${c.rank}.`),a.vA(1===f.shape[0],()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${f.shape[0]}.`),a.vA(1===f.shape[1],()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${f.shape[1]}.`);let y=c.shape[2],b=c.shape[3];a.vA(f.shape[2]===y*b,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${y*b}, but got ${f.shape[2]}.`);let x=(0,i.G)(m,c,o,u,p,h),v=(0,s.X)(x,f,1,"valid",p);return g?(0,l.t)(v,[v.shape[1],v.shape[2],v.shape[3]]):v}})},82407:(e,t,r)=>{"use strict";r.d(t,{BF:()=>i,lw:()=>l,tJ:()=>u});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>e*t),o=(0,s.B)((e,t,r,n)=>({real:e*r-t*n,imag:e*n+t*r})),l=(0,s.j)(n.xu7,i,o),u={kernelName:n.xu7,backendName:"cpu",kernelFunc:l}},82870:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({topk_:function(e,t=1,r=!0){let i=(0,s.YT)(e,"x","topk");
4114if(0===i.rank)throw Error("topk() expects the input to be of rank 1 or higher");let o=i.shape[i.shape.length-1];if(t<0)throw Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>o)throw Error(`'k' passed to topk() must be <= the last dimension (${o}) but got ${t}`);let[l,u]=n.T2.runKernel(a.TBb,{x:i},{k:t,sorted:r});return{values:l,indices:u}}})},83310:(e,t,r)=>{"use strict";r.d(t,{RF:()=>i,b2:()=>l});var n=r(45720),a=r(16879),s=r(8202);let i=(0,a.Z)((e,t)=>{let r=e-t;return r*r}),o=(0,s.j)(n.Ddj,i),l={kernelName:n.Ddj,backendName:"cpu",kernelFunc:o}},83772:(e,t,r)=>{"use strict";function n(e){let{inputs:t,backend:r}=e,{real:n,imag:a}=t,s=r.data.get(n.dataId).values,i=r.data.get(a.dataId).values,o=r.makeTensorInfo(n.shape,"complex64");return r.data.get(o.dataId).complexTensorInfos={real:r.makeTensorInfo(n.shape,"float32",s),imag:r.makeTensorInfo(a.shape,"float32",i)},o}r.d(t,{f:()=>n,v:()=>a});let a={kernelName:r(45720).pr3,backendName:"cpu",kernelFunc:n}},84198:(e,t,r)=>{"use strict";r.d(t,{v:()=>u});var n=r(5287),a=r(96609),s=r(75681),i=r(46866),o=r(18875),l=r(86036);let u=(0,o.op)({conv2DBackpropInput_:function(e,t,r,o,u,h="NHWC",p){s.vA(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let d=e,c=t,f=!1;3===t.rank&&(f=!0,c=(0,l.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]),d=[1,e[0],e[1],e[2]]),s.vA(4===d.length,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${d.length}.`),s.vA(4===c.rank,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${c.rank}`),s.vA(4===r.rank,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${r.rank}`);let m="NHWC"===h?d[3]:d[1],g="NHWC"===h?c.shape[3]:c.shape[1];s.vA(m===r.shape[2],()=>`Error in conv2dDerInput: depth of input (${m}) must match input depth for filter ${r.shape[2]}.`),s.vA(g===r.shape[3],()=>`Error in conv2dDerInput: depth of output (${g}) must match output depth for filter ${r.shape[3]}.`),i.s_("conv2dDerInput",u,p);let y={dy:c,filter:r},b={strides:o,pad:u,dataFormat:h,dimRoundingMode:p,inputShape:d},x=n.T2.runKernel(a.jfg,y,b);return f?(0,l.t)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}})},84290:(e,t,r)=>{"use strict";r.d(t,{p:()=>o});var n=r(2748),a=r(45720),s=r(21131),i=r(40693);class o extends n.Wd{constructor(e){super(e),this.scale=e.scale,e.offset?this.offset=e.offset:this.offset=0}getConfig(){let e={scale:this.scale,offset:this.offset};return Object.assign(e,super.getConfig()),e}call(e,t){return(0,a.DZQ)(()=>("float32"!==(e=(0,s.un)(e)).dtype&&(e=i.wg(e,"float32")),(0,a.WQq)((0,a.lKK)(e,this.scale),this.offset)))}}o.className="Rescaling",a.JFn.registerClass(o)},84996:(e,t,r)=>{"use strict";r.d(t,{b:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({any_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","any","bool");return n.T2.runKernel(a.FSt,{x:i},{axis:t,keepDims:r})}})},85133:(e,t,r)=>{"use strict";r.d(t,{c:()=>l});var n=r(5287),a=r(96609),s=r(75681),i=r(18875),o=r(86036);let l=(0,i.op)({conv3DBackpropInput_:function(e,t,r,i,l){s.vA(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let u=e,h=t,p=!1;4===t.rank&&(p=!0,h=(0,o.t)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),u=[1,e[0],e[1],e[2],e[3]]);let d=u[4],c=h.shape[4];s.vA(5===u.length,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${u.length}.`),s.vA(5===h.rank,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${h.rank}`),s.vA(5===r.rank,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${r.rank}`),s.vA(d===r.shape[3],()=>`Error in conv3dDerInput: depth of input (${d}) must match input depth for filter ${r.shape[3]}.`),s.vA(c===r.shape[4],()=>`Error in conv3dDerInput: depth of output (${c}) must match output depth for filter ${r.shape[4]}.`);let f={dy:h,filter:r},m={pad:l,strides:i,inputShape:u},g=n.T2.runKernel(a.gC7,f,m);return p?(0,o.t)(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}})},85648:(e,t,r)=>{"use strict";r.d(t,{g:()=>f});var n=r(47802),a=r(76110),s=r(98308),i=r(54256),o=r(18875),l=r(43578),u=r(86036),h=r(2632),p=r(57610),d=r(61324),c=r(74442);let f=(0,o.op)({irfft_:function(e){let t,r=e.shape[e.shape.length-1],o=e.size/r;if(r<=2){let n=(0,u.t)(e,[o,r]);t=(0,c.K)(n)}else{let f=[o,2*(r-1)],m=(0,u.t)((0,l.x)(e),[o,r]),g=(0,u.t)((0,s.n)(e),[o,r]),y=(0,h.B)((0,d.d)(m,[0,1],[o,r-2]),1),b=(0,i.l)((0,h.B)((0,d.d)(g,[0,1],[o,r-2]),1),(0,p.d)(-1)),x=(0,a.x)([m,y],1),v=(0,a.x)([g,b],1),w=(0,u.t)((0,n.f)(x,v),[f[0],f[1]]);t=(0,c.K)(w)}if(t=(0,l.x)(t),3===e.rank&&0!==e.shape[0]){let r=t,n=e.shape[0];t=(0,u.t)(t,[n,t.shape[0]/n,t.shape[1]]),r.dispose()}return t}})},85656:(e,t,r)=>{"use strict";r.d(t,{q:()=>a});var n=r(45720);function a(e,t,r,a){let s=e===t,i=e<t&&r<0,o=t<e&&r>1;if(s||i||o)return n.ZSL.makeZerosTypedArray(0,a);let l=Math.abs(Math.ceil((t-e)/r)),u=n.ZSL.makeZerosTypedArray(l,a);t<e&&1===r&&(r=-1),u[0]=e;for(let e=1;e<u.length;e++)u[e]=u[e-1]+r;return u}},86032:(e,t,r)=>{"use strict";r.d(t,{H:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({neg_:function(e){let t=(0,s.YT)(e,"x","neg");return n.T2.runKernel(a.l0G,{x:t})}})},86036:(e,t,r)=>{"use strict";r.d(t,{t:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({reshape_:function(e,t){let r=(0,s.YT)(e,"x","reshape","string_or_numeric");return n.T2.runKernel(a.R23,{x:r},{shape:t})}})},86049:(e,t,r)=>{"use strict";r.d(t,{$:()=>p});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(13797),l=r(46866),u=r(18875),h=r(86036);let p=(0,u.op)({avgPool_:function(e,t,r,u,p){let d=(0,s.YT)(e,"x","avgPool","float32");i.vA(l.G0(r,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${r} and dilations '1'`);let c=d,f=!1;3===d.rank&&(f=!0,c=(0,h.t)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),i.vA(4===c.rank,()=>`Error in avgPool: x must be rank 4 but got rank ${c.rank}.`),l.s_("avgPool",u,p);let m={x:c},g=n.T2.runKernel(a.ho8,m,{filterSize:t,strides:r,pad:u,dimRoundingMode:p});return(g=(0,o.w)(g,d.dtype),f)?(0,h.t)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}})},86376:(e,t,r)=>{"use strict";r.d(t,{RW:()=>u,g7:()=>c,oR:()=>d});var n=r(45720),a=r(63537);class s{constructor(e){this.maxEntries=e||100,this.cache=new Map}get(e){let t;return this.cache.has(e)&&(t=this.cache.get(e),this.cache.delete(e),this.cache.set(e,t)),t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxEntries){let e=this.cache.keys().next().value;this.cache.delete(e)}this.cache.set(e,t)}getMaxEntries(){return this.maxEntries}setMaxEntries(e){if(e<0)throw Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`);if(this.maxEntries>e)for(let t=0;t<this.maxEntries-e;t++){let e=this.cache.keys().next().value;this.cache.delete(e)}this.maxEntries=e}}var i=r(95971),o=r(91533),l=r(2748);class u{constructor(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof u)for(let t in e.id2Value)this.id2Value[t]=e.id2Value[t],t in e.id2Mask&&(this.id2Mask[t]=e.id2Mask[t]);else{if(null==e)return;for(let t of e)this.add(t.key,t.value)}}add(e,t,r){if(null==this.id2Value[e.id])this.id2Value[e.id]=function(e,t){if(null==e.dtype||e.dtype===t.dtype)return t;try{return(0,n.wgE)(t,e.dtype)}catch(r){throw new a.Qp(`The dtype of the feed (${t.dtype}) can not be cast to the dtype of the key '${e.name}' (${e.dtype}).`)}}(e,t),this.name2Id[e.name]=e.id,null!=r&&(this.id2Mask[e.id]=r);else throw new a.Qp(`Duplicate key: name=${e.name}, id=${e.id}`);return this}addFeed(e){this.add(e.key,e.value)}hasKey(e){return null!=this.id2Value[e.id]}names(){return Object.keys(this.name2Id)}getValue(e){if(e instanceof l.Ar)if(null!=this.id2Value[e.id])return this.id2Value[e.id];else throw new a.Qp(`Nonexistent key: ${e.name}`);{let t=this.name2Id[e];if(null==t)throw new a.Qp(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Value[t]}}getMask(e){if(e instanceof l.Ar)if(null!=this.id2Value[e.id])return this.id2Mask[e.id];else throw new a.Qp(`Nonexistent key: ${e.name}`);{let t=this.name2Id[e];if(null==t)throw new a.Qp(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Mask[t]}}disposeMasks(){null!=this.id2Mask&&(0,n.ASo)(this.id2Mask)}}let h=new s,p=new s;function d(e){null!=h&&h.setMaxEntries(e),null!=p&&p.setMaxEntries(e)}function c(e,t,r,a){let s,l=null!=r&&r.training,d=Array.isArray(e),c=d?e:[e],m=c.map(e=>e.name),g=[],y=t.names();for(let e of m)-1!==y.indexOf(e)?g.push(t.getValue(e)):g.push(null);null!=a&&(a.maxNumTensors=-1/0,a.minNumTensors=1/0);let b=m.join(",")+"|"+t.names().sort().join(","),x=h.get(b);if(null==x){let e=function(e,t){n.ZSL.assert(null!=e&&e.length>0,()=>"Expected at least one fetch, got none");let r=[],a={};if(1===e.length){let n=f(e[0],t);r=n.sorted,a=n.recipientMap}else{let n=new Set;for(let s of e){let{sorted:e,recipientMap:i}=f(s,t);for(let t of e)n.has(t.name)||(r.push(t),n.add(t.name));for(let e in i)null==a[e]&&(a[e]=new Set),i[e].forEach(t=>a[e].add(t))}}return{sorted:r,recipientCounts:function(e){let t={};for(let r in e)t[r]=e[r].size;return t}(a)}}(c,t);x=e.sorted,s=e.recipientCounts,h.put(b,x),p.put(b,s)}s={},l||Object.assign(s,p.get(b));let v=new u(t);for(let e=0;e<x.length;++e){if(null!=a){let e=(0,n.m1Z)().numTensors;e>a.maxNumTensors&&(a.maxNumTensors=e),e<a.minNumTensors&&(a.minNumTensors=e)}let u=x[e],h=u.sourceLayer;if(h instanceof o.m)continue;let p=[],d=[],c=[],f=!1;for(let e of u.inputs){let r=v.getValue(e),n=v.getMask(e);p.push(r),d.push(n),null!=n&&(f=!0),!l&&(s[e.name]--,0!==s[e.name]||t.hasKey(e)||-1!==m.indexOf(e.name)||r.isDisposed||!0===e.s
4114ourceLayer.stateful||c.push(r))}f&&((r=r||{}).mask=d[0]);let y=(0,i.st)(h.apply(p,r)),b=null;h.supportsMasking&&(b=h.computeMask(p,d));let w=function(e){let t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{let r=null;for(let t=0;t<e.sourceLayer.inboundNodes.length;++t)for(let n of e.sourceLayer.inboundNodes[t].outputTensors)if(n.id===e.id){r=t;break}t=e.sourceLayer.getOutputAt(r)}return t}(u),T=Array.isArray(w)?w:[w];for(let e=0;e<T.length;++e){v.hasKey(T[e])||v.add(T[e],y[e],Array.isArray(b)?b[0]:b);let t=m.indexOf(T[e].name);-1!==t&&(g[t]=y[e])}l||(0,n.ASo)(c)}return v.disposeMasks(),d?g:g[0]}function f(e,t){let r=new Set,n=[],a={};for(let e of t.names())r.add(e);let s=[],i=[];for(s.push(e);s.length>0;){let e=s[s.length-1];if(r.has(e.name)){s.pop();continue}let t=i[i.length-1]===s.length-1;if(0===e.inputs.length||t)s.pop(),n.push(e),r.add(e.name),t&&i.pop();else for(let t of(i.push(s.length-1),e.inputs))null==a[t.name]&&(a[t.name]=new Set),a[t.name].add(e.name),r.has(t.name)||s.push(t)}return{sorted:n,recipientMap:a}}},87260:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({step_:function(e,t=0){let r=(0,s.YT)(e,"x","step");return n.T2.runKernel(a.pnw,{x:r},{alpha:t})}})},87309:(e,t,r)=>{"use strict";r.d(t,{b:()=>a});var n=r(45720);function a(e,t,r,a,s,i,o,l,u,h){let p=e.values,d=t.values;if(0===a)return(0,n.ra8)(r,t.dtype);let c=u instanceof n.ylz?u:(0,n.ra8)([a/s,s],t.dtype);"string"==typeof u||"number"==typeof u?c.values.fill(u):"boolean"==typeof u&&c.values.fill(+u);for(let e=0;e<i;e++){let n=[],i=0;for(let t=0;t<o;t++){let r=p[e*o+t];n.push(r),i+=r*l[t]}if(i<0||i>=a/s)throw Error(`Invalid indices: ${n} does not index into ${r}`);for(let r=0;r<s;r++)h?c.values[i*s+r]+=d[e*s+r]:c.values[i*s+r]=0===t.rank?d[0]:d[e*s+r]}return c}},89200:(e,t,r)=>{"use strict";r.d(t,{d:()=>d});var n=r(54463),a=r(75681),s=r(86049),i=r(71550),o=r(46866),l=r(52899),u=r(18875),h=r(86036),p=r(33282);let d=(0,u.op)({pool_:function(e,t,r,u,d,c,f){let m;null==d&&(d=[1,1]),null==c&&(c=1),0===u&&(u="valid");let g=(0,n.YT)(e,"x","maxPool"),y=g,b=!1;3===g.rank&&(b=!0,y=(0,h.t)(g,[1,g.shape[0],g.shape[1],g.shape[2]])),a.vA(o.G0(c,d),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${c} and dilations '${d}'`);let x=o.E6(y.shape,t,c,d,u),v=[x.dilationHeight,x.dilationWidth];m="same"===u?function(e,t){let r=e.map((e,r)=>e+(e-1)*(t[r]-1)).map(e=>e-1),n=r.map(e=>Math.floor(e/2)),a=r.map((e,t)=>e-n[t]);return r.map((e,t)=>[n[t],a[t]])}([x.filterHeight,x.filterWidth],v):[[0,0],[0,0]];let w=1===v[0]&&1===v[1],[T,S]=function(e,t,r){let n=r.map(e=>e[0]),a=r.map(e=>e[1]),s=e.concat(n,a),i=t.map((e,t)=>(e-s[t]%e)%e),o=a.map((e,t)=>e+i[t]);return[t.map((e,t)=>[n[t],o[t]]),t.map((e,t)=>[0,i[t]])]}([x.inHeight,x.inWidth],v,m),N=w?u:"valid",k=w?y:(0,p.e)(y,v,T),I=("avg"===r?()=>(0,s.$)(k,t,c,N,f):()=>(0,l.j)(k,t,c,N,f))(),C=w?I:(0,i.G)(I,v,S);return b?(0,h.t)(C,[C.shape[1],C.shape[2],C.shape[3]]):C}})},89510:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({sigmoid_:function(e){let t=(0,s.YT)(e,"x","sigmoid","float32");return n.T2.runKernel(a.vI1,{x:t})}})},89573:(e,t,r)=>{"use strict";r.d(t,{YG:()=>i,uf:()=>l});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)(e=>Math.ceil(e)),o=(0,s.F)(n.QDP,i),l={kernelName:n.QDP,backendName:"cpu",kernelFunc:o}},89827:(e,t,r)=>{"use strict";r.d(t,{m:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({ceil_:function(e){let t=(0,s.YT)(e,"x","ceil","float32");return n.T2.runKernel(a.QDP,{x:t})}})},89967:(e,t,r)=>{"use strict";r.d(t,{e:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({pad_:function(e,t,r=0){let i=(0,s.YT)(e,"x","pad");if(0===i.rank)throw Error("pad(scalar) is not defined. Pass non-scalar to pad");return n.T2.runKernel(a.ODT,{x:i},{paddings:t,constantValue:r})}})},89972:(e,t,r)=>{"use strict";r.d(t,{D:()=>a});var n=r(22700);class a{static join(e){return new a(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,null==e||(e instanceof Array||(e=[e]),0===(e=e.map(e=>n.isTypedArray(e)?e.buffer:e)).length))return;this.bufferUniformSize=e[0].byteLength;let t=0;for(let r=0;r<e.length;r++){let n=e[r];r!==e.length-1&&n.byteLength!==this.bufferUniformSize&&(this.bufferUniformSize=void 0);let a=t+n.byteLength;this.shards.push({buffer:n,start:t,end:a}),t=a}0===this.shards.length&&(this.byteLength=0),this.byteLength=this.shards[this.shards.length-1].end}slice(e=0,t=this.byteLength){if(0===this.shards.length||(e=isNaN(Number(e))?0:e,t=isNaN(Number(t))?0:t,e=Math.max(0,e),(t=Math.min(this.byteLength,t))<=e))return new ArrayBuffer(0);let r=this.findShardForByte(e);if(-1===r)throw Error(`Could not find start shard for byte ${e}`);let n=new ArrayBuffer(t-e),a=new Uint8Array(n),s=0;for(let n=r;n<this.shards.length;n++){let r=this.shards[n],i=e+s-r.start,o=s,l=Math.min(t,r.end)-r.start,u=new Uint8Array(r.buffer,i,l-i);if(a.set(u,o),s+=u.length,t<r.end)break}return n}findShardForByte(e){if(0===this.shards.length||e<0||e>=this.byteLength)return -1;if(null!=this.bufferUniformSize)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function t(t){return e<t.start?-1:+(e>=t.end)}if(0===t(this.shards[this.previousShardIndex]))return this.previousShardIndex;let r=function(e,t){let r=0,n=e.length;for(;r<=n;){let a=Math.floor((n-r)/2)+r,s=t(e[a]);if(0===s)return a;s<0?n=a:r=a+1}return -1}(this.shards,t);return -1===r?-1:(this.previousShardIndex=r,this.previousShardIndex)}}},89990:(e,t,r)=>{"use strict";function n(e,t){let r=e.length,n=[];for(let a=0;a<r;a++){let s=r-1-a,i=e[s]||1;(t[t.length-1-a]||1)>1&&1===i&&n.unshift(s)}return n}function a(e,t){let r=[];for(let n=0;n<t.length;n++){let a=e[e.length-n-1],s=t.length-n-1,i=t[s];(null==a||1===a&&i>1)&&r.unshift(s)}return r}function s(e,t){let r=Math.max(e.length,t.length),n=Array(r);for(let a=0;a<r;a++){let s=e[e.length-a-1];null==s&&(s=1);let i=t[t.length-a-1];if(null==i&&(i=1),1===s)n[r-a-1]=i;else if(1===i)n[r-a-1]=s;else if(s!==i)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);else n[r-a-1]=s}return n}r.r(t),r.d(t,{assertAndGetBroadcastShape:()=>s,getBroadcastDims:()=>n,getReductionAxes:()=>a})},90861:(e,t,r)=>{"use strict";r.d(t,{$t:()=>S,Gk:()=>g,JJ:()=>I,Mg:()=>T,OA:()=>A,TG:()=>y,XC:()=>E,_M:()=>k,kd:()=>v,nO:()=>x});var n=r(45720),a=r(64630),s=r(40693),i=r(48671),o=r(2748),l=r(63537),u=r(72344),h=r(95971),p=r(21131),d=r(31824);function c(e,t,r,s,o,l){return(0,n.DZQ)(()=>{let u;(0,i.uM)(o),(0,i.Kx)(l),(0,i.tB)(s),null==r&&(r=[1,1]),null==s&&(s="valid"),null==o&&(o=(0,a.VI)()),null==l&&(l="max"),e=(0,d.RK)(e,o);let h="same"===s?"same":"valid";return u="max"===l?n.jgi(e,t,r,h):n.$jT(e,t,r,h),"channelsFirst"===o&&(u=n.mgz(u,[0,3,1,2])),u})}function f(e,t,r,s,o,l){return(0,n.DZQ)(()=>{let u;(0,i.uM)(o),(0,i.Kx)(l),(0,i.tB)(s),null==r&&(r=[1,1,1]),null==s&&(s="valid"),null==o&&(o=(0,a.VI)()),null==l&&(l="max"),e=(0,d.al)(e,o);let h="same"===s?"same":"valid";return u="max"===l?n.NYV(e,t,r,h):n.sub(e,t,r,h),"channelsFirst"===o&&(u=n.mgz(u,[0,4,1,2,3])),u})}class m extends o.Wd{constructor(e){if(null==e.poolSize&&(e.poolSize=2),super(e),"number"==typeof e.poolSize)this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&1===e.poolSize.length&&"number"==typeof e.poolSize[0])this.poolSize=e.poolSize;else throw new l.Qp(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if((0,h.oo)(this.poolSize,"poolSize"),null==e.strides)this.strides=this.poolSize;else if("number"==typeof e.strides)this.strides=[e.strides];else if(Array.isArray(e.strides)&&1===e.strides.length&&"number"==typeof e.strides[0])this.strides=e.strides;else throw new l.Qp(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);(0,h.oo)(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,(0,i.tB)(this.padding),this.inputSpec=[new o.eO({ndim:3})]}computeOutputShape(e){e=(0,p.U$)(e);let t=(0,u.Ol)(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t),e=s.UG((0,p.un)(e),2);let r=this.poolingFunction((0,p.un)(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return n.r2V(r,[2])})}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides};return Object.assign(e,super.getConfig()),e}}class g extends m{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),c(e,t,r,n,a,"max")}}g.className="MaxPooling1D",n.JFn.registerClass(g);class y extends m{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),c(e,t,r,n,a,"avg")}}y.className="AveragePooling1D",n.JFn.registerClass(y);class b extends o.Wd{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new l.Qp(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];(0,h.oo)(this.poolSize,"poolSize"),(0,h.oo)(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,(0,i.uM)(this.dataFormat),(0,i.tB)(this.padding),this.inputSpec=[new o.eO({ndim:4})]}computeOutputShape(e){e=(0,p.U$)(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],r="channelsFirst"===this.dataFormat?e[3]:e[2];return(t=(0,u.Ol)(t,this.poolSize[0],this.padding,this.strides[0]),r
4114=(0,u.Ol)(r,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat)?[e[0],e[1],t,r]:[e[0],t,r,e[3]]}call(e,t){return(0,n.DZQ)(()=>(this.invokeCallHook(e,t),this.poolingFunction((0,p.un)(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat};return Object.assign(e,super.getConfig()),e}}class x extends b{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),c(e,t,r,n,a,"max")}}x.className="MaxPooling2D",n.JFn.registerClass(x);class v extends b{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),c(e,t,r,n,a,"avg")}}v.className="AveragePooling2D",n.JFn.registerClass(v);class w extends o.Wd{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new l.Qp(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];(0,h.oo)(this.poolSize,"poolSize"),(0,h.oo)(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,(0,i.uM)(this.dataFormat),(0,i.tB)(this.padding),this.inputSpec=[new o.eO({ndim:5})]}computeOutputShape(e){e=(0,p.U$)(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],r="channelsFirst"===this.dataFormat?e[3]:e[2],n="channelsFirst"===this.dataFormat?e[4]:e[3];return(t=(0,u.Ol)(t,this.poolSize[0],this.padding,this.strides[0]),r=(0,u.Ol)(r,this.poolSize[1],this.padding,this.strides[1]),n=(0,u.Ol)(n,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat)?[e[0],e[1],t,r,n]:[e[0],t,r,n,e[4]]}call(e,t){return(0,n.DZQ)(()=>(this.invokeCallHook(e,t),this.poolingFunction((0,p.un)(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat};return Object.assign(e,super.getConfig()),e}}class T extends w{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),f(e,t,r,n,a,"max")}}T.className="MaxPooling3D",n.JFn.registerClass(T);class S extends w{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),f(e,t,r,n,a,"avg")}}S.className="AveragePooling3D",n.JFn.registerClass(S);class N extends o.Wd{constructor(e){super(e),this.inputSpec=[new o.eO({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new l.EH}}class k extends N{constructor(e){super(e||{})}call(e,t){return(0,n.DZQ)(()=>{let t=(0,p.un)(e);return n.i2o(t,1)})}}k.className="GlobalAveragePooling1D",n.JFn.registerClass(k);class I extends N{constructor(e){super(e||{})}call(e,t){return(0,n.DZQ)(()=>{let t=(0,p.un)(e);return n.T9B(t,1)})}}I.className="GlobalMaxPooling1D",n.JFn.registerClass(I);class C extends o.Wd{constructor(e){super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,(0,i.uM)(this.dataFormat),this.inputSpec=[new o.eO({ndim:4})]}computeOutputShape(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new l.EH}getConfig(){let e={dataFormat:this.dataFormat};return Object.assign(e,super.getConfig()),e}}class E extends C{call(e,t){return(0,n.DZQ)(()=>{let t=(0,p.un)(e);return"channelsLast"===this.dataFormat?n.i2o(t,[1,2]):n.i2o(t,[2,3])})}}E.className="GlobalAveragePooling2D",n.JFn.registerClass(E);class A extends C{call(e,t){return(0,n.DZQ)(()=>{let t=(0,p.un)(e);return"channelsLast"===this.dataFormat?n.T9B(t,[1,2]):n.T9B(t,[2,3])})}}A.className="GlobalMaxPooling2D",n.JFn.registerClass(A)},90945:(e,t,r)=>{"use strict";let n;r.d(t,{L:()=>s,m:()=>i});var a=r(95704);function s(){if(null==n){let e;if("undefined"!=typeof window)e=window;else if(void 0!==r.g)e=r.g;else if(void 0!==a)e=a;else if("undefined"!=typeof self)e=self;else throw Error("Could not find a global object");n=e}return n}function i(e,t){let r=function(){let e=s();
4114return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(r.has(e))return r.get(e);{let n=t();return r.set(e,n),r.get(e)}}},91076:(e,t,r)=>{"use strict";function n(e,t){return["x","y","z","w","u","v"].slice(0,t).map(t=>`${e}.${t}`)}function a(e,t){return 1===t?[e]:n(e,t)}function s(e,t){if(1===e)return"rc";let r="";for(let n=0;n<e;n++)r+=t[n],n<e-1&&(r+=",");return r}r.d(t,{Fd:()=>n,Jp:()=>a,kp:()=>s})},91090:(e,t,r)=>{"use strict";let n,a;r.r(t),r.d(t,{assertNotComplex:()=>ee,bindCanvasToFramebuffer:()=>F,bindColorTextureToFramebuffer:()=>R,bindTextureToProgramUniformSampler:()=>$,bindTextureUnit:()=>I,bindVertexBufferToProgramAttribute:()=>k,callAndCheck:()=>l,canBeRepresented:()=>u,createFragmentShader:()=>c,createFramebuffer:()=>N,createProgram:()=>g,createStaticIndexBuffer:()=>v,createStaticVertexBuffer:()=>x,createTexture:()=>T,createVertexShader:()=>d,getBatchDim:()=>P,getExtensionOrThrow:()=>p,getFramebufferErrorMessage:()=>O,getMaxTexturesInShader:()=>j,getNumChannels:()=>w,getProgramUniformLocation:()=>A,getProgramUniformLocationOrThrow:()=>E,getRowsCols:()=>z,getShapeAs3D:()=>B,getTextureShapeFromLogicalShape:()=>W,getWebGLDisjointQueryTimerVersion:()=>K,getWebGLErrorMessage:()=>h,getWebGLMaxTextureSize:()=>U,hasExtension:()=>H,isCapableOfRenderingToFloatTexture:()=>Q,isDownloadFloatTextureEnabled:()=>q,isReshapeFree:()=>V,isWebGLFenceEnabled:()=>J,isWebGLVersionEnabled:()=>Y,linkProgram:()=>y,logShaderSourceAndInfoLog:()=>m,resetMaxTextureSize:()=>G,resetMaxTexturesInShader:()=>Z,unbindColorTextureFromFramebuffer:()=>_,unbindTextureUnit:()=>C,validateFramebuffer:()=>D,validateProgram:()=>b,validateTextureSize:()=>S});var s=r(45720),i=r(1357),o=r(27738);function l(e,t){let r=t();return(0,s._K2)().getBool("DEBUG")&&function(e){let t=e.getError();if(t!==e.NO_ERROR)throw Error("WebGL Error: "+h(e,t))}(e),r}function u(e){return!!((0,s._K2)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||596e-10<Math.abs(e)&&65504>Math.abs(e))}function h(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}function p(e,t){return L(e,()=>e.getExtension(t),'Extension "'+t+'" not supported on this browser.')}function d(e,t){let r=L(e,()=>e.createShader(e.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(l(e,()=>e.shaderSource(r,t)),l(e,()=>e.compileShader(r)),!1===e.getShaderParameter(r,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(r)),Error("Failed to compile vertex shader.");return r}function c(e,t){let r=L(e,()=>e.createShader(e.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(l(e,()=>e.shaderSource(r,t)),l(e,()=>e.compileShader(r)),(0,s._K2)().get("ENGINE_COMPILE_ONLY"))return r;if(!1===e.getShaderParameter(r,e.COMPILE_STATUS))throw m(t,e.getShaderInfoLog(r)),Error("Failed to compile fragment shader.");return r}let f=/ERROR: [0-9]+:([0-9]+):/g;function m(e,t){let r=f.exec(t);if(null==r){console.log(`Couldn't parse line number in error: ${t}`),console.log(e);return}let n=+r[1],a=e.split("\n"),i=a.length.toString().length+2,o=a.map((e,t)=>s.ZSL.rightPad((t+1).toString(),i)+e),l=0;for(let e=0;e<o.length;e++)l=Math.max(o[e].length,l);let u=o.slice(0,n-1),h=o.slice(n-1,n),p=o.slice(n);console.log(u.join("\n")),console.log(t.split("\n")[0]),console.log(`%c ${s.ZSL.rightPad(h[0],l)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(p.join("\n"))}function g(e){return L(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}function y(e,t){if(l(e,()=>e.linkProgram(t)),!(0,s._K2)().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),Error("Failed to link vertex and fragment shaders.")}function b(e,t){if(l(e,()=>e.validateProgram(t)),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),Error("Shader program validation failed.")}function x(e,t){let r=L(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return l(e,()=>e.bindBuffer(e.ARRAY_BUFFER,r)),l(e,()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)),r}function v(e,t){let r=L(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return l(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r)),l(e,()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)),r}function w(){return 2===(0,s._K2)().getNumber("WEBGL_VERSION")?1:4}function T(e){return L(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}function S(e,t){let r=(0,s._K2)().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw Error(`Requested texture size [${e}x${t}
4114] is invalid.`);if(e>r||t>r)throw Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${r}x${r}].`)}function N(e){return L(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function k(e,t,r,n,a,s,i){let o=e.getAttribLocation(t,r);return -1!==o&&(l(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),l(e,()=>e.vertexAttribPointer(o,a,e.FLOAT,!1,s,i)),l(e,()=>e.enableVertexAttribArray(o)),!0)}function I(e,t,r){M(e,r),l(e,()=>e.activeTexture(e.TEXTURE0+r)),l(e,()=>e.bindTexture(e.TEXTURE_2D,t))}function C(e,t){M(e,t),l(e,()=>e.activeTexture(e.TEXTURE0+t)),l(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function E(e,t,r){return L(e,()=>e.getUniformLocation(t,r),'uniform "'+r+'" not present in program.')}function A(e,t,r){return e.getUniformLocation(t,r)}function $(e,t,r,n){l(e,()=>I(e,t,n)),l(e,()=>e.uniform1i(r,n))}function F(e){l(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),l(e,()=>e.viewport(0,0,e.canvas.width,e.canvas.height)),l(e,()=>e.scissor(0,0,e.canvas.width,e.canvas.height))}function R(e,t,r){l(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,r)),l(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0))}function _(e,t){l(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),l(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function D(e){let t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw Error("Error binding framebuffer: "+O(e,t))}function O(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}function L(e,t,r){let n=l(e,()=>t());if(null==n)throw Error(r);return n}function M(e,t){let r=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,n=t+e.TEXTURE0;if(n<e.TEXTURE0||n>r){let e=`[gl.TEXTURE0, gl.TEXTURE${r}]`;throw Error(`textureUnit must be in ${e}.`)}}function P(e,t=2){return s.ZSL.sizeFromShape(e.slice(0,e.length-t))}function z(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function B(e){let t=[1,1,1];return 0!==e.length&&(1!==e.length||1!==e[0])&&(t=[P(e),...z(e)]),t}function W(e,t=!1){let r=(0,s._K2)().getNumber("WEBGL_MAX_TEXTURE_SIZE"),n=(0,s._K2)().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");n===1/0&&(0,s._K2)().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(n=r/2),t&&(r*=2,n*=2,1===(e=e.map((t,r)=>r>=e.length-2?s.ZSL.nearestLargerEven(e[r]):e[r])).length&&(e=[2,e[0]])),2!==e.length&&(e=s.ZSL.squeezeShape(e).newShape);let a=s.ZSL.sizeFromShape(e),i=null;e.length<=1&&a<=r?i=[1,a]:2===e.length&&e[0]<=r&&e[1]<=r?i=e:3===e.length&&e[0]*e[1]<=r&&e[2]<=r?i=[e[0]*e[1],e[2]]:3===e.length&&e[0]<=r&&e[1]*e[2]<=r?i=[e[0],e[1]*e[2]]:4===e.length&&e[0]*e[1]*e[2]<=r&&e[3]<=r?i=[e[0]*e[1]*e[2],e[3]]:4===e.length&&e[0]<=r&&e[1]*e[2]*e[3]<=r&&(i=[e[0],e[1]*e[2]*e[3]]);let o=null!=i&&Math.max(...i)>n&&Math.min(...i)<=(t?2:1)&&Math.min(...i)>0;if(null==i||o)if(t){let t=P(e),r=2,n=2;e.length&&([r,n]=z(e)),a=r/2*t*(n/2),i=s.ZSL.sizeToSquarishShape(a).map(e=>2*e)}else i=s.ZSL.sizeToSquarishShape(a);return i}function V(e,t){if(e=e.slice(-2),t=t.slice(-2),s.ZSL.arraysEqual(e,t)||!e.length||!t.length||0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){let r=e[e.length-1],n=t[t.length-1];if(r===n||r%2==0&&n%2==0&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&e[0]%2==0&&t[0]%2==0}function U(e){if(null==n){let t=(0,i.bU)(e);n=t.getParameter(t.MAX_TEXTURE_SIZE)}return n}function G(){n=null}function Z(){a=null}function j(e){if(null==a){let t=(0,i.bU)(e);a=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,a)}function K(e){if(0===e)return 0;let t=(0,i.bU)(e);return H(t,"EXT_disjoint_timer_query_webgl2")&&2===e?2:+!!H(t,"EXT_disjoint_timer_query")}function H(e,t){return null!=e.getExtension(t)}function Y(e){try{let t=(0,i.bU)(e);if(null!=t)return!0}catch(e){console.log("Error when getting WebGL context: ",e)}return!1}function Q(e){if(0===e)return!1;let t=(0,i.bU)(e);if(1===e){if(!H(t,"OES_texture_float"))return!1}else if(!H(t,"EXT_color_buffer_float"))return!1;return X(t)}function q(e){if(0===e)return!1;let t=(0,i.bU)(e);if(1===e){if(!H(t,"OES_texture_float")||!H(t,"WEBGL_color_buffer_float"))return!1}else{if(H(t,"EXT_color_buffer_float"))return X(t);let e="EXT_color_buffer_half_float";if(H(t,e)){let a=t.getExtension(e);var r=t,n=a;let s=(0,o.EZ)(r,n),i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.texImage2D(r.TEXTURE_2D,0,s.internalFormatHalfFloat,1,1,0,s.textureFormatFloat,s.textureTypeHalfFloat,null);let l=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,l),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0);let u=r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE;return r.bindTexture(r.TEXTURE_2D,null),r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteTexture(i),r.deleteFramebuffer(l),u}return!1}return X(t)}function X(e){let t=(0,o.EZ)(e),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);let n=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,n),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);let a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(n),a}function J(e){return 2===e&&null!=(0,i.bU)(e).fenceSync}
4114function ee(e,t){Array.isArray(e)||(e=[e]),e.forEach(e=>{null!=e&&s.ZSL.assert("complex64"!==e.dtype,()=>`${t} does not support complex64 tensors in the WebGL backend.`)})}},91533:(e,t,r)=>{"use strict";r.d(t,{m:()=>o,p:()=>l});var n=r(45720),a=r(38180),s=r(63537),i=r(2748);class o extends i.Wd{constructor(e){if(super({dtype:e.dtype,name:null!=e.name?e.name:(0,a.v)("input").toString()}),null==e.batchSize&&(e.batchSize=null),null==e.sparse&&(e.sparse=!1),this.trainable=!1,this.built=!0,this.sparse=e.sparse,null!=e.inputShape&&null!=e.batchInputShape)throw new s.Qp("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");let t=e.batchInputShape;if(null==t)if(null==e.inputShape)throw new s.Qp("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");else t=[e.batchSize].concat(e.inputShape);else if(null!=e.batchSize)throw new s.Qp("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");let r=e.dtype||"float32";this.batchInputShape=t,this.dtype=r,this.inputSpec=[{shape:t}];let n=new i.Ar(this.dtype,this.batchInputShape,this,[],{},this.name);n.nodeIndex=0,n.tensorIndex=0,new i.bP({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[n],outputTensors:[n],inputMasks:[null],outputMasks:[null],inputShapes:[t],outputShapes:[t]})}apply(e,t){throw new s.Qp(`Cannot pass any input to an InputLayer's apply() method. InputLayer name: ${this.name}`)}dispose(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}}getConfig(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}}}function l(e){if(null==e.batchShape&&null==e.shape)throw Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(null!=e.batchShape&&null!=e.shape)throw new s.Qp("Please provide either a `shape` or `batchShape` argument to Input, but not both.");let t=e.batchShape;null!=e.shape&&null==t&&(t=[null].concat(e.shape));let r=e.dtype;return null==r&&(r="float32"),new o({batchInputShape:t,name:e.name,dtype:r,sparse:e.sparse}).inboundNodes[0].outputTensors[0]}o.className="InputLayer",n.JFn.registerClass(o)},91784:(e,t,r)=>{"use strict";r.d(t,{I:()=>l});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990);let l=(0,r(18875).op)({lessEqual_:function(e,t){let r=(0,i.YT)(e,"a","lessEqual","string_or_numeric"),l=(0,i.YT)(t,"b","lessEqual","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.CwD,u)}})},91941:(e,t,r)=>{"use strict";r.d(t,{i:()=>n});let n={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8}},92330:(e,t,r)=>{"use strict";r.d(t,{w:()=>a});var n=r(45720);function a(e,t,r,a){let s=n.ZSL.parseAxisParam(t,r)[0],i=[1,r[0],1];for(let e=0;e<s;e++)i[0]*=r[e];i[1]=r[s];for(let e=s+1;e<r.length;e++)i[2]*=r[e];let o=new Map,l=new Int32Array(r[s]),u=new n.ylz(i,a,e),h=[],p=1===i[0]&&1===i[2];for(let t=0;t<r[s];t++){let r;if(p)r=e[t].toString();else{let e=[];for(let r=0;r<i[0];r++)for(let n=0;n<i[2];n++)e.push(u.get(r,t,n));r=e.join(",")}let n=o.get(r);if(null!=n)l[t]=n;else{let e=o.size;o.set(r,e),l[t]=e,h.push(t)}}let d=i.slice();d[1]=o.size;let c=new n.ylz(d,a);h.forEach((e,t)=>{for(let r=0;r<i[0];r++)for(let n=0;n<i[2];n++)c.set(u.get(r,e,n),r,t,n)});let f=r.slice();return f[s]=d[1],{outputValues:c.values,outputShape:f,indices:l}}},92427:(e,t,r)=>{"use strict";r.d(t,{x:()=>s});var n=r(45720);let a=(e,t)=>{let r=t.value-e.value;return 0===r?e.index-t.index:r};function s(e,t,r,s,i){let o=t[t.length-1],[l,u]=[e.length/o,o],h=n.ZSL.getTypedArrayFromDType(r,l*s),p=n.ZSL.getTypedArrayFromDType("int32",l*s);for(let t=0;t<l;t++){let r=t*u,o=e.subarray(r,r+u),l=Array(o.length);o.forEach((e,t)=>l[t]={value:e,index:t}),s<l.length&&(!function e(t,r,s=0,i=t.length-1){for(;i>s;){if(i-s>600){let n=i-s+1,a=r-s+1,o=Math.log(n),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(n-l)/n)*Math.sign(a-n/2),h=Math.max(s,Math.floor(r-a*l/n+u)),p=Math.min(i,Math.floor(r+(n-a)*l/n+u));e(t,r,h,p)}let o=t[r],l=s,u=i;for(n.ZSL.swap(t,s,r),a(t[i],o)>0&&n.ZSL.swap(t,s,i);l<u;){for(n.ZSL.swap(t,l,u),l++,u--;0>a(t[l],o);)l+=1;for(;a(t[u],o)>0;)u-=1}0===a(t[s],o)?n.ZSL.swap(t,s,u):(u+=1,n.ZSL.swap(t,u,i)),u<=r&&(s=u+1),r<=u&&(i=u-1)}}(l,s),l=l.slice(0,s)),i&&l.sort(a);let d=t*s,c=h.subarray(d,d+s),f=p.subarray(d,d+s);for(let e=0;e<s;e++)c[e]=l[e].value,f[e]=l[e].index}let d=t.slice();return d[d.length-1]=s,[(0,n.ra8)(d,r,h),(0,n.ra8)(d,"int32",p)]}},92600:(e,t,r)=>{"use strict";r.d(t,{u:()=>s});var n=r(45720);function a(e,t){let r=e.slice(0,t);for(;r.length<t;)r.push(1);for(let n=t;n<e.length;n++)r[t-1]*=e[n];return r}function s(e,t,r,s,i,o,l,u){if(0===e.length)throw Error("paramsNestedSplits must be non empty");if(0===t[0].length)throw Error("Split tensors must not be scalars");let h=t[0][0]-1;
4114if(o.forEach((e,t)=>{if(e<0||e>=h){let r=n.ZSL.indexToLoc(t,l.length,n.ZSL.computeStrides(l)).join(",");throw Error(`indices[${r}] = ${e} is not in [0, ${h})`)}}),0===s.length)throw Error("params.rank must be nonzero");let{outSplits:p,valueSlices:d,numValues:c}=function(e,t,r,n){let a=[],s=0,i=Array(t.length-1+r.length).fill(null).map(()=>[0]);for(let e=0;e<r.length;++e){let t=r[e],a=e===r.length-1?n:r[e+1].length;if(0===t.length)throw Error("Ragged splits may not be empty");if(t[0]<0)throw Error("Ragged splits must be non-negative");if(t[t.length-1]>a)throw Error("Ragged splits must not point past values");for(let e=1;e<t.length;++e)if(t[e-1]>t[e])throw Error("Ragged splits must be sorted in ascending order")}let o=1;for(let e=0;e<t.length-1;++e){o*=t[e];let r=t[e+1];for(let t=1;t<o+1;++t)i[e].push(t*r)}for(let n=0;n<e.length;++n){let o=e[n],l=e[n]+1;for(let e=0;e<r.length;++e){let n=r[e],a=e+t.length-1;if(a>=0){let e=i[a],t=e[e.length-1]-n[o];for(let e=o;e<l;++e)i[a].push(n[e+1]+t)}o=n[o],l=n[l]}l!==o&&(a.push([o,l]),s+=l-o)}return{outSplits:i,valueSlices:a,numValues:s}}(o,l,e,s[0]),f=function(e){let t=[];for(let r=0;r<e.length;++r){let a=e[r].length,s=n.ZSL.getArrayFromDType("int32",a);t.push(s),e[r].forEach((e,t)=>s[t]=e)}return t}(p),m=function(e,t,r,s,i){let o=t.slice();o[0]=i;let l=n.ZSL.getArrayFromDType(r,n.ZSL.sizeFromShape(o)),u=e.length,h=0===u?0:u/t[0];return!function(e,t,r,n,s,i){let o=a(t,2)[1],l=a(i,2)[1],u=0;for(let t of r)for(let r=t[0];r<t[1];++r){for(let t=0;t<n;++t)s[u*l+t]=e[r*o+t];++u}}(e,t,s,h,l,o),[l,o]}(r,s,i,d,c);return[f,m[0],m[1]]}},92947:(e,t,r)=>{"use strict";r.d(t,{C:()=>l,_:()=>i});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)((e,t)=>{let{pattern:r,replaceGlobal:n,rewrite:a}=t;return e.replace(new RegExp(r,n?"g":""),a)}),o=(0,s.F)(n.GZp,i),l={kernelName:n.GZp,backendName:"cpu",kernelFunc:o}},92982:(e,t,r)=>{"use strict";r.d(t,{S:()=>a});var n=r(45720);function a(e,t,r){let a=e.length,s=[],i=0,o=0,l=Array(a);for(let n=0;n<a;++n){let a=s.length;!function(e,t,r,n){if(!e.length)return;if(0===t.length){for(let t=0;t<e.length;++t)n.push(e.subarray(t,t+1));return}if(1===t.length){let a=t[0],s=e.indexOf(a);for(;-1!==s;){let t=e.subarray(0,s);r&&0===t.length||n.push(t),s=(e=e.subarray(s+1)).indexOf(a)}r&&0===e.length||n.push(e);return}let a=0;for(let s=0;s<e.length+1;s++)if(s===e.length||-1!==t.indexOf(e[s])){let t=e.subarray(a,s);r&&0===t.length||n.push(t),a=s+1}}(e[n],t,r,s);let u=s.length-a;l[n]=u,i+=u,o=Math.max(o,u)}let u=n.ZSL.getArrayFromDType("int32",2*i),h=Array(i),p=[a,o],d=0;for(let e=0;e<a;++e)for(let t=0;t<l[e];++t)u[2*d]=e,u[2*d+1]=t,h[d]=s[d],++d;return[u,h,p]}},93020:(e,t,r)=>{"use strict";r.d(t,{X3:()=>l,ry:()=>o,zv:()=>i});var n=r(45720),a=r(64467),s=r(24446);let i=(0,a.o)(e=>1/(1+Math.exp(-e))),o=(0,s.v)(n.vI1,e=>1/(1+Math.exp(-e))),l={kernelName:n.vI1,backendName:"cpu",kernelFunc:o}},93107:(e,t,r)=>{"use strict";r.d(t,{r:()=>l});var n=r(54463),a=r(89990),s=r(75127),i=r(22599),o=r(15299);let l=(0,r(18875).op)({logicalXor_:function(e,t){let r=(0,n.YT)(e,"a","logicalXor","bool"),l=(0,n.YT)(t,"b","logicalXor","bool");return(0,a.assertAndGetBroadcastShape)(r.shape,l.shape),(0,s.n)((0,o.z)(e,t),(0,i.N)((0,s.n)(e,t)))}})},93406:(e,t,r)=>{"use strict";r.d(t,{j:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({relu6_:function(e){let t=(0,s.YT)(e,"x","relu6");return n.T2.runKernel(a.P_L,{x:t})}})},93620:(e,t,r)=>{"use strict";r.d(t,{R:()=>o});var n=r(5287),a=r(96609),s=r(54463),i=r(75681);let o=(0,r(18875).op)({depthToSpace_:function(e,t,r="NHWC"){let o=(0,s.YT)(e,"x","depthToSpace","float32"),l="NHWC"===r?o.shape[1]:o.shape[2],u="NHWC"===r?o.shape[2]:o.shape[3],h="NHWC"===r?o.shape[3]:o.shape[1];return i.vA(t>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`),i.vA(l*t>=0,()=>`Negative dimension size caused by overflow when multiplying 4115 ${l} and ${t} for depthToSpace with input shape 4116 ${o.shape}`),i.vA(u*t>=0,()=>`Negative dimension size caused by overflow when multiplying 4117 ${u} and ${t} for depthToSpace with input shape 4118 ${o.shape}`),i.vA(h%(t*t)==0,()=>`Dimension size must be evenly divisible by ${t*t} but is ${h} for depthToSpace with input shape ${o.shape}`),n.T2.runKernel(a.TMz,{x:o},{blockSize:t,dataFormat:r})}})},94494:(e,t,r)=>{"use strict";r.d(t,{Do:()=>m,XB:()=>f,f2:()=>g,zE:()=>y});var n=r(89990),a=r(48066),s=r(7907),i=r(54256),o=r(22864),l=r(3344),u=r(93406),h=r(86036),p=r(89510),d=r(87260),c=r(79625);function f(e,t,r){if(null==r||"linear"===r)return e;if("relu"===r)return(0,i.l)(e,(0,d.P)(t));throw Error(`Cannot compute gradient for fused activation ${r}.`)}function m(e,t){let r=t,a=n.getReductionAxes(e.shape,t.shape);return a.length>
41180&&(r=(0,c.c)(r,a)),(0,h.t)(r,e.shape)}function g(e,t,r,n){if("linear"===t)return e;if("relu"===t)return(0,l.V)(e);if("elu"===t)return(0,a.P)(e);if("relu6"===t)return(0,u.j)(e);if("prelu"===t)return(0,o.N)(e,r);else if("leakyrelu"===t)return(0,s.H)(e,n);else if("sigmoid"===t)return(0,p.r)(e);throw Error(`Unknown fused activation ${t}.`)}let y=(e,t)=>!(e>0)||"linear"===t},94708:(e,t,r)=>{"use strict";r.d(t,{qY:()=>m,yl:()=>u,rT:()=>y,tp:()=>g,B4:()=>f,Q5:()=>c,qP:()=>d});var n=r(90945),a=r(75681);function s(e,t,r){let n;return n=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:(0,a.Kg)(e)?`'${e}'`:"bool"===r?i(e):parseFloat(e.toFixed(7)).toString(),(0,a.av)(n,t)}function i(e){return 0===e?"false":"true"}function o(e){let t=[];for(let r=0;r<e.length;r+=2)t.push([e[r],e[r+1]]);return t}var l=r(22700);class u{constructor(e,t,r){if(this.dtype=t,this.shape=e.slice(),this.size=a.Ze(e),null!=r){let e=r.length;a.vA(e===this.size,()=>`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`)}if("complex64"===t)throw Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=r||a.Ab(t,this.size),this.strides=(0,a.Ur)(e)}set(e,...t){0===t.length&&(t=[0]),a.vA(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);let r=this.locToIndex(t);this.values[r]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(let r of e){if(r<0||r>=this.shape[t])throw Error(`Requested out of range element at ${e}. Buffer shape=${this.shape}`);t++}let r=e[e.length-1];for(let t=0;t<e.length-1;++t)r+=this.strides[t]*e[t];return this.values[r]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let r=0;r<e.length-1;++r)t+=this.strides[r]*e[r];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];let t=Array(this.shape.length);for(let r=0;r<t.length-1;++r)t[r]=Math.floor(e/this.strides[r]),e-=t[r]*this.strides[r];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return h().makeTensor(this.values,this.shape,this.dtype)}}let h=null,p=null;function d(e){h=e}function c(e){p=e}function f(e){}class m{constructor(e,t,r,n){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=a.Ze(e),this.strides=(0,a.Ur)(e),this.dataId=r,this.id=n,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let e=await this.data();return p.buffer(this.shape,this.dtype,e)}bufferSync(){return p.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return(0,a.yw)(this.shape,e,"complex64"===this.dtype)}arraySync(){return(0,a.yw)(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();let e=h().read(this.dataId);if("string"===this.dtype){let t=await e;try{return t.map(e=>l.decodeString(e))}catch(e){throw Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),h().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=h().readSync(this.dataId);if("string"===this.dtype)try{return e.map(e=>l.decodeString(e))}catch(e){throw Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();let e=await h().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),h().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw Error("Tensor is disposed.")}print(e=!1){return p.print(this,e)}clone(){return this.throwIfDisposed(),p.clone(this)}toString(e=!1){return function(e,t,r,n){let l=(0,a.Ur)(t),u=function(e,t,r,n){let i=(0,a.Ze)(t),l=n[n.length-1],u=Array(l).fill(0),h=t.length,p="complex64"===r?o(e):e;if(h>1)for(let e=0;e<i/l;e++){let t=e*l;for(let e=0;e<l;e++)u[e]=Math.max(u[e],s(p[t+e],0,r).length)}return u}(e,t,r,l),h=t.length,p=function e(t,r,n,a,l,u=!0){let h="complex64"===n?2:1,p=r[0],d=r.length;if(0===d)return"complex64"===n?[s(o(t)[0],0,n)]:"bool"===n?[i(t[0])]:[t[0].toString()];if(1===d){if(p>20){let e=Array.from(t.slice(0,3*h)),r=Array.from(t.slice((p-3)*h,p*h));return"complex64"===n&&(e=o(e),r=o(r)),["["+e.map((e,t)=>s(e,l[t],n)).join(", ")+", ..., "+r.map((e,t)=>s(e,l[p-3+t],n)).join(", ")+"]"]}return["["+("complex64"===n?o(t):Array.from(t)).map((e,t)=>s(e,l[t],n)).join(", ")+"]"]}let c=r.slice(1),f=a.slice(1),m=a[0]*h,g=[];if(p>20){for(let r=0;r<3;r++){let a=r*m,s=a+m;g.push(...e(t.slice(a,s),c,n,f,l,!1))}g.push("...");for(let r=p-3;r<p;r++){let a=r*m,s=a+m;g.push(...e(t.slice(a,s),c,n,f,l,r===p-1))}}else for(let r=0;r<p;r++){let a=r*m,s=a+m;g.push(...e(t.slice(a,s),c,n,f,l,r===p-1))}let y=2===d?",":"";g[0]="["+(p>0?g[0]+y:"");for(let e=1;e<g.length-1;e++)g[e]=" "+g[e]+y;let b=",\n";for(let e=2;e<d;e++)b+="\n";
4118return g[g.length-1]=" "+g[g.length-1]+"]"+(u?"":b),g}(e,t,r,l,u),d=["Tensor"];return n&&(d.push(` dtype: ${r}`),d.push(` rank: ${h}`),d.push(` shape: [${t}]`),d.push(" values:")),d.push(p.map(e=>" "+e).join("\n")),d.join("\n")}(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),p.cast(this,e)}variable(e=!0,t,r){return this.throwIfDisposed(),h().makeVariable(this,e,t,r)}}function g(){return(0,n.m)("Tensor",()=>m)}Object.defineProperty(m,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),g();class y extends m{constructor(e,t,r,n){super(e.shape,e.dtype,e.dataId,n),this.trainable=t,this.name=r}assign(e){if(e.dtype!==this.dtype)throw Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!a.r1(e.shape,this.shape))throw Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);h().disposeTensor(this),this.dataId=e.dataId,h().incRef(this,null)}dispose(){h().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(y,Symbol.hasInstance,{value:e=>e instanceof m&&null!=e.assign&&e.assign instanceof Function})},94715:(e,t,r)=>{"use strict";r.d(t,{b:()=>u});var n=r(5287),a=r(96609),s=r(54463),i=r(75681),o=r(18875),l=r(86036);let u=(0,o.op)({resizeNearestNeighbor_:function(e,t,r=!1,o=!1){let u=(0,s.YT)(e,"images","resizeNearestNeighbor");i.vA(3===u.rank||4===u.rank,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${u.rank}.`),i.vA(2===t.length,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`),i.vA("float32"===u.dtype||"int32"===u.dtype,()=>"`images` must have `int32` or `float32` as dtype"),i.vA(!1===o||!1===r,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let h=u,p=!1;3===u.rank&&(p=!0,h=(0,l.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]]));let[]=t,d={images:h},c=n.T2.runKernel(a.jOE,d,{alignCorners:r,halfPixelCenters:o,size:t});return p?(0,l.t)(c,[c.shape[1],c.shape[2],c.shape[3]]):c}})},94865:(e,t,r)=>{"use strict";r.d(t,{O0:()=>i.O0,ZS:()=>h,ge:()=>o,hF:()=>u,il:()=>l});var n=r(54868),a=r(91533),s=r(32655),i=r(32280);function o(e){return new s.Gw(e)}function l(e){return new i.Gx(e)}function u(e){return(0,a.p)(e)}function h(e,t){n.t6.registerCallbackConstructor(e,t)}},95249:(e,t,r)=>{"use strict";var n=r(45720),a=r(91090);let s=(0,n._K2)();s.registerFlag("HAS_WEBGL",()=>s.getNumber("WEBGL_VERSION")>0),s.registerFlag("WEBGL_VERSION",()=>(0,a.isWebGLVersionEnabled)(2)?2:+!!(0,a.isWebGLVersionEnabled)(1)),s.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1),s.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>2===s.get("WEBGL_VERSION")),s.registerFlag("WEBGL_CPU_FORWARD",()=>!0),s.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1),s.registerFlag("WEBGL_PACK",()=>s.getBool("HAS_WEBGL")),s.registerFlag("WEBGL_PACK_NORMALIZATION",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_CLIP",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_REDUCE",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_LAZILY_UNPACK",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_CONV_IM2COL",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>(0,a.getWebGLMaxTextureSize)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>(0,a.getMaxTexturesInShader)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{let e=s.getNumber("WEBGL_VERSION");return 0===e?0:(0,a.getWebGLDisjointQueryTimerVersion)(e)}),s.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>s.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!n.eMq.isMobile()),s.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>(0,a.isCapableOfRenderingToFloatTexture)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>!s.getBool("WEBGL_FORCE_F16_TEXTURES")&&s.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")),s.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>(0,a.isDownloadFloatTextureEnabled)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_FENCE_API_ENABLED",()=>
4118(0,a.isWebGLFenceEnabled)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>4*!!s.getBool("WEBGL_RENDER_FLOAT32_ENABLED")),s.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,e=>{if("number"!=typeof e)throw Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${e}.`);if(e<0&&-1!==e)throw Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)}),s.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>n.eMq.isMobile()?1:-1,e=>{if("number"!=typeof e)throw Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${e}.`);if(e<0&&-1!==e)throw Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)}),s.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128),s.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1),s.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5),s.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128),s.registerFlag("WEBGL_EXP_CONV",()=>!1),s.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>s.getBool("IS_TEST")),s.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0),s.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1),s.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1),s.registerFlag("ENGINE_COMPILE_ONLY",()=>!1)},95277:function(e,t,r){var n;!function(a,s,i){var o,l=i.pow(256,6),u=i.pow(2,52),h=2*u;function p(e,t,r){var n=[],p=f(function e(t,r){var n,a=[],s=typeof t;if(r&&"object"==s)for(n in t)try{a.push(e(t[n],r-1))}catch(e){}return a.length?a:"string"==s?t:t+"\0"}((t=!0==t?{entropy:!0}:t||{}).entropy?[e,m(s)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(256):(e=new Uint8Array(256),(a.crypto||a.msCrypto).getRandomValues(e)),m(e)}catch(e){var t=a.navigator,r=t&&t.plugins;return[+new Date,a,r,a.screen,m(s)]}}():e,3),n),g=new d(n),y=function(){for(var e=g.g(6),t=l,r=0;e<u;)e=(e+r)*256,t*=256,r=g.g(1);for(;e>=h;)e/=2,t/=2,r>>>=1;return(e+r)/t};return y.int32=function(){return 0|g.g(4)},y.quick=function(){return g.g(4)/0x100000000},y.double=y,f(m(g.S),s),(t.pass||r||function(e,t,r,n){return(n&&(n.S&&c(n,g),e.state=function(){return c(g,{})}),r)?(i.random=e,t):e})(y,p,"global"in t?t.global:this==i,t.state)}function d(e){var t,r=e.length,n=this,a=0,s=n.i=n.j=0,i=n.S=[];for(r||(e=[r++]);a<256;)i[a]=a++;for(a=0;a<256;a++)i[a]=i[s=255&s+e[a%r]+(t=i[a])],i[s]=t;(n.g=function(e){for(var t,r=0,a=n.i,s=n.j,i=n.S;e--;)t=i[a=255&a+1],r=256*r+i[255&(i[a]=i[s=255&s+t])+(i[s]=t)];return n.i=a,n.j=s,r})(256)}function c(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function f(e,t){for(var r,n=e+"",a=0;a<n.length;)t[255&a]=255&(r^=19*t[255&a])+n.charCodeAt(a++);return m(t)}function m(e){return String.fromCharCode.apply(0,e)}if(f(i.random(),s),e.exports){e.exports=p;try{o=r(41234)}catch(e){}}else void 0===(n=(function(){return p}).call(t,r,t,e))||(e.exports=n)}("undefined"!=typeof self?self:this,[],Math)},95390:(e,t,r)=>{"use strict";r.d(t,{r:()=>n});let n="4.22.0"},95853:(e,t,r)=>{"use strict";r.d(t,{z:()=>a});var n=r(45720);function a(e,t,r,s,i,o=!1,l=0){let u=s.length,h=[t[0],e.length/t[0]],p=h[1],d=u>0?i[u-1]+1:0;if(d<0)throw Error(n.C0T.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());let c=t.slice();c[0]=d;let f=c.reduce((e,t)=>e*t,1),m=n.ZSL.getArrayFromDType(r,f);if(0===u)return d>0&&m.fill(l),[m,c];if(d<=0)throw Error(n.C0T.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());let g=0,y=1,b=0,x=i[0];for(;;){let t=0;if(y<u){if(x===(t=i[y])){++y;continue}if(x>=t)throw Error(n.C0T.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage())}if(x<0||x>=d)throw Error(n.C0T.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(x,d));x>b&&m.fill(l,b*p,x*p);for(let t=g;t<y;++t){let r=s[t];if(r<0||r>
4118=h[0])throw Error(n.C0T.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(t,s[t],h[0]));for(let t=0;t<p;t++)m[x*p+t]+=e[r*p+t]}if(o)for(let e=0;e<p;e++)m[x*p+e]/=y-g;if(g=y,++y,b=x+1,x=t,y>u)break}return b<d&&m.fill(l,b*p,d*p),[m,c]}},95971:(e,t,r)=>{"use strict";r.d(t,{Am:()=>g,Cb:()=>p,Cd:()=>w,E6:()=>b,HP:()=>x,U9:()=>o,Xv:()=>f,ZF:()=>y,fD:()=>s,k4:()=>c,oo:()=>function e(t,r){Array.isArray(t)?(n.ZSL.assert(t.length>0,()=>`${r} is unexpectedly an empty array.`),t.forEach((t,n)=>e(t,`element ${n+1} of ${r}`))):n.ZSL.assert(Number.isInteger(t)&&t>0,()=>`Expected ${r} to be a positive integer, but got ${function e(t){return null===t?"null":Array.isArray(t)?"["+t.map(t=>e(t)).join(",")+"]":"string"==typeof t?`"${t}"`:`${t}`}(t)}.`)},sg:()=>v,st:()=>u,th:()=>m,uc:()=>h,vA:()=>i,wL:()=>l});var n=r(45720),a=r(63537);function s(e,t){if(Array.isArray(e)){let r=[];for(let n=0;n<t;n++)r=r.concat(e);return r}{let r=Array(t);return r.fill(e),r}}function i(e,t){if(!e)throw new a.pf(t)}function o(e,t){let r=0;for(let n of e)n===t&&r++;return r}function l(e){return 1===e.length?e[0]:e}function u(e){return Array.isArray(e)?e:[e]}function h(e){let t=e.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return"_"!==t[0]?t:"private"+t}function p(e){return e.length<=1||-1===e.indexOf("_")?e:e.replace(/[_]+(\w|$)/g,(e,t)=>t.toUpperCase())}let d={};function c(e){if(null==e)return null;let t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function f(e,t={},r={},n="object",s=!1){if("string"==typeof e){let s;if(e in r)s=r[e];else if(e in d)s=d[e];else if(null==(s=t[e]))throw new a.Qp(`Unknown ${n}: ${e}. This may be due to one of the following reasons: 41191. The ${n} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. 41202. The custom ${n} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return s}{let i,o;if(null==e.className||null==e.config)throw new a.Qp(`${n}: Improper config format: ${JSON.stringify(e)}. 4121'className' and 'config' must set.`);let l=e.className;if(l in r?[i,o]=r[l]:l in d?[i,o]=d.className:l in t&&([i,o]=t[l]),null==i)throw new a.Qp(`Unknown ${n}: ${l}. This may be due to one of the following reasons: 41221. The ${n} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. 41232. The custom ${n} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=o){let t={};for(let e of Object.keys(d))t[e]=d[e];for(let e of Object.keys(r))t[e]=r[e];e.config.customObjects=t;let n=Object.assign({},d);for(let e of Object.keys(r))d[e]=r[e];!function e(t){if(null!=t&&"object"==typeof t)if(Array.isArray(t))t.forEach(t=>e(t));else for(let r of Object.keys(t)){let n=t[r];null!=n&&"object"==typeof n&&(Array.isArray(n)||"ndarray"!==n.type||"number"!=typeof n.value?e(n):t[r]=n.value)}}(e.config);let a=o(i,e.config,r,s);return d=Object.assign({},n),a}{let t=Object.assign({},d);for(let e of Object.keys(r))d[e]=r[e];let n=new i(e.config);return d=Object.assign({},t),n}}}function m(e,t){return -1*(e<t?-1:+(e>t))}function g(e){if(null==e)return e;let t=[];for(let r of e)-1===t.indexOf(r)&&t.push(r);return t}function y(e){if(null==e)throw new a.Qp(`Invalid value in obj: ${JSON.stringify(e)}`);for(let t in e)if(e.hasOwnProperty(t))return!1;return!0}function b(e,t,r){if(null!=r&&0>e.indexOf(r))throw new a.Qp(`${r} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function x(e,t,r=0,n=1/0){return i(r>=0),i(n>=r),Array.isArray(e)&&e.length>=r&&e.length<=n&&e.every(e=>typeof e===t)}function v(e,t,r){let a,s=null!=r?r():n.ZSL.now();return(...i)=>{let o=null!=r?r():n.ZSL.now();return o-s<t?a:(s=o,a=e(...i))}}function w(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}},96196:(e,t,r)=>{"use strict";r.d(t,{m:()=>i});var n=r(71490),a=r(91076),s=r(48683);class i{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length),0===this.rank)this.userCode=` 4124 void main() { 4125 setOutput(vec4(getA(), 0., 0., 0.)); 4126 } 4127 `;else{let e=(0,a.Jp)("rc",this.rank),t=(0,s.bf)(this.rank),r=this.getOutOfBoundsCondition(e),n=this.getSetup(e),i=this.getOutput(e);this.userCode=` 4128 void main() { 4129 ${t} rc = getOutputCoords(); 4130 4131 if(${r}) { 4132 setOutput(vec4(0)); 4133 } else { 4134 ${n} 4135 4136 setOutput(vec4(${i})); 4137 } 4138 } 4139 `}}getSourceCoordsArr(e){let t=[];for(let r=0;r<=1;r++)for(let n=0;n<=1;n++){let a=`${0===r?"r":"rp1"}, ${0===n?"c":"cp1"}`;for(let t=2;t<this.rank;t++)a=`${e[e.length-1-t]},`+a;t.push(a)}return t}getOutOfBoundsCondition(e){if(1===this.rank)return`rc > ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let r=this.rank-2;r<this.rank;r++)t+=`${e[r]} >= ${this.enableShapeUniforms?`outShape[${r}]`:this.outputShape[r]}`,r<this.rank-1&&(t+="||");return t}getSetup(e){if(1===this.rank)return"";let t=e.slice(-2),r=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],n=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return` 4140 int r = ${t[0]}; 4141 int c = ${t[1]}; 4142 int rp1 = r + 1; 4143 int cp1 = c + 1; 4144 4145 bool cEdge = cp1 >= ${r}; 4146 bool rEdge = rp1 >= ${n}; 4147 `}getOutput(e){let t=this.getSourceCoordsArr(e);if(1===this.rank){let e=this.enableShapeUniforms?"outShape":this.outputShape[0];return`getA(rc), (rc + 1 >= ${e} ? 0. : getA(rc + 1)), 0, 0`}return`getA(${t[0]}), 4148 cEdge ? 0. : getA(${t[1]}),
4149 rEdge ? 0. : getA(${t[2]}), 4150 rEdge || cEdge ? 0. : getA(${t[3]})`}}},96414:(e,t,r)=>{"use strict";r.d(t,{L:()=>l});var n=r(5287),a=r(96609),s=r(72155),i=r(54463),o=r(89990);let l=(0,r(18875).op)({equal_:function(e,t){let r=(0,i.YT)(e,"a","equal","string_or_numeric"),l=(0,i.YT)(t,"b","equal","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.BRl,u)}})},96609:(e,t,r)=>{"use strict";r.d(t,{$dB:()=>R,$jE:()=>tj,$zE:()=>F,A1h:()=>L,A8B:()=>tR,BK4:()=>t8,BLA:()=>eq,BRl:()=>es,Blb:()=>t_,BoJ:()=>tL,BxF:()=>ep,C8s:()=>tO,CQC:()=>ta,Cg$:()=>e$,CwD:()=>eC,D7i:()=>tg,Ddj:()=>tB,Dr:()=>t7,DvZ:()=>tP,E3$:()=>eS,EkD:()=>o,ElG:()=>ec,EwU:()=>t0,FAs:()=>tQ,FCQ:()=>tf,FSt:()=>u,Fin:()=>tA,GZp:()=>tV,HNs:()=>N,Ik2:()=>T,J3C:()=>tI,JiE:()=>tN,Jp_:()=>h,KXH:()=>C,L6G:()=>tM,LB5:()=>k,LDN:()=>eW,LG0:()=>eY,LRy:()=>to,LWX:()=>e6,LXA:()=>e_,M6A:()=>tW,MRQ:()=>U,Mn0:()=>z,MnK:()=>B,N4F:()=>S,Ncv:()=>tt,O4G:()=>eg,OAQ:()=>ev,ODT:()=>e7,OMN:()=>i,ORI:()=>Y,PH8:()=>s,P_L:()=>tm,Pah:()=>er,PbM:()=>tK,Q6t:()=>ti,QDP:()=>E,QKF:()=>d,Qgm:()=>et,R23:()=>th,RMm:()=>t3,RUm:()=>eF,RW8:()=>eD,RXX:()=>eU,SDM:()=>e2,SQl:()=>eh,T7M:()=>re,TBb:()=>tq,TL8:()=>ej,TMz:()=>Z,TOR:()=>tb,ToN:()=>eP,TyE:()=>f,UcO:()=>tU,VAI:()=>eB,VCH:()=>b,Vvy:()=>a,WRv:()=>ez,WT3:()=>eX,WuN:()=>tF,X$8:()=>K,X0$:()=>ek,X4r:()=>tv,XQy:()=>td,XhZ:()=>ey,XmO:()=>J,YAb:()=>tG,YVe:()=>tC,ZgB:()=>ed,Zl4:()=>e3,_s9:()=>ea,aAr:()=>t9,awo:()=>t5,bCz:()=>e9,bP9:()=>q,cHb:()=>eZ,cS:()=>x,dFH:()=>t$,dLy:()=>tX,dXR:()=>t1,dv8:()=>ew,e0f:()=>e4,epO:()=>c,fUj:()=>tu,g5A:()=>eK,gC7:()=>P,gIW:()=>eT,hVg:()=>ty,hgw:()=>tc,ho8:()=>y,hql:()=>tk,huO:()=>tl,i5R:()=>ef,iGz:()=>M,iPs:()=>eN,iW0:()=>tZ,iuW:()=>tY,jAQ:()=>w,jM4:()=>eM,jOE:()=>tp,jfg:()=>O,jgd:()=>tz,jj_:()=>W,jxD:()=>Q,kdj:()=>tr,l0G:()=>e0,l6P:()=>tT,lLS:()=>eb,lNG:()=>eH,ljI:()=>n,lxb:()=>g,lzr:()=>ex,mH5:()=>ts,mIA:()=>eI,mM$:()=>e8,mnI:()=>eE,mxL:()=>em,nVu:()=>H,nY8:()=>V,nZd:()=>eR,oFs:()=>tH,oJ2:()=>tn,ox3:()=>ei,p2J:()=>_,pJc:()=>tx,pPe:()=>t2,p_m:()=>p,pk0:()=>X,pnw:()=>t6,pr3:()=>$,pyJ:()=>te,rFG:()=>tD,rFm:()=>D,rGP:()=>eu,rsH:()=>en,sDr:()=>ee,t3d:()=>eV,tG8:()=>eA,tGH:()=>j,u$b:()=>tS,u8Z:()=>l,uWl:()=>tw,urI:()=>e5,vI1:()=>tE,vaV:()=>A,vj7:()=>I,wNW:()=>G,wwC:()=>v,wx0:()=>tJ,x7F:()=>eQ,xJ3:()=>t4,xu7:()=>eJ,yPW:()=>eL,ySp:()=>eG,ybN:()=>eo,ybj:()=>el,ylV:()=>e1,zP9:()=>m,zfU:()=>eO});let n="Abs",a="Acos",s="Acosh",i="Add",o="AddN",l="All",u="Any",h="ArgMax",p="ArgMin",d="Asin",c="Asinh",f="Atan",m="Atanh",g="Atan2",y="AvgPool",b="AvgPoolGrad",x="AvgPool3D",v="AvgPool3DGrad",w="BatchMatMul",T="BatchToSpaceND",S="Bincount",N="BitwiseAnd",k="BroadcastTo",I="BroadcastArgs",C="Cast",E="Ceil",A="ClipByValue",$="Complex",F="ComplexAbs",R="Concat",_="Conv2D",D="Conv2DBackpropFilter",O="Conv2DBackpropInput",L="Conv3D",M="Conv3DBackpropFilterV2",P="Conv3DBackpropInputV2",z="Cos",B="Cosh",W="Cumprod",V="Cumsum",U="CropAndResize",G="DenseBincount",Z="DepthToSpace",j="DepthwiseConv2dNative",K="DepthwiseConv2dNativeBackpropFilter",H="DepthwiseConv2dNativeBackpropInput",Y="Diag",Q="Dilation2D",q="Dilation2DBackpropInput",X="Dilation2DBackpropFilter",J="Draw",ee="RealDiv",et="Einsum",er="Elu",en="EluGrad",ea="Erf",es="Equal",ei="Exp",eo="ExpandDims",el="Expm1",eu="FFT",eh="Fill",ep="FlipLeftRight",ed="Floor",ec="FloorDiv",ef="FusedBatchNorm",em="GatherV2",eg="GatherNd",ey="Greater",eb="GreaterEqual",ex="Identity",ev="IFFT",ew="Imag",eT="IsFinite",eS="IsInf",eN="IsNan",ek="LeakyRelu",eI="Less",eC="LessEqual",eE="LinSpace",eA="Log",e$="Log1p",eF="LogicalAnd",eR="LogicalNot",e_="LogicalOr",eD="LogicalXor",eO="LogSoftmax",eL="LowerBound",eM="LRN",eP="LRNGrad",ez="MatrixBandPart",eB="Max",eW="Maximum",eV="MaxPool",eU="MaxPoolGrad",eG="MaxPool3D",eZ="MaxPool3DGrad",ej="MaxPoolWithArgmax",eK="Mean",eH="Min",eY="Minimum",eQ="MirrorPad",eq="Mod",eX="Multinomial",eJ="Multiply",e0="Neg",e1="NotEqual",e2="NonMaxSuppressionV3",e3="NonMaxSuppressionV4",e4="NonMaxSuppressionV5",e6="OnesLike",e5="OneHot",e8="Pack",e7="PadV2",e9="Pool",te="Pow",tt="Prelu",tr="Prod",tn="RaggedGather",ta="RaggedRange",ts="RaggedTensorToTensor",ti="Range",to="Real",tl="Reciprocal",tu="Relu",th="Reshape",tp="ResizeNearestNeighbor",td="ResizeNearestNeighborGrad",tc="ResizeBilinear",tf="ResizeBilinearGrad",tm="Relu6",tg="Reverse",ty="Round",tb="Rsqrt",tx="ScatterNd",tv="TensorScatterUpdate",tw="SearchSorted",tT="Select",tS="Selu",tN="Slice",tk="Sin",tI="Sinh",tC="Sign",tE="Sigmoid",tA="Softplus",t$="Sqrt",tF="Sum",tR="SpaceToBatchND",t_="SplitV",tD="Softmax",tO="SparseFillEmptyRows",tL="SparseReshape",tM="SparseSegmentMean",tP="SparseSegmentSum",tz="SparseToDense",tB="SquaredDifference",tW="Square",tV="StaticRegexReplace",tU="StridedSlice",tG="StringNGrams",tZ="StringSplit",tj="StringToHashBucketFast",tK="Sub",tH="Tan",tY="Tanh",tQ="Tile",tq="TopK",tX="Transform",tJ="Trans
4150pose",t0="Unique",t1="Unpack",t2="UnsortedSegmentSum",t3="UpperBound",t4="ZerosLike",t6="Step",t5="FromPixels",t8="RotateWithOffset",t7="_FusedMatMul",t9="FusedConv2D",re="FusedDepthwiseConv2D"},97634:(e,t,r)=>{"use strict";r.d(t,{u:()=>u});var n=r(45720),a=r(21131),s=r(2748),i=r(40693);let{resizeBilinear:o,cropAndResize:l}=n.Slp;class u extends s.Wd{constructor(e){super(e),this.height=e.height,this.width=e.width}centerCrop(e,t,r,s,o,u,h,p){return(0,n.DZQ)(()=>{let d,c=!1,f=[t/u,r/h,(s+t)/u,(o+r)/h],m=[];3===e.rank?(c=!0,d=(0,n.t$z)([e])):d=e;for(let e=0;e<d.shape[0];e++)m.push(f);let g=(0,n.OEK)(m,[m.length,4]),y=l(d,g,(0,n.y17)(0,m.length,1,"int32"),[s,o],"nearest");return c?i.wg((0,a.un)((0,n.K$i)(y)),p):i.wg(y,p)})}upsize(e,t,r,a){return(0,n.DZQ)(()=>{let n=o(e,[t,r]);return i.wg(n,a)})}call(e,t){return(0,n.DZQ)(()=>{let t=(0,a.un)(e),r=t.dtype,n=t.shape,s=n[n.length-3],i=n[n.length-2],o=0;s!==this.height&&(o=Math.floor((s-this.height)/2));let l=0;return(i!==this.width&&0===(l=Math.floor((i-this.width)/2))&&(l=1),o>=0&&l>=0)?this.centerCrop(t,o,l,this.height,this.width,s,i,r):this.upsize(e,this.height,this.width,r)})}getConfig(){let e={height:this.height,width:this.width};return Object.assign(e,super.getConfig()),e}computeOutputShape(e){let t=(e=(0,a.U$)(e)).length-3,r=e.length-2;return e[t]=this.height,e[r]=this.width,e}}u.className="CenterCrop",n.JFn.registerClass(u)},98308:(e,t,r)=>{"use strict";r.d(t,{n:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({imag_:function(e){let t=(0,s.YT)(e,"input","imag");return n.T2.runKernel(a.dv8,{input:t})}})},98503:(e,t,r)=>{"use strict";r.d(t,{BTT:()=>d.B,tnl:()=>a.t,HQu:()=>s.H,FqL:()=>i.F,WQq:()=>o.W,QiD:()=>c,Q7R:()=>f.Q,bzn:()=>m.b,FLi:()=>g.F,XRg:()=>y.X,qRo:()=>b.q,yHs:()=>x.y,rYl:()=>v.r,FPz:()=>w.F,rfv:()=>T.r,$jT:()=>S.$,sub:()=>C,lZX:()=>D,$v7:()=>L.$,BFc:()=>M,kSi:()=>P,T5N:()=>z,GTe:()=>O.G,HbZ:()=>B,vjT:()=>W,ftb:()=>rD,ROE:()=>V,hOW:()=>U.h,ra8:()=>G.r,wgE:()=>N.w,mkO:()=>Z.m,zQh:()=>j.z,o8B:()=>K.o,faB:()=>H.f,xWs:()=>E.x,I1m:()=>Y,RPU:()=>Q,O5O:()=>q,P1l:()=>X,kA9:()=>J.k,Xtf:()=>ee.X,wX9:()=>et.w,IPL:()=>er,jIJ:()=>ea,gnS:()=>es.g,yIG:()=>ei.y,_jP:()=>rG,Lp0:()=>eo.L,rCv:()=>el.r,aOp:()=>eu,Rj8:()=>eh.R,Gl3:()=>ep.G,smy:()=>ed,X7t:()=>ec.X,y4m:()=>ef.y,ek5:()=>em.e,Omf:()=>eg.O,EZY:()=>rV,_3C:()=>ey,Pqc:()=>eb.P,FJY:()=>rU,QP2:()=>ex,LCg:()=>ev.L,Y12:()=>ew.Y,p4S:()=>eT.p,oNF:()=>eS.o,UG6:()=>eN.U,IYd:()=>ek.I,y5U:()=>eC,hVP:()=>t9.h,GSj:()=>eE.G,RIf:()=>eA.R,wh_:()=>e$.w,cZk:()=>n,kgh:()=>eF.k,SY9:()=>rW,rhj:()=>eR.r,DQN:()=>e_.D,KGM:()=>re.K,ngS:()=>eD.n,Slp:()=>nP,U4u:()=>rZ,ggX:()=>rt.g,MIs:()=>eO.M,EN4:()=>eL.E,yrW:()=>eM.y,H8d:()=>eP.H,M7h:()=>ez.M,InN:()=>eB.I,mPL:()=>nz,mT8:()=>eW,Kgs:()=>eV.K,Rm2:()=>eU.R,Kko:()=>eG.K,nqI:()=>eZ.n,HPB:()=>ej.H,VZ:()=>eK.V,n76:()=>eH.n,NSZ:()=>eY.N,ztW:()=>eQ.z,rxB:()=>eq.r,YYh:()=>nB,yzS:()=>eJ,NoW:()=>A.N,T9B:()=>e0.T,jgi:()=>e1.j,NYV:()=>e2,RO:()=>e3,PhQ:()=>e4.P,i2o:()=>e6.i,OYQ:()=>e7,jkA:()=>e9.j,BpO:()=>te.B,FFZ:()=>tt.F,ziu:()=>tr.z,Clk:()=>ti,CRk:()=>rP,lKK:()=>$.l,YDF:()=>to,OjQ:()=>tl,HZy:()=>tu.H,xbf:()=>rL.x,Ec:()=>th.E,Mw0:()=>tp.M,SaS:()=>e5.S,P61:()=>td.P,op:()=>d.op,X4o:()=>tc,eVF:()=>tf.e,BZs:()=>tm,grY:()=>tg,XHu:()=>ty,WLX:()=>tb,dzn:()=>tx.d,n7C:()=>tv.n,NsG:()=>tw.N,yyV:()=>tT.y,_eU:()=>tS._,whe:()=>tN,iyU:()=>tk,Q0_:()=>tI,_9M:()=>tC,pR9:()=>tR,FE$:()=>t_,m0H:()=>tD,YeY:()=>tO,HYA:()=>tL,y17:()=>tM,xav:()=>tP.x,VOZ:()=>tz.V,VVh:()=>tB.V,j__:()=>tW.j,tQQ:()=>I.t,BEg:()=>tV.B,QD2:()=>tU,LMr:()=>tG,I2l:()=>tZ,JYU:()=>tj,z8$:()=>rr.z,LIG:()=>tK.L,Z$r:()=>tH.Z,d_2:()=>tY.d,NFr:()=>rz,sZg:()=>eX,WfX:()=>tQ.W,wdz:()=>tq.w,F12:()=>tX,ry7:()=>F.r,_SZ:()=>tJ._,vPA:()=>nM,F8e:()=>t0.F,L0l:()=>t1.L,dik:()=>R.d,Q$M:()=>t2,zAd:()=>t3,wck:()=>t4,R0O:()=>t6,Vs9:()=>t5.V,lw0:()=>t8.l,eDJ:()=>t7.e,lMo:()=>nW,Zhr:()=>rB,lOn:()=>nL,lDo:()=>rn.l,RZD:()=>ra.R,EwI:()=>ta.E,Pbu:()=>rs.P,r2V:()=>ri.r,t$z:()=>ro.t,PMw:()=>rl.P,Ym9:()=>ru.Y,YjP:()=>nV,jbE:()=>ts.j,czq:()=>rh.c,Mlm:()=>rp.M,ymU:()=>_.y,OEK:()=>rd.O,tGX:()=>rf,KtR:()=>rm,$_$:()=>rg.$,g9W:()=>ry,Lpo:()=>rb,yxw:()=>rx,NNh:()=>rw,Vsq:()=>eI.V,rfw:()=>rT.r,mgz:()=>rO.m,efE:()=>rS,AmM:()=>rN.A,zAU:()=>rk.z,K$i:()=>rI.K,rni:()=>rC,bvq:()=>rE,_M9:()=>rA._,YJN:()=>rF,Ul9:()=>rR.U,POl:()=>r_.P});var n={};r.r(n),r.d(n,{conv2d:()=>rq,depthwiseConv2d:()=>r0,matMul:()=>r1});var a=r(4006),s=r(36),i=r(17096),o=r(44769),l=r(5287),u=r(96609),h=r(54463),p=r(75681),d=r(18875);let c=(0,d.op)({addN_:function(e){p.vA(Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"),p.vA(e.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`);let t=e.map((e,t)=>(0,h.YT)(e,`tensors${t}`,"addN")),r=t[0];
4150return t.forEach(e=>{if(e.dtype!==r.dtype)throw Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(e=>{if(!p.r1(e.shape,r.shape))throw Error("All tensors passed to tf.addN() must have the same shape")}),l.T2.runKernel(u.EkD,t)}});var f=r(45073),m=r(84996),g=r(32999),y=r(82065),b=r(76565),x=r(72655),v=r(18200),w=r(48138),T=r(39316),S=r(86049),N=r(13797),k=r(46866),I=r(86036);let C=(0,d.op)({avgPool3d_:function(e,t,r,n,a,s="NDHWC"){let i=(0,h.YT)(e,"x","avgPool3d","float32"),o=i,d=!1;4===i.rank&&(d=!0,o=(0,I.t)(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),p.vA(5===o.rank,()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`),p.vA("NDHWC"===s,()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),p.vA("number"==typeof r&&r>0||Array.isArray(r)&&r[0]>0&&r[1]>0&&r[2]>0,()=>`Error in avgPool3d: Stride must be > 0, but got '${r}'`),(0,k.s_)("avgPool3d",n,a);let c={x:o},f=l.T2.runKernel(u.cS,c,{filterSize:t,strides:r,pad:n,dimRoundingMode:a,dataFormat:s});return(f=(0,N.w)(f,o.dtype),d)?(0,I.t)(f,[f.shape[1],f.shape[2],f.shape[3],f.shape[4]]):f}});var E=r(76110),A=r(99309),$=r(54256),F=r(89510),R=r(61324),_=r(54283);let D=(0,d.op)({basicLSTMCell_:function(e,t,r,n,a,s){let i=(0,h.YT)(e,"forgetBias","basicLSTMCell"),l=(0,h.YT)(t,"lstmKernel","basicLSTMCell"),u=(0,h.YT)(r,"lstmBias","basicLSTMCell"),p=(0,h.YT)(n,"data","basicLSTMCell"),d=(0,h.YT)(a,"c","basicLSTMCell"),c=(0,h.YT)(s,"h","basicLSTMCell"),f=(0,E.x)([p,c],1),m=(0,A.N)(f,l),g=(0,o.W)(m,u),y=g.shape[0],b=g.shape[1]/4,x=[y,b],v=(0,R.d)(g,[0,0],x),w=(0,R.d)(g,[0,b],x),T=(0,R.d)(g,[0,2*b],x),S=(0,R.d)(g,[0,3*b],x),N=(0,o.W)((0,$.l)((0,F.r)(v),(0,_.y)(w)),(0,$.l)(d,(0,F.r)((0,o.W)(i,T)))),k=(0,$.l)((0,_.y)(N),(0,F.r)(S));return[N,k]}});var O=r(71550),L=r(66287);let M=(0,d.op)({batchNorm2d_:function(e,t,r,n,a,s){let i,o,l=(0,h.YT)(e,"x","batchNorm"),u=(0,h.YT)(t,"mean","batchNorm"),d=(0,h.YT)(r,"variance","batchNorm");return null!=a&&(i=(0,h.YT)(a,"scale","batchNorm")),null!=n&&(o=(0,h.YT)(n,"offset","batchNorm")),p.vA(2===l.rank,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${l.rank}.`),p.vA(2===u.rank||1===u.rank,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${u.rank}.`),p.vA(2===d.rank||1===d.rank,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${d.rank}.`),null!=i&&p.vA(2===i.rank||1===i.rank,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${i.rank}.`),null!=o&&p.vA(2===o.rank||1===o.rank,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${o.rank}.`),(0,L.$)(l,u,d,o,i,s)}}),P=(0,d.op)({batchNorm3d_:function(e,t,r,n,a,s){let i,o,l=(0,h.YT)(e,"x","batchNorm"),u=(0,h.YT)(t,"mean","batchNorm"),d=(0,h.YT)(r,"variance","batchNorm");return null!=a&&(i=(0,h.YT)(a,"scale","batchNorm")),null!=n&&(o=(0,h.YT)(n,"offset","batchNorm")),p.vA(3===l.rank,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${l.rank}.`),p.vA(3===u.rank||1===u.rank,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${u.rank}.`),p.vA(3===d.rank||1===d.rank,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${d.rank}.`),null!=i&&p.vA(3===i.rank||1===i.rank,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${i.rank}.`),null!=o&&p.vA(3===o.rank||1===o.rank,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${o.rank}.`),(0,L.$)(l,u,d,o,i,s)}}),z=(0,d.op)({batchNorm4d_:function(e,t,r,n,a,s){let i,o,l=(0,h.YT)(e,"x","batchNorm"),u=(0,h.YT)(t,"mean","batchNorm"),d=(0,h.YT)(r,"variance","batchNorm");return null!=a&&(i=(0,h.YT)(a,"scale","batchNorm")),null!=n&&(o=(0,h.YT)(n,"offset","batchNorm")),p.vA(4===l.rank,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${l.rank}.`),p.vA(4===u.rank||1===u.rank,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${u.rank}.`),p.vA(4===d.rank||1===d.rank,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${d.rank}.`),null!=i&&p.vA(4===i.rank||1===i.rank,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${i.rank}
4150.`),null!=o&&p.vA(4===o.rank||1===o.rank,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${o.rank}.`),(0,L.$)(l,u,d,o,i,s)}}),B=(0,d.op)({bincount_:function(e,t,r){let n=(0,h.YT)(e,"x","bincount"),a=(0,h.YT)(t,"weights","bincount");return p.vA("int32"===n.dtype,()=>`Error in bincount: input dtype must be int32, but got ${n.dtype}`),p.vA(r>=0,()=>`size must be non-negative, but got ${r}.`),p.vA(a.size===n.size||0===a.size,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${n.shape}, weights shape: ${a.shape}.`),l.T2.runKernel(u.N4F,{x:n,weights:a},{size:r})}}),W=(0,d.op)({bitwiseAnd_:function(e,t){let r=(0,h.YT)(e,"x","bitwiseAnd"),n=(0,h.YT)(t,"y","bitwiseAnd");if(!(0,p.r1)(r.shape,n.shape))throw Error(`BitwiseAnd: Tensors must have the same shape. x: ${r.shape}, y: ${n.shape}`);if("int32"!==r.dtype||"int32"!==n.dtype)throw Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${r.dtype} and type of y: ${n.dtype}`);return l.T2.runKernel(u.HNs,{a:r,b:n})}}),V=(0,d.op)({broadcastArgs_:function(e,t){let r=(0,h.YT)(e,"s0","broadcastArgs","int32"),n=(0,h.YT)(t,"s1","broadcastArgs","int32");if(1!==r.rank)throw Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${r.rank}`);if(1!==n.rank)throw Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${n.rank}`);return l.T2.runKernel(u.vj7,{s0:r,s1:n})}});var U=r(35199),G=r(24884),Z=r(89827),j=r(8046),K=r(4087),H=r(47802);let Y=(0,d.op)({concat1d_:function(e){return(0,E.x)(e,0)}}),Q=(0,d.op)({concat2d_:function(e,t){return(0,E.x)(e,t)}}),q=(0,d.op)({concat3d_:function(e,t){return(0,E.x)(e,t)}}),X=(0,d.op)({concat4d_:function(e,t){return(0,E.x)(e,t)}});var J=r(16289),ee=r(61630),et=r(57238);let er=(0,d.op)({conv3d_:function(e,t,r,n,a="NDHWC",s=[1,1,1]){let i=(0,h.YT)(e,"x","conv3d"),o=(0,h.YT)(t,"filter","conv3d"),d=i,c=!1;4===i.rank&&(c=!0,d=(0,I.t)(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),p.vA(5===d.rank,()=>`Error in conv3d: input must be rank 5, but got rank ${d.rank}.`),p.vA(5===o.rank,()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`),p.vA(d.shape[4]===o.shape[3],()=>`Error in conv3d: depth of input (${d.shape[4]}) must match input depth for filter ${o.shape[3]}.`),p.vA((0,k.G0)(r,s),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${r} and dilations '${s}'`),p.vA("NDHWC"===a,()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`),p.vA((0,k.qk)(s),()=>"Error in conv3D: Dilated rates should be larger than 0."),p.vA((0,k.qk)(r),()=>"Error in conv3D: Strides should be larger than 0.");let f={x:d,filter:o},m=l.T2.runKernel(u.A1h,f,{strides:r,pad:n,dataFormat:a,dilations:s});return c?(0,I.t)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}});var en=r(85133);let ea=(0,d.op)({conv3dTranspose_:function(e,t,r,n,a){let s=(0,h.YT)(e,"x","conv3dTranspose"),i=(0,h.YT)(t,"filter","conv3dTranspose");return(0,en.c)(r,s,i,n,a)}});var es=r(67633),ei=r(55107),eo=r(14732),el=r(75104);let eu=(0,d.op)({denseBincount_:function(e,t,r,n=!1){let a=(0,h.YT)(e,"x","denseBincount"),s=(0,h.YT)(t,"weights","denseBincount");return p.vA("int32"===a.dtype,()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`),p.vA(a.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`),p.vA(r>=0,()=>`size must be non-negative, but got ${r}.`),p.vA(s.size===a.size||0===s.size,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${s.shape}.`),l.T2.runKernel(u.wNW,{x:a,weights:s},{size:r,binaryOutput:n})}});var eh=r(93620),ep=r(55756);let ed=(0,d.op)({diag_:function(e){let t=(0,h.YT)(e,"x","diag");return l.T2.runKernel(u.ORI,{x:t})}});var ec=r(45770),ef=r(29337),em=r(38579),eg=r(17965);let ey=(0,d.op)({einsum_:function(e,...t){let r=t.map((e,t)=>(0,h.YT)(e,`tensors${t}`,"einsum"));return l.T2.runKernel(u.Qgm,r,{equation:e})}});var eb=r(48066);let ex=(0,d.op)({ensureShape_:function(e,t){let r=(0,h.YT)(e,"x","ensureShape","string_or_numeric");if(!(0,p.e_)(r.shape,t))throw Error(`EnsureShape: Shape of tensor ${r.shape} is not compatible with expected shape ${t}`);return e}});var ev=r(96414),ew=r(37953),eT=r(75429),eS=r(29573),eN=r(56992),ek=r(31519),eI=r(70818);
4150let eC=(0,d.op)({eye_:function(e,t,r,n="float32"){null==t&&(t=e);let a=(0,G.r)([e,t],n),s=e<=t?e:t;for(let e=0;e<s;++e)a.set(1,e,e);let i=(0,I.t)(a.toTensor(),[e,t]);if(null==r)return i;if(1===r.length)return(0,eI.V)((0,eN.U)(i,0),[r[0],1,1]);if(2===r.length)return(0,eI.V)((0,eN.U)((0,eN.U)(i,0),0),[r[0],r[1],1,1]);if(3===r.length)return(0,eI.V)((0,eN.U)((0,eN.U)((0,eN.U)(i,0),0),0),[r[0],r[1],r[2],1,1]);throw Error(`eye() currently supports only 1D and 2D batchShapes, but received ${r.length}D.`)}});var eE=r(41891),eA=r(70168),e$=r(44691),eF=r(52829),eR=r(53784),e_=r(45923),eD=r(98308),eO=r(68120),eL=r(32382),eM=r(60676),eP=r(7907),ez=r(21419),eB=r(91784);function eW(e,t,r){if(r<=0)throw Error("The number of values should be positive.");return l.T2.runKernel(u.mnI,{},{start:e,stop:t,num:r})}var eV=r(51855),eU=r(78412),eG=r(61017),eZ=r(16311),ej=r(43137),eK=r(1056),eH=r(75127),eY=r(22599),eQ=r(15299),eq=r(93107);let eX=(0,d.op)({searchSorted_:function(e,t,r="left"){let n=(0,h.YT)(e,"sortedSequence","searchSorted"),a=(0,h.YT)(t,"values","searchSorted"),s=n.shape[n.shape.length-1],i=a.shape[a.shape.length-1],o=(0,I.t)(n,[-1,s]),d=(0,I.t)(a,[-1,i]);if(o.rank<2)throw Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==d.shape[0])throw Error("Leading dimension of 'sortedSequence' and 'values' must match.");if((0,p.Ze)(d.shape)>=0x80000000)throw Error("values tensor size must less than 2147483648");if(o.shape[1]>=0x80000000)throw Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);return l.T2.runKernel(u.uWl,{sortedSequence:o,values:d},{side:r})}});function eJ(e,t){return eX(e,t,"left")}var e0=r(39616),e1=r(52899);let e2=(0,d.op)({maxPool3d_:function(e,t=[1,1,1],r,n,a,s="NDHWC"){let i=(0,h.YT)(e,"x","maxPool3d"),o=i,d=!1;4===i.rank&&(d=!0,o=(0,I.t)(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),p.vA(5===o.rank,()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`),p.vA("NDHWC"===s,()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),(0,k.s_)("maxPool3d",n,a);let c={x:o},f=l.T2.runKernel(u.ySp,c,{filterSize:t,strides:r,pad:n,dimRoundingMode:a,dataFormat:s});return d?(0,I.t)(f,[f.shape[1],f.shape[2],f.shape[3],f.shape[4]]):f}}),e3=(0,d.op)({maxPoolWithArgmax_:function(e,t,r,n,a=!1){let s=(0,h.YT)(e,"x","maxPoolWithArgmax"),i=l.T2.runKernel(u.TL8,{x:s},{filterSize:t,strides:r,pad:n,includeBatchInIndex:a});return{result:i[0],indexes:i[1]}}});var e4=r(3824),e6=r(70995),e5=r(4047),e8=r(94708);function e7(e,t,{indexing:r="xy"}={}){if("xy"!==r&&"ij"!==r)throw TypeError(`${r} is not a valid third argument to meshgrid`);if(void 0===e)return[];let n=(0,h.YT)(e,"x","meshgrid",e instanceof e8.qY?e.dtype:"float32");if(void 0===t)return[n];let a=(0,h.YT)(t,"y","meshgrid",t instanceof e8.qY?t.dtype:"float32"),s=(0,p.Ze)(n.shape),i=(0,p.Ze)(a.shape);return"xy"===r?(n=(0,I.t)(n,[1,-1]),a=(0,I.t)(a,[-1,1]),[(0,A.N)((0,e5.S)([i,1],n.dtype),n),(0,A.N)(a,(0,e5.S)([1,s],a.dtype))]):(n=(0,I.t)(n,[-1,1]),a=(0,I.t)(a,[1,-1]),[(0,A.N)(n,(0,e5.S)([1,i],n.dtype)),(0,A.N)((0,e5.S)([s,1],a.dtype),a)])}var e9=r(67146),te=r(32266),tt=r(25435),tr=r(69314),tn=r(64256),ta=r(11983),ts=r(68396);let ti=(0,d.op)({moments_:function(e,t=null,r=!1){e=(0,h.YT)(e,"x","moments");let n=(0,p.Y6)(t,e.shape),a=(0,e6.i)(e,n,r),s=a.shape;r||(s=(0,tn.SM)(a.shape,n));let i=(0,ta.E)((0,ts.j)((0,N.w)(e,"float32"),(0,I.t)(a,s)));return{mean:a,variance:(0,e6.i)(i,n,r)}}}),to=(0,d.op)({multiRNNCell_:function(e,t,r,n){let a=(0,h.YT)(t,"data","multiRNNCell"),s=(0,h.j1)(r,"c","multiRNNCell"),i=(0,h.j1)(n,"h","multiRNNCell"),o=a,l=[];for(let t=0;t<e.length;t++){let r=e[t](o,s[t],i[t]);l.push(r[0]),l.push(r[1]),o=r[1]}let u=[],p=[];for(let e=0;e<l.length;e+=2)u.push(l[e]),p.push(l[e+1]);return[u,p]}}),tl=(0,d.op)({multinomial_:function(e,t,r,n=!1){let a=(0,h.YT)(e,"logits","multinomial"),s=a.size,i=a.rank;if(s<2)throw Error(`Error in multinomial: you need at least 2 outcomes, but got ${s}.`);if(i>2)throw Error(`Rank of probabilities must be 1 or 2, but is ${i}`);r=r||Math.random();let o=1===i?(0,I.t)(a,[1,-1]):a,p={numSamples:t,seed:r,normalized:n},d=l.T2.runKernel(u.WT3,{logits:o},p);return 1===i?(0,I.t)(d,[d.size]):d}});var tu=r(86032),th=r(5232),tp=r(42926),td=r(12575);let tc=(0,d.op)({outerProduct_:function(e,t){let r=(0,h.YT)(e,"v1","outerProduct"),n=(0,h.YT)(t,"v2","outerProduct");
4150p.vA(1===r.rank&&1===n.rank,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${r.rank} and ${n.rank}.`);let a=(0,I.t)(r,[-1,1]),s=(0,I.t)(n,[1,-1]);return(0,A.N)(a,s)}});var tf=r(89967);let tm=(0,d.op)({pad1d_:function(e,t,r=0){return(0,p.vA)(2===t.length,()=>"Invalid number of paddings. Must be length of 2."),(0,tf.e)(e,[t],r)}}),tg=(0,d.op)({pad2d_:function(e,t,r=0){return(0,p.vA)(2===t.length&&2===t[0].length&&2===t[1].length,()=>"Invalid number of paddings. Must be length of 2 each."),(0,tf.e)(e,t,r)}}),ty=(0,d.op)({pad3d_:function(e,t,r=0){return(0,p.vA)(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,()=>"Invalid number of paddings. Must be length of 2 each."),(0,tf.e)(e,t,r)}}),tb=(0,d.op)({pad4d_:function(e,t,r=0){return(0,p.vA)(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,()=>"Invalid number of paddings. Must be length of 2 each."),(0,tf.e)(e,t,r)}});var tx=r(89200),tv=r(17392),tw=r(22864),tT=r(65261),tS=r(16263);let tN=(0,d.op)({raggedGather_:function(e,t,r,n){let a=e.map((e,t)=>(0,h.YT)(e,`tensors${t}`,"raggedGather","int32")),s=(0,h.YT)(t,"paramsDenseValues","raggedGather"),i=(0,h.YT)(r,"indices","raggedGather","int32"),o=l.T2.runKernel(u.oJ2,{paramsNestedSplits:a,paramsDenseValues:s,indices:i},{outputRaggedRank:n});return{outputNestedSplits:o.slice(0,o.length-1),outputDenseValues:o[o.length-1]}}}),tk=(0,d.op)({raggedRange_:function(e,t,r){let n=(0,h.YT)(e,"starts","raggedRange"),a=(0,h.YT)(t,"limits","raggedRange",n.dtype),s=(0,h.YT)(r,"deltas","raggedRange",n.dtype),i=l.T2.runKernel(u.CQC,{starts:n,limits:a,deltas:s});return{rtNestedSplits:i[0],rtDenseValues:i[1]}}}),tI=(0,d.op)({raggedTensorToTensor_:function(e,t,r,n,a){let s=(0,h.YT)(e,"shape","raggedTensorToTensor","int32"),i=(0,h.YT)(t,"values","raggedTensorToTensor"),o=(0,h.YT)(r,"defaultValue","raggedTensorToTensor",i.dtype),p=n.map((e,t)=>(0,h.YT)(e,`tensors${t}`,"raggedTensorToTensor","int32"));return l.T2.runKernel(u.mH5,{shape:s,values:i,defaultValue:o,rowPartitionTensors:p},{rowPartitionTypes:a})}}),tC=(0,d.op)({rand_:function(e,t,r){(0,p.SA)(e);let n=(0,p.Ze)(e),a=null;if(null==r||"float32"===r)a=new Float32Array(n);else if("int32"===r)a=new Int32Array(n);else if("bool"===r)a=new Uint8Array(n);else throw Error(`Unknown data type ${r}`);for(let e=0;e<n;e++)a[e]=t();return l.T2.makeTensor(a,e,r)}});var tE=r(68173);class tA{constructor(e,t,r,n,a){this.mean=e,this.stdDev=t,this.dtype=r,this.nextVal=NaN,this.truncated=n,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);let s=a||Math.random();this.random=tE.alea(s.toString())}nextValue(){let e,t;if(!isNaN(this.nextVal)){let e=this.nextVal;return this.nextVal=NaN,e}let r=!1;for(;!r;){let n,a,s;do s=(n=2*this.random()-1)*n+(a=2*this.random()-1)*a;while(s>=1||0===s);let i=Math.sqrt(-2*Math.log(s)/s);e=this.mean+this.stdDev*n*i,t=this.mean+this.stdDev*a*i,(!this.truncated||this.isValidTruncated(e))&&(r=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class t${constructor(e,t,r,n){this.alpha=e,this.beta=1/t,this.dtype=r;let a=n||Math.random();this.randu=tE.alea(a.toString()),this.randn=new tA(0,1,r,!1,this.randu()),e<1?this.d=e+2/3:this.d=e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,r,n,a,s;for(;;){do n=this.randn.nextValue(),s=1+this.c*n;while(s<=0);if(s*=s*s,t=1-.331*(e=n*n)*e,r=.5*e+this.d*(1-s+Math.log(s)),(a=this.randu())<t||Math.log(a)<r)break}return s=1/this.beta*this.d*s,this.alpha<1&&(s*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(s)}convertValue(e){return"float32"===this.dtype?e:Math.round(e)}}class tF{constructor(e=0,t=1,r,n){if(this.canReturnFloat=()=>null==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=r,null==n&&(n=Math.random()),"number"==typeof n&&(n=n.toString()),!this.canReturnFloat()&&this.range<=1)throw Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=tE.alea(n)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}
4150nextValue(){return this.convertValue(this.min+this.range*this.random())}}let tR=(0,d.op)({randomGamma_:function(e,t,r=1,n="float32",a){if((0,p.SA)(e),null==r&&(r=1),null==n&&(n="float32"),"float32"!==n&&"int32"!==n)throw Error(`Unsupported data type ${n}`);let s=new t$(t,r,n,a),i=(0,G.r)(e,n);for(let e=0;e<i.values.length;e++)i.values[e]=s.nextValue();return i.toTensor()}}),t_=(0,d.op)({randomNormal_:function(e,t=0,r=1,n,a){if((0,p.SA)(e),null!=n&&"bool"===n)throw Error(`Unsupported data type ${n}`);let s=new tA(t,r,n,!1,a),i=(0,G.r)(e,n);for(let e=0;e<i.values.length;e++)i.values[e]=s.nextValue();return i.toTensor()}}),tD=(0,d.op)({randomStandardNormal_:function(e,t,r){if(null!=t&&"bool"===t)throw Error(`Unsupported data type ${t}`);return t_(e,0,1,t,r)}}),tO=(0,d.op)({randomUniform_:function(e,t=0,r=1,n="float32",a){(0,p.SA)(e);let s=(0,G.r)(e,n),i=new tF(t,r,null,a);for(let e=0;e<s.values.length;e++)s.values[e]=i.nextValue();return s.toTensor()}}),tL=(0,d.op)({randomUniformInt_:function(e,t,r,n){return tO(e,t,r,"int32",n)}});function tM(e,t,r=1,n="float32"){if(0===r)throw Error("Cannot have a step of zero");return l.T2.runKernel(u.Q6t,{},{start:e,stop:t,step:r,dtype:n})}var tP=r(43578),tz=r(33202),tB=r(3344),tW=r(93406),tV=r(2632);let tU=(0,d.op)({reverse1d_:function(e){let t=(0,h.YT)(e,"x","reverse");return p.vA(1===t.rank,()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`),(0,tV.B)(t,0)}}),tG=(0,d.op)({reverse2d_:function(e,t){let r=(0,h.YT)(e,"x","reverse");return p.vA(2===r.rank,()=>`Error in reverse2D: x must be rank 2 but got rank ${r.rank}.`),(0,tV.B)(r,t)}}),tZ=(0,d.op)({reverse3d_:function(e,t){let r=(0,h.YT)(e,"x","reverse");return p.vA(3===r.rank,()=>`Error in reverse3D: x must be rank 3 but got rank ${r.rank}.`),(0,tV.B)(r,t)}}),tj=(0,d.op)({reverse4d_:function(e,t){let r=(0,h.YT)(e,"x","reverse");return p.vA(4===r.rank,()=>`Error in reverse4D: x must be rank 4 but got rank ${r.rank}.`),(0,tV.B)(r,t)}});var tK=r(590),tH=r(99858),tY=r(57610),tQ=r(79069),tq=r(82178);let tX=async function(e,t){let r=(0,h.YT)(e,"x","setdiff1d"),n=(0,h.YT)(t,"y","setdiff1d");p.vA(r.dtype===n.dtype,()=>`x and y should have the same dtype, but got x (${r.dtype}) and y (${n.dtype}).`),p.vA(1===r.rank,()=>`x should be 1D tensor, but got x (${r.shape}).`),p.vA(1===n.rank,()=>`y should be 1D tensor, but got y (${n.shape}).`);let a=await r.data(),s=new Set(await n.data()),i=0;for(let e=0;e<a.length;e++)!s.has(a[e])&&i++;let o=new e8.yl([i],r.dtype),l=new e8.yl([i],"int32");for(let e=0,t=0;e<a.length;e++)!s.has(a[e])&&(o.values[t]=a[e],l.values[t]=e,t++);return[o.toTensor(),l.toTensor()]};var tJ=r(13219),t0=r(20020),t1=r(77688);let t2=(0,d.op)({slice1d_:function(e,t,r){let n=(0,h.YT)(e,"x","slice1d");return p.vA(1===n.rank,()=>`slice1d expects a rank-1 tensor, but got a rank-${n.rank} tensor`),(0,R.d)(n,[t],[r])}}),t3=(0,d.op)({slice2d_:function(e,t,r){let n=(0,h.YT)(e,"x","slice2d");return p.vA(2===n.rank,()=>`slice2d expects a rank-2 tensor, but got a rank-${n.rank} tensor`),(0,R.d)(n,t,r)}}),t4=(0,d.op)({slice3d_:function(e,t,r){let n=(0,h.YT)(e,"x","slice3d");return p.vA(3===n.rank,()=>`slice3d expects a rank-3 tensor, but got a rank-${n.rank} tensor`),(0,R.d)(n,t,r)}}),t6=(0,d.op)({slice4d_:function(e,t,r){let n=(0,h.YT)(e,"x","slice4d");return p.vA(4===n.rank,()=>`slice4d expects a rank-4 tensor, but got a rank-${n.rank} tensor`),(0,R.d)(n,t,r)}});var t5=r(19832),t8=r(62958),t7=r(33282),t9=r(22313),re=r(74442),rt=r(85648),rr=r(42153),rn=r(23926),ra=r(53744),rs=r(62131),ri=r(74338),ro=r(40030),rl=r(87260),ru=r(16496),rh=r(79625),rp=r(22489),rd=r(40091),rc=r(77969);function rf(e,t){(0,p.HO)(e);let r=(0,h.MZ)(e,t);if(1!==r.length)throw Error("tensor1d() requires values to be a flat/TypedArray");return(0,rc.Q)(e,null,r,t)}function rm(e,t,r){if((0,p.HO)(e),null!=t&&2!==t.length)throw Error("tensor2d() requires shape to have two numbers");let n=(0,h.MZ)(e,r);if(2!==n.length&&1!==n.length)throw Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===n.length&&null==t)throw Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return(0,rc.Q)(e,t,n,r)}var rg=r(73888);function ry(e,t,r){if((0,p.HO)(e),null!=t&&4!==t.length)throw Error("tensor4d() requires shape to have four numbers");let n=(0,h.MZ)(e,r);if(4!==n.length&&1!==n.length)throw Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===n.length&&null==t)throw Error("tensor4d() requires shape to be provided when `values` are a flat array");return(0,rc.Q)(e,t,n,r)}function rb(e,t,r){if((0,p.HO)(e),null!=t&&5!==t.length)throw Error("tensor5d() requires shape to have five numbers");let n=(0,h.MZ)(e,r);if(5!==n.length&&1!==n.length)throw Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===n.length&&null==t)throw Error("tensor5d() requires shape to be provided when `values` are a flat array");return(0,rc.Q)(e,t,n,r)}function rx(e,t,r){if((0,p.HO)(e),null!=t&&6!==t.length)throw Error("tensor6d() requires shape to have six numbers");let n=(0,h.MZ)(e,r);if(6!==n.length&&1!==n.length)throw Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===n.length&&null==t)throw Error("tensor6d() requires shape to be provided when `values` are a flat array");return t=t||n,(0,rc.Q)(e,t,n,r)}var rv=r(2536);let rw=(0,d.op)({tensorScatterUpdate_:function(e,t,r){let n=(0,h.YT)(e,"tensor","tensorScatterupdate"),a=(0,h.YT)(t,"indices","tensorScatterupdate","int32"),s=(0,h.YT)(r,"updates","tensorScatterupdate");if(rv.validateInput(s,a,n.shape),n.dtype!==s.dtype)throw Error(`tensor and updates must have the same dtype, instead they are ${n.dtype} and ${s.dtype}.`);return l.T2.runKernel(u.X4r,{tensor:n,indices:a,updates:s},{})}});var rT=r(82870);let rS=(0,d.op)({truncatedNormal_:function(e,t=0,r=1,n,a){if((0,p.SA)(e),null!=n&&"bool"===n)throw Error("Unsupported data type $ { dtype }");let s=new tA(t,r,n,!0,a),i=(0,G.r)(e,n);for(let e=0;e<i.values.length;e++)i.values[e]=s.nextValue();return i.toTensor()}});var rN=r(39533),rk=r(15510),rI=r(3535);function rC(e,t){return eX(e,t,"right")}function rE(e,t=!0,r,n){return l.T2.makeVariable(e,t,r,n)}var rA=r(77833),r$=r(74709);let rF=async function(e){let t=(0,h.YT)(e,"condition","whereAsync","bool"),r=await t.data(),n=(0,r$.Y)(t.shape,r);
4150return e!==t&&t.dispose(),n};var rR=r(45921),r_=r(61997);let rD=async function(e,t,r){let n=(0,h.YT)(e,"tensor","boolMask"),a=(0,h.YT)(t,"mask","boolMask","bool"),s=null==r?0:r,i=a.rank,o=n.shape;p.vA(i>0,()=>"mask cannot be scalar"),p.O3(o.slice(s,s+i),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let l=1;for(let e=s;e<s+i;e++)l*=o[e];let u=o.slice(0,s).concat([l],o.slice(s+i)),d=(0,I.t)(n,u),c=(0,I.t)(a,[-1]),f=await rF(c),m=(0,ri.r)(f,[1]),g=(0,eF.k)(d,m,s);return e!==n&&n.dispose(),t!==a&&a.dispose(),m.dispose(),d.dispose(),c.dispose(),f.dispose(),g};var rO=r(32021),rL=r(75904),rM=r(72155);let rP=(0,d.op)({movingAverage_:function(e,t,r,n,a=!0){let s=(0,h.YT)(e,"v","movingAverage"),i=(0,h.YT)(t,"x","movingAverage"),l=(0,h.YT)(r,"decay","movingAverage");(0,rM.assertTypesMatch)(s,i),p.vA(p.r1(s.shape,i.shape),()=>"Shape mismatch in v and x");let u=(0,tY.d)(1),d=(0,ts.j)(u,l),c=(0,$.l)((0,ts.j)(i,s),d);if(a){p.vA(null!=n,()=>"When using zeroDebias: true, step is required.");let e=(0,h.YT)(n,"step","movingAverage");c=(0,ef.y)(c,(0,ts.j)(u,(0,tv.n)(l,e)))}return(0,o.W)(s,c)}}),rz=(0,d.op)({scatterND_:function(e,t,r){(0,p.SA)(r);let n=(0,h.YT)(e,"indices","scatterND","int32"),a=(0,h.YT)(t,"updates","scatterND");return rv.validateInput(a,n,r),l.T2.runKernel(u.pJc,{indices:n,updates:a},{shape:r})}}),rB=(0,d.op)({sparseToDense_:function(e,t,r,n=0){(0,p.SA)(r);let a=(0,h.YT)(e,"sparseIndices","sparseToDense","int32"),s=(0,h.YT)(t,"sparseValues","sparseToDense","string_or_numeric"),i=(0,h.YT)(n,"defaultValue","sparseToDense",s.dtype);if("int32"!==a.dtype)throw Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${a.dtype}.`);if(a.rank>2)throw Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${a.shape}.`);let o=a.rank>0?a.shape[0]:1,d=a.rank>1?a.shape[1]:1;if(r.length!==d)throw Error(`outputShape has incorrect number of elements:, ${r.length}, should be: ${d}.`);let c=s.size;if(0!==s.rank&&(1!==s.rank||c!==o))throw Error(`sparseValues has incorrect shape ${s.shape}, should be [] or [${o}]`);if(s.dtype!==i.dtype)throw Error("sparseValues.dtype must match defaultValues.dtype");return l.T2.runKernel(u.jgd,{sparseIndices:a,sparseValues:s,defaultValue:i},{outputShape:r})}}),rW=(0,d.op)({gatherND_:function(e,t){let r=(0,h.YT)(t,"indices","gatherND","int32"),n=(0,h.YT)(e,"x","gatherND","string_or_numeric");return l.T2.runKernel(u.O4G,{params:n,indices:r})}}),rV=(0,d.op)({dropout_:function(e,t,r,n){let a=(0,h.YT)(e,"x","dropout");if(p.vA("float32"===a.dtype,()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`),p.vA(t>=0&&t<1,()=>`rate must be a float in the range [0, 1), but got ${t}.`),0===t)return e instanceof e8.qY?a.clone():a;let s=function(e,t){if(null==t)return e.shape.slice();if(p.r1(e.shape,t))return t;if(e.shape.length===t.length){let r=[];for(let n=0;n<e.shape.length;n++)null==t[n]&&null!=e.shape[n]?r.push(e.shape[n]):r.push(t[n]);return r}return t}(a,r),i=1-t,l=(0,ef.y)((0,eA.R)((0,o.W)(tO(s,0,1,"float32",n),i)),i);return(0,$.l)(a,l)}});function rU(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function rG(e,t,r){let n=1-e%2,a=new Float32Array(e);for(let s=0;s<e;++s){let i=2*Math.PI*s/(e+n-1);a[s]=t-r*Math.cos(i)}return rf(a,"float32")}let rZ=async function(e,t,r=1){let n=(0,h.YT)(e,"predictions","inTopK"),a=(0,h.YT)(t,"targets","inTopK");(0,p.vA)(n.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${n.rank}`),(0,p.vA)(n.rank-1===a.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${n.rank} and targets rank ${a.rank}`),(0,p.O3)(n.shape.slice(0,n.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");let s=n.shape[n.shape.length-1];(0,p.vA)(r>0&&r<=s,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${s}), but got ${r}`);let i=await n.data(),o=await a.data(),[l,u]=[i.length/s,s],d=(0,p.ce)("bool",l);for(let e=0;e<l;e++){let t=e*u,n=i.subarray(t,t+u),a=[];for(let e=0;e<n.length;e++)a.push({value:n[e],index:e});a.sort((e,t)=>
4150t.value-e.value),d[e]=0;for(let t=0;t<r;t++)if(a[t].index===o[e]){d[e]=1;break}}return e!==n&&n.dispose(),t!==a&&a.dispose(),(0,rd.O)(d,a.shape,"bool")};var rj=r(46568),rK=r(89990),rH=r(43667),rY=r(84198),rQ=r(94494);let rq=(0,d.op)({fusedConv2d_:function({x:e,filter:t,strides:r,pad:n,dataFormat:a="NHWC",dilations:s=[1,1],dimRoundingMode:i,bias:d,activation:c="linear",preluActivationWeights:f,leakyreluAlpha:m}){let g,y;if(c=c||"linear",!1===(0,rQ.zE)(l.T2.state.gradientDepth,c)){p.vA("NHWC"===a,()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let l=(0,ee.X)(e,t,r,n,a,s,i);return null!=d&&(l=(0,o.W)(l,d)),(0,rQ.f2)(l,c,f,m)}let b=(0,h.YT)(e,"x","conv2d","float32"),x=(0,h.YT)(t,"filter","conv2d","float32"),v=b,w=!1;3===b.rank&&(w=!0,v=(0,I.t)(b,[1,b.shape[0],b.shape[1],b.shape[2]])),p.vA(4===v.rank,()=>`Error in fused conv2d: input must be rank 4, but got rank ${v.rank}.`),p.vA(4===x.rank,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${x.rank}.`),k.s_("fused conv2d",n,i);let T="NHWC"===a?v.shape[3]:v.shape[1];p.vA(x.shape[2]===T,()=>`Error in conv2d: depth of input (${T}) must match input depth for filter ${x.shape[2]}.`),p.vA(k.G0(r,s),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${r} and dilations '${s}'`);let S=k.uf(v.shape,x.shape,r,s,n,i);if(null!=d&&(g=(0,h.YT)(d,"bias","fused conv2d"),[g]=(0,rM.makeTypesMatch)(g,b),"NHWC"===a?rK.assertAndGetBroadcastShape(S.outShape,g.shape):(p.vA(g.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${g.shape.length}.`),p.vA(0===g.shape.length||g.shape[0]===S.outChannels||1===g.shape[0],()=>`Error in fused conv2d: bias shape (${g.shape}) is not compatible with the number of output channels (${S.outChannels})`))),null!=f){let e=f.shape;if(p.vA(e.length<=1||3===e.length,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}
4150.`),1===e.length)p.vA(1===e[0]||e[0]===S.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${S.outChannels}).`);else if(3===e.length)try{rK.assertAndGetBroadcastShape(e,S.outShape)}catch(t){throw Error(`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${S.outShape}).`)}y=(0,h.YT)(f,"prelu weights","fused conv2d")}let N=(e,t)=>{p.vA("NHWC"===a,()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`);let[i,o,l,u]=t,h=(0,rQ.XB)(e,l,c);p.vA(k.Dh(s),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);let d=[(0,rY.v)(o.shape,h,i,r,n),(0,rH.H)(o,h,i.shape,r,n)];if(null!=u){let e=(0,rQ.Do)(u,h);d.push(e)}return d},C={x:v,filter:x,bias:g,preluActivationWeights:y},E={strides:r,pad:n,dataFormat:a,dilations:s,dimRoundingMode:i,activation:c,leakyreluAlpha:m};return null==d?(0,rj._X)((e,t,r)=>{let n=l.T2.runKernel(u.aAr,C,E);return r([t,e,n]),w&&(n=(0,I.t)(n,[n.shape[1],n.shape[2],n.shape[3]])),{value:n,gradFunc:N}})(v,x):(0,rj._X)((e,t,r,n)=>{let a=l.T2.runKernel(u.aAr,C,E);return n([t,e,a,r]),w&&(a=(0,I.t)(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:N}})(v,x,g)}});var rX=r(67532),rJ=r(54402);let r0=(0,d.op)({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:r,pad:n,dataFormat:a="NHWC",dilations:s=[1,1],dimRoundingMode:i,bias:d,activation:c="linear",preluActivationWeights:f,leakyreluAlpha:m}){let g,y;if(!1===(0,rQ.zE)(l.T2.state.gradientDepth,c)){let l=(0,ep.G)(e,t,r,n,a,s,i);return null!=d&&(l=(0,o.W)(l,d)),(0,rQ.f2)(l,c,f,m)}let b=(0,h.YT)(e,"x","depthwiseConv2d","float32"),x=(0,h.YT)(t,"filter","depthwiseConv2d","float32"),v=b,w=!1;3===b.rank&&(w=!0,v=(0,I.t)(b,[1,b.shape[0],b.shape[1],b.shape[2]])),p.vA(4===v.rank,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${v.rank}.`),p.vA(4===x.rank,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${x.rank}.`),p.vA(v.shape[3]===x.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${v.shape[3]}) must match the inChannels dimension in filter ${x.shape[2]}.`),null==s&&(s=[1,1]),p.vA(k.G0(r,s),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${s}'`),k.s_("fused depthwiseConv2d",n,i);let T=k.uf(v.shape,x.shape,r,s,n,i,!0);null!=d&&(g=(0,h.YT)(d,"bias","fused conv2d"),[g]=(0,rM.makeTypesMatch)(g,b),rK.assertAndGetBroadcastShape(T.outShape,g.shape)),null!=f&&(y=(0,h.YT)(f,"prelu weights","fused depthwiseConv2d"));let S=(e,t)=>{p.vA(k.Dh(s),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`);let[a,o,l,u]=t,h=(0,rQ.XB)(e,l,c),d=(0,rJ.l)(o.shape,h,a,r,n,s,i),f=(0,rX.x)(o,h,a.shape,r,n,s,i);return null!=u?[d,f,(0,rQ.Do)(g,h)]:[d,f]},N={x:v,filter:x,bias:g,preluActivationWeights:y},C={strides:r,pad:n,dataFormat:a,dilations:s,dimRoundingMode:i,activation:c,leakyreluAlpha:m};return null==d?(0,rj._X)((e,t,r)=>{let n=l.T2.runKernel(u.T7M,N,C);return r([t,e,n]),w&&(n=(0,I.t)(n,[n.shape[1],n.shape[2],n.shape[3]])),{value:n,gradFunc:S}})(v,x):(0,rj._X)((e,t,r,n)=>{let a=l.T2.runKernel(u.T7M,N,C);return n([t,e,a,r]),w&&(a=(0,I.t)(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:S}})(v,x,g)}}),r1=(0,d.op)({fusedMatMul_:function({a:e,b:t,transposeA:r=!1,transposeB:n=!1,bias:a,activation:s="linear",preluActivationWeights:i,leakyreluAlpha:d=.2}){let c,f;if(!1===(0,rQ.zE)(l.T2.state.gradientDepth,s)){let l=(0,A.N)(e,t,r,n);return null!=a&&(l=(0,o.W)(l,a)),(0,rQ.f2)(l,s,i,d)}let m=(0,h.YT)(e,"a","fused matMul"),g=(0,h.YT)(t,"b","fused matMul");[m,g]=(0,rM.makeTypesMatch)(m,g);let y=r?m.shape[m.rank-2]:m.shape[m.rank-1],b=n?g.shape[g.rank-1]:g.shape[g.rank-2],x=r?m.shape[m.rank-1]:m.shape[m.rank-2],v=n?g.shape[g.rank-2]:g.shape[g.rank-1],w=m.shape.slice(0,-2),T=g.shape.slice(0,-2),S=p.Ze(w),N=p.Ze(T);p.vA(y===b,()=>`Error in fused matMul: inner shapes (${y}) and (${b}) of Tensors with shapes ${m.shape} and ${g.shape} and transposeA=${r} and transposeB=${n} must match.`);let k=rK.assertAndGetBroadcastShape(m.shape.slice(0,-2),g.shape.slice(0,-2)).c
4150oncat([x,v]),C=r?(0,I.t)(m,[S,y,x]):(0,I.t)(m,[S,x,y]),E=n?(0,I.t)(g,[N,v,b]):(0,I.t)(g,[N,b,v]);null!=a&&(c=(0,h.YT)(a,"bias","fused matMul"),[c]=(0,rM.makeTypesMatch)(c,m),rK.assertAndGetBroadcastShape(k,c.shape)),null!=i&&(f=(0,h.YT)(i,"prelu weights","fused matMul"));let $=(e,t)=>{let i,o,[l,u,h,p]=t,d=(0,rQ.XB)((0,I.t)(e,h.shape),h,s);return(r||n?!r&&n?(i=(0,A.N)(d,u,!1,!1),o=(0,A.N)(d,l,!0,!1)):r&&!n?(i=(0,A.N)(u,d,!1,!0),o=(0,A.N)(l,d,!1,!1)):(i=(0,A.N)(u,d,!0,!0),o=(0,A.N)(d,l,!0,!0)):(i=(0,A.N)(d,u,!1,!0),o=(0,A.N)(l,d,!0,!1)),null!=a)?[i,o,(0,rQ.Do)(p,d)]:[i,o]},F={a:C,b:E,bias:c,preluActivationWeights:f},R={transposeA:r,transposeB:n,activation:s,leakyreluAlpha:d};return null==a?(0,rj._X)((e,t,r)=>{let n=l.T2.runKernel(u.Dr,F,R);return r([e,t,n]),{value:(0,I.t)(n,k),gradFunc:$}})(C,E):(0,rj._X)((e,t,r,n)=>{let a=l.T2.runKernel(u.Dr,F,R);return n([e,t,a,r]),{value:(0,I.t)(a,k),gradFunc:$}})(C,E,c)}}),r2=(0,d.op)({hammingWindow_:function(e){return rG(e,.54,.46)}}),r3=(0,d.op)({hannWindow_:function(e){return rG(e,.5,.5)}}),r4=(0,d.op)({frame_:function(e,t,r,n=!1,a=0){let s=0,i=[];for(;s+t<=e.size;)i.push((0,R.d)(e,s,t)),s+=r;if(n)for(;s<e.size;){let n=s+t-e.size,o=(0,E.x)([(0,R.d)(e,s,t-n),(0,eE.G)([n],a)]);i.push(o),s+=r}return 0===i.length?rm([],[0,t]):(0,I.t)((0,E.x)(i),[i.length,t])}}),r6=(0,d.op)({stft_:function(e,t,r,n,a=r3){null==n&&(n=rU(t));let s=r4(e,t,r),i=(0,$.l)(s,a(t));return(0,rr.z)(i,n)}}),r5=(0,d.op)({cropAndResize_:function(e,t,r,n,a="bilinear",s=0){let i=(0,h.YT)(e,"image","cropAndResize"),o=(0,h.YT)(t,"boxes","cropAndResize","float32"),d=(0,h.YT)(r,"boxInd","cropAndResize","int32"),c=o.shape[0];return p.vA(4===i.rank,()=>`Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`),p.vA(2===o.rank&&4===o.shape[1],()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${o.shape}.`),p.vA(1===d.rank&&d.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${o.shape}.`),p.vA(2===n.length,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${n.length}.`),p.vA(n[0]>=1&&n[1]>=1,()=>`cropSize must be atleast [1,1], but was ${n}`),p.vA("bilinear"===a||"nearest"===a,()=>`method must be bilinear or nearest, but was ${a}`),l.T2.runKernel(u.MRQ,{image:i,boxes:o,boxInd:d},{method:a,extrapolationValue:s,cropSize:n})}}),r8=(0,d.op)({flipLeftRight_:function(e){let t=(0,h.YT)(e,"image","flipLeftRight","float32");return p.vA(4===t.rank,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`),l.T2.runKernel(u.BxF,{image:t},{})}}),r7=(0,d.op)({grayscaleToRGB_:function(e){let t=(0,h.YT)(e,"image","grayscaleToRGB"),r=t.rank-1,n=t.shape[r];p.vA(t.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`),p.vA(1===n,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${n}.`);let a=Array(t.rank);return a.fill(1,0,r),a[r]=3,(0,eI.V)(t,a)}}),r9=(0,d.op)({rgbToGrayscale_:function(e){let t,r=(0,h.YT)(e,"image","RGBToGrayscale"),n=r.rank-1,a=r.shape[n];p.vA(r.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${r.rank}.`),p.vA(3===a,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${a}.`);let s=r.dtype,i=(0,N.w)(r,"float32"),o=rf([.2989,.587,.114]);switch(r.rank){case 2:t=ey("ij,j->i",i,o);break;case 3:t=ey("ijk,k->ij",i,o);break;case 4:t=ey("ijkl,l->ijk",i,o);break;case 5:t=ey("ijklm,m->ijkl",i,o);break;case 6:t=ey("ijklmn,n->ijklm",i,o);break;default:throw Error("Not a valid tensor rank.")}return t=(0,eN.U)(t,-1),(0,N.w)(t,s)}}),ne=(0,d.op)({rotateWithOffset_:function(e,t,r=0,n=.5){let a=(0,h.YT)(e,"image","rotateWithOffset","float32");return p.vA(4===a.rank,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`),l.T2.runKernel(u.BK4,{image:a},{radians:t,fillValue:r,center:n})}});function nt(e,t,r,n,a,s){null==n&&(n=.5),null==a&&(a=-1/0),null==s&&(s=0);let i=e.shape[0];return r=Math.min(r,i),p.vA(0<=n&&n<=1,()=>`iouThreshold must be in [0, 1], but was '${n}'`),p.vA(2===e.rank,()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`),p.vA(4===e.shape[1],()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`),p.vA(1===t.rank,()=>"scores must be a 1D tensor"),p.vA(t.shape[0]===i,()=>`scores has incompatible shape with boxes. Expected ${i}, but was ${t.shape[0]}`),p.vA(0<=s&&s<=1,()=>`softNmsSigma must be in [0, 1], but was '${s}'`),{maxOutputSize:r,iouThreshold:n,scoreThreshold:a,softNmsSigma:s}}let nr=(0,d.op)({nonMaxSuppression_:function(e,t,r,n=.5,a=-1/0){let s=(0,h.YT)(e,"boxes","nonMaxSuppression","float32"),i=(0,h.YT)(t,"scores","nonMaxSuppression","float32"),o=nt(s,i,r,n,a);r=o.maxOutputSize;let p={maxOutputSize:r,iouThreshold:n=o.iouThreshold,scoreThreshold:a=o.scoreThreshold};return l.T2.runKernel(u.SDM,{boxes:s,scores:i},p)}});var nn=r(71446);async function na(e,t,r,n=.5,a=-1/0){let s=(0,h.YT)(e,"boxes","nonMaxSuppressionAsync"),i=(0,h.YT)(t,"scores","nonMaxSuppressionAsync"),o=nt(s,i,r,n,a);r=o.maxOutputSize,n=o.iouThreshold,a=o.scoreThreshold;let l=await Promise.all([s.data(),i.data()]),u=l[0],p=l[1],{selectedIndices:d}=(0,nn.c7)(u,p,r,n,a);return s!==e&&s.dispose(),i!==t&&i.dispose(),rf(d,"int32")}let ns=(0,d.op)({nonMaxSuppressionWithScore_:function(e,t,r,n=.5,a=-1/0,s=0){let i=(0,h.YT)(e,"boxes","nonMaxSuppression"),o=(0,h.YT)(t,"scores","nonMaxSuppression"),p=nt(i,o,r,n,a,s);r=p.maxOutputSize,n=p.iouThreshold,a=p.scoreThreshold;let d={maxOutputSize:r,iouThreshold:n,scoreThreshold:a,softNmsSigma:s=p.softNmsSigma},c=l.T2.runKernel(u.e0f,{boxes:i,scores:o},d);return{selectedIndices:c[0],selectedScores:c[1]}}});async function ni(e,t,r,n=.5,a=-1/0,s=0){let i=(0,h.YT)(e,"boxes","nonMaxSuppressionAsync"),o=(0,h.YT)(t,"scores","nonMaxSuppressionAsync"),l=nt(i,o,r,n,a,s);r=l.maxOutputSize,n=l.iouThreshold,a=l.scoreThreshold,s=l.softNmsSigma;let u=await Promise.all([i.data(),o.data()]),p=u[0],d=u[1],{selectedIndices:c,selectedScores:f}=(0,nn.ut)(p,d,r,n,a,s);return i!==e&&i.dispose(),o!==t&&o.dispose(),{selectedIndices:rf(c,"int32"),selectedScores:rf(f)}}let no=(0,d.op)({nonMaxSuppressionPadded_:function(e,t,r,n=.5,a=-1/0,s=!1){let i=(0,h.YT)(e,"boxes","nonMaxSuppression"),o=(0,h.YT)(t,"scores","nonMaxSuppression"),p=nt(i,o,r,n,a,null),d=p.maxOutputSize,c=p.iouThreshold,f=p.scoreThreshold,m=l.T2.runKernel(u.Zl4,{boxes:i,scores:o},{maxOutputSize:d,iouThreshold:c,scoreThreshold:f,padToMaxOutputSize:s});return{selectedIndices:m[0],validOutputs:m[1]}}});async function nl(e,t,r,n=.5,a=-1/0,s=!1){let i=(0,h.YT)(e,"boxes","nonMaxSuppressionAsync"),o=(0,h.YT)(t,"scores","nonMaxSuppressionAsync"),l=nt(i,o,r,n,a,null),u=l.maxOutputSize,p=l.iouThreshold,d=l.scoreThreshold,[c,f]=await Promise.all([i.data(),o.data()]),{selectedIndices:m,validOutputs:g}=(0,nn.ZS)(c,f,u,p,d,s);return i!==e&&i.dispose(),o!==t&&o.dispose(),{selectedIndices:rf(m,"int32"),validOutputs:(0,tY.d)(g,"int32")}}var nu=r(46921),nh=r(94715);let np=(0,d.op)({threshold_:function(e,t="binary",r=!1,n=.5){let a,s,i,l,u=(0,h.YT)(e,"image","threshold"),d=u.shape[0]*u.shape[1],c=(0,$.l)(rf([n]),255);if(p.vA(3===u.rank,()=>`Error in threshold: image must be rank 3,but got rank ${u.rank}.`),p.vA(3===u.shape[2]||1===u.shape[2],()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${u.shape[2]}.`),p.vA("int32"===u.dtype||"float32"===u.dtype,()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${u.dtype}.`),p.vA("otsu"===t||"binary"===t,()=>`Method must be binary or otsu, but was ${t}`),3===u.shape[2]){[a,s,i]=(0,rn.l)(u,[1,1,1],-1);let e=(0,$.l)(a,.2989),t=(0,$.l)(s,.587),r=(0,$.l)(i,.114);l=(0,o.W)((0,o.W)(e,t),r)}else l=e;"otsu"===t&&(c=function(e,t){let r,n,a,s,i,l,u=rf([-1]),h=rf([0]),p=rf([0]);for(let d=0;d<e.size-1;d++){r=(0,R.d)(e,0,d+1),n=(0,R.d)(e,d+1),i=(0,ef.y)((0,rh.c)(r),t),l=(0,ef.y)((0,rh.c)(n),t);let c=(0,rh.c)((0,$.l)(r,tM(0,r.size)));a=(0,ef.y)(c,(0,rh.c)(r));let f=(0,eE.G)(n.shape,r.size),m=(0,o.W)(tM(0,n.size),f),g=(0,$.l)(n,m);s=(0,ef.y)((0,rh.c)(g),(0,rh.c)(n));let y=(0,ts.j)(a,s),b=(0,ts.j)(a,s),x=(0,$.l)(i,l);p=(0,$.l)((0,$.l)(x,y),b);let v=(0,eR.r)(p,h);h=(0,rA._)(v,p,h),u=(0,rA._)(v,rf([d]),u)}return u}(B((0,N.w)((0,tK.L)(l),"int32"),(0,rd.O)([]),256),d));let f=r?(0,eB.I)(l,c):(0,eR.r)(l,c);return(0,N.w)((0,$.l)(f,255),"int32")}}),nd=(0,d.op)({transform_:function(e,t,r="nearest",n="constant",a=0,s){let i=(0,h.YT)(e,"image","transform","float32"),o=(0,h.YT)(t,"transforms","transform","float32");return p.vA(4===i.rank,()=>`Error in transform: image must be rank 4,but got rank ${i.rank}
4150.`),p.vA(2===o.rank&&(o.shape[0]===i.shape[0]||1===o.shape[0])&&8===o.shape[1],()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),p.vA(null==s||2===s.length,()=>`Error in transform: outputShape must be [height, width] or null, but got ${s}.`),l.T2.runKernel(u.dLy,{image:i,transforms:o},{interpolation:r,fillMode:n,fillValue:a,outputShape:s})}}),nc=(0,d.op)({bandPart_:function(e,t,r){let n,a,s=(0,h.YT)(e,"a","bandPart");(0,p.vA)(s.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${s.rank}.`);let i=s.shape,[o,l]=s.shape.slice(-2);"number"==typeof t?((0,p.vA)(t%1==0,()=>`bandPart(): numLower must be an integer, got ${t}.`),(0,p.vA)(t<=o,()=>`bandPart(): numLower (${t}) must not be greater than the number of rows (${o}).`),n=(0,h.YT)(t<0?o:t,"numLower","bandPart")):((0,p.vA)("int32"===t.dtype,()=>"bandPart(): numLower's dtype must be an int32."),n=(0,rA._)((0,ez.M)(t,0),o,(0,te.B)(t,o))),"number"==typeof r?((0,p.vA)(r%1==0,()=>`bandPart(): numUpper must be an integer, got ${r}.`),(0,p.vA)(r<=l,()=>`bandPart(): numUpper (${r}) must not be greater than the number of columns (${l}).`),a=(0,h.YT)(r<0?l:r,"numUpper","bandPart")):((0,p.vA)("int32"===r.dtype,()=>"bandPart(): numUpper's dtype must be an int32."),a=(0,rA._)((0,ez.M)(r,0),l,(0,te.B)(r,l)));let u=(0,I.t)(tM(0,o,1,"int32"),[-1,1]),d=tM(0,l,1,"int32"),c=(0,ts.j)(u,d),f=(0,eH.n)((0,eB.I)(c,n),(0,e_.D)(c,(0,tu.H)(a))),m=(0,rR.U)([o,l],s.dtype);return(0,I.t)((0,ro.t)((0,rI.K)((0,I.t)(s,[-1,o,l])).map(e=>(0,rA._)(f,e,m))),i)}}),nf=(0,d.op)({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,(0,p.vA)(null!=e&&e.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");let r=e[0].shape[0];for(let t=1;t<e.length;++t)(0,p.vA)(e[t].shape[0]===r,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${r})`)}else t=!0,e=(0,rn.l)(e,e.shape[0],0).map(e=>(0,ri.r)(e,[0]));(0,p.vA)(e.length<=e[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);let r=[],n=e;for(let t=0;t<e.length;++t)r.push(l.T2.tidy(()=>{let e=n[t];if(t>0)for(let n=0;n<t;++n){let t=(0,$.l)((0,rh.c)((0,$.l)(r[n],e)),r[n]);e=(0,ts.j)(e,t)}return(0,ef.y)(e,(0,rL.x)(e,"euclidean"))}));return t?(0,ro.t)(r,0):r}});var nm=r(13649);function ng(e,t=!1){return l.T2.tidy(()=>{(0,p.vA)(2===e.shape.length,()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);let r=e.shape[0],n=e.shape[1],a=eC(r),s=(0,K.o)(e),i=rm([[1]],[1,1]),o=(0,K.o)(i),u=r>=n?n:r;for(let e=0;e<u;++e){let t=s,u=o,h=a;[o,s,a]=l.T2.tidy(()=>{let t=(0,R.d)(s,[e,e],[r-e,1]),l=(0,rL.x)(t),u=(0,R.d)(s,[e,e],[1,1]),h=(0,rA._)((0,eR.r)(u,0),rm([[-1]]),rm([[1]])),p=(0,ts.j)(u,(0,$.l)(h,l)),d=(0,ef.y)(t,p);o=1===d.shape[0]?(0,K.o)(i):(0,E.x)([i,(0,R.d)(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);let c=(0,tu.H)((0,ef.y)((0,A.N)(h,p),l)),f=(0,R.d)(s,[e,0],[r-e,n]),m=(0,$.l)(c,o),g=(0,rO.m)(o);if(0===e)s=(0,ts.j)(f,(0,A.N)(m,(0,A.N)(g,f)));else{let t=(0,ts.j)(f,(0,A.N)(m,(0,A.N)(g,f)));s=(0,E.x)([(0,R.d)(s,[0,0],[e,n]),t],0)}let y=(0,rO.m)(m),b=(0,R.d)(a,[0,e],[r,a.shape[1]-e]);if(0===e)a=(0,ts.j)(b,(0,A.N)((0,A.N)(b,o),y));else{let t=(0,ts.j)(b,(0,A.N)((0,A.N)(b,o),y));a=(0,E.x)([(0,R.d)(a,[0,0],[r,e]),t],1)}return[o,s,a]}),(0,nm.AS)([t,u,h])}return!t&&r>n&&(a=(0,R.d)(a,[0,0],[r,n]),s=(0,R.d)(s,[0,0],[n,n])),[a,s]})}let ny=(0,d.op)({qr_:function(e,t=!1){if((0,p.vA)(e.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`),2===e.rank)return ng(e,t);{let r=e.shape.slice(0,e.shape.length-2).reduce((e,t)=>e*t),n=(0,rI.K)((0,I.t)(e,[r,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],s=[];return n.forEach(e=>{let[r,n]=ng(e,t);a.push(r),s.push(n)}),[(0,I.t)((0,ro.t)(a,0),e.shape),(0,I.t)((0,ro.t)(s,0),e.shape)]}}});var nb=r(22492);let nx=(0,d.op)({computeWeightedLoss_:function(e,t,r=nb.i.SUM_BY_NONZERO_WEIGHTS){let n=(0,h.YT)(e,"losses","computeWeightedLoss"),a=null;null!=t&&(a=(0,h.YT)(t,"weights","computeWeightedLoss"));let s=null==a?n:(0,$.l)(n,a);if(r===nb.i.NONE)return s;if(r===nb.i.SUM)return(0,rh.c)(s);if(r===nb.i.MEAN)if(null==a)return(0,e6.i)(s);else{let e=n.size/a.size,t=(0,ef.y)((0,rh.c)(s),(0,rh.c)(a));return e>1?(0,ef.y)(t,(0,tY.d)(e)):t}if(r===nb.i.SUM_BY_NONZERO_WEIGHTS)if(null==a)return(0,ef.y)((0,rh.c)(s),(0,tY.d)(n.size));else{let e=(0,$.l)(a,(0,e5.S)(n.shape)),t=(0,N.w)((0,rh.c)((0,th.E)(e,(0,tY.d)(0))),"float32");return(0,ef.y)((0,rh.c)(s),t)}throw Error(`Unknown reduction: ${r}`)}}),nv=(0,d.op)({absoluteDifference_:function(e,t,r,n=nb.i.SUM_BY_NONZERO_WEIGHTS){let s=(0,h.YT)(e,"labels","absoluteDifference"),i=(0,h.YT)(t,"predictions","absoluteDifference"),o=null;return null!=r&&(o=(0,h.YT)(r,"weights","absoluteDifference")),(0,p.O3)(s.shape,i.shape,"Error in absoluteDifference: "),nx((0,a.t)((0,ts.j)(s,i)),o,n)}}),nw=(0,d.op)({cosineDistance_:function(e,t,r,n,a=nb.i.SUM_BY_NONZERO_WEIGHTS){let s=(0,h.YT)(e,"labels","cosineDistance"),i=(0,h.YT)(t,"predictions","cosineDistance"),o=null;null!=n&&(o=(0,h.YT)(n,"weights","cosineDistance")),(0,p.O3)(s.shape,i.shape,"Error in cosineDistance: ");let l=(0,tY.d)(1);return nx((0,ts.j)(l,(0,rh.c)((0,$.l)(s,i),r,!0)),o,a)}}),nT=(0,d.op)({hingeLoss_:function(e,t,r,n=nb.i.SUM_BY_NONZERO_WEIGHTS){let a=(0,h.YT)(e,"labels","hingeLoss"),s=(0,h.YT)(t,"predictions","hingeLoss"),i=null;null!=r&&(i=(0,h.YT)(r,"weights","hingeLoss")),(0,p.O3)(a.shape,s.shape,"Error in hingeLoss: ");let o=(0,tY.d)(1);return a=(0,ts.j)((0,$.l)((0,tY.d)(2),a),o),nx((0,tB.V)((0,ts.j)(o,(0,$.l)(a,s))),i,n)}}),nS=(0,d.op)({huberLoss_:function(e,t,r,n=1,s=nb.i.SUM_BY_NONZERO_WEIGHTS){let i=(0,h.YT)(e,"labels","huberLoss"),l=(0,h.YT)(t,"predictions","huberLoss"),u=null;null!=r&&(u=(0,h.YT)(r,"weights","huberLoss")),(0,p.O3)(i.shape,l.shape,"Error in huberLoss: ");let d=(0,tY.d)(n),c=(0,a.t)((0,ts.j)(l,i)),f=(0,te.B)(c,d),m=(0,ts.j)(c,f);return nx((0,o.W)((0,$.l)((0,tY.d)(.5),(0,ta.E)(f)),(0,$.l)(d,m)),u,s)}}),nN=(0,d.op)({logLoss_:function(e,t,r,n=1e-7,a=nb.i.SUM_BY_NONZERO_WEIGHTS){let s=(0,h.YT)(e,"labels","logLoss"),i=(0,h.YT)(t,"predictions","logLoss"),l=null;null!=r&&(l=(0,h.YT)(r,"weights","logLoss")),(0,p.O3)(s.shape,i.shape,"Error in logLoss: ");let u=(0,tY.d)(1),d=(0,tY.d)(n),c=(0,tu.H)((0,$.l)(s,(0,eU.R)((0,o.W)(i,d)))),f=(0,$.l)((0,ts.j)(u,s),(0,eU.R)((0,o.W)((0,ts.j)(u,i),d)));return nx((0,ts.j)(c,f),l,a)}}),nk=(0,d.op)({meanSquaredError_:function(e,t,r,n=nb.i.SUM_BY_NONZERO_WEIGHTS){let a=(0,h.YT)(e,"labels","meanSquaredError"),s=(0,h.YT)(t,"predictions","meanSquaredError"),i=null;return null!=r&&(i=(0,h.YT)(r,"weights","meanSquaredError")),(0,p.O3)(a.shape,s.shape,"Error in meanSquaredError: "),nx((0,rs.P)(a,s),i,n)}}),nI=(0,d.op)({sigmoidCrossEntropy_:function(e,t,r,n=0,s=nb.i.SUM_BY_NONZERO_WEIGHTS){let i=(0,h.YT)(e,"multiClassLabels","sigmoidCrossEntropy"),l=(0,h.YT)(t,"logits","sigmoidCrossEntropy"),u=null;if(null!=r&&(u=(0,h.YT)(r,"weights","sigmoidCrossEntropy")),(0,p.O3)(i.shape,l.shape,"Error in sigmoidCrossEntropy: "),n>0){let e=(0,tY.d)(n),t=(0,tY.d)(1),r=(0,tY.d)(.5);i=(0,o.W)((0,$.l)(i,(0,ts.j)(t,e)),(0,$.l)(r,e))}return nx(function(e,t){let r=(0,h.YT)(e,"labels","sigmoidCrossEntropyWithLogits"),n=(0,h.YT)(t,"logits","sigmoidCrossEntropyWithLogits");(0,p.O3)(r.shape,n.shape,"Error in sigmoidCrossEntropyWithLogits: ");let s=(0,tB.V)(n),i=(0,$.l)(n,r),l=(0,eG.K)((0,eS.o)((0,tu.H)((0,a.t)(n))
4150));return(0,o.W)((0,ts.j)(s,i),l)}(i,l),u,s)}}),nC=(0,d.op)({softmaxCrossEntropy_:function(e,t,r,n=0,a=nb.i.SUM_BY_NONZERO_WEIGHTS){let s=(0,h.YT)(e,"onehotLabels","softmaxCrossEntropy"),i=(0,h.YT)(t,"logits","softmaxCrossEntropy"),l=null;if(null!=r&&(l=(0,h.YT)(r,"weights","softmaxCrossEntropy")),(0,p.O3)(s.shape,i.shape,"Error in softmaxCrossEntropy: "),n>0){let e=(0,tY.d)(n),t=(0,tY.d)(1),r=(0,tY.d)(s.shape[1]);s=(0,o.W)((0,$.l)(s,(0,ts.j)(t,e)),(0,ef.y)(e,r))}return nx(function(e,t,r=-1){if(-1===r&&(r=t.rank-1),r!==t.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${r}`);return(0,rj._X)((e,t,n)=>{let a=(0,eK.V)(t,[r],!0),s=(0,ts.j)((0,N.w)(t,"float32"),a);n([e,s]);let i=(0,tu.H)((0,$.l)(s,e));return{value:(0,rh.c)(i,[r]),gradFunc:(e,t)=>{let[n,a]=t,s=(0,tn.SM)(e.shape,[r]);return[(0,$.l)((0,I.t)(e,s),(0,ts.j)((0,N.w)(n,"float32"),(0,eS.o)(a))),(0,$.l)((0,I.t)(e,s),(0,ts.j)((0,eS.o)(a),(0,N.w)(n,"float32")))]}}})(e,t)}(s,i),l,a)}}),nE=(0,d.op)({sparseFillEmptyRows_:function(e,t,r,n){let a=(0,h.YT)(e,"indices","sparseFillEmptyRows","int32"),s=(0,h.YT)(t,"values","sparseFillEmptyRows"),i=(0,h.YT)(r,"denseShape","sparseFillEmptyRows","int32"),o=(0,h.YT)(n,"defaultValue","sparseFillEmptyRows",s.dtype);if(2!==a.rank)throw Error(`Indices should be Tensor2D but received shape 4151 ${a.shape}`);if(1!==s.rank)throw Error(`Values should be Tensor1D but received shape ${s.shape}`);if(1!==i.rank)throw Error(`Dense shape should be Tensor1D but received shape ${i.shape}`);if(0!==o.rank)throw Error(`Default value should be a scalar but received shape ${o.shape}`);let p=l.T2.runKernel(u.C8s,{indices:a,values:s,denseShape:i,defaultValue:o});return{outputIndices:p[0],outputValues:p[1],emptyRowIndicator:p[2],reverseIndexMap:p[3]}}}),nA=(0,d.op)({sparseReshape_:function(e,t,r){let n=(0,h.YT)(e,"inputIndices","sparseReshape","int32"),a=(0,h.YT)(t,"inputShape","sparseReshape","int32"),s=(0,h.YT)(r,"newShape","sparseReshape","int32");if(2!==n.rank)throw Error(`Input indices should be Tensor2D but received shape 4152 ${n.shape}`);if(1!==a.rank)throw Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==s.rank)throw Error(`New shape should be Tensor1D but received shape ${s.shape}`);let i=l.T2.runKernel(u.BoJ,{inputIndices:n,inputShape:a,newShape:s});return{outputIndices:i[0],outputShape:i[1]}}}),n$=(0,d.op)({sparseSegmentMean_:function(e,t,r){let n=(0,h.YT)(e,"data","sparseSegmentMean"),a=(0,h.YT)(t,"indices","sparseSegmentMean","int32"),s=(0,h.YT)(r,"segmentIds","sparseSegmentMean","int32");if(n.rank<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw Error(`Indices should be Tensor1D but received shape 4153 ${a.shape}`);if(1!==s.rank)throw Error(`Segment ids should be Tensor1D but received shape 4154 ${s.shape}`);return l.T2.runKernel(u.L6G,{data:n,indices:a,segmentIds:s})}}),nF=(0,d.op)({sparseSegmentSum_:function(e,t,r){let n=(0,h.YT)(e,"data","sparseSegmentSum"),a=(0,h.YT)(t,"indices","sparseSegmentSum","int32"),s=(0,h.YT)(r,"segmentIds","sparseSegmentSum","int32");if(n.rank<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw Error(`Indices should be Tensor1D but received shape 4155 ${a.shape}`);if(1!==s.rank)throw Error(`Segment ids should be Tensor1D but received shape 4156 ${s.shape}`);return l.T2.runKernel(u.DvZ,{data:n,indices:a,segmentIds:s})}}),nR=(0,d.op)({stringNGrams_:function(e,t,r,n,a,s,i,o){let p=(0,h.YT)(e,"data","stringNGrams","string");if("string"!==p.dtype)throw Error("Data must be of datatype string");if(1!==p.shape.length)throw Error(`Data must be a vector, saw: ${p.shape}`);let d=(0,h.YT)(t,"dataSplits","stringNGrams");if("int32"!==d.dtype)throw Error("Data splits must be of datatype int32");let c=l.T2.runKernel(u.YAb,{data:p,dataSplits:d},{separator:r,nGramWidths:n,leftPad:a,rightPad:s,padWidth:i,preserveShortSequences:o});return{nGrams:c[0],nGramsSplits:c[1]}}}),n_=(0,d.op)({stringSplit_:function(e,t,r=!0){let n=(0,h.YT)(e,"input","stringSplit","string"),a=(0,h.YT)(t,"delimiter","stringSplit","string");if(1!==n.rank)throw Error(`Input should be Tensor1D but received shape ${n.shape}`);if(0!==a.rank)throw Error(`Delimiter should be a scalar but received shape ${a.shape}`);let s=l.T2.runKernel(u.iW0,{input:n,delimiter:a},{skipEmpty:r});return{indices:s[0],values:s[1],shape:s[2]}}}),nD=(0,d.op)({stringToHashBucketFast_:function(e,t){let r=(0,h.YT)(e,"input","stringToHashBucketFast","string");if(t<=0)throw Error("Number of buckets must be at least 1");return l.T2.runKernel(u.$jE,{input:r},{numBuckets:t})}}),nO=(0,d.op)({staticRegexReplace_:function(e,t,r,n=!0){let a=(0,h.YT)(e,"input","staticRegexReplace","string");return l.T2.runKernel(u.GZp,{x:a},{pattern:t,rewrite:r,replaceGlobal:n})}}),nL={fft:t9.h,ifft:re.K,rfft:rr.z,irfft:rt.g},nM={hammingWindow:r2,hannWindow:r3,frame:r4,stft:r6},nP={flipLeftRight:r8,grayscaleToRGB:r7,resizeNearestNeighbor:nh.b,resizeBilinear:nu.v,rgbToGrayscale:r9,rotateWithOffset:ne,cropAndResize:r5,nonMaxSuppression:nr,nonMaxSuppressionAsync:na,nonMaxSuppressionWithScore:ns,nonMaxSuppressionWithScoreAsync:ni,nonMaxSuppressionPadded:no,nonMaxSuppressionPaddedAsync:nl,threshold:np,transform:nd},nz={bandPart:nc,gramSchmidt:nf,qr:ny},nB={absoluteDifference:nv,computeWeightedLoss:nx,cosineDistance:nw,hingeLoss:nT,huberLoss:nS,logLoss:nN,meanSquaredError:nk,sigmoidCrossEntropy:nI,softmaxCrossEntropy:nC},nW={sparseFillEmptyRows:nE,sparseReshape:nA,sparseSegmentMean:n$,sparseSegmentSum:nF},nV={stringNGrams:nR,stringSplit:n_,stringToHashBucketFast:nD,staticRegexReplace:nO}},98722:(e,t,r)=>{"use strict";r.r(t),r.d(t,{addImpl:()=>a.mx,bincountImpl:()=>s.X,bincountReduceImpl:()=>s.N,bitwiseAndImpl:()=>
4156i.f6,castImpl:()=>o.ct,ceilImpl:()=>l.YG,concatImpl:()=>u.h,equalImpl:()=>h.z3,expImpl:()=>p.sG,expm1Impl:()=>d.uM,floorDivImpl:()=>f.C1,floorImpl:()=>c.vS,gatherNdImpl:()=>m.q,gatherV2Impl:()=>g.G,greaterEqualImpl:()=>b.lg,greaterImpl:()=>y.rq,lessEqualImpl:()=>v.cu,lessImpl:()=>x.WR,linSpaceImpl:()=>w.G,logImpl:()=>T.px,maxImpl:()=>S.j,maximumImpl:()=>N.He,minimumImpl:()=>k.hE,multiplyImpl:()=>I.BF,negImpl:()=>C.Dk,notEqualImpl:()=>E.cl,prodImpl:()=>A._B,raggedGatherImpl:()=>$.u,raggedRangeImpl:()=>F._,raggedTensorToTensorImpl:()=>R.K,rangeImpl:()=>_.q,rsqrtImpl:()=>D.Zy,scatterImpl:()=>O.b,sigmoidImpl:()=>L.zv,simpleAbsImpl:()=>n.dH,sliceImpl:()=>M.HS,sparseFillEmptyRowsImpl:()=>P.y,sparseReshapeImpl:()=>z.l,sparseSegmentReductionImpl:()=>B.z,sqrtImpl:()=>W.x6,squaredDifferenceImpl:()=>V.RF,staticRegexReplaceImpl:()=>U._,stridedSliceImpl:()=>G.e,stringNGramsImpl:()=>Z.G,stringSplitImpl:()=>j.S,stringToHashBucketFastImpl:()=>K.f,subImpl:()=>H.dl,tileImpl:()=>Y.D,topKImpl:()=>Q.x,transposeImpl:()=>q._,uniqueImpl:()=>X.w});var n=r(1888),a=r(58611),s=r(48319),i=r(16592),o=r(13419),l=r(89573),u=r(59635),h=r(4768),p=r(49335),d=r(38193),c=r(2498),f=r(62637),m=r(47820),g=r(54658),y=r(67934),b=r(48374),x=r(53553),v=r(71387),w=r(66114),T=r(28566),S=r(26761),N=r(78522),k=r(20176),I=r(82407),C=r(76466),E=r(30823),A=r(47045),$=r(92600),F=r(59802),R=r(50206),_=r(85656),D=r(81384),O=r(87309),L=r(93020),M=r(69510),P=r(65114),z=r(15385),B=r(95853),W=r(52310),V=r(83310),U=r(92947),G=r(46978),Z=r(54574),j=r(92982),K=r(1275),H=r(51982),Y=r(47871),Q=r(92427),q=r(25550),X=r(92330)},99309:(e,t,r)=>{"use strict";r.d(t,{N:()=>o});var n=r(5287),a=r(96609),s=r(72155),i=r(54463);let o=(0,r(18875).op)({matMul_:function(e,t,r=!1,o=!1){let l=(0,i.YT)(e,"a","matMul"),u=(0,i.YT)(t,"b","matMul");[l,u]=(0,s.makeTypesMatch)(l,u);let h={a:l,b:u};return n.T2.runKernel(a.jAQ,h,{transposeA:r,transposeB:o})}})},99858:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(5287),a=r(96609),s=r(54463);let i=(0,r(18875).op)({rsqrt_:function(e){let t=(0,s.YT)(e,"x","rsqrt","float32");return n.T2.runKernel(a.TOR,{x:t})}})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.