varIp=Object.defineProperty;varSe=(n,t)=>()=>(t||(t={exports:{}},n(t.exports,t)),t.exports),AI=n=>Ip(n,"__esModule",{value:!0}),Ap=(n,t)=>{AI(n);for(vareint)Ip(n,e,{get:t[e],enumerable:!0})};varTp=Se(()=>{});varNp=Se(()=>{});varcs=Se(()=>{});varji=Se(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});varJo=function(n,t){returnJo=Object.setPrototypeOf||{__proto__:[]}instanceofArray&&function(e,i){e.__proto__=i}||function(e,i){for(varrini)i.hasOwnProperty(r)&&(e[r]=i[r])},Jo(n,t)};functionMn(n,t){Jo(n,t);functione(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,newe)}functionde(n,t,e,i){returnnew(e||(e=Promise))(function(r,a){functions(u){try{l(i.next(u))}catch(c){a(c)}}functiono(u){try{l(i.throw(u))}catch(c){a(c)}}functionl(u){u.done?r(u.value):newe(function(c){c(u.value)}).then(s,o)}l((i=i.apply(n,t||[])).next())})}functionpe(n,t){vare={label:0,sent:function(){if(a[0]&1)throwa[1];returna[1]},trys:[],ops:[]},i,r,a,s;returns={next:o(0),throw:o(1),return:o(2)},typeofSymbol=="function"&&(s[Symbol.iterator]=function(){returnthis}),s;functiono(u){returnfunction(c){returnl([u,c])}}functionl(u){if(i)thrownewTypeError("Generator is already executing.");for(;e;)try{if(i=1,r&&(a=u[0]&2?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)returna;(r=0,a)&&(u=[u[0]&2,a.value]);switch(u[0]){case0:case1:a=u;break;case4:returne.label++,{value:u[1],done:!1};case5:e.label++,r=u[1],u=[0];continue;case7:u=e.ops.pop(),e.trys.pop();continue;default:if(!(a=e.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){e.label=u[1];break}if(u[0]===6&&e.label<a[1]){e.label=a[1],a=u;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(u);break}a[2]&&e.ops.pop(),e.trys.pop();continue}u=t.call(n,e)}catch(c){u=[6,c],r=0}finally{i=a=0}if(u[0]&5)throwu[1];return{value:u[0]?u[1]:void0,done:!0}}}varTI=1e-7,NI=1e-4,xI=function(){functionn(t,e){this.backend=t,this.dataMover=e,this.data=newWeakMap,this.dataIdsCount=0}returnn.prototype.get=function(t){returnthis.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t)},n.prototype.set=function(t,e){this.dataIdsCount++,this.data.set(t,e)},n.prototype.has=function(t){returnthis.data.has(t)},n.prototype.delete=function(t){returnthis.dataIdsCount--,this.data.delete(t)},n.prototype.numDataIds=function(){returnthis.dataIdsCount},n}(),xp=function(){functionn(){}returnn.prototype.time=function(t){return$("time")},n.prototype.read=function(t){return$("read")},n.prototype.readSync=function(t){return$("readSync")},n.prototype.numDataIds=function(){return$("numDataIds")},n.prototype.disposeData=function(t){return$("disposeData")},n.prototype.write=function(t,e,i){return$("write")},n.prototype.move=function(t,e,i,r){return$("move")},n.prototype.memory=function(){return$("memory")},n.prototype.floatPrecision=function(){return$("floatPrecision")},n.prototype.epsilon=function(){returnthis.floatPrecision()===32?TI:NI},n.prototype.batchMatMul=function(t,e,i,r){return$("batchMatMul")},n.prototype.fusedBatchMatMul=function(t){vare=t.a,i=t.b,r=t.transposeA,a=t.transposeB,s=t.bias,o=t.activation,l=t.preluActivationWeights;return$("fusedBatchMatMul")},n.prototype.slice=function(t,e,i){return$("slice")},n.prototype.stridedSlice=function(t,e,i,r){return$("stridedSlice")},n.prototype.unstack=function(t,e){return$("unstack")},n.prototype.reverse=function(t,e){return$("reverse")},n.prototype.concat=function(t,e){return$("concat")},n.prototype.neg=function(t){return$("neg")},n.prototype.add=function(t,e){return$("add")},n.prototype.addN=function(t){return$("addN")},n.prototype.subtract=function(t,e){return$("subtract")},n.prototype.multiply=function(t,e){return$("multiply")},n.prototype.realDivide=function(t,e){return$("realDivide")},n.prototype.floorDiv=function(t,e){return$("floorDiv")},n.prototype.sum=function(t,e){return$("sum")},n.prototype.prod=function(t,e){return$("prod")},n.prototype.unsortedSegmentSum=f
`;return v[v.length-1]=" "+v[v.length-1]+"]"+(a?"":x),v}function ma(n){for(var t=[],e=0;e<n.length;e+=2)t.push([n[e],n[e+1]]);return t}var bs=function(){function n(t,e,i){var r=this;if(this.dtype=e,this.shape=t.slice(),this.size=st(t),i!=null){var a=i.length;E(a===this.size,function(){return"Length of values '"+a+"' does not match the size "+("inferred by the shape '"+r.size+"'.")})}if(e==="complex64")throw new 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=i||Ff(e,this.size),this.strides=yr(t)}return n.prototype.set=function(t){for(var e=this,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];i.length===0&&(i=[0]),E(i.length===this.rank,function(){return"The number of provided coordinates ("+i.length+") must "+("match the rank ("+e.rank+")")});var a=this.locToIndex(i);this.values[a]=t},n.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t.length===0&&(t=[0]);for(var i=0,r=0,a=t;r<a.length;r++){var s=a[r];if(s<0||s>=this.shape[i]){var o="Requested out of range element at "+t+". "+(" Buffer shape="+this.shape);throw new Error(o)}i++}for(var l=t[t.length-1],u=0;u<t.length-1;++u)l+=this.strides[u]*t[u];return this.values[l]},n.prototype.locToIndex=function(t){if(this.rank===0)return 0;if(this.rank===1)return t[0];for(var e=t[t.length-1],i=0;i<t.length-1;++i)e+=this.strides[i]*t[i];return e},n.prototype.indexToLoc=function(t){if(this.rank===0)return[];if(this.rank===1)return[t];for(var e=new Array(this.shape.length),i=0;i<e.length-1;++i)e[i]=Math.floor(t/this.strides[i]),t-=e[i]*this.strides[i];return e[e.length-1]=t,e},Object.defineProperty(n.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),n.prototype.toTensor=function(){return Nn().makeTensor(this.values,this.shape,this.dtype)},n}(),Nn=null,Sr=null;function o2(n){Nn=n}function l2(n){Sr=n}var Y=function(){function n(t,e,i,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=st(t),this.strides=yr(t),this.dataId=i,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}return Object.defineProperty(n.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),n.prototype.buffer=function(){return de(this,void 0,void 0,function(){var t;return pe(this,function(e){switch(e.label){case 0:return[4,this.data()];case 1:return t=e.sent(),[2,Sr.buffer(this.shape,this.dtype,t)]}})})},n.prototype.bufferSync=function(){return Sr.buffer(this.shape,this.dtype,this.dataSync())},n.prototype.array=function(){return de(this,void 0,void 0,function(){var t;return pe(this,function(e){switch(e.label){case 0:return[4,this.data()];case 1:return t=e.sent(),[2,br(this.shape,t)]}})})},n.prototype.arraySync=function(){return br(this.shape,this.dataSync())},n.prototype.data=function(){return de(this,void 0,void 0,function(){var t,e;return pe(this,function(i){switch(i.label){case 0:return this.throwIfDisposed(),t=Nn().read(this.dataId),this.dtype==="string"?[4,t]:[3,2];case 1:e=i.sent();try{return[2,e.map(function(r){return Ku(r)})]}catch(r){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}i.label=2;case 2:return[2,t]}})})},n.prototype.dataSync=function(){this.throwIfDisposed();var t=Nn().readSync(this.dataId);if(this.dtype==="string")try{return t.map(function(e){return Ku(e)})}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t},n.prototype.bytes=function(){return de(this,void 0,void 0,function(){var t;return pe(this,function(e){switch(e.label){case 0:return this.throwIfDisposed(),[4,Nn().read(this.dataId)];case 1:return t=e.sent(),this.dtype==="string"?[2,t]:[2,new Uint8Array(t.buffer)]}})})},n.prototype.dispose=function(){if(this.isDisposed)return;Nn().disposeTensor(this),this.isDisposedInternal=!0},Object.defineProperty(n.prototype,"isDisposed",{get:function(){return this.is
`)+"Manifest JSON has weights with names: "+(l.join(", ")+"."));return c=a.reduce(function(g,v,b){return v&&g.push(b),g},[]),h=[],c.forEach(function(g){e[g].paths.forEach(function(v){var b=i+(i.endsWith("/")?"":"/")+v;h.push(b)})}),[4,n(h)];case 1:return d=m.sent(),p={},f=0,c.forEach(function(g){for(var v=e[g].paths.length,b=0,w=0;w<v;w++)b+=d[f+w].byteLength;for(var S=new ArrayBuffer(b),L=new Uint8Array(S),x=0,C=0;C<v;C++){var R=new Uint8Array(d[f+C]);L.set(R,x),x+=R.byteLength}var D=s[g];D.forEach(function(k){var W=S.slice(k.groupOffset,k.groupOffset+k.sizeBytes),F=Qf(W,[k.manifestEntry]);for(var P in F)p[P]=F[P]}),f+=v}),[2,p]}})})}}var lA="application/octet-stream",uA="application/json",pm=function(){function n(t,e){if(this.DEFAULT_METHOD="POST",e==null&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.onProgress=e.onProgress,this.weightUrlConverter=e.weightUrlConverter,e.fetchFunc!=null?(E(typeof e.fetchFunc=="function",function(){return"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"}),this.fetch=e.fetchFunc):this.fetch=Me().platform.fetch,E(t!=null&&t.length>0,function(){return"URL path for http must not be null, undefined or empty."}),Array.isArray(t)&&E(t.length===2,function(){return"URL paths for http must have a length of 2, "+("(actual length is "+t.length+").")}),this.path=t,e.requestInit!=null&&e.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{}}return n.prototype.save=function(t){return de(this,void 0,void 0,function(){var e,i,r,a;return pe(this,function(s){switch(s.label){case 0:if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit),e.body=new FormData,i=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata,weightsManifest:i},e.body.append("model.json",new Blob([JSON.stringify(r)],{type:uA}),"model.json"),t.weightData!=null&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:lA}),"model.weights.bin"),[4,this.fetch(this.path,e)];case 1:if(a=s.sent(),a.ok)return[2,{modelArtifactsInfo:ya(t),responses:[a]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+(a.status+"."))}})})},n.prototype.load=function(){return de(this,void 0,void 0,function(){var t,e,i,r,a,s,o,l,u,c,h,d,p,f,m;return pe(this,function(g){switch(g.label){case 0:return[4,this.fetch(this.path,this.requestInit)];case 1:if(t=g.sent(),!t.ok)throw new 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.");g.label=2;case 2:return g.trys.push([2,4,,5]),[4,t.json()];case 3:return e=g.sent(),[3,5];case 4:throw i=g.sent(),r="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?r+=" 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.":r+=" Please make sure the server is serving valid JSON for this request.",new Error(r);case 5:if(a=e.modelTopology,s=e.weightsManifest,o=e.generatedBy,l=e.convertedBy,u=e.format,c=e.userDefinedMetadata,a==null&&s==null)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return s!=null?[4,this.loadWeights(s)]:[3,7];case 6:p=g.sent(),h=p[0],d=p[1],g.label=7;case 7:return f={modelTopology:a,weightSpecs:h,weightData:d,userDefinedMetadata:c,generatedBy:o,convertedBy:l,format:u},m=e.modelInitializer,m&&(f.modelInitializer=m),[2,f]}})})},n.prototype.loadWe
`)+("Expected: "+u+"."))}}function FA(n,t){n().then(function(){return t.fail()},function(){return t()})}function WA(n,t){var e=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?[t]:t;return ei(n)||ei(n[0])||ei(t)||ei(t[0])?mc(n,e,function(i,r){return i==r}):mc(n,t,function(i,r){return gc(i,r,0)})}function UA(n,t,e){if(e==null&&(e=fc()),!gc(n,t,e))throw new Error("Numbers differ: actual === "+n+", expected === "+t)}function gc(n,t,e){return!isFinite(n)&&!isFinite(t)?!0:!(isNaN(n)||isNaN(t)||Math.abs(n-t)>e)}function BA(n,t,e){for(var i=0;i<n.length;i++)if(n[i]<t||n[i]>e)throw new Error("Value out of range:"+n[i]+" low: "+t+", high: "+e)}function zA(n,t){expect(new Float32Array(n)).toEqual(new Float32Array(t))}var PA={__proto__:null,TEST_EPSILON_FLOAT16:Dm,expectArraysClose:kA,testEpsilon:fc,expectPromiseToFail:FA,expectArraysEqual:WA,expectNumbersClose:UA,expectValuesInRange:BA,expectArrayBuffersEqual:zA};var _A="2.6.0";function MA(){Me().set("PROD",!0)}function HA(){Me().set("DEBUG",!0)}function VA(){Me().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Lt(n){Me().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(n+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function qA(){z.disposeVariables()}function GA(){return z}function YA(){return z.memory()}function KA(n){return z.profile(n)}function pt(n,t){return z.tidy(n,t)}function Bt(n){var t=Qu(n);t.forEach(function(e){return e.dispose()})}function km(n){return z.keep(n)}function jA(n){return z.time(n)}function $A(n){return z.setBackend(n)}function XA(){return z.ready()}function JA(){return z.backendName}function ZA(n){z.removeBackend(n)}function QA(n){return z.findBackend(n)}function eT(n){return z.findBackendFactory(n)}function tT(n,t,e){return e===void 0&&(e=1),z.registerBackend(n,t,e)}function nT(){return z.backend}function iT(n,t){Me().setPlatform(n,t)}function rT(n,t){var e,i=O(n,"a","add"),r=O(t,"b","add");e=rt(i,r),i=e[0],r=e[1];var a=function(o,l){var u=o.add(i,r);return l([i,r]),u},s={a:i,b:r};return z.runKernelFunc(a,s,null,hs)}var fe=U({add_:rT});function aT(n,t){var e,i=O(n,"a","floorDiv"),r=O(t,"b","floorDiv");e=rt(i,r),i=e[0],r=e[1];var a=function(o,l){var u=o.floorDiv(i,r);return l([i,r]),u},s={a:i,b:r};return z.runKernelFunc(a,s,null,Dl)}var vc=U({floorDiv_:aT});function sT(n,t){var e,i=O(n,"a","div"),r=O(t,"b","div");if(e=rt(i,r),i=e[0],r=e[1],i.dtype==="int32"&&r.dtype==="int32")return vc(i,r);var a=function(l,u){var c=l.realDivide(i,r);return u([i,r]),c},s={a:i,b:r},o={};return z.runKernelFunc(a,s,null,Nl,o)}var Ie=U({div_:sT});function oT(n,t){var e,i=O(n,"a","mul"),r=O(t,"b","mul");e=rt(i,r),i=e[0],r=e[1];var a=function(o,l){var u=o.multiply(i,r);return l([i,r]),u},s={a:i,b:r};return z.runKernelFunc(a,s,null,Jl)}var J=U({mul_:oT});function lT(n){var t=O(n,"x","abs"),e={x:t};return z.runKernelFunc(function(i,r){return r([t]),t.dtype==="complex64"?i.complexAbs(t):i.abs(t)},e,null,Qo)}var Vt=U({abs_:lT});function uT(n){var t=O(n,"x","acos"),e={x:t};return z.runKernelFunc(function(i,r){var a=i.acos(t);return r([t]),a},e,null,el)}var Fm=U({acos_:uT});function cT(n){var t=O(n,"x","acosh"),e={x:t};return z.runKernelFunc(function(i,r){var a=i.acosh(t);return r([t]),a},e,null,tl)}var Wm=U({acosh_:cT});function hT(n){E(Array.isArray(n),function(){return"The argument passed to tf.addN() must be a list of tensors"}),E(n.length>=1,function(){return"Must pass at least one tensor to tf.addN(), but got "+(""+n.length)});var t=n.map(function(a,s){return O(a,"tensors"+s,"addN")}),e=t[0];t.forEach(function(a){if(a.dtype!==e.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(function(a){if(!sn(a.shape,e.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});var i=function(a,s){var o=a.addN(t);return s(t),o},r=t;return z.runKernelFunc(i,r,null,nl)}var dT=U({addN_:hT});function yc(n,t){for(var e=0;e<n.length;++e)if(n[n.length-e-1]!==t-1-e)return!1;return!0}function Um(n,t,e){for(var i=n
withdtype`+s.dtype+". ")});var i=function(s,o){var l=Ze(t,e[0].shape)[0],u=jm(e.map(function(d){return d.shape}),l);if(st(u)===0)return ri([],u);if(e=e.filter(function(d){return d.size>0}),e.length===1)return e[0];var c=e.map(function(d){return d.shape});Km(c,l);var h=s.concat(e,l);return o(e),h},r=e,a={axis:t};return z.runKernelFunc(i,r,null,vl,a)}var Nt=U({concat_:ET});function DT(n){var t=O(n,"x","sigmoid"),e={x:t};return z.runKernelFunc(function(i,r){var a=i.sigmoid(t);return r([a]),a},e,null,bu)}var Bi=U({sigmoid_:DT});function kT(n,t,e){var i=O(n,"x","slice");if(i.rank===0)throw new Error("Slicing scalar is not possible");var r=function(o,l){var u=pc(i,t,e),c=u[0],h=u[1];return ym(i,c,h),l([i]),o.slice(i,c,h)},a={x:i},s={begin:t,size:e};return z.runKernelFunc(r,a,null,mu,s)}var ze=U({slice_:kT});function FT(n){var t=O(n,"x","tanh"),e={x:t};return z.runKernelFunc(function(i,r){var a=i.tanh(t);return r([a]),a},e,null,Ru)}var xs=U({tanh_:FT});function WT(n,t,e,i,r,a){var s=O(n,"forgetBias","basicLSTMCell"),o=O(t,"lstmKernel","basicLSTMCell"),l=O(e,"lstmBias","basicLSTMCell"),u=O(i,"data","basicLSTMCell"),c=O(r,"c","basicLSTMCell"),h=O(a,"h","basicLSTMCell"),d=Nt([u,h],1),p=Fe(d,o),f=fe(p,l),m=f.shape[0],g=f.shape[1]/4,v=[m,g],b=ze(f,[0,0],v),w=ze(f,[0,g],v),S=ze(f,[0,g*2],v),L=ze(f,[0,g*3],v),x=fe(J(Bi(b),xs(w)),J(c,Bi(fe(s,S)))),C=J(xs(x),Bi(L));return[x,C]}var UT=U({basicLSTMCell_:WT});function BT(n,t,e){var i=O(n,"x","batchToSpaceND"),r=t.reduce(function(l,u){return l*u});E(i.rank>=1+t.length,function(){return"input rank is "+i.rank+" but should be > than blockShape.length "+t.length}),E(e.length===t.length,function(){return"crops.length is "+e.length+" but should be equal to blockShape.length "+t.length}),E(i.shape[0]%r===0,function(){return"input tensor batch is "+i.shape[0]+" but is not divisible by the product of "+("the elements of blockShape "+t.join(" * ")+" === "+r)});var a=function(l){return l.batchToSpaceND(i,t,e)},s={x:i},o={blockShape:t,crops:e};return z.runKernelFunc(a,s,null,pl,o)}var Cs=U({batchToSpaceND_:BT});function zT(n){var t;return n.rank===0||n.rank===1?t=V(n,[1,1,1,n.size]):n.rank===2?t=V(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?t=V(n,[1,n.shape[0],n.shape[1],n.shape[2]]):t=n,t}function PT(n,t,e,i,r,a){a==null&&(a=.001);var s=O(n,"x","batchNorm"),o=O(t,"mean","batchNorm"),l=O(e,"variance","batchNorm"),u;r!=null&&(u=O(r,"scale","batchNorm"));var c;i!=null&&(c=O(i,"offset","batchNorm")),E(o.rank===l.rank,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),E(c==null||o.rank===c.rank,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),E(u==null||o.rank===u.rank,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var h=zT(s),d=function(g,v){return v([h,o,l,u]),g.batchNorm(h,Rs(o),Rs(l),Rs(c),Rs(u),a)},p={x:h,scale:u,offset:c,mean:o,variance:l},f={varianceEpsilon:a},m=z.runKernelFunc(d,p,null,kl,f);return V(m,s.shape)}function Rs(n){return n==null?null:n.rank===0?V(n,[n.size]):n.rank===1?n:n.rank===2?V(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?V(n,[1,n.shape[0],n.shape[1],n.shape[2]]):n}var La=U({batchNorm_:PT});function _T(n,t,e,i,r,a){var s=O(n,"x","batchNorm"),o=O(t,"mean","batchNorm"),l=O(e,"variance","batchNorm"),u;r!=null&&(u=O(r,"scale","batchNorm"));var c;return i!=null&&(c=O(i,"offset","batchNorm")),E(s.rank===2,function(){return"Error in batchNorm2D: x must be rank 2 but got rank "+(s.rank+".")}),E(o.rank===2||o.rank===1,function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but "+("got rank "+o.rank+".")}),E(l.rank===2||l.rank===1,function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 "+("but got rank "+l.rank+".")}),u!=null&&E(u.rank===2||u.rank===1,function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 "+("but got rank "+u.rank+".")}),c!=null&&E(c.rank===2||c.rank===1,function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 "+("but got rank "+c.rank+".")}),La(s,o,l,c,u,a)}var
`+i.shape}),E(s%(t*t)===0,function(){return"Dimension size must be evenly divisible by "+t*t+" but is "+s+" for depthToSpace with input shape "+i.shape});var o=function(c){return c.depthToSpace(i,t,e)},l={x:i},u={blockSize:t,dataFormat:e};return z.runKernelFunc(o,l,null,Mp,u)}var eg=U({depthToSpace_:m1});function g1(n,t,e,i,r,a,s){r===void 0&&(r="NHWC"),a===void 0&&(a=[1,1]);var o=O(n,"x","depthwiseConv2d"),l=O(t,"filter","depthwiseConv2d"),u=o,c=!1;o.rank===3&&(c=!0,u=V(o,[1,o.shape[0],o.shape[1],o.shape[2]])),E(u.rank===4,function(){return"Error in depthwiseConv2d: input must be rank 4, but got "+("rank "+u.rank+".")}),E(l.rank===4,function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+(l.rank+".")}),E(u.shape[3]===l.shape[2],function(){return"Error in depthwiseConv2d: number of input channels "+("("+u.shape[3]+") must match the inChannels dimension in ")+("filter "+l.shape[2]+".")}),s!=null&&E(it(i),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+s+" but got pad "+i+".")});var h=function(m,g){a==null&&(a=[1,1]),E(zt(e,a),function(){return"Error in depthwiseConv2d: Either strides or dilations must be "+("1. Got strides "+e+" and dilations '"+a+"'")});var v=On(u.shape,l.shape,e,a,i,s,!0),b=m.depthwiseConv2D(u,l,v);return g([u,l]),b},d={x:u,filter:l},p={strides:e,pad:i,dataFormat:r,dilations:a,dimRoundingMode:s},f=z.runKernelFunc(h,d,null,Al,p);return c?V(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var Ia=U({depthwiseConv2d_:g1});function v1(n){var t=O(n,"x","diag"),e=function(r){var a=V(t,[t.size]),s=r.diag(a),o=n.shape.concat(n.shape);return V(s,o)},i={x:t};return z.runKernelFunc(e,i,null,qp)}var y1=U({diag_:v1});function b1(n,t,e,i,r,a){r===void 0&&(r=[1,1]),a===void 0&&(a="NHWC");var s=O(n,"x","dilation2d"),o=O(t,"filter","dilation2d");E(s.rank===3||s.rank===4,function(){return"Error in dilation2d: input must be rank 3 or 4, but got rank "+(s.rank+".")}),E(o.rank===3,function(){return"Error in dilation2d: filter must be rank 3, but got rank "+(o.rank+".")}),E(a==="NHWC",function(){return"Error in dilation2d: Only NHWC is currently supported, "+("but got dataFormat of "+a)});var l=s,u=!1;s.rank===3&&(l=V(s,[1,s.shape[0],s.shape[1],s.shape[2]]),u=!0);var c={x:l,filter:o},h={strides:e,pad:i,dilations:r},d=z.runKernel(Tl,c,h);return u?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var tg=U({dilation2d_:b1});function w1(n,t){for(var e=n.length,i=[],r=0;r<e;r++){var a=e-1-r,s=n[a]||1,o=t[t.length-1-r]||1;o>1&&s===1&&i.unshift(a)}return i}function ft(n,t){for(var e=[],i=0;i<t.length;i++){var r=n[n.length-i-1],a=t.length-i-1,s=t[a];(r==null||r===1&&s>1)&&e.unshift(a)}return e}function Qe(n,t){for(var e=[],i=Math.max(n.length,t.length),r=0;r<i;r++){var a=n[n.length-r-1];a==null&&(a=1);var s=t[t.length-r-1];if(s==null&&(s=1),a===1)e.unshift(s);else if(s===1)e.unshift(a);else if(a!==s){var o="Operands could not be broadcast together with shapes "+(n+" and "+t+".");throw Error(o)}else e.unshift(a)}return e}function S1(n,t){var e,i=O(n,"a","equal"),r=O(t,"b","equal");e=rt(i,r),i=e[0],r=e[1],Qe(i.shape,r.shape);var a=function(o){return o.equal(i,r)},s={a:i,b:r};return z.runKernelFunc(a,s,null,jp)}var Aa=U({equal_:S1});function L1(n,t,e){var i=O(t,"a","where"),r=O(e,"b","where"),a=O(n,"condition","where","bool"),s=Qe(i.shape,r.shape),o=Os(i,s),l=Os(r,s);a.rank===1&&E(a.shape[0]===i.shape[0],function(){return"The first dimension of `a` must match the size of `condition`."}),a.rank!==1&&Ue(a.shape,l.shape,"Error in where: ");var u=function(h,d){var p=h.select(a,o,l);return d([a]),p},c={condition:a,t:o,e:l};return z.runKernelFunc(u,c,null,pu)}var hn=U({where_:L1});function I1(n){var t=O(n,"x","zerosLike"),e={x:t};return z.runKernelFunc(function(i){return i.zerosLike(t)},e,null,Fu)}var Ee=U({zerosLike_:I1});function A1(n,t){var e,i=O(n,"a","div"),r=O(t,"b","div");e=rt(i,r),i=e[0],r=e[1];var a=Ie(i,r),s=Ee(a),o=Aa(r,s);return hn(o,s,a)}var ng=U({divNoNan_:A1});function T1(n,t){var e=O(n,"t1","dot"),i=O(t,"t2","dot");E((e.rank===1||e.rank===2)&&(i.rank===1||i
rank`+a.rank+"."}),E(it(t),function(){return"Error in localResponseNormalization: depthRadius must be an "+("integer but got depthRadius "+t+".")});var s=a,o=!1;a.rank===3&&(o=!0,s=V(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var l=function(d,p){var f=d.localResponseNormalization4D(s,t,e,i,r);return p([s,f]),f},u={x:s},c={depthRadius:t,bias:e,alpha:i,beta:r},h=z.runKernelFunc(l,u,null,Vl,c);return o?V(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var dg=U({localResponseNormalization_:X1});function J1(n){var t=O(n,"x","log"),e={x:t};return z.runKernelFunc(function(i,r){var a=i.log(t);return r([t]),a},e,null,_l)}var _i=U({log_:J1});function Z1(n){var t=O(n,"x","log1p"),e={x:t};return z.runKernelFunc(function(i,r){var a=i.log1p(t);return r([t]),a},e,null,Ml)}var Cc=U({log1p_:Z1});function Q1(n){return E(ti(n),function(){return"The f passed in grad(f) must be a function"}),function(t,e){var i=O(t,"x","tf.grad",null),r=e!=null?O(e,"dy","tf.grad"):null;return z.tidy(function(){var a=z.gradients(function(){return n(i)},[i],r),s=a.value,o=a.grads;return r!=null&&Ue(s.shape,r.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Us(o),o[0]})}}function eN(n){return E(ti(n),function(){return"The f passed in grads(f) must be a function"}),function(t,e){E(Array.isArray(t),function(){return"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"});var i=va(t,"args","tf.grads",null),r=e!=null?O(e,"dy","tf.grads"):null;return z.tidy(function(){var a=z.gradients(function(){return n.apply(void 0,i)},i,r),s=a.value,o=a.grads;return r!=null&&Ue(s.shape,r.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Us(o),o})}}function tN(n){return E(ti(n),function(){return"The f passed in valueAndGrad(f) must be a function"}),function(t,e){E(t instanceof Y,function(){return"The x passed in valueAndGrad(f)(x) must be a tensor"}),E(e==null||e instanceof Y,function(){return"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"});var i=z.gradients(function(){return n(t)},[t],e),r=i.grads,a=i.value;return Us(r),{grad:r[0],value:a}}}function nN(n){return E(ti(n),function(){return"The f passed in valueAndGrads(f) must be a function"}),function(t,e){E(Array.isArray(t)&&t.every(function(r){return r instanceof Y}),function(){return"The args passed in valueAndGrads(f)(args) must be array of tensors"}),E(e==null||e instanceof Y,function(){return"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"});var i=z.gradients(function(){return n.apply(void 0,t)},t,e);return e!=null&&Ue(i.value.shape,e.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Us(i.grads),i}}function pg(n,t){E(ti(n),function(){return"The f passed in variableGrads(f) must be a function"}),E(t==null||Array.isArray(t)&&t.every(function(h){return h instanceof ga}),function(){return"The varList passed in variableGrads(f, varList) must be an array of variables"});var e=t!=null;if(!e){t=[];for(var i in z.registeredVariables)t.push(z.registeredVariables[i])}var r=e?t.filter(function(h){return!h.trainable}):null,a=t.length;t=t.filter(function(h){return h.trainable}),E(t.length>0,function(){return"variableGrads() expects at least one of the input variables to "+("be trainable, but none of the "+a+" variables is ")+"trainable."});var s=!0,o=z.gradients(n,t,null,s),l=o.value,u=o.grads;E(u.some(function(h){return h!=null}),function(){return"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()."}),E(l.rank===0,function(){return"The f passed in variableGrads(f) must return a scalar, but it "+("returned a rank-"+l.rank+" tensor")});var c={};return t.forEach(function(h,d){u[d]!=null&&(c[h.name]=u[d])}),r!=null&&r.forEach(function(h){return c[h.name]=null}),{value:l,grads:c}}function En(n){return z.customGrad(n)}function Us(n){var t=n.filter(function(e){return e==null}).length;if(t>0)throw ne
thefyoupassedenclosesalloperationsthatleadfromxtoy.`)}function iN(n){var t=O(n,"x","neg"),e={x:t};return z.runKernelFunc(function(i){return i.neg(t)},e,null,Zl)}var mt=U({neg_:iN});function rN(n){var t=O(n,"x","softplus"),e={x:t};return z.runKernelFunc(function(i,r){var a=i.softplus(t);return r([t]),a},e,null,wu)}var Rc=U({softplus_:rN});function aN(n){var t=O(n,"x","logSigmoid"),e=En(function(i){var r=mt(Rc(mt(i))),a=function(s){var o=J(s,Bi(mt(i)));return o};return{value:r,gradFunc:a}});return e(t)}var fg=U({logSigmoid_:aN});function sN(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var i=O(n,"x","max"),r=function(o,l){var u=Ze(t,i.shape),c=u,h=Qt(c,i.rank),d=i;h!=null&&(d=lt(i,h),c=Rn(c.length,d.rank));var p=o.max(d,c);h!=null&&d.dispose();var f=p;if(e){var m=Zt(f.shape,Ze(t,i.shape));f=V(f,m),p.dispose()}return l([i,f]),f},a={x:i},s={reductionIndices:t,keepDims:e};return z.runKernelFunc(r,a,null,ql,s)}var Mi=U({max_:sN});function oN(n,t){var e,i=O(n,"a","sub"),r=O(t,"b","sub");e=rt(i,r),i=e[0],r=e[1];var a=function(o,l){var u=o.subtract(i,r);return l([i,r]),u},s={a:i,b:r};return z.runKernelFunc(a,s,null,xu)}var ge=U({sub_:oN});function lN(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var i=O(n,"x","sum");i.dtype==="bool"&&(i=ue(i,"int32"));var r=function(o,l){l([i]);var u=Ze(t,i.shape),c=Qt(u,i.rank),h=u,d=i;c!=null&&(d=lt(i,c),h=Rn(h.length,i.rank));var p=o.sum(d,h);if(e){var f=Zt(p.shape,u);p=V(p,f)}return p},a={x:i},s={axis:t,keepDims:e};return z.runKernelFunc(r,a,null,Lu,s)}var Ae=U({sum_:lN});function uN(n,t){t===void 0&&(t=-1);var e=O(n,"logits","logSoftmax");if(t===-1&&(t=e.rank-1),t!==e.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. "+("Logits was rank "+e.rank+" and axis was "+t));var i=function(s,o){var l=!0,u=Mi(n,t,!0),c=ge(n,u),h=ge(ue(c,"float32"),_i(Ae(dn(c),t,l)));return o([h]),h},r={logits:e},a={axis:t};return z.runKernelFunc(i,r,null,Hl,a)}var mg=U({logSoftmax_:uN});function cN(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var i=O(n,"x","logSumExp"),r=Ze(t,i.shape),a=Mi(i,r,!0),s=ge(i,a),o=dn(s),l=Ae(o,r),u=_i(l),c=fe(V(a,u.shape),u);if(e){var h=Zt(c.shape,r);return V(c,h)}return c}var Oc=U({logSumExp_:cN});function hN(n,t){var e=O(n,"a","logicalAnd","bool"),i=O(t,"b","logicalAnd","bool");Qe(e.shape,i.shape);var r={a:e,b:i};return z.runKernelFunc(function(a){return a.logicalAnd(e,i)},r,null,sf)}var Hi=U({logicalAnd_:hN});function dN(n){var t=O(n,"x","logicalNot","bool"),e={x:t};return z.runKernelFunc(function(i){return i.logicalNot(t)},e,null,of)}var Bs=U({logicalNot_:dN});function pN(n,t){var e=O(n,"a","logicalOr","bool"),i=O(t,"b","logicalOr","bool");Qe(e.shape,i.shape);var r={a:e,b:i};return z.runKernelFunc(function(a){return a.logicalOr(e,i)},r,null,lf)}var Ec=U({logicalOr_:pN});function fN(n,t){var e=O(n,"a","logicalXor","bool"),i=O(t,"b","logicalXor","bool");return Qe(e.shape,i.shape),Hi(Ec(n,t),Bs(Hi(n,t)))}var gg=U({logicalXor_:fN});function mN(n,t,e,i,r){var a=O(n,"x","maxPool"),s=1,o=a,l=!1;a.rank===3&&(l=!0,o=V(a,[1,a.shape[0],a.shape[1],a.shape[2]])),E(o.rank===4,function(){return"Error in maxPool: input must be rank 4 but got rank "+o.rank+"."}),E(zt(e,s),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+e+" and dilations '"+s+"'")}),r!=null&&E(it(i),function(){return"Error in maxPool: pad must be an integer when using, "+("dimRoundingMode "+r+" but got pad "+i+".")});var u=function(p,f){var m=xr(o.shape,t,e,1,i,r),g;return m.filterWidth===1&&m.filterHeight===1&&sn(m.inShape,m.outShape)?g=o.clone():g=p.maxPool(o,m),f([o,g]),g},c={x:o},h={filterSize:t,strides:e,pad:i,dimRoundingMode:r},d=z.runKernelFunc(u,c,null,Yl,h);return l?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Dc=U({maxPool_:mN});function gN(n,t,e,i,r,a,s){t===void 0&&(t=[1,1,1]),a===void 0&&(a="NDHWC"),s==null?s=[1,1,1]:Lt("dilations is deprecated, this field will be gone in v3.0.0.");var o=O(n,"x","maxPool3d"),l=o,u=!1;o.rank===4&&(u=!0,l=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),E(l.rank===5,function(){return"Error i
`+("1. The "+i+" is defined in Python, in which ")+`caseitneedstobeportedtoTensorFlow.jsoryourJavaScriptcode.
`+("2. The custom "+i+" is defined in JavaScript, ")+"but is not registered properly with tf.serialization.registerClass().");return u}else{var c=n;if(c.className==null||c.config==null)throw new M(i+": Improper config format: "+(JSON.stringify(c)+`.
`)+"'className' and 'config' must set.");var h=c.className,d=void 0,p=void 0;if(h in e?(a=e[h],d=a[0],p=a[1]):h in on?(s=on.className,d=s[0],p=s[1]):h in t&&(o=t[h],d=o[0],p=o[1]),d==null)throw new M("Unknown "+i+": "+h+`.Thismaybeduetooneofthefollowingreasons:
`+("1. The "+i+" is defined in Python, in which ")+`caseitneedstobeportedtoTensorFlow.jsoryourJavaScriptcode.
`+("2. The custom "+i+" is defined in JavaScript, ")+"but is not registered properly with tf.serialization.registerClass().");if(p!=null){for(var f={},m=0,g=Object.keys(on);m<g.length;m++){var v=g[m];f[v]=on[v]}for(var b=0,w=Object.keys(e);b<w.length;b++){var v=w[b];f[v]=e[v]}var S=c.config;S.customObjects=f;for(var L=qt({},on),x=0,C=Object.keys(e);x<C.length;x++){var v=C[x];on[v]=e[v]}rh(c.config);var R=p(d,c.config,e,r);return on=qt({},L),R}else{for(var L=qt({},on),D=0,k=Object.keys(e);D<k.length;D++){var v=k[D];on[v]=e[v]}var R=new d(c.config);return on=qt({},L),R}}}function MD(n,t){return n<t?-1:n>t?1:0}function Qs(n,t){return-1*MD(n,t)}function di(n){if(n==null)return n;for(var t=[],e=0,i=n;e<i.length;e++){var r=i[e];t.indexOf(r)===-1&&t.push(r)}return t}function HD(n){if(n==null)throw new M("Invalid value in obj: "+JSON.stringify(n));for(var t in n)if(n.hasOwnProperty(t))return!1;return!0}function zr(n,t,e){if(e==null)return;if(n.indexOf(e)<0)throw new M(e+" is not a valid "+t+". Valid values are "+n+" or null/undefined.")}function ah(n,t,e,i){return e===void 0&&(e=0),i===void 0&&(i=Infinity),kn(e>=0),kn(i>=e),Array.isArray(n)&&n.length>=e&&n.length<=i&&n.every(function(r){return typeof r===t})}function It(n,t){Array.isArray(n)?(y.util.assert(n.length>0,function(){return t+" is unexpectedly an empty array."}),n.forEach(function(e,i){return It(e,"element "+(i+1)+" of "+t)})):y.util.assert(Number.isInteger(n)&&n>0,function(){return"Expected "+t+" to be a positive integer, but got "+(yv(n)+".")})}function yv(n){return n===null?"null":Array.isArray(n)?"["+n.map(function(t){return yv(t)}).join(",")+"]":typeof n=="string"?'"'+n+'"':""+n}function VD(n,t){var e=y.util.now(),i,r=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var o=y.util.now();return o-e<t||(e=o,i=n.apply(void 0,a)),i};return r}function bv(n){return n==="relu"?"relu":n==="linear"?"linear":n==="elu"?"elu":null}function sh(n,t){return y.tidy(function(){return y.sqrt(y.sum(y.mul(n,n),t,!0))})}var Ea=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getConfig=function(){return{}},t}(y.serialization.Serializable),wv=function(n){Q(t,n);function t(e){var i=n.call(this)||this;return i.defaultMaxValue=2,i.defaultAxis=0,i.maxValue=e.maxValue!=null?e.maxValue:i.defaultMaxValue,i.axis=e.axis!=null?e.axis:i.defaultAxis,i}return t.prototype.apply=function(e){var i=this;return y.tidy(function(){var r=sh(e,i.axis),a=y.clipByValue(r,0,i.maxValue);return y.mul(e,y.div(a,y.add(gt(),r)))})},t.prototype.getConfig=function(){return{maxValue:this.maxValue,axis:this.axis}},t.className="MaxNorm",t}(Ea);y.serialization.registerClass(wv);var Sv=function(n){Q(t,n);function t(e){var i=n.call(this)||this;return i.defaultAxis=0,i.axis=e.axis!=null?e.axis:i.defaultAxis,i}return t.prototype.apply=function(e){var i=this;return y.tidy(function(){return y.div(e,y.add(gt(),sh(e,i.axis)))})},t.prototype.getConfig=function(){return{axis:this.axis}},t.className="UnitNorm",t}(Ea);y.serialization.registerClass(Sv);var Lv=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.apply=function(e){return y.relu(e)},t.className="NonNeg",t}(Ea);y.serialization.registerClass(Lv);var Iv=function(n){Q(t,n);function t(e){var i=n.call(this)||this;return i.defaultMinValue=0,i.defaultMaxValue=1,i.defaultRate=1,i.defaultAxis=0,i.minValue=e.minValue!=null?e.minValue:i.defaultMinValue,i.maxValue=e.maxValue!=null?e.maxValue:i.defaultMaxValue,i.rate=e.rate!=null?e.rate:i.defaultRate,i.axis=e.axis!=null?e.axis:i.defaultAxis,i}return t.prototype.apply=function(e){var i=this;return y.tidy(function(){var r=sh(e,i.axis),a=y.add(y.mul(i.rate,y.clipByValue(r,i.minValue,i.maxValue)),y.mul(1-i.rate,r));return y.mul(e,y.div(a,y.add(gt(),r)))})},t.prototype.getConfig=function(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}},t.className="MinMaxNorm",t}(Ea);y.serialization.registerClass(Iv);var Av={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};fun
becausethevaluedtypeis`+e.dtype+", but TensorArray dtype is "+this.dtype+".");if(this.size()===0&&(this.elementShape==null||this.elementShape.length===0)&&(this.elementShape=e.shape),un(this.elementShape,e.shape,"TensorArray "+this.name+": Could not write to TensorArray index "+t+"."),i.read)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+", because it has already been read.");if(i.written)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+", because it has already been written.");i.tensor=e,B.keep(e),i.written=!0,this.tensors[t]=i},n.prototype.writeMany=function(t,e){var i=this;if(t.length!==e.length)throw new Error("TensorArray "+this.name+": could not write multiple tensors,"+("because the index size: "+t.length+" is not the same as tensors size: "+e.length+"."));t.forEach(function(r,a){return i.write(r,e[a])})},n.prototype.gather=function(t,e){if(!!e&&e!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but gather requested dtype "+e);if(t)t=t.slice(0,this.size());else{t=[];for(var i=0;i<this.size();i++)t.push(i)}if(t.length===0)return B.tensor([],[0].concat(this.elementShape));var r=this.readMany(t);return un(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),B.stack(r,0)},n.prototype.concat=function(t){if(!!t&&t!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but concat requested dtype "+t);if(this.size()===0)return B.tensor([],[0].concat(this.elementShape));for(var e=[],i=0;i<this.size();i++)e.push(i);var r=this.readMany(e);return un(this.elementShape,r[0].shape,"TensorArray shape mismatch: tensor array shape ("+this.elementShape+") vs first tensor shape ("+r[0].shape+")"),B.concat(r,0)},n.prototype.scatter=function(t,e){if(e.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+e.dtype);if(t.length!==e.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+t.length+" vs. "+e.shape[0]);var i=Math.max.apply(Math,t);if(!this.dynamicSize&&i>=this.maxSize)throw new Error("Max index must be < array size ("+i+" vs. "+this.maxSize+")");this.writeMany(t,B.unstack(e,0))},n.prototype.split=function(t,e){var i=this;if(e.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+e.dtype);var r=0,a=t.map(function(c){return r+=c,r});if(r!==e.shape[0])throw new Error(`Expectedsumoflengthstobeequalto
tensor.shape[0],butsumoflengthsis
`+r+", and tensor's shape is: "+e.shape);if(!this.dynamicSize&&t.length!==this.maxSize)throw new Error("TensorArray's size is not equal to the size of lengths ("+this.maxSize+" vs. "+t.length+"), and the TensorArray is not marked as dynamically resizeable");var s=r===0?0:e.size/r,o=[];B.tidy(function(){e=B.reshape(e,[1,r,s]);for(var c=0;c<t.length;++c){var h=c===0?0:a[c-1],d=[0,h,0],p=[1,t[c],s];o[c]=B.reshape(B.slice(e,d,p),i.elementShape)}return o});for(var l=[],u=0;u<t.length;u++)l[u]=u;this.writeMany(l,o)},n}();var Ao=function(){function n(t,e,i,r){r===void 0&&(r=-1),this.tensors=t,this.elementShape=e,this.elementDtype=i,t!=null&&t.forEach(function(a){if(i!==a.dtype)throw new Error("Invalid data types; op elements "+i+", but list elements "+a.dtype);un(e,a.shape,"TensorList shape mismatch: "),B.keep(a)}),this.idTensor=B.scalar(0),this.maxNumElements=r,B.keep(this.idTensor)}return Object.defineProperty(n.prototype,"id",{get:function(){return this.idTensor.id},enumerable:!0,configurable:!0}),n.prototype.copy=function(){return new n(this.tensors.slice(),this.elementShape,this.elementDtype)},n.prototype.clearAndClose=function(t){this.tensors.forEach(function(e){(t==null||!t.has(e.id))&&e.dispose()}),this.tensors.length=0,this.idTensor.dispose()},n.prototype.size=function(){return this.tensors.length},n.prototype.stack=function(t,e,i){var r=this;if(i===void 0&&(i=-1),e!==this.elementDtype)throw new Error("Invalid data types; op elements "+e+", but list elements "+this.elementDtype);if(i!==-1&&this.tensors.length!==i)throw new Error("Operation expected a list with "+i+" elements but got a list with "+this.tensors.length+" elements.");return un(t,this.elementShape,"TensorList shape mismatch: "),B.tidy(function(){var a=r.tensors.map(function(s){return B.reshape(s,t)});return B.stack(a,0)})},n.prototype.popBack=function(t,e){if(e!==this.elementDtype)throw new Error("Invalid data types; op elements "+e+", but list elements "+this.elementDtype);if(this.size()===0)throw new Error("Trying to pop from an empty list.");var i=this.tensors.pop();return un(i.shape,t,"TensorList shape mismatch: "),B.reshape(i,t)},n.prototype.pushBack=function(t){if(t.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+t.dtype+", but list elements "+this.elementDtype);if(un(t.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");B.keep(t),this.tensors.push(t)},n.prototype.resize=function(t){if(t<0)throw new Error("TensorListResize expects size to be non-negative. Got: "+t);if(this.maxNumElements!==-1&&t>this.maxNumElements)throw new Error("TensorListResize input size "+t+" is greater maxNumElement "+this.maxNumElements+".");this.tensors.length=t},n.prototype.getItem=function(t,e,i){if(i!==this.elementDtype)throw new Error("Invalid data types; op elements "+i+", but list elements "+this.elementDtype);if(t<0||t>this.tensors.length)throw new Error("Trying to access element "+t+" in a list with "+this.tensors.length+" elements.");if(this.tensors[t]==null)throw new Error("element at index "+t+" is null.");return un(this.tensors[t].shape,e,"TensorList shape mismatch: "),this.tensors[t]},n.prototype.setItem=function(t,e){if(e.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+e.dtype+", but list elements "+this.elementDtype);if(t<0||this.maxNumElements!==-1&&t>=this.maxNumElements)throw new Error("Trying to set element "+t+" in a list with max "+this.maxNumElements+" elements.");un(this.elementShape,e.shape,"TensorList shape mismatch: "),B.keep(e),this.tensors[t]=e},n.prototype.gather=function(t,e,i){var r=this;if(e!==this.elementDtype)throw new Error("Invalid data types; op elements "+e+", but list elements "+this.elementDtype);return un(this.elementShape,i,"TensorList shape mismatch: "),t=t.slice(0,this.size()),t.length===0?B.tensor([],[0].concat(this.elementShape)):B.tidy(function(){var a=t.map(function(s){return B.reshape(r.tensors[s],i)});return B.stack(a,0)})},n.prototype.concat=function(t,e){var i=thi
`).map(function(s){return s.endsWith("\r")&&(s=s.slice(0,-1)),s}),[2,r]}})})},t}(qa);var No='"',Ga=Symbol("out"),gw=Symbol("field"),xo=Symbol("quote"),ud=Symbol("quoteafterquote"),vw=Symbol("quoteinquote"),yw=function(n){He(t,n);function t(e,i){var r=n.call(this)||this;return r.input=e,r.hasHeader=!0,r.fullColumnNames=null,r.columnNamesValidated=!1,r.columnConfigs=null,r.configuredColumnsOnly=!1,r.delimiter=",",r.delimWhitespace=!1,r.base=new mw(e),i||(i={}),r.hasHeader=!(i.hasHeader===!1),r.fullColumnNames=i.columnNames,r.columnConfigs=i.columnConfigs,r.configuredColumnsOnly=i.configuredColumnsOnly,i.delimWhitespace?(Ne.util.assert(i.delimiter==null,function(){return"Delimiter should not be provided when delimWhitespace is true."}),r.delimWhitespace=!0,r.delimiter=" "):r.delimiter=i.delimiter?i.delimiter:",",r}return t.prototype.columnNames=function(){return se(this,void 0,void 0,function(){return oe(this,function(e){switch(e.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:e.sent(),e.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}})})},t.prototype.setColumnNames=function(){return se(this,void 0,void 0,function(){var e,i,r,a,s,o,l,u=this;return oe(this,function(c){switch(c.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(e=c.sent(),!this.fullColumnNames&&!e)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&e&&Ne.util.assert(e.length===this.fullColumnNames.length,function(){return"The length of provided columnNames ("+u.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+")."}),this.fullColumnNames||(this.fullColumnNames=e),i=this.fullColumnNames.reduce(function(h,d){return h[d]=h[d]+1||1,h},{}),r=Object.keys(i).filter(function(h){return i[h]>1}),Ne.util.assert(r.length===0,function(){return"Duplicate column names found: "+r.toString()}),this.columnConfigs){for(a=0,s=Object.keys(this.columnConfigs);a<s.length;a++)if(o=s[a],l=this.fullColumnNames.indexOf(o),l===-1)throw new Error('The key "'+o+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}return this.columnNamesValidated=!0,[2]}})})},t.prototype.maybeReadHeaderLine=function(){return se(this,void 0,void 0,function(){var e,i,r,a;return oe(this,function(s){switch(s.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return e=s.sent(),[4,e.next()];case 2:if(i=s.sent(),i.done)throw new Error("No data was found for CSV parsing.");return r=i.value,a=this.parseRow(r,!1),[2,a];case 3:return[2,null]}})})},t.prototype.iterator=function(){return se(this,void 0,void 0,function(){var e,i=this;return oe(this,function(r){switch(r.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:r.sent(),r.label=2;case 2:return[4,this.base.iterator()];case 3:return e=r.sent(),this.hasHeader&&(e=e.skip(1)),[2,e.map(function(a){return i.makeDataElement(a)})]}})})},t.prototype.makeDataElement=function(e){for(var i=this.parseRow(e),r={},a={},s=0;s<this.fullColumnNames.length;s++){var o=this.fullColumnNames[s],l=this.columnConfigs?this.columnConfigs[o]:null;if(this.configuredColumnsOnly&&!l)continue;var u=i[s],c=null;if(u==="")if(l&&l.default!==void 0)c=l.default;else{if(l&&(l.required||l.isLabel))throw new Error("Required column "+o+" is empty in this line: "+e);c=void 0}else{var h=Number(u);if(isNaN(h))l&&l.dtype==="bool"?c=this.getBoolean(u):c=u;else if(!l||!l.dtype)c=h;else switch(l.dtype){case"float32":c=h;break;case"int32":c=Math.floor(h);break;case"bool":c=this.getBoolean(u);break;default:c=h}}l&&l.isLabel?a[o]=c:r[o]=c}return Object.keys(a).length===0?r:{xs:r,ys:a}},t.prototype.getBoolean=function(e){return e==="1"||e.toLowerCase()==="true"?1:0},t.prototype.parseRow=function(e,i){i===void 0&&(i=!0);for(var r=[],a=0,s=e.length,o=Ga,l=0;l<s;l++)switch(o){case Ga:switch(e.charAt(l)){case No:a=l+1,o=xo;break;case this.delimiter:if(a=l+1,this.delimiter===" "&&this
============================
Hithere👋.LookslikeyouarerunningTensorFlow.jsinNode.js.Tospeedthingsupdramatically,installournodebackend,whichbindstoTensorFlowC++,byrunningnpmi@tensorflow/tfjs-node,ornpmi@tensorflow/tfjs-node-gpuifyouhaveCUDA.Thencallrequire('@tensorflow/tfjs-node');(-gpusuffixforCUDA)atthestartofyourprogram.Visithttps://github.com/tensorflow/tfjs-node for more details.
============================`));var a={};return this.data.set(a,{values:e,dtype:r,refCount:1}),a},t.prototype.makeTensorInfo=function(e,i,r){var a=this.write(r,e,i);return{dataId:a,shape:e,dtype:i}},t.prototype.incRef=function(e){var i=this.data.get(e);i.refCount++},t.prototype.decRef=function(e){if(this.data.has(e)){var i=this.data.get(e);i.refCount--}},t.prototype.move=function(e,i,r,a){this.data.set(e,{values:i,dtype:a,refCount:1})},t.prototype.numDataIds=function(){return this.data.numDataIds()},t.prototype.read=function(e){return Mw(this,void 0,void 0,function(){return Hw(this,function(i){return[2,this.readSync(e)]})})},t.prototype.readSync=function(e){var i=this.data.get(e),r=i.dtype,a=i.complexTensorInfos;if(r==="complex64"){var s=this.readSync(a.real.dataId),o=this.readSync(a.imag.dataId);return T.backend_util.mergeRealAndImagArrays(s,o)}return this.data.get(e).values},t.prototype.bufferSync=function(e){var i=this.readSync(e.dataId),r=i;if(e.dtype==="string")try{r=i.map(function(a){return T.util.decodeString(a)})}catch(a){throw new Error("Failed to decode encoded string bytes into utf-8")}return T.buffer(e.shape,e.dtype,r)},t.prototype.makeOutput=function(e,i,r){var a=this.write(e,i,r);return T.engine().makeTensorFromDataId(a,i,r,this)},t.prototype.disposeData=function(e){if(this.data.has(e)){var i=this.data.get(e).complexTensorInfos;i!=null&&(this.disposeData(i.real.dataId),this.disposeData(i.imag.dataId)),this.data.delete(e)}},t.prototype.disposeIntermediateTensorInfo=function(e){var i=e.dataId;if(this.data.has(i)){var r=this.data.get(i);r.refCount--,r.refCount<1&&this.disposeData(i)}},t.prototype.time=function(e){return Mw(this,void 0,void 0,function(){var i,r;return Hw(this,function(a){return i=T.util.now(),e(),r=T.util.now()-i,[2,{kernelMs:r}]})})},t.prototype.memory=function(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}},t.prototype.stridedSlice=function(e,i,r,a){ae(e,"stridedSlice");var s=T.slice_util.computeOutShape(i,r,a);if(s.some(function(p){return p===0}))return T.tensor([],s);for(var o=T.buffer(s,e.dtype),l=this.bufferSync(e),u=0;u<o.size;u++){for(var c=o.indexToLoc(u),h=new Array(c.length),d=0;d<h.length;d++)h[d]=c[d]*a[d]+i[d];o.set.apply(o,[l.get.apply(l,h)].concat(c))}return o.toTensor()},t.prototype.diag=function(e){for(var i=this.readSync(e.dataId),r=T.buffer([e.size,e.size],e.dtype),a=r.values,s=0;s<i.length;s++)a[s*e.size+s]=i[s];return r.toTensor()},t.prototype.unstack=function(e,i){for(var r=e.shape[i],a=new Array(e.rank-1),s=0,o=0;o<e.rank;o++)o!==i&&(a[s++]=e.shape[o]);var l=new Array(e.rank).fill(0),u=e.shape.slice();u[i]=1;for(var c=new Array(r),o=0;o<c.length;o++)l[i]=o,c[o]=T.slice(e,l,u).reshape(a);return c},t.prototype.reverse=function(e,i){ae(e,"reverse");for(var r=T.buffer(e.shape,e.dtype),a=this.bufferSync(e),s=function(l){var u=r.indexToLoc(l),c=u.slice();i.forEach(function(h){return c[h]=e.shape[h]-1-c[h]}),r.set.apply(r,[a.get.apply(a,c)].concat(u))},o=0;o<r.size;o++)s(o);return r.toTensor()},t.prototype.neg=function(e){return ae(e,"neg"),T.mul(T.scalar(-1),e)},t.prototype.addN=function(e){var i=this;ae(e,"addN");for(var r=e.map(function(c){return i.readSync(c.dataId)}),a=T.buffer(e[0].shape,e[0].dtype),s=a.values,o=0;o<e.length;o++)for(var l=r[o],u=0;u<s.length;u++)s[u]+=l[u];return a.toTensor()},t.prototype.softmax=function(e,i){var r=T.util.parseAxisParam([i],e.shape),a=T.max(e,r),s=T.backend_util.expandShapeToKeepDim(a.shape,r),o=T.sub(e,a.reshape(s)),l=T.exp(o),u=this.sum(l,r).reshape(s);return T.div(l,u)},t.prototype.pow=function(e,i){return ae([e,i],"pow"),this.broadcastedBinaryOp(e,i,e.dtype,function(r,a){return Math.pow(r,a)})},t.prototype.batchMatMul=function(e,i,r,a){ae([e,i],"matMul");for(var s=r?e.shape[1]:e.shape[2],o=r?e.shape[2]:e.shape[1],l=a?i.shape[1]:i.shape[2],u=e.shape[0],c=this.readSync(e.dataId),h=this.readSync(i.dataId),d=r?[e.strides[0],1,e.strides[1]]:[e.strides[0],e.strides[1],1],p=d[0],f=d[1],m=d[2],g=a?[1,i.strides[1],i.strides[0]]:[i.strides[
returnmod(a,b);`,FM="return (b >= 1.0) ? a : a * (b + 1.0);",j0="return (a < 0.) ? b * a : a;",bt=function(){function n(t,e,i){this.variableNames=["A","B"],this.outputShape=N.backend_util.assertAndGetBroadcastShape(e,i),this.userCode=`
`}return n.prototype.getCustomSetupFunc=function(t){var e=this;return function(i,r){e.index==null&&(e.index=i.getUniformLocation(r,"index")),i.gl.uniform1f(e.index,t)}},n}();function Q0(n,t){if(n===1)return""+t;if(n===2)return t+".x, "+t+".y";if(n===3)return t+".x, "+t+".y, "+t+".z";if(n===4)return t+".x, "+t+".y, "+t+".z, "+t+".w";throw Error("Cumulative sum for rank "+n+" is not yet supported")}function eS(n,t){if(n===1)return""+t;if(n===2)return t+".y";if(n===3)return t+".z";if(n===4)return t+".w";throw Error("Cumulative sum for rank "+n+" is not yet supported")}var l5=function(){function n(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=Xa.DENSE;var e=Za(t),i=Dt();this.outputShape=t,this.userCode=`
`}return n}();var Y5=function(){function n(t,e){this.variableNames=["x"];var i=t.length;if(i>4)throw new Error("WebGL backend: Reverse of rank-"+i+" tensor is not yet supported");if(this.outputShape=t,i===1){this.userCode=`
`}return n}();var $5=function(){function n(t,e,i){this.variableNames=["c","a","b"],this.outputShape=e;var r,a;if(i>4)throw Error("Where for rank "+i+" is not yet supported");if(i===1)a="resRC",r="resRC";else{for(var s=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],l=[],u=0;u<e.length;u++)l.push(""+s[u]),u<t&&o.push(""+s[u]);r=o.join(),a=l.join()}var c=Je(i);this.userCode=`
`}return n.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the "+("length of start ("+t.length+")"));return function(i,r){if(e.startLoc==null&&(e.startLoc=i.getUniformLocationNoThrow(r,"start"),e.startLoc==null))return;i.gl.uniform1iv(e.startLoc,t)}},n}(),Vd=["x","y","z","w","u","v"];function X5(n){if(n===1)return"sourceLoc";if(n<=6)return Vd.slice(0,n).map(function(t){return"sourceLoc."+t}).join(",");throw Error("Slicing for rank "+n+" is not yet supported")}var Z5=function(){function n(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length;var e=Je(this.rank),i=$t("coords",this.rank),r=$t("sourceLoc",this.rank),a=this.rank===1?"sourceLoc":"vec2("+r.slice(-2).join()+")",s="getChannel(getSource("+r.join()+"), "+a+")",o=`
`}return n.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the "+("length of start ("+t.length+")"));return function(i,r){if(e.startLoc==null&&(e.startLoc=i.getUniformLocationNoThrow(r,"start"),e.startLoc==null))return;i.gl.uniform1iv(e.startLoc,t)}},n}();var Q5=function(){function n(t,e,i){this.variableNames=["x"],this.outputShape=i;var r=i.length,a=Je(i.length),s=Je(i.length),o="";if(r===1)o="coords * strides + begin";else{var l=0;o=i.map(function(u,c){return l++,i.length===1?"coords * strides["+c+"] + begin["+c+"]":"coords["+(l-1)+"] * strides["+c+"] + begin["+c+"]"}).join(",")}this.userCode=`
`}return n}();var _S=N.backend_util.segment_util,U9=N.kernel_impls.split,B9=N.kernel_impls.tile,z9=N.kernel_impls.topkImpl,P9=N.kernel_impls.whereImpl,_9=1e-7,M9=1e-4,Mo={};function H9(n){return n in Mo||(Mo[n]={}),Mo[n]}function Ho(n,t){if(t===void 0&&(t=!1),n==="linear")return t?k9:s9;if(n==="relu")return t?BS:RS;if(n==="elu")return t?PS:ES;if(n==="relu6")return t?zS:OS;if(n==="prelu")return t?$0:j0;throw new Error("Activation "+n+" has not been implemented for the WebGL backend.")}var V9=128,q9=600;function G9(){return N.env().global.screen==null?1024:N.env().global.screen.height*N.env().global.screen.width*window.devicePixelRatio*q9/1024/1024}var MS=1e3,HS=function(n){HP(t,n);function t(e){var i=n.call(this)||this;if(i.pendingRead=new WeakMap,i.pendingDisposal=new WeakSet,i.dataRefCount=new WeakMap,i.numBytesInGPU=0,i.uploadWaitMs=0,i.downloadWaitMs=0,i.warnedAboutMemory=!1,i.warnedAboutCPUBackend=!1,i.pendingDeletes=0,i.disposed=!1,!N.env().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(e==null){var r=zn(N.env().getNumber("WEBGL_VERSION"));i.binaryCache=H9(N.env().getNumber("WEBGL_VERSION")),i.gpgpu=new wS(r),i.canvas=r.canvas,i.gpgpuCreatedLocally=!0}else i.gpgpu=e,i.binaryCache={},i.gpgpuCreatedLocally=!1,i.canvas=e.gl.canvas;return i.textureManager=new e9(i.gpgpu),i.numMBBeforeWarning=G9(),i.texData=new N.DataStorage(i,N.engine()),i}return t.prototype.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes},t.prototype.write=function(e,i,r){if((N.env().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||N.env().getBool("DEBUG"))&&this.checkNumericalProblems(e),r==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var a={};return this.texData.set(a,{shape:i,dtype:r,values:e,usage:tn.UPLOAD,refCount:1}),a},t.prototype.incRef=function(e){var i=this.texData.get(e);i.refCount++},t.prototype.decRef=function(e){if(this.texData.has(e)){var i=this.texData.get(e);i.refCount--}},t.prototype.move=function(e,i,r,a){if(N.env().getBool("DEBUG")&&this.checkNumericalProblems(i),a==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:r,dtype:a,values:i,usage:tn.UPLOAD,refCount:1})},t.prototype.disposeIntermediateTensorInfo=function(e){var i=e.dataId;if(this.texData.has(i)){var r=this.texData.get(i);r.refCount--,r.refCount<1&&this.disposeData(i)}},t.prototype.readSync=function(e){var i=this.texData.get(e),r=i.values,a=i.dtype,s=i.complexTensors,o=i.slice,l=i.shape,u=i.isPacked;if(o!=null){var c=void 0;u?c=new rs(l,_o):c=new Re(l,_o);var h=this.runWebGLProgram(c,[{dataId:e,shape:l,dtype:a}],a),d=this.readSync(h.dataId);return this.disposeIntermediateTensorInfo(h),d}if(r!=null)return this.convertAndCacheOnCPU(e);if(a==="string")return r;var p=this.activeTimers!=null,f;p&&(f=N.util.now());var m;if(a==="complex64"){var g=s.real.dataSync(),v=s.imag.dataSync();m=N.backend_util.mergeRealAndImagArrays(g,v)}else m=this.getValuesFromTexture(e);return p&&(this.downloadWaitMs+=N.util.now()-f),this.convertAndCacheOnCPU(e,m)},t.prototype.read=function(e){return Oo(this,void 0,void 0,function(){var i,r,a,s,o,l,u,c,h,d,p,f,m,g,v,b,w,S,L,x,C,R;return Eo(this,function(D){switch(D.label){case 0:if(this.pendingRead.has(e))return i=this.pendingRead.get(e),[2,new Promise(function(k){return i.push(k)})];if(r=this.texData.get(e),a=r.values,s=r.shape,o=r.slice,l=r.dtype,u=r.complexTensors,c=r.isPacked,o!=null)return h=void 0,c?h=new rs(s,_o):h=new Re(s,_o),d=this.runWebGLProgram(h,[{dataId:e,shape:s,dtype:l}],l),p=this.read(d.dataId),this.disposeIntermediateTensorInfo(d),[2,p];if(a!=null)return[2,this.convertAndCacheOnCPU(e)];if(!N.env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&N.env().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");return f=null,l!=="complex64"&&N.env().get("WEBGL_BUFFER_SUPPORTED")&&(m=this.decode(e),g=this.texData.
`}return n}();var l6=function(n){var t=n.inputs,e=n.backend,i=n.attrs,r=t.x,a=t.mean,s=t.variance,o=t.offset,l=t.scale;N.util.assert(a.shape.length===s.shape.length,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),N.util.assert(o==null||a.shape.length===o.shape.length,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),N.util.assert(l==null||a.shape.length===l.shape.length,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var u=i.varianceEpsilon;u==null&&(u=.001);var c=[r,a,s],h=null;o!=null&&(h=o.shape,c.push(o));var d=null;l!=null&&(d=l.shape,c.push(l));var p=N.env().getBool("WEBGL_PACK_NORMALIZATION")?new o6(r.shape,a.shape,s.shape,h,d,u):new s6(r.shape,a.shape,s.shape,h,d,u),f=e.runWebGLProgram(p,c,c[0].dtype);return f},u6={kernelName:N.FusedBatchNorm,backendName:"webgl",kernelFunc:l6};var c6=qS+`
`}return n}();var L6={kernelName:N.FromPixels,backendName:"webgl",kernelFunc:S6},aa;function S6(n){var t=n.inputs,e=n.backend,i=n.attrs,r=t.pixels,a=i.numChannels,s=typeof HTMLVideoElement!="undefined"&&r instanceof HTMLVideoElement,o=typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement,l=s?[r.videoWidth,r.videoHeight]:[r.width,r.height],u=l[0],c=l[1],h=[c,u],d=[c,u,a];(o||s)&&(aa==null&&(aa=document.createElement("canvas").getContext("2d")),aa.canvas.width=u,aa.canvas.height=c,aa.drawImage(r,0,0,u,c),r=aa.canvas);var p=e.makeTensorInfo(h,"int32");e.texData.get(p.dataId).usage=tn.PIXELS,e.gpgpu.uploadPixelDataToTexture(e.getTexture(p.dataId),r);var f=N.env().getBool("WEBGL_PACK")?new w6(d):new b6(d),m=e.runWebGLProgram(f,[p],"int32");return e.disposeData(p.dataId),m}function I6(n){for(var t=[];t.length===0||t[t.length-1].outSize!==1;){var e=t.length?t[t.length-1].outSize:n[1],i=N.backend_util.computeOptimalWindowSize(e);t.push({inSize:e,windowSize:i,outSize:Math.ceil(e/i)})}return t}function A6(n,t,e,i){for(var r=I6(n.shape),a=n,s=0;s<r.length;s++){var o=r[s],l=o.inSize,u=o.windowSize,c=o.outSize,h=new LS({windowSize:u,inSize:l,batchSize:n.shape[0],outSize:c},e),d=a;a=i.runWebGLProgram(h,[a],t),d.dataId!==n.dataId&&i.disposeData(d.dataId)}return a}function T6(n,t,e){var i=[lr(n.shape)].concat(ur(n.shape)),r={dtype:n.dtype,shape:i,dataId:n.dataId},a=[lr(t)].concat(ur(t)),s=new IS(a,i),o=!0,l=e.runWebGLProgram(s,[r],n.dtype,null,o);return{dataId:l.dataId,shape:t,dtype:l.dtype}}function Yd(n){var t=n.inputs,e=n.backend,i=n.attrs,r=t.x,a=i.shape,s=e,o=N.util.sizeFromShape(r.shape),l=N.util.inferFromImplicitShape(a,o),u=N.util.sizeFromShape(l);N.util.assert(o===u,function(){return"The new shape ("+l+") has "+u+" elements and the old "+("shape ("+r.shape+") has "+o+" elements. The new shape and old ")+"shape must have the same number of elements."});var c=s.texData.get(r.dataId);return c.isPacked&&!ts(r.shape,l)&&!(c.texture!==null&&ts(c.shape,l))?T6(r,l,s):(s.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype})}var N6={kernelName:N.Reshape,backendName:"webgl",kernelFunc:Yd};function x6(n,t,e,i){var r=N.util.sizeFromShape(t),a=N.util.sizeFromShape(n.shape),s=a/r,o=Yd({inputs:{x:n},attrs:{shape:[s,r]},backend:i}),l=A6(o,n.dtype,"max",i),u=Yd({inputs:{x:l},attrs:{shape:e},backend:i});return i.disposeIntermediateTensorInfo(o),i.disposeIntermediateTensorInfo(l),u}var R6=function(){function n(t,e){this.variableNames=["A"];for(var i=new Array(t.length),r=0;r<i.length;r++)i[r]=t[e[r]];this.outputShape=i,this.rank=i.length;var a=Je(this.rank),s=C6(e);this.userCode=`
voidmain(){
`+a+`resRC=getOutputCoords();
setOutput(getA(`+s+`));
}
`}return n}();function C6(n){var t=n.length;if(t>6)throw Error("Transpose for rank "+t+" is not yet supported");for(var e=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],i=new Array(t),r=0;r<n.length;r++)i[n[r]]=e[r];return i.join()}var O6=function(){function n(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var i=new Array(t.length),r=0;r<i.length;r++)i[r]=t[e[r]];if(this.outputShape=i,this.rank=i.length,this.rank>6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");for(var a=Je(this.rank),s=P0("rc",this.rank),o=new Array(this.rank),r=0;r<e.length;r++)o[e[r]]=s[r];var l="vec2("+o.slice(-2).join()+")",u="++"+s[this.rank-1]+" < "+i[this.rank-1],c="getChannel(getA("+o.join()+"), "+l+")";this.userCode=`
voidmain(){
`+a+`rc=getOutputCoords();
vec4result=vec4(0.);
result[0]=`+c+`;
if(`+u+`){
result[1]=`+c+`;
}
--`+s[this.rank-1]+`;
if(++`+s[this.rank-2]+" < "+i[this.rank-2]+`){
result[2]=`+c+`;
if(`+u+`){
result[3]=`+c+`;
}
}
setOutput(result);
}
`}return n}();function GS(n,t,e){var i=N.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new O6(n.shape,t):new R6(n.shape,t);return e.runWebGLProgram(i,[n],n.dtype)}var E6={kernelName:N.Max,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.attrs,i=n.backend,r=t.x,a=e,s=a.reductionIndices,o=a.keepDims,l=i,u=r.shape.length,c=N.util.parseAxisParam(s,r.shape),h=c,d=N.backend_util.getAxesPermutation(h,u),p=d!=null,f=l.shouldExecuteOnCPU([r]),m=r;if(p){if(f){for(var g=l.texData.get(m.dataId),v=g.values,b=new Array(u),w=0;w<b.length;w++)b[w]=r.shape[d[w]];var S=z0(v,r.shape,r.dtype,d,b);m=l.makeTensorInfo(b,r.dtype);var L=l.texData.get(m.dataId);L.values=S}else m=GS(r,d,l);h=N.backend_util.getInnerMostAxes(h.length,u)}N.backend_util.assertAxesAreInnerMostDims("max",h,u);var x=N.backend_util.computeOutAndReduceShapes(m.shape,h),C=x[0],R=x[1],D=C;o&&(D=N.backend_util.expandShapeToKeepDim(C,c));var k;if(f){var g=l.texData.get(m.dataId),v=g.values,W=N_(v,N.util.sizeFromShape(R),D,r.dtype);k=l.makeTensorInfo(D,r.dtype);var F=l.texData.get(k.dataId);F.values=W}else k=x6(m,R,D,l);return p&&l.disposeIntermediateTensorInfo(m),k}};function D6(n){var t=n.inputs,e=n.backend,i=n.attrs,r=t.x;Qr(r,"maxPool");var a=i.filterSize,s=i.strides,o=i.pad,l=i.dimRoundingMode,u=1;N.util.assert(N.backend_util.eitherStridesOrDilationsAreOne(s,u),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+s+" and dilations '"+u+"'")});var c=N.backend_util.computePool2DInfo(r.shape,a,s,u,o,l);if(c.filterWidth===1&&c.filterHeight===1&&N.util.arraysEqual(c.inShape,c.outShape))return Gd({inputs:{x:r},backend:e});var h=new is(c,"max",!1);return e.runWebGLProgram(h,[r],r.dtype)}var k6={kernelName:N.MaxPool,backendName:"webgl",kernelFunc:D6};function F6(n){var t=n.inputs,e=n.backend,i=n.attrs,r=t.dy,a=t.input,s=t.output,o=a;Qr([a,s],"maxPoolBackprop");var l=i.filterSize,u=i.strides,c=i.pad,h=i.dimRoundingMode,d=N.backend_util.computePool2DInfo(o.shape,l,u,1,c,h),p=!0,f=new is(d,"max",p),m=e.runWebGLProgram(f,[o],o.dtype),g=new R5(d),v=e.runWebGLProgram(g,[r,m],o.dtype);return e.disposeIntermediateTensorInfo(m),v}var W6={kernelName:N.MaxPoolBackprop,backendName:"webgl",kernelFunc:F6};function U6(n,t,e,i){var r=new is(e,"max",!1),a=i.runWebGLProgram(r,[n],"float32");r=new is(e,"max",!0,!0,t);var s=i.runWebGLProgram(r,[n],"float32");return[a,s]}var B6={kernelName:N.MaxPoolWithArgmax,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.attrs,i=n.backend,r=t.x,a=e,s=a.filterSize,o=a.strides,l=a.pad,u=a.includeBatchInIndex,c=i;N.util.assert(r.shape.length===4,function(){return"Error in maxPool: input must be rank 4 but got rank "+r.shape.length+"."});var h=[1,1];N.util.assert(N.backend_util.eitherStridesOrDilationsAreOne(o,h),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+o+" and dilations '"+h+"'")});var d=N.backend_util.computePool2DInfo(r.shape,s,o,h,l),p=U6(r,u,d,c),f=p[0],m=p[1];return[f,m]}};var z6={kernelName:N.NonMaxSuppressionV3,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.backend,i=n.attrs;N.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var r=t,a=r.boxes,s=r.scores,o=i,l=o.maxOutputSize,u=o.iouThreshold,c=o.scoreThreshold,h=e,d=h.readSync(a.dataId),p=h.readSync(s.dataId),f=l,m=u,g=c;return N.kernel_impls.nonMaxSuppressionV3Impl(d,p,f,m,g)}};var P6=N.kernel_impls.nonMaxSuppressionV4Impl,_6={kernelName:N.NonMaxSuppressionV4,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.backend,i=n.attrs;N.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var r=t,a=r.boxes,s=r.scores,o=i,l=o.maxOutputSize,u=o.iouThreshold,c=o.scoreThreshold,h=o.padToMaxOutputSize,d=e,p=d.readSync(a.dataId),f=d.readSync(s.dataId),m=P6(p,f,l,u,c,h),g=m.selectedIndices,v=m.validOutputs;return[g,v]}};var M6=N.kernel_impls.nonMaxSuppressionV5Impl,H6={kernelName:N.NonMaxSuppressionV5,backendName:"webgl",kernelFunc:function(n){var t=n.in