/*! For license information please see index.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["vscode-languagedetection"]=t():e["vscode-languagedetection"]=t()}(this,(function(){return(()=>{var e={5528:(e,t,n)=>{"use strict";n.r(t),n.d(t,{MathBackendCPU:()=>i,shared:()=>r,version_cpu:()=>dt});var r={};n.r(r),n.d(r,{addImpl:()=>x,bincountImpl:()=>T,bincountReduceImpl:()=>_,ceilImpl:()=>$,concatImpl:()=>O,equalImpl:()=>B,expImpl:()=>R,expm1Impl:()=>L,floorImpl:()=>q,gatherNdImpl:()=>j,gatherV2Impl:()=>K,greaterEqualImpl:()=>Q,greaterImpl:()=>X,lessEqualImpl:()=>ae,lessImpl:()=>te,linSpaceImpl:()=>ie,logImpl:()=>ue,maxImpl:()=>pe,maximumImpl:()=>de,minimumImpl:()=>fe,multiplyImpl:()=>be,negImpl:()=>xe,notEqualImpl:()=>Se,prodImpl:()=>Me,rangeImpl:()=>De,rsqrtImpl:()=>Fe,sigmoidImpl:()=>Ce,simpleAbsImpl:()=>u,sliceImpl:()=>ze,sparseFillEmptyRowsImpl:()=>We,sparseReshapeImpl:()=>He,sparseSegmentReductionImpl:()=>qe,sqrtImpl:()=>Ge,squaredDifferenceImpl:()=>Ke,stridedSliceImpl:()=>Je,stringNGramsImpl:()=>Ye,stringSplitImpl:()=>tt,stringToHashBucketFastImpl:()=>nt,subImpl:()=>rt,tileImpl:()=>it,topKImpl:()=>ct,transposeImpl:()=>_e,uniqueImpl:()=>pt});var a=n(5363);function s(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&a.util.assert("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}const o=a.kernel_impls.whereImpl;class i extends a.KernelBackend{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new a.DataStorage(this,(0,a.engine)())}nextDataId(){return i.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,(0,a.env)().get("IS_NODE")&&a.backend_util.warn("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================"));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&a.util.isString(n[0])){const s=n.map((e=>a.util.encodeString(e)));r=this.write(s,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){if(this.data.has(e)){return this.data.get(e).refCount}return 0}incRef(e){this.data.get(e).refCount++}decRef(e){if(this.data.has(e)){this.data.get(e).refCount--}}move(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);if("complex64"===t){const e=this.readSync(n.real.dataId),t=this.readSync(n.imag.dataId);return a.backend_util.mergeRealAndImagArrays(e,t)}return this.data.get(e).values}bufferSync(e){const t=this.readSync(e.dataId);let n=t;if("string"===e.dtype)try{n=t.map((e=>a.util.decodeString(e)))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return(0,a.buffer)(e.shape,e.dtype,n)}makeOutput(e,t,n){const r=this.write(e,t,n);return(0,a.engine)().makeTensorFromDataId(r,t,n,this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=a.util.now();e();return{kernelMs:a.util.now()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){s([e],"where");const t=this.readSync(e.dataId);return o(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}function u(e){const t=new Float32Array(e.length);for(let n=0;n{const{x:t}=e.inputs,n=e.backend;s(t,"abs");let r=new Float32Array(a.util.sizeFromShape(t.shape));return r=u(n.data.get(t.dataId).values),n.makeOutput(r,t.shape,"float32")}};function c(e){return(t,n,r,s,o)=>{const i=a.backend_util.assertAndGetBroadcastShape(t,n),u=i.length,l=a.util.computeStrides(i),c=a.util.sizeFromShape(i),p=a.util.getTypedArrayFromDType(o,c),d=t.length,h=n.length,m=a.util.computeStrides(t),f=a.util.computeStrides(n),g=a.backend_util.getBroadcastDims(t,i),y=a.backend_util.getBroadcastDims(n,i);if(g.length+y.length===0)for(let t=0;to[e]=0));const i=a.util.locToIndex(o,d,m),c=n.slice(-h);y.forEach((e=>c[e]=0));const b=a.util.locToIndex(c,h,f);p[t]=e(r[i],s[b])}return[p,i]}}function p(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,s=n.data.get(r.dataId).values,o=n.data.get(a.dataId).values,i=n.makeTensorInfo(r.shape,"complex64");return n.data.get(i.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",s),imag:n.makeTensorInfo(a.shape,"float32",o)},i}const d={kernelName:a.Complex,backendName:"cpu",kernelFunc:p};function h(e,t,n="float32"){if("complex64"===n){return p({inputs:{real:h(e,t,"float32"),imag:h(e,t,"float32")},backend:e})}const r=a.util.makeZerosTypedArray(a.util.sizeFromShape(t),n);return e.makeTensorInfo(t,n,r)}function m(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const f={kernelName:a.Identity,backendName:"cpu",kernelFunc:m};function g(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,s=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,s)}const y={kernelName:a.Real,backendName:"cpu",kernelFunc:g};function b(e){const{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{dtype:o}=r;if("complex64"===o){if("complex64"===s.dtype)return m({inputs:{x:s},backend:n});const e=h(n,s.shape,s.dtype),t=b({inputs:{x:s},backend:n,attrs:{dtype:"float32"}}),r=p({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===s.dtype){const e=g({inputs:{input:s},backend:n}),t=b({inputs:{x:e},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(e),t}if(!a.util.hasEncodingLoss(s.dtype,o)){const e=m({inputs:{x:s},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:o}}if("int32"===o){const e=n.data.get(s.dataId).values,t=Int32Array.from(e);return n.makeTensorInfo(s.shape,"int32",t)}if("bool"===o){const e=n.data.get(s.dataId).values,t=a.util.toTypedArray([0],s.dtype),[r,o]=c(((e,t)=>e!==t?1:0))(s.shape,[],e,t,"bool");return n.makeTensorInfo(o,"bool",r)}throw new Error(`Error in Cast: failed to cast ${s.dtype} to ${o}`)}const k={kernelName:a.Cast,backendName:"cpu",kernelFunc:b};function w(e,t,n,r){return null==n?({inputs:n,backend:o})=>{const{a:i,b:u}=n,l=o;s([i,u],e);const c=l.data.get(i.dataId).values,p=l.data.get(u.dataId).values,d="string"===i.dtype?a.backend_util.fromUint8ToStringArray(c):c,h="string"===i.dtype?a.backend_util.fromUint8ToStringArray(p):p,m=r||i.dtype,[f,g]=t(i.shape,u.shape,d,h,m);return l.makeTensorInfo(g,m,f)}:({inputs:e,backend:a})=>{const{a:s,b:o}=e,i=a;if("complex64"===s.dtype||"complex64"===o.dtype){const e=b({inputs:{x:s},backend:i,attrs:{dtype:"complex64"}}),t=i.data.get(e.dataId),r=t.complexTensorInfos.real,a=t.complexTensorInfos.imag,u=i.data.get(r.dataId).values,l=i.data.get(a.dataId).values,c=b({inputs:{x:o},backend:i,attrs:{dtype:"complex64"}}),d=i.data.get(c.dataId),h=d.complexTensorInfos.real,m=d.complexTensorInfos.imag,f=i.data.get(h.dataId).values,g=i.data.get(m.dataId).values,[y,k,w]=n(s.shape,o.shape,u,l,f,g),v=i.makeTensorInfo(w,"float32",y),x=i.makeTensorInfo(w,"float32",k),N=p({inputs:{real:v,imag:x},backend:i});return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(c),i.disposeIntermediateTensorInfo(v),i.disposeIntermediateTensorInfo(x),N}{const e=i.data.get(s.dataId).values,n=i.data.get(o.dataId).values,a=r||s.dtype,[u,l]=t(s.shape,o.shape,e,n,a);return i.makeTensorInfo(l,a,u)}}}function v(e){return(t,n,r,s,o,i)=>{const u=a.backend_util.assertAndGetBroadcastShape(t,n),l=a.util.sizeFromShape(u),c=u.length,p=a.util.computeStrides(u),d=a.util.getTypedArrayFromDType("float32",l),h=a.util.getTypedArrayFromDType("float32",l),m=a.backend_util.getBroadcastDims(t,u),f=a.backend_util.getBroadcastDims(n,u),g=a.backend_util.mergeRealAndImagArrays(r,s),y=a.backend_util.mergeRealAndImagArrays(o,i),b=t.length,k=a.util.computeStrides(t),w=n.length,v=a.util.computeStrides(n);if(m.length+f.length===0)for(let t=0;tr[e]=0));const s=a.util.locToIndex(r,b,k),o=n.slice(-w);f.forEach((e=>o[e]=0));const i=a.util.locToIndex(o,w,v),u=e(g[2*s],g[2*s+1],y[2*i],y[2*i+1]);d[t]=u.real,h[t]=u.imag}return[d,h,u]}}const x=c(((e,t)=>e+t)),N=v(((e,t,n,r)=>({real:e+n,imag:t+r}))),S=w(a.Add,x,N),I={kernelName:a.Add,backendName:"cpu",kernelFunc:S};function T(e,t,n,r,s){const o=a.util.sizeFromShape(r),i=a.util.makeZerosTypedArray(s,n);for(let n=0;n=s||(i[r]+=o>0?t[n]:1)}return i}function _(e,t,n,r=!1){const s=e.shape[0],o=e.shape[1],i=(0,a.buffer)([s,n],t.dtype);for(let a=0;a=n||(r?i.set(1,a,o):t.size>0?i.set(i.get(a,o)+t.get(a,s),a,o):i.set(i.get(a,o)+1,a,o))}return i}function E(e){return(t,n,r)=>{const s=a.util.getTypedArrayFromDType(n,t.length);for(let n=0;n{const{x:u}=r;if(s(u,e),"string"===u.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const l=i,c=l.data.get(u.dataId).values,p=a.util.sizeFromShape(u.shape),d=n||u.dtype,h=a.util.getArrayFromDType(d,p);for(let e=0;e{const{x:i}=r;if(s(i,e),"string"===i.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const u=o,l=u.data.get(i.dataId).values,c=n||i.dtype,p=t(l,c,a);return u.makeTensorInfo(i.shape,c,p)}}const $=E((e=>Math.ceil(e))),D=M(a.Ceil,$),F={kernelName:a.Ceil,backendName:"cpu",kernelFunc:D};function O(e,t,n,r){const s=a.util.getArrayFromDType(n,a.util.sizeFromShape(t));if(r&&"string"!==n){let t=0;e.forEach((e=>{const n=a.util.sizeFromShape(e.shape);s.set(e.vals,t),t+=n}))}else{let r=0;e.forEach((e=>{const o="string"===n?a.backend_util.fromUint8ToStringArray(e.vals):e.vals;let i=0;for(let n=0;ne===t?1:0)),C=w(a.Equal,B,null,"bool"),V={kernelName:a.Equal,backendName:"cpu",kernelFunc:C},R=E((e=>Math.exp(e))),z=M(a.Exp,R),P={kernelName:a.Exp,backendName:"cpu",kernelFunc:z},L=E((e=>Math.expm1(e))),W=M(a.Expm1,L),H={kernelName:a.Expm1,backendName:"cpu",kernelFunc:W},q=E((e=>Math.floor(e))),G=M(a.Floor,q),U={kernelName:a.Floor,backendName:"cpu",kernelFunc:G};function j(e,t,n,r,s,o,i,u,l){const c=(0,a.buffer)([r,o],n);for(let n=0;n=l/o)throw new Error(`Invalid indices: ${r} does not index into ${u}`);for(let e=0;ee>t?1:0)),Z=w(a.Greater,X,null,"bool"),J={kernelName:a.Greater,backendName:"cpu",kernelFunc:Z},Q=c(((e,t)=>e>=t?1:0)),Y=w(a.GreaterEqual,Q,null,"bool"),ee={kernelName:a.GreaterEqual,backendName:"cpu",kernelFunc:Y},te=c(((e,t)=>ee<=t?1:0)),se=w(a.LessEqual,ae,null,"bool"),oe={kernelName:a.LessEqual,backendName:"cpu",kernelFunc:se};function ie(e,t,n){const r=(t-e)/(n-1),s=a.util.makeZerosTypedArray(n,"float32");s[0]=e;for(let e=1;eMath.log(e))),le=M(a.Log,ue),ce={kernelName:a.Log,backendName:"cpu",kernelFunc:le};function pe(e,t,n,r){const s=a.util.getTypedArrayFromDType(r,a.util.sizeFromShape(n));for(let n=0;na)&&(a=t)}s[n]=a}return s}const de=c(((e,t)=>Math.max(e,t))),he=w(a.Maximum,de),me={kernelName:a.Maximum,backendName:"cpu",kernelFunc:he},fe=c(((e,t)=>Math.min(e,t))),ge=w(a.Minimum,fe),ye={kernelName:a.Minimum,backendName:"cpu",kernelFunc:ge},be=c(((e,t)=>e*t)),ke=v(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),we=w(a.Multiply,be,ke),ve={kernelName:a.Multiply,backendName:"cpu",kernelFunc:we};function xe(e,t,n){const r=a.util.createScalarValue(-1,n);return be([],t,r,e,n)}const Ne={kernelName:a.Neg,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;s(r,"neg");const a=n.data.get(r.dataId).values,[o,i]=xe(a,r.shape,r.dtype);return n.makeTensorInfo(i,r.dtype,o)}},Se=c(((e,t)=>e!==t?1:0)),Ie=w(a.NotEqual,Se,null,"bool"),Te={kernelName:a.NotEqual,backendName:"cpu",kernelFunc:Ie};function _e(e,t,n,r,s){const o=t.length,i=a.util.sizeFromShape(t),u=a.util.computeStrides(t),l=a.util.computeStrides(s),c=a.util.getTypedArrayFromDType(n,a.util.sizeFromShape(s));for(let t=0;tn.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(k,b,g)}};function De(e,t,n,r){if(e===t||e1)return a.util.makeZerosTypedArray(0,r);const s=Math.abs(Math.ceil((t-e)/n)),o=a.util.makeZerosTypedArray(s,r);t1/Math.sqrt(e))),Oe=M(a.Rsqrt,Fe),Be={kernelName:a.Rsqrt,backendName:"cpu",kernelFunc:Oe},Ce=E((e=>1/(1+Math.exp(-e)))),Ve=A(a.Sigmoid,(e=>1/(1+Math.exp(-e)))),Re={kernelName:a.Sigmoid,backendName:"cpu",kernelFunc:Ve};function ze(e,t,n,r,s){const o=a.slice_util.isSliceContinous(r,t,n),i=a.util.sizeFromShape(n),u=a.util.computeStrides(r);if(o){const n=a.slice_util.computeFlatOffset(t,u);return"string"===s?e.slice(n,n+i):e.subarray(n,n+i)}const l="string"===s?a.backend_util.fromUint8ToStringArray(e):e,c=(0,a.buffer)(r,s,l),p=(0,a.buffer)(n,s);for(let e=0;ee+t[n]));p.set(c.get(...r),...n)}return"string"===s?a.backend_util.fromStringArrayToUint8(p.values):p.values}function Pe(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{begin:i,size:u}=r;s(o,"slice");const[l,c]=a.slice_util.parseSliceParams(o,i,u);a.slice_util.assertParamsValid(o,l,c);const p=ze(n.data.get(o.dataId).values,l,c,o.shape,o.dtype);return n.makeTensorInfo(c,o.dtype,p)}const Le={kernelName:a.Slice,backendName:"cpu",kernelFunc:Pe};function We(e,t,n,r,s,o,i){const u=t[0],l=o[0],c=new Array(l),p=new Array(u),d=t[1];if(0===l){if(0!==u)throw new Error(`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${u}`);return[a.util.getArrayFromDType(n,0),[0,d],a.util.getArrayFromDType(s,0),c,p]}let h=!0,m=0;const f=new Array(l).fill(0);for(let t=0;t=l)throw new Error(`indices(${t}, 0) is invalid: ${n} >= ${l}`);++f[n],h=h&&n>=m,m=n}let g=!0;for(let e=0;e0&&(f[e]+=f[e-1])}if(g&&h){const t=e,n=r;for(let e=0;e0){m[h-1]=1;for(let e=h-2;e>=0;--e)m[e]=m[e+1]*r[e+1]}const f=[];if(u>0){f[u-1]=1;for(let e=u-2;e>=0;--e)f[e]=f[e+1]*l[e+1]}const g=a.util.getArrayFromDType(n,i*u);for(let t=0;t0?s[u-1]+1:0;if(p<0)throw new Error("segment ids must be >= 0");const d=t.slice();d[0]=p;const h=d.reduce(((e,t)=>e*t),1),m=a.util.getArrayFromDType(n,h);if(0===u)return p>0&&m.fill(i),[m,d];if(p<=0)throw new Error("segment ids must be >= 0");let f=0,g=1,y=0,b=s[f];for(;;){let t=0;if(g=t)throw new Error("segment ids are not increasing")}if(b<0||b>=p)throw new Error(`Segment id ${b} out of range [0, ${p}), possibly because segmentIds input is not sorted.`);b>y&&m.fill(i,y*c,b*c);for(let t=f;t=l[0])throw new Error(`Bad: indices[${t}] == ${r[t]} out of range [0, ${l[0]})`);for(let t=0;tu)break}return yMath.sqrt(e))),Ue=A(a.Sqrt,(e=>Math.sqrt(e))),je={kernelName:a.Sqrt,backendName:"cpu",kernelFunc:Ue},Ke=c(((e,t)=>{const n=e-t;return n*n})),Xe=w(a.SquaredDifference,Ke),Ze={kernelName:a.SquaredDifference,backendName:"cpu",kernelFunc:Xe};function Je(e,t,n,r){const s=(0,a.buffer)(e,t.dtype);for(let e=0;e0?0:o-i);let d=0;d+=u*this.leftPad.length;for(let t=0;te.forEach((e=>h[m++]=e));for(let e=0;e0){f(e[p+c-1]);for(let e=0;e0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let a=1;a=e;if(r=r&&t[a]<=n,!r)throw new Error(`Invalid split value ${t[a]}, must be in [${e}, ${n}]`);e=t[a]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const s=r-1,o=a.util.getArrayFromDType("int32",r);if(0===n||0===r){const e=new Array(n);for(let e=0;e<=s;++e)o[e]=0;return[e,o]}o[0]=0;for(let e=1;e<=s;++e){const n=t[e]-t[e-1];let r=0;this.nGramWidths.forEach((e=>{r+=this.getNumNGrams(n,e)})),this.preserveShort&&n>0&&0===r&&(r=1),o[e]=o[e-1]+r}const i=new Array(o[s]);for(let n=0;n{const o=t[n+1]-t[n],u=this.getNumNGrams(o,s);this.createNGrams(e,r,i,a,u,s),a+=u})),this.preserveShort&&a===o[n]){const s=t[n+1]-t[n];if(0===s)continue;const o=s+2*this.padWidth,u=1;this.createNGrams(e,r,i,a,u,o)}}return[i,o]}}function Ye(e,t,n,r,a,s,o,i){return new Qe(n,r,a,s,o,i).compute(e,t)}function et(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;te-t)),at=v(((e,t,n,r)=>({real:e-n,imag:t-r}))),st=w(a.Sub,rt,at),ot={kernelName:a.Sub,backendName:"cpu",kernelFunc:st};function it(e,t){const n=new Array(e.rank);for(let r=0;r{const n=t.value-e.value;return 0===n?e.index-t.index:n};function lt(e,t,n=0,r=e.length-1){for(;r>n;){if(r-n>600){const a=r-n+1,s=t-n+1,o=Math.log(a),i=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*i*(a-i)/a)*Math.sign(s-a/2);lt(e,t,Math.max(n,Math.floor(t-s*i/a+u)),Math.min(r,Math.floor(t+(a-s)*i/a+u)))}const s=e[t];let o=n,i=r;for(a.util.swap(e,n,t),ut(e[r],s)>0&&a.util.swap(e,n,r);o0;)i-=1}0===ut(e[n],s)?a.util.swap(e,n,i):(i+=1,a.util.swap(e,i,r)),i<=t&&(n=i+1),t<=i&&(r=i-1)}}function ct(e,t,n,r,s){const o=t[t.length-1],[i,u]=[e.length/o,o],l=a.util.getTypedArrayFromDType(n,i*r),c=a.util.getTypedArrayFromDType("int32",i*r);for(let t=0;to[t]={value:e,index:t})),r{for(let n=0;nnew i),1);const ht=A(a.Elu,(e=>e>=0?e:Math.exp(e)-1)),mt={kernelName:a.Elu,backendName:"cpu",kernelFunc:ht};function ft(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{alpha:i}=r;s([o],"leakyRelu");const u=a.util.sizeFromShape(o.shape),l=n.data.get(o.dataId).values,c=a.util.getTypedArrayFromDType("float32",u);for(let e=0;ee<0?t*e:e));function bt(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t;s([r,a],"prelu");const o=n.data.get(r.dataId).values,i=n.data.get(a.dataId).values,[u,l]=yt(r.shape,a.shape,o,i,r.dtype);return n.makeTensorInfo(l,r.dtype,u)}const kt={kernelName:a.Prelu,backendName:"cpu",kernelFunc:bt},wt=A(a.Relu,(e=>Math.max(0,e))),vt={kernelName:a.Relu,backendName:"cpu",kernelFunc:wt},xt=A(a.Relu6,(e=>Math.min(Math.max(0,e),6))),Nt={kernelName:a.Relu6,backendName:"cpu",kernelFunc:xt};function St(e,t,n,r,a){if("linear"===n)return m({inputs:{x:t},backend:e});if("relu"===n)return wt({inputs:{x:t},backend:e});if("elu"===n)return ht({inputs:{x:t},backend:e});if("relu6"===n)return xt({inputs:{x:t},backend:e});if("prelu"===n)return bt({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return ft({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return Ve({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function It(e){const{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{shape:o}=r,i=a.util.sizeFromShape(s.shape),u=a.util.inferFromImplicitShape(o,i),l=a.util.sizeFromShape(u);a.util.assert(i===l,(()=>`The new shape (${u}) has ${l} elements and the old shape (${s.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(s.dataId);const c=n.data.get(s.dataId);if(null!=c.complexTensorInfos){const e=c.complexTensorInfos.real,t=c.complexTensorInfos.imag;e.shape=u,t.shape=u}return{dataId:s.dataId,shape:u,dtype:s.dtype}}const Tt={kernelName:a.Reshape,backendName:"cpu",kernelFunc:It};function _t(e){const{inputs:t,backend:n,attrs:r}=e,{a:o,b:i}=t,{transposeA:u,transposeB:l}=r;s([o,i],"matMul");const c=o.shape.length,p=i.shape.length,d=u?o.shape[c-2]:o.shape[c-1],h=l?i.shape[p-1]:i.shape[p-2],m=u?o.shape[c-1]:o.shape[c-2],f=l?i.shape[p-2]:i.shape[p-1],g=o.shape.slice(0,-2),y=i.shape.slice(0,-2),b=a.util.sizeFromShape(g),k=a.util.sizeFromShape(y),w=b===k||1===b||1===k;a.util.assert(c>=2&&p>=2&&w,(()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${g}) and (${y}).`));const v=(b>k?o.shape.slice(0,-2):i.shape.slice(0,-2)).concat([m,f]);a.util.assert(d===h,(()=>`Error in matMul: inner shapes (${d}) and (${h}) of Tensors with shapes ${o.shape} and ${i.shape} and transposeA=${u} and transposeB=${l} must match.`));const x=l?[k,f,h]:[k,h,f],N=It({inputs:{x:o},backend:n,attrs:{shape:u?[b,d,m]:[b,m,d]}}),S=It({inputs:{x:i},backend:n,attrs:{shape:x}}),I=u?N.shape[1]:N.shape[2],T=u?N.shape[2]:N.shape[1],_=l?S.shape[1]:S.shape[2],E=Math.max(b,k),A=n.data.get(N.dataId).values,M=n.data.get(S.dataId).values,$=a.util.computeStrides(N.shape),D=a.util.computeStrides(S.shape),[F,O,B]=u?[$[0],1,$[1]]:[$[0],$[1],1],[C,V,R]=l?[1,D[1],D[0]]:[D[1],1,D[0]],z=T*_,P=(0,a.buffer)([E,T,_],N.dtype),L=P.values,W=n.blockSize;for(let e=0;eMath.acos(e))),$t={kernelName:a.Acos,backendName:"cpu",kernelFunc:Mt},Dt=A(a.Acosh,(e=>Math.acosh(e))),Ft={kernelName:a.Acosh,backendName:"cpu",kernelFunc:Dt};const Ot={kernelName:a.AddN,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,r=t;s(t,"addN");const o=r.map((e=>n.data.get(e.dataId).values)),i=(0,a.buffer)(r[0].shape,r[0].dtype),u=i.values;for(let e=0;en&&(n=a,r=e)}f[e]=r}return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(d,"int32",f)}};const Rt={kernelName:a.ArgMin,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:i}=r;s(o,"argMin");let u=a.util.parseAxisParam(i,o.shape);const l=a.backend_util.getAxesPermutation(u,o.shape.length);let c=o;const p=[];null!=l&&(c=Ee({inputs:{x:o},backend:n,attrs:{perm:l}}),p.push(c),u=a.backend_util.getInnerMostAxes(u.length,c.shape.length)),u=[u[0]],a.backend_util.assertAxesAreInnerMostDims("argMin",u,c.shape.length);const[d,h]=a.backend_util.computeOutAndReduceShapes(c.shape,u),m=a.util.sizeFromShape(d),f=a.util.makeZerosTypedArray(m,"int32"),g=a.util.sizeFromShape(h),y=n.data.get(c.dataId).values;for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(d,"int32",f)}},zt=A(a.Asin,(e=>Math.asin(e))),Pt={kernelName:a.Asin,backendName:"cpu",kernelFunc:zt},Lt=A(a.Asinh,(e=>Math.asinh(e))),Wt={kernelName:a.Asinh,backendName:"cpu",kernelFunc:Lt},Ht=A(a.Atan,(e=>Math.atan(e))),qt={kernelName:a.Atan,backendName:"cpu",kernelFunc:Ht},Gt=c(((e,t)=>Math.atan2(e,t))),Ut=w(a.Atan2,Gt),jt={kernelName:a.Atan2,backendName:"cpu",kernelFunc:Ut},Kt=A(a.Atanh,(e=>Math.atanh(e))),Xt={kernelName:a.Atanh,backendName:"cpu",kernelFunc:Kt};function Zt(e,t,n,r,s,o){const i=s.strideHeight,u=s.strideWidth,l=s.dilationHeight,c=s.dilationWidth,p=s.effectiveFilterHeight,d=s.effectiveFilterWidth,h=s.padInfo.top,m=s.padInfo.left,f="max"===o?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=(0,a.buffer)(s.outShape,n),y=g.values,b=s.outShape[1]*s.outShape[2]*s.outShape[3],k=s.outShape[2]*s.outShape[3],w=s.outShape[3];for(let t=0;tg?g=a:"avg"===o&&(b+=a,k++)}if(isNaN(g))break}y[N+n*w+t]="avg"===o?b/k:g}}}return g}function Jt(e,t,n,r,s=!1,o=!1){const i=(0,a.buffer)(r.outShape,"int32"),u=r.strideHeight,l=r.strideWidth,c=r.dilationHeight,p=r.dilationWidth,d=r.effectiveFilterHeight,h=r.effectiveFilterWidth,m=r.padInfo.top,f=r.padInfo.left,g=(0,a.buffer)(t,n,e);for(let e=0;ew&&(w=l,v=s?o?((e*r.inHeight+n)*r.inWidth+a)*r.inChannels+t:(n*r.inWidth+a)*r.inChannels+t:i*h+u)}}i.set(v,e,n,u,t)}}return i}function Qt(e,t,n,r,s,o){const i=s.strideDepth,u=s.strideHeight,l=s.strideWidth,c=s.dilationDepth,p=s.dilationHeight,d=s.dilationWidth,h=s.effectiveFilterDepth,m=s.effectiveFilterHeight,f=s.effectiveFilterWidth,g=s.padInfo.front,y=s.padInfo.top,b=s.padInfo.left,k="max"===o?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,w=(0,a.buffer)(s.outShape,n),v=w.values,x=s.outShape[1]*s.outShape[2]*s.outShape[3]*s.outShape[4],N=s.outShape[2]*s.outShape[3]*s.outShape[4],S=s.outShape[3]*s.outShape[4],I=s.outShape[4];for(let t=0;tx?x=s:"avg"===o&&(N+=s,S++),isNaN(x))break}if(isNaN(x))break}if(isNaN(x))break}v[y+t]="avg"===o?N/S:x}}}}return w}const Yt={kernelName:a.AvgPool,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t;s(o,"avgPool");const{filterSize:i,strides:u,pad:l,dimRoundingMode:c}=r;a.util.assert(a.backend_util.eitherStridesOrDilationsAreOne(u,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${u} and dilations '1'`));const p=a.backend_util.computePool2DInfo(o.shape,i,u,1,l,c);let d;if(1===p.filterWidth&&1===p.filterHeight&&a.util.arraysEqual(p.inShape,p.outShape))d=m({inputs:{x:o},backend:n});else{const e=n.data.get(o.dataId).values,t=a.util.computeStrides(o.shape),r=Zt(e,o.shape,o.dtype,t,p,"avg");d=n.makeTensorInfo(p.outShape,o.dtype,r.values)}return d}};const en={kernelName:a.AvgPool3D,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{filterSize:i,strides:u,pad:l,dimRoundingMode:c,dataFormat:p}=r;s(o,"avgPool3d");const d=a.backend_util.computePool3DInfo(o.shape,i,u,1,l,c,p),h=Qt(n.data.get(o.dataId).values,o.shape,o.dtype,a.util.computeStrides(o.shape),d,"avg");return n.makeTensorInfo(h.shape,"float32",h.values)}};const tn={kernelName:a.AvgPool3DGrad,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,input:i}=t,{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r;s([o,i],"avgPool3DGrad");const d=a.backend_util.computePool3DInfo(i.shape,u,l,1,c,p),h=d.strideDepth,m=d.strideHeight,f=d.strideWidth,g=d.filterDepth,y=d.filterHeight,b=d.filterWidth,k=d.dilationDepth,w=d.dilationHeight,v=d.dilationWidth,x=d.effectiveFilterDepth,N=d.effectiveFilterHeight,S=d.effectiveFilterWidth,I=x-1-d.padInfo.front,T=S-1-d.padInfo.left,_=N-1-d.padInfo.top,E=(0,a.buffer)(i.shape,"float32"),A=1/(g*y*b),M=n.bufferSync(o);for(let e=0;e=d.outDepth||Math.floor(r)!==r))for(let n=0;n=d.outHeight||Math.floor(a)!==a))for(let n=0;n=d.outWidth||Math.floor(s)!==s)continue;u+=M.get(e,r,a,s,t)}}}E.set(u*A,e,n,r,a,t)}return n.makeTensorInfo(E.shape,E.dtype,E.values)}};const nn={kernelName:a.AvgPoolGrad,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,input:i}=t,u=i;s([o,i],"avgPoolGrad");const{filterSize:l,strides:c,pad:p}=r,d=a.backend_util.computePool2DInfo(u.shape,l,c,1,p),h=d.strideHeight,m=d.strideWidth,f=d.filterHeight,g=d.filterWidth,y=d.dilationHeight,b=d.dilationWidth,k=d.effectiveFilterHeight,w=d.effectiveFilterWidth,v=w-1-d.padInfo.left,x=k-1-d.padInfo.top,N=(0,a.buffer)(u.shape,"float32"),S=1/(f*g),I=n.data.get(o.dataId).values,T=(0,a.buffer)(o.shape,"float32",I);for(let e=0;e=d.outHeight||Math.floor(r)!==r))for(let n=0;n=d.outWidth||Math.floor(a)!==a)continue;o+=T.get(e,r,a,t)}}N.set(o*S,e,n,r,t)}return n.makeTensorInfo(N.shape,N.dtype,N.values)}};const rn={kernelName:a.FusedBatchNorm,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,scale:i,offset:u,mean:l,variance:c}=t;a.util.assert(l.shape.length===c.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),a.util.assert(null==u||l.shape.length===u.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),a.util.assert(null==i||l.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),s([o,l,c,i,u],"batchNorm");let{varianceEpsilon:p}=r;null==p&&(p=.001);const d=n.data.get(o.dataId).values,h=n.data.get(l.dataId).values,m=n.data.get(c.dataId).values,f=i?n.data.get(i.dataId).values:new Float32Array([1]),g=u?n.data.get(u.dataId).values:new Float32Array([0]),y=new Float32Array(d.length),b=g.length,k=f.length,w=m.length,v=h.length;let x=0,N=0,S=0,I=0;for(let e=0;e=b&&(x=0),N>=v&&(N=0),S>=k&&(S=0),I>=w&&(I=0);return n.makeTensorInfo(o.shape,o.dtype,y)}};const an={kernelName:a.BatchToSpaceND,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{blockShape:i,crops:u}=r;s([o],"batchToSpaceND");const l=i.reduce(((e,t)=>e*t)),c=a.backend_util.getReshaped(o.shape,i,l),p=a.backend_util.getPermuted(c.length,i.length),d=a.backend_util.getReshapedPermuted(o.shape,i,l),h=a.backend_util.getSliceBeginCoords(u,i.length),m=a.backend_util.getSliceSize(d,u,i.length),f=It({inputs:{x:o},backend:n,attrs:{shape:c}}),g=Ee({inputs:{x:f},backend:n,attrs:{perm:p}}),y=It({inputs:{x:g},backend:n,attrs:{shape:d}}),b=Pe({inputs:{x:y},backend:n,attrs:{begin:h,size:m}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(y),b}};const sn={kernelName:a.Bincount,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:s}=t,{size:o}=r,i=T(n.data.get(a.dataId).values,n.data.get(s.dataId).values,s.dtype,s.shape,o);return n.makeTensorInfo([o],s.dtype,i)}};const on={kernelName:a.BroadcastArgs,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:s}=t,o=n.data.get(r.dataId).values,i=n.data.get(s.dataId).values,u=a.backend_util.assertAndGetBroadcastShape(Array.from(o),Array.from(i));return n.makeTensorInfo([u.length],"int32",Int32Array.from(u))}},un=A(a.ClipByValue,((e,t)=>{const n=t;return e>n.clipValueMax?n.clipValueMax:e{const{x:t}=e.inputs,n=e.backend,r=new Float32Array(a.util.sizeFromShape(t.shape)),s=n.data.get(t.dataId),o=s.complexTensorInfos.real,i=s.complexTensorInfos.imag,u=n.data.get(o.dataId).values,l=n.data.get(i.dataId).values;for(let e=0;ee.shape)),o);if(0===a.util.sizeFromShape(i))return n.makeTensorInfo(i,t[0].dtype,[]);const u=t.filter((e=>a.util.sizeFromShape(e.shape)>0));if(1===u.length)return m({inputs:{x:u[0]},backend:n});const l=u.map((e=>e.shape));if(a.backend_util.assertParamsConsistent(l,o),"complex64"===u[0].dtype){const e=u.map((e=>g({inputs:{input:e},backend:n}))),t=u.map((e=>pn({inputs:{input:e},backend:n}))),r=hn({inputs:e,backend:n,attrs:{axis:o}}),a=hn({inputs:t,backend:n,attrs:{axis:o}}),s=p({inputs:{real:r,imag:a},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),s}const c=u.map((e=>{const t=a.util.sizeFromShape(e.shape.slice(o));return It({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),d=c.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));i=a.backend_util.computeOutShape(c.map((e=>e.shape)),1);const h=1===c[0].shape[0],f=O(d,i,t[0].dtype,h),y=a.backend_util.computeOutShape(u.map((e=>e.shape)),o),b=n.makeTensorInfo(y,t[0].dtype,f);return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),b}const mn={kernelName:a.Concat,backendName:"cpu",kernelFunc:hn};function fn(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,filter:i}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}=r;s([o,i],"conv2d");const h=a.backend_util.convertConv2DDataFormat(c),m=a.backend_util.computeConv2DInfo(o.shape,i.shape,u,p,l,d,!1,h),f=m.filterHeight,g=m.filterWidth,y=m.dilationHeight,b=m.dilationWidth,k=m.padInfo.left,w=m.padInfo.top,v="channelsLast"===m.dataFormat,x=new a.TensorBuffer(m.outShape,o.dtype),N=a.util.computeStrides(o.shape),S=a.util.computeStrides(i.shape),I=N[0],T=v?N[1]:N[2],_=v?N[2]:1,E=v?1:N[1],A=x.strides[0],M=v?x.strides[1]:x.strides[2],$=v?x.strides[2]:1,D=v?1:x.strides[1],F=n.data.get(o.dataId).values,O=n.data.get(i.dataId).values,B=x.values;for(let e=0;e=m.inHeight)continue;const s=e*S[0],o=t+n*T;for(let e=0;e=m.inWidth)continue;const a=o+r*_;let i=s+e*S[1];for(let e=0;e=p.inDepth)continue;const s=e*_[0],o=t+n*T[1];for(let e=0;e=p.inHeight)continue;const a=s+e*_[1],i=o+r*T[2];for(let e=0;e=p.inWidth)continue;const s=a+e*_[2],o=i+t*p.inChannels;let u=s;for(let e=0;eMath.cos(e))),Nn={kernelName:a.Cos,backendName:"cpu",kernelFunc:xn},Sn=A(a.Cosh,(e=>Math.cosh(e))),In={kernelName:a.Cosh,backendName:"cpu",kernelFunc:Sn};const Tn={kernelName:a.CropAndResize,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:s,boxes:o,boxInd:i}=t,{cropSize:u,method:l,extrapolationValue:c}=r,[p,d,h,m]=s.shape,f=o.shape[0],[g,y]=u,b=(0,a.buffer)([f,g,y,m],"float32"),k=n.data.get(o.dataId).values,w=n.data.get(i.dataId).values,v=n.data.get(s.dataId).values,x=a.util.computeStrides(s.shape),N=a.util.computeStrides(b.shape);for(let e=0;e=p)continue;const i=g>1?(a-n)*(d-1)/(g-1):0,u=y>1?(s-r)*(h-1)/(y-1):0;for(let t=0;t1?n*(d-1)+t*i:.5*(n+a)*(d-1);if(p<0||p>d-1)for(let n=0;n1?r*(h-1)+l*u:.5*(r+s)*(h-1);if(p<0||p>h-1){for(let n=0;n1?r*(h-1)+n*u:.5*(r+s)*(h-1);if(a<0||a>h-1){for(let r=0;re+g-t-1:(e,t)=>e+t;for(let e=0;e`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`)),a.util.assert(o>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${o}`));const u=s.shape[0],l=s.shape[1],c=s.shape[2],p=s.shape[3],d=l*o,h=c*o,m=p/(o*o),f=n.data.get(s.dataId).values,g=new Float32Array(u*d*h*m);let y=0;for(let e=0;e`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`));const f=a.backend_util.computeConv2DInfo(o.shape,i.shape,u,m,l,p,!0),{filterHeight:g,filterWidth:y,dilationHeight:b,dilationWidth:k,padInfo:w}=f,v=w.left,x=w.top,N=f.outChannels/f.inChannels,S=new a.TensorBuffer(f.outShape,o.dtype),I=n.data.get(o.dataId).values,T=n.data.get(i.dataId).values,_=S.values;for(let e=0;e=f.inHeight)continue;const s=e*h[0],o=t+n*d[1];for(let e=0;e=f.inWidth)continue;const a=s+e*h[1],i=o+r*f.inChannels;let u=t,l=a;for(let e=0;e{const{x:r,filter:s}=e,{strides:o,pad:i,dilations:u}=n,l=t,c=l.data.get(r.dataId).values,p=r.shape.length,d=l.data.get(s.dataId).values,h=s.shape.length,{batchSize:m,inHeight:f,inWidth:g,inChannels:y,outHeight:b,outWidth:k,padInfo:w,strideHeight:v,strideWidth:x,filterHeight:N,filterWidth:S,dilationHeight:I,dilationWidth:T,outShape:_}=a.backend_util.computeDilation2DInfo(r.shape,s.shape,o,i,"NHWC",u),E=a.util.sizeFromShape(_),A=_.length,M=a.util.getArrayFromDType(r.dtype,E);for(let e=0;e=0&&o=0&&ml&&(l=g)}}}M[a.util.locToIndex([e,t,o,u],A,a.util.computeStrides(_))]=l}}}return{dataId:l.write(a.util.toTypedArray(M,r.dtype),_,r.dtype),shape:_,dtype:r.dtype}}},Cn={kernelName:a.Dilation2DBackpropFilter,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:s,dy:o}=e,{strides:i,pad:u,dilations:l}=n,c=t,p=a.util.toNestedArray(r.shape,c.data.get(r.dataId).values),d=a.util.toNestedArray(s.shape,c.data.get(s.dataId).values),{batchSize:h,inHeight:m,inWidth:f,inChannels:g,outHeight:y,outWidth:b,padInfo:k,strideHeight:w,strideWidth:v,filterHeight:x,filterWidth:N,dilationHeight:S,dilationWidth:I,outShape:T}=a.backend_util.computeDilation2DInfo(r.shape,s.shape,i,u,"NHWC",l);a.util.assert(o.rank===T.length,(()=>`Error in ${a.Dilation2DBackpropFilter}, dy must have the same rank as output ${T.length}, but got ${o.rank}`));const _=a.util.toNestedArray(T,c.data.get(o.dataId).values),E=a.util.makeZerosNestedTypedArray(s.shape,s.dtype);for(let e=0;e=0&&r=0&&lo&&(o=a,i=t,u=n)}}}E[i][u][s]+=_[e][t][r][s]}}}return{dataId:c.write(a.util.toTypedArray(E,r.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}},Vn={kernelName:a.Dilation2DBackpropInput,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:s,dy:o}=e,{strides:i,pad:u,dilations:l}=n,c=t,p=a.util.toNestedArray(r.shape,c.data.get(r.dataId).values),d=a.util.toNestedArray(s.shape,c.data.get(s.dataId).values),{batchSize:h,inHeight:m,inWidth:f,inChannels:g,outHeight:y,outWidth:b,padInfo:k,strideHeight:w,strideWidth:v,filterHeight:x,filterWidth:N,dilationHeight:S,dilationWidth:I,outShape:T}=a.backend_util.computeDilation2DInfo(r.shape,s.shape,i,u,"NHWC",l);a.util.assert(o.rank===T.length,(()=>`Error in ${a.Dilation2DBackpropInput}, dy must have the same rank as output ${T.length}, but got ${o.rank}`));const _=a.util.toNestedArray(T,c.data.get(o.dataId).values),E=a.util.makeZerosNestedTypedArray(r.shape,r.dtype);for(let e=0;e=0&&r=0&&lo&&(o=a,i=r,u=l)}}}E[e][i][u][s]+=_[e][t][r][s]}}}return{dataId:c.write(a.util.toTypedArray(E,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};function Rn(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:i,keepDims:u}=r;let l;s(o,"sum"),l="bool"===o.dtype?b({inputs:{x:o},backend:n,attrs:{dtype:"int32"}}):m({inputs:{x:o},backend:n});const c=l.shape.length,p=a.util.parseAxisParam(i,l.shape),d=a.backend_util.getAxesPermutation(p,c);let f=p,g=l;null!=d&&(g=Ee({inputs:{x:l},backend:n,attrs:{perm:d}}),f=a.backend_util.getInnerMostAxes(f.length,c)),a.backend_util.assertAxesAreInnerMostDims("sum",f,g.shape.length);const[y,k]=a.backend_util.computeOutAndReduceShapes(g.shape,f);let w=h(n,y,a.backend_util.upcastType(g.dtype,"int32"));const v=a.util.sizeFromShape(k),x=n.data.get(w.dataId).values,N=n.data.get(g.dataId).values;for(let e=0;e=0&&(h=Rn({inputs:{x:h},backend:n,attrs:{axis:c[e]-(i.length-m),keepDims:!1}}),f.push(h)),m--)}for(const e of f)e!==h&&n.disposeIntermediateTensorInfo(e);return h}};const Ln={kernelName:a.EluGrad,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{dy:r,y:o}=t;s([r,o],"eluGrad");const i=new Float32Array(a.util.sizeFromShape(o.shape)),u=n.data.get(o.dataId).values,l=n.data.get(r.dataId).values;for(let e=0;e=1?l[e]:l[e]*(t+1)}return n.makeTensorInfo(o.shape,"float32",i)}},Wn=a.backend_util.ERF_P,Hn=a.backend_util.ERF_A1,qn=a.backend_util.ERF_A2,Gn=a.backend_util.ERF_A3,Un=a.backend_util.ERF_A4,jn=a.backend_util.ERF_A5,Kn=A(a.Erf,(e=>{const t=Math.sign(e),n=Math.abs(e),r=1/(1+Wn*n);return t*(1-((((jn*r+Un)*r+Gn)*r+qn)*r+Hn)*r*Math.exp(-n*n))})),Xn={kernelName:a.Erf,backendName:"cpu",kernelFunc:Kn};function Zn(e){const{inputs:t,backend:n,attrs:r}=e,{input:s}=t,{dim:o}=r,i=s.shape.length,u=s.shape.slice();let l=o;return o<0&&(a.util.assert(-(i+1)<=o,(()=>`Axis must be in the interval [${-(i+1)}, ${i}]`)),l=i+o+1),u.splice(l,0,1),It({inputs:{x:s},backend:n,attrs:{shape:u}})}const Jn={kernelName:a.ExpandDims,backendName:"cpu",kernelFunc:Zn},Qn=c(((e,t)=>e/t)),Yn=w(a.RealDiv,Qn),er={kernelName:a.RealDiv,backendName:"cpu",kernelFunc:Yn};function tr(e,t,n){const r=e.shape,s=r[0],o=r[1],i=n.data.get(e.dataId),u=i.complexTensorInfos.real,l=i.complexTensorInfos.imag,c=[s,o],d=a.util.sizeFromShape(c),h=a.util.getTypedArrayFromDType("float32",d),m=a.util.getTypedArrayFromDType("float32",d);for(let e=0;e{const{image:r}=e,s=n,o=a.util.getTypedArrayFromDType(r.dtype,a.util.sizeFromShape(r.shape)),[i,u,l,c]=r.shape,p=s.data.get(r.dataId).values;for(let e=0;e=0&&sMath.floor(e/t))),lr=w(a.FloorDiv,ur,null,"int32"),cr={kernelName:a.FloorDiv,backendName:"cpu",kernelFunc:lr};const pr={kernelName:a.FusedConv2D,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s,bias:o,preluActivationWeights:i}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:m}=r;let f=fn({inputs:{x:a,filter:s},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(o){const e=f;f=S({inputs:{a:f,b:o},backend:n}),n.disposeIntermediateTensorInfo(e)}if(h){const e=f;f=St(n,f,h,i,m),n.disposeIntermediateTensorInfo(e)}return f}};const dr={kernelName:a.FusedDepthwiseConv2D,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s,bias:o,preluActivationWeights:i}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:m}=r;let f=Mn({inputs:{x:a,filter:s},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(o){const e=f;f=S({inputs:{a:f,b:o},backend:n}),n.disposeIntermediateTensorInfo(e)}if(h){const e=f;f=St(n,f,h,i,m),n.disposeIntermediateTensorInfo(e)}return f}};const hr={kernelName:a.GatherNd,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{params:r,indices:s}=t,o=a.util.sizeFromShape(r.shape),i=s.shape,u=i[i.length-1],[l,c,p,d]=a.backend_util.prepareAndValidate(r,s);if(0===c)return n.makeTensorInfo(l,r.dtype,[]);const h=j(n.data.get(s.dataId).values,n.bufferSync(r),r.dtype,c,u,p,d,r.shape,o);return n.makeTensorInfo(l,r.dtype,h.values)}};const mr={kernelName:a.GatherV2,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,indices:i}=t,{axis:u,batchDims:l}=r;s([o,i],"gatherV2");let c=l;null==l&&(c=0);const p=a.util.sizeFromShape(i.shape),d=a.util.parseAxisParam(u,o.shape)[0],h=a.backend_util.segment_util.collectGatherOpShapeInfo(o,i,d,c),m=It({inputs:{x:o},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),f=It({inputs:{x:i},backend:n,attrs:{shape:[h.batchSize,p/h.batchSize]}}),g=[h.batchSize,h.outerSize,p/h.batchSize,h.sliceSize],y=n.bufferSync(f),b=K(n.bufferSync(m),y,g);return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),n.makeTensorInfo(h.outputShape,b.dtype,b.values)}};const fr={kernelName:a.IFFT,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t,s=a.util.sizeFromShape(r.shape),o=r.shape[r.shape.length-1],i=It({inputs:{x:r},backend:n,attrs:{shape:[s/o,o]}}),u=tr(i,!0,n),l=It({inputs:{x:u},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(u),l}},gr=A(a.IsFinite,(e=>Number.isFinite(e)?1:0),"bool"),yr={kernelName:a.IsFinite,backendName:"cpu",kernelFunc:gr},br=A(a.IsInf,(e=>Math.abs(e)===1/0?1:0),"bool"),kr={kernelName:a.IsInf,backendName:"cpu",kernelFunc:br},wr=A(a.IsNan,(e=>Number.isNaN(e)?1:0),"bool"),vr={kernelName:a.IsNan,backendName:"cpu",kernelFunc:wr};const xr={kernelName:a.LinSpace,backendName:"cpu",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:r,stop:a,num:s}=n,o=ie(r,a,s);return t.makeTensorInfo([o.length],"float32",o)}},Nr=A(a.Log1p,(e=>Math.log1p(e))),Sr={kernelName:a.Log1p,backendName:"cpu",kernelFunc:Nr},Ir=c(((e,t)=>e&&t)),Tr=w(a.LogicalAnd,Ir,null,"bool"),_r={kernelName:a.LogicalAnd,backendName:"cpu",kernelFunc:Tr},Er=A(a.LogicalNot,(e=>e?0:1),"bool"),Ar={kernelName:a.LogicalNot,backendName:"cpu",kernelFunc:Er},Mr=c(((e,t)=>e||t)),$r=w(a.LogicalOr,Mr,null,"bool"),Dr={kernelName:a.LogicalOr,backendName:"cpu",kernelFunc:$r};const Fr={kernelName:a.LRN,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{depthRadius:i,bias:u,alpha:l,beta:c}=r;s(o,"LRN");const p=o.shape[3],d=p-1,h=n.data.get(o.dataId).values,m=a.util.sizeFromShape(o.shape),f=new Float32Array(m);function g(e){const t=e%p;let n=e-t+Math.max(0,t-i);const r=e-t+Math.min(t+i,d);let a=0;for(;n<=r;n++){const e=h[n];a+=e*e}return a}for(let e=0;e`Error in maxPool: Either strides or dilations must be 1. Got strides ${u} and dilations '1'`));const p=a.backend_util.computePool2DInfo(o.shape,i,u,1,l,c);let d;if(1===p.filterWidth&&1===p.filterHeight&&a.util.arraysEqual(p.inShape,p.outShape))d=m({inputs:{x:o},backend:n});else{const e=n.data.get(o.dataId).values,t=a.util.computeStrides(o.shape),r=Zt(e,o.shape,o.dtype,t,p,"max");d=n.makeTensorInfo(p.outShape,o.dtype,r.values)}return d}};const Rr={kernelName:a.MaxPool3D,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{filterSize:i,strides:u,pad:l,dimRoundingMode:c,dataFormat:p}=r;s(o,"maxPool3d");const d=a.backend_util.computePool3DInfo(o.shape,i,u,1,l,c,p),h=Qt(n.data.get(o.dataId).values,o.shape,o.dtype,a.util.computeStrides(o.shape),d,"max");return n.makeTensorInfo(h.shape,"float32",h.values)}};const zr={kernelName:a.MaxPool3DGrad,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,input:i}=t,{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r;s([o,i],"maxPool3DGrad");const d=a.backend_util.computePool3DInfo(i.shape,u,l,1,c,p),h=function(e,t){const n=(0,a.buffer)(t.outShape,"int32"),r=t.strideDepth,s=t.strideHeight,o=t.strideWidth,i=t.dilationDepth,u=t.dilationHeight,l=t.dilationWidth,c=t.effectiveFilterDepth,p=t.effectiveFilterHeight,d=t.effectiveFilterWidth,h=t.padInfo.front,m=t.padInfo.top,f=t.padInfo.left;for(let a=0;a=S&&(S=u,I=n*p*d+s*p+i)}}}n.set(I,a,y,r,s,g)}}}return n}(n.bufferSync(i),d),m=d.strideDepth,f=d.strideHeight,g=d.strideWidth,y=d.dilationDepth,b=d.dilationHeight,k=d.dilationWidth,w=d.effectiveFilterDepth,v=d.effectiveFilterHeight,x=d.effectiveFilterWidth,N=w-1-d.padInfo.front,S=x-1-d.padInfo.left,I=v-1-d.padInfo.top,T=(0,a.buffer)(i.shape,"float32"),_=n.bufferSync(o);for(let e=0;e=d.outDepth||Math.floor(r)!==r))for(let a=0;a=d.outHeight||Math.floor(s)!==s))for(let o=0;o=d.outWidth||Math.floor(l)!==l)continue;const c=w*v*x-1-h.get(e,r,s,l,t)===n*v*x+a*x+o?1:0;if(0===c)continue;u+=_.get(e,r,s,l,t)*c}}}T.set(u,e,n,r,a,t)}return n.makeTensorInfo(T.shape,T.dtype,T.values)}};const Pr={kernelName:a.MaxPoolGrad,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,input:i,output:u}=t,l=i;s([i,u],"maxPoolGrad");const{filterSize:c,strides:p,pad:d,dimRoundingMode:h}=r,m=a.backend_util.computePool2DInfo(l.shape,c,p,1,d,h),f=n.data.get(l.dataId).values,g=(0,a.buffer)(m.outShape,l.dtype,Jt(f,l.shape,l.dtype,m).values),y=m.strideHeight,b=m.strideWidth,k=m.dilationHeight,w=m.dilationWidth,v=m.effectiveFilterHeight,x=m.effectiveFilterWidth,N=x-1-m.padInfo.left,S=v-1-m.padInfo.top,I=(0,a.buffer)(l.shape,"float32"),T=n.data.get(o.dataId).values,_=(0,a.buffer)(o.shape,"float32",T);for(let e=0;e=m.outHeight||Math.floor(r)!==r))for(let a=0;a=m.outWidth||Math.floor(i)!==i)continue;const u=v*x-1-g.get(e,r,i,t)===n*x+a?1:0;if(0===u)continue;o+=_.get(e,r,i,t)*u}}I.set(o,e,n,r,t)}return n.makeTensorInfo(I.shape,I.dtype,I.values)}};const Lr={kernelName:a.MaxPoolWithArgmax,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:o,strides:i,pad:u,includeBatchInIndex:l}=t,c=n;s(r,"MaxPoolWithArgmax");const p=c.data.get(r.dataId).values,d=a.backend_util.computePool2DInfo(r.shape,o,i,[1,1],u),[h,m]=function(e,t,n,r,s){const o=Zt(e,0,n,a.util.computeStrides(t),s,"max"),i=Jt(e,t,n,s,!0,r);return[o.values,i.values]}(p,r.shape,r.dtype,l,d),f=c.write(h,d.outShape,r.dtype),g=c.write(m,d.outShape,r.dtype);return[{dataId:f,shape:d.outShape,dtype:r.dtype},{dataId:g,shape:d.outShape,dtype:"int32"}]}};const Wr={kernelName:a.Mean,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:o,keepDims:i}=r,u=a.util.parseAxisParam(o,s.shape),l=a.backend_util.computeOutAndReduceShapes(s.shape,u)[1],c=a.util.sizeFromShape(l),p=[],d=n.makeTensorInfo([],"float32",new Float32Array([c]));p.push(d);const h=b({inputs:{x:s},backend:n,attrs:{dtype:"float32"}});p.push(h);const m=Yn({inputs:{a:h,b:d},backend:n});p.push(m);const f=Rn({inputs:{x:m},backend:n,attrs:{axis:o,keepDims:i}});return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),f}};const Hr={kernelName:a.Min,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:i,keepDims:u}=r;s(o,"min");const l=a.util.parseAxisParam(i,o.shape);let c=l;const p=a.backend_util.getAxesPermutation(c,o.shape.length);let d=o;null!=p&&(d=Ee({inputs:{x:o},backend:n,attrs:{perm:p}}),c=a.backend_util.getInnerMostAxes(c.length,o.shape.length)),a.backend_util.assertAxesAreInnerMostDims("min",c,d.shape.length);const[h,m]=a.backend_util.computeOutAndReduceShapes(d.shape,c),f=a.util.sizeFromShape(m),g=a.util.makeZerosTypedArray(a.util.sizeFromShape(h),d.dtype),y=n.data.get(d.dataId).values;for(let e=0;ee[0]+o.shape[t]+e[1])),c=i.map((e=>e[0])),p=i.map(((e,t)=>e[0]+o.shape[t])),d="reflect"===u?0:1,h=n.data.get(o.dataId).values,m=o.shape.length,f=a.util.computeStrides(o.shape),g=a.util.sizeFromShape(l),y=l.length,b=a.util.computeStrides(l),k=a.util.getTypedArrayFromDType(o.dtype,g);for(let e=0;e=p[e]&&(t[e]=2*(p[e]-1)-t[e]+d);t=t.map(((e,t)=>e-c[t]));const n=a.util.locToIndex(t,m,f);k[e]=h[n]}return{dataId:n.write(k,l,o.dtype),shape:l,dtype:o.dtype}}},Gr=c(((e,t)=>{const n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),Ur=w(a.Mod,Gr),jr={kernelName:a.Mod,backendName:"cpu",kernelFunc:Ur};var Kr=n(6377);function Xr(e){const{inputs:t,backend:n,attrs:r}=e,{logits:s}=t,{dim:o}=r,i=s.shape.length;let u=o;if(-1===u&&(u=i-1),u!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${u}`);const l=a.util.parseAxisParam([u],s.shape),c=Br({inputs:{x:s},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),p=a.backend_util.expandShapeToKeepDim(c.shape,l),d=It({inputs:{x:c},backend:n,attrs:{shape:p}}),h=st({inputs:{a:s,b:d},backend:n}),m=z({inputs:{x:h},backend:n}),f=Rn({inputs:{x:m},backend:n,attrs:{axis:l,keepDims:!1}}),g=It({inputs:{x:f},backend:n,attrs:{shape:p}}),y=Yn({inputs:{a:m,b:g},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(g),y}const Zr={kernelName:a.Softmax,backendName:"cpu",kernelFunc:Xr};const Jr={kernelName:a.Multinomial,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:o}=t,{numSamples:i,seed:u,normalized:l}=r;s(o,"multinomial");const c=l?o:Xr({inputs:{logits:o},backend:n,attrs:{dim:-1}}),p=c.shape[0],d=c.shape[1],h=n.data.get(c.dataId).values,m=[p,i],f=a.util.makeZerosTypedArray(a.util.sizeFromShape(m),"int32");for(let e=0;e=0&&d[e]{a.util.assertShapesMatch(o,e.shape,"All tensors passed to stack must have matching shapes"),a.util.assert(i===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const u=[],l=hn({inputs:t.map((e=>{const t=Zn({inputs:{input:e},backend:n,attrs:{dim:s}});return u.push(t),t})),backend:n,attrs:{axis:s}});return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),l}const la={kernelName:a.Pack,backendName:"cpu",kernelFunc:ua};const ca={kernelName:a.PadV2,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{paddings:i,constantValue:u}=r;s(o,"pad");const l=i.map(((e,t)=>e[0]+o.shape[t]+e[1])),c=i.map((e=>e[0])),p=n.data.get(o.dataId).values,d=a.util.sizeFromShape(o.shape),h=o.shape.length,m=a.util.computeStrides(o.shape),f=a.util.sizeFromShape(l),g=l.length,y=a.util.computeStrides(l),b=a.util.getTypedArrayFromDType(o.dtype,f);0!==u&&b.fill(u);for(let e=0;ee+c[t]));b[a.util.locToIndex(t,g,y)]=p[e]}return{dataId:n.write(b,l,o.dtype),shape:l,dtype:o.dtype}}},pa=c(((e,t)=>Math.pow(e,t))),da=w(a.Pow,pa),ha={kernelName:a.Pow,backendName:"cpu",kernelFunc:da};const ma={kernelName:a.Range,backendName:"cpu",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:r,stop:a,dtype:s,step:o}=n,i=De(r,a,o,s);return t.makeTensorInfo([i.length],s,i)}},fa=A(a.Reciprocal,(e=>1/e)),ga={kernelName:a.Reciprocal,backendName:"cpu",kernelFunc:fa};const ya={kernelName:a.ResizeBilinear,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:o}=t,{alignCorners:i,halfPixelCenters:u,size:l}=r;s(o,"resizeBilinear");const c=a.util.computeStrides(o.shape),[p,d]=l,[h,m,f,g]=o.shape,y=n.data.get(o.dataId).values,b=new Float32Array(a.util.sizeFromShape([h,p,d,g])),k=[i&&p>1?m-1:m,i&&d>1?f-1:f],w=[i&&p>1?p-1:p,i&&d>1?d-1:d];let v=0;const x=k[0]/w[0],N=k[1]/w[1];for(let e=0;e1?p-1:p,u&&f>1?d-1:d],b=[u&&m>1?m-1:m,u&&f>1?f-1:f],k=y[0]/b[0],w=y[1]/b[1],v=n.data.get(i.dataId).values;let x=0;for(let e=0;e1?m-1:m,i&&d>1?f-1:f],w=[i&&p>1?p-1:p,i&&d>1?d-1:d],v=k[0]/w[0],x=k[1]/w[1];let N=0;for(let e=0;e1?d-1:d,u&&g>1?h-1:h],w=[u&&f>1?f-1:f,u&&g>1?g-1:g],v=k[0]/w[0],x=k[1]/w[1],N=1/v,S=1/x,I=2*Math.ceil(N)+2,T=2*Math.ceil(S)+2;for(let e=0;e=f)continue;const p=t+l*c[1],m=l*v;if(e===Math.min(d-1,u?Math.round(m):Math.floor(m)))for(let e=0;e=g)continue;const a=p+t*c[2],s=t*x;r===Math.min(h-1,u?Math.round(s):Math.floor(s))&&(o+=b[a+n])}}y[s+n]=o}}}}return n.makeTensorInfo(o.shape,o.dtype,y)}};const va={kernelName:a.Reverse,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{dims:i}=r;s(o,"reverse");const u=o.shape.length,l=a.util.parseAxisParam(i,o.shape);if(0===u)return m({inputs:{x:o},backend:n});const c=new a.TensorBuffer(o.shape,o.dtype),p=n.bufferSync(o);for(let e=0;en[e]=o.shape[e]-1-n[e])),c.set(p.get(...n),...t)}return n.makeTensorInfo(c.shape,c.dtype,c.values)}},xa={kernelName:a.RotateWithOffset,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:s,fillValue:o,center:i}=t,u=n,l=a.util.getTypedArrayFromDType(r.dtype,a.util.sizeFromShape(r.shape)),[c,p,d,h]=r.shape,[m,f]=a.backend_util.getImageCenter(i,p,d),g=Math.sin(s),y=Math.cos(s),b=u.data.get(r.dataId).values;for(let e=0;e=0&&w=0&&v{const t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),Sa={kernelName:a.Round,backendName:"cpu",kernelFunc:Na};function Ia(e,t,n,r,s,o,i,u,l,c){const p=[r/s,s],d=e.values,h=t.values;if(0===r)return(0,a.buffer)(n,t.dtype);const m=(0,a.buffer)(p,t.dtype);m.values.fill(l);for(let e=0;e=r/s)throw new Error(`Invalid indices: ${a} does not index into ${n}`);for(let n=0;n1||1===o.shape.length?1:a.util.sizeFromShape(o.shape.slice(1));for(let e=0;ee>=0?Aa*e:Ea*(Math.exp(e)-1))),$a={kernelName:a.Selu,backendName:"cpu",kernelFunc:Ma},Da=A(a.Sign,(e=>e<0?-1:e>0?1:0)),Fa={kernelName:a.Sign,backendName:"cpu",kernelFunc:Da},Oa=A(a.Sin,(e=>Math.sin(e))),Ba={kernelName:a.Sin,backendName:"cpu",kernelFunc:Oa},Ca=A(a.Sinh,(e=>Math.sinh(e))),Va={kernelName:a.Sinh,backendName:"cpu",kernelFunc:Ca},Ra=Math.log(1.1920928955078125e-7)+2,za=A(a.Softplus,(e=>{const t=e>-Ra,n=eNumber(e))))),n.makeTensorInfo([f.length],r.dtype,new Int32Array(f))]}};const Ha={kernelName:a.SparseReshape,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{inputIndices:r,inputShape:a,newShape:s}=t;if(2!==r.shape.length)throw new Error(`Input indices should be a matrix but received shape\n ${r.shape}`);if(1!==a.shape.length)throw new Error(`Input shape should be a vector but received shape\n ${a.shape}`);if(1!==s.shape.length)throw new Error(`Target shape should be a vector but received shape ${s.shape}`);const o=Array.from(n.data.get(a.dataId).values),i=n.data.get(r.dataId).values,u=Array.from(n.data.get(s.dataId).values),[l,c,p]=He(i,r.shape,r.dtype,o,u);return[n.makeTensorInfo(c,r.dtype,l),n.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}};const qa={kernelName:a.SparseSegmentMean,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:s}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==s.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${s.shape}`);const o=n.data.get(r.dataId).values,i=n.data.get(a.dataId).values,u=n.data.get(s.dataId).values,[l,c]=qe(o,r.shape,r.dtype,i,u,!0);return n.makeTensorInfo(c,r.dtype,l)}};const Ga={kernelName:a.SparseSegmentSum,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:s}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==s.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${s.shape}`);const o=n.data.get(r.dataId).values,i=n.data.get(a.dataId).values,u=n.data.get(s.dataId).values,[l,c]=qe(o,r.shape,r.dtype,i,u);return n.makeTensorInfo(c,r.dtype,l)}};const Ua={kernelName:a.SparseToDense,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sparseIndices:s,sparseValues:o,defaultValue:i}=t,{outputShape:u}=r,{sliceRank:l,numUpdates:c,sliceSize:p,strides:d,outputSize:h}=a.backend_util.calculateShapes(o,s,u),m=Ia(n.bufferSync(s),n.bufferSync(o),u,h,p,c,l,d,n.data.get(i.dataId).values[0],!1);return n.makeTensorInfo(u,m.dtype,m.values)}};const ja={kernelName:a.SplitV,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{numOrSizeSplits:o,axis:i}=r,u=a.util.parseAxisParam(i,s.shape)[0],l=a.backend_util.prepareSplitSize(s,o,u),c=new Array(s.shape.length).fill(0),p=s.shape.slice();return l.map((e=>{const t=[...p];t[u]=e;const r=Pe({inputs:{x:s},backend:n,attrs:{begin:c,size:t}});return c[u]+=e,r}))}},Ka={kernelName:a.Square,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{x:n}=e,r=t;s(n,"square");const a=r.data.get(n.dataId).values,o=new Float32Array(a.length);for(let e=0;e{const n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),Za={kernelName:a.Step,backendName:"cpu",kernelFunc:Xa};const Ja={kernelName:a.StridedSlice,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{begin:i,end:u,strides:l,beginMask:c,endMask:p,ellipsisMask:d,newAxisMask:h,shrinkAxisMask:m}=r;s(o,"stridedSlice");const{nonStrided:f,$begin:g,$strides:y,size:b,newShape:k,outShape:w}=a.slice_util.sliceInfo(o.shape,i,u,l,c,p,d,h,m),v=It({inputs:{x:o},backend:n,attrs:{shape:k}});let x;if(f){const e=Pe({inputs:{x:v},backend:n,attrs:{begin:g,size:b}});x=It({inputs:{x:e},backend:n,attrs:{shape:w}}),n.disposeIntermediateTensorInfo(e)}else if(w.some((e=>0===e)))x=n.makeTensorInfo(w,o.dtype,[]);else{const e=Je(w,n.bufferSync(v),y,g);x=n.makeTensorInfo(e.shape,e.dtype,e.values)}const N=It({inputs:{x},backend:n,attrs:{shape:w}});return n.disposeIntermediateTensorInfo(v),n.disposeIntermediateTensorInfo(x),N}};const Qa={kernelName:a.StringNGrams,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:s,leftPad:o,rightPad:i,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.data.get(c.dataId).values,h=n.data.get(p.dataId).values,[m,f]=Ye(d,h,a,s,o,i,u,l);return[n.makeTensorInfo([m.length],"string",m),n.makeTensorInfo(p.shape,"int32",f)]}};const Ya={kernelName:a.StringSplit,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{skipEmpty:a}=r,{input:s,delimiter:o}=t;if("string"!==s.dtype)throw new Error("Input must be of datatype string");if(1!==s.shape.length)throw new Error(`Input must be a vector, got shape: ${s.shape}`);if(0!==o.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`);const i=n.data.get(s.dataId).values,u=n.data.get(o.dataId).values[0],[l,c,p]=tt(i,u,a),d=c.length;return[n.makeTensorInfo([d,2],"int32",l),n.makeTensorInfo([d],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};const es={kernelName:a.StringToHashBucketFast,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{numBuckets:a}=r,{input:s}=t;if("string"!==s.dtype)throw new Error("Input must be of datatype string");if(a<=0)throw new Error("Number of buckets must be at least 1");const o=nt(n.data.get(s.dataId).values,a);return n.makeTensorInfo(s.shape,"int32",o)}},ts=A(a.Tan,(e=>Math.tan(e))),ns={kernelName:a.Tan,backendName:"cpu",kernelFunc:ts},rs=A(a.Tanh,(e=>Math.tanh(e))),as={kernelName:a.Tanh,backendName:"cpu",kernelFunc:rs};const ss={kernelName:a.Tile,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reps:o}=r;s(a,"tile");const i=it(n.bufferSync(a),o);return n.makeTensorInfo(i.shape,i.dtype,i.values)}};const os={kernelName:a.TopK,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{k:o,sorted:i}=r;s(a,"topk");const u=n.data.get(a.dataId).values,[l,c]=ct(u,a.shape,a.dtype,o,i);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(c.shape,c.dtype,c.values)]}};const is={kernelName:a.Transform,backendName:"cpu",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{image:s,transforms:o}=t,{interpolation:i,fillMode:u,fillValue:l,outputShape:c}=n,[p,d,h,m]=s.shape,[f,g]=null!=c?c:[d,h],y=[p,f,g,m],b=a.util.computeStrides(s.shape),k=b[0],w=b[1],v=b[2],x=a.util.getTypedArrayFromDType(s.dtype,a.util.sizeFromShape(y));x.fill(l);const N=r.data.get(s.dataId).values,S=r.data.get(o.dataId).values;for(let e=0;et-1)if(t<=1)n=0;else{const e=2*t;n-=e*Math.trunc(n/e),n>=t&&(n=e-n-1)}return a.util.clamp(0,n,t-1)}(e,t);case"wrap":return function(e,t){let n=e;if(n<0)if(t<=1)n=0;else{const e=t-1;n+=t*(Math.trunc(-n/e)+1)}else if(n>t-1)if(t<=1)n=0;else{const e=t-1;n-=t*Math.trunc(n/e)}return a.util.clamp(0,n,t-1)}(e,t);case"nearest":return function(e,t){return a.util.clamp(0,e,t-1)}(e,t);case"constant":default:return function(e,t){return e}(e)}}function ls(e,t,n,r,a,s,o,i,u,l,c){return 0<=i&&in.disposeIntermediateTensorInfo(e))),h}},fs=[At,l,$t,Ft,I,Ot,Bt,Ct,Vt,Rt,Pt,Wt,qt,jt,Xt,Yt,en,tn,nn,Et,rn,an,sn,on,k,F,ln,d,cn,mn,yn,bn,gn,wn,vn,kn,Nn,In,Tn,_n,En,An,$n,Dn,Fn,On,Bn,Vn,Cn,er,Pn,mt,Ln,V,Xn,P,Jn,H,ar,or,ir,U,cr,pr,dr,hr,mr,J,ee,f,fr,dn,yr,kr,vr,gt,re,oe,xr,ce,Sr,_r,Ar,Dr,Fr,Or,me,Vr,Rr,zr,Pr,Lr,Cr,Wr,Hr,ye,qr,jr,Jr,ve,Ne,Yr,ta,ra,Te,aa,ia,la,ca,ha,kt,$e,ma,y,ga,vt,Nt,Tt,ya,ba,ka,wa,va,xa,Sa,Be,Ta,_a,$a,Re,Fa,Ba,Va,Le,Zr,Pa,La,Wa,Ha,qa,Ga,Ua,ja,je,Ka,Ze,Za,Ja,Qa,Ya,es,ot,zn,ns,as,ss,os,Ae,is,ds,hs,ms,oa];for(const e of fs)(0,a.registerKernel)(e)},4933:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GraphModel:()=>gr,deregisterOp:()=>E,loadGraphModel:()=>yr,registerOp:()=>T,version_converter:()=>br});var r={};n.r(r),n.d(r,{json:()=>C});var a={};n.r(a),n.d(a,{json:()=>V});var s={};n.r(s),n.d(s,{json:()=>R});var o={};n.r(o),n.d(o,{json:()=>z});var i={};n.r(i),n.d(i,{json:()=>P});var u={};n.r(u),n.d(u,{json:()=>L});var l={};n.r(l),n.d(l,{json:()=>W});var c={};n.r(c),n.d(c,{json:()=>H});var p={};n.r(p),n.d(p,{json:()=>q});var d={};n.r(d),n.d(d,{json:()=>G});var h={};n.r(h),n.d(h,{json:()=>U});var m={};n.r(m),n.d(m,{json:()=>j});var f={};n.r(f),n.d(f,{json:()=>K});var g={};n.r(g),n.d(g,{json:()=>X});var y={};n.r(y),n.d(y,{json:()=>Z});var b={};n.r(b),n.d(b,{json:()=>J});var k={};n.r(k),n.d(k,{json:()=>Q});var w={};n.r(w),n.d(w,{json:()=>Y});var v={};n.r(v),n.d(v,{json:()=>ee});var x,N,S=n(5363);!function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF"}(x||(x={})),function(e){let t;!function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"}(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))}(N||(N={}));const I={};function T(e,t){const n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};I[e]=n}function _(e){return I[e]}function E(e){delete I[e]}function A(e,t,n,r,a){const s=t.inputParams[e];if(s&&void 0!==s.inputIndexStart){const e=s.inputIndexStart,o=0===s.inputIndexEnd?void 0:void 0===s.inputIndexEnd?e+1:s.inputIndexEnd;if("tensor"===s.type)return M(t.inputNames[s.inputIndexStart],n,r,a);if("tensors"===s.type){return t.inputNames.slice(e,o).map((e=>M(e,n,r,a)))}const i=M(t.inputNames.slice(e)[0],n,r,a),u=i.dataSync();return"number"===s.type?u[0]:S.util.toNestedArray(i.shape,u)}const o=t.attrParams[e];return o&&o.value}function M(e,t,n,r){const[a,s]=F(e);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const o=n.currentContextIds.find((e=>!!t[D(a,e)]));return void 0!==o?t[D(a,o)][s]:void 0}function $(e,t){const[n,r,a]=F(e);return[D(n,t&&t.currentContextId),r,a]}function D(e,t){return t?`${e}-${t}`:e}function F(e){const t=e.split(":");if(1===t.length)return[e,0,void 0];const n=t[0],r=3===t.length?t[1]:void 0;return[n,Number(t[t.length-1]),r]}function O(e,t,n){let r=A("pad",e,t,n);if("explicit"===r){r=A("explicitPaddings",e,t,n);const a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=r[2*e],a[e][1]=r[2*e+1];return a}return r}function B(e){return e.kept?e:(0,S.clone)(e)}const C=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],V=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],R=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]}],z=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number"}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],P=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],L=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],W=[{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],H=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],q=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]}],G=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]}],U=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],j=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}],K=[{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}],X=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],Z=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],J=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],Q=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],Y=[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],ee=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];class te{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[].concat(...[r,a,s,o,i,u,l,c,p,d,h,m,f,g,y,b,k,w,v].map((e=>e.json)));this.opMappers=e.reduce(((e,t)=>(e[t.tfOpName]=t,e)),{})}transformGraph(e,t={}){const n=e.node,r=[],a=[],s=[],o=n.reduce(((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?r.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):null!=t.input&&0!==t.input.length||s.push(e[t.name]),e)),{});let i=[];const u=[];let l={},c={};null!=t&&(l=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));const p=Object.keys(o);p.forEach((e=>{const t=o[e];t.inputNames.forEach(((e,n)=>{const[r,,a]=$(e),s=o[r];if(null!=s.outputs){const e=s.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(s),s.children.push(t)}))})),0===Object.keys(c).length?p.forEach((e=>{const t=o[e];0===t.children.length&&u.push(t)})):Object.keys(c).forEach((e=>{const[t]=$(e),n=o[t];null!=n&&(n.signatureKey=c[e],u.push(n))})),Object.keys(l).length>0?Object.keys(l).forEach((e=>{const[t]=$(e),n=o[t];n&&(n.signatureKey=l[e],i.push(n))})):i=r;let d={};null!=e.library&&null!=e.library.function&&(d=e.library.function.reduce(((e,t)=>(e[t.signature.name]=this.mapFunction(t),e)),{}));const h={nodes:o,inputs:i,outputs:u,weights:a,placeholders:r,signature:t,functions:d};return s.length>0&&(h.initNodes=s),h}mapSignatureEntries(e){return Object.keys(e||{}).reduce(((t,n)=>(t[e[n].name]=n,t)),{})}mapNode(e){const t=_(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});const n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((e=>e.startsWith("^")?e.substr(1):e)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce(((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e)),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce(((t,n)=>{const r=n.type;let a;switch(n.type){case"string":a=re(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=re(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=he(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=he(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=se(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=se(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=de(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=de(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=ae(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ae(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=fe(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=fe(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=pe(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=pe(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=me(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=me(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":a=ue(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ue(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":a=le(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=le(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=ie(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ie(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`)}return t[n.name]={value:a,type:r},t}),{})),n}mapFunction(e){const t=e.nodeDef,n=[];let r={};null!=t&&(r=t.reduce(((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&n.push(e[t.name]),e)),{}));const a=[],s=[];e.signature.inputArg.forEach((e=>{const[t]=$(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:oe(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,a.push(n),r[t]=n}));Object.keys(r).forEach((e=>{const t=r[e];t.inputNames.forEach(((e,n)=>{const[a,,s]=$(e),o=r[a];if(null!=o.outputs){const e=o.outputs.indexOf(s);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(o),o.children.push(t)}))}));const o=e.ret;e.signature.outputArg.forEach((e=>{const[t,n]=$(o[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,s.push(a))}));const i=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:s,weights:n,placeholders:[],signature:i}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce(((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e)),{}),outputs:e.signature.outputArg.reduce(((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t)),{})}}mapArgToTensorInfo(e,t){let n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}function ne(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=(0,S.env)().global;if(void 0!==t.atob)return t.atob(e);if("undefined"!=typeof Buffer)return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function re(e,t,n,r=!1){const a=e[t];return null!=a?ne(a.s,r):n}function ae(e,t,n){const r=e[t];return r?r.b:n}function se(e,t,n){const r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function oe(e){switch("string"==typeof e&&(e=x[e]),e){case x.DT_FLOAT:return"float32";case x.DT_INT32:case x.DT_INT64:case x.DT_INT8:case x.DT_UINT8:return"int32";case x.DT_BOOL:return"bool";case x.DT_DOUBLE:return"float32";case x.DT_STRING:return"string";default:return null}}function ie(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function ue(e,t,n){const r=e[t];return r&&r.type?oe(r.type):n}function le(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map((e=>oe(e))):n}function ce(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((e=>"number"==typeof e.size?e.size:parseInt(e.size,10))):[]}function pe(e,t,n){const r=e[t];return r&&r.shape?ce(r.shape):n}function de(e,t,n){const r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((e=>"number"==typeof e?e:parseInt(e,10))):n}function he(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map((e=>ne(e,r))):n}function me(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((e=>ce(e))):n}function fe(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class ge{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((e=>this.getInput(e))),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce(((e,t)=>(e[t]=this.getAttr(t),e)),{}))}getInput(e){return M(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return M(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return se(this.node.rawAttrs,e,t);if(null!=n.s)return re(this.node.rawAttrs,e,t);if(null!=n.b)return ae(this.node.rawAttrs,e,t);if(null!=n.shape)return pe(this.node.rawAttrs,e,t);if(null!=n.type)return ue(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return de(this.node.rawAttrs,e,t);if(null!=n.list.s)return he(this.node.rawAttrs,e,t);if(null!=n.list.shape)return me(this.node.rawAttrs,e,t);if(null!=n.list.b)return fe(this.node.rawAttrs,e,t);if(null!=n.list.type)return le(this.node.rawAttrs,e,t)}return t}}var ye=n(6407),be=n(3135),ke=n(5228),we=n(4841),ve=n(1274),xe=n(9322),Ne=n(9165),Se=n(827),Ie=n(4513),Te=n(632),_e=n(3453),Ee=n(5265);var Ae=n(6235),Me=n(7839),$e=n(1470),De=n(2421),Fe=n(1891),Oe=n(7037),Be=n(9812),Ce=n(369),Ve=n(6825),Re=n(1661),ze=n(173),Pe=n(2699),Le=n(3233),We=n(4650),He=n(4842),qe=n(3426),Ge=n(6943),Ue=n(2597),je=n(7474),Ke=n(4386),Xe=n(7370),Ze=n(9036),Je=n(766),Qe=n(7409),Ye=n(7809),et=n(5503),tt=n(625),nt=n(9331),rt=n(4434),at=n(3254),st=n(3694),ot=n(3261),it=n(248),ut=n(1869),lt=n(1173),ct=n(2279),pt=n(3582),dt=n(2634),ht=n(9451),mt=n(9133),ft=n(8151),gt=n(6230);function yt(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){S.util.assert(e.length===t.length,(()=>n+` Shapes ${e} and ${t} must match`));for(let r=0;rn+` Shapes ${e} and ${t} must match`))}}}function bt(e){return"number"!=typeof e&&!e.some((e=>e<0))}function kt(e,t,n){let r=wt(e,n);const a=!bt(r);if(a&&0===t.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&t.forEach((e=>{r=wt(e.shape,r)})),!bt(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function wt(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);const n=[];for(let r=0;r=0&&s>=0&&a!==s)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:s}return n}class vt{constructor(e,t,n,r,a,s,o){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=s,this.clearAfterRead=o,this.tensors=[],this.closed_=!1,this.idTensor=(0,S.scalar)(0),(0,S.keep)(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map((e=>this.read(e)))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),yt(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);n.tensor=t,(0,S.keep)(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach(((e,n)=>this.write(e,t[n])))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,(0,S.unstack)(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0;const r=e.map((e=>(n+=e,n)));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);const a=0===n?0:t.size/n,s=[];(0,S.tidy)((()=>{t=(0,S.reshape)(t,[1,n,a]);for(let n=0;n{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);yt(t,e.shape,"TensorList shape mismatch: "),(0,S.keep)(e)})),this.idTensor=(0,S.scalar)(0),this.maxNumElements=r,(0,S.keep)(this.idTensor)}get id(){return this.idTensor.id}copy(){return new xt([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);yt(e,this.elementShape,"TensorList shape mismatch: ");const r=kt(this.elementShape,this.tensors,e);return(0,S.tidy)((()=>{const e=this.tensors.map((e=>(0,S.reshape)(e,r)));return(0,S.stack)(e,0)}))}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=kt(this.elementShape,this.tensors,e),r=this.tensors.pop();return yt(r.shape,e,"TensorList shape mismatch: "),(0,S.reshape)(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(yt(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");(0,S.keep)(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);this.tensors.length=e}getItem(e,t,n){if(n!==this.elementDtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${this.elementDtype}`);if(e<0||e>this.tensors.length)throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw new Error(`element at index ${e} is null.`);yt(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=kt(this.elementShape,this.tensors,t);return(0,S.reshape)(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);yt(this.elementShape,t.shape,"TensorList shape mismatch: "),(0,S.keep)(t),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);yt(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=kt(this.elementShape,this.tensors,n);return 0===e.length?(0,S.tensor)([],[0].concat(r)):(0,S.tidy)((()=>{const t=e.map((e=>(0,S.reshape)(this.tensors[e],r)));return(0,S.stack)(t,0)}))}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);yt(this.elementShape,t,"TensorList shape mismatch: ");const n=kt(this.elementShape,this.tensors,t);return 0===this.size()?(0,S.tensor)([],[0].concat(n)):(0,S.tidy)((()=>{const e=this.tensors.map((e=>(0,S.reshape)(e,n)));return(0,S.concat)(e,0)}))}}const Nt=async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=A("thenBranch",e,t,n),a=A("elseBranch",e,t,n),s=A("cond",e,t,n),o=A("args",e,t,n);return(await s.data())[0]?n.functionMap[r].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=A("body",e,t,n),a=A("cond",e,t,n),s=A("args",e,t,n),o=await n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap),i=s.map((e=>e.id));let u=await o[0].data();o.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||e.dispose()}));let l=s;for(;u[0];){const e=l;l=await n.functionMap[r].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);const t=l.map((e=>e.id));e.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}));const s=await n.functionMap[a].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);u=await s[0].data(),s.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}))}return l}case"LoopCond":return[B(A("pred",e,t,n))];case"Switch":{const r=A("pred",e,t,n);let a=A("data",e,t,n);return a.kept||(a=B(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find((e=>void 0!==M(e,t,n)));if(r){return[B(M(r,t,n))]}return}case"Enter":{const r=A("frameName",e,t,n),a=A("tensor",e,t,n);return n.enterFrame(r),[B(a)]}case"Exit":{const r=A("tensor",e,t,n);return n.exitFrame(),[B(r)]}case"NextIteration":{const r=A("tensor",e,t,n);return n.nextIteration(),[B(r)]}case"TensorArrayV3":{const r=A("size",e,t,n),a=A("dtype",e,t,n),s=A("elementShape",e,t,n),o=A("dynamicSize",e,t,n),i=A("clearAfterRead",e,t,n),u=A("identicalElementShapes",e,t,n),l=A("name",e,t,n),c=new vt(l,a,r,s,u,o,i);return n.addTensorArray(c),[c.idTensor,(0,S.scalar)(1)]}case"TensorArrayWriteV3":{const r=A("tensorArrayId",e,t,n),a=A("index",e,t,n),s=A("tensor",e,t,n),o=n.getTensorArray(r.id);return o.write(a,s),[o.idTensor]}case"TensorArrayReadV3":{const r=A("tensorArrayId",e,t,n),a=A("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=A("tensorArrayId",e,t,n),a=A("indices",e,t,n),s=A("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,s)]}case"TensorArrayScatterV3":{const r=A("tensorArrayId",e,t,n),a=A("indices",e,t,n),s=A("tensor",e,t,n),o=n.getTensorArray(r.id);return o.scatter(a,s),[o.idTensor]}case"TensorArrayConcatV3":{const r=A("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),s=A("dtype",e,t,n);return[a.concat(s)]}case"TensorArraySplitV3":{const r=A("tensorArrayId",e,t,n),a=A("tensor",e,t,n),s=A("lengths",e,t,n),o=n.getTensorArray(r.id);return o.split(s,a),[o.idTensor]}case"TensorArraySizeV3":{const r=A("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return[(0,S.scalar)(a.size(),"int32")]}case"TensorArrayCloseV3":{const r=A("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=A("tensorListId",e,t,n),a=A("index",e,t,n),s=A("tensor",e,t,n),o=n.getTensorList(r.id);return o.setItem(a,s),[o.idTensor]}case"TensorListGetItem":{const r=A("tensorListId",e,t,n),a=A("index",e,t,n),s=A("elementShape",e,t,n),o=A("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,s,o)]}case"TensorListScatterV2":case"TensorListScatter":{const r=A("indices",e,t,n),a=function(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const a=Math.max(...t);if(null!=r&&-1!==r&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);const s=new xt([],n,e.dtype,r),o=(0,S.unstack)(e,0);return t.forEach(((e,t)=>{s.setItem(e,o[t])})),s}(A("tensor",e,t,n),r,A("elementShape",e,t,n),A("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=A("elementShape",e,t,n),a=A("elementDType",e,t,n);let s;s="TensorListReserve"===e.op?"numElements":"maxNumElements";const o=function(e,t,n){return new xt([],e,t,n)}(r,a,A(s,e,t,n));return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{const r=A("tensorListId",e,t,n),a=A("indices",e,t,n),s=A("elementShape",e,t,n),o=A("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,o,s)]}case"TensorListStack":{const r=A("tensorListId",e,t,n),a=A("elementShape",e,t,n),s=A("elementDType",e,t,n),o=A("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,s,o)]}case"TensorListFromTensor":{const r=function(e,t,n){const r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);yt(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=(0,S.unstack)(e);return new xt(a,t,r)}(A("tensor",e,t,n),A("elementShape",e,t,n),A("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":{const r=A("tensorListId",e,t,n),a=n.getTensorList(r.id),s=A("dtype",e,t,n),o=A("elementShape",e,t,n);return[a.concat(s,o)]}case"TensorListPushBack":{const r=A("tensorListId",e,t,n),a=A("tensor",e,t,n),s=n.getTensorList(r.id);return s.pushBack(a),[s.idTensor]}case"TensorListPopBack":{const r=A("tensorListId",e,t,n),a=A("elementShape",e,t,n),s=A("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,s)]}case"TensorListSplit":{const r=A("tensor",e,t,n),a=A("elementShape",e,t,n),s=function(e,t,n){let r=0;const a=t.map((e=>(r+=e,r)));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`);const s=wt(e.shape.slice(1),n),o=0===r?0:e.size/r,i=(0,S.tidy)((()=>{const n=[];e=(0,S.reshape)(e,[1,r,o]);for(let r=0;re.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return nn.i(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),(0,S.tidy)((()=>{const e=(0,S.unstack)(t),r=n.length,a=e.length;S.util.assert(r===a,(()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`));for(let t=0;t{const e=[];for(let r=0;r{switch(e.category){case"arithmetic":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[ye.I(A("a",e,t,n),A("b",e,t,n))];case"AddN":return[be.Q(A("tensors",e,t,n))];case"FloorMod":case"Mod":return[ke.w(A("a",e,t,n),A("b",e,t,n))];case"Mul":return[we.d(A("a",e,t,n),A("b",e,t,n))];case"RealDiv":case"Div":return[ve.h(A("a",e,t,n),A("b",e,t,n))];case"DivNoNan":return[xe.N(A("a",e,t,n),A("b",e,t,n))];case"FloorDiv":return[Ne.q(A("a",e,t,n),A("b",e,t,n))];case"Sub":return[Se.l(A("a",e,t,n),A("b",e,t,n))];case"Minimum":return[Ie.L(A("a",e,t,n),A("b",e,t,n))];case"Maximum":return[Te.g(A("a",e,t,n),A("b",e,t,n))];case"Pow":return[_e.s(A("a",e,t,n),A("b",e,t,n))];case"SquaredDifference":return[Ee.$(A("a",e,t,n),A("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"basic_math":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"Abs":case"ComplexAbs":return[Ae.W(A("x",e,t,n))];case"Acos":return[Me.K(A("x",e,t,n))];case"Acosh":return[$e._(A("x",e,t,n))];case"Asin":return[De.Z(A("x",e,t,n))];case"Asinh":return[Fe.V(A("x",e,t,n))];case"Atan":return[Oe.z(A("x",e,t,n))];case"Atan2":return[Be.f(A("x",e,t,n),A("y",e,t,n))];case"Atanh":return[Ce.C(A("x",e,t,n))];case"Ceil":return[Ve.m(A("x",e,t,n))];case"Complex":return[Re.P(A("real",e,t,n),A("imag",e,t,n))];case"Cos":return[ze.m(A("x",e,t,n))];case"Cosh":return[Pe.f(A("x",e,t,n))];case"Elu":return[Le.p(A("x",e,t,n))];case"Erf":return[We.q(A("x",e,t,n))];case"Exp":return[He.Q(A("x",e,t,n))];case"Expm1":return[qe.t(A("x",e,t,n))];case"Floor":return[Ge.G(A("x",e,t,n))];case"Log":return[Ue.c(A("x",e,t,n))];case"Log1p":return[je.K(A("x",e,t,n))];case"Imag":return[Ke.a(A("x",e,t,n))];case"Neg":return[Xe.W(A("x",e,t,n))];case"Reciprocal":return[Ze.M(A("x",e,t,n))];case"Real":return[Je.k(A("x",e,t,n))];case"Relu":return[Qe.U(A("x",e,t,n))];case"Round":return[Ye.N(A("x",e,t,n))];case"Selu":return[et.U(A("x",e,t,n))];case"Sigmoid":return[tt.X(A("x",e,t,n))];case"Sin":return[nt.O(A("x",e,t,n))];case"Sign":return[rt.X(A("x",e,t,n))];case"Sinh":return[at.R(A("x",e,t,n))];case"Softplus":return[st.W(A("x",e,t,n))];case"Sqrt":return[ot._(A("x",e,t,n))];case"Square":return[it.h(A("x",e,t,n))];case"Tanh":return[ut.A(A("x",e,t,n))];case"Tan":return[lt.O(A("x",e,t,n))];case"ClipByValue":return[ct.i(A("x",e,t,n),A("clipValueMin",e,t,n),A("clipValueMax",e,t,n))];case"Relu6":return[pt.b(A("x",e,t,n))];case"Rsqrt":return[dt.b(M(e.inputNames[0],t,n))];case"Prod":return[ht.W(A("x",e,t,n),A("axes",e,t,n))];case"LeakyRelu":return[mt.h(A("x",e,t,n),A("alpha",e,t,n))];case"Prelu":return[ft.A(A("x",e,t,n),A("alpha",e,t,n))];case"IsNan":return[gt.i(M(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"control":return Nt(e,t,n);case"convolution":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"Conv1D":{const r=A("stride",e,t,n),a=A("pad",e,t,n),s=A("dataFormat",e,t,n).toUpperCase(),o=A("dilation",e,t,n);return[St.P(A("x",e,t,n),A("filter",e,t,n),r,a,s,o)]}case"Conv2D":{const r=A("strides",e,t,n),a=O(e,t,n),s=A("dataFormat",e,t,n).toUpperCase(),o=A("dilations",e,t,n);return[It.T(A("x",e,t,n),A("filter",e,t,n),[r[1],r[2]],a,s,[o[1],o[2]])]}case"_FusedConv2D":{const{stride:r,pad:a,dataFormat:s,dilations:o,biasArg:i,preluArg:u,activationFunc:l,leakyreluAlpha:c}=Ct(e,t,n);return[Tt.conv2d({x:A("x",e,t,n),filter:A("filter",e,t,n),strides:[r[1],r[2]],pad:a,dataFormat:s,dilations:[o[1],o[2]],bias:i,activation:l,preluActivationWeights:u,leakyreluAlpha:c})]}case"FusedDepthwiseConv2dNative":{const{stride:r,pad:a,dataFormat:s,dilations:o,biasArg:i,preluArg:u,activationFunc:l,leakyreluAlpha:c}=Ct(e,t,n);return[Tt.depthwiseConv2d({x:A("x",e,t,n),filter:A("filter",e,t,n),strides:[r[1],r[2]],pad:a,dataFormat:s,dilations:[o[1],o[2]],bias:i,activation:l,preluActivationWeights:u,leakyreluAlpha:c})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const r=A("outputShape",e,t,n),a=A("strides",e,t,n),s=O(e,t,n);return[_t.b(A("x",e,t,n),A("filter",e,t,n),r,[a[1],a[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const r=A("strides",e,t,n),a=O(e,t,n),s=A("dilations",e,t,n),o=A("dataFormat",e,t,n).toUpperCase();return[Et.B(A("input",e,t,n),A("filter",e,t,n),[r[1],r[2]],a,o,[s[1],s[2]])]}case"Conv3D":{const r=A("strides",e,t,n),a=A("pad",e,t,n),s=A("dataFormat",e,t,n).toUpperCase(),o=A("dilations",e,t,n);return[At.p(A("x",e,t,n),A("filter",e,t,n),[r[1],r[2],r[3]],a,s,[o[1],o[2],o[3]])]}case"AvgPool":{const r=A("strides",e,t,n),a=A("pad",e,t,n),s=A("kernelSize",e,t,n);return[Mt.w(A("x",e,t,n),[s[1],s[2]],[r[1],r[2]],a)]}case"MaxPool":{const r=A("strides",e,t,n),a=A("pad",e,t,n),s=A("kernelSize",e,t,n);return[$t._(A("x",e,t,n),[s[1],s[2]],[r[1],r[2]],a)]}case"MaxPoolWithArgmax":{const r=A("strides",e,t,n),a=A("pad",e,t,n),s=A("kernelSize",e,t,n),o=A("includeBatchInIndex",e,t,n),{result:i,indexes:u}=Dt.I(A("x",e,t,n),[s[1],s[2]],[r[1],r[2]],a,o);return[i,u]}case"AvgPool3D":{const r=A("strides",e,t,n),a=A("pad",e,t,n),s=A("kernelSize",e,t,n);return[Ft.u(A("x",e,t,n),[s[1],s[2],s[3]],[r[1],r[2],r[3]],a)]}case"MaxPool3D":{const r=A("strides",e,t,n),a=A("pad",e,t,n),s=A("kernelSize",e,t,n);return[Ot.Y(A("x",e,t,n),[s[1],s[2],s[3]],[r[1],r[2],r[3]],a)]}case"Dilation2D":{const r=A("strides",e,t,n),a=A("pad",e,t,n),s=A("dilations",e,t,n),o=r[1],i=r[2],u=s[1],l=s[2];return[Bt.W(A("x",e,t,n),A("filter",e,t,n),[o,i],a,[u,l],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"creation":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"Fill":{const r=A("shape",e,t,n),a=A("dtype",e,t,n),s=A("value",e,t,n);return[Vt.h(r,s,a)]}case"LinSpace":{const r=A("start",e,t,n),a=A("stop",e,t,n),s=A("num",e,t,n);return[Rt.S(r,a,s)]}case"Multinomial":{const r=A("logits",e,t,n),a=A("numSamples",e,t,n),s=A("seed",e,t,n);return[zt.S(r,a,s)]}case"OneHot":{const r=A("indices",e,t,n),a=A("depth",e,t,n),s=A("onValue",e,t,n),o=A("offValue",e,t,n);return[Pt.l(r,a,s,o)]}case"Ones":return[Lt.i(A("shape",e,t,n),A("dtype",e,t,n))];case"OnesLike":return[Wt.J(A("x",e,t,n))];case"RandomUniform":return[Ht.L(A("shape",e,t,n),A("minval",e,t,n),A("maxval",e,t,n),A("dtype",e,t,n))];case"Range":{const r=A("start",e,t,n),a=A("stop",e,t,n),s=A("step",e,t,n);return[qt.w(r,a,s,A("dtype",e,t,n))]}case"TruncatedNormal":{const r=A("shape",e,t,n),a=A("mean",e,t,n),s=A("stdDev",e,t,n),o=A("seed",e,t,n);return[Gt.X(r,a,s,A("dtype",e,t,n),o)]}case"Zeros":return[Ut.l(A("shape",e,t,n),A("dtype",e,t,n))];case"ZerosLike":return[jt.P(A("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"dynamic":return(async(e,t,n)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:a,maxOutputSize:s,iouThreshold:o,scoreThreshold:i,softNmsSigma:u}=Qt(e,t,n),l=await Kt.BHj.nonMaxSuppressionWithScoreAsync(r,a,s,o,i,u);return[l.selectedIndices,l.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:a,maxOutputSize:s,iouThreshold:o,scoreThreshold:i}=Qt(e,t,n),u=A("padToMaxOutputSize",e,t,n),l=await Kt.BHj.nonMaxSuppressionPaddedAsync(r,a,s,o,i,u);return[l.selectedIndices,l.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:a,maxOutputSize:s,iouThreshold:o,scoreThreshold:i}=Qt(e,t,n);return[await Kt.BHj.nonMaxSuppressionAsync(r,a,s,o,i)]}case"Where":{const r=Xt.p(A("condition",e,t,n),"bool"),a=[await Zt.i(r)];return r.dispose(),a}case"ListDiff":return Jt.O(A("x",e,t,n),A("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"TopKV2":{const r=A("x",e,t,n),a=A("k",e,t,n),s=A("sorted",e,t,n),o=Yt.h(r,a,s);return[o.values,o.indices]}case"Unique":{const r=A("x",e,t,n),a=en.T(r);return[a.values,a.indices]}case"UniqueV2":{const r=A("x",e,t,n),a=A("axis",e,t,n),s=en.T(r,a);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"image":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"ResizeBilinear":{const r=A("images",e,t,n),a=A("size",e,t,n),s=A("alignCorners",e,t,n),o=A("halfPixelCenters",e,t,n);return[Kt.BHj.resizeBilinear(r,[a[0],a[1]],s,o)]}case"ResizeNearestNeighbor":{const r=A("images",e,t,n),a=A("size",e,t,n),s=A("alignCorners",e,t,n),o=A("halfPixelCenters",e,t,n);return[Kt.BHj.resizeNearestNeighbor(r,[a[0],a[1]],s,o)]}case"CropAndResize":{const r=A("image",e,t,n),a=A("boxes",e,t,n),s=A("boxInd",e,t,n),o=A("cropSize",e,t,n),i=A("method",e,t,n),u=A("extrapolationValue",e,t,n);return[Kt.BHj.cropAndResize(r,a,s,o,i,u)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"graph":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const r=A("default",e,t,n);return[M(e.name,t,n)||r];case"Placeholder":return[M(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":return[B(A("x",e,t,n))];case"IdentityN":return A("x",e,t,n).map((e=>B(e)));case"Snapshot":return[B(A("x",e,t,n))];case"Shape":return[tn.R(A("x",e,t,n).shape,"int32")];case"ShapeN":return A("x",e,t,n).map((e=>tn.R(e.shape)));case"Size":return[nn.i(A("x",e,t,n).size,"int32")];case"Rank":return[nn.i(A("x",e,t,n).rank,"int32")];case"NoOp":return[nn.i(1)];case"Print":const a=A("x",e,t,n),s=A("data",e,t,n),o=A("message",e,t,n),i=A("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let e=0;e((e,t,n)=>{switch(e.op){case"Equal":return[an.D(A("a",e,t,n),A("b",e,t,n))];case"NotEqual":return[sn.Q(A("a",e,t,n),A("b",e,t,n))];case"Greater":return[on.p(A("a",e,t,n),A("b",e,t,n))];case"GreaterEqual":return[un.b(A("a",e,t,n),A("b",e,t,n))];case"Less":return[ln.d(A("a",e,t,n),A("b",e,t,n))];case"LessEqual":return[cn.z(A("a",e,t,n),A("b",e,t,n))];case"LogicalAnd":return[pn.H(A("a",e,t,n),A("b",e,t,n))];case"LogicalNot":return[dn.h(A("a",e,t,n))];case"LogicalOr":return[hn.K(A("a",e,t,n),A("b",e,t,n))];case"Select":case"SelectV2":return[mn.a(A("condition",e,t,n),A("a",e,t,n),A("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"matrices":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[fn.O(A("a",e,t,n),A("b",e,t,n),A("transposeA",e,t,n),A("transposeB",e,t,n))];case"Einsum":return[gn.W(A("equation",e,t,n),...A("tensors",e,t,n))];case"Transpose":return[yn.p(A("x",e,t,n),A("perm",e,t,n))];case"_FusedMatMul":const[r,a]=A("fusedOps",e,t,n),s="biasadd"===r,o="prelu"===a,i=A("numArgs",e,t,n),u=A("leakyreluAlpha",e,t,n);if(s){if(o&&2!==i)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&1!==i)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[l,c]=A("args",e,t,n);return[Tt.matMul({a:A("a",e,t,n),b:A("b",e,t,n),transposeA:A("transposeA",e,t,n),transposeB:A("transposeB",e,t,n),bias:l,activation:a,preluActivationWeights:c,leakyreluAlpha:u})];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"normalization":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[bn.t(A("x",e,t,n),A("mean",e,t,n),A("variance",e,t,n),A("offset",e,t,n),A("scale",e,t,n),A("epsilon",e,t,n))];case"LRN":return[kn.G(A("x",e,t,n),A("radius",e,t,n),A("bias",e,t,n),A("alpha",e,t,n),A("beta",e,t,n))];case"Softmax":return[wn.X(A("x",e,t,n))];case"LogSoftmax":return[vn.C(A("x",e,t,n))];case"SparseToDense":return[xn.e(A("sparseIndices",e,t,n),A("outputShape",e,t,n),A("sparseValues",e,t,n),A("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"reduction":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"Max":{const r=A("axis",e,t,n),a=A("keepDims",e,t,n);return[Nn.F(A("x",e,t,n),r,a)]}case"Mean":{const r=A("axis",e,t,n),a=A("keepDims",e,t,n);return[Sn.J(A("x",e,t,n),r,a)]}case"Min":{const r=A("axis",e,t,n),a=A("keepDims",e,t,n);return[In.V(A("x",e,t,n),r,a)]}case"Sum":{const r=A("axis",e,t,n),a=A("keepDims",e,t,n);return[Tn.S(A("x",e,t,n),r,a)]}case"All":{const r=A("axis",e,t,n),a=A("keepDims",e,t,n);return[_n.$(A("x",e,t,n),r,a)]}case"Any":{const r=A("axis",e,t,n),a=A("keepDims",e,t,n);return[En.Y(A("x",e,t,n),r,a)]}case"ArgMax":{const r=A("axis",e,t,n);return[An.N(A("x",e,t,n),r)]}case"ArgMin":{const r=A("axis",e,t,n);return[Mn.v(A("x",e,t,n),r)]}case"Prod":{const r=A("axis",e,t,n),a=A("keepDims",e,t,n);return[ht.W(A("x",e,t,n),r,a)]}case"Cumsum":{const r=A("axis",e,t,n),a=A("exclusive",e,t,n),s=A("reverse",e,t,n);return[$n.z(A("x",e,t,n),r,a,s)]}case"Bincount":const r=A("x",e,t,n),a=A("weights",e,t,n),s=A("size",e,t,n);return[Dn.y(r,a,s)];case"DenseBincount":{const r=A("x",e,t,n),a=A("weights",e,t,n),s=A("size",e,t,n),o=A("binaryOutput",e,t,n);return[Fn.p(r,a,s,o)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"slice_join":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"ConcatV2":case"Concat":{const r=A("n",e,t,n),a=A("axis",e,t,n);let s=A("tensors",e,t,n);return s=s.slice(0,r),[On.z(s,a)]}case"Gather":{const r=A("x",e,t,n),a=A("indices",e,t,n);return[Bn.I(r,Xt.p(a,"int32"),0)]}case"GatherV2":{const r=A("axis",e,t,n),a=A("batchDims",e,t,n),s=A("x",e,t,n),o=A("indices",e,t,n);return[Bn.I(s,Xt.p(o,"int32"),r,a)]}case"Reverse":{const r=A("dims",e,t,n),a=[];for(let e=0;e{const r=A("axis",e,t,n),a=A("tensors",e,t,n),s=a[0].shape,o=zn.L(a[0]).shape,i=a.map((e=>{const t=S.util.arraysEqual(e.shape,s);if(!t&&!S.util.arraysEqual(zn.L(e).shape,o))throw new Error("the input tensors shape does not match");return t?e:Pn.X(e,s)}));return[Ln.k(i,r)]}));case"Unpack":{const r=A("axis",e,t,n),a=A("tensor",e,t,n);return Wn.H(a,r)}case"Tile":{const r=A("reps",e,t,n);return[Hn.G(A("x",e,t,n),r)]}case"Split":case"SplitV":{const r=A("axis",e,t,n),a=A("numOrSizeSplits",e,t,n),s=A("x",e,t,n);return qn.V(s,a,r)}case"ScatterNd":{const r=A("indices",e,t,n),a=A("values",e,t,n),s=A("shape",e,t,n);return[Gn.s(r,a,s)]}case"GatherNd":{const r=A("x",e,t,n),a=A("indices",e,t,n);return[Un.d(r,a)]}case"SparseToDense":{const r=A("sparseIndices",e,t,n),a=A("outputShape",e,t,n),s=A("sparseValues",e,t,n),o=A("defaultValue",e,t,n);return[xn.e(r,s,a,s.dtype===o.dtype?o:Xt.p(o,s.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"sparse":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:r,outputValues:a,emptyRowIndicator:s,reverseIndexMap:o}=Kt.rVs.sparseFillEmptyRows(A("indices",e,t,n),A("values",e,t,n),A("denseShape",e,t,n),A("defaultValue",e,t,n));return[r,a,s,o]}case"SparseReshape":{const{outputIndices:r,outputShape:a}=Kt.rVs.sparseReshape(A("inputIndices",e,t,n),A("inputShape",e,t,n),A("newShape",e,t,n));return[r,a]}case"SparseSegmentMean":return[Kt.rVs.sparseSegmentMean(A("data",e,t,n),A("indices",e,t,n),A("segmentIds",e,t,n))];case"SparseSegmentSum":return[Kt.rVs.sparseSegmentSum(A("data",e,t,n),A("indices",e,t,n),A("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"spectral":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"FFT":return[jn.k(A("x",e,t,n))];case"IFFT":return[Kn.S(A("x",e,t,n))];case"RFFT":return[Xn.Q(A("x",e,t,n))];case"IRFFT":return[Zn.w(A("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"string":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"StringNGrams":{const{nGrams:r,nGramsSplits:a}=Kt.Z_8.stringNGrams(A("data",e,t,n),A("dataSplits",e,t,n),A("separator",e,t,n),A("nGramWidths",e,t,n),A("leftPad",e,t,n),A("rightPad",e,t,n),A("padWidth",e,t,n),A("preserveShortSequences",e,t,n));return[r,a]}case"StringSplit":{const{indices:r,values:a,shape:s}=Kt.Z_8.stringSplit(A("input",e,t,n),A("delimiter",e,t,n),A("skipEmpty",e,t,n));return[r,a,s]}case"StringToHashBucketFast":return[Kt.Z_8.stringToHashBucketFast(A("input",e,t,n),A("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"transformation":return S.tidy((()=>((e,t,n)=>{switch(e.op){case"Cast":return[Xt.p(A("x",e,t,n),A("dtype",e,t,n))];case"ExpandDims":{const r=A("axis",e,t,n);return[Jn.d(A("x",e,t,n),r)]}case"Squeeze":{const r=A("axis",e,t,n);return[zn.L(A("x",e,t,n),r)]}case"Reshape":return[Pn.X(A("x",e,t,n),A("shape",e,t,n))];case"MirrorPad":return[Qn.V(A("x",e,t,n),A("padding",e,t,n),A("mode",e,t,n))];case"PadV2":case"Pad":return[Yn.v(A("x",e,t,n),A("padding",e,t,n),A("constantValue",e,t,n))];case"SpaceToBatchND":{const r=A("blockShape",e,t,n),a=A("paddings",e,t,n);return[er.f(A("x",e,t,n),r,a)]}case"BatchToSpaceND":{const r=A("blockShape",e,t,n),a=A("crops",e,t,n);return[tr.E(A("x",e,t,n),r,a)]}case"DepthToSpace":{const r=A("blockSize",e,t,n),a=A("dataFormat",e,t,n).toUpperCase();return[nr.n(A("x",e,t,n),r,a)]}case"BroadcastTo":return[rr.U(A("x",e,t,n),A("shape",e,t,n))];case"BroadcastArgs":return[ar.X(A("s0",e,t,n),A("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"hash_table":return(async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{const a=A("keyDType",e,t,n),s=A("valueDType",e,t,n),o=new rn(a,s);return r.addHashTable(e.name,o),[o.handle]}case"LookupTableImport":case"LookupTableImportV2":{const a=A("tableHandle",e,t,n,r),s=A("keys",e,t,n),o=A("values",e,t,n),i=r.getHashTableById(a.id);return[await i.import(s,o)]}case"LookupTableFind":case"LookupTableFindV2":{const a=A("tableHandle",e,t,n,r),s=A("keys",e,t,n),o=A("defaultValue",e,t,n),i=r.getHashTableById(a.id);return[await i.find(s,o)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=A("tableHandle",e,t,n,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n,r);case"custom":const a=_(e.op);if(a&&a.customExecutor)return a.customExecutor(new ge(e,t,n));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return S.util.isPromise(a)?a.then((e=>[].concat(e))):[].concat(a)}class or{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`)).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function ir(e,t,n,r){const a=new Set,s=[];let o=null,i=null;const u=new Set,l=Object.keys(e).map((e=>F(e)[0]));let c=[];null!=r&&(c=r.map((e=>F(e.name)[0])));const p=[...t];for(;p.length>0;){const e=p.pop();(pr(e)||dr(e)||hr(e))&&null==o&&(o=e,i=o.children.map((e=>e.name)).filter((e=>a.has(e)))),a.add(e.name),null==n[e.name]&&(-1===l.indexOf(e.name)&&-1===c.indexOf(e.name)&&(0!==e.inputs.length?e.inputs.forEach((e=>{u.has(e.name)||(u.add(e.name),p.push(e))})):s.push(e.name)))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:s,dynamicNode:o,syncInputs:i}}const ur=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],lr=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],cr=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function pr(e){return ur.indexOf(e.op)>=0}function dr(e){return lr.indexOf(e.op)>=0}function hr(e){return cr.indexOf(e.op)>=0}class mr{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach((t=>{this._functionExecutorMap[t]=new mr(e.functions[t],this)}))}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map((t=>e[t].map((e=>e.id))));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((e=>e.signatureKey||e.name))}get outputNodes(){return this._outputs.map((e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t}))}get functions(){return Object.keys(this._functions).reduce(((e,t)=>(e[t]=this._functions[t].signature,e)),{})}getCompilationKey(e,t){const n=e.map((e=>e.name)).sort(),r=t.map((e=>e.name)).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){const n=ir(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:s}=n;if(null!=a)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${s}]`);if(r.length>0){const n=t.map((e=>e.name)),a=Object.keys(e);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${a}]. Missing the following inputs: [${r}]`)}return function(e,t,n){const{usedNodes:r,inputs:a}=n,s=[],o=Object.keys(a).map((e=>F(e)[0])).map((t=>e.nodes[t])),i=e.initNodes;o.forEach((e=>{r.has(e.name)&&s.push(e)})),e.weights.forEach((e=>{r.has(e.name)&&s.push(e)})),null!=i&&i.forEach((e=>{r.has(e.name)&&s.push(e)}));const u=new Set,l=[];for(;s.length>0;){const e=s.pop();u.add(e.name),t[e.name]||l.push(e),e.children.forEach((e=>{!u.has(e.name)&&r.has(e.name)&&e.inputs.every((e=>u.has(e.name)))&&s.push(e)}))}return l}(this.graph,this.weightMap,n)}execute(e,t){e=this.mapInputs(e);const n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=n.map((e=>this.graph.nodes[F(e)[0]])),a=t.map((e=>F(e)[0]));let s=a.map((e=>this.graph.nodes[e]));0===s.length&&(s=this._outputs);const o=this.getCompilationKey(r,s);let i=this.compiledMap.get(o);null==i&&(i=this.compile(e,s),this.compiledMap.set(o,i));const u={},l={};return(0,S.tidy)((()=>{const n=new or(this.weightMap,u,l,this.functionExecutorMap),r=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,a]=F(t),s=[];s[a]=e[t],r[n]=s}));const s=this.getFrozenTensorIds(r),o={};for(let e=0;eM(e,r,n)))}))}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map((t=>e[t])).map((e=>e.map((e=>e.id)))));return new Set(t)}checkTensorForDisposal(e,t,n,r,a,s,o){"control"!==t.category&&-1===s.indexOf(e)&&(n[e].forEach((e=>{null!=e&&(o[e.id]=(o[e.id]||0)+t.children.length)})),t.inputs.forEach((e=>{if("control"!==e.category){const t=function(e,t,n){return t[D(e,n.currentContextId)]}(e.name,n,r);null!=t&&t.forEach((e=>{if(e&&!e.kept&&!a.has(e.id)){const t=o[e.id];1===t?(e.dispose(),delete o[e.id]):null!=t&&o[e.id]--}}))}})))}async executeAsync(e,t){return this._executeAsync(e,t)}async _executeAsync(e,t,n=!1,r={},a={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));const s=new or(this.weightMap,r,a,this.functionExecutorMap),o=await this.executeWithControlFlow(e,s,t,n),i=t.map((e=>M(e,o,s))),u=i.map((e=>e.id)),l=Object.keys(e).map((t=>e[t].id)),c=new Set([...u,...l,...this.weightIds]);return Object.keys(o).forEach((e=>{o[e].forEach((e=>{!e||e.kept||e.isDisposed||c.has(e.id)||e.dispose()}))})),null==this.parent&&s.dispose(c),i}async executeFunctionAsync(e,t,n){const r=e.reduce(((e,t,n)=>(e[this.inputs[n].name]=t,e)),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){const a=Object.keys(e),s=a.map((e=>this.graph.nodes[F(e)[0]])),o=n.map((e=>F(e)[0]));let i=o.map((e=>this.graph.nodes[e]));0===i.length&&(i=this._outputs);const{usedNodes:u,missingInputs:l,dynamicNode:c,syncInputs:p}=ir(e,i,this.weightMap,this._initNodes),d=[...s,...this.graph.weights,...this._initNodes||[]].map((e=>({node:e,contexts:t.currentContext}))),h=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,r]=F(t),a=[];a[r]=e[t],h[n]=a}));const m={},f=this.getFrozenTensorIds(h),g={};for(;d.length>0;){const e=this.processStack(s,d,t,h,g,f,o,m,u);await Promise.all(e)}null!=c||r||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const y=i.filter((e=>!pr(e)&&!M(e.name,h,t))).map((e=>e.name));if(y.length>0){let e="";throw null!=c&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${a}]. Consider providing the following inputs: [${l}]. ${e}`)}return h}processStack(e,t,n,r,a,s,o,i,u){const l=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let c="";if("Enter"===e.node.op&&A("isConstant",e.node,r,n)&&([c]=$(e.node.name,n)),null==r[e.node.name]){const p=sr(e.node,r,n,this._resourceManager);c||([c]=$(e.node.name,n));const d=n.currentContext;S.util.isPromise(p)?l.push(p.then((l=>(r[c]=l,n.currentContext=d,this.checkTensorForDisposal(c,e.node,r,n,s,o,i),this.processChildNodes(e.node,t,n,r,a,u),l)))):(r[c]=p,this.checkTensorForDisposal(c,e.node,r,n,s,o,i),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return l}processChildNodes(e,t,n,r,a,s){e.children.forEach((e=>{const[o]=$(e.name,n);!a[o]&&s.has(e.name)&&("Merge"===e.op?e.inputNames.some((e=>!!M(e,r,n)))&&(a[o]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((e=>!!M(e,r,n)))&&(a[o]=!0,t.push({contexts:n.currentContext,node:e})))}))}dispose(){Object.keys(this.weightMap).forEach((e=>this.weightMap[e].forEach((e=>e.dispose()))))}checkInputShapeAndType(e){Object.keys(e).forEach((t=>{const n=e[t],[r]=F(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const e=a.attrParams.shape.value,t=e.length===n.shape.length&&n.shape.every(((t,n)=>-1===e[n]||e[n]===t));S.util.assert(t,(()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`))}a.attrParams.dtype&&a.attrParams.dtype.value&&S.util.assert(n.dtype===a.attrParams.dtype.value,(()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(e){const t={};for(const n in e)if(null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n]){t[this._signature.inputs[n].name]=e[n]}else t[n]=e[n];return t}checkInputs(e){const t=Object.keys(e).filter((e=>{const[t]=F(e);return null==this.graph.nodes[t]}));if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map((e=>{if(null!=this._signature&&null!=this._signature.outputs&&null!=this._signature.outputs[e]){return this._signature.outputs[e].name}return e}),{})}checkOutputs(e){e.forEach((e=>{const[t]=F(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)}))}}class fr{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}class gr{constructor(e,t={}){this.modelUrl=e,this.loadOptions=t,this.version="n/a",null==t&&(this.loadOptions={}),this.resourceManager=new fr}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=S.io.browserHTTPRequest(e,this.loadOptions);else{const t=S.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(S.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}async load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=await this.handler.load();return this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n;n=null!=this.artifacts.userDefinedMetadata&&null!=this.artifacts.userDefinedMetadata.signature?this.artifacts.userDefinedMetadata.signature:this.artifacts.signature,this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=S.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new mr(te.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){const t=te.Instance.transformGraph(e.modelInitializer);this.initializer=new mr(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(e,t){if("string"==typeof e){const t=S.io.getSaveHandlers(e);if(0===t.length)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}predict(e,t){return this.execute(e,this.outputNodes)}normalizeInputs(e){if(!(e instanceof S.Tensor||Array.isArray(e)))return e;if((e=Array.isArray(e)?e:[e]).length!==this.inputNodes.length)throw new Error(`Input tensor count mismatch,the graph model has ${this.inputNodes.length} placeholders, while there are ${e.length} input tensors.`);return this.inputNodes.reduce(((t,n,r)=>(t[n]=e[r],t)),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=this.executor.execute(e,t);return n.length>1?n:n[0]}async executeAsync(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce(((t,n)=>(t[n]=[e[n]],t)),{})}dispose(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}async function yr(e,t={}){if(null==e)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&null==e.load&&(e.endsWith("/")||(e+="/"),e=`${e}model.json?tfjs-format=file`);const n=new gr(e,t);return await n.load(),n}const br="3.9.0"},8713:(e,t,n)=>{"use strict";n.d(t,{JL:()=>r,Zu:()=>a});class r{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class a{refCount(e){return s("refCount")}incRef(e){return s("incRef")}timerAvailable(){return!0}time(e){return s("time")}read(e){return s("read")}readSync(e){return s("readSync")}numDataIds(){return s("numDataIds")}disposeData(e,t){return s("disposeData")}write(e,t,n){return s("write")}move(e,t,n,r,a){return s("move")}memory(){return s("memory")}floatPrecision(){return s("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return s("dispose")}}function s(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}},3337:(e,t,n)=>{"use strict";function r(e,t,n){const r=function(e,t,n){return function(e,t,n){let r=0,a=e.length,s=0,o=!1;for(;r>>1);const i=n(t,e[s]);i>0?r=s+1:(a=s,o=!i)}return o?r:-r-1}(e,t,n||a)}(e,t,n),s=r<0?-(r+1):r;e.splice(s,0,t)}function a(e,t){return e>t?1:es&&h.push({score:t[e],boxIndex:e,suppressBeginIndex:0});h.sort(p);const m=o>0?-.5/o:0,f=[],g=[];for(;f.length0;){const t=h.pop(),{score:n,boxIndex:o,suppressBeginIndex:i}=t;if(n=i;--n){const r=l(e,o,f[n]);if(r>=a){u=!0;break}if(t.score=t.score*c(a,m,r),t.score<=s)break}t.suppressBeginIndex=f.length,u||(t.score===n?(f.push(o),g.push(t.score)):t.score>s&&r(h,t,p))}const y=f.length,b=n-y;u&&b>0&&(f.push(...new Array(b).fill(0)),g.push(...new Array(b).fill(0)));const k={selectedIndices:f};return i&&(k.selectedScores=g),d&&(k.validOutputs=y),k}function l(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),s=Math.min(r[0],r[2]),o=Math.min(r[1],r[3]),i=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),d=Math.max(a[1],a[3]),h=(i-s)*(u-o),m=(p-l)*(d-c);if(h<=0||m<=0)return 0;const f=Math.max(s,l),g=Math.max(o,c),y=Math.min(i,p),b=Math.min(u,d),k=Math.max(y-f,0)*Math.max(b-g,0);return k/(h+m-k)}function c(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function p(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}n.d(t,{GP:()=>s,qP:()=>o,pA:()=>i})},8333:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var r=n(2657);function a(e,t){const n=[];for(let e=0;e{"use strict";n.d(t,{BV:()=>w,wv:()=>k});var r=n(8713),a=n(2885),s=n(5938),o=n(9121),i=n(6151),u=n(9122),l=n(569);class c{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new d)}profileKernel(e,t,n){let r;const s=()=>{r=n()};let o;const i=u.now();if(this.backendTimer.timerAvailable())o=this.backendTimer.time(s);else{s();for(const e of r)e.dataSync();o=Promise.resolve({kernelMs:u.now()-i})}if((0,a.OB)().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t{p(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:o.then((e=>e.kernelMs)),extraInfo:o.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:s}=e;n.forEach((e=>{Promise.all([e.data(),r,s]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function p(e,t,n){if("float32"!==t)return!1;for(let t=0;t0?r:""} `}}console.log(`%c${i}\t%c${o}\t%c${u}D ${p}\t%c${c}\t%c${d}\t%c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}var h=n(4077),m=n(747),f=n(4706);function g(e){return null!=e.kernelName}class y{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class b{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new y}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){(0,i.tr)(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof r.Zu||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t(tthis.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;tthis.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return b.nextTensorId++}nextVariableId(){return b.nextVariableId++}clone(e){const t=w.runKernel(o.iJ,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e},n={dtype:"float32"};return w.runKernel(o.RF,t,n)}})),[],{}),t}runKernel(e,t,n){null==this.backendName&&this.backend;if(!(null!=(0,i.pI)(e,this.backendName)))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],o=r-t-a-s;if(o>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${o} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,s=this.state.numTensors;let o,u;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const c=g(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(g(e)){const{kernelName:t,inputs:a,attrs:s}=e;null==this.backendName&&this.backend;const c=(0,i.pI)(t,this.backendName);l.hu(null!=c,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),o=()=>{const e=this.backend.numDataIds();u=c.kernelFunc({inputs:a,attrs:s,backend:this.backend});const o=Array.isArray(u)?u:[u];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,o);const i=o.map((e=>{if(null!=e.rank)return e;const{dataId:t,shape:n,dtype:r}=e;return this.makeTensorFromDataId(t,n,r)}));if(r){const e=this.getTensorsForGradient(t,a,i);n=this.saveTensorsForBackwardMode(e)}return i}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};o=()=>{const e=this.backend.numDataIds();u=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(u)?u:[u];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,e,n),n}}const{inputs:p,attrs:d}=e,h=g(e)?null:e.backwardsFunc;let m;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(m=this.profiler.profileKernel(c,p,(()=>o())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(m),t=m.outputs):t=o()})),r&&this.addTapeNode(c,p,t,h,n,d),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-s,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(p).map((e=>null!=p[e]?p[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:m.timeMs,extraInfo:m.extraInfo}),Array.isArray(u)?t:t[0]}saveTensorsForBackwardMode(e){return e.map((e=>this.keep(this.clone(e))))}getTensorsForGradient(e,t,n){const r=(0,i.uk)(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let s;r.saveAllInputs?(l.hu(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),s=Object.keys(t).map((e=>t[e]))):s=e.map((e=>t[e]));const o=n.filter(((e,t)=>a[t]));return s.concat(o)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let a=e;"string"===n&&l.HD(e[0])&&(a=e.map((e=>u.encodeString(e))));const s=r.write(a,t,n),o=new h.es(t,n,s,this.nextTensorId());if(this.trackTensor(o,r),"string"===n){const e=this.state.tensorInfo.get(s),t=(0,l.Ub)(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return o}makeTensorFromDataId(e,t,n,r){n=n||"float32";const a=new h.es(t,n,e,this.nextTensorId());return this.trackTensor(a,r),a}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new h._w(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*l.bT(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof h._w||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*l.bT(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,s){const o={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},u=(0,i.uk)(e);null!=u&&(r=u.gradFunc),null!=r&&(o.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=l.wT(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,s))),this.state.activeTape.push(o)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=(0,m.getTensorsInContainer)(e),n=new Set(t.map((e=>e.id)));for(let e=0;e{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(l.hu(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));l.hu(a instanceof h.es,(()=>"The result y returned by f() must be a tensor."));const s=function(e,t,n){const r={},a={};for(let e=0;er[e.id]=!0)),i=!0,a[s.id]=!0;break}if(i)break}}const s={};s[n.id]=!0;const o={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[a.id]=null==n?function(e){const t=(0,l.p8)((0,l.NA)(e),"float32");return w.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const s=t[a],o=[];if(s.outputs.forEach((t=>{const n=e[t.id];null!=n?o.push(n):o.push(null)})),null==s.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);const i=s.gradient(o);for(const t in s.inputs){if(!(t in i))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(i)}.`);const a=n((()=>i[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const o=s.inputs[t];if(!l.cO(a.shape,o.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${o.shape}'`);if(null==e[o.id])e[o.id]=a;else{const t=e[o.id];e[o.id]=r(t,a),t.dispose()}}}}(e,s,(e=>this.tidy(e)),v);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:a,grads:r}}))}customGrad(e){return l.hu(l.mf(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;l.hu(t.every((e=>e instanceof h.es)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};t.forEach(((e,t)=>{r[t]=e}));return this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),l.hu(n.value instanceof h.es,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),l.hu(l.mf(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const a=n.gradFunc(e,r),s=Array.isArray(a)?a:[a];l.hu(s.length===t.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),l.hu(s.every((e=>e instanceof h.es)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const o={};return s.forEach(((e,t)=>{o[t]=()=>e})),o},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}async time(e){const t=(0,u.now)(),n=await this.backend.time(e);return n.wallMs=(0,u.now)()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new y;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function k(){const e=(0,s.D)();if(null==e._tfengine){const t=new a.qA(e);e._tfengine=new b(t)}return(0,a.iG)(e._tfengine.ENV),(0,h.Vi)((()=>e._tfengine)),e._tfengine}b.nextTensorId=0,b.nextVariableId=0;const w=k();function v(e,t){const n={a:e,b:t};return w.runKernel(o.mm,n)}},2885:(e,t,n)=>{"use strict";n.d(t,{qA:()=>o,OB:()=>u,Vi:()=>l,iG:()=>c});var r=n(569),a=n(4706);const s="tfjsflags";class o{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=i,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&a.Z(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];a.Z(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if((0,r.tI)(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);if(s in e){e.tfjsflags.split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}(t,n)}))}}}function i(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function u(){return l}let l=null;function c(e){l=e}},5938:(e,t,n)=>{"use strict";let r;function a(){if(null==r){let e;if("undefined"!=typeof window)e=window;else if("undefined"!=typeof global)e=global;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}r=e}return r}function s(e,t){const n=function(){const e=a();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}n.d(t,{D:()=>a,R:()=>s})},4368:(e,t,n)=>{"use strict";n.d(t,{G4:()=>i,R:()=>u,cF:()=>l,MX:()=>c,N8:()=>p,SR:()=>d,sq:()=>h,N5:()=>m,lu:()=>f,B9:()=>g,Cn:()=>y,XV:()=>b,CQ:()=>k,Cd:()=>w,N_:()=>v,cj:()=>x,x3:()=>N,ze:()=>S,jq:()=>I,y3:()=>T,VY:()=>_});var r=n(7097),a=n(2885),s=n(4077),o=n(747);function i(){(0,a.OB)().set("PROD",!0)}function u(){(0,a.OB)().set("DEBUG",!0)}function l(){(0,a.OB)().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function c(e){(0,a.OB)().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function p(){r.BV.disposeVariables()}function d(){return r.BV}function h(){return r.BV.memory()}function m(e){return r.BV.profile(e)}function f(e,t){return r.BV.tidy(e,t)}function g(e){(0,o.getTensorsInContainer)(e).forEach((e=>e.dispose()))}function y(e){return r.BV.keep(e)}function b(e){return r.BV.time(e)}function k(e){return r.BV.setBackend(e)}function w(){return r.BV.ready()}function v(){return r.BV.backendName}function x(e){r.BV.removeBackend(e)}function N(e){return r.BV.findBackend(e)}function S(e){return r.BV.findBackendFactory(e)}function I(e,t,n=1){return r.BV.registerBackend(e,t,n)}function T(){return r.BV.backend}function _(e,t){(0,a.OB)().setPlatform(e,t)}(0,s.FZ)(c)},633:(e,t,n)=>{"use strict";n.d(t,{cb:()=>d,pn:()=>p,h7:()=>l,fN:()=>c,UQ:()=>i,ti:()=>u});var r=n(7097),a=n(4077),s=n(3740),o=n(569);function i(e){return o.hu(o.mf(e),(()=>"The f passed in grad(f) must be a function")),(t,n)=>{const a=(0,s._1)(t,"x","tf.grad","string_or_numeric"),i=null!=n?(0,s._1)(n,"dy","tf.grad"):null;return r.BV.tidy((()=>{const{value:t,grads:n}=r.BV.gradients((()=>e(a)),[a],i);return null!=i&&o.k5(t.shape,i.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),h(n),n[0]}))}}function u(e){return o.hu(o.mf(e),(()=>"The f passed in grads(f) must be a function")),(t,n)=>{o.hu(Array.isArray(t),(()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"));const a=(0,s.sI)(t,"args","tf.grads","string_or_numeric"),i=null!=n?(0,s._1)(n,"dy","tf.grads"):null;return r.BV.tidy((()=>{const{value:t,grads:n}=r.BV.gradients((()=>e(...a)),a,i);return null!=i&&o.k5(t.shape,i.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),h(n),n}))}}function l(e){return o.hu(o.mf(e),(()=>"The f passed in valueAndGrad(f) must be a function")),(t,n)=>{o.hu(t instanceof a.es,(()=>"The x passed in valueAndGrad(f)(x) must be a tensor")),o.hu(null==n||n instanceof a.es,(()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"));const{grads:s,value:i}=r.BV.gradients((()=>e(t)),[t],n);return h(s),{grad:s[0],value:i}}}function c(e){return o.hu(o.mf(e),(()=>"The f passed in valueAndGrads(f) must be a function")),(t,n)=>{o.hu(Array.isArray(t)&&t.every((e=>e instanceof a.es)),(()=>"The args passed in valueAndGrads(f)(args) must be array of tensors")),o.hu(null==n||n instanceof a.es,(()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"));const s=r.BV.gradients((()=>e(...t)),t,n);return null!=n&&o.k5(s.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),h(s.grads),s}}function p(e,t){o.hu(o.mf(e),(()=>"The f passed in variableGrads(f) must be a function")),o.hu(null==t||Array.isArray(t)&&t.every((e=>e instanceof a._w)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in r.BV.registeredVariables)t.push(r.BV.registeredVariables[e])}const s=n?t.filter((e=>!e.trainable)):null,i=t.length;t=t.filter((e=>e.trainable)),o.hu(t.length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${i} variables is trainable.`));const{value:u,grads:l}=r.BV.gradients(e,t,null,!0);o.hu(l.some((e=>null!=e)),(()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize().")),o.hu(0===u.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${u.rank} tensor`));const c={};return t.forEach(((e,t)=>{null!=l[t]&&(c[e.name]=l[t])})),null!=s&&s.forEach((e=>c[e.name]=null)),{value:u,grads:c}}function d(e){return r.BV.customGrad(e)}function h(e){if(e.filter((e=>null==e)).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.")}},5363:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Abs:()=>je.SY,Acos:()=>je.VG,Acosh:()=>je.Sp,AdadeltaOptimizer:()=>jt,AdagradOptimizer:()=>Xt,AdamOptimizer:()=>Qt,AdamaxOptimizer:()=>tn,Add:()=>je.mm,AddN:()=>je.Xz,All:()=>je.oT,Any:()=>je.IK,ArgMax:()=>je.sJ,ArgMin:()=>je.aJ,Asin:()=>je.M2,Asinh:()=>je.qw,Atan:()=>je.jM,Atan2:()=>je.QC,Atanh:()=>je.Oy,AvgPool:()=>je.Jh,AvgPool3D:()=>je._k,AvgPool3DGrad:()=>je.IM,AvgPoolGrad:()=>je.RO,BatchMatMul:()=>je.XL,BatchToSpaceND:()=>je.zw,Bincount:()=>je.zv,BroadcastArgs:()=>je.eE,BroadcastTo:()=>je.Ly,Cast:()=>je.RF,Ceil:()=>je.gJ,ClipByValue:()=>je.xn,Complex:()=>je.Zz,ComplexAbs:()=>je.yj,Concat:()=>je.Eh,Conv2D:()=>je.mh,Conv2DBackpropFilter:()=>je.wU,Conv2DBackpropInput:()=>je.wm,Conv3D:()=>je.x1,Conv3DBackpropFilterV2:()=>je.o2,Conv3DBackpropInputV2:()=>je.ik,Cos:()=>je.mc,Cosh:()=>je.TR,CropAndResize:()=>je.Vc,Cumsum:()=>je.iH,DataStorage:()=>or.JL,DenseBincount:()=>je.QR,DepthToSpace:()=>je.T0,DepthwiseConv2dNative:()=>je.ci,DepthwiseConv2dNativeBackpropFilter:()=>je.sL,DepthwiseConv2dNativeBackpropInput:()=>je.y7,Diag:()=>je.$w,Dilation2D:()=>je.p4,Dilation2DBackpropFilter:()=>je.Vn,Dilation2DBackpropInput:()=>je.ek,ENV:()=>y.Vi,Einsum:()=>je.$g,Elu:()=>je.SX,EluGrad:()=>je.HE,Environment:()=>y.qA,Equal:()=>je.hd,Erf:()=>je.Om,Exp:()=>je.NE,ExpandDims:()=>je.YF,Expm1:()=>je.Y0,FFT:()=>je.vw,Fill:()=>je.de,FlipLeftRight:()=>je.Uy,Floor:()=>je.OR,FloorDiv:()=>je.je,FromPixels:()=>je.eB,FusedBatchNorm:()=>je.sH,FusedConv2D:()=>je._V,FusedDepthwiseConv2D:()=>je.lu,GatherNd:()=>je.q1,GatherV2:()=>je.qi,Greater:()=>je.iZ,GreaterEqual:()=>je.Ac,IFFT:()=>je.Qg,Identity:()=>je.iJ,Imag:()=>je.J_,IsFinite:()=>je.av,IsInf:()=>je.iW,IsNan:()=>je.r7,KernelBackend:()=>or.Zu,LRN:()=>je.eZ,LRNGrad:()=>je.Hh,LeakyRelu:()=>je.J$,Less:()=>je.vt,LessEqual:()=>je.CA,LinSpace:()=>je.e7,Log:()=>je.Zb,Log1p:()=>je.kU,LogSoftmax:()=>je.qC,LogicalAnd:()=>je.PY,LogicalNot:()=>je.Vf,LogicalOr:()=>je.MZ,Max:()=>je.Yo,MaxPool:()=>je.mT,MaxPool3D:()=>je.OA,MaxPool3DGrad:()=>je.OU,MaxPoolGrad:()=>je.OV,MaxPoolWithArgmax:()=>je.vF,Maximum:()=>je.BM,Mean:()=>je.q2,Min:()=>je.c1,Minimum:()=>je.q8,MirrorPad:()=>je.jQ,Mod:()=>je.Vb,MomentumOptimizer:()=>rn,Multinomial:()=>je.NZ,Multiply:()=>je.wY,Neg:()=>je.ku,NonMaxSuppressionV3:()=>je.uv,NonMaxSuppressionV4:()=>je.cy,NonMaxSuppressionV5:()=>je.W0,NotEqual:()=>je.yQ,OP_SCOPE_SUFFIX:()=>on.zvA,OneHot:()=>je.we,OnesLike:()=>je.qW,Optimizer:()=>Ut,Pack:()=>je.Qi,PadV2:()=>je.ly,Pool:()=>je.Kg,Pow:()=>je.pe,Prelu:()=>je.o0,Prod:()=>je.Dl,RMSPropOptimizer:()=>an,Range:()=>je.e6,Rank:()=>sn.yw,Real:()=>je.xJ,RealDiv:()=>je.oH,Reciprocal:()=>je.$H,Reduction:()=>un.I,Relu:()=>je.qk,Relu6:()=>je.Sb,Reshape:()=>je.HZ,ResizeBilinear:()=>je._Y,ResizeBilinearGrad:()=>je.zb,ResizeNearestNeighbor:()=>je.dp,ResizeNearestNeighborGrad:()=>je.Hm,Reverse:()=>je.mK,RotateWithOffset:()=>je.b9,Round:()=>je.e0,Rsqrt:()=>je.bV,SGDOptimizer:()=>nn,ScatterNd:()=>je.xQ,Select:()=>je.Ph,Selu:()=>je.oF,Sigmoid:()=>je.a5,Sign:()=>je.i5,Sin:()=>je.RQ,Sinh:()=>je.w3,Slice:()=>je.p2,Softmax:()=>je.Gc,Softplus:()=>je.MR,SpaceToBatchND:()=>je.TQ,SparseFillEmptyRows:()=>je.O3,SparseReshape:()=>je.nh,SparseSegmentMean:()=>je.YW,SparseSegmentSum:()=>je.Zj,SparseToDense:()=>je.D2,SplitV:()=>je.L8,Sqrt:()=>je.FK,Square:()=>je.bK,SquaredDifference:()=>je._t,Step:()=>je.h8,StridedSlice:()=>je.m2,StringNGrams:()=>je._J,StringSplit:()=>je.s1,StringToHashBucketFast:()=>je.Xk,Sub:()=>je.Tr,Sum:()=>je.GB,Tan:()=>je.sE,Tanh:()=>je.MI,Tensor:()=>xe.es,TensorBuffer:()=>xe.YD,Tile:()=>je.n9,TopK:()=>je.cW,Transform:()=>je.wx,Transpose:()=>je.G3,Unique:()=>je.kp,Unpack:()=>je.To,UnsortedSegmentSum:()=>je.Qv,Variable:()=>xe._w,ZerosLike:()=>je.Ru,_FusedMatMul:()=>je.us,abs:()=>on.WnP,acos:()=>on.Khb,acosh:()=>on.__u,add:()=>on.IHx,addN:()=>on.QBD,all:()=>on.$6P,any:()=>on.YjB,argMax:()=>on.NqF,argMin:()=>on.vHJ,asin:()=>on.ZRM,asinh:()=>on.VfV,atan:()=>on.z4N,atan2:()=>on.fvJ,atanh:()=>on.C80,avgPool:()=>on.wS1,avgPool3d:()=>on.uR5,backend:()=>Vt.y3,backend_util:()=>d,basicLSTMCell:()=>on.zEQ,batchNorm:()=>on.tgs,batchNorm2d:()=>on.Dxk,batchNorm3d:()=>on.JY5,batchNorm4d:()=>on.p3b,batchToSpaceND:()=>on.E4h,bincount:()=>on.yE8,booleanMaskAsync:()=>on.anm,broadcastArgs:()=>on.XsQ,broadcastTo:()=>on.UFq,browser:()=>o,buffer:()=>on.f3b,cast:()=>on.pju,ceil:()=>on.mDi,clipByValue:()=>on.iUl,clone:()=>on.d9v,complex:()=>on.PYB,concat:()=>on.zoF,concat1d:()=>on.gME,concat2d:()=>on.Izb,concat3d:()=>on.MNy,concat4d:()=>on.ZaL,conv1d:()=>on.PAt,conv2d:()=>on.Tek,conv2dTranspose:()=>on.bc,conv3d:()=>on.pdZ,conv3dTranspose:()=>on.$QV,copyRegisteredKernels:()=>Ke.T3,cos:()=>on.mCk,cosh:()=>on.f9Y,cosineWindow:()=>on.mew,cumsum:()=>on.zbp,customGrad:()=>qt.cb,denseBincount:()=>on.ppE,deprecationWarn:()=>Vt.MX,depthToSpace:()=>on.nTT,depthwiseConv2d:()=>on.B10,device_util:()=>r,diag:()=>on.Ka3,dilation2d:()=>on.WmZ,disableDeprecationWarnings:()=>Vt.cF,dispose:()=>Vt.B9,disposeVariables:()=>Vt.N8,div:()=>on.hiC,divNoNan:()=>on.NTj,dot:()=>on.AKD,dropout:()=>on.rvX,einsum:()=>on.WYO,elu:()=>on.pyx,enableDebugMode:()=>Vt.R,enableProdMode:()=>Vt.G4,enclosingPowerOfTwo:()=>on.GRh,engine:()=>Vt.SR,env:()=>y.OB,equal:()=>on.DgJ,erf:()=>on.qNN,exp:()=>on.Qqt,expandDims:()=>on.dt4,expm1:()=>on.t$B,eye:()=>on.iyy,fft:()=>on.kp_,fill:()=>on.hlL,findBackend:()=>Vt.x3,findBackendFactory:()=>Vt.ze,floor:()=>on.GWj,floorDiv:()=>on.qPi,fused:()=>on.imm,gather:()=>on.Iqj,gatherND:()=>on.dbB,gather_util:()=>i,getBackend:()=>Vt.N_,getGradient:()=>Ke.uk,getKernel:()=>Ke.pI,getKernelsForBackend:()=>Ke.tr,grad:()=>qt.UQ,grads:()=>qt.ti,greater:()=>on.pjt,greaterEqual:()=>on.brS,ifft:()=>on.Sxn,imag:()=>on.asL,image:()=>on.BHj,inTopKAsync:()=>on.V3u,io:()=>a,irfft:()=>on.wx0,isFinite:()=>on.xVT,isInf:()=>on.UWc,isNaN:()=>on.i2d,keep:()=>Vt.Cn,kernel_impls:()=>h,leakyRelu:()=>on.hi7,less:()=>on.d9m,lessEqual:()=>on.zN1,linalg:()=>on.$r2,linspace:()=>on.SX3,localResponseNormalization:()=>on.G9k,log:()=>on.cM7,log1p:()=>on.Krr,logSigmoid:()=>on.e_t,logSoftmax:()=>on.CmS,logSumExp:()=>on.l_t,logicalAnd:()=>on.HvI,logicalNot:()=>on.hJK,logicalOr:()=>on.K5V,logicalXor:()=>on.egP,losses:()=>on.MB5,matMul:()=>on.OI3,math:()=>s,max:()=>on.Fp7,maxPool:()=>on._sB,maxPool3d:()=>on.YQQ,maxPoolWithArgmax:()=>on.Ip$,maximum:()=>on.gWQ,mean:()=>on.J69,memory:()=>Vt.sq,meshgrid:()=>on.ry_,min:()=>on.VV$,minimum:()=>on.LTh,mirrorPad:()=>on.VdP,mod:()=>on.wQq,moments:()=>on.Gi7,movingAverage:()=>on.p_,mul:()=>on.dC7,multiRNNCell:()=>on.rq4,multinomial:()=>on.SJ_,neg:()=>on.W76,nextFrame:()=>dn,norm:()=>on.KOy,notEqual:()=>on.Quu,oneHot:()=>on.lfX,ones:()=>on.iUs,onesLike:()=>on.JpU,op:()=>on.op,outerProduct:()=>on.N2O,pad:()=>on.vku,pad1d:()=>on.pNR,pad2d:()=>on.koy,pad3d:()=>on.t1L,pad4d:()=>on.lGY,pool:()=>on.d_R,pow:()=>on.sQ3,prelu:()=>on.AL3,print:()=>on.S0v,prod:()=>on.WVs,profile:()=>Vt.N5,rand:()=>on.TN_,randomGamma:()=>on.wzB,randomNormal:()=>on.nGf,randomUniform:()=>on.LGj,range:()=>on.w6H,ready:()=>Vt.Cd,real:()=>on.kwC,reciprocal:()=>on.M25,registerBackend:()=>Vt.jq,registerGradient:()=>Ke.Li,registerKernel:()=>Ke.wC,relu:()=>on.UYe,relu6:()=>on.btT,removeBackend:()=>Vt.cj,reshape:()=>on.XLQ,reverse:()=>on.GYS,reverse1d:()=>on.SDf,reverse2d:()=>on.diP,reverse3d:()=>on.sx7,reverse4d:()=>on.mG2,rfft:()=>on.QEs,round:()=>on.NMM,rsqrt:()=>on.bp0,scalar:()=>on.iD$,scatterND:()=>on.snQ,scatter_util:()=>rt,selu:()=>on.U8D,separableConv2d:()=>on.U_I,serialization:()=>l,setBackend:()=>Vt.CQ,setPlatform:()=>Vt.VY,setdiff1dAsync:()=>on.ODp,sigmoid:()=>on.XD2,sign:()=>on.Xxe,signal:()=>on.tdS,sin:()=>on.O$l,sinh:()=>on.R_K,slice:()=>on.tPi,slice1d:()=>on.jZU,slice2d:()=>on.SmN,slice3d:()=>on.CnO,slice4d:()=>on.p0P,slice_util:()=>u,softmax:()=>on.XAC,softplus:()=>on.Wvh,spaceToBatchND:()=>on.fBT,sparse:()=>on.rVs,sparseToDense:()=>on.ers,spectral:()=>on.uN7,split:()=>on.Vl2,sqrt:()=>on._b3,square:()=>on.h62,squaredDifference:()=>on.$i,squeeze:()=>on.L9e,stack:()=>on.knu,step:()=>on.Nbs,stridedSlice:()=>on.NXj,string:()=>on.Z_8,sub:()=>on.luU,sum:()=>on.Smz,sumOutType:()=>sn.z4,tan:()=>on.ORZ,tanh:()=>on.AEp,tensor:()=>on.XeE,tensor1d:()=>on.RRF,tensor2d:()=>on.odF,tensor3d:()=>on.wOQ,tensor4d:()=>on.yXz,tensor5d:()=>on.Bfx,tensor6d:()=>on.xZs,tensor_util:()=>Nt,test_util:()=>c,tidy:()=>Vt.lu,tile:()=>on.Gg6,time:()=>Vt.XV,topk:()=>on.hg7,train:()=>cn,transpose:()=>on.p4s,truncatedNormal:()=>on.Xu6,unique:()=>on.Two,unregisterGradient:()=>Ke.bt,unregisterKernel:()=>Ke.nE,unsortedSegmentSum:()=>on.pUJ,unstack:()=>on.HHK,upcastType:()=>sn.x8,util:()=>St,valueAndGrad:()=>qt.h7,valueAndGrads:()=>qt.fN,variable:()=>on.VD$,variableGrads:()=>qt.pn,version_core:()=>Ct,where:()=>on.arb,whereAsync:()=>on.itS,zeros:()=>on.lls,zerosLike:()=>on.P84});var r={};n.r(r),n.d(r,{isBrowser:()=>g,isMobile:()=>f});var a={};n.r(a),n.d(a,{browserFiles:()=>_e,browserHTTPRequest:()=>Ce,concatenateArrayBuffers:()=>E,copyModel:()=>de,decodeWeights:()=>S,encodeWeights:()=>N,fromMemory:()=>ze,getLoadHandlers:()=>R,getModelArtifactsForJSON:()=>$,getModelArtifactsInfoForJSON:()=>D,getSaveHandlers:()=>V,http:()=>Be,isHTTPScheme:()=>Fe,listModels:()=>ce,loadWeights:()=>Me,moveModel:()=>he,registerLoadRouter:()=>C,registerSaveRouter:()=>B,removeModel:()=>pe,weightsLoaderFactory:()=>$e,withSaveHandler:()=>Pe});var s={};n.r(s),n.d(s,{confusionMatrix:()=>Ue});var o={};n.r(o),n.d(o,{fromPixels:()=>tt,fromPixelsAsync:()=>Ye,toPixels:()=>et});var i={};n.r(i),n.d(i,{prepareAndValidate:()=>nt});var u={};n.r(u),n.d(u,{assertParamsValid:()=>at,computeFlatOffset:()=>yt,computeOutShape:()=>ot,getNormalizedAxes:()=>ct,isSliceContinous:()=>gt,maskToAxes:()=>st,parseSliceParams:()=>bt,sliceInfo:()=>kt,startForAxis:()=>mt,startIndicesWithElidedDims:()=>pt,stopForAxis:()=>ft,stopIndicesWithElidedDims:()=>dt,stridesForAxis:()=>ht,stridesWithElidedDims:()=>it});var l={};n.r(l),n.d(l,{Serializable:()=>wt,SerializationMap:()=>vt,registerClass:()=>xt});var c={};n.r(c),n.d(c,{TEST_EPSILON_FLOAT16:()=>It,encodeStrings:()=>Bt,expectArrayBuffersEqual:()=>Ot,expectArraysClose:()=>Tt,expectArraysEqual:()=>Mt,expectNumbersClose:()=>$t,expectPromiseToFail:()=>At,expectValuesInRange:()=>Ft,testEpsilon:()=>_t});var p={};n.r(p),n.d(p,{collectGatherOpShapeInfo:()=>tr,computeOutShape:()=>er,segOpComputeOptimalWindowSize:()=>Yn});var d={};n.r(d),n.d(d,{ERF_A1:()=>Mn,ERF_A2:()=>$n,ERF_A3:()=>Dn,ERF_A4:()=>Fn,ERF_A5:()=>On,ERF_P:()=>An,PARALLELIZE_THRESHOLD:()=>kn,SELU_SCALE:()=>En,SELU_SCALEALPHA:()=>_n,applyActivation:()=>bn.QH,assertAndGetBroadcastShape:()=>mn.$N,assertAxesAreInnerMostDims:()=>hn.lB,assertParamsConsistent:()=>fn,assignToTypedArray:()=>Ln,axesAreInnerMostDims:()=>hn.YB,calculateShapes:()=>rt.calculateShapes,checkEinsumDimSizes:()=>Kn,combineLocations:()=>hn.Vh,complexWithEvenIndex:()=>Rn,complexWithOddIndex:()=>zn,computeConv2DInfo:()=>yn.Ix,computeConv3DInfo:()=>yn.jw,computeDefaultPad:()=>yn.aO,computeDilation2DInfo:()=>yn.Rf,computeOptimalWindowSize:()=>wn,computeOutAndReduceShapes:()=>hn.kz,computeOutShape:()=>gn,computePool2DInfo:()=>yn.Xw,computePool3DInfo:()=>yn.pl,convertConv2DDataFormat:()=>yn.sl,decodeEinsumEquation:()=>Un,eitherStridesOrDilationsAreOne:()=>yn.jT,expandShapeToKeepDim:()=>hn.rv,exponent:()=>Hn,exponents:()=>Wn,fromStringArrayToUint8:()=>rr,fromUint8ToStringArray:()=>nr,getAxesPermutation:()=>hn.Q3,getBroadcastDims:()=>mn.XF,getComplexWithIndex:()=>Pn,getEinsumComputePath:()=>Xn,getEinsumPermutation:()=>jn,getFusedBiasGradient:()=>bn.pf,getFusedDyActivation:()=>bn.Fr,getImageCenter:()=>vn,getInnerMostAxes:()=>hn.sY,getPermuted:()=>Nn,getReductionAxes:()=>mn.RR,getReshaped:()=>xn,getReshapedPermuted:()=>Sn,getSliceBeginCoords:()=>In,getSliceSize:()=>Tn,getUndoAxesPermutation:()=>hn.LJ,isIdentityPermutation:()=>Zn,log:()=>Bn.c,mergeRealAndImagArrays:()=>Cn,prepareAndValidate:()=>nt,prepareSplitSize:()=>Qn,segment_util:()=>p,shouldFuse:()=>bn.uy,slice_util:()=>u,splitRealAndImagArrays:()=>Vn,tupleValuesAreOne:()=>yn.I0,upcastType:()=>sn.x8,validateInput:()=>rt.validateInput,validateUpdateShape:()=>rt.validateUpdateShape,warn:()=>Bn.Z});var h={};n.r(h),n.d(h,{nonMaxSuppressionV3Impl:()=>ar.GP,nonMaxSuppressionV4Impl:()=>ar.qP,nonMaxSuppressionV5Impl:()=>ar.pA,whereImpl:()=>sr.Z});var m=n(7097);function f(e){if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){const t=e;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function g(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var y=n(2885);const b=(0,y.OB)();b.registerFlag("DEBUG",(()=>!1),(e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),b.registerFlag("IS_BROWSER",(()=>g())),b.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),b.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),b.registerFlag("PROD",(()=>!1)),b.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>b.getBool("DEBUG"))),b.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),b.registerFlag("IS_TEST",(()=>!1)),b.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),b.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1));var k=n(1661),w=n(701),v=n(569);const x={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};async function N(e,t){const n=[],r=[],a=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);for(let s=0;s{const t=await i.bytes(),n=t.reduce(((e,t)=>e+t.length),0)+4*t.length,r=new Uint8Array(n);let a=0;for(let e=0;e{if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)}));const r=new Uint8Array(t);let a=0;return n.forEach((e=>{r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}const T="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function _(e){return T?Buffer.byteLength(e):new Blob([e]).size}function E(e){if(1===e.length)return e[0];let t=0;e.forEach((e=>{t+=e.byteLength}));const n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function A(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function M(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}async function $(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),null!=e.weightsManifest){const[r,a]=await t(e.weightsManifest);n.weightSpecs=r,n.weightData=a}return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),n}function D(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:_(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:_(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function F(){const e=function(){const e=e=>{let t=e<<13,n=0;for(;0==(8388608&t);)n-=8388608,t<<=1;return t&=-8388609,n+=947912704,t|n},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}(),t=function(){const e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}(),n=function(){const e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return r=>{const a=new ArrayBuffer(4*r.length),s=new Uint32Array(a);for(let a=0;a>10]+(1023&o)]+t[o>>10];s[a]=i}return new Float32Array(a)}}class O{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==O.instance&&(O.instance=new O),O.instance}static registerSaveRouter(e){O.getInstance().saveRouters.push(e)}static registerLoadRouter(e){O.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return O.getHandlers(e,"save")}static getLoadHandlers(e,t){return O.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?O.getInstance().loadRouters:O.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const B=e=>O.registerSaveRouter(e),C=e=>O.registerLoadRouter(e),V=e=>O.getSaveHandlers(e),R=(e,t)=>O.getLoadHandlers(e,t),z="tensorflowjs",P="models_store",L="model_info_store";function W(){if(!(0,y.OB)().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function H(e){const t=e.result;t.createObjectStore(P,{keyPath:"modelPath"}),t.createObjectStore(L,{keyPath:"modelPath"})}class q{constructor(e){if(this.indexedDB=W(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const r=this.indexedDB.open(z,1);r.onupgradeneeded=()=>H(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(P,"readonly"),r=t.objectStore(P).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=D(t),s=a.transaction(L,"readwrite");let o=s.objectStore(L);const i=o.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;i.onsuccess=()=>{u=a.transaction(P,"readwrite");const i=u.objectStore(P).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});i.onsuccess=()=>e({modelArtifactsInfo:r}),i.onerror=e=>{o=s.objectStore(L);const t=o.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(i.error)),t.onerror=e=>(a.close(),n(i.error))}},i.onerror=e=>(a.close(),n(i.error)),s.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}q.URL_SCHEME="indexeddb://";const G=e=>{return(0,y.OB)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(q.URL_SCHEME)?(t=e.slice(q.URL_SCHEME.length),new q(t)):null;var t};O.registerSaveRouter(G),O.registerLoadRouter(G);class U{constructor(){this.indexedDB=W()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(z,1);n.onupgradeneeded=()=>H(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(L,"readonly"),s=a.objectStore(L).getAll();s.onsuccess=()=>{const t={};for(const e of s.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},s.onerror=e=>(r.close(),t(s.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(q.URL_SCHEME)?t.slice(q.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(z,1);r.onupgradeneeded=()=>H(r),r.onsuccess=()=>{const a=r.result,s=a.transaction(L,"readwrite"),o=s.objectStore(L),i=o.get(e);let u;i.onsuccess=()=>{if(null==i.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=o.delete(e),s=()=>{u=a.transaction(P,"readwrite");const r=u.objectStore(P).delete(e);r.onsuccess=()=>t(i.result.modelArtifactsInfo),r.onerror=e=>n(i.error)};r.onsuccess=s,r.onerror=e=>(s(),a.close(),n(i.error))}},i.onerror=e=>(a.close(),n(i.error)),s.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const j="/",K="tensorflowjs_models",X="info",Z="model_topology",J="weight_specs",Q="weight_data",Y="model_metadata";function ee(e){return{info:[K,e,X].join(j),topology:[K,e,Z].join(j),weightSpecs:[K,e,J].join(j),weightData:[K,e,Q].join(j),modelMetadata:[K,e,Y].join(j)}}function te(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function ne(e){const t=e.split(j);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(j)}class re{constructor(e){if(!(0,y.OB)().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=ee(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=D(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if(T)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e{return(0,y.OB)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(re.URL_SCHEME)?(t=e.slice(re.URL_SCHEME.length),new re(t)):null;var t};O.registerSaveRouter(ae),O.registerLoadRouter(ae);class se{constructor(){(0,v.hu)((0,y.OB)().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),(0,v.hu)("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=K+j,n=j+X;for(let r=0;r"scheme must not be undefined or null.")),e.endsWith(oe)&&(e=e.slice(0,e.indexOf(oe))),(0,v.hu)(e.length>0,(()=>"scheme must not be an empty string."));const n=ie.getInstance();(0,v.hu)(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=this.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}}function ue(e){if(-1===e.indexOf(oe))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${ie.getSchemes().join(",")}`);return{scheme:e.split(oe)[0],path:e.split(oe)[1]}}async function le(e,t,n=!1){(0,v.hu)(e!==t,(()=>`Old path and new path are the same: '${e}'`));const r=O.getLoadHandlers(e);(0,v.hu)(r.length>0,(()=>`Copying failed because no load handler is found for source URL ${e}.`)),(0,v.hu)(r.length<2,(()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`));const a=r[0],s=O.getSaveHandlers(t);(0,v.hu)(s.length>0,(()=>`Copying failed because no save handler is found for destination URL ${t}.`)),(0,v.hu)(s.length<2,(()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`));const o=s[0],i=ue(e).scheme,u=ue(e).path,l=i===ue(e).scheme,c=await a.load();n&&l&&await ie.getManager(i).removeModel(u);const p=await o.save(c);return n&&!l&&await ie.getManager(i).removeModel(u),p.modelArtifactsInfo}async function ce(){const e=ie.getSchemes(),t={};for(const n of e){const e=await ie.getManager(n).listModels();for(const r in e){t[n+oe+r]=e[r]}}return t}async function pe(e){const t=ue(e);return ie.getManager(t.scheme).removeModel(t.path)}async function de(e,t){return le(e,t,!1)}async function he(e,t){return le(e,t,!0)}class me{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}}if((0,y.OB)().get("IS_BROWSER")){(0,y.OB)().setPlatform("browser",new me);try{ie.registerManager(re.URL_SCHEME,new se)}catch(e){}try{ie.registerManager(q.URL_SCHEME,new U)}catch(e){}}const fe=()=>n(7854);let ge;class ye{constructor(){this.util=n(1669),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=(0,y.OB)().global.fetch?(0,y.OB)().global.fetch(e,t):(null==ge&&(ge=fe()),ge(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}}(0,y.OB)().get("IS_NODE")&&(0,y.OB)().setPlatform("node",new ye);var be=n(2657),ke=n(2271),we=n(8723),ve=n(9798),xe=n(4077);(0,m.wv)();const Ne={buffer:be.f,cast:ke.p,clone:we.d,print:ve.S};(0,xe.Vp)(Ne);function Se(e){return new Promise((e=>setTimeout(e))).then(e)}class Ie{constructor(e){if(!(0,y.OB)().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Ie.URL_SCHEME)&&(e=e.slice(Ie.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=M(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await Se((()=>a.dispatchEvent(new MouseEvent("click")))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await Se((()=>e.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:D(e)}}}}Ie.URL_SCHEME="downloads://";class Te{constructor(e){if(null==e||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise(((e,t)=>{const n=new FileReader;n.onload=n=>{const r=JSON.parse(n.target.result),a=r.modelTopology;if(null==a)return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==r.weightsManifest)return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void e({modelTopology:a});const s=$(r,(e=>this.loadWeights(e)));e(s)},n.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)}))}loadWeights(e){const t=[],n=[];for(const r of e)t.push(...r.weights),n.push(...r.paths);const r=this.checkManifestAndWeightFiles(e),a=n.map((e=>this.loadWeightsFile(e,r[e])));return Promise.all(a).then((e=>[t,E(e)]))}loadWeightsFile(e,t){return new Promise(((n,r)=>{const a=new FileReader;a.onload=e=>{const t=e.target.result;n(t)},a.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)}))}checkManifestAndWeightFiles(e){const t=[],n=this.weightsFiles.map((e=>A(e.name))),r={};for(const a of e)a.paths.forEach((e=>{const a=A(e);if(-1!==t.indexOf(a))throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===n.indexOf(a))throw new Error(`Weight file with basename '${a}' is not provided.`);r[e]=this.weightsFiles[n.indexOf(a)]}));if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return r}}function _e(e){return new Te(e)}function Ee(e,t,n,r){!function(e){(0,v.hu)(null!=e&&Array.isArray(e)&&e.length>0,(()=>"promises must be a none empty array"))}(e),function(e,t){(0,v.hu)(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`)),(0,v.hu)(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`)),(0,v.hu)(t>=e,(()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`))}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map((s=>(s.then((s=>{const o=n+ ++a/e.length*(r-n);return t(o),s})),s))))}async function Ae(e,t){null==t&&(t={});const n=null==t.fetchFunc?(0,y.OB)().platform.fetch:t.fetchFunc,r=e.map((e=>n(e,t.requestInit,{isBinary:!0}))),a=(null==t.onProgress?await Promise.all(r):await Ee(r,t.onProgress,0,.5)).map((e=>e.arrayBuffer()));return null==t.onProgress?await Promise.all(a):await Ee(a,t.onProgress,.5,1)}async function Me(e,t="",n,r){return $e((e=>Ae(e,{requestInit:r})))(e,t,n)}function $e(e){return async(t,n="",r)=>{const a=t.map((()=>!1)),s={},o=null!=r?r.map((()=>!1)):[],i=[];if(t.forEach(((e,t)=>{let n=0;e.weights.forEach((e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,l=x[u]*v.NA(e.shape),c=()=>{a[t]=!0,null==s[t]&&(s[t]=[]),s[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=r?r.forEach(((t,n)=>{t===e.name&&(c(),o[n]=!0)})):c(),i.push(e.name),n+=l}))})),!o.every((e=>e))){const e=r.filter(((e,t)=>!o[t]));throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${i.join(", ")}.`)}const u=a.reduce(((e,t,n)=>(t&&e.push(n),e)),[]),l=[];u.forEach((e=>{t[e].paths.forEach((e=>{const t=n+(n.endsWith("/")?"":"/")+e;l.push(t)}))}));const c=await e(l),p={};let d=0;return u.forEach((e=>{const n=t[e].paths.length;let r=0;for(let e=0;e{const t=S(a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)p[e]=t[e]})),d+=n})),p}}O.registerSaveRouter((e=>(0,y.OB)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ie.URL_SCHEME)?function(e="model"){return new Ie(e)}(e.slice(Ie.URL_SCHEME.length)):null));class De{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?((0,v.hu)("function"==typeof t.fetchFunc,(()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)")),this.fetch=t.fetchFunc):this.fetch=(0,y.OB)().platform.fetch,(0,v.hu)(null!=e&&e.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(e)&&(0,v.hu)(2===e.length,(()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`)),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const n=M(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:"application/octet-stream"}),"model.weights.bin");const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:D(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){const e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(e){let t=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?t+=" 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.":t+=" Please make sure the server is serving valid JSON for this request.",new Error(t)}const n=t.modelTopology,r=t.weightsManifest;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return $(t,(e=>this.loadWeights(e)))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(e){const t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),r=e.substring(0,t),a=n>t?e.substring(n):"";return[r+"/",a]}(t),a=this.weightPathPrefix||n,s=[];for(const t of e)s.push(...t.weights);const o=[],i=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?i.push(this.weightUrlConverter(e)):o.push(a+e+r);this.weightUrlConverter&&o.push(...await Promise.all(i));return[s,E(await Ae(o,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress}))]}}function Fe(e){return null!=e.match(De.URL_SCHEME_REGEX)}De.URL_SCHEME_REGEX=/^https?:\/\//;const Oe=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every((e=>Fe(e))):Fe(e),n)return Be(e,t)}return null};function Be(e,t){return new De(e,t)}function Ce(e,t){return Be(e,t)}O.registerSaveRouter(Oe),O.registerLoadRouter(Oe);class Ve{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}}class Re{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}}function ze(e,t,n,r){if(1===arguments.length){return null!=e.modelTopology||null!=e.weightSpecs?new Ve(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Ve({modelTopology:e}))}return console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Ve({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r})}function Pe(e){return new Re(e)}var Le=n(3740),We=n(8687),He=n(6708),qe=n(2668),Ge=n(9065);const Ue=(0,qe.op)({confusionMatrix_:function(e,t,n){const r=(0,Le._1)(e,"labels","confusionMatrix"),a=(0,Le._1)(t,"predictions","confusionMatrix");v.hu(null==n||n>0&&Number.isInteger(n),(()=>`If provided, numClasses must be a positive integer, but got ${n}`)),v.hu(1===r.rank,(()=>`Expected the rank of labels to be 1, but got ${r.rank}`)),v.hu(1===a.rank,(()=>`Expected the rank of predictions to be 1, but got ${a.rank}`)),v.hu(r.shape[0]===a.shape[0],(()=>`Mismatch in the number of examples: ${r.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`)),v.hu(n>0&&Number.isInteger(n),(()=>`numClasses is required to be a positive integer, but got ${n}`));const s=(0,He.l)((0,ke.p)(r,"int32"),n),o=(0,He.l)((0,ke.p)(a,"int32"),n),i=(0,Ge.p)(s),u=(0,We.O)(i,o);return(0,ke.p)(u,"int32")}});var je=n(9121),Ke=n(6151),Xe=n(9906);let Ze;function Je(e,t=3){if(t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,r=!1,a=!1,s=!1,o=!1,i=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)s=!0;else if(null!=e.getContext)o=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`);i=!0}if(a){const t=2;if(a&&e.readyState element.")}if(null!=(0,Ke.pI)(je.eB,m.BV.backendName)){const n={pixels:e},r={numChannels:t};return m.BV.runKernel(je.eB,n,r)}const[u,l]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let c,p;if(o?c=e.getContext("2d").getImageData(0,0,u,l).data:r||n?c=e.data:(s||a||i)&&(null==Ze&&(Ze=document.createElement("canvas").getContext("2d")),Ze.canvas.width=u,Ze.canvas.height=l,Ze.drawImage(e,0,0,u,l),c=Ze.getImageData(0,0,u,l).data),4===t)p=new Int32Array(c);else{const e=u*l;p=new Int32Array(e*t);for(let n=0;n4||2===s)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${s}`);if("float32"!==n.dtype&&"int32"!==n.dtype)throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);const o=await n.data(),i="float32"===n.dtype?255:1,u=new Uint8ClampedArray(a*r*4);for(let e=0;e1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${a}.`)}else if("int32"===n.dtype&&(a<0||a>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${a}.`);1===s?(t[0]=a*i,t[1]=a*i,t[2]=a*i):t[r]=a*i}const r=4*e;u[r+0]=Math.round(t[0]),u[r+1]=Math.round(t[1]),u[r+2]=Math.round(t[2]),u[r+3]=Math.round(t[3])}if(null!=t){t.width=a,t.height=r;const e=t.getContext("2d"),n=new ImageData(u,a,r);e.putImageData(n,0,0)}return n!==e&&n.dispose(),u}const tt=(0,qe.op)({fromPixels_:Je});function nt(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if("int32"!==t.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===(0,v.NA)(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,s=a[a.length-1];let o=1;for(let e=0;ee/l)),1].slice(0,s);return[u,o,l,c]}var rt=n(3028);function at(e,t,n){const r=e.shape.length;v.hu(r===t.length,(()=>`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),v.hu(r===n.length,(()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`));for(let a=0;a`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`))}function st(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function ot(e,t,n){const r=[];for(let a=0;a0){const u=t[0],l=n+1;c=pt(o,u,l,r,e),p=dt(i,u,l,a,e),d=it(s,u,l,e)}else for(let t=0;t-1)s[a]=0;else{const o=ut(t,n,a);let i=r[o];e&1<-1)s[a]=Number.MAX_SAFE_INTEGER;else{const o=ut(t,n,a);let i=r[o];e&1<0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return o<0&&(o+=u),o=v.uZ(0,o,u-1),o}function ft(e,t,n,r,a,s){let o=t[a];const i=n[a]||1;(e&1<0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return o<0&&(o+=u),o=i>0?v.uZ(0,o,u):v.uZ(-1,o,u-1),o}function gt(e,t,n){let r=n.length;for(let e=0;e1){r=e;break}for(let a=r+1;a0||n[a]!==e[a])return!1;return!0}function yt(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r{v.hu(-1!==e,(()=>"slice() does not support negative begin indexing."))})),s=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.lengtht>=0?t:(v.hu(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-r[n]))),[r,s]}function kt(e,t,n,r,a,s,o,i,u){let l=t.slice(),c=n.slice(),p=r;null==r&&(p=new Array(l.length));const d=st(o);if(d.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(0!==o&&0!==i)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(0!==o&&0!==u)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");const h=e.length-l.length,m=st(i),f=e.slice();m.forEach((e=>{l[e]=0,c[e]=1,f.splice(e,0,1)}));const{begin:g,end:y,strides:b}=ct(f,d,h,l,c,p,a,s,o);l=g,c=y,p=b;const k=st(u);k.forEach((e=>{c[e]=l[e]+1,p[e]=1}));const w=ot(l,c,p),v=w.filter(((e,t)=>-1===k.indexOf(t)));return{nonStrided:p.every((e=>1===e)),$begin:l,$end:c,$strides:p,size:w,newShape:f,outShape:v}}class wt{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class vt{constructor(){this.classNameMap={}}static getMap(){return null==vt.instance&&(vt.instance=new vt),vt.instance}static register(e){vt.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function xt(e){(0,v.hu)(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),(0,v.hu)("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),(0,v.hu)(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),vt.register(e)}var Nt=n(747),St=n(9122);const It=.1;function Tt(e,t,n){return null==n&&(n=_t()),Et(e,t,((e,t)=>Dt(e,t,n)))}function _t(){return 32===m.BV.backend.floatPrecision()?.001:It}function Et(e,t,n){let r=!0;if(((0,v.fU)(e)||(0,v.fU)(t))&&(r=!1),(0,v.fU)(e)&&(0,v.fU)(t)&&(r=!0),r){const n=e.constructor.name,r=t.constructor.name;if(n!==r)throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${r}`)}if(Array.isArray(e)&&Array.isArray(t)){const n=(0,Le.C)(e),r=(0,Le.C)(t);if(!(0,v.cO)(n,r))throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${r}]`)}const a=(0,v.fU)(e)?e:(0,v.xH)(e),s=(0,v.fU)(t)?t:(0,v.xH)(t);if(a.length!==s.length)throw new Error(`Arrays have different lengths actual: ${a.length} vs expected: ${s.length}.\nActual: ${a}.\nExpected: ${s}.`);for(let e=0;et.fail()),(()=>t()))}function Mt(e,t){const n="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return(0,v.HD)(e)||(0,v.HD)(e[0])||(0,v.HD)(t)||(0,v.HD)(t[0])?Et(e,n,((e,t)=>e==t)):Et(e,t,((e,t)=>Dt(e,t,0)))}function $t(e,t,n){if(null==n&&(n=_t()),!Dt(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function Dt(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function Ft(e,t,n){for(let r=0;rn)throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`)}function Ot(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))}function Bt(e){for(let t=0;t({name:e.name,tensor:a[e.name]})));this.applyGradients(e)}else this.applyGradients(a);return(0,Vt.B9)(a),t?r:(r.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return(0,qt.pn)(e,t)}dispose(){null!=this.iterations_&&(0,Vt.B9)(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:(0,Gt.i)(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(Ut,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class jt extends Ut{constructor(e,t,n=null){super(),this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=m.BV.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=m.BV.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:(0,Vt.lu)((()=>(0,Ht.P)(r).variable(false)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:(0,Vt.lu)((()=>(0,Ht.P)(r).variable(false)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const s=this.accumulatedGrads[n].variable,o=this.accumulatedUpdates[n].variable;(0,Vt.lu)((()=>{const e=(0,Rt.I)((0,Pt.d)(s,this.rho),(0,Pt.d)((0,Wt.h)(a),1-this.rho)),t=(0,Pt.d)((0,zt.h)((0,Lt._)((0,Rt.I)(o,this.epsilon)),(0,Lt._)((0,Rt.I)(s,this.epsilon))),a),n=(0,Rt.I)((0,Pt.d)(o,this.rho),(0,Pt.d)((0,Wt.h)(t),1-this.rho));s.assign(e),o.assign(n);const i=(0,Rt.I)((0,Pt.d)(t,-this.learningRate),r);r.assign(i)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&((0,Vt.B9)(this.accumulatedGrads.map((e=>e.variable))),(0,Vt.B9)(this.accumulatedUpdates.map((e=>e.variable))))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){const t=(e=await this.extractIterations(e)).length/2;this.accumulatedGrads=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(false)}))),this.accumulatedUpdates=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}jt.className="Adadelta",xt(jt);var Kt=n(4006);class Xt extends Ut{constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=m.BV.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:(0,Vt.lu)((()=>(0,Kt.h)(r.shape,this.initialAccumulatorValue).variable(e)))}}const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const s=this.accumulatedGrads[n].variable;(0,Vt.lu)((()=>{const e=(0,Rt.I)(s,(0,Wt.h)(a));s.assign(e);const t=(0,Rt.I)((0,Pt.d)((0,zt.h)(a,(0,Lt._)((0,Rt.I)(e,m.BV.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&(0,Vt.B9)(this.accumulatedGrads.map((e=>e.variable)))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);this.accumulatedGrads=e.map((e=>({originalName:e.name,variable:e.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}Xt.className="Adagrad",xt(Xt);var Zt=n(3453),Jt=n(827);class Qt extends Ut{constructor(e,t,n,r=null){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],(0,Vt.lu)((()=>{this.accBeta1=(0,Gt.i)(t).variable(),this.accBeta2=(0,Gt.i)(n).variable()})),null==r&&(this.epsilon=m.BV.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);(0,Vt.lu)((()=>{const n=(0,Jt.l)(1,this.accBeta1),r=(0,Jt.l)(1,this.accBeta2);t.forEach(((t,a)=>{const s=m.BV.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:(0,Vt.lu)((()=>(0,Ht.P)(s).variable(false)))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:(0,Vt.lu)((()=>(0,Ht.P)(s).variable(false)))});const o=Array.isArray(e)?e[a].tensor:e[t];if(null==o)return;const i=this.accumulatedFirstMoment[a].variable,u=this.accumulatedSecondMoment[a].variable,l=(0,Rt.I)((0,Pt.d)(i,this.beta1),(0,Pt.d)(o,1-this.beta1)),c=(0,Rt.I)((0,Pt.d)(u,this.beta2),(0,Pt.d)((0,Wt.h)(o),1-this.beta2)),p=(0,zt.h)(l,n),d=(0,zt.h)(c,r);i.assign(l),u.assign(c);const h=(0,Rt.I)((0,Pt.d)((0,zt.h)(p,(0,Rt.I)((0,Lt._)(d),this.epsilon)),-this.learningRate),s);s.assign(h)})),this.accBeta1.assign((0,Pt.d)(this.accBeta1,this.beta1)),this.accBeta2.assign((0,Pt.d)(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&(0,Vt.B9)(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&(0,Vt.B9)(this.accumulatedSecondMoment.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),(0,Vt.lu)((()=>{this.accBeta1.assign((0,Zt.s)(this.beta1,this.iterations_+1)),this.accBeta2.assign((0,Zt.s)(this.beta2,this.iterations_+1))}));const t=e.length/2;this.accumulatedFirstMoment=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(false)}))),this.accumulatedSecondMoment=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}Qt.className="Adam",xt(Qt);var Yt=n(6235),en=n(632);class tn extends Ut{constructor(e,t,n,r=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],(0,Vt.lu)((()=>{this.iteration=(0,Gt.i)(0).variable(),this.accBeta1=(0,Gt.i)(t).variable()})),null==r&&(this.epsilon=m.BV.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);(0,Vt.lu)((()=>{const n=(0,Jt.l)(1,this.accBeta1),r=(0,zt.h)(-this.learningRate,(0,Rt.I)((0,Pt.d)(this.iteration,this.decay),1));t.forEach(((t,a)=>{const s=m.BV.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:(0,Ht.P)(s).variable(false)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:(0,Ht.P)(s).variable(false)});const o=Array.isArray(e)?e[a].tensor:e[t];if(null==o)return;const i=this.accumulatedFirstMoment[a].variable,u=this.accumulatedWeightedInfNorm[a].variable,l=(0,Rt.I)((0,Pt.d)(i,this.beta1),(0,Pt.d)(o,1-this.beta1)),c=(0,Pt.d)(u,this.beta2),p=(0,Yt.W)(o),d=(0,en.g)(c,p);i.assign(l),u.assign(d);const h=(0,Rt.I)((0,Pt.d)((0,zt.h)(r,n),(0,zt.h)(l,(0,Rt.I)(d,this.epsilon))),s);s.assign(h)})),this.iteration.assign((0,Rt.I)(this.iteration,1)),this.accBeta1.assign((0,Pt.d)(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&(0,Vt.B9)(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&(0,Vt.B9)(this.accumulatedWeightedInfNorm.map((e=>e.variable)))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}tn.className="Adamax",xt(tn);class nn extends Ut{constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Array.isArray(e)?e[n].tensor:e[t];if(null==r)return;const a=m.BV.registeredVariables[t];(0,Vt.lu)((()=>{const e=(0,Rt.I)((0,Pt.d)(this.c,r),a);a.assign(e)}))})),this.incrementIterations()}setLearningRate(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(0,Vt.Cn)((0,Gt.i)(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(0!==(e=await this.extractIterations(e)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}nn.className="SGD",xt(nn);class rn extends nn{constructor(e,t,n=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=(0,Gt.i)(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=m.BV.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:(0,Vt.lu)((()=>(0,Ht.P)(r).variable(e)))}}const a=this.accumulations[n].variable,s=Array.isArray(e)?e[n].tensor:e[t];null!=s&&(0,Vt.lu)((()=>{let e;const t=(0,Rt.I)((0,Pt.d)(this.m,a),s);e=this.useNesterov?(0,Rt.I)((0,Pt.d)(this.c,(0,Rt.I)(s,(0,Pt.d)(t,this.m))),r):(0,Rt.I)((0,Pt.d)(this.c,t),r),a.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&(0,Vt.B9)(this.accumulations.map((e=>e.variable)))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);this.accumulations=e.map((e=>({originalName:e.name,variable:e.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}rn.className="Momentum",xt(rn);class an extends Ut{constructor(e,t=.9,n=0,r=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==r&&(this.epsilon=m.BV.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=m.BV.registeredVariables[t],a=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:(0,Vt.lu)((()=>(0,Ht.P)(r).variable(a)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:(0,Vt.lu)((()=>(0,Ht.P)(r).variable(a)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:(0,Vt.lu)((()=>(0,Ht.P)(r).variable(a)))});const s=Array.isArray(e)?e[n].tensor:e[t];if(null==s)return;const o=this.accumulatedMeanSquares[n].variable,i=this.accumulatedMoments[n].variable;(0,Vt.lu)((()=>{const e=(0,Rt.I)((0,Pt.d)(o,this.decay),(0,Pt.d)((0,Wt.h)(s),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,a=(0,Rt.I)((0,Pt.d)(t,this.decay),(0,Pt.d)(s,1-this.decay)),u=(0,zt.h)((0,Pt.d)(s,this.learningRate),(0,Lt._)((0,Jt.l)(e,(0,Rt.I)((0,Wt.h)(a),this.epsilon)))),l=(0,Rt.I)((0,Pt.d)(i,this.momentum),u);o.assign(e),t.assign(a),i.assign(l);const c=(0,Jt.l)(r,l);r.assign(c)}else{const e=(0,Rt.I)((0,Pt.d)(o,this.decay),(0,Pt.d)((0,Wt.h)(s),1-this.decay)),t=(0,Rt.I)((0,Pt.d)(i,this.momentum),(0,zt.h)((0,Pt.d)(s,this.learningRate),(0,Lt._)((0,Rt.I)(e,this.epsilon))));o.assign(e),i.assign(t);const n=(0,Jt.l)(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&(0,Vt.B9)(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&(0,Vt.B9)(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&(0,Vt.B9)(this.accumulatedMoments.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,n=!1;this.accumulatedMeanSquares=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.accumulatedMoments=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}an.className="RMSProp",xt(an);var sn=n(1221),on=n(4885),un=n(9876);class ln{static sgd(e){return new nn(e)}static momentum(e,t,n=!1){return new rn(e,t,n)}static rmsprop(e,t=.9,n=0,r=null,a=!1){return new an(e,t,n,r,a)}static adam(e=.001,t=.9,n=.999,r=null){return new Qt(e,t,n,r)}static adadelta(e=.001,t=.95,n=null){return new jt(e,t,n)}static adamax(e=.002,t=.9,n=.999,r=null,a=0){return new tn(e,t,n,r,a)}static adagrad(e,t=.1){return new Xt(e,t)}}const cn={sgd:ln.sgd,momentum:ln.momentum,adadelta:ln.adadelta,adagrad:ln.adagrad,rmsprop:ln.rmsprop,adamax:ln.adamax,adam:ln.adam},pn="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function dn(){return new Promise((e=>pn((()=>e()))))}var hn=n(3591),mn=n(2200);function fn(e,t){const n=e[0].length;e.forEach(((e,t)=>{v.hu(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),v.hu(t>=0&&t`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,a)=>{for(let s=0;s`Error in concat${n}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`))}))}function gn(e,t){const n=e[0].slice();for(let r=1;r=2*t+1||r%2==1?a.push(r):n.push(r);r.push(...n),r.push(0),r.push(...a)}return r}function Sn(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n/g;function Un(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(Gn,"").length)/qn.length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error('Equation must contain exactly one arrow ("->").');const[r,a]=e.split(qn);(0,v.hu)(-1===r.indexOf("..."),(()=>'The ellipsis notation ("...") is not supported yet.'));const s=r.split(","),o=s.length;if(t!==o)throw new Error(`Expected ${o} input tensors, received ${t}`);if(o>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const i=[];for(let e=0;e-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===i.indexOf(t)&&i.push(t)}for(let e=0;e-1!==e)),{permutationIndices:n,expandDims:r}}function Kn(e,t,n){const r=new Array(e);for(let e=0;e`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`))}}function Xn(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;ee===t))}function Jn(e,t){const n=[];for(let r=0;r"Number of splits must evenly divide the axis.")),r=new Array(t).fill(e.shape[n]/t);else{const a=t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0);(0,v.hu)(a<=1,(()=>"There should be only one negative value in split array."));const s=t.indexOf(-1);if(-1!==s){const r=t.reduce(((e,t)=>t>0?e+t:e));t[s]=e.shape[n]-r}(0,v.hu)(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),r=t}return r}function Yn(e,t){let n,r=!1;for(e<=kn?(n=e,r=!0):n=(0,v.jP)(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=(0,v.jP)(e,n+1);return n}function er(e,t,n){const r=[],a=e.length;for(let s=0;sa))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>s)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${s}).`);if(n(0,St.decodeString)(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function rr(e){return e.map((e=>(0,St.encodeString)(e)))}var ar=n(3337),sr=n(8333),or=n(8713)},9121:(e,t,n)=>{"use strict";n.d(t,{SY:()=>r,VG:()=>a,Sp:()=>s,mm:()=>o,Xz:()=>i,oT:()=>u,IK:()=>l,sJ:()=>c,aJ:()=>p,M2:()=>d,qw:()=>h,jM:()=>m,Oy:()=>f,QC:()=>g,Jh:()=>y,RO:()=>b,_k:()=>k,IM:()=>w,XL:()=>v,zw:()=>x,zv:()=>N,Ly:()=>S,eE:()=>I,RF:()=>T,gJ:()=>_,xn:()=>E,Zz:()=>A,yj:()=>M,Eh:()=>$,mh:()=>D,wU:()=>F,wm:()=>O,x1:()=>B,o2:()=>C,ik:()=>V,mc:()=>R,TR:()=>z,iH:()=>P,Vc:()=>L,QR:()=>W,T0:()=>H,ci:()=>q,sL:()=>G,y7:()=>U,$w:()=>j,p4:()=>K,ek:()=>X,Vn:()=>Z,oH:()=>J,$g:()=>Q,SX:()=>Y,HE:()=>ee,Om:()=>te,hd:()=>ne,NE:()=>re,YF:()=>ae,Y0:()=>se,vw:()=>oe,de:()=>ie,Uy:()=>ue,OR:()=>le,je:()=>ce,sH:()=>pe,qi:()=>de,q1:()=>he,iZ:()=>me,Ac:()=>fe,iJ:()=>ge,Qg:()=>ye,J_:()=>be,av:()=>ke,iW:()=>we,r7:()=>ve,J$:()=>xe,vt:()=>Ne,CA:()=>Se,e7:()=>Ie,Zb:()=>Te,kU:()=>_e,PY:()=>Ee,Vf:()=>Ae,MZ:()=>Me,qC:()=>$e,eZ:()=>De,Hh:()=>Fe,Yo:()=>Oe,BM:()=>Be,mT:()=>Ce,OV:()=>Ve,OA:()=>Re,OU:()=>ze,vF:()=>Pe,q2:()=>Le,c1:()=>We,q8:()=>He,jQ:()=>qe,Vb:()=>Ge,NZ:()=>Ue,wY:()=>je,ku:()=>Ke,yQ:()=>Xe,uv:()=>Ze,cy:()=>Je,W0:()=>Qe,qW:()=>Ye,we:()=>et,Qi:()=>tt,ly:()=>nt,Kg:()=>rt,pe:()=>at,o0:()=>st,Dl:()=>ot,e6:()=>it,xJ:()=>ut,$H:()=>lt,qk:()=>ct,HZ:()=>pt,dp:()=>dt,Hm:()=>ht,_Y:()=>mt,zb:()=>ft,Sb:()=>gt,mK:()=>yt,e0:()=>bt,bV:()=>kt,xQ:()=>wt,Ph:()=>vt,oF:()=>xt,p2:()=>Nt,RQ:()=>St,w3:()=>It,i5:()=>Tt,a5:()=>_t,MR:()=>Et,FK:()=>At,GB:()=>Mt,TQ:()=>$t,L8:()=>Dt,Gc:()=>Ft,O3:()=>Ot,nh:()=>Bt,YW:()=>Ct,Zj:()=>Vt,D2:()=>Rt,_t:()=>zt,bK:()=>Pt,m2:()=>Lt,_J:()=>Wt,s1:()=>Ht,Xk:()=>qt,Tr:()=>Gt,sE:()=>Ut,MI:()=>jt,n9:()=>Kt,cW:()=>Xt,wx:()=>Zt,G3:()=>Jt,kp:()=>Qt,To:()=>Yt,Qv:()=>en,Ru:()=>tn,h8:()=>nn,eB:()=>rn,b9:()=>an,us:()=>sn,_V:()=>on,lu:()=>un});const r="Abs",a="Acos",s="Acosh",o="Add",i="AddN",u="All",l="Any",c="ArgMax",p="ArgMin",d="Asin",h="Asinh",m="Atan",f="Atanh",g="Atan2",y="AvgPool",b="AvgPoolGrad",k="AvgPool3D",w="AvgPool3DGrad",v="BatchMatMul",x="BatchToSpaceND",N="Bincount",S="BroadcastTo",I="BroadcastArgs",T="Cast",_="Ceil",E="ClipByValue",A="Complex",M="ComplexAbs",$="Concat",D="Conv2D",F="Conv2DBackpropFilter",O="Conv2DBackpropInput",B="Conv3D",C="Conv3DBackpropFilterV2",V="Conv3DBackpropInputV2",R="Cos",z="Cosh",P="Cumsum",L="CropAndResize",W="DenseBincount",H="DepthToSpace",q="DepthwiseConv2dNative",G="DepthwiseConv2dNativeBackpropFilter",U="DepthwiseConv2dNativeBackpropInput",j="Diag",K="Dilation2D",X="Dilation2DBackpropInput",Z="Dilation2DBackpropFilter",J="RealDiv",Q="Einsum",Y="Elu",ee="EluGrad",te="Erf",ne="Equal",re="Exp",ae="ExpandDims",se="Expm1",oe="FFT",ie="Fill",ue="FlipLeftRight",le="Floor",ce="FloorDiv",pe="FusedBatchNorm",de="GatherV2",he="GatherNd",me="Greater",fe="GreaterEqual",ge="Identity",ye="IFFT",be="Imag",ke="IsFinite",we="IsInf",ve="IsNan",xe="LeakyRelu",Ne="Less",Se="LessEqual",Ie="LinSpace",Te="Log",_e="Log1p",Ee="LogicalAnd",Ae="LogicalNot",Me="LogicalOr",$e="LogSoftmax",De="LRN",Fe="LRNGrad",Oe="Max",Be="Maximum",Ce="MaxPool",Ve="MaxPoolGrad",Re="MaxPool3D",ze="MaxPool3DGrad",Pe="MaxPoolWithArgmax",Le="Mean",We="Min",He="Minimum",qe="MirrorPad",Ge="Mod",Ue="Multinomial",je="Multiply",Ke="Neg",Xe="NotEqual",Ze="NonMaxSuppressionV3",Je="NonMaxSuppressionV4",Qe="NonMaxSuppressionV5",Ye="OnesLike",et="OneHot",tt="Pack",nt="PadV2",rt="Pool",at="Pow",st="Prelu",ot="Prod",it="Range",ut="Real",lt="Reciprocal",ct="Relu",pt="Reshape",dt="ResizeNearestNeighbor",ht="ResizeNearestNeighborGrad",mt="ResizeBilinear",ft="ResizeBilinearGrad",gt="Relu6",yt="Reverse",bt="Round",kt="Rsqrt",wt="ScatterNd",vt="Select",xt="Selu",Nt="Slice",St="Sin",It="Sinh",Tt="Sign",_t="Sigmoid",Et="Softplus",At="Sqrt",Mt="Sum",$t="SpaceToBatchND",Dt="SplitV",Ft="Softmax",Ot="SparseFillEmptyRows",Bt="SparseReshape",Ct="SparseSegmentMean",Vt="SparseSegmentSum",Rt="SparseToDense",zt="SquaredDifference",Pt="Square",Lt="StridedSlice",Wt="StringNGrams",Ht="StringSplit",qt="StringToHashBucketFast",Gt="Sub",Ut="Tan",jt="Tanh",Kt="Tile",Xt="TopK",Zt="Transform",Jt="Transpose",Qt="Unique",Yt="Unpack",en="UnsortedSegmentSum",tn="ZerosLike",nn="Step",rn="FromPixels",an="RotateWithOffset",sn="_FusedMatMul",on="FusedConv2D",un="FusedDepthwiseConv2D"},6151:(e,t,n)=>{"use strict";n.d(t,{pI:()=>u,uk:()=>l,tr:()=>c,wC:()=>p,Li:()=>d,nE:()=>h,bt:()=>m,T3:()=>f});var r=n(2885),a=n(5938),s=n(4706);const o=(0,a.R)("kernelRegistry",(()=>new Map)),i=(0,a.R)("gradRegistry",(()=>new Map));function u(e,t){const n=g(e,t);return o.get(n)}function l(e){return i.get(e)}function c(e){const t=o.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[s,o]=a,[i]=s.split("_");i===e&&n.push(o)}return n}function p(e){const{kernelName:t,backendName:n}=e,r=g(t,n);o.has(r)&&s.Z(`The kernel '${t}' for backend '${n}' is already registered`),o.set(r,e)}function d(e){const{kernelName:t}=e;i.has(t)&&(0,r.OB)().getBool("DEBUG")&&s.Z(`Overriding the gradient for '${t}'`),i.set(t,e)}function h(e,t){const n=g(e,t);if(!o.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);o.delete(n)}function m(e){if(!i.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);i.delete(e)}function f(e,t){c(e).forEach((e=>{p(Object.assign({},e,{backendName:t}))}))}function g(e,t){return`${t}_${e}`}},4706:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a,c:()=>s});var r=n(2885);function a(...e){(0,r.OB)().getBool("IS_TEST")||(0,r.OB)().getBool("PROD")||console.warn(...e)}function s(...e){(0,r.OB)().getBool("IS_TEST")||(0,r.OB)().getBool("PROD")||console.log(...e)}},6235:(e,t,n)=>{"use strict";n.d(t,{W:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({abs_:function(e){const t=(0,s._1)(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return r.BV.runKernel(a.yj,e)}{const e={x:t};return r.BV.runKernel(a.SY,e)}}})},7839:(e,t,n)=>{"use strict";n.d(t,{K:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({acos_:function(e){const t={x:(0,s._1)(e,"x","acos")};return r.BV.runKernel(a.VG,t)}})},1470:(e,t,n)=>{"use strict";n.d(t,{_:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({acosh_:function(e){const t={x:(0,s._1)(e,"x","acosh")};return r.BV.runKernel(a.Sp,t)}})},6407:(e,t,n)=>{"use strict";n.d(t,{I:()=>i});var r=n(7097),a=n(9121),s=n(747),o=n(3740);const i=(0,n(2668).op)({add_:function(e,t){let n=(0,o._1)(e,"a","add"),i=(0,o._1)(t,"b","add");[n,i]=(0,s.makeTypesMatch)(n,i);const u={a:n,b:i};return r.BV.runKernel(a.mm,u)}})},3135:(e,t,n)=>{"use strict";n.d(t,{Q:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({addN_:function(e){o.hu(Array.isArray(e),(()=>"The argument passed to tf.addN() must be a list of tensors")),o.hu(e.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`));const t=e.map(((e,t)=>(0,s._1)(e,`tensors${t}`,"addN"))),n=t[0];t.forEach((e=>{if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((e=>{if(!o.cO(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const i=t;return r.BV.runKernel(a.Xz,i)}})},781:(e,t,n)=>{"use strict";n.d(t,{$:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({all_:function(e,t=null,n=!1){const o={x:(0,s._1)(e,"x","all","bool")},i={axis:t,keepDims:n};return r.BV.runKernel(a.oT,o,i)}})},2998:(e,t,n)=>{"use strict";n.d(t,{Y:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({any_:function(e,t=null,n=!1){const o={x:(0,s._1)(e,"x","any","bool")},i={axis:t,keepDims:n};return r.BV.runKernel(a.IK,o,i)}})},47:(e,t,n)=>{"use strict";n.d(t,{N:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({argMax_:function(e,t=0){const n={x:(0,s._1)(e,"x","argMax")},o={axis:t};return r.BV.runKernel(a.sJ,n,o)}})},7394:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({argMin_:function(e,t=0){const n={x:(0,s._1)(e,"x","argMin")},o={axis:t};return r.BV.runKernel(a.aJ,n,o)}})},2421:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({asin_:function(e){const t={x:(0,s._1)(e,"x","asin")};return r.BV.runKernel(a.M2,t)}})},1891:(e,t,n)=>{"use strict";n.d(t,{V:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({asinh_:function(e){const t={x:(0,s._1)(e,"x","asinh")};return r.BV.runKernel(a.qw,t)}})},7037:(e,t,n)=>{"use strict";n.d(t,{z:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({atan_:function(e){const t={x:(0,s._1)(e,"x","atan")};return r.BV.runKernel(a.jM,t)}})},9812:(e,t,n)=>{"use strict";n.d(t,{f:()=>i});var r=n(7097),a=n(9121),s=n(747),o=n(3740);const i=(0,n(2668).op)({atan2_:function(e,t){let n=(0,o._1)(e,"a","atan2"),i=(0,o._1)(t,"b","atan2");[n,i]=(0,s.makeTypesMatch)(n,i);const u={a:n,b:i};return r.BV.runKernel(a.QC,u)}})},369:(e,t,n)=>{"use strict";n.d(t,{C:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({atanh_:function(e){const t={x:(0,s._1)(e,"x","atanh")};return r.BV.runKernel(a.Oy,t)}})},5176:(e,t,n)=>{"use strict";n.d(t,{w:()=>p});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2271),u=n(2582),l=n(2668),c=n(4968);const p=(0,l.op)({avgPool_:function(e,t,n,l,p){const d=(0,s._1)(e,"x","avgPool","float32");o.hu(u.jT(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let h=d,m=!1;3===d.rank&&(m=!0,h=(0,c.X)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),o.hu(4===h.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${h.rank}.`)),null!=p&&o.hu(o.GN(l),(()=>`Error in avgPool: pad must be an integer when using, dimRoundingMode ${p} but got pad ${l}.`));const f={x:h},g={filterSize:t,strides:n,pad:l,dimRoundingMode:p};let y=r.BV.runKernel(a.Jh,f,g);return y=(0,i.p)(y,d.dtype),m?(0,c.X)(y,[y.shape[1],y.shape[2],y.shape[3]]):y}})},1749:(e,t,n)=>{"use strict";n.d(t,{u:()=>c});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2271),u=n(2668),l=n(4968);const c=(0,u.op)({avgPool3d_:function(e,t,n,u,c,p="NDHWC"){const d=(0,s._1)(e,"x","avgPool3d","float32");let h=d,m=!1;4===d.rank&&(m=!0,h=(0,l.X)(d,[1,d.shape[0],d.shape[1],d.shape[2],d.shape[3]])),o.hu(5===h.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${h.rank}.`)),o.hu("NDHWC"===p,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${p}`)),null!=c&&o.hu(o.GN(u),(()=>`Error in avgPool3d: pad must be an integer when using, dimRoundingMode ${c} but got pad ${u}.`));const f={x:h},g={filterSize:t,strides:n,pad:u,dimRoundingMode:c,dataFormat:p};let y=r.BV.runKernel(a._k,f,g);return y=(0,i.p)(y,h.dtype),m?(0,l.X)(y,[y.shape[1],y.shape[2],y.shape[3],y.shape[4]]):y}})},3591:(e,t,n)=>{"use strict";n.d(t,{YB:()=>a,Vh:()=>s,kz:()=>o,rv:()=>i,lB:()=>u,Q3:()=>l,LJ:()=>c,sY:()=>p});var r=n(569);function a(e,t){for(let n=0;ne[t]))]}function i(e,t){return s(e,t.map((e=>1)),t)}function u(e,t,n){r.hu(a(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function l(e,t){if(a(e,t))return null;const n=[];for(let r=0;rn.push(e))),n}function c(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function p(e,t){const n=[];for(let r=t-e;r{"use strict";n.d(t,{E:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({batchToSpaceND_:function(e,t,n){const i=(0,s._1)(e,"x","batchToSpaceND"),u=t.reduce(((e,t)=>e*t));o.hu(i.rank>=1+t.length,(()=>`input rank is ${i.rank} but should be > than blockShape.length ${t.length}`)),o.hu(n.length===t.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)),o.hu(i.shape[0]%u==0,(()=>`input tensor batch is ${i.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${u}`));const l={x:i},c={blockShape:t,crops:n};return r.BV.runKernel(a.zw,l,c)}})},7505:(e,t,n)=>{"use strict";n.d(t,{t:()=>u});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(4968);const u=(0,n(2668).op)({batchNorm_:function(e,t,n,u,l,c){null==c&&(c=.001);const p=(0,s._1)(e,"x","batchNorm"),d=(0,s._1)(t,"mean","batchNorm"),h=(0,s._1)(n,"variance","batchNorm");let m,f;null!=l&&(m=(0,s._1)(l,"scale","batchNorm")),null!=u&&(f=(0,s._1)(u,"offset","batchNorm")),o.hu(d.rank===h.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),o.hu(null==f||d.rank===f.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),o.hu(null==m||d.rank===m.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const g={x:function(e){let t;return t=0===e.rank||1===e.rank?(0,i.X)(e,[1,1,1,e.size]):2===e.rank?(0,i.X)(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?(0,i.X)(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(p),scale:m,offset:f,mean:d,variance:h},y={varianceEpsilon:c},b=r.BV.runKernel(a.sH,g,y);return(0,i.X)(b,p.shape)}})},3865:(e,t,n)=>{"use strict";n.d(t,{y:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({bincount_:function(e,t,n){const i=(0,s._1)(e,"x","bincount"),u=(0,s._1)(t,"weights","bincount");o.hu("int32"===i.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${i.dtype}`)),o.hu(n>=0,(()=>`size must be non-negative, but got ${n}.`)),o.hu(u.size===i.size||0===u.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${i.shape}, weights shape: ${u.shape}.`));const l={x:i,weights:u},c={size:n};return r.BV.runKernel(a.zv,l,c)}})},8194:(e,t,n)=>{"use strict";n.d(t,{X:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({broadcastArgs_:function(e,t){const n=(0,s._1)(e,"s0","broadcastArgs","int32"),o=(0,s._1)(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==o.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${o.rank}`);const i={s0:n,s1:o};return r.BV.runKernel(a.eE,i)}})},8247:(e,t,n)=>{"use strict";n.d(t,{U:()=>l});var r=n(7097),a=n(9121),s=n(3740),o=n(8723),i=n(2668),u=n(4968);const l=(0,i.op)({broadcastTo_:function(e,t){let n=(0,s._1)(e,"broadcastTo","x");const i=n.shape;if(t.some((e=>!(e>0)||e%1!=0)))throw new Error(`broadcastTo(): Invalid broadcast shape [${t}].`);if(t.lengthn.rank){const e=n.shape.slice();for(;e.length=0;e--)if(l[e]===t[e])c[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${i}] cannot be broadcast to [${t}].`);if(0===c.map(((e,t)=>e>1?t:-1)).filter((e=>e>=0)).length)return(0,o.d)(n);const p={x:n},d={reps:c};return r.BV.runKernel(a.n9,p,d)}})},2200:(e,t,n)=>{"use strict";function r(e,t){const n=e.length,r=[];for(let a=0;a1&&1===o&&r.unshift(s)}return r}function a(e,t){const n=[];for(let r=0;r1)&&n.unshift(s)}return n}function s(e,t){const n=[],r=Math.max(e.length,t.length);for(let a=0;ar,RR:()=>a,$N:()=>s})},2657:(e,t,n)=>{"use strict";n.d(t,{f:()=>s});var r=n(4077),a=n(569);function s(e,t="float32",n){return t=t||"float32",a.Mu(e),new r.YD(e,t,n)}},2271:(e,t,n)=>{"use strict";n.d(t,{p:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({cast_:function(e,t){const n=(0,s._1)(e,"x","cast");if(!o.LP(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const i={x:n},u={dtype:t};return r.BV.runKernel(a.RF,i,u)}})},6825:(e,t,n)=>{"use strict";n.d(t,{m:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({ceil_:function(e){const t={x:(0,s._1)(e,"x","ceil")};return r.BV.runKernel(a.gJ,t)}})},2279:(e,t,n)=>{"use strict";n.d(t,{i:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({clipByValue_:function(e,t,n){const i=(0,s._1)(e,"x","clipByValue");o.hu(t<=n,(()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`));const u={x:i},l={clipValueMin:t,clipValueMax:n};return r.BV.runKernel(a.xn,u,l)}})},8723:(e,t,n)=>{"use strict";n.d(t,{d:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({clone_:function(e){const t={x:(0,s._1)(e,"x","clone","string_or_numeric")};return r.BV.runKernel(a.iJ,t)}})},1661:(e,t,n)=>{"use strict";n.d(t,{P:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({complex_:function(e,t){const n=(0,s._1)(e,"real","complex"),i=(0,s._1)(t,"imag","complex");o.k5(n.shape,i.shape,`real and imag shapes, ${n.shape} and ${i.shape}, must match in call to tf.complex().`);const u={real:n,imag:i};return r.BV.runKernel(a.Zz,u)}})},6884:(e,t,n)=>{"use strict";n.d(t,{z:()=>u});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(8723);const u=(0,n(2668).op)({concat_:function(e,t=0){(0,o.hu)(e.length>=1,(()=>"Pass at least one tensor to concat"));const n=(0,s.sI)(e,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((e=>{if("complex64"!==e.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `)})),1===n.length)return(0,i.d)(n[0]);const u=n,l={axis:t};return r.BV.runKernel(a.Eh,u,l)}})},1355:(e,t,n)=>{"use strict";n.d(t,{P:()=>l});var r=n(3740),a=n(569),s=n(4794),o=n(2582),i=n(2668),u=n(4968);const l=(0,i.op)({conv1d_:function(e,t,n,i,l="NWC",c=1,p){const d=(0,r._1)(e,"x","conv1d"),h=(0,r._1)(t,"filter","conv1d");let m=d,f=!1;2===d.rank&&(f=!0,m=(0,u.X)(d,[1,d.shape[0],d.shape[1]])),a.hu(3===m.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${m.rank}.`)),a.hu(3===h.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${h.rank}.`)),null!=p&&a.hu(a.GN(i),(()=>`Error in conv1d: pad must be an integer when using, dimRoundingMode ${p} but got pad ${i}.`)),a.hu(m.shape[2]===h.shape[1],(()=>`Error in conv1d: depth of input (${m.shape[2]}) must match input depth for filter ${h.shape[1]}.`)),a.hu(o.jT(n,c),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${c}'`)),a.hu("NWC"===l,(()=>`Error in conv1d: got dataFormat of ${l} but only NWC is currently supported.`));const g=(0,u.X)(h,[1,h.shape[0],h.shape[1],h.shape[2]]),y=(0,u.X)(m,[m.shape[0],1,m.shape[1],m.shape[2]]),b=[1,n],k=[1,c],w=(0,s.T)(y,g,b,i,"NHWC",k,p);return f?(0,u.X)(w,[w.shape[2],w.shape[3]]):(0,u.X)(w,[w.shape[0],w.shape[2],w.shape[3]])}})},4794:(e,t,n)=>{"use strict";n.d(t,{T:()=>c});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2582),u=n(2668),l=n(4968);const c=(0,u.op)({conv2d_:function(e,t,n,u,c="NHWC",p=[1,1],d){const h=(0,s._1)(e,"x","conv2d"),m=(0,s._1)(t,"filter","conv2d");let f=h,g=!1;3===h.rank&&(g=!0,f=(0,l.X)(h,[1,h.shape[0],h.shape[1],h.shape[2]])),o.hu(4===f.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${f.rank}.`)),o.hu(4===m.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${m.rank}.`)),null!=d&&o.hu(o.GN(u),(()=>`Error in conv2d: pad must be an integer when using, dimRoundingMode ${d} but got pad ${u}.`));const y="NHWC"===c?f.shape[3]:f.shape[1];o.hu(y===m.shape[2],(()=>`Error in conv2d: depth of input (${y}) must match input depth for filter ${m.shape[2]}.`)),o.hu(i.jT(n,p),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${p}'`));const b={x:f,filter:m},k={strides:n,pad:u,dataFormat:c,dilations:p,dimRoundingMode:d},w=r.BV.runKernel(a.mh,b,k);return g?(0,l.X)(w,[w.shape[1],w.shape[2],w.shape[3]]):w}})},9832:(e,t,n)=>{"use strict";n.d(t,{_:()=>u});var r=n(7097),a=n(9121),s=n(569),o=n(2668),i=n(4968);const u=(0,o.op)({conv2DBackpropInput_:function(e,t,n,o,u,l="NHWC",c){s.hu(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let p=e,d=t,h=!1;3===t.rank&&(h=!0,d=(0,i.X)(t,[1,t.shape[0],t.shape[1],t.shape[2]]),p=[1,e[0],e[1],e[2]]),s.hu(4===p.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${p.length}.`)),s.hu(4===d.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${d.rank}`)),s.hu(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const m="NHWC"===l?p[3]:p[1],f="NHWC"===l?d.shape[3]:d.shape[1];s.hu(m===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${m}) must match input depth for filter ${n.shape[2]}.`)),s.hu(f===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${f}) must match output depth for filter ${n.shape[3]}.`)),null!=c&&s.hu(s.GN(u),(()=>`Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode ${c} but got pad ${u}.`));const g={dy:d,filter:n},y={strides:o,pad:u,dataFormat:l,dimRoundingMode:c,inputShape:p},b=r.BV.runKernel(a.wm,g,y);return h?(0,i.X)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}})},1405:(e,t,n)=>{"use strict";n.d(t,{b:()=>s});var r=n(3740),a=n(9832);const s=(0,n(2668).op)({conv2dTranspose_:function(e,t,n,s,o,i){const u=(0,r._1)(e,"x","conv2dTranspose"),l=(0,r._1)(t,"filter","conv2dTranspose");return(0,a._)(n,u,l,s,o,"NHWC",i)}})},473:(e,t,n)=>{"use strict";n.d(t,{p:()=>c});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2582),u=n(2668),l=n(4968);const c=(0,u.op)({conv3d_:function(e,t,n,u,c="NDHWC",p=[1,1,1]){const d=(0,s._1)(e,"x","conv3d"),h=(0,s._1)(t,"filter","conv3d");let m=d,f=!1;4===d.rank&&(f=!0,m=(0,l.X)(d,[1,d.shape[0],d.shape[1],d.shape[2],d.shape[3]])),o.hu(5===m.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${m.rank}.`)),o.hu(5===h.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${h.rank}.`)),o.hu(m.shape[4]===h.shape[3],(()=>`Error in conv3d: depth of input (${m.shape[4]}) must match input depth for filter ${h.shape[3]}.`)),o.hu((0,i.jT)(n,p),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${p}'`)),o.hu("NDHWC"===c,(()=>`Error in conv3d: got dataFormat of ${c} but only NDHWC is currently supported.`));const g={x:m,filter:h},y={strides:n,pad:u,dataFormat:c,dilations:p},b=r.BV.runKernel(a.x1,g,y);return f?(0,l.X)(b,[b.shape[1],b.shape[2],b.shape[3],b.shape[4]]):b}})},2582:(e,t,n)=>{"use strict";function r(e,t,n,r,a="NHWC",s){return o(e,[...t,e[3]],n,s,r,null,null,f(a))}function a(e,t,n,r,a,s,i="channelsLast"){const[u,c]=l(t);let p;if("channelsLast"===i)p=[u,c,e[3],e[3]];else{if("channelsFirst"!==i)throw new Error(`Unknown dataFormat ${i}`);p=[u,c,e[1],e[1]]}return o(e,p,n,r,a,s,!1,i)}function s(e,t,n,r,a,s,o="NDHWC"){const[u,l,p]=c(t);let d,h;if("NDHWC"===o)h="channelsLast",d=[u,l,p,e[4],e[4]];else{if("NCDHW"!==o)throw new Error(`Unknown dataFormat ${o}`);h="channelsFirst",d=[u,l,p,e[1],e[1]]}return i(e,d,n,r,a,!1,h,s)}function o(e,t,n,r,a,s,o=!1,i="channelsLast"){let[c,h,m,f]=[-1,-1,-1,-1];if("channelsLast"===i)[c,h,m,f]=e;else{if("channelsFirst"!==i)throw new Error(`Unknown dataFormat ${i}`);[c,f,h,m]=e}const[g,y,,b]=t,[k,w]=l(n),[v,x]=l(r),N=p(g,v),S=p(y,x),{padInfo:I,outHeight:T,outWidth:_}=function(e,t,n,r,a,s,o,i,l){let c,p,h;if("number"==typeof e){c={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=u(e,t,n));const s=e[0],o=e[1],i=d((s-t+2*r)/n+1,a),l=d((o-t+2*r)/n+1,a);return[i,l]}([t,n],s,r,e,i);p=a[0],h=a[1]}else if("same"===e){p=Math.ceil(t/r),h=Math.ceil(n/a);const e=Math.max(0,(p-1)*r+s-t),i=Math.max(0,(h-1)*a+o-n),u=Math.floor(e/2),l=e-u,d=Math.floor(i/2);c={top:u,bottom:l,left:d,right:i-d,type:"SAME"}}else if("valid"===e)c={top:0,bottom:0,left:0,right:0,type:"VALID"},p=Math.ceil((t-s+1)/r),h=Math.ceil((n-o+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const u="channelsLast"===l?e[1][0]:e[2][0],m="channelsLast"===l?e[1][1]:e[2][1],f="channelsLast"===l?e[2][0]:e[3][0],g="channelsLast"===l?e[2][1]:e[3][1];c={top:u,bottom:m,left:f,right:g,type:0===u&&0===m&&0===f&&0===g?"VALID":"EXPLICIT"},p=d((t-s+u+m)/r+1,i),h=d((n-o+f+g)/a+1,i)}}return{padInfo:c,outHeight:p,outWidth:h}}(a,h,m,k,w,N,S,s,i),E=o?b*f:b;let A;return"channelsFirst"===i?A=[c,E,T,_]:"channelsLast"===i&&(A=[c,T,_,E]),{batchSize:c,dataFormat:i,inHeight:h,inWidth:m,inChannels:f,outHeight:T,outWidth:_,outChannels:E,padInfo:I,strideHeight:k,strideWidth:w,filterHeight:g,filterWidth:y,effectiveFilterHeight:N,effectiveFilterWidth:S,dilationHeight:v,dilationWidth:x,inShape:e,outShape:A,filterShape:t}}function i(e,t,n,r,a,s=!1,o="channelsLast",i){let[l,h,m,f,g]=[-1,-1,-1,-1,-1];if("channelsLast"===o)[l,h,m,f,g]=e;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[l,g,h,m,f]=e}const[y,b,k,,w]=t,[v,x,N]=c(n),[S,I,T]=c(r),_=p(y,S),E=p(b,I),A=p(k,T),{padInfo:M,outDepth:$,outHeight:D,outWidth:F}=function(e,t,n,r,a,s,o,i,l,c,p){let h,m,f,g;if("number"==typeof e){h={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const s=function(e,t,n,r,a,s){null==a&&(a=u(e,t,r));const o=e[0],i=e[1],l=e[2],c=d((o-t+2*a)/r+1,s),p=d((i-t+2*a)/r+1,s),h=d((l-t+2*a)/r+1,s);return[c,p,h,n]}([t,n,r,1],i,1,a,e,p);m=s[0],f=s[1],g=s[2]}else if("same"===e){m=Math.ceil(t/a),f=Math.ceil(n/s),g=Math.ceil(r/o);const e=(m-1)*a+i-t,u=(f-1)*s+l-n,p=(g-1)*o+c-r,d=Math.floor(e/2),y=e-d,b=Math.floor(u/2),k=u-b,w=Math.floor(p/2);h={top:b,bottom:k,left:w,right:p-w,front:d,back:y,type:"SAME"}}else{if("valid"!==e)throw Error(`Unknown padding parameter: ${e}`);h={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},m=Math.ceil((t-i+1)/a),f=Math.ceil((n-l+1)/s),g=Math.ceil((r-c+1)/o)}return{padInfo:h,outDepth:m,outHeight:f,outWidth:g}}(a,h,m,f,v,x,N,_,E,A,i),O=s?w*g:w;let B;return"channelsFirst"===o?B=[l,O,$,D,F]:"channelsLast"===o&&(B=[l,$,D,F,O]),{batchSize:l,dataFormat:o,inDepth:h,inHeight:m,inWidth:f,inChannels:g,outDepth:$,outHeight:D,outWidth:F,outChannels:O,padInfo:M,strideDepth:v,strideHeight:x,strideWidth:N,filterDepth:y,filterHeight:b,filterWidth:k,effectiveFilterDepth:_,effectiveFilterHeight:E,effectiveFilterWidth:A,dilationDepth:S,dilationHeight:I,dilationWidth:T,inShape:e,outShape:B,filterShape:t}}function u(e,t,n,r=1){const a=p(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function l(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function c(e){return"number"==typeof e?[e,e,e]:e}function p(e,t){return t<=1?e:e+(e-1)*(t-1)}function d(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function h(e){const[t,n,r]=l(e);return 1===t&&1===n&&1===r}function m(e,t){return h(e)||h(t)}function f(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}n.d(t,{Rf:()=>r,Xw:()=>a,pl:()=>s,Ix:()=>o,jw:()=>i,aO:()=>u,I0:()=>h,jT:()=>m,sl:()=>f})},173:(e,t,n)=>{"use strict";n.d(t,{m:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({cos_:function(e){const t={x:(0,s._1)(e,"x","cos")};return r.BV.runKernel(a.mc,t)}})},2699:(e,t,n)=>{"use strict";n.d(t,{f:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({cosh_:function(e){const t={x:(0,s._1)(e,"x","cosh")};return r.BV.runKernel(a.TR,t)}})},7405:(e,t,n)=>{"use strict";n.d(t,{z:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({cumsum_:function(e,t=0,n=!1,o=!1){const i={x:(0,s._1)(e,"x","cumsum")},u={axis:t,exclusive:n,reverse:o};return r.BV.runKernel(a.iH,i,u)}})},5746:(e,t,n)=>{"use strict";n.d(t,{p:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({denseBincount_:function(e,t,n,i=!1){const u=(0,s._1)(e,"x","denseBincount"),l=(0,s._1)(t,"weights","denseBincount");o.hu("int32"===u.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${u.dtype}`)),o.hu(u.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${u.rank}.`)),o.hu(n>=0,(()=>`size must be non-negative, but got ${n}.`)),o.hu(l.size===u.size||0===l.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${u.shape}, weights shape: ${l.shape}.`));const c={x:u,weights:l},p={size:n,binaryOutput:i};return r.BV.runKernel(a.QR,c,p)}})},9112:(e,t,n)=>{"use strict";n.d(t,{n:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({depthToSpace_:function(e,t,n="NHWC"){const i=(0,s._1)(e,"x","depthToSpace"),u="NHWC"===n?i.shape[1]:i.shape[2],l="NHWC"===n?i.shape[2]:i.shape[3],c="NHWC"===n?i.shape[3]:i.shape[1];o.hu(u*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${u} and ${t} for depthToSpace with input shape\n ${i.shape}`)),o.hu(l*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${l} and ${t} for depthToSpace with input shape\n ${i.shape}`)),o.hu(c%(t*t)==0,(()=>`Dimension size must be evenly divisible by ${t*t} but is ${c} for depthToSpace with input shape ${i.shape}`));const p={x:i},d={blockSize:t,dataFormat:n};return r.BV.runKernel(a.T0,p,d)}})},4718:(e,t,n)=>{"use strict";n.d(t,{B:()=>l});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2668),u=n(4968);const l=(0,i.op)({depthwiseConv2d_:function(e,t,n,i,l="NHWC",c=[1,1],p){const d=(0,s._1)(e,"x","depthwiseConv2d"),h=(0,s._1)(t,"filter","depthwiseConv2d");let m=d,f=!1;3===d.rank&&(f=!0,m=(0,u.X)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),o.hu(4===m.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${m.rank}.`)),o.hu(4===h.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${h.rank}.`)),o.hu(m.shape[3]===h.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${m.shape[3]}) must match the inChannels dimension in filter ${h.shape[2]}.`)),null!=p&&o.hu(o.GN(i),(()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${p} but got pad ${i}.`));const g={x:m,filter:h},y={strides:n,pad:i,dataFormat:l,dilations:c,dimRoundingMode:p},b=r.BV.runKernel(a.ci,g,y);return f?(0,u.X)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}})},557:(e,t,n)=>{"use strict";n.d(t,{W:()=>l});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2668),u=n(4968);const l=(0,i.op)({dilation2d_:function(e,t,n,i,l=[1,1],c="NHWC"){const p=(0,s._1)(e,"x","dilation2d"),d=(0,s._1)(t,"filter","dilation2d");o.hu(3===p.rank||4===p.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${p.rank}.`)),o.hu(3===d.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${d.rank}.`)),o.hu("NHWC"===c,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${c}`));let h=p,m=!1;3===p.rank&&(h=(0,u.X)(p,[1,p.shape[0],p.shape[1],p.shape[2]]),m=!0);const f={x:h,filter:d},g={strides:n,pad:i,dilations:l},y=r.BV.runKernel(a.p4,f,g);return m?(0,u.X)(y,[y.shape[1],y.shape[2],y.shape[3]]):y}})},1274:(e,t,n)=>{"use strict";n.d(t,{h:()=>u});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(9165);const u=(0,n(2668).op)({div_:function(e,t){let n=(0,o._1)(e,"a","div"),u=(0,o._1)(t,"b","div");if([n,u]=(0,s.makeTypesMatch)(n,u),"int32"===n.dtype&&"int32"===u.dtype)return(0,i.q)(n,u);const l={a:n,b:u};return r.BV.runKernel(a.oH,l,{})}})},9322:(e,t,n)=>{"use strict";n.d(t,{N:()=>c});var r=n(747),a=n(3740),s=n(1274),o=n(6477),i=n(2668),u=n(5912),l=n(6577);const c=(0,i.op)({divNoNan_:function(e,t){let n=(0,a._1)(e,"a","div"),i=(0,a._1)(t,"b","div");[n,i]=(0,r.makeTypesMatch)(n,i);const c=(0,s.h)(n,i),p=(0,l.P)(c),d=(0,o.D)(i,p);return(0,u.a)(d,p,c)}})},4653:(e,t,n)=>{"use strict";n.d(t,{W:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({einsum_:function(e,...t){const n=t.map(((e,t)=>(0,s._1)(e,`tensors${t}`,"einsum"))),o={equation:e};return r.BV.runKernel(a.$g,n,o)}})},3233:(e,t,n)=>{"use strict";n.d(t,{p:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({elu_:function(e){const t={x:(0,s._1)(e,"x","elu")};return r.BV.runKernel(a.SX,t)}})},6477:(e,t,n)=>{"use strict";n.d(t,{D:()=>u});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200);const u=(0,n(2668).op)({equal_:function(e,t){let n=(0,o._1)(e,"a","equal","string_or_numeric"),u=(0,o._1)(t,"b","equal","string_or_numeric");[n,u]=(0,s.makeTypesMatch)(n,u),(0,i.$N)(n.shape,u.shape);const l={a:n,b:u};return r.BV.runKernel(a.hd,l)}})},4650:(e,t,n)=>{"use strict";n.d(t,{q:()=>u});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2271);const u=(0,n(2668).op)({erf_:function(e){let t=(0,s._1)(e,"x","erf");o.hu("int32"===t.dtype||"float32"===t.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===t.dtype&&(t=(0,i.p)(t,"float32"));const n={x:t};return r.BV.runKernel(a.Om,n)}})},4842:(e,t,n)=>{"use strict";n.d(t,{Q:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({exp_:function(e){const t={x:(0,s._1)(e,"x","exp")};return r.BV.runKernel(a.NE,t)}})},1300:(e,t,n)=>{"use strict";n.d(t,{d:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({expandDims_:function(e,t=0){const n=(0,s._1)(e,"x","expandDims","string_or_numeric");o.hu(t<=n.rank,(()=>"Axis must be <= rank of the tensor"));const i={input:n},u={dim:t};return r.BV.runKernel(a.YF,i,u)}})},3426:(e,t,n)=>{"use strict";n.d(t,{t:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({expm1_:function(e){const t={x:(0,s._1)(e,"x","expm1")};return r.BV.runKernel(a.Y0,t)}})},4006:(e,t,n)=>{"use strict";n.d(t,{h:()=>s});var r=n(7097),a=n(9121);function s(e,t,n){const s={shape:e,value:t,dtype:n};return r.BV.runKernel(a.de,{},s)}},6943:(e,t,n)=>{"use strict";n.d(t,{G:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({floor_:function(e){const t={x:(0,s._1)(e,"x","floor")};return r.BV.runKernel(a.OR,t)}})},9165:(e,t,n)=>{"use strict";n.d(t,{q:()=>i});var r=n(7097),a=n(9121),s=n(747),o=n(3740);const i=(0,n(2668).op)({floorDiv_:function(e,t){let n=(0,o._1)(e,"a","floorDiv"),i=(0,o._1)(t,"b","floorDiv");[n,i]=(0,s.makeTypesMatch)(n,i);const u={a:n,b:i};return r.BV.runKernel(a.je,u)}})},2277:(e,t,n)=>{"use strict";n.r(t),n.d(t,{conv2d:()=>b,depthwiseConv2d:()=>x,matMul:()=>S});var r=n(7097),a=n(633),s=n(9121),o=n(747),i=n(3740),u=n(569),l=n(6407),c=n(2200),p=n(4794),d=n(2668),h=n(4968);const m=(0,d.op)({conv2DBackpropFilter_:function(e,t,n,a,o,i="NHWC",l){let c=e;3===e.rank&&(c=(0,h.X)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let p=t;3===p.rank&&(p=(0,h.X)(t,[1,t.shape[0],t.shape[1],t.shape[2]])),u.hu(4===c.rank,(()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${c.shape}.`)),u.hu(4===p.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${p.shape}.`)),u.hu(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const d="NHWC"===i?c.shape[3]:c.shape[1],m="NHWC"===i?p.shape[3]:p.shape[1];u.hu(d===n[2],(()=>`Error in conv2dDerFilter: depth of input ${d}) must match input depth in filter (${n[2]}.`)),u.hu(m===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${m}) must match output depth for filter (${n[3]}).`)),null!=l&&u.hu(u.GN(o),(()=>`Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode ${l} but got pad ${o}.`));const f={x:c,dy:p},g={strides:a,pad:o,dataFormat:i,dimRoundingMode:l,filterShape:n};return r.BV.runKernel(s.wU,f,g)}});var f=n(9832),g=n(2582),y=n(9323);const b=(0,d.op)({fusedConv2d_:function({x:e,filter:t,strides:n,pad:d,dataFormat:b="NHWC",dilations:k=[1,1],dimRoundingMode:w,bias:v,activation:x="linear",preluActivationWeights:N,leakyreluAlpha:S}){if(x=x||"linear",!1===(0,y.uy)(r.BV.state.gradientDepth,x)){let r=(0,p.T)(e,t,n,d,b,k,w);return null!=v&&(r=(0,l.I)(r,v)),(0,y.QH)(r,x,N,S)}const I=(0,i._1)(e,"x","conv2d"),T=(0,i._1)(t,"filter","conv2d");let _=I,E=!1;3===I.rank&&(E=!0,_=(0,h.X)(I,[1,I.shape[0],I.shape[1],I.shape[2]])),u.hu(4===_.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${_.rank}.`)),u.hu(4===T.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${T.rank}.`)),null!=w&&u.hu(u.GN(d),(()=>`Error in fused conv2d: pad must be an integer when using, dimRoundingMode ${w} but got pad ${d}.`)),u.hu(_.shape[3]===T.shape[2],(()=>`Error in conv2d: depth of input (${_.shape[3]}) must match input depth for filter ${T.shape[2]}.`)),u.hu(g.jT(n,k),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${k}'`)),u.hu("NHWC"===b,(()=>`Error in conv2d: got dataFormat of ${b} but only NHWC is currently supported.`));const A=g.Ix(_.shape,T.shape,n,k,d,w);let M,$;null!=v&&(M=(0,i._1)(v,"bias","fused conv2d"),[M]=(0,o.makeTypesMatch)(M,I),c.$N(A.outShape,M.shape)),null!=N&&($=(0,i._1)(N,"prelu weights","fused conv2d"));const D=(e,t)=>{const[r,a,s,o]=t,i=(0,y.Fr)(e,s,x);u.hu(g.I0(k),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${k}'`));const l=[(0,f._)(a.shape,i,r,n,d),m(a,i,r.shape,n,d)];if(null!=o){const e=(0,y.pf)(o,i);l.push(e)}return l},F={x:_,filter:T,bias:M,preluActivationWeights:$},O={strides:n,pad:d,dataFormat:b,dilations:k,dimRoundingMode:w,activation:x,leakyreluAlpha:S};if(null==v){return(0,a.cb)(((e,t,n)=>{let a=r.BV.runKernel(s._V,F,O);return n([t,e,a]),E&&(a=(0,h.X)(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:D}}))(_,T)}return(0,a.cb)(((e,t,n,a)=>{let o=r.BV.runKernel(s._V,F,O);return a([t,e,o,n]),E&&(o=(0,h.X)(o,[o.shape[1],o.shape[2],o.shape[3]])),{value:o,gradFunc:D}}))(_,T,M)}});var k=n(4718);const w=(0,d.op)({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,a,o,i=[1,1],u){let l=e;3===e.rank&&(l=(0,h.X)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let c=t;3===c.rank&&(c=(0,h.X)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const p={x:l,dy:c},d={strides:a,pad:o,dimRoundingMode:u,dilations:i,filterShape:n};return r.BV.runKernel(s.sL,p,d)}});const v=(0,d.op)({depthwiseConv2dNativeBackpropInput_:function(e,t,n,a,o,i=[1,1],u){let l=t,c=!1;3===t.rank&&(c=!0,l=(0,h.X)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const p={dy:l,filter:n},d={strides:a,pad:o,dimRoundingMode:u,dilations:i,inputShape:e},m=r.BV.runKernel(s.y7,p,d);return c?(0,h.X)(m,[m.shape[1],m.shape[2],m.shape[3]]):m}});const x=(0,d.op)({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:p,dataFormat:d="NHWC",dilations:m=[1,1],dimRoundingMode:f,bias:b,activation:x="linear",preluActivationWeights:N,leakyreluAlpha:S}){if(!1===(0,y.uy)(r.BV.state.gradientDepth,x)){let r=(0,k.B)(e,t,n,p,d,m,f);return null!=b&&(r=(0,l.I)(r,b)),(0,y.QH)(r,x,N,S)}const I=(0,i._1)(e,"x","depthwiseConv2d"),T=(0,i._1)(t,"filter","depthwiseConv2d");let _=I,E=!1;3===I.rank&&(E=!0,_=(0,h.X)(I,[1,I.shape[0],I.shape[1],I.shape[2]])),u.hu(4===_.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${_.rank}.`)),u.hu(4===T.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${T.rank}.`)),u.hu(_.shape[3]===T.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${_.shape[3]}) must match the inChannels dimension in filter ${T.shape[2]}.`)),null==m&&(m=[1,1]),u.hu(g.jT(n,m),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${m}'`)),null!=f&&u.hu(u.GN(p),(()=>`Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode ${f} but got pad ${p}.`));const A=g.Ix(_.shape,T.shape,n,m,p,f,!0);let M,$;null!=b&&(M=(0,i._1)(b,"bias","fused conv2d"),[M]=(0,o.makeTypesMatch)(M,I),c.$N(A.outShape,M.shape)),null!=N&&($=(0,i._1)(N,"prelu weights","fused depthwiseConv2d"));const D=(e,t)=>{u.hu(g.I0(m),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${m}'`));const[r,a,s,o]=t,i=(0,y.Fr)(e,s,x),l=v(a.shape,i,r,n,p,m,f),c=w(a,i,r.shape,n,p,m,f);if(null!=o){return[l,c,(0,y.pf)(M,i)]}return[l,c]},F={x:_,filter:T,bias:M,preluActivationWeights:$},O={strides:n,pad:p,dataFormat:d,dilations:m,dimRoundingMode:f,activation:x,leakyreluAlpha:S};if(null==b){return(0,a.cb)(((e,t,n)=>{let a=r.BV.runKernel(s.lu,F,O);return n([t,e,a]),E&&(a=(0,h.X)(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:D}}))(_,T)}return(0,a.cb)(((e,t,n,a)=>{let o=r.BV.runKernel(s.lu,F,O);return a([t,e,o,n]),E&&(o=(0,h.X)(o,[o.shape[1],o.shape[2],o.shape[3]])),{value:o,gradFunc:D}}))(_,T,M)}});var N=n(8687);const S=(0,d.op)({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:p=!1,bias:d,activation:m="linear",preluActivationWeights:f,leakyreluAlpha:g}){if(!1===(0,y.uy)(r.BV.state.gradientDepth,m)){let r=(0,N.O)(e,t,n,p);return null!=d&&(r=(0,l.I)(r,d)),(0,y.QH)(r,m,f,g)}let b=(0,i._1)(e,"a","fused matMul"),k=(0,i._1)(t,"b","fused matMul");[b,k]=(0,o.makeTypesMatch)(b,k);const w=n?b.shape[b.rank-2]:b.shape[b.rank-1],v=p?k.shape[k.rank-1]:k.shape[k.rank-2],x=n?b.shape[b.rank-1]:b.shape[b.rank-2],S=p?k.shape[k.rank-2]:k.shape[k.rank-1],I=b.shape.slice(0,-2),T=k.shape.slice(0,-2),_=u.NA(I),E=u.NA(T);u.hu(b.rank>=2&&k.rank>=2&&b.rank===k.rank,(()=>`Error in fused matMul: inputs must have the same rank of at least 2, got ranks ${b.rank} and ${k.rank}.`)),u.hu(u.cO(I,T),(()=>`Error in fused matMul: outer dimensions (${I}) and (${T}) of Tensors with shapes ${b.shape} and ${k.shape} must match.`)),u.hu(w===v,(()=>`Error in fused matMul: inner shapes (${w}) and (${v}) of Tensors with shapes ${b.shape} and ${k.shape} and transposeA=${n} and transposeB=${p} must match.`));const A=b.shape.slice(0,-2).concat([x,S]),M=n?(0,h.X)(b,[_,w,x]):(0,h.X)(b,[_,x,w]),$=p?(0,h.X)(k,[E,S,v]):(0,h.X)(k,[E,v,S]);let D,F;null!=d&&(D=(0,i._1)(d,"bias","fused matMul"),[D]=(0,o.makeTypesMatch)(D,b),c.$N(A,D.shape)),null!=f&&(F=(0,i._1)(f,"prelu weights","fused matMul"));const O=(e,t)=>{const[r,a,s,o]=t,i=(0,y.Fr)((0,h.X)(e,s.shape),s,m);let u,l;if(n||p?!n&&p?(u=(0,N.O)(i,a,!1,!1),l=(0,N.O)(i,r,!0,!1)):n&&!p?(u=(0,N.O)(a,i,!1,!0),l=(0,N.O)(r,i,!1,!1)):(u=(0,N.O)(a,i,!0,!0),l=(0,N.O)(i,r,!0,!0)):(u=(0,N.O)(i,a,!1,!0),l=(0,N.O)(r,i,!0,!1)),null!=d){return[u,l,(0,y.pf)(o,i)]}return[u,l]},B={a:M,b:$,bias:D,preluActivationWeights:F},C={transposeA:n,transposeB:p,activation:m,leakyreluAlpha:g};if(null==d){return(0,a.cb)(((e,t,n)=>{const a=r.BV.runKernel(s.us,B,C);return n([e,t,a]),{value:(0,h.X)(a,A),gradFunc:O}}))(M,$)}return(0,a.cb)(((e,t,n,a)=>{const o=r.BV.runKernel(s.us,B,C);return a([e,t,o,n]),{value:(0,h.X)(o,A),gradFunc:O}}))(M,$,D)}})},9323:(e,t,n)=>{"use strict";n.d(t,{Fr:()=>m,pf:()=>f,QH:()=>g,uy:()=>y});var r=n(2200),a=n(3233),s=n(9133),o=n(4841),i=n(8151),u=n(7409),l=n(3582),c=n(4968),p=n(625),d=n(1901),h=n(5475);function m(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return(0,o.d)(e,(0,d.N)(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function f(e,t){let n=t;const a=r.RR(e.shape,t.shape);return a.length>0&&(n=(0,h.S)(n,a)),(0,c.X)(n,e.shape)}function g(e,t,n,r){if("linear"===t)return e;if("relu"===t)return(0,u.U)(e);if("elu"===t)return(0,a.p)(e);if("relu6"===t)return(0,l.b)(e);if("prelu"===t)return(0,i.A)(e,n);if("leakyrelu"===t)return(0,s.h)(e,r);if("sigmoid"===t)return(0,p.X)(e);throw new Error(`Unknown fused activation ${t}.`)}const y=(e,t)=>!(e>0)||"linear"===t},4926:(e,t,n)=>{"use strict";n.d(t,{I:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({gather_:function(e,t,n=0,o=0){const i={x:(0,s._1)(e,"x","gather"),indices:(0,s._1)(t,"indices","gather","int32")},u={axis:n,batchDims:o};return r.BV.runKernel(a.qi,i,u)}})},7494:(e,t,n)=>{"use strict";n.d(t,{d:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({gatherND_:function(e,t){const n=(0,s._1)(t,"indices","gatherND","int32"),o={params:(0,s._1)(e,"x","gatherND","string_or_numeric"),indices:n};return r.BV.runKernel(a.q1,o)}})},636:(e,t,n)=>{"use strict";n.d(t,{p:()=>u});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200);const u=(0,n(2668).op)({greater_:function(e,t){let n=(0,o._1)(e,"a","greater","string_or_numeric"),u=(0,o._1)(t,"b","greater","string_or_numeric");[n,u]=(0,s.makeTypesMatch)(n,u),(0,i.$N)(n.shape,u.shape);const l={a:n,b:u};return r.BV.runKernel(a.iZ,l)}})},7630:(e,t,n)=>{"use strict";n.d(t,{b:()=>u});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200);const u=(0,n(2668).op)({greaterEqual_:function(e,t){let n=(0,o._1)(e,"a","greaterEqual","string_or_numeric"),u=(0,o._1)(t,"b","greaterEqual","string_or_numeric");[n,u]=(0,s.makeTypesMatch)(n,u),(0,i.$N)(n.shape,u.shape);const l={a:n,b:u};return r.BV.runKernel(a.Ac,l)}})},4386:(e,t,n)=>{"use strict";n.d(t,{a:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({imag_:function(e){const t={input:(0,s._1)(e,"input","imag")};return r.BV.runKernel(a.J_,t)}})},6230:(e,t,n)=>{"use strict";n.d(t,{i:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({isNaN_:function(e){const t={x:(0,s._1)(e,"x","isNaN")};return r.BV.runKernel(a.r7,t)}})},9133:(e,t,n)=>{"use strict";n.d(t,{h:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({leakyRelu_:function(e,t=.2){const n={x:(0,s._1)(e,"x","leakyRelu")},o={alpha:t};return r.BV.runKernel(a.J$,n,o)}})},6573:(e,t,n)=>{"use strict";n.d(t,{d:()=>u});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200);const u=(0,n(2668).op)({less_:function(e,t){let n=(0,o._1)(e,"a","less","string_or_numeric"),u=(0,o._1)(t,"b","less","string_or_numeric");[n,u]=(0,s.makeTypesMatch)(n,u),(0,i.$N)(n.shape,u.shape);const l={a:n,b:u};return r.BV.runKernel(a.vt,l)}})},624:(e,t,n)=>{"use strict";n.d(t,{z:()=>u});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200);const u=(0,n(2668).op)({lessEqual_:function(e,t){let n=(0,o._1)(e,"a","lessEqual","string_or_numeric"),u=(0,o._1)(t,"b","lessEqual","string_or_numeric");[n,u]=(0,s.makeTypesMatch)(n,u),(0,i.$N)(n.shape,u.shape);const l={a:n,b:u};return r.BV.runKernel(a.CA,l)}})},4135:(e,t,n)=>{"use strict";n.d(t,{S:()=>s});var r=n(7097),a=n(9121);function s(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");const s={start:e,stop:t,num:n};return r.BV.runKernel(a.e7,{},s)}},9648:(e,t,n)=>{"use strict";n.d(t,{G:()=>l});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2668),u=n(4968);const l=(0,i.op)({localResponseNormalization_:function(e,t=5,n=1,i=1,l=.5){const c=(0,s._1)(e,"x","localResponseNormalization");o.hu(4===c.rank||3===c.rank,(()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${c.rank}.`)),o.hu(o.GN(t),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`));let p=c,d=!1;3===c.rank&&(d=!0,p=(0,u.X)(c,[1,c.shape[0],c.shape[1],c.shape[2]]));const h={x:p},m={depthRadius:t,bias:n,alpha:i,beta:l},f=r.BV.runKernel(a.eZ,h,m);return d?(0,u.X)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}})},2597:(e,t,n)=>{"use strict";n.d(t,{c:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({log_:function(e){const t={x:(0,s._1)(e,"x","log")};return r.BV.runKernel(a.Zb,t)}})},7474:(e,t,n)=>{"use strict";n.d(t,{K:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({log1p_:function(e){const t={x:(0,s._1)(e,"x","log1p")};return r.BV.runKernel(a.kU,t)}})},1510:(e,t,n)=>{"use strict";n.d(t,{C:()=>h});var r=n(633),a=n(3740),s=n(2271),o=n(4842),i=n(2597),u=n(3307),l=n(4841),c=n(2668),p=n(827),d=n(5475);const h=(0,c.op)({logSoftmax_:function(e,t=-1){const n=(0,a._1)(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`);return(0,r.cb)(((e,n)=>{const r=(0,u.F)(e,t,!0),a=(0,p.l)(e,r),c=(0,p.l)((0,s.p)(a,"float32"),(0,i.c)((0,d.S)((0,o.Q)(a),t,!0)));n([c]);return{value:c,gradFunc:(e,n)=>{const[r]=n,a=(0,o.Q)(r);return(0,p.l)(e,(0,l.d)((0,d.S)(e,t,!0),a))}}}))(n)}})},2856:(e,t,n)=>{"use strict";n.d(t,{H:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(2200);const i=(0,n(2668).op)({logicalAnd_:function(e,t){const n=(0,s._1)(e,"a","logicalAnd","bool"),i=(0,s._1)(t,"b","logicalAnd","bool");(0,o.$N)(n.shape,i.shape);const u={a:n,b:i};return r.BV.runKernel(a.PY,u)}})},8651:(e,t,n)=>{"use strict";n.d(t,{h:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({logicalNot_:function(e){const t={x:(0,s._1)(e,"x","logicalNot","bool")};return r.BV.runKernel(a.Vf,t)}})},5750:(e,t,n)=>{"use strict";n.d(t,{K:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(2200);const i=(0,n(2668).op)({logicalOr_:function(e,t){const n=(0,s._1)(e,"a","logicalOr","bool"),i=(0,s._1)(t,"b","logicalOr","bool");(0,o.$N)(n.shape,i.shape);const u={a:n,b:i};return r.BV.runKernel(a.MZ,u)}})},9876:(e,t,n)=>{"use strict";var r;n.d(t,{I:()=>r}),function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(r||(r={}))},8687:(e,t,n)=>{"use strict";n.d(t,{O:()=>i});var r=n(7097),a=n(9121),s=n(747),o=n(3740);const i=(0,n(2668).op)({matMul_:function(e,t,n=!1,i=!1){let u=(0,o._1)(e,"a","matMul"),l=(0,o._1)(t,"b","matMul");[u,l]=(0,s.makeTypesMatch)(u,l);const c={a:u,b:l},p={transposeA:n,transposeB:i};return r.BV.runKernel(a.XL,c,p)}})},3307:(e,t,n)=>{"use strict";n.d(t,{F:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({max_:function(e,t=null,n=!1){const o={x:(0,s._1)(e,"x","max")},i={reductionIndices:t,keepDims:n};return r.BV.runKernel(a.Yo,o,i)}})},1174:(e,t,n)=>{"use strict";n.d(t,{_:()=>c});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2582),u=n(2668),l=n(4968);const c=(0,u.op)({maxPool_:function(e,t,n,u,c){const p=(0,s._1)(e,"x","maxPool");let d=p,h=!1;3===p.rank&&(h=!0,d=(0,l.X)(p,[1,p.shape[0],p.shape[1],p.shape[2]])),o.hu(4===d.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${d.rank}.`)),o.hu(i.jT(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),null!=c&&o.hu(o.GN(u),(()=>`Error in maxPool: pad must be an integer when using, dimRoundingMode ${c} but got pad ${u}.`));const m={x:d},f={filterSize:t,strides:n,pad:u,dimRoundingMode:c},g=r.BV.runKernel(a.mT,m,f);return h?(0,l.X)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}})},5020:(e,t,n)=>{"use strict";n.d(t,{Y:()=>l});var r=n(7097),a=n(9121),s=n(3740),o=n(569),i=n(2668),u=n(4968);const l=(0,i.op)({maxPool3d_:function(e,t=[1,1,1],n,i,l,c="NDHWC"){const p=(0,s._1)(e,"x","maxPool3d");let d=p,h=!1;4===p.rank&&(h=!0,d=(0,u.X)(p,[1,p.shape[0],p.shape[1],p.shape[2],p.shape[3]])),o.hu(5===d.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${d.rank}.`)),o.hu("NDHWC"===c,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${c}`)),null!=l&&o.hu(o.GN(i),(()=>`Error in maxPool3d: pad must be an integer when using, dimRoundingMode ${l} but got pad ${i}.`));const m={x:d},f={filterSize:t,strides:n,pad:i,dimRoundingMode:l,dataFormat:c},g=r.BV.runKernel(a.OA,m,f);return h?(0,u.X)(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}})},6877:(e,t,n)=>{"use strict";n.d(t,{I:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({maxPoolWithArgmax_:function(e,t,n,o,i=!1){const u={x:(0,s._1)(e,"x","maxPoolWithArgmax")},l={filterSize:t,strides:n,pad:o,includeBatchInIndex:i},c=r.BV.runKernel(a.vF,u,l);return{result:c[0],indexes:c[1]}}})},632:(e,t,n)=>{"use strict";n.d(t,{g:()=>l});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200),u=n(2271);const l=(0,n(2668).op)({maximum_:function(e,t){let n=(0,o._1)(e,"a","maximum"),l=(0,o._1)(t,"b","maximum");[n,l]=(0,s.makeTypesMatch)(n,l),"bool"===n.dtype&&(n=(0,u.p)(n,"int32"),l=(0,u.p)(l,"int32")),(0,i.$N)(n.shape,l.shape);const c={a:n,b:l};return r.BV.runKernel(a.BM,c)}})},5130:(e,t,n)=>{"use strict";n.d(t,{J:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({mean_:function(e,t=null,n=!1){const o={x:(0,s._1)(e,"x","mean")},i={axis:t,keepDims:n};return r.BV.runKernel(a.q2,o,i)}})},5735:(e,t,n)=>{"use strict";n.d(t,{V:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({min_:function(e,t=null,n=!1){const o={x:(0,s._1)(e,"x","min")},i={axis:t,keepDims:n};return r.BV.runKernel(a.c1,o,i)}})},4513:(e,t,n)=>{"use strict";n.d(t,{L:()=>l});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200),u=n(2271);const l=(0,n(2668).op)({minimum_:function(e,t){let n=(0,o._1)(e,"a","minimum"),l=(0,o._1)(t,"b","minimum");[n,l]=(0,s.makeTypesMatch)(n,l),"bool"===n.dtype&&(n=(0,u.p)(n,"int32"),l=(0,u.p)(l,"int32")),(0,i.$N)(n.shape,l.shape);const c={a:n,b:l};return r.BV.runKernel(a.q8,c)}})},1483:(e,t,n)=>{"use strict";n.d(t,{V:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({mirrorPad_:function(e,t,n){o.hu("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const i=(0,s._1)(e,"x","mirrorPad");if(0===i.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");o.hu(t.length===i.rank,(()=>`Padding doesn't match input. Must be ${i.rank}. Got ${t.length}.`));const u="reflect"===n?1:0;for(let e=0;e"Invalid number of paddings. Must be length of 2 each.")),o.hu(t[e][0]>=0&&t[e][0]<=i.shape[e]-u&&t[e][1]>=0&&t[e][1]<=i.shape[e]-u,(()=>`Padding in dimension ${e} cannot be greater than or equal to ${i.shape[e]-u} or less than 0 for input of shape ${i.shape}`));const l={paddings:t,mode:n},c={x:i};return r.BV.runKernel(a.jQ,c,l)}})},5228:(e,t,n)=>{"use strict";n.d(t,{w:()=>i});var r=n(7097),a=n(9121),s=n(747),o=n(3740);const i=(0,n(2668).op)({mod_:function(e,t){let n=(0,o._1)(e,"a","mod"),i=(0,o._1)(t,"b","mod");[n,i]=(0,s.makeTypesMatch)(n,i);const u={a:n,b:i};return r.BV.runKernel(a.Vb,u)}})},4841:(e,t,n)=>{"use strict";n.d(t,{d:()=>i});var r=n(7097),a=n(9121),s=n(747),o=n(3740);const i=(0,n(2668).op)({mul_:function(e,t){let n=(0,o._1)(e,"a","mul"),i=(0,o._1)(t,"b","mul");[n,i]=(0,s.makeTypesMatch)(n,i);const u={a:n,b:i};return r.BV.runKernel(a.wY,u)}})},686:(e,t,n)=>{"use strict";n.d(t,{S:()=>u});var r=n(7097),a=n(9121),s=n(3740),o=n(2668),i=n(4968);const u=(0,o.op)({multinomial_:function(e,t,n,o=!1){const u=(0,s._1)(e,"logits","multinomial"),l=u.size,c=u.rank;if(l<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${l}.`);if(c>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${c}`);n=n||Math.random();const p={logits:1===c?(0,i.X)(u,[1,-1]):u},d={numSamples:t,seed:n,normalized:o},h=r.BV.runKernel(a.NZ,p,d);return 1===c?(0,i.X)(h,[h.size]):h}})},7370:(e,t,n)=>{"use strict";n.d(t,{W:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({neg_:function(e){const t={x:(0,s._1)(e,"x","neg")};return r.BV.runKernel(a.ku,t)}})},6500:(e,t,n)=>{"use strict";n.d(t,{Q:()=>u});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200);const u=(0,n(2668).op)({notEqual_:function(e,t){let n=(0,o._1)(e,"a","notEqual","string_or_numeric"),u=(0,o._1)(t,"b","notEqual","string_or_numeric");[n,u]=(0,s.makeTypesMatch)(n,u),(0,i.$N)(n.shape,u.shape);const l={a:n,b:u};return r.BV.runKernel(a.yQ,l)}})},6708:(e,t,n)=>{"use strict";n.d(t,{l:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({oneHot_:function(e,t,n=1,o=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const i={indices:(0,s._1)(e,"indices","oneHot","int32")},u={depth:t,onValue:n,offValue:o};return r.BV.runKernel(a.we,i,u)}})},4917:(e,t,n)=>{"use strict";n.d(t,{i:()=>i});var r=n(7097),a=n(569),s=n(1661),o=n(9640);function i(e,t="float32"){if("complex64"===t){const t=i(e,"float32"),n=(0,o.l)(e,"float32");return(0,s.P)(t,n)}const n=(0,a.p8)((0,a.NA)(e),t);return r.BV.makeTensor(n,e,t)}},7846:(e,t,n)=>{"use strict";n.d(t,{J:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({onesLike_:function(e){const t={x:(0,s._1)(e,"x","onesLike")};return r.BV.runKernel(a.qW,t)}})},2668:(e,t,n)=>{"use strict";n.d(t,{z:()=>s,op:()=>o});var r=n(7097),a=n(569);const s="__op";function o(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const o=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=s;const i=(...e)=>{r.BV.startScope(n);try{const t=o(...e);return(0,a.tI)(t)&&console.error("Cannot return a Promise inside of tidy."),r.BV.endScope(t),t}catch(e){throw r.BV.endScope(null),e}};return Object.defineProperty(i,"name",{value:n,configurable:!0}),i}},4885:(e,t,n)=>{"use strict";n.d(t,{zvA:()=>N.z,WnP:()=>r.W,Khb:()=>a.K,__u:()=>s._,IHx:()=>o.I,QBD:()=>i.Q,$6P:()=>u.$,YjB:()=>l.Y,NqF:()=>c.N,vHJ:()=>p.v,ZRM:()=>d.Z,VfV:()=>h.V,z4N:()=>m.z,fvJ:()=>f.f,C80:()=>g.C,wS1:()=>y.w,uR5:()=>b.u,zEQ:()=>_,tgs:()=>A.t,Dxk:()=>$,JY5:()=>D,p3b:()=>F,E4h:()=>E.E,yE8:()=>O.y,anm:()=>Rn,XsQ:()=>B.X,UFq:()=>C.U,f3b:()=>V.f,pju:()=>R.p,mDi:()=>z.m,iUl:()=>P.i,d9v:()=>L.d,PYB:()=>W.P,zoF:()=>w.z,gME:()=>H,Izb:()=>q,MNy:()=>G,ZaL:()=>U,PAt:()=>j.P,Tek:()=>K.T,bc:()=>X.b,pdZ:()=>Z.p,$QV:()=>te,mCk:()=>ne.m,f9Y:()=>re.f,mew:()=>Xn,zbp:()=>ae.z,ppE:()=>se.p,nTT:()=>oe.n,B10:()=>ie.B,Ka3:()=>ue,WmZ:()=>le.W,hiC:()=>ce.h,NTj:()=>pe.N,AKD:()=>de,rvX:()=>jn,WYO:()=>he.W,pyx:()=>me.p,GRh:()=>Kn,DgJ:()=>fe.D,qNN:()=>ge.q,Qqt:()=>ye.Q,dt4:()=>be.d,t$B:()=>ke.t,iyy:()=>ve,kp_:()=>un.k,hlL:()=>xe.h,GWj:()=>Ne.G,qPi:()=>Se.q,imm:()=>Jn,Iqj:()=>Ie.I,dbB:()=>Un.d,pjt:()=>Te.p,brS:()=>_e.b,Sxn:()=>ln.S,asL:()=>Ee.a,BHj:()=>Wr,V3u:()=>Zn,wx0:()=>cn.w,xVT:()=>Ae,UWc:()=>Me,i2d:()=>$e.i,hi7:()=>De.h,d9m:()=>Fe.d,zN1:()=>Oe.z,$r2:()=>Hr,SX3:()=>Be.S,G9k:()=>Ce.G,cM7:()=>Ve.c,Krr:()=>Re.K,e_t:()=>We,CmS:()=>He.C,l_t:()=>Ke,HvI:()=>Xe.H,hJK:()=>Ze.h,K5V:()=>Je.K,egP:()=>Ye,MB5:()=>qr,OI3:()=>v.O,Fp7:()=>Ge.F,_sB:()=>et._,YQQ:()=>tt.Y,Ip$:()=>nt.I,gWQ:()=>rt.g,J69:()=>at.J,ry_:()=>it,VV$:()=>ut.V,LTh:()=>lt.L,VdP:()=>ct.V,wQq:()=>pt.w,Gi7:()=>ht,p_:()=>Hn,dC7:()=>x.d,rq4:()=>mt,SJ_:()=>ft.S,W76:()=>Pe.W,KOy:()=>Ln,Quu:()=>gt.Q,lfX:()=>yt.l,iUs:()=>st.i,JpU:()=>bt.J,op:()=>N.op,N2O:()=>kt,vku:()=>wt.v,pNR:()=>vt,koy:()=>xt,t1L:()=>Nt,lGY:()=>St,d_R:()=>_t,sQ3:()=>Et.s,AL3:()=>At.A,S0v:()=>Mt.S,WVs:()=>$t.W,TN_:()=>Dt,wzB:()=>Ot,nGf:()=>Bt,LGj:()=>Ct.L,w6H:()=>Vt.w,kwC:()=>Rt.k,M25:()=>zt.M,UYe:()=>Pt.U,btT:()=>Lt.b,XLQ:()=>Y.X,GYS:()=>Wt.G,SDf:()=>Ht,diP:()=>qt,sx7:()=>Gt,mG2:()=>Ut,QEs:()=>pn.Q,NMM:()=>jt.N,bp0:()=>Kt.b,iD$:()=>Xt.i,snQ:()=>qn.s,U8D:()=>Zt.U,U_I:()=>Jt,ODp:()=>Qt.O,XD2:()=>S.X,Xxe:()=>Yt.X,tdS:()=>Lr,O$l:()=>en.O,R_K:()=>tn.R,tPi:()=>I.t,jZU:()=>nn,SmN:()=>rn,CnO:()=>an,p0P:()=>sn,XAC:()=>on.X,Wvh:()=>Le.W,fBT:()=>Tt.f,rVs:()=>Gr,ers:()=>Gn.e,uN7:()=>Pr,Vl2:()=>dn.V,_b3:()=>hn._,h62:()=>dt.h,$i:()=>mn.$,L9e:()=>fn.L,knu:()=>gn.k,Nbs:()=>yn.N,NXj:()=>bn.N,Z_8:()=>Ur,luU:()=>Ue.l,Smz:()=>je.S,ORZ:()=>kn.O,AEp:()=>T.A,XeE:()=>wn.X,RRF:()=>vn.R,odF:()=>Nn,wOQ:()=>Sn.w,yXz:()=>In,Bfx:()=>Tn,xZs:()=>_n,Gg6:()=>we.G,hg7:()=>En.h,p4s:()=>zn.p,Xu6:()=>An.X,Two:()=>Mn.T,pUJ:()=>$n,HHK:()=>Dn.H,VD$:()=>Fn,arb:()=>On.a,itS:()=>Bn.i,lls:()=>Cn.l,P84:()=>Vn.P});var r=n(6235),a=n(7839),s=n(1470),o=n(6407),i=n(3135),u=n(781),l=n(2998),c=n(47),p=n(7394),d=n(2421),h=n(1891),m=n(7037),f=n(9812),g=n(369),y=n(5176),b=n(1749),k=n(3740),w=n(6884),v=n(8687),x=n(4841),N=n(2668),S=n(625),I=n(2676),T=n(1869);const _=(0,N.op)({basicLSTMCell_:function(e,t,n,r,a,s){const i=(0,k._1)(e,"forgetBias","basicLSTMCell"),u=(0,k._1)(t,"lstmKernel","basicLSTMCell"),l=(0,k._1)(n,"lstmBias","basicLSTMCell"),c=(0,k._1)(r,"data","basicLSTMCell"),p=(0,k._1)(a,"c","basicLSTMCell"),d=(0,k._1)(s,"h","basicLSTMCell"),h=(0,w.z)([c,d],1),m=(0,v.O)(h,u),f=(0,o.I)(m,l),g=f.shape[0],y=f.shape[1]/4,b=[g,y],N=(0,I.t)(f,[0,0],b),_=(0,I.t)(f,[0,y],b),E=(0,I.t)(f,[0,2*y],b),A=(0,I.t)(f,[0,3*y],b),M=(0,o.I)((0,x.d)((0,S.X)(N),(0,T.A)(_)),(0,x.d)(p,(0,S.X)((0,o.I)(i,E))));return[M,(0,x.d)((0,T.A)(M),(0,S.X)(A))]}});var E=n(8441),A=n(7505),M=n(569);const $=(0,N.op)({batchNorm2d_:function(e,t,n,r,a,s){const o=(0,k._1)(e,"x","batchNorm"),i=(0,k._1)(t,"mean","batchNorm"),u=(0,k._1)(n,"variance","batchNorm");let l,c;return null!=a&&(l=(0,k._1)(a,"scale","batchNorm")),null!=r&&(c=(0,k._1)(r,"offset","batchNorm")),M.hu(2===o.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`)),M.hu(2===i.rank||1===i.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`)),M.hu(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=l&&M.hu(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=c&&M.hu(2===c.rank||1===c.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`)),(0,A.t)(o,i,u,c,l,s)}});const D=(0,N.op)({batchNorm3d_:function(e,t,n,r,a,s){const o=(0,k._1)(e,"x","batchNorm"),i=(0,k._1)(t,"mean","batchNorm"),u=(0,k._1)(n,"variance","batchNorm");let l,c;return null!=a&&(l=(0,k._1)(a,"scale","batchNorm")),null!=r&&(c=(0,k._1)(r,"offset","batchNorm")),M.hu(3===o.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`)),M.hu(3===i.rank||1===i.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`)),M.hu(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=l&&M.hu(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=c&&M.hu(3===c.rank||1===c.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`)),(0,A.t)(o,i,u,c,l,s)}});const F=(0,N.op)({batchNorm4d_:function(e,t,n,r,a,s){const o=(0,k._1)(e,"x","batchNorm"),i=(0,k._1)(t,"mean","batchNorm"),u=(0,k._1)(n,"variance","batchNorm");let l,c;return null!=a&&(l=(0,k._1)(a,"scale","batchNorm")),null!=r&&(c=(0,k._1)(r,"offset","batchNorm")),M.hu(4===o.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`)),M.hu(4===i.rank||1===i.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`)),M.hu(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=l&&M.hu(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=c&&M.hu(4===c.rank||1===c.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`)),(0,A.t)(o,i,u,c,l,s)}});var O=n(3865),B=n(8194),C=n(8247),V=n(2657),R=n(2271),z=n(6825),P=n(2279),L=n(8723),W=n(1661);const H=(0,N.op)({concat1d_:function(e){return(0,w.z)(e,0)}});const q=(0,N.op)({concat2d_:function(e,t){return(0,w.z)(e,t)}});const G=(0,N.op)({concat3d_:function(e,t){return(0,w.z)(e,t)}});const U=(0,N.op)({concat4d_:function(e,t){return(0,w.z)(e,t)}});var j=n(1355),K=n(4794),X=n(1405),Z=n(473),J=n(7097),Q=n(9121),Y=n(4968);const ee=(0,N.op)({conv3DBackpropInput_:function(e,t,n,r,a){M.hu(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let s=e,o=t,i=!1;4===t.rank&&(i=!0,o=(0,Y.X)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),s=[1,e[0],e[1],e[2],e[3]]);const u=s[4],l=o.shape[4];M.hu(5===s.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${s.length}.`)),M.hu(5===o.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${o.rank}`)),M.hu(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),M.hu(u===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[3]}.`)),M.hu(l===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${n.shape[4]}.`));const c={dy:o,filter:n},p={pad:a,strides:r,inputShape:s},d=J.BV.runKernel(Q.ik,c,p);return i?(0,Y.X)(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}});const te=(0,N.op)({conv3dTranspose_:function(e,t,n,r,a){const s=(0,k._1)(e,"x","conv3dTranspose"),o=(0,k._1)(t,"filter","conv3dTranspose");return ee(n,s,o,r,a)}});var ne=n(173),re=n(2699),ae=n(7405),se=n(5746),oe=n(9112),ie=n(4718);const ue=(0,N.op)({diag_:function(e){const t={x:(0,k._1)(e,"x","diag")};return J.BV.runKernel(Q.$w,t)}});var le=n(557),ce=n(1274),pe=n(9322);const de=(0,N.op)({dot_:function(e,t){const n=(0,k._1)(e,"t1","dot"),r=(0,k._1)(t,"t2","dot");M.hu(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`));const a=1===n.rank?n.size:n.shape[1],s=1===r.rank?r.size:r.shape[0];if(M.hu(a===s,(()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${s}.`)),1===n.rank&&1===r.rank){const e=(0,Y.X)(n,[1,-1]),t=(0,Y.X)(r,[-1,1]),a=(0,v.O)(e,t);return(0,Y.X)(a,[])}if(1===n.rank&&2===r.rank){const e=(0,Y.X)(n,[1,-1]),t=(0,Y.X)(r,[r.shape[0],r.shape[1]]),a=(0,v.O)(e,t);return(0,Y.X)(a,[a.size])}if(2===n.rank&&1===r.rank){const e=(0,Y.X)(r,[-1,1]),t=(0,v.O)(n,e);return(0,Y.X)(t,[t.size])}{const e=(0,Y.X)(r,[r.shape[0],r.shape[1]]);return(0,v.O)(n,e)}}});var he=n(4653),me=n(3233),fe=n(6477),ge=n(4650),ye=n(4842),be=n(1300),ke=n(3426),we=n(7501);const ve=(0,N.op)({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=(0,V.f)([e,t],r),s=e<=t?e:t;for(let e=0;e({value:(0,Pe.W)((0,Le.W)((0,Pe.W)(e))),gradFunc:t=>(0,x.d)(t,(0,S.X)((0,Pe.W)(e)))})))(t)}});var He=n(1510),qe=n(3591),Ge=n(3307),Ue=n(827),je=n(5475);const Ke=(0,N.op)({logSumExp_:function(e,t=null,n=!1){const r=(0,k._1)(e,"x","logSumExp"),a=(0,M.EC)(t,r.shape),s=(0,Ge.F)(r,a,!0),i=(0,Ue.l)(r,s),u=(0,ye.Q)(i),l=(0,je.S)(u,a),c=(0,Ve.c)(l),p=(0,o.I)((0,Y.X)(s,c.shape),c);if(n){const e=(0,qe.rv)(p.shape,a);return(0,Y.X)(p,e)}return p}});var Xe=n(2856),Ze=n(8651),Je=n(5750),Qe=n(2200);const Ye=(0,N.op)({logicalXor_:function(e,t){const n=(0,k._1)(e,"a","logicalXor","bool"),r=(0,k._1)(t,"b","logicalXor","bool");return(0,Qe.$N)(n.shape,r.shape),(0,Xe.H)((0,Je.K)(e,t),(0,Ze.h)((0,Xe.H)(e,t)))}});var et=n(1174),tt=n(5020),nt=n(6877),rt=n(632),at=n(5130),st=n(4917),ot=n(4077);function it(e,t,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===e)return[];let r=(0,k._1)(e,"x","meshgrid",e instanceof ot.es?e.dtype:"float32");if(void 0===t)return[r];let a=(0,k._1)(t,"y","meshgrid",t instanceof ot.es?t.dtype:"float32");const s=(0,M.NA)(r.shape),o=(0,M.NA)(a.shape);return"xy"===n?(r=(0,Y.X)(r,[1,-1]),a=(0,Y.X)(a,[-1,1]),[(0,v.O)((0,st.i)([o,1],r.dtype),r),(0,v.O)(a,(0,st.i)([1,s],a.dtype))]):(r=(0,Y.X)(r,[-1,1]),a=(0,Y.X)(a,[1,-1]),[(0,v.O)(r,(0,st.i)([1,o],r.dtype)),(0,v.O)((0,st.i)([s,1],a.dtype),a)])}var ut=n(5735),lt=n(4513),ct=n(1483),pt=n(5228),dt=n(248);const ht=(0,N.op)({moments_:function(e,t=null,n=!1){e=(0,k._1)(e,"x","moments");const r=(0,M.EC)(t,e.shape),a=(0,at.J)(e,r,n);let s=a.shape;n||(s=(0,qe.rv)(a.shape,r));const o=(0,dt.h)((0,Ue.l)((0,R.p)(e,"float32"),(0,Y.X)(a,s)));return{mean:a,variance:(0,at.J)(o,r,n)}}});const mt=(0,N.op)({multiRNNCell_:function(e,t,n,r){const a=(0,k._1)(t,"data","multiRNNCell"),s=(0,k.sI)(n,"c","multiRNNCell"),o=(0,k.sI)(r,"h","multiRNNCell");let i=a;const u=[];for(let t=0;t`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`));const a=(0,Y.X)(n,[-1,1]),s=(0,Y.X)(r,[1,-1]);return(0,v.O)(a,s)}});var wt=n(9682);const vt=(0,N.op)({pad1d_:function(e,t,n=0){return(0,M.hu)(2===t.length,(()=>"Invalid number of paddings. Must be length of 2.")),(0,wt.v)(e,[t],n)}});const xt=(0,N.op)({pad2d_:function(e,t,n=0){return(0,M.hu)(2===t.length&&2===t[0].length&&2===t[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),(0,wt.v)(e,t,n)}});const Nt=(0,N.op)({pad3d_:function(e,t,n=0){return(0,M.hu)(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),(0,wt.v)(e,t,n)}});const St=(0,N.op)({pad4d_:function(e,t,n=0){return(0,M.hu)(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),(0,wt.v)(e,t,n)}});var It=n(2582),Tt=n(7918);const _t=(0,N.op)({pool_:function(e,t,n,r,a,s){null==a&&(a=[1,1]),null==s&&(s=1),0===r&&(r="valid");const o=(0,k._1)(e,"x","maxPool");let i=o,u=!1;3===o.rank&&(u=!0,i=(0,Y.X)(o,[1,o.shape[0],o.shape[1],o.shape[2]])),M.hu(It.jT(s,a),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${s} and dilations '${a}'`));const l=It.Xw(i.shape,t,s,a,r),c=[l.dilationHeight,l.dilationWidth];let p;p="same"===r?function(e,t){const n=e.map(((e,n)=>e+(e-1)*(t[n]-1))).map((e=>e-1)),r=n.map((e=>Math.floor(e/2))),a=n.map(((e,t)=>e-r[t]));return n.map(((e,t)=>[r[t],a[t]]))}([l.filterHeight,l.filterWidth],c):[[0,0],[0,0]];const d=1===c[0]&&1===c[1],[h,m]=function(e,t,n){const r=n.map((e=>e[0])),a=n.map((e=>e[1])),s=e.concat(r,a),o=t.map(((e,t)=>(e-s[t]%e)%e)),i=a.map(((e,t)=>e+o[t])),u=t.map(((e,t)=>[r[t],i[t]])),l=t.map(((e,t)=>[0,o[t]]));return[u,l]}([l.inHeight,l.inWidth],c,p),f=d?r:"valid",g=d?i:(0,Tt.f)(i,c,h),b=("avg"===n?()=>(0,y.w)(g,t,s,f):()=>(0,et._)(g,t,s,f))(),w=d?b:(0,E.E)(b,c,m);return u?(0,Y.X)(w,[w.shape[1],w.shape[2],w.shape[3]]):w}});var Et=n(3453),At=n(8151),Mt=n(9798),$t=n(9451);const Dt=(0,N.op)({rand_:function(e,t,n){const r=(0,M.NA)(e);let a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);a=new Uint8Array(r)}for(let e=0;e`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)),(0,Wt.G)(t,0)}});const qt=(0,N.op)({reverse2d_:function(e,t){const n=(0,k._1)(e,"x","reverse");return M.hu(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),(0,Wt.G)(n,t)}});const Gt=(0,N.op)({reverse3d_:function(e,t){const n=(0,k._1)(e,"x","reverse");return M.hu(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),(0,Wt.G)(n,t)}});const Ut=(0,N.op)({reverse4d_:function(e,t){const n=(0,k._1)(e,"x","reverse");return M.hu(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),(0,Wt.G)(n,t)}});var jt=n(7809),Kt=n(2634),Xt=n(9494),Zt=n(5503);const Jt=(0,N.op)({separableConv2d_:function(e,t,n,r,a,s=[1,1],o="NHWC"){const i=(0,k._1)(e,"x","separableConv2d"),u=(0,k._1)(t,"depthwiseFilter","separableConv2d"),l=(0,k._1)(n,"pointwiseFilter","separableConv2d");let c=i,p=!1;if(3===i.rank&&(p=!0,c=(0,Y.X)(i,[1,i.shape[0],i.shape[1],i.shape[2]])),"NCHW"===o)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");M.hu(4===c.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`)),M.hu(4===u.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${u.rank}.`)),M.hu(4===l.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${u.rank}.`)),M.hu(1===l.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`)),M.hu(1===l.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`));const d=u.shape[2],h=u.shape[3];M.hu(l.shape[2]===d*h,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*h}, but got ${l.shape[2]}.`));const m=(0,ie.B)(c,u,r,a,o,s),f=(0,K.T)(m,l,1,"valid",o);return p?(0,Y.X)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});var Qt=n(6567),Yt=n(4434),en=n(9331),tn=n(3254);const nn=(0,N.op)({slice1d_:function(e,t,n){const r=(0,k._1)(e,"x","slice1d");return M.hu(1===r.rank,(()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)),(0,I.t)(r,[t],[n])}});const rn=(0,N.op)({slice2d_:function(e,t,n){const r=(0,k._1)(e,"x","slice2d");return M.hu(2===r.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)),(0,I.t)(r,t,n)}});const an=(0,N.op)({slice3d_:function(e,t,n){const r=(0,k._1)(e,"x","slice3d");return M.hu(3===r.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)),(0,I.t)(r,t,n)}});const sn=(0,N.op)({slice4d_:function(e,t,n){const r=(0,k._1)(e,"x","slice4d");return M.hu(4===r.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)),(0,I.t)(r,t,n)}});var on=n(682),un=n(7020),ln=n(8447),cn=n(4415),pn=n(3710),dn=n(8644),hn=n(3261),mn=n(5265),fn=n(9590),gn=n(2991),yn=n(1901),bn=n(5158),kn=n(1173),wn=n(701),vn=n(6092),xn=n(7852);function Nn(e,t,n){if((0,M.Cq)(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=(0,k.C)(e,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return(0,xn.H)(e,t,r,n)}var Sn=n(9906);function In(e,t,n){if((0,M.Cq)(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=(0,k.C)(e,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return(0,xn.H)(e,t,r,n)}function Tn(e,t,n){if((0,M.Cq)(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=(0,k.C)(e,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return(0,xn.H)(e,t,r,n)}function _n(e,t,n){if((0,M.Cq)(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=(0,k.C)(e,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return t=t||r,(0,xn.H)(e,t,r,n)}var En=n(3243),An=n(3596),Mn=n(9608);const $n=(0,N.op)({unsortedSegmentSum_:function(e,t,n){const r=(0,k._1)(e,"x","unsortedSegmentSum"),a=(0,k._1)(t,"segmentIds","unsortedSegmentSum","int32");(0,M.hu)((0,M.GN)(n),(()=>"numSegments must be of dtype int"));const s={x:r,segmentIds:a},o={numSegments:n};return J.BV.runKernel(Q.Qv,s,o)}});var Dn=n(4136);function Fn(e,t=!0,n,r){return J.BV.makeVariable(e,t,n,r)}var On=n(5912),Bn=n(6380),Cn=n(9640),Vn=n(6577);const Rn=async function(e,t,n){const r=(0,k._1)(e,"tensor","boolMask"),a=(0,k._1)(t,"mask","boolMask","bool"),s=null==n?0:n,o=a.rank,i=r.shape;M.hu(o>0,(()=>"mask cannot be scalar")),M.k5(i.slice(s,s+o),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let e=s;e"Shape mismatch in v and x"));const l=(0,Xt.i)(1),c=(0,Ue.l)(l,u);let p=(0,x.d)((0,Ue.l)(i,s),c);if(a){M.hu(null!=r,(()=>"When using zeroDebias: true, step is required."));const e=(0,k._1)(r,"step","movingAverage");p=(0,ce.h)(p,(0,Ue.l)(l,(0,Et.s)(u,e)))}return(0,o.I)(s,p)}});var qn=n(3100),Gn=n(9758),Un=n(7494);const jn=(0,N.op)({dropout_:function(e,t,n,r){const a=(0,k._1)(e,"x","dropout");if(M.hu("float32"===a.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`)),M.hu(t>=0&&t<1,(()=>`rate must be a float in the range [0, 1), but got ${t}.`)),0===t)return e instanceof ot.es?a.clone():a;const s=function(e,t){if(null==t)return e.shape.slice();if(M.cO(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)),(0,M.hu)(r.rank-1===a.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`)),(0,M.k5)(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const s=r.shape[r.shape.length-1];(0,M.hu)(n>0&&n<=s,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${s}), but got ${n}`));const o=await r.data(),i=await a.data(),[u,l]=[o.length/s,s],c=(0,M.WP)("bool",u);for(let e=0;et.value-e.value)),c[e]=0;for(let t=0;t`Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`)),M.hu(2===i.rank&&4===i.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${i.shape}.`)),M.hu(1===u.rank&&u.shape[0]===l,(()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${i.shape}.`)),M.hu(2===r.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)),M.hu(r[0]>=1&&r[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${r}`)),M.hu("bilinear"===a||"nearest"===a,(()=>`method must be bilinear or nearest, but was ${a}`));const c={image:o,boxes:i,boxInd:u},p={method:a,extrapolationValue:s,cropSize:r};return J.BV.runKernel(Q.Vc,c,p)}});const rr=(0,N.op)({flipLeftRight_:function(e){const t=(0,k._1)(e,"image","flipLeftRight","float32");M.hu(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return J.BV.runKernel(Q.Uy,n,{})}});const ar=(0,N.op)({grayscaleToRGB_:function(e){const t=(0,k._1)(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];M.hu(t.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)),M.hu(1===r,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`));const a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,(0,we.G)(t,a)}});const sr=(0,N.op)({rotateWithOffset_:function(e,t,n=0,r=.5){const a=(0,k._1)(e,"image","rotateWithOffset","float32");M.hu(4===a.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`));const s={image:a},o={radians:t,fillValue:n,center:r};return J.BV.runKernel(Q.b9,s,o)}});function or(e,t,n,r,a,s){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==s&&(s=0);const o=e.shape[0];return n=Math.min(n,o),M.hu(0<=r&&r<=1,(()=>`iouThreshold must be in [0, 1], but was '${r}'`)),M.hu(2===e.rank,(()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`)),M.hu(4===e.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)),M.hu(1===t.rank,(()=>"scores must be a 1D tensor")),M.hu(t.shape[0]===o,(()=>`scores has incompatible shape with boxes. Expected ${o}, but was ${t.shape[0]}`)),M.hu(0<=s&&s<=1,(()=>`softNmsSigma must be in [0, 1], but was '${s}'`)),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:s}}const ir=(0,N.op)({nonMaxSuppression_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const s=(0,k._1)(e,"boxes","nonMaxSuppression"),o=(0,k._1)(t,"scores","nonMaxSuppression"),i=or(s,o,n,r,a),u={maxOutputSize:n=i.maxOutputSize,iouThreshold:r=i.iouThreshold,scoreThreshold:a=i.scoreThreshold};return J.BV.runKernel(Q.uv,{boxes:s,scores:o},u)}});var ur=n(3337);const lr=async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const s=(0,k._1)(e,"boxes","nonMaxSuppressionAsync"),o=(0,k._1)(t,"scores","nonMaxSuppressionAsync"),i=or(s,o,n,r,a);n=i.maxOutputSize,r=i.iouThreshold,a=i.scoreThreshold;const u=await Promise.all([s.data(),o.data()]),l=u[0],c=u[1],{selectedIndices:p}=(0,ur.GP)(l,c,n,r,a);return s!==e&&s.dispose(),o!==t&&o.dispose(),(0,vn.R)(p,"int32")};const cr=(0,N.op)({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,s=0){const o=(0,k._1)(e,"boxes","nonMaxSuppression"),i=(0,k._1)(t,"scores","nonMaxSuppression"),u=or(o,i,n,r,a,s),l={boxes:o,scores:i},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:s=u.softNmsSigma},p=J.BV.runKernel(Q.W0,l,c);return{selectedIndices:p[0],selectedScores:p[1]}}});const pr=async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,s=0){const o=(0,k._1)(e,"boxes","nonMaxSuppressionAsync"),i=(0,k._1)(t,"scores","nonMaxSuppressionAsync"),u=or(o,i,n,r,a,s);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,s=u.softNmsSigma;const l=await Promise.all([o.data(),i.data()]),c=l[0],p=l[1],{selectedIndices:d,selectedScores:h}=(0,ur.pA)(c,p,n,r,a,s);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:(0,vn.R)(d,"int32"),selectedScores:(0,vn.R)(h)}};const dr=(0,N.op)({nonMaxSuppressionPadded_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,s=!1){const o=(0,k._1)(e,"boxes","nonMaxSuppression"),i=(0,k._1)(t,"scores","nonMaxSuppression"),u=or(o,i,n,r,a,null),l={boxes:o,scores:i},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:s},p=J.BV.runKernel(Q.cy,l,c);return{selectedIndices:p[0],validOutputs:p[1]}}});const hr=async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,s=!1){const o=(0,k._1)(e,"boxes","nonMaxSuppressionAsync"),i=(0,k._1)(t,"scores","nonMaxSuppressionAsync"),u=or(o,i,n,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,p=u.scoreThreshold,[d,h]=await Promise.all([o.data(),i.data()]),{selectedIndices:m,validOutputs:f}=(0,ur.qP)(d,h,l,c,p,s);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:(0,vn.R)(m,"int32"),validOutputs:(0,Xt.i)(f,"int32")}};const mr=(0,N.op)({resizeBilinear_:function(e,t,n=!1,r=!1){const a=(0,k._1)(e,"images","resizeBilinear");M.hu(3===a.rank||4===a.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`)),M.hu(2===t.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)),M.hu(!1===r||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let s=a,o=!1;3===a.rank&&(o=!0,s=(0,Y.X)(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,i={images:s},u={alignCorners:n,halfPixelCenters:r,size:t},l=J.BV.runKernel(Q._Y,i,u);return o?(0,Y.X)(l,[l.shape[1],l.shape[2],l.shape[3]]):l}});const fr=(0,N.op)({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const a=(0,k._1)(e,"images","resizeNearestNeighbor");M.hu(3===a.rank||4===a.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`)),M.hu(2===t.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)),M.hu("float32"===a.dtype||"int32"===a.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),M.hu(!1===r||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let s=a,o=!1;3===a.rank&&(o=!0,s=(0,Y.X)(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,i={images:s},u={alignCorners:n,halfPixelCenters:r,size:t},l=J.BV.runKernel(Q.dp,i,u);return o?(0,Y.X)(l,[l.shape[1],l.shape[2],l.shape[3]]):l}});const gr=(0,N.op)({threshold_:function(e,t="binary",n=!1,r=.5){const a=(0,k._1)(e,"image","threshold"),s=a.shape[0]*a.shape[1];let i,u,l,c,p=(0,x.d)((0,vn.R)([r]),255);if(M.hu(3===a.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`)),M.hu(3===a.shape[2]||1===a.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`)),M.hu("int32"===a.dtype||"float32"===a.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`)),M.hu("otsu"===t||"binary"===t,(()=>`Method must be binary or otsu, but was ${t}`)),3===a.shape[2]){[i,u,l]=(0,dn.V)(a,[1,1,1],-1);const e=(0,x.d)(i,.2989),t=(0,x.d)(u,.587),n=(0,x.d)(l,.114);c=(0,o.I)((0,o.I)(e,t),n)}else c=e;if("otsu"===t){p=function(e,t){let n,r,a,s,i,u,l=(0,vn.R)([-1]),c=(0,vn.R)([0]),p=(0,vn.R)([0]);for(let d=0;d`Error in transform: image must be rank 4,but got rank ${o.rank}.`)),M.hu(2===i.rank&&(i.shape[0]===o.shape[0]||1===i.shape[0])&&8===i.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),M.hu(null==s||2===s.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${s}.`));const u={image:o,transforms:i},l={interpolation:n,fillMode:r,fillValue:a,outputShape:s};return J.BV.runKernel(Q.wx,u,l)}});const br=(0,N.op)({bandPart_:function(e,t,n){(0,M.hu)(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),(0,M.hu)(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`));const r=(0,k._1)(e,"a","bandPart");(0,M.hu)(r.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`));const a=r.shape,[s,o]=r.shape.slice(-2);if(!(t<=s))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${s}).`);if(!(n<=o))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`);t<0&&(t=s),n<0&&(n=o);const i=(0,Y.X)((0,Vt.w)(0,s,1,"int32"),[-1,1]),u=(0,Vt.w)(0,o,1,"int32"),l=(0,Ue.l)(i,u),c=(0,Xe.H)((0,Oe.z)(l,(0,Xt.i)(+t,"int32")),(0,_e.b)(l,(0,Xt.i)(-n,"int32"))),p=(0,Cn.l)([s,o],r.dtype);return(0,Y.X)((0,gn.k)((0,Dn.H)((0,Y.X)(r,[-1,s,o])).map((e=>(0,On.a)(c,e,p)))),a)}});const kr=(0,N.op)({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,(0,M.hu)(null!=e&&e.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=e[0].shape[0];for(let t=1;t`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`))}else t=!0,e=(0,dn.V)(e,e.shape[0],0).map((e=>(0,fn.L)(e,[0])));(0,M.hu)(e.length<=e[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`));const n=[],r=e;for(let t=0;t{let e=r[t];if(t>0)for(let r=0;r{(0,M.hu)(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],r=e.shape[1];let a=ve(n),s=(0,L.d)(e);const o=Nn([[1]],[1,1]);let i=(0,L.d)(o);const u=n>=r?r:n;for(let e=0;e{const t=(0,I.t)(s,[e,e],[n-e,1]),u=Ln(t),l=(0,I.t)(s,[e,e],[1,1]),c=(0,On.a)((0,Te.p)(l,0),Nn([[-1]]),Nn([[1]])),p=(0,Ue.l)(l,(0,x.d)(c,u)),d=(0,ce.h)(t,p);i=1===d.shape[0]?(0,L.d)(o):(0,w.z)([o,(0,I.t)(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);const h=(0,Pe.W)((0,ce.h)((0,v.O)(c,p),u)),m=(0,I.t)(s,[e,0],[n-e,r]),f=(0,x.d)(h,i),g=(0,zn.p)(i);if(0===e)s=(0,Ue.l)(m,(0,v.O)(f,(0,v.O)(g,m)));else{const t=(0,Ue.l)(m,(0,v.O)(f,(0,v.O)(g,m)));s=(0,w.z)([(0,I.t)(s,[0,0],[e,r]),t],0)}const y=(0,zn.p)(f),b=(0,I.t)(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=(0,Ue.l)(b,(0,v.O)((0,v.O)(b,i),y));else{const t=(0,Ue.l)(b,(0,v.O)((0,v.O)(b,i),y));a=(0,w.z)([(0,I.t)(a,[0,0],[n,e]),t],1)}return[i,s,a]})),(0,wr.B9)([t,u,l])}return!t&&n>r&&(a=(0,I.t)(a,[0,0],[n,r]),s=(0,I.t)(s,[0,0],[r,r])),[a,s]}))}const xr=(0,N.op)({qr_:function(e,t=!1){if((0,M.hu)(e.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)),2===e.rank)return vr(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce(((e,t)=>e*t)),r=(0,Dn.H)((0,Y.X)(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],s=[];r.forEach((e=>{const[n,r]=vr(e,t);a.push(n),s.push(r)}));return[(0,Y.X)((0,gn.k)(a,0),e.shape),(0,Y.X)((0,gn.k)(s,0),e.shape)]}}});var Nr=n(9876);const Sr=(0,N.op)({computeWeightedLoss_:function(e,t,n=Nr.I.SUM_BY_NONZERO_WEIGHTS){const r=(0,k._1)(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=(0,k._1)(t,"weights","computeWeightedLoss"));const s=null==a?r:(0,x.d)(r,a);if(n===Nr.I.NONE)return s;if(n===Nr.I.SUM)return(0,je.S)(s);if(n===Nr.I.MEAN){if(null==a)return(0,at.J)(s);{const e=r.size/a.size,t=(0,ce.h)((0,je.S)(s),(0,je.S)(a));return e>1?(0,ce.h)(t,(0,Xt.i)(e)):t}}if(n===Nr.I.SUM_BY_NONZERO_WEIGHTS){if(null==a)return(0,ce.h)((0,je.S)(s),(0,Xt.i)(r.size));{const e=(0,x.d)(a,(0,st.i)(r.shape)),t=(0,R.p)((0,je.S)((0,gt.Q)(e,(0,Xt.i)(0))),"float32");return(0,ce.h)((0,je.S)(s),t)}}throw Error(`Unknown reduction: ${n}`)}});const Ir=(0,N.op)({absoluteDifference_:function(e,t,n,a=Nr.I.SUM_BY_NONZERO_WEIGHTS){const s=(0,k._1)(e,"labels","absoluteDifference"),o=(0,k._1)(t,"predictions","absoluteDifference");let i=null;null!=n&&(i=(0,k._1)(n,"weights","absoluteDifference")),(0,M.k5)(s.shape,o.shape,"Error in absoluteDifference: ");const u=(0,r.W)((0,Ue.l)(s,o));return Sr(u,i,a)}});const Tr=(0,N.op)({cosineDistance_:function(e,t,n,r,a=Nr.I.SUM_BY_NONZERO_WEIGHTS){const s=(0,k._1)(e,"labels","cosineDistance"),o=(0,k._1)(t,"predictions","cosineDistance");let i=null;null!=r&&(i=(0,k._1)(r,"weights","cosineDistance")),(0,M.k5)(s.shape,o.shape,"Error in cosineDistance: ");const u=(0,Xt.i)(1),l=(0,Ue.l)(u,(0,je.S)((0,x.d)(s,o),n,!0));return Sr(l,i,a)}});const _r=(0,N.op)({hingeLoss_:function(e,t,n,r=Nr.I.SUM_BY_NONZERO_WEIGHTS){let a=(0,k._1)(e,"labels","hingeLoss");const s=(0,k._1)(t,"predictions","hingeLoss");let o=null;null!=n&&(o=(0,k._1)(n,"weights","hingeLoss")),(0,M.k5)(a.shape,s.shape,"Error in hingeLoss: ");const i=(0,Xt.i)(1);a=(0,Ue.l)((0,x.d)((0,Xt.i)(2),a),i);const u=(0,Pt.U)((0,Ue.l)(i,(0,x.d)(a,s)));return Sr(u,o,r)}});const Er=(0,N.op)({huberLoss_:function(e,t,n,a=1,s=Nr.I.SUM_BY_NONZERO_WEIGHTS){const i=(0,k._1)(e,"labels","huberLoss"),u=(0,k._1)(t,"predictions","huberLoss");let l=null;null!=n&&(l=(0,k._1)(n,"weights","huberLoss")),(0,M.k5)(i.shape,u.shape,"Error in huberLoss: ");const c=(0,Xt.i)(a),p=(0,r.W)((0,Ue.l)(u,i)),d=(0,lt.L)(p,c),h=(0,Ue.l)(p,d),m=(0,o.I)((0,x.d)((0,Xt.i)(.5),(0,dt.h)(d)),(0,x.d)(c,h));return Sr(m,l,s)}});const Ar=(0,N.op)({logLoss_:function(e,t,n,r=1e-7,a=Nr.I.SUM_BY_NONZERO_WEIGHTS){const s=(0,k._1)(e,"labels","logLoss"),i=(0,k._1)(t,"predictions","logLoss");let u=null;null!=n&&(u=(0,k._1)(n,"weights","logLoss")),(0,M.k5)(s.shape,i.shape,"Error in logLoss: ");const l=(0,Xt.i)(1),c=(0,Xt.i)(r),p=(0,Pe.W)((0,x.d)(s,(0,Ve.c)((0,o.I)(i,c)))),d=(0,x.d)((0,Ue.l)(l,s),(0,Ve.c)((0,o.I)((0,Ue.l)(l,i),c))),h=(0,Ue.l)(p,d);return Sr(h,u,a)}});const Mr=(0,N.op)({meanSquaredError_:function(e,t,n,r=Nr.I.SUM_BY_NONZERO_WEIGHTS){const a=(0,k._1)(e,"labels","meanSquaredError"),s=(0,k._1)(t,"predictions","meanSquaredError");let o=null;null!=n&&(o=(0,k._1)(n,"weights","meanSquaredError")),(0,M.k5)(a.shape,s.shape,"Error in meanSquaredError: ");const i=(0,mn.$)(a,s);return Sr(i,o,r)}});const $r=(0,N.op)({sigmoidCrossEntropy_:function(e,t,n,a=0,s=Nr.I.SUM_BY_NONZERO_WEIGHTS){let i=(0,k._1)(e,"multiClassLabels","sigmoidCrossEntropy");const u=(0,k._1)(t,"logits","sigmoidCrossEntropy");let l=null;if(null!=n&&(l=(0,k._1)(n,"weights","sigmoidCrossEntropy")),(0,M.k5)(i.shape,u.shape,"Error in sigmoidCrossEntropy: "),a>0){const e=(0,Xt.i)(a),t=(0,Xt.i)(1),n=(0,Xt.i)(.5);i=(0,o.I)((0,x.d)(i,(0,Ue.l)(t,e)),(0,x.d)(n,e))}const c=function(e,t){const n=(0,k._1)(e,"labels","sigmoidCrossEntropyWithLogits"),a=(0,k._1)(t,"logits","sigmoidCrossEntropyWithLogits");(0,M.k5)(n.shape,a.shape,"Error in sigmoidCrossEntropyWithLogits: ");const s=(0,Pt.U)(a),i=(0,x.d)(a,n),u=(0,Re.K)((0,ye.Q)((0,Pe.W)((0,r.W)(a))));return(0,o.I)((0,Ue.l)(s,i),u)}(i,u);return Sr(c,l,s)}});const Dr=(0,N.op)({softmaxCrossEntropy_:function(e,t,n,r=0,a=Nr.I.SUM_BY_NONZERO_WEIGHTS){let s=(0,k._1)(e,"onehotLabels","softmaxCrossEntropy");const i=(0,k._1)(t,"logits","softmaxCrossEntropy");let u=null;if(null!=n&&(u=(0,k._1)(n,"weights","softmaxCrossEntropy")),(0,M.k5)(s.shape,i.shape,"Error in softmaxCrossEntropy: "),r>0){const e=(0,Xt.i)(r),t=(0,Xt.i)(1),n=(0,Xt.i)(s.shape[1]);s=(0,o.I)((0,x.d)(s,(0,Ue.l)(t,e)),(0,ce.h)(e,n))}const l=function(e,t,n=-1){if(-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`);return(0,ze.cb)(((e,t,r)=>{const a=Ke(t,[n],!0),s=(0,Ue.l)((0,R.p)(t,"float32"),a);r([e,s]);const o=(0,Pe.W)((0,x.d)(s,e));return{value:(0,je.S)(o,[n]),gradFunc:(e,t)=>{const[r,a]=t,s=(0,qe.rv)(e.shape,[n]);return[(0,x.d)((0,Y.X)(e,s),(0,Ue.l)((0,R.p)(r,"float32"),(0,ye.Q)(a))),(0,x.d)((0,Y.X)(e,s),(0,Ue.l)((0,ye.Q)(a),(0,R.p)(r,"float32")))]}}}))(e,t)}(s,i);return Sr(l,u,a)}});const Fr=(0,N.op)({sparseFillEmptyRows_:function(e,t,n,r){const a=(0,k._1)(e,"indices","sparseFillEmptyRows"),s=(0,k._1)(t,"values","sparseFillEmptyRows"),o=(0,k._1)(n,"denseShape","sparseFillEmptyRows"),i=(0,k._1)(r,"defaultValue","sparseFillEmptyRows",s.dtype);if(2!==a.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${a.shape}`);if(1!==s.rank)throw new Error(`Values should be Tensor1D but received shape ${s.shape}`);if(1!==o.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${o.shape}`);if(0!==i.rank)throw new Error(`Default value should be a scalar but received shape ${i.shape}`);const u={indices:a,values:s,denseShape:o,defaultValue:i},l=J.BV.runKernel(Q.O3,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}});const Or=(0,N.op)({sparseReshape_:function(e,t,n){const r=(0,k._1)(e,"inputIndices","sparseReshape"),a=(0,k._1)(t,"inputShape","sparseReshape"),s=(0,k._1)(n,"newShape","sparseReshape");if(2!==r.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`);if(1!==a.rank)throw new Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==s.rank)throw new Error(`New shape should be Tensor1D but received shape ${s.shape}`);const o={inputIndices:r,inputShape:a,newShape:s},i=J.BV.runKernel(Q.nh,o);return{outputIndices:i[0],outputShape:i[1]}}});const Br=(0,N.op)({sparseSegmentMean_:function(e,t,n){const r=(0,k._1)(e,"data","sparseSegmentMean"),a=(0,k._1)(t,"indices","sparseSegmentMean"),s=(0,k._1)(n,"segmentIds","sparseSegmentMean");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==s.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${s.shape}`);const o={data:r,indices:a,segmentIds:s};return J.BV.runKernel(Q.YW,o)}});const Cr=(0,N.op)({sparseSegmentSum_:function(e,t,n){const r=(0,k._1)(e,"data","sparseSegmentSum"),a=(0,k._1)(t,"indices","sparseSegmentSum"),s=(0,k._1)(n,"segmentIds","sparseSegmentSum");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==s.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${s.shape}`);const o={data:r,indices:a,segmentIds:s};return J.BV.runKernel(Q.Zj,o)}});const Vr=(0,N.op)({stringNGrams_:function(e,t,n,r,a,s,o,i){const u=(0,k._1)(e,"data","stringNGrams","string");if("string"!==u.dtype)throw new Error("Data must be of datatype string");if(1!==u.shape.length)throw new Error(`Data must be a vector, saw: ${u.shape}`);const l=(0,k._1)(t,"dataSplits","stringNGrams");if("int32"!==l.dtype)throw new Error("Data splits must be of datatype int32");const c={separator:n,nGramWidths:r,leftPad:a,rightPad:s,padWidth:o,preserveShortSequences:i},p={data:u,dataSplits:l},d=J.BV.runKernel(Q._J,p,c);return{nGrams:d[0],nGramsSplits:d[1]}}});const Rr=(0,N.op)({stringSplit_:function(e,t,n=!0){const r=(0,k._1)(e,"input","stringSplit","string"),a=(0,k._1)(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(0!==a.rank)throw new Error(`Delimiter should be a scalar but received shape ${a.shape}`);const s={skipEmpty:n},o={input:r,delimiter:a},i=J.BV.runKernel(Q.s1,o,s);return{indices:i[0],values:i[1],shape:i[2]}}});const zr=(0,N.op)({stringToHashBucketFast_:function(e,t){const n=(0,k._1)(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");const a={input:n};return J.BV.runKernel(Q.Xk,a,r)}}),Pr={fft:un.k,ifft:ln.S,rfft:pn.Q,irfft:cn.w},Lr={hammingWindow:Qn,hannWindow:Yn,frame:er,stft:tr},Wr={flipLeftRight:rr,grayscaleToRGB:ar,resizeNearestNeighbor:fr,resizeBilinear:mr,rotateWithOffset:sr,cropAndResize:nr,nonMaxSuppression:ir,nonMaxSuppressionAsync:lr,nonMaxSuppressionWithScore:cr,nonMaxSuppressionWithScoreAsync:pr,nonMaxSuppressionPadded:dr,nonMaxSuppressionPaddedAsync:hr,threshold:gr,transform:yr},Hr={bandPart:br,gramSchmidt:kr,qr:xr},qr={absoluteDifference:Ir,computeWeightedLoss:Sr,cosineDistance:Tr,hingeLoss:_r,huberLoss:Er,logLoss:Ar,meanSquaredError:Mr,sigmoidCrossEntropy:$r,softmaxCrossEntropy:Dr},Gr={sparseFillEmptyRows:Fr,sparseReshape:Or,sparseSegmentMean:Br,sparseSegmentSum:Cr},Ur={stringNGrams:Vr,stringSplit:Rr,stringToHashBucketFast:zr}},9682:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({pad_:function(e,t,n=0){const o=(0,s._1)(e,"x","pad");if(0===o.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const i={paddings:t,constantValue:n},u={x:o};return r.BV.runKernel(a.ly,u,i)}})},3453:(e,t,n)=>{"use strict";n.d(t,{s:()=>i});var r=n(7097),a=n(9121),s=n(747),o=n(3740);const i=(0,n(2668).op)({pow_:function(e,t){let n=(0,o._1)(e,"base","pow"),i=(0,o._1)(t,"exp","pow");[n,i]=(0,s.makeTypesMatch)(n,i);const u={a:n,b:i};return r.BV.runKernel(a.pe,u)}})},8151:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({prelu_:function(e,t){const n={x:(0,s._1)(e,"x","prelu"),alpha:(0,s._1)(t,"alpha","prelu")};return r.BV.runKernel(a.o0,n)}})},9798:(e,t,n)=>{"use strict";function r(e,t=!1){console.log(e.toString(t))}n.d(t,{S:()=>r})},9451:(e,t,n)=>{"use strict";n.d(t,{W:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(2271);const i=(0,n(2668).op)({prod_:function(e,t=null,n=!1){let i=(0,s._1)(e,"x","prod");"bool"===i.dtype&&(i=(0,o.p)(i,"int32"));const u={x:i},l={axis:t,keepDims:n};return r.BV.runKernel(a.Dl,u,l)}})},6845:(e,t,n)=>{"use strict";n.d(t,{Yi:()=>a,T9:()=>s,wv:()=>o});var r=n(6377);class a{constructor(e,t,n,a,s){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=a,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);const o=s||Math.random();this.random=r.alea(o.toString())}nextValue(){if(!isNaN(this.nextVal)){const e=this.nextVal;return this.nextVal=NaN,e}let e,t,n=!1;for(;!n;){let r,a,s;do{r=2*this.random()-1,a=2*this.random()-1,s=r*r+a*a}while(s>=1||0===s);const o=Math.sqrt(-2*Math.log(s)/s);e=this.mean+this.stdDev*r*o,t=this.mean+this.stdDev*a*o,this.truncated&&!this.isValidTruncated(e)||(n=!0)}return this.truncated&&!this.isValidTruncated(t)||(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class s{constructor(e,t,n,s){this.alpha=e,this.beta=1/t,this.dtype=n;const o=s||Math.random();this.randu=r.alea(o.toString()),this.randn=new a(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,r,a,s;for(;;){do{r=this.randn.nextValue(),s=1+this.c*r}while(s<=0);if(s*=s*s,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-s+Math.log(s)),a=this.randu(),anull==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=n,null==a&&(a=Math.random()),"number"==typeof a&&(a=a.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=r.alea(a)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}},5002:(e,t,n)=>{"use strict";n.d(t,{L:()=>o});var r=n(2657),a=n(2668),s=n(6845);const o=(0,a.op)({randomUniform_:function(e,t=0,n=1,a="float32",o){const i=(0,r.f)(e,a),u=new s.wv(t,n,null,o);for(let e=0;e{"use strict";n.d(t,{w:()=>s});var r=n(7097),a=n(9121);function s(e,t,n=1,s="float32"){if(0===n)throw new Error("Cannot have a step of zero");const o={start:e,stop:t,step:n,dtype:s};return r.BV.runKernel(a.e6,{},o)}},766:(e,t,n)=>{"use strict";n.d(t,{k:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({real_:function(e){const t={input:(0,s._1)(e,"input","real")};return r.BV.runKernel(a.xJ,t)}})},9036:(e,t,n)=>{"use strict";n.d(t,{M:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({reciprocal_:function(e){const t={x:(0,s._1)(e,"x","reciprocal")};return r.BV.runKernel(a.$H,t)}})},7409:(e,t,n)=>{"use strict";n.d(t,{U:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({relu_:function(e){const t={x:(0,s._1)(e,"x","relu")};return r.BV.runKernel(a.qk,t)}})},3582:(e,t,n)=>{"use strict";n.d(t,{b:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({relu6_:function(e){const t={x:(0,s._1)(e,"x","relu6")};return r.BV.runKernel(a.Sb,t)}})},4968:(e,t,n)=>{"use strict";n.d(t,{X:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({reshape_:function(e,t){const n={x:(0,s._1)(e,"x","reshape","string_or_numeric")},o={shape:t};return r.BV.runKernel(a.HZ,n,o)}})},7486:(e,t,n)=>{"use strict";n.d(t,{G:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({reverse_:function(e,t){const n={x:(0,s._1)(e,"x","reverse")},o={dims:t};return r.BV.runKernel(a.mK,n,o)}})},7809:(e,t,n)=>{"use strict";n.d(t,{N:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({round_:function(e){const t={x:(0,s._1)(e,"x","round")};return r.BV.runKernel(a.e0,t)}})},2634:(e,t,n)=>{"use strict";n.d(t,{b:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({rsqrt_:function(e){const t={x:(0,s._1)(e,"x","rsqrt")};return r.BV.runKernel(a.bV,t)}})},9494:(e,t,n)=>{"use strict";n.d(t,{i:()=>s});var r=n(569),a=n(7852);function s(e,t){if(((0,r.fU)(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&(0,r.fU)(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return(0,a.H)(e,[],[],t)}},3100:(e,t,n)=>{"use strict";n.d(t,{s:()=>u});var r=n(7097),a=n(9121),s=n(3740),o=n(2668),i=n(3028);const u=(0,o.op)({scatterND_:function(e,t,n){const o=(0,s._1)(e,"indices","scatterND","int32"),u=(0,s._1)(t,"updates","scatterND");i.validateInput(u,o,n);const l={indices:o,updates:u},c={shape:n};return r.BV.runKernel(a.xQ,l,c)}})},3028:(e,t,n)=>{"use strict";n.r(t),n.d(t,{validateUpdateShape:()=>a,validateInput:()=>s,calculateShapes:()=>o});var r=n(569);function a(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,s=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${a}.`;if(n.rank1?t.shape[a-1]:1,o=n.length;let i=1;for(let e=s;e{"use strict";n.d(t,{U:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({selu_:function(e){const t={x:(0,s._1)(e,"x","selu")};return r.BV.runKernel(a.oF,t)}})},6567:(e,t,n)=>{"use strict";n.d(t,{O:()=>o});var r=n(4077),a=n(3740),s=n(569);const o=async function(e,t){const n=(0,a._1)(e,"x","setdiff1d"),o=(0,a._1)(t,"y","setdiff1d");s.hu(n.dtype===o.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${o.dtype}).`)),s.hu(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),s.hu(1===o.rank,(()=>`y should be 1D tensor, but got y (${o.shape}).`));const i=await n.data(),u=await o.data(),l=new Set(u);let c=0;for(let e=0;e{"use strict";n.d(t,{X:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({sigmoid_:function(e){const t={x:(0,s._1)(e,"x","sigmoid")};return r.BV.runKernel(a.a5,t)}})},4434:(e,t,n)=>{"use strict";n.d(t,{X:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({sign_:function(e){const t={x:(0,s._1)(e,"x","sign")};return r.BV.runKernel(a.i5,t)}})},9331:(e,t,n)=>{"use strict";n.d(t,{O:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({sin_:function(e){const t={x:(0,s._1)(e,"x","sin")};return r.BV.runKernel(a.RQ,t)}})},3254:(e,t,n)=>{"use strict";n.d(t,{R:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({sinh_:function(e){const t={x:(0,s._1)(e,"x","sinh")};return r.BV.runKernel(a.w3,t)}})},2676:(e,t,n)=>{"use strict";n.d(t,{t:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({slice_:function(e,t,n){const o=(0,s._1)(e,"x","slice","string_or_numeric");if(0===o.rank)throw new Error("Slicing scalar is not possible");const i={x:o},u={begin:t,size:n};return r.BV.runKernel(a.p2,i,u)}})},682:(e,t,n)=>{"use strict";n.d(t,{X:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({softmax_:function(e,t=-1){const n=(0,s._1)(e,"logits","softmax","float32");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${t}`);const o={logits:n},i={dim:t};return r.BV.runKernel(a.Gc,o,i)}})},3694:(e,t,n)=>{"use strict";n.d(t,{W:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({softplus_:function(e){const t={x:(0,s._1)(e,"x","softplus")};return r.BV.runKernel(a.MR,t)}})},7918:(e,t,n)=>{"use strict";n.d(t,{f:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({spaceToBatchND_:function(e,t,n){const i=(0,s._1)(e,"x","spaceToBatchND");o.hu(i.rank>=1+t.length,(()=>`input rank ${i.rank} should be > than [blockShape] ${t.length}`)),o.hu(n.length===t.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)),o.hu(i.shape.reduce(((e,r,a)=>a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e),!0),(()=>`input spatial dimensions ${i.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`));const u={x:i},l={blockShape:t,paddings:n};return r.BV.runKernel(a.TQ,u,l)}})},9758:(e,t,n)=>{"use strict";n.d(t,{e:()=>o});var r=n(7097),a=n(9121);var s=n(3740);const o=(0,n(2668).op)({sparseToDense_:function(e,t,n,o=0){const i=(0,s._1)(e,"sparseIndices","sparseToDense","int32"),u=(0,s._1)(t,"sparseValues","sparseToDense"),l=(0,s._1)(o,"defaultValue","sparseToDense",u.dtype);!function(e,t,n,r){if("int32"!==e.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${e.shape}.`);const a=e.rank>0?e.shape[0]:1,s=e.rank>1?e.shape[1]:1;if(n.length!==s)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${s}.`);const o=t.size;if(0!==t.rank&&(1!==t.rank||o!==a))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${a}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(i,u,n,l);const c={sparseIndices:i,sparseValues:u,defaultValue:l},p={outputShape:n};return r.BV.runKernel(a.D2,c,p)}})},7020:(e,t,n)=>{"use strict";n.d(t,{k:()=>o});var r=n(7097),a=n(9121),s=n(569);const o=(0,n(2668).op)({fft_:function(e){(0,s.hu)("complex64"===e.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`));const t={input:e};return r.BV.runKernel(a.vw,t)}})},8447:(e,t,n)=>{"use strict";n.d(t,{S:()=>o});var r=n(7097),a=n(9121),s=n(569);const o=(0,n(2668).op)({ifft_:function(e){(0,s.hu)("complex64"===e.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`));const t={input:e};return r.BV.runKernel(a.Qg,t)}})},4415:(e,t,n)=>{"use strict";n.d(t,{w:()=>m});var r=n(1661),a=n(6884),s=n(4386),o=n(4841),i=n(2668),u=n(766),l=n(4968),c=n(7486),p=n(9494),d=n(2676),h=n(8447);const m=(0,i.op)({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let i;if(t<=2){const r=(0,l.X)(e,[n,t]);i=(0,h.S)(r)}else{const m=[n,2*(t-1)],f=(0,l.X)((0,u.k)(e),[n,t]),g=(0,l.X)((0,s.a)(e),[n,t]),y=(0,c.G)((0,d.t)(f,[0,1],[n,t-2]),1),b=(0,o.d)((0,c.G)((0,d.t)(g,[0,1],[n,t-2]),1),(0,p.i)(-1)),k=(0,a.z)([f,y],1),w=(0,a.z)([g,b],1),v=(0,l.X)((0,r.P)(k,w),[m[0],m[1]]);i=(0,h.S)(v)}if(i=(0,u.k)(i),3===e.rank&&0!==e.shape[0]){const t=i,n=e.shape[0];i=(0,l.X)(i,[n,i.shape[0]/n,i.shape[1]]),t.dispose()}return i}})},3710:(e,t,n)=>{"use strict";n.d(t,{Q:()=>f});var r=n(569),a=n(1661),s=n(6884),o=n(4386),i=n(2668),u=n(766),l=n(4968),c=n(2676),p=n(8644),d=n(9640),h=n(6577),m=n(7020);const f=(0,i.op)({rfft_:function(e,t){(0,r.hu)("float32"===e.dtype,(()=>`The dtype for rfft() must be real value but got ${e.dtype}`));let n=e.shape[e.shape.length-1];const i=e.size/n;let f;if(null!=t&&t0)),a=e.shape.map((e=>e));a[e.shape.length-1]=t,f=(0,c.t)(e,r,a),n=t}else if(null!=t&&t>n){const r=e.shape.map((e=>e));r[e.shape.length-1]=t-n,f=(0,s.z)([e,(0,d.l)(r)],e.shape.length-1),n=t}else f=e;const g=(0,h.P)(f),y=(0,l.X)((0,a.P)(f,g),[i,n]),b=(0,m.k)(y),k=Math.floor(n/2)+1,w=(0,u.k)(b),v=(0,o.a)(b),x=(0,p.V)(w,[k,n-k],w.shape.length-1),N=(0,p.V)(v,[k,n-k],v.shape.length-1),S=f.shape.slice();return S[f.shape.length-1]=k,(0,l.X)((0,a.P)(x[0],N[0]),S)}})},8644:(e,t,n)=>{"use strict";n.d(t,{V:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({split_:function(e,t,n=0){const o={x:(0,s._1)(e,"x","split")},i={numOrSizeSplits:t,axis:n};return r.BV.runKernel(a.L8,o,i)}})},3261:(e,t,n)=>{"use strict";n.d(t,{_:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({sqrt_:function(e){const t={x:(0,s._1)(e,"x","sqrt")};return r.BV.runKernel(a.FK,t)}})},248:(e,t,n)=>{"use strict";n.d(t,{h:()=>s});var r=n(7097),a=n(3740);const s=(0,n(2668).op)({square_:function(e){const t=(0,a._1)(e,"x","square");return r.BV.runKernel("Square",{x:t},{})}})},5265:(e,t,n)=>{"use strict";n.d(t,{$:()=>u});var r=n(7097),a=n(9121),s=n(747),o=n(3740),i=n(2200);const u=(0,n(2668).op)({squaredDifference_:function(e,t){let n=(0,o._1)(e,"a","squaredDifference"),u=(0,o._1)(t,"b","squaredDifference");[n,u]=(0,s.makeTypesMatch)(n,u),(0,i.$N)(n.shape,u.shape);const l={a:n,b:u};return r.BV.runKernel(a._t,l,{})}})},9590:(e,t,n)=>{"use strict";n.d(t,{L:()=>i});var r=n(3740),a=n(569),s=n(2668),o=n(4968);const i=(0,s.op)({squeeze_:function(e,t){const n=(0,r._1)(e,"x","squeeze");return(0,o.X)(n,(0,a.bp)(n.shape,t).newShape)}})},2991:(e,t,n)=>{"use strict";n.d(t,{k:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({stack_:function(e,t=0){const n=(0,s.sI)(e,"tensors","stack","string_or_numeric");o.hu(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&o.hu(t<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const i=n,u={axis:t};return r.BV.runKernel(a.Qi,i,u)}})},1901:(e,t,n)=>{"use strict";n.d(t,{N:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({step_:function(e,t=0){const n={x:(0,s._1)(e,"x","step")},o={alpha:t};return r.BV.runKernel(a.h8,n,o)}})},5158:(e,t,n)=>{"use strict";n.d(t,{N:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({stridedSlice_:function(e,t,n,o,i=0,u=0,l=0,c=0,p=0){const d={x:(0,s._1)(e,"x","stridedSlice","string_or_numeric")},h={begin:t,end:n,strides:o,beginMask:i,endMask:u,ellipsisMask:l,newAxisMask:c,shrinkAxisMask:p};return r.BV.runKernel(a.m2,d,h)}})},827:(e,t,n)=>{"use strict";n.d(t,{l:()=>i});var r=n(7097),a=n(9121),s=n(747),o=n(3740);const i=(0,n(2668).op)({sub_:function(e,t){let n=(0,o._1)(e,"a","sub"),i=(0,o._1)(t,"b","sub");[n,i]=(0,s.makeTypesMatch)(n,i);const u={a:n,b:i};return r.BV.runKernel(a.Tr,u)}})},5475:(e,t,n)=>{"use strict";n.d(t,{S:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(2271);const i=(0,n(2668).op)({sum_:function(e,t=null,n=!1){let i=(0,s._1)(e,"x","sum");"bool"===i.dtype&&(i=(0,o.p)(i,"int32"));const u={x:i},l={axis:t,keepDims:n};return r.BV.runKernel(a.GB,u,l)}})},1173:(e,t,n)=>{"use strict";n.d(t,{O:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({tan_:function(e){const t={x:(0,s._1)(e,"x","tan")};return r.BV.runKernel(a.sE,t)}})},1869:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({tanh_:function(e){const t={x:(0,s._1)(e,"x","tanh")};return r.BV.runKernel(a.MI,t)}})},701:(e,t,n)=>{"use strict";n.d(t,{X:()=>s});var r=n(3740),a=n(7852);function s(e,t,n){const s=(0,r.C)(e,n);return(0,a.H)(e,t,s,n)}},6092:(e,t,n)=>{"use strict";n.d(t,{R:()=>o});var r=n(3740),a=n(569),s=n(7852);function o(e,t){(0,a.Cq)(e);const n=(0,r.C)(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return(0,s.H)(e,null,n,t)}},9906:(e,t,n)=>{"use strict";n.d(t,{w:()=>o});var r=n(3740),a=n(569),s=n(7852);function o(e,t,n){if((0,a.Cq)(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");const o=(0,r.C)(e,n);if(3!==o.length&&1!==o.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===o.length&&null==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return(0,s.H)(e,t,o,n)}},7852:(e,t,n)=>{"use strict";n.d(t,{H:()=>o});var r=n(7097),a=n(569),s=n(9122);function o(e,t,n,o){if(null==o&&(o=(0,a.D2)(e)),"complex64"===o)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!(0,a.fU)(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){(0,a.Mu)(t);const e=(0,a.NA)(t),r=(0,a.NA)(n);(0,a.hu)(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return(0,a.fU)(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==o?(0,s.toTypedArray)(e,o):(0,a.xH)(e,[],!0),r.BV.makeTensor(e,t,o)}},7501:(e,t,n)=>{"use strict";n.d(t,{G:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({tile_:function(e,t){const n=(0,s._1)(e,"x","tile","string_or_numeric");o.hu(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`));const i={x:n},u={reps:t};return r.BV.runKernel(a.n9,i,u)}})},3243:(e,t,n)=>{"use strict";n.d(t,{h:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({topk_:function(e,t=1,n=!0){const o=(0,s._1)(e,"x","topk");if(0===o.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const i=o.shape[o.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>i)throw new Error(`'k' passed to topk() must be <= the last dimension (${i}) but got ${t}`);const u={x:o},l={k:t,sorted:n},[c,p]=r.BV.runKernel(a.cW,u,l);return{values:c,indices:p}}})},9065:(e,t,n)=>{"use strict";n.d(t,{p:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({transpose_:function(e,t){const n=(0,s._1)(e,"x","transpose");if(null==t&&(t=n.shape.map(((e,t)=>t)).reverse()),o.hu(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`)),t.forEach((e=>{o.hu(e>=0&&e"All entries in 'perm' must be between 0 and "+(n.rank-1)+` but got ${t}`))})),n.rank<=1)return n.clone();const i={x:n},u={perm:t};return r.BV.runKernel(a.G3,i,u)}})},3596:(e,t,n)=>{"use strict";n.d(t,{X:()=>o});var r=n(2657),a=n(2668),s=n(6845);const o=(0,a.op)({truncatedNormal_:function(e,t=0,n=1,a,o){if(null!=a&&"bool"===a)throw new Error("Unsupported data type $ { dtype }");const i=new s.Yi(t,n,a,!0,o),u=(0,r.f)(e,a);for(let e=0;e{"use strict";n.d(t,{T:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({unique_:function(e,t=0){const n=(0,s._1)(e,"x","unique","string_or_numeric");(0,o.hu)(n.rank>0,(()=>"The input tensor must be at least 1D"));const i={x:n},u={axis:t},[l,c]=r.BV.runKernel(a.kp,i,u);return{values:l,indices:c}}})},4136:(e,t,n)=>{"use strict";n.d(t,{H:()=>i});var r=n(7097),a=n(9121),s=n(3740),o=n(569);const i=(0,n(2668).op)({unstack_:function(e,t=0){const n=(0,s._1)(e,"x","unstack","string_or_numeric");o.hu(t>=-n.shape.length&&t`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`));const i={value:n},u={axis:t};return r.BV.runKernel(a.To,i,u)}})},5912:(e,t,n)=>{"use strict";n.d(t,{a:()=>u});var r=n(7097),a=n(9121),s=n(3740),o=n(8247),i=n(2200);const u=(0,n(2668).op)({where_:function(e,t,n){const u=(0,s._1)(t,"a","where"),l=(0,s._1)(n,"b","where"),c=(0,s._1)(e,"condition","where","bool"),p=(0,i.$N)((0,i.$N)(c.shape,u.shape),l.shape),d={condition:(0,o.U)(c,p),t:(0,o.U)(u,p),e:(0,o.U)(l,p)};return r.BV.runKernel(a.Ph,d)}})},6380:(e,t,n)=>{"use strict";n.d(t,{i:()=>s});var r=n(8333),a=n(3740);const s=async function(e){const t=(0,a._1)(e,"condition","whereAsync","bool"),n=await t.data(),s=(0,r.Z)(t.shape,n);return e!==t&&t.dispose(),s}},9640:(e,t,n)=>{"use strict";n.d(t,{l:()=>o});var r=n(7097),a=n(569),s=n(1661);function o(e,t="float32"){if("complex64"===t){const t=o(e,"float32"),n=o(e,"float32");return(0,s.P)(t,n)}const n=(0,a.wT)((0,a.NA)(e),t);return r.BV.makeTensor(n,e,t)}},6577:(e,t,n)=>{"use strict";n.d(t,{P:()=>o});var r=n(7097),a=n(9121),s=n(3740);const o=(0,n(2668).op)({zerosLike_:function(e){const t={x:(0,s._1)(e,"x","zerosLike")};return r.BV.runKernel(a.Ru,t)}})},4077:(e,t,n)=>{"use strict";n.d(t,{es:()=>b,YD:()=>p,_w:()=>k,FZ:()=>y,Vp:()=>g,Vi:()=>f});var r=n(5938),a=n(569);function s(e,t,n,r){const s=(0,a.e3)(t),i=function(e,t,n,r){const s=(0,a.NA)(t),i=r[r.length-1],u=new Array(i).fill(0),c=t.length,p="complex64"===n?l(e):e;if(c>1)for(let e=0;e" "+e)).join("\n")),d.join("\n")}function o(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:(0,a.HD)(e)?`'${e}'`:"bool"===n?i(e):parseFloat(e.toFixed(7)).toString(),(0,a.oj)(r,t)}function i(e){return 0===e?"false":"true"}function u(e,t,n,r,a,s=!0){const c="complex64"===n?2:1,p=t[0],d=t.length;if(0===d){if("complex64"===n){return[o(l(e)[0],0,n)]}return"bool"===n?[i(e[0])]:[e[0].toString()]}if(1===d){if(p>20){const t=3*c;let r=Array.from(e.slice(0,t)),s=Array.from(e.slice((p-3)*c,p*c));return"complex64"===n&&(r=l(r),s=l(s)),["["+r.map(((e,t)=>o(e,a[t],n))).join(", ")+", ..., "+s.map(((e,t)=>o(e,a[p-3+t],n))).join(", ")+"]"]}return["["+("complex64"===n?l(e):Array.from(e)).map(((e,t)=>o(e,a[t],n))).join(", ")+"]"]}const h=t.slice(1),m=r.slice(1),f=r[0]*c,g=[];if(p>20){for(let t=0;t<3;t++){const r=t*f,s=r+f;g.push(...u(e.slice(r,s),h,n,m,a,!1))}g.push("...");for(let t=p-3;t`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===t)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=n||a.rQ(t,this.size),this.strides=(0,a.e3)(e)}set(e,...t){0===t.length&&(t=[0]),a.hu(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){const t=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(t)}t++}let n=e[e.length-1];for(let t=0;tc.decodeString(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataSync(){this.throwIfDisposed();const e=d().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>c.decodeString(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();const e=await d().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(d().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return h.print(this,e)}clone(){return this.throwIfDisposed(),h.clone(this)}toString(e=!1){return s(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),h.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),d().makeVariable(this,e,t,n)}}Object.defineProperty(b,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),(0,r.R)("Tensor",(()=>b));class k extends b{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!a.cO(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);d().disposeTensor(this),this.dataId=e.dataId,d().incRef(this,null)}dispose(){d().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(k,Symbol.hasInstance,{value:e=>e instanceof b&&null!=e.assign&&e.assign instanceof Function})},747:(e,t,n)=>{"use strict";n.r(t),n.d(t,{makeTypesMatch:()=>o,assertTypesMatch:()=>i,isTensorInList:()=>u,getTensorsInContainer:()=>l});var r=n(4077),a=n(1221),s=n(569);function o(e,t){if(e.dtype===t.dtype)return[e,t];const n=(0,a.x8)(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function i(e,t){(0,s.hu)(e.dtype===t.dtype,(()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`))}function u(e,t){return t.some((t=>t.id===e.id))}function l(e){const t=[];return c(e,t,new Set),t}function c(e,t,n){if(null==e)return;if(e instanceof r.es)return void t.push(e);if(a=e,!Array.isArray(a)&&"object"!=typeof a)return;var a;const s=e;for(const e in s){const r=s[e];n.has(r)||(n.add(r),c(r,t,n))}}},3740:(e,t,n)=>{"use strict";n.d(t,{C:()=>u,_1:()=>p,sI:()=>d});var r=n(7097),a=n(2885),s=n(4077),o=n(569),i=n(9122);function u(e,t){let n=e;if((0,o.fU)(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||(0,o.fU)(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&(0,a.OB)().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&l(e,r,[]),r}function l(e,t,n){if(n=n||[],!Array.isArray(e)&&!(0,o.fU)(e))return void(0,o.hu)(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));(0,o.hu)(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),(0,o.hu)(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t=0&&(l=a),c(a,l,t,n),null==e||!(0,o.fU)(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){const r=null==e?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const p=u(e,l);(0,o.fU)(e)||Array.isArray(e)||(e=[e]);const d="string"!==l?(0,i.toTypedArray)(e,l):(0,o.xH)(e,[],!0);return r.BV.makeTensor(d,p,l)}function d(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map(((e,a)=>p(e,`${t}[${a}]`,n,r)))}},1221:(e,t,n)=>{"use strict";var r,a,s,o,i;n.d(t,{yw:()=>r,x8:()=>l,z4:()=>c}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(r||(r={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(a||(a={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(s||(s={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(o||(o={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(i||(i={}));const u={float32:o,int32:a,bool:s,complex64:i};function l(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return u[e][t]}function c(e){return l(e,"int32")}},9122:(e,t,n)=>{"use strict";n.r(t),n.d(t,{arraysEqual:()=>a.cO,assert:()=>a.hu,assertNonNegativeIntegerDimensions:()=>a.Mu,assertNonNull:()=>a.Cq,assertShapesMatch:()=>a.k5,bytesFromStringArray:()=>a.Ub,bytesPerElement:()=>a.bT,checkConversionForErrors:()=>a.D5,clamp:()=>a.uZ,computeStrides:()=>a.e3,createScalarValue:()=>k,createShuffledIndices:()=>a.U$,decodeString:()=>S,distSquared:()=>a.E7,encodeString:()=>N,fetch:()=>x,fingerPrint64:()=>b,flatten:()=>a.xH,getArrayFromDType:()=>a.rQ,getTypedArrayFromDType:()=>a.WP,hasEncodingLoss:()=>a.QB,hexToLong:()=>i,indexToLoc:()=>a.NE,inferDtype:()=>a.D2,inferFromImplicitShape:()=>a.JZ,isBoolean:()=>a.jn,isFunction:()=>a.mf,isInt:()=>a.GN,isNumber:()=>a.hj,isPromise:()=>a.tI,isScalarShape:()=>a.N9,isString:()=>a.HD,isTypedArray:()=>a.fU,isValidDtype:()=>a.LP,locToIndex:()=>a.qy,makeOnesTypedArray:()=>a.p8,makeZerosNestedTypedArray:()=>a.l6,makeZerosTypedArray:()=>a.wT,nearestDivisor:()=>a.jP,nearestLargerEven:()=>a.nY,now:()=>v,parseAxisParam:()=>a.EC,randUniform:()=>a.bj,repeatedTry:()=>a.WD,rightPad:()=>a.oj,shuffle:()=>a.TV,shuffleCombo:()=>a.d7,sizeFromShape:()=>a.NA,sizeToSquarishShape:()=>a.YP,squeezeShape:()=>a.bp,sum:()=>a.Sm,swap:()=>a.LF,tanh:()=>a.AE,toNestedArray:()=>a.GX,toTypedArray:()=>w});var r=n(2885),a=n(569),s=n(3720);const o=n.n(s)()||s;function i(e){return o.fromString(e,!0,16)}const u=i("c3a5c85c97cb3127"),l=i("b492b66fbe98f273"),c=i("9ae16a3b2f90404f");function p(e){return e.xor(e.shru(47))}function d(e,t,n){const r=e.slice(t,t+n);return o.fromBytes(Array.from(r),!0,!0)}function h(e,t){return d(e,t,8)}function m(e,t){return d(e,t,4)}function f(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function g(e,t,n=i("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let a=t.xor(r).mul(n);return a=a.xor(a.shru(47)),a=a.mul(n),a}function y(e,t,n,r){return function(e,t,n,r,a,s){a=a.add(e),s=f(s.add(a).add(r),21);const o=a;return a=(a=a.add(t)).add(n),s=s.add(f(a,44)),[a.add(r),s.add(o)]}(h(e,t),h(e,t+8),h(e,t+16),h(e,t+24),n,r)}function b(e,t=e.length){const n=o.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=c.add(2*t),r=h(e,0).add(c),a=h(e,t-8);return g(f(a,37).mul(n).add(r),f(r,25).add(a).mul(n),n)}if(t>=4){const n=c.add(2*t);return g(m(e,0).shl(3).add(t),m(e,t-4),n)}if(t>0){const n=e[0]+(e[t>>1]<<8),r=t+(e[t-1]<<2);return p(c.mul(n).xor(u.mul(r))).mul(c)}return c}(e,t):function(e,t=e.length){const n=c.add(2*t),r=h(e,0).mul(l),a=h(e,8),s=h(e,t-8).mul(n),o=h(e,t-16).mul(c);return g(f(r.add(a),43).add(f(s,30)).add(o),r.add(f(a.add(c),18)).add(s),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=c.add(2*t),r=h(e,0).mul(c),a=h(e,8),s=h(e,t-8).mul(n),o=h(e,t-16).mul(c),i=f(r.add(a),43).add(f(s,30)).add(o),u=g(i,r.add(f(a.add(c),18)).add(s),n),l=h(e,16).mul(n),p=h(e,24),d=i.add(h(e,t-32)).mul(n),m=u.add(h(e,t-24)).mul(n);return g(f(l.add(p),43).add(f(d,30)).add(m),l.add(f(p.add(r),18)).add(d),n)}(e,t);let r=n,a=n.mul(l).add(113),s=p(a.mul(c).add(113)).mul(c),i=[o.UZERO,o.UZERO],d=[o.UZERO,o.UZERO];r=r.mul(c).add(h(e,0));let b=0;const k=64*(t-1>>6),w=k+(t-1&63)-63;do{r=f(r.add(a).add(i[0]).add(h(e,b+8)),37).mul(l),a=f(a.add(i[1]).add(h(e,b+48)),42).mul(l),r=r.xor(d[1]),a=a.add(i[0]).add(h(e,b+40)),s=f(s.add(d[0]),33).mul(l),i=y(e,b,i[1].mul(l),r.add(d[0])),d=y(e,b+32,s.add(d[1]),a.add(h(e,b+16))),[s,r]=[r,s],b+=64}while(b!==k);const v=l.add(s.and(255).shl(1));return b=w,d[0]=d[0].add(t-1&63),i[0]=i[0].add(d[0]),d[0]=d[0].add(i[0]),r=f(r.add(a).add(i[0]).add(h(e,b+8)),37).mul(v),a=f(a.add(i[1]).add(h(e,b+48)),42).mul(v),r=r.xor(d[1].mul(9)),a=a.add(i[0].mul(9).add(h(e,b+40))),s=f(s.add(d[0]),33).mul(v),i=y(e,b,i[1].mul(v),r.add(d[0])),d=y(e,b+32,s.add(d[1]),a.add(h(e,b+16))),[s,r]=[r,s],g(g(i[0],d[0],v).add(p(a).mul(u)).add(s),g(i[1],d[1],v).add(r),v)}function k(e,t){return"string"===t?N(e):w([e],t)}function w(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=a.xH(e)),(0,r.OB)().getBool("DEBUG")&&a.D5(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n{"use strict";function r(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,i(e,t,n)}function a(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,r=0;for(;n>0;)r=Math.random()*n|0,n--,i(e,n,r),i(t,n,r)}function s(e,t,n){return Math.max(e,Math.min(t,n))}function o(e){return e%2==0?e:e+1}function i(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function u(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`))}function h(e){p(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function m(e,t=[],n=!1){if(null==t&&(t=[]),Array.isArray(e)||D(e)&&!n)for(let r=0;r0),n){return new Promise(((r,a)=>{let s=0;const o=()=>{if(e())return void r();s++;const i=t(s);null!=n&&s>=n?a():setTimeout(o,i)};o()}))}function S(e,t){let n=1,r=-1;for(let t=0;t=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===r){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===n)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);const a=e.slice();return a[r]=t/n,a}function I(e,t){const n=t.length;return p((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),p(e.every((e=>b(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function T(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,s=null==t||a?null:I(t,e).sort();let o=0;for(let t=0;tt)&&1===e[t]&&(n.push(e[t]),r.push(t)),s[o]<=t&&o++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function _(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error(`Unknown data type ${e}`);n=new Uint8Array(t)}return n}function E(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function A(e,t){for(let n=0;nt+=e.length)),t}function B(e){return"string"==typeof e||e instanceof String}function C(e){return"boolean"==typeof e}function V(e){return"number"==typeof e}function R(e){return Array.isArray(e)?R(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":V(e)?"float32":B(e)?"string":C(e)?"bool":"float32"}function z(e){return!!(e&&e.constructor&&e.call&&e.apply)}function P(e,t){for(let n=t;n=0;--r)n[r]=n[r+1]*e[r+1];return n}function W(e,t,n,r=!1){const a=new Array;if(1===t.length){const s=t[0]*(r?2:1);for(let t=0;te*t))*(r?2:1);for(let t=0;te*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return W(0,e,t,n)}function q(e,t){const n=G(e,t);for(let e=0;ee*t),1);if(null==t||"float32"===t)return H(e,new Float32Array(n));if("int32"===t)return H(e,new Int32Array(n));if("bool"===t)return H(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function j(e){e.forEach((t=>{p(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function K(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;tr,d7:()=>a,uZ:()=>s,nY:()=>o,LF:()=>i,Sm:()=>u,bj:()=>l,E7:()=>c,hu:()=>p,k5:()=>d,Cq:()=>h,xH:()=>m,NA:()=>f,N9:()=>g,cO:()=>y,GN:()=>b,AE:()=>k,YP:()=>w,U$:()=>v,oj:()=>x,WD:()=>N,JZ:()=>S,EC:()=>I,bp:()=>T,WP:()=>_,rQ:()=>E,D5:()=>A,LP:()=>M,QB:()=>$,fU:()=>D,bT:()=>F,Ub:()=>O,HD:()=>B,jn:()=>C,hj:()=>V,D2:()=>R,mf:()=>z,jP:()=>P,e3:()=>L,GX:()=>H,p8:()=>q,wT:()=>G,l6:()=>U,Mu:()=>j,qy:()=>K,NE:()=>X,tI:()=>Z})},3720:e=>{e.exports=n;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function n(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function r(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=r;var a={},s={};function o(e,t){var n,r,o;return t?(o=0<=(e>>>=0)&&e<256)&&(r=s[e])?r:(n=u(e,(0|e)<0?-1:0,!0),o&&(s[e]=n),n):(o=-128<=(e|=0)&&e<128)&&(r=a[e])?r:(n=u(e,e<0?-1:0,!1),o&&(a[e]=n),n)}function i(e,t){if(isNaN(e))return t?y:g;if(t){if(e<0)return y;if(e>=h)return x}else{if(e<=-m)return N;if(e+1>=m)return v}return e<0?i(-e,t).neg():u(e%d|0,e/d|0,t)}function u(e,t,r){return new n(e,t,r)}n.fromInt=o,n.fromNumber=i,n.fromBits=u;var l=Math.pow;function c(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||360)throw Error("interior hyphen");if(0===r)return c(e.substring(1),t,n).neg();for(var a=i(l(n,8)),s=g,o=0;o>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},S.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((s=u).isZero())return c+o;for(;c.length<6;)c="0"+c;o=""+c+o}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(N)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},S.isOdd=function(){return 1==(1&this.low)},S.isEven=function(){return 0==(1&this.low)},S.equals=function(e){return r(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},S.eq=S.equals,S.notEquals=function(e){return!this.eq(e)},S.neq=S.notEquals,S.ne=S.notEquals,S.lessThan=function(e){return this.comp(e)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(e){return this.comp(e)<=0},S.lte=S.lessThanOrEqual,S.le=S.lessThanOrEqual,S.greaterThan=function(e){return this.comp(e)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(e){return this.comp(e)>=0},S.gte=S.greaterThanOrEqual,S.ge=S.greaterThanOrEqual,S.compare=function(e){if(r(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(N)?N:this.not().add(b)},S.neg=S.negate,S.add=function(e){r(e)||(e=p(e));var t=this.high>>>16,n=65535&this.high,a=this.low>>>16,s=65535&this.low,o=e.high>>>16,i=65535&e.high,l=e.low>>>16,c=0,d=0,h=0,m=0;return h+=(m+=s+(65535&e.low))>>>16,d+=(h+=a+l)>>>16,c+=(d+=n+i)>>>16,c+=t+o,u((h&=65535)<<16|(m&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},S.subtract=function(e){return r(e)||(e=p(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return g;if(r(e)||(e=p(e)),t)return u(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(N))return e.isOdd()?N:g;if(e.eq(N))return this.isOdd()?N:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(f)&&e.lt(f))return i(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,a=65535&this.high,s=this.low>>>16,o=65535&this.low,l=e.high>>>16,c=65535&e.high,d=e.low>>>16,h=65535&e.low,m=0,y=0,b=0,k=0;return b+=(k+=o*h)>>>16,y+=(b+=s*h)>>>16,b&=65535,y+=(b+=o*d)>>>16,m+=(y+=a*h)>>>16,y&=65535,m+=(y+=s*d)>>>16,y&=65535,m+=(y+=o*c)>>>16,m+=n*h+a*d+s*c+o*l,u((b&=65535)<<16|(k&=65535),(m&=65535)<<16|(y&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(r(e)||(e=p(e)),e.isZero())throw Error("division by zero");var n,a,s;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return y;if(e.gt(this.shru(1)))return k;s=y}else{if(this.eq(N))return e.eq(b)||e.eq(w)?N:e.eq(N)?b:(n=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?b:w:(a=this.sub(e.mul(n)),s=n.add(a.div(e)));if(e.eq(N))return this.unsigned?y:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=g}for(a=this;a.gte(e);){n=Math.max(1,Math.floor(a.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(n)/Math.LN2),c=o<=48?1:l(2,o-48),d=i(n),h=d.mul(e);h.isNegative()||h.gt(a);)h=(d=i(n-=c,this.unsigned)).mul(e);d.isZero()&&(d=b),s=s.add(d),a=a.sub(h)}return s},S.div=S.divide,S.modulo=function(e){return r(e)||(e=p(e)),t?u((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},S.mod=S.modulo,S.rem=S.modulo,S.not=function(){return u(~this.low,~this.high,this.unsigned)},S.and=function(e){return r(e)||(e=p(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return r(e)||(e=p(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return r(e)||(e=p(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},S.shiftLeft=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low<>>32-e,this.unsigned):u(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(e){if(r(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?u(this.low>>>e|t<<32-e,t>>>e,this.unsigned):u(32===e?t:t>>>e-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.shr_u=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},S.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},S.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},7854:(e,t,n)=>{"use strict";n.r(t),n.d(t,{FetchError:()=>d,Headers:()=>A,Request:()=>H,Response:()=>V,default:()=>K});const r=require("stream"),a=require("http"),s=require("url"),o=require("https"),i=require("zlib"),u=r.Readable,l=Symbol("buffer"),c=Symbol("type");class p{constructor(){this[c]="";const e=arguments[0],t=arguments[1],n=[];let r=0;if(e){const t=e,a=Number(t.length);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:{},a=n.size;let s=void 0===a?0:a;var o=n.timeout;let i=void 0===o?0:o;null==e?e=null:b(e)?e=Buffer.from(e.toString()):k(e)||Buffer.isBuffer(e)||("[object ArrayBuffer]"===Object.prototype.toString.call(e)?e=Buffer.from(e):ArrayBuffer.isView(e)?e=Buffer.from(e.buffer,e.byteOffset,e.byteLength):e instanceof r||(e=Buffer.from(String(e)))),this[m]={body:e,disturbed:!1,error:null},this.size=s,this.timeout=i,e instanceof r&&e.on("error",(function(e){const n="AbortError"===e.name?e:new d(`Invalid response body while trying to fetch ${t.url}: ${e.message}`,"system",e);t[m].error=n}))}function y(){var e=this;if(this[m].disturbed)return g.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[m].disturbed=!0,this[m].error)return g.Promise.reject(this[m].error);let t=this.body;if(null===t)return g.Promise.resolve(Buffer.alloc(0));if(k(t)&&(t=t.stream()),Buffer.isBuffer(t))return g.Promise.resolve(t);if(!(t instanceof r))return g.Promise.resolve(Buffer.alloc(0));let n=[],a=0,s=!1;return new g.Promise((function(r,o){let i;e.timeout&&(i=setTimeout((function(){s=!0,o(new d(`Response timeout while trying to fetch ${e.url} (over ${e.timeout}ms)`,"body-timeout"))}),e.timeout)),t.on("error",(function(t){"AbortError"===t.name?(s=!0,o(t)):o(new d(`Invalid response body while trying to fetch ${e.url}: ${t.message}`,"system",t))})),t.on("data",(function(t){if(!s&&null!==t){if(e.size&&a+t.length>e.size)return s=!0,void o(new d(`content size at ${e.url} over limit: ${e.size}`,"max-size"));a+=t.length,n.push(t)}})),t.on("end",(function(){if(!s){clearTimeout(i);try{r(Buffer.concat(n,a))}catch(t){o(new d(`Could not create Buffer from response body for ${e.url}: ${t.message}`,"system",t))}}}))}))}function b(e){return"object"==typeof e&&"function"==typeof e.append&&"function"==typeof e.delete&&"function"==typeof e.get&&"function"==typeof e.getAll&&"function"==typeof e.has&&"function"==typeof e.set&&("URLSearchParams"===e.constructor.name||"[object URLSearchParams]"===Object.prototype.toString.call(e)||"function"==typeof e.sort)}function k(e){return"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&"function"==typeof e.constructor&&"string"==typeof e.constructor.name&&/^(Blob|File)$/.test(e.constructor.name)&&/^(Blob|File)$/.test(e[Symbol.toStringTag])}function w(e){let t,n,a=e.body;if(e.bodyUsed)throw new Error("cannot clone body after it is used");return a instanceof r&&"function"!=typeof a.getBoundary&&(t=new f,n=new f,a.pipe(t),a.pipe(n),e[m].body=t,a=n),a}function v(e){return null===e?null:"string"==typeof e?"text/plain;charset=UTF-8":b(e)?"application/x-www-form-urlencoded;charset=UTF-8":k(e)?e.type||null:Buffer.isBuffer(e)||"[object ArrayBuffer]"===Object.prototype.toString.call(e)||ArrayBuffer.isView(e)?null:"function"==typeof e.getBoundary?`multipart/form-data;boundary=${e.getBoundary()}`:e instanceof r?null:"text/plain;charset=UTF-8"}function x(e){const t=e.body;return null===t?0:k(t)?t.size:Buffer.isBuffer(t)?t.length:t&&"function"==typeof t.getLengthSync&&(t._lengthRetrievers&&0==t._lengthRetrievers.length||t.hasKnownLength&&t.hasKnownLength())?t.getLengthSync():null}g.prototype={get body(){return this[m].body},get bodyUsed(){return this[m].disturbed},arrayBuffer(){return y.call(this).then((function(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}))},blob(){let e=this.headers&&this.headers.get("content-type")||"";return y.call(this).then((function(t){return Object.assign(new p([],{type:e.toLowerCase()}),{[l]:t})}))},json(){var e=this;return y.call(this).then((function(t){try{return JSON.parse(t.toString())}catch(t){return g.Promise.reject(new d(`invalid json response body at ${e.url} reason: ${t.message}`,"invalid-json"))}}))},text(){return y.call(this).then((function(e){return e.toString()}))},buffer(){return y.call(this)},textConverted(){var e=this;return y.call(this).then((function(t){return function(e,t){if("function"!=typeof h)throw new Error("The package `encoding` must be installed to use the textConverted() function");const n=t.get("content-type");let r,a,s="utf-8";n&&(r=/charset=([^;]*)/i.exec(n));a=e.slice(0,1024).toString(),!r&&a&&(r=/0&&void 0!==arguments[0]?arguments[0]:void 0;if(this[E]=Object.create(null),e instanceof A){const t=e.raw(),n=Object.keys(t);for(const e of n)for(const n of t[e])this.append(e,n)}else if(null==e);else{if("object"!=typeof e)throw new TypeError("Provided initializer must be an object");{const t=e[Symbol.iterator];if(null!=t){if("function"!=typeof t)throw new TypeError("Header pairs must be iterable");const n=[];for(const t of e){if("object"!=typeof t||"function"!=typeof t[Symbol.iterator])throw new TypeError("Each header pair must be iterable");n.push(Array.from(t))}for(const e of n){if(2!==e.length)throw new TypeError("Each header pair must be a name/value tuple");this.append(e[0],e[1])}}else for(const t of Object.keys(e)){const n=e[t];this.append(t,n)}}}}get(e){I(e=`${e}`);const t=_(this[E],e);return void 0===t?null:this[E][t].join(", ")}forEach(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=M(this),r=0;for(;r1&&void 0!==arguments[1]?arguments[1]:"key+value";const n=Object.keys(e[E]).sort();return n.map("key"===t?function(e){return e.toLowerCase()}:"value"===t?function(t){return e[E][t].join(", ")}:function(t){return[t.toLowerCase(),e[E][t].join(", ")]})}A.prototype.entries=A.prototype[Symbol.iterator],Object.defineProperty(A.prototype,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(A.prototype,{get:{enumerable:!0},forEach:{enumerable:!0},set:{enumerable:!0},append:{enumerable:!0},has:{enumerable:!0},delete:{enumerable:!0},keys:{enumerable:!0},values:{enumerable:!0},entries:{enumerable:!0}});const $=Symbol("internal");function D(e,t){const n=Object.create(F);return n[$]={target:e,kind:t,index:0},n}const F=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==F)throw new TypeError("Value of `this` is not a HeadersIterator");var e=this[$];const t=e.target,n=e.kind,r=e.index,a=M(t,n);return r>=a.length?{value:void 0,done:!0}:(this[$].index=r+1,{value:a[r],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));function O(e){const t=Object.assign({__proto__:null},e[E]),n=_(e[E],"Host");return void 0!==n&&(t[n]=t[n][0]),t}Object.defineProperty(F,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});const B=Symbol("Response internals"),C=a.STATUS_CODES;class V{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g.call(this,e,t);const n=t.status||200,r=new A(t.headers);if(null!=e&&!r.has("Content-Type")){const t=v(e);t&&r.append("Content-Type",t)}this[B]={url:t.url,status:n,statusText:t.statusText||C[n],headers:r,counter:t.counter}}get url(){return this[B].url||""}get status(){return this[B].status}get ok(){return this[B].status>=200&&this[B].status<300}get redirected(){return this[B].counter>0}get statusText(){return this[B].statusText}get headers(){return this[B].headers}clone(){return new V(w(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}g.mixIn(V.prototype),Object.defineProperties(V.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),Object.defineProperty(V.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const R=Symbol("Request internals"),z=s.parse,P=s.format,L="destroy"in r.Readable.prototype;function W(e){return"object"==typeof e&&"object"==typeof e[R]}class H{constructor(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};W(e)?t=z(e.url):(t=e&&e.href?z(e.href):z(`${e}`),e={});let r=n.method||e.method||"GET";if(r=r.toUpperCase(),(null!=n.body||W(e)&&null!==e.body)&&("GET"===r||"HEAD"===r))throw new TypeError("Request with GET/HEAD method cannot have body");let a=null!=n.body?n.body:W(e)&&null!==e.body?w(e):null;g.call(this,a,{timeout:n.timeout||e.timeout||0,size:n.size||e.size||0});const s=new A(n.headers||e.headers||{});if(null!=a&&!s.has("Content-Type")){const e=v(a);e&&s.append("Content-Type",e)}let o=W(e)?e.signal:null;if("signal"in n&&(o=n.signal),null!=o&&!function(e){const t=e&&"object"==typeof e&&Object.getPrototypeOf(e);return!(!t||"AbortSignal"!==t.constructor.name)}(o))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[R]={method:r,redirect:n.redirect||e.redirect||"follow",headers:s,parsedURL:t,signal:o},this.follow=void 0!==n.follow?n.follow:void 0!==e.follow?e.follow:20,this.compress=void 0!==n.compress?n.compress:void 0===e.compress||e.compress,this.counter=n.counter||e.counter||0,this.agent=n.agent||e.agent}get method(){return this[R].method}get url(){return P(this[R].parsedURL)}get headers(){return this[R].headers}get redirect(){return this[R].redirect}get signal(){return this[R].signal}clone(){return new H(this)}}function q(e){Error.call(this,e),this.type="aborted",this.message=e,Error.captureStackTrace(this,this.constructor)}g.mixIn(H.prototype),Object.defineProperty(H.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(H.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}}),q.prototype=Object.create(Error.prototype),q.prototype.constructor=q,q.prototype.name="AbortError";const G=r.PassThrough,U=s.resolve;function j(e,t){if(!j.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return g.Promise=j.Promise,new j.Promise((function(n,s){const u=new H(e,t),l=function(e){const t=e[R].parsedURL,n=new A(e[R].headers);if(n.has("Accept")||n.set("Accept","*/*"),!t.protocol||!t.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(t.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(e.signal&&e.body instanceof r.Readable&&!L)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let a=null;if(null==e.body&&/^(POST|PUT)$/i.test(e.method)&&(a="0"),null!=e.body){const t=x(e);"number"==typeof t&&(a=String(t))}a&&n.set("Content-Length",a),n.has("User-Agent")||n.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),e.compress&&!n.has("Accept-Encoding")&&n.set("Accept-Encoding","gzip,deflate");let s=e.agent;return"function"==typeof s&&(s=s(t)),n.has("Connection")||s||n.set("Connection","close"),Object.assign({},t,{method:e.method,headers:O(n),agent:s})}(u),c=("https:"===l.protocol?o:a).request,p=u.signal;let h=null;const m=function(){let e=new q("The user aborted a request.");s(e),u.body&&u.body instanceof r.Readable&&u.body.destroy(e),h&&h.body&&h.body.emit("error",e)};if(p&&p.aborted)return void m();const f=function(){m(),b()},g=c(l);let y;function b(){g.abort(),p&&p.removeEventListener("abort",f),clearTimeout(y)}p&&p.addEventListener("abort",f),u.timeout&&g.once("socket",(function(e){y=setTimeout((function(){s(new d(`network timeout at: ${u.url}`,"request-timeout")),b()}),u.timeout)})),g.on("error",(function(e){s(new d(`request to ${u.url} failed, reason: ${e.message}`,"system",e)),b()})),g.on("response",(function(e){clearTimeout(y);const t=function(e){const t=new A;for(const n of Object.keys(e))if(!N.test(n))if(Array.isArray(e[n]))for(const r of e[n])S.test(r)||(void 0===t[E][n]?t[E][n]=[r]:t[E][n].push(r));else S.test(e[n])||(t[E][n]=[e[n]]);return t}(e.headers);if(j.isRedirect(e.statusCode)){const r=t.get("Location"),a=null===r?null:U(u.url,r);switch(u.redirect){case"error":return s(new d(`uri requested responds with a redirect, redirect mode is set to error: ${u.url}`,"no-redirect")),void b();case"manual":if(null!==a)try{t.set("Location",a)}catch(e){s(e)}break;case"follow":if(null===a)break;if(u.counter>=u.follow)return s(new d(`maximum redirect reached at: ${u.url}`,"max-redirect")),void b();const r={headers:new A(u.headers),follow:u.follow,counter:u.counter+1,agent:u.agent,compress:u.compress,method:u.method,body:u.body,signal:u.signal,timeout:u.timeout,size:u.size};return 303!==e.statusCode&&u.body&&null===x(u)?(s(new d("Cannot follow redirect with body being a readable stream","unsupported-redirect")),void b()):(303!==e.statusCode&&(301!==e.statusCode&&302!==e.statusCode||"POST"!==u.method)||(r.method="GET",r.body=void 0,r.headers.delete("content-length")),n(j(new H(a,r))),void b())}}e.once("end",(function(){p&&p.removeEventListener("abort",f)}));let r=e.pipe(new G);const a={url:u.url,status:e.statusCode,statusText:e.statusMessage,headers:t,size:u.size,timeout:u.timeout,counter:u.counter},o=t.get("Content-Encoding");if(!u.compress||"HEAD"===u.method||null===o||204===e.statusCode||304===e.statusCode)return h=new V(r,a),void n(h);const l={flush:i.Z_SYNC_FLUSH,finishFlush:i.Z_SYNC_FLUSH};if("gzip"==o||"x-gzip"==o)return r=r.pipe(i.createGunzip(l)),h=new V(r,a),void n(h);if("deflate"!=o&&"x-deflate"!=o){if("br"==o&&"function"==typeof i.createBrotliDecompress)return r=r.pipe(i.createBrotliDecompress()),h=new V(r,a),void n(h);h=new V(r,a),n(h)}else{e.pipe(new G).once("data",(function(e){r=8==(15&e[0])?r.pipe(i.createInflate()):r.pipe(i.createInflateRaw()),h=new V(r,a),n(h)}))}})),function(e,t){const n=t.body;null===n?e.end():k(n)?n.stream().pipe(e):Buffer.isBuffer(n)?(e.write(n),e.end()):n.pipe(e)}(g,u)}))}j.isRedirect=function(e){return 301===e||302===e||303===e||307===e||308===e},j.Promise=global.Promise;const K=j},6377:(e,t,n)=>{var r=n(4832),a=n(8652),s=n(801),o=n(2030),i=n(3618),u=n(9049),l=n(1971);l.alea=r,l.xor128=a,l.xorwow=s,l.xorshift7=o,l.xor4096=i,l.tychei=u,e.exports=l},4832:function(e,t,n){var r;!function(e,a,s){function o(e){var t,n=this,r=(t=4022871197,function(e){e=e.toString();for(var n=0;n>>0,t=(r*=t)>>>0,t+=4294967296*(r-=t)}return 2.3283064365386963e-10*(t>>>0)});n.next=function(){var e=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=e-(n.c=0|e)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(e),n.s0<0&&(n.s0+=1),n.s1-=r(e),n.s1<0&&(n.s1+=1),n.s2-=r(e),n.s2<0&&(n.s2+=1),r=null}function i(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var n=new o(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&i(r,n),a.state=function(){return i(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.alea=u}(0,e=n.nmd(e),n.amdD)},9049:function(e,t,n){var r;!function(e,a,s){function o(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&i(r,n),a.state=function(){return i(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.tychei=u}(0,e=n.nmd(e),n.amdD)},8652:function(e,t,n){var r;!function(e,a,s){function o(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&i(r,n),a.state=function(){return i(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor128=u}(0,e=n.nmd(e),n.amdD)},3618:function(e,t,n){var r;!function(e,a,s){function o(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,s=t.i;return t.w=r=r+1640531527|0,n=a[s+34&127],e=a[s=s+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[s]=n^e,t.i=s,n+(r^r>>>16)|0},function(e,t){var n,r,a,s,o,i=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,s=-32;s>>15,r^=r<<4,r^=r>>>13,s>=0&&(o=o+1640531527|0,a=0==(n=i[127&s]^=r+o)?a+1:0);for(a>=128&&(i[127&(t&&t.length||0)]=-1),a=127,s=512;s>0;--s)r=i[a+34&127],n=i[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,i[a]=r^n;e.w=o,e.X=i,e.i=a}(t,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var n=new o(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&i(r,n),a.state=function(){return i(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor4096=u}(0,e=n.nmd(e),n.amdD)},2030:function(e,t,n){var r;!function(e,a,s){function o(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function i(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var n=new o(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&i(r,n),a.state=function(){return i(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorshift7=u}(0,e=n.nmd(e),n.amdD)},801:function(e,t,n){var r;!function(e,a,s){function o(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r>>4),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var n=new o(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&i(r,n),a.state=function(){return i(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorwow=u}(0,e=n.nmd(e),n.amdD)},1971:(e,t,n)=>{var r;!function(a,s){var o,i=this,u=256,l=s.pow(u,6),c=s.pow(2,52),p=2*c,d=255;function h(e,t,n){var r=[],d=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,b(a)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(u):(e=new Uint8Array(u),(i.crypto||i.msCrypto).getRandomValues(e)),b(e)}catch(e){var t=i.navigator,n=t&&t.plugins;return[+new Date,i,n,i.screen,b(a)]}}():e,3),r),h=new m(r),k=function(){for(var e=h.g(6),t=l,n=0;e=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return k.int32=function(){return 0|h.g(4)},k.quick=function(){return h.g(4)/4294967296},k.double=k,y(b(h.S),a),(t.pass||n||function(e,t,n,r){return r&&(r.S&&f(r,h),e.state=function(){return f(h,{})}),n?(s.random=e,t):e})(k,d,"global"in t?t.global:this==s,t.state)}function m(e){var t,n=e.length,r=this,a=0,s=r.i=r.j=0,o=r.S=[];for(n||(e=[n++]);a0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]=this._maxContentSize&&(e=e.substring(0,this._maxContentSize)),this._normalizeNewline&&(e=e.replace(/\r\n/g,"\n")),[4,this._model.executeAsync(u.tensor([e]))];case 2:for(t=i.sent(),n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t[1]:t,a=n.dataSync(),s=r.dataSync(),o=[],c=0;ca[l]&&(l=c);return[2,o.sort((function(e,t){return t.confidence-e.confidence}))]}}))}))},e.prototype.dispose=function(){var e;null===(e=this._model)||void 0===e||e.dispose()},e.DEFAULT_MAX_CONTENT_SIZE=1e5,e.DEFAULT_MIN_CONTENT_SIZE=20,e.NODE_MODEL_JSON_FUNC=function(){return o(void 0,void 0,void 0,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return s(n(5747))}))];case 1:return e=r.sent(),[4,Promise.resolve().then((function(){return s(n(5622))}))];case 2:return t=r.sent(),[2,new Promise((function(n,r){e.readFile(t.join(__dirname,"..","..","model","model.json"),(function(e,t){e?r(e):n(JSON.parse(t.toString()))}))}))]}}))}))},e.NODE_WEIGHTS_FUNC=function(){return o(void 0,void 0,void 0,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:return[4,Promise.resolve().then((function(){return s(n(5747))}))];case 1:return e=r.sent(),[4,Promise.resolve().then((function(){return s(n(5622))}))];case 2:return t=r.sent(),[2,new Promise((function(n,r){e.readFile(t.join(__dirname,"..","..","model","group1-shard1of1.bin"),(function(e,t){e?r(e):n(t.buffer)}))}))]}}))}))},e}();t.ModelOperations=p},6417:e=>{"use strict";e.exports=require("crypto")},5747:e=>{"use strict";e.exports=require("fs")},5622:e=>{"use strict";e.exports=require("path")},1669:e=>{"use strict";e.exports=require("util")}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var s=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.loaded=!0,s.exports}return n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n(6086)})()}));