varmZ=Object.create,Jm=Object.defineProperty,gZ=Object.getPrototypeOf,vZ=Object.prototype.hasOwnProperty,yZ=Object.getOwnPropertyNames,bZ=Object.getOwnPropertyDescriptor,WD=o=>Jm(o,"__esModule",{value:!0}),Zm=(o,a)=>()=>(a||(a={exports:{}},o(a.exports,a)),a.exports),kf=(o,a)=>{WD(o);for(variina)Jm(o,i,{get:a[i],enumerable:!0})},wZ=(o,a,i)=>{if(WD(o),a&&typeofa=="object"||typeofa=="function")for(letcofyZ(a))!vZ.call(o,c)&&c!=="default"&&Jm(o,c,{get:()=>a[c],enumerable:!(i=bZ(a,c))||i.enumerable});returno},se=o=>o&&o.__esModule?o:wZ(Jm(o!=null?mZ(gZ(o)):{},"default",{value:o,enumerable:!0}),o),Nx=Zm(xZ=>{kf(xZ,{FetchError:()=>sr,Headers:()=>jr,Request:()=>Bo,Response:()=>us,default:()=>FZ});varis=se(require("stream")),vx=se(require("http")),Qm=se(require("url")),VD=se(require("https")),$a=se(require("zlib")),TZ=is.default.Readable,Oo=Symbol("buffer"),yx=Symbol("type"),Fi=class{constructor(){this[yx]="";leta=arguments[0],i=arguments[1],c=[],f=0;if(a){letg=a,v=Number(g.length);for(letw=0;w<v;w++){letT=g[w],N;TinstanceofBuffer?N=T:ArrayBuffer.isView(T)?N=Buffer.from(T.buffer,T.byteOffset,T.byteLength):TinstanceofArrayBuffer?N=Buffer.from(T):TinstanceofFi?N=T[Oo]:N=Buffer.from(typeofT=="string"?T:String(T)),f+=N.length,c.push(N)}}this[Oo]=Buffer.concat(c);letd=i&&i.type!==void0&&String(i.type).toLowerCase();d&&!/[^\u0020-\u007E]/.test(d)&&(this[yx]=d)}getsize(){returnthis[Oo].length}gettype(){returnthis[yx]}text(){returnPromise.resolve(this[Oo].toString())}arrayBuffer(){leta=this[Oo],i=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength);returnPromise.resolve(i)}stream(){leta=newTZ;returna._read=function(){},a.push(this[Oo]),a.push(null),a}toString(){return"[object Blob]"}slice(){leta=this.size,i=arguments[0],c=arguments[1],f,d;i===void0?f=0:i<0?f=Math.max(a+i,0):f=Math.min(i,a),c===void0?d=a:c<0?d=Math.max(a+c,0):d=Math.min(c,a);letg=Math.max(d-f,0),v=this[Oo],w=v.slice(f,f+g),T=newFi([],{type:arguments[2]});returnT[Oo]=w,T}};Object.defineProperties(Fi.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}});Object.defineProperty(Fi.prototype,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0});functionsr(o,a,i){Error.call(this,o),this.message=o,this.type=a,i&&(this.code=this.errno=i.code),Error.captureStackTrace(this,this.constructor)}sr.prototype=Object.create(Error.prototype);sr.prototype.constructor=sr;sr.prototype.name="FetchError";varbx;try{bx=require("encoding").convert}catch(o){}varMo=Symbol("Body internals"),UD=is.default.PassThrough;functionHn(o){vara=this,i=arguments.length>1&&arguments[1]!==void0?arguments[1]:{},c=i.size;letf=c===void0?0:c;vard=i.timeout;letg=d===void0?0:d;o==null?o=null:GD(o)?o=Buffer.from(o.toString()):Sf(o)||(Buffer.isBuffer(o)||(Object.prototype.toString.call(o)==="[object ArrayBuffer]"?o=Buffer.from(o):ArrayBuffer.isView(o)?o=Buffer.from(o.buffer,o.byteOffset,o.byteLength):oinstanceofis.default||(o=Buffer.from(String(o))))),this[Mo]={body:o,disturbed:!1,error:null},this.size=f,this.timeout=g,oinstanceofis.default&&o.on("error",function(v){letw=v.name==="AbortError"?v:newsr(`Invalid response body while trying to fetch ${a.url}: ${v.message}`,"system",v);a[Mo].error=w})}Hn.prototype={getbody(){returnthis[Mo].body},getbodyUsed(){returnthis[Mo].disturbed},arrayBuffer(){returnbc.call(this).then(function(o){returno.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)})},blob(){leto=this.headers&&this.headers.get("content-type")||"";returnbc.call(this).then(function(a){returnObject.assign(newFi([],{type:o.toLowerCase()}),{[Oo]:a})})},json(){varo=this;returnbc.call(this).then(function(a){try{returnJSON.parse(a.toString())}catch(i){returnHn.Promise.reject(newsr(`invalid json response body at ${o.url} reason: ${i.message}`,"invalid-json"))}})},text(){returnbc.call(this).then(function(o){returno.toString()})},buffer(){returnbc.call(this)},textConverted(){varo=this;returnbc.call(this).then(function(a){returnkZ(a,o.headers)})}};Object.defineProperties(Hn.prototype,{body:{enumerable:
`;return x[x.length-1]=" "+x[x.length-1]+"]"+(u?"":C),x}function ah(n){let t=[];for(let e=0;e<n.length;e+=2)t.push([n[e],n[e+1]]);return t}class bn{constructor(t,e,r){if(this.dtype=e,this.shape=t.slice(),this.size=O(t),r!=null){let s=r.length;k(s===this.size,()=>`Lengthofvalues'${s}'doesnotmatchthesizeinferredbytheshape'${this.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=r||Kt(e,this.size),this.strides=Jt(t)}set(t,...e){e.length===0&&(e=[0]),k(e.length===this.rank,()=>`Thenumberofprovidedcoordinates(${e.length})mustmatchtherank(${this.rank})`);let r=this.locToIndex(e);this.values[r]=t}get(...t){t.length===0&&(t=[0]);let e=0;for(let s of t){if(s<0||s>=this.shape[e]){let u=`Requestedoutofrangeelementat${t}.Buffershape=${this.shape}`;throw new Error(u)}e++}let r=t[t.length-1];for(let s=0;s<t.length-1;++s)r+=this.strides[s]*t[s];return this.values[r]}locToIndex(t){if(this.rank===0)return 0;if(this.rank===1)return t[0];let e=t[t.length-1];for(let r=0;r<t.length-1;++r)e+=this.strides[r]*t[r];return e}indexToLoc(t){if(this.rank===0)return[];if(this.rank===1)return[t];let e=new Array(this.shape.length);for(let r=0;r<e.length-1;++r)e[r]=Math.floor(t/this.strides[r]),t-=e[r]*this.strides[r];return e[e.length-1]=t,e}get rank(){return this.shape.length}toTensor(){return Gs().makeTensor(this.values,this.shape,this.dtype)}}let Gs=null,Tu=null,Z2=null;function nP(n){Gs=n}function rP(n){Tu=n}function sP(n){Z2=n}class at{constructor(t,e,r,s){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=O(t),this.strides=Jt(t),this.dataId=r,this.id=s,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let t=await this.data();return Tu.buffer(this.shape,this.dtype,t)}bufferSync(){return Tu.buffer(this.shape,this.dtype,this.dataSync())}async array(){let t=await this.data();return Mr(this.shape,t)}arraySync(){return Mr(this.shape,this.dataSync())}async data(){this.throwIfDisposed();let t=Gs().read(this.dataId);if(this.dtype==="string"){let e=await t;try{return e.map(r=>rh(r))}catch(r){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return t}dataSync(){this.throwIfDisposed();let t=Gs().readSync(this.dataId);if(this.dtype==="string")try{return t.map(e=>rh(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}async bytes(){this.throwIfDisposed();let t=await Gs().read(this.dataId);return this.dtype==="string"?t:new Uint8Array(t.buffer)}dispose(){if(this.isDisposed)return;Gs().disposeTensor(this),this.isDisposedInternal=!0}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(t=!1){return Tu.print(this,t)}clone(){return this.throwIfDisposed(),Tu.clone(this)}toString(t=!1){let e=this.dataSync();return tP(e,this.shape,this.dtype,t)}cast(t){return this.throwIfDisposed(),Tu.cast(this,t)}variable(t=!0,e,r){return this.throwIfDisposed(),Gs().makeVariable(this,t,e,r)}}Object.defineProperty(at,Symbol.hasInstance,{value:n=>!!n&&n.data!=null&&n.dataSync!=null&&n.throwIfDisposed!=null});class ih extends at{constructor(t,e,r,s){super(t.shape,t.dtype,t.dataId,s);this.trainable=e,this.name=r}assign(t){if(t.dtype!==this.dtype)throw new Error(`dtypeofthenewvalue(${t.dtype})andpreviousvalue(${this.dtype})mustmatch`);if(!K(t.shape,this.shape))throw new Error(`shapeofthenewvalue(${t.shape})andpreviousvalue(${this.shape})mustmatch`);Gs().disposeTensor(this),this.dataId=t.dataId,Gs().incRef(this,null)}dispose(){Gs().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(ih,Symbol.hasInstance,{value:n=>n instanceof at&&n.assign!=null&&n.assign instanceof Function});(function(n){n.R0="R0",n.R1="R1",n.R2="R2",n.R3="R3",n.R4="R
ManifestJSONhasweightswithnames:${h.join(", ")}.`)}let p=s.reduce((S,C,I)=>(C&&S.push(I),S),[]),m=[];p.forEach(S=>{t[S].paths.forEach(C=>{let I=e+(e.endsWith("/")?"":"/")+C;m.push(I)})});let y=await n(m),b={},x=0;return p.forEach(S=>{let C=t[S].paths.length,I=0;for(let _=0;_<C;_++)I+=y[x+_].byteLength;let D=new ArrayBuffer(I),R=new Uint8Array(D),A=0;for(let _=0;_<C;_++){let B=new Uint8Array(y[x+_]);R.set(B,A),A+=B.byteLength}let L=u[S];L.forEach(_=>{let B=D.slice(_.groupOffset,_.groupOffset+_.sizeBytes),V=Jp(B,[_.manifestEntry]);for(let q in V)b[q]=V[q]}),x+=C}),b}}let XP="application/octet-stream",YP="application/json";class Fy{constructor(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?(k(typeof e.fetchFunc=="function",()=>"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=ft().platform.fetch,k(t!=null&&t.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(t)&&k(t.length===2,()=>`URLpathsforhttpmusthavealengthof2,(actuallengthis${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||{}}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");let e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);e.body=new FormData;let r=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],s={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata,weightsManifest:r};e.body.append("model.json",new Blob([JSON.stringify(s)],{type:YP}),"model.json"),t.weightData!=null&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:XP}),"model.weights.bin");let u=await this.fetch(this.path,e);if(u.ok)return{modelArtifactsInfo:ch(t),responses:[u]};throw new Error(`BrowserHTTPRequest.save()failedduetoHTTPresponsestatus${u.status}.`)}async load(){let t=await this.fetch(this.path,this.requestInit);if(!t.ok)throw new Error(`Requestto${this.path}failedwithstatuscode${t.status}.PleaseverifythisURLpointstothemodelJSONofthemodeltoload.`);let e;try{e=await t.json()}catch(S){let C=`FailedtoparsemodelJSONofresponsefrom${this.path}.`;throw this.path.endsWith(".pb")?C+=" 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.":C+=" Please make sure the server is serving valid JSON for this request.",new Error(C)}let r=e.modelTopology,s=e.weightsManifest,u=e.generatedBy,l=e.convertedBy,h=e.format,p=e.userDefinedMetadata;if(r==null&&s==null)throw new Error(`TheJSONfromHTTPpath${this.path}containsneithermodeltopologyormanifestforweights.`);let m,y;if(s!=null){let S=await this.loadWeights(s);[m,y]=S}let b={modelTopology:r,weightSpecs:m,weightData:y,userDefinedMetadata:p,generatedBy:u,convertedBy:l,format:h},x=e.modelInitializer;return x&&(b.modelInitializer=x),b}async loadWeights(t){let e=Array.isArray(this.path)?this.path[1]:this.path,[r,s]=JP(e),u=this.weightPathPrefix||r,l=[];for(let y of t)l.push(...y.weights);let h=[],p=[];for(let y of t)for(let b of y.paths)this.weightUrlConverter!=null?p.push(this.weightUrlConverter(b)):h.push(u+b+s);this.weightUrlConverter&&h.push(...await Promise.all(p));let m=await yS(h,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[l,Zp(m)]}}Fy.URL_SCHEME_REGEX=/^https?:\/\//;function JP(n){let t=n.lastIndexOf("/"),e=n.lastIndexOf("?"),r=n.su
Actual:${s}.
Expected:${u}.`);for(let l=0;l<u.length;++l){let h=s[l],p=u[l];if(!e(h,p))throw new Error(`Arraysdiffer:actual[${l}]=${h},expected[${l}]=${p}.
Actual:${s}.
Expected:${u}.`)}}function vO(n,t){n().then(()=>t.fail(),()=>t())}function yO(n,t){let e=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?[t]:t;return dn(n)||dn(n[0])||dn(t)||dn(t[0])?Vy(n,e,(r,s)=>r==s):Vy(n,t,(r,s)=>Gy(r,s,0))}function Uy(n,t,e){if(e==null&&(e=ad()),!Gy(n,t,e))throw new Error(`Numbersdiffer:actual===${n},expected===${t}`)}function Gy(n,t,e){return!isFinite(n)&&!isFinite(t)?!0:!(isNaN(n)||isNaN(t)||Math.abs(n-t)>e)}function bO(n,t,e){for(let r=0;r<n.length;r++)if(n[r]<t||n[r]>e)throw new Error(`Valueoutofrange:${n[r]}low:${t},high:${e}`)}function wO(n,t){expect(new Float32Array(n)).toEqual(new Float32Array(t))}var xO=Object.freeze({__proto__:null,TEST_EPSILON_FLOAT16:RS,expectArraysClose:gO,testEpsilon:ad,expectPromiseToFail:vO,expectArraysEqual:yO,expectNumbersClose:Uy,expectValuesInRange:bO,expectArrayBuffersEqual:wO});let PS="2.7.0";function TO(){ft().set("PROD",!0)}function kO(){ft().set("DEBUG",!0)}function SO(){ft().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Tn(n){ft().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(n+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}sP(Tn);function CO(){J.disposeVariables()}function yo(){return J}function id(){return J.memory()}function NO(n){return J.profile(n)}function ot(n,t){return J.tidy(n,t)}function oe(n){let t=mo(n);t.forEach(e=>e.dispose())}function An(n){return J.keep(n)}function IO(n){return J.time(n)}function OS(n){return J.setBackend(n)}function EO(){return J.ready()}function DO(){return J.backendName}function $O(n){J.removeBackend(n)}function AO(n){return J.findBackend(n)}function _O(n){return J.findBackendFactory(n)}function Hy(n,t,e=1){return J.registerBackend(n,t,e)}function MS(){return J.backend}function FO(n,t){ft().setPlatform(n,t)}function RO(n,t){let e=z(n,"a","add"),r=z(t,"b","add");[e,r]=nn(e,r);let s=(l,h)=>{let p=l.add(e,r);return h([e,r]),p},u={a:e,b:r};return J.runKernelFunc(s,u,null,ri)}let Nt=X({add_:RO});function PO(n,t){let e=z(n,"a","floorDiv"),r=z(t,"b","floorDiv");[e,r]=nn(e,r);let s=(l,h)=>{let p=l.floorDiv(e,r);return h([e,r]),p},u={a:e,b:r};return J.runKernelFunc(s,u,null,Uv)}let ud=X({floorDiv_:PO});function OO(n,t){let e=z(n,"a","div"),r=z(t,"b","div");if([e,r]=nn(e,r),e.dtype==="int32"&&r.dtype==="int32")return ud(e,r);let s=(h,p)=>{let m=h.realDivide(e,r);return p([e,r]),m},u={a:e,b:r},l={};return J.runKernelFunc(s,u,null,mu,l)}let Ht=X({div_:OO});function MO(n,t){let e=z(n,"a","mul"),r=z(t,"b","mul");[e,r]=nn(e,r);let s=(l,h)=>{let p=l.multiply(e,r);return h([e,r]),p},u={a:e,b:r};return J.runKernelFunc(s,u,null,gu)}let st=X({mul_:MO});function LO(n){let t=z(n,"x","abs"),e={x:t};return J.runKernelFunc((r,s)=>(s([t]),t.dtype==="complex64"?r.complexAbs(t):r.abs(t)),e,null,hp)}let kn=X({abs_:LO});function BO(n){let t=z(n,"x","acos"),e={x:t};return J.runKernelFunc((r,s)=>{let u=r.acos(t);return s([t]),u},e,null,dl)}let qy=X({acos_:BO});function zO(n){let t=z(n,"x","acosh"),e={x:t};return J.runKernelFunc((r,s)=>{let u=r.acosh(t);return s([t]),u},e,null,ml)}let jy=X({acosh_:zO});function WO(n){k(Array.isArray(n),()=>"The argument passed to tf.addN() must be a list of tensors"),k(n.length>=1,()=>`Mustpassatleastonetensortotf.addN(),butgot${n.length}`);let t=n.map((u,l)=>z(u,`tensors${l}`,"addN")),e=t[0];t.forEach(u=>{if(u.dtype!==e.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(u=>{if(!K(u.shape,e.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});let r=(u,l)=>{let h=u.addN(t);return l(t),h},s=t;return J.runKernelFunc(r,s,null,$v)}let LS=X({addN_:WO});function Ky(n,t){for(let e=0;e<n.length;++e)if(n[n.length-e-1]!==t-1-e)return!1;return!0}function BS(n,t,e){let r=n.length+t.length,s=[],u=0,l=0;for(let h=0;h<r;h++)e.indexOf(h)===-1?s.push(n[u++]):s.push(t[l++]);return s}function Bn(n,t){let e=[],r=n.length;for(let u=0;u<r;u++)t.indexOf(u)===-1&&e.push(n[u]);let s=t.map(u=>n[u]);return[e,s]}function zn(n,t
withdtype${l.dtype}.`)});let r=(l,h)=>{let p=Et(t,e[0].shape)[0],m=bo(e.map(x=>x.shape),p);if(O(m)===0)return vn([],m);if(e=e.filter(x=>x.size>0),e.length===1)return e[0];let y=e.map(x=>x.shape);fd(y,p);let b=l.concat(e,p);return h(e),b},s=e,u={axis:t};return J.runKernelFunc(r,s,null,kl,u)}let sn=X({concat_:rM});function sM(n){let t=z(n,"x","sigmoid"),e={x:t};return J.runKernelFunc((r,s)=>{let u=r.sigmoid(t);return s([u]),u},e,null,Yl)}let js=X({sigmoid_:sM});function oM(n,t,e){let r=z(n,"x","slice");if(r.rank===0)throw new Error("Slicing scalar is not possible");let s=(h,p)=>{let[m,y]=od(r,t,e);return By(r,m,y),p([r]),h.slice(r,m,y)},u={x:r},l={begin:t,size:e};return J.runKernelFunc(s,u,null,Pp,l)}let ge=X({slice_:oM});function aM(n){let t=z(n,"x","tanh"),e={x:t};return J.runKernelFunc((r,s)=>{let u=r.tanh(t);return s([u]),u},e,null,Ql)}let Du=X({tanh_:aM});function iM(n,t,e,r,s,u){let l=z(n,"forgetBias","basicLSTMCell"),h=z(t,"lstmKernel","basicLSTMCell"),p=z(e,"lstmBias","basicLSTMCell"),m=z(r,"data","basicLSTMCell"),y=z(s,"c","basicLSTMCell"),b=z(u,"h","basicLSTMCell"),x=sn([m,b],1),S=xe(x,h),C=Nt(S,p),I=C.shape[0],D=C.shape[1]/4,R=[I,D],A=ge(C,[0,0],R),L=ge(C,[0,D],R),_=ge(C,[0,D*2],R),B=ge(C,[0,D*3],R),V=Nt(st(js(A),Du(L)),st(y,js(Nt(l,_)))),q=st(Du(V),js(B));return[V,q]}let uM=X({basicLSTMCell_:iM});function cM(n,t,e){let r=z(n,"x","batchToSpaceND"),s=t.reduce((p,m)=>p*m);k(r.rank>=1+t.length,()=>`inputrankis${r.rank}butshouldbe>thanblockShape.length${t.length}`),k(e.length===t.length,()=>`crops.lengthis${e.length}butshouldbeequaltoblockShape.length${t.length}`),k(r.shape[0]%s===0,()=>`inputtensorbatchis${r.shape[0]}butisnotdivisiblebytheproductoftheelementsofblockShape${t.join(" * ")}===${s}`);let u=p=>p.batchToSpaceND(r,t,e),l={x:r},h={blockShape:t,crops:e};return J.runKernelFunc(u,l,null,Rv,h)}let mh=X({batchToSpaceND_:cM});function lM(n){let t;return n.rank===0||n.rank===1?t=rt(n,[1,1,1,n.size]):n.rank===2?t=rt(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?t=rt(n,[1,n.shape[0],n.shape[1],n.shape[2]]):t=n,t}function hM(n,t,e,r,s,u){u==null&&(u=.001);let l=z(n,"x","batchNorm"),h=z(t,"mean","batchNorm"),p=z(e,"variance","batchNorm"),m;s!=null&&(m=z(s,"scale","batchNorm"));let y;r!=null&&(y=z(r,"offset","batchNorm")),k(h.rank===p.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),k(y==null||h.rank===y.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),k(m==null||h.rank===m.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let b=lM(l),x=(D,R)=>(R([b,h,p,m]),D.batchNorm(b,pd(h),pd(p),pd(y),pd(m),u)),S={x:b,scale:m,offset:y,mean:h,variance:p},C={varianceEpsilon:u},I=J.runKernelFunc(x,S,null,$l,C);return rt(I,l.shape)}function pd(n){return n==null?null:n.rank===0?rt(n,[n.size]):n.rank===1?n:n.rank===2?rt(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?rt(n,[1,n.shape[0],n.shape[1],n.shape[2]]):n}let fi=X({batchNorm_:hM});function fM(n,t,e,r,s,u){let l=z(n,"x","batchNorm"),h=z(t,"mean","batchNorm"),p=z(e,"variance","batchNorm"),m;s!=null&&(m=z(s,"scale","batchNorm"));let y;return r!=null&&(y=z(r,"offset","batchNorm")),k(l.rank===2,()=>`ErrorinbatchNorm2D:xmustberank2butgotrank${l.rank}.`),k(h.rank===2||h.rank===1,()=>`ErrorinbatchNorm2D:meanmustberank2orrank1butgotrank${h.rank}.`),k(p.rank===2||p.rank===1,()=>`ErrorinbatchNorm2D:variancemustberank2orrank1butgotrank${p.rank}.`),m!=null&&k(m.rank===2||m.rank===1,()=>`ErrorinbatchNorm2D:scalemustberank2orrank1butgotrank${m.rank}.`),y!=null&&k(y.rank===2||y.rank===1,()=>`ErrorinbatchNorm2D:offsetmustberank2orrank1butgotrank${y.rank}.`),fi(l,h,p,y,m,u)}let zS=X({batchNorm2d_:fM});function pM(n,t,e,r,s,u){let l=z(n,"x","batchNorm"),h=z(t,"mean","batchNorm"),p=z(e,"variance","batchNorm"),m;s!=null&&(m=z(s,"scale","batchNorm"));let y;return r!=null&&(y=z(r,"offset","batchNorm")),k(l.rank===3,()=>`ErrorinbatchNorm3D:xmustberank3butgotrank${l.rank}.`),
rank${u.rank}.`),k(nt(t),()=>`ErrorinlocalResponseNormalization:depthRadiusmustbeanintegerbutgotdepthRadius${t}.`);let l=u,h=!1;u.rank===3&&(h=!0,l=rt(u,[1,u.shape[0],u.shape[1],u.shape[2]]));let p=(x,S)=>{let C=x.localResponseNormalization4D(l,t,e,r,s);return S([l,C]),C},m={x:l},y={depthRadius:t,bias:e,alpha:r,beta:s},b=J.runKernelFunc(p,m,null,jv,y);return h?rt(b,[b.shape[1],b.shape[2],b.shape[3]]):b}let pb=X({localResponseNormalization_:hL});function fL(n){let t=z(n,"x","log"),e={x:t};return J.runKernelFunc((r,s)=>{let u=r.log(t);return s([t]),u},e,null,Pl)}let Nr=X({log_:fL});function pL(n){let t=z(n,"x","log1p"),e={x:t};return J.runKernelFunc((r,s)=>{let u=r.log1p(t);return s([t]),u},e,null,Ol)}let wd=X({log1p_:pL});function dL(n){return k(Ln(n),()=>"The f passed in grad(f) must be a function"),(t,e)=>{let r=z(t,"x","tf.grad",null),s=e!=null?z(e,"dy","tf.grad"):null;return J.tidy(()=>{let{value:u,grads:l}=J.gradients(()=>n(r),[r],s);return s!=null&&$(u.shape,s.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),xd(l),l[0]})}}function mL(n){return k(Ln(n),()=>"The f passed in grads(f) must be a function"),(t,e)=>{k(Array.isArray(t),()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");let r=uh(t,"args","tf.grads",null),s=e!=null?z(e,"dy","tf.grads"):null;return J.tidy(()=>{let{value:u,grads:l}=J.gradients(()=>n(...r),r,s);return s!=null&&$(u.shape,s.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),xd(l),l})}}function gL(n){return k(Ln(n),()=>"The f passed in valueAndGrad(f) must be a function"),(t,e)=>{k(t instanceof at,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),k(e==null||e instanceof at,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:r,value:s}=J.gradients(()=>n(t),[t],e);return xd(r),{grad:r[0],value:s}}}function vL(n){return k(Ln(n),()=>"The f passed in valueAndGrads(f) must be a function"),(t,e)=>{k(Array.isArray(t)&&t.every(s=>s instanceof at),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),k(e==null||e instanceof at,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let r=J.gradients(()=>n(...t),t,e);return e!=null&&$(r.value.shape,e.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),xd(r.grads),r}}function db(n,t){k(Ln(n),()=>"The f passed in variableGrads(f) must be a function"),k(t==null||Array.isArray(t)&&t.every(m=>m instanceof ih),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let e=t!=null;if(!e){t=[];for(let m in J.registeredVariables)t.push(J.registeredVariables[m])}let r=e?t.filter(m=>!m.trainable):null,s=t.length;t=t.filter(m=>m.trainable),k(t.length>0,()=>`variableGrads()expectsatleastoneoftheinputvariablestobetrainable,butnoneofthe${s}variablesistrainable.`);let u=!0,{value:l,grads:h}=J.gradients(n,t,null,u);k(h.some(m=>m!=null),()=>"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()."),k(l.rank===0,()=>`ThefpassedinvariableGrads(f)mustreturnascalar,butitreturnedarank-${l.rank}tensor`);let p={};return t.forEach((m,y)=>{h[y]!=null&&(p[m.name]=h[y])}),r!=null&&r.forEach(m=>p[m.name]=null),{value:l,grads:p}}function Ks(n){return J.customGrad(n)}function xd(n){let t=n.filter(e=>e==null).length;if(t>0)throw new Error(`Cannotcomputegradientofy=f(x)withrespecttox.Makesurethat
2.Thecustom${r}isdefinedinJavaScript,butisnotregisteredproperlywithtf.serialization.registerClass().`);return l}else{let u=n;if(u.className==null||u.config==null)throw new Q(`${r}:Improperconfigformat:${JSON.stringify(u)}.
'className'and'config'mustset.`);let l=u.className,h,p;if(l in e?[h,p]=e[l]:l in rs?[h,p]=rs.className:l in t&&([h,p]=t[l]),h==null)throw new Q(`Unknown${r}:${l}.Thismaybeduetooneofthefollowingreasons:
2.Thecustom${r}isdefinedinJavaScript,butisnotregisteredproperlywithtf.serialization.registerClass().`);if(p!=null){let m={};for(let S of Object.keys(rs))m[S]=rs[S];for(let S of Object.keys(e))m[S]=e[S];let y=u.config;y.customObjects=m;let b=Object.assign({},rs);for(let S of Object.keys(e))rs[S]=e[S];tw(u.config);let x=p(h,u.config,e,s);return rs=Object.assign({},b),x}else{let m=Object.assign({},rs);for(let b of Object.keys(e))rs[b]=e[b];let y=new h(u.config);return rs=Object.assign({},m),y}}}function iV(n,t){return n<t?-1:n>t?1:0}function Xd(n,t){return-1*iV(n,t)}function mht(n){switch(n){case"float32":return"float32";default:throw new Q(`Invaliddtype:${n}`)}}function ght(n,t){if(n==null||t==null)return n===t;if(n.length!==t.length)return!1;for(let e=0;e<n.length;++e)if(n[e]!==t[e])return!1;return!0}function ma(n){if(n==null)return n;let t=[];for(let e of n)t.indexOf(e)===-1&&t.push(e);return t}function uV(n){if(n==null)throw new Q(`Invalidvalueinobj:${JSON.stringify(n)}`);for(let t in n)if(n.hasOwnProperty(t))return!1;return!0}function Hu(n,t,e){if(e==null)return;if(n.indexOf(e)<0)throw new Q(`${e}isnotavalid${t}.Validvaluesare${n}ornull/undefined.`)}function ew(n,t,e=0,r=Infinity){return Vr(e>=0),Vr(r>=e),Array.isArray(n)&&n.length>=e&&n.length<=r&&n.every(s=>typeof s===t)}function _n(n,t){Array.isArray(n)?(k(n.length>0,()=>`${t}isunexpectedlyanemptyarray.`),n.forEach((e,r)=>_n(e,`element${r+1}of${t}`))):k(Number.isInteger(n)&&n>0,()=>`Expected${t}tobeapositiveinteger,butgot${tN(n)}.`)}function tN(n){return n===null?"null":Array.isArray(n)?"["+n.map(t=>tN(t)).join(",")+"]":typeof n=="string"?`"${n}"`:`${n}`}function cV(n,t){let e=cr(),r,s=(...u)=>{let l=cr();return l-e<t||(e=l,r=n(...u)),r};return s}function eN(n){return n==="relu"?"relu":n==="linear"?"linear":n==="elu"?"elu":null}function vht(...n){Vr(n.length>0,"arrayOfValues is empty");for(let t of n)Vr(Array.isArray(t),"one of the values is not an array"),Vr(t.length>0,"one of the values is empty");return n.reduce((t,e)=>t.length===0?e.map(r=>[r]):e.map(r=>t.map(s=>[...s,r])).reduce((r,s)=>r.concat(s),[]),[])}function nw(n,t){return ot(()=>Wn(Xt(st(n,n),t,!0)))}class Wh extends li{getConfig(){return{}}}class rw extends Wh{constructor(t){super();this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=t.maxValue!=null?t.maxValue:this.defaultMaxValue,this.axis=t.axis!=null?t.axis:this.defaultAxis}apply(t){return ot(()=>{let e=nw(t,this.axis),r=fr(e,0,this.maxValue);return st(t,Ht(r,Nt(Cn(),e)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}rw.className="MaxNorm",kt(rw);class sw extends Wh{constructor(t){super();this.defaultAxis=0,this.axis=t.axis!=null?t.axis:this.defaultAxis}apply(t){return ot(()=>Ht(t,Nt(Cn(),nw(t,this.axis))))}getConfig(){return{axis:this.axis}}}sw.className="UnitNorm",kt(sw);class ow extends Wh{apply(t){return Ys(t)}}ow.className="NonNeg",kt(ow);class aw extends Wh{constructor(t){super();this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=t.minValue!=null?t.minValue:this.defaultMinValue,this.maxValue=t.maxValue!=null?t.maxValue:this.defaultMaxValue,this.rate=t.rate!=null?t.rate:this.defaultRate,this.axis=t.axis!=null?t.axis:this.defaultAxis}apply(t){return ot(()=>{let e=nw(t,this.axis),r=Nt(st(this.rate,fr(e,this.minValue,this.maxValue)),st(1-this.rate,e));return st(t,Ht(r,Nt(Cn(),e)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}aw.className="MinMaxNorm",kt(aw);let nN={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Nn(n){return Qb(n)}function rN(n,t={}){return zh(n,Lr.getMap().classNameMap,t,"constraint")}function In(n){if(n==null)return null;if(typeof n=="string"){let t=n in nN?nN[n]:n,e={className:t,config:{}};return rN(e)}else return n instanceof Wh?n:rN(n)}function lV(n){return new rw(n)}function hV(n){return new sw(n)}function fV(){return new ow}function pV(n){return new aw(n)}var dV=Object.freeze({__proto__:null,maxNorm:lV,unitNorm:hV,non
becausethevaluedtypeis${e.dtype},butTensorArraydtypeis${this.dtype}.`);if(this.size()===0&&(this.elementShape==null||this.elementShape.length===0)&&(this.elementShape=e.shape),os(this.elementShape,e.shape,`TensorArray${this.name}:CouldnotwritetoTensorArrayindex${t}.`),r.read)throw new Error(`TensorArray${this.name}:CouldnotwritetoTensorArrayindex${t},becauseithasalreadybeenread.`);if(r.written)throw new Error(`TensorArray${this.name}:CouldnotwritetoTensorArrayindex${t},becauseithasalreadybeenwritten.`);r.tensor=e,An(e),r.written=!0,this.tensors[t]=r}writeMany(t,e){if(t.length!==e.length)throw new Error(`TensorArray${this.name}:couldnotwritemultipletensors,becausetheindexsize:${t.length}isnotthesameastensorssize:${e.length}.`);t.forEach((r,s)=>this.write(r,e[s]))}gather(t,e){if(!!e&&e!==this.dtype)throw new Error(`TensorArraydtypeis${this.dtype}butgatherrequesteddtype${e}`);if(t)t=t.slice(0,this.size());else{t=[];for(let s=0;s<this.size();s++)t.push(s)}if(t.length===0)return vn([],[0].concat(this.elementShape));let r=this.readMany(t);return os(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),mr(r,0)}concat(t){if(!!t&&t!==this.dtype)throw new Error(`TensorArraydtypeis${this.dtype}butconcatrequesteddtype${t}`);if(this.size()===0)return vn([],[0].concat(this.elementShape));let e=[];for(let s=0;s<this.size();s++)e.push(s);let r=this.readMany(e);return os(this.elementShape,r[0].shape,`TensorArrayshapemismatch:tensorarrayshape(${this.elementShape})vsfirsttensorshape(${r[0].shape})`),sn(r,0)}scatter(t,e){if(e.dtype!==this.dtype)throw new Error(`TensorArraydtypeis${this.dtype}buttensorhasdtype${e.dtype}`);if(t.length!==e.shape[0])throw new Error(`Expectedlen(indices)==tensor.shape[0],butsaw:${t.length}vs.${e.shape[0]}`);let r=Math.max(...t);if(!this.dynamicSize&&r>=this.maxSize)throw new Error(`Maxindexmustbe<arraysize(${r}vs.${this.maxSize})`);this.writeMany(t,bs(e,0))}split(t,e){if(e.dtype!==this.dtype)throw new Error(`TensorArraydtypeis${this.dtype}buttensorhasdtype${e.dtype}`);let r=0,s=t.map(p=>(r+=p,r));if(r!==e.shape[0])throw new Error(`Expectedsumoflengthstobeequalto
${r},andtensor's shape is: ${e.shape}`);if(!this.dynamicSize&&t.length!==this.maxSize)throw new Error(`TensorArray'ssizeisnotequaltothesizeoflengths(${this.maxSize}vs.${t.length}),andtheTensorArrayisnotmarkedasdynamicallyresizeable`);let u=r===0?0:e.size/r,l=[];ot(()=>{e=rt(e,[1,r,u]);for(let p=0;p<t.length;++p){let m=p===0?0:s[p-1],y=[0,m,0],b=[1,t[p],u];l[p]=rt(ge(e,y,b),this.elementShape)}return l});let h=[];for(let p=0;p<t.length;p++)h[p]=p;this.writeMany(h,l)}}class ec{constructor(t,e,r,s=-1){this.tensors=t,this.elementShape=e,this.elementDtype=r,t!=null&&t.forEach(u=>{if(r!==u.dtype)throw new Error(`Invaliddatatypes;opelements${r},butlistelements${u.dtype}`);os(e,u.shape,"TensorList shape mismatch: "),An(u)}),this.idTensor=Ot(0),this.maxNumElements=s,An(this.idTensor)}get id(){return this.idTensor.id}copy(){return new ec([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(t){this.tensors.forEach(e=>{(t==null||!t.has(e.id))&&e.dispose()}),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(t,e,r=-1){if(e!==this.elementDtype)throw new Error(`Invaliddatatypes;opelements${e},butlistelements${this.elementDtype}`);if(r!==-1&&this.tensors.length!==r)throw new Error(`Operationexpectedalistwith${r}elementsbutgotalistwith${this.tensors.length}elements.`);return os(t,this.elementShape,"TensorList shape mismatch: "),ot(()=>{let s=this.tensors.map(u=>rt(u,t));return mr(s,0)})}popBack(t,e){if(e!==this.elementDtype)throw new Error(`Invaliddatatypes;opelements${e},butlistelements${this.elementDtype}`);if(this.size()===0)throw new Error("Trying to pop from an empty list.");let r=this.tensors.pop();return os(r.shape,t,"TensorList shape mismatch: "),rt(r,t)}pushBack(t){if(t.dtype!==this.elementDtype)throw new Error(`Invaliddatatypes;opelements${t.dtype},butlistelements${this.elementDtype}`);if(os(t.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");An(t),this.tensors.push(t)}resize(t){if(t<0)throw new Error(`TensorListResizeexpectssizetobenon-negative.Got:${t}`);if(this.maxNumElements!==-1&&t>this.maxNumElements)throw new Error(`TensorListResizeinputsize${t}isgreatermaxNumElement${this.maxNumElements}.`);this.tensors.length=t}getItem(t,e,r){if(r!==this.elementDtype)throw new Error(`Invaliddatatypes;opelements${r},butlistelements${this.elementDtype}`);if(t<0||t>this.tensors.length)throw new Error(`Tryingtoaccesselement${t}inalistwith${this.tensors.length}elements.`);if(this.tensors[t]==null)throw new Error(`elementatindex${t}isnull.`);return os(this.tensors[t].shape,e,"TensorList shape mismatch: "),this.tensors[t]}setItem(t,e){if(e.dtype!==this.elementDtype)throw new Error(`Invaliddatatypes;opelements${e.dtype},butlistelements${this.elementDtype}`);if(t<0||this.maxNumElements!==-1&&t>=this.maxNumElements)throw new Error(`Tryingtosetelement${t}inalistwithmax${this.maxNumElements}elements.`);os(this.elementShape,e.shape,"TensorList shape mismatch: "),An(e),this.tensors[t]=e}gather(t,e,r){if(e!==this.elementDtype)throw new Error(`Invaliddatatypes;opelements${e},butlistelements${this.elementDtype}`);return os(this.elementShape,r,"TensorList shape mismatch: "),t=t.slice(0,this.size()),t.length===0?vn([],[0].concat(this.elementShape)):ot(()=>{let s=t.map(u=>rt(this.tensors[u],r));return mr(s,0)})}concat(t,e){if(!!t&&t!==this.elementDtype)throw new Error(`TensorListdtypeis${this.elementDtype}butconcatrequesteddtype${t}`);return os(this.elementShape,e,"TensorList shape mismatch: "),this.size()===0?vn([],[0].concat(this.elementShape)):ot(()=>{let r=this.tensors.map(s=>rt(s,e));return sn(r,0)})}}function Fq(n,t,e){let r=n.dtype;if(n.shape.length<1)throw new Error(`Tensormustbeatleastavector,butsawshape:${n.shape}`);if(n.dtype!==e)throw new Error(`Invaliddatatypes;opelements${n.dtype},butlistelements${e}`);let s=n.shape.slice(1
${t}`);let s;return this.size===Infinity||this.size==null?s=this.size:e?s=Math.ceil(this.size/t):s=Math.floor(this.size/t),Ar(async()=>(await r.iterator()).columnMajorBatch(t,e,$j),s)}concatenate(t){let e=this,r;return this.size===Infinity||t.size===Infinity?r=Infinity:this.size!=null&&t.size!=null?r=this.size+t.size:r=null,Ar(async()=>(await e.iterator()).concatenate(await t.iterator()),r)}filter(t){let e=this,r;return this.size===Infinity?r=Infinity:r=null,Ar(async()=>(await e.iterator()).filter(s=>ot(()=>t(s))),r)}async forEachAsync(t){return(await this.iterator()).forEachAsync(t)}map(t){let e=this;return Ar(async()=>(await e.iterator()).map(r=>ot(()=>t(r))),this.size)}mapAsync(t){let e=this;return Ar(async()=>(await e.iterator()).mapAsync(t),this.size)}prefetch(t){if(t==null)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");let e=this;return Ar(async()=>(await e.iterator()).prefetch(t),this.size)}repeat(t){let e=this,r;return this.size!=null&&t>0?r=this.size*t:t===0?r=0:this.size!=null&&(t===void 0||t<0)?r=Infinity:r=null,Ar(async()=>{let s=lf(async()=>({value:await e.iterator(),done:!1}));return KI(s.take(t))},r)}skip(t){let e=this,r;return this.size!=null&&t>=0&&this.size>=t?r=this.size-t:this.size!=null&&(this.size<t||t===void 0||t<0)?r=0:r=null,Ar(async()=>(await e.iterator()).skip(t),r)}shuffle(t,e,r=!0){if(t==null||t<0)throw this.size==null?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new 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)`);lets=this,u=Lu(e||cr().toString());returnAr(async()=>{letl=u.int32();returnr&&(l+=u.int32()),(awaits.iterator()).shuffle(t,l.toString())},this.size)}take(t){lete=this,r;returnthis.size!=null&&this.size>t?r=t:this.size!=null&&this.size<=t?r=this.size:r=null,Ar(async()=>(awaite.iterator()).take(t),r)}asynctoArray(){if(this.size===Infinity)thrownewError("Can not convert infinite data stream to array.");return(awaitthis.iterator()).toArray()}asynctoArrayForTest(){if(this.size===Infinity)thrownewError("Can not convert infinite data stream to array.");return(awaitthis.iterator()).toArrayForTest()}}rc.MAX_BUFFER_SIZE=1e4;functionAr(n,t=null){returnnewclassextendsrc{constructor(){super(...arguments);this.size=t}asynciterator(){returnn()}}}functionEj(n){returnAr(async()=>jI(n),n.length)}functionDj(n){if(!nc(n))thrownewError("The argument to zip() must be an object or array.");lett;if(Array.isArray(n))for(lete=0;e<n.length;e++)t=t==null?n[e].size:Math.min(t,n[e].size);elseif(ninstanceofObject)for(leteinn)t=t==null?n[e].size:Math.min(t,n[e].size);returnAr(async()=>{lete=awaitHI(n,r=>{if(rinstanceofrc)return{value:r.iterator(),recurse:!1};if(nc(r))return{value:null,recurse:!0};thrownewError("Leaves of the structure passed to zip() must be Datasets, not primitives.")});returnmj(e,Sa.SHORTEST)},t)}function$j(n){if(n===null)returnnull;lett=n[0];if(hj(t)){lete=Aj(n);return{value:e,recurse:!1}}return{value:null,recurse:!0}}functionAj(n){if(n.length===0)thrownewError("Can't make a batch of zero elements.");returnn[0]instanceofat?mr(n):vn(n)}classZIextendsrc{constructor(t){super();this.input=t}asynciterator(){lett=awaitthis.input.iterator(),e=t.decodeUTF8(),r=e.split(`
`).map(s=>(s.endsWith("\r")&&(s=s.slice(0,-1)),s));return r}}let Rm='"',hf=Symbol("out"),QI=Symbol("field"),Pm=Symbol("quote"),H0=Symbol("quoteafterquote"),tE=Symbol("quoteinquote");class eE extends rc{constructor(t,e){super();this.input=t,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new ZI(t),e||(e={}),this.hasHeader=!(e.hasHeader===!1),this.fullColumnNames=e.columnNames,this.columnConfigs=e.columnConfigs,this.configuredColumnsOnly=e.configuredColumnsOnly,e.delimWhitespace?(k(e.delimiter==null,()=>"Delimiter should not be provided when delimWhitespace is true."),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=e.delimiter?e.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){let t=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&t&&k(t.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 ("+t.length.toString()+")."),this.fullColumnNames||(this.fullColumnNames=t);let e=this.fullColumnNames.reduce((s,u)=>(s[u]=s[u]+1||1,s),{}),r=Object.keys(e).filter(s=>e[s]>1);if(k(r.length===0,()=>"Duplicate column names found: "+r.toString()),this.columnConfigs)for(let s of Object.keys(this.columnConfigs)){let u=this.fullColumnNames.indexOf(s);if(u===-1)throw new Error('The key "'+s+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){let t=await this.base.iterator(),e=await t.next();if(e.done)throw new Error("No data was found for CSV parsing.");let r=e.value,s=this.parseRow(r,!1);return s}else return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let t=await this.base.iterator();return this.hasHeader&&(t=t.skip(1)),t.map(e=>this.makeDataElement(e))}makeDataElement(t){let e=this.parseRow(t),r={},s={};for(let u=0;u<this.fullColumnNames.length;u++){let l=this.fullColumnNames[u],h=this.columnConfigs?this.columnConfigs[l]:null;if(this.configuredColumnsOnly&&!h)continue;{let p=e[u],m=null;if(p==="")if(h&&h.default!==void 0)m=h.default;else{if(h&&(h.required||h.isLabel))throw new Error(`Requiredcolumn${l}isemptyinthisline:${t}`);m=void 0}else{let y=Number(p);if(isNaN(y))h&&h.dtype==="bool"?m=this.getBoolean(p):m=p;else if(!h||!h.dtype)m=y;else switch(h.dtype){case"float32":m=y;break;case"int32":m=Math.floor(y);break;case"bool":m=this.getBoolean(p);break;default:m=y}}h&&h.isLabel?s[l]=m:r[l]=m}}return Object.keys(s).length===0?r:{xs:r,ys:s}}getBoolean(t){return t==="1"||t.toLowerCase()==="true"?1:0}parseRow(t,e=!0){let r=[],s=0,u=t.length,l=hf;for(let h=0;h<u;h++)switch(l){case hf:switch(t.charAt(h)){case Rm:s=h+1,l=Pm;break;case this.delimiter:if(s=h+1,this.delimiter===" "&&this.delimWhitespace)break;r.push(""),l=hf;break;default:l=QI,s=h;break}break;case QI:switch(t.charAt(h)){case this.delimiter:r.push(t.substring(s,h)),l=hf,s=h+1;break;default:}break;case Pm:switch(t.charAt(h)){case Rm:l=H0;break;default:}break;case H0:switch(t.charAt(h)){case this.delimiter:r.push(t.substring(s,h-1)),l=hf,s=h+1;break;case Rm:l=Pm;break;default:l=tE;break}break;case tE:switch(t.charAt(h)){case Rm:l=Pm;break;default:}break;default:}if(l===H0?r.push(t.substring(s,u-1)):r.push(t.substring(s)),e&&r.length!==this.fullColumnNames.length)throw new Error(`Invalidrowincsvfile.Shouldhave${this.fullColumnNames.length}elementsinarow,butgot${r}`);return r}}class q0 extends Rn{constructor(t){super();this.microphoneConfig=t,this.isClosed=!1,this.fftSize=t.fftSize||1024;let e=Math.log2(this.fftSize);if(this.fftSize<0||e<4||e>14||!Number.isInteger(e))throw new Error(
Hithere\u{1F44B}.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.
`}function AX(n){let t=n.shapeInfo.logicalShape,e=t.length,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),u=n.shapeInfo.texShape,l=[Math.ceil(u[0]/2),Math.ceil(u[1]/2)],h=l[0],p=l[1],m=Math.ceil(t[e-1]/2),y=m*Math.ceil(t[e-2]/2),b="int b, int row, int col",x=`b*${y}+(row/2)*${m}+(col/2)`;for(let C=2;C<e-1;C++)b=`intb${C},`+b,y*=t[e-C-1],x=`b${C}*${y}+`+x;let S=rr();return`
returnmod(a,b);`,ZX="return (b >= 1.0) ? a : a * (b + 1.0);",KE="return (a < 0.) ? b * a : a;";class Yn{constructor(t,e,r){this.variableNames=["A","B"],this.outputShape=ve(e,r),this.userCode=`
`}}class ZE{constructor(t,e=!1,r=null,s=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.outShape;let u=t.inHeight,l=t.inWidth,h=t.padInfo.top,p=t.padInfo.left,m=t.strideHeight,y=t.strideWidth,b=t.dilationHeight,x=t.dilationWidth,S=t.filterHeight,C=t.filterWidth,I=C,D="int xR; int xC; int xCOffset;";for(let _=0;_<S;_++)for(let B=0;B<C;B++)D+=`
`}}class xf{constructor(t,e,r,s=!1,u=!1){if(this.variableNames=["x"],e==="avg"&&r)throw new Error("Cannot compute positions for average pool.");let l=t.filterWidth,h=t.strideHeight,p=t.strideWidth,m=t.dilationHeight,y=t.dilationWidth,b=t.effectiveFilterHeight,x=t.effectiveFilterWidth,S=t.padInfo.top,C=t.padInfo.left;this.outputShape=t.outShape;let I=e==="avg",D=`((batch*${t.inHeight}+xR)*${t.inWidth}+xC)*${t.inChannels}+d`,R=`(xR*${t.inWidth}+xC)*${t.inChannels}+d`,A="0.0";if(I||(A="-1.0 / 1e-20"),r){let j=">=";this.userCode=`
`}}class lx{constructor(t,e,r,s=!1,u=!1){if(this.variableNames=["x"],e==="avg"&&r)throw new Error("Cannot compute positions for average pool.");let l=t.filterWidth,h=t.strideDepth,p=t.strideHeight,m=t.strideWidth,y=t.dilationDepth,b=t.dilationHeight,x=t.dilationWidth,S=t.effectiveFilterDepth,C=t.effectiveFilterHeight,I=t.effectiveFilterWidth,D=t.padInfo.front,R=t.padInfo.top,A=t.padInfo.left;this.outputShape=t.outShape;let L=e==="avg",_="0.0";if(L||(_="-1.0 / 1e-20"),r){let tt=">=";this.userCode=`
`}}class k7{constructor(t,e){this.variableNames=["x"];let r=t.length;if(r>4)throw new Error(`WebGLbackend:Reverseofrank-${r}tensorisnotyetsupported`);if(this.outputShape=t,r===1){this.userCode=`
`}}class A7{constructor(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(t,e,r){let s=fD(e,r),u=pD(t,s,r);u in this.freeTextures||(this.freeTextures[u]=[]),u in this.usedTextures||(this.usedTextures[u]=[]);let l=hD(t,s,this.gpgpu.gl,this.gpgpu.textureConfig,r);if(this.freeTextures[u].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=l,this.log();let p=this.freeTextures[u].shift();return this.usedTextures[u].push(p),p}let h;return s===Vn.PACKED_2X2_FLOAT32?h=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):s===Vn.PACKED_2X2_FLOAT16?h=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):s===Vn.UNPACKED_FLOAT32?h=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):s===Vn.UNPACKED_FLOAT16?h=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):s===Vn.PACKED_4X1_UNSIGNED_BYTE&&(h=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[u].push(h),this.numUsedTextures++,this._numBytesAllocated+=l,this.log(),h}releaseTexture(t,e,r,s){if(this.freeTextures==null)return;let u=fD(r,s),l=pD(e,u,s);l in this.freeTextures||(this.freeTextures[l]=[]);let h=hD(e,u,this.gpgpu.gl,this.gpgpu.textureConfig,s),p=ft().get("WEBGL_DELETE_TEXTURE_THRESHOLD");p!==-1&&this._numBytesAllocated>p?(this.gpgpu.deleteMatrixTexture(t),this._numBytesAllocated-=h):(this.freeTextures[l].push(t),this.numFreeTextures++,this._numBytesFree+=h),this.numUsedTextures--;let m=this.usedTextures[l],y=m.indexOf(t);if(y<0)throw new Error("Cannot release a texture that was never provided by this texture manager");m.splice(y,1),this.log()}log(){if(!this.logEnabled)return;let t=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures}/${this.numUsedTextures}`,`(${t})`);let e=this._numBytesFree/this._numBytesAllocated;console.log(`Bytesallocated:${this._numBytesAllocated}`),console.log(`Bytesunused:${this._numBytesFree}(${Math.round(100*e)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures==null)return;for(let t in this.freeTextures)this.freeTextures[t].forEach(e=>{this.gpgpu.deleteMatrixTexture(e)});for(let t in this.usedTextures)this.usedTextures[t].forEach(e=>{this.gpgpu.deleteMatrixTexture(e)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}function _7(n,t){let e=n;if(t===e.R32F)return 4;if(t===e.R16F)return 2;if(t===e.RGBA32F)return 16;if(t===n.RGBA)return 16;if(t===e.RGBA16F)return 8;throw new Error(`Unknowninternalformat${t}`)}function hD(n,t,e,r,s){let u=F7(t,r),l;if(s){let[p,m]=ic(n[0],n[1]);l=p*m}else{let[p,m]=vf(n[0],n[1]);l=p*m}let h=_7(e,u);return l*h}function F7(n,t){switch(n){case Vn.PACKED_2X2_FLOAT32:return oD(t);case Vn.PACKED_2X2_FLOAT16:return aD(t);case Vn.UNPACKED_FLOAT32:return nD(t);case Vn.UNPACKED_FLOAT16:return rD(t);case Vn.PACKED_4X1_UNSIGNED_BYTE:return sD(t);default:throw new Error(`Unknownphysicaltexturetype${n}`)}}function R7(n){return ft().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?n?Vn.PACKED_2X2_FLOAT32:Vn.UNPACKED_FLOAT32:n?Vn.PACKED_2X2_FLOAT16:Vn.UNPACKED_FLOAT16}function fD(n,t){if(n===Hr.UPLOAD)return Vn.PACKED_2X2_FLOAT32;if(n===Hr.RENDER||n==null)return R7(t);if(n===Hr.DOWNLOAD||n===Hr.PIXELS)return Vn.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknownlogicaltexturetype${n}`)}function pD(n,t,e){return`${n[0]}_${n[1]}_${t}_${e}`}class P7{constructor(t,e){this.variableNames=["A"];let r=new Array(t.length);for(let l=0;l<r.length;l++)r[l]=t[l]*e[l];this.outputShape=r,this.rank=r.length;let s=We(this.rank),u=O7(t);this.userCode=`
`,K9=Km(j9),X9={kernelName:vu,backendName:"webgl",kernelFunc:K9};let Y9="return x * x;",J9=Km(Y9),Z9={kernelName:Mp,backendName:"webgl",kernelFunc:J9};let BD="return (a - b) * (a - b);",Q9=mc({opSnippet:BD,packedOpSnippet:BD}),tZ={kernelName:yu,backendName:"webgl",kernelFunc:Q9};let zD="return a - b;",eZ=mc({opSnippet:zD,packedOpSnippet:zD,supportsComplex:!0,cpuKernelImpl:X8}),nZ={kernelName:bu,backendName:"webgl",kernelFunc:eZ};let rZ="return tan(x);",sZ=Km(rZ),oZ={kernelName:wu,backendName:"webgl",kernelFunc:sZ};let aZ={kernelName:th,backendName:"webgl",kernelFunc:({inputs:n,attrs:t,backend:e})=>{let{x:r}=n,{perm:s}=t,u=e,l=r.shape.length,h=new Array(l);for(let m=0;m<h.length;m++)h[m]=r.shape[s[m]];let p;if(u.shouldExecuteOnCPU([r])){let m=u.texData.get(r.dataId),y=m.values,b=ix(y,r.shape,r.dtype,s,h);p=u.makeTensorInfo(h,r.dtype);let x=u.texData.get(p.dataId);x.values=b}else p=dx(r,s,u);return p}};function iZ(n){let{inputs:t,attrs:e,backend:r}=n,{axis:s}=e,{x:u}=t;bf(u,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");let l=r.readSync(u.dataId),{outputValues:h,outputShape:p,indices:m}=Y8(l,s,u.shape,u.dtype);return[r.makeTensorInfo(p,u.dtype,h),r.makeTensorInfo([m.length],"int32",m)]}let uZ={kernelName:Lp,backendName:"webgl",kernelFunc:iZ};let cZ=[AJ,PJ,MJ,BJ,UJ,XJ,IJ,n9,o9,c9,h9,p9,g9,NJ,b9,ZJ,C9,I9,D9,A9,F9,M9,B9,z9,V9,G9,HJ,qJ,t9,q9,X9,Z9,nZ,tZ,oZ,aZ,uZ];for(let n of cZ)Hp(n);let lZ="2.7.0";let hZ={"tfjs-core":PS,"tfjs-backend-cpu":I6,"tfjs-backend-webgl":SJ,"tfjs-data":uE,"tfjs-layers":bm,"tfjs-converter":VI,tfjs:lZ};o.Abs=hp,o.Acos=dl,o.Acosh=ml,o.AdadeltaOptimizer=Ah,o.AdagradOptimizer=_h,o.AdamOptimizer=Fh,o.AdamaxOptimizer=Rh,o.Add=ri,o.AddN=$v,o.All=T2,o.Any=k2,o.ArgMax=Av,o.ArgMin=_v,o.Asin=gl,o.Asinh=vl,o.Atan=yl,o.Atan2=fp,o.Atanh=bl,o.AvgPool=wl,o.AvgPool3D=Fv,o.AvgPool3DBackprop=S2,o.AvgPoolBackprop=pp,o.BatchMatMul=dp,o.BatchToSpaceND=Rv,o.BroadcastTo=Pv,o.Callback=II,o.CallbackList=xN,o.Cast=pu,o.Ceil=xl,o.ClipByValue=Tl,o.Complex=mp,o.Concat=kl,o.Conv2D=gp,o.Conv2DBackpropFilter=Ov,o.Conv2DBackpropInput=vp,o.Conv3D=yp,o.Conv3DBackpropFilterV2=Mv,o.Conv3DBackpropInputV2=Lv,o.Cos=du,o.Cosh=Sl,o.CropAndResize=C2,o.Cumsum=Bv,o.CustomCallback=kN,o.DataStorage=c,o.DepthToSpace=N2,o.DepthwiseConv2dNative=bp,o.DepthwiseConv2dNativeBackpropFilter=zv,o.DepthwiseConv2dNativeBackpropInput=Wv,o.Diag=I2,o.Dilation2D=wp,o.Dilation2DBackpropFilter=Tp,o.Dilation2DBackpropInput=xp,o.Div=mu,o.EarlyStopping=DI,o.Elu=Cl,o.EluGrad=E2,o.Environment=b2,o.Equal=D2,o.Erf=Nl,o.Exp=Il,o.Expm1=El,o.FFT=kp,o.Fill=Vv,o.FlipLeftRight=Sp,o.Floor=Dl,o.FloorDiv=Uv,o.FromPixels=Bp,o.FusedBatchNorm=$l,o.FusedConv2D=Vp,o.FusedDepthwiseConv2D=Up,o.GatherNd=$2,o.GatherV2=Gv,o.GraphModel=WI,o.Greater=A2,o.GreaterEqual=Hv,o.History=TN,o.IFFT=Cp,o.Identity=Al,o.Imag=Np,o.InputSpec=Fn,o.IsFinite=_l,o.IsInf=Fl,o.IsNan=Rl,o.KernelBackend=f,o.LRN=jv,o.LRNBackprop=M2,o.LayerVariable=Ts,o.LayersModel=Io,o.Less=_2,o.LessEqual=F2,o.LinSpace=R2,o.Log=Pl,o.Log1p=Ol,o.LogSoftmax=qv,o.LogicalAnd=P2,o.LogicalNot=Ip,o.LogicalOr=O2,o.Max=Ml,o.MaxPool=Ll,o.MaxPool3D=Xv,o.MaxPool3DBackprop=L2,o.MaxPoolBackprop=Ep,o.MaxPoolWithArgmax=Dp,o.Maximum=Kv,o.Mean=Yv,o.Min=Jv,o.Minimum=Zv,o.MirrorPad=Bl,o.Mod=Qv,o.MomentumOptimizer=Ph,o.Multiply=gu,o.Negate=ty,o.NonMaxSuppressionV3=ey,o.NonMaxSuppressionV4=$p,o.NonMaxSuppressionV5=Ap,o.NotEqual=zl,o.OP_SCOPE_SUFFIX=aS,o.OneHot=ry,o.OnesLike=ny,o.Optimizer=ko,o.PadV2=_p,o.Pool=UR,o.Pow=sy,o.Prelu=Fp,o.Prod=B2,o.RMSPropOptimizer=Oh,o.RNN=Is,o.Range=z2,o.Real=Rp,o.Reciprocal=Wl,o.Relu=Vl,o.Relu6=Gl,o.Reshape=Ul,o.ResizeBilinear=ay,o.ResizeBilinearGrad=V2,o.ResizeNearestNeighbor=oy,o.ResizeNearestNeighborGrad=W2,o.Reverse=iy,o.RotateWithOffset=zp,o.Round=Hl,o.Rsqrt=ql,o.SGDOptimizer=Uu,o.ScatterNd=U2,o.SelectV2=uy,o.Selu=jl,o.Sequential=Ii,o.Sigmoid=Yl,o.Sign=Xl,o.Sin=vu,o.Sinh=Kl,o.Slice=Pp,o.Softmax=hy,o.Softplus=Jl,o.SpaceToBatchND=Op,o.SparseToDense=G2,o.SplitV=ly,o.Sqrt=Zl,o.Square=Mp,o.SquaredDifference=yu,o.Step=eh,o.StridedSlice=H2,o.Sub=bu,o.Sum=cy,o.SymbolicTensor=k
`;return H[H.length-1]=" "+H[H.length-1]+"]"+(d?"":Ct),H}function Lf(o){for(var a=[],i=0;i<o.length;i+=2)a.push([o[i],o[i+1]]);return a}var gg=function(){function o(a,i,c){var f=this;if(this.dtype=i,this.shape=a.slice(),this.size=mn(a),c!=null){var d=c.length;U(d===this.size,function(){return"Length of values '"+d+"' does not match the size "+("inferred by the shape '"+f.size+"'.")})}if(i==="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=c||i$(i,this.size),this.strides=Nc(a)}return o.prototype.set=function(a){for(var i=this,c=[],f=1;f<arguments.length;f++)c[f-1]=arguments[f];c.length===0&&(c=[0]),U(c.length===this.rank,function(){return"The number of provided coordinates ("+c.length+") must "+("match the rank ("+i.rank+")")});var d=this.locToIndex(c);this.values[d]=a},o.prototype.get=function(){for(var a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];a.length===0&&(a=[0]);for(var c=0,f=0,d=a;f<d.length;f++){var g=d[f];if(g<0||g>=this.shape[c]){var v="Requested out of range element at "+a+". "+(" Buffer shape="+this.shape);throw new Error(v)}c++}for(var w=a[a.length-1],T=0;T<a.length-1;++T)w+=this.strides[T]*a[T];return this.values[w]},o.prototype.locToIndex=function(a){if(this.rank===0)return 0;if(this.rank===1)return a[0];for(var i=a[a.length-1],c=0;c<a.length-1;++c)i+=this.strides[c]*a[c];return i},o.prototype.indexToLoc=function(a){if(this.rank===0)return[];if(this.rank===1)return[a];for(var i=new Array(this.shape.length),c=0;c<i.length-1;++c)i[c]=Math.floor(a/this.strides[c]),a-=i[c]*this.strides[c];return i[i.length-1]=a,i},Object.defineProperty(o.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),o.prototype.toTensor=function(){return io().makeTensor(this.values,this.shape,this.dtype)},o}(),io=null,$c=null;function NQ(o){io=o}function IQ(o){$c=o}var ut=function(){function o(a,i,c,f){this.kept=!1,this.isDisposedInternal=!1,this.shape=a.slice(),this.dtype=i||"float32",this.size=mn(a),this.strides=Nc(a),this.dataId=c,this.id=f,this.rankType=this.rank<5?this.rank.toString():"higher"}return Object.defineProperty(o.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),o.prototype.buffer=function(){return qt(this,void 0,void 0,function(){var a;return jt(this,function(i){switch(i.label){case 0:return[4,this.data()];case 1:return a=i.sent(),[2,$c.buffer(this.shape,this.dtype,a)]}})})},o.prototype.bufferSync=function(){return $c.buffer(this.shape,this.dtype,this.dataSync())},o.prototype.array=function(){return qt(this,void 0,void 0,function(){var a;return jt(this,function(i){switch(i.label){case 0:return[4,this.data()];case 1:return a=i.sent(),[2,Ic(this.shape,a)]}})})},o.prototype.arraySync=function(){return Ic(this.shape,this.dataSync())},o.prototype.data=function(){return qt(this,void 0,void 0,function(){var a,i;return jt(this,function(c){switch(c.label){case 0:return this.throwIfDisposed(),a=io().read(this.dataId),this.dtype==="string"?[4,a]:[3,2];case 1:i=c.sent();try{return[2,i.map(function(f){return UT(f)})]}catch(f){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}c.label=2;case 2:return[2,a]}})})},o.prototype.dataSync=function(){this.throwIfDisposed();var a=io().readSync(this.dataId);if(this.dtype==="string")try{return a.map(function(i){return UT(i)})}catch(i){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return a},o.prototype.bytes=function(){return qt(this,void 0,void 0,function(){var a;return jt(this,function(i){switch(i.label){case 0:return this.throwIfDisposed(),[4,io().read(this.dataId)];case 1:return a=i.sent(),this.dtype==="string"?[2,a]:[2,new Uint8Array(a.buffer)]}})})},o.prototype.dispose=function(){if(this.isDisposed)return;io().disposeTensor(this),this.isDisposedInternal=!0},Object.defineProperty(o.prototype,"isDisposed",{get:function(){return this.
`)+"Manifest JSON has weights with names: "+(w.join(", ")+"."));return N=d.reduce(function(O,H,K){return H&&O.push(K),O},[]),E=[],N.forEach(function(O){i[O].paths.forEach(function(H){var K=c+(c.endsWith("/")?"":"/")+H;E.push(K)})}),[4,o(E)];case 1:return k=G.sent(),$={},M=0,N.forEach(function(O){for(var H=i[O].paths.length,K=0,nt=0;nt<H;nt++)K+=k[M+nt].byteLength;for(var ct=new ArrayBuffer(K),dt=new Uint8Array(ct),Ct=0,St=0;St<H;St++){var It=new Uint8Array(k[M+St]);dt.set(It,Ct),Ct+=It.byteLength}var Gt=g[O];Gt.forEach(function(Et){var Wt=ct.slice(Et.groupOffset,Et.groupOffset+Et.sizeBytes),_t=DA(Wt,[Et.manifestEntry]);for(var Kt in _t)$[Kt]=_t[Kt]}),M+=H}),[2,$]}})})}}var Itt="application/octet-stream",Ett="application/json",UA=function(){function o(a,i){if(this.DEFAULT_METHOD="POST",i==null&&(i={}),this.weightPathPrefix=i.weightPathPrefix,this.onProgress=i.onProgress,this.weightUrlConverter=i.weightUrlConverter,i.fetchFunc!=null?(U(typeof i.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=i.fetchFunc):this.fetch=Fe().platform.fetch,U(a!=null&&a.length>0,function(){return"URL path for http must not be null, undefined or empty."}),Array.isArray(a)&&U(a.length===2,function(){return"URL paths for http must have a length of 2, "+("(actual length is "+a.length+").")}),this.path=a,i.requestInit!=null&&i.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=i.requestInit||{}}return o.prototype.save=function(a){return qt(this,void 0,void 0,function(){var i,c,f,d;return jt(this,function(g){switch(g.label){case 0:if(a.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return i=Object.assign({method:this.DEFAULT_METHOD},this.requestInit),i.body=new FormData,c=[{paths:["./model.weights.bin"],weights:a.weightSpecs}],f={modelTopology:a.modelTopology,format:a.format,generatedBy:a.generatedBy,convertedBy:a.convertedBy,userDefinedMetadata:a.userDefinedMetadata,weightsManifest:c},i.body.append("model.json",new Blob([JSON.stringify(f)],{type:Ett}),"model.json"),a.weightData!=null&&i.body.append("model.weights.bin",new Blob([a.weightData],{type:Itt}),"model.weights.bin"),[4,this.fetch(this.path,i)];case 1:if(d=g.sent(),d.ok)return[2,{modelArtifactsInfo:Wf(a),responses:[d]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+(d.status+"."))}})})},o.prototype.load=function(){return qt(this,void 0,void 0,function(){var a,i,c,f,d,g,v,w,T,N,E,k,$,M,G;return jt(this,function(O){switch(O.label){case 0:return[4,this.fetch(this.path,this.requestInit)];case 1:if(a=O.sent(),!a.ok)throw new Error("Request to "+this.path+" failed with status code "+(a.status+". Please verify this URL points to ")+"the model JSON of the model to load.");O.label=2;case 2:return O.trys.push([2,4,,5]),[4,a.json()];case 3:return i=O.sent(),[3,5];case 4:throw c=O.sent(),f="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?f+=" 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.":f+=" Please make sure the server is serving valid JSON for this request.",new Error(f);case 5:if(d=i.modelTopology,g=i.weightsManifest,v=i.generatedBy,w=i.convertedBy,T=i.format,N=i.userDefinedMetadata,d==null&&g==null)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return g!=null?[4,this.loadWeights(g)]:[3,7];case 6:$=O.sent(),E=$[0],k=$[1],O.label=7;case 7:return M={modelTopology:d,weightSpecs:E,weightData:k,userDefinedMetadata:N,generatedBy:v,convertedBy:w,format:T},G=i.modelInitializer,G&&(M.modelInitial
`)+("Expected: "+T+"."))}}function Qtt(o,a){o().then(function(){return a.fail()},function(){return a()})}function tet(o,a){var i=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?[a]:a;return Oa(o)||Oa(o[0])||Oa(a)||Oa(a[0])?hk(o,i,function(c,f){return c==f}):hk(o,a,function(c,f){return fk(c,f,0)})}function eet(o,a,i){if(i==null&&(i=lk()),!fk(o,a,i))throw new Error("Numbers differ: actual === "+o+", expected === "+a)}function fk(o,a,i){return!isFinite(o)&&!isFinite(a)?!0:!(isNaN(o)||isNaN(a)||Math.abs(o-a)>i)}function net(o,a,i){for(var c=0;c<o.length;c++)if(o[c]<a||o[c]>i)throw new Error("Value out of range:"+o[c]+" low: "+a+", high: "+i)}function ret(o,a){expect(new Float32Array(o)).toEqual(new Float32Array(a))}var set={__proto__:null,TEST_EPSILON_FLOAT16:u_,expectArraysClose:Ztt,testEpsilon:lk,expectPromiseToFail:Qtt,expectArraysEqual:tet,expectNumbersClose:eet,expectValuesInRange:net,expectArrayBuffersEqual:ret};var oet="2.7.0";function aet(){Fe().set("PROD",!0)}function iet(){Fe().set("DEBUG",!0)}function uet(){Fe().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Mn(o){Fe().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(o+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function cet(){Z.disposeVariables()}function het(){return Z}function fet(){return Z.memory()}function pet(o){return Z.profile(o)}function En(o,a){return Z.tidy(o,a)}function wr(o){var a=XT(o);a.forEach(function(i){return i.dispose()})}function c_(o){return Z.keep(o)}function det(o){return Z.time(o)}function met(o){return Z.setBackend(o)}function get(){return Z.ready()}function vet(){return Z.backendName}function yet(o){Z.removeBackend(o)}function bet(o){return Z.findBackend(o)}function wet(o){return Z.findBackendFactory(o)}function xet(o,a,i){return i===void 0&&(i=1),Z.registerBackend(o,a,i)}function Tet(){return Z.backend}function ket(o,a){Fe().setPlatform(o,a)}function Cet(o,a){var i,c=W(o,"a","add"),f=W(a,"b","add");i=pn(c,f),c=i[0],f=i[1];var d=function(v,w){var T=v.add(c,f);return w([c,f]),T},g={a:c,b:f};return Z.runKernelFunc(d,g,null,hg)}var Yt=Y({add_:Cet});function Net(o,a){var i,c=W(o,"a","floorDiv"),f=W(a,"b","floorDiv");i=pn(c,f),c=i[0],f=i[1];var d=function(v,w){var T=v.floorDiv(c,f);return w([c,f]),T},g={a:c,b:f};return Z.runKernelFunc(d,g,null,D1)}var pk=Y({floorDiv_:Net});function Iet(o,a){var i,c=W(o,"a","div"),f=W(a,"b","div");if(i=pn(c,f),c=i[0],f=i[1],c.dtype==="int32"&&f.dtype==="int32")return pk(c,f);var d=function(w,T){var N=w.realDivide(c,f);return T([c,f]),N},g={a:c,b:f},v={};return Z.runKernelFunc(d,g,null,k1,v)}var ae=Y({div_:Iet});function Eet(o,a){var i,c=W(o,"a","mul"),f=W(a,"b","mul");i=pn(c,f),c=i[0],f=i[1];var d=function(v,w){var T=v.multiply(c,f);return w([c,f]),T},g={a:c,b:f};return Z.runKernelFunc(d,g,null,X1)}var pt=Y({mul_:Eet});function Det(o){var a=W(o,"x","abs"),i={x:a};return Z.runKernelFunc(function(c,f){return f([a]),a.dtype==="complex64"?c.complexAbs(a):c.abs(a)},i,null,Yx)}var _r=Y({abs_:Det});function $et(o){var a=W(o,"x","acos"),i={x:a};return Z.runKernelFunc(function(c,f){var d=c.acos(a);return f([a]),d},i,null,Jx)}var l_=Y({acos_:$et});function Aet(o){var a=W(o,"x","acosh"),i={x:a};return Z.runKernelFunc(function(c,f){var d=c.acosh(a);return f([a]),d},i,null,Zx)}var h_=Y({acosh_:Aet});function _et(o){U(Array.isArray(o),function(){return"The argument passed to tf.addN() must be a list of tensors"}),U(o.length>=1,function(){return"Must pass at least one tensor to tf.addN(), but got "+(""+o.length)});var a=o.map(function(d,g){return W(d,"tensors"+g,"addN")}),i=a[0];a.forEach(function(d){if(d.dtype!==i.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),a.forEach(function(d){if(!Rs(d.shape,i.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});var c=function(d,g){var v=d.addN(a);return g(a),v},f=a;return Z.runKernelFunc(c,f,null,Qx)}var Fet=Y({addN_:_et});function dk(o,a){for(var i=0;i<o.length;++i)if(o[o.length-i-1]!==a-1-i)
withdtype`+g.dtype+". ")});var c=function(g,v){var w=Qe(a,i[0].shape)[0],T=S_(i.map(function(k){return k.shape}),w);if(mn(T)===0)return za([],T);if(i=i.filter(function(k){return k.size>0}),i.length===1)return i[0];var N=i.map(function(k){return k.shape});k_(N,w);var E=g.concat(i,w);return v(i),E},f=i,d={axis:a};return Z.runKernelFunc(c,f,null,d1,d)}var qn=Y({concat_:Zet});function Qet(o){var a=W(o,"x","sigmoid"),i={x:a};return Z.runKernelFunc(function(c,f){var d=c.sigmoid(a);return f([d]),d},i,null,vT)}var Hi=Y({sigmoid_:Qet});function tnt(o,a,i){var c=W(o,"x","slice");if(c.rank===0)throw new Error("Slicing scalar is not possible");var f=function(v,w){var T=ck(c,a,i),N=T[0],E=T[1];return KA(c,N,E),w([c]),v.slice(c,N,E)},d={x:c},g={begin:a,size:i};return Z.runKernelFunc(f,d,null,pT,g)}var De=Y({slice_:tnt});function ent(o){var a=W(o,"x","tanh"),i={x:a};return Z.runKernelFunc(function(c,f){var d=c.tanh(a);return f([d]),d},i,null,IT)}var Sg=Y({tanh_:ent});function nnt(o,a,i,c,f,d){var g=W(o,"forgetBias","basicLSTMCell"),v=W(a,"lstmKernel","basicLSTMCell"),w=W(i,"lstmBias","basicLSTMCell"),T=W(c,"data","basicLSTMCell"),N=W(f,"c","basicLSTMCell"),E=W(d,"h","basicLSTMCell"),k=qn([T,E],1),$=Ce(k,v),M=Yt($,w),G=M.shape[0],O=M.shape[1]/4,H=[G,O],K=De(M,[0,0],H),nt=De(M,[0,O],H),ct=De(M,[0,O*2],H),dt=De(M,[0,O*3],H),Ct=Yt(pt(Hi(K),Sg(nt)),pt(N,Hi(Yt(g,ct)))),St=pt(Sg(Ct),Hi(dt));return[Ct,St]}var rnt=Y({basicLSTMCell_:nnt});function snt(o,a,i){var c=W(o,"x","batchToSpaceND"),f=a.reduce(function(w,T){return w*T});U(c.rank>=1+a.length,function(){return"input rank is "+c.rank+" but should be > than blockShape.length "+a.length}),U(i.length===a.length,function(){return"crops.length is "+i.length+" but should be equal to blockShape.length "+a.length}),U(c.shape[0]%f===0,function(){return"input tensor batch is "+c.shape[0]+" but is not divisible by the product of "+("the elements of blockShape "+a.join(" * ")+" === "+f)});var d=function(w){return w.batchToSpaceND(c,a,i)},g={x:c},v={blockShape:a,crops:i};return Z.runKernelFunc(d,g,null,l1,v)}var Cg=Y({batchToSpaceND_:snt});function ont(o){var a;return o.rank===0||o.rank===1?a=it(o,[1,1,1,o.size]):o.rank===2?a=it(o,[1,1,o.shape[0],o.shape[1]]):o.rank===3?a=it(o,[1,o.shape[0],o.shape[1],o.shape[2]]):a=o,a}function ant(o,a,i,c,f,d){d==null&&(d=.001);var g=W(o,"x","batchNorm"),v=W(a,"mean","batchNorm"),w=W(i,"variance","batchNorm"),T;f!=null&&(T=W(f,"scale","batchNorm"));var N;c!=null&&(N=W(c,"offset","batchNorm")),U(v.rank===w.rank,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),U(N==null||v.rank===N.rank,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),U(T==null||v.rank===T.rank,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var E=ont(g),k=function(O,H){return H([E,v,w,T]),O.batchNorm(E,Ng(v),Ng(w),Ng(N),Ng(T),d)},$={x:E,scale:T,offset:N,mean:v,variance:w},M={varianceEpsilon:d},G=Z.runKernelFunc(k,$,null,$1,M);return it(G,g.shape)}function Ng(o){return o==null?null:o.rank===0?it(o,[o.size]):o.rank===1?o:o.rank===2?it(o,[1,1,o.shape[0],o.shape[1]]):o.rank===3?it(o,[1,o.shape[0],o.shape[1],o.shape[2]]):o}var Hf=Y({batchNorm_:ant});function int(o,a,i,c,f,d){var g=W(o,"x","batchNorm"),v=W(a,"mean","batchNorm"),w=W(i,"variance","batchNorm"),T;f!=null&&(T=W(f,"scale","batchNorm"));var N;return c!=null&&(N=W(c,"offset","batchNorm")),U(g.rank===2,function(){return"Error in batchNorm2D: x must be rank 2 but got rank "+(g.rank+".")}),U(v.rank===2||v.rank===1,function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but "+("got rank "+v.rank+".")}),U(w.rank===2||w.rank===1,function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 "+("but got rank "+w.rank+".")}),T!=null&&U(T.rank===2||T.rank===1,function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 "+("but got rank "+T.rank+".")}),N!=null&&U(N.rank===2||N.rank===1,function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 "+("but got ran
`+c.shape}),U(g%(a*a)===0,function(){return"Dimension size must be evenly divisible by "+a*a+" but is "+g+" for depthToSpace with input shape "+c.shape});var v=function(N){return N.depthToSpace(c,a,i)},w={x:c},T={blockSize:a,dataFormat:i};return Z.runKernelFunc(v,w,null,D$,T)}var $_=Y({depthToSpace_:Ont});function Mnt(o,a,i,c,f,d,g){f===void 0&&(f="NHWC"),d===void 0&&(d=[1,1]);var v=W(o,"x","depthwiseConv2d"),w=W(a,"filter","depthwiseConv2d"),T=v,N=!1;v.rank===3&&(N=!0,T=it(v,[1,v.shape[0],v.shape[1],v.shape[2]])),U(T.rank===4,function(){return"Error in depthwiseConv2d: input must be rank 4, but got "+("rank "+T.rank+".")}),U(w.rank===4,function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+(w.rank+".")}),U(T.shape[3]===w.shape[2],function(){return"Error in depthwiseConv2d: number of input channels "+("("+T.shape[3]+") must match the inChannels dimension in ")+("filter "+w.shape[2]+".")}),g!=null&&U(fn(c),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+g+" but got pad "+c+".")});var E=function(G,O){d==null&&(d=[1,1]),U(xr(i,d),function(){return"Error in depthwiseConv2d: Either strides or dilations must be "+("1. Got strides "+i+" and dilations '"+d+"'")});var H=Os(T.shape,w.shape,i,d,c,g,!0),K=G.depthwiseConv2D(T,w,H);return O([T,w]),K},k={x:T,filter:w},$={strides:i,pad:c,dataFormat:f,dilations:d,dimRoundingMode:g},M=Z.runKernelFunc(E,k,null,x1,$);return N?it(M,[M.shape[1],M.shape[2],M.shape[3]]):M}var qf=Y({depthwiseConv2d_:Mnt});function Lnt(o){var a=W(o,"x","diag"),i=function(f){var d=it(a,[a.size]),g=f.diag(d),v=o.shape.concat(o.shape);return it(g,v)},c={x:a};return Z.runKernelFunc(i,c,null,_$)}var Bnt=Y({diag_:Lnt});function znt(o,a,i,c,f,d){f===void 0&&(f=[1,1]),d===void 0&&(d="NHWC");var g=W(o,"x","dilation2d"),v=W(a,"filter","dilation2d");U(g.rank===3||g.rank===4,function(){return"Error in dilation2d: input must be rank 3 or 4, but got rank "+(g.rank+".")}),U(v.rank===3,function(){return"Error in dilation2d: filter must be rank 3, but got rank "+(v.rank+".")}),U(d==="NHWC",function(){return"Error in dilation2d: Only NHWC is currently supported, "+("but got dataFormat of "+d)});var w=g,T=!1;g.rank===3&&(w=it(g,[1,g.shape[0],g.shape[1],g.shape[2]]),T=!0);var N={x:w,filter:v},E={strides:i,pad:c,dilations:f},k=Z.runKernel(T1,N,E);return T?it(k,[k.shape[1],k.shape[2],k.shape[3]]):k}var A_=Y({dilation2d_:znt});function Wnt(o,a){for(var i=o.length,c=[],f=0;f<i;f++){var d=i-1-f,g=o[d]||1,v=a[a.length-1-f]||1;v>1&&g===1&&c.unshift(d)}return c}function Dn(o,a){for(var i=[],c=0;c<a.length;c++){var f=o[o.length-c-1],d=a.length-c-1,g=a[d];(f==null||f===1&&g>1)&&i.unshift(d)}return i}function tn(o,a){for(var i=[],c=Math.max(o.length,a.length),f=0;f<c;f++){var d=o[o.length-f-1];d==null&&(d=1);var g=a[a.length-f-1];if(g==null&&(g=1),d===1)i.unshift(g);else if(g===1)i.unshift(d);else if(d!==g){var v="Operands could not be broadcast together with shapes "+(o+" and "+a+".");throw Error(v)}else i.unshift(d)}return i}function Vnt(o,a){var i,c=W(o,"a","equal"),f=W(a,"b","equal");i=pn(c,f),c=i[0],f=i[1],tn(c.shape,f.shape);var d=function(v){return v.equal(c,f)},g={a:c,b:f};return Z.runKernelFunc(d,g,null,O$)}var jf=Y({equal_:Vnt});function Unt(o,a,i){var c=W(a,"a","where"),f=W(i,"b","where"),d=W(o,"condition","where","bool"),g=tn(c.shape,f.shape),v=Ig(c,g),w=Ig(f,g);d.rank===1&&U(d.shape[0]===c.shape[0],function(){return"The first dimension of `a` must match the size of `condition`."}),d.rank!==1&&Ee(d.shape,w.shape,"Error in where: ");var T=function(E,k){var $=E.select(d,v,w);return k([d]),$},N={condition:d,t:v,e:w};return Z.runKernelFunc(T,N,null,hT)}var Ms=Y({where_:Unt});function Gnt(o){var a=W(o,"x","zerosLike"),i={x:a};return Z.runKernelFunc(function(c){return c.zerosLike(a)},i,null,_T)}var ke=Y({zerosLike_:Gnt});function Hnt(o,a){var i,c=W(o,"a","div"),f=W(a,"b","div");i=pn(c,f),c=i[0],f=i[1];var d=ae(c,f),g=ke(d),v=jf(f,g);return Ms(v,g,d)}var __=Y({divNoNan_:Hnt});function qnt(o,a){var i=W(o,"t1","dot"),c=W(a,"t2","dot");U((i.rank===1||i.r
rank`+d.rank+"."}),U(fn(a),function(){return"Error in localResponseNormalization: depthRadius must be an "+("integer but got depthRadius "+a+".")});var g=d,v=!1;d.rank===3&&(v=!0,g=it(d,[1,d.shape[0],d.shape[1],d.shape[2]]));var w=function(k,$){var M=k.localResponseNormalization4D(g,a,i,c,f);return $([g,M]),M},T={x:g},N={depthRadius:a,bias:i,alpha:c,beta:f},E=Z.runKernelFunc(w,T,null,z1,N);return v?it(E,[E.shape[1],E.shape[2],E.shape[3]]):E}var V_=Y({localResponseNormalization_:vrt});function yrt(o){var a=W(o,"x","log"),i={x:a};return Z.runKernelFunc(function(c,f){var d=c.log(a);return f([a]),d},i,null,M1)}var Ki=Y({log_:yrt});function brt(o){var a=W(o,"x","log1p"),i={x:a};return Z.runKernelFunc(function(c,f){var d=c.log1p(a);return f([a]),d},i,null,L1)}var Sk=Y({log1p_:brt});function wrt(o){return U(Ma(o),function(){return"The f passed in grad(f) must be a function"}),function(a,i){var c=W(a,"x","tf.grad",null),f=i!=null?W(i,"dy","tf.grad"):null;return Z.tidy(function(){var d=Z.gradients(function(){return o(c)},[c],f),g=d.value,v=d.grads;return f!=null&&Ee(g.shape,f.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Fg(v),v[0]})}}function xrt(o){return U(Ma(o),function(){return"The f passed in grads(f) must be a function"}),function(a,i){U(Array.isArray(a),function(){return"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"});var c=zf(a,"args","tf.grads",null),f=i!=null?W(i,"dy","tf.grads"):null;return Z.tidy(function(){var d=Z.gradients(function(){return o.apply(void 0,c)},c,f),g=d.value,v=d.grads;return f!=null&&Ee(g.shape,f.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Fg(v),v})}}function Trt(o){return U(Ma(o),function(){return"The f passed in valueAndGrad(f) must be a function"}),function(a,i){U(a instanceof ut,function(){return"The x passed in valueAndGrad(f)(x) must be a tensor"}),U(i==null||i instanceof ut,function(){return"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"});var c=Z.gradients(function(){return o(a)},[a],i),f=c.grads,d=c.value;return Fg(f),{grad:f[0],value:d}}}function krt(o){return U(Ma(o),function(){return"The f passed in valueAndGrads(f) must be a function"}),function(a,i){U(Array.isArray(a)&&a.every(function(f){return f instanceof ut}),function(){return"The args passed in valueAndGrads(f)(args) must be array of tensors"}),U(i==null||i instanceof ut,function(){return"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"});var c=Z.gradients(function(){return o.apply(void 0,a)},a,i);return i!=null&&Ee(c.value.shape,i.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Fg(c.grads),c}}function U_(o,a){U(Ma(o),function(){return"The f passed in variableGrads(f) must be a function"}),U(a==null||Array.isArray(a)&&a.every(function(E){return E instanceof Bf}),function(){return"The varList passed in variableGrads(f, varList) must be an array of variables"});var i=a!=null;if(!i){a=[];for(var c in Z.registeredVariables)a.push(Z.registeredVariables[c])}var f=i?a.filter(function(E){return!E.trainable}):null,d=a.length;a=a.filter(function(E){return E.trainable}),U(a.length>0,function(){return"variableGrads() expects at least one of the input variables to "+("be trainable, but none of the "+d+" variables is ")+"trainable."});var g=!0,v=Z.gradients(o,a,null,g),w=v.value,T=v.grads;U(T.some(function(E){return E!=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()."}),U(w.rank===0,function(){return"The f passed in variableGrads(f) must return a scalar, but it "+("returned a rank-"+w.rank+" tensor")});var N={};return a.forEach(function(E,k){T[k]!=null&&(N[E.name]=T[k])}),f!=null&&f.forEach(function(E){return N[E.name]=null}),{value:w,grads:N}}function ho(o){return Z.customGrad(o)}function Fg(o){var a=o.filter(function(i){return i==null}).length;
thefyoupassedenclosesalloperationsthatleadfromxtoy.`)}function Srt(o){var a=W(o,"x","neg"),i={x:a};return Z.runKernelFunc(function(c){return c.neg(a)},i,null,Y1)}var $n=Y({neg_:Srt});function Crt(o){var a=W(o,"x","softplus"),i={x:a};return Z.runKernelFunc(function(c,f){var d=c.softplus(a);return f([a]),d},i,null,yT)}var Ck=Y({softplus_:Crt});function Nrt(o){var a=W(o,"x","logSigmoid"),i=ho(function(c){var f=$n(Ck($n(c))),d=function(g){var v=pt(g,Hi($n(c)));return v};return{value:f,gradFunc:d}});return i(a)}var G_=Y({logSigmoid_:Nrt});function Irt(o,a,i){a===void 0&&(a=null),i===void 0&&(i=!1);var c=W(o,"x","max"),f=function(v,w){var T=Qe(a,c.shape),N=T,E=Ps(N,c.rank),k=c;E!=null&&(k=On(c,E),N=lo(N.length,k.rank));var $=v.max(k,N);E!=null&&k.dispose();var M=$;if(i){var G=Jr(M.shape,Qe(a,c.shape));M=it(M,G),$.dispose()}return w([c,M]),M},d={x:c},g={reductionIndices:a,keepDims:i};return Z.runKernelFunc(f,d,null,W1,g)}var Xi=Y({max_:Irt});function Ert(o,a){var i,c=W(o,"a","sub"),f=W(a,"b","sub");i=pn(c,f),c=i[0],f=i[1];var d=function(v,w){var T=v.subtract(c,f);return w([c,f]),T},g={a:c,b:f};return Z.runKernelFunc(d,g,null,CT)}var Qt=Y({sub_:Ert});function Drt(o,a,i){a===void 0&&(a=null),i===void 0&&(i=!1);var c=W(o,"x","sum");c.dtype==="bool"&&(c=Bt(c,"int32"));var f=function(v,w){w([c]);var T=Qe(a,c.shape),N=Ps(T,c.rank),E=T,k=c;N!=null&&(k=On(c,N),E=lo(E.length,c.rank));var $=v.sum(k,E);if(i){var M=Jr($.shape,T);$=it($,M)}return $},d={x:c},g={axis:a,keepDims:i};return Z.runKernelFunc(f,d,null,wT,g)}var ie=Y({sum_:Drt});function $rt(o,a){a===void 0&&(a=-1);var i=W(o,"logits","logSoftmax");if(a===-1&&(a=i.rank-1),a!==i.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. "+("Logits was rank "+i.rank+" and axis was "+a));var c=function(g,v){var w=!0,T=Xi(o,a,!0),N=Qt(o,T),E=Qt(Bt(N,"float32"),Ki(ie(Ls(N),a,w)));return v([E]),E},f={logits:i},d={axis:a};return Z.runKernelFunc(c,f,null,B1,d)}var H_=Y({logSoftmax_:$rt});function Art(o,a,i){a===void 0&&(a=null),i===void 0&&(i=!1);var c=W(o,"x","logSumExp"),f=Qe(a,c.shape),d=Xi(c,f,!0),g=Qt(c,d),v=Ls(g),w=ie(v,f),T=Ki(w),N=Yt(it(d,T.shape),T);if(i){var E=Jr(N.shape,f);return it(N,E)}return N}var Nk=Y({logSumExp_:Art});function _rt(o,a){var i=W(o,"a","logicalAnd","bool"),c=W(a,"b","logicalAnd","bool");tn(i.shape,c.shape);var f={a:i,b:c};return Z.runKernelFunc(function(d){return d.logicalAnd(i,c)},f,null,j$)}var Yi=Y({logicalAnd_:_rt});function Frt(o){var a=W(o,"x","logicalNot","bool"),i={x:a};return Z.runKernelFunc(function(c){return c.logicalNot(a)},i,null,K$)}var Rg=Y({logicalNot_:Frt});function Rrt(o,a){var i=W(o,"a","logicalOr","bool"),c=W(a,"b","logicalOr","bool");tn(i.shape,c.shape);var f={a:i,b:c};return Z.runKernelFunc(function(d){return d.logicalOr(i,c)},f,null,X$)}var Ik=Y({logicalOr_:Rrt});function Prt(o,a){var i=W(o,"a","logicalXor","bool"),c=W(a,"b","logicalXor","bool");return tn(i.shape,c.shape),Yi(Ik(o,a),Rg(Yi(o,a)))}var q_=Y({logicalXor_:Prt});function Ort(o,a,i,c,f){var d=W(o,"x","maxPool"),g=1,v=d,w=!1;d.rank===3&&(w=!0,v=it(d,[1,d.shape[0],d.shape[1],d.shape[2]])),U(v.rank===4,function(){return"Error in maxPool: input must be rank 4 but got rank "+v.rank+"."}),U(xr(i,g),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+i+" and dilations '"+g+"'")}),f!=null&&U(fn(c),function(){return"Error in maxPool: pad must be an integer when using, "+("dimRoundingMode "+f+" but got pad "+c+".")});var T=function($,M){var G=Oc(v.shape,a,i,1,c,f),O;return G.filterWidth===1&&G.filterHeight===1&&Rs(G.inShape,G.outShape)?O=v.clone():O=$.maxPool(v,G),M([v,O]),O},N={x:v},E={filterSize:a,strides:i,pad:c,dimRoundingMode:f},k=Z.runKernelFunc(T,N,null,U1,E);return w?it(k,[k.shape[1],k.shape[2],k.shape[3]]):k}var Ek=Y({maxPool_:Ort});function Mrt(o,a,i,c,f,d,g){a===void 0&&(a=[1,1,1]),d===void 0&&(d="NDHWC"),g==null?g=[1,1,1]:Mn("dilations is deprecated, this field will be gone in v3.0.0.");var v=W(o,"x","maxPool3d"),w=v,T=!1;v.rank===4&&(T=!0,w=it(v,[1,v.shape[0],v.shape[1],v.shape[2],v.shape[3]])),U(w