1/*! For license information please see tensorflow.3230f5e50ed04b6cad7d.js.LICENSE.txt */ 2(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[272],{43940:function(e,t,n){"use strict";n.d(t,{q:function(){return a}});var r=n(42840);function a(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&r.euu.assert("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}},4471:function(e,t,n){"use strict";var r=n(42840),a=n(43940);const o=r.lKA._U;class s extends r.qe${nextDataId(){return s.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new r.iaN(this,(0,r.sn1)())}write(e,t,n){this.firstUse&&(this.firstUse=!1,(0,r._K2)().get("IS_NODE")&&r.cxb.warn("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));const a={id:this.nextDataId()};return this.data.set(a,{values:e,dtype:n,refCount:1}),a}makeTensorInfo(e,t,n){let a;if("string"===t&&null!=n&&n.length>0&&r.euu.isString(n[0])){const o=n.map((e=>r.euu.encodeString(e)));a=this.write(o,e,t)}else a=this.write(n,e,t);return{dataId:a,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){this.data.get(e).refCount++}decRef(e){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 r.cxb.mergeRealAndImagArrays(e,t)}return r.euu.convertBackendValuesAndArrayBuffer(this.data.get(e).values,t)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>r.euu.decodeString(e)));return(0,r.cz0)(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return(0,r.cz0)(e.shape,e.dtype,t)}makeOutput(e,t,n){return(0,r.sn1)().makeTensorFromTensorInfo(this.makeTensorInfo(t,n,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;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=r.euu.now();return e(),{kernelMs:r.euu.now()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){(0,a.q)([e],"where");const t=this.readSync(e.dataId);return o(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}function i(e){return(t,n,a)=>{const o=r.euu.getArrayFromDType(n,t.length);for(let n=0;n<t.length;++n)o[n]=e(t[n],a);return o}}function u(e,t,n){return c(e,i(t),n)}function c(e,t,n){return({inputs:o,attrs:s,backend:i})=>{const{x:u}=o;(0,a.q)(u,e);const c=i,l=c.data.get(u.dataId).values;let p;if("string"===u.dtype){if(!Array.isArray(l))throw new Error("String tensor's value was not an instance of Array");p=r.cxb.fromUint8ToStringArray(l)}else p=l;const d=n||u.dtype,h=t(p,d,s);return c.makeTensorInfo(u.shape,d,h)}}s.nextDataId=0,(0,r.gJo)("cpu",(()=>new s),1);const l=u(r.wP9,(e=>e>=0?e:Math.exp(e)-1)),p={kernelName:r.wP9,backendName:"cpu",kernelFunc:l};function d(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 h={kernelName:r.oPg,backendName:"cpu",kernelFunc:d};function f(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{alpha:i}=o;(0,a.q)([s],"leakyRelu");const u=r.euu.sizeFromShape(s.shape),c=n.data.get(s.dataId).values,l=r.euu.getTypedArrayFromDType("float32",u);for(let e=0;e<c.length;e++)l[e]=c[e]<0?i*c[e]:c[e];return n.makeTensorInfo(s.shape,"float32",l)}const m={kernelName:r.Mb$,backendName:"cpu",kernelFunc:f};function g(e){return(t,n,a,o,s)=>{const i=r.cxb.assertAndGetBroadcastShape(t,n),u=i.length,c=r.euu.computeStrides(i),l=r.euu.sizeFromShape(i),p=r.euu.getTypedArrayFromDType(s,l),d=t.length,h=n.length,f=r.euu.computeStrides(t),m=r.euu.computeStrides(n),g=r.c
2xb.getBroadcastDims(t,i),y=r.cxb.getBroadcastDims(n,i);if(g.length+y.length===0)for(let t=0;t<p.length;++t)p[t]=e(a[t%a.length],o[t%o.length]);else for(let t=0;t<p.length;++t){const n=r.euu.indexToLoc(t,u,c),s=n.slice(-d);g.forEach((e=>s[e]=0));const i=r.euu.locToIndex(s,d,f),l=n.slice(-h);y.forEach((e=>l[e]=0));const b=r.euu.locToIndex(l,h,m);p[t]=e(a[i],o[b])}return[p,i]}}const y=g(((e,t)=>e<0?t*e:e));function b(e){const{inputs:t,backend:n}=e,{x:r,alpha:o}=t;(0,a.q)([r,o],"prelu");const s=n.data.get(r.dataId).values,i=n.data.get(o.dataId).values,[u,c]=y(r.shape,o.shape,s,i,"float32");return n.makeTensorInfo(c,"float32",u)}const w={kernelName:r.cBF,backendName:"cpu",kernelFunc:b},v=u(r.IHk,(e=>Math.max(0,e))),k={kernelName:r.IHk,backendName:"cpu",kernelFunc:v},x=u(r.QwE,(e=>Math.min(Math.max(0,e),6))),_={kernelName:r.QwE,backendName:"cpu",kernelFunc:x},I=(i((e=>1/(1+Math.exp(-e)))),u(r.ac,(e=>1/(1+Math.exp(-e))))),S={kernelName:r.ac,backendName:"cpu",kernelFunc:I};function N(e,t,n,r,a){if("linear"===n)return d({inputs:{x:t},backend:e});if("relu"===n)return v({inputs:{x:t},backend:e});if("elu"===n)return l({inputs:{x:t},backend:e});if("relu6"===n)return x({inputs:{x:t},backend:e});if("prelu"===n)return b({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return f({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return I({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function M(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,o=n.data.get(r.dataId).values,s=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",o),imag:n.makeTensorInfo(a.shape,"float32",s)},i}const T={kernelName:r.sXm,backendName:"cpu",kernelFunc:M};function E(e,t,n="float32"){if("complex64"===n)return M({inputs:{real:E(e,t,"float32"),imag:E(e,t,"float32")},backend:e});const a=r.euu.makeZerosTypedArray(r.euu.sizeFromShape(t),n);return e.makeTensorInfo(t,n,a)}function A(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,o=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,o)}const F={kernelName:r.U1$,backendName:"cpu",kernelFunc:A};function D(e){const{inputs:t,backend:n,attrs:a}=e,{x:o}=t,{dtype:s}=a;if("complex64"===s){if("complex64"===o.dtype)return d({inputs:{x:o},backend:n});const e=E(n,o.shape,o.dtype),t=D({inputs:{x:o},backend:n,attrs:{dtype:"float32"}}),r=M({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===o.dtype){const e=A({inputs:{input:o},backend:n}),t=D({inputs:{x:e},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(e),t}if(!r.euu.hasEncodingLoss(o.dtype,s)){const e=d({inputs:{x:o},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:s}}const i=n.data.get(o.dataId).values,[u,c,l]=function(e,t,n,a){if("int32"===a)return[t,"int32",Int32Array.from(e)];if("bool"===a){const a=r.euu.toTypedArray([0],n),[o,s]=g(((e,t)=>e!==t?1:0))(t,[],e,a,"bool");return[s,"bool",o]}throw new Error(`Error in Cast: failed to cast ${n} to ${a}`)}(i,o.shape,o.dtype,s);return n.makeTensorInfo(u,c,l)}const O={kernelName:r.Utj,backendName:"cpu",kernelFunc:D};function C(e,t,n,o){return null==n?({inputs:n,backend:s})=>{const{a:i,b:u}=n,c=s;(0,a.q)([i,u],e);const l=c.data.get(i.dataId).values,p=c.data.get(u.dataId).values,d="string"===i.dtype?r.cxb.fromUint8ToStringArray(l):l,h="string"===i.dtype?r.cxb.fromUint8ToStringArray(p):p,f=o||i.dtype,[m,g]=t(i.shape,u.shape,d,h,f);return c.makeTensorInfo(g,f,m)}:({inputs:e,backend:r})=>{const{a:a,b:s}=e,i=r;if("complex64"===a.dtype||"complex64"===s.dtype){const e=D({inputs:{x:a},backend:i,attrs:{dtype:"complex64"}}),t=i.data.get(e.dataId),r=t.complexTensorInfos.real,o=t.complexTensorInfos.imag,u=i.data.get(r.dataId).values,c=i.data.get(o.dataId).values,l=D({inputs:{x:s},backend:i,attrs:{dtype:"complex64"}}),p=i.data.get(l.dataId),d=p.complexTensorInfos.real,h=p.complexTensorInfos.imag,f=i.data.get(d.dataId).values,m=i.data.get(h.dataId).values,[g,y,b]=n(a.shape,s.shape,u,c,f,m),w=i.makeTensorInfo(b,"float32",g),v=i.makeTensorInfo(b,"float32",y),k=M({inputs:{real:w,imag:v},backend:i}
vendor: 1,796 bytes, line 2
2);return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(l),i.disposeIntermediateTensorInfo(w),i.disposeIntermediateTensorInfo(v),k}{const e=i.data.get(a.dataId).values,n=i.data.get(s.dataId).values,r=o||a.dtype,[u,c]=t(a.shape,s.shape,e,n,r);return i.makeTensorInfo(c,r,u)}}}function P(e){return(t,n,a,o,s,i)=>{const u=r.cxb.assertAndGetBroadcastShape(t,n),c=r.euu.sizeFromShape(u),l=u.length,p=r.euu.computeStrides(u),d=r.euu.getTypedArrayFromDType("float32",c),h=r.euu.getTypedArrayFromDType("float32",c),f=r.cxb.getBroadcastDims(t,u),m=r.cxb.getBroadcastDims(n,u),g=r.cxb.mergeRealAndImagArrays(a,o),y=r.cxb.mergeRealAndImagArrays(s,i),b=t.length,w=r.euu.computeStrides(t),v=n.length,k=r.euu.computeStrides(n);if(f.length+m.length===0)for(let t=0;t<d.length;t++){const n=t%g.length,r=t%y.length,a=e(g[2*n],g[2*n+1],y[2*r],y[2*r+1]);d[t]=a.real,h[t]=a.imag}else for(let t=0;t<d.length;t++){const n=r.euu.indexToLoc(t,l,p),a=n.slice(-b);f.forEach((e=>a[e]=0));const o=r.euu.locToIndex(a,b,w),s=n.slice(-v);m.forEach((e=>s[e]=0));const i=r.euu.locToIndex(s,v,k),u=e(g[2*o],g[2*o+1],y[2*i],y[2*i+1]);d[t]=u.real,h[t]=u.imag}return[d,h,u]}}const R=g(((e,t)=>e+t)),$=P(((e,t,n,r)=>({real:e+n,imag:t+r}))),L=C(r.OMN,R,$),W={kernelName:r.OMN,backendName:"cpu",kernelFunc:L};function z(e){const{inputs:t,backend:n,attrs:a}=e,{x:o}=t,{shape:s}=a,i=r.euu.sizeFromShape(o.shape),u=r.euu.inferFromImplicitShape(s,i),c=r.euu.sizeFromShape(u);r.euu.assert(i===c,(()=>`The new shape (${u}) has ${c} elements and the old shape (${o.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(o.dataId);const l=n.data.get(o.dataId);if(null!=l.complexTensorInfos){const e=l.complexTensorInfos.real,t=l.complexTensorInfos.imag;e.shape=u,t.shape=u}
2return{dataId:o.dataId,shape:u,dtype:o.dtype}}const B={kernelName:r.MvO,backendName:"cpu",kernelFunc:z};function U(e){const{inputs:t,backend:n,attrs:o}=e,{a:s,b:i}=t,{transposeA:u,transposeB:c}=o;(0,a.q)([s,i],"matMul");const l=s.shape.length,p=i.shape.length,d=u?s.shape[l-2]:s.shape[l-1],h=c?i.shape[p-1]:i.shape[p-2],f=u?s.shape[l-1]:s.shape[l-2],m=c?i.shape[p-2]:i.shape[p-1],g=s.shape.slice(0,-2),y=i.shape.slice(0,-2),b=r.euu.sizeFromShape(g),w=r.euu.sizeFromShape(y),v=r.qm_.assertAndGetBroadcastShape(s.shape.slice(0,-2),i.shape.slice(0,-2)).concat([f,m]);r.euu.assert(d===h,(()=>`Error in matMul: inner shapes (${d}) and (${h}) of Tensors with shapes ${s.shape} and ${i.shape} and transposeA=${u} and transposeB=${c} must match.`));const k=c?[w,m,h]:[w,h,m],x=z({inputs:{x:s},backend:n,attrs:{shape:u?[b,d,f]:[b,f,d]}}),_=z({inputs:{x:i},backend:n,attrs:{shape:k}}),I=u?x.shape[1]:x.shape[2],S=u?x.shape[2]:x.shape[1],N=c?_.shape[1]:_.shape[2],M=Math.max(b,w),T=n.data.get(x.dataId).values,E=n.data.get(_.dataId).values,A=r.euu.computeStrides(x.shape),F=r.euu.computeStrides(_.shape),[D,O,C]=u?[A[0],1,A[1]]:[A[0],A[1],1],[P,R,$]=c?[1,F[1],F[0]]:[F[1],1,F[0]],L=S*N,W=(0,r.cz0)([M,S,N],x.dtype),B=W.values,U=n.blockSize;for(let e=0;e<M;e++){const t=e%b,n=e%w;for(let r=0;r<S;r+=U){const a=Math.min(r+U,S);for(let o=0;o<N;o+=U){const s=Math.min(o+U,N);for(let i=0;i<I;i+=U){const u=Math.min(i+U,I);for(let c=r;c<a;c++)for(let r=o;r<s;r++){let a=0;for(let e=i;e<u;e++)a+=T[t*D+c*O+e*C]*E[e*P+r*R+n*$];B[e*L+(c*N+r)]+=a}}}}}return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(_),n.makeTensorInfo(v,W.dtype,W.values)}const H={kernelName:r.Sye,backendName:"cpu",kernelFunc:U},V={kernelName:r.gHH,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a:a,b:o,bias:s,preluActivationWeights:i}=t,{transposeA:u,transposeB:c,activation:l,leakyreluAlpha:p}=r;let d,h,f;const m=[];d=U({inputs:{a:a,b:o},attrs:{transposeA:u,transposeB:c},backend:n}),s&&(h=L({inputs:{a:d,b:s},backend:n}),m.push(d),d=h),l&&(f=N(n,d,l,i,p),m.push(d),d=f);for(const e of m)n.disposeIntermediateTensorInfo(e);return d}},G={kernelName:r.UXy,backendName:"cpu",kernelFunc:e=>{const{x:t}=e.inputs,n=e.backend;(0,a.q)(t,"abs");let o=new Float32Array(r.euu.sizeFromShape(t.shape));return o=function(e){const t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}(n.data.get(t.dataId).values),n.makeOutput(o,t.shape,t.dtype)}},q=u(r.Y93,(e=>Math.acos(e))),j={kernelName:r.Y93,backendName:"cpu",kernelFunc:q},K=u(r.yak,(e=>Math.acosh(e))),Q={kernelName:r.yak,backendName:"cpu",kernelFunc:K},Y={kernelName:r.SE4,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,o=t;(0,a.q)(t,"addN");const s=o.map((e=>n.data.get(e.dataId).values)),i=(0,r.cz0)(o[0].shape,o[0].dtype),u=i.values;for(let e=0;e<o.length;e++){const t=s[e];for(let e=0;e<u.length;e++)u[e]+=t[e]}return n.makeTensorInfo(i.shape,i.dtype,i.values)}};function J(e,t,n,a,o){const s=t.length,i=r.euu.sizeFromShape(t),u=r.euu.computeStrides(t),c=r.euu.computeStrides(o),l=r.euu.getTypedArrayFromDType(n,r.euu.sizeFromShape(o));for(let t=0;t<i;++t){const n=r.euu.indexToLoc(t,s,u),o=new Array(n.length);for(let e=0;e<o.length;e++)o[e]=n[a[e]];l[r.euu.locToIndex(o,s,c)]=e[t]}return l}function Z(e){const{inputs:t,attrs:n,backend:r}=e,{x:o}=t,{perm:s}=n;(0,a.q)(o,"transpose");const i=o.shape.length,u=new Array(i);for(let e=0;e<u.length;e++)u[e]=o.shape[s[e]];const c=J(r.data.get(o.dataId).values,o.shape,o.dtype,s,u);
vendor: 5,370 bytes, line 2
2return{dataId:r.write(c,u,o.dtype),shape:u,dtype:o.dtype}}const X={kernelName:r.$Up,backendName:"cpu",kernelFunc:Z},ee={kernelName:r.u8Z,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i,keepDims:u}=o;(0,a.q)(s,"all");const c=r.euu.parseAxisParam(i,s.shape);let l=c;const p=r.cxb.getAxesPermutation(l,s.shape.length);let d=s;null!=p&&(d=Z({inputs:{x:s},backend:n,attrs:{perm:p}}),l=r.cxb.getInnerMostAxes(l.length,s.shape.length)),r.cxb.assertAxesAreInnerMostDims("all",l,d.shape.length);const[h,f]=r.cxb.computeOutAndReduceShapes(d.shape,l),m=r.euu.sizeFromShape(f),g=r.euu.makeZerosTypedArray(r.euu.sizeFromShape(h),d.dtype),y=n.data.get(d.dataId).values;for(let e=0;e<g.length;++e){const t=e*m;let n=y[t];for(let e=0;e<m;++e){const r=y[t+e];n=n&&r}g[e]=n}null!=p&&n.disposeIntermediateTensorInfo(d);const b=n.makeTensorInfo(h,d.dtype,g);if(u){const e=z({inputs:{x:b},backend:n,attrs:{shape:r.cxb.expandShapeToKeepDim(h,c)}});return n.disposeIntermediateTensorInfo(b),e}return b}},te={kernelName:r.YdD,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i,keepDims:u}=o;(0,a.q)(s,"any");const c=r.euu.parseAxisParam(i,s.shape);let l=c;const p=r.cxb.getAxesPermutation(l,s.shape.length);let d=s;null!=p&&(d=Z({inputs:{x:s},backend:n,attrs:{perm:p}}),l=r.cxb.getInnerMostAxes(l.length,s.shape.length)),r.cxb.assertAxesAreInnerMostDims("any",l,d.shape.length);const[h,f]=r.cxb.computeOutAndReduceShapes(d.shape,l),m=r.euu.sizeFromShape(f),g=r.euu.makeZerosTypedArray(r.euu.sizeFromShape(h),d.dtype),y=n.data.get(d.dataId).values;for(let e=0;e<g.length;++e){const t=e*m;let n=y[t];for(let e=0;e<m;++e){const r=y[t+e];n=n||r}g[e]=n}null!=p&&n.disposeIntermediateTensorInfo(d);const b=n.makeTensorInfo(h,d.dtype,g);if(u){const e=z({inputs:{x:b},backend:n,attrs:{shape:r.cxb.expandShapeToKeepDim(h,c)}});return n.disposeIntermediateTensorInfo(b),e}return b}},ne={kernelName:r.IBO,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i}=o;(0,a.q)(s,"argMax");let u=r.euu.parseAxisParam(i,s.shape);const c=r.cxb.getAxesPermutation(u,s.shape.length);let l=s;const p=[];null!=c&&(l=Z({inputs:{x:s},backend:n,attrs:{perm:c}}),p.push(l),u=r.cxb.getInnerMostAxes(u.length,l.shape.length)),u=[u[0]],r.cxb.assertAxesAreInnerMostDims("argMax",u,l.shape.length);const[d,h]=r.cxb.computeOutAndReduceShapes(l.shape,u),f=r.euu.sizeFromShape(d),m=r.euu.makeZerosTypedArray(f,"int32"),g=r.euu.sizeFromShape(h),y=n.data.get(l.dataId).values;for(let e=0;e<m.length;++e){const t=e*g;let n=y[t],r=0;for(let e=0;e<g;++e){const a=y[t+e];a>n&&(n=a,r=e)}m[e]=r}return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(d,"int32",m)}},re={kernelName:r.ovQ,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i}=o;(0,a.q)(s,"argMin");let u=r.euu.parseAxisParam(i,s.shape);const c=r.cxb.getAxesPermutation(u,s.shape.length);let l=s;const p=[];null!=c&&(l=Z({inputs:{x:s},backend:n,attrs:{perm:c}}),p.push(l),u=r.cxb.getInnerMostAxes(u.length,l.shape.length)),u=[u[0]],r.cxb.assertAxesAreInnerMostDims("argMin",u,l.shape.length);const[d,h]=r.cxb.computeOutAndReduceShapes(l.shape,u),f=r.euu.sizeFromShape(d),m=r.euu.makeZerosTypedArray(f,"int32"),g=r.euu.sizeFromShape(h),y=n.data.get(l.dataId).values;for(let e=0;e<m.length;++e){const t=e*g;let n=y[t],r=0;for(let e=0;e<g;++e){const a=y[t+e];a<n&&(n=a,r=e)}m[e]=r}return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(d,"int32",m)}},ae=u(r.Kgs,(e=>Math.asin(e))),oe={kernelName:r.Kgs,backendName:"cpu",kernelFunc:ae},se=u(r.ILp,(e=>Math.asinh(e))),ie={kernelName:r.ILp,backendName:"cpu",kernelFunc:se},ue=u(r.oNL,(e=>Math.atan(e))),ce={kernelName:r.oNL,backendName:"cpu",kernelFunc:ue},le=g(((e,t)=>Math.atan2(e,t))),pe=C(r.s1o,le),de={kernelName:r.s1o,backendName:"cpu",kernelFunc:pe},he=u(r.cL,(e=>Math.atanh(e))),fe={kernelName:r.cL,backendName:"cpu",kernelFunc:he};function me(e,t,n,a,o,s){const i=o.strideHeight,u=o.strideWidth,c=o.dilationHeight,l=o.dilationWidth,p=o.effectiveFilterHeight,d=o.effectiveFilterWidth,h=o.padInfo.top,f=o.padInfo.left,m="max"===s?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=(0,r.cz0)(o.outShape,n),y=g.values,b=o.outShape[1]*o.outShape[2]*o.outShape[3],w=o.outShape[2]*o.outShape[3],v=o.outShape[3];for(let t=0;t<o.batchSize;++t){const n=t*b,r=t*a[0];for(let t=0;t<o.inChannels;++t)for(let g=0;g<o.outHeight;++g){const b=g*i-h,k=Math.max(0,b),x=Math.min(o.inHeight,p+b),_=n+g*w;for(let n=0;n<o.outWidth;++n){const i=n*u-f,p=Math.max(0,i),h=Math.min(o.inWidth,d+i);let g=m,b=0,w=0;for(let n=k;n<x;n+=c){const o=r+n*a[1];for(let n=p;n<h;n+=l){const r=e[o+n*a[2]+t];"max"===s&&r>g?g=r:"avg"===s&&(b+=r,w++)}if(isNaN(g))break}y[_+n*v+t]="avg"===s?b/w:g}}}return g}function ge(e,t,n,a,o=!1,s=!1){const i=(0,r.cz0)(a.outShape,"int32"),u=a.strideHeight,c=a.strideWidth,l=a.dilationHeight,p=a.dilationWidth,d=a.effectiveFilterHeight,h=a.effectiveFilterWidth,f=a.padInfo.top,m=a.padInfo.left,g=(0,r.cz0)(t,n,e);for(let e=0;e<a.batchSize;++e)for(let t=0;t<a.inChannels;++t)for(let n=0;n<a.outHeight;++n){const r=n*u-f;let y=r;for(;y<0;)y+=l;const b=Math.min(a.inHeight,d+r);for(let u=0;u<a.outWidth;++u){const d=u*c-m;let f=d;for(;f<0;)f+=p;const w=Math.min(a.inWidth,h+d);let v=Number.NEGATIVE_INFINITY,k=-1;for(let n=y;
2n<b;n+=l){const i=n-r;for(let r=f;r<w;r+=p){const u=r-d,c=g.get(e,n,r,t);c>v&&(v=c,k=o?s?((e*a.inHeight+n)*a.inWidth+r)*a.inChannels+t:(n*a.inWidth+r)*a.inChannels+t:i*h+u)}}i.set(k,e,n,u,t)}}return i}function ye(e,t,n,a,o,s){const i=o.strideDepth,u=o.strideHeight,c=o.strideWidth,l=o.dilationDepth,p=o.dilationHeight,d=o.dilationWidth,h=o.effectiveFilterDepth,f=o.effectiveFilterHeight,m=o.effectiveFilterWidth,g=o.padInfo.front,y=o.padInfo.top,b=o.padInfo.left,w="max"===s?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,v=(0,r.cz0)(o.outShape,n),k=v.values,x=o.outShape[1]*o.outShape[2]*o.outShape[3]*o.outShape[4],_=o.outShape[2]*o.outShape[3]*o.outShape[4],I=o.outShape[3]*o.outShape[4],S=o.outShape[4];for(let t=0;t<o.batchSize;++t){const n=t*x,r=t*a[0];for(let t=0;t<o.inChannels;++t)for(let v=0;v<o.outDepth;++v){const x=v*i-g;let N=x;for(;N<0;)N+=l;const M=Math.min(o.inDepth,h+x),T=n+v*_;for(let n=0;n<o.outHeight;++n){const i=n*u-y;let h=i;for(;h<0;)h+=p;const g=Math.min(o.inHeight,f+i),v=T+n*I;for(let n=0;n<o.outWidth;++n){const i=n*c-b;let u=i;for(;u<0;)u+=d;const f=Math.min(o.inWidth,m+i),y=v+n*S;let x=w,_=0,I=0;for(let n=N;n<M;n+=l){const o=r+n*a[1];for(let n=h;n<g;n+=p){const r=o+n*a[2];for(let n=u;n<f;n+=d){const o=e[r+n*a[3]+t];if("max"===s&&o>x?x=o:"avg"===s&&(_+=o,I++),isNaN(x))break}if(isNaN(x))break}if(isNaN(x))break}k[y+t]="avg"===s?_/Math.max(I,1):x}}}}return v}const be={kernelName:r.ITk,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t;(0,a.q)(s,"avgPool");const{filterSize:i,strides:u,pad:c,dimRoundingMode:l}=o;r.euu.assert(r.cxb.eitherStridesOrDilationsAreOne(u,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${u} and dilations '1'`));const p=r.cxb.computePool2DInfo(s.shape,i,u,1,c,l);let h;if(1===p.filterWidth&&1===p.filterHeight&&r.euu.arraysEqual(p.inShape,p.outShape))h=d({inputs:{x:s},backend:n});else{const e=n.data.get(s.dataId).values,t=r.euu.computeStrides(s.shape),a=me(e,s.shape,s.dtype,t,p,"avg");h=n.makeTensorInfo(p.outShape,s.dtype,a.values)}return h}},we={kernelName:r.wre,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{filterSize:i,strides:u,pad:c,dimRoundingMode:l,dataFormat:p}=o;(0,a.q)(s,"avgPool3d");const d=r.cxb.computePool3DInfo(s.shape,i,u,1,c,l,p),h=ye(n.data.get(s.dataId).values,s.shape,s.dtype,r.euu.computeStrides(s.shape),d,"avg");return n.makeTensorInfo(h.shape,"float32",h.values)}},ve={kernelName:r.CSC,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{dy:s,input:i}=t,{filterSize:u,strides:c,pad:l,dimRoundingMode:p}=o;(0,a.q)([s,i],"avgPool3DGrad");const d=r.cxb.computePool3DInfo(i.shape,u,c,1,l,p),h=d.strideDepth,f=d.strideHeight,m=d.strideWidth,g=d.filterDepth,y=d.filterHeight,b=d.filterWidth,w=d.dilationDepth,v=d.dilationHeight,k=d.dilationWidth,x=d.effectiveFilterDepth,_=d.effectiveFilterHeight,I=d.effectiveFilterWidth,S=x-1-d.padInfo.front,N=I-1-d.padInfo.left,M=_-1-d.padInfo.top,T=(0,r.cz0)(i.shape,"float32"),E=1/(g*y*b),A=n.bufferSync(s);for(let e=0;e<d.batchSize;++e)for(let t=0;t<d.inChannels;++t)for(let n=0;n<d.inDepth;++n)for(let r=0;r<d.inHeight;++r)for(let a=0;a<d.inWidth;++a){const o=n-S,s=r-M,i=a-N;let u=0;for(let n=0;n<x;n+=w){const r=(o+n)/h;if(!(r<0||r>=d.outDepth||Math.floor(r)!==r))for(let n=0;n<_;n+=v){const a=(s+n)/f;if(!(a<0||a>=d.outHeight||Math.floor(a)!==a))for(let n=0;n<I;n+=k){const o=(i+n)/m;o<0||o>=d.outWidth||Math.floor(o)!==o||(u+=A.get(e,r,a,o,t))}}}T.set(u*E,e,n,r,a,t)}return n.makeTensorInfo(T.shape,T.dtype,T.values)}},ke={kernelName:r.S4W,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{dy:s,input:i}=t,u=i;(0,a.q)([s,i],"avgPoolGrad");const{filterSize:c,strides:l,pad:p}=o,d=r.cxb.computePool2DInfo(u.shape,c,l,1,p),h=d.strideHeight,f=d.strideWidth,m=d.filterHeight,g=d.filterWidth,y=d.dilationHeight,b=d.dilationWidth,w=d.effectiveFilterHeight,v=d.effectiveFilterWidth,k=v-1-d.padInfo.left,x=w-1-d.padInfo.top,_=(0,r.cz0)(u.shape,"float32"),I=1/(m*g),S=n.data.get(s.dataId).values,N=(0,r.cz0)(s.shape,"float32",S);for(let e=0;e<d.batchSize;++e)for(let t=0;t<d.inChannels;++t)for(let n=0;n<d.inHeight;++n)for(let r=0;r<d.inWidth;++r){const a=n-x,o=r-k;let s=0;for(let n=0;n<w;n+=y){const r=(a+n)/h;if(!(r<0||r>=d.outHeight||Math.floor(r)!==r))for(let n=0;n<v;n+=b){const a=(o+n)/f;a<0||a>=d.outWidth||Math.floor(a)!==a||(s+=N.get(e,r,a,t))}}_.set(s*I,e,n,r,t)}return n.makeTensorInfo(_.shape,_.dtype,_.values)}},xe={kernelName:r.Qxm,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,scale:i,offset:u,mean:c,variance:l}=t;r.euu.assert(c.shape.length===l.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),r.euu.assert(null==u||c.shape.length===u.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),r.euu.assert(null==i||c.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),(0,a.q)([s,c,l,i,u],"batchNorm");let{varianceEpsilon:p}=o;null==p&&(p=.001);const d=n.data.get(s.dataId).values,h=n.data.get(c.dataId).values,f=n.data.get(l.dataId).values,m=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,w=m.length,v=f.length,k=h.length;let x=0,_=0,I=0,S=0;for(let e=0;e<d.length;++e)y[e]=g[x++]+(d[e]-h[_++])*m[I++]/Math.sqrt(f[S++]+p),x>=b&&(x=0),_>=k&&(_=0),I>=w&&(I=0),S>=v&&(S=0);return n.makeTensorInfo(s.shape,s.dtype,y)}};var _e=n(23960);const Ie={kernelName:r.EV6,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}
vendor: 23,044 bytes, line 2
2=t,{blockShape:i,crops:u}=o;(0,a.q)([s],"batchToSpaceND");const c=i.reduce(((e,t)=>e*t)),l=r.cxb.getReshaped(s.shape,i,c),p=r.cxb.getPermuted(l.length,i.length),d=r.cxb.getReshapedPermuted(s.shape,i,c),h=r.cxb.getSliceBeginCoords(u,i.length),f=r.cxb.getSliceSize(d,u,i.length),m=z({inputs:{x:s},backend:n,attrs:{shape:l}}),g=Z({inputs:{x:m},backend:n,attrs:{perm:p}}),y=z({inputs:{x:g},backend:n,attrs:{shape:d}}),b=(0,_e.SM)({inputs:{x:y},backend:n,attrs:{begin:h,size:f}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(y),b}};function Se(e,t,n,a,o){const s=r.euu.sizeFromShape(a),i=r.euu.makeZerosTypedArray(o,n);for(let n=0;n<e.length;n++){const r=e[n];if(r<0)throw new Error("Input x must be non-negative!");r>=o||(i[r]+=s>0?t[n]:1)}return i}const Ne={kernelName:r.M3o,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:o}=t,{size:s}=r,i=Se(n.data.get(a.dataId).values,n.data.get(o.dataId).values,o.dtype,o.shape,s);return n.makeTensorInfo([s],o.dtype,i)}},Me=g(((e,t)=>e&t)),Te=C(r.eCV,Me),Ee={kernelName:r.eCV,backendName:"cpu",kernelFunc:Te},Ae={kernelName:r.orO,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:a,s1:o}=t,s=n.data.get(a.dataId).values,i=n.data.get(o.dataId).values,u=r.cxb.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return n.makeTensorInfo([u.length],"int32",Int32Array.from(u))}},Fe=i((e=>Math.ceil(e))),De=c(r.OeR,Fe),Oe={kernelName:r.OeR,backendName:"cpu",kernelFunc:De},Ce=u(r.Oe9,((e,t)=>{const n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e})),Pe={kernelName:r.Oe9,backendName:"cpu",kernelFunc:Ce},Re={kernelName:r.SmE,backendName:"cpu",kernelFunc:e=>{const{x:t}=e.inputs,n=e.backend,a=new Float32Array(r.euu.sizeFromShape(t.shape)),o=n.data.get(t.dataId),s=o.complexTensorInfos.real,i=o.complexTensorInfos.imag,u=n.data.get(s.dataId).values,c=n.data.get(i.dataId).values;for(let e=0;e<u.length;e++){const t=u[e],n=c[e];a[e]=Math.hypot(t,n)}return n.makeOutput(a,t.shape,"float32")}};var $e=n(91428);function Le(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.imag,o=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,o)}const We={kernelName:r.EV7,backendName:"cpu",kernelFunc:Le};function ze(e){const{inputs:t,backend:n,attrs:a}=e,{axis:o}=a,s=r.euu.parseAxisParam(o,t[0].shape)[0],i=t.map((e=>e.shape));r.cxb.assertParamsConsistent(i,s);let u=r.cxb.computeOutShape(t.map((e=>e.shape)),s);if(0===r.euu.sizeFromShape(u))return n.makeTensorInfo(u,t[0].dtype,[]);const c=t.filter((e=>r.euu.sizeFromShape(e.shape)>0));if(1===c.length)return d({inputs:{x:c[0]},backend:n});if("complex64"===c[0].dtype){const e=c.map((e=>A({inputs:{input:e},backend:n}))),t=c.map((e=>Le({inputs:{input:e},backend:n}))),r=ze({inputs:e,backend:n,attrs:{axis:s}}),a=ze({inputs:t,backend:n,attrs:{axis:s}}),o=M({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),o}const l=c.map((e=>{const t=r.euu.sizeFromShape(e.shape.slice(s));return z({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),p=l.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));u=r.cxb.computeOutShape(l.map((e=>e.shape)),1);const h=1===l[0].shape[0],f=(0,$e.m)(p,u,t[0].dtype,h),m=r.cxb.computeOutShape(c.map((e=>e.shape)),s),g=n.makeTensorInfo(m,t[0].dtype,f);return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),g}const Be={kernelName:r.usi,backendName:"cpu",kernelFunc:ze};function Ue(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,filter:i}=t,{strides:u,pad:c,dataFormat:l,dilations:p,dimRoundingMode:d}=o;(0,a.q)([s,i],"conv2d");const h=r.cxb.convertConv2DDataFormat(l),f=r.cxb.computeConv2DInfo(s.shape,i.shape,u,p,c,d,!1,h),m=f.filterHeight,g=f.filterWidth,y=f.dilationHeight,b=f.dilationWidth,w=f.padInfo.left,v=f.padInfo.top,k="channelsLast"===f.dataFormat,x=new r.Kq3(f.outShape,s.dtype),_=r.euu.computeStrides(s.shape),I=r.euu.computeStrides(i.shape),S=_[0],N=k?_[1]:_[2],M=k?_[2]:1,T=k?1:_[1],E=x.strides[0],A=k?x.strides[1]:x.strides[2],F=k?x.strides[2]:1,D=k?1:x.strides[1],O=n.data.get(s.dataId).values,C=n.data.get(i.dataId).values,P=x.values;for(let e=0;e<f.batchSize;++e){const t=e*S,n=e*E;for(let e=0;e<f.outHeight;++e){const r=n+e*A,a=e*f.strideHeight-v;for(let e=0;e<m;++e){const n=a+e*y;if(n<0||n>=f.inHeight)continue;const o=e*I[0],s=t+n*N;for(let e=0;e<f.outWidth;++e){const t=r+e*F,n=e*f.strideWidth-w;for(let e=0;e<g;++e){const r=n+e*b;if(r<0||r>=f.inWidth)continue;const a=s+r*M;let i=o+e*I[1];for(let e=0;e<f.inChannels;++e){const n=O[a+e*T];for(let e=0;e<f.outChannels;++e)P[t+e*D]+=n*C[i+e];i+=f.outChannels}}}}}}return n.makeTensorInfo(x.shape,x.dtype,P)}const He={kernelName:r.a_P,backendName:"cpu",kernelFunc:Ue},Ve={kernelName:r.OHx,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,dy:i}=t,{strides:u,pad:c,dataFormat:l,dimRoundingMode:p,filterShape:d}=o;(0,a.q)([s,i],"conv2dBackpropFilter");const h=r.cxb.convertConv2DDataFormat(l),f=r.cxb.computeConv2DInfo(s.shape,d,u,1,c,p,!1,h),{strideHeight:m,strideWidth:g,filterHeight:y,filterWidth:b}=f,w="channelsLast"===f.dataFormat,v=new r.Kq3(f.filterShape,"float32"),k=f.padInfo.left,x=f.padInfo.top,_=n.data.get(s.dataId).values,I=n.data.get(i.dataId).values,S=new r.Kq3(s.shape,s.dtype,_),N=new r.Kq3(i.shape,i.dtype,I);for(let e=0;e<y;++e){const t=Math.max(0,Math.ceil((x-e)/m)),n=Math.min(f.outHeight,(f.inHeight+x-e)/m);for(let r=0;r<b;++r){const a=Math.max(0,Math.ceil((k-r)/g)),o=Math.min(f.outWidth,(f.inWidth+k-r)/g);for(let s=0;s<f.inChannels;++s)for(let i=0;i<f.outChannels;++i){let u=0;for(let c=0;c<f.batchSize;++c)for(let l=t;l<n;++l){const t=e+l*m-x;for(let e=a;e<o;++e){const n=r+e*g-k;u+=w?S.get(c,t,n,s)*N.get(c,l,e,i):S.get(c,s,t,n)*N.get(c,i,l,e)}}v.set(u,e,r,s,i)}}}return n.makeTensorInfo(v.shape,v.dtype,v.values)}},Ge={kernelName:r.Mz5,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{dy:s,filter:i}=t,{inputShape:u,strides:c,pad:l,dataFormat:p,dimRoundingMode:d}=o;(0,a.q)([s,i],"conv2dBackpropInput");const h=r.euu.computeStrides(i.shape),f=r.euu.computeStrides(s.shape);let m=r.cxb.convertConv2DDataFormat(p);const g=r.cxb.computeConv2DInfo(u,i.shape,c,1,l,d,!1,m),y=new r.Kq3(g.inShape,"float32"),b=y.values,w=n.data.get(s.dataId).values,v=n.data.get(i.dataId).values,[k,x,_]=h,{batchSize:I,filterHeight:S,filterWidth:N,inChannels:M,inHeight:T,inWidth:E,outChannels:A,outHeight:F,outWidth:D,strideHeight:O,strideWidth:C}=g;m=g.dataFormat;const P=S-1-g.padInfo.top,R=N-1-g.padInfo.left,$="channelsLast"===m,L=y.strides[0],W=$?y.strides[1]:y.strides[2],z=$?y.strides[2]:1,B=$?1:y.strides[1],U=f[0],H=$?f[1]:f[2],V=$?f[2]:1,G=$?1:f[1];for(let e=0;e<I;++e)for(let t=0;t<M;++t)for(let n=0;n<T;++n){const r=n-P,a=Math.max(0,Math.ceil(r/O)),o=Math.min(F,(S+r)/O);for(let s=0;s<E;++s){const i=s-R,u=Math.max(0,Math.ceil(i/C)),c=Math.min(D,(N+i)/C);let l=0;for(let n=a;n<o;++n){const a=n*O-r;for(let r=u;r<c;++r){const o=U*e+H*n+V*r,s=k*(S-1-a)+x*(N-1-(r*C-i))+_*t;for(let e=0;e<A;++e)l+=w[o+G*e]*v[s+e]}}b[L*e+W*n+z*s+B*t]=l}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}},qe={kernelName:r.WE3,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,filter:i}=t,{strides:u,pad:c,dilations:l}=o;(0,a.q)([s,i],"conv3d");const p=r.cxb.computeConv3DInfo(s.shape,i.shape,u,l,c),{filterDepth:d,filterHeight:h,filterWidth:f,dilationDepth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=p,w=b.front,v=b.left,k=b.top,x=new r.Kq3(p.outShape,s.dtype),_=n.data.get(s.dataId).values,I=n.data.get(i.dataId).values,S=x.values,N=r.euu.computeStrides(s.shape),M=r.euu.computeStrides(i.shape);for(let e=0;e<p.batchSize;++e){const t=e*N[0],n=e*x.strides[0];for(let e=0;e<p.outDepth;++e){const r=n+e*x.strides[1],a=e*p.strideDepth-w;for(let e=0;e<d;++e){const n=a+e*m;if(n<0||n>=p.inDepth)continue;const o=e*M[0],s=t+n*N[1];for(let e=0;e<p.outHeight;++e){const t=r+e*x.strides[2],n=e*p.strideHeight-k;for(let e=0;e<h;++e){const r=n+e*g;if(r<0||r>=p.inHeight)continue;const a=o+e*M[1],i=s+r*N[2];for(let e=0;e<p.outWidth;++e){const n=t+e*p.outChannels,r=e*p.strideWidth-v;for(let e=0;e<f;++e){const t=r+e*y;if(t<0||t>=p.inWidth)continue;const o=a+e*M[2],s=i+t*p.inChannels;let u=o;for(let e=0;e<p.inChannels;++e){const t=_[s+e];for(let e=0;e<p.outChannels;++e)S[n+e]+=t*I[u+e];u+=p.outChannels}}}}}}}}return n.makeTensorInfo(x.shape,x.dtype,x.values)}},je={kernelName:r.QjG,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,dy:i}=t,{strides:u,pad:c,filterShape:l}=o;(0,a.q)([s,i],"conv3dBackpropFilterV2");const p=r.euu.computeStrides(s.shape),d=r.euu.computeStrides(i.shape),h=r.cxb.computeConv3DInfo(s.shape,l,u,1,c),f=h.strideDepth,m=h.strideHeight,g=h.strideWidth,y=h.filterDepth,b=h.filterHeight,w=h.filterWidth,v=new r.Kq3(h.filterShape,"float32"),k=v.values,[x,_,I,S]=v.strides,N=n.data.get(i.dataId).values,[M,T,E,A]=d,F=n.data.get(s.dataId).values,[D,O,C,P]=p,R=h.padInfo.front,$=h.padInfo.left,L=h.padInfo.top;for(let e=0;e<y;++e){const t=Math.max(0,Math.ceil((R-e)/f)),n=Math.min(h.outDepth,(h.inDepth+R-e)/f),r=e*x;for(let a=0;a<b;++a){const o=Math.max(0,Math.ceil((L-a)/m)),s=Math.min(h.outHeight,(h.inHeight+L-a)/m),i=a*_+r;for(let r=0;r<w;++r){const u=Math.max(0,Math.ceil(($-r)/g)),c=Math.min(h.outWidth,(h.inWidth+$-r)/g),l=r*I+i;for(let i=0;i<h.inChannels;++i){const p=i*S+l;for(let l=0;l<h.outChannels;++l){let d=0;for(let p=0;p<h.batchSize;++p){const h=p*D,y=p*M;for(let p=t;p<n;++p){const t=(e+p*f-R)*O+h,n=p*T+y;for(let e=o;e<s;++e){const o=(a+e*m-L)*C+t,s=e*E+n;for(let e=u;e<c;++e){const t=e*A+s;d+=F[(r+e*g-$)*P+o+i]*N[t+l]}}}}k[p+l]=d}}}}}return n.makeTensorInfo(v.shape,v.dtype,v.values)}},Ke={kernelName:r.ygG,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{dy:s,filter:i}=t,{pad:u,strides:c,inputShape:l}=o;(0,a.q)([s],"conv3dBackpropInputV2");const p=r.euu.computeStrides(s.shape),d=r.euu.computeStrides(i.shape),h=r.cxb.computeConv3DInfo(l,i.shape,c,1,u),f=new r.Kq3(h.inShape,"float32"),m=f.values,[g,y,b,w]=f.strides,v=n.data.get(s.dataId).values,[k,x,_,I]=p,S=n.data.get(i.dataId).values,[N,M,T,E]=d,{batchSize:A,filterDepth:F,filterHeight:D,filterWidth:O,inChannels:C,inDepth:P,inHeight:R,inWidth:$,outChannels:L,outDepth:W,outHeight:z,outWidth:B,strideDepth:U,strideHeight:H,strideWidth:V}=h,G=F-1-h.padInfo.front,q=D-1-h.padInfo.top,j=O-1-h.padInfo.left;for(let e=0;e<A;++e)for(let t=0;t<C;++t)for(let n=0;n<P;++n){const r=n-G,a=Math.max(0,Math.ceil(r/U)),o=Math.min(W,(F+r)/U);for(let s=0;s<R;++s){const i=s-q,u=Math.max(0,Math.ceil(i/H)),c=Math.min(z,(D+i)/H);for(let l=0;l<$;++l){const p=l-j,d=Math.max(0,Math.ceil(p/V)),h=Math.min(B,(O+p)/V);let f=0;for(let n=a;n<o;++n){const a=n*U-r;for(let r=u;r<c;++r){const o=r*H-i;for(let s=d;s<h;++s){const i=k*e+x*n+_*r+I*s,u=N*(F-1-a)+M*(D-1-o)+T*(O-1-(s*V-p))+E*t;for(let e=0;e<L;++e)f+=v[i+e]*S[u+e]}}}m[g*e+y*n+b*s+w*l+t]=f}}}return n.makeTensorInfo(f.shape,f.dtype,f.values)}},Qe=u(r.EHc,(e=>Math.cos(e))),Ye={kernelName:r.EHc,backendName:"cpu",kernelFunc:Qe},Je=u(r.YZ3,(e=>Math.cosh(e))),Ze={kernelName:r.YZ3,backendName:"cpu",kernelFunc:Je},Xe={kernelName:r.WO0,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{image:o,boxes:s,boxInd:i}=t,{cropSize:u,method:c,extrapolationValue:l}=a,[p,d,h,f]=o.shape,m=s.shape[0],[g,y]=u,b=(0,r.cz0)([m,g,y,f],"float32"),w=n.data.get(s.dataId).values,v=n.data.get(i.dataId).values,k=n.data.get(o.dataId).values,x=r.euu.computeStrides(o.shape),_=r.euu.computeStrides(b.shape);for(let e=0;e<m;e++){const t=4*e,n=w[t],r=w[t+1],a=w[t+2],o=w[t+3],s=v[e];if(s>=p)continue;const i=g>1?(a-n)*(d-1)/(g-1):0,u=y>1?(o-r)*(h-1)/(y-1):0;for(let t=0;t<g;t++){const p=g>1?n*(d-1)+t*i:.5*(n+a)*(d-1);if(p<0||p>d-1)for(let n=0;n<y;n++)for(let r=0;r<f;r++){const a=r+n*_[2]+t*_[1]+e*_[0];b.values[a]=l}else if("bilinear"===c){const n=Math.floor(p),a=Math.ceil(p),i=p-n;for(let c=0;c<y;c++){const p=y>1?r*(h-1)+c*u:.5*(r+o)*(h-1);if(p<0||p>h-1){for(let n=0;n<f;n++){const r=n+c*_[2]+t*_[1]+e*_[0];b.values[r]=l}continue}const d=Math.floor(p),m=Math.ceil(p),g=p-d;for(let r=0;r<f;r++){let o=r+d*x[2]+n*x[1]+s*x[0];const u=k[o];o=r+m*x[2]+n*x[1]+s*x[0];const l=k[o];o=r+d*x[2]+a*x[1]+s*x[0];const p=k[o];o=r+m*x[2]+a*x[1]+s*x[0];const h=u+(l-u)*g,f=p+(k[o]-p)*g;o=r+c*_[2]+t*_[1]+e*_[0],b.values[o]=h+(f-h)*i}}}else for(let n=0;n<y;++n){const a=y>1?r*(h-1)+n*u:.5*(r+o)*(h-1);if(a<0||a>h-1){for(let r=0;r<f;r++){const a=r+n*_[2]+t*_[1]+e*_[0];b.values[a]=l}continue}const i=Math.round(a),c=Math.round(p);for(let r=0;r<f;r++){const a=r+i*x[2]+c*x[1]+s*x[0],o=r+n*_[2]+t*_[1]+e*_[0];b.values[o]=k[a]}}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}},et={kernelName:r.yuV,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i,exclusive:u,reverse:c}=o;(0,a.q)(s,"cumprod");const l=r.cxb.getAxesPermutation([i],s.shape.length);let p=s;null!=l&&(p=Z({inputs:{x:s},backend:n,attrs:{perm:l}}));const d=r.cxb.getInnerMostAxes(1,s.shape.length)[0];if(d!==p.shape.length-1)throw new Error(`backend.cumprod in CPU expects an inner-most axis=${p.shape.length-1} but got axis=${d}`);const h=(0,r.OAw)(p.dtype,"int32"),f=r.euu.makeOnesTypedArray(r.euu.sizeFromShape(p.shape),h),m=n.data.get(p.dataId).values,g=p.shape[p.shape.length-1],y=c?(e,t)=>e+g-t-1:(e,t)=>e+t;for(let e=0;e<m.length;e+=g)for(let t=0;t<g;t++){const n=y(e,t);if(0===t)f[n]=u?1:m[n];else{const r=y(e,t-1);f[n]=u?m[r]*f[r]:m[n]*f[r]}}const b=n.makeTensorInfo(p.shape,h,f);if(null!=l){const e=Z({inputs:{x:b},backend:n,attrs:{perm:r.cxb.getUndoAxesPermutation(l)}});return n.disposeIntermediateTensorInfo(b),n.disposeIntermediateTensorInfo(p),e}return b}},tt={kernelName:r.gBx,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i,exclusive:u,reverse:c}=o;(0,a.q)(s,"cumsum");const l=r.cxb.getAxesPermutation([i],s.shape.length);let p=s;null!=l&&(p=Z({inputs:{x:s},backend:n,attrs:{perm:l}}));const d=r.cxb.getInnerMostAxes(1,s.shape.length)[0];if(d!==p.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${p.shape.length-1} but got axis=${d}`);const h=(0,r.OAw)(p.dtype,"int32"),f=r.euu.makeZerosTypedArray(r.euu.sizeFromShape(p.shape),h),m=n.data.get(p.dataId).values,g=p.shape[p.shape.length-1],y=c?(e,t)=>e+g-t-1:(e,t)=>e+t;for(let e=0;e<m.length;e+=g)for(let t=0;t<g;t++){const n=y(e,t);if(0===t)f[n]=u?0:m[n];else{const r=y(e,t-1);f[n]=u?m[r]+f[r]:m[n]+f[r]}}const b=n.makeTensorInfo(p.shape,h,f);if(null!=l){const e=Z({inputs:{x:b},backend:n,attrs:{perm:r.cxb.getUndoAxesPermutation(l)}});return n.disposeIntermediateTensorInfo(b),n.disposeIntermediateTensorInfo(p),e}return b}},nt={kernelName:r.COo,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:o,weights:s}=t,{size:i,binaryOutput:u}=a;if(1===o.shape.length){const e=Se(n.data.get(o.dataId).values,n.data.get(s.dataId).values,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,e)}if(2===o.shape.length){const e=function(e,t,n,a=!1){const o=e.shape[0],s=e.shape[1],i=(0,r.cz0)([o,n],t.dtype);for(let r=0;r<o;r++)for(let o=0;o<s;o++){const s=e.get(r,o);if(s<0)throw new Error("Input x must be non-negative!");s>=n||(a?i.set(1,r,s):t.size>0?i.set(i.get(r,s)+t.get(r,o),r,s):i.set(i.get(r,s)+1,r,s))}return i}(n.bufferSync(o),n.bufferSync(s),i,u);return n.makeTensorInfo(e.shape,s.dtype,e.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${o.shape.length}.`)}},rt={kernelName:r.OEe,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:o}=t,{blockSize:s,dataFormat:i}=a;r.euu.assert("NHWC"===i,(()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`));const u=o.shape[0],c=o.shape[1],l=o.shape[2],p=o.shape[3],d=c*s,h=l*s,f=p/(s*s),m=n.data.get(o.dataId).values,g=new Float32Array(u*d*h*f);let y=0;for(let e=0;e<u;++e)for(let t=0;t<d;++t){const n=Math.floor(t/s),r=t%s;for(let t=0;t<h;++t){const a=Math.floor(t/s),o=(r*s+t%s)*f;for(let t=0;t<f;++t){const r=t+o+p*(a+l*(n+c*e));g[y++]=m[r]}}}return n.makeTensorInfo([u,d,h,f],o.dtype,g)}};function at(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,filter:i}=t,{strides:u,pad:c,dilations:l,dimRoundingMode:p}=o;(0,a.q)([s,i],"depthwiseConv2DNative");const d=r.euu.computeStrides(s.shape),h=r.euu.computeStrides(i.shape);let f=l;null==f&&(f=[1,1]),r.euu.assert(r.cxb.eitherStridesOrDilationsAreOne(u,f),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${f}'`));const m=r.cxb.computeConv2DInfo(s.shape,i.shape,u,f,c,p,!0),{filterHeight:g,filterWidth:y,dilationHeight:b,dilationWidth:w,padInfo:v}=m,k=v.left,x=v.top,_=m.outChannels/m.inChannels,I=new r.Kq3(m.outShape,s.dtype),S=n.data.get(s.dataId).values,N=n.data.get(i.dataId).values,M=I.values;for(let e=0;e<m.batchSize;++e){const t=e*d[0],n=e*I.strides[0];for(let e=0;e<m.outHeight;++e){const r=n+e*I.strides[1],a=e*m.strideHeight-x;for(let e=0;e<g;++e){const n=a+e*b;if(n<0||n>=m.inHeight)continue;const o=e*h[0],s=t+n*d[1];for(let e=0;e<m.outWidth;++e){const t=r+e*I.strides[2],n=e*m.strideWidth-k;for(let e=0;e<y;++e){const r=n+e*w;if(r<0||r>=m.inWidth)continue;const a=o+e*h[1],i=s+r*m.inChannels;let u=t,c=a;for(let e=0;e<m.inChannels;++e){const t=S[i+e];for(let e=0;e<_;++e)M[u+e]+=t*N[c+e];u+=_,c+=_}}}}}}return n.makeTensorInfo(I.shape,I.dtype,I.values)}const ot={kernelName:r.Fql,backendName:"cpu",kernelFunc:at},st={kernelName:r.eKw,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,dy:i}=t,{strides:u,dilations:c,pad:l,dimRoundingMode:p,filterShape:d}=o;(0,a.q)([s,i],"depthwiseConv2dNativeBackpropFilter");const h=r.cxb.computeConv2DInfo(s.shape,d,u,c,l,p,!0),{strideHeight:f,strideWidth:m,filterHeight:g,filterWidth:y}=h,b=new r.Kq3(h.filterShape,"float32"),w=h.padInfo.left,v=h.padInfo.top,k=h.outChannels/h.inChannels,x=n.data.get(s.dataId).values,_=new r.Kq3(s.shape,s.dtype,x),I=n.data.get(i.dataId).values,S=new r.Kq3(i.shape,i.dtype,I);for(let e=0;e<g;++e){const t=Math.max(0,Math.ceil((v-e)/f)),n=Math.min(h.outHeight,(h.inHeight+v-e)/f);for(let r=0;r<y;++r){const a=Math.max(0,Math.ceil((w-r)/m)),o=Math.min(h.outWidth,(h.inWidth+w-r)/m);for(let s=0;s<h.outChannels;++s){const i=Math.trunc(s/k),u=s%k;let c=0;for(let u=0;u<h.batchSize;++u)for(let l=t;l<n;++l){const t=e+l*f-v;for(let e=a;e<o;++e){const n=r+e*m-w;c+=_.get(u,t,n,i)*S.get(u,l,e,s)}}b.set(c,e,r,i,u)}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}},it={kernelName:r.yoD,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{dy:s,filter:i}=t,{strides:u,dilations:c,pad:l,dimRoundingMode:p,inputShape:d}=o;(0,a.q)([s,i],"depthwiseConv2DNativeBackpropInput");const h=r.euu.computeStrides(s.shape),f=r.euu.computeStrides(i.shape),m=r.cxb.computeConv2DInfo(d,i.shape,u,c,l,p,!0),g=new r.Kq3(m.inShape,"float32"),y=g.values,[b,w,v]=g.strides,k=n.data.get(s.dataId).values,[x,_,I]=h,S=n.data.get(i.dataId).values,[N,M,T]=f,{batchSize:E,filterHeight:A,filterWidth:F,inChannels:D,inHeight:O,inWidth:C,outChannels:P,outHeight:R,outWidth:$,strideHeight:L,strideWidth:W}=m,z=A-1-m.padInfo.top,B=F-1-m.padInfo.left,U=P/D;for(let e=0;e<E;++e)for(let t=0;t<D;++t)for(let n=0;n<O;++n){const r=n-z,a=Math.max(0,Math.ceil(r/L)),o=Math.min(R,(A+r)/L);for(let s=0;s<C;++s){const i=s-B,u=Math.max(0,Math.ceil(i/W)),c=Math.min($,(F+i)/W);let l=0;for(let n=a;n<o;++n){const a=n*L-r;for(let r=u;r<c;++r){const o=x*e+_*n+I*r,s=N*(A-1-a)+M*(F-1-(r*W-i))+T*t;for(let e=0;e<U;++e)l+=k[o+(t*U+e)]*S[s+e]}}y[b*e+w*n+v*s+t]=l}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}},ut={kernelName:r.uIb,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:a}=t,o=r.euu.sizeFromShape(a.shape),s=n.data.get(a.dataId).values,i=(0,r.cz0)([o,o],a.dtype),u=i.values;for(let e=0;e<s.length;e++)u[e*o+e]=s[e];const c=[...a.shape,...a.shape];return n.makeTensorInfo(c,i.dtype,i.values)}},ct={kernelName:r.I7R,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:a,filter:o}=e,{strides:s,pad:i,dilations:u}=n,c=t,l=c.data.get(a.dataId).values,p=a.shape.length,d=c.data.get(o.dataId).values,h=o.shape.length,{batchSize:f,inHeight:m,inWidth:g,inChannels:y,outHeight:b,outWidth:w,padInfo:v,strideHeight:k,strideWidth:x,filterHeight:_,filterWidth:I,dilationHeight:S,dilationWidth:N,outShape:M}=r.cxb.computeDilation2DInfo(a.shape,o.shape,s,i,"NHWC",u),T=r.euu.sizeFromShape(M),E=M.length,A=r.euu.getArrayFromDType(a.dtype,T);for(let e=0;e<f;++e)for(let t=0;t<b;++t){const n=t*k-v.top;for(let s=0;s<w;++s){const i=s*x-v.left;for(let u=0;u<y;++u){let c=Number.MIN_SAFE_INTEGER;for(let t=0;t<_;++t){const s=n+t*S;if(s>=0&&s<m)for(let n=0;n<I;++n){const f=i+n*N;if(f>=0&&f<g){const i=r.euu.locToIndex([e,s,f,u],p,r.euu.computeStrides(a.shape)),m=r.euu.locToIndex([t,n,u],h,r.euu.computeStrides(o.shape)),g=l[i]+d[m];g>c&&(c=g)}}}A[r.euu.locToIndex([e,t,s,u],E,r.euu.computeStrides(M))]=c}}}return{dataId:c.write(r.euu.toTypedArray(A,a.dtype),M,a.dtype),shape:M,dtype:a.dtype}}},lt={kernelName:r.c1F,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:a,filter:o,dy:s}=e,{strides:i,pad:u,dilations:c}=n,l=t,p=r.euu.toNestedArray(a.shape,l.data.get(a.dataId).values),d=r.euu.toNestedArray(o.shape,l.data.get(o.dataId).values),{batchSize:h,inHeight:f,inWidth:m,inChannels:g,outHeight:y,outWidth:b,padInfo:w,strideHeight:v,strideWidth:k,filterHeight:x,filterWidth:_,dilationHeight:I,dilationWidth:S,outShape:N}=r.cxb.computeDilation2DInfo(a.shape,o.shape,i,u,"NHWC",c);r.euu.assert(s.rank===N.length,(()=>`Error in ${r.c1F}, dy must have the same rank as output ${N.length}, but got ${s.rank}`));const M=r.euu.toNestedArray(N,l.data.get(s.dataId).values),T=r.euu.makeZerosNestedTypedArray(o.shape,o.dtype);for(let e=0;e<h;++e)for(let t=0;t<y;++t){const n=t*v-w.top;for(let r=0;r<b;++r){const a=r*k-w.left;for(let o=0;o<g;++o){let s=Number.MIN_SAFE_INTEGER,i=0,u=0;for(let t=0;t<x;++t){const r=n+t*I;if(r>=0&&r<f)for(let n=0;n<_;++n){const c=a+n*S;if(c>=0&&c<m){const a=p[e][r][c][o]+d[t][n][o];a>s&&(s=a,i=t,u=n)}}}T[i][u][o]+=M[e][t][r][o]}}}return{dataId:l.write(r.euu.toTypedArray(T,a.dtype),o.shape,o.dtype),shape:o.shape,dtype:o.dtype}}},pt={kernelName:r.cFK,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:a,filter:o,dy:s}=e,{strides:i,pad:u,dilations:c}=n,l=t,p=r.euu.toNestedArray(a.shape,l.data.get(a.dataId).values),d=r.euu.toNestedArray(o.shape,l.data.get(o.dataId).values),{batchSize:h,inHeight:f,inWidth:m,inChannels:g,outHeight:y,outWidth:b,padInfo:w,strideHeight:v,strideWidth:k,filterHeight:x,filterWidth:_,dilationHeight:I,dilationWidth:S,outShape:N}=r.cxb.computeDilation2DInfo(a.shape,o.shape,i,u,"NHWC",c);r.euu.assert(s.rank===N.length,(()=>`Error in ${r.cFK}, dy must have the same rank as output ${N.length}, but got ${s.rank}
2`));const M=r.euu.toNestedArray(N,l.data.get(s.dataId).values),T=r.euu.makeZerosNestedTypedArray(a.shape,a.dtype);for(let e=0;e<h;++e)for(let t=0;t<y;++t){const n=t*v-w.top;for(let r=0;r<b;++r){const a=r*k-w.left;for(let o=0;o<g;++o){let s=Number.MIN_SAFE_INTEGER,i=n<0?0:n,u=a<0?0:a;for(let t=0;t<x;++t){const r=n+t*I;if(r>=0&&r<f)for(let n=0;n<_;++n){const c=a+n*S;if(c>=0&&c<m){const a=p[e][r][c][o]+d[t][n][o];a>s&&(s=a,i=r,u=c)}}}T[e][i][u][o]+=M[e][t][r][o]}}}return{dataId:l.write(r.euu.toTypedArray(T,a.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},dt={kernelName:r.IBu,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a}=t,{canvas:o,options:s}=r,{contextOptions:i,imageOptions:u}=s||{},c=(null==u?void 0:u.alpha)||1,l=(null==i?void 0:i.contextType)||"2d";if("2d"!==l)throw new Error(`Context type ${i.contextType} is not supported by the CPU backend.`);const p=o.getContext(l,(null==i?void 0:i.contextAttributes)||{});if(null==p)throw new Error(`Could not get the context with ${l} type.`);const[d,h]=a.shape.slice(0,2),f=2===a.shape.length?1:a.shape[2],m=n.data.get(a.dataId).values,g="float32"===a.dtype?255:1,y=new Uint8ClampedArray(h*d*4);for(let e=0;e<d*h;++e){const t=[0,0,0,255*c];for(let n=0;n<f;n++){const r=m[e*f+n];if("float32"===a.dtype){if(r<0||r>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${r}.`)}else if("int32"===a.dtype&&(r<0||r>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${r}.`);1===f?(t[0]=r*g,t[1]=r*g,t[2]=r*g):t[n]=r*g}const n=4*e;y[n+0]=Math.round(t[0]),y[n+1]=Math.round(t[1]),y[n+2]=Math.round(t[2]),y[n+3]=Math.round(t[3])}o.width=h,o.height=d;const b=new ImageData(y,h,d);return p.putImageData(b,0,0),a}},ht=g(((e,t)=>e*t)),ft=P(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),mt=C(r.SSu,ht,ft),gt={kernelName:r.SSu,backendName:"cpu",kernelFunc:mt};function yt(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i,keepDims:u}=o;let c;(0,a.q)(s,"sum"),c="bool"===s.dtype?D({inputs:{x:s},backend:n,attrs:{dtype:"int32"}}):d({inputs:{x:s},backend:n});const l=c.shape.length,p=r.euu.parseAxisParam(i,c.shape),h=r.cxb.getAxesPermutation(p,l);let f=p,m=c;null!=h&&(m=Z({inputs:{x:c},backend:n,attrs:{perm:h}}),f=r.cxb.getInnerMostAxes(f.length,l)),r.cxb.assertAxesAreInnerMostDims("sum",f,m.shape.length);const[g,y]=r.cxb.computeOutAndReduceShapes(m.shape,f);let b=E(n,g,r.cxb.upcastType(m.dtype,"int32"));const w=r.euu.sizeFromShape(y),v=n.data.get(b.dataId).values,k=n.data.get(m.dataId).values;for(let e=0;e<v.length;++e){const t=e*w;let n=0;for(let e=0;e<w;++e)n+=k[t+e];v[e]=n}if(u){const e=b;b=z({inputs:{x:b},backend:n,attrs:{shape:r.cxb.expandShapeToKeepDim(b.shape,p)}}),n.disposeIntermediateTensorInfo(e)}return n.disposeIntermediateTensorInfo(c),null!=h&&n.disposeIntermediateTensorInfo(m),b}const bt={kernelName:r.srk,backendName:"cpu",kernelFunc:yt},wt={kernelName:r._2b,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{equation:o}=a,s=t,{allDims:i,summedDims:u,idDims:c}=r.cxb.decodeEinsumEquation(o,s.length);r.cxb.checkEinsumDimSizes(i.length,c,s);const{path:l,steps:p}=r.cxb.getEinsumComputePath(u,c),d=p.length;let h=null,f=i.length;const m=[];for(let e=0;e<d;++e){for(const t of p[e]){const{permutationIndices:e,expandDims:a}=r.cxb.getEinsumPermutation(f,c[t]);let o;r.cxb.isIdentityPermutation(e)?o=s[t]:(o=Z({inputs:{x:s[t]},backend:n,attrs:{perm:e}}),m.push(o));const i=o.shape.slice();for(let e=0;e<a.length;++e)i.splice(a[e],0,1);r.euu.arraysEqual(o.shape,i)||(o=z({inputs:{x:o},backend:n,attrs:{shape:i}}),m.push(o)),null===h?h=o:(h=mt({inputs:{a:o,b:h},backend:n}),m.push(h))}e<d-1&&(l[e]>=0&&(h=yt({inputs:{x:h},backend:n,attrs:{axis:l[e]-(i.length-f),keepDims:!1}}),m.push(h)),f--)}for(const e of m)e!==h&&n.disposeIntermediateTensorInfo(e);return h}},vt={kernelName:r.Oyk,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{dy:o,y:s}=t;(0,a.q)([o,s],"eluGrad");const i=new Float32Array(r.euu.sizeFromShape(s.shape)),u=n.data.get(s.dataId).values,c=n.data.get(o.dataId).values;for(let e=0;e<u.length;++e){const t=u[e];i[e]=t>=0?c[e]:c[e]*(t+1)}return n.makeTensorInfo(s.shape,"float32",i)}},kt=g(((e,t)=>e===t?1:0)),xt=C(r.Ooc,kt,null,"bool"),_t={kernelName:r.Ooc,backendName:"cpu",kernelFunc:xt},It=r.cxb.ERF_P,St=r.cxb.ERF_A1,Nt=r.cxb.ERF_A2,Mt=r.cxb.ERF_A3,Tt=r.c
vendor: 5,236 bytes, line 2
2xb.ERF_A4,Et=r.cxb.ERF_A5,At=u(r._s9,(e=>{const t=Math.sign(e),n=Math.abs(e),r=1/(1+It*n);return t*(1-((((Et*r+Tt)*r+Mt)*r+Nt)*r+St)*r*Math.exp(-n*n))})),Ft={kernelName:r._s9,backendName:"cpu",kernelFunc:At},Dt=i((e=>Math.exp(e))),Ot=c(r.ox3,Dt,"float32"),Ct={kernelName:r.ox3,backendName:"cpu",kernelFunc:Ot};function Pt(e){const{inputs:t,backend:n,attrs:a}=e,{input:o}=t,{dim:s}=a,i=o.shape.length,u=o.shape.slice();let c=s;return s<0&&(r.euu.assert(-(i+1)<=s,(()=>`Axis must be in the interval [${-(i+1)}, ${i}]`)),c=i+s+1),u.splice(c,0,1),z({inputs:{x:o},backend:n,attrs:{shape:u}})}const Rt={kernelName:r.IbD,backendName:"cpu",kernelFunc:Pt},$t=i((e=>Math.expm1(e))),Lt=c(r.MrP,$t),Wt={kernelName:r.MrP,backendName:"cpu",kernelFunc:Lt},zt=g(((e,t)=>e/t)),Bt=C(r.uMf,zt),Ut={kernelName:r.uMf,backendName:"cpu",kernelFunc:Bt},Ht=g(((e,t)=>e-t)),Vt=P(((e,t,n,r)=>({real:e-n,imag:t-r}))),Gt=C(r.UVd,Ht,Vt),qt={kernelName:r.UVd,backendName:"cpu",kernelFunc:Gt};function jt(e,t,n){const a=e.shape,o=a[0],s=a[1],i=n.data.get(e.dataId),u=i.complexTensorInfos.real,c=i.complexTensorInfos.imag,l=[o,s],p=r.euu.sizeFromShape(l),d=r.euu.getTypedArrayFromDType("float32",p),h=r.euu.getTypedArrayFromDType("float32",p);for(let e=0;e<o;e++){const a=(0,_e.SM)({inputs:{x:u},backend:n,attrs:{begin:[e,0],size:[1,s]}}),o=(0,_e.SM)({inputs:{x:c},backend:n,attrs:{begin:[e,0],size:[1,s]}}),i=M({inputs:{real:a,imag:o},backend:n}),{real:l,imag:p}=Kt(i,t,n),f=r.cxb.mergeRealAndImagArrays(l,p);for(let t=0;t<s;t++){const n=r.cxb.getComplexWithIndex(f,t);d[e*s+t]=n.real,h[e*s+t]=n.imag}n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i)}const f=n.makeTensorInfo(l,"float32",d),m=n.makeTensorInfo(l,"float32",h),g=M({inputs:{real:f,imag:m},backend:n});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}function Kt(e,t,n){const a=r.euu.sizeFromShape(e.shape),o=n.data.get(e.dataId),s=n.data.get(o.complexTensorInfos.real.dataId).values,i=n.data.get(o.complexTensorInfos.imag.dataId).values;if(0==((u=a)&u-1)){const o=Qt(s,i,a,t,n),u=[e.shape[0],e.shape[1]];if(t){const e=n.makeTensorInfo(u,"float32",o.real),t=n.makeTensorInfo(u,"float32",o.imag),s=n.makeTensorInfo([],"float32",r.euu.createScalarValue(a,"float32")),i=d({inputs:{x:s},backend:n}),c=Ut.kernelFunc({inputs:{a:e,b:s},backend:n}),l=Ut.kernelFunc({inputs:{a:t,b:i},backend:n}),p=n.data.get(c.dataId).values,h=n.data.get(l.dataId).values;return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(l),{real:p,imag:h}}return o}{const e=function(e,t,n){const a=new Float32Array(2*t);for(let o=0;o<t;o++){let s=0,i=0;for(let a=0;a<t;a++){const u=r.cxb.exponent(o*a,t,n),c=r.cxb.getComplexWithIndex(e,a);s+=c.real*u.real-c.imag*u.imag,i+=c.real*u.imag+c.imag*u.real}n&&(s/=t,i/=t),r.cxb.assignToTypedArray(a,s,i,o)}return a}(r.cxb.mergeRealAndImagArrays(s,i),a,t);return r.cxb.splitRealAndImagArrays(e)}var u}function Qt(e,t,n,a,o){if(1===n)return{real:e,imag:t};const s=r.cxb.mergeRealAndImagArrays(e,t),i=n/2,u=r.cxb.complexWithEvenIndex(s),c=u.real,l=u.imag,p=[c.length],d=o.makeTensorInfo(p,"float32",c),h=o.makeTensorInfo(p,"float32",l),f=M({inputs:{real:d,imag:h},backend:o}),m=r.cxb.complexWithOddIndex(s),g=m.real,y=m.imag,b=[g.length],w=o.makeTensorInfo(b,"float32",g),v=o.makeTensorInfo(b,"float32",y),k=M({inputs:{real:w,imag:v},backend:o}),x=Qt(c,l,i,a,o),_=x.real,I=x.imag,S=[_.length],N=o.makeTensorInfo(S,"float32",_),T=o.makeTensorInfo(S,"float32",I),E=M({inputs:{real:N,imag:T},backend:o}),F=Qt(g,y,i,a,o),D=F.real,O=F.imag,C=[D.length],P=o.makeTensorInfo(C,"float32",D),R=o.makeTensorInfo(C,"float32",O),$=M({inputs:{real:P,imag:R},backend:o}),W=r.cxb.exponents(n,a),z=[W.real.length],B=o.makeTensorInfo(z,"float32",W.real),U=o.makeTensorInfo(z,"float32",W.imag),H=M({inputs:{real:B,imag:U},backend:o}),V=mt({inputs:{a:H,b:$},backend:o}),G=L({inputs:{a:E,b:V},backend:o}),q=Gt({inputs:{a:E,b:V},backend:o}),j=A({inputs:{input:G},backend:o}),K=A({inputs:{input:q},backend:o}),Q=Le({inputs:{input:G},backend:o}),Y=Le({inputs:{input:q},backend:o}),J=ze({inputs:[j,K],backend:o,attrs:{axis:0}}),Z=ze({inputs:[Q,Y],backend:o,attrs:{axis:0}}),X=o.data.get(J.dataId).values,ee=o.data.get(Z.dataId).values;return o.disposeIntermediateTensorInfo(d),o.disposeIntermediateTensorInfo(h),o.disposeIntermediateTensorInfo(f),o.disposeIntermediateTensorInfo(w),o.disposeIntermediateTensorInfo(v),o.disposeIntermediateTensorInfo(k),o.disposeIntermediateTensorInfo(N),o.disposeIntermediateTensorInfo(T),o.disposeIntermediateTensorInfo(E),o.disposeIntermediateTensorInfo(P),o.disposeIntermediateTensorInfo(R),o.disposeIntermediateTensorInfo($),o.disposeIntermediateTensorInfo(B),o.disposeIntermediateTensorInfo(U),o.disposeIntermediateTensorInfo(H),o.disposeIntermediateTensorInfo(V),o.disposeIntermediateTensorInfo(G),o.disposeIntermediateTensorInfo(q),o.disposeIntermediateTensorInfo(j),o.disposeIntermediateTensorInfo(Q),o.disposeIntermediateTensorInfo(K),o.disposeIntermediateTensorInfo(Y),o.disposeIntermediateTensorInfo(J),o.disposeIntermediateTensorInfo(Z
2),{real:X,imag:ee}}const Yt={kernelName:r.mkE,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:a}=t,o=r.euu.sizeFromShape(a.shape),s=a.shape[a.shape.length-1],i=z({inputs:{x:a},backend:n,attrs:{shape:[o/s,s]}}),u=jt(i,!1,n),c=z({inputs:{x:u},backend:n,attrs:{shape:a.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(u),c}};function Jt(e){const{backend:t,attrs:n}=e,{shape:a,value:o,dtype:s}=n,i=s||r.euu.inferDtype(o),u=r.euu.getArrayFromDType(i,r.euu.sizeFromShape(a));return function(e,t,n){e.fill(t)}(u,o),t.makeTensorInfo(a,i,u)}const Zt={kernelName:r.MnI,backendName:"cpu",kernelFunc:Jt},Xt={kernelName:r.ELw,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:a}=e,o=n,s=r.euu.getTypedArrayFromDType(a.dtype,r.euu.sizeFromShape(a.shape)),[i,u,c,l]=a.shape,p=o.data.get(a.dataId).values;for(let e=0;e<i;e++){const t=e*c*u*l;for(let e=0;e<u;e++){const n=e*(c*l);for(let e=0;e<c;e++){const r=e*l;for(let a=0;a<l;a++){const o=Math.round(c-e-1),i=t+n+r+a;let u=p[i];o>=0&&o<c&&(u=p[t+n+o*l+a]),s[i]=u}}}}return{dataId:o.write(s,a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},en=i((e=>Math.floor(e))),tn=c(r.WmE,en),nn={kernelName:r.WmE,backendName:"cpu",kernelFunc:tn},rn=g(((e,t)=>Math.floor(e/t))),an=C(r._6e,rn,null,"int32"),on={kernelName:r._6e,backendName:"cpu",kernelFunc:an},sn={kernelName:r.S4v,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o,bias:s,preluActivationWeights:i}=t,{strides:u,pad:c,dataFormat:l,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=Ue({inputs:{x:a,filter:o},backend:n,attrs:{strides:u,pad:c,dataFormat:l,dilations:p,dimRoundingMode:d}});if(s){const e=m;if("NCHW"===l&&1===s.shape.length&&1!==s.shape[0]){const e=z({inputs:{x:s},backend:n,attrs:{shape:[s.shape[0],1,1]}});m=L({inputs:{a:m,b:e},backend:n}),n.disposeIntermediateTensorInfo(e)}else m=L({inputs:{a:m,b:s},backend:n});n.disposeIntermediateTensorInfo(e)}if(h){const e=m;if("NCHW"===l&&"prelu"===h&&1===i.shape.length&&1!==i.shape[0]){const e=z({inputs:{x:i},backend:n,attrs:{shape:[i.shape[0],1,1]}});m=N(n,m,h,e,f),n.disposeIntermediateTensorInfo(e)}else m=N(n,m,h,i,f);n.disposeIntermediateTensorInfo(e)}return m}},un={kernelName:r.Mjd,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o,bias:s,preluActivationWeights:i}=t,{strides:u,pad:c,dataFormat:l,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=at({inputs:{x:a,filter:o},backend:n,attrs:{strides:u,pad:c,dataFormat:l,dilations:p,dimRoundingMode:d}});if(s){const e=m;m=L({inputs:{a:m,b:s},backend:n}),n.disposeIntermediateTensorInfo(e)}if(h){const e=m;m=N(n,m,h,i,f),n.disposeIntermediateTensorInfo(e)}return m}},cn={kernelName:r.SOJ,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{params:a,indices:o}=t,s=r.euu.sizeFromShape(a.shape),i=o.shape,u=i[i.length-1],[c,l,p,d]=r.cxb.prepareAndValidate(a,o);if(0===l)return n.makeTensorInfo(c,a.dtype,[]);const h=function(e,t,n,a,o,s,i,u,c){const l=(0,r.cz0)([a,s],n);for(let n=0;n<a;n++){const r=[];let a=0;for(let t=0;t<o;t++){const s=e[n*o+t];a+=s*i[t],r.push(s)}if(a<0||a>=c/s)throw new Error(`Invalid indices: ${r} does not index into ${u}`);for(let e=0;e<s;e++)l.values[n*s+e]=t.get(...t.indexToLoc(a*s+e))}return l}(n.data.get(o.dataId).values,n.bufferSync(a),a.dtype,l,u,p,d,a.shape,s);return n.makeTensorInfo(c,a.dtype,h.values)}},ln={kernelName:r.UV,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,indices:i}=t,{axis:u,batchDims:c}=o;(0,a.q)([s,i],"gatherV2");const l=r.euu.parseAxisParam(u,s.shape)[0],p=n.data.get(i.dataId).values,d=s.shape[l];for(let e=0;e<p.length;++e){const t=p[e];r.euu.assert(t<=d-1&&t>=0,(()=>`GatherV2: the index value ${t} is not in [0, ${d-1}]`))}let h=c;null==c&&(h=0);const f=r.euu.sizeFromShape(i.shape),m=r.cxb.segment_util.collectGatherOpShapeInfo(s,i,l,h),g=z({inputs:{x:s},backend:n,attrs:{shape:[m.batchSize,m.outerSize,m.dimSize,m.sliceSize]}}),y=z({inputs:{x:i},backend:n,attrs:{shape:[m.batchSize,f/m.batchSize]}}),b=[m.batchSize,m.outerSize,f/m.batchSize,m.sliceSize],w=n.bufferSync(y),v=function(e,t,n){const a=(0,r.cz0)(n,e.dtype);for(let n=0;n<a.size;++n){const r=a.indexToLoc(n).slice(),o=r[0],s=r[2],i=t.locToIndex([o,s]);r[2]=t.values[i];const u=e.locToIndex(r);0<=u&&u<e.values.length&&(a.values[n]=e.values[u])}return a}(n.bufferSync(g),w,b);return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(y),n.makeTensorInfo(m.outputShape,v.dtype,v.values)}},pn=g(((e,t)=>e>t?1:0)),dn=C(r.o3B,pn,null,"bool"),hn={kernelName:r.o3B,backendName:"cpu",kernelFunc:dn},fn=g(((e,t)=>e>=t?1:0)),mn=C(r.QD,fn,null,"bool"),gn={kernelName:r.QD,backendName:"cpu",kernelFunc:mn},yn={kernelName:r.OAQ,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}
vendor: 40,991 bytes, line 2
2=e,{input:a}=t,o=r.euu.sizeFromShape(a.shape),s=a.shape[a.shape.length-1],i=z({inputs:{x:a},backend:n,attrs:{shape:[o/s,s]}}),u=jt(i,!0,n),c=z({inputs:{x:u},backend:n,attrs:{shape:a.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(u),c}},bn=u(r.iwm,(e=>Number.isFinite(e)?1:0),"bool"),wn={kernelName:r.iwm,backendName:"cpu",kernelFunc:bn},vn=u(r.aMl,(e=>Math.abs(e)===1/0?1:0),"bool"),kn={kernelName:r.aMl,backendName:"cpu",kernelFunc:vn},xn=u(r.OiK,(e=>Number.isNaN(e)?1:0),"bool"),_n={kernelName:r.OiK,backendName:"cpu",kernelFunc:xn},In=g(((e,t)=>e<t?1:0)),Sn=C(r.GoJ,In,null,"bool"),Nn={kernelName:r.GoJ,backendName:"cpu",kernelFunc:Sn},Mn=g(((e,t)=>e<=t?1:0)),Tn=C(r.SMP,Mn,null,"bool"),En={kernelName:r.SMP,backendName:"cpu",kernelFunc:Tn},An={kernelName:r.Kst,backendName:"cpu",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:a,stop:o,num:s}=n,i=function(e,t,n){const a=(t-e)/(n-1),o=r.euu.makeZerosTypedArray(n,"float32");o[0]=e;for(let e=1;e<o.length;e++)o[e]=o[e-1]+a;return o}(a,o,s);return t.makeTensorInfo([i.length],"float32",i)}},Fn=i((e=>Math.log(e))),Dn=c(r.qwJ,Fn),On={kernelName:r.qwJ,backendName:"cpu",kernelFunc:Dn},Cn=u(r.eg6,(e=>Math.log1p(e))),Pn={kernelName:r.eg6,backendName:"cpu",kernelFunc:Cn},Rn=g(((e,t)=>e&&t)),$n=C(r.SSA,Rn,null,"bool"),Ln={kernelName:r.SSA,backendName:"cpu",kernelFunc:$n},Wn=u(r._S1,(e=>e?0:1),"bool"),zn={kernelName:r._S1,backendName:"cpu",kernelFunc:Wn},Bn=g(((e,t)=>e||t)),Un=C(r.whD,Bn,null,"bool"),Hn={kernelName:r.whD,backendName:"cpu",kernelFunc:Un},Vn={kernelName:r.wfw,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{depthRadius:i,bias:u,alpha:c,beta:l}=o;(0,a.q)(s,"LRN");const p=s.shape[3],d=p-1,h=n.data.get(s.dataId).values,f=r.euu.sizeFromShape(s.shape),m=new Float32Array(f);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<f;e++){const t=g(e),n=h[e]*Math.pow(u+c*t,-l);m[e]=n}return n.makeTensorInfo(s.shape,s.dtype,m)}},Gn={kernelName:r.SAF,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,y:i,dy:u}=t,{depthRadius:c,bias:l,alpha:p,beta:d}=o;(0,a.q)(u,"LRNGrad");const h=r.euu.sizeFromShape(u.shape),f=u.shape[3],m=n.data.get(u.dataId).values,g=n.data.get(s.dataId).values,y=n.data.get(i.dataId).values,b=new Float32Array(h),w=h;for(let e=0;e<w;e++){const t=e%f,n=e-t+Math.max(0,t-c),r=e-t+Math.min(f,t+c+1);let a=0;for(let e=n;e<r;e++)a+=Math.pow(g[e],2);a=p*a+l;for(let t=n;t<r;t++){let n=-2*p*d*g[t]*y[e]/a;e===t&&(n+=Math.pow(a,-d)),n*=m[e],b[t]+=n}}return n.makeTensorInfo(u.shape,s.dtype,b)}};function qn(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{reductionIndices:i,keepDims:u}=o,c=n;let l=s.shape;const p=l.length,d=r.euu.parseAxisParam(i,l);let h=d;const f=r.cxb.getAxesPermutation(h,p);let m=c.data.get(s.dataId).values;if(null!=f){const e=new Array(p);for(let t=0;t<e.length;t++)e[t]=l[f[t]];m=J(m,l,s.dtype,f,e),h=r.cxb.getInnerMostAxes(h.length,p),l=e}(0,a.q)(s,"max"),r.cxb.assertAxesAreInnerMostDims("max",h,p);const[g,y]=r.cxb.computeOutAndReduceShapes(l,h),b=function(e,t,n,a){const o=r.euu.getTypedArrayFromDType(a,r.euu.sizeFromShape(n));for(let n=0;n<o.length;++n){const r=n*t;let a=e[r];for(let n=0;n<t;++n){const t=e[r+n];(Number.isNaN(t)||t>a)&&(a=t)}o[n]=a}return o}(m,r.euu.sizeFromShape(y),g,s.dtype),w=c.write(b,g,s.dtype);let v=g;return u&&(v=r.cxb.expandShapeToKeepDim(g,d)),{dataId:w,shape:v,dtype:s.dtype}}const jn={kernelName:r.aUJ,backendName:"cpu",kernelFunc:qn},Kn=g(((e,t)=>Math.max(e,t))),Qn=C(r.qik,Kn),Yn={kernelName:r.qik,backendName:"cpu",kernelFunc:Qn},Jn={kernelName:r.MNi,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t;(0,a.q)(s,"maxPool");const{filterSize:i,strides:u,pad:c,dimRoundingMode:l}=o;r.euu.assert(r.cxb.eitherStridesOrDilationsAreOne(u,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${u} and dilations '1'`));const p=r.cxb.computePool2DInfo(s.shape,i,u,1,c,l);let h;if(1===p.filterWidth&&1===p.filterHeight&&r.euu.arraysEqual(p.inShape,p.outShape))h=d({inputs:{x:s},backend:n});else{const e=n.data.get(s.dataId).values,t=r.euu.computeStrides(s.shape),a=me(e,s.shape,s.dtype,t,p,"max");h=n.makeTensorInfo(p.outShape,s.dtype,a.values)}return h}},Zn={kernelName:r.C4i,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{filterSize:i,strides:u,pad:c,dimRoundingMode:l,dataFormat:p}=o;(0,a.q)(s,"maxPool3d");const d=r.cxb.computePool3DInfo(s.shape,i,u,1,c,l,p),h=ye(n.data.get(s.dataId).values,s.shape,s.dtype,r.euu.computeStrides(s.shape),d,"max");return n.makeTensorInfo(h.shape,"float32",h.values)}},Xn={kernelName:r.amh,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{dy:s,input:i}=t,{filterSize:u,strides:c,pad:l,dimRoundingMode:p}=o;(0,a.q)([s,i],"maxPool3DGrad");const d=r.cxb.computePool3DInfo(i.shape,u,c,1,l,p),h=function(e,t){const n=(0,r.cz0)(t.outShape,"int32"),a=t.strideDepth,o=t.strideHeight,s=t.strideWidth,i=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterDepth,p=t.effectiveFilterHeight,d=t.effectiveFilterWidth,h=t.padInfo.front,f=t.padInfo.top,m=t.padInfo.left;for(let r=0;r<t.batchSize;++r)for(let g=0;g<t.inChannels;++g)for(let y=0;y<t.outDepth;++y){const b=y*a-h;let w=b;for(;w<0;)w+=i;const v=Math.min(t.inDepth,l+b);for(let a=0;a<t.outHeight;++a){const l=a*o-f;let h=l;for(;h<0;)h+=u;const k=Math.min(t.inHeight,p+l);for(let o=0;o<t.outWidth;++o){const f=o*s-m;let x=f;for(;x<0;)x+=c;const _=Math.min(t.inWidth,d+f);let I=Number.NEGATIVE_INFINITY,S=-1;for(let t=w;t<v;t+=i){const n=t-b;for(let a=h;a<k;a+=u){const o=a-l;for(let s=x;s<_;s+=c){const i=s-f,u=e.get(r,t,a,s,g);u>=I&&(I=u,S=n*p*d+o*p+i)}}}n.set(S,r,y,a,o,g)}}}return n}(n.bufferSync(i),d),f=d.strideDepth,m=d.strideHeight,g=d.strideWidth,y=d.dilationDepth,b=d.dilationHeight,w=d.dilationWidth,v=d.effectiveFilterDepth,k=d.effectiveFilterHeight,x=d.effectiveFilterWidth,_=v-1-d.padInfo.front,I=x-1-d.padInfo.left,S=k-1-d.padInfo.top,N=(0,r.cz0)(i.shape,"float32"),M=n.bufferSync(s);for(let e=0;e<d.batchSize;++e)for(let t=0;t<d.inChannels;++t)for(let n=0;n<d.inDepth;++n)for(let r=0;r<d.inHeight;++r)for(let a=0;a<d.inWidth;++a){const o=n-_,s=r-S,i=a-I;let u=0;for(let n=0;n<v;n+=y){const r=(o+n)/f;if(!(r<0||r>=d.outDepth||Math.floor(r)!==r))for(let a=0;a<k;a+=b){const o=(s+a)/m;if(!(o<0||o>=d.outHeight||Math.floor(o)!==o))for(let s=0;s<x;s+=w){const c=(i+s)/g;if(c<0||c>=d.outWidth||Math.floor(c)!==c)continue;const l=v*k*x-1-h.get(e,r,o,c,t)===n*k*x+a*x+s?1:0;0!==l&&(u+=M.get(e,r,o,c,t)*l)}}}N.set(u,e,n,r,a,t)}return n.makeTensorInfo(N.shape,N.dtype,N.values)}},er={kernelName:r.AdS,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{dy:s,input:i,output:u}=t,c=i;(0,a.q)([i,u],"maxPoolGrad");const{filterSize:l,strides:p,pad:d,dimRoundingMode:h}=o,f=r.cxb.computePool2DInfo(c.shape,l,p,1,d,h),m=n.data.get(c.dataId).values,g=(0,r.cz0)(f.outShape,c.dtype,ge(m,c.shape,c.dtype,f).values),y=f.strideHeight,b=f.strideWidth,w=f.dilationHeight,v=f.dilationWidth,k=f.effectiveFilterHeight,x=f.effectiveFilterWidth,_=x-1-f.padInfo.left,I=k-1-f.padInfo.top,S=(0,r.cz0)(c.shape,"float32"),N=n.data.get(s.dataId).values,M=(0,r.cz0)(s.shape,"float32",N);for(let e=0;e<f.batchSize;++e)for(let t=0;t<f.inChannels;++t)for(let n=0;n<f.inHeight;++n)for(let r=0;r<f.inWidth;++r){const a=n-I,o=r-_;let s=0;for(let n=0;n<k;n+=w){const r=(a+n)/y;if(!(r<0||r>=f.outHeight||Math.floor(r)!==r))for(let a=0;a<x;a+=v){const i=(o+a)/b;if(i<0||i>=f.outWidth||Math.floor(i)!==i)continue;const u=k*x-1-g.get(e,r,i,t)===n*x+a?1:0;0!==u&&(s+=M.get(e,r,i,t)*u)}}S.set(s,e,n,r,t)}return n.makeTensorInfo(S.shape,S.dtype,S.values)}},tr={kernelName:r.yqo,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:o}=e,{filterSize:s,strides:i,pad:u,includeBatchInIndex:c}=t,l=n;(0,a.q)(o,"MaxPoolWithArgmax");const p=l.data.get(o.dataId).values,d=r.cxb.computePool2DInfo(o.shape,s,i,[1,1],u),[h,f]=function(e,t,n,a,o){const s=me(e,0,n,r.euu.computeStrides(t),o,"max"),i=ge(e,t,n,o,!0,a);return[s.values,i.values]}(p,o.shape,o.dtype,c,d),m=l.write(h,d.outShape,o.dtype),g=l.write(f,d.outShape,o.dtype);return[{dataId:m,shape:d.outShape,dtype:o.dtype},{dataId:g,shape:d.outShape,dtype:"int32"}]}},nr={kernelName:r.iN$,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:o}=t,{axis:s,keepDims:i}=a,u=r.euu.parseAxisParam(s,o.shape),c=r.cxb.computeOutAndReduceShapes(o.shape,u)[1],l=r.euu.sizeFromShape(c),p=[],d=n.makeTensorInfo([],"float32",new Float32Array([l]));p.push(d);const h=D({inputs:{x:o},backend:n,attrs:{dtype:"float32"}});p.push(h);const f=Bt({inputs:{a:h,b:d},backend:n});p.push(f);const m=yt({inputs:{x:f},backend:n,attrs:{axis:s,keepDims:i}});return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),m}},rr={kernelName:r.WW2,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i,keepDims:u}=o;(0,a.q)(s,"min");const c=r.euu.parseAxisParam(i,s.shape);let l=c;const p=r.cxb.getAxesPermutation(l,s.shape.length);let d=s;null!=p&&(d=Z({inputs:{x:s},backend:n,attrs:{perm:p}}),l=r.cxb.getInnerMostAxes(l.length,s.shape.length)),r.cxb.assertAxesAreInnerMostDims("min",l,d.shape.length);const[h,f]=r.cxb.computeOutAndReduceShapes(d.shape,l),m=r.euu.sizeFromShape(f),g=r.euu.makeZerosTypedArray(r.euu.sizeFromShape(h),d.dtype),y=n.data.get(d.dataId).values;for(let e=0;e<g.length;++e){const t=e*m;let n=y[t];for(let e=0;e<m;++e){const r=y[t+e];(Number.isNaN(r)||r<n)&&(n=r)}g[e]=n}null!=p&&n.disposeIntermediateTensorInfo(d);const b=n.makeTensorInfo(h,d.dtype,g);if(u){const e=z({inputs:{x:b},backend:n,attrs:{shape:r.cxb.expandShapeToKeepDim(h,c)}});return n.disposeIntermediateTensorInfo(b),e}return b}},ar=g(((e,t)=>Math.min(e,t))),or=C(r.sly,ar),sr={kernelName:r.sly,backendName:"cpu",kernelFunc:or},ir={kernelName:r.C6u,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{paddings:i,mode:u}=o;(0,a.q)(s,"mirrorPad");const c=i.map(((e,t)=>e[0]+s.shape[t]+e[1])),l=i.map((e=>e[0])),p=i.map(((e,t)=>e[0]+s.shape[t])),d="reflect"===u?0:1,h=n.data.get(s.dataId).values,f=s.shape.length,m=r.euu.computeStrides(s.shape),g=r.euu.sizeFromShape(c),y=c.length,b=r.euu.computeStrides(c),w=r.euu.getTypedArrayFromDType(s.dtype,g);for(let e=0;e<g;e++){let t=r.euu.indexToLoc(e,y,b);for(let e=0;e<y;e++)t[e]<l[e]?t[e]=2*l[e]-t[e]-d:t[e]>=p[e]&&(t[e]=2*(p[e]-1)-t[e]+d);t=t.map(((e,t)=>e-l[t]));const n=r.euu.locToIndex(t,f,m);w[e]=h[n]}return{dataId:n.write(w,c,s.dtype),shape:c,dtype:s.dtype}}},ur=g(((e,t)=>{const n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),cr=C(r.InO,ur),lr={kernelName:r.InO,backendName:"cpu",kernelFunc:cr};var pr=n(4792);function dr(e){const{inputs:t,backend:n,attrs:a}=e,{logits:o}=t,{dim:s}=a,i=o.shape.length;let u=s;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 c=r.euu.parseAxisParam([u],o.shape),l=qn({inputs:{x:o},backend:n,attrs:{reductionIndices:c,keepDims:!1}}),p=r.cxb.expandShapeToKeepDim(l.shape,c),d=z({inputs:{x:l},backend:n,attrs:{shape:p}}),h=Gt({inputs:{a:o,b:d},backend:n}),f=Ot({inputs:{x:h},backend:n}),m=yt({inputs:{x:f},backend:n,attrs:{axis:c,keepDims:!1}}),g=z({inputs:{x:m},backend:n,attrs:{shape:p}}),y=Bt({inputs:{a:f,b:g},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),y}const hr={kernelName:r.a0o,backendName:"cpu",kernelFunc:dr},fr={kernelName:r.UdG,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{logits:s}=t,{numSamples:i,seed:u,normalized:c}=o;(0,a.q)(s,"multinomial");const l=c?s:dr({inputs:{logits:s},backend:n,attrs:{dim:-1}}),p=l.shape[0],d=l.shape[1],h=n.data.get(l.dataId).values,f=[p,i],m=r.euu.makeZerosTypedArray(r.euu.sizeFromShape(f),"int32");for(let e=0;e<p;++e){const t=e*d,n=new Float32Array(d-1);n[0]=h[t];for(let e=1;e<n.length;++e)n[e]=n[e-1]+h[t+e];const r=pr.alea(u.toString()),a=e*i;for(let e=0;e<i;++e){const t=r();m[a+e]=n.length;for(let r=0;r<n.length;r++)if(t<n[r]){m[a+e]=r;break}}}return c||n.disposeIntermediateTensorInfo(l),n.makeTensorInfo(f,"int32",m)}},mr={kernelName:r.yUy,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:o}=t;(0,a.q)(o,"neg");const s=n.data.get(o.dataId).values,[i,u]=function(e,t,n){const a=r.euu.createScalarValue(-1,n);return ht([],t,a,e,n)}(s,o.shape,o.dtype);return n.makeTensorInfo(u,o.dtype,i)}},gr=r.lKA.Wm,yr={kernelName:r.aaw,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{boxes:o,scores:s}=t,{maxOutputSize:i,iouThreshold:u,scoreThreshold:c}=r;(0,a.q)(o,"NonMaxSuppression");const l=n.data.get(o.dataId).values,p=n.data.get(s.dataId).values,{selectedIndices:d}=gr(l,p,i,u,c);return n.makeTensorInfo([d.length],"int32",new Int32Array(d))}},br=r.lKA.Mf,wr={kernelName:r.Q7n,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{boxes:o,scores:s}=t,{maxOutputSize:i,iouThreshold:u,scoreThreshold:c,padToMaxOutputSize:l}=r;(0,a.q)(o,"NonMaxSuppressionPadded");const p=n.data.get(o.dataId).values,d=n.data.get(s.dataId).values,{selectedIndices:h,validOutputs:f}=br(p,d,i,u,c,l);return[n.makeTensorInfo([h.length],"int32",new Int32Array(h)),n.makeTensorInfo([],"int32",new Int32Array([f]))]}},vr=r.lKA.eQ,kr={kernelName:r.q82,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{boxes:o,scores:s}=t,{maxOutputSize:i,iouThreshold:u,scoreThreshold:c,softNmsSigma:l}=r;(0,a.q)(o,"NonMaxSuppressionWithScore");const p=n.data.get(o.dataId).values,d=n.data.get(s.dataId).values,h=i,f=u,m=c,g=l,{selectedIndices:y,selectedScores:b}=vr(p,d,h,f,m,g);return[n.makeTensorInfo([y.length],"int32",new Int32Array(y)),n.makeTensorInfo([b.length],"float32",new Float32Array(b))]}},xr=g(((e,t)=>e!==t?1:0)),_r=C(r.Ki5,xr,null,"bool"),Ir={kernelName:r.Ki5,backendName:"cpu",kernelFunc:_r},Sr={kernelName:r.mon,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{indices:s}=t,{dtype:i,depth:u,onValue:c,offValue:l}=o;(0,a.q)(s,"oneHot");const p=r.euu.sizeFromShape(s.shape),d=new Float32Array(p*u);d.fill(l);const h=n.data.get(s.dataId).values;for(let e=0;e<p;++e)h[e]>=0&&h[e]<u&&(d[e*u+h[e]]=c);return n.makeTensorInfo([...s.shape,u],i,d)}};function Nr(e){const{inputs:t,backend:n}=e,{x:r}=t;if("string"===r.dtype)throw new Error("zerosLike is not supported for string tensors");if("complex64"===r.dtype){const e=A({inputs:{input:r},backend:n}),t=Nr({inputs:{x:e},backend:n}),a=Le({inputs:{input:r},backend:n}),o=Nr({inputs:{x:a},backend:n}),s=M({inputs:{real:t,imag:o},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),s}return Jt({backend:n,attrs:{shape:r.shape,value:0,dtype:r.dtype}})}const Mr={kernelName:r.qKC,backendName:"cpu",kernelFunc:Nr},Tr={kernelName:r.O_l,backendName:"cpu",kernelFunc:function e(t){const{inputs:n,backend:r}=t,{x:a}=n;if("string"===a.dtype)throw new Error("onesLike is not supported for string tensors");if("complex64"===a.dtype){const t=A({inputs:{input:a},backend:r}),n=e({inputs:{x:t},backend:r}),o=Le({inputs:{input:a},backend:r}),s=Nr({inputs:{x:o},backend:r}),i=M({inputs:{real:n,imag:s},backend:r});return r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),i}return Jt({backend:r,attrs:{shape:a.shape,value:1,dtype:a.dtype}})}};function Er(e){const{inputs:t,backend:n,attrs:a}=e,{axis:o}=a;if(1===t.length)return Pt({inputs:{input:t[0]},backend:n,attrs:{dim:o}});const s=t[0].shape,i=t[0].dtype;t.forEach((e=>{r.euu.assertShapesMatch(s,e.shape,"All tensors passed to stack must have matching shapes"),r.euu.assert(i===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const u=[],c=ze({inputs:t.map((e=>{const t=Pt({inputs:{input:e},backend:n,attrs:{dim:o}});return u.push(t),t})),backend:n,attrs:{axis:o}});return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}const Ar={kernelName:r.cJi,backendName:"cpu",kernelFunc:Er},Fr={kernelName:r.Q8A,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{paddings:i,constantValue:u}=o;(0,a.q)(s,"pad");const c=i.map(((e,t)=>e[0]+s.shape[t]+e[1])),l=i.map((e=>e[0])),p=n.data.get(s.dataId).values,d=r.euu.sizeFromShape(s.shape),h=s.shape.length,f=r.euu.computeStrides(s.shape),m=r.euu.sizeFromShape(c),g=c.length,y=r.euu.computeStrides(c),b=r.euu.getTypedArrayFromDType(s.dtype,m);0!==u&&b.fill(u);for(let e=0;e<d;e++){const t=r.euu.indexToLoc(e,h,f).map(((e,t)=>e+l[t]));b[r.euu.locToIndex(t,g,y)]=p[e]}return{dataId:n.write(b,c,s.dtype),shape:c,dtype:s.dtype}}},Dr=g(((e,t)=>Math.pow(e,t))),Or=C(r.sTH,Dr),Cr={kernelName:r.sTH,backendName:"cpu",kernelFunc:Or},Pr={kernelName:r.e_0,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{axis:i,keepDims:u}=o;(0,a.q)(s,"prod");const c=s.shape.length,l=r.euu.parseAxisParam(i,s.shape),p=r.cxb.getAxesPermutation(l,c);let d=l,h=s;const f=[];null!=p&&(h=Z({inputs:{x:s},backend:n,attrs:{perm:p}}),f.push(h),d=r.cxb.getInnerMostAxes(d.length,c));const m=n.data.get(h.dataId).values,{outVals:g,outShape:y,outDtype:b}=function(e,t,n,a){const[o,s]=r.cxb.computeOutAndReduceShapes(e,a),i=(0,r.OAw)(t,"int32"),u=r.euu.makeZerosTypedArray(r.euu.sizeFromShape(o),i),c=r.euu.sizeFromShape(s);for(let e=0;e<u.length;++e){const t=e*c;let r=1;for(let e=0;e<c;++e)r*=n[t+e];u[e]=r}return{outVals:u,outShape:o,outDtype:i}}(h.shape,h.dtype,m,d);let w=y;return u&&(w=r.cxb.expandShapeToKeepDim(y,l)),f.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(w,b,g)}};function Rr(e,t){const n=e.slice(0,t);for(;n.length<t;)n.push(1);for(let r=t;r<e.length;r++)n[t-1]*=e[r];return n}function $r(e,t,n,a,o,s,i,u){if(0===e.length)throw new Error("paramsNestedSplits must be non empty");if(0===t[0].length)throw new Error("Split tensors must not be scalars");if(function(e,t,n){e.forEach(((e,a)=>{if(e<0||e>=n){const o=r.euu.indexToLoc(a,t.length,r.euu.computeStrides(t)).join(",");throw new Error(`indices[${o}] = ${e} is not in [0, ${n})`)}}))}(s,i,t[0][0]-1),0===a.length)throw new Error("params.rank must be nonzero");const c=a[0],{outSplits:l,valueSlices:p,numValues:d}=function(e,t,n,r){const a=[];let o=0;const s=t.length-1+n.length,i=new Array(s).fill(null).map((()=>[0]));!function(e,t){for(let n=0;n<e.length;++n){const r=e[n],a=n===e.length-1?t:e[n+1].length;if(0===r.length)throw new Error("Ragged splits may not be empty");if(r[0]<0)throw new Error("Ragged splits must be non-negative");if(r[r.length-1]>a)throw new Error("Ragged splits must not point past values");for(let e=1;e<r.length;++e)if(r[e-1]>r[e])throw new Error("Ragged splits must be sorted in ascending order")}}(n,r);let u=1;for(let e=0;e<t.length-1;++e){u*=t[e];const n=t[e+1];for(let t=1;t<u+1;++t)i[e].push(t*n)}for(let r=0;r<e.length;++r){let s=e[r],u=e[r]+1;for(let e=0;e<n.length;++e){const r=n[e],a=e+t.length-1;if(a>=0){const e=i[a],t=e[e.length-1]-r[s];for(let e=s;e<u;++e)i[a].push(r[e+1]+t)}s=r[s],u=r[u]}u!==s&&(a.push([s,u]),o+=u-s)}return{outSplits:i,valueSlices:a,numValues:o}}(s,i,e,c),h=function(e){const t=[];for(let n=0;n<e.length;++n){const a=e[n].length,o=r.euu.getArrayFromDType("int32",a);t.push(o),e[n].forEach(((e,t)=>o[t]=e))}return t}(l),f=function(e,t,n,a,o){const s=t.slice();s[0]=o;const i=r.euu.getArrayFromDType(n,r.euu.sizeFromShape(s)),u=e.length;return function(e,t,n,r,a,o){const s=Rr(t,2)[1],i=Rr(o,2)[1];let u=0;for(const t of n)for(let n=t[0];n<t[1];++n){for(let t=0;t<r;++t)a[u*i+t]=e[n*s+t];++u}}(e,t,a,0===u?0:u/t[0],i,s),[i,s]}(n,a,o,p,d);return[h,f[0],f[1]]}const Lr={kernelName:r.KGR,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{paramsNestedSplits:a,paramsDenseValues:o,indices:s}=t,{outputRaggedRank:i}=r,u=a.map((e=>n.data.get(e.dataId).values)),c=a.map((e=>e.shape)),l=n.data.get(o.dataId).values,p=n.data.get(s.dataId).values,[d,h,f]=$r(u,c,l,o.shape,o.dtype,p,s.shape),m=d.map((e=>n.makeTensorInfo([e.length],"int32",e))),g=n.makeTensorInfo(f,o.dtype,h);return m.concat([g])}},Wr=2147483647,zr={kernelName:r.sdx,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{starts:a,limits:o,deltas:s}=t,i=n.data.get(a.dataId).values,u=n.data.get(o.dataId).values,c=n.data.get(s.dataId).values,[l,p]=function(e,t,n,a,o,s,i){if(t.length>1)throw new Error("starts must be a scalar or vector");if(o.length>1)throw new Error("limits must be a scalar or vector");if(i.length>1)throw new Error("deltas must be a scalar or vector");const u=0===t.length,c=0===o.length,l=0===i.length,p=[];u||p.push(t[0]),c||p.push(o[0]),l||p.push(i[0]);for(let e=1;e<p.length;++e)if(p[e]!==p[e-1])throw new Error("starts, limits, and deltas must have the same shape");const d=0===p.length?1:p[0],h=r.euu.getArrayFromDType("int32",d+1);h[0]=0;for(let t=0;t<d;++t){const n=u?e[0]:e[t],r=c?a[0]:a[t],o=l?s[0]:s[t];if(0===o)throw new Error("Requires delta != 0");let i;if(o>0&&r<n||o<0&&r>n)i=0;else if(i=Math.ceil(Math.abs((r-n)/o)),i>Wr)throw new Error("Requires ((limit - start) / delta) <= 2147483647");h[t+1]=h[t]+i}const f=h[d],m=r.euu.getArrayFromDType(n,f);let g=0;for(let t=0;t<d;++t){const n=h[t+1]-h[t];let r=u?e[0]:e[t];const a=l?s[0]:s[t];for(let e=0;e<n;++e)m[g++]=r,r+=a}return[h,m]}(i,a.shape,a.dtype,u,o.shape,c,s.shape);return[n.makeTensorInfo([l.length],"int32",l),n.makeTensorInfo([p.length],a.dtype,p)]}};var Br=r.cxb.RowPartitionType;class Ur{constructor(e,t,n,a,o,s,i,u,c,l){this.shape=e,this.shapeShape=t,this.values=n,this.valuesShape=a,this.valuesDType=o,this.defaultValue=s,this.defaultValueShape=i,this.rowPartitionValues=u,this.rowPartitionValuesShapes=c,this.rowPartitionTypes=r.cxb.getRowPartitionTypesHelper(l),this.raggedRank=r.cxb.getRaggedRank(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===Br.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===Br.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case Br.VALUE_ROWIDS:return Ur.getMaxWidthValueRowID(t);case Br.ROW_SPLITS:return Ur.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${Br[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(0===t||1===t)return 0;let n=0;for(let r=0;r<t-1;++r){const t=e[r+1]-e[r];t>n&&(n=t)}return n}static getMaxWidthValueRowID(e){const t=e.length;if(0===t)return 0;let n=0,r=e[0],a=0;for(let o=1;o<t;++o){const t=e[o];t!==r&&(r=t,a=Math.max(o-n,a),n=o)}return Math.max(t-n,a)}tensorShapeFromTensor(e,t,n=!0){if(0===t.length){if(-1===e[0])return[];throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return Vr(e,n)}calculateOutputSize(e){const t=this.valuesShape,n=this.defaultValueShape;r.cxb.validateDefaultValueShape(n,t);const a=this.tensorShapeFromTensor(this.shape,this.shapeShape),o=r.cxb.combineRaggedTensorToTensorShapes(this.raggedRank,a,t);o[0]<0&&(o[0]=e);for(let e=1;e<=this.raggedRank;++e)o[e]<0&&(o[e]=this.getMaxWidth(e));return o}calculateFirstParentOutputIndex(e,t,n){const a=Math.min(e,n),o=[];let s=0;for(let e=0;e<a;++e,s+=t)o.push(s);for(let t=a;t<e;++t)o.push(-1);return r.euu.assert(o.length===e,(()=>"Final length of result must be equal to firstDimension.")),o}calculateOutputIndexRowSplit(e,t,n,r){const a=e.length,o=[];for(let s=0;s<a-1;++s){const a=e[s+1]-e[s];let i=Math.min(r,a),u=t[s];-1===u&&(i=0);for(let e=0;e<i;++e)o.push(u),u+=n;for(let e=0;e<a-i;++e)o.push(-1)}if(a>0&&o.length!==e[a-1])throw new Error("Invalid row split size.");return o}calculateOutputIndexValueRowID(e,t,n,r){const a=e.length,o=[];if(0===a)return[];let s=0,i=e[0];if(i>=t.length)throw new Error(`Got currentValueRowId=${i}, which is not less than ${t.length}`);let u=t[i];o.push(u);for(let c=1;c<a;++c){const a=e[c];if(a===i)u>=0&&(++s,s<r?u+=n:u=-1);else{if(s=0,i=a,a>=t.length)throw new Error(`Got nextValueRowId=${a} which is not less than ${t.length}`);u=t[a]}o.push(u)}if(o.length!==e.length)throw new Error("Invalid row ids.");return o}calculateOutputIndex(e,t,n,r){const a=this.getRowPartitionTensor(e),o=this.getRowPartitionTypeByDimension(e);switch(o){case Br.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(a,t,n,r);case Br.ROW_SPLITS:if(a.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${a.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(a,t,n,r);default:throw new Error(`Unsupported partition type: ${Br[o]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw new Error("No row_partition_types given.");const t=this.rowPartitionTypes[0];switch(t){case Br.FIRST_DIM_SIZE:return e[0];case Br.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case Br.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${Br[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const e=this.getFirstDimensionSize(),t=this.calculateOutputSize(e),n=new Array(this.raggedRank+1);n[n.length-1]=1;for(let e=n.length-2;e>=0;--e)n[e]=n[e+1]*t[e+1];const a=Vr(t,!1),o=r.euu.getArrayFromDType(this.valuesDType,r.euu.sizeFromShape(a));if(n[0]*t[0]>0){let r=this.calculateFirstParentOutputIndex(e,n[0],t[0]);for(let e=1;e<=this.raggedRank;++e)r=this.calculateOutputIndex(e-1,r,n[e],t[e]);this.setOutput(this.raggedRank,r,o,a)}return[a,o]}setOutput(e,t,n,a){if(0===n.length)return;const o=this.values,s=n;let i=a.slice();i=i.slice(e+1);const u=r.euu.sizeFromShape(i),c=t.length;let l=this.defaultValue;if(l.length!==u&&1!==l.length){const e=this.defaultValueShape;(0,r.G6I)((()=>{const t=(0,r.OoG)(l,e),n=(0,r.Cet)(t,i);l=n.dataSync()}))}let p=0,d=0,h=0;for(let e=0;e<=c;++e){let r=e<c?t[e]:-1;if(r!==h){if(d<h){const e=o.subarray(p*u);Hr(s.subarray(d*u),e,(h-d)*u)}if(e>=c){const e=n.length;r=Math.floor(e/u)}if(r>h)if(1===this.defaultValue.length)s.subarray(h*u,r*u).fill(this.defaultValue[0]),h=r;else for(;r>h;)Hr(s.slice(h*u),l,u),++h;r<0?(p=e+1,d=h):(p=e,d=h,h=d+1)}else++h}}}function Hr(e,t,n){for(let r=0;r<n;r++)e[r]=t[r]}function Vr(e,t){const n=[];for(let r of e){if(r<0){if(!t)throw new Error(`Dimension ${r} must be >= 0`);if(r<-1)throw new Error(`Dimension ${r} must be >= -1`);r=-1}n.push(r)}return n}const Gr={kernelName:r.wF4,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{shape:a,values:o,defaultValue:s,rowPartitionTensors:i}=t,{rowPartitionTypes:u}=r,c=n.data.get(a.dataId).values,l=n.data.get(o.dataId).values,p=n.data.get(s.dataId).values,d=i.map((e=>n.data.get(e.dataId).values)),h=i.map((e=>e.shape)),[f,m]=function(e,t,n,r,a,o,s,i,u,c){return new Ur(e,t,n,r,a,o,s,i,u,c).compute()}(c,a.shape,l,o.shape,o.dtype,p,s.shape,d,h,u);return n.makeTensorInfo(f,o.dtype,m)}};var qr=n(33996);const jr={kernelName:r.EHu,backendName:"cpu",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:r,stop:a,dtype:o,step:s}=n,i=(0,qr.S)(r,a,s,o);return t.makeTensorInfo([i.length],o,i)}},Kr=u(r.Ezp,(e=>1/e)),Qr={kernelName:r.Ezp,backendName:"cpu",kernelFunc:Kr},Yr={kernelName:r.qaT,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{images:s}=t,{alignCorners:i,halfPixelCenters:u,size:c}=o;(0,a.q)(s,"resizeBilinear");const l=r.euu.computeStrides(s.shape),[p,d]=c,[h,f,m,g]=s.shape,y=n.data.get(s.dataId).values,b=new Float32Array(r.euu.sizeFromShape([h,p,d,g])),w=[i&&p>1?f-1:f,i&&d>1?m-1:m],v=[i&&p>1?p-1:p,i&&d>1?d-1:d];let k=0;const x=w[0]/v[0],_=w[1]/v[1];for(let e=0;e<h;e++)for(let t=0;t<p;t++){let n;n=u?x*(t+.5)-.5:x*t;const r=Math.max(0,Math.floor(n)),a=n-r,o=Math.min(f-1,Math.ceil(n)),s=e*l[0]+r*l[1],i=e*l[0]+o*l[1];for(let e=0;e<d;e++){let t;t=u?_*(e+.5)-.5:_*e;const n=Math.max(0,Math.floor(t)),r=t-n,o=Math.min(m-1,Math.ceil(t)),c=s+n*l[2],p=i+n*l[2],d=s+o*l[2],h=i+o*l[2];for(let e=0;e<g;e++){const t=y[c+e],n=y[p+e],o=t+(y[d+e]-t)*r,s=o+(n+(y[h+e]-n)*r-o)*a;b[k++]=s}}}return n.makeTensorInfo([h,p,d,g],"float32",b)}},Jr={kernelName:r.ewH,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{images:s,dy:i}=t,{alignCorners:u}=o;(0,a.q)([i,s],"resizeBilinearGrad");const c=r.euu.computeStrides(s.shape),[l,p,d,h]=s.shape,[,f,m]=i.shape,g=new Float32Array(l*p*d*h),y=[u&&f>1?p-1:p,u&&m>1?d-1:d],b=[u&&f>1?f-1:f,u&&m>1?m-1:m],w=y[0]/b[0],v=y[1]/b[1],k=n.data.get(i.dataId).values;let x=0;for(let e=0;e<l;e++){const t=e*c[0];for(let e=0;e<f;e++){const n=e*w,r=Math.floor(n),a=Math.min(Math.ceil(n),p-1),o=t+r*c[1],s=t+a*c[1],i=n-r,u=1-i;for(let e=0;e<m;e++){const t=e*v,n=Math.floor(t),r=Math.min(Math.ceil(t),d-1),a=t-n,l=1-a,p=o+n*c[2],f=o+r*c[2],m=s+n*c[2],y=s+r*c[2],b=u*l,w=u*a,_=i*l,I=i*a;for(let e=0;e<h;e++){const t=k[x++];g[p+e]+=t*b,g[f+e]+=t*w,g[m+e]+=t*_,g[y+e]+=t*I}}}}return n.makeTensorInfo([l,d,p,h],"float32",g)}},Zr={kernelName:r.Co2,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{images:s}=t,{alignCorners:i,halfPixelCenters:u,size:c}=o;(0,a.q)(s,"resizeNearestNeighbor");const l=r.euu.computeStrides(s.shape),[p,d]=c,[h,f,m,g]=s.shape,y=n.data.get(s.dataId).values,b=new Float32Array(h*p*d*g),w=[i&&p>1?f-1:f,i&&d>1?m-1:m],v=[i&&p>1?p-1:p,i&&d>1?d-1:d],k=w[0]/v[0],x=w[1]/v[1];let _=0;for(let e=0;e<h;e++){const t=e*l[0];for(let e=0;e<p;e++){const n=u?k*(e+.5):k*e;let r=Math.min(f-1,i?Math.round(n):Math.floor(n));u&&(r=Math.max(0,r));const a=t+r*l[1];for(let e=0;e<d;e++){const t=u?x*(e+.5):x*e;let n=Math.min(m-1,i?Math.round(t):Math.floor(t));u&&(n=Math.max(0,n));const r=a+n*l[2];for(let e=0;e<g;e++){const t=y[r+e];b[_++]=t}}}}return n.makeTensorInfo([h,p,d,g],s.dtype,b)}},Xr={kernelName:r.WCE,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{images:s,dy:i}=t,{alignCorners:u}=o;(0,a.q)([i,s],"resizeNearestNeighborGrad");const c=r.euu.computeStrides(s.shape),l=r.euu.computeStrides(i.shape),[p,d,h,f]=s.shape,[,m,g]=i.shape,y=new Float32Array(p*d*h*f),b=n.data.get(i.dataId).values,w=[u&&m>1?d-1:d,u&&g>1?h-1:h],v=[u&&m>1?m-1:m,u&&g>1?g-1:g],k=w[0]/v[0],x=w[1]/v[1],_=1/k,I=1/x,S=2*Math.ceil(_)+2,N=2*Math.ceil(I)+2;for(let e=0;e<p;e++){const t=e*c[0];for(let e=0;e<d;e++){const n=t+e*c[1],r=Math.floor(e*_),a=Math.floor(r-S/2);for(let r=0;r<h;r++){const o=n+r*c[2],s=Math.floor(r*I),i=Math.floor(s-N/2);for(let n=0;n<f;n++){let s=0;for(let o=0;o<S;o++){const c=o+a;if(c<0||c>=m)continue;const p=t+c*l[1],f=c*k;if(e===Math.min(d-1,u?Math.round(f):Math.floor(f)))for(let e=0;e<N;e++){const t=e+i;if(t<0||t>=g)continue;const a=p+t*l[2],o=t*x;r===Math.min(h-1,u?Math.round(o):Math.floor(o))&&(s+=b[a+n])}}y[o+n]=s}}}}return n.makeTensorInfo(s.shape,s.dtype,y)}},ea={kernelName:r.glo,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{dims:i}=o;(0,a.q)(s,"reverse");const u=s.shape.length,c=r.euu.parseAxisParam(i,s.shape);if(0===u)return d({inputs:{x:s},backend:n});const l=new r.Kq3(s.shape,s.dtype),p=n.bufferSync(s);for(let e=0;e<l.size;e++){const t=l.indexToLoc(e),n=t.slice();c.forEach((e=>n[e]=s.shape[e]-1-n[e])),l.set(p.get(...n),...t)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}},ta={kernelName:r.qWz,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:a}=e,{radians:o,fillValue:s,center:i}=t,u=n,c=r.euu.getTypedArrayFromDType(a.dtype,r.euu.sizeFromShape(a.shape)),[l,p,d,h]=a.shape,[f,m]=r.cxb.getImageCenter(i,p,d),g=Math.sin(o),y=Math.cos(o),b=u.data.get(a.dataId).values;for(let e=0;e<l;e++){const t=e*d*p*h;for(let e=0;e<p;e++){const n=e*(d*h);for(let r=0;r<d;r++){const a=r*h;for(let o=0;o<h;o++){const i=[l,e,r,o],u=i[2],w=i[1];let v=(u-f)*y-(w-m)*g,k=(u-f)*g+(w-m)*y;v=Math.round(v+f),k=Math.round(k+m);let x=s;"number"!=typeof s&&(x=3===o?255:s[o]),v>=0&&v<d&&k>=0&&k<p&&(x=b[t+k*(d*h)+v*h+o]),c[t+n+a+o]=x}}}}return{dataId:u.write(c,a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},na=u(r.I$0,(e=>{const t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),ra={kernelName:r.I$0,backendName:"cpu",kernelFunc:na},aa=i((e=>1/Math.sqrt(e))),oa=c(r.o9c,aa),sa={kernelName:r.o9c,backendName:"cpu",kernelFunc:oa};function ia(e,t,n,a,o,s,i,u,c,l){const p=[a/o,o],d=e.values,h=t.values;if(0===a)return(0,r.cz0)(n,t.dtype);const f=c instanceof r.Kq3?c:(0,r.cz0)(p,t.dtype);"string"==typeof c||"number"==typeof c?f.values.fill(c):"boolean"==typeof c&&f.values.fill(+c);for(let e=0;e<s;e++){const r=[];let s=0;for(let t=0;t<i;t++){const n=d[e*i+t];r.push(n),s+=n*u[t]}if(s<0||s>=a/o)throw new Error(`Invalid indices: ${r} does not index into ${n}`);for(let n=0;n<o;n++)l?f.values[s*o+n]+=h[e*o+n]:f.values[s*o+n]=0===t.rank?h[0]:h[e*o+n]}return f}const ua={kernelName:r.qiV,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{indices:o,updates:s}=t,{shape:i}=a,{sliceRank:u,numUpdates:c,sliceSize:l,strides:p,outputSize:d}=r.cxb.calculateShapes(s,o,i),h=ia(n.bufferSync(o),n.bufferSync(s),i,d,l,c,u,p,0,!0);return n.makeTensorInfo(i,h.dtype,h.values)}};function ca(e,t){let n=0,r=e.length,a=0;for(;n<r;)a=Math.floor((n+r)/2),e[a]<t?n=a+1:r=a;return r}function la(e,t){let n=0,r=e.length,a=0;for(;n<r;)a=Math.floor((n+r)/2),e[a]<=t?n=a+1:r=a;return r}const pa={kernelName:r.wvl,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{sortedSequence:o,values:s}=t,{side:i}=a,u=function(e,t,n,a,o,s){const i=r.euu.getArrayFromDType("int32",n*o);for(let r=0;r<n;++r){const n=e.slice(r*a,(r+1)*a),u=r*o;for(let e=0;e<o;++e)i[u+e]="left"===s?ca(n,t[e+u]):la(n,t[e+u])}return i}(n.data.get(o.dataId).values,n.data.get(s.dataId).values,o.shape[0],o.shape[1],s.shape[1],i);return n.makeTensorInfo(s.shape,"int32",u)}},da={kernelName:r.M1e,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:o,t:s,e:i}=t;(0,a.q)([o,s,i],"select");const u=o.shape.length,c=n.data.get(o.dataId).values,l=n.data.get(s.dataId).values,p=n.data.get(i.dataId).values,d=(0,r.OAw)(s.dtype,i.dtype),h=r.euu.makeZerosTypedArray(r.euu.sizeFromShape(s.shape),d);let f=0;const m=0===u||u>1||1===s.shape.length?1:r.euu.sizeFromShape(s.shape.slice(1));for(let e=0;e<c.length;e++)for(let t=0;t<m;t++)1===c[e]?h[f++]=l[e]:h[f++]=p[e];return n.makeTensorInfo(s.shape,d,h)}},ha=r.cxb.SELU_SCALEALPHA,fa=r.cxb.SELU_SCALE,ma=u(r.PWB,(e=>e>=0?fa*e:ha*(Math.exp(e)-1))),ga={kernelName:r.PWB,backendName:"cpu",kernelFunc:ma},ya=u(r.oyM,(e=>e<0?-1:e>0?1:0)),ba={kernelName:r.oyM,backendName:"cpu",kernelFunc:ya},wa=u(r.mrT,(e=>Math.sin(e))),va={kernelName:r.mrT,backendName:"cpu",kernelFunc:wa},ka=u(r.OCc,(e=>Math.sinh(e))),xa={kernelName:r.OCc,backendName:"cpu",kernelFunc:ka},_a=Math.log(1.1920928955078125e-7)+2,Ia=u(r.eWt,(e=>{const t=e>-_a,n=e<_a,r=Math.exp(e);let a;return a=n?r:t?e:Math.log(1+r),a})),Sa={kernelName:r.eWt,backendName:"cpu",kernelFunc:Ia},Na={kernelName:r.sH1,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{blockShape:i,paddings:u}=o;(0,a.q)([s],"spaceToBatchND");const c=r.euu.sizeFromShape(i),l=[[0,0]];l.push(...u);for(let e=1+i.length;e<s.shape.length;++e)l.push([0,0]);const p=Fr.kernelFunc({inputs:{x:s},backend:n,attrs:{paddings:l,constantValue:0}}),d=r.cxb.getReshaped(p.shape,i,c,!1),h=r.cxb.getPermuted(d.length,i.length,!1),f=r.cxb.getReshapedPermuted(p.shape,i,c,!1),m=z({inputs:{x:p},backend:n,attrs:{shape:d}}),g=Z({inputs:{x:m},backend:n,attrs:{perm:h}}),y=z({inputs:{x:g},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),y}},Ma={kernelName:r.Omm,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{indices:a,values:o,denseShape:s,defaultValue:i}=t;if(1!==s.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${s.shape}`);if(2!==a.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${a.shape}`);if(1!==o.shape.length)throw new Error(`Values must be a vector, saw:\n ${o.shape}`);if(0!==i.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${i.shape}`);const u=n.data.get(a.dataId).values,c=n.data.get(o.dataId).values,l=n.data.get(s.dataId).values,p=n.data.get(i.dataId).values[0],[d,h,f,m,g]=function(e,t,n,a,o,s,i){const u=t[0],c=s[0],l=new Array(c),p=new Array(u),d=t[1];if(0===c){if(0!==u)throw new Error(r.cxb.getSparseFillEmptyRowsIndicesDenseShapeMismatch(u));return[r.euu.getArrayFromDType(n,0),[0,d],r.euu.getArrayFromDType(o,0),l,p]}let h=!0,f=0;const m=new Array(c).fill(0);for(let t=0;t<u;++t){const n=e[t*d];if(n<0)throw new Error(r.cxb.getSparseFillEmptyRowsNegativeIndexErrorMessage(t,n));if(n>=c)throw new Error(r.cxb.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(t,n,c));++m[n],h=h&&n>=f,f=n}let g=!0;for(let e=0;e<c;++e){const t=0===m[e];l[e]=t,g=g&&!t,m[e]=Math.max(m[e],1),e>0&&(m[e]+=m[e-1])}if(g&&h){const t=e,n=a;for(let e=0;e<u;++e)p[e]=e;return[t,[u,d],n,l,p]}{const t=m[c-1],s=r.euu.getArrayFromDType(n,t*d),h=r.euu.getArrayFromDType(o,t),f=new Array(c).fill(0);for(let t=0;t<u;++t){const n=e[t*d],r=f[n],o=(0===n?0:m[n-1])+r;f[n]++;for(let n=0;n<d;++n)s[o*d+n]=e[t*d+n];h[o]=a[t],p[t]=o}for(let e=0;e<c;++e)if(0===f[e]){const t=0===e?0:m[e-1];s[t*d+0]=e;for(let e=1;e<d;++e)s[t*d+e]=0;h[t]=i}return[s,[t,d],h,l,p]}}(u,a.shape,a.dtype,c,o.dtype,l,p);return[n.makeTensorInfo(h,a.dtype,d),n.makeTensorInfo([h[0]],o.dtype,f),n.makeTensorInfo([m.length],"bool",new Uint8Array(m.map((e=>Number(e))))),n.makeTensorInfo([g.length],a.dtype,new Int32Array(g))]}},Ta={kernelName:r.kfs,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{inputIndices:a,inputShape:o,newShape:s}=t;if(2!==a.shape.length)throw new Error(`Input indices should be a matrix but received shape\n ${a.shape}`);if(1!==o.shape.length)throw new Error(`Input shape should be a vector but received shape\n ${o.shape}`);if(1!==s.shape.length)throw new Error(`Target shape should be a vector but received shape ${s.shape}`);const i=Array.from(n.data.get(o.dataId).values),u=n.data.get(a.dataId).values,c=Array.from(n.data.get(s.dataId).values),[l,p,d]=function(e,t,n,a,o){const s=r.euu.sizeFromShape(a),i=t[0],u=o.length,c=[];let l=1,p=-1;for(let e=0;e<u;++e){const t=o[e];if(-1===t){if(-1!==p)throw new Error(r.cxb.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(p,e));p=e,c.push(1)}else{if(t<0)throw new Error(r.cxb.getSparseReshapeNegativeOutputDimErrorMessage(e,t));l*=t,c.push(t)}}if(-1!==p){if(l<=0)throw new Error(r.cxb.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage());const e=Math.trunc(s/l);if(l*e!==s)throw new Error(r.cxb.getSparseReshapeInputOutputMultipleErrorMessage(a,c));c[p]=e}if(r.euu.sizeFromShape(c)!==s)throw new Error(r.cxb.getSparseReshapeInputOutputMismatchErrorMessage(a,c));const d=a.length,h=[];if(d>0){h[d-1]=1;for(let e=d-2;e>=0;--e)h[e]=h[e+1]*a[e+1]}const f=[];if(u>0){f[u-1]=1;for(let e=u-2;e>=0;--e)f[e]=f[e+1]*c[e+1]}const m=r.euu.getArrayFromDType(n,i*u);for(let t=0;t<i;++t){let n=0;for(let r=0;r<d;++r)n+=e[t*d+r]*h[r];for(let e=0;e<u;++e)m[t*u+e]=Math.trunc(n/f[e]),n%=f[e]}return[m,[i,u],c]}(u,a.shape,a.dtype,i,c);return[n.makeTensorInfo(p,a.dtype,l),n.makeTensorInfo([d.length],s.dtype,new Int32Array(d))]}};function Ea(e,t,n,a,o,s=!1,i=0){const u=a.length,c=[t[0],e.length/t[0]],l=c[1],p=u>0?o[u-1]+1:0;if(p<0)throw new Error(r.cxb.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());const d=t.slice();d[0]=p;const h=d.reduce(((e,t)=>e*t),1),f=r.euu.getArrayFromDType(n,h);if(0===u)return p>0&&f.fill(i),[f,d];if(p<=0)throw new Error(r.cxb.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());let m=0,g=1,y=0,b=o[m];for(;;){let t=0;if(g<u){if(t=o[g],b===t){++g;continue}if(b>=t)throw new Error(r.cxb.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage())}if(b<0||b>=p)throw new Error(r.cxb.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(b,p));b>y&&f.fill(i,y*l,b*l);for(let t=m;t<g;++t){const n=a[t];if(n<0||n>=c[0])throw new Error(r.cxb.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(t,a[t],c[0]));for(let t=0;t<l;t++)f[b*l+t]+=e[n*l+t]}if(s)for(let e=0;e<l;e++)f[b*l+e]/=g-m;if(m=g,++g,y=b+1,b=t,g>u)break}return y<p&&f.fill(i,y*l,p*l),[f,d]}const Aa={kernelName:r.QxB,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:o}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");
2if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==o.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${o.shape}`);if(a.shape[0]!==o.shape[0])throw new Error("segmentIds and indices should have same size.");const s=n.data.get(r.dataId).values,i=n.data.get(a.dataId).values,u=n.data.get(o.dataId).values,[c,l]=Ea(s,r.shape,r.dtype,i,u,!0);return n.makeTensorInfo(l,r.dtype,c)}},Fa={kernelName:r.ra4,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:o}=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!==o.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${o.shape}`);if(a.shape[0]!==o.shape[0])throw new Error("segmentIds and indices should have same size.");const s=n.data.get(r.dataId).values,i=n.data.get(a.dataId).values,u=n.data.get(o.dataId).values,[c,l]=Ea(s,r.shape,r.dtype,i,u);return n.makeTensorInfo(l,r.dtype,c)}},Da={kernelName:r.inF,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{sparseIndices:o,sparseValues:s,defaultValue:i}=t,{outputShape:u}=a,{sliceRank:c,numUpdates:l,sliceSize:p,strides:d,outputSize:h}=r.cxb.calculateShapes(s,o,u),f=!1,m=n.bufferSync(o);let g;switch(s.dtype){case"bool":g=ia(m,n.bufferSync(s),u,h,p,l,c,d,Boolean(n.data.get(i.dataId).values[0]),f);break;case"float32":case"int32":g=ia(m,n.bufferSync(s),u,h,p,l,c,d,n.data.get(i.dataId).values[0],f);break;case"string":g=ia(m,n.bufferSync(s),u,h,p,l,c,d,r.euu.decodeString(n.data.get(i.dataId).values[0]),f);break;default:throw new Error(`Unsupported type ${s.dtype}`)}return n.makeTensorInfo(u,g.dtype,g.values)}},Oa={kernelName:r.kDP,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:o}=t,{numOrSizeSplits:s,axis:i}=a,u=r.euu.parseAxisParam(i,o.shape)[0],c=r.cxb.prepareSplitSize(o,s,u),l=new Array(o.shape.length).fill(0),p=o.shape.slice();return c.map((e=>{const t=[...p];t[u]=e;const r=(0,_e.SM)({inputs:{x:o},backend:n,attrs:{begin:l,size:t}});return l[u]+=e,r}))}},Ca=(i((e=>Math.sqrt(e))),u(r.Sed,(e=>Math.sqrt(e)))),Pa={kernelName:r.Sed,backendName:"cpu",kernelFunc:Ca},Ra={kernelName:r.GSE,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{x:n}=e,r=t;(0,a.q)(n,"square");const o=r.data.get(n.dataId).values,s=new Float32Array(o.length);for(let e=0;e<o.length;++e){const t=o[e];s[e]=t*t}return{dataId:r.write(s,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},$a=g(((e,t)=>{const n=e-t;return n*n})),La=C(r.uI0,$a),Wa={kernelName:r.uI0,backendName:"cpu",kernelFunc:La},za=i(((e,t)=>{const{pattern:n,replaceGlobal:r,rewrite:a}=t;return e.replace(new RegExp(n,r?"g":""),a)})),Ba=c(r.CM,za),Ua={kernelName:r.CM,backendName:"cpu",kernelFunc:Ba},Ha=u(r.Ku3,((e,t)=>{const n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),Va={kernelName:r.Ku3,backendName:"cpu",kernelFunc:Ha},Ga={kernelName:r.cB,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{begin:i,end:u,strides:c,beginMask:l,endMask:p,ellipsisMask:d,newAxisMask:h,shrinkAxisMask:f}=o;(0,a.q)(s,"stridedSlice");const{finalShapeSparse:m,finalShape:g,isIdentity:y,sliceDim0:b,isSimpleSlice:w,begin:v,end:k,strides:x}=r.sL.sliceInfo(s.shape,i,u,c,l,p,d,h,f);let _;if(y)_=z({inputs:{x:s},backend:n,attrs:{shape:g}});else if(b||w){r.euu.assert(s.shape.length>=1,(()=>`Input must have rank at least 1, got: ${s.shape.length}`));const e=r.sL.computeOutShape(v,k,x),t=(0,_e.SM)({inputs:{x:s},backend:n,attrs:{begin:v,size:e}});_=z({inputs:{x:t},backend:n,attrs:{shape:g}}),n.disposeIntermediateTensorInfo(t)}else{const e=function(e,t,n,a){const o=(0,r.cz0)(e,t.dtype);for(let e=0;e<o.size;e++){const r=o.indexToLoc(e),s=new Array(r.length);for(let e=0;e<s.length;e++)s[e]=r[e]*n[e]+a[e];o.set(t.get(...s),...r)}return o}(m,n.bufferSync(s),x,v);_=n.makeTensorInfo(g,e.dtype,e.values)}return _}};var qa=n(72652);const ja={kernelName:r.MPe,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:o,leftPad:s,rightPad:i,padWidth:u,preserveShortSequences:c}=r,{data:l,dataSplits:p}=t,d=n.data.get(l.dataId).values,h=n.data.get(p.dataId).values,[f,m]=(0,qa.s)(d,h,a,o,s,i,u,c);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};var Ka=n(29772);const Qa={kernelName:r.YNA,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{skipEmpty:a}=r,{input:o,delimiter:s}=t;if("string"!==o.dtype)throw new Error("Input must be of datatype string");if(1!==o.shape.length)throw new Error(`Input must be a vector, got shape: ${o.shape}`);if(0!==s.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${s.shape}`);const i=n.data.get(o.dataId).values,u=n.data.get(s.dataId).values[0],[c,l,p]=(0,Ka.i)(i,u,a),d=l.length;return[n.makeTensorInfo([d,2],"int32",c),n.makeTensorInfo([d],"string",l),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};var Ya=n(20128);const Ja={kernelName:r.Atw,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{numBuckets:a}=r,{input:o}=t;if("string"!==o.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 s=n.data.get(o.dataId).values,i=(0,Ya.e)(s,a);return n.makeTensorInfo(o.shape,"int32",i)}},Za=u(r.epr,(e=>Math.tan(e))),Xa={kernelName:r.epr,backendName:"cpu",kernelFunc:Za},eo=u(r.Yvq,(e=>Math.tanh(e))),to={kernelName:r.Yvq,backendName:"cpu",kernelFunc:eo},no={kernelName:r.EBb,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{tensor:a,indices:o,updates:s}=t,{sliceRank:i,numUpdates:u,sliceSize:c,strides:l,outputSize:p}=r.cxb.calculateShapes(s,o,a.shape),d=n.bufferSync(o),h=n.bufferSync(s),f=n.bufferSync(a),m=ia(d,h,a.shape,p,c,u,i,l,f,!1);return n.makeTensorInfo(a.shape,m.dtype,m.values)}},ro={kernelName:r.g$J,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{reps:i}=o;(0,a.q)(s,"tile");const u=function(e,t){const n=new Array(e.rank);for(let r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];const a=(0,r.cz0)(n,e.dtype);for(let t=0;t<a.values.length;++t){const n=a.indexToLoc(t),r=new Array(e.rank);for(let t=0;t<r.length;t++)r[t]=n[t]%e.shape[t];const o=e.locToIndex(r);a.values[t]=e.values[o]}return a}(n.bufferSync(s),i);return n.makeTensorInfo(u.shape,u.dtype,u.values)}},ao=(e,t)=>{const n=t.value-e.value;return 0===n?e.index-t.index:n};function oo(e,t,n=0,a=e.length-1){for(;a>n;){if(a-n>600){const r=a-n+1,o=t-n+1,s=Math.log(r),i=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*i*(r-i)/r)*Math.sign(o-r/2);oo(e,t,Math.max(n,Math.floor(t-o*i/r+u)),Math.min(a,Math.floor(t+(r-o)*i/r+u)))}const o=e[t];let s=n,i=a;for(r.euu.swap(e,n,t),ao(e[a],o)>0&&r.euu.swap(e,n,a);s<i;){for(r.euu.swap(e,s,i),s++,i--;ao(e[s],o)<0;)s+=1;for(;ao(e[i],o)>0;)i-=1}0===ao(e[n],o)?r.euu.swap(e,n,i):(i+=1,r.euu.swap(e,i,a)),i<=t&&(n=i+1),t<=i&&(a=i-1)}}const so={kernelName:r.iIN,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s}=t,{k:i,sorted:u}=o;(0,a.q)(s,"topk");const c=n.data.get(s.dataId).values,[l,p]=function(e,t,n,a,o){const s=t[t.length-1],[i,u]=[e.length/s,s],c=r.euu.getTypedArrayFromDType(n,i*a),l=r.euu.getTypedArrayFromDType("int32",i*a);for(let t=0;t<i;t++){const n=t*u,r=e.subarray(n,n+u);let s=new Array(r.length);r.forEach(((e,t)=>s[t]={value:e,index:t})),a<s.length&&(oo(s,a),s=s.slice(0,a)),o&&s.sort(ao);const i=t*a,p=c.subarray(i,i+a),d=l.subarray(i,i+a);for(let e=0;e<a;e++)p[e]=s[e].value,d[e]=s[e].index}const p=t.slice();return p[p.length-1]=a,[(0,r.cz0)(p,n,c),(0,r.cz0)(p,"int32",l)]}(c,s.shape,s.dtype,i,u);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(p.shape,p.dtype,p.values)]}},io={kernelName:r.wjp,backendName:"cpu",kernelFunc:function(e){const{inputs:t,attrs:n,backend:a}=e,{image:o,transforms:s}=t,{interpolation:i,fillMode:u,fillValue:c,outputShape:l}=n,[p,d,h,f]=o.shape,[m,g]=null!=l?l:[d,h],y=[p,m,g,f],b=r.euu.computeStrides(o.shape),w=b[0],v=b[1],k=b[2],x=r.euu.computeStrides(y),_=x[0],I=x[1],S=x[2],N=r.euu.getTypedArrayFromDType(o.dtype,r.euu.sizeFromShape(y));N.fill(c);const M=a.data.get(o.dataId).values,T=a.data.get(s.dataId).values;for(let e=0;e<p;++e){const t=1===s.shape[0]?T:T.subarray(8*e,8*e+8);for(let n=0;n<m;++n)for(let r=0;r<g;++r)for(let a=0;a<f;++a){let o;const s=t[6]*r+t[7]*n+1;if(0===s)continue;const l=(t[0]*r+t[1]*n+t[2])/s,p=(t[3]*r+t[4]*n+t[5])/s,f=uo(l,h,u),m=uo(p,d,u);switch(i){case"nearest":o=lo(M,d,h,w,v,k,e,m,f,a,c);break;case"bilinear":o=po(M,d,h,w,v,k,e,m,f,a,c);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${i}`)}
vendor: 8,287 bytes, line 2
2N[e*_+n*I+r*S+a]=o}return a.makeTensorInfo(y,o.dtype,N)}return{dataId:a.write(N,y,o.dtype),shape:o.shape,dtype:o.dtype}}};function uo(e,t,n){switch(n){case"reflect":return function(e,t){let n=e;if(n<0)if(t<=1)n=0;else{const e=2*t;n<e&&(n=e*Math.trunc(-n/e)+n),n=n<-t?n+e:-n-1}else if(n>t-1)if(t<=1)n=0;else{const e=2*t;n-=e*Math.trunc(n/e),n>=t&&(n=e-n-1)}return r.euu.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 r.euu.clamp(0,n,t-1)}(e,t);case"nearest":return function(e,t){return r.euu.clamp(0,e,t-1)}(e,t);default:return function(e,t){return e}(e)}}function co(e,t,n,r,a,o,s,i,u,c,l){return 0<=i&&i<t&&0<=u&&u<n?e[s*r+i*a+u*o+c]:l}function lo(e,t,n,r,a,o,s,i,u,c,l){return co(e,t,n,r,a,o,s,Math.round(i),Math.round(u),c,l)}function po(e,t,n,r,a,o,s,i,u,c,l){const p=Math.floor(i),d=Math.floor(u),h=p+1,f=d+1;return(h-i)*((f-u)*co(e,t,n,r,a,o,s,p,d,c,l)+(u-d)*co(e,t,n,r,a,o,s,p,f,c,l))+(i-p)*((f-u)*co(e,t,n,r,a,o,s,h,d,c,l)+(u-d)*co(e,t,n,r,a,o,s,h,f,c,l))}var ho=n(20932);const fo={kernelName:r.Kyi,backendName:"cpu",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{axis:o}=n,{x:s}=t;(0,a.q)(s,"unique");const i=r.data.get(s.dataId).values,{outputValues:u,outputShape:c,indices:l}=(0,ho.c)(i,o,s.shape,s.dtype);return[r.makeTensorInfo(c,s.dtype,u),r.makeTensorInfo([l.length],"int32",l)]}},mo={kernelName:r.YZK,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:o}=r;o<0&&(o+=a.shape.length);const s=a.shape.length,i=a.shape[o],u=new Array(s-1);let c=0;for(let e=0;e<s;e++)e!==o&&(u[c++]=a.shape[e]);const l=new Array(s).fill(0),p=a.shape.slice();p[o]=1;const d=new Array(i);for(let e=0;e<d.length;e++){l[o]=e;const t=(0,_e.SM)({inputs:{x:a},backend:n,attrs:{begin:l,size:p}});d[e]=z({inputs:{x:t},backend:n,attrs:{shape:u}}),n.disposeIntermediateTensorInfo(t)}return d}},go={kernelName:r.imz,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:o}=e,{x:s,segmentIds:i}=t,{numSegments:u}=o;(0,a.q)(s,"unsortedSegmentSum");const c=[],l=[],p=s.shape.length-i.shape.length;let d=i;for(let e=0;e<p;++e){const t=Pt({inputs:{input:d},backend:n,attrs:{dim:e+1}});d=t,l.push(t)}for(let e=0;e<u;++e){const t=r.euu.createScalarValue(e,"int32"),a=n.makeTensorInfo([],"int32",t),o=xt({inputs:{a:a,b:d},backend:n}),i=D({inputs:{x:o},backend:n,attrs:{dtype:"float32"}}),u=mt({inputs:{a:i,b:s},backend:n}),p=yt({inputs:{x:u},backend:n,attrs:{axis:0,keepDims:!1}});c.push(p),l.push(a),l.push(o),l.push(i),l.push(u),l.push(p)}const h=Er({inputs:c,backend:n,attrs:{axis:0}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}},yo=[V,G,j,Q,W,Y,ee,te,ne,re,oe,ie,ce,de,fe,be,we,ve,ke,H,xe,Ie,Ne,Ee,Ae,O,Oe,Pe,T,Re,Be,He,Ve,Ge,qe,je,Ke,Ye,Ze,Xe,et,tt,nt,rt,ot,st,it,ut,ct,lt,pt,dt,wt,p,vt,_t,Ft,Ct,Rt,Wt,Yt,Zt,Xt,nn,on,sn,un,cn,ln,hn,gn,h,yn,We,wn,kn,_n,m,Nn,En,An,On,Pn,Ln,zn,Hn,Vn,Gn,jn,Yn,Jn,Zn,Xn,er,tr,nr,rr,sr,ir,lr,fr,gt,mr,yr,wr,kr,Ir,Sr,Tr,Ar,Fr,Cr,w,Pr,Lr,zr,Gr,jr,F,Ut,Qr,k,_,B,Yr,Jr,Zr,Xr,ea,ta,ra,sa,ua,pa,da,ga,S,ba,va,xa,_e.Iv,hr,Sa,Na,Ma,Ta,Aa,Fa,Da,Oa,Pa,Ra,Wa,Ua,Va,Ga,ja,Qa,Ja,qt,bt,Xa,to,no,ro,so,io,X,fo,mo,go,Mr];for(const e of yo)(0,r.qe5)(e)},91428:function(e,t,n){"use strict";n.d(t,{m:function(){return a}});var r=n(42840);function a(e,t,n,a){const o=r.euu.getArrayFromDType(n,r.euu.sizeFromShape(t));if(a&&"string"!==n){let t=0;e.forEach((e=>{const n=r.euu.sizeFromShape(e.shape);o.set(e.vals,t),t+=n}))}else{let a=0;e.forEach((e=>{const s="string"===n?r.cxb.fromUint8ToStringArray(e.vals):e.vals;let i=0;for(let n=0;n<e.shape[0];++n){const r=n*t[1]+a;for(let t=0;t<e.shape[1];++t)o[r+t]=s[i++]}a+=e.shape[1]}))}return o}},33996:function(e,t,n){"use strict";n.d(t,{S:function(){return a}});var r=n(42840);function a(e,t,n,a){if(e===t||e<t&&n<0||t<e&&n>1)return r.euu.makeZerosTypedArray(0,a);const o=Math.abs(Math.ceil((t-e)/n)),s=r.euu.makeZerosTypedArray(o,a);t<e&&1===n&&(n=-1),s[0]=e;for(let e=1;e<s.length;e++)s[e]=s[e-1]+n;return s}},23960:function(e,t,n){"use strict";n.d(t,{Iv:function(){return i},Ki:function(){return o},SM:function(){return s}});var r=n(42840),a=n(43940);function o(e,t,n,a,o){const s=r.sL.isSliceContinous(a,t,n),i=r.euu.sizeFromShape(n),u=r.euu.computeStrides(a);if(s){const n=r.sL.computeFlatOffset(t,u);return"string"===o?e.slice(n,n+i):e.subarray(n,n+i)}const c="string"===o?r.cxb.fromUint8ToStringArray(e):e,l=(0,r.cz0)(a,o,c),p=(0,r.cz0)(n,o);for(let e=0;e<p.size;++e){const n=p.indexToLoc(e),r=n.map(((e,n)=>e+t[n]));p.set(l.get(...r),...n)}return"string"===o?r.cxb.fromStringArrayToUint8(p.values):p.values}function s(e){const{inputs:t,backend:n,attrs:s}=e,{x:i}=t,{begin:u,size:c}=s;(0,a.q)(i,"slice");const[l,p]=r.sL.parseSliceParams(i,u,c);r.sL.assertParamsValid(i,l,p);const d=o(n.data.get(i.dataId).values,l,p,i.shape,i.dtype);return n.makeTensorInfo(p,i.dtype,d)}const i={kernelName:r.eKt,backendName:"cpu",kernelFunc:s}},72652:function(e,t,n){"use strict";n.d(t,{s:function(){return o}});var r=n(42840);class a{constructor(e,t,n,a,o,s){this.separator=r.euu.encodeString(e),this.nGramWidths=t,this.leftPad=r.euu.encodeString(n),this.rightPad=r.euu.encodeString(a),this.padWidth=o,this.preserveShort=s}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,a,o){for(let s=0;s<a;++s){const i=this.getPadWidth(o),u=Math.max(0,i-s),c=Math.max(0,i-(a-(s+1))),l=o-(u+c),p=t+(u>0?0:s-i);let d=0;d+=u*this.leftPad.length;for(let t=0;t<l;++t)d+=e[p+t].length;d+=c*this.rightPad.length,d+=(u+c+l-1)*this.separator.length,n[r+s]=new Uint8Array(d);const h=n[r+s];let f=0;const m=e=>e.forEach((e=>h[f++]=e));for(let e=0;e<u;++e)m(this.leftPad),m(this.separator);for(let t=0;t<l-1;++t)m(e[p+t]),m(this.separator);if(l>0){m(e[p+l-1]);for(let e=0;e<c;++e)m(this.separator),m(this.rightPad)}else{for(let e=0;e<c-1;++e)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(e,t){const n=e.length,a=t.length;if(a>0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let r=1;r<a;++r){let a=t[r]>=e;if(a=a&&t[r]<=n,!a)throw new Error(`Invalid split value ${t[r]}, must be in [${e}, ${n}]`);e=t[r]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const o=a-1,s=r.euu.getArrayFromDType("int32",a);if(0===n||0===a){const e=new Array(n);for(let e=0;e<=o;++e)s[e]=0;return[e,s]}s[0]=0;for(let e=1;e<=o;++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),s[e]=s[e-1]+r}const i=new Array(s[o]);for(let n=0;n<o;++n){const r=t[n];let a=s[n];if(this.nGramWidths.forEach((o=>{const s=t[n+1]-t[n],u=this.getNumNGrams(s,o);this.createNGrams(e,r,i,a,u,o),a+=u})),this.preserveShort&&a===s[n]){const o=t[n+1]-t[n];if(0===o)continue;const s=o+2*this.padWidth,u=1;this.createNGrams(e,r,i,a,u,s)}}return[i,s]}}function o(e,t,n,r,o,s,i,u){return new a(n,r,o,s,i,u).compute(e,t)}},29772:function(e,t,n){"use strict";n.d(t,{i:function(){return o}});var r=n(42840);function a(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;t<e.length;++t)r.push(e.subarray(t,t+1));return}if(1===t.length){const a=t[0];let o=e.indexOf(a);for(;-1!==o;){const t=e.subarray(0,o);n&&0===t.length||r.push(t),o=(e=e.subarray(o+1)).indexOf(a)}return void(n&&0===e.length||r.push(e))}let a=0;for(let o=0;o<e.length+1;o++)if(o===e.length||-1!==t.indexOf(e[o])){const t=e.subarray(a,o);n&&0===t.length||r.push(t),a=o+1}}function o(e,t,n){const o=e.length,s=[];let i=0,u=0;const c=new Array(o);for(let r=0;r<o;++r){const o=s.length;a(e[r],t,n,s);const l=s.length-o;c[r]=l,i+=l,u=Math.max(u,l)}const l=r.euu.getArrayFromDType("int32",2*i),p=new Array(i),d=[o,u];let h=0;for(let e=0;e<o;++e)for(let t=0;t<c[e];++t)l[2*h]=e,l[2*h+1]=t,p[h]=s[h],++h;return[l,p,d]}},20128:function(e,t,n){"use strict";n.d(t,{e:function(){return a}});var r=n(42840);function a(e,t){const n=r.euu.getArrayFromDType("int32",e.length);for(let a=0;a<e.length;++a)n[a]=r.euu.fingerPrint64(e[a]).modulo(t).getLowBitsUnsigned();return n}},20932:function(e,t,n){"use strict";n.d(t,{c:function(){return a}});var r=n(42840);
vendor: 78,708 bytes, line 2
2function a(e,t,n,a){const o=r.euu.parseAxisParam(t,n)[0],s=[1,n[0],1];for(let e=0;e<o;e++)s[0]*=n[e];s[1]=n[o];for(let e=o+1;e<n.length;e++)s[2]*=n[e];const i=new Map,u=new Int32Array(n[o]),c=new r.Kq3(s,a,e),l=[],p=1===s[0]&&1===s[2];for(let t=0;t<n[o];t++){let n;if(p)n=e[t].toString();else{const e=[];for(let n=0;n<s[0];n++)for(let r=0;r<s[2];r++)e.push(c.get(n,t,r));n=e.join(",")}const r=i.get(n);if(null!=r)u[t]=r;else{const e=i.size;i.set(n,e),u[t]=e,l.push(t)}}const d=s.slice();d[1]=i.size;const h=new r.Kq3(d,a);l.forEach(((e,t)=>{for(let n=0;n<s[0];n++)for(let r=0;r<s[2];r++)h.set(c.get(n,e,r),n,t,r)}));const f=n.slice();return f[o]=d[1],{outputValues:h.values,outputShape:f,indices:u}}},98462:function(e,t,n){"use strict";n.d(t,{Co:function(){return ha},aG:function(){return ga}});var r,a,o=n(42840);let s;!function(e){e[e.float32=0]="float32",e[e.int32=1]="int32",e[e.bool=2]="bool",e[e.string=3]="string",e[e.complex64=4]="complex64"}(r||(r={})),function(e){e[e.linear=0]="linear",e[e.relu=1]="relu",e[e.relu6=2]="relu6",e[e.prelu=3]="prelu",e[e.leakyrelu=4]="leakyrelu",e[e.sigmoid=5]="sigmoid",e[e.elu=6]="elu"}(a||(a={}));const i={kernelName:o.gHH,backendName:"wasm",setupFunc:function(e){s=e.wasm.cwrap(o.gHH,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a:i,b:u,bias:c,preluActivationWeights:l}=t;if("float32"!==i.dtype||"float32"!==u.dtype)throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");const{transposeA:p,transposeB:d,activation:h,leakyreluAlpha:f}=r,m=n.dataIdMap.get(i.dataId).id,g=n.dataIdMap.get(u.dataId).id;let y=0;if(null!=c){const e=n.dataIdMap.get(c.dataId);if(1!==e.shape.length)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${e.shape.length}.`);y=e.id}const b=null==l?0:n.dataIdMap.get(l.dataId).id,w=a[h];if(null==w)throw new Error(`${h} activation not yet supported for FusedConv2D in the wasm backend.`);const v=p?i.shape[2]:i.shape[1],k=d?u.shape[1]:u.shape[2],x=o.qm_.assertAndGetBroadcastShape(i.shape.slice(0,-2),u.shape.slice(0,-2)),_=n.makeOutput([...x,v,k],i.dtype),I=n.dataIdMap.get(_.dataId).id,S=new Uint8Array(new Int32Array(i.shape).buffer),N=new Uint8Array(new Int32Array(u.shape).buffer);return s(m,S,i.shape.length,g,N,u.shape.length,p,d,w,y,b,f||0,I),_}};function u(e,t){let n;return{kernelName:e,backendName:"wasm",setupFunc:function(t){n=t.wasm.cwrap(e,null,["number","number","number"])},kernelFunc:function(e){const{backend:a,inputs:{x:s}}=e,i=a.dataIdMap.get(s.dataId).id,u=a.makeOutput(s.shape,t||s.dtype),c=a.dataIdMap.get(u.dataId).id;return 0===o.euu.sizeFromShape(u.shape)||n(i,r[s.dtype],c),u}}}const c=u(o.UXy),l=u(o.Y93),p=u(o.yak);function d(e,t,n){let a;return{kernelName:e,backendName:"wasm",setupFunc:function(t){a=t.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:s}=e,{a:i,b:u}=s,c=t.dataIdMap.get(i.dataId).id,l=t.dataIdMap.get(u.dataId).id,p=null!=n?n:i.dtype,d=o.cxb.assertAndGetBroadcastShape(i.shape,u.shape),h=t.makeOutput(d,p);if(0===o.euu.sizeFromShape(d))return h;const f=new Uint8Array(new Int32Array(i.shape).buffer),m=new Uint8Array(new Int32Array(u.shape).buffer),g=t.dataIdMap.get(h.dataId).id;return a(c,f,i.shape.length,l,m,u.shape.length,r[i.dtype],g),h}}}const h=d(o.OMN);let f;const m={kernelName:o.SE4,backendName:"wasm",setupFunc:function(e){f=e.wasm.cwrap(o.SE4,null,["array","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n}=e,a=n.makeOutput(t[0].shape,t[0].dtype);if(0===o.euu.sizeFromShape(a.shape))return a;const s=t.map((e=>n.dataIdMap.get(e.dataId).id)),i=new Uint8Array(new Int32Array(s).buffer),u=n.dataIdMap.get(a.dataId).id;return f(i,s.length,r[a.dtype],u),a}};function g(e){const{inputs:{x:t},backend:n}=e;if("string"===t.dtype)return(0,o.mwg)(n.readSync(t.dataId),t.shape,t.dtype);const r=n.makeOutput(t.shape,t.dtype),a=n.typedArrayFromHeap(t);return n.typedArrayFromHeap(r).set(a),r}const y={kernelName:o.oPg,backendName:"wasm",kernelFunc:g};let b;function w(e){const{inputs:t,backend:n,attrs:a}=e,[o,s]=function(e,t){const n=[],r=[];for(let a=0;a<e.length;++a)1!==e[a]&&n.push(e[a]),1!==e[t[a]]&&r.push(t[a]);for(let e=0;e<r.length;++e){let t=-1;for(let n=0;n<r.length;++n)r[n]>=e&&(-1===t||r[t]>r[n])&&(t=n);r[t]=e}return[n,r]}(t.x.shape,a.perm);let i=!0;for(let e=0;e<s.length;e++)s[e]!==e&&(i=!1);const u=function(e,t){const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];return n}(t.x.shape,a.perm),c={dataId:t.x.dataId,shape:o,dtype:t.x.dtype};if(i){const e=g({inputs:t,backend:n});return e.shape=u,e}const l=n.makeOutput(u,c.dtype),p=n.dataIdMap.get(c.dataId).id,d=n.dataIdMap.get(l.dataId).id,h=new Uint8Array(new Int32Array(s).buffer),f=new Uint8Array(new Int32Array(c.shape).buffer);return b(p,f,c.shape.length,r[c.dtype],d,h,s.length),l}const v={kernelName:o.$Up,backendName:"wasm",kernelFunc:w,setupFunc:function(e){b=e.wasm.cwrap(o.$Up,null,["number","array","number","number","number","array","number"])}};function k(e,t,n){const r=e.shape,a=e.shape.length,s=o.euu.parseAxisParam(t,r);let i=s;const u=o.cxb.getAxesPermutation(i,a);let c=null,l=!1;if(null!=u){const t=new Array(a);for(let e=0;e<t.length;e++)t[e]=r[u[e]];i=o.cxb.getInnerMostAxes(i.length,a),c=w({inputs:{x:e},attrs:{perm:u},backend:n});const s=n.dataIdMap.get(e.dataId).id;n.dataIdMap.get(c.dataId).id!==s&&(l=!0)}return{transposed:c,originalAxes:s,axes:i,inputWasTransposed:l}}let x;const _={kernelName:o.u8Z,backendName:"wasm",setupFunc:function(e){x=e.wasm.cwrap(o.u8Z,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:s}=r,{x:i}=n;let u=t.dataIdMap.get(i.dataId).id,c=i;const{transposed:l,axes:p,originalAxes:d,inputWasTransposed:h}=k(i,a,t);h&&(c=l,u=t.dataIdMap.get(l.dataId).id);const f=c.shape.length;o.cxb.assertAxesAreInnerMostDims("all",p,f);const[m,g]=o.cxb.computeOutAndReduceShapes(c.shape,p),y=o.euu.sizeFromShape(g),b=t.makeOutput(m,i.dtype);if(0!==o.euu.sizeFromShape(c.shape)){const e=t.dataIdMap.get(b.dataId).id;x(u,y,e)}if(h&&t.disposeData(l.dataId),s){const e=o.cxb.expandShapeToKeepDim(b.shape,d);b.shape=e}return b}};let I;const S={kernelName:o.YdD,backendName:"wasm",setupFunc:function(e){I=e.wasm.cwrap(o.YdD,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:s}=r,{x:i}=n;let u=t.dataIdMap.get(i.dataId).id,c=i;const{transposed:l,axes:p,originalAxes:d,inputWasTransposed:h}=k(i,a,t);h&&(c=l,u=t.dataIdMap.get(l.dataId).id);const f=c.shape.length;o.cxb.assertAxesAreInnerMostDims("any",p,f);const[m,g]=o.cxb.computeOutAndReduceShapes(c.shape,p),y=o.euu.sizeFromShape(g),b=t.makeOutput(m,i.dtype);if(0!==o.euu.sizeFromShape(c.shape)){const e=t.dataIdMap.get(b.dataId).id;I(u,y,e)}if(h&&t.disposeData(l.dataId),s){const e=o.cxb.expandShapeToKeepDim(b.shape,d);b.shape=e}return b}};function N(e){let t;return{kernelName:e,backendName:"wasm",setupFunc:function(n){t=n.wasm.cwrap(e,null,["number","number","number","number","number"])},kernelFunc:function(e){const{backend:n,inputs:a,attrs:s}=e,{axis:i}=s,{x:u}=a,c=n.dataIdMap.get(u.dataId).id;let l=c,p=u;const{transposed:d,axes:h,inputWasTransposed:f}=k(u,i,n);if(f){const e=n.dataIdMap.get(d.dataId).id;e!==c&&(p=d,l=e)}const m=p.shape.slice(0,-1),g=n.makeOutput(m,"int32"),y=n.dataIdMap.get(g.dataId).id,b=o.euu.sizeFromShape(g.shape),w=p.shape[h[0]];return t(l,r[p.dtype],b,w,y),f&&n.disposeData(d.dataId),g}}}const M=N(o.IBO),T=N(o.ovQ),E=u(o.Kgs),A=u(o.ILp),F=u(o.oNL),D=d(o.s1o),O=u(o.cL);let C;const P={kernelName:o.ITk,backendName:"wasm",setupFunc:function(e){C=e.wasm.cwrap(o.ITk,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,a=t.x,s=r.dataIdMap.get(a.dataId).id,{filterSize:i,strides:u,pad:c,dimRoundingMode:l}=n,p=o.cxb.computePool2DInfo(a.shape,i,u,1,c,l),d=p.filterHeight,h=p.filterWidth,f=p.padInfo.top,m=p.padInfo.right,g=p.padInfo.bottom,y=p.padInfo.left,b=p.strideHeight,w=p.strideWidth,v=p.inChannels;if("channelsLast"!==p.dataFormat)throw new Error(`wasm backend does not support dataFormat:'${p.dataFormat}'. Please use 'channelsLast'.`);if(1!==p.dilationWidth||1!==p.dilationHeight)throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${p.dilationHeight}, ${p.dilationWidth}].`);const k=r.makeOutput(p.outShape,"float32"),x=r.dataIdMap.get(k.dataId).id;return C(s,a.shape[0],a.shape[1],a.shape[2],d,h,f,m,g,y,b,w,v,x),k}};let R;const $={kernelName:o.wre,backendName:"wasm",setupFunc:function(e){R=e.wasm.cwrap("AvgPool3D",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:s,strides:i,pad:u,dimRoundingMode:c,dataFormat:l}=r,p=o.cxb.computePool3DInfo(a.shape,s,i,1,u,c,l),d=n.makeOutput(p.outShape,a.dtype);return R(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(d.dataId).id,p.batchSize,p.inChannels,p.inDepth,p.inHeight,p.inWidth,p.outDepth,p.outHeight,p.outWidth,p.strideDepth,p.strideHeight,p.strideWidth,p.dilationDepth,p.dilationHeight,p.dilationWidth,p.effectiveFilterDepth,p.effectiveFilterHeight,p.effectiveFilterWidth,p.padInfo.front,p.padInfo.top,p.padInfo.left),d}};let L;const W={kernelName:o.CSC,backendName:"wasm",setupFunc:function(e){L=e.wasm.cwrap("AvgPool3DGrad",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:s}=t,{filterSize:i,strides:u,pad:c,dimRoundingMode:l}=r,p=o.cxb.computePool3DInfo(s.shape,i,u,1,c,l),d=n.makeOutput(s.shape,s.dtype);return L(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(d.dataId).id,p.batchSize,p.inChannels,p.inDepth,p.inHeight,p.inWidth,p.outDepth,p.outHeight,p.outWidth,p.strideDepth,p.strideHeight,p.strideWidth,p.dilationDepth,p.dilationHeight,p.dilationWidth,p.effectiveFilterDepth,p.effectiveFilterHeight,p.effectiveFilterWidth,p.padInfo.front,p.padInfo.top,p.padInfo.left,p.filterDepth,p.filterHeight,p.filterWidth),d}};let z;const B={kernelName:o.S4W,backendName:"wasm",setupFunc:function(e){z=e.wasm.cwrap("AvgPoolGrad",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:s}=t,{filterSize:i,strides:u,pad:c}=r,l=o.cxb.computePool2DInfo(s.shape,i,u,1,c),p=n.makeOutput(s.shape,s.dtype);return z(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(p.dataId).id,l.batchSize,l.inChannels,l.inHeight,l.inWidth,l.outHeight,l.outWidth,l.strideHeight,l.strideWidth,l.dilationHeight,l.dilationWidth,l.effectiveFilterHeight,l.effectiveFilterWidth,l.padInfo.top,l.padInfo.left,l.filterHeight,l.filterWidth),p}};function U(e){const{inputs:t,attrs:n}=e,{x:r}=t,{shape:a}=n,s=o.euu.sizeFromShape(r.shape),i=o.euu.inferFromImplicitShape(a,s);return o.euu.assert(s===o.euu.sizeFromShape(i),(()=>`new shape: ${i}, old shape: ${r.shape}. New shape and old shape must have the same number of elements.`)),e.backend.incRef(r.dataId),{dataId:r.dataId,shape:i,dtype:r.dtype}}const H={kernelName:o.MvO,backendName:"wasm",kernelFunc:U};let V;const G={kernelName:o.Sye,backendName:"wasm",setupFunc:function(e){V=e.wasm.cwrap(o.Sye,null,["number","array","number","number","array","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a:a,b:s}=t,{transposeA:i,transposeB:u}=r;if("float32"!==a.dtype||"float32"!==s.dtype)throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");const c=a.shape.length,l=s.shape.length,p=i?a.shape[c-2]:a.shape[c-1],d=u?s.shape[l-1]:s.shape[l-2],h=i?a.shape[c-1]:a.shape[c-2],f=u?s.shape[l-2]:s.shape[l-1],m=a.shape.slice(0,-2),g=s.shape.slice(0,-2),y=o.euu.sizeFromShape(m),b=o.euu.sizeFromShape(g),w=o.qm_.assertAndGetBroadcastShape(a.shape.slice(0,-2),s.shape.slice(0,-2)).concat([h,f]);o.euu.assert(p===d,(()=>`Error in matMul: inner shapes (${p}) and (${d}) of Tensors with shapes ${a.shape} and ${s.shape} and transposeA=${i} and transposeB=${u} must match.`));const v=u?[b,f,d]:[b,d,f],k=U({inputs:{x:a},backend:n,attrs:{shape:i?[y,p,h]:[y,h,p]}}),x=U({inputs:{x:s},backend:n,attrs:{shape:v}}),_=n.dataIdMap.get(k.dataId).id,I=n.dataIdMap.get(x.dataId).id,S=i?k.shape[2]:k.shape[1],N=u?x.shape[1]:x.shape[2],M=Math.max(y,b),T=n.makeOutput([M,S,N],k.dtype),E=n.dataIdMap.get(T.dataId).id,A=new Uint8Array(new Int32Array(k.shape).buffer),F=new Uint8Array(new Int32Array(x.shape).buffer);return V(_,A,k.shape.length,I,F,x.shape.length,i,u,E),n.disposeData(k.dataId),n.disposeData(x.dataId),T.shape=w,T}};var q=n(23960);function j(e){const{inputs:{x:t},attrs:{begin:n,size:r},backend:a}=e,[s,i]=o.sL.parseSliceParams(t,n,r),u=o.sL.isSliceContinous(t.shape,s,i),c=a.readSync(t.dataId),l=a.makeOutput(i,t.dtype),p=o.euu.computeStrides(t.shape),d=a.dataIdMap.get(l.dataId);if(u){const e=o.sL.computeFlatOffset(s,p);return"string"===t.dtype?d.stringBytes=c.slice(e,e+o.euu.sizeFromShape(i)):a.typedArrayFromHeap(l).set(c.subarray(e,e+o.euu.sizeFromShape(i))),l}if("string"===t.dtype){const e=(0,q.Ki)(c,s,i,t.shape,t.dtype);return d.stringBytes=e,l}const h=a.typedArrayFromHeap(l),f=t.shape.length;if(2===f)!function(e,t,n,r,a){let o=0;const s=r[0],i=r[1],u=s+a[0];for(let r=s;r<u;r++){const s=r*t+i;n.set(e.subarray(s,s+a[1]),o),o+=a[1]}}(c,p[0],h,s,i);else if(3===f)!function(e,t,n,r,a,o){let s=0;const i=a[0],u=a[1],c=a[2],l=i+o[0],p=u+o[1];for(let a=i;a<l;a++)for(let i=u;i<p;i++){const u=a*t+i*n+c;r.set(e.subarray(u,u+o[2]),s),s+=o[2]}}(c,p[0],p[1],h,s,i);else if(4===f)!function(e,t,n,r,a,o,s){let i=0;const u=o[0],c=o[1],l=o[2],p=u+s[0],d=c+s[1],h=l+s[2],f=o[3];for(let o=u;o<p;o++)for(let u=c;u<d;u++)for(let c=l;c<h;c++){const l=o*t+u*n+c*r+f;a.set(e.subarray(l,l+s[3]),i),i+=s[3]}}(c,p[0],p[1],p[2],h,s,i);else{const e=(0,q.Ki)(c,s,i,t.shape,t.dtype);h.set(e)}return l}const K={kernelName:o.eKt,backendName:"wasm",kernelFunc:j},Q={kernelName:o.EV6,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:s,crops:i}=r,u=s.reduce(((e,t)=>e*t)),c=o.cxb.getReshaped(a.shape,s,u),l=o.cxb.getPermuted(c.length,s.length),p=o.cxb.getReshapedPermuted(a.shape,s,u),d=o.cxb.getSliceBeginCoords(i,s.length),h=o.cxb.getSliceSize(p,i,s.length),f=U({inputs:{x:a},backend:n,attrs:{shape:c}}),m=w({inputs:{x:f},backend:n,attrs:{perm:l}}),g=U({inputs:{x:m},backend:n,attrs:{shape:p}}),y=j({inputs:{x:g},backend:n,attrs:{begin:d,size:h}});return n.disposeData(f.dataId),n.disposeData(m.dataId),n.disposeData(g.dataId),y}};let Y;const J={kernelName:o.M3o,backendName:"wasm",setupFunc:function(e){Y=e.wasm.cwrap(o.M3o,null,["number","number","boolean","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{x:o,weights:s}=n,{size:i}=a,u=0!==s.shape.reduce(((e,t)=>e*t),1),c=1===o.shape.length?[i]:[o.shape[0],i],l=t.makeOutput(c,s.dtype);function p(e){return t.dataIdMap.get(e.dataId).id}return Y(p(o),i,u,p(s),r[s.dtype],p(l)),l}},Z=d(o.eCV),X={kernelName:o.orO,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,s=n.typedArrayFromHeap(r),i=n.typedArrayFromHeap(a),u=o.cxb.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return n.makeOutput([u.length],"int32",void 0,new Int32Array(u))}};function ee(e){const{inputs:{x:t},attrs:{dtype:n},backend:r}=e,a=r.makeOutput(t.shape,n),o=r.typedArrayFromHeap(t);return r.typedArrayFromHeap(a).set(o),a}const te={kernelName:o.Utj,backendName:"wasm",kernelFunc:ee},ne=u(o.OeR);let re;const ae={kernelName:o.Oe9,backendName:"wasm",setupFunc:function(e){re=e.wasm.cwrap(o.Oe9,null,["number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:o,clipValueMax:s}=r,i=n.dataIdMap.get(a.dataId).id,u=n.makeOutput(a.shape,a.dtype),c=n.dataIdMap.get(u.dataId).id;return re(i,o,s,c),u}};var oe=n(91428);function se(e){const{inputs:t,backend:n}=e,r=o.euu.parseAxisParam(e.attrs.axis,t[0].shape)[0],a=t.map((e=>e.shape));o.cxb.assertParamsConsistent(a,r);let s=o.cxb.computeOutShape(t.map((e=>e.shape)),r);const i=t.filter((e=>o.euu.sizeFromShape(e.shape)>0));if(1===i.length)return g({inputs:{x:i[0]},backend:n});const u=n.makeOutput(s,t[0].dtype);if(0===o.euu.sizeFromShape(s))return u;if("string"===i[0].dtype){const e=i.map((e=>{const t=o.euu.sizeFromShape(e.shape.slice(r));return U({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),a=e.map((e=>({vals:n.readSync(e.dataId),shape:e.shape})));s=o.cxb.computeOutShape(e.map((e=>e.shape)),1);const c=1===e[0].shape[0],l=(0,oe.m)(a,s,t[0].dtype,c),p=o.cxb.computeOutShape(i.map((e=>e.shape)),r);return u.shape=p,n.dataIdMap.get(u.dataId).stringBytes=o.cxb.fromStringArrayToUint8(l),e.forEach((e=>n.disposeData(e.dataId))),u}const c=o.euu.sizeFromShape(i[0].shape.slice(0,r));let l=0;const p=i.map((e=>{const t=o.euu.sizeFromShape(e.shape.slice(r));return l+=t,t})),d=i.map((e=>n.typedArrayFromHeap(e))),h=n.typedArrayFromHeap(u);for(let e=0;e<c;e++){let t=e*l;for(let n=0;n<d.length;n++){const r=p[n],a=e*r,o=d[n].subarray(a,a+r);h.set(o,t),t+=r}}return u}const ie={kernelName:o.usi,backendName:"wasm",kernelFunc:se};let ue;const ce={kernelName:o.a_P,backendName:"wasm",setupFunc:function(e){ue=e.wasm.cwrap(o.a_P,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:s}=t,i=r.dataIdMap.get(a.dataId).id,u=r.dataIdMap.get(s.dataId).id,{strides:c,dilations:l,pad:p,dimRoundingMode:d,dataFormat:h}=n,f=o.cxb.convertConv2DDataFormat(h),m=o.cxb.computeConv2DInfo(a.shape,s.shape,c,l,p,d,!1,f),g=m.filterHeight,y=m.filterWidth,b=m.padInfo.top,w=m.padInfo.right,v=m.padInfo.bottom,k=m.padInfo.left,x=m.dilationHeight,_=m.dilationWidth,I=m.strideHeight,S=m.strideWidth,N=m.inChannels,M=m.outChannels,T="SAME"===m.padInfo.type?1:0;if("channelsLast"!==m.dataFormat)throw new Error(`wasm backend Conv2D does not support dataFormat:'${m.dataFormat}'. Please use 'channelsLast'.`);const E=r.makeOutput(m.outShape,"float32"),A=r.dataIdMap.get(E.dataId).id;return ue(i,a.shape[0],a.shape[1],a.shape[2],u,g,y,b,w,v,k,T,x,_,I,S,N,M,A),E}};let le;const pe={kernelName:o.Mz5,backendName:"wasm",setupFunc:function(e){le=e.wasm.cwrap(o.Mz5,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{dy:a,filter:s}=n,{strides:i,pad:u,dataFormat:c,dimRoundingMode:l,inputShape:p}=r,d=o.cxb.convertConv2DDataFormat(c),h=o.cxb.computeConv2DInfo(p,s.shape,i,1,u,l,!1,d),{batchSize:f,filterHeight:m,filterWidth:g,inChannels:y,inHeight:b,inWidth:w,outChannels:v,outHeight:k,outWidth:x,strideHeight:_,strideWidth:I}=h,S=m-1-h.padInfo.top,N=g-1-h.padInfo.left,M="channelsLast"===h.dataFormat,T=o.euu.computeStrides(h.inShape),E=o.euu.computeStrides(a.shape),[A,F,D]=o.euu.computeStrides(s.shape),O=T[0],C=M?T[1]:T[2],P=M?T[2]:1,R=M?1:T[1],$=E[0],L=M?E[1]:E[2],W=M?E[2]:1,z=M?1:E[1],B=t.makeOutput(h.inShape,"float32"),U=t.dataIdMap.get(B.dataId).id,H=t.dataIdMap.get(a.dataId).id,V=t.dataIdMap.get(s.dataId).id;return le(H,V,f,m,g,b,w,y,k,x,v,_,I,S,N,A,F,D,O,C,P,R,$,L,W,z,U),B}};let de;const he={kernelName:o.WE3,backendName:"wasm",setupFunc:function(e){de=e.wasm.cwrap(o.WE3,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s}=t,{strides:i,pad:u,dilations:c}=r;if("float32"!==a.dtype)throw new Error(`Tensor x must have dtype float32, got ${a.dtype}`);if("float32"!==s.dtype)throw new Error(`Tensor filter must have dtype float32, got ${s.dtype}`);const l=o.cxb.computeConv3DInfo(a.shape,s.shape,i,c,u),p=n.makeOutput(l.outShape,a.dtype);return de(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(p.dataId).id,l.batchSize,l.inDepth,l.inHeight,l.inWidth,l.inChannels,l.outDepth,l.outHeight,l.outWidth,l.outChannels,l.strideDepth,l.strideHeight,l.strideWidth,l.dilationDepth,l.dilationHeight,l.dilationWidth,l.filterDepth,l.filterHeight,l.filterWidth,l.padInfo.front,l.padInfo.top,l.padInfo.left),p}};let fe;const me={kernelName:o.QjG,backendName:"wasm",setupFunc:function(e){fe=e.wasm.cwrap(o.QjG,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:s}=t,{strides:i,pad:u,filterShape:c}=r;if("float32"!==a.dtype)throw new Error(`Tensor dy must have dtype float32, got ${a.dtype}`);if("float32"!==s.dtype)throw new Error(`Tensor filter must have dtype float32, got ${s.dtype}`);const l=o.cxb.computeConv3DInfo(a.shape,c,i,1,u),p=n.makeOutput(l.filterShape,s.dtype);return fe(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(p.dataId).id,l.batchSize,l.inDepth,l.inHeight,l.inWidth,l.inChannels,l.outDepth,l.outHeight,l.outWidth,l.outChannels,l.strideDepth,l.strideHeight,l.strideWidth,l.dilationDepth,l.dilationHeight,l.dilationWidth,l.filterDepth,l.filterHeight,l.filterWidth,l.padInfo.front,l.padInfo.top,l.padInfo.left),p}};let ge;const ye={kernelName:o.ygG,backendName:"wasm",setupFunc:function(e){ge=e.wasm.cwrap(o.ygG,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:s}=t,{pad:i,strides:u,inputShape:c}=r;if("float32"!==a.dtype)throw new Error(`Tensor dy must have dtype float32, got ${a.dtype}`);if("float32"!==s.dtype)throw new Error(`Tensor filter must have dtype float32, got ${s.dtype}`);const l=o.cxb.computeConv3DInfo(c,s.shape,u,1,i),p=n.makeOutput(l.inShape,a.dtype);return ge(n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(p.dataId).id,l.batchSize,l.inDepth,l.inHeight,l.inWidth,l.inChannels,l.outDepth,l.outHeight,l.outWidth,l.outChannels,l.strideDepth,l.strideHeight,l.strideWidth,l.dilationDepth,l.dilationHeight,l.dilationWidth,l.filterDepth,l.filterHeight,l.filterWidth,l.padInfo.front,l.padInfo.top,l.padInfo.left),p}},be=u(o.EHc),we=u(o.YZ3);var ve;let ke;!function(e){e[e.bilinear=0]="bilinear",e[e.nearest=1]="nearest"}(ve||(ve={}));const xe={kernelName:o.WO0,backendName:"wasm",setupFunc:function(e){ke=e.wasm.cwrap(o.WO0,null,["number","number","number","number","array","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{method:a,extrapolationValue:o,cropSize:s}=r,{image:i,boxes:u,boxInd:c}=n,l=u.shape[0],[p,d]=s,h=[l,p,d,i.shape[3]];let f,m=t.dataIdMap.get(i.dataId);"float32"!==i.dtype&&(f=ee({backend:t,inputs:{x:i},attrs:{dtype:"float32"}}),m=t.dataIdMap.get(f.dataId));const g=m.id,y=t.dataIdMap.get(u.dataId).id,b=t.dataIdMap.get(c.dataId).id,w=t.makeOutput(h,"float32"),v=t.dataIdMap.get(w.dataId).id,k=new Uint8Array(new Int32Array(i.shape).buffer);return ke(g,y,b,l,k,p,d,ve[a],o,v),null!=f&&t.disposeData(f.dataId),w}};let _e;const Ie={kernelName:o.yuV,backendName:"wasm",setupFunc:function(e){_e=e.wasm.cwrap(o.yuV,null,["number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:s}=t,{axis:i,exclusive:u,reverse:c}=a,l=s.shape.length;o.euu.assert("float32"===s.dtype||"int32"===s.dtype,(()=>`cumprod does not support ${s.dtype} tensors in the WASM backend`));const p=o.cxb.getAxesPermutation([i],l);let d=s;null!==p&&(d=w({inputs:{x:s},attrs:{perm:p},backend:n}));const h=o.cxb.getInnerMostAxes(1,l)[0];o.cxb.assertAxesAreInnerMostDims("cumprod",[h],l);const f=n.makeOutput(d.shape,d.dtype),m=d.shape[h],g=n.dataIdMap.get(d.dataId).id,y=n.dataIdMap.get(f.dataId).id;_e(g,u?1:0,c?1:0,m,y,r[s.dtype]);let b=f;return null!==p&&(b=w({inputs:{x:f},attrs:{perm:o.cxb.getUndoAxesPermutation(p)},backend:n}),n.disposeData(d.dataId),n.disposeData(f.dataId)),b}};let Se;const Ne={kernelName:o.gBx,backendName:"wasm",setupFunc:function(e){Se=e.wasm.cwrap(o.gBx,null,["number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:s}=t,{axis:i,exclusive:u,reverse:c}=a,l=s.shape.length;o.euu.assert("float32"===s.dtype||"int32"===s.dtype,(()=>`cumsum does not support ${s.dtype} tensors in the WASM backend`));const p=o.cxb.getAxesPermutation([i],l);let d=s;null!==p&&(d=w({inputs:{x:s},attrs:{perm:p},backend:n}));const h=o.cxb.getInnerMostAxes(1,l)[0];o.cxb.assertAxesAreInnerMostDims("cumsum",[h],l);const f=n.makeOutput(d.shape,d.dtype),m=d.shape[h],g=n.dataIdMap.get(d.dataId).id,y=n.dataIdMap.get(f.dataId).id;Se(g,u?1:0,c?1:0,m,y,r[s.dtype]);let b=f;return null!==p&&(b=w({inputs:{x:f},attrs:{perm:o.cxb.getUndoAxesPermutation(p)},backend:n}),n.disposeData(d.dataId),n.disposeData(f.dataId)),b}};let Me;const Te={kernelName:o.COo,backendName:"wasm",setupFunc:function(e){Me=e.wasm.cwrap("DenseBincount",null,["number","array","number","number","boolean","number","number","boolean","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{x:o,weights:s}=n,{size:i,binaryOutput:u}=a,c=0!==s.shape.reduce(((e,t)=>e*t),1),l=1===o.shape.length?[i]:[o.shape[0],i],p=t.makeOutput(l,s.dtype);function d(e){return t.dataIdMap.get(e.dataId).id}return Me(d(o),new Uint8Array(new Int32Array(o.shape).buffer),o.shape.length,i,c,d(s),r[s.dtype],u,d(p)),p}};let Ee;const Ae={kernelName:o.OEe,backendName:"wasm",setupFunc:function(e){Ee=e.wasm.cwrap(o.OEe,null,["number","number","number","array","number","array","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{x:a}=n,{blockSize:s,dataFormat:i}=r,u=a.shape[0],c=("NHWC"===i?a.shape[1]:a.shape[2])*s,l=("NHWC"===i?a.shape[2]:a.shape[3])*s,p=("NHWC"===i?a.shape[3]:a.shape[1])/(s*s),d="NHWC"===i?[u,c,l,p]:[u,p,c,l],h=t.makeOutput(d,"float32"),f=t.dataIdMap.get(a.dataId).id,m=new Uint8Array(new Int32Array(o.euu.computeStrides(a.shape)).buffer),g=new Uint8Array(new Int32Array(d).buffer),y=new Uint8Array(new Int32Array(o.euu.computeStrides(d)).buffer),b=t.dataIdMap.get(h.dataId).id;return Ee(f,s,"NHWC"===i?1:0,m,a.shape.length-1,g,y,d.length,b),h}};let Fe;const De={kernelName:o.Fql,backendName:"wasm",setupFunc:function(e){Fe=e.wasm.cwrap(o.Fql,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:s}=t,i=r.dataIdMap.get(a.dataId).id,u=r.dataIdMap.get(s.dataId).id,{strides:c,dilations:l,pad:p,dimRoundingMode:d}=n,h=null==l?[1,1]:l,f=o.cxb.computeConv2DInfo(a.shape,s.shape,c,h,p,d,!0),m=f.filterHeight,g=f.filterWidth,y=f.padInfo.top,b=f.padInfo.right,w=f.padInfo.bottom,v=f.padInfo.left,k=f.dilationHeight,x=f.dilationWidth,_=f.strideHeight,I=f.strideWidth,S=f.inChannels,N=f.outChannels,M="SAME"===f.padInfo.type?1:0;if("channelsLast"!==f.dataFormat)throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${f.dataFormat}'. Please use 'channelsLast'.`);const T=r.makeOutput(f.outShape,"float32"),E=r.dataIdMap.get(T.dataId).id;return Fe(i,a.shape[0],a.shape[1],a.shape[2],u,m,g,y,b,w,v,M,k,x,_,I,S,N,E),T}};let Oe;const Ce={kernelName:o.uIb,backendName:"wasm",setupFunc:function(e){Oe=e.wasm.cwrap("Diag",null,["number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:a}=t,s=o.euu.sizeFromShape(a.shape),i=n.makeOutput([...a.shape,...a.shape],a.dtype);return Oe(n.dataIdMap.get(a.dataId).id,r[a.dtype],s,n.dataIdMap.get(i.dataId).id),i}};let Pe;const Re={kernelName:o.I7R,backendName:"wasm",setupFunc:function(e){Pe=e.wasm.cwrap(o.I7R,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:s,filter:i}=t,{strides:u,pad:c,dilations:l}=a;if(s.dtype!==i.dtype)throw new Error(`Dilation2D error: x must have the same dtype as filter. Got ${s.dtype} and ${i.dtype}`);const p=o.cxb.computeDilation2DInfo(s.shape,i.shape,u,c,"NHWC",l),d=n.makeOutput(p.outShape,s.dtype);return Pe(n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(i.dataId).id,n.dataIdMap.get(d.dataId).id,r[s.dtype],p.batchSize,p.inChannels,p.inHeight,p.inWidth,p.outHeight,p.outWidth,p.strideHeight,p.strideWidth,p.dilationHeight,p.dilationWidth,p.filterHeight,p.filterWidth,p.padInfo.top,p.padInfo.left),d}};let $e;const Le={kernelName:o.c1F,backendName:"wasm",setupFunc:function(e){$e=e.wasm.cwrap(o.c1F,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:s,filter:i,dy:u}=t,{strides:c,pad:l,dilations:p}=a;if(s.dtype!==i.dtype||s.dtype!==u.dtype)throw new Error(`Dilation2DBackpropFilter error: x must have the same dtype as filter and dy. Got ${s.dtype}, ${i.dtype}, and ${u.dtype}`);const d=o.cxb.computeDilation2DInfo(s.shape,i.shape,c,l,"NHWC",p),h=n.makeOutput(i.shape,i.dtype);return $e(n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(i.dataId).id,n.dataIdMap.get(u.dataId).id,n.dataIdMap.get(h.dataId).id,r[s.dtype],d.batchSize,d.inChannels,d.inHeight,d.inWidth,d.outHeight,d.outWidth,d.strideHeight,d.strideWidth,d.dilationHeight,d.dilationWidth,d.filterHeight,d.filterWidth,d.padInfo.top,d.padInfo.left),h}};let We;const ze={kernelName:o.cFK,backendName:"wasm",setupFunc:function(e){We=e.wasm.cwrap(o.cFK,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:s,filter:i,dy:u}=t,{strides:c,pad:l,dilations:p}=a;if(s.dtype!==i.dtype||s.dtype!==u.dtype)throw new Error(`Dilation2DBackpropInput error: x must have the same dtype as filter and dy. Got ${s.dtype}, ${i.dtype}, and ${u.dtype}`);const d=o.cxb.computeDilation2DInfo(s.shape,i.shape,c,l,"NHWC",p),h=n.makeOutput(s.shape,s.dtype);return We(n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(i.dataId).id,n.dataIdMap.get(u.dataId).id,n.dataIdMap.get(h.dataId).id,r[s.dtype],d.batchSize,d.inChannels,d.inHeight,d.inWidth,d.outHeight,d.outWidth,d.strideHeight,d.strideWidth,d.dilationHeight,d.dilationWidth,d.filterHeight,d.filterWidth,d.padInfo.top,d.padInfo.left),h}},Be=u(o.wP9);let Ue;const He={kernelName:o.Oyk,backendName:"wasm",setupFunc:function(e){Ue=e.wasm.cwrap(o.Oyk,null,["number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n}=e,{dy:r,y:a}=t,o=n.makeOutput(a.shape,"float32"),s=e=>n.dataIdMap.get(e.dataId).id;return Ue(s(a),s(r),s(o)),o}},Ve=d(o.Ooc,0,"bool"),Ge=u(o._s9),qe=u(o.ox3,"float32");function je(e){const{inputs:t,attrs:n,backend:r}=e,{input:a}=t,{dim:s}=n,i=a.shape.length,u=a.shape.slice();let c=s;return s<0&&(o.euu.assert(-(i+1)<=s,(()=>`Axis must be in the interval [${-(i+1)}, ${i}]`)),c=i+s+1),u.splice(c,0,1),U({inputs:{x:a},backend:r,attrs:{shape:u}})}const Ke={kernelName:o.IbD,backendName:"wasm",kernelFunc:je},Qe=u(o.MrP,"float32");function Ye(e){const{attrs:{shape:t,value:n,dtype:r},backend:a}=e,o=a.makeOutput(t,r);return a.typedArrayFromHeap(o).fill(n),o}const Je={kernelName:o.MnI,backendName:"wasm",kernelFunc:Ye};let Ze;const Xe={kernelName:o.ELw,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n}=e,{image:r}=t,a=n.makeOutput(r.shape,r.dtype),o=n.dataIdMap.get(r.dataId).id,s=n.dataIdMap.get(a.dataId).id,[i,u,c,l]=r.shape;return Ze(o,i,u,c,l,s),a},setupFunc:function(e){Ze=e.wasm.cwrap(o.ELw,null,["number","number","number","number","number","number"])}},et=u(o.WmE),tt=d(o._6e);let nt;const rt={kernelName:o.Qxm,backendName:"wasm",setupFunc:function(e){nt=e.wasm.cwrap(o.Qxm,null,["number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{varianceEpsilon:a}=r,{x:s,mean:i,variance:u,offset:c,scale:l}=n,p=t.dataIdMap.get(s.dataId).id,d=t.dataIdMap.get(i.dataId).id,h=t.dataIdMap.get(u.dataId).id,f=null!=c?t.dataIdMap.get(c.dataId).id:0,m=null!=l?t.dataIdMap.get(l.dataId).id:0,g=t.makeOutput(s.shape,s.dtype);if(0===o.euu.sizeFromShape(s.shape))return g;const y=t.dataIdMap.get(g.dataId).id;return nt(p,d,h,f,m,a,y),g}};let at;const ot={kernelName:o.S4v,backendName:"wasm",setupFunc:function(e){at=e.wasm.cwrap(o.S4v,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:s,filter:i,bias:u,preluActivationWeights:c}=t,{strides:l,pad:p,dilations:d,dataFormat:h,dimRoundingMode:f,activation:m,leakyreluAlpha:g}=n,y=o.cxb.computeConv2DInfo(s.shape,i.shape,l,d,p,f),b=a[m];if(null==b)throw new Error(`${m} activation not yet supported for FusedConv2D in the wasm backend.`);const w=r.dataIdMap.get(s.dataId).id,v=r.dataIdMap.get(i.dataId).id,k=y.outChannels;let x=0;if(null!=u){const e=r.dataIdMap.get(u.dataId);if(1!==e.shape.length)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${e.shape.length}.`);if(e.shape[0]!==k)throw new Error(`FusedConv2D bias shape (${e.shape}) does not match the number of output channels (${k})`);x=e.id}const _=y.filterHeight,I=y.filterWidth,S=y.padInfo.top,N=y.padInfo.right,M=y.padInfo.bottom,T=y.padInfo.left,E=y.dilationHeight,A=y.dilationWidth,F=y.strideHeight,D=y.strideWidth,O=y.inChannels,C="SAME"===y.padInfo.type?1:0,P=y.batchSize,R=y.inHeight,$=y.inWidth;if("NHWC"!==h)throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${h}'. Please use 'NHWC'.`);const L=r.makeOutput(y.outShape,"float32"),W=r.dataIdMap.get(L.dataId).id,z=null==c?0:r.dataIdMap.get(c.dataId).id;return at(w,P,R,$,v,_,I,x,S,N,M,T,C,E,A,F,D,O,k,b,z,g||0,W),L}};let st;const it={kernelName:o.Mjd,backendName:"wasm",setupFunc:function(e){st=e.wasm.cwrap(o.Mjd,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:s,filter:i,bias:u,preluActivationWeights:c}=t,{strides:l,pad:p,dilations:d,dataFormat:h,dimRoundingMode:f,activation:m,leakyreluAlpha:g}=n,y=o.cxb.computeConv2DInfo(s.shape,i.shape,l,d,p,f,!0),b=a[m];if(null==b)throw new Error(`${m} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);const w=r.dataIdMap.get(s.dataId).id,v=r.dataIdMap.get(i.dataId).id,k=y.outChannels;let x=0;if(null!=u){const e=r.dataIdMap.get(u.dataId);if(1!==e.shape.length)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${e.shape.length}.`);if(e.shape[0]!==k)throw new Error(`FusedDepthwiseConv2D bias shape (${e.shape}) does not match the number of output channels (${k})`);x=e.id}const _=y.filterHeight,I=y.filterWidth,S=y.padInfo.top,N=y.padInfo.right,M=y.padInfo.bottom,T=y.padInfo.left,E=y.dilationHeight,A=y.dilationWidth,F=y.strideHeight,D=y.strideWidth,O=y.inChannels,C="SAME"===y.padInfo.type?1:0,P=y.batchSize,R=y.inHeight,$=y.inWidth;if("NHWC"!==h)throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${h}'. Please use 'NHWC'.`);const L=r.makeOutput(y.outShape,"float32"),W=r.dataIdMap.get(L.dataId).id,z=null==c?0:r.dataIdMap.get(c.dataId).id;return st(w,P,R,$,v,_,I,x,S,N,M,T,C,E,A,F,D,O,k,b,z,g||0,W),L}};let ut;const ct={kernelName:o.SOJ,backendName:"wasm",setupFunc:function(e){ut=e.wasm.cwrap(o.SOJ,null,["number","number","number","number","number","number","array","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{params:a,indices:s}=n,[i,u,c,l]=o.EJ6.prepareAndValidate(a,s),p=t.makeOutput(i,a.dtype);if(0===u)return p;const d=s.shape,h=d[d.length-1],f=t.dataIdMap.get(a.dataId).id,m=t.dataIdMap.get(s.dataId).id,g=new Uint8Array(new Int32Array(l).buffer),y=t.dataIdMap.get(p.dataId).id;return ut(f,r[a.dtype],m,u,h,c,g,y),p}};let lt;const pt={kernelName:o.UV,backendName:"wasm",setupFunc:function(e){lt=e.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{x:s,indices:i}=n,{axis:u,batchDims:c}=a,l=o.euu.parseAxisParam(u,s.shape)[0],p=t.readSync(i.dataId),d=s.shape[l];for(let e=0;e<p.length;++e){const t=p[e];o.euu.assert(t<=d-1&&t>=0,(()=>`GatherV2: the index value ${t} is not in [0, ${d-1}]`))}const h=o.cxb.segment_util.collectGatherOpShapeInfo(s,i,l,c),f=U({inputs:{x:s},attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]},backend:t}),m=o.euu.sizeFromShape(i.shape),g=U({inputs:{x:i},attrs:{shape:[h.batchSize,m/h.batchSize]},backend:t}),y=[h.batchSize,h.outerSize,m/h.batchSize,h.sliceSize],b=t.makeOutput(y,s.dtype);if(0===o.euu.sizeFromShape(s.shape))return b;const w=f.shape.length-1,v=t.dataIdMap.get(f.dataId).id,k=t.dataIdMap.get(g.dataId).id,x=t.dataIdMap.get(b.dataId).id,_=new Uint8Array(new Int32Array(o.euu.computeStrides(f.shape)).buffer),I=new Uint8Array(new Int32Array(o.euu.computeStrides(y)).buffer);return lt(v,r[s.dtype],_,w,k,h.batchSize,I,x),t.disposeData(f.dataId),t.disposeData(g.dataId),b.shape=h.outputShape,b}},dt=d(o.o3B,0,"bool"),ht=d(o.QD,0,"bool"),ft=u(o.iwm,"bool"),mt=u(o.aMl,"bool"),gt=u(o.OiK,"bool");let yt;const bt={kernelName:o.Mb$,backendName:"wasm",setupFunc:function(e){yt=e.wasm.cwrap(o.Mb$,null,["number","number","number","number"])},kernelFunc:function(e){const{inputs:{x:t},attrs:{alpha:n},backend:a}=e,s=a.dataIdMap.get(t.dataId).id,i=a.makeOutput(t.shape,"float32");if(0!==o.euu.sizeFromShape(t.shape)){const e=a.dataIdMap.get(i.dataId).id;yt(s,r[t.dtype],n,e)}return i}},wt=d(o.GoJ,0,"bool"),vt=d(o.SMP,0,"bool");let kt;const xt={kernelName:o.Kst,backendName:"wasm",setupFunc:function(e){kt=e.wasm.cwrap(o.Kst,null,["number","number","number","number"])},kernelFunc:function(e){const{attrs:t,backend:n}=e,{start:r,stop:a,num:o}=t,s=Math.floor(o),i=n.makeOutput([s],"float32");return kt(n.dataIdMap.get(i.dataId).id,r,a,s),i}},_t=u(o.qwJ),It=u(o.eg6),St=d(o.SSA,0,"bool"),Nt=u(o._S1),Mt=d(o.whD,0,"bool"),Tt=d(o.cnd,0,"bool");let Et;const At={kernelName:o.wfw,backendName:"wasm",setupFunc:function(e){Et=e.wasm.cwrap(o.wfw,null,["number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:o,bias:s,alpha:i,beta:u}=r;if("float32"!==a.dtype)throw new Error("LRN error: x must have dtype float32");const c=n.makeOutput(a.shape,a.dtype);return Et(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(c.dataId).id,a.shape[3],o,s,i,u),c}};let Ft;const Dt={kernelName:o.SAF,backendName:"wasm",setupFunc:function(e){Ft=e.wasm.cwrap(o.SAF,null,["number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,y:o,dy:s}=t,{depthRadius:i,bias:u,alpha:c,beta:l}=r;if("float32"!==a.dtype||"float32"!==o.dtype||"float32"!==s.dtype)throw new Error("LRNGrad error: x, y, and dy must have dtype float32");const p=n.makeOutput(a.shape,a.dtype);return Ft(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(o.dataId).id,n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(p.dataId).id,s.shape[3],i,u,c,l),p}};let Ot;const Ct={kernelName:o.aUJ,backendName:"wasm",setupFunc:function(e){Ot=e.wasm.cwrap(o.aUJ,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{reductionIndices:s,keepDims:i}=a,{x:u}=n;let c=t.dataIdMap.get(u.dataId).id,l=u;const{transposed:p,axes:d,originalAxes:h,inputWasTransposed:f}=k(u,s,t);f&&(l=p,c=t.dataIdMap.get(p.dataId).id);const m=l.shape.length;o.cxb.assertAxesAreInnerMostDims("max",d,m);const[g,y]=o.cxb.computeOutAndReduceShapes(l.shape,d),b=o.euu.sizeFromShape(y),w=t.makeOutput(g,u.dtype);if(0!==o.euu.sizeFromShape(l.shape)){const e=t.dataIdMap.get(w.dataId).id;Ot(c,r[u.dtype],b,e)}if(f&&t.disposeData(p.dataId),i){const e=o.cxb.expandShapeToKeepDim(w.shape,h);w.shape=e}return w}},Pt=d(o.qik);let Rt;const $t={kernelName:o.MNi,backendName:"wasm",setupFunc:function(e){Rt=e.wasm.cwrap(o.MNi,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,a=t.x,s=r.dataIdMap.get(a.dataId).id;o.euu.assert("float32"===a.dtype,(()=>`Error in MaxPool: only float32 input is supported. Got ${a.dtype}.`));const{filterSize:i,strides:u,pad:c,dimRoundingMode:l}=n,p=o.cxb.computePool2DInfo(a.shape,i,u,1,c,l),d=p.filterHeight,h=p.filterWidth,f=p.padInfo.top,m=p.padInfo.right,g=p.padInfo.bottom,y=p.padInfo.left,b=p.dilationHeight,w=p.dilationWidth,v=p.strideHeight,k=p.strideWidth,x=p.inChannels,_=p.outChannels;if("channelsLast"!==p.dataFormat)throw new Error(`wasm backend does not support dataFormat:'${p.dataFormat}'. Please use 'channelsLast'.`);const I=r.makeOutput(p.outShape,"float32"),S=r.dataIdMap.get(I.dataId).id;return Rt(s,a.shape[0],a.shape[1],a.shape[2],d,h,f,m,g,y,b,w,v,k,x,_,S),I}};let Lt;const Wt={kernelName:o.C4i,backendName:"wasm",setupFunc:function(e){Lt=e.wasm.cwrap("MaxPool3D",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:s,strides:i,pad:u,dimRoundingMode:c,dataFormat:l}=r,p=o.cxb.computePool3DInfo(a.shape,s,i,1,u,c,l),d=n.makeOutput(p.outShape,a.dtype);return Lt(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(d.dataId).id,p.batchSize,p.inChannels,p.inDepth,p.inHeight,p.inWidth,p.outDepth,p.outHeight,p.outWidth,p.strideDepth,p.strideHeight,p.strideWidth,p.dilationDepth,p.dilationHeight,p.dilationWidth,p.effectiveFilterDepth,p.effectiveFilterHeight,p.effectiveFilterWidth,p.padInfo.front,p.padInfo.top,p.padInfo.left),d}};let zt;const Bt={kernelName:o.amh,backendName:"wasm",setupFunc:function(e){zt=e.wasm.cwrap("MaxPool3DGrad",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:s}=t,{filterSize:i,strides:u,pad:c,dimRoundingMode:l}=r,p=o.cxb.computePool3DInfo(s.shape,i,u,1,c,l),d=n.makeOutput(s.shape,s.dtype);return zt(n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(d.dataId).id,p.batchSize,p.inChannels,p.inDepth,p.inHeight,p.inWidth,p.outDepth,p.outHeight,p.outWidth,p.strideDepth,p.strideHeight,p.strideWidth,p.dilationDepth,p.dilationHeight,p.dilationWidth,p.effectiveFilterDepth,p.effectiveFilterHeight,p.effectiveFilterWidth,p.padInfo.front,p.padInfo.top,p.padInfo.left),d}};let Ut;const Ht={kernelName:o.AdS,backendName:"wasm",setupFunc:function(e){Ut=e.wasm.cwrap("MaxPoolGrad",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:s}=t,{filterSize:i,strides:u,pad:c,dimRoundingMode:l}=r,p=o.cxb.computePool2DInfo(s.shape,i,u,1,c,l),d=n.makeOutput(s.shape,s.dtype);return Ut(n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(d.dataId).id,p.batchSize,p.inChannels,p.inHeight,p.inWidth,p.outHeight,p.outWidth,p.strideHeight,p.strideWidth,p.dilationHeight,p.dilationWidth,p.effectiveFilterHeight,p.effectiveFilterWidth,p.padInfo.top,p.padInfo.left),d}};let Vt;const Gt={kernelName:o.yqo,backendName:"wasm",setupFunc:function(e){Vt=e.wasm.cwrap("MaxPoolWithArgmax",null,["number","number","number","number","boolean","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:s}=t,{filterSize:i,strides:u,pad:c,includeBatchInIndex:l}=a;o.euu.assert(4===s.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${s.shape.length}.`));const p=[1,1];o.euu.assert(o.cxb.eitherStridesOrDilationsAreOne(u,p),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${u} and dilations '${p}'`));const d=o.cxb.computePool2DInfo(s.shape,i,u,[1,1],c),h=n.makeOutput(d.outShape,s.dtype),f=n.makeOutput(d.outShape,"int32");return Vt(n.dataIdMap.get(s.dataId).id,n.dataIdMap.get(h.dataId).id,n.dataIdMap.get(f.dataId).id,r[s.dtype],l,d.batchSize,d.inChannels,d.inHeight,d.inWidth,d.outHeight,d.outWidth,d.strideHeight,d.strideWidth,d.dilationHeight,d.dilationWidth,d.effectiveFilterHeight,d.effectiveFilterWidth,d.padInfo.top,d.padInfo.left),[h,f]}};let qt;const jt={kernelName:o.iN$,backendName:"wasm",setupFunc:function(e){qt=e.wasm.cwrap(o.iN$,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:s}=r,{x:i}=n,u=t.dataIdMap.get(i.dataId).id;let c=u,l=i;const{transposed:p,axes:d,originalAxes:h,inputWasTransposed:f}=k(i,a,t);let m=d;if(f){const e=t.dataIdMap.get(p.dataId).id;e!==u&&(l=p,c=e,m=o.cxb.getInnerMostAxes(m.length,l.shape.length))}o.cxb.assertAxesAreInnerMostDims("mean",m,l.shape.length);const[g,y]=o.cxb.computeOutAndReduceShapes(l.shape,m),b=o.euu.sizeFromShape(y);let w=l;"float32"!==l.dtype&&(w=ee({backend:t,inputs:{x:l},attrs:{dtype:"float32"}}),c=t.dataIdMap.get(w.dataId).id);const v=t.makeOutput(g,"float32");if(0!==o.euu.sizeFromShape(l.shape)){const e=t.dataIdMap.get(v.dataId).id;qt(c,b,e)}if(f&&t.disposeData(p.dataId),s){const e=o.cxb.expandShapeToKeepDim(v.shape,h);v.shape=e}return"float32"!==l.dtype&&t.disposeData(w.dataId),v}};let Kt;const Qt={kernelName:o.WW2,backendName:"wasm",setupFunc:function(e){Kt=e.wasm.cwrap(o.WW2,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{axis:s,keepDims:i}=a,{x:u}=n,c=t.dataIdMap.get(u.dataId).id;let l=c,p=u;const{transposed:d,axes:h,originalAxes:f,inputWasTransposed:m}=k(u,s,t);if(m){const e=t.dataIdMap.get(d.dataId).id;e!==c&&(p=d,l=e)}const g=p.shape.length;o.cxb.assertAxesAreInnerMostDims("min",h,g);const[y,b]=o.cxb.computeOutAndReduceShapes(p.shape,h),w=o.euu.sizeFromShape(b),v=t.makeOutput(y,p.dtype);if(0!==o.euu.sizeFromShape(p.shape)){const e=t.dataIdMap.get(v.dataId).id;Kt(l,r[u.dtype],w,e)}if(m&&t.disposeData(d.dataId),i){const e=o.cxb.expandShapeToKeepDim(v.shape,f);v.shape=e}return v}},Yt=d(o.sly);var Jt;let Zt;!function(e){e[e.reflect=0]="reflect",e[e.symmetric=1]="symmetric"}(Jt||(Jt={}));const Xt={kernelName:o.C6u,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n,attrs:{paddings:a,mode:o}}=e,s=a.map(((e,n)=>e[0]+t.shape[n]+e[1])),i=n.dataIdMap.get(t.dataId).id,u=n.makeOutput(s,t.dtype),c=n.dataIdMap.get(u.dataId).id,l=new Uint8Array(new Int32Array(t.shape).buffer),p=a.map((e=>e[0])),d=a.map((e=>e[1])),h=new Uint8Array(new Int32Array(p).buffer),f=new Uint8Array(new Int32Array(d).buffer);return Zt(i,l,t.shape.length,r[t.dtype],h,f,Jt[o],c),u},setupFunc:function(e){Zt=e.wasm.cwrap(o.C6u,null,["number","array","number","number","array","array","number","number"])}};let en;function tn(e){const{backend:t,inputs:{logits:n},attrs:{dim:r}}=e,a=t.dataIdMap.get(n.dataId).id,s=t.makeOutput(n.shape,n.dtype),i=t.dataIdMap.get(s.dataId).id,u=n.shape[r],c=o.euu.sizeFromShape(n.shape)/u;return 0===o.euu.sizeFromShape(s.shape)||en(a,i,u,c),s}const nn={kernelName:o.a0o,backendName:"wasm",setupFunc:function(e){en=e.wasm.cwrap(o.a0o,null,["number","number","number","number"])},kernelFunc:tn};let rn;const an={kernelName:o.UdG,backendName:"wasm",setupFunc:function(e){rn=e.wasm.cwrap(o.UdG,null,["number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:o,seed:s,normalized:i}=r;if("float32"!==a.dtype)throw new Error(`Tensor logits must have dtype float32, got ${a.dtype}`);const u=i?a:tn({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),[c,l]=u.shape,p=n.makeOutput([c,o],"int32");return rn(n.dataIdMap.get(u.dataId).id,c,l,o,s,n.dataIdMap.get(p.dataId).id),i||n.disposeData(u.dataId),p}},on=d(o.InO),sn=d(o.SSu),un=u(o.yUy);function cn(e,t){const n=new Int32Array(e.wasm.HEAPU8.buffer,t,4),r=n[0],a=n[1],o=n[2],s=n[3];return e.wasm._free(t),{pSelectedIndices:r,selectedSize:a,pSelectedScores:o,pValidOutputs:s}}let ln;const pn={kernelName:o.aaw,backendName:"wasm",setupFunc:function(e){ln=e.wasm.cwrap(o.aaw,"number",["number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:o,scoreThreshold:s}=r,{boxes:i,scores:u}=n,c=t.dataIdMap.get(i.dataId).id,l=t.dataIdMap.get(u.dataId).id,p=ln(c,l,o,a,s),{pSelectedIndices:d,selectedSize:h,pSelectedScores:f,pValidOutputs:m}=cn(t,p);return t.wasm._free(f),t.wasm._free(m),t.makeOutput([h],"int32",d)}};let dn;const hn={kernelName:o.Q7n,backendName:"wasm",setupFunc:function(e){dn=e.wasm.cwrap(o.Q7n,"number",["number","number","number","number","number","bool"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:o,scoreThreshold:s,padToMaxOutputSize:i}=r,{boxes:u,scores:c}=n,l=t.dataIdMap.get(u.dataId).id,p=t.dataIdMap.get(c.dataId).id,d=dn(l,p,o,a,s,i),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=cn(t,d);return t.wasm._free(m),[t.makeOutput([f],"int32",h),t.makeOutput([],"int32",g)]}};let fn;const mn={kernelName:o.q82,backendName:"wasm",setupFunc:function(e){fn=e.wasm.cwrap(o.q82,"number",["number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:o,scoreThreshold:s,softNmsSigma:i}=r,{boxes:u,scores:c}=n,l=t.dataIdMap.get(u.dataId).id,p=t.dataIdMap.get(c.dataId).id,d=fn(l,p,o,a,s,i),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=cn(t,d);return t.wasm._free(g),[t.makeOutput([f],"int32",h),t.makeOutput([f],"float32",m)]}},gn=d(o.Ki5,0,"bool");let yn;const bn={kernelName:o.mon,backendName:"wasm",setupFunc:function(e){yn=e.wasm.cwrap(o.mon,null,["number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{dtype:o,depth:s,onValue:i,offValue:u}=r,c=n.makeOutput([...a.shape,s],o),l=n.dataIdMap.get(c.dataId).id,p=n.dataIdMap.get(a.dataId).id;return yn(p,s,i,u,l),c}},wn={kernelName:o.O_l,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(1),r}},vn={kernelName:o.cJi,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return je({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const s=t[0].shape,i=t[0].dtype;t.forEach((e=>{o.euu.assertShapesMatch(s,e.shape,"All tensors passed to stack must have matching shapes"),o.euu.assert(i===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const u=[],c=se({inputs:t.map((e=>{const t=je({inputs:{input:e},backend:n,attrs:{dim:a}});return u.push(t),t})),backend:n,attrs:{axis:a}});return u.forEach((e=>n.disposeData(e.dataId))),c}};let kn;const xn={kernelName:o.Q8A,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n,attrs:{paddings:a,constantValue:s}}=e,i=a.map(((e,n)=>e[0]+t.shape[n]+e[1]));if(0===o.euu.sizeFromShape(t.shape))return Ye({backend:n,attrs:{shape:i,value:s,dtype:t.dtype}});const u=n.dataIdMap.get(t.dataId).id,c=n.makeOutput(i,t.dtype),l=n.dataIdMap.get(c.dataId).id,p=new Uint8Array(new Int32Array(t.shape).buffer),d=a.map((e=>e[0])),h=a.map((e=>e[1])),f=new Uint8Array(new Int32Array(d).buffer),m=new Uint8Array(new Int32Array(h).buffer);return kn(u,p,t.shape.length,r[t.dtype],f,m,s,l),c},setupFunc:function(e){kn=e.wasm.cwrap(o.Q8A,null,["number","array","number","number","array","array","number","number"])}},_n=d(o.sTH);let In;const Sn={kernelName:o.cBF,backendName:"wasm",setupFunc:function(e){In=e.wasm.cwrap(o.cBF,null,["number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t,o=n.dataIdMap.get(r.dataId).id,s=n.dataIdMap.get(a.dataId).id;let i=o;const u=r;let c=u;"float32"!==u.dtype&&(c=ee({backend:n,inputs:{x:r},attrs:{dtype:"float32"}}),i=n.dataIdMap.get(c.dataId).id);const l=n.makeOutput(r.shape,"float32"),p=n.dataIdMap.get(l.dataId).id;return In(i,s,p),"float32"!==u.dtype&&n.disposeData(c.dataId),l}};let Nn;const Mn={kernelName:o.e_0,backendName:"wasm",setupFunc:function(e){Nn=e.wasm.cwrap(o.e_0,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{axis:s,keepDims:i}=a,{x:u}=n,c=t.dataIdMap.get(u.dataId).id;let l=c,p=u;const{transposed:d,axes:h,originalAxes:f,inputWasTransposed:m}=k(u,s,t);let g=h;if(m){const e=t.dataIdMap.get(d.dataId).id;e!==c&&(p=d,l=e,g=o.cxb.getInnerMostAxes(g.length,p.shape.length))}o.cxb.assertAxesAreInnerMostDims("prod",g,p.shape.length);const[y,b]=o.cxb.computeOutAndReduceShapes(p.shape,g),w=o.euu.sizeFromShape(b),v=t.makeOutput(y,p.dtype);if(0!==o.euu.sizeFromShape(p.shape)){const e=t.dataIdMap.get(v.dataId).id;Nn(l,w,r[v.dtype],e)}if(m&&t.disposeData(d.dataId),i){const e=o.cxb.expandShapeToKeepDim(v.shape,f);v.shape=e}return v}};var Tn=n(33996);const En={kernelName:o.EHu,backendName:"wasm",kernelFunc:e=>{const{backend:t,attrs:n}=e,{start:r,stop:a,step:o,dtype:s}=n,i=(0,Tn.S)(r,a,o,s),u=t.makeOutput([i.length],s);return t.typedArrayFromHeap(u).set(i),u}},An=d(o.uMf),Fn=u(o.Ezp),Dn=u(o.IHk),On=u(o.QwE);let Cn;const Pn={kernelName:o.qaT,backendName:"wasm",setupFunc:function(e){Cn=e.wasm.cwrap(o.qaT,null,["number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{images:a}=n,{alignCorners:s,halfPixelCenters:i,size:u}=r,[c,l]=u,[p,d,h,f]=a.shape,m=[p,c,l,f];let g,y=t.dataIdMap.get(a.dataId);"float32"!==y.dtype&&(g=ee({backend:t,inputs:{x:a},attrs:{dtype:"float32"}}),y=t.dataIdMap.get(g.dataId));const b=y.id,w=t.makeOutput(m,"float32");if(0===o.euu.sizeFromShape(a.shape))return w;const v=t.dataIdMap.get(w.dataId).id;return Cn(b,p,d,h,f,c,l,s?1:0,i?1:0,v),null!=g&&t.disposeData(g.dataId),w}};let Rn;const $n={kernelName:o.ewH,backendName:"wasm",setupFunc:function(e){Rn=e.wasm.cwrap(o.ewH,null,["number","number","number","array","array","boolean"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:o}=t,{alignCorners:s}=r,i=n.makeOutput(a.shape,"float32");let u,c=n.dataIdMap.get(a.dataId);return"float32"!==c.dtype&&(u=ee({backend:n,inputs:{x:a},attrs:{dtype:"float32"}}),c=n.dataIdMap.get(u.dataId)),Rn(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(o.dataId).id,n.dataIdMap.get(i.dataId).id,new Uint8Array(new Int32Array(a.shape).buffer),new Uint8Array(new Int32Array(o.shape).buffer),s),null!=u&&n.disposeData(u.dataId),i}};let Ln;const Wn={kernelName:o.Co2,backendName:"wasm",setupFunc:function(e){Ln=e.wasm.cwrap(o.Co2,null,["number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{images:a}=n,{alignCorners:s,halfPixelCenters:i,size:u}=r,[c,l]=u,[p,d,h,f]=a.shape,m=[p,c,l,f],g=t.makeOutput(m,"float32");if(0===o.euu.sizeFromShape(a.shape))return g;let y,b=t.dataIdMap.get(a.dataId);"float32"!==b.dtype&&(y=ee({backend:t,inputs:{x:a},attrs:{dtype:"float32"}}),b=t.dataIdMap.get(y.dataId));const w=b.id,v=t.dataIdMap.get(g.dataId).id;return Ln(w,p,d,h,f,c,l,s?1:0,i?1:0,v),null!=y&&t.disposeData(y.dataId),g}};let zn;const Bn={kernelName:o.WCE,backendName:"wasm",setupFunc:function(e){zn=e.wasm.cwrap(o.WCE,null,["number","number","number","array","array","boolean"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:o}=t,{alignCorners:s}=r,i=n.makeOutput(a.shape,"float32");let u,c=n.dataIdMap.get(a.dataId);return"float32"!==c.dtype&&(u=ee({backend:n,inputs:{x:a},attrs:{dtype:"float32"}}),c=n.dataIdMap.get(u.dataId)),zn(n.dataIdMap.get(a.dataId).id,n.dataIdMap.get(o.dataId).id,n.dataIdMap.get(i.dataId).id,new Uint8Array(new Int32Array(a.shape).buffer),new Uint8Array(new Int32Array(o.shape).buffer),s),null!=u&&n.disposeData(u.dataId),i}};let Un;const Hn={kernelName:o.glo,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:s}=r,i=o.euu.parseAxisParam(s,a.shape);if(0===a.shape.length)return g({inputs:{x:a},backend:n});const u=n.makeOutput(a.shape,a.dtype),c=n.dataIdMap.get(a.dataId).id,l=n.dataIdMap.get(u.dataId).id,p=new Uint8Array(new Int32Array(i).buffer),d=new Uint8Array(new Int32Array(a.shape).buffer);Un(c,p,i.length,d,a.shape.length,l);const h=U({inputs:{x:u},attrs:{shape:a.shape},backend:n});return n.disposeData(u.dataId),h},setupFunc:function(e){Un=e.wasm.cwrap(o.glo,null,["number","array","number","array","number","number"])}};let Vn;const Gn={kernelName:o.qWz,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a}=t,{radians:s,fillValue:i,center:u}=r,c=n.makeOutput(a.shape,a.dtype),l=n.dataIdMap.get(a.dataId).id,p=n.dataIdMap.get(c.dataId).id,[d,h,f,m]=a.shape,[g,y]=o.cxb.getImageCenter(u,h,f),b="number"==typeof i?[i,i,i,0===i?0:255]:[...i,255],w=new Uint8Array(new Int32Array(b).buffer);return Vn(l,d,h,f,m,s,g,y,w,b.length,p),c},setupFunc:function(e){Vn=e.wasm.cwrap(o.qWz,null,["number","number","number","number","number","number","number","number","array","number","number"])}},qn=u(o.I$0),jn=u(o.o9c);let Kn;const Qn={kernelName:o.qiV,backendName:"wasm",setupFunc:function(e){Kn=e.wasm.cwrap(o.qiV,null,["number","number","number","number","number","number","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{indices:s,updates:i}=n,{shape:u}=a,c=t.makeOutput(u,i.dtype);if(0===o.euu.sizeFromShape(u))return c;const{sliceRank:l,numUpdates:p,sliceSize:d,strides:h,outputSize:f}=o.KGH.calculateShapes(i,s,u),m=t.dataIdMap.get(s.dataId).id,g=t.dataIdMap.get(i.dataId).id,y=new Uint8Array(new Int32Array(h).buffer),b=t.dataIdMap.get(c.dataId).id;return Kn(m,g,r[i.dtype],l,p,d,y,f,b),c}};let Yn;const Jn={kernelName:o.wvl,backendName:"wasm",setupFunc:function(e){Yn=e.wasm.cwrap(o.wvl,null,["number","number","number","number","number","number","bool","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{sortedSequence:o,values:s}=t,{side:i}=a;if(o.dtype!==s.dtype)throw new Error(`SearchSorted error: sorted_sequence must have the same dtype as values. Got ${o.dtype} and ${s.dtype}`);const u=n.makeOutput(s.shape,"int32");function c(e){return n.dataIdMap.get(e.dataId).id}return Yn(c(o),c(s),o.shape[0],o.shape[1],s.shape[1],r[o.dtype],"left"===i,c(u)),u}};let Zn;const Xn={kernelName:o.M1e,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:r,t:a,e:s}=t,i=n.dataIdMap.get(r.dataId).id,u=n.dataIdMap.get(a.dataId).id,c=n.dataIdMap.get(s.dataId).id,l=n.makeOutput(a.shape,a.dtype),p=n.dataIdMap.get(l.dataId).id,d=r.shape.length,h=a.shape.length,f=0===d||d>1||1===h?1:o.euu.sizeFromShape(a.shape.slice(1));return Zn(i,u,c,f,p),l},setupFunc:function(e){Zn=e.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}},er=u(o.PWB);let tr;const nr={kernelName:"Sigmoid",backendName:"wasm",setupFunc:function(e){tr=e.wasm.cwrap(o.ac,null,["number","number"])},kernelFunc:function(e){const{backend:t,inputs:{x:n}}=e,r=t.dataIdMap.get(n.dataId).id,a=t.makeOutput(n.shape,n.dtype),s=t.dataIdMap.get(a.dataId).id;return 0===o.euu.sizeFromShape(a.shape)||tr(r,s),a}},rr=u(o.oyM),ar=u(o.mrT),or=u(o.OCc),sr=u(o.eWt),ir={kernelName:o.sH1,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:s,paddings:i}=r,u=o.euu.sizeFromShape(s),c=[[0,0]];c.push(...i);for(let e=1+s.length;e<a.shape.length;++e)c.push([0,0]);const l=xn.kernelFunc({inputs:{x:a},backend:n,attrs:{paddings:c,constantValue:0}}),p=o.cxb.getReshaped(l.shape,s,u,!1),d=o.cxb.getPermuted(p.length,s.length,!1),h=o.cxb.getReshapedPermuted(l.shape,s,u,!1),f=U({inputs:{x:l},backend:n,attrs:{shape:p}}),m=w({inputs:{x:f},backend:n,attrs:{perm:d}}),g=U({inputs:{x:m},backend:n,attrs:{shape:h}});return n.disposeData(l.dataId),n.disposeData(f.dataId),n.disposeData(m.dataId),g}};let ur;const cr={kernelName:o.Omm,backendName:"wasm",setupFunc:function(e){ur=e.wasm.cwrap("SparseFillEmptyRows","number",["number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{indices:a,values:s,denseShape:i,defaultValue:u}=n,c=a.shape[0],l=a.shape[1],p=t.readSync(i.dataId)[0],d=[c+p,l],h=t.dataIdMap.get(a.dataId).id,f=t.dataIdMap.get(s.dataId).id,m=t.dataIdMap.get(u.dataId).id,g=t.makeOutput(d,a.dtype),y=t.dataIdMap.get(g.dataId).id,b=t.makeOutput(d.slice(0,1),s.dtype),w=t.dataIdMap.get(b.dataId).id,v=t.makeOutput([p],"bool"),k=t.dataIdMap.get(v.dataId).id,x=t.makeOutput([c],a.dtype),_=t.dataIdMap.get(x.dataId).id,I=t.makeOutput([4],"int32"),S=t.dataIdMap.get(I.dataId).id,N=ur(h,f,r[s.dtype],c,p,l,m,y,w,k,_,S),M=t.readSync(I.dataId);let T;switch(M[0]){case 1:T=o.cxb.getSparseFillEmptyRowsIndicesDenseShapeMismatch(M[1]);break;case 2:T=o.cxb.getSparseFillEmptyRowsNegativeIndexErrorMessage(M[1],M[2]);break;case 3:T=o.cxb.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(M[1],M[2],M[3]);break;default:T=""}if(t.disposeData(I.dataId),T)throw t.disposeData(g.dataId),t.disposeData(b.dataId),t.disposeData(v.dataId),t.disposeData(x.dataId),new Error(T);let E=g,A=b;return N!==d[0]&&(E=j({inputs:{x:g},attrs:{begin:0,size:[N,l]},backend:t}),A=j({inputs:{x:b},attrs:{begin:0,size:N},backend:t}),t.disposeData(g.dataId),t.disposeData(b.dataId)),[E,A,v,x]}};let lr;const pr={kernelName:o.kfs,backendName:"wasm",setupFunc:function(e){lr=e.wasm.cwrap(o.kfs,null,["number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{inputIndices:r,inputShape:a,newShape:s}=n;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 i=t.dataIdMap.get(r.dataId).id,u=t.dataIdMap.get(a.dataId).id,c=t.dataIdMap.get(s.dataId).id,l=r.shape[0],p=o.euu.sizeFromShape(s.shape),d=t.makeOutput([l,p],r.dtype),h=t.dataIdMap.get(d.dataId).id,f=t.makeOutput([p],s.dtype),m=t.dataIdMap.get(f.dataId).id,g=t.makeOutput([3],"int32"),y=t.dataIdMap.get(g.dataId).id;lr(i,u,c,l,h,m,y);const b=t.readSync(g.dataId);let w;switch(b[0]){case 0:w=o.cxb.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(b[1],b[2]);break;case 1:w=o.cxb.getSparseReshapeNegativeOutputDimErrorMessage(b[1],b[2]);break;case 2:w=o.cxb.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage();break;case 3:{const e=Array.from(t.readSync(a.dataId)),n=Array.from(t.readSync(f.dataId));w=o.cxb.getSparseReshapeInputOutputMultipleErrorMessage(e,n);break}case 4:{const e=Array.from(t.readSync(a.dataId)),n=Array.from(t.readSync(f.dataId));w=o.cxb.getSparseReshapeInputOutputMismatchErrorMessage(e,n);break}default:w=""}if(t.disposeData(g.dataId),w)throw t.disposeData(d.dataId),t.disposeData(f.dataId),new Error(w);return[d,f]}};let dr;function hr(e){dr=e.wasm.cwrap("SparseSegmentReduction",null,["number","number","number","number","number","number","number","number","number"])}function fr(e,t){const{backend:n,inputs:a}=e,{data:s,indices:i,segmentIds:u}=a,c=i.shape[0],l=n.readSync(u.dataId,c-1,c)[0],p=c>0?l+1:0;if(p<0)throw new Error(o.cxb.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());const d=s.shape.slice();d[0]=p;const h=n.dataIdMap.get(s.dataId).id,f=n.dataIdMap.get(i.dataId).id,m=n.dataIdMap.get(u.dataId).id,g=n.makeOutput(d,s.dtype),y=n.dataIdMap.get(g.dataId).id,b=n.makeOutput([4],"int32"),w=n.dataIdMap.get(b.dataId).id;dr(h,r[s.dtype],s.shape[0],f,m,y,w,t,0);const v=n.readSync(b.dataId);let k;switch(v[0]){case 0:k=o.cxb.getSparseSegmentReductionNegativeSegmentIdsErrorMessage();break;case 1:k=o.cxb.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage();break;case 2:k=o.cxb.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(v[1],v[2]);break;case 3:k=o.cxb.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(v[1],v[2],v[3]);break;default:k=""}if(n.disposeData(b.dataId),k)throw n.disposeData(g.dataId),new Error(k);return g}const mr={kernelName:o.QxB,backendName:"wasm",setupFunc:hr,kernelFunc:function(e){return fr(e,!0)}},gr={kernelName:o.ra4,backendName:"wasm",setupFunc:hr,kernelFunc:function(e){return fr(e,!1)}};let yr;const br={kernelName:o.inF,backendName:"wasm",setupFunc:function(e){yr=e.wasm.cwrap(o.inF,null,["number","number","number","number","number","number","number","number","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{sparseIndices:s,sparseValues:i,defaultValue:u}=n,{outputShape:c}=a,l=t.makeOutput(c,u.dtype);if(0===o.euu.sizeFromShape(c))return l;const{sliceRank:p,numUpdates:d,sliceSize:h,strides:f,outputSize:m}=o.cxb.calculateShapes(i,s,c),g=t.dataIdMap.get(s.dataId).id,y=t.dataIdMap.get(i.dataId).id,b=t.dataIdMap.get(u.dataId).id,w=new Uint8Array(new Int32Array(f).buffer),v=t.dataIdMap.get(l.dataId).id;return yr(g,y,i.shape.length,b,r[u.dtype],p,d,h,w,m,v),l}},wr={kernelName:o.kDP,backendName:"wasm",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a}=t,{numOrSizeSplits:s,axis:i}=n,u=o.euu.parseAxisParam(i,a.shape)[0],c=o.cxb.prepareSplitSize(a,s,u),l=new Array(a.shape.length).fill(0),p=a.shape.slice();return c.map((e=>{const t=[...p];t[u]=e;const n=j({inputs:{x:a},attrs:{begin:l,size:t},backend:r});return l[u]+=e,n}))}},vr=u(o.Sed),kr=u(o.GSE),xr=d(o.uI0);let _r;const Ir={kernelName:o.Ku3,backendName:"wasm",setupFunc:function(e){_r=e.wasm.cwrap(o.Ku3,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{alpha:o}=a,{x:s}=n,i=t.dataIdMap.get(s.dataId).id,u=t.makeOutput(s.shape,s.dtype),c=t.dataIdMap.get(u.dataId).id;return _r(i,o,r[s.dtype],c),u}};let Sr;const Nr={kernelName:o.cB,backendName:"wasm",setupFunc:function(e){Sr=e.wasm.cwrap(o.cB,null,["number","array","number","array","array","array","array","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{x:a}=n,{begin:s,end:i,strides:u,beginMask:c,endMask:l,ellipsisMask:p,newAxisMask:d,shrinkAxisMask:h}=r,{finalShapeSparse:f,finalShape:m,isIdentity:g,sliceDim0:y,isSimpleSlice:b,begin:w,end:v,strides:k}=o.sL.sliceInfo(a.shape,s,i,u,c,l,p,d,h);let x;if(g)x=U({inputs:{x:a},backend:t,attrs:{shape:m}});else if(y||b){o.euu.assert(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=o.sL.computeOutShape(w,v,k),n=j({inputs:{x:a},backend:t,attrs:{begin:w,size:e}});x=U({inputs:{x:n},backend:t,attrs:{shape:m}}),t.disposeData(n.dataId)}else{const e=t.makeOutput(f,"float32"),n=t.dataIdMap.get(a.dataId).id,r=new Uint8Array(new Int32Array(o.euu.computeStrides(a.shape)).buffer),s=new Uint8Array(new Int32Array(w).buffer),i=new Uint8Array(new Int32Array(v).buffer),u=new Uint8Array(new Int32Array(k).buffer),c=new Uint8Array(new Int32Array(f).buffer),l=new Uint8Array(new Int32Array(o.euu.computeStrides(f)).buffer),p=t.dataIdMap.get(e.dataId).id;Sr(n,r,a.shape.length,s,i,u,c,l,f.length,p),x=U({inputs:{x:e},backend:t,attrs:{shape:m}}),t.disposeData(e.dataId)}return x}};var Mr=n(72652);const Tr={kernelName:o.MPe,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{data:a,dataSplits:o}=n,{separator:s,nGramWidths:i,leftPad:u,rightPad:c,padWidth:l,preserveShortSequences:p}=r,d=t.readSync(a.dataId),h=t.readSync(o.dataId),[f,m]=(0,Mr.s)(d,h,s,i,u,c,l,p),g=t.makeOutput([f.length],"string");t.dataIdMap.get(g.dataId).stringBytes=f;const y=t.makeOutput(o.shape,"int32");return t.typedArrayFromHeap(y).set(m),[g,y]}};var Er=n(29772);const Ar={kernelName:o.YNA,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{input:a,delimiter:o}=n,{skipEmpty:s}=r,i=t.readSync(a.dataId),u=t.readSync(o.dataId),[c,l,p]=(0,Er.i)(i,u[0],s),d=l.length,h=t.makeOutput([d,2],"int32");t.typedArrayFromHeap(h).set(c);const f=t.makeOutput([d],"string");t.dataIdMap.get(f.dataId).stringBytes=l;const m=t.makeOutput([2],"int32");return t.typedArrayFromHeap(m).set(p),[h,f,m]}};var Fr=n(20128);const Dr={kernelName:o.Atw,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{input:a}=n,{numBuckets:o}=r,s=t.readSync(a.dataId),i=(0,Fr.e)(s,o),u=t.makeOutput(a.shape,"int32");return t.typedArrayFromHeap(u).set(i),u}},Or=d(o.UVd);let Cr;const Pr={kernelName:o.srk,backendName:"wasm",setupFunc:function(e){Cr=e.wasm.cwrap(o.srk,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{axis:s,keepDims:i}=a,{x:u}=n,c=t.dataIdMap.get(u.dataId).id;let l=c,p=u;const{transposed:d,axes:h,originalAxes:f,inputWasTransposed:m}=k(u,s,t);let g=h;if(m){const e=t.dataIdMap.get(d.dataId).id;e!==c&&(p=d,l=e,g=o.cxb.getInnerMostAxes(g.length,p.shape.length))}o.cxb.assertAxesAreInnerMostDims("sum",g,p.shape.length);const[y,b]=o.cxb.computeOutAndReduceShapes(p.shape,g),w=o.euu.sizeFromShape(b),v=t.makeOutput(y,p.dtype);if(0!==o.euu.sizeFromShape(p.shape)){const e=t.dataIdMap.get(v.dataId).id;Cr(l,w,r[v.dtype],e)}if(m&&t.disposeData(d.dataId),i){const e=o.cxb.expandShapeToKeepDim(v.shape,f);v.shape=e}return v}},Rr=u(o.epr),$r=u(o.Yvq);let Lr;const Wr={kernelName:o.EBb,backendName:"wasm",setupFunc:function(e){Lr=e.wasm.cwrap(o.EBb,null,["number","number","number","number","number","number","array","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:a}=e,{tensor:s,indices:i,updates:u}=n,{}=a,c=t.makeOutput(s.shape,s.dtype);if(0===o.euu.sizeFromShape(s.shape))return c;const{sliceRank:l,numUpdates:p,sliceSize:d,strides:h,outputSize:f}=o.KGH.calculateShapes(u,i,s.shape),m=t.dataIdMap.get(i.dataId).id,g=t.dataIdMap.get(u.dataId).id,y=t.dataIdMap.get(s.dataId).id,b=new Uint8Array(new Int32Array(h).buffer),w=t.dataIdMap.get(c.dataId).id;return Lr(m,g,r[u.dtype],l,p,d,b,f,w,y),c}};let zr;const Br={kernelName:o.g$J,backendName:"wasm",setupFunc:function(e){zr=e.wasm.cwrap(o.g$J,null,["number","array","number","array","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:a}=e,{x:o}=t,s=n.dataIdMap.get(o.dataId).id,{reps:i}=a,u=new Array(o.shape.length);for(let e=0;e<u.length;e++)u[e]=o.shape[e]*i[e];const c=new Uint8Array(new Int32Array(o.shape).buffer),l=new Uint8Array(new Int32Array(u).buffer),p=n.makeOutput(u,o.dtype),d=n.dataIdMap.get(p.dataId).id;return zr(s,c,o.shape.length,l,u.length,r[p.dtype],d),p}};let Ur;const Hr={kernelName:o.iIN,backendName:"wasm",setupFunc:function(e){Ur=e.wasm.cwrap(o.iIN,null,["number","array","number","number","number","bool","number","number"])},kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:a}=e,{k:o,sorted:s}=n,i=t.dataIdMap.get(a.dataId).id,u=new Uint8Array(new Int32Array(a.shape).buffer),c=a.shape.slice();c[c.length-1]=o;const l=t.makeOutput(c,a.dtype),p=t.dataIdMap.get(l.dataId).id,d=t.makeOutput(c,"int32"),h=t.dataIdMap.get(d.dataId).id;return Ur(i,u,a.shape.length,r[a.dtype],o,s,p,h),[l,d]}};let Vr;const Gr={kernelName:o.wjp,backendName:"wasm",setupFunc:function(e){Vr=e.wasm.cwrap(o.wjp,null,["number","number","bool","number","number","number","number","number","number","array","number","array","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{image:a,transforms:s}=n,{interpolation:i,fillMode:u,fillValue:c,outputShape:l}=r,[p,d,h,f]=a.shape,[m,g]=null!=l?l:[d,h],y=[p,m,g,f],b=new Uint8Array(new Int32Array(o.euu.computeStrides(a.shape)).buffer),w=new Uint8Array(new Int32Array(o.euu.computeStrides(y)).buffer),v=t.makeOutput(y,a.dtype),k=t.dataIdMap.get(v.dataId).id,x=t.dataIdMap.get(a.dataId).id,_=t.dataIdMap.get(s.dataId).id,I="nearest"===i?1:2;let S;switch(u){case"constant":default:S=1;break;case"reflect":S=2;break;case"wrap":S=3;break;case"nearest":S=4}return Vr(x,_,s.shape[0]>1,p,m,g,f,h,d,b,a.shape.length-1,w,y.length-1,I,S,c,k),v}};var qr=n(20932);const jr={kernelName:o.Kyi,backendName:"wasm",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{axis:a}=n,{x:o}=t,{outputValues:s,outputShape:i,indices:u}=(0,qr.c)(r.readSync(o.dataId),a,o.shape,o.dtype);return[r.makeOutput(i,o.dtype,void 0,s),r.makeOutput([u.length],"int32",void 0,u)]}},Kr={kernelName:o.YZK,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:o}=r;o<0&&(o+=a.shape.length);const s=a.shape[o],i=a.shape.length,u=new Array(i-1);let c=0;for(let e=0;e<i;e++)e!==o&&(u[c++]=a.shape[e]);const l=new Array(s),p=new Array(i).fill(0),d=a.shape.slice();d[o]=1;for(let e=0;e<l.length;e++)p[o]=e,l[e]=j({inputs:{x:a},attrs:{begin:p,size:d},backend:n});return l.map((({dataId:e,dtype:t})=>({dataId:e,dtype:t,shape:u})))}},Qr={kernelName:o.qKC,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(0),r}},Yr=[i,c,l,p,h,m,_,S,M,T,E,A,F,D,O,P,B,$,W,G,Q,J,Z,X,te,ne,ae,ie,ce,pe,he,me,ye,be,we,xe,Ie,Ne,Te,Ae,De,Ce,Re,Le,ze,Be,He,Ve,Ge,qe,Ke,Qe,Je,Xe,et,tt,rt,ot,it,ct,pt,dt,ht,y,ft,mt,gt,bt,wt,vt,xt,It,_t,St,Nt,Mt,Tt,At,Dt,Ct,Pt,$t,Wt,Bt,Ht,Gt,jt,Qt,Yt,Xt,an,on,sn,un,pn,hn,mn,gn,bn,wn,vn,xn,_n,Sn,Mn,En,An,Fn,Dn,On,H,Pn,$n,Wn,Bn,Hn,Gn,qn,jn,Qn,Jn,Xn,er,nr,rr,ar,or,K,nn,sr,ir,cr,pr,mr,gr,br,wr,vr,kr,xr,Ir,Nr,Tr,Ar,Dr,Or,Pr,Rr,$r,Wr,Br,Hr,Gr,v,jr,Kr,Qr];for(const e of Yr)(0,o.qe5)(e);const Jr=(0,o._K2)();Jr.registerFlag("WASM_HAS_SIMD_SUPPORT",(async()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]))}catch(e){return!1}})),Jr.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",(async()=>{if(Jr.get("IS_NODE"))return!1;try{return(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch(e){return!1}}));var Zr=n(49264),Xr=n.n(Zr),ea=n(13712),ta=n(84928),na=n.n(ta);const ra=Xr()||Zr,aa=na()||ta;class oa extends o.qe${constructor(e){super(),this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.initWithThreadsCount(fa),ma=this.wasm.tfjs.getThreadsCount(),this.dataIdMap=new o.iaN(this,(0,o.sn1)())}write(e,t,n){const r={id:this.dataIdNextNumber++};return this.move(r,e,t,n,1),r}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){const t=o.euu.now();return e(),{kernelMs:o.euu.now()-t}}move(e,t,n,r,a){const s=this.dataIdNextNumber++;if("string"===r){const o=t;return void this.dataIdMap.set(e,{id:s,stringBytes:o,shape:n,dtype:r,memoryOffset:null,refCount:a})}const i=o.euu.sizeFromShape(n),u=i*o.euu.bytesPerElement(r),c=this.wasm._malloc(u)>>>0;this.dataIdMap.set(e,{id:s,memoryOffset:c,shape:n,dtype:r,refCount:a}),this.wasm.tfjs.registerTensor(s,i,c),null!=t&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,u),c)}async read(e){return this.readSync(e)}readSync(e,t,n){const{memoryOffset:r,dtype:a,shape:s,stringBytes:i}=this.dataIdMap.get(e);if("string"===a)return null!=t&&0!==t||!(null==n||n>=i.length)?i.slice(t,n):i;t=t||0,n=n||o.euu.sizeFromShape(s);const u=o.euu.bytesPerElement(a);return function(e,t){switch(t){case"float32":return new Float32Array(e);case"int32":return new Int32Array(e);case"bool":return new Uint8Array(e);default:throw new Error(`Unknown dtype ${t}`)}}(this.wasm.HEAPU8.slice(r+t*u,r+n*u).buffer,a)}disposeData(e,t=!1){if(this.dataIdMap.has(e)){const n=this.dataIdMap.get(e);if(n.refCount--,!t&&n.refCount>0)return!1;this.wasm._free(n.memoryOffset),this.wasm.tfjs.disposeData(n.id),this.dataIdMap.delete(e)}return!0}refCount(e){return this.dataIdMap.has(e)?this.dataIdMap.get(e).refCount:0}incRef(e){const t=this.dataIdMap.get(e);null!=t&&t.refCount++}floatPrecision(){return 32}getMemoryOffset(e){return this.dataIdMap.get(e).memoryOffset}dispose(){this.wasm.tfjs.dispose(),"PThread"in this.wasm&&this.wasm.PThread.terminateAllThreads(),this.wasm=null}memory(){return{unreliable:!1}}makeOutput(e,t,n,r){let a;if(null==n)a=this.write(null!=r?r:null,e,t);else{const r=this.dataIdNextNumber++;a={id:r},this.dataIdMap.set(a,{id:r,memoryOffset:n,shape:e,dtype:t,refCount:1});const s=o.euu.sizeFromShape(e);this.wasm.tfjs.registerTensor(r,s,n)}return{dataId:a,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:n}){const r=this.wasm.HEAPU8.buffer,{memoryOffset:a}=this.dataIdMap.get(n),s=o.euu.sizeFromShape(e);switch(t){case"float32":return new Float32Array(r,a,s);case"int32":return new Int32Array(r,a,s);case"bool":return new Uint8Array(r,a,s);default:throw new Error(`Unknown dtype ${t}`)}}}function sa(e,t,n){if(null!=ua)return ua;let r="tfjs-backend-wasm.wasm";return e&&t?r="tfjs-backend-wasm-threaded-simd.wasm":e&&(r="tfjs-backend-wasm-simd.wasm"),null!=la&&null!=la[r]?la[r]:n+r}
2const ia=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"];let ua=null,ca=null,la={},pa=!1,da=!1;function ha(e,t=!1){if(pa)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPaths()` before you call `tf.setBackend()` or `tf.ready()`");if("string"==typeof e)ca=e;else{la=e;const t=ia.filter((e=>null==la[e]));if(t.length>0)throw new Error(`There were no entries found for the following binaries: ${t.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`)}da=t}let fa=-1,ma=null;const ga="4.11.0";(0,o.gJo)("wasm",(async()=>{const{wasm:e}=await async function(){const[e,t]=await Promise.all([(0,o._K2)().getAsync("WASM_HAS_SIMD_SUPPORT"),(0,o._K2)().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise(((n,r)=>{const a={};var s;a.locateFile=(n,r)=>{if(n.endsWith(".worker.js")){const e=ea.O.replace(/\n/g,"\\n"),t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}return n.endsWith(".wasm")?sa(e,t,null!=ca?ca:r):r+n},da&&(a.instantiateWasm=(s=sa(e,t,null!=ca?ca:""),(e,t)=>(o.euu.fetch(s,{credentials:"same-origin"}).then((n=>{n.ok||e.env.a(`failed to load wasm binary file at '${s}'`),n.arrayBuffer().then((n=>{WebAssembly.instantiate(n,e).then((e=>{t(e.instance,e.module)}))}))})),{})));let i,u=!1;a.onAbort=()=>{u||pa||(pa=!0,r({message:"Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers"}))},t&&e&&null==ua?(a.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+ra.toString()],{type:"text/javascript"}),i=ra(a)):i=aa(a),i.then((e=>{u=!0,pa=!1,e.tfjs={init:e.cwrap("init",null,[]),initWithThreadsCount:e.cwrap("init_with_threads_count",null,["number"]),getThreadsCount:e.cwrap("get_threads_count","number",[]),registerTensor:e.cwrap("register_tensor",null,["number","number","number"]),disposeData:e.cwrap("dispose_data",null,["number"]),dispose:e.cwrap("dispose",null,[])},n({wasm:e})})).catch(r)}))}();return new oa(e)}),2)},49264:function(e,t,n){var r,a=(r=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){function t(){return F.buffer!=P&&V(F.buffer),R}function a(){return F.buffer!=P&&V(F.buffer),$}function o(){return F.buffer!=P&&V(F.buffer),L}function s(){return F.buffer!=P&&V(F.buffer),W}function i(){return F.buffer!=P&&V(F.buffer),z}var u,c,l,p=void 0!==(e=e||{})?e:{};p.ready=new Promise((function(e,t){u=e,c=t})),"undefined"!=typeof process&&process.listeners&&(l={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var d,h,f,m=Object.assign({},p),g=[],y=(e,t)=>{throw t},b="object"==typeof window,w="function"==typeof importScripts,v="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,k=p.ENVIRONMENT_IS_PTHREAD||!1,x="";function _(e){return p.locateFile?p.locateFile(e,x):x+e}if(v){var I=n(65912),S=n(39080);let e;x=w?S.dirname(x)+"/":"//",d=(e,t)=>(e=ae(e)?new URL(e):S.normalize(e),I.readFileSync(e,t?void 0:"utf8")),f=e=>{var t=d(e,!0);return t.buffer||(t=new Uint8Array(t)),t},h=(e,t,n)=>{e=ae(e)?new URL(e):S.normalize(e),I.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),g=process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof ie))throw e})),process.on("unhandledRejection",(function(e){throw e})),y=(e,t)=>{if(Y())throw process.exitCode=e,t;var n;(n=t)instanceof ie||A("exiting due to exception: "+n),process.exit(e)},p.inspect=function(){return"[Emscripten Module object]"};try{e=n(72248)}catch(e){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),e}n.g.Worker=e.Worker}else(b||w)&&(w?x=self.location.href:"undefined"!=typeof document&&document.currentScript&&(x=document.currentScript.src),void 0!==r&&r&&(x=r),x=0!==x.indexOf("blob:")?x.substr(0,x.replace(/[?#].*/,"").lastIndexOf("/")+1):"",v||(d=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},w&&(f=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),h=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)}));v&&"undefined"==typeof performance&&(n.g.performance=n(85940).performance);var N=console.log.bind(console),M=console.warn.bind(console);v&&(N=e=>I.writeSync(1,e+"\n"),M=e=>I.writeSync(2,e+"\n"));var T,E=p.print||N,A=p.printErr||M;Object.assign(p,m),m=null,p.arguments&&(g=p.arguments),p.thisProgram&&p.thisProgram,p.quit&&(y=p.quit),Atomics.load,Atomics.store,Atomics.compareExchange,p.wasmBinary&&(T=p.wasmBinary);var F,D,O=p.noExitRuntime||!0;"object"!=typeof WebAssembly&&te("no native wasm support detected");var C,P,R,$,L,W,z,B=!1,U="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function H(e,t,n){for(var r=(t>>>=0)+n,a=t;e[a]&&!(a>=r);)++a;if(a-t>16&&e.buffer&&U)return U.decode(e.buffer instanceof SharedArrayBuffer?e.slice(t,a):e.subarray(t,a));for(var o="";t<a;){var s=e[t++];if(128&s){var i=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|i<<6|u:(7&s)<<18|i<<12|u<<6|63&e[t++])<65536)o+=String.fromCharCode(s);else{var c=s-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&s)<<6|i)}else o+=String.fromCharCode(s)}return o}function V(e){P=e,p.HEAP8=R=new Int8Array(e),p.HEAP16=new Int16Array(e),p.HEAP32=L=new Int32Array(e),p.HEAPU8=$=new Uint8Array(e),p.HEAPU16=new Uint16Array(e),p.HEAPU32=W=new Uint32Array(e),p.HEAPF32=new Float32Array(e),p.HEAPF64=z=new Float64Array(e)}k&&(P=p.buffer);var G,q=p.INITIAL_MEMORY||16777216;if(k)F=p.wasmMemory,P=p.buffer;else if(p.wasmMemory)F=p.wasmMemory;else if(!((F=new WebAssembly.Memory({initial:q/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw A("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may
2need to set a flag"),v&&A("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");F&&(P=F.buffer),q=P.byteLength,V(P);var j=[],K=[],Q=[];function Y(){return O}function J(){k||he(K)}var Z=0,X=null,ee=null;function te(e){p.onAbort&&p.onAbort(e),A(e="Aborted("+e+")"),B=!0,C=1,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw c(t),t}var ne;function re(e){return e.startsWith("data:application/octet-stream;base64,")}function ae(e){return e.startsWith("file://")}function oe(e){try{if(e==ne&&T)return new Uint8Array(T);if(f)return f(e);throw"both async and sync fetching of the wasm failed"}catch(e){te(e)}}re(ne="tfjs-backend-wasm-threaded-simd.wasm")||(ne=_(ne));var se={};function ie(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function ue(e){var t=de.pthreads[e];t||te(undefined),de.returnWorkerToPool(t)}function ce(e){var t=de.getNewWorker();if(!t)return 6;de.runningWorkers.push(t),de.pthreads[e.pthread_ptr]=t,t.pthread_ptr=e.pthread_ptr;var n={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return t.runPthread=()=>{v&&t.ref(),t.postMessage(n,e.transferList),delete t.runPthread},t.loaded&&t.runPthread(),0}function le(e){if(k)return ke(1,1,e);C=e,Y()||(de.terminateAllThreads(),p.onExit&&p.onExit(e),B=!0),y(e,new ie(e))}var pe=function(e,t){if(C=e,!t&&k)throw fe(e),"unwind";le(e)},de={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init:function(){k?de.initWorker():de.initMainThread()},initMainThread:function(){for(var e=8;e--;)de.allocateUnusedWorker()},initWorker:function(){O=!1},setExitStatus:function(e){C=e},terminateAllThreads:function(){for(var e of Object.values(de.pthreads))de.returnWorkerToPool(e);for(var e of de.unusedWorkers)e.terminate();de.unusedWorkers=[]},returnWorkerToPool:function(e){var t=e.pthread_ptr;delete de.pthreads[t],de.unusedWorkers.push(e),de.runningWorkers.splice(de.runningWorkers.indexOf(e),1),e.pthread_ptr=0,v&&e.unref(),ze(t)},receiveObjectTransfer:function(e){},threadInitTLS:function(){de.tlsInitFunctions.forEach((e=>e()))},loadWasmModuleToWorker:function(e,t){e.onmessage=n=>{var r,a=n.data,o=a.cmd;if(e.pthread_ptr&&(de.currentProxiedOperationCallerThread=e.pthread_ptr),a.targetThread&&a.targetThread!=Re()){var s=de.pthreads[a.targetThread];return s?s.postMessage(a,a.transferList):A('Internal error! Worker sent a message "'+o+'" to target pthread '+a.targetThread+", but that thread no longer exists!"),void(de.currentProxiedOperationCallerThread=void 0)}"processProxyingQueue"===o?we(a.queue):"spawnThread"===o?ce(a):"cleanupThread"===o?ue(a.thread):"killThread"===o?function(e){var t=de.pthreads[e];delete de.pthreads[e],t.terminate(),ze(e),de.runningWorkers.splice(de.runningWorkers.indexOf(t),1),t.pthread_ptr=0}(a.thread):"cancelThread"===o?(r=a.thread,de.pthreads[r].postMessage({cmd:"cancel"})):"loaded"===o?(e.loaded=!0,v&&e.unref(),t&&t(e),e.runPthread&&e.runPthread()):"print"===o?E("Thread "+a.threadId+": "+a.text):"printErr"===o?A("Thread "+a.threadId+": "+a.text):"alert"===o?alert("Thread "+a.threadId+": "+a.text):"setimmediate"===a.target?e.postMessage(a):"callHandler"===o?p[a.handler](...a.args):o&&A("worker sent an unknown command "+o),de.currentProxiedOperationCallerThread=void 0},e.onerror=e=>{throw A("worker sent an error! "+e.filename+":"+e.lineno+": "+e.message),e},v&&(e.on("message",(function(t){e.onmessage({data:t})})),e.on("error",(function(t){e.onerror(t)})),e.on("detachedExit",(function(){})));var n=[];for(var a of["onExit","onAbort","print","printErr"])p.hasOwnProperty(a)&&n.push(a);e.postMessage({cmd:"load",handlers:n,urlOrBlob:p.mainScriptUrlOrBlob||r,wasmMemory:F,wasmModule:D})},allocateUnusedWorker:function(){var e,t=_("tfjs-backend-wasm-threaded-simd.worker.js");e=new Worker(t),de.unusedWorkers.push(e)},getNewWorker:function(){return 0==de.unusedWorkers.length&&(de.allocateUnusedWorker(),de.loadWasmModuleToWorker(de.unusedWorkers[0])),de.unusedWorkers.pop()}};function he(e){for(;e.length>0;)e.shift()(p)}function fe(e){if(k)return ke(2,0,e);try{pe(e)}catch(e){!function(e){if(e instanceof ie||"unwind"==e)return C;y(1,e)}(e)}}p.PThread=de,p.establishStackSpace=function(){var e=Re(),t=o()[e+52>>>2],n=o()[e+56>>>2];Ue(t,t-n),Ve(t)};var me,ge=[];function ye(e,t,n,r){return k?ke(3,1,e,t,n,r):be(e,t,n,r)}function be(e,t,n,r){if("undefined"==typeof SharedArrayBuffer)return A("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];if(k&&0===a.length)return ye(e,t,n,r);var o={startRoutine:n,pthread_ptr:e,arg:r,transferList:a};return k?(o.cmd="spawnThread",postMessage(o,a),0):ce(o)}function we(e){Atomics.store(o(),e>>2,1),Re()&&We(e),Atomics.compareExchange(o(),e>>2,1,0)}function ve(e){ve.shown||(ve.shown={}),ve.shown[e]||(ve.shown[e]=1,v&&(e="warning: "+e),A(e))}function ke(e,t){var n,r,a,o=arguments.length-2,s=arguments;return n=()=>{for(var n=o,r=Ge(8*n),a=r>>3,u=0;u<o;u++){var c=s[2+u];i()[a+u>>>0]=c}return Le(e,n,r,t)}
vendor: 14,453 bytes, line 2
2,r=He(),a=n(),Ve(r),a}p.invokeEntryPoint=function(e,t){var n,r,a=((r=ge[n=e])||(n>=ge.length&&(ge.length=n+1),ge[n]=r=G.get(n)),r)(t);Y()?de.setExitStatus(a):Be(a)},p.executeNotifiedProxyingQueue=we,me=v?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.timeOrigin+performance.now();var xe=[];function _e(e){try{return F.grow(e-P.byteLength+65535>>>16),V(F.buffer),1}catch(e){}}function Ie(e){return k?ke(4,1,e):52}function Se(e,t,n,r,a){return k?ke(5,1,e,t,n,r,a):70}var Ne=[null,[],[]];function Me(e,t){var n=Ne[e];0===t||10===t?((1===e?E:A)(H(n,0)),n.length=0):n.push(t)}function Te(e,t,n,r){if(k)return ke(6,1,e,t,n,r);for(var o=0,i=0;i<n;i++){var u=s()[t>>>2],c=s()[t+4>>>2];t+=8;for(var l=0;l<c;l++)Me(e,a()[u+l>>>0]);o+=c}return s()[r>>>2]=o,0}function Ee(e){return p["_"+e]}function Ae(e,n,r,o,s){var i={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);!function(e,t,n){!function(e,t,n,r){if(!(r>0))return 0;for(var a=(n>>>=0)+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),s<=127){if(n>=a)break;t[n++>>>0]=s}else if(s<=2047){if(n+1>=a)break;t[n++>>>0]=192|s>>6,t[n++>>>0]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++>>>0]=224|s>>12,t[n++>>>0]=128|s>>6&63,t[n++>>>0]=128|63&s}else{if(n+3>=a)break;t[n++>>>0]=240|s>>18,t[n++>>>0]=128|s>>12&63,t[n++>>>0]=128|s>>6&63,t[n++>>>0]=128|63&s}}t[n>>>0]=0}(e,a(),t,n)}(e,t=Ge(n),n)}return t},array:e=>{var n=Ge(e.length);return function(e,n){t().set(e,n>>>0)}(e,n),n}},u=Ee(e),c=[],l=0;if(o)for(var p=0;p<o.length;p++){var d=i[r[p]];d?(0===l&&(l=He()),c[p]=d(o[p])):c[p]=o[p]}var h=u.apply(null,c);return function(e){return 0!==l&&Ve(l),function(e){return"string"===n?(t=e,(t>>>=0)?H(a(),t,r):""):"boolean"===n?Boolean(e):e;var t,r}(e)}(h)}de.init();var Fe,De,Oe,Ce=[null,le,fe,ye,Ie,Se,Te],Pe={__emscripten_init_main_thread_js:function(e){$e(e,!w,1,!b),de.threadInitTLS()},__emscripten_thread_cleanup:function(e){k?postMessage({cmd:"cleanupThread",thread:e}):ue(e)},__pthread_create_js:be,_emscripten_default_pthread_stack_size:function(){return 65536},_emscripten_get_now_is_monotonic:function(){return!0},_emscripten_notify_task_queue:function(e,t,n,r){if(e==t)setTimeout((()=>we(r)));else if(k)postMessage({targetThread:e,cmd:"processProxyingQueue",queue:r});else{var a=de.pthreads[e];if(!a)return;a.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},_emscripten_set_offscreencanvas_size:function(e,t,n){return-1},abort:function(){te("")},emscripten_check_blocking_allowed:function(){v||w||ve("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},emscripten_date_now:function(){return Date.now()},emscripten_get_heap_max:function(){return 4294901760},emscripten_get_now:me,emscripten_memcpy_big:function(e,t,n){a().copyWithin(e>>>0,t>>>0,t+n>>>0)},emscripten_num_logical_cores:function(){return v?n(9252).cpus().length:navigator.hardwareConcurrency},emscripten_receive_on_main_thread_js:function(e,t,n){xe.length=t;for(var r=n>>3,a=0;a<t;a++)xe[a]=i()[r+a>>>0];return(e<0?se[-e-1]:Ce[e]).apply(null,xe)},emscripten_resize_heap:function(e){var t=a().length;if((e>>>=0)<=t)return!1;var n,r=4294901760;if(e>r)return!1;for(var o=1;o<=4;o*=2){var s=t*(1+.2/o);if(s=Math.min(s,e+100663296),_e(Math.min(r,(n=Math.max(e,s))+(65536-n%65536)%65536)))return!0}return!1},emscripten_unwind_to_js_event_loop:function(){throw"unwind"},exit:pe,fd_close:Ie,fd_seek:Se,fd_write:Te,memory:F||p.wasmMemory},Re=(function(){var e={env:Pe,wasi_snapshot_preview1:Pe};function t(e,t){var n,r,a=e.exports;if(p.asm=a,n=p.asm._emscripten_tls_init,de.tlsInitFunctions.push(n),G=p.asm.__indirect_function_table,r=p.asm.__wasm_call_ctors,K.unshift(r),D=t,!k){var o=de.unusedWorkers.length;de.unusedWorkers.forEach((function(e){de.loadWasmModuleToWorker(e,(function(){--o||function(e){if(Z--,p.monitorRunDependencies&&p.monitorRunDependencies(Z),0==Z&&(null!==X&&(clearInterval(X),X=null),ee)){var t=ee;ee=null,t()}}()}))}))}}function n(e){t(e.instance,e.module)}function r(t){return function(){if(!T&&(b||w)){if("function"==typeof fetch&&!ae(ne))return fetch(ne,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+ne+"'";return e.arrayBuffer()})).catch((function(){return oe(ne)}));if(h)return new Promise((function(e,t){h(ne,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return oe(ne)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){A("failed to asynchronously prepare wasm: "+e),te(e)}))}if(k||(Z++,p.monitorRunDependencies&&p.monitorRunDependencies(Z)),p.instantiateWasm)try{return p.instantiateWasm(e,t)}catch(e){A("Module.instantiateWasm callback failed with error: "+e),c(e)}(T||"function"!=typeof WebAssembly.instantiateStreaming||re(ne)||ae(ne)||v||"function"!=typeof fetch?r(n):fetch(ne,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return A("wasm streaming compile failed: "+e),A("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(c)}(),p.___wasm_call_ctors=function(){return(p.___wasm_call_ctors=p.asm.__wasm_call_ctors).apply(null,arguments)},p._init=function(){return(p._init=p.asm.init).apply(null,arguments)},p._init_with_threads_count=function(){return(p._init_with_threads_count=p.asm.init_with_threads_count).apply(null,arguments)},p._get_threads_count=function(){return(p._get_threads_count=p.asm.get_threads_count).apply(null,arguments)},p._register_tensor=function(){return(p._register_tensor=p.asm.register_tensor).apply(null,arguments)},p._dispose_data=function(){return(p._dispose_data=p.asm.dispose_data).apply(null,arguments)},p._dispose=function(){return(p._dispose=p.asm.dispose).apply(null,arguments)},p._Abs=function(){return(p._Abs=p.asm.Abs).apply(null,arguments)},p._Acos=function(){return(p._Acos=p.asm.Acos).apply(null,arguments)},p._Acosh=function(){return(p._Acosh=p.asm.Acosh).apply(null,arguments)},p._Add=function(){return(p._Add=p.asm.Add).apply(null,arguments)},p._AddN=function(){return(p._AddN=p.asm.AddN).apply(null,arguments)},p._All=function(){return(p._All=p.asm.All).apply(null,arguments)},p._Any=function(){return(p._Any=p.asm.Any).apply(null,arguments)},p._ArgMax=function(){return(p._ArgMax=p.asm.ArgMax).apply(null,arguments)},p._ArgMin=function(){return(p._ArgMin=p.asm.ArgMin).apply(null,arguments)},p._Asin=function(){return(p._Asin=p.asm.Asin).apply(null,arguments)},p._Asinh=function(){return(p._Asinh=p.asm.Asinh).apply(null,arguments)},p._Atan=function(){return(p._Atan=p.asm.Atan).apply(null,arguments)},p._Atan2=function(){return(p._Atan2=p.asm.Atan2).apply(null,arguments)},p._Atanh=function(){return(p._Atanh=p.asm.Atanh).apply(null,arguments)},p._AvgPool=function(){return(p._AvgPool=p.asm.AvgPool).apply(null,arguments)},p._AvgPool3D=function(){return(p._AvgPool3D=p.asm.AvgPool3D).apply(null,arguments)},p._AvgPool3DGrad=function(){return(p._AvgPool3DGrad=p.asm.AvgPool3DGrad).apply(null,arguments)},p._AvgPoolGrad=function(){return(p._AvgPoolGrad=p.asm.AvgPoolGrad).apply(null,arguments)},p._BatchMatMul=function(){return(p._BatchMatMul=p.asm.BatchMatMul).apply(null,arguments)},p._Bincount=function(){return(p._Bincount=p.asm.Bincount).apply(null,arguments)},p._BitwiseAnd=function(){return(p._BitwiseAnd=p.asm.BitwiseAnd).apply(null,arguments)},p._Ceil=function(){return(p._Ceil=p.asm.Ceil).apply(null,arguments)},p._ClipByValue=function(){return(p._ClipByValue=p.asm.ClipByValue).apply(null,arguments)},p._Conv2D=function(){return(p._Conv2D=p.asm.Conv2D).apply(null,arguments)},p._Conv2DBackpropInput=function(){return(p._Conv2DBackpropInput=p.asm.Conv2DBackpropInput).apply(null,arguments)},p._Conv3D=function(){return(p._Conv3D=p.asm.Conv3D).apply(null,arguments)},p._Conv3DBackpropFilterV2=function(){return(p._Conv3DBackpropFilterV2=p.asm.Conv3DBackpropFilterV2).apply(null,arguments)},p._Conv3DBackpropInputV2=function(){return(p._Conv3DBackpropInputV2=p.asm.Conv3DBackpropInputV2).apply(null,arguments)},p._Cos=function(){return(p._Cos=p.asm.Cos).apply(null,arguments)},p._Cosh=function(){return(p._Cosh=p.asm.Cosh).apply(null,arguments)},p._CropAndResize=function(){return(p._CropAndResize=p.asm.CropAndResize).apply(null,arguments)},p._Cumprod=function(){return(p._Cumprod=p.asm.Cumprod).apply(null,arguments)},p._Cumsum=function(){return(p._Cumsum=p.asm.Cumsum).apply(null,arguments)},p._DenseBincount=function(){return(p._DenseBincount=p.asm.DenseBincount).apply(null,arguments)},p._DepthToSpace=function(){return(p._DepthToSpace=p.asm.DepthToSpace).apply(null,arguments)},p._DepthwiseConv2dNative=function(){return(p._DepthwiseConv2dNative=p.asm.DepthwiseConv2dNative).apply(null,arguments)},p._Diag=function(){return(p._Diag=p.asm.Diag).apply(null,arguments)},p._Dilation2D=function(){return(p._Dilation2D=p.asm.Dilation2D).apply(null,arguments)},p._Dilation2DBackpropFilter=function(){return(p._Dilation2DBackpropFilter=p.asm.Dilation2DBackpropFilter).apply(null,arguments)},p._Dilation2DBackpropInput=function(){return(p._Dilation2DBackpropInput=p.asm.Dilation2DBackpropInput).apply(null,arguments)},p._Elu=function(){return(p._Elu=p.asm.Elu).apply(null,arguments)},p._EluGrad=function(){return(p._EluGrad=p.asm.EluGrad).apply(null,arguments)},p._Equal=function(){return(p._Equal=p.asm.Equal).apply(null,arguments)},p._Erf=function(){return(p._Erf=p.asm.Erf).apply(null,arguments)},p._Exp=function(){return(p._Exp=p.asm.Exp).apply(null,arguments)},p._Expm1=function(){return(p._Expm1=p.asm.Expm1).apply(null,arguments)},p._FlipLeftRight=function(){return(p._FlipLeftRight=p.asm.FlipLeftRight).apply(null,arguments)},p._Floor=function(){return(p._Floor=p.asm.Floor).apply(null,arguments)},p._FloorDiv=function(){return(p._FloorDiv=p.asm.FloorDiv).apply(null,arguments)},p._FusedBatchNorm=function(){return(p._FusedBatchNorm=p.asm.FusedBatchNorm).apply(null,arguments)},p._FusedConv2D=function(){return(p._FusedConv2D=p.asm.FusedConv2D).apply(null,arguments)},p._FusedDepthwiseConv2D=function(){return(p._FusedDepthwiseConv2D=p.asm.FusedDepthwiseConv2D).apply(null,arguments)},p._Gather=function(){return(p._Gather=p.asm.Gather).apply(null,arguments)},p._GatherNd=function(){return(p._GatherNd=p.asm.GatherNd).apply(null,arguments)},p._Greater=function(){return(p._Greater=p.asm.Greater).apply(null,arguments)},p._GreaterEqual=function(){return(p._GreaterEqual=p.asm.GreaterEqual).apply(null,arguments)},p._IsFinite=function(){return(p._IsFinite=p.asm.IsFinite).apply(null,arguments)},p._IsInf=function(){return(p._IsInf=p.asm.IsInf).apply(null,arguments)},p._IsNan=function(){return(p._IsNan=p.asm.IsNan).apply(null,arguments)},p._LRN=function(){return(p._LRN=p.asm.LRN).apply(null,arguments)},p._LRNGrad=function(){return(p._LRNGrad=p.asm.LRNGrad).apply(null,arguments)},p._LeakyRelu=function(){return(p._LeakyRelu=p.asm.LeakyRelu).apply(null,arguments)},p._Less=function(){return(p._Less=p.asm.Less).apply(null,arguments)},p._LessEqual=function(){return(p._LessEqual=p.asm.LessEqual).apply(null,arguments)},p._LinSpace=function(){return(p._LinSpace=p.asm.LinSpace).apply(null,arguments)},p._Log=function(){return(p._Log=p.asm.Log).apply(null,arguments)},p._Log1p=function(){return(p._Log1p=p.asm.Log1p).apply(null,arguments)},p._LogicalAnd=function(){return(p._LogicalAnd=p.asm.LogicalAnd).apply(null,arguments)},p._LogicalNot=function(){return(p._LogicalNot=p.asm.LogicalNot).apply(null,arguments)},p._LogicalOr=function(){return(p._LogicalOr=p.asm.LogicalOr).apply(null,arguments)},p._LogicalXor=function(){return(p._LogicalXor=p.asm.LogicalXor).apply(null,arguments)},p._Max=function(){return(p._Max=p.asm.Max).apply(null,arguments)},p._MaxPool=function(){return(p._MaxPool=p.asm.MaxPool).apply(null,arguments)},p._MaxPool3D=function(){return(p._MaxPool3D=p.asm.MaxPool3D).apply(null,arguments)},p._MaxPool3DGrad=function(){return(p._MaxPool3DGrad=p.asm.MaxPool3DGrad).apply(null,arguments)},p._MaxPoolGrad=function(){return(p._MaxPoolGrad=p.asm.MaxPoolGrad).apply(null,arguments)},p._MaxPoolWithArgmax=function(){return(p._MaxPoolWithArgmax=p.asm.MaxPoolWithArgmax).apply(null,arguments)},p._Maximum=function(){return(p._Maximum=p.asm.Maximum).apply(null,arguments)},p._Mean=function(){return(p._Mean=p.asm.Mean).apply(null,arguments)},p._Min=function(){return(p._Min=p.asm.Min).apply(null,arguments)},p._Minimum=function(){return(p._Minimum=p.asm.Minimum).apply(null,arguments)},p._MirrorPad=function(){return(p._MirrorPad=p.asm.MirrorPad).apply(null,arguments)},p._Mod=function(){return(p._Mod=p.asm.Mod).apply(null,arguments)},p._Multinomial=function(){return(p._Multinomial=p.asm.Multinomial).apply(null,arguments)},p._Multiply=function(){return(p._Multiply=p.asm.Multiply).apply(null,arguments)},p._Neg=function(){return(p._Neg=p.asm.Neg).apply(null,arguments)},p._NonMaxSuppressionV3=function(){return(p._NonMaxSuppressionV3=p.asm.NonMaxSuppressionV3).apply(null,arguments)},p._NonMaxSuppressionV4=function(){return(p._NonMaxSuppressionV4=p.asm.NonMaxSuppressionV4).apply(null,arguments)},p._NonMaxSuppressionV5=function(){return(p._NonMaxSuppressionV5=p.asm.NonMaxSuppressionV5).apply(null,arguments)},p._NotEqual=function(){return(p._NotEqual=p.asm.NotEqual).apply(null,arguments)},p._OneHot=function(){return(p._OneHot=p.asm.OneHot).apply(null,arguments)},p._PadV2=function(){return(p._PadV2=p.asm.PadV2).apply(null,arguments)},p._Pow=function(){return(p._Pow=p.asm.Pow).apply(null,arguments)},p._Prelu=function(){return(p._Prelu=p.asm.Prelu).apply(null,arguments)},p._Prod=function(){return(p._Prod=p.asm.Prod).apply(null,arguments)},p._RealDiv=function(){return(p._RealDiv=p.asm.RealDiv).apply(null,arguments)},p._Reciprocal=function(){return(p._Reciprocal=p.asm.Reciprocal).apply(null,arguments)},p._Relu=function(){return(p._Relu=p.asm.Relu).apply(null,arguments)},p._Relu6=function(){return(p._Relu6=p.asm.Relu6).apply(null,arguments)},p._ResizeBilinear=function(){return(p._ResizeBilinear=p.asm.ResizeBilinear).apply(null,arguments)},p._ResizeBilinearGrad=function(){return(p._ResizeBilinearGrad=p.asm.ResizeBilinearGrad).apply(null,arguments)},p._ResizeNearestNeighbor=function(){return(p._ResizeNearestNeighbor=p.asm.ResizeNearestNeighbor).apply(null,arguments)},p._ResizeNearestNeighborGrad=function(){return(p._ResizeNearestNeighborGrad=p.asm.ResizeNearestNeighborGrad).apply(null,arguments)}
2,p._Reverse=function(){return(p._Reverse=p.asm.Reverse).apply(null,arguments)},p._RotateWithOffset=function(){return(p._RotateWithOffset=p.asm.RotateWithOffset).apply(null,arguments)},p._Round=function(){return(p._Round=p.asm.Round).apply(null,arguments)},p._Rsqrt=function(){return(p._Rsqrt=p.asm.Rsqrt).apply(null,arguments)},p._ScatterNd=function(){return(p._ScatterNd=p.asm.ScatterNd).apply(null,arguments)},p._SearchSorted=function(){return(p._SearchSorted=p.asm.SearchSorted).apply(null,arguments)},p._SelectV2=function(){return(p._SelectV2=p.asm.SelectV2).apply(null,arguments)},p._Selu=function(){return(p._Selu=p.asm.Selu).apply(null,arguments)},p._Sigmoid=function(){return(p._Sigmoid=p.asm.Sigmoid).apply(null,arguments)},p._Sign=function(){return(p._Sign=p.asm.Sign).apply(null,arguments)},p._Sin=function(){return(p._Sin=p.asm.Sin).apply(null,arguments)},p._Sinh=function(){return(p._Sinh=p.asm.Sinh).apply(null,arguments)},p._Softmax=function(){return(p._Softmax=p.asm.Softmax).apply(null,arguments)},p._Softplus=function(){return(p._Softplus=p.asm.Softplus).apply(null,arguments)},p._SparseFillEmptyRows=function(){return(p._SparseFillEmptyRows=p.asm.SparseFillEmptyRows).apply(null,arguments)},p._SparseReshape=function(){return(p._SparseReshape=p.asm.SparseReshape).apply(null,arguments)},p._SparseSegmentReduction=function(){return(p._SparseSegmentReduction=p.asm.SparseSegmentReduction).apply(null,arguments)},p._SparseToDense=function(){return(p._SparseToDense=p.asm.SparseToDense).apply(null,arguments)},p._Sqrt=function(){return(p._Sqrt=p.asm.Sqrt).apply(null,arguments)},p._Square=function(){return(p._Square=p.asm.Square).apply(null,arguments)},p._SquaredDifference=function(){return(p._SquaredDifference=p.asm.SquaredDifference).apply(null,arguments)},p._Step=function(){return(p._Step=p.asm.Step).apply(null,arguments)},p._StridedSlice=function(){return(p._StridedSlice=p.asm.StridedSlice).apply(null,arguments)},p._Sub=function(){return(p._Sub=p.asm.Sub).apply(null,arguments)},p._Sum=function(){return(p._Sum=p.asm.Sum).apply(null,arguments)},p._Tan=function(){return(p._Tan=p.asm.Tan).apply(null,arguments)},p._Tanh=function(){return(p._Tanh=p.asm.Tanh).apply(null,arguments)},p._TensorScatterUpdate=function(){return(p._TensorScatterUpdate=p.asm.TensorScatterUpdate).apply(null,arguments)},p._Tile=function(){return(p._Tile=p.asm.Tile).apply(null,arguments)},p._TopK=function(){return(p._TopK=p.asm.TopK).apply(null,arguments)},p._Transform=function(){return(p._Transform=p.asm.Transform).apply(null,arguments)},p._Transpose=function(){return(p._Transpose=p.asm.Transpose).apply(null,arguments)},p.__FusedMatMul=function(){return(p.__FusedMatMul=p.asm._FusedMatMul).apply(null,arguments)},p._malloc=function(){return(p._malloc=p.asm.malloc).apply(null,arguments)},p._free=function(){return(p._free=p.asm.free).apply(null,arguments)},p.__emscripten_tls_init=function(){return(p.__emscripten_tls_init=p.asm._emscripten_tls_init).apply(null,arguments)},p._pthread_self=function(){return(Re=p._pthread_self=p.asm.pthread_self).apply(null,arguments)}),$e=(p.___errno_location=function(){return(p.___errno_location=p.asm.__errno_location).apply(null,arguments)},p.__emscripten_thread_init=function(){return($e=p.__emscripten_thread_init=p.asm._emscripten_thread_init).apply(null,arguments)}),Le=(p.__emscripten_thread_crashed=function(){return(p.__emscripten_thread_crashed=p.asm._emscripten_thread_crashed).apply(null,arguments)},p._emscripten_main_thread_process_queued_calls=function(){return(p._emscripten_main_thread_process_queued_calls=p.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},p._emscripten_main_browser_thread_id=function(){return(p._emscripten_main_browser_thread_id=p.asm.emscripten_main_browser_thread_id).apply(null,arguments)},p._emscripten_run_in_main_runtime_thread_js=function(){return(Le=p._emscripten_run_in_main_runtime_thread_js=p.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)}),We=(p._emscripten_dispatch_to_thread_=function(){return(p._emscripten_dispatch_to_thread_=p.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},p.__emscripten_proxy_execute_task_queue=function(){return(We=p.__emscripten_proxy_execute_task_queue=p.asm._emscripten_proxy_execute_task_queue).apply(null,arguments)}),ze=p.__emscripten_thread_free_data=function(){return(ze=p.__emscripten_thread_free_data=p.asm._emscripten_thread_free_data).apply(null,arguments)},Be=p.__emscripten_thread_exit=function(){return(Be=p.__emscripten_thread_exit=p.asm._emscripten_thread_exit).apply(null,arguments)},Ue=p._emscripten_stack_set_limits=function(){return(Ue=p._emscripten_stack_set_limits=p.asm.emscripten_stack_set_limits).apply(null,arguments)},He=p.stackSave=function(){return(He=p.stackSave=p.asm.stackSave).apply(null,arguments)},Ve=p.stackRestore=function(){return(Ve=p.stackRestore=p.asm.stackRestore).apply(null,arguments)},Ge=p.stackAlloc=function(){return(Ge=p.stackAlloc=p.asm.stackAlloc).apply(null,arguments)};function qe(e){if(e=e||g,!(Z>0)){if(k)return u(p),J(),void startWorker(p);!function(){if(p.preRun)for("function"==typeof p.preRun&&(p.preRun=[p.preRun]);p.preRun.length;)e=p.preRun.shift(),j.unshift(e);var e;he(j)}(),Z>
20||(p.setStatus?(p.setStatus("Running..."),setTimeout((function(){setTimeout((function(){p.setStatus("")}),1),t()}),1)):t())}function t(){Fe||(Fe=!0,p.calledRun=!0,B||(J(),u(p),p.onRuntimeInitialized&&p.onRuntimeInitialized(),function(){if(!k){if(p.postRun)for("function"==typeof p.postRun&&(p.postRun=[p.postRun]);p.postRun.length;)e=p.postRun.shift(),Q.unshift(e);var e;he(Q)}}()))}}if(p.dynCall_iijjiiii=function(){return(p.dynCall_iijjiiii=p.asm.dynCall_iijjiiii).apply(null,arguments)},p.dynCall_jiji=function(){return(p.dynCall_jiji=p.asm.dynCall_jiji).apply(null,arguments)},p.keepRuntimeAlive=Y,p.wasmMemory=F,p.cwrap=function(e,t,n,r){var a=(n=n||[]).every((e=>"number"===e||"boolean"===e));return"string"!==t&&a&&!r?Ee(e):function(){return Ae(e,t,n,arguments)}},p.ExitStatus=ie,p.PThread=de,ee=function e(){Fe||qe(),Fe||(ee=e)},p.preInit)for("function"==typeof p.preInit&&(p.preInit=[p.preInit]);p.preInit.length>0;)p.preInit.pop()();if(qe(),l&&(De={uncaughtException:process.listeners("uncaughtException").filter((function(e){return!l.uncaughtException.indexOf(e)>-1})),unhandledRejection:process.listeners("unhandledRejection").filter((function(e){return!l.unhandledRejection.indexOf(e)>-1}))}),"undefined"!=typeof WasmBackendModule)Oe=WasmBackendModule;else{if(void 0===e)throw new Error("Could not find wasm module in post.js");Oe=e}if(De){var je=Oe._dispose;Oe._dispose=function(){je(),De.uncaughtException.forEach((function(e){process.removeListener("uncaughtException",e)})),De.unhandledRejection.forEach((function(e){process.removeListener("unhandledRejection",e)}))}}return e.ready});e.exports=a},13712:function(e){e.exports.O='"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",data=>onmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8")+"//# sourceURL="+f)},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;var pendingNotifiedProxyingQueues=[];function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+"\n");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onunhandledrejection=e=>{throw e.reason??e};self.startWorker=instance=>{Module=instance;postMessage({"cmd":"loaded"})};self.onmessage=e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;for(const handler of e.data.handlers){Module[handler]=function(){postMessage({cmd:"callHandler",handler:handler,args:[...arguments]})}}Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob=="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module)}else if(e.data.cmd==="run"){Module["__emscripten_thread_init"](e.data.pthread_ptr,0,0,1);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){pendingNotifiedProxyingQueues.forEach(queue=>{Module["executeNotifiedProxyingQueue"](queue)});pendingNotifiedProxyingQueues=[];initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processProxyingQueue"){if(initializedJS){Module["executeNotifiedProxyingQueue"](e.data.queue)}else{pendingNotifiedProxyingQueues.push(e.data.queue)}}else if(e.data.cmd){err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}};'},84928:function(e,t,n){var r,a=(r=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){var t,a,o,s=void 0!==(e=e||{})?e:{};s.ready=new Promise((function(e,n){t=e,a=n})),"undefined"!=typeof process&&process.listeners&&(o={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var i,u,c,l=Object.assign({},s),p=[],d="object"==typeof window,h="function"==typeof importScripts,f="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,m="";if(f){var g=n(65912),y=n(39080);m=h?y.dirname(m)+"/":"//",i=(e,t)=>
vendor: 4,986 bytes, line 2
2(e=z(e)?new URL(e):y.normalize(e),g.readFileSync(e,t?void 0:"utf8")),c=e=>{var t=i(e,!0);return t.buffer||(t=new Uint8Array(t)),t},u=(e,t,n)=>{e=z(e)?new URL(e):y.normalize(e),g.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),p=process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof U))throw e})),process.on("unhandledRejection",(function(e){throw e})),s.inspect=function(){return"[Emscripten Module object]"}}else(d||h)&&(h?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),r&&(m=r),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},h&&(c=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),u=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var b,w,v=s.print||console.log.bind(console),k=s.printErr||console.warn.bind(console);Object.assign(s,l),l=null,s.arguments&&(p=s.arguments),s.thisProgram&&s.thisProgram,s.quit&&s.quit,s.wasmBinary&&(b=s.wasmBinary),s.noExitRuntime,"object"!=typeof WebAssembly&&R("no native wasm support detected");var x,_,I,S,N=!1,M="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function T(e,t,n){for(var r=(t>>>=0)+n,a=t;e[a]&&!(a>=r);)++a;if(a-t>16&&e.buffer&&M)return M.decode(e.subarray(t,a));for(var o="";t<a;){var s=e[t++];if(128&s){var i=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|i<<6|u:(7&s)<<18|i<<12|u<<6|63&e[t++])<65536)o+=String.fromCharCode(s);else{var c=s-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&s)<<6|i)}else o+=String.fromCharCode(s)}return o}function E(e){x=e,s.HEAP8=_=new Int8Array(e),s.HEAP16=new Int16Array(e),s.HEAP32=new Int32Array(e),s.HEAPU8=I=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAPU32=S=new Uint32Array(e),s.HEAPF32=new Float32Array(e),s.HEAPF64=new Float64Array(e)}s.INITIAL_MEMORY;var A=[],F=[],D=[],O=0,C=null,P=null;function R(e){s.onAbort&&s.onAbort(e),k(e="Aborted("+e+")"),N=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw a(t),t}var $,L;function W(e){return e.startsWith("data:application/octet-stream;base64,")}function z(e){return e.startsWith("file://")}function B(e){try{if(e==$&&b)return new Uint8Array(b);if(c)return c(e);throw"both async and sync fetching of the wasm failed"}catch(e){R(e)}}function U(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function H(e){for(;e.length>0;)e.shift()(s)}function V(e){try{return w.grow(e-x.byteLength+65535>>>16),E(w.buffer),1}catch(e){}}W($="tfjs-backend-wasm.wasm")||(L=$,$=s.locateFile?s.locateFile(L,m):m+L);var G=[null,[],[]];function q(e,t){var n=G[e];0===t||10===t?((1===e?v:k)(T(n,0)),n.length=0):n.push(t)}function j(e){return s["_"+e]}function K(e,t,n,r,a){var o={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);!function(e,t,n){!function(e,t,n,r){if(!(r>0))return 0;for(var a=(n>>>=0)+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),s<=127){if(n>=a)break;t[n++>>>0]=s}else if(s<=2047){if(n+1>=a)break;t[n++>>>0]=192|s>>6,t[n++>>>0]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++>>>0]=224|s>>12,t[n++>>>0]=128|s>>6&63,t[n++>>>0]=128|63&s}else{if(n+3>=a)break;t[n++>>>0]=240|s>>18,t[n++>>>0]=128|s>>12&63,t[n++>>>0]=128|s>>6&63,t[n++>>>0]=128|63&s}}t[n>>>0]=0}(e,I,t,n)}(e,t=te(n),n)}return t},array:e=>{var t=te(e.length);return function(e,t){_.set(e,t>>>0)}(e,t),t}},s=j(e),i=[],u=0;if(r)for(var c=0;c<r.length;c++){var l=o[n[c]];l?(0===u&&(u=X()),i[c]=l(r[c])):i[c]=r[c]}var p=s.apply(null,i);return function(e){return 0!==u&&ee(u),function(e){return"string"===t?(n=e,(n>>>=0)?T(I,n,r):""):"boolean"===t?Boolean(e):e;var n,r}(e)}(p)}var Q,Y,J,Z={abort:function(){R("")},emscripten_get_heap_max:function(){return 4294901760},emscripten_memcpy_big:function(e,t,n){I.copyWithin(e>>>0,t>>>0,t+n>>>0)},emscripten_resize_heap:function(e){var t,n=I.length,r=4294901760;if((e>>>=0)>r)return!1;for(var a=1;a<=4;a*=2){var o=n*(1+.2/a);if(o=Math.min(o,e+100663296),V(Math.min(r,(t=Math.max(e,o))+(65536-t%65536)%65536)))return!0}return!1},fd_close:function(e){return 52},fd_seek:function(e,t,n,r,a){return 70},fd_write:function(e,t,n,r){for(var a=0,o=0;o<n;o++){var s=S[t>>>2],i=S[t+4>>>2];t+=8;for(var u=0;u<i;u++)q(e,I[s+u>>>0]);a+=i}return S[r>>>2]=a,0}},X=(function(){var e={env:Z,wasi_snapshot_preview1:Z};function t(e,t){var n,r=e.exports;s.asm=r,E((w=s.asm.memory).buffer),s.asm.__indirect_function_table,n=s.asm.__wasm_call_ctors,F.unshift(n),function(e){if(O--,s.monitorRunDependencies&&s.monitorRunDependencies(O),
vendor: 1,187 bytes, line 2
20==O&&(null!==C&&(clearInterval(C),C=null),P)){var t=P;P=null,t()}}()}function n(e){t(e.instance)}function r(t){return function(){if(!b&&(d||h)){if("function"==typeof fetch&&!z($))return fetch($,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+$+"'";return e.arrayBuffer()})).catch((function(){return B($)}));if(u)return new Promise((function(e,t){u($,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return B($)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){k("failed to asynchronously prepare wasm: "+e),R(e)}))}if(O++,s.monitorRunDependencies&&s.monitorRunDependencies(O),s.instantiateWasm)try{return s.instantiateWasm(e,t)}catch(e){k("Module.instantiateWasm callback failed with error: "+e),a(e)}(b||"function"!=typeof WebAssembly.instantiateStreaming||W($)||z($)||f||"function"!=typeof fetch?r(n):fetch($,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return k("wasm streaming compile failed: "+e),k("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(a
vendor: 12,226 bytes, line 2
2)}(),s.___wasm_call_ctors=function(){return(s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},s._init=function(){return(s._init=s.asm.init).apply(null,arguments)},s._init_with_threads_count=function(){return(s._init_with_threads_count=s.asm.init_with_threads_count).apply(null,arguments)},s._get_threads_count=function(){return(s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},s._register_tensor=function(){return(s._register_tensor=s.asm.register_tensor).apply(null,arguments)},s._dispose_data=function(){return(s._dispose_data=s.asm.dispose_data).apply(null,arguments)},s._dispose=function(){return(s._dispose=s.asm.dispose).apply(null,arguments)},s._Abs=function(){return(s._Abs=s.asm.Abs).apply(null,arguments)},s._Acos=function(){return(s._Acos=s.asm.Acos).apply(null,arguments)},s._Acosh=function(){return(s._Acosh=s.asm.Acosh).apply(null,arguments)},s._Add=function(){return(s._Add=s.asm.Add).apply(null,arguments)},s._AddN=function(){return(s._AddN=s.asm.AddN).apply(null,arguments)},s._All=function(){return(s._All=s.asm.All).apply(null,arguments)},s._Any=function(){return(s._Any=s.asm.Any).apply(null,arguments)},s._ArgMax=function(){return(s._ArgMax=s.asm.ArgMax).apply(null,arguments)},s._ArgMin=function(){return(s._ArgMin=s.asm.ArgMin).apply(null,arguments)},s._Asin=function(){return(s._Asin=s.asm.Asin).apply(null,arguments)},s._Asinh=function(){return(s._Asinh=s.asm.Asinh).apply(null,arguments)},s._Atan=function(){return(s._Atan=s.asm.Atan).apply(null,arguments)},s._Atan2=function(){return(s._Atan2=s.asm.Atan2).apply(null,arguments)},s._Atanh=function(){return(s._Atanh=s.asm.Atanh).apply(null,arguments)},s._AvgPool=function(){return(s._AvgPool=s.asm.AvgPool).apply(null,arguments)},s._AvgPool3D=function(){return(s._AvgPool3D=s.asm.AvgPool3D).apply(null,arguments)},s._AvgPool3DGrad=function(){return(s._AvgPool3DGrad=s.asm.AvgPool3DGrad).apply(null,arguments)},s._AvgPoolGrad=function(){return(s._AvgPoolGrad=s.asm.AvgPoolGrad).apply(null,arguments)},s._BatchMatMul=function(){return(s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},s._Bincount=function(){return(s._Bincount=s.asm.Bincount).apply(null,arguments)},s._BitwiseAnd=function(){return(s._BitwiseAnd=s.asm.BitwiseAnd).apply(null,arguments)},s._Ceil=function(){return(s._Ceil=s.asm.Ceil).apply(null,arguments)},s._ClipByValue=function(){return(s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},s._Conv2D=function(){return(s._Conv2D=s.asm.Conv2D).apply(null,arguments)},s._Conv2DBackpropInput=function(){return(s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},s._Conv3D=function(){return(s._Conv3D=s.asm.Conv3D).apply(null,arguments)},s._Conv3DBackpropFilterV2=function(){return(s._Conv3DBackpropFilterV2=s.asm.Conv3DBackpropFilterV2).apply(null,arguments)},s._Conv3DBackpropInputV2=function(){return(s._Conv3DBackpropInputV2=s.asm.Conv3DBackpropInputV2).apply(null,arguments)},s._Cos=function(){return(s._Cos=s.asm.Cos).apply(null,arguments)},s._Cosh=function(){return(s._Cosh=s.asm.Cosh).apply(null,arguments)},s._CropAndResize=function(){return(s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},s._Cumprod=function(){return(s._Cumprod=s.asm.Cumprod).apply(null,arguments)},s._Cumsum=function(){return(s._Cumsum=s.asm.Cumsum).apply(null,arguments)},s._DenseBincount=function(){return(s._DenseBincount=s.asm.DenseBincount).apply(null,arguments)},s._DepthToSpace=function(){return(s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},s._DepthwiseConv2dNative=function(){return(s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},s._Diag=function(){return(s._Diag=s.asm.Diag).apply(null,arguments)},s._Dilation2D=function(){return(s._Dilation2D=s.asm.Dilation2D).apply(null,arguments)},s._Dilation2DBackpropFilter=function(){return(s._Dilation2DBackpropFilter=s.asm.Dilation2DBackpropFilter).apply(null,arguments)},s._Dilation2DBackpropInput=function(){return(s._Dilation2DBackpropInput=s.asm.Dilation2DBackpropInput).apply(null,arguments)},s._Elu=function(){return(s._Elu=s.asm.Elu).apply(null,arguments)},s._EluGrad=function(){return(s._EluGrad=s.asm.EluGrad).apply(null,arguments)},s._Equal=function(){return(s._Equal=s.asm.Equal).apply(null,arguments)},s._Erf=function(){return(s._Erf=s.asm.Erf).apply(null,arguments)},s._Exp=function(){return(s._Exp=s.asm.Exp).apply(null,arguments)},s._Expm1=function(){return(s._Expm1=s.asm.Expm1).apply(null,arguments)},s._FlipLeftRight=function(){return(s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},s._Floor=function(){return(s._Floor=s.asm.Floor).apply(null,arguments)},s._FloorDiv=function(){return(s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},s._FusedBatchNorm=function(){return(s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},s._FusedConv2D=function(){return(s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},s._FusedDepthwiseConv2D=function(){return(s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},s._Gather=function(){return(s._Gather=s.asm.Gather).apply(null,arguments)},s._GatherNd=function(){return(s._GatherNd=s.asm.GatherNd).apply(null,arguments)},s._Greater=function(){return(s._Greater=s.asm.Greater).apply(null,arguments)},s._GreaterEqual=function(){return(s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},s._IsFinite=function(){return(s._IsFinite=s.asm.IsFinite).apply(null,arguments)},s._IsInf=function(){return(s._IsInf=s.asm.IsInf).apply(null,arguments)},s._IsNan=function(){return(s._IsNan=s.asm.IsNan).apply(null,arguments)},s._LRN=function(){return(s._LRN=s.asm.LRN).apply(null,arguments)},s._LRNGrad=function(){return(s._LRNGrad=s.asm.LRNGrad).apply(null,arguments)},s._LeakyRelu=function(){return(s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},s._Less=function(){return(s._Less=s.asm.Less).apply(null,arguments)},s._LessEqual=function(){return(s._LessEqual=s.asm.LessEqual).apply(null,arguments)},s._LinSpace=function(){return(s._LinSpace=s.asm.LinSpace).apply(null,arguments)},s._Log=function(){return(s._Log=s.asm.Log).apply(null,arguments)},s._Log1p=function(){return(s._Log1p=s.asm.Log1p).apply(null,arguments)},s._LogicalAnd=function(){return(s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},s._LogicalNot=function(){return(s._LogicalNot=s.asm.LogicalNot).apply(null,arguments)},s._LogicalOr=function(){return(s._LogicalOr=s.asm.LogicalOr).apply(null,arguments)},s._LogicalXor=function(){return(s._LogicalXor=s.asm.LogicalXor).apply(null,arguments)},s._Max=function(){return(s._Max=s.asm.Max).apply(null,arguments)},s._MaxPool=function(){return(s._MaxPool=s.asm.MaxPool).apply(null,arguments)},s._MaxPool3D=function(){return(s._MaxPool3D=s.asm.MaxPool3D).apply(null,arguments)},s._MaxPool3DGrad=function(){return(s._MaxPool3DGrad=s.asm.MaxPool3DGrad).apply(null,arguments)},s._MaxPoolGrad=function(){return(s._MaxPoolGrad=s.asm.MaxPoolGrad).apply(null,arguments)},s._MaxPoolWithArgmax=function(){return(s._MaxPoolWithArgmax=s.asm.MaxPoolWithArgmax).apply(null,arguments)},s._Maximum=function(){return(s._Maximum=s.asm.Maximum).apply(null,arguments)},s._Mean=function(){return(s._Mean=s.asm.Mean).apply(null,arguments)},s._Min=function(){return(s._Min=s.asm.Min).apply(null,arguments)},s._Minimum=function(){return(s._Minimum=s.asm.Minimum).apply(null,arguments)},s._MirrorPad=function(){return(s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},s._Mod=function(){return(s._Mod=s.asm.Mod).apply(null,arguments)},s._Multinomial=function(){return(s._Multinomial=s.asm.Multinomial).apply(null,arguments)},s._Multiply=function(){return(s._Multiply=s.asm.Multiply).apply(null,arguments)},s._Neg=function(){return(s._Neg=s.asm.Neg).apply(null,arguments)},s._NonMaxSuppressionV3=function(){return(s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},s._NonMaxSuppressionV4=function(){return(s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},s._NonMaxSuppressionV5=function(){return(s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},s._NotEqual=function(){return(s._NotEqual=s.asm.NotEqual).apply(null,arguments)},s._OneHot=function(){return(s._OneHot=s.asm.OneHot).apply(null,arguments)},s._PadV2=function(){return(s._PadV2=s.asm.PadV2).apply(null,arguments)},s._Pow=function(){return(s._Pow=s.asm.Pow).apply(null,arguments)},s._Prelu=function(){return(s._Prelu=s.asm.Prelu).apply(null,arguments)},s._Prod=function(){return(s._Prod=s.asm.Prod).apply(null,arguments)},s._RealDiv=function(){return(s._RealDiv=s.asm.RealDiv).apply(null,arguments)},s._Reciprocal=function(){return(s._Reciprocal=s.asm.Reciprocal).apply(null,arguments)},s._Relu=function(){return(s._Relu=s.asm.Relu).apply(null,arguments)},s._Relu6=function(){return(s._Relu6=s.asm.Relu6).apply(null,arguments)},s._ResizeBilinear=function(){return(s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},s._ResizeBilinearGrad=function(){return(s._ResizeBilinearGrad=s.asm.ResizeBilinearGrad).apply(null,arguments)},s._ResizeNearestNeighbor=function(){return(s._ResizeNearestNeighbor=s.asm.ResizeNearestNeighbor).apply(null,arguments)},s._ResizeNearestNeighborGrad=function(){return(s._ResizeNearestNeighborGrad=s.asm.ResizeNearestNeighborGrad).apply(null,arguments)},s._Reverse=function(){return(s._Reverse=s.asm.Reverse).apply(null,arguments)},s._RotateWithOffset=function(){return(s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},s._Round=function(){return(s._Round=s.asm.Round).apply(null,arguments)},s._Rsqrt=function(){return(s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},s._ScatterNd=function(){return(s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},s._SearchSorted=function(){return(s._SearchSorted=s.asm.SearchSorted).apply(null,arguments)},s._SelectV2=function(){return(s._SelectV2=s.asm.SelectV2).apply(null,arguments)},s._Selu=function(){return(s._Selu=s.asm.Selu).apply(null,arguments)},s._Sigmoid=function(){return(s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},s._Sign=function(){return(s._Sign=s.asm.Sign).apply(null,arguments)},s._Sin=function(){return(s._Sin=s.asm.Sin).apply(null,arguments)},s._Sinh=function(){return(s._Sinh=s.asm.Sinh).apply(null,arguments)},s._Softmax=function(){return(s._Softmax=s.asm.Softmax).apply(null,arguments)},s._Softplus=function(){return(s._Softplus=s.asm.Softplus).apply(null,arguments)},s._SparseFillEmptyRows=function(){return(s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},s._SparseReshape=function(){return(s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},s._SparseSegmentReduction=function(){return(s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},s._SparseToDense=function(){return(s._SparseToDense=s.asm.SparseToDense).apply(null,arguments)},s._Sqrt=function(){return(s._Sqrt=s.asm.Sqrt).apply(null,arguments)},s._Square=function(){return(s._Square=s.asm.Square).apply(null,arguments)},s._SquaredDifference=function(){return(s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},s._Step=function(){return(s._Step=s.asm.Step).apply(null,arguments)},s._StridedSlice=function(){return(s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},s._Sub=function(){return(s._Sub=s.asm.Sub).apply(null,arguments)},s._Sum=function(){return(s._Sum=s.asm.Sum).apply(null,arguments)},s._Tan=function(){return(s._Tan=s.asm.Tan).apply(null,arguments)},s._Tanh=function(){return(s._Tanh=s.asm.Tanh).apply(null,arguments)},s._TensorScatterUpdate=function(){return(s._TensorScatterUpdate=s.asm.TensorScatterUpdate).apply(null,arguments)},s._Tile=function(){return(s._Tile=s.asm.Tile).apply(null,arguments)},s._TopK=function(){return(s._TopK=s.asm.TopK).apply(null,arguments)},s._Transform=function(){return(s._Transform=s.asm.Transform).apply(null,arguments)},s._Transpose=function(){return(s._Transpose=s.asm.Transpose).apply(null,arguments)},s.__FusedMatMul=function(){return(s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},s._malloc=function(){return(s._malloc=s.asm.malloc).apply(null,arguments)},s._free=function(){return(s._free=s.asm.free).apply(null,arguments)},s.___errno_location=function(){return(s.___errno_location=s.asm.__errno_location).apply(null,arguments)}
2,s.stackSave=function(){return(X=s.stackSave=s.asm.stackSave).apply(null,arguments)}),ee=s.stackRestore=function(){return(ee=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},te=s.stackAlloc=function(){return(te=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)};function ne(e){function n(){Q||(Q=!0,s.calledRun=!0,N||(H(F),t(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),function(){if(s.postRun)for("function"==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;)e=s.postRun.shift(),D.unshift(e);var e;H(D)}()))}e=e||p,O>0||(function(){if(s.preRun)for("function"==typeof s.preRun&&(s.preRun=[s.preRun]);s.preRun.length;)e=s.preRun.shift(),A.unshift(e);var e;H(A)}(),O>0||(s.setStatus?(s.setStatus("Running..."),setTimeout((function(){setTimeout((function(){s.setStatus("")}),1),n()}),1)):n()))}if(s.dynCall_iijjiiii=function(){return(s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},s.dynCall_jiji=function(){return(s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)},s.cwrap=function(e,t,n,r){var a=(n=n||[]).every((e=>"number"===e||"boolean"===e));return"string"!==t&&a&&!r?j(e):function(){return K(e,t,n,arguments)}},P=function e(){Q||ne(),Q||(P=e)},s.preInit)for("function"==typeof s.preInit&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();if(ne(),o&&(Y={uncaughtException:process.listeners("uncaughtException").filter((function(e){return!o.uncaughtException.indexOf(e)>-1})),unhandledRejection:process.listeners("unhandledRejection").filter((function(e){return!o.unhandledRejection.indexOf(e)>-1}))}),void 0!==e)J=e;else{if("undefined"==typeof WasmBackendModuleThreadedSimd)throw new Error("Could not find wasm module in post.js");J=WasmBackendModuleThreadedSimd}if(Y){var re=J._dispose;J._dispose=function(){re(),Y.uncaughtException.forEach((function(e){process.removeListener("uncaughtException",e)})),Y.unhandledRejection.forEach((function(e){process.removeListener("unhandledRejection",e)}))}}return e.ready});e.exports=a},82756:function(e,t,n){"use strict";n.d(t,{i:function(){return r},qe:function(){return a}});
2class 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 o("refCount")}incRef(e){return o("incRef")}timerAvailable(){return!0}time(e){return o("time")}read(e){return o("read")}readSync(e){return o("readSync")}readToGPU(e,t){return o("readToGPU")}numDataIds(){return o("numDataIds")}disposeData(e,t){return o("disposeData")}write(e,t,n){return o("write")}move(e,t,n,r,a){return o("move")}createTensorFromGPUData(e,t,n){return o("createTensorFromGPUData")}memory(){return o("memory")}floatPrecision(){return o("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return o("dispose")}}function o(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`)}},75941:function(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,o=0,s=!1;for(;r<a;){o=r+(a-r>>>1);const i=n(t,e[o]);i>0?r=o+1:(a=o,s=!i)}return s?r:-r-1}(e,t,n||a)}(e,t,n),o=r<0?-(r+1):r;e.splice(o,0,t)}function a(e,t){return e>t?1:e<t?-1:0}function o(e,t,n,r,a){return u(e,t,n,r,a,0)}function s(e,t,n,r,a,o){return u(e,t,n,r,a,0,!1,o,!0)}function i(e,t,n,r,a,o){return u(e,t,n,r,a,o,!0)}function u(e,t,n,a,o,s,i=!1,u=!1,d=!1){const h=[];for(let e=0;e<t.length;e++)t[e]>o&&h.push({score:t[e],boxIndex:e,suppressBeginIndex:0});h.sort(p);const f=s>0?-.5/s:0,m=[],g=[];for(;m.length<n&&h.length>0;){const t=h.pop(),{score:n,boxIndex:s,suppressBeginIndex:i}=t;if(n<o)break;let u=!1;for(let n=m.length-1;n>=i;--n){const r=c(e,s,m[n]);if(r>=a){u=!0;break}if(t.score=t.score*l(a,f,r),t.score<=o)break}t.suppressBeginIndex=m.length,u||(t.score===n?(m.push(s),g.push(t.score)):t.score>o&&r(h,t,p))}const y=m.length,b=n-y;u&&b>0&&(m.push(...new Array(b).fill(0)),g.push(...new Array(b).fill(0)));const w={selectedIndices:m};return i&&(w.selectedScores=g),d&&(w.validOutputs=y),w}function c(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),o=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),i=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),c=Math.min(a[0],a[2]),l=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),d=Math.max(a[1],a[3]),h=(i-o)*(u-s),f=(p-c)*(d-l);if(h<=0||f<=0)return 0;const m=Math.max(o,c),g=Math.max(s,l),y=Math.min(i,p),b=Math.min(u,d),w=Math.max(y-m,0)*Math.max(b-g,0);return w/(h+f-w)}function l(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,{Wm:function(){return o},Mf:function(){return s},eQ:function(){return i}})},13328:function(e,t,n){"use strict";n.d(t,{_:function(){return a}});var r=n(9653);function a(e,t){const n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(e);const a=(0,r.c)(e,"int32"),o=(0,r.c)([n.length,e.length],"int32");for(let t=0;t<n.length;t++){const r=a.indexToLoc(n[t]),s=t*e.length;o.values.set(r,s)}return o.toTensor()}},31748:function(e,t,n){"use strict";n.d(t,{cL:function(){return v},Y$:function(){return w}});var r=n(82756),a=n(41920),o=n(18308),s=n(38128),i=n(28616),u=n(44327),c=n(10680),l=n(15952);class p{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new h)}profileKernel(e,t,n){let r;const o=()=>{r=n()};let s;const i=c.now();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(o);else{o();for(const e of r)e.dataSync();s=Promise.resolve({kernelMs:c.now()-i})}if((0,a._K)().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{d(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:s.then((e=>e.kernelMs)),extraInfo:s.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:o}=e;n.forEach((e=>{Promise.all([e.data(),r,o]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function d(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(isNaN(r)||!isFinite(r))return console.warn(`Found ${r} in the result of '${n}'`),!0}return!1}class h{logKernelProfile(e,t,n,r,a,o){const s="number"==typeof r?l.Uf(`${r}ms`,9):r.error,i=l.Uf(e,25),u=t.rank,c=t.size,p=l.Uf(t.shape.toString(),14);let d="";for(const e in a){const n=a[e];if(null!=n){const r=n.shape||t.shape,a=r.length;d+=`${e}: ${a}D ${a>0?r:""} `}}console.log(`%c${i}\t%c${s}\t%c${u}D ${p}\t%c${c}\t%c${d}\t%c${o}
2`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}var f=n(74364),m=n(4172);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<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(u.m(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);
2if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new p(this.backendInstance),!0}setupRegisteredKernels(){(0,i.Ww)(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){(0,i.Ww)(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.qe||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t<this.pendingBackendInitId||(this.registry[e]=n,this.pendingBackendInit=null,0)))).catch((n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,u.m(`Initialization of backend ${e} failed`),u.m(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return u.m(`Initialization of backend ${e} failed`),u.m(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:r,asyncInit:a}=this.initializeBackend(n);if(a||r)return{name:n,asyncInit:a}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),r=n.backend,a=this.readSync(t),o=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,a,n.shape,n.dtype,o),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,r=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}return this.scopedRun((()=>this.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=v.runKernel(s.oPg,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e};return v.runKernel(s.Utj,t,{dtype:"float32"})}})),[],{}),t}runKernel(e,t,n){if(null==this.backendName&&this.backend,null==(0,i.G)(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 o=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],s=r-t-a-o;if(s>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${s} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,o=this.state.numTensors;let s,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:o}=e;null==this.backendName&&this.backend;const c=(0,i.G)(t,this.backendName);l.Uc(null!=c,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),s=()=>{const e=this.backend.numDataIds();
vendor: 4,921 bytes, line 2
2u=c.kernelFunc({inputs:a,attrs:o,backend:this.backend});const s=Array.isArray(u)?u:[u];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,s);const i=s.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));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)))))};s=()=>{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 f;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(f=this.profiler.profileKernel(c,p,(()=>s())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(f),t=f.outputs):t=s()})),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-o,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(p).map((e=>null!=p[e]?p[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:f.timeMs,extraInfo:f.extraInfo}),Array.isArray(u)?t:t[0]}saveTensorsForBackwardMode(e){const t=e.map((e=>this.keep(this.clone(e))));return t}getTensorsForGradient(e,t,n){const r=(0,i.kx)(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let o;r.saveAllInputs?(l.Uc(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),o=Object.keys(t).map((e=>t[e]))):o=e.map((e=>t[e]));const s=n.filter(((e,t)=>a[t]));return o.concat(s)}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.ct(e[0])&&(a=e.map((e=>c.encodeString(e))));const o=r.write(a,t,n),s=new f.w3(t,n,o,this.nextTensorId());if(this.trackTensor(s,r),"string"===n){const e=this.state.tensorInfo.get(o),t=(0,l.YX)(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return s}makeTensorFromDataId(e,t,n,r){const a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:a}=e,o=new f.w3(r,a,n,this.nextTensorId());return this.trackTensor(o,t),o}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new f.QB(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.U1(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 f.QB||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.U1(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>
20&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,o){const s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},u=(0,i.kx)(e);null!=u&&(r=u.gradFunc),null!=r&&(s.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=l.K6(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,o))),this.state.activeTape.push(s)}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.Ck)(e),n=new Set(t.map((e=>e.id)));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const r=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach((e=>{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(l.Uc(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.Uc(a instanceof f.w3,(()=>"The result y returned by f() must be a tensor."));const o=function(e,t,n){const r={},a={};for(let e=0;e<t.length;e++)r[t[e].id]=!0;for(let n=0;n<e.length;n++){const o=e[n],s=o.inputs;for(const e in s){const n=s[e];let i=!1;for(let e=0;e<t.length;e++)if(r[n.id]){o.outputs.forEach((e=>r[e.id]=!0)),i=!0,a[o.id]=!0;break}if(i)break}}const o={};o[n.id]=!0;const s={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e<n.outputs.length;e++)if(o[n.outputs[e].id]){for(const e in r)o[r[e].id]=!0,s[n.id]=!0;break}}const i=[];for(let t=0;t<e.length;t++){const n=e[t];if(a[n.id]&&s[n.id]){const e={};for(const t in n.inputs){const a=n.inputs[t];r[a.id]&&(e[t]=a)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,i.push(t)}}return i}(this.state.activeTape,t,a);if(!r&&0===o.length&&t.length>0)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.Do)((0,l.It)(e),"float32");return v.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const o=t[a],s=[];if(o.outputs.forEach((t=>{const n=e[t.id];null!=n?s.push(n):s.push(null)})),null==o.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${o.kernelName}.`);const i=o.gradient(s);for(const t in o.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 ${o.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const s=o.inputs[t];if(!l.eu(a.shape,s.shape))throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${s.shape}'`);if(null==e[s.id])e[s.id]=a;else{const t=e[s.id];e[s.id]=r(t,a),t.dispose()}}}}(e,o,(e=>this.tidy(e)),k);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.Uc(l.mg(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;l.Uc(t.every((e=>e instanceof f.w3)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};return t.forEach(((e,t)=>{r[t]=e})),this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),l.Uc(n.value instanceof f.w3,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),l.Uc(l.mg(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),o=Array.isArray(a)?a:[a];l.Uc(o.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.Uc(o.every((e=>e instanceof f.w3)),(()=>"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 s={};return o.forEach(((e,t)=>{s[t]=()=>e})),s},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=(0,c.now)(),n=await this.backend.time(e);return n.wallMs=(0,c.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 w(){const e=(0,o.M)();if(null==e._tfengine){const t=new a.Ih(e);e._tfengine=new b(t)}return(0,a.sn)(e._tfengine.ENV),(0,f.CE)((()=>e._tfengine)),e._tfengine}b.nextTensorId=0,b.nextVariableId=0;const v=w();function k(e,t){const n={a:e,b:t};return v.runKernel(s.OMN,n)}},41920:function(e,t,n){"use strict";n.d(t,{Ih:function(){return o},_K:function(){return i},sn:function(){return c}});var r=n(15952);const a="tfjsflags";class o{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=s,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(i().getBool("IS_TEST")||i().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];i().getBool("IS_TEST")||i().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if((0,r.um)(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)}getString(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);a in e&&e[a].split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){const n=t.toLowerCase();return"true"===n||"false"===n?"true"===n:""+ +n===n?+n:t}(0,n)}))}}function s(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 i(){return u}let u=null;function c(e){u=e}}
2,18308:function(e,t,n){"use strict";let r;function a(){if(null==r){let e;if("undefined"!=typeof window)e=window;else if(void 0!==n.g)e=n.g;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 o(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,{A:function(){return o},M:function(){return a}})},8244:function(e,t,n){"use strict";n.d(t,{G6:function(){return u},Mt:function(){return c},Oi:function(){return l},gJ:function(){return h},oh:function(){return d},sn:function(){return i},yO:function(){return p}});var r=n(31748),a=n(41920),o=n(74364),s=n(4172);function i(){return r.cL}function u(e,t){return r.cL.tidy(e,t)}function c(e){(0,s.Ck)(e).forEach((e=>e.dispose()))}function l(e){return r.cL.keep(e)}function p(e){return r.cL.setBackend(e)}function d(){return r.cL.ready()}function h(e,t,n=1){return r.cL.registerBackend(e,t,n)}(0,o.Oi)((function(e){(0,a._K)().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}))},18640:function(e,t,n){"use strict";n.d(t,{Sw:function(){return i},u:function(){return s}});var r=n(31748),a=n(74364),o=n(15952);function s(e,t){o.Uc(o.mg(e),(()=>"The f passed in variableGrads(f) must be a function")),o.Uc(null==t||Array.isArray(t)&&t.every((e=>e instanceof a.QB)),(()=>"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.cL.registeredVariables)t.push(r.cL.registeredVariables[e])}const s=n?t.filter((e=>!e.trainable)):null,i=t.length;t=t.filter((e=>e.trainable)),o.Uc(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:c}=r.cL.gradients(e,t,null,!0);o.Uc(c.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.Uc(0===u.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${u.rank} tensor`));const l={};return t.forEach(((e,t)=>{null!=c[t]&&(l[e.name]=c[t])})),null!=s&&s.forEach((e=>l[e.name]=null)),{value:u,grads:l}}function i(e){return r.cL.customGrad(e)}},42840:function(e,t,n){"use strict";n.d(t,{UXy:function(){return dt.UXy},Y93:function(){return dt.Y93},yak:function(){return dt.yak},OMN:function(){return dt.OMN},SE4:function(){return dt.SE4},u8Z:function(){return dt.u8Z},YdD:function(){return dt.YdD},IBO:function(){return dt.IBO},ovQ:function(){return dt.ovQ},Kgs:function(){return dt.Kgs},ILp:function(){return dt.ILp},oNL:function(){return dt.oNL},s1o:function(){return dt.s1o},cL:function(){return dt.cL},ITk:function(){return dt.ITk},wre:function(){return dt.wre},CSC:function(){return dt.CSC},S4W:function(){return dt.S4W},Sye:function(){return dt.Sye},EV6:function(){return dt.EV6},M3o:function(){return dt.M3o},eCV:function(){return dt.eCV},orO:function(){return dt.orO},Utj:function(){return dt.Utj},OeR:function(){return dt.OeR},Oe9:function(){return dt.Oe9},sXm:function(){return dt.sXm},SmE:function(){return dt.SmE},usi:function(){return dt.usi},a_P:function(){return dt.a_P},OHx:function(){return dt.OHx},Mz5:function(){return dt.Mz5},WE3:function(){return dt.WE3},QjG:function(){return dt.QjG},ygG:function(){return dt.ygG},EHc:function(){return dt.EHc},YZ3:function(){return dt.YZ3},WO0:function(){return dt.WO0},yuV:function(){return dt.yuV},gBx:function(){return dt.gBx},iaN:function(){return sr.i},COo:function(){return dt.COo},OEe:function(){return dt.OEe},Fql:function(){return dt.Fql},eKw:function(){return dt.eKw},yoD:function(){return dt.yoD},uIb:function(){return dt.uIb},I7R:function(){return dt.I7R},c1F:function(){return dt.c1F},cFK:function(){return dt.cFK},IBu:function(){return dt.IBu},_2b:function(){return dt._2b},wP9:function(){return dt.wP9},Oyk:function(){return dt.Oyk},Ooc:function(){return dt.Ooc},_s9:function(){return dt._s9},ox3:function(){return dt.ox3},IbD:function(){return dt.IbD},MrP:function(){return dt.MrP},mkE:function(){return dt.mkE},MnI:function(){return dt.MnI},ELw:function(){return dt.ELw},WmE:function(){return dt.WmE},_6e:function(){return dt._6e},Qxm:function(){return dt.Qxm},S4v:function(){return dt.S4v},Mjd:function(){return dt.Mjd},SOJ:function(){return dt.SOJ},UV:function(){return dt.UV},o3B:function(){return dt.o3B},QD:function(){return dt.QD},OAQ:function(){return dt.OAQ},oPg:function(){return dt.oPg}
2,EV7:function(){return dt.EV7},iwm:function(){return dt.iwm},aMl:function(){return dt.aMl},OiK:function(){return dt.OiK},qe$:function(){return sr.qe},wfw:function(){return dt.wfw},SAF:function(){return dt.SAF},Mb$:function(){return dt.Mb$},GoJ:function(){return dt.GoJ},SMP:function(){return dt.SMP},Kst:function(){return dt.Kst},qwJ:function(){return dt.qwJ},eg6:function(){return dt.eg6},SSA:function(){return dt.SSA},_S1:function(){return dt.qe$},whD:function(){return dt.whD},cnd:function(){return dt.cnd},aUJ:function(){return dt.aUJ},MNi:function(){return dt.MNi},C4i:function(){return dt.C4i},amh:function(){return dt.amh},AdS:function(){return dt.AdS},yqo:function(){return dt.yqo},qik:function(){return dt.qik},iN$:function(){return dt.iN$},WW2:function(){return dt.WW2},sly:function(){return dt.sly},C6u:function(){return dt.C6u},InO:function(){return dt.InO},UdG:function(){return dt.UdG},SSu:function(){return dt.SSu},yUy:function(){return dt.yUy},aaw:function(){return dt.aaw},Q7n:function(){return dt.Q7n},q82:function(){return dt.q82},Ki5:function(){return dt.Ki5},mon:function(){return dt.mon},O_l:function(){return dt.O_l},cJi:function(){return dt.cJi},Q8A:function(){return dt.Q8A},sTH:function(){return dt.sTH},cBF:function(){return dt.cBF},e_0:function(){return dt.e_0},KGR:function(){return dt.KGR},sdx:function(){return dt.sdx},wF4:function(){return dt.wF4},EHu:function(){return dt.EHu},U1$:function(){return dt.U1$},uMf:function(){return dt.uMf},Ezp:function(){return dt.Ezp},IHk:function(){return dt.IHk},QwE:function(){return dt.QwE},MvO:function(){return dt.MvO},qaT:function(){return dt.qaT},ewH:function(){return dt.ewH},Co2:function(){return dt.Co2},WCE:function(){return dt.WCE},glo:function(){return dt.glo},qWz:function(){return dt.qWz},I$0:function(){return dt.I$0},o9c:function(){return dt.o9c},qiV:function(){return dt.qiV},wvl:function(){return dt.wvl},M1e:function(){return dt.M1e},PWB:function(){return dt.PWB},ac:function(){return dt.ac},oyM:function(){return dt.oyM},mrT:function(){return dt.mrT},OCc:function(){return dt.OCc},eKt:function(){return dt.eKt},a0o:function(){return dt.a0o},eWt:function(){return dt.eWt},sH1:function(){return dt.sH1},Omm:function(){return dt.Omm},kfs:function(){return dt.kfs},QxB:function(){return dt.QxB},ra4:function(){return dt.ra4},inF:function(){return dt.inF},kDP:function(){return dt.kDP},Sed:function(){return dt.Sed},GSE:function(){return dt.GSE},uI0:function(){return dt.uI0},CM:function(){return dt.CM},Ku3:function(){return dt.Ku3},cB:function(){return dt.cB},MPe:function(){return dt.MPe},YNA:function(){return dt.YNA},Atw:function(){return dt.Atw},UVd:function(){return dt.UVd},srk:function(){return dt.srk},epr:function(){return dt.epr},Yvq:function(){return dt.Yvq},w3A:function(){return ke.w3},Kq3:function(){return ke.Kq},EBb:function(){return dt.EBb},g$J:function(){return dt.g$J},iIN:function(){return dt.iIN},wjp:function(){return dt.wjp},$Up:function(){return dt.$Up},Kyi:function(){return dt.Kyi},YZK:function(){return dt.YZK},imz:function(){return dt.imz},QBX:function(){return ke.QB},qKC:function(){return dt.qKC},gHH:function(){return dt.gHH},WQq:function(){return jt.WQq},q2x:function(){return jt.q2x},cxb:function(){return u},QtV:function(){return jt.QtV},Cet:function(){return jt.Cet},qm_:function(){return pt},aW8:function(){return a},cz0:function(){return jt.cz0},WM5:function(){return jt.WM5},Qjg:function(){return jt.Qjg},ctR:function(){return jt.ctR},WUr:function(){return jt.WUr},QlL:function(){return jt.QlL},gLu:function(){return jt.gLu},Mtx:function(){return _e.Mt},MbH:function(){return jt.MbH},sn1:function(){return _e.sn},_K2:function(){return p._K},oNF:function(){return jt.oNF},aW5:function(){return jt.aW5},ymW:function(){return jt.ymW},EJ6:function(){return o},c$0:function(){return jt.c$0},io:function(){return r},Oi1:function(){return _e.Oi},lKA:function(){return c},_o$:function(){return jt._o$},kvL:function(){return jt.kvL},_SL:function(){return jt._SL},E7T:function(){return jt.E7T},KUd:function(){return jt.KUd},eui:function(){return jt.eui},ohm:function(){return _e.oh},gJo:function(){return _e.gJ},qe5:function(){return ht.qe},wDQ:function(){return jt.wDQ},OoG:function(){return jt.OoG},SgB:function(){return jt.SgB},KGH:function(){return Nt},Kd4:function(){return jt.Kd4},yOC:function(){return _e.yO},_CL:function(){return jt._CL},SME:function(){return jt.SME},msk:function(){return jt.msk},sL:function(){return s},UhY:function(){return jt.UhY},sLr:function(){return jt.sLr},Qfh:function(){return jt.Qfh},AT$:function(){return jt.AT$},mwg:function(){return jt.mwg},SC3:function(){return jt.SC3},Enf:function(){return jt.Enf},Av9:function(){return jt.Av9},IFH:function(){return jt.IFH},G6I:function(){return _e.G6},CUy:function(){return jt.CUy},oLj:function(){return jt.oLj},iqB:function(){return jt.iqB},OAw:function(){return qt.OA},euu:function(){return y},DjU:function(){return jt.DjU}});var r={};n.r(r),n.d(r,{CompositeArrayBuffer:function(){return b},browserFiles:function(){return Ke},browserHTTPRequest:function(){return rt},concatenateArrayBuffers:function(){return N},copyModel:function(){return de},decodeWeights:function(){return x},encodeWeights:function(){return k},fromMemory:function(){return it},fromMemorySync:function(){return ut},getLoadHandlers:function(){return L},getModelArtifactsForJSON:function(){return A},getModelArtifactsForJSONSync:function(){return E},getModelArtifactsInfoForJSON:function(){return F},getSaveHandlers:function(){return $},getWeightSpecs:function(){return D},http:function(){return nt},isHTTPScheme:function(){return et},listModels:function(){return le},loadWeights:function(){return Je},moveModel:function(){return he},registerLoadRouter:function(){return R},registerSaveRouter:function(){return P},removeModel:function(){return pe},weightsLoaderFactory:function(){return Ze},withSaveHandler:function(){return ct},withSaveHandlerSync:function(){return lt}});var a={};n.r(a),n.d(a,{draw:function(){return _t},fromPixels:function(){return It},fromPixelsAsync:function(){return vt},toPixels:function(){return xt}});var o={};n.r(o),n.d(o,{prepareAndValidate:function(){return St}});var s={};n.r(s),n.d(s,{assertParamsValid:function(){return Et},computeFlatOffset:function(){return Ut},computeOutShape:function(){return Ft},getNormalizedAxes:function(){return Pt},isSliceContinous:function(){return Bt},maskToAxes:function(){return At},parseSliceParams:function(){return Ht},sliceInfo:function(){return Vt},startForAxis:function(){return Wt},startIndicesWithElidedDims:function(){return Rt},stopForAxis:function(){return zt},stopIndicesWithElidedDims:function(){return $t},stridesForAxis:function(){return Lt},stridesWithElidedDims:function(){return Dt}});var i={};n.r(i),n.d(i,{collectGatherOpShapeInfo:function(){return tr},computeOutShape:function(){return er},segOpComputeOptimalWindowSize:function(){return Xn}});var u={};n.r(u),n.d(u,{ERF_A1:function(){return gn},ERF_A2:function(){return yn},ERF_A3:function(){return bn},ERF_A4:function(){return wn},ERF_A5:function(){return vn},ERF_P:function(){return mn},PARALLELIZE_THRESHOLD:function(){return an},RowPartitionType:function(){return Jt},SELU_SCALE:function(){return fn},SELU_SCALEALPHA:function(){return hn},applyActivation:function(){return Xt.il},assertAndGetBroadcastShape:function(){return pt.assertAndGetBroadcastShape},assertAxesAreInnerMostDims:function(){return Kt.eO},assertParamsConsistent:function(){return Qt},assignToTypedArray:function(){return Mn},axesAreInnerMostDims:function(){return Kt.KQ},calculateShapes:function(){return Nt.calculateShapes},checkEinsumDimSizes:function(){return Rn},checkPadOnDimRoundingMode:function(){return Zt.YV},combineLocations:function(){return Kt.Wu},combineRaggedTensorToTensorShapes:function(){return en},complexWithEvenIndex:function(){return In},complexWithOddIndex:function(){return Sn},computeConv2DInfo:function(){return Zt.S4},computeConv3DInfo:function(){return Zt.QR},computeDefaultPad:function(){return Zt.Kq},computeDilation2DInfo:function(){return Zt.br},computeOptimalWindowSize:function(){return on},computeOutAndReduceShapes:function(){return Kt.q0},computeOutShape:function(){return Yt},computePool2DInfo:function(){return Zt.ZB},computePool3DInfo:function(){return Zt.ye}
2,convertConv2DDataFormat:function(){return Zt.QN},decodeEinsumEquation:function(){return Cn},eitherStridesOrDilationsAreOne:function(){return Zt.uo},expandShapeToKeepDim:function(){return Kt.Mp},exponent:function(){return En},exponents:function(){return Tn},fromStringArrayToUint8:function(){return rr},fromUint8ToStringArray:function(){return nr},getAxesPermutation:function(){return Kt.mZ},getBroadcastDims:function(){return pt.getBroadcastDims},getComplexWithIndex:function(){return Nn},getEinsumComputePath:function(){return $n},getEinsumPermutation:function(){return Pn},getFusedBiasGradient:function(){return Xt.Ql},getFusedDyActivation:function(){return Xt.u1},getImageCenter:function(){return sn},getInnerMostAxes:function(){return Kt.sd},getPermuted:function(){return cn},getRaggedRank:function(){return nn},getReductionAxes:function(){return pt.getReductionAxes},getReshaped:function(){return un},getReshapedPermuted:function(){return ln},getRowPartitionTypesHelper:function(){return tn},getSliceBeginCoords:function(){return pn},getSliceSize:function(){return dn},getSparseFillEmptyRowsIndicesDenseShapeMismatch:function(){return Bn},getSparseFillEmptyRowsNegativeIndexErrorMessage:function(){return Un},getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:function(){return Hn},getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:function(){return qn},getSparseReshapeInputOutputMismatchErrorMessage:function(){return Kn},getSparseReshapeInputOutputMultipleErrorMessage:function(){return jn},getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:function(){return Vn},getSparseReshapeNegativeOutputDimErrorMessage:function(){return Gn},getSparseSegmentReductionIndicesOutOfRangeErrorMessage:function(){return Zn},getSparseSegmentReductionNegativeSegmentIdsErrorMessage:function(){return Qn},getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:function(){return Yn},getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:function(){return Jn},getUndoAxesPermutation:function(){return Kt.mI},isIdentityPermutation:function(){return Ln},log:function(){return kn.Y},mergeRealAndImagArrays:function(){return xn},prepareAndValidate:function(){return St},prepareSplitSize:function(){return zn},segment_util:function(){return i},shouldFuse:function(){return Xt.M$},slice_util:function(){return s},splitRealAndImagArrays:function(){return _n},stridesOrDilationsArePositive:function(){return Zt.iC},tupleValuesAreOne:function(){return Zt.mw},upcastType:function(){return qt.OA},validateDefaultValueShape:function(){return rn},validateInput:function(){return Nt.validateInput},validateUpdateShape:function(){return Nt.validateUpdateShape},warn:function(){return kn.m}});var c={};n.r(c),n.d(c,{Wm:function(){return ar.Wm},Mf:function(){return ar.Mf},eQ:function(){return ar.eQ},_U:function(){return or._}});var l=n(31748),p=n(41920);const d=(0,p._K)();d.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.")})),d.registerFlag("IS_BROWSER",(()=>"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope)),d.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),d.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),d.registerFlag("IS_SAFARI",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor))),d.registerFlag("PROD",(()=>!1)),d.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>d.getBool("DEBUG"))),d.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),d.registerFlag("IS_TEST",(()=>!1)),d.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>d.getBool("DEBUG"))),d.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),d.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),d.registerFlag("USE_SETTIMEOUTCUSTOM",(()=>!1));var h=n(44720),f=n(77016),m=n(15952);const g={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};var y=n(10680);class b{static join(e){return new b(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,null==e)return;if(e instanceof Array||(e=[e]),0===(e=e.map((e=>y.isTypedArray(e)?e.buffer:e))).length)return;this.bufferUniformSize=e[0].byteLength;let t=0;for(let n=0;n<e.length;n++){const r=e[n];n!==e.length-1&&r.byteLength!==this.bufferUniformSize&&(this.bufferUniformSize=void 0);const a=t+r.byteLength;this.shards.push({buffer:r,start:t,end:a}),t=a}0===this.shards.length&&(this.byteLength=0),this.byteLength=this.shards[this.shards.length-1].end}slice(e=0,t=this.byteLength){if(0===this.shards.length)return new ArrayBuffer(0);if(e=isNaN(Number(e))?0:e,t=isNaN(Number(t))?0:t,e=Math.max(0,e),(t=Math.min(this.byteLength,t))<=e)return new ArrayBuffer(0);const n=this.findShardForByte(e);if(-1===n)throw new Error(`Could not find start shard for byte ${e}`);const r=new ArrayBuffer(t-e),a=new Uint8Array(r);let o=0;for(let r=n;r<this.shards.length;r++){const n=this.shards[r],s=e+o-n.start,i=o,u=Math.min(t,n.end)-n.start,c=new Uint8Array(n.buffer,s,u-s);if(a.set(c,i),o+=c.length,t<n.end)break}return r}
2findShardForByte(e){if(0===this.shards.length||e<0||e>=this.byteLength)return-1;if(null!=this.bufferUniformSize)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function t(t){return e<t.start?-1:e>=t.end?1:0}if(0===t(this.shards[this.previousShardIndex]))return this.previousShardIndex;const n=function(e,t){let n=0,r=e.length;for(;n<=r;){const a=Math.floor((r-n)/2)+n,o=t(e[a]);if(0===o)return a;o<0?r=a:n=a+1}return-1}(this.shards,t);return-1===n?-1:(this.previousShardIndex=n,this.previousShardIndex)}}var w=n(33296).Buffer;const v=4;async function k(e,t){const n=[],r=[],a=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);for(let o=0;o<a.length;++o){const s=a[o],i=Array.isArray(e)?e[o].tensor:e[s];if("float32"!==i.dtype&&"int32"!==i.dtype&&"bool"!==i.dtype&&"string"!==i.dtype&&"complex64"!==i.dtype)throw new Error(`Unsupported dtype in weight '${s}': ${i.dtype}`);const u={name:s,shape:i.shape,dtype:i.dtype};if("string"===i.dtype){const e=new Promise((async e=>{const t=await i.bytes(),n=t.reduce(((e,t)=>e+t.length),0)+v*t.length,r=new Uint8Array(n);let a=0;for(let e=0;e<t.length;e++){const n=t[e],o=new Uint8Array(new Uint32Array([n.length]).buffer);r.set(o,a),a+=v,r.set(n,a),a+=n.length}e(r)}));r.push(e)}else r.push(i.data());null!=t&&(u.group=t),n.push(u)}return{data:_(await Promise.all(r)),specs:n}}function x(e,t){const n=new b(e),r={};let a,o=0;for(const e of t){const t=e.name,s=e.dtype,i=e.shape,u=(0,m.It)(i);let c;if("quantization"in e){const r=e.quantization;if("uint8"===r.dtype||"uint16"===r.dtype){if(!("min"in r)||!("scale"in r))throw new Error(`Weight ${e.name} with quantization ${r.dtype} doesn't have corresponding metadata min and scale.`)}else{if("float16"!==r.dtype)throw new Error(`Weight ${e.name} has unknown quantization dtype ${r.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);if("float32"!==s)throw new Error(`Weight ${e.name} is quantized with ${r.dtype} which only supports weights of type float32 not ${s}.`)}const i=g[r.dtype],l=n.slice(o,o+u*i),p="uint8"===r.dtype?new Uint8Array(l):new Uint16Array(l);if("float32"===s)if("uint8"===r.dtype||"uint16"===r.dtype){c=new Float32Array(p.length);for(let e=0;e<p.length;e++){const t=p[e];c[e]=t*r.scale+r.min}}else{if("float16"!==r.dtype)throw new Error(`Unsupported quantization type ${r.dtype} for weight type float32.`);void 0===a&&(a=O()),c=a(p)}else{if("int32"!==s)throw new Error(`Unsupported dtype in weight '${t}': ${s}`);if("uint8"!==r.dtype&&"uint16"!==r.dtype)throw new Error(`Unsupported quantization type ${r.dtype} for weight type int32.`);c=new Int32Array(p.length);for(let e=0;e<p.length;e++){const t=p[e];c[e]=Math.round(t*r.scale+r.min)}}o+=u*i}else if("string"===s){const t=(0,m.It)(e.shape);c=[];for(let e=0;e<t;e++){const e=new Uint32Array(n.slice(o,o+v))[0];o+=v;const t=new Uint8Array(n.slice(o,o+e));c.push(t),o+=e}}else{const e=g[s],a=n.slice(o,o+u*e);if("float32"===s)c=new Float32Array(a);else if("int32"===s)c=new Int32Array(a);else if("bool"===s)c=new Uint8Array(a);else{if("complex64"!==s)throw new Error(`Unsupported dtype in weight '${t}': ${s}`);{c=new Float32Array(a);const e=new Float32Array(c.length/2),n=new Float32Array(c.length/2);for(let t=0;t<e.length;t++)e[t]=c[2*t],n[t]=c[2*t+1];const o=(0,f.m)(e,i,"float32"),s=(0,f.m)(n,i,"float32");r[t]=(0,h.c)(o,s),o.dispose(),s.dispose()}}o+=u*e}"complex64"!==s&&(r[t]=(0,f.m)(c,i,s))}return r}function _(e){if(null===e)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0;const n=[];e.forEach((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 I=void 0!==w&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function S(e){return I?w.byteLength(e,"utf8"):new Blob([e]).size}function N(e){return b.join(e)}function M(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function T(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.initializerSignature&&(n.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}function E(e,t,n){const r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(r.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");r.weightSpecs=t,r.weightData=n}return null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(r.initializerSignature=e.initializerSignature),r}async function A(e,t){let n,r;return null!=e.weightsManifest&&([n,r]=await t(e.weightsManifest)),E(e,n,r)}function F(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:S(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:S(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new b(e.weightData).byteLength}}function D(e){const t=[];for(const n of e)t.push(...n.weights);return t}function O(){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;
vendor: 5,003 bytes, line 2
2for(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),o=new Uint32Array(a);for(let a=0;a<r.length;a++){const s=r[a],i=e[n[s>>10]+(1023&s)]+t[s>>10];o[a]=i}return new Float32Array(a)}}class C{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==C.instance&&(C.instance=new C),C.instance}static registerSaveRouter(e){C.getInstance().saveRouters.push(e)}static registerLoadRouter(e){C.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return C.getHandlers(e,"save")}static getLoadHandlers(e,t){return C.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?C.getInstance().loadRouters:C.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const P=e=>C.registerSaveRouter(e),R=e=>C.registerLoadRouter(e),$=e=>C.getSaveHandlers(e),L=(e,t)=>C.getLoadHandlers(e,t),W="tensorflowjs",z="models_store",B="model_info_store";function U(){if(!(0,p._K)().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(z,{keyPath:"modelPath"}),t.createObjectStore(B,{keyPath:"modelPath"})}class V{constructor(e){if(this.indexedDB=U(),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(W,1);r.onupgradeneeded=()=>H(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(z,"readonly"),r=t.objectStore(z).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{t.weightData=b.join(t.weightData);const r=F(t),o=a.transaction(B,"readwrite");let s,i,u=o.objectStore(B);try{s=u.put({modelPath:this.modelPath,modelArtifactsInfo:r})}catch(e){return n(e)}s.onsuccess=()=>{i=a.transaction(z,"readwrite");const s=i.objectStore(z);let c;try{c=s.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r})}catch(e){return n(e)}c.onsuccess=()=>e({modelArtifactsInfo:r}),c.onerror=e=>{u=o.objectStore(B);const t=u.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(c.error)),t.onerror=e=>(a.close(),n(c.error))}},s.onerror=e=>(a.close(),n(s.error)),o.oncomplete=()=>{null==i?a.close():i.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}V.URL_SCHEME="indexeddb://";const G=e=>{return(0,p._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(V.URL_SCHEME)?(t=e.slice(V.URL_SCHEME.length),new V(t)):null;var t};C.registerSaveRouter(G),C.registerLoadRouter(G);class q{constructor(){this.indexedDB=U()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(W,1);n.onupgradeneeded=()=>H(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(B,"readonly"),o=a.objectStore(B).getAll();o.onsuccess=()=>{const t={};for(const e of o.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},o.onerror=e=>(r.close(),t(o.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(V.URL_SCHEME)?t.slice(V.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(W,1);r.onupgradeneeded=()=>H(r),r.onsuccess=()=>{const a=r.result,o=a.transaction(B,"readwrite"),s=o.objectStore(B),i=s.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=s.delete(e),o=()=>{u=a.transaction(z,"readwrite");const r=u.objectStore(z).delete(e);r.onsuccess=()=>t(i.result.modelArtifactsInfo),r.onerror=e=>n(i.error)};r.onsuccess=o,r.onerror=e=>(o(),a.close(),n(i.error))}},i.onerror=e=>(a.close(),n(i.error)),o.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const j="/",K="tensorflowjs_models",Q="info",Y="model_topology",J="weight_specs",Z="weight_data",X="model_metadata";function ee(e){return{info:[K,e,Q].join(j),topology:[K,e,Y].join(j),weightSpecs:[K,e,J].join(j),weightData:[K,e,Z].join(j),modelMetadata:[K,e,X].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)}
2class re{constructor(e){if(!(0,p._K)().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=F(e),a=b.join(e.weightData);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(I)return w.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e<r;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(a));const o={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,initializerSignature:null!=e.initializerSignature?e.initializerSignature:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(o)),{modelArtifactsInfo:r}}catch(e){throw te(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==r)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;const a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){const e=JSON.parse(a);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(t.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}const o=this.LS.getItem(this.keys.weightData);if(null==o)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if(I){const t=w.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(o),t}}re.URL_SCHEME="localstorage://";const ae=e=>{return(0,p._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(re.URL_SCHEME)?(t=e.slice(re.URL_SCHEME.length),new re(t)):null;var t};C.registerSaveRouter(ae),C.registerLoadRouter(ae);class oe{constructor(){(0,m.Uc)((0,p._K)().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),(0,m.Uc)("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+Q;for(let r=0;r<this.LS.length;++r){const a=this.LS.key(r);a.startsWith(t)&&a.endsWith(n)&&(e[ne(a)]=JSON.parse(this.LS.getItem(a)))}return e}async removeModel(e){var t;const n=ee(e=(t=e).startsWith(re.URL_SCHEME)?t.slice(re.URL_SCHEME.length):t);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${e}'`);const r=JSON.parse(this.LS.getItem(n.info));return te(n),r}}const se="://";class ie{constructor(){this.managers={}}static getInstance(){return null==ie.instance&&(ie.instance=new ie),ie.instance}static registerManager(e,t){(0,m.Uc)(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith(se)&&(e=e.slice(0,e.indexOf(se))),(0,m.Uc)(e.length>0,(()=>"scheme must not be an empty string."));const n=ie.getInstance();(0,m.Uc)(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=ie.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(ie.getInstance().managers)}}function ue(e){if(-1===e.indexOf(se))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${ie.getSchemes().join(",")}`);return{scheme:e.split(se)[0],path:e.split(se)[1]}}async function ce(e,t,n=!1){(0,m.Uc)(e!==t,(()=>`Old path and new path are the same: '${e}'`));const r=C.getLoadHandlers(e);(0,m.Uc)(r.length>0,(()=>`Copying failed because no load handler is found for source URL ${e}.`)),(0,m.Uc)(r.length<2,(()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`));const a=r[0],o=C.getSaveHandlers(t);(0,m.Uc)(o.length>0,(()=>
2`Copying failed because no save handler is found for destination URL ${t}.`)),(0,m.Uc)(o.length<2,(()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`));const s=o[0],i=ue(e).scheme,u=ue(e).path,c=i===ue(e).scheme,l=await a.load();n&&c&&await ie.getManager(i).removeModel(u);const p=await s.save(l);return n&&!c&&await ie.getManager(i).removeModel(u),p.modelArtifactsInfo}async function le(){const e=ie.getSchemes(),t={};for(const n of e){const e=await ie.getManager(n).listModels();for(const r in e)t[n+se+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 ce(e,t,!1)}async function he(e,t){return ce(e,t,!0)}var fe=n(68744);class me{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw 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)}setTimeoutCustom(e,t){"undefined"!=typeof window&&(0,p._K)().getBool("USE_SETTIMEOUTCUSTOM")?(this.functionRefs.push(e),setTimeout((()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")}),t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",(e=>{e.source===window&&e.data.name===this.messageName&&(e.stopPropagation(),(0,this.functionRefs[e.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0))}),!0))):setTimeout(e,t)}isTypedArray(e){return(0,fe.a)(e)}}if((0,p._K)().get("IS_BROWSER")){(0,p._K)().setPlatform("browser",new me);try{ie.registerManager(re.URL_SCHEME,new oe)}catch(e){}try{ie.registerManager(V.URL_SCHEME,new q)}catch(e){}}let ge;(0,p._K)().get("IS_NODE")&&!(0,p._K)().get("IS_BROWSER")&&(0,p._K)().setPlatform("node",new class{constructor(){this.util=n(18688),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=(0,p._K)().global.fetch?(0,p._K)().global.fetch(e,t):(null==ge&&(ge=n(24748)),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)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}});var ye=n(9653),be=n(6356),we=n(98400),ve=n(90800),ke=n(74364);(0,l.Y$)();const xe={buffer:ye.c,cast:be.W,clone:we.c,print:ve.S};(0,ke.O8)(xe);var _e=n(8244),Ie=n(67160),Se=n(95660),Ne=n(9344),Me=n(2992),Te=n(82916),Ee=n(50216),Ae=n(18640),Fe=n(12988);const De=new Map,Oe=new Map;class Ce{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class Pe{constructor(){this.classNameMap={}}static getMap(){return null==Pe.instance&&(Pe.instance=new Pe),Pe.instance}static register(e){Pe.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function Re(e,t,n){(0,m.Uc)(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),(0,m.Uc)("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),(0,m.Uc)(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),void 0===t&&(t="Custom"),void 0===n&&(n=e.className);const r=t+">"+n;return Pe.register(e),De.set(r,e),Oe.set(e,r),e}class $e extends Ce{minimize(e,t=!1,n){const{value:r,grads:a}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:a[e.name]})));this.applyGradients(e)}else this.applyGradients(a);return(0,_e.Mt)(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,Ae.u)(e,t)}dispose(){null!=this.iterations_&&(0,_e.Mt)(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:(0,Fe.
2S)(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($e,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});var Le=n(86381),We=n(94380),ze=n(90256),Be=n(84320),Ue=n(50032);class He extends $e{static get className(){return"SGD"}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=l.cL.registeredVariables[t];(0,_e.G6)((()=>{const e=(0,Ie.W)((0,Ne.E)(this.c,r),a);a.assign(e)}))})),this.incrementIterations()}setLearningRate(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(0,_e.Oi)((0,Fe.S)(-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)}}const Ve=[class extends $e{static get className(){return"Adadelta"}constructor(e,t,n=null){super(),this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=l.cL.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=l.cL.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:(0,_e.G6)((()=>(0,Ee.E)(r).variable(!1)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:(0,_e.G6)((()=>(0,Ee.E)(r).variable(!1)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const o=this.accumulatedGrads[n].variable,s=this.accumulatedUpdates[n].variable;(0,_e.G6)((()=>{const e=(0,Ie.W)((0,Ne.E)(o,this.rho),(0,Ne.E)((0,Te.Q)(a),1-this.rho)),t=(0,Ne.E)((0,Se.M)((0,Me._)((0,Ie.W)(s,this.epsilon)),(0,Me._)((0,Ie.W)(o,this.epsilon))),a),n=(0,Ie.W)((0,Ne.E)(s,this.rho),(0,Ne.E)((0,Te.Q)(t),1-this.rho));o.assign(e),s.assign(n);const i=(0,Ie.W)((0,Ne.E)(t,-this.learningRate),r);r.assign(i)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&((0,_e.Mt)(this.accumulatedGrads.map((e=>e.variable))),(0,_e.Mt)(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(!1)}))),this.accumulatedUpdates=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}},class extends $e{static get className(){return"Adagrad"}constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=l.cL.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:(0,_e.G6)((()=>(0,Le.y)(r.shape,this.initialAccumulatorValue).variable(e)))}}const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const o=this.accumulatedGrads[n].variable;(0,_e.G6)((()=>{const e=(0,Ie.W)(o,(0,Te.Q)(a));o.assign(e);const t=(0,Ie.W)((0,Ne.E)((0,Se.M)(a,(0,Me._)((0,Ie.W)(e,l.cL.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&(0,_e.Mt)(this.accumulatedGrads.map((e=>e.variable)))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map((e=>({name:e.originalName,tensor:e.variable}
2))))}async setWeights(e){e=await this.extractIterations(e),this.accumulatedGrads=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}},class extends $e{static get className(){return"Adam"}constructor(e,t,n,r=null){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],(0,_e.G6)((()=>{this.accBeta1=(0,Fe.S)(t).variable(),this.accBeta2=(0,Fe.S)(n).variable()})),null==r&&(this.epsilon=l.cL.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);(0,_e.G6)((()=>{const n=(0,ze.A)(1,this.accBeta1),r=(0,ze.A)(1,this.accBeta2);t.forEach(((t,a)=>{const o=l.cL.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:(0,_e.G6)((()=>(0,Ee.E)(o).variable(!1)))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:(0,_e.G6)((()=>(0,Ee.E)(o).variable(!1)))});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const i=this.accumulatedFirstMoment[a].variable,u=this.accumulatedSecondMoment[a].variable,c=(0,Ie.W)((0,Ne.E)(i,this.beta1),(0,Ne.E)(s,1-this.beta1)),p=(0,Ie.W)((0,Ne.E)(u,this.beta2),(0,Ne.E)((0,Te.Q)(s),1-this.beta2)),d=(0,Se.M)(c,n),h=(0,Se.M)(p,r);i.assign(c),u.assign(p);const f=(0,Ie.W)((0,Ne.E)((0,Se.M)(d,(0,Ie.W)((0,Me._)(h),this.epsilon)),-this.learningRate),o);o.assign(f)})),this.accBeta1.assign((0,Ne.E)(this.accBeta1,this.beta1)),this.accBeta2.assign((0,Ne.E)(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&(0,_e.Mt)(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&(0,_e.Mt)(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,_e.G6)((()=>{this.accBeta1.assign((0,We.g)(this.beta1,this.iterations_+1)),this.accBeta2.assign((0,We.g)(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(!1)}))),this.accumulatedSecondMoment=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}},class extends $e{static get className(){return"Adamax"}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,_e.G6)((()=>{this.iteration=(0,Fe.S)(0).variable(),this.accBeta1=(0,Fe.S)(t).variable()})),null==r&&(this.epsilon=l.cL.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);(0,_e.G6)((()=>{const n=(0,ze.A)(1,this.accBeta1),r=(0,Se.M)(-this.learningRate,(0,Ie.W)((0,Ne.E)(this.iteration,this.decay),1));t.forEach(((t,a)=>{const o=l.cL.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:(0,Ee.E)(o).variable(!1)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:(0,Ee.E)(o).variable(!1)});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const i=this.accumulatedFirstMoment[a].variable,u=this.accumulatedWeightedInfNorm[a].variable,c=(0,Ie.W)((0,Ne.E)(i,this.beta1),(0,Ne.E)(s,1-this.beta1)),p=(0,Ne.E)(u,this.beta2),d=(0,Be.a)(s),h=(0,Ue.W)(p,d);i.assign(c),u.assign(h);const f=(0,Ie.W)((0,Ne.E)((0,Se.M)(r,n),(0,Se.M)(c,(0,Ie.W)(h,this.epsilon))),o);o.assign(f)})),this.iteration.assign((0,Ie.W)(this.iteration,1)),this.accBeta1.assign((0,Ne.E)(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&(0,_e.Mt)(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&(0,_e.Mt)(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)}},class extends He{static get className(){return"Momentum"}constructor(e,t,n=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=(0,Fe.
2S)(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=l.cL.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:(0,_e.G6)((()=>(0,Ee.E)(r).variable(e)))}}const a=this.accumulations[n].variable,o=Array.isArray(e)?e[n].tensor:e[t];null!=o&&(0,_e.G6)((()=>{let e;const t=(0,Ie.W)((0,Ne.E)(this.m,a),o);e=this.useNesterov?(0,Ie.W)((0,Ne.E)(this.c,(0,Ie.W)(o,(0,Ne.E)(t,this.m))),r):(0,Ie.W)((0,Ne.E)(this.c,t),r),a.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&(0,_e.Mt)(this.accumulations.map((e=>e.variable)))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),this.accumulations=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}},class extends $e{static get className(){return"RMSProp"}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=l.cL.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=l.cL.registeredVariables[t],a=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:(0,_e.G6)((()=>(0,Ee.E)(r).variable(a)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:(0,_e.G6)((()=>(0,Ee.E)(r).variable(a)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:(0,_e.G6)((()=>(0,Ee.E)(r).variable(a)))});const o=Array.isArray(e)?e[n].tensor:e[t];if(null==o)return;const s=this.accumulatedMeanSquares[n].variable,i=this.accumulatedMoments[n].variable;(0,_e.G6)((()=>{const e=(0,Ie.W)((0,Ne.E)(s,this.decay),(0,Ne.E)((0,Te.Q)(o),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,a=(0,Ie.W)((0,Ne.E)(t,this.decay),(0,Ne.E)(o,1-this.decay)),u=(0,Se.M)((0,Ne.E)(o,this.learningRate),(0,Me._)((0,ze.A)(e,(0,Ie.W)((0,Te.Q)(a),this.epsilon)))),c=(0,Ie.W)((0,Ne.E)(i,this.momentum),u);s.assign(e),t.assign(a),i.assign(c);const l=(0,ze.A)(r,c);r.assign(l)}else{const e=(0,Ie.W)((0,Ne.E)(s,this.decay),(0,Ne.E)((0,Te.Q)(o),1-this.decay)),t=(0,Ie.W)((0,Ne.E)(i,this.momentum),(0,Se.M)((0,Ne.E)(o,this.learningRate),(0,Me._)((0,Ie.W)(e,this.epsilon))));s.assign(e),i.assign(t);const n=(0,ze.A)(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&(0,_e.Mt)(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&(0,_e.Mt)(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&(0,_e.Mt)(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)}},He];function Ge(e){return new Promise((e=>setTimeout(e))).then(e)}
vendor: 4,231 bytes, line 2
2class qe{constructor(e){if(!(0,p._K)().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(qe.URL_SCHEME)&&(e=e.slice(qe.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=b.join(e.weightData),n=window.URL.createObjectURL(new Blob([t],{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 t=T(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(t)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await Ge((()=>a.dispatchEvent(new MouseEvent("click")))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=n,await Ge((()=>e.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:F(e)}}}}qe.URL_SCHEME="downloads://";class je{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 o=A(r,(e=>this.loadWeights(e)));e(o)},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]))}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=>M(e.name))),r={};for(const a of e)a.paths.forEach((e=>{const a=M(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 Ke(e){return new je(e)}function Qe(e,t,n,r){!function(e){(0,m.Uc)(null!=e&&Array.isArray(e)&&e.length>0,(()=>"promises must be a none empty array"))}(e),function(e,t){(0,m.Uc)(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`)),(0,m.Uc)(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`)),(0,m.Uc)(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((o=>(o.then((o=>{const s=n+ ++a/e.length*(r-n);return t(s),o})),o))))}async function Ye(e,t){null==t&&(t={});const n=null==t.fetchFunc?(0,p._K)().platform.fetch:t.fetchFunc,r=e.map((e=>n(e,t.requestInit,{isBinary:!0}))),a=(null==t.onProgress?await Promise.all(r):await Qe(r,t.onProgress,0,.5)).map((e=>e.arrayBuffer()));return null==t.onProgress?await Promise.all(a):await Qe(a,t.onProgress,.5,1)}async function Je(e,t="",n,r){return Ze((e=>Ye(e,{requestInit:r}
2)))(e,t,n)}function Ze(e){return async(t,n="",r)=>{const a=t.map((()=>!1)),o={},s=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,c=g[u]*m.It(e.shape),l=()=>{a[t]=!0,null==o[t]&&(o[t]=[]),o[t].push({manifestEntry:e,groupOffset:n,sizeBytes:c})};null!=r?r.forEach(((t,n)=>{t===e.name&&(l(),s[n]=!0)})):l(),i.push(e.name),n+=c}))})),!s.every((e=>e))){const e=r.filter(((e,t)=>!s[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)),[]),c=[];u.forEach((e=>{t[e].paths.forEach((e=>{const t=n+(n.endsWith("/")?"":"/")+e;c.push(t)}))}));const l=await e(c),p={};let d=0;return u.forEach((e=>{const n=t[e].paths.length,r=new b(l.slice(d,d+n));o[e].forEach((e=>{const t=x(r.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)p[e]=t[e]})),d+=n})),p}}C.registerSaveRouter((e=>(0,p._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(qe.URL_SCHEME)?function(e="model"){return new qe(e)}(e.slice(qe.URL_SCHEME.length)):null));class Xe{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,m.Uc)("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,p._K)().platform.fetch,(0,m.Uc)(null!=e&&e.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(e)&&(0,m.Uc)(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=T(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);if(t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData){const n=b.join(e.weightData);t.body.append("model.weights.bin",new Blob([n],{type:"application/octet-stream"}),"model.weights.bin")}const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:F(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 A(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("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}(t),a=this.weightPathPrefix||n,o=D(e),s=[],i=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?i.push(this.weightUrlConverter(e)):s.push(a+e+r);return this.weightUrlConverter&&s.push(...await Promise.all(i)),[o,await Ye(s,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress})]}}function et(e){return null!=e.match(Xe.URL_SCHEME_REGEX)}Xe.URL_SCHEME_REGEX=/^https?:\/\//;const tt=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every((e=>et(e))):et(e),n)return nt(e,t)}return null};function nt(e,t){return new Xe(e,t)}function rt(e,t){return nt(e,t)}C.registerSaveRouter(tt),C.registerLoadRouter(tt);class at{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}
2class ot{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class st{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function it(e,t,n,r){return new st(ut(...arguments))}function ut(e,t,n,r){return 1===arguments.length?null!=e.modelTopology||null!=e.weightSpecs?new at(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 at({modelTopology: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 at({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}function ct(e){return new ot(e)}function lt(e){return new ot(e)}var pt=n(74144),dt=n(38128),ht=n(28616),ft=n(72180),mt=n(17336),gt=n(9556);let yt,bt=!1;function wt(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,o=!1,s=!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)o=!0;else if(null!=e.getContext)s=!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(null!=(0,ht.G)(dt.QjT,l.cL.backendName)){const n={pixels:e},r={numChannels:t};return l.cL.runKernel(dt.QjT,n,r)}const[u,c]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let p,d;if(s)p=e.getContext("2d").getImageData(0,0,u,c).data;else if(r||n)p=e.data;else if(o||a||i){if(null==yt)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");yt=new OffscreenCanvas(1,1).getContext("2d")}else yt=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});yt.canvas.width=u,yt.canvas.height=c,yt.drawImage(e,0,0,u,c),p=yt.getImageData(0,0,u,c).data}if(4===t)d=new Int32Array(p);else{const e=u*c;d=new Int32Array(e*t);for(let n=0;n<e;n++)for(let e=0;e<t;++e)d[n*t+e]=p[4*n+e]}const h=[c,u,t];return(0,gt.A)(d,h,"int32")}async function vt(e,t=3){let n=null;if((0,p._K)().getBool("WRAP_TO_IMAGEBITMAP")&&function(e){return"undefined"!=typeof window&&"undefined"!=typeof ImageBitmap&&window.hasOwnProperty("createImageBitmap")&&!(e instanceof ImageBitmap)&&function(e){return null!=e&&0!==e.width&&0!==e.height}(e)&&!function(e){return null!=e&&e.data instanceof Uint8Array}(e)}(e)){let t;try{t=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch(e){t=null}n=null!=t&&t.width===e.width&&t.height===e.height?t:e}else n=e;return wt(n,t)}function kt(e){if(2!==e.rank&&3!==e.rank)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${e.rank}.`);const t=2===e.rank?1:e.shape[2];if(t>4||2===t)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${t}`);if("float32"!==e.dtype&&"int32"!==e.dtype)throw new Error(`Unsupported type for toPixels: ${e.dtype}. Please use float32 or int32 tensors.`)}async function xt(e,t){let n=(0,ft.ay)(e,"img","toPixels");if(!(e instanceof ke.w3)){const e=n;n=(0,be.W)(e,"int32"),e.dispose()}kt(n);const[r,a]=n.shape.slice(0,2),o=2===n.rank?1:n.shape[2],s=await n.data(),i="float32"===n.dtype?255:1,u=new Uint8ClampedArray(a*r*4);for(let e=0;e<r*a;++e){const t=[0,0,0,255];for(let r=0;r<o;r++){const a=s[e*o+r];
2if("float32"===n.dtype){if(a<0||a>1)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===o?(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){bt||null!=(0,ht.G)(dt.IBu,l.cL.backendName)&&(console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."),bt=!0),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}function _t(e,t,n){let r=(0,ft.ay)(e,"img","draw");if(!(e instanceof ke.w3)){const e=r;r=(0,be.W)(e,"int32"),e.dispose()}kt(r),function(e){const t=(null==e?void 0:e.alpha)||1;if(t>1||t<0)throw new Error(`Alpha value ${t} is suppoed to be in range [0 - 1].`)}(null==n?void 0:n.imageOptions);const a={image:r},o={canvas:t,options:n};l.cL.runKernel(dt.IBu,a,o)}const It=(0,mt.op)({fromPixels_:wt});function St(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,m.It)(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,o=a[a.length-1];let s=1;for(let e=0;e<a.length-1;++e)s*=a[e];const i=e.shape,u=a.slice();u.pop();let c=1;for(let e=o;e<n;++e)c*=i[e],u.push(i[e]);const l=[...(0,m.gH)(e.shape).map((e=>e/c)),1].slice(0,o);return[u,s,c,l]}var Nt=n(65e3);const Mt=-2,Tt=-1;function Et(e,t,n){const r=e.shape.length;m.Uc(r===t.length,(()=>`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),m.Uc(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<r;++a)m.Uc(t[a]+n[a]<=e.shape[a],(()=>`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`))}function At(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function Ft(e,t,n){const r=[];for(let a=0;a<e.length;a++)r[a]=Math.ceil((t[a]-e[a])/n[a]);return r}function Dt(e,t,n,r){const a=[...e];for(let e=a.length;e<r.length;e++)a.push(1);for(let e=0;e<n;e++)0===e?a[t]=1:(a.splice(t,0,1),a.pop());return a}function Ot(e,t,n){return n<=e?n:n-(t-1)}function Ct(e,t){const n=[];for(let r=0;r<e;r++)n.push(t+r);return n}function Pt(e,t,n,r,a,o,s,i,u){const c=e.length;let l=new Array(c),p=new Array(c),d=new Array(c);if(t.length&&n>0){const u=t[0],c=n+1;l=Rt(s,u,c,r,e),p=$t(i,u,c,a,e),d=Dt(o,u,c,e)}else for(let t=0;t<c;t++)l[t]=Wt(s,r,o,e,t,u),p[t]=zt(i,a,o,e,t,u),d[t]=Lt(o,t,u);return{begin:l,end:p,strides:d}}function Rt(e,t,n,r,a){const o=[...a],s=Ct(n,t);for(let a=0;a<o.length;a++)if(s.indexOf(a)>-1)o[a]=0;else{const s=Ot(t,n,a);let i=r[s];e&1<<s&&(i=0),o[a]=i}return o}function $t(e,t,n,r,a){const o=[...a],s=Ct(n,t);for(let a=0;a<o.length;a++)if(s.indexOf(a)>-1)o[a]=Number.MAX_SAFE_INTEGER;else{const s=Ot(t,n,a);let i=r[s];e&1<<s&&(i=Number.MAX_SAFE_INTEGER),o[a]=i}for(let e=0;e<o.length;e++){const t=a[e];o[e]<0&&(o[e]+=t),o[e]=m.qk(0,o[e],a[e])}return o}function Lt(e,t,n){let r=e[t];return(n&1<<t||null==r)&&(r=1),r}function Wt(e,t,n,r,a,o){let s=t[a];const i=n[a]||1;(e&1<<a||o&1<<a||null==s)&&(s=i>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=m.qk(0,s,u-1),s}function zt(e,t,n,r,a,o){let s=t[a];const i=n[a]||1;(e&1<<a||o&1<<a||null==s)&&(s=i>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=i>0?m.qk(0,s,u):m.qk(-1,s,u-1),s}function Bt(e,t,n){let r=n.length;for(let e=0;e<n.length;e++)if(n[e]>1){r=e;break}for(let a=r+1;a<n.length;a++)if(t[a]>0||n[a]!==e[a])return!1;return!0}function Ut(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function Ht(e,t,n){let r;const a=e.shape.length;let o;return r="number"==typeof t?[t,...new Array(a-1).fill(0)]:t.length<a?t.concat(new Array(a-t.length).fill(0)):t.slice(),r.forEach((e=>{m.Uc(-1!==e,(()=>"slice() does not support negative begin indexing."))})),o=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.length<a?n.concat(new Array(a-n.length).fill(-1)):n,o=o.map(((t,n)=>t>=0?t:(m.Uc(-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,o]}function Vt(e,t,n,r,a,o,s,i,u){let c;if(null==r?(c=new Array(t.length),c.fill(1)):c=r,null!=s&&0!=(s&s-1))throw new Error("Multiple ellipses in slice is not allowed.");let l=!1;const p={dims:c.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:c.slice(),beginMask:a,endMask:o,ellipsisMask:s,newAxisMask:i,shrinkAxisMask:u};for(let e=0;e<p.dims;
vendor: 5,750 bytes, line 2
2e++)l&&0!=(1<<e&i)&&p.numAddAxisAfterEllipsis++,1<<e&s&&(l=!0);l||(p.ellipsisMask|=1<<p.dims,p.dims++);const d={dims:e.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};!function(e,t){t.beginMask=0,t.endMask=0,t.shrinkAxisMask=0;let n=0;t.beginValid=null!=e.begin,t.endValid=null!=e.end,t.begin=new Array(t.dims),t.end=new Array(t.dims),t.strides=new Array(t.dims),t.finalShapeGatherIndices=[],t.finalShapeGatherIndicesSparse=[],t.inputShapeGatherIndicesSparse=new Array(t.dims);for(let r=0;r<e.dims;r++)if(1<<r&e.ellipsisMask){const a=Math.min(t.dims-(e.dims-r)+1+e.numAddAxisAfterEllipsis,t.dims);for(;n<a;n++)t.begin[n]=0,t.end[n]=0,t.strides[n]=1,t.beginMask|=1<<n,t.endMask|=1<<n,t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(-1),t.inputShapeGatherIndicesSparse[n]=r}else if(1<<r&e.newAxisMask)t.finalShapeGatherIndices.push(Mt),t.finalShapeGatherIndicesSparse.push(-1);else{if(n===t.begin.length)throw Error(`Index out of range using input dim ${n}; input has only ${t.dims} dims, ${t.begin.length}.`);null!=e.begin&&(t.begin[n]=e.begin[r]),null!=e.end&&(t.end[n]=e.end[r]),t.strides[n]=e.strides[r],e.beginMask&1<<r&&(t.beginMask|=1<<n),e.endMask&1<<r&&(t.endMask|=1<<n),e.shrinkAxisMask&1<<r?(t.finalShapeGatherIndices.push(Tt),t.finalShapeGatherIndicesSparse.push(-1),t.shrinkAxisMask|=1<<n):(t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(r)),t.inputShapeGatherIndicesSparse[n]=r,n++}}(p,d);let h=!0,f=!0,m=!0;const g=[],y=[];for(let t=0;t<e.length;++t){if(0===d.strides[t])throw Error(`strides[${t}] must be non-zero`);const n=!!(d.shrinkAxisMask&1<<t),r=e[t];if(-1===r){g.push(n?1:-1);continue}const a=[d.beginMask&1<<t,d.endMask&1<<t],o=[d.strides[t]>0?0:-1,d.strides[t]>0?r:r-1];if(n&&d.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===d.strides[t];const s=!!(d.beginMask&1<<t&&d.endMask&1<<t);if(d.beginValid&&d.endValid){if(n){const e=d.begin[t]<0?r+d.begin[t]:d.begin[t];if(d.begin[t]=e,d.end[t]=d.begin[t]+1,e<0||e>=r)throw Error(`slice index ${d.begin[t]} of dimension ${t} out of bounds.`)}else d.begin[t]=Gt(d.begin[t],0,d.strides[t],r,a,o),d.end[t]=Gt(d.end[t],1,d.strides[t],r,a,o);const e=1===d.strides[t]&&0===d.begin[t]&&d.end[t]===r;h=h&&e,f=f&&(0===t&&1===d.strides[t]||e)}else h=h&&1===d.strides[t]&&s,f=f&&(0===t&&1===d.strides[t]||s);let i,u=!1;if(d.beginValid&&d.endValid?(i=d.end[t]-d.begin[t],u=!0):n?(i=1,u=!0):s&&r>=0&&(i=d.strides[t]<0?-r:r,u=!0),u){let e;e=0===i||i<0!=d.strides[t]<0?0:Math.trunc(i/d.strides[t])+(i%d.strides[t]!=0?1:0),g.push(e)}else g.push(-1)}for(let e=0;e<d.finalShapeGatherIndices.length;++e){const t=d.finalShapeGatherIndices[e];t>=0?y.push(g[t]):t===Mt&&y.push(1)}return{finalShapeSparse:y.filter(((e,t)=>d.finalShapeGatherIndices[t]!==Mt)),finalShape:y,isIdentity:h,sliceDim0:f,isSimpleSlice:m,begin:d.begin,end:d.end,strides:d.strides}}function Gt(e,t,n,r,a,o){if(a[t])return n>0?o[t]:o[t+1&1];{const t=e<0?r+e:e;return t<o[0]?o[0]:t>o[1]?o[1]:t}}var qt=n(22500),jt=n(41932),Kt=n(34752);function Qt(e,t){const n=e[0].length;e.forEach(((e,t)=>{m.Uc(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),m.Uc(t>=0&&t<n,(()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,a)=>{for(let o=0;o<n;o++)m.Uc(o===t||e[o]===r[o],(()=>`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 Yt(e,t){const n=e[0].slice();for(let r=1;r<e.length;r++)n[t]+=e[r][t];return n}var Jt,Zt=n(35044),Xt=n(46120);function en(e,t,n){let r=new Array;if(null==n&&null==t)return r;if(null==t)for(;r.length<e+n.length;)r.push(-1);else r=t.slice();if(null==n)return r;if(e+n.length!==r.length)throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e+n.length}, but shape.rank = ${r.length}`);for(let a=1;a<n.length;++a){const o=n[a],s=r[r.length-n.length+a],i=r[s];if(o>=0)if(i>=0){if(i!==o)throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${a+e}] = ${o} but shape[${a+e}] = ${i}`)}else r[s]=o}return r}function tn(e){const t={FIRST_DIM_SIZE:Jt.FIRST_DIM_SIZE,VALUE_ROWIDS:Jt.VALUE_ROWIDS,ROW_LENGTHS:Jt.ROW_LENGTHS,ROW_SPLITS:Jt.ROW_SPLITS,ROW_LIMITS:Jt.ROW_LIMITS,ROW_STARTS:Jt.ROW_STARTS},n=[];for(const r of e){if(!(r in t))break;n.push(t[r])}return n}function nn(e){return 0===e.length?0:e[0]===Jt.FIRST_DIM_SIZE?e.length-1:e.length}function rn(e,t){if(null==e||null==t)return;const n=e.length,r=t.length;if(n>=r)throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${r})`);for(let a=0;a<Math.min(n,r-1);++a){const n=e[a],r=t[a+1];if(n>=0&&r>=0&&1!==n&&n!==r)throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${a-e.length}] = ${n} but ragged tensor input.flatValues.shape[${a-e.length}] = ${r}`)}}!function(e){e[e.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",e[e.VALUE_ROWIDS=1]="VALUE_ROWIDS",e[e.ROW_LENGTHS=2]="ROW_LENGTHS",e[e.ROW_SPLITS=3]="ROW_SPLITS",e[e.ROW_LIMITS=4]="ROW_LIMITS",e[e.ROW_STARTS=5]="ROW_STARTS"}(Jt||(Jt={}));const an=30;function on(e){return e<=an?e:(0,m.Y_)(e,Math.floor(Math.sqrt(e)))}function sn(e,t,n){return[n*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}function un(e,t,n,r=!0){let a=[];if(r)a=a.concat(t.slice(0)),a.push(e[0]/n),a=a.concat(e.slice(1));else{a=a.concat(e[0]);const n=t.length;for(let r=0;r<n;++r)a=a.concat([e[r+1]/t[r],t[r]]);a=a.concat(e.slice(n+1))}return a}function cn(e,t,n=!0){const r=[];if(n){r.push(t);
vendor: 4,687 bytes, line 2
2for(let n=t+1;n<e;++n)n<=2*t?(r.push(n),r.push(n-(t+1))):r.push(n)}else{const n=[],a=[];for(let r=1;r<e;++r)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 ln(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n<e.length;++n)n<=t.length?r?a.push(t[n-1]*e[n]):a.push(e[n]/t[n-1]):a.push(e[n]);return a}function pn(e,t){const n=[0];for(let r=0;r<t;++r)n.push(e[r][0]);return n}function dn(e,t,n){const r=e.slice(0,1);for(let a=0;a<n;++a)r.push(e[a+1]-t[a][0]-t[a][1]);return r}const hn=1.7580993408473768,fn=1.0507009873554805,mn=.3275911,gn=.254829592,yn=-.284496736,bn=1.421413741,wn=-1.453152027,vn=1.061405429;var kn=n(44327);function xn(e,t){if(e.length!==t.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);const n=new Float32Array(2*e.length);for(let r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}function _n(e){const t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}}function In(e){const t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=0;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}}function Sn(e){const t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=2;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}}function Nn(e,t){return{real:e[2*t],imag:e[2*t+1]}}function Mn(e,t,n,r){e[2*r]=t,e[2*r+1]=n}function Tn(e,t){const n=new Float32Array(e/2),r=new Float32Array(e/2);for(let a=0;a<Math.ceil(e/2);a++){const o=(t?2:-2)*Math.PI*(a/e);n[a]=Math.cos(o),r[a]=Math.sin(o)}return{real:n,imag:r}}function En(e,t,n){const r=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(r),imag:Math.sin(r)}}const An="->",Fn=/->/g,Dn=",",On="...";function Cn(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(Fn,"").length)/An.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 ("${An}").`);const[r,a]=e.split(An);(0,m.Uc)(-1===r.indexOf(On),(()=>`The ellipsis notation ("${On}") is not supported yet.`));const o=r.split(Dn),s=o.length;if(t!==s)throw new Error(`Expected ${s} input tensors, received ${t}`);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const i=[];for(let e=0;e<a.length;++e){const t=a[e];if(!o.some((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<r.length;++e){const t=r[e];-1===i.indexOf(t)&&t!==Dn&&i.push(t)}const u=new Array(o.length);for(let e=0;e<s;++e){if(new Set(o[e].split("")).size!==o[e].length)throw new Error(`Found duplicate axes in input component ${o[e]}. Support for duplicate axes in input is not implemented yet.`);u[e]=[];for(let t=0;t<o[e].length;++t)u[e].push(i.indexOf(o[e][t]))}const c=i.length,l=[];for(let e=a.length;e<c;++e)l.push(e);return{allDims:i,summedDims:l,idDims:u}}function Pn(e,t){let n=new Array(e);n.fill(-1);for(let e=0;e<t.length;++e)n[t[e]]=e;const r=[];for(let t=0;t<e;++t)-1===n[t]&&r.push(t);return n=n.filter((e=>-1!==e)),{permutationIndices:n,expandDims:r}}function Rn(e,t,n){const r=new Array(e);for(let e=0;e<n.length;++e){const a=n[e].shape;for(let n=0;n<t[e].length;++n)void 0===r[t[e][n]]?r[t[e][n]]=a[n]:(0,m.Uc)(r[t[e][n]]===a[n],(()=>`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`))}}function $n(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;e<a;++e)r.push([]);const o=[];for(let e=0;e<n.length;++e){const a=Wn(t,n[e]);for(const t of a)-1===o.indexOf(t)&&(r[e].push(t),o.push(t))}return{path:n,steps:r}}function Ln(e){return e.every(((e,t)=>e===t))}function Wn(e,t){const n=[];for(let r=0;r<e.length;++r)0!==e[r].length&&-1===e[r].indexOf(t)&&-1!==t||n.push(r);return n}function zn(e,t,n=0){let r=[];if("number"==typeof t)(0,m.Uc)(e.shape[n]%t==0,(()=>"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,m.Uc)(a<=1,(()=>"There should be only one negative value in split array."));const o=t.indexOf(-1);if(-1!==o){const r=t.reduce(((e,t)=>t>0?e+t:e));t[o]=e.shape[n]-r}(0,m.Uc)(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 Bn(e){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}`}function Un(e,t){return`indices(${e}
2, 0) is invalid: ${t} < 0`}function Hn(e,t,n){return`indices(${e}, 0) is invalid: ${t} >= ${n}`}function Vn(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function Gn(e,t){return`size ${e} must be non-negative, not ${t}`}function qn(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function jn(e,t){return`Input to reshape is a SparseTensor with ${(0,m.It)(e)}\n dense values, but the requested shape requires a multiple of ${(0,m.It)(t)}. inputShape=${e} outputShape= ${t}`}function Kn(e,t){return`Input to reshape is a tensor with ${(0,m.It)(e)} dense values, but the requested shape has ${(0,m.It)(t)}. inputShape=${e} outputShape=${t}`}function Qn(){return"segment ids must be >= 0"}function Yn(){return"segment ids are not increasing"}function Jn(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function Zn(e,t,n){return`Bad: indices[${e}] == ${t} out of range [0, ${n})`}function Xn(e,t){let n,r=!1;for(e<=an?(n=e,r=!0):n=(0,m.Y_)(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=(0,m.Y_)(e,n+1);return n}function er(e,t,n){const r=[],a=e.length;for(let o=0;o<a;o++)o!==t?r.push(e[o]):r.push(n);return r}function tr(e,t,n,r){const a=t.shape.length,o=e.shape.length;if(0!==r&&(r<-a||r>a))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>o)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${o}).`);if(n<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);for(let n=0;n<r;++n)if(e.shape[n]!==t.shape[n])throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);const s=e.shape[n],i=[];let u=1,c=1,l=1;for(let t=0;t<r;++t)i.push(e.shape[t]),u*=e.shape[t];for(let t=r;t<n;t++)i.push(e.shape[t]),c*=e.shape[t];for(let e=r;e<a;e++)i.push(t.shape[e]);for(let t=n+1;t<o;t++)i.push(e.shape[t]),l*=e.shape[t];return{batchSize:u,sliceSize:l,outerSize:c,dimSize:s,outputShape:i}}function nr(e){try{return e.map((e=>(0,y.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,y.encodeString)(e)))}var ar=n(75941),or=n(13328),sr=n(82756);!function(){for(const e of Ve)Re(e)}()},38128:function(e,t,n){"use strict";n.d(t,{$Up:function(){return an},AdS:function(){return We},Atw:function(){return Jt},C4i:function(){return ze},C6u:function(){return qe},CM:function(){return jt},COo:function(){return H},CSC:function(){return v},Co2:function(){return gt},EBb:function(){return St},EHc:function(){return L},EHu:function(){return pt},ELw:function(){return le},EV6:function(){return x},EV7:function(){return ve},Ezp:function(){return ht},Fql:function(){return G},GSE:function(){return qt},GoJ:function(){return Se},I$0:function(){return xt},I7R:function(){return Q},IBO:function(){return l},IBu:function(){return Z},IHk:function(){return ft},ILp:function(){return h},ITk:function(){return y},IbD:function(){return se},InO:function(){return je},KGR:function(){return ut},Kgs:function(){return d},Ki5:function(){return Je},Kst:function(){return Me},Ku3:function(){return ln},Kyi:function(){return on},M1e:function(){return Mt},M3o:function(){return _},MNi:function(){return Le},MPe:function(){return Qt},Mb$:function(){return Ie},Mjd:function(){return mn},MnI:function(){return ce},MrP:function(){return ie},MvO:function(){return mt},Mz5:function(){return C},OAQ:function(){return we},OCc:function(){return Ft},OEe:function(){return V},OHx:function(){return O},OMN:function(){return s},O_l:function(){return tt},Oe9:function(){return T},OeR:function(){return M},OiK:function(){return _e},Omm:function(){return zt},Ooc:function(){return ae},Oyk:function(){return ne},PWB:function(){return Tt},Q7n:function(){return Xe},Q8A:function(){return at},QD:function(){return ye},QjG:function(){return R},QjT:function(){return pn},QwE:function(){return vt},QxB:function(){return Ut},Qxm:function(){return he},S4W:function(){return b},S4v:function(){return fn},SAF:function(){return Pe},SE4:function(){return i},SMP:function(){return Ne},SOJ:function(){return me},SSA:function(){return Ae},SSu:function(){return Qe},Sed:function(){return Pt},SmE:function(){return A},Sye:function(){return k},U1$:function(){return dt},UV:function(){return fe},UVd:function(){return Zt},UXy:function(){return r},UdG:function(){return Ke},Utj:function(){return N},WCE:function(){return yt},WE3:function(){return P},WO0:function(){return U},WW2:function(){return Ve},WmE:function(){return pe},Y93:function(){return a},YNA:function(){return Yt},YZ3:function(){return W},YZK:function(){return sn},YdD:function(){return c},Yvq:function(){return en},_2b:function(){return ee},_6e:function(){return de},_s9:function(){return re},a0o:function(){return Wt},aMl:function(){return xe},aUJ:function(){return Re},a_P:function(){return D},aaw:function(){return Ze},ac:function(){return Ot},amh:function(){return Be},c1F:function(){return J},cB:function(){return Kt},cBF:function(){return st},cFK:function(){return Y},cJi:function(){return rt},cL:function(){return m},cnd:function(){return Oe},eCV:function(){return I},eKt:function(){return Et},eKw:function(){return q},eWt:function(){return Ct},e_0:function(){return it},eg6:function(){return Ee},epr:function(){return Xt},ewH:function(){return wt},g$J:function(){return tn},gBx:function(){return B},gHH:function(){return hn},glo:function(){return kt},iIN:function(){return nn},iN$:function(){return He},imz:function(){return un},inF:function(){return Vt},iwm:function(){return ke},kDP:function(){return Lt},kfs:function(){return Bt},mkE:function(){return ue},mon:function(){return nt},mrT:function(){return At},o3B:function(){return ge},o9c:function(){return _t},oNL:function(){return f},oPg:function(){return be},orO:function(){return S},ovQ:function(){return p},ox3:function(){return oe},oyM:function(){return Dt},q82:function(){return et},qKC:function(){return cn},qWz:function(){return dn},qaT:function(){return bt},qe$:function(){return Fe},qiV:function(){return It},qik:function(){return $e},qwJ:function(){return Te},ra4:function(){return Ht},s1o:function(){return g},sH1:function(){return $t},sTH:function(){return ot},sXm:function(){return E},sdx:function(){return ct},sly:function(){return Ge},srk:function(){return Rt},u8Z:function(){return u},uI0:function(){return Gt},uIb:function(){return K},uMf:function(){return X},usi:function(){return F},wF4:function(){return lt},wP9:function(){return te},wfw:function(){return Ce},whD:function(){return De},wjp:function(){return rn},wre:function(){return w},wvl:function(){return Nt},yUy:function(){return Ye},yak:function(){return o},ygG:function(){return $},yoD:function(){return j},yqo:function(){return Ue},yuV:function(){return z}});const r="Abs",a="Acos",o="Acosh",s="Add",i="AddN",u="All",c="Any",l="ArgMax",p="ArgMin",d="Asin",h="Asinh",f="Atan",m="Atanh",g="Atan2",y="AvgPool",b="AvgPoolGrad",w="AvgPool3D",v="AvgPool3DGrad",k="BatchMatMul",x="BatchToSpaceND",_="Bincount",I="BitwiseAnd",S="BroadcastArgs",N="Cast",M="Ceil",T="ClipByValue",E="Complex",A="ComplexAbs",F="Concat",D="Conv2D",O="Conv2DBackpropFilter",C="Conv2DBackpropInput",P
2="Conv3D",R="Conv3DBackpropFilterV2",$="Conv3DBackpropInputV2",L="Cos",W="Cosh",z="Cumprod",B="Cumsum",U="CropAndResize",H="DenseBincount",V="DepthToSpace",G="DepthwiseConv2dNative",q="DepthwiseConv2dNativeBackpropFilter",j="DepthwiseConv2dNativeBackpropInput",K="Diag",Q="Dilation2D",Y="Dilation2DBackpropInput",J="Dilation2DBackpropFilter",Z="Draw",X="RealDiv",ee="Einsum",te="Elu",ne="EluGrad",re="Erf",ae="Equal",oe="Exp",se="ExpandDims",ie="Expm1",ue="FFT",ce="Fill",le="FlipLeftRight",pe="Floor",de="FloorDiv",he="FusedBatchNorm",fe="GatherV2",me="GatherNd",ge="Greater",ye="GreaterEqual",be="Identity",we="IFFT",ve="Imag",ke="IsFinite",xe="IsInf",_e="IsNan",Ie="LeakyRelu",Se="Less",Ne="LessEqual",Me="LinSpace",Te="Log",Ee="Log1p",Ae="LogicalAnd",Fe="LogicalNot",De="LogicalOr",Oe="LogicalXor",Ce="LRN",Pe="LRNGrad",Re="Max",$e="Maximum",Le="MaxPool",We="MaxPoolGrad",ze="MaxPool3D",Be="MaxPool3DGrad",Ue="MaxPoolWithArgmax",He="Mean",Ve="Min",Ge="Minimum",qe="MirrorPad",je="Mod",Ke="Multinomial",Qe="Multiply",Ye="Neg",Je="NotEqual",Ze="NonMaxSuppressionV3",Xe="NonMaxSuppressionV4",et="NonMaxSuppressionV5",tt="OnesLike",nt="OneHot",rt="Pack",at="PadV2",ot="Pow",st="Prelu",it="Prod",ut="RaggedGather",ct="RaggedRange",lt="RaggedTensorToTensor",pt="Range",dt="Real",ht="Reciprocal",ft="Relu",mt="Reshape",gt="ResizeNearestNeighbor",yt="ResizeNearestNeighborGrad",bt="ResizeBilinear",wt="ResizeBilinearGrad",vt="Relu6",kt="Reverse",xt="Round",_t="Rsqrt",It="ScatterNd",St="TensorScatterUpdate",Nt="SearchSorted",Mt="Select",Tt="Selu",Et="Slice",At="Sin",Ft="Sinh",Dt="Sign",Ot="Sigmoid",Ct="Softplus",Pt="Sqrt",Rt="Sum",$t="SpaceToBatchND",Lt="SplitV",Wt="Softmax",zt="SparseFillEmptyRows",Bt="SparseReshape",Ut="SparseSegmentMean",Ht="SparseSegmentSum",Vt="SparseToDense",Gt="SquaredDifference",qt="Square",jt="StaticRegexReplace",Kt="StridedSlice",Qt="StringNGrams",Yt="StringSplit",Jt="StringToHashBucketFast",Zt="Sub",Xt="Tan",en="Tanh",tn="Tile",nn="TopK",rn="Transform",an="Transpose",on="Unique",sn="Unpack",un="UnsortedSegmentSum",cn="ZerosLike",ln="Step",pn="FromPixels",dn="RotateWithOffset",hn="_FusedMatMul",fn="FusedConv2D",mn="FusedDepthwiseConv2D"},28616:function(e,t,n){"use strict";n.d(t,{G:function(){return i},Ww:function(){return c},kx:function(){return u},qe:function(){return l}});var r=n(18308),a=n(44327);const o=(0,r.A)("kernelRegistry",(()=>new Map)),s=(0,r.A)("gradRegistry",(()=>new Map));function i(e,t){const n=p(e,t);return o.get(n)}function u(e){return s.get(e)}function c(e){const t=o.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[o,s]=a,[i]=o.split("_");i===e&&n.push(s)}return n}function l(e){const{kernelName:t,backendName:n}=e,r=p(t,n);o.has(r)&&a.m(`The kernel '${t}' for backend '${n}' is already registered`),o.set(r,e)}function p(e,t){return`${t}_${e}`}},44327:function(e,t,n){"use strict";n.d(t,{Y:function(){return o},m:function(){return a}});var r=n(41920);function a(...e){(0,r._K)().getBool("IS_TEST")||(0,r._K)().getBool("PROD")||console.warn(...e)}function o(...e){(0,r._K)().getBool("IS_TEST")||(0,r._K)().getBool("PROD")||console.log(...e)}},84320:function(e,t,n){"use strict";n.d(t,{a:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({abs_:function(e){const t=(0,o.ay)(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return r.cL.runKernel(a.SmE,e)}{const e={x:t};return r.cL.runKernel(a.UXy,e)}}})},67160:function(e,t,n){"use strict";n.d(t,{W:function(){return i}});var r=n(31748),a=n(38128),o=n(4172),s=n(72180);const i=(0,n(17336).op)({add_:function(e,t){let n=(0,s.ay)(e,"a","add"),i=(0,s.ay)(t,"b","add");[n,i]=(0,o.yE)(n,i);const u={a:n,b:i};return r.cL.runKernel(a.OMN,u)}})},34752:function(e,t,n){"use strict";n.d(t,{KQ:function(){return a},Mp:function(){return i},Wu:function(){return o},eO:function(){return u},mI:function(){return l},mZ:function(){return c},q0:function(){return s},sd:function(){return p}});var r=n(15952);function a(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function o(e,t,n){const r=e.length+t.length,a=[];let o=0,s=0;for(let i=0;i<r;i++)-1===n.indexOf(i)?a.push(e[o++]):a.push(t[s++]);return a}function s(e,t){const n=[],r=e.length;for(let a=0;a<r;a++)-1===t.indexOf(a)&&n.push(e[a]);return[n,t.map((t=>e[t]))]}function i(e,t){return o(e,t.map((e=>1)),t)}function u(e,t,n){r.Uc(a(t,n),(()=>`${e}
2 supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function c(e,t){if(a(e,t))return null;const n=[];for(let r=0;r<t;++r)-1===e.indexOf(r)&&n.push(r);return e.forEach((e=>n.push(e))),n}function l(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<t;++r)n.push(r);return n}},74144:function(e,t,n){"use strict";function r(e,t){const n=e.length,r=[];for(let a=0;a<n;a++){const o=n-1-a,s=e[o]||1;(t[t.length-1-a]||1)>1&&1===s&&r.unshift(o)}return r}function a(e,t){const n=[];for(let r=0;r<t.length;r++){const a=e[e.length-r-1],o=t.length-r-1,s=t[o];(null==a||1===a&&s>1)&&n.unshift(o)}return n}function o(e,t){const n=Math.max(e.length,t.length),r=new Array(n);for(let a=0;a<n;a++){let o=e[e.length-a-1];null==o&&(o=1);let s=t[t.length-a-1];if(null==s&&(s=1),1===o)r[n-a-1]=s;else if(1===s)r[n-a-1]=o;else{if(o!==s)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);r[n-a-1]=o}}return r}n.r(t),n.d(t,{assertAndGetBroadcastShape:function(){return o},getBroadcastDims:function(){return r},getReductionAxes:function(){return a}})},9653:function(e,t,n){"use strict";n.d(t,{c:function(){return o}});var r=n(74364),a=n(15952);function o(e,t="float32",n){return t=t||"float32",a.Ix(e),new r.Kq(e,t,n)}},6356:function(e,t,n){"use strict";n.d(t,{W:function(){return i}});var r=n(31748),a=n(38128),o=n(72180),s=n(15952);const i=(0,n(17336).op)({cast_:function(e,t){const n=(0,o.ay)(e,"x","cast");if(!s.FP(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.cL.runKernel(a.Utj,i,u)}})},98400:function(e,t,n){"use strict";n.d(t,{c:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({clone_:function(e){const t={x:(0,o.ay)(e,"x","clone","string_or_numeric")};return r.cL.runKernel(a.oPg,t)}})},44720:function(e,t,n){"use strict";n.d(t,{c:function(){return i}});var r=n(31748),a=n(38128),o=n(72180),s=n(15952);const i=(0,n(17336).op)({complex_:function(e,t){const n=(0,o.ay)(e,"real","complex"),i=(0,o.ay)(t,"imag","complex");s.kl(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.cL.runKernel(a.sXm,u)}})},35044:function(e,t,n){"use strict";n.d(t,{Kq:function(){return c},QN:function(){return y},QR:function(){return u},S4:function(){return i},YV:function(){return b},ZB:function(){return o},br:function(){return a},iC:function(){return g},mw:function(){return f},uo:function(){return m},ye:function(){return s}});var r=n(15952);function a(e,t,n,r,a="NHWC",o){return i(e,[...t,e[3]],n,o,r,null,null,y(a))}function o(e,t,n,r,a,o,s="channelsLast"){const[u,c]=l(t);let p;if("channelsLast"===s)p=[u,c,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);p=[u,c,e[1],e[1]]}return i(e,p,n,r,a,o,!1,s)}function s(e,t,n,r,a,o,s="NDHWC"){const[i,c,l]=p(t);let d,h;if("NDHWC"===s)h="channelsLast",d=[i,c,l,e[4],e[4]];else{if("NCDHW"!==s)throw new Error(`Unknown dataFormat ${s}`);h="channelsFirst",d=[i,c,l,e[1],e[1]]}return u(e,d,n,r,a,!1,h,o)}function i(e,t,n,r,a,o,s=!1,i="channelsLast"){let[u,p,f,m]=[-1,-1,-1,-1];if("channelsLast"===i)[u,p,f,m]=e;else{if("channelsFirst"!==i)throw new Error(`Unknown dataFormat ${i}`);[u,m,p,f]=e}const[g,y,,b]=t,[w,v]=l(n),[k,x]=l(r),_=d(g,k),I=d(y,x),{padInfo:S,outHeight:N,outWidth:M}=function(e,t,n,r,a,o,s,i,u){let l,p,d;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=c(e,t,n));const o=e[1];return[h((e[0]-t+2*r)/n+1,a),h((o-t+2*r)/n+1,a)]}([t,n],o,r,e,i);p=a[0],d=a[1]}else if("same"===e){p=Math.ceil(t/r),d=Math.ceil(n/a);const e=Math.max(0,(p-1)*r+o-t),i=Math.max(0,(d-1)*a+s-n),u=Math.floor(e/2),c=e-u,h=Math.floor(i/2);l={top:u,bottom:c,left:h,right:i-h,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},p=Math.ceil((t-o+1)/r),d=Math.ceil((n-s+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const c="channelsLast"===u?e[1][0]:e[2][0],f="channelsLast"===u?e[1][1]:e[2][1],m="channelsLast"===u?e[2][0]:e[3][0],g="channelsLast"===u?e[2][1]:e[3][1];
2l={top:c,bottom:f,left:m,right:g,type:0===c&&0===f&&0===m&&0===g?"VALID":"EXPLICIT"},p=h((t-o+c+f)/r+1,i),d=h((n-s+m+g)/a+1,i)}}return{padInfo:l,outHeight:p,outWidth:d}}(a,p,f,w,v,_,I,o,i),T=s?b*m:b;let E;return"channelsFirst"===i?E=[u,T,N,M]:"channelsLast"===i&&(E=[u,N,M,T]),{batchSize:u,dataFormat:i,inHeight:p,inWidth:f,inChannels:m,outHeight:N,outWidth:M,outChannels:T,padInfo:S,strideHeight:w,strideWidth:v,filterHeight:g,filterWidth:y,effectiveFilterHeight:_,effectiveFilterWidth:I,dilationHeight:k,dilationWidth:x,inShape:e,outShape:E,filterShape:t}}function u(e,t,n,r,a,o=!1,s="channelsLast",i){let[u,l,f,m,g]=[-1,-1,-1,-1,-1];if("channelsLast"===s)[u,l,f,m,g]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[u,g,l,f,m]=e}const[y,b,w,,v]=t,[k,x,_]=p(n),[I,S,N]=p(r),M=d(y,I),T=d(b,S),E=d(w,N),{padInfo:A,outDepth:F,outHeight:D,outWidth:O}=function(e,t,n,r,a,o,s,i,u,l,p){let d,f,m,g;if("valid"===e&&(e=0),"number"==typeof e){d={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const y=function(e,t,n,r,a,o){null==a&&(a=c(e,t[0],r[0]));const s=[0,0,0,1];for(let n=0;n<3;n++)e[n]+2*a>=t[n]&&(s[n]=h((e[n]-t[n]+2*a)/r[n]+1,o));return s}([t,n,r,1],[i,u,l],0,[a,o,s],e,p);f=y[0],m=y[1],g=y[2]}else{if("same"!==e)throw Error(`Unknown padding parameter: ${e}`);{f=Math.ceil(t/a),m=Math.ceil(n/o),g=Math.ceil(r/s);const e=(f-1)*a+i-t,c=(m-1)*o+u-n,p=(g-1)*s+l-r,h=Math.floor(e/2),y=e-h,b=Math.floor(c/2),w=c-b,v=Math.floor(p/2);d={top:b,bottom:w,left:v,right:p-v,front:h,back:y,type:"SAME"}}}return{padInfo:d,outDepth:f,outHeight:m,outWidth:g}}(a,l,f,m,k,x,_,M,T,E,i),C=o?v*g:v;let P;return"channelsFirst"===s?P=[u,C,F,D,O]:"channelsLast"===s&&(P=[u,F,D,O,C]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:f,inWidth:m,inChannels:g,outDepth:F,outHeight:D,outWidth:O,outChannels:C,padInfo:A,strideDepth:k,strideHeight:x,strideWidth:_,filterDepth:y,filterHeight:b,filterWidth:w,effectiveFilterDepth:M,effectiveFilterHeight:T,effectiveFilterWidth:E,dilationDepth:I,dilationHeight:S,dilationWidth:N,inShape:e,outShape:P,filterShape:t}}function c(e,t,n,r=1){const a=d(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 p(e){return"number"==typeof e?[e,e,e]:e}function d(e,t){return t<=1?e:e+(e-1)*(t-1)}function h(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 f(e){const[t,n,r]=l(e);return 1===t&&1===n&&1===r}function m(e,t){return f(e)||f(t)}function g(e){return l(e).every((e=>e>0))}function y(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function b(e,t,n){if(null!=n){if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);if("number"==typeof t)r.Uc(r.EH(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`));else{if("object"!=typeof t)throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);t.forEach((t=>{t.forEach((t=>{r.Uc(r.EH(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`))}))}))}}}},95660:function(e,t,n){"use strict";n.d(t,{M:function(){return u}});var r=n(31748),a=n(38128),o=n(4172),s=n(72180),i=n(66944);const u=(0,n(17336).op)({div_:function(e,t){let n=(0,s.ay)(e,"a","div"),u=(0,s.ay)(t,"b","div");if([n,u]=(0,o.yE)(n,u),"int32"===n.dtype&&"int32"===u.dtype)return(0,i.K)(n,u);const c={a:n,b:u};return r.cL.runKernel(a.uMf,c,{})}})},39556:function(e,t,n){"use strict";n.d(t,{w:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({elu_:function(e){const t={x:(0,o.ay)(e,"x","elu","float32")};return r.cL.runKernel(a.wP9,t)}})},86381:function(e,t,n){"use strict";n.d(t,{y:function(){return s}});var r=n(31748),a=n(38128),o=n(15952);function s(e,t,n){(0,o.Ix)(e);const s={shape:e,value:t,dtype:n=n||(0,o.GA)(t)};return r.cL.runKernel(a.MnI,{},s)}},66944:function(e,t,n){"use strict";n.d(t,{K:function(){return i}});var r=n(31748),a=n(38128),o=n(4172),s=n(72180);const i=(0,n(17336).op)({floorDiv_:function(e,t){let n=(0,s.ay)(e,"a","floorDiv"),i=(0,s.ay)(t,"b","floorDiv");[n,i]=(0,o.yE)(n,i);const u={a:n,b:i};return r.cL.runKernel(a._6e,u)}})},46120:function(e,t,n){"use strict";n.d(t,{M$:function(){return y},Ql:function(){return m},il:function(){return g},u1:function(){return f}});var r=n(74144),a=n(39556),o=n(73740),s=n(9344),i=n(20736),u=n(36500),c=n(98908),l=n(58432),p=n(37984),d=n(21804),h=n(95872);function f(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return(0,s.E)(e,(0,d.W)(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function m(e,t){let n=t;const a=r.getReductionAxes(e.shape,t.shape);return a.length>0&&(n=(0,h.o)(n,a)),(0,l.O)(n,e.shape)}function g(e,t,n,r){if("linear"===t)return e;if("relu"===t)return(0,u.w)(e);if("elu"===t)return(0,a.w)(e);if("relu6"===t)return(0,c.a)(e);if("prelu"===t)return(0,i.S)(e,n);if("leakyrelu"===t)return(0,o.C)(e,r);if("sigmoid"===t)return(0,p._)(e);throw new Error(`Unknown fused activation ${t}.`)}const y=(e,t)=>!(e>0)||"linear"===t},73740:function(e,t,n){"use strict";n.d(t,{C:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({leakyRelu_:function(e,t=.2){const n={x:(0,o.ay)(e,"x","leakyRelu")},s={alpha:t};return r.cL.runKernel(a.Mb$,n,s)}})},50032:function(e,t,n){"use strict";n.d(t,{W:function(){return c}});var r=n(31748),a=n(38128),o=n(4172),s=n(72180),i=n(74144),u=n(6356);const c=(0,n(17336).op)({maximum_:function(e,t){let n=(0,s.ay)(e,"a","maximum"),c=(0,s.ay)(t,"b","maximum");[n,c]=(0,o.yE)(n,c),"bool"===n.dtype&&(n=(0,u.W)(n,"int32"),c=(0,u.W)(c,"int32")),(0,i.assertAndGetBroadcastShape)(n.shape,c.shape);const l={a:n,b:c};return r.cL.runKernel(a.qik,l)}})},9344:function(e,t,n){"use strict";n.d(t,{E:function(){return i}});var r=n(31748),a=n(38128),o=n(4172),s=n(72180);const i=(0,n(17336).op)({mul_:function(e,t){let n=(0,s.ay)(e,"a","mul"),i=(0,s.ay)(t,"b","mul");[n,i]=(0,o.yE)(n,i);const u={a:n,b:i};return r.cL.runKernel(a.SSu,u)}})},17336:function(e,t,n){"use strict";n.d(t,{I:function(){return o},op:function(){return s}});var r=n(31748),a=n(15952);const o="__op";function s(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 s=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=o;const i=(...e)=>{r.cL.startScope(n);try{const t=s(...e);
2return(0,a.um)(t)&&console.error("Cannot return a Promise inside of tidy."),r.cL.endScope(t),t}catch(e){throw r.cL.endScope(null),e}};return Object.defineProperty(i,"name",{value:n,configurable:!0}),i}},41932:function(e,t,n){"use strict";n.d(t,{IpH:function(){return u.I},a2b:function(){return a.a},mEb:function(){return c},c5J:function(){return l},WQq:function(){return p.W},OiD:function(){return h},Q7R:function(){return f},uWw:function(){return m},E9L:function(){return g},QT8:function(){return y},qRo:function(){return b},AHs:function(){return w},MQ0:function(){return v},WEK:function(){return x},IsS:function(){return _},q2x:function(){return M},k$b:function(){return T},WKV:function(){return R},QtV:function(){return L},oLn:function(){return W},Ulu:function(){return z},KyW:function(){return B},UtN:function(){return $},aej:function(){return U},Q7g:function(){return H},mWy:function(){return ur},MBr:function(){return V},Cet:function(){return G},cz0:function(){return q.c},WM5:function(){return I.W},KmW:function(){return j},Qjg:function(){return Q},ctR:function(){return E.c},c$h:function(){return Y.c},WUr:function(){return A},e8l:function(){return J},Yrn:function(){return Z},w7n:function(){return X},Y3R:function(){return ee},G_J:function(){return ne},QlL:function(){return te},m_y:function(){return ae},_oS:function(){return oe},sLq:function(){return ie},W8e:function(){return ue},o7c:function(){return ce},Sy6:function(){return yr},cP9:function(){return le},kt$:function(){return pe},obE:function(){return de},eM6:function(){return he},gLu:function(){return fe},KCo:function(){return me},s5H:function(){return ge},MbH:function(){return ye.M},aGi:function(){return xe},eAo:function(){return _e},U7y:function(){return mr},Mry:function(){return Ie},w54:function(){return Se.w},mYz:function(){return gr},vuS:function(){return Ne},yyq:function(){return we},Y12:function(){return Me},qgr:function(){return Le},oNF:function(){return We},aW5:function(){return ze},K0Z:function(){return Be},iOb:function(){return He},Ccp:function(){return Dn},ymW:function(){return K.y},wxi:function(){return Ve},Ks0:function(){return Ge.K},Ckv:function(){return r},cJu:function(){return qe},YGD:function(){return fr},aqr:function(){return je},QHi:function(){return Ke},KGM:function(){return On},gXe:function(){return Qe},c$0:function(){return sa},Suf:function(){return br},uOu:function(){return Cn},W0A:function(){return Ye},CoA:function(){return Je},WOs:function(){return Ze},CEm:function(){return Xe.C},SwJ:function(){return et},Kcv:function(){return tt},rhK:function(){return ia},cv1:function(){return nt},sHn:function(){return rt},YzJ:function(){return at},OwK:function(){return ot},Uv2:function(){return ct},SmB:function(){return pt},a4N:function(){return dt},KYp:function(){return ht},WyF:function(){return ft},KDS:function(){return mt},YV:function(){return gt},kXy:function(){return ua},Ogf:function(){return wt},_o$:function(){return F},kvL:function(){return Ee},_SL:function(){return vt},s1D:function(){return kt},SIj:function(){return xt},Win:function(){return _t.W},moX:function(){return It},ArG:function(){return Tt},SYq:function(){return Ae},OCI:function(){return Et},c1V:function(){return At},gXk:function(){return Ft},wJ8:function(){return Dt},EFC:function(){return pr},E7T:function(){return D.E},aCm:function(){return Ot},MtA:function(){return Ct},KUd:function(){return it},Cyy:function(){return $e},UWg:function(){return Pt},ktM:function(){return Rt},eGt:function(){return Nt},W4q:function(){return $t},op:function(){return u.op},_A_:function(){return Lt},eui:function(){return Wt},Kqt:function(){return zt},g1E:function(){return Bt},aaf:function(){return Ut},E50:function(){return Ht},isx:function(){return Gt},g39:function(){return Fe.g},SCD:function(){return qt.S},S4e:function(){return jt.S},iOQ:function(){return Kt},InV:function(){return Qt},ZX5:function(){return Yt},kPy:function(){return Jt},ySJ:function(){return Zt},MH6:function(){return rn},Ogc:function(){return an},e6k:function(){return on},QNb:function(){return sn},AXY:function(){return un},ikV:function(){return cn},gvH:function(){return ln},M7P:function(){return pn},wDQ:function(){return dn.w},aqo:function(){return hn.a},OoG:function(){return N.O},uGn:function(){return fn},CWo:function(){return mn},wrC:function(){return gn},Eht:function(){return yn},s$$:function(){return bn},Ile:function(){return Rn},kLe:function(){return wn},Qoo:function(){return vn},SgB:function(){return De.S},_mR:function(){return dr},c92:function(){return bt},kpW:function(){return kn},Kd4:function(){return xn},cPK:function(){return _n},_CL:function(){return O._},kqB:function(){return In},OCB:function(){return oa},g$V:function(){return Sn},MBb:function(){return Nn},SME:function(){return C},UfB:function(){return Mn},Ehh:function(){return Tn},msk:function(){return En},WuO:function(){return An},UhY:function(){return Fn},uYt:function(){return ut},qYv:function(){return Vt},CQ_:function(){return ca},eIE:function(){return hr},CGt:function(){return aa},SGy:function(){return Pn},_Im:function(){return Oe._},Qri:function(){return Ce.Q},uCq:function(){return $n},sLr:function(){return Ln},Qfh:function(){return Wn},WYO:function(){return zn.W},c7v:function(){return Bn},QbE:function(){return la},AT$:function(){return lt.A},ohi:function(){return Pe.o},a6P:function(){return Un},SyI:function(){return P},mwg:function(){return Hn.m},SC3:function(){return Gn},Enf:function(){return qn},Av9:function(){return jn.A},IFH:function(){return Kn},Qvy:function(){return Qn},olQ:function(){return Yn},CgD:function(){return Zn},CUy:function(){return Ue},GER:function(){return Xn},oLj:function(){return lr},KEu:function(){return er},Swr:function(){return tr},szS:function(){return nr},iqB:function(){return rr},MZf:function(){return ar},QRA:function(){return or},A9N:function(){return ve},i0p:function(){return ir},DjU:function(){return St},Exq:function(){return ke.E}});var r={};n.r(r),n.d(r,{conv2d:function(){return kr},depthwiseConv2d:function(){return Ir},matMul:function(){return Sr}});var a=n(84320),o=n(31748),s=n(38128),i=n(72180),u=n(17336);const c=(0,u.op)({acos_:function(e){const t={x:(0,i.ay)(e,"x","acos")};return o.cL.runKernel(s.Y93,t)}}
2),l=(0,u.op)({acosh_:function(e){const t={x:(0,i.ay)(e,"x","acosh")};return o.cL.runKernel(s.yak,t)}});var p=n(67160),d=n(15952);const h=(0,u.op)({addN_:function(e){d.Uc(Array.isArray(e),(()=>"The argument passed to tf.addN() must be a list of tensors")),d.Uc(e.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`));const t=e.map(((e,t)=>(0,i.ay)(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(!d.eu(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const r=t;return o.cL.runKernel(s.SE4,r)}}),f=(0,u.op)({all_:function(e,t=null,n=!1){const r={x:(0,i.ay)(e,"x","all","bool")},a={axis:t,keepDims:n};return o.cL.runKernel(s.u8Z,r,a)}}),m=(0,u.op)({any_:function(e,t=null,n=!1){const r={x:(0,i.ay)(e,"x","any","bool")},a={axis:t,keepDims:n};return o.cL.runKernel(s.YdD,r,a)}}),g=(0,u.op)({argMax_:function(e,t=0){const n={x:(0,i.ay)(e,"x","argMax")},r={axis:t};return o.cL.runKernel(s.IBO,n,r)}}),y=(0,u.op)({argMin_:function(e,t=0){const n={x:(0,i.ay)(e,"x","argMin")},r={axis:t};return o.cL.runKernel(s.ovQ,n,r)}}),b=(0,u.op)({asin_:function(e){const t={x:(0,i.ay)(e,"x","asin")};return o.cL.runKernel(s.Kgs,t)}}),w=(0,u.op)({asinh_:function(e){const t={x:(0,i.ay)(e,"x","asinh")};return o.cL.runKernel(s.ILp,t)}}),v=(0,u.op)({atan_:function(e){const t={x:(0,i.ay)(e,"x","atan")};return o.cL.runKernel(s.oNL,t)}});var k=n(4172);const x=(0,u.op)({atan2_:function(e,t){let n=(0,i.ay)(e,"a","atan2"),r=(0,i.ay)(t,"b","atan2");[n,r]=(0,k.yE)(n,r);const a={a:n,b:r};return o.cL.runKernel(s.s1o,a)}}),_=(0,u.op)({atanh_:function(e){const t={x:(0,i.ay)(e,"x","atanh")};return o.cL.runKernel(s.cL,t)}});var I=n(6356),S=n(35044),N=n(58432);const M=(0,u.op)({avgPool_:function(e,t,n,r,a){const u=(0,i.ay)(e,"x","avgPool","float32");d.Uc(S.uo(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let c=u,l=!1;3===u.rank&&(l=!0,c=(0,N.O)(u,[1,u.shape[0],u.shape[1],u.shape[2]])),d.Uc(4===c.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${c.rank}.`)),S.YV("avgPool",r,a);const p={x:c},h={filterSize:t,strides:n,pad:r,dimRoundingMode:a};let f=o.cL.runKernel(s.ITk,p,h);return f=(0,I.W)(f,u.dtype),l?(0,N.O)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),T=(0,u.op)({avgPool3d_:function(e,t,n,r,a,u="NDHWC"){const c=(0,i.ay)(e,"x","avgPool3d","float32");let l=c,p=!1;4===c.rank&&(p=!0,l=(0,N.O)(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),d.Uc(5===l.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${l.rank}.`)),d.Uc("NDHWC"===u,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${u}`)),d.Uc("number"==typeof n&&n>0||Array.isArray(n)&&n[0]>0&&n[1]>0&&n[2]>0,(()=>`Error in avgPool3d: Stride must be > 0, but got '${n}'`)),(0,S.YV)("avgPool3d",r,a);const h={x:l},f={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:u};let m=o.cL.runKernel(s.wre,h,f);return m=(0,I.W)(m,l.dtype),p?(0,N.O)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}});var E=n(98400);const A=(0,u.op)({concat_:function(e,t=0){(0,d.Uc)(e.length>=1,(()=>"Pass at least one tensor to concat"));const n=(0,i.Y$)(e,"tensors","concat","string_or_numeric");
2if("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,E.c)(n[0]);const r=n,a={axis:t};return o.cL.runKernel(s.usi,r,a)}}),F=(0,u.op)({matMul_:function(e,t,n=!1,r=!1){let a=(0,i.ay)(e,"a","matMul"),u=(0,i.ay)(t,"b","matMul");[a,u]=(0,k.yE)(a,u);const c={a:a,b:u},l={transposeA:n,transposeB:r};return o.cL.runKernel(s.Sye,c,l)}});var D=n(9344),O=n(37984);const C=(0,u.op)({slice_:function(e,t,n){const r=(0,i.ay)(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");const a={x:r},u={begin:t,size:n};return o.cL.runKernel(s.eKt,a,u)}}),P=(0,u.op)({tanh_:function(e){const t={x:(0,i.ay)(e,"x","tanh","float32")};return o.cL.runKernel(s.Yvq,t)}}),R=(0,u.op)({basicLSTMCell_:function(e,t,n,r,a,o){const s=(0,i.ay)(e,"forgetBias","basicLSTMCell"),u=(0,i.ay)(t,"lstmKernel","basicLSTMCell"),c=(0,i.ay)(n,"lstmBias","basicLSTMCell"),l=(0,i.ay)(r,"data","basicLSTMCell"),d=(0,i.ay)(a,"c","basicLSTMCell"),h=(0,i.ay)(o,"h","basicLSTMCell"),f=A([l,h],1),m=F(f,u),g=(0,p.W)(m,c),y=g.shape[0],b=g.shape[1]/4,w=[y,b],v=C(g,[0,0],w),k=C(g,[0,b],w),x=C(g,[0,2*b],w),_=C(g,[0,3*b],w),I=(0,p.W)((0,D.E)((0,O._)(v),P(k)),(0,D.E)(d,(0,O._)((0,p.W)(s,x))));return[I,(0,D.E)(P(I),(0,O._)(_))]}}),$=(0,u.op)({batchToSpaceND_:function(e,t,n){const r=(0,i.ay)(e,"x","batchToSpaceND"),a=t.reduce(((e,t)=>e*t));d.Uc(r.rank>=1+t.length,(()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`)),d.Uc(n.length===t.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)),d.Uc(r.shape[0]%a==0,(()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${a}`));const u={x:r},c={blockShape:t,crops:n};return o.cL.runKernel(s.EV6,u,c)}}),L=(0,u.op)({batchNorm_:function(e,t,n,r,a,u){null==u&&(u=.001);const c=(0,i.ay)(e,"x","batchNorm"),l=(0,i.ay)(t,"mean","batchNorm"),p=(0,i.ay)(n,"variance","batchNorm");let h,f;null!=a&&(h=(0,i.ay)(a,"scale","batchNorm")),null!=r&&(f=(0,i.ay)(r,"offset","batchNorm")),d.Uc(l.rank===p.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),d.Uc(null==f||l.rank===f.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),d.Uc(null==h||l.rank===h.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const m={x:function(e){let t;return t=0===e.rank||1===e.rank?(0,N.O)(e,[1,1,1,e.size]):2===e.rank?(0,N.O)(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?(0,N.O)(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(c),scale:h,offset:f,mean:l,variance:p},g={varianceEpsilon:u},y=o.cL.runKernel(s.Qxm,m,g);return(0,N.O)(y,c.shape)}}),W=(0,u.op)({batchNorm2d_:function(e,t,n,r,a,o){const s=(0,i.ay)(e,"x","batchNorm"),u=(0,i.ay)(t,"mean","batchNorm"),c=(0,i.ay)(n,"variance","batchNorm");let l,p;return null!=a&&(l=(0,i.ay)(a,"scale","batchNorm")),null!=r&&(p=(0,i.ay)(r,"offset","batchNorm")),d.Uc(2===s.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${s.rank}.`)),d.Uc(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${u.rank}.`)),d.Uc(2===c.rank||1===c.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${c.rank}.`)),null!=l&&d.Uc(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=p&&d.Uc(2===p.rank||1===p.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${p.rank}.`)),L(s,u,c,p,l,o)}}),z=(0,u.op)({batchNorm3d_:function(e,t,n,r,a,o){const s=(0,i.ay)(e,"x","batchNorm"),u=(0,i.ay)(t,"mean","batchNorm"),c=(0,i.ay)(n,"variance","batchNorm");let l,p;return null!=a&&(l=(0,i.ay)(a,"scale","batchNorm")),null!=r&&(p=(0,i.ay)(r,"offset","batchNorm")),d.Uc(3===s.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${s.rank}.`)),d.Uc(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${u.rank}.`)),d.Uc(3===c.rank||1===c.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${c.rank}.`)),null!=l&&d.Uc(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=p&&d.Uc(3===p.rank||1===p.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${p.rank}.`)),L(s,u,c,p,l,o)}}),B=(0,u.op)({batchNorm4d_:function(e,t,n,r,a,o){const s=(0,i.ay)(e,"x","batchNorm"),u=(0,i.ay)(t,"mean","batchNorm"),c=(0,i.ay)(n,"variance","batchNorm");let l,p;return null!=a&&(l=(0,i.ay)(a,"scale","batchNorm")),null!=r&&(p=(0,i.ay)(r,"offset","batchNorm")),d.Uc(4===s.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${s.rank}
2.`)),d.Uc(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${u.rank}.`)),d.Uc(4===c.rank||1===c.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${c.rank}.`)),null!=l&&d.Uc(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=p&&d.Uc(4===p.rank||1===p.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${p.rank}.`)),L(s,u,c,p,l,o)}}),U=(0,u.op)({bincount_:function(e,t,n){const r=(0,i.ay)(e,"x","bincount"),a=(0,i.ay)(t,"weights","bincount");d.Uc("int32"===r.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`)),d.Uc(n>=0,(()=>`size must be non-negative, but got ${n}.`)),d.Uc(a.size===r.size||0===a.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${a.shape}.`));const u={x:r,weights:a},c={size:n};return o.cL.runKernel(s.M3o,u,c)}}),H=(0,u.op)({bitwiseAnd_:function(e,t){const n=(0,i.ay)(e,"x","bitwiseAnd"),r=(0,i.ay)(t,"y","bitwiseAnd");if(!(0,d.eu)(n.shape,r.shape))throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${n.shape}, y: ${r.shape}`);if("int32"!==n.dtype||"int32"!==r.dtype)throw new Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${n.dtype} and type of y: ${r.dtype}`);const a={a:n,b:r};return o.cL.runKernel(s.eCV,a)}}),V=(0,u.op)({broadcastArgs_:function(e,t){const n=(0,i.ay)(e,"s0","broadcastArgs","int32"),r=(0,i.ay)(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!==r.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const a={s0:n,s1:r};return o.cL.runKernel(s.orO,a)}}),G=(0,u.op)({broadcastTo_:function(e,t){let n=(0,i.ay)(e,"broadcastTo","x");const r=n.shape;if((0,d.Ix)(t),t.length<n.rank)throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${n.rank}.`);if(t.length>n.rank){const e=n.shape.slice();for(;e.length<t.length;)e.unshift(1);n=(0,N.O)(n,e)}const a=n.shape,u=Array.from(t);for(let e=t.length-1;e>=0;e--)if(a[e]===t[e])u[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);if(0===u.map(((e,t)=>e>1?t:-1)).filter((e=>e>=0)).length)return(0,E.c)(n);const c={x:n},l={reps:u};return o.cL.runKernel(s.g$J,c,l)}});var q=n(9653);const j=(0,u.op)({ceil_:function(e){const t={x:(0,i.ay)(e,"x","ceil","float32")};return o.cL.runKernel(s.OeR,t)}});var K=n(86381);const Q=(0,u.op)({clipByValue_:function(e,t,n){const r=(0,i.ay)(e,"x","clipByValue");if(d.Uc(t<=n,(()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`)),t===n)return(0,K.y)(r.shape,t,r.dtype);const a={x:r},u={clipValueMin:t,clipValueMax:n};return o.cL.runKernel(s.Oe9,a,u)}});var Y=n(44720);const J=(0,u.op)({concat1d_:function(e){return A(e,0)}}),Z=(0,u.op)({concat2d_:function(e,t){return A(e,t)}}),X=(0,u.op)({concat3d_:function(e,t){return A(e,t)}}),ee=(0,u.op)({concat4d_:function(e,t){return A(e,t)}}),te=(0,u.op)({conv2d_:function(e,t,n,r,a="NHWC",u=[1,1],c){const l=(0,i.ay)(e,"x","conv2d","float32"),p=(0,i.ay)(t,"filter","conv2d","float32");let h=l,f=!1;3===l.rank&&(f=!0,h=(0,N.O)(l,[1,l.shape[0],l.shape[1],l.shape[2]])),d.Uc(4===h.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${h.rank}.`)),d.Uc(4===p.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${p.rank}.`)),S.YV("conv2d",r,c);const m="NHWC"===a?h.shape[3]:h.shape[1];d.Uc(m===p.shape[2],(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${p.shape[2]}.`)),d.Uc(S.uo(n,u),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${u}'`)),d.Uc(S.iC(u),(()=>"Error in conv2D: Dilated rates should be larger than 0.")),d.Uc(S.iC(n),(()=>"Error in conv2D: Strides should be larger than 0."));const g={x:h,filter:p},y={strides:n,pad:r,dataFormat:a,dilations:u,dimRoundingMode:c},b=o.cL.runKernel(s.a_P,g,y);return f?(0,N.O)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}}),ne=(0,u.op)({conv1d_:function(e,t,n,r,a="NWC",o=1,s){const u=(0,i.ay)(e,"x","conv1d"),c=(0,i.ay)(t,"filter","conv1d");let l=u,p=!1;2===u.rank&&(p=!0,l=(0,N.O)(u,[1,u.shape[0],u.shape[1]])),d.Uc(3===l.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`)),d.Uc(3===c.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${c.rank}.`)),S.YV("conv1d",r,s),d.Uc(l.shape[2]===c.shape[1],(()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${c.shape[1]}.`)),d.Uc(S.uo(n,o),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${o}'`)),d.Uc(S.iC(o),(()=>"Error in conv1D: Dilated rates should be larger than 0.")),d.Uc(S.iC(n),(()=>"Error in conv1D: Stride should be larger than 0.")),d.Uc("NWC"===a,(()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`));const h=(0,N.O)(c,[1,c.shape[0],c.shape[1],c.shape[2]]),f=(0,N.O)(l,[l.shape[0],1,l.shape[1],l.shape[2]]),m=te(f,h,[1,n],r,"NHWC",[1,o],s);return p?(0,N.O)(m,[m.shape[2],m.shape[3]]):(0,N.O)(m,[m.shape[0],m.shape[2],m.shape[3]])}}
2),re=(0,u.op)({conv2DBackpropInput_:function(e,t,n,r,a,i="NHWC",u){d.Uc(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let c=e,l=t,p=!1;3===t.rank&&(p=!0,l=(0,N.O)(t,[1,t.shape[0],t.shape[1],t.shape[2]]),c=[1,e[0],e[1],e[2]]),d.Uc(4===c.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${c.length}.`)),d.Uc(4===l.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`)),d.Uc(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const h="NHWC"===i?c[3]:c[1],f="NHWC"===i?l.shape[3]:l.shape[1];d.Uc(h===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${h}) must match input depth for filter ${n.shape[2]}.`)),d.Uc(f===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${f}) must match output depth for filter ${n.shape[3]}.`)),S.YV("conv2dDerInput",a,u);const m={dy:l,filter:n},g={strides:r,pad:a,dataFormat:i,dimRoundingMode:u,inputShape:c},y=o.cL.runKernel(s.Mz5,m,g);return p?(0,N.O)(y,[y.shape[1],y.shape[2],y.shape[3]]):y}}),ae=(0,u.op)({conv2dTranspose_:function(e,t,n,r,a,o){const s=(0,i.ay)(e,"x","conv2dTranspose"),u=(0,i.ay)(t,"filter","conv2dTranspose");return re(n,s,u,r,a,"NHWC",o)}}),oe=(0,u.op)({conv3d_:function(e,t,n,r,a="NDHWC",u=[1,1,1]){const c=(0,i.ay)(e,"x","conv3d"),l=(0,i.ay)(t,"filter","conv3d");let p=c,h=!1;4===c.rank&&(h=!0,p=(0,N.O)(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),d.Uc(5===p.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${p.rank}.`)),d.Uc(5===l.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${l.rank}.`)),d.Uc(p.shape[4]===l.shape[3],(()=>`Error in conv3d: depth of input (${p.shape[4]}) must match input depth for filter ${l.shape[3]}.`)),d.Uc((0,S.uo)(n,u),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${u}'`)),d.Uc("NDHWC"===a,(()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`)),d.Uc((0,S.iC)(u),(()=>"Error in conv3D: Dilated rates should be larger than 0.")),d.Uc((0,S.iC)(n),(()=>"Error in conv3D: Strides should be larger than 0."));const f={x:p,filter:l},m={strides:n,pad:r,dataFormat:a,dilations:u},g=o.cL.runKernel(s.WE3,f,m);return h?(0,N.O)(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),se=(0,u.op)({conv3DBackpropInput_:function(e,t,n,r,a){d.Uc(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let i=e,u=t,c=!1;4===t.rank&&(c=!0,u=(0,N.O)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);const l=i[4],p=u.shape[4];d.Uc(5===i.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${i.length}.`)),d.Uc(5===u.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${u.rank}`)),d.Uc(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),d.Uc(l===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`)),d.Uc(p===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[4]}.`));const h={dy:u,filter:n},f={pad:a,strides:r,inputShape:i},m=o.cL.runKernel(s.ygG,h,f);return c?(0,N.O)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}}),ie=(0,u.op)({conv3dTranspose_:function(e,t,n,r,a){const o=(0,i.ay)(e,"x","conv3dTranspose"),s=(0,i.ay)(t,"filter","conv3dTranspose");return se(n,o,s,r,a)}}),ue=(0,u.op)({cos_:function(e){const t={x:(0,i.ay)(e,"x","cos","float32")};return o.cL.runKernel(s.EHc,t)}}),ce=(0,u.op)({cosh_:function(e){const t={x:(0,i.ay)(e,"x","cosh","float32")};return o.cL.runKernel(s.YZ3,t)}}),le=(0,u.op)({cumprod_:function(e,t=0,n=!1,r=!1){const a={x:(0,i.ay)(e,"x","cumprod")},u={axis:t,exclusive:n,reverse:r};return o.cL.runKernel(s.yuV,a,u)}}),pe=(0,u.op)({cumsum_:function(e,t=0,n=!1,r=!1){const a={x:(0,i.ay)(e,"x","cumsum")},u={axis:t,exclusive:n,reverse:r};return o.cL.runKernel(s.gBx,a,u)}}),de=(0,u.op)({denseBincount_:function(e,t,n,r=!1){const a=(0,i.ay)(e,"x","denseBincount"),u=(0,i.ay)(t,"weights","denseBincount");d.Uc("int32"===a.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`)),d.Uc(a.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`)),d.Uc(n>=0,(()=>`size must be non-negative, but got ${n}.`)),d.Uc(u.size===a.size||0===u.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${u.shape}.`));const c={x:a,weights:u},l={size:n,binaryOutput:r};return o.cL.runKernel(s.COo,c,l)}}),he=(0,u.op)({depthToSpace_:function(e,t,n="NHWC"){const r=(0,i.ay)(e,"x","depthToSpace","float32"),a="NHWC"===n?r.shape[1]:r.shape[2],u="NHWC"===n?r.shape[2]:r.shape[3],c="NHWC"===n?r.shape[3]:r.shape[1];d.Uc(t>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`)),d.Uc(a*t>=0,(()=>
2`Negative dimension size caused by overflow when multiplying\n ${a} and ${t} for depthToSpace with input shape\n ${r.shape}`)),d.Uc(u*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${u} and ${t} for depthToSpace with input shape\n ${r.shape}`)),d.Uc(c%(t*t)==0,(()=>`Dimension size must be evenly divisible by ${t*t} but is ${c} for depthToSpace with input shape ${r.shape}`));const l={x:r},p={blockSize:t,dataFormat:n};return o.cL.runKernel(s.OEe,l,p)}}),fe=(0,u.op)({depthwiseConv2d_:function(e,t,n,r,a="NHWC",u=[1,1],c){const l=(0,i.ay)(e,"x","depthwiseConv2d","float32"),p=(0,i.ay)(t,"filter","depthwiseConv2d","float32");let h=l,f=!1;3===l.rank&&(f=!0,h=(0,N.O)(l,[1,l.shape[0],l.shape[1],l.shape[2]])),d.Uc(4===h.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`)),d.Uc(4===p.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`));const m="NHWC"===a?h.shape[3]:h.shape[1];d.Uc(m===p.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${m}) must match the inChannels dimension in filter ${p.shape[2]}.`)),S.YV("depthwiseConv2d",r,c);const g={x:h,filter:p},y={strides:n,pad:r,dataFormat:a,dilations:u,dimRoundingMode:c},b=o.cL.runKernel(s.Fql,g,y);return f?(0,N.O)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}}),me=(0,u.op)({diag_:function(e){const t={x:(0,i.ay)(e,"x","diag")};return o.cL.runKernel(s.uIb,t)}}),ge=(0,u.op)({dilation2d_:function(e,t,n,r,a=[1,1],u="NHWC"){const c=(0,i.ay)(e,"x","dilation2d"),l=(0,i.ay)(t,"filter","dilation2d");d.Uc(3===c.rank||4===c.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${c.rank}.`)),d.Uc(3===l.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${l.rank}.`)),d.Uc("NHWC"===u,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${u}`));let p=c,h=!1;3===c.rank&&(p=(0,N.O)(c,[1,c.shape[0],c.shape[1],c.shape[2]]),h=!0),d.Uc(p.shape[3]===l.shape[2],(()=>`Error in dilation2d: input and filter must have the same depth: ${p.shape[3]} vs ${l.shape[2]}`));const f={x:p,filter:l},m={strides:n,pad:r,dilations:a},g=o.cL.runKernel(s.I7R,f,m);return h?(0,N.O)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}});var ye=n(95660),be=n(74144);const we=(0,u.op)({equal_:function(e,t){let n=(0,i.ay)(e,"a","equal","string_or_numeric"),r=(0,i.ay)(t,"b","equal","string_or_numeric");[n,r]=(0,k.yE)(n,r),(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.Ooc,a)}}),ve=(0,u.op)({where_:function(e,t,n){const r=(0,i.ay)(t,"a","where"),a=(0,i.ay)(n,"b","where"),u=(0,i.ay)(e,"condition","where","bool"),c=(0,be.assertAndGetBroadcastShape)((0,be.assertAndGetBroadcastShape)(u.shape,r.shape),a.shape),l={condition:G(u,c),t:G(r,c),e:G(a,c)};return o.cL.runKernel(s.M1e,l)}});var ke=n(50216);const xe=(0,u.op)({divNoNan_:function(e,t){let n=(0,i.ay)(e,"a","div"),r=(0,i.ay)(t,"b","div");[n,r]=(0,k.yE)(n,r);const a=(0,ye.M)(n,r),o=(0,ke.E)(a),s=we(r,o);return ve(s,o,a)}}),_e=(0,u.op)({dot_:function(e,t){const n=(0,i.ay)(e,"t1","dot"),r=(0,i.ay)(t,"t2","dot");d.Uc(!(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],o=1===r.rank?r.size:r.shape[0];if(d.Uc(a===o,(()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${o}.`)),1===n.rank&&1===r.rank){const e=(0,N.O)(n,[1,-1]),t=(0,N.O)(r,[-1,1]),a=F(e,t);return(0,N.O)(a,[])}if(1===n.rank&&2===r.rank){const e=(0,N.O)(n,[1,-1]),t=(0,N.O)(r,[r.shape[0],r.shape[1]]),a=F(e,t);return(0,N.O)(a,[a.size])}if(2===n.rank&&1===r.rank){const e=(0,N.O)(r,[-1,1]),t=F(n,e);return(0,N.O)(t,[t.size])}{const e=(0,N.O)(r,[r.shape[0],r.shape[1]]);return F(n,e)}}}),Ie=(0,u.op)({einsum_:function(e,...t){const n=t.map(((e,t)=>(0,i.ay)(e,`tensors${t}`,"einsum"))),r={equation:e};return o.cL.runKernel(s._2b,n,r)}});var Se=n(39556);const Ne=(0,u.op)({ensureShape_:function(e,t){const n=(0,i.ay)(e,"x","ensureShape","string_or_numeric");if(!(0,d.mQ)(n.shape,t))throw new Error(`EnsureShape: Shape of tensor ${n.shape} is not compatible with expected shape ${t}`);return e}}),Me=(0,u.op)({erf_:function(e){let t=(0,i.ay)(e,"x","erf");d.Uc("int32"===t.dtype||"float32"===t.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===t.dtype&&(t=(0,I.W)(t,"float32"));const n={x:t};return o.cL.runKernel(s._s9,n)}});var Te=n(34752);const Ee=(0,u.op)({max_:function(e,t=null,n=!1){const r={x:(0,i.ay)(e,"x","max")},a={reductionIndices:t,keepDims:n};return o.cL.runKernel(s.aUJ,r,a)}}
2),Ae=(0,u.op)({min_:function(e,t=null,n=!1){const r={x:(0,i.ay)(e,"x","min")},a={axis:t,keepDims:n};return o.cL.runKernel(s.WW2,r,a)}});var Fe=n(94380),De=n(12988),Oe=n(2992),Ce=n(82916),Pe=n(95872);function Re(e,t,n=null){if(0===e.rank)return(0,a.a)(e);if(1!==e.rank&&null===n)return Re((0,N.O)(e,[-1]),t,n);if(1===e.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===t)return(0,Pe.o)((0,a.a)(e),n);if(t===1/0)return Ee((0,a.a)(e),n);if(t===-1/0)return Ae((0,a.a)(e),n);if("euclidean"===t||2===t)return(0,Oe._)((0,Pe.o)((0,Fe.g)((0,a.a)(e),(0,De.S)(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&2===n.length){if(1===t)return Ee((0,Pe.o)((0,a.a)(e),n[0]),n[1]-1);if(t===1/0)return Ee((0,Pe.o)((0,a.a)(e),n[1]),n[0]);if(t===-1/0)return Ae((0,Pe.o)((0,a.a)(e),n[1]),n[0]);if("fro"===t||"euclidean"===t)return(0,Oe._)((0,Pe.o)((0,Ce.Q)(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const $e=(0,u.op)({norm_:function(e,t="euclidean",n=null,r=!1){const a=Re(e=(0,i.ay)(e,"x","norm"),t,n);let o=a.shape;if(r){const t=(0,d.YL)(n,e.shape);o=Te.Mp(a.shape,t)}return(0,N.O)(a,o)}}),Le=(0,u.op)({euclideanNorm_:function(e,t=null,n=!1){return $e(e,"euclidean",t,n)}}),We=(0,u.op)({exp_:function(e){const t={x:(0,i.ay)(e,"x","exp")};return o.cL.runKernel(s.ox3,t)}}),ze=(0,u.op)({expandDims_:function(e,t=0){const n=(0,i.ay)(e,"x","expandDims","string_or_numeric");d.Uc(t<=n.rank,(()=>"Axis must be <= rank of the tensor"));const r={input:n},a={dim:t};return o.cL.runKernel(s.IbD,r,a)}}),Be=(0,u.op)({expm1_:function(e){const t={x:(0,i.ay)(e,"x","expm1")};return o.cL.runKernel(s.MrP,t)}}),Ue=(0,u.op)({tile_:function(e,t){const n=(0,i.ay)(e,"x","tile","string_or_numeric");d.Uc(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`));const r={x:n},a={reps:t};return o.cL.runKernel(s.g$J,r,a)}}),He=(0,u.op)({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=(0,q.c)([e,t],r),o=e<=t?e:t;for(let e=0;e<o;++e)a.set(1,e,e);const s=(0,N.O)(a.toTensor(),[e,t]);if(null==n)return s;if(1===n.length)return Ue(ze(s,0),[n[0],1,1]);if(2===n.length)return Ue(ze(ze(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return Ue(ze(ze(ze(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`)}}),Ve=(0,u.op)({floor_:function(e){const t={x:(0,i.ay)(e,"x","floor","float32")};return o.cL.runKernel(s.WmE,t)}});var Ge=n(66944);const qe=(0,u.op)({gather_:function(e,t,n=0,r=0){const a={x:(0,i.ay)(e,"x","gather"),indices:(0,i.ay)(t,"indices","gather","int32")},u={axis:n,batchDims:r};return o.cL.runKernel(s.UV,a,u)}}),je=(0,u.op)({greater_:function(e,t){let n=(0,i.ay)(e,"a","greater","string_or_numeric"),r=(0,i.ay)(t,"b","greater","string_or_numeric");[n,r]=(0,k.yE)(n,r),(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.o3B,a)}}),Ke=(0,u.op)({greaterEqual_:function(e,t){let n=(0,i.ay)(e,"a","greaterEqual","string_or_numeric"),r=(0,i.ay)(t,"b","greaterEqual","string_or_numeric");[n,r]=(0,k.yE)(n,r),(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.QD,a)}}),Qe=(0,u.op)({imag_:function(e){const t={input:(0,i.ay)(e,"input","imag")};return o.cL.runKernel(s.EV7,t)}}),Ye=(0,u.op)({isFinite_:function(e){const t={x:(0,i.ay)(e,"x","isFinite")};return o.cL.runKernel(s.iwm,t)}}),Je=(0,u.op)({isInf_:function(e){const t={x:(0,i.ay)(e,"x","isInf")};return o.cL.runKernel(s.aMl,t)}}),Ze=(0,u.op)({isNaN_:function(e){const t={x:(0,i.ay)(e,"x","isNaN")};return o.cL.runKernel(s.OiK,t)}});var Xe=n(73740);const et=(0,u.op)({less_:function(e,t){let n=(0,i.ay)(e,"a","less","string_or_numeric"),r=(0,i.ay)(t,"b","less","string_or_numeric");[n,r]=(0,k.yE)(n,r),(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.GoJ,a)}}),tt=(0,u.op)({lessEqual_:function(e,t){let n=(0,i.ay)(e,"a","lessEqual","string_or_numeric"),r=(0,i.ay)(t,"b","lessEqual","string_or_numeric");[n,r]=(0,k.yE)(n,r),(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.SMP,a)}});function nt(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");const r={start:e,stop:t,num:n};return o.cL.runKernel(s.Kst,{},r)}const rt=(0,u.op)({localResponseNormalization_:function(e,t=5,n=1,r=1,a=.5){const u=(0,i.ay)(e,"x","localResponseNormalization");d.Uc(4===u.rank||3===u.rank,(()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${u.rank}.`)),d.Uc(d.EH(t),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`));let c=u,l=!1;3===u.rank&&(l=!0,c=(0,N.O)(u,[1,u.shape[0],u.shape[1],u.shape[2]]));const p={x:c},h={depthRadius:t,bias:n,alpha:r,beta:a},f=o.cL.runKernel(s.wfw,p,h);return l?(0,N.O)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}
2),at=(0,u.op)({log_:function(e){const t={x:(0,i.ay)(e,"x","log","float32")};return o.cL.runKernel(s.qwJ,t)}}),ot=(0,u.op)({log1p_:function(e){const t={x:(0,i.ay)(e,"x","log1p")};return o.cL.runKernel(s.eg6,t)}});var st=n(18640);const it=(0,u.op)({neg_:function(e){const t={x:(0,i.ay)(e,"x","neg")};return o.cL.runKernel(s.yUy,t)}}),ut=(0,u.op)({softplus_:function(e){const t={x:(0,i.ay)(e,"x","softplus")};return o.cL.runKernel(s.eWt,t)}}),ct=(0,u.op)({logSigmoid_:function(e){const t=(0,i.ay)(e,"x","logSigmoid");return(0,st.Sw)((e=>({value:it(ut(it(e))),gradFunc:t=>(0,D.E)(t,(0,O._)(it(e)))})))(t)}});var lt=n(90256);const pt=(0,u.op)({logSoftmax_:function(e,t=-1){const n=(0,i.ay)(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}`);const r=(0,st.Sw)(((e,n)=>{const r=Ee(e,t,!0),a=(0,lt.A)(e,r),o=(0,lt.A)((0,I.W)(a,"float32"),at((0,Pe.o)(We(a),t,!0)));return n([o]),{value:o,gradFunc:(e,n)=>{const[r]=n,a=We(r);return(0,lt.A)(e,(0,D.E)((0,Pe.o)(e,t,!0),a))}}}));return r(n)}}),dt=(0,u.op)({logSumExp_:function(e,t=null,n=!1){const r=(0,i.ay)(e,"x","logSumExp"),a=(0,d.YL)(t,r.shape),o=Ee(r,a,!0),s=(0,lt.A)(r,o),u=We(s),c=(0,Pe.o)(u,a),l=at(c),h=(0,p.W)((0,N.O)(o,l.shape),l);if(n){const e=(0,Te.Mp)(h.shape,a);return(0,N.O)(h,e)}return h}}),ht=(0,u.op)({logicalAnd_:function(e,t){const n=(0,i.ay)(e,"a","logicalAnd","bool"),r=(0,i.ay)(t,"b","logicalAnd","bool");(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.SSA,a)}}),ft=(0,u.op)({logicalNot_:function(e){const t={x:(0,i.ay)(e,"x","logicalNot","bool")};return o.cL.runKernel(s.qe$,t)}}),mt=(0,u.op)({logicalOr_:function(e,t){const n=(0,i.ay)(e,"a","logicalOr","bool"),r=(0,i.ay)(t,"b","logicalOr","bool");(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.whD,a)}}),gt=(0,u.op)({logicalXor_:function(e,t){const n=(0,i.ay)(e,"a","logicalXor","bool"),r=(0,i.ay)(t,"b","logicalXor","bool");return(0,be.assertAndGetBroadcastShape)(n.shape,r.shape),ht(mt(e,t),ft(ht(e,t)))}}),yt=2147483648,bt=(0,u.op)({searchSorted_:function(e,t,n="left"){const r=(0,i.ay)(e,"sortedSequence","searchSorted"),a=(0,i.ay)(t,"values","searchSorted"),u=r.shape[r.shape.length-1],c=a.shape[a.shape.length-1],l=(0,N.O)(r,[-1,u]),p=(0,N.O)(a,[-1,c]);if(l.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(l.shape[0]!==p.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if((0,d.It)(p.shape)>=yt)throw new Error("values tensor size must less than 2147483648");if(l.shape[1]>=yt)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${l.shape[1]}`);const h={sortedSequence:l,values:p},f={side:n};return o.cL.runKernel(s.wvl,h,f)}});function wt(e,t){return bt(e,t,"left")}const vt=(0,u.op)({maxPool_:function(e,t,n,r,a){const u=(0,i.ay)(e,"x","maxPool");let c=u,l=!1;3===u.rank&&(l=!0,c=(0,N.O)(u,[1,u.shape[0],u.shape[1],u.shape[2]])),d.Uc(4===c.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${c.rank}.`)),d.Uc(S.uo(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),S.YV("maxPool",r,a);const p={x:c},h={filterSize:t,strides:n,pad:r,dimRoundingMode:a},f=o.cL.runKernel(s.MNi,p,h);return l?(0,N.O)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),kt=(0,u.op)({maxPool3d_:function(e,t=[1,1,1],n,r,a,u="NDHWC"){const c=(0,i.ay)(e,"x","maxPool3d");let l=c,p=!1;4===c.rank&&(p=!0,l=(0,N.O)(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),d.Uc(5===l.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${l.rank}.`)),d.Uc("NDHWC"===u,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${u}`)),(0,S.YV)("maxPool3d",r,a);const h={x:l},f={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:u},m=o.cL.runKernel(s.C4i,h,f);return p?(0,N.O)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}}),xt=(0,u.op)({maxPoolWithArgmax_:function(e,t,n,r,a=!1){const u={x:(0,i.ay)(e,"x","maxPoolWithArgmax")},c={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},l=o.cL.runKernel(s.yqo,u,c);return{result:l[0],indexes:l[1]}}});var _t=n(50032);
2const It=(0,u.op)({mean_:function(e,t=null,n=!1){const r={x:(0,i.ay)(e,"x","mean")},a={axis:t,keepDims:n};return o.cL.runKernel(s.iN$,r,a)}});function St(e,t="float32"){if((0,d.Ix)(e),"complex64"===t){const t=St(e,"float32"),n=St(e,"float32");return(0,Y.c)(t,n)}const n=(0,d.K6)((0,d.It)(e),t);return o.cL.makeTensor(n,e,t)}function Nt(e,t="float32"){if((0,d.Ix)(e),"complex64"===t){const t=Nt(e,"float32"),n=St(e,"float32");return(0,Y.c)(t,n)}const n=(0,d.Do)((0,d.It)(e),t);return o.cL.makeTensor(n,e,t)}var Mt=n(74364);function Tt(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,i.ay)(e,"x","meshgrid",e instanceof Mt.w3?e.dtype:"float32");if(void 0===t)return[r];let a=(0,i.ay)(t,"y","meshgrid",t instanceof Mt.w3?t.dtype:"float32");const o=(0,d.It)(r.shape),s=(0,d.It)(a.shape);return"xy"===n?(r=(0,N.O)(r,[1,-1]),a=(0,N.O)(a,[-1,1]),[F(Nt([s,1],r.dtype),r),F(a,Nt([1,o],a.dtype))]):(r=(0,N.O)(r,[-1,1]),a=(0,N.O)(a,[1,-1]),[F(r,Nt([1,s],r.dtype)),F(Nt([o,1],a.dtype),a)])}const Et=(0,u.op)({minimum_:function(e,t){let n=(0,i.ay)(e,"a","minimum"),r=(0,i.ay)(t,"b","minimum");[n,r]=(0,k.yE)(n,r),"bool"===n.dtype&&(n=(0,I.W)(n,"int32"),r=(0,I.W)(r,"int32")),(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.sly,a)}}),At=(0,u.op)({mirrorPad_:function(e,t,n){d.Uc("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const r=(0,i.ay)(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");d.Uc(t.length===r.rank,(()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`));const a="reflect"===n?1:0;for(let e=0;e<r.rank;e++)d.Uc(2===t[e].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),d.Uc(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(()=>`Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e]-a} or less than 0 for input of shape ${r.shape}`));const u={paddings:t,mode:n},c={x:r};return o.cL.runKernel(s.C6u,c,u)}}),Ft=(0,u.op)({mod_:function(e,t){let n=(0,i.ay)(e,"a","mod"),r=(0,i.ay)(t,"b","mod");[n,r]=(0,k.yE)(n,r);const a={a:n,b:r};return o.cL.runKernel(s.InO,a)}}),Dt=(0,u.op)({moments_:function(e,t=null,n=!1){e=(0,i.ay)(e,"x","moments");const r=(0,d.YL)(t,e.shape),a=It(e,r,n);let o=a.shape;n||(o=(0,Te.Mp)(a.shape,r));const s=(0,Ce.Q)((0,lt.A)((0,I.W)(e,"float32"),(0,N.O)(a,o)));return{mean:a,variance:It(s,r,n)}}}),Ot=(0,u.op)({multiRNNCell_:function(e,t,n,r){const a=(0,i.ay)(t,"data","multiRNNCell"),o=(0,i.Y$)(n,"c","multiRNNCell"),s=(0,i.Y$)(r,"h","multiRNNCell");let u=a;const c=[];for(let t=0;t<e.length;t++){const n=e[t](u,o[t],s[t]);c.push(n[0]),c.push(n[1]),u=n[1]}const l=[],p=[];for(let e=0;e<c.length;e+=2)l.push(c[e]),p.push(c[e+1]);return[l,p]}}),Ct=(0,u.op)({multinomial_:function(e,t,n,r=!1){const a=(0,i.ay)(e,"logits","multinomial"),u=a.size,c=a.rank;if(u<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${u}.`);if(c>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${c}`);n=n||Math.random();const l={logits:1===c?(0,N.O)(a,[1,-1]):a},p={numSamples:t,seed:n,normalized:r},d=o.cL.runKernel(s.UdG,l,p);return 1===c?(0,N.O)(d,[d.size]):d}}),Pt=(0,u.op)({notEqual_:function(e,t){let n=(0,i.ay)(e,"a","notEqual","string_or_numeric"),r=(0,i.ay)(t,"b","notEqual","string_or_numeric");[n,r]=(0,k.yE)(n,r),(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.Ki5,a)}}),Rt=(0,u.op)({oneHot_:function(e,t,n=1,r=0,a="int32"){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const u={indices:(0,i.ay)(e,"indices","oneHot","int32")},c={dtype:a,depth:t,onValue:n,offValue:r};return o.cL.runKernel(s.mon,u,c)}}),$t=(0,u.op)({onesLike_:function(e){const t={x:(0,i.ay)(e,"x","onesLike")};return o.cL.runKernel(s.O_l,t)}}),Lt=(0,u.op)({outerProduct_:function(e,t){const n=(0,i.ay)(e,"v1","outerProduct"),r=(0,i.ay)(t,"v2","outerProduct");d.Uc(1===n.rank&&1===r.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank}
2 and ${r.rank}.`));const a=(0,N.O)(n,[-1,1]),o=(0,N.O)(r,[1,-1]);return F(a,o)}}),Wt=(0,u.op)({pad_:function(e,t,n=0){const r=(0,i.ay)(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const a={paddings:t,constantValue:n},u={x:r};return o.cL.runKernel(s.Q8A,u,a)}}),zt=(0,u.op)({pad1d_:function(e,t,n=0){return(0,d.Uc)(2===t.length,(()=>"Invalid number of paddings. Must be length of 2.")),Wt(e,[t],n)}}),Bt=(0,u.op)({pad2d_:function(e,t,n=0){return(0,d.Uc)(2===t.length&&2===t[0].length&&2===t[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),Wt(e,t,n)}}),Ut=(0,u.op)({pad3d_:function(e,t,n=0){return(0,d.Uc)(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.")),Wt(e,t,n)}}),Ht=(0,u.op)({pad4d_:function(e,t,n=0){return(0,d.Uc)(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.")),Wt(e,t,n)}}),Vt=(0,u.op)({spaceToBatchND_:function(e,t,n){const r=(0,i.ay)(e,"x","spaceToBatchND");d.Uc(r.rank>=1+t.length,(()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`)),d.Uc(n.length===t.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)),d.Uc(r.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 ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`));const a={x:r},u={blockShape:t,paddings:n};return o.cL.runKernel(s.sH1,a,u)}}),Gt=(0,u.op)({pool_:function(e,t,n,r,a,o,s){null==a&&(a=[1,1]),null==o&&(o=1),0===r&&(r="valid");const u=(0,i.ay)(e,"x","maxPool");let c=u,l=!1;3===u.rank&&(l=!0,c=(0,N.O)(u,[1,u.shape[0],u.shape[1],u.shape[2]])),d.Uc(S.uo(o,a),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${o} and dilations '${a}'`));const p=S.ZB(c.shape,t,o,a,r),h=[p.dilationHeight,p.dilationWidth];let f;f="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]]))}([p.filterHeight,p.filterWidth],h):[[0,0],[0,0]];const m=1===h[0]&&1===h[1],[g,y]=function(e,t,n){const r=n.map((e=>e[0])),a=n.map((e=>e[1])),o=e.concat(r,a),s=t.map(((e,t)=>(e-o[t]%e)%e)),i=a.map(((e,t)=>e+s[t]));return[t.map(((e,t)=>[r[t],i[t]])),t.map(((e,t)=>[0,s[t]]))]}([p.inHeight,p.inWidth],h,f),b=m?r:"valid",w=m?c:Vt(c,h,g),v=("avg"===n?()=>M(w,t,o,b,s):()=>vt(w,t,o,b,s))(),k=m?v:$(v,h,y);return l?(0,N.O)(k,[k.shape[1],k.shape[2],k.shape[3]]):k}});var qt=n(20736),jt=n(90800);const Kt=(0,u.op)({prod_:function(e,t=null,n=!1){let r=(0,i.ay)(e,"x","prod");"bool"===r.dtype&&(r=(0,I.W)(r,"int32"));const a={x:r},u={axis:t,keepDims:n};return o.cL.runKernel(s.e_0,a,u)}}),Qt=(0,u.op)({raggedGather_:function(e,t,n,r){const a={paramsNestedSplits:e.map(((e,t)=>(0,i.ay)(e,`tensors${t}`,"raggedGather","int32"))),paramsDenseValues:(0,i.ay)(t,"paramsDenseValues","raggedGather"),indices:(0,i.ay)(n,"indices","raggedGather","int32")},u={outputRaggedRank:r},c=o.cL.runKernel(s.KGR,a,u);return{outputNestedSplits:c.slice(0,c.length-1),outputDenseValues:c[c.length-1]}}}),Yt=(0,u.op)({raggedRange_:function(e,t,n){const r=(0,i.ay)(e,"starts","raggedRange"),a={starts:r,limits:(0,i.ay)(t,"limits","raggedRange",r.dtype),deltas:(0,i.ay)(n,"deltas","raggedRange",r.dtype)},u=o.cL.runKernel(s.sdx,a);return{rtNestedSplits:u[0],rtDenseValues:u[1]}}}),Jt=(0,u.op)({raggedTensorToTensor_:function(e,t,n,r,a){const u=(0,i.ay)(e,"shape","raggedTensorToTensor","int32"),c=(0,i.ay)(t,"values","raggedTensorToTensor"),l={shape:u,values:c,defaultValue:(0,i.ay)(n,"defaultValue","raggedTensorToTensor",c.dtype),rowPartitionTensors:r.map(((e,t)=>(0,i.ay)(e,`tensors${t}`,"raggedTensorToTensor","int32")))},p={rowPartitionTypes:a};return o.cL.runKernel(s.wF4,l,p)}}),Zt=(0,u.op)({rand_:function(e,t,n){(0,d.Ix)(e);const r=(0,d.It)(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<r;e++)a[e]=t();return o.cL.makeTensor(a,e,n)}});var Xt=n(4792);class en{constructor(e,t,n,r,a){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);const o=a||Math.random();this.random=Xt.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,o;do{r=2*this.random()-1,a=2*this.random()-1,o=r*r+a*a}while(o>=1||0===o);const s=Math.sqrt(-2*Math.log(o)/o);e=this.mean+this.stdDev*r*s,t=this.mean+this.stdDev*a*s,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 tn{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;const a=r||Math.random();this.randu=Xt.alea(a.toString()),this.randn=new en(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,o;for(;;){do{r=this.randn.nextValue(),o=1+this.c*r}while(o<=0);if(o*=o*o,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-o+Math.log(o)),a=this.randu(),a<t||Math.log(a)<n)break}return o=1/this.beta*this.d*o,this.alpha<1&&(o*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(o)}convertValue(e){return"float32"===this.dtype?e:Math.round(e)}}class nn{constructor(e=0,t=1,n,r){if(this.canReturnFloat=()=>null==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=Xt.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}
2nextValue(){return this.convertValue(this.min+this.range*this.random())}}const rn=(0,u.op)({randomGamma_:function(e,t,n=1,r="float32",a){if((0,d.Ix)(e),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error(`Unsupported data type ${r}`);const o=new tn(t,n,r,a),s=(0,q.c)(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}}),an=(0,u.op)({randomNormal_:function(e,t=0,n=1,r,a){if((0,d.Ix)(e),null!=r&&"bool"===r)throw new Error(`Unsupported data type ${r}`);const o=new en(t,n,r,!1,a),s=(0,q.c)(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}}),on=(0,u.op)({randomStandardNormal_:function(e,t,n){if(null!=t&&"bool"===t)throw new Error(`Unsupported data type ${t}`);return an(e,0,1,t,n)}}),sn=(0,u.op)({randomUniform_:function(e,t=0,n=1,r="float32",a){(0,d.Ix)(e);const o=(0,q.c)(e,r),s=new nn(t,n,null,a);for(let e=0;e<o.values.length;e++)o.values[e]=s.nextValue();return o.toTensor()}}),un=(0,u.op)({randomUniformInt_:function(e,t,n,r){return sn(e,t,n,"int32",r)}});function cn(e,t,n=1,r="float32"){if(0===n)throw new Error("Cannot have a step of zero");const a={start:e,stop:t,step:n,dtype:r};return o.cL.runKernel(s.EHu,{},a)}const ln=(0,u.op)({real_:function(e){const t={input:(0,i.ay)(e,"input","real")};return o.cL.runKernel(s.U1$,t)}}),pn=(0,u.op)({reciprocal_:function(e){const t={x:(0,i.ay)(e,"x","reciprocal")};return o.cL.runKernel(s.Ezp,t)}});var dn=n(36500),hn=n(98908);const fn=(0,u.op)({reverse_:function(e,t){const n={x:(0,i.ay)(e,"x","reverse")},r={dims:t};return o.cL.runKernel(s.glo,n,r)}}),mn=(0,u.op)({reverse1d_:function(e){const t=(0,i.ay)(e,"x","reverse");return d.Uc(1===t.rank,(()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)),fn(t,0)}}),gn=(0,u.op)({reverse2d_:function(e,t){const n=(0,i.ay)(e,"x","reverse");return d.Uc(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),fn(n,t)}}),yn=(0,u.op)({reverse3d_:function(e,t){const n=(0,i.ay)(e,"x","reverse");return d.Uc(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),fn(n,t)}}),bn=(0,u.op)({reverse4d_:function(e,t){const n=(0,i.ay)(e,"x","reverse");return d.Uc(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),fn(n,t)}}),wn=(0,u.op)({round_:function(e){const t={x:(0,i.ay)(e,"x","round")};return o.cL.runKernel(s.I$0,t)}}),vn=(0,u.op)({rsqrt_:function(e){const t={x:(0,i.ay)(e,"x","rsqrt","float32")};return o.cL.runKernel(s.o9c,t)}}),kn=(0,u.op)({selu_:function(e){const t={x:(0,i.ay)(e,"x","selu")};return o.cL.runKernel(s.PWB,t)}}),xn=(0,u.op)({separableConv2d_:function(e,t,n,r,a,o=[1,1],s="NHWC"){const u=(0,i.ay)(e,"x","separableConv2d"),c=(0,i.ay)(t,"depthwiseFilter","separableConv2d"),l=(0,i.ay)(n,"pointwiseFilter","separableConv2d");let p=u,h=!1;if(3===u.rank&&(h=!0,p=(0,N.O)(u,[1,u.shape[0],u.shape[1],u.shape[2]])),"NCHW"===s)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");d.Uc(4===p.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${p.rank}.`)),d.Uc(4===c.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${c.rank}.`)),d.Uc(4===l.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${c.rank}.`)),d.Uc(1===l.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`)),d.Uc(1===l.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`));const f=c.shape[2],m=c.shape[3];d.Uc(l.shape[2]===f*m,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${f*m}, but got ${l.shape[2]}.`));const g=fe(p,c,r,a,s,o),y=te(g,l,1,"valid",s);return h?(0,N.O)(y,[y.shape[1],y.shape[2],y.shape[3]]):y}}),_n=async function(e,t){const n=(0,i.ay)(e,"x","setdiff1d"),r=(0,i.ay)(t,"y","setdiff1d");d.Uc(n.dtype===r.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)),d.Uc(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),d.Uc(1===r.rank,(()=>`y should be 1D tensor, but got y (${r.shape}).`));const a=await n.data(),o=await r.data(),s=new Set(o);let u=0;for(let e=0;e<a.length;e++)s.has(a[e])||u++;const c=new Mt.Kq([u],n.dtype),l=new Mt.Kq([u],"int32");for(let e=0,t=0;e<a.length;e++)s.has(a[e])||(c.values[t]=a[e],l.values[t]=e,t++);return[c.toTensor(),l.toTensor()]},In=(0,u.op)({sign_:function(e){const t={x:(0,i.ay)(e,"x","sign")};return o.cL.runKernel(s.oyM,t)}}),Sn=(0,u.op)({sin_:function(e){const t={x:(0,i.ay)(e,"x","sin","float32")};return o.cL.runKernel(s.mrT,t)}}),Nn=(0,u.op)({sinh_:function(e){const t={x:(0,i.ay)(e,"x","sinh")};return o.cL.runKernel(s.OCc,t)}}),Mn=(0,u.op)({slice1d_:function(e,t,n){const r=(0,i.ay)(e,"x","slice1d");return d.Uc(1===r.rank,(()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)),C(r,[t],[n])}}),Tn=(0,u.op)({slice2d_:function(e,t,n){const r=(0,i.ay)(e,"x","slice2d");return d.Uc(2===r.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)),C(r,t,n)}}),En=(0,u.op)({slice3d_:function(e,t,n){const r=(0,i.ay)(e,"x","slice3d");return d.Uc(3===r.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)),C(r,t,n)}}),An=(0,u.op)({slice4d_:function(e,t,n){const r=(0,i.ay)(e,"x","slice4d");return d.Uc(4===r.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)),C(r,t,n)}}),Fn=(0,u.op)({softmax_:function(e,t=-1){const n=(0,i.ay)(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}
2 and dim was ${t}`);const r={logits:n},a={dim:t};return o.cL.runKernel(s.a0o,r,a)}}),Dn=(0,u.op)({fft_:function(e){(0,d.Uc)("complex64"===e.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`));const t={input:e};return o.cL.runKernel(s.mkE,t)}}),On=(0,u.op)({ifft_:function(e){(0,d.Uc)("complex64"===e.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`));const t={input:e};return o.cL.runKernel(s.OAQ,t)}}),Cn=(0,u.op)({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let r;if(t<=2){const a=(0,N.O)(e,[n,t]);r=On(a)}else{const a=[n,2*(t-1)],o=(0,N.O)(ln(e),[n,t]),s=(0,N.O)(Qe(e),[n,t]),i=fn(C(o,[0,1],[n,t-2]),1),u=(0,D.E)(fn(C(s,[0,1],[n,t-2]),1),(0,De.S)(-1)),c=A([o,i],1),l=A([s,u],1),p=(0,N.O)((0,Y.c)(c,l),[a[0],a[1]]);r=On(p)}if(r=ln(r),3===e.rank&&0!==e.shape[0]){const t=r,n=e.shape[0];r=(0,N.O)(r,[n,r.shape[0]/n,r.shape[1]]),t.dispose()}return r}}),Pn=(0,u.op)({split_:function(e,t,n=0){const r={x:(0,i.ay)(e,"x","split")},a={numOrSizeSplits:t,axis:n};return o.cL.runKernel(s.kDP,r,a)}}),Rn=(0,u.op)({rfft_:function(e,t){(0,d.Uc)("float32"===e.dtype,(()=>`The dtype for rfft() must be real value but got ${e.dtype}`));let n=e.shape[e.shape.length-1];const r=e.size/n;let a;if(null!=t&&t<n){const r=e.shape.map((e=>0)),o=e.shape.map((e=>e));o[e.shape.length-1]=t,a=C(e,r,o),n=t}else if(null!=t&&t>n){const r=e.shape.map((e=>e));r[e.shape.length-1]=t-n,a=A([e,St(r)],e.shape.length-1),n=t}else a=e;const o=(0,ke.E)(a),s=(0,N.O)((0,Y.c)(a,o),[r,n]),i=Dn(s),u=Math.floor(n/2)+1,c=ln(i),l=Qe(i),p=Pn(c,[u,n-u],c.shape.length-1),h=Pn(l,[u,n-u],l.shape.length-1),f=a.shape.slice();return f[a.shape.length-1]=u,(0,N.O)((0,Y.c)(p[0],h[0]),f)}}),$n=(0,u.op)({squaredDifference_:function(e,t){let n=(0,i.ay)(e,"a","squaredDifference"),r=(0,i.ay)(t,"b","squaredDifference");[n,r]=(0,k.yE)(n,r),(0,be.assertAndGetBroadcastShape)(n.shape,r.shape);const a={a:n,b:r};return o.cL.runKernel(s.uI0,a,{})}}),Ln=(0,u.op)({squeeze_:function(e,t){const n=(0,i.ay)(e,"x","squeeze","string_or_numeric");return(0,N.O)(n,(0,d.gD)(n.shape,t).newShape)}}),Wn=(0,u.op)({stack_:function(e,t=0){const n=(0,i.Y$)(e,"tensors","stack","string_or_numeric");d.Uc(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&d.Uc(t<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const r=n,a={axis:t};return o.cL.runKernel(s.cJi,r,a)}});var zn=n(21804);const Bn=(0,u.op)({stridedSlice_:function(e,t,n,r,a=0,u=0,c=0,l=0,p=0){const d={x:(0,i.ay)(e,"x","stridedSlice","string_or_numeric")},h={begin:t,end:n,strides:r,beginMask:a,endMask:u,ellipsisMask:c,newAxisMask:l,shrinkAxisMask:p};return o.cL.runKernel(s.cB,d,h)}}),Un=(0,u.op)({tan_:function(e){const t={x:(0,i.ay)(e,"x","tan","float32")};return o.cL.runKernel(s.epr,t)}});var Hn=n(77016),Vn=n(31560);function Gn(e,t){(0,d.Qn)(e);const n=(0,i._y)(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return(0,Vn.e)(e,null,n,t)}function qn(e,t,n){if((0,d.Qn)(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=(0,i._y)(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,Vn.e)(e,t,r,n)}var jn=n(9556);function Kn(e,t,n){if((0,d.Qn)(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=(0,i._y)(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,Vn.e)(e,t,r,n)}function Qn(e,t,n){if((0,d.Qn)(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=(0,i._y)(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,Vn.e)(e,t,r,n)}
2function Yn(e,t,n){if((0,d.Qn)(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=(0,i._y)(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,Vn.e)(e,t,r,n)}var Jn=n(65e3);const Zn=(0,u.op)({tensorScatterUpdate_:function(e,t,n){const r=(0,i.ay)(e,"tensor","tensorScatterupdate"),a=(0,i.ay)(t,"indices","tensorScatterupdate","int32"),u=(0,i.ay)(n,"updates","tensorScatterupdate");if(Jn.validateInput(u,a,r.shape),r.dtype!==u.dtype)throw new Error(`tensor and updates must have the same dtype, instead they are ${r.dtype} and ${u.dtype}.`);const c={tensor:r,indices:a,updates:u};return o.cL.runKernel(s.EBb,c,{})}}),Xn=(0,u.op)({topk_:function(e,t=1,n=!0){const r=(0,i.ay)(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const a=r.shape[r.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>a)throw new Error(`'k' passed to topk() must be <= the last dimension (${a}) but got ${t}`);const u={x:r},c={k:t,sorted:n},[l,p]=o.cL.runKernel(s.iIN,u,c);return{values:l,indices:p}}}),er=(0,u.op)({truncatedNormal_:function(e,t=0,n=1,r,a){if((0,d.Ix)(e),null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");const o=new en(t,n,r,!0,a),s=(0,q.c)(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}}),tr=(0,u.op)({unique_:function(e,t=0){const n=(0,i.ay)(e,"x","unique","string_or_numeric");(0,d.Uc)(n.rank>0,(()=>"The input tensor must be at least 1D"));const r={x:n},a={axis:t},[u,c]=o.cL.runKernel(s.Kyi,r,a);return{values:u,indices:c}}}),nr=(0,u.op)({unsortedSegmentSum_:function(e,t,n){const r=(0,i.ay)(e,"x","unsortedSegmentSum"),a=(0,i.ay)(t,"segmentIds","unsortedSegmentSum","int32");(0,d.Uc)((0,d.EH)(n),(()=>"numSegments must be of dtype int"));const u={x:r,segmentIds:a},c={numSegments:n};return o.cL.runKernel(s.imz,u,c)}}),rr=(0,u.op)({unstack_:function(e,t=0){const n=(0,i.ay)(e,"x","unstack","string_or_numeric");d.Uc(t>=-n.shape.length&&t<n.shape.length,(()=>`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`));const r={value:n},a={axis:t};return o.cL.runKernel(s.YZK,r,a)}});function ar(e,t){return bt(e,t,"right")}function or(e,t=!0,n,r){return o.cL.makeVariable(e,t,n,r)}var sr=n(13328);const ir=async function(e){const t=(0,i.ay)(e,"condition","whereAsync","bool"),n=await t.data(),r=(0,sr._)(t.shape,n);
2return e!==t&&t.dispose(),r},ur=async function(e,t,n){const r=(0,i.ay)(e,"tensor","boolMask"),a=(0,i.ay)(t,"mask","boolMask","bool"),o=null==n?0:n,s=a.rank,u=r.shape;d.Uc(s>0,(()=>"mask cannot be scalar")),d.kl(u.slice(o,o+s),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let c=1;for(let e=o;e<o+s;e++)c*=u[e];const l=u.slice(0,o).concat([c],u.slice(o+s)),p=(0,N.O)(r,l),h=(0,N.O)(a,[-1]),f=await ir(h),m=Ln(f,[1]),g=qe(p,m,o);return e!==r&&r.dispose(),t!==a&&a.dispose(),m.dispose(),p.dispose(),h.dispose(),f.dispose(),g};var cr=n(8244);const lr=(0,u.op)({transpose_:function(e,t,n){const r=(0,i.ay)(e,"x","transpose");if(null==t&&(t=r.shape.map(((e,t)=>t)).reverse()),d.Uc(r.rank===t.length,(()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`)),t.forEach((e=>{d.Uc(e>=0&&e<r.rank,(()=>"All entries in 'perm' must be between 0 and "+(r.rank-1)+` but got ${t}`))})),r.rank<=1)return r.clone();const a={x:r},u={perm:t};return"complex64"===r.dtype?(0,cr.G6)((()=>{let e=ln(r),t=Qe(r);return e=o.cL.runKernel(s.$Up,{x:e},u),t=o.cL.runKernel(s.$Up,{x:t},u),n&&(t=it(t)),(0,Y.c)(e,t)})):o.cL.runKernel(s.$Up,a,u)}}),pr=(0,u.op)({movingAverage_:function(e,t,n,r,a=!0){const o=(0,i.ay)(e,"v","movingAverage"),s=(0,i.ay)(t,"x","movingAverage"),u=(0,i.ay)(n,"decay","movingAverage");(0,k.q8)(o,s),d.Uc(d.eu(o.shape,s.shape),(()=>"Shape mismatch in v and x"));const c=(0,De.S)(1),l=(0,lt.A)(c,u);let h=(0,D.E)((0,lt.A)(s,o),l);if(a){d.Uc(null!=r,(()=>"When using zeroDebias: true, step is required."));const e=(0,i.ay)(r,"step","movingAverage");h=(0,ye.M)(h,(0,lt.A)(c,(0,Fe.g)(u,e)))}return(0,p.W)(o,h)}}),dr=(0,u.op)({scatterND_:function(e,t,n){(0,d.Ix)(n);const r=(0,i.ay)(e,"indices","scatterND","int32"),a=(0,i.ay)(t,"updates","scatterND");Jn.validateInput(a,r,n);const u={indices:r,updates:a},c={shape:n};return o.cL.runKernel(s.qiV,u,c)}}),hr=(0,u.op)({sparseToDense_:function(e,t,n,r=0){(0,d.Ix)(n);const a=(0,i.ay)(e,"sparseIndices","sparseToDense","int32"),u=(0,i.ay)(t,"sparseValues","sparseToDense","string_or_numeric"),c=(0,i.ay)(r,"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,o=e.rank>1?e.shape[1]:1;if(n.length!==o)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${o}.`);const s=t.size;if(0!==t.rank&&(1!==t.rank||s!==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")}(a,u,n,c);const l={sparseIndices:a,sparseValues:u,defaultValue:c},p={outputShape:n};return o.cL.runKernel(s.inF,l,p)}}),fr=(0,u.op)({gatherND_:function(e,t){const n=(0,i.ay)(t,"indices","gatherND","int32"),r={params:(0,i.ay)(e,"x","gatherND","string_or_numeric"),indices:n};return o.cL.runKernel(s.SOJ,r)}}),mr=(0,u.op)({dropout_:function(e,t,n,r){const a=(0,i.ay)(e,"x","dropout");if(d.Uc("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.`)),d.Uc(t>=0&&t<1,(()=>`rate must be a float in the range [0, 1), but got ${t}.`)),0===t)return e instanceof Mt.w3?a.clone():a;const o=function(e,t){if(null==t)return e.shape.slice();if(d.eu(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r<e.shape.length;r++)null==t[r]&&null!=e.shape[r]?n.push(e.shape[r]):n.push(t[r]);return n}return t}(a,n),s=1-t,u=(0,ye.M)(Ve((0,p.W)(sn(o,0,1,"float32",r),s)),s);return(0,D.E)(a,u)}});function gr(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function yr(e,t,n){const r=1-e%2,a=new Float32Array(e);for(let o=0;o<e;++o){const s=2*Math.PI*o/(e+r-1);a[o]=t-n*Math.cos(s)}return Gn(a,"float32")}const br=async function(e,t,n=1){const r=(0,i.ay)(e,"predictions","inTopK"),a=(0,i.ay)(t,"targets","inTopK");(0,d.Uc)(r.rank>1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)),(0,d.Uc)(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,d.kl)(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 o=r.shape[r.shape.length-1];(0,d.Uc)(n>0&&n<=o,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${o}), but got ${n}`));const s=await r.data(),u=await a.data(),[c,l]=[s.length/o,o],p=(0,d.q2)("bool",c);for(let e=0;e<c;e++){const t=e*l,r=s.subarray(t,t+l),a=[];for(let e=0;e<r.length;e++)a.push({value:r[e],index:e});a.sort(((e,t)=>t.value-e.value)),p[e]=0;for(let t=0;t<n;t++)if(a[t].index===u[e]){p[e]=1;break}}return e!==r&&r.dispose(),t!==a&&a.dispose(),(0,Hn.m)(p,a.shape,"bool")}
2,wr=(0,u.op)({conv2DBackpropFilter_:function(e,t,n,r,a,i="NHWC",u){let c=e;3===e.rank&&(c=(0,N.O)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;3===l.rank&&(l=(0,N.O)(t,[1,t.shape[0],t.shape[1],t.shape[2]])),d.Uc(4===c.rank,(()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${c.shape}.`)),d.Uc(4===l.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`)),d.Uc(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const p="NHWC"===i?c.shape[3]:c.shape[1],h="NHWC"===i?l.shape[3]:l.shape[1];d.Uc(p===n[2],(()=>`Error in conv2dDerFilter: depth of input ${p}) must match input depth in filter (${n[2]}.`)),d.Uc(h===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${h}) must match output depth for filter (${n[3]}).`)),S.YV("conv2dDerFilter",a,u);const f={x:c,dy:l},m={strides:r,pad:a,dataFormat:i,dimRoundingMode:u,filterShape:n};return o.cL.runKernel(s.OHx,f,m)}});var vr=n(46120);const kr=(0,u.op)({fusedConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:u=[1,1],dimRoundingMode:c,bias:l,activation:h="linear",preluActivationWeights:f,leakyreluAlpha:m}){if(h=h||"linear",!1===(0,vr.M$)(o.cL.state.gradientDepth,h)){d.Uc("NHWC"===a,(()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let o=te(e,t,n,r,a,u,c);return null!=l&&(o=(0,p.W)(o,l)),(0,vr.il)(o,h,f,m)}const g=(0,i.ay)(e,"x","conv2d","float32"),y=(0,i.ay)(t,"filter","conv2d","float32");let b=g,w=!1;3===g.rank&&(w=!0,b=(0,N.O)(g,[1,g.shape[0],g.shape[1],g.shape[2]])),d.Uc(4===b.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${b.rank}.`)),d.Uc(4===y.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${y.rank}.`)),S.YV("fused conv2d",r,c);const v="NHWC"===a?b.shape[3]:b.shape[1];d.Uc(y.shape[2]===v,(()=>`Error in conv2d: depth of input (${v}) must match input depth for filter ${y.shape[2]}.`)),d.Uc(S.uo(n,u),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${u}'`));
2const x=S.S4(b.shape,y.shape,n,u,r,c);let _,I;if(null!=l&&(_=(0,i.ay)(l,"bias","fused conv2d"),[_]=(0,k.yE)(_,g),"NHWC"===a?be.assertAndGetBroadcastShape(x.outShape,_.shape):(d.Uc(_.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${_.shape.length}.`)),d.Uc(0===_.shape.length||_.shape[0]===x.outChannels||1===_.shape[0],(()=>`Error in fused conv2d: bias shape (${_.shape}) is not compatible with the number of output channels (${x.outChannels})`)))),null!=f){const e=f.shape;if(d.Uc(e.length<=1||3===e.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)),1===e.length)d.Uc(1===e[0]||e[0]===x.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${x.outChannels}).`));else if(3===e.length)try{be.assertAndGetBroadcastShape(e,x.outShape)}catch(t){const n=`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${x.outShape}).`;throw Error(n)}I=(0,i.ay)(f,"prelu weights","fused conv2d")}const M=(e,t)=>{d.Uc("NHWC"===a,(()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`));const[o,s,i,c]=t,l=(0,vr.u1)(e,i,h);d.Uc(S.mw(u),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${u}'`));const p=[re(s.shape,l,o,n,r),wr(s,l,o.shape,n,r)];if(null!=c){const e=(0,vr.Ql)(c,l);p.push(e)}return p},T={x:b,filter:y,bias:_,preluActivationWeights:I},E={strides:n,pad:r,dataFormat:a,dilations:u,dimRoundingMode:c,activation:h,leakyreluAlpha:m};if(null==l){const e=(0,st.Sw)(((e,t,n)=>
2{let r=o.cL.runKernel(s.S4v,T,E);return n([t,e,r]),w&&(r=(0,N.O)(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:M}}));return e(b,y)}{const e=(0,st.Sw)(((e,t,n,r)=>{let a=o.cL.runKernel(s.S4v,T,E);return r([t,e,a,n]),w&&(a=(0,N.O)(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:M}}));return e(b,y,_)}}}),xr=(0,u.op)({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,i=[1,1],u){let c=e;3===e.rank&&(c=(0,N.O)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;3===l.rank&&(l=(0,N.O)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const p={x:c,dy:l},d={strides:r,pad:a,dimRoundingMode:u,dilations:i,filterShape:n};return o.cL.runKernel(s.eKw,p,d)}}),_r=(0,u.op)({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,i=[1,1],u){let c=t,l=!1;3===t.rank&&(l=!0,c=(0,N.O)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const p={dy:c,filter:n},d={strides:r,pad:a,dimRoundingMode:u,dilations:i,inputShape:e},h=o.cL.runKernel(s.yoD,p,d);return l?(0,N.O)(h,[h.shape[1],h.shape[2],h.shape[3]]):h}}),Ir=(0,u.op)({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:u=[1,1],dimRoundingMode:c,bias:l,activation:h="linear",preluActivationWeights:f,leakyreluAlpha:m}){if(!1===(0,vr.M$)(o.cL.state.gradientDepth,h)){let o=fe(e,t,n,r,a,u,c);return null!=l&&(o=(0,p.W)(o,l)),(0,vr.il)(o,h,f,m)}const g=(0,i.ay)(e,"x","depthwiseConv2d","float32"),y=(0,i.ay)(t,"filter","depthwiseConv2d","float32");let b=g,w=!1;3===g.rank&&(w=!0,b=(0,N.O)(g,[1,g.shape[0],g.shape[1],g.shape[2]])),d.Uc(4===b.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${b.rank}.`)),d.Uc(4===y.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${y.rank}.`)),d.Uc(b.shape[3]===y.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${b.shape[3]}) must match the inChannels dimension in filter ${y.shape[2]}.`)),null==u&&(u=[1,1]),d.Uc(S.uo(n,u),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${u}'`)),S.YV("fused depthwiseConv2d",r,c);const v=S.S4(b.shape,y.shape,n,u,r,c,!0);let x,_;null!=l&&(x=(0,i.ay)(l,"bias","fused conv2d"),[x]=(0,k.yE)(x,g),be.assertAndGetBroadcastShape(v.outShape,x.shape)),null!=f&&(_=(0,i.ay)(f,"prelu weights","fused depthwiseConv2d"));const I=(e,t)=>{d.Uc(S.mw(u),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${u}'`));const[a,o,s,i]=t,l=(0,vr.u1)(e,s,h),p=_r(o.shape,l,a,n,r,u,c),f=xr(o,l,a.shape,n,r,u,c);return null!=i?[p,f,(0,vr.Ql)(x,l)]:[p,f]},M={x:b,filter:y,bias:x,preluActivationWeights:_},T={strides:n,pad:r,dataFormat:a,dilations:u,dimRoundingMode:c,activation:h,leakyreluAlpha:m};if(null==l){const e=(0,st.Sw)(((e,t,n)=>{let r=o.cL.runKernel(s.Mjd,M,T);return n([t,e,r]),w&&(r=(0,N.O)(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:I}}));return e(b,y)}{const e=(0,st.Sw)(((e,t,n,r)=>{let a=o.cL.runKernel(s.Mjd,M,T);return r([t,e,a,n]),w&&(a=(0,N.O)(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:I}}));return e(b,y,x)}}}),Sr=(0,u.op)({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:a,activation:u="linear",preluActivationWeights:c,leakyreluAlpha:l=.2}){if(!1===(0,vr.M$)(o.cL.state.gradientDepth,u)){let o=F(e,t,n,r);return null!=a&&(o=(0,p.W)(o,a)),(0,vr.il)(o,u,c,l)}let h=(0,i.ay)(e,"a","fused matMul"),f=(0,i.ay)(t,"b","fused matMul");[h,f]=(0,k.yE)(h,f);const m=n?h.shape[h.rank-2]:h.shape[h.rank-1],g=r?f.shape[f.rank-1]:f.shape[f.rank-2],y=n?h.shape[h.rank-1]:h.shape[h.rank-2],b=r?f.shape[f.rank-2]:f.shape[f.rank-1],w=h.shape.slice(0,-2),v=f.shape.slice(0,-2),x=d.It(w),_=d.It(v);d.Uc(m===g,(()=>`Error in fused matMul: inner shapes (${m}) and (${g}) of Tensors with shapes ${h.shape} and ${f.shape} and transposeA=${n} and transposeB=${r} must match.`));const I=be.assertAndGetBroadcastShape(h.shape.slice(0,-2),f.shape.slice(0,-2)).concat([y,b]),S=n?(0,N.O)(h,[x,m,y]):(0,N.O)(h,[x,y,m]),M=r?(0,N.O)(f,[_,b,g]):(0,N.O)(f,[_,g,b]);let T,E;null!=a&&(T=(0,i.ay)(a,"bias","fused matMul"),[T]=(0,k.yE)(T,h),be.assertAndGetBroadcastShape(I,T.shape)),null!=c&&(E=(0,i.ay)(c,"prelu weights","fused matMul"));const A=(e,t)=>
2{const[o,s,i,c]=t,l=(0,vr.u1)((0,N.O)(e,i.shape),i,u);let p,d;return n||r?!n&&r?(p=F(l,s,!1,!1),d=F(l,o,!0,!1)):n&&!r?(p=F(s,l,!1,!0),d=F(o,l,!1,!1)):(p=F(s,l,!0,!0),d=F(l,o,!0,!0)):(p=F(l,s,!1,!0),d=F(o,l,!0,!1)),null!=a?[p,d,(0,vr.Ql)(c,l)]:[p,d]},D={a:S,b:M,bias:T,preluActivationWeights:E},O={transposeA:n,transposeB:r,activation:u,leakyreluAlpha:l};if(null==a){const e=(0,st.Sw)(((e,t,n)=>{const r=o.cL.runKernel(s.gHH,D,O);return n([e,t,r]),{value:(0,N.O)(r,I),gradFunc:A}}));return e(S,M)}{const e=(0,st.Sw)(((e,t,n,r)=>{const a=o.cL.runKernel(s.gHH,D,O);return r([e,t,a,n]),{value:(0,N.O)(a,I),gradFunc:A}}));return e(S,M,T)}}}),Nr=(0,u.op)({hammingWindow_:function(e){return yr(e,.54,.46)}}),Mr=(0,u.op)({hannWindow_:function(e){return yr(e,.5,.5)}}),Tr=(0,u.op)({frame_:function(e,t,n,r=!1,a=0){let o=0;const s=[];for(;o+t<=e.size;)s.push(C(e,o,t)),o+=n;if(r)for(;o<e.size;){const r=o+t-e.size,i=A([C(e,o,t-r),(0,K.y)([r],a)]);s.push(i),o+=n}return 0===s.length?qn([],[0,t]):(0,N.O)(A(s),[s.length,t])}}),Er=(0,u.op)({stft_:function(e,t,n,r,a=Mr){null==r&&(r=gr(t));const o=Tr(e,t,n),s=(0,D.E)(o,a(t));return Rn(s,r)}}),Ar=(0,u.op)({cropAndResize_:function(e,t,n,r,a="bilinear",u=0){const c=(0,i.ay)(e,"image","cropAndResize"),l=(0,i.ay)(t,"boxes","cropAndResize","float32"),p=(0,i.ay)(n,"boxInd","cropAndResize","int32"),h=l.shape[0];d.Uc(4===c.rank,(()=>`Error in cropAndResize: image must be rank 4,but got rank ${c.rank}.`)),d.Uc(2===l.rank&&4===l.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${h},4] but had shape ${l.shape}.`)),d.Uc(1===p.rank&&p.shape[0]===h,(()=>`Error in cropAndResize: boxInd must be have size [${h}] but had shape ${l.shape}.`)),d.Uc(2===r.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)),d.Uc(r[0]>=1&&r[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${r}`)),d.Uc("bilinear"===a||"nearest"===a,(()=>`method must be bilinear or nearest, but was ${a}`));const f={image:c,boxes:l,boxInd:p},m={method:a,extrapolationValue:u,cropSize:r};return o.cL.runKernel(s.WO0,f,m)}}),Fr=(0,u.op)({flipLeftRight_:function(e){const t=(0,i.ay)(e,"image","flipLeftRight","float32");d.Uc(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return o.cL.runKernel(s.ELw,n,{})}}),Dr=(0,u.op)({grayscaleToRGB_:function(e){const t=(0,i.ay)(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];d.Uc(t.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)),d.Uc(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,Ue(t,a)}}),Or=(0,u.op)({rgbToGrayscale_:function(e){const t=(0,i.ay)(e,"image","RGBToGrayscale"),n=t.rank-1,r=t.shape[n];d.Uc(t.rank>=2,(()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${t.rank}.`)),d.Uc(3===r,(()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`));const a=t.dtype,o=(0,I.W)(t,"float32"),s=Gn([.2989,.587,.114]);let u;switch(t.rank){case 2:u=Ie("ij,j->i",o,s);break;case 3:u=Ie("ijk,k->ij",o,s);break;case 4:u=Ie("ijkl,l->ijk",o,s);break;case 5:u=Ie("ijklm,m->ijkl",o,s);break;case 6:u=Ie("ijklmn,n->ijklm",o,s);break;default:throw new Error("Not a valid tensor rank.")}return u=ze(u,-1),(0,I.W)(u,a)}}),Cr=(0,u.op)({rotateWithOffset_:function(e,t,n=0,r=.5){const a=(0,i.ay)(e,"image","rotateWithOffset","float32");d.Uc(4===a.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`));const u={image:a},c={radians:t,fillValue:n,center:r};return o.cL.runKernel(s.qWz,u,c)}});function Pr(e,t,n,r,a,o){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==o&&(o=0);const s=e.shape[0];return n=Math.min(n,s),d.Uc(0<=r&&r<=1,(()=>`iouThreshold must be in [0, 1], but was '${r}'`)),d.Uc(2===e.rank,(()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`)),d.Uc(4===e.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)),d.Uc(1===t.rank,(()=>"scores must be a 1D tensor")),d.Uc(t.shape[0]===s,(()=>`scores has incompatible shape with boxes. Expected ${s}, but was ${t.shape[0]}`)),d.Uc(0<=o&&o<=1,(()=>`softNmsSigma must be in [0, 1], but was '${o}'`)),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:o}}
2const Rr=(0,u.op)({nonMaxSuppression_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const u=(0,i.ay)(e,"boxes","nonMaxSuppression","float32"),c=(0,i.ay)(t,"scores","nonMaxSuppression","float32"),l=Pr(u,c,n,r,a),p={maxOutputSize:n=l.maxOutputSize,iouThreshold:r=l.iouThreshold,scoreThreshold:a=l.scoreThreshold};return o.cL.runKernel(s.aaw,{boxes:u,scores:c},p)}});var $r=n(75941);const Lr=(0,u.op)({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,u=0){const c=(0,i.ay)(e,"boxes","nonMaxSuppression"),l=(0,i.ay)(t,"scores","nonMaxSuppression"),p=Pr(c,l,n,r,a,u),d={boxes:c,scores:l},h={maxOutputSize:n=p.maxOutputSize,iouThreshold:r=p.iouThreshold,scoreThreshold:a=p.scoreThreshold,softNmsSigma:u=p.softNmsSigma},f=o.cL.runKernel(s.q82,d,h);return{selectedIndices:f[0],selectedScores:f[1]}}}),Wr=(0,u.op)({nonMaxSuppressionPadded_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,u=!1){const c=(0,i.ay)(e,"boxes","nonMaxSuppression"),l=(0,i.ay)(t,"scores","nonMaxSuppression"),p=Pr(c,l,n,r,a,null),d={boxes:c,scores:l},h={maxOutputSize:p.maxOutputSize,iouThreshold:p.iouThreshold,scoreThreshold:p.scoreThreshold,padToMaxOutputSize:u},f=o.cL.runKernel(s.Q7n,d,h);return{selectedIndices:f[0],validOutputs:f[1]}}}),zr=(0,u.op)({resizeBilinear_:function(e,t,n=!1,r=!1){const a=(0,i.ay)(e,"images","resizeBilinear");d.Uc(3===a.rank||4===a.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`)),d.Uc(2===t.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)),d.Uc(!1===r||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let u=a,c=!1;3===a.rank&&(c=!0,u=(0,N.O)(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,l={images:u},p={alignCorners:n,halfPixelCenters:r,size:t},h=o.cL.runKernel(s.qaT,l,p);return c?(0,N.O)(h,[h.shape[1],h.shape[2],h.shape[3]]):h}}),Br=(0,u.op)({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const a=(0,i.ay)(e,"images","resizeNearestNeighbor");d.Uc(3===a.rank||4===a.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`)),d.Uc(2===t.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)),d.Uc("float32"===a.dtype||"int32"===a.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),d.Uc(!1===r||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let u=a,c=!1;3===a.rank&&(c=!0,u=(0,N.O)(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,l={images:u},p={alignCorners:n,halfPixelCenters:r,size:t},h=o.cL.runKernel(s.Co2,l,p);return c?(0,N.O)(h,[h.shape[1],h.shape[2],h.shape[3]]):h}}
2),Ur=(0,u.op)({threshold_:function(e,t="binary",n=!1,r=.5){const a=(0,i.ay)(e,"image","threshold"),o=a.shape[0]*a.shape[1];let s,u,c,l,h=(0,D.E)(Gn([r]),255);if(d.Uc(3===a.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`)),d.Uc(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]}.`)),d.Uc("int32"===a.dtype||"float32"===a.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`)),d.Uc("otsu"===t||"binary"===t,(()=>`Method must be binary or otsu, but was ${t}`)),3===a.shape[2]){[s,u,c]=Pn(a,[1,1,1],-1);const e=(0,D.E)(s,.2989),t=(0,D.E)(u,.587),n=(0,D.E)(c,.114);l=(0,p.W)((0,p.W)(e,t),n)}else l=e;"otsu"===t&&(h=function(e,t){let n,r,a,o,s,i,u=Gn([-1]),c=Gn([0]),l=Gn([0]);for(let d=0;d<e.size-1;d++){n=C(e,0,d+1),r=C(e,d+1),s=(0,ye.M)((0,Pe.o)(n),t),i=(0,ye.M)((0,Pe.o)(r),t);const h=(0,Pe.o)((0,D.E)(n,cn(0,n.size)));a=(0,ye.M)(h,(0,Pe.o)(n));const f=(0,K.y)(r.shape,n.size),m=(0,p.W)(cn(0,r.size),f),g=(0,D.E)(r,m);o=(0,ye.M)((0,Pe.o)(g),(0,Pe.o)(r));const y=(0,lt.A)(a,o),b=(0,lt.A)(a,o),w=(0,D.E)(s,i);l=(0,D.E)((0,D.E)(w,y),b);const v=je(l,c);c=ve(v,l,c),u=ve(v,Gn([d]),u)}return u}(U((0,I.W)(wn(l),"int32"),(0,Hn.m)([]),256),o));const f=n?tt(l,h):je(l,h);return(0,I.W)((0,D.E)(f,255),"int32")}}),Hr=(0,u.op)({transform_:function(e,t,n="nearest",r="constant",a=0,u){const c=(0,i.ay)(e,"image","transform","float32"),l=(0,i.ay)(t,"transforms","transform","float32");d.Uc(4===c.rank,(()=>`Error in transform: image must be rank 4,but got rank ${c.rank}.`)),d.Uc(2===l.rank&&(l.shape[0]===c.shape[0]||1===l.shape[0])&&8===l.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),d.Uc(null==u||2===u.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${u}.`));const p={image:c,transforms:l},h={interpolation:n,fillMode:r,fillValue:a,outputShape:u};return o.cL.runKernel(s.wjp,p,h)}}),Vr=(0,u.op)({bandPart_:function(e,t,n){const r=(0,i.ay)(e,"a","bandPart");(0,d.Uc)(r.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`));const a=r.shape,[o,s]=r.shape.slice(-2);let u,c;"number"==typeof t?((0,d.Uc)(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),(0,d.Uc)(t<=o,(()=>`bandPart(): numLower (${t}) must not be greater than the number of rows (${o}).`)),u=(0,i.ay)(t<0?o:t,"numLower","bandPart")):((0,d.Uc)("int32"===t.dtype,(()=>"bandPart(): numLower's dtype must be an int32.")),u=ve(et(t,0),o,Et(t,o))),"number"==typeof n?((0,d.Uc)(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`)),(0,d.Uc)(n<=s,(()=>`bandPart(): numUpper (${n}) must not be greater than the number of columns (${s}).`)),c=(0,i.ay)(n<0?s:n,"numUpper","bandPart")):((0,d.Uc)("int32"===n.dtype,(()=>"bandPart(): numUpper's dtype must be an int32.")),c=ve(et(n,0),s,Et(n,s)));const l=(0,N.O)(cn(0,o,1,"int32"),[-1,1]),p=cn(0,s,1,"int32"),h=(0,lt.A)(l,p),f=ht(tt(h,u),Ke(h,it(c))),m=St([o,s],r.dtype);return(0,N.O)(Wn(rr((0,N.O)(r,[-1,o,s])).map((e=>ve(f,e,m)))),a)}}),Gr=(0,u.op)({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,(0,d.Uc)(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<e.length;++t)(0,d.Uc)(e[t].shape[0]===n,(()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`))}else t=!0,e=Pn(e,e.shape[0],0).map((e=>Ln(e,[0])));(0,d.Uc)(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<e.length;++t)n.push(o.cL.tidy((()=>{let e=r[t];if(t>0)for(let r=0;r<t;++r){const t=(0,D.E)((0,Pe.o)((0,D.E)(n[r],e)),n[r]);e=(0,lt.A)(e,t)}return(0,ye.M)(e,$e(e,"euclidean"))})));return t?Wn(n,0):n}});function qr(e,t=!1){return o.cL.tidy((()=>{(0,d.Uc)(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=He(n),s=(0,E.c)(e);const i=qn([[1]],[1,1]);let u=(0,E.c)(i);const c=n>=r?r:n;for(let e=0;e<c;++e){const t=s,c=u,l=a;[u,s,a]=o.cL.tidy((()=>{const t=C(s,[e,e],[n-e,1]),o=$e(t),c=C(s,[e,e],[1,1]),l=ve(je(c,0),qn([[-1]]),qn([[1]])),p=(0,lt.A)(c,(0,D.E)(l,o)),d=(0,ye.M)(t,p);u=1===d.shape[0]?(0,E.c)(i):A([i,C(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);const h=it((0,ye.M)(F(l,p),o)),f=C(s,[e,0],[n-e,r]),m=(0,D.E)(h,u),g=lr(u);if(0===e)s=(0,lt.A)(f,F(m,F(g,f)));else{const t=(0,lt.A)(f,F(m,F(g,f)));s=A([C(s,[0,0],[e,r]),t],0)}const y=lr(m),b=C(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=(0,lt.A)(b,F(F(b,u),y));else{const t=(0,lt.A)(b,F(F(b,u),y));a=A([C(a,[0,0],[n,e]),t],1)}return[u,s,a]})),(0,cr.Mt)([t,c,l])}return!t&&n>r&&(a=C(a,[0,0],[n,r]),s=C(s,[0,0],[r,r])),[a,s]}))}
2const jr=(0,u.op)({qr_:function(e,t=!1){if((0,d.Uc)(e.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)),2===e.rank)return qr(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce(((e,t)=>e*t)),r=rr((0,N.O)(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],o=[];return r.forEach((e=>{const[n,r]=qr(e,t);a.push(n),o.push(r)})),[(0,N.O)(Wn(a,0),e.shape),(0,N.O)(Wn(o,0),e.shape)]}}});var Kr;!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"}(Kr||(Kr={}));const Qr=(0,u.op)({computeWeightedLoss_:function(e,t,n=Kr.SUM_BY_NONZERO_WEIGHTS){const r=(0,i.ay)(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=(0,i.ay)(t,"weights","computeWeightedLoss"));const o=null==a?r:(0,D.E)(r,a);if(n===Kr.NONE)return o;if(n===Kr.SUM)return(0,Pe.o)(o);if(n===Kr.MEAN){if(null==a)return It(o);{const e=r.size/a.size,t=(0,ye.M)((0,Pe.o)(o),(0,Pe.o)(a));return e>1?(0,ye.M)(t,(0,De.S)(e)):t}}if(n===Kr.SUM_BY_NONZERO_WEIGHTS){if(null==a)return(0,ye.M)((0,Pe.o)(o),(0,De.S)(r.size));{const e=(0,D.E)(a,Nt(r.shape)),t=(0,I.W)((0,Pe.o)(Pt(e,(0,De.S)(0))),"float32");return(0,ye.M)((0,Pe.o)(o),t)}}throw Error(`Unknown reduction: ${n}`)}}),Yr=(0,u.op)({absoluteDifference_:function(e,t,n,r=Kr.SUM_BY_NONZERO_WEIGHTS){const o=(0,i.ay)(e,"labels","absoluteDifference"),s=(0,i.ay)(t,"predictions","absoluteDifference");let u=null;null!=n&&(u=(0,i.ay)(n,"weights","absoluteDifference")),(0,d.kl)(o.shape,s.shape,"Error in absoluteDifference: ");const c=(0,a.a)((0,lt.A)(o,s));return Qr(c,u,r)}}),Jr=(0,u.op)({cosineDistance_:function(e,t,n,r,a=Kr.SUM_BY_NONZERO_WEIGHTS){const o=(0,i.ay)(e,"labels","cosineDistance"),s=(0,i.ay)(t,"predictions","cosineDistance");let u=null;null!=r&&(u=(0,i.ay)(r,"weights","cosineDistance")),(0,d.kl)(o.shape,s.shape,"Error in cosineDistance: ");const c=(0,De.S)(1),l=(0,lt.A)(c,(0,Pe.o)((0,D.E)(o,s),n,!0));return Qr(l,u,a)}}),Zr=(0,u.op)({hingeLoss_:function(e,t,n,r=Kr.SUM_BY_NONZERO_WEIGHTS){let a=(0,i.ay)(e,"labels","hingeLoss");const o=(0,i.ay)(t,"predictions","hingeLoss");let s=null;null!=n&&(s=(0,i.ay)(n,"weights","hingeLoss")),(0,d.kl)(a.shape,o.shape,"Error in hingeLoss: ");const u=(0,De.S)(1);a=(0,lt.A)((0,D.E)((0,De.S)(2),a),u);const c=(0,dn.w)((0,lt.A)(u,(0,D.E)(a,o)));return Qr(c,s,r)}}),Xr=(0,u.op)({huberLoss_:function(e,t,n,r=1,o=Kr.SUM_BY_NONZERO_WEIGHTS){const s=(0,i.ay)(e,"labels","huberLoss"),u=(0,i.ay)(t,"predictions","huberLoss");let c=null;null!=n&&(c=(0,i.ay)(n,"weights","huberLoss")),(0,d.kl)(s.shape,u.shape,"Error in huberLoss: ");const l=(0,De.S)(r),h=(0,a.a)((0,lt.A)(u,s)),f=Et(h,l),m=(0,lt.A)(h,f),g=(0,p.W)((0,D.E)((0,De.S)(.5),(0,Ce.Q)(f)),(0,D.E)(l,m));return Qr(g,c,o)}}),ea=(0,u.op)({logLoss_:function(e,t,n,r=1e-7,a=Kr.SUM_BY_NONZERO_WEIGHTS){const o=(0,i.ay)(e,"labels","logLoss"),s=(0,i.ay)(t,"predictions","logLoss");let u=null;null!=n&&(u=(0,i.ay)(n,"weights","logLoss")),(0,d.kl)(o.shape,s.shape,"Error in logLoss: ");const c=(0,De.S)(1),l=(0,De.S)(r),h=it((0,D.E)(o,at((0,p.W)(s,l)))),f=(0,D.E)((0,lt.A)(c,o),at((0,p.W)((0,lt.A)(c,s),l))),m=(0,lt.A)(h,f);return Qr(m,u,a)}}),ta=(0,u.op)({meanSquaredError_:function(e,t,n,r=Kr.SUM_BY_NONZERO_WEIGHTS){const a=(0,i.ay)(e,"labels","meanSquaredError"),o=(0,i.ay)(t,"predictions","meanSquaredError");let s=null;null!=n&&(s=(0,i.ay)(n,"weights","meanSquaredError")),(0,d.kl)(a.shape,o.shape,"Error in meanSquaredError: ");const u=$n(a,o);return Qr(u,s,r)}}),na=(0,u.op)({sigmoidCrossEntropy_:function(e,t,n,r=0,o=Kr.SUM_BY_NONZERO_WEIGHTS){let s=(0,i.ay)(e,"multiClassLabels","sigmoidCrossEntropy");const u=(0,i.ay)(t,"logits","sigmoidCrossEntropy");let c=null;if(null!=n&&(c=(0,i.ay)(n,"weights","sigmoidCrossEntropy")),(0,d.kl)(s.shape,u.shape,"Error in sigmoidCrossEntropy: "),r>0){const e=(0,De.S)(r),t=(0,De.S)(1),n=(0,De.S)(.5);s=(0,p.W)((0,D.E)(s,(0,lt.A)(t,e)),(0,D.E)(n,e))}const l=function(e,t){const n=(0,i.ay)(e,"labels","sigmoidCrossEntropyWithLogits"),r=(0,i.ay)(t,"logits","sigmoidCrossEntropyWithLogits");(0,d.kl)(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const o=(0,dn.w)(r),s=(0,D.E)(r,n),u=ot(We(it((0,a.a)(r))));return(0,p.W)((0,lt.A)(o,s),u)}(s,u);return Qr(l,c,o)}}),ra=(0,u.op)({softmaxCrossEntropy_:function(e,t,n,r=0,a=Kr.SUM_BY_NONZERO_WEIGHTS){let o=(0,i.ay)(e,"onehotLabels","softmaxCrossEntropy");const s=(0,i.ay)(t,"logits","softmaxCrossEntropy");let u=null;if(null!=n&&(u=(0,i.ay)(n,"weights","softmaxCrossEntropy")),(0,d.kl)(o.shape,s.shape,"Error in softmaxCrossEntropy: "),r>0){const e=(0,De.S)(r),t=(0,De.S)(1),n=(0,De.S)(o.shape[1]);
2o=(0,p.W)((0,D.E)(o,(0,lt.A)(t,e)),(0,ye.M)(e,n))}const c=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}`);const r=(0,st.Sw)(((e,t,r)=>{const a=dt(t,[n],!0),o=(0,lt.A)((0,I.W)(t,"float32"),a);r([e,o]);const s=it((0,D.E)(o,e));return{value:(0,Pe.o)(s,[n]),gradFunc:(e,t)=>{const[r,a]=t,o=(0,Te.Mp)(e.shape,[n]);return[(0,D.E)((0,N.O)(e,o),(0,lt.A)((0,I.W)(r,"float32"),We(a))),(0,D.E)((0,N.O)(e,o),(0,lt.A)(We(a),(0,I.W)(r,"float32")))]}}}));return r(e,t)}(o,s);return Qr(c,u,a)}}),aa={fft:Dn,ifft:On,rfft:Rn,irfft:Cn},oa={hammingWindow:Nr,hannWindow:Mr,frame:Tr,stft:Er},sa={flipLeftRight:Fr,grayscaleToRGB:Dr,resizeNearestNeighbor:Br,resizeBilinear:zr,rgbToGrayscale:Or,rotateWithOffset:Cr,cropAndResize:Ar,nonMaxSuppression:Rr,nonMaxSuppressionAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const o=(0,i.ay)(e,"boxes","nonMaxSuppressionAsync"),s=(0,i.ay)(t,"scores","nonMaxSuppressionAsync"),u=Pr(o,s,n,r,a);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold;const c=await Promise.all([o.data(),s.data()]),l=c[0],p=c[1],{selectedIndices:d}=(0,$r.Wm)(l,p,n,r,a);return o!==e&&o.dispose(),s!==t&&s.dispose(),Gn(d,"int32")},nonMaxSuppressionWithScore:Lr,nonMaxSuppressionWithScoreAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,o=0){const s=(0,i.ay)(e,"boxes","nonMaxSuppressionAsync"),u=(0,i.ay)(t,"scores","nonMaxSuppressionAsync"),c=Pr(s,u,n,r,a,o);n=c.maxOutputSize,r=c.iouThreshold,a=c.scoreThreshold,o=c.softNmsSigma;const l=await Promise.all([s.data(),u.data()]),p=l[0],d=l[1],{selectedIndices:h,selectedScores:f}=(0,$r.eQ)(p,d,n,r,a,o);return s!==e&&s.dispose(),u!==t&&u.dispose(),{selectedIndices:Gn(h,"int32"),selectedScores:Gn(f)}},nonMaxSuppressionPadded:Wr,nonMaxSuppressionPaddedAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,o=!1){const s=(0,i.ay)(e,"boxes","nonMaxSuppressionAsync"),u=(0,i.ay)(t,"scores","nonMaxSuppressionAsync"),c=Pr(s,u,n,r,a,null),l=c.maxOutputSize,p=c.iouThreshold,d=c.scoreThreshold,[h,f]=await Promise.all([s.data(),u.data()]),{selectedIndices:m,validOutputs:g}=(0,$r.Mf)(h,f,l,p,d,o);return s!==e&&s.dispose(),u!==t&&u.dispose(),{selectedIndices:Gn(m,"int32"),validOutputs:(0,De.S)(g,"int32")}},threshold:Ur,transform:Hr},ia={bandPart:Vr,gramSchmidt:Gr,qr:jr},ua={absoluteDifference:Yr,computeWeightedLoss:Qr,cosineDistance:Jr,hingeLoss:Zr,huberLoss:Xr,logLoss:ea,meanSquaredError:ta,sigmoidCrossEntropy:na,softmaxCrossEntropy:ra},ca={sparseFillEmptyRows:(0,u.op)({sparseFillEmptyRows_:function(e,t,n,r){const a=(0,i.ay)(e,"indices","sparseFillEmptyRows","int32"),u=(0,i.ay)(t,"values","sparseFillEmptyRows"),c=(0,i.ay)(n,"denseShape","sparseFillEmptyRows","int32"),l=(0,i.ay)(r,"defaultValue","sparseFillEmptyRows",u.dtype);if(2!==a.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${a.shape}`);if(1!==u.rank)throw new Error(`Values should be Tensor1D but received shape ${u.shape}`);if(1!==c.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${c.shape}`);if(0!==l.rank)throw new Error(`Default value should be a scalar but received shape ${l.shape}`);const p={indices:a,values:u,denseShape:c,defaultValue:l},d=o.cL.runKernel(s.Omm,p);return{outputIndices:d[0],outputValues:d[1],emptyRowIndicator:d[2],reverseIndexMap:d[3]}}}),sparseReshape:(0,u.op)({sparseReshape_:function(e,t,n){const r=(0,i.ay)(e,"inputIndices","sparseReshape","int32"),a=(0,i.ay)(t,"inputShape","sparseReshape","int32"),u=(0,i.ay)(n,"newShape","sparseReshape","int32");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!==u.rank)throw new Error(`New shape should be Tensor1D but received shape ${u.shape}`);const c={inputIndices:r,inputShape:a,newShape:u},l=o.cL.runKernel(s.kfs,c);return{outputIndices:l[0],outputShape:l[1]}}}),sparseSegmentMean:(0,u.op)({sparseSegmentMean_:function(e,t,n){const r=(0,i.ay)(e,"data","sparseSegmentMean"),a=(0,i.ay)(t,"indices","sparseSegmentMean","int32"),u=(0,i.ay)(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");
2if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==u.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${u.shape}`);const c={data:r,indices:a,segmentIds:u};return o.cL.runKernel(s.QxB,c)}}),sparseSegmentSum:(0,u.op)({sparseSegmentSum_:function(e,t,n){const r=(0,i.ay)(e,"data","sparseSegmentSum"),a=(0,i.ay)(t,"indices","sparseSegmentSum","int32"),u=(0,i.ay)(n,"segmentIds","sparseSegmentSum","int32");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!==u.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${u.shape}`);const c={data:r,indices:a,segmentIds:u};return o.cL.runKernel(s.ra4,c)}})},la={stringNGrams:(0,u.op)({stringNGrams_:function(e,t,n,r,a,u,c,l){const p=(0,i.ay)(e,"data","stringNGrams","string");if("string"!==p.dtype)throw new Error("Data must be of datatype string");if(1!==p.shape.length)throw new Error(`Data must be a vector, saw: ${p.shape}`);const d=(0,i.ay)(t,"dataSplits","stringNGrams");if("int32"!==d.dtype)throw new Error("Data splits must be of datatype int32");const h={separator:n,nGramWidths:r,leftPad:a,rightPad:u,padWidth:c,preserveShortSequences:l},f={data:p,dataSplits:d},m=o.cL.runKernel(s.MPe,f,h);return{nGrams:m[0],nGramsSplits:m[1]}}}),stringSplit:(0,u.op)({stringSplit_:function(e,t,n=!0){const r=(0,i.ay)(e,"input","stringSplit","string"),a=(0,i.ay)(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 u={skipEmpty:n},c={input:r,delimiter:a},l=o.cL.runKernel(s.YNA,c,u);return{indices:l[0],values:l[1],shape:l[2]}}}),stringToHashBucketFast:(0,u.op)({stringToHashBucketFast_:function(e,t){const n=(0,i.ay)(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 o.cL.runKernel(s.Atw,a,r)}}),staticRegexReplace:(0,u.op)({staticRegexReplace_:function(e,t,n,r=!0){const a=(0,i.ay)(e,"input","staticRegexReplace","string"),u={pattern:t,rewrite:n,replaceGlobal:r};return o.cL.runKernel(s.CM,{x:a},u)}})}},94380:function(e,t,n){"use strict";n.d(t,{g:function(){return i}});var r=n(31748),a=n(38128),o=n(4172),s=n(72180);const i=(0,n(17336).op)({pow_:function(e,t){let n=(0,s.ay)(e,"base","pow"),i=(0,s.ay)(t,"exp","pow");[n,i]=(0,o.yE)(n,i);const u={a:n,b:i};return r.cL.runKernel(a.sTH,u)}})},20736:function(e,t,n){"use strict";n.d(t,{S:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({prelu_:function(e,t){const n={x:(0,o.ay)(e,"x","prelu"),alpha:(0,o.ay)(t,"alpha","prelu")};return r.cL.runKernel(a.cBF,n)}})},90800:function(e,t,n){"use strict";function r(e,t=!1){console.log(e.toString(t))}n.d(t,{S:function(){return r}})},36500:function(e,t,n){"use strict";n.d(t,{w:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({relu_:function(e){const t={x:(0,o.ay)(e,"x","relu")};return r.cL.runKernel(a.IHk,t)}})},98908:function(e,t,n){"use strict";n.d(t,{a:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({relu6_:function(e){const t={x:(0,o.ay)(e,"x","relu6")};return r.cL.runKernel(a.QwE,t)}})},58432:function(e,t,n){"use strict";n.d(t,{O:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({reshape_:function(e,t){const n={x:(0,o.ay)(e,"x","reshape","string_or_numeric")},s={shape:t};return r.cL.runKernel(a.MvO,n,s)}})},12988:function(e,t,n){"use strict";n.d(t,{S:function(){return o}});var r=n(10680),a=n(31560);function o(e,t){if(((0,r.isTypedArray)(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.isTypedArray)(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return(0,a.e)(e,[],[],t)}},65e3:function(e,t,n){"use strict";n.r(t),n.d(t,{calculateShapes:function(){return s},validateInput:function(){return o},validateUpdateShape:function(){return a}});var r=n(15952);function a(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,o=`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.rank<a)throw new Error(o+` update.rank < ${a}. `);if(e.length<r+(n.rank-a))throw new Error(o+` Output shape length < ${r+(n.rank-a)}`);if(n.rank!==a+e.length-r)throw new Error(o+" update.rank != "+(a+e.length-r));for(let e=0;e<a;++e)if(n.shape[e]!==t.shape[e])throw new Error(o+` updates.shape[${e}] (${n.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`);for(let t=0;t<n.rank-a;++t)if(n.shape[t+a]!==e[t+r])throw new Error(o+` updates.shape[${t+a}] (${n.shape[t+a]}) != shape[${t+a}] (${e[t+a]})`)}function o(e,t,n){if(t.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==t.dtype)throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(n.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`);if(0===n.length){if(0===t.size)throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(0===e.size)throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`)}a(n,t,e)}function s(e,t,n){const a=t.shape.length,o=a>1?t.shape[a-1]:1,s=n.length;let i=1;for(let e=o;e<s;++e)i*=n[e];const u=o<1?1:o;return{sliceRank:o,numUpdates:(0,r.It)(t.shape)/u,sliceSize:i,strides:[...(0,r.gH)(n.slice(0,o)),1],outputSize:(0,r.It)(n)}}},37984:function(e,t,n){"use strict";n.d(t,{_:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({sigmoid_:function(e){const t={x:(0,o.ay)(e,"x","sigmoid","float32")};return r.cL.runKernel(a.ac,t)}})},2992:function(e,t,n){"use strict";n.d(t,{_:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({sqrt_:function(e){const t={x:(0,o.ay)(e,"x","sqrt","float32")};return r.cL.runKernel(a.Sed,t)}})},82916:function(e,t,n){"use strict";n.d(t,{Q:function(){return o}});var r=n(31748),a=n(72180);const o=(0,n(17336).op)({square_:function(e){const t=(0,a.ay)(e,"x","square");return r.cL.runKernel("Square",{x:t},{})}})},21804:function(e,t,n){"use strict";n.d(t,{W:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({step_:function(e,t=0){const n={x:(0,o.ay)(e,"x","step")},s={alpha:t};return r.cL.runKernel(a.Ku3,n,s)}})},90256:function(e,t,n){"use strict";n.d(t,{A:function(){return i}});var r=n(31748),a=n(38128),o=n(4172),s=n(72180);const i=(0,n(17336).op)({sub_:function(e,t){let n=(0,s.ay)(e,"a","sub"),i=(0,s.ay)(t,"b","sub");[n,i]=(0,o.yE)(n,i);const u={a:n,b:i};return r.cL.runKernel(a.UVd,u)}})},95872:function(e,t,n){"use strict";n.d(t,{o:function(){return i}});var r=n(31748),a=n(38128),o=n(72180),s=n(6356);const i=(0,n(17336).op)({sum_:function(e,t=null,n=!1){let i=(0,o.ay)(e,"x","sum");"bool"===i.dtype&&(i=(0,s.W)(i,"int32"));const u={x:i},c={axis:t,keepDims:n};return r.cL.runKernel(a.srk,u,c)}})},77016:function(e,t,n){"use strict";n.d(t,{m:function(){return o}});var r=n(72180),a=n(31560);function o(e,t,n){const o=(0,r._y)(e,n);return(0,a.e)(e,t,o,n)}},9556:function(e,t,n){"use strict";n.d(t,{A:function(){return s}});var r=n(72180),a=n(15952),o=n(31560);function s(e,t,n){if((0,a.Qn)(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");const s=(0,r._y)(e,n);if(3!==s.length&&1!==s.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===s.length&&null==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return(0,o.e)(e,t,s,n)}},31560:function(e,t,n){"use strict";n.d(t,{e:function(){return i}});var r=n(31748),a=n(22500),o=n(15952),s=n(10680);function i(e,t,n,i){if(null==i)i=(0,o.GA)(e);else if("complex64"===i)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");
2if((0,a.ay)(e)||(0,a.oj)(e)){if("float32"!==i&&"int32"!==i)throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${i}.`);return r.cL.backend.createTensorFromGPUData(e,t||n,i)}if(!(0,s.isTypedArray)(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,o.Ix)(t);const e=(0,o.It)(t),r=(0,o.It)(n);(0,o.Uc)(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e<n.length;++e){const r=n[e],a=e!==n.length-1||r!==(0,o.It)(t.slice(e));(0,o.Uc)(n[e]===t[e]||!a,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return(0,s.isTypedArray)(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==i?(0,s.toTypedArray)(e,i):(0,s.flatten)(e,[],!0),r.cL.makeTensor(e,t,i)}},50216:function(e,t,n){"use strict";n.d(t,{E:function(){return s}});var r=n(31748),a=n(38128),o=n(72180);const s=(0,n(17336).op)({zerosLike_:function(e){const t={x:(0,o.ay)(e,"x","zerosLike")};return r.cL.runKernel(a.qKC,t)}})},68744:function(e,t,n){"use strict";function r(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}n.d(t,{a:function(){return r}})},74364:function(e,t,n){"use strict";n.d(t,{w3:function(){return k},Kq:function(){return f},QB:function(){return x},Oi:function(){return v},O8:function(){return w},CE:function(){return b}});var r=n(18308),a=n(15952);const o=20,s=3,i=7;function u(e,t,n,r){const o=(0,a.gH)(t),s=function(e,t,n,r){const o=(0,a.It)(t),s=r[r.length-1],i=new Array(s).fill(0),u=t.length,l="complex64"===n?d(e):e;if(u>1)for(let e=0;e<o/s;e++){const t=e*s;for(let e=0;e<s;e++)i[e]=Math.max(i[e],c(l[t+e],0,n).length)}return i}(e,t,n,o),i=t.length,u=p(e,t,n,o,s),l=["Tensor"];return r&&(l.push(` dtype: ${n}`),l.push(` rank: ${i}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(u.map((e=>" "+e)).join("\n")),l.join("\n")}function c(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(i))} + ${parseFloat(e[1].toFixed(i))}j`:(0,a.ct)(e)?`'${e}'`:"bool"===n?l(e):parseFloat(e.toFixed(i)).toString(),(0,a.Uf)(r,t)}function l(e){return 0===e?"false":"true"}function p(e,t,n,r,a,i=!0){const u="complex64"===n?2:1,h=t[0],f=t.length;if(0===f)return"complex64"===n?[c(d(e)[0],0,n)]:"bool"===n?[l(e[0])]:[e[0].toString()];if(1===f){if(h>o){const t=s*u;let r=Array.from(e.slice(0,t)),o=Array.from(e.slice((h-s)*u,h*u));return"complex64"===n&&(r=d(r),o=d(o)),["["+r.map(((e,t)=>c(e,a[t],n))).join(", ")+", ..., "+o.map(((e,t)=>c(e,a[h-s+t],n))).join(", ")+"]"]}return["["+("complex64"===n?d(e):Array.from(e)).map(((e,t)=>c(e,a[t],n))).join(", ")+"]"]}const m=t.slice(1),g=r.slice(1),y=r[0]*u,b=[];if(h>o){for(let t=0;t<s;t++){const r=t*y,o=r+y;b.push(...p(e.slice(r,o),m,n,g,a,!1))}b.push("...");for(let t=h-s;t<h;t++){const r=t*y,o=r+y;b.push(...p(e.slice(r,o),m,n,g,a,t===h-1))}}else for(let t=0;t<h;t++){const r=t*y,o=r+y;b.push(...p(e.slice(r,o),m,n,g,a,t===h-1))}const w=2===f?",":"";b[0]="["+(h>0?b[0]+w:"");for(let e=1;e<b.length-1;e++)b[e]=" "+b[e]+w;let v=",\n";for(let e=2;e<f;e++)v+="\n";return b[b.length-1]=" "+b[b.length-1]+"]"+(i?"":v),b}function d(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var h=n(10680);class f{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=a.It(e),null!=n){const e=n.length;a.Uc(e===this.size,(()=>`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.Om(t,this.size),this.strides=(0,a.gH)(e)}set(e,...t){0===t.length&&(t=[0]),a.Uc(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;t<e.length-1;++t)n+=this.strides[t]*e[t];return this.values[n]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];const t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return m().makeTensor(this.values,this.shape,this.dtype)}}let m=null,g=null,y=null;function b(e){m=e}function w(e){g=e}function v(e){y=e}class k{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=a.It(e),this.strides=(0,a.gH)(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return g.buffer(this.shape,this.dtype,e)}bufferSync(){return g.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return(0,a.aE)(this.shape,e,"complex64"===this.dtype)}arraySync(){return(0,a.aE)(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=m().read(this.dataId);if("string"===this.dtype){const t=await e;
2try{return t.map((e=>h.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}dataToGPU(e){return this.throwIfDisposed(),m().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=m().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>h.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 m().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),m().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return g.print(this,e)}clone(){return this.throwIfDisposed(),g.clone(this)}toString(e=!1){return u(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),g.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),m().makeVariable(this,e,t,n)}}Object.defineProperty(k,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),(0,r.A)("Tensor",(()=>k));class x extends k{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.eu(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);m().disposeTensor(this),this.dataId=e.dataId,m().incRef(this,null)}dispose(){m().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(x,Symbol.hasInstance,{value:e=>e instanceof k&&null!=e.assign&&e.assign instanceof Function})},4172:function(e,t,n){"use strict";n.d(t,{Ck:function(){return u},q8:function(){return i},yE:function(){return s}});var r=n(74364),a=n(22500),o=n(15952);function s(e,t){if(e.dtype===t.dtype)return[e,t];const n=(0,a.OA)(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function i(e,t){(0,o.Uc)(e.dtype===t.dtype,(()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`))}function u(e){const t=[];return c(e,t,new Set),t}function c(e,t,n){if(null==e)return;if(e instanceof r.w3)return void t.push(e);if(a=e,!Array.isArray(a)&&"object"!=typeof a)return;var a;const o=e;for(const e in o){const r=o[e];n.has(r)||(n.add(r),c(r,t,n))}}},72180:function(e,t,n){"use strict";n.d(t,{Y$:function(){return h},_y:function(){return c},ay:function(){return d}});var r=n(31748),a=n(41920),o=n(74364),s=n(22500),i=n(10680),u=n(15952);function c(e,t){let n=e;if((0,i.isTypedArray)(e))return"string"===t?[]:[e.length];if((0,s.oj)(e)){const t=e.channels||"RGBA";return[e.height,e.width*t.length]}if((0,s.ay)(e))return[e.buffer.size/(null==t?4:(0,u.U1)(t))];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||(0,i.isTypedArray)(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&(0,a._K)().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&l(e,r,[]),r}function l(e,t,n){if(n=n||[],!Array.isArray(e)&&!(0,i.isTypedArray)(e))return void(0,u.Uc)(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));(0,u.Uc)(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),(0,u.Uc)(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<e.length;++t)l(e[t],r,n.concat(t))}function p(e,t,n,r){if("string_or_numeric"!==e){if(null==e)throw new Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw new Error(`Argument '${n}' passed to '${r}' must be ${e} tensor, but got ${t} tensor`)}}function d(e,t,n,a="numeric"){if(e instanceof o.w3)return p(a,e.dtype,t,n),e;let s=(0,u.GA)(e);if("string"!==s&&["bool","int32","float32"].indexOf(a)>=0&&(s=a),p(a,s,t,n),null==e||!(0,i.isTypedArray)(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 l=c(e,s);(0,i.isTypedArray)(e)||Array.isArray(e)||(e=[e]);const d="string"!==s?(0,i.toTypedArray)(e,s):(0,i.flatten)(e,[],!0);return r.cL.makeTensor(d,l,s)}function h(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)=>d(e,`${t}[${a}]`,n,r)))}},22500:function(e,t,n){"use strict";var r,a,o,s,i;n.d(t,{OA:function(){return c},ay:function(){return p},oj:function(){return l}}),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"}(o||(o={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(s||(s={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(i||(i={}));
vendor: 10,978 bytes, line 2
2const u={float32:s,int32:a,bool:o,complex64:i};function c(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 l(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function p(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}},10680:function(e,t,n){"use strict";n.r(t),n.d(t,{arraysEqual:function(){return o.eu},arraysEqualWithNull:function(){return o.mQ},assert:function(){return o.Uc},assertNonNegativeIntegerDimensions:function(){return o.Ix},assertNonNull:function(){return o.Qn},assertShapesMatch:function(){return o.kl},bytesFromStringArray:function(){return o.YX},bytesPerElement:function(){return o.U1},checkConversionForErrors:function(){return o.KQ},clamp:function(){return o.qk},computeStrides:function(){return o.gH},convertBackendValuesAndArrayBuffer:function(){return o.Cj},createScalarValue:function(){return v},createShuffledIndices:function(){return o.iG},decodeString:function(){return S},distSquared:function(){return o.c5},encodeString:function(){return I},fetch:function(){return _},fingerPrint64:function(){return w},flatten:function(){return M},getArrayFromDType:function(){return o.Om},getTypedArrayFromDType:function(){return o.q2},hasEncodingLoss:function(){return o.JQ},hexToLong:function(){return u},indexToLoc:function(){return o.UU},inferDtype:function(){return o.GA},inferFromImplicitShape:function(){return o.UJ},isBoolean:function(){return o.am},isFunction:function(){return o.mg},isInt:function(){return o.EH},isNumber:function(){return o.Ib},isPromise:function(){return o.um},isScalarShape:function(){return o.OK},isString:function(){return o.ct},isTypedArray:function(){return N},isValidDtype:function(){return o.FP},locToIndex:function(){return o.C8},makeOnesTypedArray:function(){return o.Do},makeZerosNestedTypedArray:function(){return o.YD},makeZerosTypedArray:function(){return o.K6},nearestDivisor:function(){return o.Y_},nearestLargerEven:function(){return o.aD},now:function(){return x},parseAxisParam:function(){return o.YL},randUniform:function(){return o._Y},repeatedTry:function(){return o.Cu},rightPad:function(){return o.Uf},shuffle:function(){return o.YP},shuffleCombo:function(){return o.__},sizeFromShape:function(){return o.It},sizeToSquarishShape:function(){return o.lH},squeezeShape:function(){return o.gD},sum:function(){return o.oh},swap:function(){return o.C},tanh:function(){return o.Sy},toNestedArray:function(){return o.aE},toTypedArray:function(){return k}});var r=n(41920),a=n(68744),o=n(15952),s=n(69300);const i=n.n(s)()||s;function u(e){return i.fromString(e,!0,16)}const c=u("c3a5c85c97cb3127"),l=u("b492b66fbe98f273"),p=u("9ae16a3b2f90404f");function d(e){return e.xor(e.shru(47))}function h(e,t,n){const r=e.slice(t,t+n);return i.fromBytes(Array.from(r),!0,!0)}function f(e,t){return h(e,t,8)}function m(e,t){return h(e,t,4)}function g(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function y(e,t,n=u("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 b(e,t,n,r){return function(e,t,n,r,a,o){a=a.add(e),o=g(o.add(a).add(r),21);const s=a;return a=(a=a.add(t)).add(n),o=o.add(g(a,44)),[a.add(r),o.add(s)]}(f(e,t),f(e,t+8),f(e,t+16),f(e,t+24),n,r)}function w(e,t=e.length){const n=i.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=p.add(2*t),r=f(e,0).add(p),a=f(e,t-8);return y(g(a,37).mul(n).add(r),g(r,25).add(a).mul(n),n)}if(t>=4){const n=p.add(2*t);return y(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 d(p.mul(n).xor(c.mul(r))).mul(p)}return p}(e,t):function(e,t=e.length){const n=p.add(2*t),r=f(e,0).mul(l),a=f(e,8),o=f(e,t-8).mul(n),s=f(e,t-16).mul(p);return y(g(r.add(a),43).add(g(o,30)).add(s),r.add(g(a.add(p),18)).add(o),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=p.add(2*t),r=f(e,0).mul(p),a=f(e,8),o=f(e,t-8).mul(n),s=f(e,t-16).mul(p),i=g(r.add(a),43).add(g(o,30)).add(s),u=y(i,r.add(g(a.add(p),18)).add(o),n),c=f(e,16).mul(n),l=f(e,24),d=i.add(f(e,t-32)).mul(n),h=u.add(f(e,t-24)).mul(n);return y(g(c.add(l),43).add(g(d,30)).add(h),c.add(g(l.add(r),18)).add(d),n)}(e,t);let r=n,a=n.mul(l).add(113),o=d(a.mul(p).add(113)).mul(p),s=[i.UZERO,i.UZERO],u=[i.UZERO,i.UZERO];r=r.mul(p).add(f(e,0));let h=0;const w=64*(t-1>>6),v=w+(t-1&63)-63;do{r=g(r.add(a).add(s[0]).add(f(e,h+8)),37).mul(l),a=g(a.add(s[1]).add(f(e,h+48)),42).mul(l),r=r.xor(u[1]),a=a.add(s[0]).add(f(e,h+40)),o=g(o.add(u[0]),33).mul(l),s=b(e,h,s[1].mul(l),r.add(u[0])),u=b(e,h+32,o.add(u[1]),a.add(f(e,h+16))),[o,r]=[r,o],h+=64}while(h!==w);const k=l.add(o.and(255).shl(1));return h=v,u[0]=u[0].add(t-1&63),s[0]=s[0].add(u[0]),u[0]=u[0].add(s[0]),r=g(r.add(a).add(s[0]).add(f(e,h+8)),37).mul(k),a=g(a.add(s[1]).add(f(e,h+48)),42).mul(k),r=r.xor(u[1].mul(9)),a=a.add(s[0].mul(9).add(f(e,h+40))),o=g(o.add(u[0]),33).mul(k),s=b(e,h,s[1].mul(k),r.add(u[0])),u=b(e,h+32,o.add(u[1]),a.add(f(e,h+16))),[o,r]=[r,o],y(y(s[0],u[0],k).add(d(a).mul(c)).add(o),y(s[1],u[1],k).add(r),k)}function v(e,t){return"string"===t?I(e):k([e],t)}function k(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=M(e)),(0,r._K)().getBool("DEBUG")&&o.KQ(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<t.length;++n)0!==Math.round(e[n])&&(t[n]=1);return t}throw new Error(`Unknown data type ${t}`)}function x(){return(0,r._K)().platform.now()}function _(e,t){return(0,r._K)().platform.fetch(e,t)}function I(e,t="utf-8"){return t=t||"utf-8",(0,r._K)().platform.encode(e,t)}function S(e,t="utf-8"){return t=t||"utf-8",(0,r._K)().platform.decode(e,t)}function N(e){return null!=(0,r._K)().platform.isTypedArray?(0,r._K)().platform.isTypedArray(e):(0,a.a)(e)}function M(e,t=[],n=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||o.um(e)||null==e||N(e)&&n)t.push(e);else if(Array.isArray(e)||N(e))for(let r=0;r<e.length;++r)M(e[r],t,n);else{let r=-1;for(const t of Object.keys(e))/^([1-9]+[0-9]*|0)$/.test(t)&&(r=Math.max(r,Number(t)));for(let a=0;a<=r;a++)M(e[a],t,n)}return t}},15952:function(e,t,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 o(e,t,n){return Math.max(e,Math.min(t,n))}function s(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;n<e.length;n++)t+=e[n];return t}function c(e,t){const n=Math.random();return t*n+(1-n)*e}function l(e,t){let n=0;for(let r=0;r<e.length;r++){const a=Number(e[r])-Number(t[r]);n+=a*a}return n}function p(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function d(e,t,n=""){p(y(e,t),(()=>n+` 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 f(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function m(e){return 0===e.length}function g(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(null!==e[n]&&null!==t[n]&&e[n]!==t[n])return!1;return!0}function y(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function b(e){return e%1==0}function w(e){if(null!=Math.tanh)return Math.tanh(e);if(e===1/0)return 1;if(e===-1/0)return-1;{const t=Math.exp(2*e);return(t-1)/(t+1)}}function v(e){const t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function k(e){const t=new Uint32Array(e);for(let n=0;n<e;++n)t[n]=n;return r(t),t}function x(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function _(e,t=(e=>0),n,r){return new Promise(((a,o)=>{let s=0;const i=()=>{if(e())return void a();s++;const u=t(s);null!=n&&s>=n?o():null!=r?r(i,u):setTimeout(i,u)};i()}))}function I(e,t){let n=1,r=-1;for(let t=0;t<e.length;++t)if(e[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 S(e,t){const n=t.length;return p((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e<n)),(()=>`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 N(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,o=null==t||a?null:S(t,e).sort();let s=0;for(let t=0;t<e.length;++t){if(null!=o){if(o[s]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==o[s]||o[s]>t)&&1===e[t]&&(n.push(e[t]),r.push(t)),o[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function M(e,t){return T(e,t)}function T(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 E(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${t} being uploaded contains ${r}.`)}}function A(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function F(e,t){return!("complex64"===t||"float32"===t&&"complex64"!==e||"int32"===t&&"float32"!==e&&"complex64"!==e||"bool"===t&&"bool"===e)}function D(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function O(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}function C(e){return"string"==typeof e||e instanceof String}function P(e){return"boolean"==typeof e}function R(e){return"number"==typeof e}function $(e){return Array.isArray(e)?$(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":R(e)?"float32":C(e)?"
2string":P(e)?"bool":"float32"}function L(e){return!!(e&&e.constructor&&e.call&&e.apply)}function W(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function z(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function B(e,t,n,r=!1){const a=new Array;if(1===t.length){const o=t[0]*(r?2:1);for(let t=0;t<o;t++)a[t]=n[e+t]}else{const o=t[0],s=t.slice(1),i=s.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<o;t++)a[t]=B(e+t*i,s,n,r)}return a}function U(e,t,n=!1){if(0===e.length)return t[0];const r=e.reduce(((e,t)=>e*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 B(0,e,t,n)}function H(e,t){if(Array.isArray(e))return e;if("float32"===t)return e instanceof Float32Array?e:new Float32Array(e);if("int32"===t)return e instanceof Int32Array?e:new Int32Array(e);if("bool"===t||"string"===t)return Uint8Array.from(new Int32Array(e));throw new Error(`Unknown dtype ${t}`)}function V(e,t){const n=G(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}function G(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function q(e,t){const n=e.reduce(((e,t)=>e*t),1);if(null==t||"float32"===t)return U(e,new Float32Array(n));if("int32"===t)return U(e,new Int32Array(n));if("bool"===t)return U(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;t<e.length-1;++t)r+=n[t]*e[t];return r}function Q(e,t,n){if(0===t)return[];if(1===t)return[e];const r=new Array(t);for(let t=0;t<r.length-1;++t)r[t]=Math.floor(e/n[t]),e-=r[t]*n[t];return r[r.length-1]=e,r}function Y(e){return e&&e.then&&"function"==typeof e.then}n.d(t,{C:function(){return i},C8:function(){return K},Cj:function(){return H},Cu:function(){return _},Do:function(){return V},EH:function(){return b},FP:function(){return A},GA:function(){return $},Ib:function(){return R},It:function(){return f},Ix:function(){return j},JQ:function(){return F},K6:function(){return G},KQ:function(){return E},OK:function(){return m},Om:function(){return T},Qn:function(){return h},Sy:function(){return w},U1:function(){return D},UJ:function(){return I},UU:function(){return Q},Uc:function(){return p},Uf:function(){return x},YD:function(){return q},YL:function(){return S},YP:function(){return r},YX:function(){return O},Y_:function(){return W},_Y:function(){return c},__:function(){return a},aD:function(){return s},aE:function(){return U},am:function(){return P},c5:function(){return l},ct:function(){return C},eu:function(){return y},gD:function(){return N},gH:function(){return z},iG:function(){return k},kl:function(){return d},lH:function(){return v},mQ:function(){return g},mg:function(){return L},oh:function(){return u},q2:function(){return M},qk:function(){return o},um:function(){return Y}})},20488:function(e,t,n){"use strict";n.d(t,{_E:function(){return Dt},am:function(){return yn},Yr:function(){return r},k7:function(){return be},YX:function(){return Yt},wv:function(){return bn}});var r={};n.r(r),n.d(r,{AnchorPosition:function(){return Q},DrawBox:function(){return ne},DrawBoxOptions:function(){return te},DrawFaceLandmarks:function(){return je},DrawFaceLandmarksOptions:function(){return qe},DrawTextField:function(){return ee},DrawTextFieldOptions:function(){return X},drawContour:function(){return o},drawDetections:function(){return re},drawFaceExpressions:function(){return He},drawFaceLandmarks:function(){return Ke}});var a=n(42840);function o(e,t,n){if(void 0===n&&(n=!1),e.beginPath(),t.slice(1).forEach((function(n,r){var a=n.x,o=n.y,s=t[r];e.moveTo(s.x,s.y),e.lineTo(a,o)})),n){var r=t[t.length-1],a=t[0];if(!r||!a)return;e.moveTo(r.x,r.y),e.lineTo(a.x,a.y)}e.stroke()}
2var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},s(e,t)};function i(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=function(){return u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},u.apply(this,arguments)};function c(e,t,n,r){return new(n||(n=Promise))((function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}u((r=r.apply(e,t||[])).next())}))}function l(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}function p(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),a=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,i=o.length;s<i;s++,a++)r[a]=o[s];return r}var d=function(){function e(e,t){if(!k(e)||!k(t))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:e,height:t}));this._width=e,this._height=t}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),e.prototype.reverse=function(){return new e(1/this.width,1/this.height)},e}();function h(e,t){return e instanceof a.w3A&&e.shape.length===t}function f(e){return h(e,3)}function m(e){return h(e,4)}function g(e){return e%2==0}function y(e,t){void 0===t&&(t=2);var n=Math.pow(10,t);return Math.floor(e*n)/n}function b(e){return e&&e.width&&e.height}function w(e){return e.reduce((function(e,t){return e.add(t)}),new _(0,0)).div(new _(e.length,e.length))}function v(e,t,n){return Array(e).fill(0).map((function(e,r){return t+r*n}))}function k(e){return!!e&&e!==1/0&&e!==-1/0&&!isNaN(e)||0===e}function x(e){return k(e)&&0<=e&&e<=1}var _=function(){function e(e,t){this._x=e,this._y=t}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.sub=function(t){return new e(this.x-t.x,this.y-t.y)},e.prototype.mul=function(t){return new e(this.x*t.x,this.y*t.y)},e.prototype.div=function(t){return new e(this.x/t.x,this.y/t.y)},e.prototype.abs=function(){return new e(Math.abs(this.x),Math.abs(this.y))},e.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y))},e}(),I=function(){function e(t,n){void 0===n&&(n=!0);var r=t||{},a=[r.left,r.top,r.right,r.bottom].every(k),o=[r.x,r.y,r.width,r.height].every(k);if(!o&&!a)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(r));var s=o?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top],i=s[0],u=s[1],c=s[2],l=s[3];e.assertIsValidBox({x:i,y:u,width:c,height:l},"Box.constructor",n),this._x=i,this._y=u,this._width=c,this._height=l}return e.isRect=function(e){return!!e&&[e.x,e.y,e.width,e.height].every(k)},e.assertIsValidBox=function(t,n,r){if(void 0===r&&(r=!1),!e.isRect(t))throw new Error(n+" - invalid box: "+JSON.stringify(t)+", expected object with properties x, y, width, height");if(!r&&(t.width<0||t.height<0))throw new Error(n+" - width ("+t.width+") and height ("+t.height+") must be positive numbers")},Object.defineProperty(e.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topLeft",{get:function(){return new _(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topRight",{get:function(){return new _(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomLeft",{get:function(){return new _(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomRight",{get:function(){return new _(this.right,this.bottom)},enumerable:!0,configurable:!0}),e.prototype.round=function(){var t=[this.x,this.y,this.width,this.height].map((function(e){return Math.round(e)}));return new e({x:t[0],y:t[1],width:t[2],height:t[3]})},e.prototype.floor=function(){var t=[this.x,this.y,this.width,this.height].map((function(e){return Math.floor(e)}));return new e({x:t[0],y:t[1],width:t[2],height:t[3]})},e.prototype.toSquare=function(){var t=this,n=t.x,r=t.y,a=t.width,o=t.height,s=Math.abs(a-o);return a<o&&(n-=s/2,a+=s),o<a&&(r-=s/2,o+=s),new e({x:n,y:r,width:a,height:o})},e.prototype.rescale=function(t){var n=b(t)?t.width:t,r=b(t)?t.he
2ight:t;return new e({x:this.x*n,y:this.y*r,width:this.width*n,height:this.height*r})},e.prototype.pad=function(t,n){var r=[this.x-t/2,this.y-n/2,this.width+t,this.height+n];return new e({x:r[0],y:r[1],width:r[2],height:r[3]})},e.prototype.clipAtImageBorders=function(t,n){var r=this,a=r.x,o=r.y,s=r.right,i=r.bottom,u=Math.max(a,0),c=Math.max(o,0),l=s-u,p=i-c;return new e({x:u,y:c,width:Math.min(l,t-u),height:Math.min(p,n-c)}).floor()},e.prototype.shift=function(t,n){var r=this.width,a=this.height;return new e({x:this.x+t,y:this.y+n,width:r,height:a})},e.prototype.padAtBorders=function(e,t){var n=this.width+1,r=this.height+1,a=n,o=r,s=this.left,i=this.top,u=this.right,c=this.bottom;return u>t&&(a=-u+t+n,u=t),c>e&&(o=-c+e+r,c=e),s<1&&(o=2-s,s=1),i<1&&(o=2-i,i=1),{dy:1,edy:o,dx:1,edx:a,y:i,ey:c,x:s,ex:u,w:n,h:r}},e.prototype.calibrate=function(t){return new e({left:this.left+t.left*this.width,top:this.top+t.top*this.height,right:this.right+t.right*this.width,bottom:this.bottom+t.bottom*this.height}).toSquare().round()},e}(),S=function(e){function t(t,n,r,a,o){return void 0===o&&(o=!1),e.call(this,{left:t,top:n,right:r,bottom:a},o)||this}return i(t,e),t}(I),N=function(){function e(e,t,n,r,a){this._imageDims=new d(a.width,a.height),this._score=e,this._classScore=t,this._className=n,this._box=new I(r).rescale(this._imageDims)}return Object.defineProperty(e.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"relativeBox",{get:function(){return new I(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),e.prototype.forSize=function(t,n){return new e(this.score,this.classScore,this.className,this.relativeBox,{width:t,height:n})},e}(),M=function(e){function t(t,n,r){return e.call(this,t,t,"",n,r)||this}return i(t,e),t.prototype.forSize=function(n,r){var a=e.prototype.forSize.call(this,n,r);return new t(a.score,a.relativeBox,a.imageDims)},t}(N);function T(e,t,n){void 0===n&&(n=!0);var r=Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top));return n?r/(e.area+t.area-r):r/Math.min(e.area,t.area)}function E(e,t,n,r){void 0===r&&(r=!0);for(var a=t.map((function(e,t){return{score:e,boxIndex:t}})).sort((function(e,t){return e.score-t.score})).map((function(e){return e.boxIndex})),o=[],s=function(){var t=a.pop();o.push(t);for(var s=a,i=[],u=0;u<s.length;u++){var c=s[u],l=e[t],p=e[c];i.push(T(l,p,r))}a=a.filter((function(e,t){return i[t]<=n}))};a.length>0;)s();return o}function A(e,t){return a.G6I((function(){var n=t[0],r=t[1],o=t[2],s=a.ymW(p(e.shape.slice(0,3),[1]),n),i=a.ymW(p(e.shape.slice(0,3),[1]),r),u=a.ymW(p(e.shape.slice(0,3),[1]),o),c=a.WUr([s,i,u],3);return a.AT$(e,c)}))}function F(e){return 1/(1+Math.exp(-e))}var D,O=function(e){function t(t,n,r,a,o){return void 0===o&&(o=!1),e.call(this,{x:t,y:n,width:r,height:a},o)||this}return i(t,e),t}(I),C=function(){function e(e,t,n){void 0===n&&(n=new _(0,0));var r=t.width,a=t.height;this._imgDims=new d(r,a),this._shift=n,this._positions=e.map((function(e){return e.mul(new _(r,a)).add(n)}))}return Object.defineProperty(e.prototype,"shift",{get:function(){return new _(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"relativePositions",{get:function(){var e=this;return this._positions.map((function(t){return t.sub(e._shift).div(new _(e.imageWidth,e.imageHeight))}))},enumerable:!0,configurable:!0}),e.prototype.forSize=function(e,t){return new this.constructor(this.relativePositions,{width:e,height:t})},e.prototype.shiftBy=function(e,t){return new this.constructor(this.relativePositions,this._imgDims,new _(e,t))},e.prototype.shiftByPoint=function(e){return this.shiftBy(e.x,e.y)},e.prototype.align=function(e,t){if(void 0===t&&(t={}),e){var n=e instanceof M?e.box.floor():new I(e);return this.shiftBy(n.x,n.y).align(null,t)}var r=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},t),a=r.useDlibAlignment,o=r.minBoxPadding;return a?this.alignDlib():this.alignMinBbox(o)},e.prototype.alignDlib=function(){var e=this.getRefPointsForAlignment(),t=e[0],n=e[1],r=e[2],a=function(e){return r.sub(e).magnitude()},o=(a(t)+a(n))/2,s=Math.floor(o/.45),i=w(e),u=Math.floor(Math.max(0,i.x-.5*s)),c=Math.floor(Math.max(0,i.y-.43*s));return new O(u,c,Math.min(s,this.imageWidth+u),Math.min(s,this.imageHeight+c))},e.prototype.alignMinBbox=function(e){var t,n,r,a,o,s,i,u=(n=(t=this.positions).map((function(e){return e.x})),r=t.map((function(e){return e.y})),a=n.reduce((function(e,t){return t<e?t:e}),1/0),o=r.reduce((function(e,t){return t<e?t:e}),1/0),s=n.reduce((function(e,t){return e<t?t:e}),0),i=r.reduce((function(e,t){return e<t?t:e}),0),new S(a,o,s,i));return u.pad(u.width*e,u.height*e)},e.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},e}(),P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.getRefPointsForAlignment=function(){var e=this.positions;return[e[0],e[1],w([e[3],e[4]])]},t}(C),R=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.getJawOutline=function(){return this.positions.slice(0,17)},t.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},t.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},t.prototype.getNose=function(){return this.positions.slice(27,36)},t.prototype.getLeftEye=function(){return this.positions.slice(36,42)},t.prototype.getRightEye=function(){return this.positions.slice(42,48)},t.prototype.getMouth=function(){return this.positions.slice(48,68)},t.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(w)},t}(C),$=function(){function e(e,t){this._label=e,this._distance=t}return Object.defineProperty(e.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),e.prototype.toString=function(e){return void 0===e&&(e=!0),this.label+(e?" ("+y(this.distance)+")":"")},e}(),L=function(e){function t(t,n){var r=e.call(this,t)||this;return r._label=n,r}return i(t,e),t.assertIsValidLabeledBox=function(e,t){if(I.assertIsValidBox(e,t),!k(e.label))throw new Error(t+" - expected property label ("+e.label+") to be a number")},Object.defineProperty(t.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),t}(I),W=function(){function e(e,t){if("string"!=typeof e)throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(t)||t.some((function(e){return!(e instanceof Float32Array)})))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=e,this._descriptors=t}return Object.defineProperty(e.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),e.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map((function(e){return Array.from(e)}))}},e.fromJSON=function(t){var n=t.descriptors.map((function(e){return new Float32Array(e)}));return new e(t.label,n)},e}();function z(e){return e.detection instanceof M}function B(e,t){var n={detection:t};return Object.assign({},e,n)}function U(){var e=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")};return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D:CanvasRenderingContext2D,Image:HTMLImageElement,ImageData:ImageData,Video:HTMLVideoElement,createCanvasElement:function(){return document.createElement("canvas")},createImageElement:function(){return document.createElement("img")},fetch:e,readFile:function(){throw new Error("readFile - filesystem not available for browser environment")}}}function H(e){var t="";if(!e)try{e=n(30264)}catch(e){t=e.toString()}return{readFile:e?function(t){return new Promise((function(n,r){e.readFile(t,(function(e,t){return e?r(e):n(t)}))}))}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+t)}}}function V(){var e=n.g.Canvas||n.g.HTMLCanvasElement,t=n.g.Image||n.g.HTMLImageElement,r=n.g.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},a=H();return u({Canvas:e||function(){},CanvasRenderingContext2D:n.g.CanvasRenderingContext2D||function(){},Image:t||function(){},ImageData:n.g.ImageData||function(){},Video:n.g.HTMLVideoElement||function(){},createCanvasElement:function(){if(e)return new e;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},createImageElement:function(){if(t)return new t;throw new Error("createImageElement - missing Image implementation for nodejs environment")},fetch:r},a)}function G(){return"object"==typeof window&&"undefined"!=typeof document&&"undefined"!=typeof HTMLImageElement&&"undefined"!=typeof HTMLCanvasElement&&"undefined"!=typeof HTMLVideoElement&&"undefined"!=typeof ImageData&&"undefined"!=typeof CanvasRenderingContext2D}function q(){return"object"==typeof n.g&&"undefined"!=typeof process&&!!process.version}function j(e){D=e}function K(){G()&&j(U()),q()&&j(V())}!function(e){function t(t,n,r,a){var o=e.call(this,t,n)||this;return o._score=r,o._classScore=a,o}i(t,e),t.assertIsValidPredictedBox=function(e,t){if(L.assertIsValidLabeledBox(e,t),!x(e.score)||!x(e.classScore))throw new Error(t+" - expected properties score ("+e.score+") and ("+e.classScore+") to be a number between [0, 1]")},Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0})}(L);var Q,Y={getEnv:function(){if(!D)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return D},setEnv:j,initialize:K,createBrowserEnv:U,createFileSystem:H,createNodejsEnv:V,monkeyPatch:function(e){if(D||K(),!D)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var t=e.Canvas,n=void 0===t?D.Canvas:t,r=e.Image,a=void 0===r?D.Image:r;D.Canvas=n,D.Image=a,D.createCanvasElement=e.createCanvasElement||function(){return new n},D.createImageElement=e.createImageElement||function(){return new a},D.ImageData=e.ImageData||D.ImageData,D.Video=e.Video||D.Video,D.fetch=e.fetch||D.fetch,D.readFile=e.readFile||D.readFile},isBrowser:G,isNodejs:q};function J(e){return Y.isNodejs()||"string"!=typeof e?e:document.getElementById(e)}function Z(e){var t=Y.getEnv(),n=t.Canvas;if(e instanceof t.CanvasRenderingContext2D)return e;var r=J(e);if(!(r instanceof n))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var a=r.getContext("2d");if(!a)throw new Error("resolveContext2d - canvas 2d context is null");return a}K(),function(e){e.TOP_LEFT="TOP_LEFT",e.TOP_RIGHT="TOP_RIGHT",e.BOTTOM_LEFT="BOTTOM_LEFT",e.BOTTOM_RIGHT="BOTTOM_RIGHT"}(Q||(Q={}));var X=function(e){void 0===e&&(e={});var t=e.anchorPosition,n=e.backgroundColor,r=e.fontColor,a=e.fontSize,o=e.fontStyle,s=e.padding;this.anchorPosition=t||Q.TOP_LEFT,this.backgroundColor=n||"rgba(0, 0, 0, 0.5)",this.fontColor=r||"rgba(255, 255, 255, 1)",this.fontSize=a||14,this.fontStyle=o||"Georgia",this.padding=s||4},ee=function(){function e(t,n,r){void 0===r&&(r={}),this.text="string"==typeof t?[t]:t instanceof e?t.text:t,this.anchor=n,this.options=new X(r)}return e.prototype.measureWidth=function(e){var t=this.options.padding;return this.text.map((function(t){return e.measureText(t).width})).reduce((function(e,t){return e<t?t:e}),0)+2*t},e.prototype.measureHeight=function(){var e=this.options,t=e.fontSize,n=e.padding;return this.text.length*t+2*n},e.prototype.getUpperLeft=function(e,t){var n=this.options.anchorPosition,r=n===Q.BOTTOM_RIGHT||n===Q.TOP_RIGHT,a=n===Q.BOTTOM_LEFT||n===Q.BOTTOM_RIGHT,o=this.measureWidth(e),s=this.measureHeight(),i=r?this.anchor.x-o:this.anchor.x,u=a?this.anchor.y-s:this.anchor.y;if(t){var c=t.width,l=t.height;return{x:Math.max(Math.min(i,c-o),0),y:Math.max(Math.min(u,l-s),0)}}return{x:i,y:u}},e.prototype.draw=function(e){var t=J(e),n=Z(t),r=this.options,a=r.backgroundColor,o=r.fontColor,s=r.fontSize,i=r.fontStyle,u=r.padding;n.font=s+"px "+i;var c=this.measureWidth(n),l=this.measureHeight();n.fillStyle=a;var p=this.getUpperLeft(n,t);n.fillRect(p.x,p.y,c,l),n.fillStyle=o,this.text.forEach((function(e,t){var r=u+p.x,a=u+p.y+(t+1)*s;n.fillText(e,r,a)}))},e}(),te=function(e){void 0===e&&(e={});var t=e.boxColor,n=e.lineWidth,r=e.label,a=e.drawLabelOptions;this.boxColor=t||"rgba(0, 0, 255, 1)",this.lineWidth=n||2,this.label=r;var o={anchorPosition:Q.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new X(Object.assign({},o,a))},ne=function(){function e(e,t){void 0===t&&(t={}),this.box=new I(e),this.options=new te(t)}return e.prototype.draw=function(e){var t=Z(e),n=this.options,r=n.boxColor,a=n.lineWidth,o=this.box,s=o.x,i=o.y,u=o.width,c=o.height;t.strokeStyle=r,t.lineWidth=a,t.strokeRect(s,i,u,c);var l=this.options.label;l&&new ee([l],{x:s-a/2,y:i},this.options.drawLabelOptions).draw(e)},e}();
2function re(e,t){(Array.isArray(t)?t:[t]).forEach((function(t){var n=t instanceof M?t.score:z(t)?t.detection.score:void 0,r=t instanceof M?t.box:z(t)?t.detection.box:new I(t),a=n?""+y(n):void 0;new ne(r,{label:a}).draw(e)}))}function ae(e){var t=Y.getEnv(),n=t.Image,r=t.Video;return e instanceof n&&e.complete||e instanceof r&&e.readyState>=3}function oe(e){var t=Y.getEnv(),n=t.Image,r=t.Video;return e instanceof n?new d(e.naturalWidth,e.naturalHeight):e instanceof r?new d(e.videoWidth,e.videoHeight):new d(e.width,e.height)}function se(e){var t=e.width,n=e.height,r=(0,Y.getEnv().createCanvasElement)();return r.width=t,r.height=n,r}function ie(e,t){var n=Y.getEnv().ImageData;if(!(e instanceof n||ae(e)))throw new Error("createCanvasFromMedia - media has not finished loading yet");var r=t||oe(e),a=r.width,o=r.height,s=se({width:a,height:o});return e instanceof n?Z(s).putImageData(e,0,0):Z(s).drawImage(e,0,0,a,o),s}function ue(e,t){return c(this,void 0,void 0,(function(){var n,r,o,s,i,u;return l(this,(function(c){switch(c.label){case 0:return n=t||Y.getEnv().createCanvasElement(),r=e.shape.slice(m(e)?1:0),o=r[0],s=r[1],i=r[2],u=a.G6I((function(){return e.as3D(o,s,i).toInt()})),[4,a.aW8.toPixels(u,n)];case 1:return c.sent(),u.dispose(),[2,n]}}))}))}function ce(e){var t=Y.getEnv(),n=t.Image,r=t.Canvas,a=t.Video;return e instanceof n||e instanceof r||e instanceof a}var le=function(){function e(e,t){var n=this;if(void 0===t&&(t=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(e))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+e);this._treatAsBatchInput=t,this._batchSize=e.length,e.forEach((function(e,t){if(f(e))return n._imageTensors[t]=e,void(n._inputDimensions[t]=e.shape);if(m(e)){var r=e.shape[0];if(1!==r)throw new Error("NetInput - tf.Tensor4D with batchSize "+r+" passed, but not supported in input array");return n._imageTensors[t]=e,void(n._inputDimensions[t]=e.shape.slice(1))}var a=e instanceof Y.getEnv().Canvas?e:ie(e);n._canvases[t]=a,n._inputDimensions[t]=[a.height,a.width,3]}))}return Object.defineProperty(e.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reshapedInputDimensions",{get:function(){var e=this;return v(this.batchSize,0,1).map((function(t,n){return e.getReshapedInputDimensions(n)}))},enumerable:!0,configurable:!0}),e.prototype.getInput=function(e){return this.canvases[e]||this.imageTensors[e]},e.prototype.getInputDimensions=function(e){return this._inputDimensions[e]},e.prototype.getInputHeight=function(e){return this._inputDimensions[e][0]},e.prototype.getInputWidth=function(e){return this._inputDimensions[e][1]},e.prototype.getReshapedInputDimensions=function(e){if("number"!=typeof this.inputSize)throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");return t={width:this.getInputWidth(e),height:this.getInputHeight(e)},n=this.inputSize,r=t.width,a=t.height,o=n/Math.max(a,r),new d(Math.round(r*o),Math.round(a*o));var t,n,r,a,o},e.prototype.toBatchTensor=function(e,t){var n=this;return void 0===t&&(t=!0),this._inputSize=e,a.G6I((function(){var r=v(n.batchSize,0,1).map((function(r){var o=n.getInput(r);if(o instanceof a.w3A){var s=m(o)?o:o.expandDims();return(s=function(e,t){return void 0===t&&(t=!1),a.G6I((function(){var n=e.shape.slice(1),r=n[0],o=n[1];if(r===o)return e;var s=Math.abs(r-o),i=Math.round(s*(t?.5:1)),u=r>o?2:1,c=function(t){var n=e.shape.slice();return n[u]=t,a.ymW(n,0)},l=c(i),p=s-l.shape[u],d=[t&&p?c(p):null,e,l].filter((function(e){return!!e})).map((function(e){return e.toFloat()}));return a.WUr(d,u)}))}(s,t)).shape[1]===e&&s.shape[2]===e||(s=a.c$0.resizeBilinear(s,[e,e])),s.as3D(e,e,3)}if(o instanceof Y.getEnv().Canvas)return a.aW8.fromPixels(function(e,t,n){void 0===n&&(n=!1);var r=Y.getEnv(),a=r.Image,o=r.Canvas;if(!(e instanceof a||e instanceof o))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var s=oe(e),i=t/Math.max(s.height,s.width),u=i*s.width,c=i*s.height,l=se({width:t,height:t}),p=e instanceof o?e:ie(e),d=Math.abs(u-c)/2,h=n&&u<c?d:0,f=n&&c<u?d:0;return Z(l).drawImage(p,h,f,u,c),l}(o,e,t));throw new Error("toBatchTensor - at batchIdx "+r+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+o)}));return a.Qfh(r.map((function(e){return e.toFloat()}))).as4D(n.batchSize,e,e,3)}))},e}();function pe(e){return c(this,void 0,void 0,(function(){var t,n,r;return l(this,(function(a){switch(a.label){case 0:if(e instanceof le)return[2,e];if(!(t=Array.isArray(e)?e:[e]).length)throw new Error("toNetInput - empty array passed as input");return n=function(t){return Array.isArray(e)?" at input index "+t+":":""}
2,(r=t.map(J)).forEach((function(e,r){if(!ce(e)&&!f(e)&&!m(e)){if("string"==typeof t[r])throw new Error("toNetInput -"+n(r)+" string passed, but could not resolve HTMLElement for element id "+t[r]);throw new Error("toNetInput -"+n(r)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id")}if(m(e)){var a=e.shape[0];if(1!==a)throw new Error("toNetInput -"+n(r)+" tf.Tensor4D with batchSize "+a+" passed, but not supported in input array")}})),[4,Promise.all(r.map((function(e){return ce(e)&&(t=e,new Promise((function(e,n){if(t instanceof Y.getEnv().Canvas||ae(t))return e();function r(t){t.currentTarget&&(t.currentTarget.removeEventListener("load",r),t.currentTarget.removeEventListener("error",a),e(t))}function a(e){e.currentTarget&&(e.currentTarget.removeEventListener("load",r),e.currentTarget.removeEventListener("error",a),n(e))}t.addEventListener("load",r),t.addEventListener("error",a)})));var t})))];case 1:return a.sent(),[2,new le(r,Array.isArray(e))]}}))}))}function de(e,t){return c(this,void 0,void 0,(function(){var n,r,a,o,s,i;return l(this,(function(u){switch(u.label){case 0:return n=Y.getEnv().Canvas,r=e,e instanceof n?[3,5]:[4,pe(e)];case 1:if((a=u.sent()).batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return(o=a.getInput(0))instanceof n?(s=o,[3,4]):[3,2];case 2:return[4,ue(o)];case 3:s=u.sent(),u.label=4;case 4:r=s,u.label=5;case 5:return i=Z(r),[2,t.map((function(e){return e instanceof M?e.forSize(r.width,r.height).box.floor():e})).map((function(e){return e.clipAtImageBorders(r.width,r.height)})).map((function(e){var t=e.x,n=e.y,r=e.width,a=e.height,o=se({width:r,height:a});return Z(o).putImageData(i.getImageData(t,n,r,a),0,0),o}))]}}))}))}function he(e,t){return c(this,void 0,void 0,(function(){return l(this,(function(n){if(!f(e)&&!m(e))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(m(e)&&e.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,a.G6I((function(){var n=e.shape.slice(m(e)?1:0),r=n[0],o=n[1],s=n[2],i=t.map((function(e){return e instanceof M?e.forSize(o,r).box:e})).map((function(e){return e.clipAtImageBorders(o,r)})).map((function(t){var n=t.x,i=t.y,u=t.width,c=t.height;return a.msk(e.as3D(r,o,s),[i,n,0],[c,u,s])}));return i}))]}))}))}function fe(e,t){return c(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,(0,Y.getEnv().fetch)(e,t)];case 1:if(!((n=r.sent()).status<400))throw new Error("failed to fetch: ("+n.status+") "+n.statusText+", from url: "+n.url);return[2,n]}}))}))}function me(e){return c(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,fe(e)];case 1:return[2,t.sent().json()]}}))}))}function ge(e,t){var n=t+"-weights_manifest.json";if(!e)return{modelBaseUri:"",manifestUri:n};if("/"===e)return{modelBaseUri:"/",manifestUri:"/"+n};var r=e.startsWith("http://")?"http://":e.startsWith("https://")?"https://":"",a=(e=e.replace(r,"")).split("/").filter((function(e){return e})),o=e.endsWith(".json")?a[a.length-1]:n,s=r+(e.endsWith(".json")?a.slice(0,a.length-1):a).join("/");return{modelBaseUri:s=e.startsWith("/")?"/"+s:s,manifestUri:"/"===s?"/"+o:s+"/"+o}}function ye(e,t){return c(this,void 0,void 0,(function(){var n,r,o,s;return l(this,(function(i){switch(i.label){case 0:return n=ge(e,t),r=n.manifestUri,o=n.modelBaseUri,[4,me(r)];case 1:return s=i.sent(),[2,a.io.loadWeights(s,o)]}}))}))}function be(e,t,n){void 0===n&&(n=!1);var r=n?oe(t):t,a=r.width,o=r.height;return e.width=a,e.height=o,{width:a,height:o}}var we=function(){function e(e){this._name=e,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(e.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),e.prototype.getParamFromPath=function(e){var t=this.traversePropertyPath(e);return t.obj[t.objProp]},e.prototype.reassignParamFromPath=function(e,t){var n=this.traversePropertyPath(e),r=n.obj,a=n.objProp;r[a].dispose(),r[a]=t},e.prototype.getParamList=function(){var e=this;return this._paramMappings.map((function(t){var n=t.paramPath;return{path:n,tensor:e.getParamFromPath(n)}}))},e.prototype.getTrainableParams=function(){return this.getParamList().filter((function(e){return e.tensor instanceof a.QBX}))},e.prototype.getFrozenParams=function(){return this.getParamList().filter((function(e){return!(e.tensor instanceof a.QBX)}))},e.prototype.variable=function(){var e=this;
2this.getFrozenParams().forEach((function(t){var n=t.path,r=t.tensor;e.reassignParamFromPath(n,r.variable())}))},e.prototype.freeze=function(){var e=this;this.getTrainableParams().forEach((function(t){var n=t.path,r=t.tensor,o=a.mwg(r.dataSync());r.dispose(),e.reassignParamFromPath(n,o)}))},e.prototype.dispose=function(e){void 0===e&&(e=!0),this.getParamList().forEach((function(t){if(e&&t.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+t.path);t.tensor.dispose()})),this._params=void 0},e.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map((function(e){var t=e.tensor;return Array.from(t.dataSync())})).reduce((function(e,t){return e.concat(t)})))},e.prototype.load=function(e){return c(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return e instanceof Float32Array?(this.extractWeights(e),[2]):[4,this.loadFromUri(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.loadFromUri=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:if(e&&"string"!=typeof e)throw new Error(this._name+".loadFromUri - expected model uri");return[4,ye(e,this.getDefaultModelName())];case 1:return t=n.sent(),this.loadFromWeightMap(t),[2]}}))}))},e.prototype.loadFromDisk=function(e){return c(this,void 0,void 0,(function(){var t,n,r,o,s,i,u,c,p,d;return l(this,(function(l){switch(l.label){case 0:if(e&&"string"!=typeof e)throw new Error(this._name+".loadFromDisk - expected model file path");return t=Y.getEnv().readFile,n=ge(e,this.getDefaultModelName()),r=n.manifestUri,o=n.modelBaseUri,s=function(e){return Promise.all(e.map((function(e){return t(e).then((function(e){return e.buffer}))})))},i=a.io.weightsLoaderFactory(s),p=(c=JSON).parse,[4,t(r)];case 1:return u=p.apply(c,[l.sent().toString()]),[4,i(u,o)];case 2:return d=l.sent(),this.loadFromWeightMap(d),[2]}}))}))},e.prototype.loadFromWeightMap=function(e){var t=this.extractParamsFromWeigthMap(e),n=t.paramMappings,r=t.params;this._paramMappings=n,this._params=r},e.prototype.extractWeights=function(e){var t=this.extractParams(e),n=t.paramMappings,r=t.params;this._paramMappings=n,this._params=r},e.prototype.traversePropertyPath=function(e){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var t=e.split("/").reduce((function(t,n){if(!t.nextObj.hasOwnProperty(n))throw new Error("traversePropertyPath - object does not have property "+n+", for path "+e);return{obj:t.nextObj,objProp:n,nextObj:t.nextObj[n]}}),{nextObj:this.params}),n=t.obj,r=t.objProp;if(!(n&&r&&n[r]instanceof a.w3A))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+e);return{obj:n,objProp:r}},e}();function ve(e,t,n){return a.G6I((function(){var r=a.Kd4(e,t.depthwise_filter,t.pointwise_filter,n,"same");return a.WQq(r,t.bias)}))}function ke(e,t,n){return void 0===n&&(n=!1),a.G6I((function(){var r=a.wDQ(n?a.WQq(a.QlL(e,t.conv0.filters,[2,2],"same"),t.conv0.bias):ve(e,t.conv0,[2,2])),o=ve(r,t.conv1,[1,1]),s=ve(a.wDQ(a.WQq(r,o)),t.conv2,[1,1]);return a.wDQ(a.WQq(r,a.WQq(o,s)))}))}function xe(e,t,n,r){return void 0===n&&(n=!1),void 0===r&&(r=!0),a.G6I((function(){var o=a.wDQ(n?a.WQq(a.QlL(e,t.conv0.filters,r?[2,2]:[1,1],"same"),t.conv0.bias):ve(e,t.conv0,r?[2,2]:[1,1])),s=ve(o,t.conv1,[1,1]),i=ve(a.wDQ(a.WQq(o,s)),t.conv2,[1,1]),u=ve(a.wDQ(a.WQq(o,a.WQq(s,i))),t.conv3,[1,1]);return a.wDQ(a.WQq(o,a.WQq(s,a.WQq(i,u))))}))}function _e(e,t,n,r){return void 0===n&&(n="same"),void 0===r&&(r=!1),a.G6I((function(){var o=a.WQq(a.QlL(e,t.filters,[1,1],n),t.bias);return r?a.wDQ(o):o}))}function Ie(e,t){Object.keys(e).forEach((function(n){t.some((function(e){return e.originalPath===n}))||e[n].dispose()}))}function Se(e,t){return function(n,r,o,s){var i=a.IFH(e(n*r*o*o),[o,o,n,r]),u=a.SC3(e(r));return t.push({paramPath:s+"/filters"},{paramPath:s+"/bias"}),{filters:i,bias:u}}}function Ne(e,t){return function(n,r,o){var s=a.Enf(e(n*r),[n,r]),i=a.SC3(e(r));return t.push({paramPath:o+"/weights"},{paramPath:o+"/bias"}),{weights:s,bias:i}}}var Me=function(e,t,n){this.depthwise_filter=e,this.pointwise_filter=t,this.bias=n};function Te(e,t){return function(n,r,o){var s=a.IFH(e(9*n),[3,3,n,1]),i=a.IFH(e(n*r),[1,1,n,r]),u=a.SC3(e(r));return t.push({paramPath:o+"/depthwise_filter"},{paramPath:o+"/pointwise_filter"},{paramPath:o+"/bias"}),new Me(s,i,u)}}function Ee(e){return function(t){var n=e(t+"/depthwise_filter",4),r=e(t+"/pointwise_filter",4),a=e(t+"/bias",1);return new Me(n,r,a)}}function Ae(e,t){return function(n,r,a){var o=e[n];if(!h(o,r))throw new Error("expected weightMap["+n+"] to be a Tensor"+r+"D, instead have "+o);return t.push({originalPath:n,paramPath:a||n}),o}}function Fe(e){var t=e;return{extractWeights:function(e){var n=t.slice(0,e);return t=t.slice(e),n},getRemainingWeights:function(){return t}}}function De(e,t){var n=Se(e,t),r=Te(e,t);function a(e,t,a,o){return void 0===o&&(o=!1),{conv0:o?n(e,t,3,a+"/conv0"):r(e,t,a+"/conv0"),conv1:r(t,t,a+"/conv1"),conv2:r(t,t,a+"/conv2")}}
2return{extractDenseBlock3Params:a,extractDenseBlock4Params:function(e,t,n,o){void 0===o&&(o=!1);var s=a(e,t,n,o);return{conv0:s.conv0,conv1:s.conv1,conv2:s.conv2,conv3:r(t,t,n+"/conv3")}}}}function Oe(e){return function(t){return{filters:e(t+"/filters",4),bias:e(t+"/bias",1)}}}function Ce(e,t){var n=Ae(e,t),r=Oe(n),a=Ee(n);return{extractDenseBlock3Params:function(e,t){return void 0===t&&(t=!1),{conv0:t?r(e+"/conv0"):a(e+"/conv0"),conv1:a(e+"/conv1"),conv2:a(e+"/conv2")}},extractDenseBlock4Params:function(e,t){return void 0===t&&(t=!1),{conv0:t?r(e+"/conv0"):a(e+"/conv0"),conv1:a(e+"/conv1"),conv2:a(e+"/conv2"),conv3:a(e+"/conv3")}}}}var Pe=function(e){function t(){return e.call(this,"FaceFeatureExtractor")||this}return i(t,e),t.prototype.forwardInput=function(e){var t=this.params;if(!t)throw new Error("FaceFeatureExtractor - load model before inference");return a.G6I((function(){var n=xe(A(e.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(a.SgB(255)),t.dense0,!0);return n=xe(n,t.dense1),n=xe(n,t.dense2),n=xe(n,t.dense3),a.q2x(n,[7,7],[2,2],"valid")}))},t.prototype.forward=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,pe(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},t.prototype.extractParamsFromWeigthMap=function(e){return function(e){var t=[],n=Ce(e,t).extractDenseBlock4Params,r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2"),dense3:n("dense3")};return Ie(e,t),{params:r,paramMappings:t}}(e)},t.prototype.extractParams=function(e){return function(e){var t=[],n=Fe(e),r=n.extractWeights,a=n.getRemainingWeights,o=De(r,t).extractDenseBlock4Params,s=o(3,32,"dense0",!0),i=o(32,64,"dense1"),u=o(64,128,"dense2"),c=o(128,256,"dense3");if(0!==a().length)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:t,params:{dense0:s,dense1:i,dense2:u,dense3:c}}}(e)},t}(we);function Re(e,t){return a.G6I((function(){return a.WQq(a._o$(e,t.weights),t.bias)}))}function $e(e){var t={},n={};return Object.keys(e).forEach((function(r){(r.startsWith("fc")?n:t)[r]=e[r]})),{featureExtractorMap:t,classifierMap:n}}var Le=function(e){function t(t,n){var r=e.call(this,t)||this;return r._faceFeatureExtractor=n,r}return i(t,e),Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var t=this,n=this.params;if(!n)throw new Error(this._name+" - load model before inference");return a.G6I((function(){var r=e instanceof le?t.faceFeatureExtractor.forwardInput(e):e;return Re(r.as2D(r.shape[0],-1),n.fc)}))},t.prototype.dispose=function(t){void 0===t&&(t=!0),this.faceFeatureExtractor.dispose(t),e.prototype.dispose.call(this,t)},t.prototype.loadClassifierParams=function(e){var t=this.extractClassifierParams(e),n=t.params,r=t.paramMappings;this._params=n,this._paramMappings=r},t.prototype.extractClassifierParams=function(e){return function(e,t,n){var r=[],a=Fe(e),o=a.extractWeights,s=a.getRemainingWeights,i=Ne(o,r)(t,n,"fc");if(0!==s().length)throw new Error("weights remaing after extract: "+s().length);return{paramMappings:r,params:{fc:i}}}(e,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},t.prototype.extractParamsFromWeigthMap=function(e){var t=$e(e),n=t.featureExtractorMap,r=t.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(n),function(e){var t=[],n=Ae(e,t),r={fc:("fc",{weights:n("fc/weights",2),bias:n("fc/bias",1)})};return Ie(e,t),{params:r,paramMappings:t}}(r)},t.prototype.extractParams=function(e){var t=this.getClassifierChannelsIn(),n=this.getClassifierChannelsOut(),r=n*t+n,a=e.slice(0,e.length-r),o=e.slice(e.length-r);return this.faceFeatureExtractor.extractWeights(a),this.extractClassifierParams(o)},t}(we),We=["neutral","happy","sad","angry","fearful","disgusted","surprised"],ze=function(){function e(e){var t=this;if(7!==e.length)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+e.length);We.forEach((function(n,r){t[n]=e[r]}))}return e.prototype.asSortedArray=function(){var e=this;return We.map((function(t){return{expression:t,probability:e[t]}})).sort((function(e,t){return t.probability-e.probability}))},e}(),Be=function(e){function t(t){return void 0===t&&(t=new Pe),e.call(this,"FaceExpressionNet",t)||this}return i(t,e),t.prototype.forwardInput=function(e){var t=this;return a.G6I((function(){return a.UhY(t.runNet(e))}))},t.prototype.forward=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,pe(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.predictExpressions=function(e){return c(this,void 0,void 0,(function(){var t,n,r,o,s=this;return l(this,(function(i){switch(i.label){case 0:return[4,pe(e)];case 1:return t=i.sent(),[4,this.forwardInput(t)];case 2:return n=i.sent(),[4,Promise.all(a.iqB(n).map((function(e){return c(s,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,e.data()];case 1:return t=n.sent(),e.dispose(),[2,t]}}))}))})))];case 3:return r=i.sent(),n.dispose(),o=r.map((function(e){return new ze(e)})),[2,t.isBatchInput?o:o[0]]}}))}))},t.prototype.getDefaultModelName=function(){return"face_expression_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t.prototype.getClassifierChannelsOut=function(){return 7},t}(Le);function Ue(e,t){var n={expressions:t};return Object.assign({},e,n)}function He(e,t,n,r){void 0===n&&(n=.1),(Array.isArray(t)?t:[t]).forEac
2h((function(t){var a=t instanceof ze?t:t.expressions instanceof ze?t.expressions:void 0;if(!a)throw new Error("drawFaceExpressions - expected faceExpressions to be FaceExpressions | WithFaceExpressions<{}> or array thereof");var o=a.asSortedArray().filter((function(e){return e.probability>n})),s=z(t)?t.detection.box.bottomLeft:r||new _(0,0),i=new ee(o.map((function(e){return e.expression+" ("+y(e.probability)+")"})),s);i.draw(e)}))}function Ve(e){return z(e)&&e.landmarks instanceof C&&e.unshiftedLandmarks instanceof C&&e.alignedRect instanceof M}function Ge(e,t){var n=e.detection.box,r=t.shiftBy(n.x,n.y),a=r.align(),o=e.detection.imageDims,s={landmarks:r,unshiftedLandmarks:t,alignedRect:new M(e.detection.score,a.rescale(o.reverse()),o)};return Object.assign({},e,s)}var qe=function(e){void 0===e&&(e={});var t=e.drawLines,n=void 0===t||t,r=e.drawPoints,a=void 0===r||r,o=e.lineWidth,s=e.lineColor,i=e.pointSize,u=e.pointColor;this.drawLines=n,this.drawPoints=a,this.lineWidth=o||1,this.pointSize=i||2,this.lineColor=s||"rgba(0, 255, 255, 1)",this.pointColor=u||"rgba(255, 0, 255, 1)"},je=function(){function e(e,t){void 0===t&&(t={}),this.faceLandmarks=e,this.options=new qe(t)}
2return e.prototype.draw=function(e){var t=Z(e),n=this.options,r=n.drawLines,a=n.drawPoints,s=n.lineWidth,i=n.lineColor,u=n.pointSize,c=n.pointColor;r&&this.faceLandmarks instanceof R&&(t.strokeStyle=i,t.lineWidth=s,o(t,this.faceLandmarks.getJawOutline()),o(t,this.faceLandmarks.getLeftEyeBrow()),o(t,this.faceLandmarks.getRightEyeBrow()),o(t,this.faceLandmarks.getNose()),o(t,this.faceLandmarks.getLeftEye(),!0),o(t,this.faceLandmarks.getRightEye(),!0),o(t,this.faceLandmarks.getMouth(),!0)),a&&(t.strokeStyle=c,t.fillStyle=c,this.faceLandmarks.positions.forEach((function(e){t.beginPath(),t.arc(e.x,e.y,u,0,2*Math.PI),t.fill()})))},e}();function Ke(e,t){(Array.isArray(t)?t:[t]).forEach((function(t){var n=t instanceof C?t:Ve(t)?t.landmarks:void 0;if(!n)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new je(n).draw(e)}))}function Qe(e,t,n){return a.WQq(a.QlL(e,t.filters,n,"same"),t.bias)}function Ye(e,t,n){void 0===n&&(n=!0);var r=n?a.wDQ(e):e;return r=ve(r,t.separable_conv0,[1,1]),r=ve(a.wDQ(r),t.separable_conv1,[1,1]),r=a._SL(r,[3,3],[2,2],"same"),a.WQq(r,Qe(e,t.expansion_conv,[2,2]))}var Je,Ze,Xe=function(e){function t(t){var n=e.call(this,"TinyXception")||this;return n._numMainBlocks=t,n}return i(t,e),t.prototype.forwardInput=function(e){var t=this,n=this.params;if(!n)throw new Error("TinyXception - load model before inference");return a.G6I((function(){var r=A(e.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(a.SgB(256)),o=a.wDQ(Qe(r,n.entry_flow.conv_in,[2,2]));return o=Ye(o,n.entry_flow.reduction_block_0,!1),o=Ye(o,n.entry_flow.reduction_block_1),v(t._numMainBlocks,0,1).forEach((function(e){o=function(e,t){var n=ve(a.wDQ(e),t.separable_conv0,[1,1]);return n=ve(a.wDQ(n),t.separable_conv1,[1,1]),n=ve(a.wDQ(n),t.separable_conv2,[1,1]),a.WQq(n,e)}(o,n.middle_flow["main_block_"+e])})),o=Ye(o,n.exit_flow.reduction_block),o=a.wDQ(ve(o,n.exit_flow.separable_conv,[1,1]))}))},t.prototype.forward=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,pe(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.getDefaultModelName=function(){return"tiny_xception_model"},t.prototype.extractParamsFromWeigthMap=function(e){return function(e,t){var n=[],r=function(e,t){var n=Ae(e,t),r=Oe(n),a=Ee(n);return{extractConvParams:r,extractSeparableConvParams:a,extractReductionBlockParams:function(e){return{separable_conv0:a(e+"/separable_conv0"),separable_conv1:a(e+"/separable_conv1"),expansion_conv:r(e+"/expansion_conv")}},extractMainBlockParams:function(e){return{separable_conv0:a(e+"/separable_conv0"),separable_conv1:a(e+"/separable_conv1"),separable_conv2:a(e+"/separable_conv2")}}}}(e,n),a=r.extractConvParams,o=r.extractSeparableConvParams,s=r.extractReductionBlockParams,i=r.extractMainBlockParams,u={conv_in:a("entry_flow/conv_in"),reduction_block_0:s("entry_flow/reduction_block_0"),reduction_block_1:s("entry_flow/reduction_block_1")},c={};v(t,0,1).forEach((function(e){c["main_block_"+e]=i("middle_flow/main_block_"+e)}));var l={reduction_block:s("exit_flow/reduction_block"),separable_conv:o("exit_flow/separable_conv")};return Ie(e,n),{params:{entry_flow:u,middle_flow:c,exit_flow:l},paramMappings:n}}(e,this._numMainBlocks)},t.prototype.extractParams=function(e){return function(e,t){var n=[],r=Fe(e),a=r.extractWeights,o=r.getRemainingWeights,s=function(e,t){var n=Se(e,t),r=Te(e,t);return{extractConvParams:n,extractSeparableConvParams:r,extractReductionBlockParams:function(e,t,a){return{separable_conv0:r(e,t,a+"/separable_conv0"),separable_conv1:r(t,t,a+"/separable_conv1"),expansion_conv:n(e,t,1,a+"/expansion_conv")}},extractMainBlockParams:function(e,t){return{separable_conv0:r(e,e,t+"/separable_conv0"),separable_conv1:r(e,e,t+"/separable_conv1"),separable_conv2:r(e,e,t+"/separable_conv2")}}}}(a,n),i=s.extractConvParams,u=s.extractSeparableConvParams,c=s.extractReductionBlockParams,l=s.extractMainBlockParams,p={conv_in:i(3,32,3,"entry_flow/conv_in"),reduction_block_0:c(32,64,"entry_flow/reduction_block_0"),reduction_block_1:c(64,128,"entry_flow/reduction_block_1")}
2,d={};v(t,0,1).forEach((function(e){d["main_block_"+e]=l(128,"middle_flow/main_block_"+e)}));var h={reduction_block:c(128,256,"exit_flow/reduction_block"),separable_conv:u(256,512,"exit_flow/separable_conv")};if(0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:n,params:{entry_flow:p,middle_flow:d,exit_flow:h}}}(e,this._numMainBlocks)},t}(we);(Ze=Je||(Je={})).FEMALE="female",Ze.MALE="male";var et,tt=function(e){function t(t){void 0===t&&(t=new Xe(2));var n=e.call(this,"AgeGenderNet")||this;return n._faceFeatureExtractor=t,n}return i(t,e),Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var t=this,n=this.params;if(!n)throw new Error(this._name+" - load model before inference");return a.G6I((function(){var r=e instanceof le?t.faceFeatureExtractor.forwardInput(e):e,o=a.q2x(r,[7,7],[2,2],"valid").as2D(r.shape[0],-1);return{age:Re(o,n.fc.age).as1D(),gender:Re(o,n.fc.gender)}}))},t.prototype.forwardInput=function(e){var t=this;return a.G6I((function(){var n=t.runNet(e),r=n.age,o=n.gender;return{age:r,gender:a.UhY(o)}}))},t.prototype.forward=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,pe(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.predictAgeAndGender=function(e){return c(this,void 0,void 0,(function(){var t,n,r,o,s,i,u=this;return l(this,(function(p){switch(p.label){case 0:return[4,pe(e)];case 1:return t=p.sent(),[4,this.forwardInput(t)];case 2:return n=p.sent(),r=a.iqB(n.age),o=a.iqB(n.gender),s=r.map((function(e,t){return{ageTensor:e,genderTensor:o[t]}})),[4,Promise.all(s.map((function(e){var t=e.ageTensor,n=e.genderTensor;return c(u,void 0,void 0,(function(){var e,r,a,o,s;return l(this,(function(i){switch(i.label){case 0:return[4,t.data()];case 1:return e=i.sent()[0],[4,n.data()];case 2:return r=i.sent()[0],o=(a=r>.5)?Je.MALE:Je.FEMALE,s=a?r:1-r,t.dispose(),n.dispose(),[2,{age:e,gender:o,genderProbability:s}]}}))}))})))];case 3:return i=p.sent(),n.age.dispose(),n.gender.dispose(),[2,t.isBatchInput?i:i[0]]}}))}))},t.prototype.getDefaultModelName=function(){return"age_gender_model"},t.prototype.dispose=function(t){void 0===t&&(t=!0),this.faceFeatureExtractor.dispose(t),e.prototype.dispose.call(this,t)},t.prototype.loadClassifierParams=function(e){var t=this.extractClassifierParams(e),n=t.params,r=t.paramMappings;this._params=n,this._paramMappings=r},t.prototype.extractClassifierParams=function(e){return function(e){var t=[],n=Fe(e),r=n.extractWeights,a=n.getRemainingWeights,o=Ne(r,t),s=o(512,1,"fc/age"),i=o(512,2,"fc/gender");if(0!==a().length)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:t,params:{fc:{age:s,gender:i}}}}(e)},t.prototype.extractParamsFromWeigthMap=function(e){var t=$e(e),n=t.featureExtractorMap,r=t.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(n),function(e){var t=[],n=Ae(e,t);function r(e){return{weights:n(e+"/weights",2),bias:n(e+"/bias",1)}}var a={fc:{age:r("fc/age"),gender:r("fc/gender")}};return Ie(e,t),{params:a,paramMappings:t}}(r)},t.prototype.extractParams=function(e){var t=e.slice(0,e.length-1539),n=e.slice(e.length-1539);return this.faceFeatureExtractor.extractWeights(t),this.extractClassifierParams(n)},t}(we),nt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.postProcess=function(e,t,n){var r=n.map((function(e){var n=e.width,r=e.height,a=t/Math.max(r,n);return{width:n*a,height:r*a}})),o=r.length;return a.G6I((function(){var n=function(e,t){return a.Qfh([a.ymW([68],e),a.ymW([68],t)],1).as2D(1,136).as1D()},s=function(e,t){var n=r[e],a=n.width,o=n.height;return t(a,o)?Math.abs(a-o)/2:0};return e.mul(a.ymW([o,136],t)).sub(a.Qfh(Array.from(Array(o),(function(e,t){return n(function(e){return s(e,(function(e,t){return e<t}))}(t),function(e){return s(e,(function(e,t){return t<e}))}(t))})))).div(a.Qfh(Array.from(Array(o),(function(e,t){return n(r[t].width,r[t].height)}))))}))},t.prototype.forwardInput=function(e){var t=this;return a.G6I((function(){var n=t.runNet(e);return t.postProcess(n,e.inputSize,e.inputDimensions.map((function(e){return{height:e[0],width:e[1]}})))}))},t.prototype.forward=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,pe(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.detectLandmarks=function(e){return c(this,void 0,void 0,(function(){var t,n,r,o=this;return l(this,(function(s){switch(s.label){case 0:return[4,pe(e)];case 1:return t=s.sent(),n=a.G6I((function(){return a.iqB(o.forwardInput(t))})),[4,Promise.all(n.map((function(e,n){return c(o,void 0,void 0,(function(){var r,a,o,s,i;return l(this,(function(u){switch(u.label){case 0:return o=(a=Array).from,[4,e.data()];case 1:return r=o.apply(a,[u.sent()]),s=r.filter((function(e,t){return g(t)})),i=r.filter((function(e,t){return!g(t)})),[2,new R(Array(68).fill(0).map((function(e,t){return new _(s[t],i[t])}
2)),{height:t.getInputHeight(n),width:t.getInputWidth(n)})]}}))}))})))];case 2:return r=s.sent(),n.forEach((function(e){return e.dispose()})),[2,t.isBatchInput?r:r[0]]}}))}))},t.prototype.getClassifierChannelsOut=function(){return 136},t}(Le),rt=function(e){function t(t){return void 0===t&&(t=new Pe),e.call(this,"FaceLandmark68Net",t)||this}return i(t,e),t.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t}(nt),at=function(e){function t(){return e.call(this,"TinyFaceFeatureExtractor")||this}return i(t,e),t.prototype.forwardInput=function(e){var t=this.params;if(!t)throw new Error("TinyFaceFeatureExtractor - load model before inference");return a.G6I((function(){var n=ke(A(e.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(a.SgB(255)),t.dense0,!0);return n=ke(n,t.dense1),n=ke(n,t.dense2),a.q2x(n,[14,14],[2,2],"valid")}))},t.prototype.forward=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,pe(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},t.prototype.extractParamsFromWeigthMap=function(e){return function(e){var t=[],n=Ce(e,t).extractDenseBlock3Params,r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2")};return Ie(e,t),{params:r,paramMappings:t}}(e)},t.prototype.extractParams=function(e){return function(e){var t=[],n=Fe(e),r=n.extractWeights,a=n.getRemainingWeights,o=De(r,t).extractDenseBlock3Params,s=o(3,32,"dense0",!0),i=o(32,64,"dense1"),u=o(64,128,"dense2");if(0!==a().length)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:t,params:{dense0:s,dense1:i,dense2:u}}}(e)},t}(we),ot=function(e){function t(t){return void 0===t&&(t=new at),e.call(this,"FaceLandmark68TinyNet",t)||this}return i(t,e),t.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},t.prototype.getClassifierChannelsIn=function(){return 128},t}(nt);function st(e,t,n,r,o){void 0===o&&(o="same");var s=t.conv,i=s.filters,u=s.bias,c=a.QlL(e,i,n,o);return c=function(e,t){return a.WQq(a.E7T(e,t.weights),t.biases)}(c=a.WQq(c,u),t.scale),r?a.wDQ(c):c}function it(e,t){return st(e,t,[1,1],!1)}function ut(e,t){return st(e,t,[2,2],!0,"valid")}function ct(e,t){function n(n,r,o,s){var i=function(n,r,o,s){var i=function(t,n,r){var o=e(t),s=o.length/(n*r*r);if(s%1!=0)throw new Error("depth has to be an integer: "+s+", weights.length: "+o.length+", numFilters: "+n+", filterSize: "+r);return a.G6I((function(){return a.oLj(a.IFH(o,[n,s,r,r]),[2,3,1,0])}))}(n,r,o),u=a.SC3(e(r));return t.push({paramPath:s+"/filters"},{paramPath:s+"/bias"}),{filters:i,bias:u}}(n,r,o,s+"/conv"),u=function(n,r){var o=a.SC3(e(n)),s=a.SC3(e(n));return t.push({paramPath:r+"/weights"},{paramPath:r+"/biases"}),{weights:o,biases:s}}(r,s+"/scale");return{conv:i,scale:u}}return{extractConvLayerParams:n,extractResidualLayerParams:function(e,t,r,a,o){return void 0===o&&(o=!1),{conv1:n((o?.5:1)*e,t,r,a+"/conv1"),conv2:n(e,t,r,a+"/conv2")}}}}function lt(e){var t=[],n=function(e,t){var n=Ae(e,t);function r(e){var t=n(e+"/conv/filters",4),r=n(e+"/conv/bias",1),a=function(e){return{weights:n(e+"/scale/weights",1),biases:n(e+"/scale/biases",1)}}(e);return{conv:{filters:t,bias:r},scale:a}}return{extractConvLayerParams:r,extractResidualLayerParams:function(e){return{conv1:r(e+"/conv1"),conv2:r(e+"/conv2")}}}}(e,t),r=n.extractConvLayerParams,a=n.extractResidualLayerParams,o=r("conv32_down"),s=a("conv32_1"),i=a("conv32_2"),u=a("conv32_3"),c=a("conv64_down"),l=a("conv64_1"),p=a("conv64_2"),d=a("conv64_3"),f=a("conv128_down"),m=a("conv128_1"),g=a("conv128_2"),y=a("conv256_down"),b=a("conv256_1"),w=a("conv256_2"),v=a("conv256_down_out"),k=e.fc;if(t.push({originalPath:"fc",paramPath:"fc"}),!h(k,2))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+k);var x={conv32_down:o,conv32_1:s,conv32_2:i,conv32_3:u,conv64_down:c,conv64_1:l,conv64_2:p,conv64_3:d,conv128_down:f,conv128_1:m,conv128_2:g,conv256_down:y,conv256_1:b,conv256_2:w,conv256_down_out:v,fc:k};return Ie(e,t),{params:x,paramMappings:t}}function pt(e,t){var n=function(e,t){return st(e,t,[1,1],!0)}(e,t.conv1);return n=it(n,t.conv2),n=a.WQq(n,e),a.wDQ(n)}function dt(e,t){var n=ut(e,t.conv1);n=it(n,t.conv2);var r=a.q2x(e,2,2,"valid"),o=a.DjU(r.shape),s=r.shape[3]!==n.shape[3];if(r.shape[1]!==n.shape[1]||r.shape[2]!==n.shape[2]){var i=p(n.shape);i[1]=1;var u=a.DjU(i),c=p((n=a.WUr([n,u],1)).shape);c[2]=1;var l=a.DjU(c);n=a.WUr([n,l],2)}return r=s?a.WUr([r,o],3):r,n=a.WQq(r,n),a.wDQ(n)}i((function(){return null!==et&&et.apply(this,arguments)||this}),et=rt);var ht=function(e){function t(){return e.call(this,"FaceRecognitionNet")||this}return i(t,e),t.prototype.forwardInput=function(e){var t=this.params;if(!t)throw new Error("FaceRecognitionNet - load model before inference");return a.G6I((function(){var n=ut(A(e.toBatchTensor(150,!0).toFloat
2(),[122.782,117.001,104.298]).div(a.SgB(256)),t.conv32_down);n=pt(n=a._SL(n,3,2,"valid"),t.conv32_1),n=pt(n,t.conv32_2),n=pt(n,t.conv32_3),n=pt(n=dt(n,t.conv64_down),t.conv64_1),n=pt(n,t.conv64_2),n=pt(n,t.conv64_3),n=pt(n=dt(n,t.conv128_down),t.conv128_1),n=pt(n,t.conv128_2),n=pt(n=dt(n,t.conv256_down),t.conv256_1);var r=(n=dt(n=pt(n,t.conv256_2),t.conv256_down_out)).mean([1,2]);return a._o$(r,t.fc)}))},t.prototype.forward=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,pe(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.computeFaceDescriptor=function(e){return c(this,void 0,void 0,(function(){var t,n,r,o=this;return l(this,(function(s){switch(s.label){case 0:return[4,pe(e)];case 1:return t=s.sent(),n=a.G6I((function(){return a.iqB(o.forwardInput(t))})),[4,Promise.all(n.map((function(e){return e.data()})))];case 2:return r=s.sent(),n.forEach((function(e){return e.dispose()})),[2,t.isBatchInput?r:r[0]]}}))}))},t.prototype.getDefaultModelName=function(){return"face_recognition_model"},t.prototype.extractParamsFromWeigthMap=function(e){return lt(e)},t.prototype.extractParams=function(e){return function(e){var t=Fe(e),n=t.extractWeights,r=t.getRemainingWeights,o=[],s=ct(n,o),i=s.extractConvLayerParams,u=s.extractResidualLayerParams,c=i(4704,32,7,"conv32_down"),l=u(9216,32,3,"conv32_1"),p=u(9216,32,3,"conv32_2"),d=u(9216,32,3,"conv32_3"),h=u(36864,64,3,"conv64_down",!0),f=u(36864,64,3,"conv64_1"),m=u(36864,64,3,"conv64_2"),g=u(36864,64,3,"conv64_3"),y=u(147456,128,3,"conv128_down",!0),b=u(147456,128,3,"conv128_1"),w=u(147456,128,3,"conv128_2"),v=u(589824,256,3,"conv256_down",!0),k=u(589824,256,3,"conv256_1"),x=u(589824,256,3,"conv256_2"),_=u(589824,256,3,"conv256_down_out"),I=a.G6I((function(){return a.oLj(a.Enf(n(32768),[128,256]),[1,0])}));if(o.push({paramPath:"fc"}),0!==r().length)throw new Error("weights remaing after extract: "+r().length);return{params:{conv32_down:c,conv32_1:l,conv32_2:p,conv32_3:d,conv64_down:h,conv64_1:f,conv64_2:m,conv64_3:g,conv128_down:y,conv128_1:b,conv128_2:w,conv256_down:v,conv256_1:k,conv256_2:x,conv256_down_out:_,fc:I},paramMappings:o}}(e)},t}(we);function ft(e,t,n){var r={gender:t,genderProbability:n};return Object.assign({},e,r)}var mt=function(){function e(e){var t=void 0===e?{}:e,n=t.minFaceSize,r=t.scaleFactor,a=t.maxNumScales,o=t.scoreThresholds,s=t.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=n||20,this._scaleFactor=r||.709,this._maxNumScales=a||10,this._scoreThresholds=o||[.6,.7,.7],this._scaleSteps=s,"number"!=typeof this._minFaceSize||this._minFaceSize<0)throw new Error(this._name+" - expected minFaceSize to be a number > 0");if("number"!=typeof this._scaleFactor||this._scaleFactor<=0||this._scaleFactor>=1)throw new Error(this._name+" - expected scaleFactor to be a number between 0 and 1");if("number"!=typeof this._maxNumScales||this._maxNumScales<0)throw new Error(this._name+" - expected maxNumScales to be a number > 0");if(!Array.isArray(this._scoreThresholds)||3!==this._scoreThresholds.length||this._scoreThresholds.some((function(e){return"number"!=typeof e})))throw new Error(this._name+" - expected scoreThresholds to be an array of numbers of length 3");if(this._scaleSteps&&(!Array.isArray(this._scaleSteps)||this._scaleSteps.some((function(e){return"number"!=typeof e}))))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(e.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),e}();function gt(e,t,n){return a.G6I((function(){var r=a.QlL(e,t.filters,n,"same");return r=a.WQq(r,t.batch_norm_offset),a.Qjg(r,0,6)}))}function yt(e,t,n){var r=e.arraySync(),a=Math.min(r[t][0],r[t][2]),o=Math.min(r[t][1],r[t][3]),s=Math.max(r[t][0],r[t][2]),i=Math.max(r[t][1],r[t][3]),u=Math.min(r[n][0],r[n][2]),c=Math.min(r[n][1],r[n][3]),l=Math.max(r[n][0],r[n][2]),p=Math.max(r[n][1],r[n][3]),d=(s-a)*(i-o),h=(l-u)*(p-c);if(d<=0||h<=0)return 0;var f=Math.max(a,u),m=Math.max(o,c),g=Math.min(s,l),y=Math.min(i,p),b=Math.max(g-f,0)*Math.max(y-m,0);return b/(d+h-b)}function bt(e,t){return a.G6I((function(){var n=e.shape[0];return{boxPredictionEncoding:a.OoG(_e(e,t.box_encoding_predictor),[n,-1,1,4]),classPrediction:a.OoG(_e(e,t.class_predictor),[n,-1,3])}}))}var wt=function(){function e(e){var t=void 0===e?{}:e,n=t.minConfidence,r=t.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=n||.5,this._maxResults=r||100,"number"!=typeof this._minConfidence||this._minConfidence<=0||this._minConfidence>=1)throw new Error(this._name+" - expected minConfidence to be a number between 0 and 1");if("number"!=typeof this._maxResults)throw new Error(this._name+" - expected maxResults to be a number")}return Object.defineProperty(e.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),e}(),vt=function(e){function t(){return e.call(this,"SsdMobilenetv1")||this}return i(t,e),t.prototype.forwardInput=function(e){var t=this.params;if(!t)throw new Error("SsdMobilenetv1 - load model before inference");
2return a.G6I((function(){var n=e.toBatchTensor(512,!1).toFloat(),r=function(e,t){return a.G6I((function(){var n=null,r=gt(e,t.conv_0,[2,2]);if([t.conv_1,t.conv_2,t.conv_3,t.conv_4,t.conv_5,t.conv_6,t.conv_7,t.conv_8,t.conv_9,t.conv_10,t.conv_11,t.conv_12,t.conv_13].forEach((function(e,t){var o=t+1,s=function(e){return[2,4,6,12].some((function(t){return t===e}))?[2,2]:[1,1]}(o);r=function(e,t,n){return a.G6I((function(){var r=a.gLu(e,t.filters,n,"same");return r=a.QtV(r,t.batch_norm_mean,t.batch_norm_variance,t.batch_norm_offset,t.batch_norm_scale,.0010000000474974513),a.Qjg(r,0,6)}))}(r,e.depthwise_conv,s),r=gt(r,e.pointwise_conv,[1,1]),11===o&&(n=r)})),null===n)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:n}}))}(a.AT$(a.E7T(n,a.SgB(.007843137718737125)),a.SgB(1)),t.mobilenetv1),o=function(e,t,n){return a.G6I((function(){var r=gt(e,n.conv_0,[1,1]),o=gt(r,n.conv_1,[2,2]),s=gt(o,n.conv_2,[1,1]),i=gt(s,n.conv_3,[2,2]),u=gt(i,n.conv_4,[1,1]),c=gt(u,n.conv_5,[2,2]),l=gt(c,n.conv_6,[1,1]),p=gt(l,n.conv_7,[2,2]),d=bt(t,n.box_predictor_0),h=bt(e,n.box_predictor_1),f=bt(o,n.box_predictor_2),m=bt(i,n.box_predictor_3),g=bt(c,n.box_predictor_4),y=bt(p,n.box_predictor_5);return{boxPredictions:a.WUr([d.boxPredictionEncoding,h.boxPredictionEncoding,f.boxPredictionEncoding,m.boxPredictionEncoding,g.boxPredictionEncoding,y.boxPredictionEncoding],1),classPredictions:a.WUr([d.classPrediction,h.classPrediction,f.classPrediction,m.classPrediction,g.classPrediction,y.classPrediction],1)}}))}(r.out,r.conv11,t.prediction_layer);return function(e,t,n){return a.G6I((function(){var r=e.shape[0],o=function(e,t){var n=function(e){var t=a.iqB(a.oLj(e,[1,0])),n=[a.AT$(t[2],t[0]),a.AT$(t[3],t[1])];return{sizes:n,centers:[a.WQq(t[0],a.MbH(n[0],a.SgB(2))),a.WQq(t[1],a.MbH(n[1],a.SgB(2)))]}}(e),r=n.sizes,o=n.centers,s=a.iqB(a.oLj(t,[1,0])),i=a.MbH(a.E7T(a.oNF(a.MbH(s[2],a.SgB(5))),r[0]),a.SgB(2)),u=a.WQq(a.E7T(a.MbH(s[0],a.SgB(10)),r[0]),o[0]),c=a.MbH(a.E7T(a.oNF(a.MbH(s[3],a.SgB(5))),r[1]),a.SgB(2)),l=a.WQq(a.E7T(a.MbH(s[1],a.SgB(10)),r[1]),o[1]);return a.oLj(a.Qfh([a.AT$(u,i),a.AT$(l,c),a.WQq(u,i),a.WQq(l,c)]),[1,0])}(a.OoG(a.CUy(n.extra_dim,[r,1,1]),[-1,4]),a.OoG(e,[-1,4]));o=a.OoG(o,[r,o.shape[0]/r,4]);var s=a._CL(a.SME(t,[0,0,1],[-1,-1,-1])),i=a.SME(s,[0,0,0],[-1,-1,1]);return i=a.OoG(i,[r,i.shape[1]]),{boxes:a.iqB(o),scores:a.iqB(i)}}))}(o.boxPredictions,o.classPredictions,t.output_layer)}))},t.prototype.forward=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=this.forwardInput,[4,pe(e)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))},t.prototype.locateFaces=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,r,a,o,s,i,u,c,p,d,h,f,m,g,y,b,w,v,k,x;return l(this,(function(l){switch(l.label){case 0:return n=new wt(t),r=n.maxResults,a=n.minConfidence,[4,pe(e)];case 1:for(o=l.sent(),s=this.forwardInput(o),i=s.boxes,u=s.scores,c=i[0],p=u[0],d=1;d<i.length;d++)i[d].dispose(),u[d].dispose();return m=(f=Array).from,[4,p.data()];case 2:return h=m.apply(f,[l.sent()]),g=function(e,t,n,r,a){var o=e.shape[0],s=Math.min(n,o),i=t.map((function(e,t){return{score:e,boxIndex:t}})).filter((function(e){return e.score>a})).sort((function(e,t){return t.score-e.score})),u=[];return i.forEach((function(t){if(!(u.length>=s)){for(var n=t.score,r=u.length-1;r>=0;--r){var o=yt(e,t.boxIndex,u[r]);if(0!==o&&(t.score*=o<=.5?1:0,t.score<=a))break}n===t.score&&u.push(t.boxIndex)}})),u}(c,h,r,0,a),y=o.getReshapedInputDimensions(0),b=o.inputSize,w=b/y.width,v=b/y.height,k=c.arraySync(),x=g.map((function(e){var t=[Math.max(0,k[e][0]),Math.min(1,k[e][2])].map((function(e){return e*v})),n=t[0],r=t[1],a=[Math.max(0,k[e][1]),Math.min(1,k[e][3])].map((function(e){return e*w})),s=a[0],i=a[1];return new M(h[e],new O(s,n,i-s,r-n),{height:o.getInputHeight(0),width:o.getInputWidth(0)})})),c.dispose(),p.dispose(),[2,x]}}))}))},t.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},t.prototype.extractParamsFromWeigthMap=function(e){return function(e){var t=[],n=function(e,t){var n=Ae(e,t);function r(e,t,r){return{filters:n(e+"/Conv2d_"+t+"_pointwise/weights",4,r+"/filters"),batch_norm_offset:n(e+"/Conv2d_"+t+"_pointwise/convolution_bn_offset",1,r+"/batch_norm_offset")}}function a(e){var t="mobilenetv1/conv_"+e,a="MobilenetV1/Conv2d_"+e+"_depthwise",o=t+"/depthwise_conv",s=t+"/pointwise_conv";return{depthwise_conv:{filters:n(a+"/depthwise_weights",4,o+"/filters"),batch_norm_scale:n(a+"/BatchNorm/gamma",1,o+"/batch_norm_scale"),batch_norm_offset:n(a+"/BatchNorm/beta",1,o+"/batch_norm_offset"),batch_norm_mean:n(a+"/BatchNorm/moving_mean",1,o+"/batch_norm_mean"),batch_norm_variance:n(a+"/BatchNorm/moving_variance",1,o+"/batch_norm_variance")},pointwise_conv:r("MobilenetV1",e,s)}}function o(e,t){return{filters:n(e+"/weights",4,t+"/filters"),bias:n(e+"/biases",1,t+"/bias")}}function s(e){return{box_encoding_predictor:o("Prediction/BoxPredictor_"+e+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+e+"/box_encoding_predictor"),class_predictor:o("Prediction/BoxPredictor_"+e+"/ClassPredictor","prediction_layer/box_predictor_"+e+"/class_predictor")}}return{extractMobilenetV1Params:function(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:a(1),conv_2:a(2),conv_3:a(3),conv_4:a(4),conv_5:a(5),conv_6:a(6),conv_7:a(7),conv_8:a(8),conv_9:a(9),conv_10:a(10),conv_11:a(11),conv_12:a(12),conv_13:a(13)}},extractPredictionLayerParams:function(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:s(0),box_predictor_1:s(1),box_predictor_2:s(2),box_predictor_3:s(3),box_predictor_4:s(4),box_predictor_5:s(5)}}}}(e,t),r=n.extractMobilenetV1Params,a=n.extractPredictionLayerParams,o=e["Output/extra_dim"];if(t.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!f(o))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+o);var s={mobilenetv1:r(),prediction_layer:a(),output_layer:{extra_dim:o}};return Ie(e,t),{params:s,paramMappings:t}}(e)},t.prototype.extractParams=function(e){return function(e){var t=[],n=Fe(e),r=n.extractWeights,o=n.getRemainingWeights,s=function(e,t){function n(n,r,o,s,i){var u=a.IFH(e(n*r*o*o),[o,o,n,r]),c=a.SC3(e(r));return t.push({paramPath:s+"/filters"},{paramPath:s+"/"+(i?"batch_norm_offset":"bias")}),{filters:u,bias:c}}function r(e,t,r,a){var o=n(e,t,r,a,!0);return{filters:o.filters,batch_norm_offset:o.bias}}function o(n,o,s){var i=function(n,r){var o=a.IFH(e(9*n),[3,3,n,1]),s=a.SC3(e(n)),i=a.SC3(e(n)),u=a.SC3(e(n)),c=a.SC3(e(n));return t.push({paramPath:r+"/filters"},{paramPath:r+"/batch_norm_scale"},{paramPath:r+"/batch_norm_offset"},{paramPath:r+"/batch_norm_mean"},{paramPath:r+"/batch_norm_variance"}),{filters:o,batch_norm_scale:s,batch_norm_offset:i,batch_norm_mean:u,batch_norm_variance:c}}(n,s+"/depthwise_conv");return{depthwise_conv:i,pointwise_conv:r(n,o,1,s+"/pointwise_conv")}}return{extractMobilenetV1Params:function(){return{conv_0:r(3,32,3,"mobilenetv1/conv_0"),conv_1:o(32,64,"mobilenetv1/conv_1"),conv_2:o(64,128,"mobilenetv1/conv_2"),conv_3:o(128,128,"mobilenetv1/conv_3"),conv_4:o(128,256,"mobilenetv1/conv_4"),conv_5:o(256,256,"mobilenetv1/conv_5"),conv_6:o(256,512,"mobilenetv1/conv_6"),conv_7:o(512,512,"mobilenetv1/conv_7"),conv_8:o(512,512,"mobilenetv1/conv_8"),conv_9:o(512,512,"mobilenetv1/conv_9"),conv_10:o(512,512,"mobilenetv1/conv_10"),conv_11:o(512,512,"mobilenetv1/conv_11"),conv_12:o(512,1024,"mobilenetv1/conv_12"),conv_13:o(1024,1024,"mobilenetv1/conv_13")}},extractPredictionLayerParams:function(){return{conv_0:r(1024,256,1,"prediction_layer/conv_0"),conv_1:r(256,512,3,"prediction_layer/conv_1"),conv_2:r(512,128,1,"prediction_layer/conv_2"),conv_3:r(128,256,3,"prediction_layer/conv_3"),conv_4:r(256,128,1,"prediction_layer/conv_4"),conv_5:r(128,256,3,"prediction_layer/conv_5"),conv_6:r(256,64,1,"prediction_layer/conv_6"),conv_7:r(64,128,3,"prediction_layer/conv_7"),box_predictor_0:{box_encoding_predictor:n(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),class_predictor:n(512,9,1,"prediction_layer/box_predictor_0/class_predictor")},box_predictor_1:{box_encoding_predictor:n(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),class_predictor:n(1024,18,1,"prediction_layer/box_predictor_1/class_predictor")},box_predictor_2:{box_encoding_predictor:n(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),class_predictor:n(512,18,1,"prediction_layer/box_predictor_2/class_predictor")},box_predictor_3:{box_encoding_predictor:n(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),class_predictor:n(256,18,1,"prediction_layer/box_predictor_3/class_predictor")},box_predictor_4:{box_encoding_predictor:n(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),class_predictor:n(256,18,1,"prediction_layer/box_predictor_4/class_predictor")},box_predictor_5:{box_encoding_predictor:n(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),class_predictor:n(128,18,1,"prediction_layer/box_predictor_5/class_predictor")}}}}}(r,t),i=s.extractMobilenetV1Params,u=s.extractPredictionLayerParams,c=i(),l=u(),p={extra_dim:a.Av9(r(20472),[1,5118,4])};if(t.push({paramPath:"output_layer/extra_dim"}),0!==o().length)throw new Error("weights remaing after extract: "+o().length);return{params:{mobilenetv1:c,prediction_layer:l,output_layer:p},paramMappings:t}}(e)},t}(we);!function(e){i((function(){return null!==e&&e.apply(this,arguments)||this}),e)}(vt);var kt,xt=[new _(.738768,.874946),new _(2.42204,2.65704),new _(4.30971,7.04493),new _(10.246,4.59428),new _(12.6868,11.8741)],_t=[new _(1.603231,2.094468),new _(6.041143,7.080126
2),new _(2.882459,3.518061),new _(4.266906,5.178857),new _(9.041765,10.66308)],It=[117.001,114.697,97.404],St=function(e){return"number"==typeof e};function Nt(e){return a.G6I((function(){var t=a.E7T(e,a.SgB(.10000000149011612));return a.WQq(a.wDQ(a.AT$(e,t)),t)}))}function Mt(e,t){return a.G6I((function(){var n=a.eui(e,[[0,0],[1,1],[1,1],[0,0]]);return n=a.QlL(n,t.conv.filters,[1,1],"valid"),n=a.AT$(n,t.bn.sub),n=a.E7T(n,t.bn.truediv),Nt(n=a.WQq(n,t.conv.bias))}))}function Tt(e,t){return a.G6I((function(){var n=a.eui(e,[[0,0],[1,1],[1,1],[0,0]]);return n=a.Kd4(n,t.depthwise_filter,t.pointwise_filter,[1,1],"valid"),Nt(n=a.WQq(n,t.bias))}))}!function(e){e[e.XS=224]="XS",e[e.SM=320]="SM",e[e.MD=416]="MD",e[e.LG=608]="LG"}(kt||(kt={}));var Et=function(){function e(e){var t=void 0===e?{}:e,n=t.inputSize,r=t.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=n||416,this._scoreThreshold=r||.5,"number"!=typeof this._inputSize||this._inputSize%32!=0)throw new Error(this._name+" - expected inputSize to be a number divisible by 32");if("number"!=typeof this._scoreThreshold||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(this._name+" - expected scoreThreshold to be a number between 0 and 1")}return Object.defineProperty(e.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),e}(),At=function(e){function t(t){var n=e.call(this,"TinyYolov2")||this;return function(e){if(!e)throw new Error("invalid config: "+e);if("boolean"!=typeof e.withSeparableConvs)throw new Error("config.withSeparableConvs has to be a boolean, have: "+e.withSeparableConvs);if(!St(e.iouThreshold)||e.iouThreshold<0||e.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+e.iouThreshold);if(!Array.isArray(e.classes)||!e.classes.length||!e.classes.every((function(e){return"string"==typeof e})))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(e.classes));if(!Array.isArray(e.anchors)||!e.anchors.length||!e.anchors.map((function(e){return e||{}})).every((function(e){return St(e.x)&&St(e.y)})))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(e.anchors));if(e.meanRgb&&(!Array.isArray(e.meanRgb)||3!==e.meanRgb.length||!e.meanRgb.every(St)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(e.meanRgb))}(t),n._config=t,n}return i(t,e),Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),t.prototype.runTinyYolov2=function(e,t){var n=Mt(e,t.conv0);return n=Mt(n=a._SL(n,[2,2],[2,2],"same"),t.conv1),n=Mt(n=a._SL(n,[2,2],[2,2],"same"),t.conv2),n=Mt(n=a._SL(n,[2,2],[2,2],"same"),t.conv3),n=Mt(n=a._SL(n,[2,2],[2,2],"same"),t.conv4),n=Mt(n=a._SL(n,[2,2],[2,2],"same"),t.conv5),n=Mt(n=a._SL(n,[2,2],[1,1],"same"),t.conv6),_e(n=Mt(n,t.conv7),t.conv8,"valid",!1)},t.prototype.runMobilenet=function(e,t){var n=this.config.isFirstLayerConv2d?Nt(_e(e,t.conv0,"valid",!1)):Tt(e,t.conv0);return n=Tt(n=a._SL(n,[2,2],[2,2],"same"),t.conv1),n=Tt(n=a._SL(n,[2,2],[2,2],"same"),t.conv2),n=Tt(n=a._SL(n,[2,2],[2,2],"same"),t.conv3),n=Tt(n=a._SL(n,[2,2],[2,2],"same"),t.conv4),n=Tt(n=a._SL(n,[2,2],[2,2],"same"),t.conv5),n=a._SL(n,[2,2],[1,1],"same"),n=t.conv6?Tt(n,t.conv6):n,_e(n=t.conv7?Tt(n,t.conv7):n,t.conv8,"valid",!1)},t.prototype.forwardInput=function(e,t){var n=this,r=this.params;if(!r)throw new Error("TinyYolov2 - load model before inference");return a.G6I((function(){var o=e.toBatchTensor(t,!1).toFloat();return o=(o=n.config.meanRgb?A(o,n.config.meanRgb):o).div(a.SgB(256)),n.config.withSeparableConvs?n.runMobilenet(o,r):n.runTinyYolov2(o,r)}))},t.prototype.forward=function(e,t){return c(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,pe(e)];case 1:return[4,n.apply(this,[r.sent(),t])];case 2:return[2,r.sent()]}}))}))},t.prototype.detect=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,r,o,s,i,u,c,p,d,h,f,m,g=this;return l(this,(function(l){switch(l.label){case 0:return n=new Et(t),r=n.inputSize,o=n.scoreThreshold,[4,pe(e)];case 1:return s=l.sent(),[4,this.forwardInput(s,r)];case 2:return i=l.sent(),u=a.G6I((function(){return a.iqB(i)[0].expandDims()})),c={width:s.getInputWidth(0),height:s.getInputHeight(0)},[4,this.extractBoxes(u,s.getReshapedInputDimensions(0),o)];case 3:return p=l.sent(),i.dispose(),u.dispose(),d=p.map((function(e){return e.box})),h=p.map((function(e){return e.score})),f=p.map((function(e){return e.classScore})),m=p.map((function(e){return g.config.classes[e.label]})),[2,E(d.map((function(e){return e.rescale(r)})),h,this.config.iouThreshold,!0).map((function(e){return new N(h[e],f[e],m[e],d[e],c)}))]}}))}))},t.prototype.getDefaultModelName=function(){return""},t.prototype.extractParamsFromWeigthMap=function(e){return function(e,t){var n,r=[],a=function(e,t){var n=Ae(e,t);function r(e){return{filters:n(e+"/filters",4),bias:n(e+"/bias",1)}}return{extractConvParams:r,extractConvWithBatchNormParams:function(e){var t=r(e+"/conv"),a=function(e){return{sub:n(e+"/sub",1),truediv:n(e+"/truediv",1)}}(e+"/bn");return{conv:t,bn:a}},extractSeparableConvParams:Ee(n)}}(e,r),o=a.extractConvParams,s=a.extractConvWithBatchNormParams,i=a.extractSeparableConvParams;if(t.withSeparableConvs){var u=t.filterSizes&&t.filterSizes.length||9;n={conv0:t.isFirstLayerConv2d?o("conv0"):i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),
2conv6:u>7?i("conv6"):void 0,conv7:u>8?i("conv7"):void 0,conv8:o("conv8")}}else n={conv0:s("conv0"),conv1:s("conv1"),conv2:s("conv2"),conv3:s("conv3"),conv4:s("conv4"),conv5:s("conv5"),conv6:s("conv6"),conv7:s("conv7"),conv8:o("conv8")};return Ie(e,r),{params:n,paramMappings:r}}(e,this.config)},t.prototype.extractParams=function(e){var n=this.config.filterSizes||t.DEFAULT_FILTER_SIZES,r=n?n.length:void 0;if(7!==r&&8!==r&&9!==r)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+r+" filterSizes in config");return function(e,t,n,r){var o,s=Fe(e),i=s.extractWeights,u=s.getRemainingWeights,c=[],l=function(e,t){var n=Se(e,t),r=Te(e,t);return{extractConvParams:n,extractConvWithBatchNormParams:function(r,o,s){var i=n(r,o,3,s+"/conv"),u=function(n,r){var o=a.SC3(e(n)),s=a.SC3(e(n));return t.push({paramPath:r+"/sub"},{paramPath:r+"/truediv"}),{sub:o,truediv:s}}(o,s+"/bn");return{conv:i,bn:u}},extractSeparableConvParams:r}}(i,c),p=l.extractConvParams,d=l.extractConvWithBatchNormParams,h=l.extractSeparableConvParams;if(t.withSeparableConvs){var f=r[0],m=r[1],g=r[2],y=r[3],b=r[4],w=r[5],v=r[6],k=r[7],x=r[8];o={conv0:t.isFirstLayerConv2d?p(f,m,3,"conv0"):h(f,m,"conv0"),conv1:h(m,g,"conv1"),conv2:h(g,y,"conv2"),conv3:h(y,b,"conv3"),conv4:h(b,w,"conv4"),conv5:h(w,v,"conv5"),conv6:k?h(v,k,"conv6"):void 0,conv7:x?h(k,x,"conv7"):void 0,conv8:p(x||k||v,5*n,1,"conv8")}}else f=r[0],m=r[1],g=r[2],y=r[3],b=r[4],w=r[5],v=r[6],k=r[7],x=r[8],o={conv0:d(f,m,"conv0"),conv1:d(m,g,"conv1"),conv2:d(g,y,"conv2"),conv3:d(y,b,"conv3"),conv4:d(b,w,"conv4"),conv5:d(w,v,"conv5"),conv6:d(v,k,"conv6"),conv7:d(k,x,"conv7"),conv8:p(x,5*n,1,"conv8")};if(0!==u().length)throw new Error("weights remaing after extract: "+u().length);return{params:o,paramMappings:c}}(e,this.config,this.boxEncodingSize,n)},t.prototype.extractBoxes=function(e,t,n){return c(this,void 0,void 0,(function(){var r,o,s,i,c,p,d,h,f,m,g,y,b,w,v,k,x,_,I,N,M,T,E,A,D,O,C,P,R,$=this;return l(this,(function(l){switch(l.label){case 0:return r=t.width,o=t.height,s=Math.max(r,o),i=s/r,c=s/o,p=e.shape[1],d=this.config.anchors.length,h=a.G6I((function(){var t=e.reshape([p,p,d,$.boxEncodingSize]);return[t.slice([0,0,0,0],[p,p,d,4]),t.slice([0,0,0,4],[p,p,d,1]),$.withClassScores?a.UhY(t.slice([0,0,0,5],[p,p,d,$.config.classes.length]),3):a.SgB(0)]})),f=h[0],m=h[1],g=h[2],y=[],[4,m.array()];case 1:return b=l.sent(),[4,f.array()];case 2:w=l.sent(),v=0,l.label=3;case 3:if(!(v<p))return[3,12];k=0,l.label=4;case 4:if(!(k<p))return[3,11];x=0,l.label=5;case 5:return x<d?(_=F(b[v][k][x][0]),!n||_>n?(I=(k+F(w[v][k][x][0]))/p*i,N=(v+F(w[v][k][x][1]))/p*c,M=Math.exp(w[v][k][x][2])*this.config.anchors[x].x/p*i,T=Math.exp(w[v][k][x][3])*this.config.anchors[x].y/p*c,E=I-M/2,A=N-T/2,D={row:v,col:k,anchor:x},this.withClassScores?[4,this.extractPredictedClass(g,D)]:[3,7]):[3,9]):[3,10];case 6:return R=l.sent(),[3,8];case 7:R={classScore:1,label:0},l.label=8;case 8:C=(O=R).classScore,P=O.label,y.push(u({box:new S(E,A,E+M,A+T),score:_,classScore:_*C,label:P},D)),l.label=9;case 9:return x++,[3,5];case 10:return k++,[3,4];case 11:return v++,[3,3];case 12:return f.dispose(),m.dispose(),g.dispose(),[2,y]}}))}))},t.prototype.extractPredictedClass=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,o;return l(this,(function(s){switch(s.label){case 0:return n=t.row,r=t.col,a=t.anchor,[4,e.array()];case 1:return o=s.sent(),[2,Array(this.config.classes.length).fill(0).map((function(e,t){return o[n][r][a][t]})).map((function(e,t){return{classScore:e,label:t}})).reduce((function(e,t){return e.classScore>t.classScore?e:t}))]}}))}))},t.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],t}(we),Ft=function(e){function t(t){void 0===t&&(t=!0);var n=Object.assign({},{withSeparableConvs:t,iouThreshold:.4,classes:["face"]},t?{anchors:_t,meanRgb:It}:{anchors:xt,withClassScores:!0});return e.call(this,n)||this}return i(t,e),Object.defineProperty(t.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,t){return c(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.detect(e,t)];case 1:return[2,n.sent().map((function(e){return new M(e.score,e.relativeBox,{width:e.imageWidth,height:e.imageHeight})}))]}}))}))},t.prototype.getDefaultModelName=function(){return this.withSeparableConvs?"tiny_yolov2_separable_conv_model":"tiny_yolov2_model"},t.prototype.extractParamsFromWeigthMap=function(t){return e.prototype.extractParamsFromWeigthMap.call(this,t)},t}(At),Dt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._name="TinyFaceDetectorOptions",t}return i(t,e),t}(Et),Ot=function(){function e(){}return e.prototype.then=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t=e,[4,this.run()];case 1:return[2,t.apply(void 0,[n.sent()])]}}))}))},e.prototype.run=function(){return c(this,void 0,void 0,(function(){return l(this,(function(e){throw new Error("ComposableTask - run is not implemented")}))}))},e}();function Ct(e,t){var n={descriptor:t};return Object.assign({},e,n)}function Pt(e,t,n,r,o){return void 0===o&&(o=function(e){return e.alignedRect}),c(this,void 0,void 0,(function(){var s,i,u,c,p;return l(this,(function(l){switch(l.label){case 0:return s=e.map((function(e){return Ve(e)?o(e):e.detection})),(u=r)?[3,5]:t instanceof a.w3A?[4,he(t,s)]:[3,2];case 1:return c=l.sent(),[3,4];case 2:return[4,de(t,s)];case 3:c=l.sent(),l.label=4;case 4:u=c,l.label=5;case 5:return[4,n(i=u)];
2case 6:return p=l.sent(),i.forEach((function(e){return e instanceof a.w3A&&e.dispose()})),[2,p]}}))}))}function Rt(e,t,n,r,a){return c(this,void 0,void 0,(function(){var o=this;return l(this,(function(s){return[2,Pt([e],t,(function(e){return c(o,void 0,void 0,(function(){return l(this,(function(t){return[2,n(e[0])]}))}))}),r,a)]}))}))}function $t(e,t){var n=t[0],r=t[1];return{height:Math.floor(n*e),width:Math.floor(r*e)}}var Lt=function(e){function t(t,n,r,a){return e.call(this,{left:t,top:n,right:r,bottom:a},!0)||this}return i(t,e),t}(I);function Wt(e){return a.G6I((function(){return a.E7T(a.AT$(e,a.SgB(127.5)),a.SgB(.0078125))}))}function zt(e,t){return a.G6I((function(){return a.WQq(a.wDQ(e),a.E7T(t,a.KUd(a.wDQ(a.KUd(e)))))}))}function Bt(e,t,n){return void 0===n&&(n=!1),a.G6I((function(){var r=_e(e,t.conv1,"valid");return r=zt(r,t.prelu1_alpha),r=zt(r=_e(r=a._SL(r,n?[2,2]:[3,3],[2,2],"same"),t.conv2,"valid"),t.prelu2_alpha),zt(r=_e(r=n?r:a._SL(r,[3,3],[2,2],"valid"),t.conv3,"valid"),t.prelu3_alpha)}))}function Ut(e,t,n,r,o){o.stage1=[];var s=t.map((function(t){return a.G6I((function(){var n={scale:t},o=function(e,t){return a.G6I((function(){var n=$t(t,e.shape.slice(1)),r=n.height,o=n.width,s=Wt(a.c$0.resizeBilinear(e,[r,o]));return a.oLj(s,[0,2,1,3])}))}(e,t),s=Date.now(),i=function(e,t){return a.G6I((function(){var n=Bt(e,t,!0),r=_e(n,t.conv4_1,"valid"),o=a.aW5(a.kvL(r,3),3);return{prob:a.UhY(a.AT$(r,o),3),regions:_e(n,t.conv4_2,"valid")}}))}(o,r),u=i.prob,c=i.regions;return n.pnet=Date.now()-s,{scoresTensor:a.iqB(a.iqB(u,3)[1])[0],regionsTensor:a.iqB(c)[0],scale:t,statsForScale:n}}))})),i=s.map((function(e){var t=e.scoresTensor,r=e.regionsTensor,a=e.scale,s=e.statsForScale,i=function(e,t,n,r){for(var a=[],o=e.arraySync(),s=0;s<e.shape[0];s++)for(var i=0;i<e.shape[1];i++)o[s][i]>=r&&a.push(new _(i,s));return a.map((function(e){var r=new S(Math.round((2*e.y+1)/n),Math.round((2*e.x+1)/n),Math.round((2*e.y+12)/n),Math.round((2*e.x+12)/n)),a=o[e.y][e.x],s=t.arraySync();return{cell:r,score:a,region:new Lt(s[e.y][e.x][0],s[e.y][e.x][1],s[e.y][e.x][2],s[e.y][e.x][3])}}))}(t,r,a,n);if(t.dispose(),r.dispose(),!i.length)return o.stage1.push(s),[];var u=Date.now(),c=E(i.map((function(e){return e.cell})),i.map((function(e){return e.score})),.5);return s.nms=Date.now()-u,s.numBoxes=c.length,o.stage1.push(s),c.map((function(e){return i[e]}))})),u=i.reduce((function(e,t){return e.concat(t)}),[]),c=[],l=[];if(u.length>0){var p=Date.now(),d=E(u.map((function(e){return e.cell})),u.map((function(e){return e.score})),.7);o.stage1_nms=Date.now()-p,l=d.map((function(e){return u[e].score})),c=d.map((function(e){return u[e]})).map((function(e){var t=e.cell,n=e.region;return new S(t.left+n.left*t.width,t.top+n.top*t.height,t.right+n.right*t.width,t.bottom+n.bottom*t.height).toSquare().round()}))}return{boxes:c,scores:l}}function Ht(e,t,n){var r=n.width,o=n.height;return c(this,void 0,void 0,(function(){var n,s,i,u=this;return l(this,(function(p){switch(p.label){case 0:return n=Z(e),[4,Promise.all(t.map((function(t){return c(u,void 0,void 0,(function(){var r,a,o,s,i,u,c,p;return l(this,(function(l){return r=t.padAtBorders(e.height,e.width),a=r.y,o=r.ey,s=r.x,i=r.ex,u=s-1,c=a-1,p=n.getImageData(u,c,i-u,o-c),[2,Y.isNodejs()?ie(p):createImageBitmap(p)]}))}))})))];case 1:return s=p.sent(),i=[],s.forEach((function(e){var t=Z(se({width:r,height:o}));t.drawImage(e,0,0,r,o);for(var n=t.getImageData(0,0,r,o).data,a=[],s=0;s<n.length;s+=4)a.push(n[s+2]),a.push(n[s+1]),a.push(n[s]);i.push(a)})),[2,i.map((function(e){return a.G6I((function(){return Wt(a.oLj(a.IFH(e,[1,r,o,3]),[0,2,1,3]).toFloat())}))}))]}}))}))}function Vt(e,t,n,r,o){return c(this,void 0,void 0,(function(){var s,i,u,c,p,d,h,f,m,g,y,b,w,v;return l(this,(function(l){switch(l.label){case 0:return s=Date.now(),[4,Ht(e,t,{width:24,height:24})];case 1:return i=l.sent(),o.stage2_extractImagePatches=Date.now()-s,s=Date.now(),u=i.map((function(e){var t=function(e,t){return a.G6I((function(){var n=Bt(e,t),r=zt(Re(a.OoG(n,[n.shape[0],t.fc1.weights.shape[0]]),t.fc1),t.prelu4_alpha),o=Re(r,t.fc2_1),s=a.aW5(a.kvL(o,1),1),i=a.UhY(a.AT$(o,s),1),u=Re(r,t.fc2_2);return{scores:a.iqB(i,1)[1],regions:u}}))}(e,r);return e.dispose(),t})),o.stage2_rnet=Date.now()-s,c=u.length>1?a.WUr(u.map((function(e){return e.scores}))):u[0].scores,h=(d=Array).from,[4,c.data()];case 2:return p=h.apply(d,[l.sent()]),c.dispose(),f=p.map((function(e,t){return{score:e,idx:t}})).filter((function(e){return e.score>n})).map((function(e){return e.idx})),m=f.map((function(e){return t[e]})),g=f.map((function(e){return p[e]})),y=[],b=[],m.length>0&&(s=Date.now(),w=E(m,g,.7),o.stage2_nms=Date.now()-s,v=w.map((function(e){var t=u[f[e]].regions.arraySync();return new Lt(t[0][0],t[0][1],t[0][2],t[0][3])})),b=w.map((function(e){return g[e]})),y=w.map((function(e,t){return m[e].calibrate(v[t])}))),u.forEach((function(e){e.regions.dispose(),e.scores.dispose()})),[2,{boxes:y,scores:b}]}}))}))}function Gt(e,t,n,r,o){return c(this,void 0,void 0,(function(){var s,i,u,c,p,d,h,f,m,g,y,b,w,v,k;return l(this,(function(l){switch(l.label){case 0:return s=Date.now(),[4,Ht(e,t,{width:48,height:48})];case 1:return i=l.sent(),o.stage3_extractImagePatches=Date.now()-s,s=Date.now(),u=i.map((function(e){var t=function(e,t){return a.G6I((function(){var n=Bt(e,t);n=zt(n=_e(n=a._SL(n,[2,2],[2,2],"same"),t.conv4,"valid"),t.prelu4_alpha);var r=zt(Re(a.OoG(n,[n.shape[0],t.fc1.weights.shape[0]]),t.fc1),t.prelu5_alpha),o=Re(r,t.fc2_1),s=a.aW5(a.kvL(o,1),1),i=a.UhY(a.AT$(o,s),1),u=Re(r,t.fc2_2),c=Re(r,t.fc2_3);return{scores:a.iqB(i,1)[1],regions:u,points:c}}))}(e,r);return e.dispose(),t})),o.stage3_onet=Date.now()-s,c=u.length>1?a.WUr(u.map((function(e){return e.scores}))):u[0].scores,h=(d=Array).from,[4,c.data()];case 2:return p=h.apply(d,[l.sent()]),c.dispose(),f=p.map((function(e,t){return{score:e,idx:t}})).filter((function(e){return e.score>n})).map((function(e){return e.idx})),m=f.map((function(e){var t=u[e].regions.arraySync();return new Lt(t[0][0],t[0][1],t[0][2],t[0][3])})),g=f.map((function(e,n){return t[e].calibrate(m[n])})),y=f.map((function(e){return p[e]})),b=[],w=[],v=[],g.length>0&&(s=Date.now(),k=E(g,y,.7,!1),o.stage3_nms=Date.now()-s,b=k.map((function(e){return g[e]})),w=k.map((function(e){return y[e]})),v=k.map((function(e,t){return Array(5).fill(0).map((function(n,r){var a=u[e].points.arraySync();return new _(a[0][r]*(b[t].width+1)+b[t].left,a[0][r+5]*(b[t].height+1)+b[t].top)}))}))),u.forEach((function(e){e.regions.dispose(),e.scores.dispose(),e.points.dispose()})),[2,{boxes:b,scores:w,points:v}]}}))}))}var qt=function(e){function t(){return e.call(this,"Mtcnn")||this}return i(t,e),t.prototype.load=function(t){return c(this,void 0,void 0,(function(){return l(this,(function(n){return console.warn("mtcnn is deprecated and will be removed soon"),[2,e.prototype.load.call(this,t)]}))}))},t.prototype.loadFromDisk=function(t){return c(this,void 0,void 0,(function(){return l(this,(function(n){return console.warn("mtcnn is deprecated and will be removed soon"),[2,e.prototype.loadFromDisk.call(this,t)]}))}))},t.prototype.forwardInput=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,r,o,s,i,u,c,p,d,h,f,m,g,y,b,w,v,k,x,I,S;return l(this,(function(l){switch(l.label){case 0:if(!(n=this.params))throw new Error("Mtcnn - load model before inference");if(!(r=e.canvases[0]))throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return o={},s=Date.now(),i=a.G6I((function(){return e=a.aW5(a.aW8.fromPixels(r)).toFloat
2(),a.G6I((function(){return a.Qfh(a.iqB(e,3).reverse(),3)}));var e})),u=function(e){return i.dispose(),o.total=Date.now()-s,e},c=i.shape.slice(1),p=c[0],d=c[1],h=new mt(t),f=h.minFaceSize,m=h.scaleFactor,g=h.maxNumScales,y=h.scoreThresholds,b=h.scaleSteps,w=(b||function(e,t,n){for(var r=n[0],a=n[1],o=12/e,s=[],i=Math.min(r,a)*o,u=0;i>=12;)s.push(o*Math.pow(t,u)),i*=t,u+=1;return s}(f,m,[p,d])).filter((function(e){var t=$t(e,[p,d]);return Math.min(t.width,t.height)>12})).slice(0,g),o.scales=w,o.pyramid=w.map((function(e){return $t(e,[p,d])})),v=Date.now(),[4,Ut(i,w,y[0],n.pnet,o)];case 1:return k=l.sent(),o.total_stage1=Date.now()-v,k.boxes.length?(o.stage2_numInputBoxes=k.boxes.length,v=Date.now(),[4,Vt(r,k.boxes,y[1],n.rnet,o)]):[2,u({results:[],stats:o})];case 2:return x=l.sent(),o.total_stage2=Date.now()-v,x.boxes.length?(o.stage3_numInputBoxes=x.boxes.length,v=Date.now(),[4,Gt(r,x.boxes,y[2],n.onet,o)]):[2,u({results:[],stats:o})];case 3:return I=l.sent(),o.total_stage3=Date.now()-v,S=I.boxes.map((function(e,t){return Ge(B({},new M(I.scores[t],new O(e.left/d,e.top/p,e.width/d,e.height/p),{height:p,width:d})),new P(I.points[t].map((function(t){return t.sub(new _(e.left,e.top)).div(new _(e.width,e.height))})),{width:e.width,height:e.height}))})),[2,u({results:S,stats:o})]}}))}))},t.prototype.forward=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,pe(e)];case 1:return[4,n.apply(this,[r.sent(),t])];case 2:return[2,r.sent().results]}}))}))},t.prototype.forwardWithStats=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return n=this.forwardInput,[4,pe(e)];case 1:return[2,n.apply(this,[r.sent(),t])]}}))}))},t.prototype.getDefaultModelName=function(){return"mtcnn_model"},t.prototype.extractParamsFromWeigthMap=function(e){return function(e){var t=[],n=function(e,t){var n=Ae(e,t);function r(e){return{filters:n(e+"/weights",4,e+"/filters"),bias:n(e+"/bias",1)}}function a(e){return{weights:n(e+"/weights",2),bias:n(e+"/bias",1)}}function o(e){return n(e,1)}function s(e){return{conv1:r(e+"/conv1"),prelu1_alpha:o(e+"/prelu1_alpha"),conv2:r(e+"/conv2"),prelu2_alpha:o(e+"/prelu2_alpha"),conv3:r(e+"/conv3"),prelu3_alpha:o(e+"/prelu3_alpha")}}return{extractPNetParams:function(){var e=s("pnet"),t=r("pnet/conv4_1"),n=r("pnet/conv4_2");return u(u({},e),{conv4_1:t,conv4_2:n})},extractRNetParams:function(){var e=s("rnet"),t=a("rnet/fc1"),n=o("rnet/prelu4_alpha"),r=a("rnet/fc2_1"),i=a("rnet/fc2_2");return u(u({},e),{fc1:t,prelu4_alpha:n,fc2_1:r,fc2_2:i})},extractONetParams:function(){var e=s("onet"),t=r("onet/conv4"),n=o("onet/prelu4_alpha"),i=a("onet/fc1"),c=o("onet/prelu5_alpha"),l=a("onet/fc2_1"),p=a("onet/fc2_2"),d=a("onet/fc2_3");return u(u({},e),{conv4:t,prelu4_alpha:n,fc1:i,prelu5_alpha:c,fc2_1:l,fc2_2:p,fc2_3:d})}}}(e,t),r=n.extractPNetParams,a=n.extractRNetParams,o=n.extractONetParams,s=r(),i=a(),c=o();return Ie(e,t),{params:{pnet:s,rnet:i,onet:c},paramMappings:t}}(e)},t.prototype.extractParams=function(e){return function(e){var t=Fe(e),n=t.extractWeights,r=t.getRemainingWeights,o=[],s=function(e,t){var n=Se(e,t),r=Ne(e,t);function o(n,r){var o=a.SC3(e(n));return t.push({paramPath:r}),o}function s(e,t,r){return void 0===r&&(r=!1),{conv1:n(e[0],e[1],3,t+"/conv1"),prelu1_alpha:o(e[1],t+"/prelu1_alpha"),conv2:n(e[1],e[2],3,t+"/conv2"),prelu2_alpha:o(e[2],t+"/prelu2_alpha"),conv3:n(e[2],e[3],r?2:3,t+"/conv3"),prelu3_alpha:o(e[3],t+"/prelu3_alpha")}}return{extractPNetParams:function(){var e=s([3,10,16,32],"pnet"),t=n(32,2,1,"pnet/conv4_1"),r=n(32,4,1,"pnet/conv4_2");return u(u({},e),{conv4_1:t,conv4_2:r})},extractRNetParams:function(){var e=s([3,28,48,64],"rnet",!0),t=r(576,128,"rnet/fc1"),n=o(128,"rnet/prelu4_alpha"),a=r(128,2,"rnet/fc2_1"),i=r(128,4,"rnet/fc2_2");return u(u({},e),{fc1:t,prelu4_alpha:n,fc2_1:a,fc2_2:i})},extractONetParams:function(){var e=s([3,32,64,64],"onet"),t=n(64,128,2,"onet/conv4"),a=o(128,"onet/prelu4_alpha"),i=r(1152,256,"onet/fc1"),c=o(256,"onet/prelu5_alpha"),l=r(256,2,"onet/fc2_1"),p=r(256,4,"onet/fc2_2"),d=r(256,10,"onet/fc2_3");return u(u({},e),{conv4:t,prelu4_alpha:a,fc1:i,prelu5_alpha:c,fc2_1:l,fc2_2:p,fc2_3:d})}}}(n,o),i=s.extractPNetParams,c=s.extractRNetParams,l=s.extractONetParams,p=i(),d=c(),h=l();if(0!==r().length)throw new Error("weights remaing after extract: "+r().length);return{params:{pnet:p,rnet:d,onet:h},paramMappings:o}}(e)},t}
2(we),jt=[new _(1.603231,2.094468),new _(6.041143,7.080126),new _(2.882459,3.518061),new _(4.266906,5.178857),new _(9.041765,10.66308)],Kt=[117.001,114.697,97.404],Qt=function(e){function t(){var t={withSeparableConvs:!0,iouThreshold:.4,classes:["face"],anchors:jt,meanRgb:Kt,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return e.call(this,t)||this}return i(t,e),Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,t){return c(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.detect(e,t)];case 1:return[2,n.sent().map((function(e){return new M(e.score,e.relativeBox,{width:e.imageWidth,height:e.imageHeight})}))]}}))}))},t.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},t.prototype.extractParamsFromWeigthMap=function(t){return e.prototype.extractParamsFromWeigthMap.call(this,t)},t}(At),Yt={ssdMobilenetv1:new vt,tinyFaceDetector:new Qt,tinyYolov2:new Ft,mtcnn:new qt,faceLandmark68Net:new rt,faceLandmark68TinyNet:new ot,faceRecognitionNet:new ht,faceExpressionNet:new Be,ageGenderNet:new tt};function Jt(e,t){var n={age:t};return Object.assign({},e,n)}var Zt=function(e){function t(t,n,r){var a=e.call(this)||this;return a.parentTask=t,a.input=n,a.extractedFaces=r,a}return i(t,e),t}(Ot),Xt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t,n=this;return l(this,(function(r){switch(r.label){case 0:return[4,this.parentTask];case 1:return[4,Pt(e=r.sent(),this.input,(function(e){return c(n,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,Promise.all(e.map((function(e){return Yt.faceExpressionNet.predictExpressions(e)})))];case 1:return[2,t.sent()]}}))}))}),this.extractedFaces)];case 2:return t=r.sent(),[2,e.map((function(e,n){return Ue(e,t[n])}))]}}))}))},t.prototype.withAgeAndGender=function(){return new an(this,this.input)},t}(Zt),en=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t;return l(this,(function(n){switch(n.label){case 0:return[4,this.parentTask];case 1:return(e=n.sent())?[4,Rt(e,this.input,(function(e){return Yt.faceExpressionNet.predictExpressions(e)}),this.extractedFaces)]:[2];case 2:return t=n.sent(),[2,Ue(e,t)]}}))}))},t.prototype.withAgeAndGender=function(){return new on(this,this.input)},t}(Zt),tn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.withAgeAndGender=function(){return new sn(this,this.input)},t.prototype.withFaceDescriptors=function(){return new ln(this,this.input)},t}(Xt),nn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.withAgeAndGender=function(){return new un(this,this.input)},t.prototype.withFaceDescriptor=function(){return new pn(this,this.input)},t}(en),rn=function(e){function t(t,n,r){var a=e.call(this)||this;return a.parentTask=t,a.input=n,a.extractedFaces=r,a}return i(t,e),t}(Ot),an=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t,n=this;return l(this,(function(r){switch(r.label){case 0:return[4,this.parentTask];case 1:return[4,Pt(e=r.sent(),this.input,(function(e){return c(n,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,Promise.all(e.map((function(e){return Yt.ageGenderNet.predictAgeAndGender(e)})))];case 1:return[2,t.sent()]}}))}))}),this.extractedFaces)];case 2:return t=r.sent(),[2,e.map((function(e,n){var r=t[n],a=r.age;return Jt(ft(e,r.gender,r.genderProbability),a)}))]}}))}))},t.prototype.withFaceExpressions=function(){return new Xt(this,this.input)},t}(rn),on=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a;return l(this,(function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return(e=o.sent())?[4,Rt(e,this.input,(function(e){return Yt.ageGenderNet.predictAgeAndGender(e)}),this.extractedFaces)]:[2];case 2:return t=o.sent(),n=t.age,r=t.gender,a=t.genderProbability,[2,Jt(ft(e,r,a),n)]}}))}))},t.prototype.withFaceExpressions=function(){return new en(this,this.input)},t}(rn),sn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.withFaceExpressions=function(){return new tn(this,this.input)},t.prototype.withFaceDescriptors=function(){return new ln(this,this.input)},t}(an),un=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.withFaceExpressions=function(){return new nn(this,this.input)},t.prototype.withFaceDescriptor=function(){return new pn(this,this.input)},t}(on),cn=function(e){function t(t,n){var r=e.call(this)||this;return r.parentTask=t,r.input=n,r}return i(t,e),t}(Ot),ln=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return[4,this.parentTask];case 1:return[4,Pt(e=t.sent(),this.input,(function(e){return Promise.all(e.map((function(e){return Yt.faceRecognitionNet.computeFaceDescriptor(e)})))}),null,(function(e){return e.landmarks.align(null,{useDlibAlignment:!0})}
2))];case 2:return[2,t.sent().map((function(t,n){return Ct(e[n],t)}))]}}))}))},t.prototype.withFaceExpressions=function(){return new tn(this,this.input)},t.prototype.withAgeAndGender=function(){return new sn(this,this.input)},t}(cn),pn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t;return l(this,(function(n){switch(n.label){case 0:return[4,this.parentTask];case 1:return(e=n.sent())?[4,Rt(e,this.input,(function(e){return Yt.faceRecognitionNet.computeFaceDescriptor(e)}),null,(function(e){return e.landmarks.align(null,{useDlibAlignment:!0})}))]:[2];case 2:return t=n.sent(),[2,Ct(e,t)]}}))}))},t.prototype.withFaceExpressions=function(){return new nn(this,this.input)},t.prototype.withAgeAndGender=function(){return new un(this,this.input)},t}(cn),dn=function(e){function t(t,n,r){var a=e.call(this)||this;return a.parentTask=t,a.input=n,a.useTinyLandmarkNet=r,a}return i(t,e),Object.defineProperty(t.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?Yt.faceLandmark68TinyNet:Yt.faceLandmark68Net},enumerable:!0,configurable:!0}),t}(Ot),hn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,o,s=this;return l(this,(function(i){switch(i.label){case 0:return[4,this.parentTask];case 1:return e=i.sent(),t=e.map((function(e){return e.detection})),this.input instanceof a.w3A?[4,he(this.input,t)]:[3,3];case 2:return r=i.sent(),[3,5];case 3:return[4,de(this.input,t)];case 4:r=i.sent(),i.label=5;case 5:return n=r,[4,Promise.all(n.map((function(e){return s.landmarkNet.detectLandmarks(e)})))];case 6:return o=i.sent(),n.forEach((function(e){return e instanceof a.w3A&&e.dispose()})),[2,e.map((function(e,t){return Ge(e,o[t])}))]}}))}))},t.prototype.withFaceExpressions=function(){return new tn(this,this.input)},t.prototype.withAgeAndGender=function(){return new sn(this,this.input)},t.prototype.withFaceDescriptors=function(){return new ln(this,this.input)},t}(dn),fn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,o;return l(this,(function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return(e=s.sent())?(t=e.detection,this.input instanceof a.w3A?[4,he(this.input,[t])]:[3,3]):[2];case 2:return r=s.sent(),[3,5];case 3:return[4,de(this.input,[t])];case 4:r=s.sent(),s.label=5;case 5:return n=r,[4,this.landmarkNet.detectLandmarks(n[0])];case 6:return o=s.sent(),n.forEach((function(e){return e instanceof a.w3A&&e.dispose()})),[2,Ge(e,o)]}}))}))},t.prototype.withFaceExpressions=function(){return new nn(this,this.input)},t.prototype.withAgeAndGender=function(){return new un(this,this.input)},t.prototype.withFaceDescriptor=function(){return new pn(this,this.input)},t}(dn),mn=function(e){function t(t,n){void 0===n&&(n=new wt);var r=e.call(this)||this;return r.input=t,r.options=n,r}return i(t,e),t}(Ot),gn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t,n,r;return l(this,(function(a){switch(a.label){case 0:return t=(e=this).input,(n=e.options)instanceof mt?[4,Yt.mtcnn.forward(t,n)]:[3,2];case 1:return[2,a.sent().map((function(e){return e.detection}))];case 2:if(r=n instanceof Dt?function(e){return Yt.tinyFaceDetector.locateFaces(e,n)}:n instanceof wt?function(e){return Yt.ssdMobilenetv1.locateFaces(e,n)}:n instanceof Et?function(e){return Yt.tinyYolov2.locateFaces(e,n)}:null,!r)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,r(t)]}}))}))},t.prototype.runAndExtendWithFaceDetections=function(){var e=this;return new Promise((function(t){return c(e,void 0,void 0,(function(){var e;return l(this,(function(n){switch(n.label){case 0:return[4,this.run()];case 1:return e=n.sent(),[2,t(e.map((function(e){return B({},e)})))]}}))}))}))},t.prototype.withFaceLandmarks=function(e){return void 0===e&&(e=!1),new hn(this.runAndExtendWithFaceDetections(),this.input,e)},t.prototype.withFaceExpressions=function(){return new Xt(this.runAndExtendWithFaceDetections(),this.input)},t.prototype.withAgeAndGender=function(){return new an(this.runAndExtendWithFaceDetections(),this.input)},t}(mn);function yn(e,t){return void 0===t&&(t=new wt),new gn(e,t)}function bn(e,t){var n=new d(t.width,t.height),r=n.width,a=n.height;if(r<=0||a<=0)throw new Error("resizeResults - invalid dimensions: "+JSON.stringify({width:r,height:a}));if(Array.isArray(e))return e.map((function(e){return bn(e,{width:r,height:a})}));if(Ve(e)){var o=e.detection.forSize(r,a),s=e.unshiftedLandmarks.forSize(o.box.width,o.box.height);return Ge(B(e,o),s)}return z(e)?B(e,e.detection.forSize(r,a)):e instanceof C||e instanceof M?e.forSize(r,a):e}!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}i(t,e),t.prototype.run=function(){return c(this,void 0,void 0,(function(){var e,t;return l(this,(function(n){switch(n.label){case 0:return[4,new gn(this.input,this.options)];case 1:return e=n.sent(),t=e[0],e.forEach((function(e){e.score>t.score&&(t=e)})),[2,t]}}))}))},t.prototype.runAndExtendWithFaceDetection=function(){var e=this;return new Promise((function(t){return c(e,void 0,void 0,(function(){var e;return l(this,(function(n){switch(n.label){case 0:return[4,this.run()];case 1:return e=n.sent(),[2,t(e?B({},e):void 0)]}}))}))}))},t.prototype.withFaceLandmarks=function(e){return void 0===e&&(e=!1),new fn(this.runAndExtendWithFaceDetection(),this.input,e)},t.prototype.withFaceExpressions=function(){return new en(this.runAndExtendWithFaceDetection(),this.input)},t.prototype.withAgeAndGender=function(){return new on(this.runAndExtendWithFaceDetection(),this.input)}}(mn),function(){function e(e,t){void 0===t&&(t=.6),this._distanceThreshold=t;var n=Array.isArray(e)?e:[e];if(!n.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var r=1,a=function(){return"person "+r++};this._labeledDescriptors=n.map((function(e){if(e instanceof W)return e;if(e instanceof Float32Array)return new W(a(),[e]);if(e.descriptor&&e.descriptor instanceof Float32Array)return new W(a(),[e.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")}))}Object.defineProperty(e.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),e.prototype.computeMeanDistance=function(e,t){return t.map((function(t){return function(e,t){if(e.length!==t.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var n=Array.from(e),r=Array.from(t);return Math.sqrt(n.map((function(e,t){return e-r[t]})).reduce((function(e,t){return e+Math.pow(t,2)}),0))}(t,e)})).reduce((function(e,t){return e+t}),0)/(t.length||1)},e.prototype.matchDescriptor=function(e){var t=this;return this.labeledDescriptors.map((function(n){var r=n.descriptors,a=n.label;return new $(a,t.computeMeanDistance(e,r))})).reduce((function(e,t){return e.distance<t.distance?e:t}))},e.prototype.findBestMatch=function(e){var t=this.matchDescriptor(e);return t.distance<this.distanceThreshold?t:new $("unknown",t.distance)},e.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map((function(e){return e.toJSON()}))}},e.fromJSON=function(t){return new e(t.labeledDescriptors.map((function(e){return W.fromJSON(e)})),t.distanceThreshold)}}()},70137:function(e,t,n){"use strict";n.d(t,{M9:function(){return ct},q:function(){return wt}});var r={};n.r(r),n.d(r,{json:function(){return $}});var a={};n.r(a),n.d(a,{json:function(){return L}});var o={};n.r(o),n.d(o,{json:function(){return W}});var s={};n.r(s),n.d(s,{json:function(){return z}});var i={};n.r(i),n.d(i,{json:function(){return B}});var u={};n.r(u),n.d(u,{json:function(){return U}});var c={};n.r(c),n.d(c,{json:function(){return H}});var l={};n.r(l),n.d(l,{json:function(){return V}});var p={};n.r(p),n.d(p,{json:function(){return G}});var d={};n.r(d),n.d(d,{json:function(){return q}});var h={};n.r(h),n.d(h,{json:function(){return j}});var f={};n.r(f),n.d(f,{json:function(){return K}});var m={};n.r(m),n.d(m,{json:function(){return Q}});var g={};n.r(g),n.d(g,{json:function(){return Y}});var y={};n.r(y),n.d(y,{json:function(){return J}});var b={};n.r(b),n.d(b,{json:function(){return Z}});var w={};n.r(w),n.d(w,{json:function(){return X}});var v={};n.r(v),n.d(v,{json:function(){return ee}});var k={};n.r(k),n.d(k,{json:function(){return te}});var x={};n.r(x),n.d(x,{OP_SCOPE_SUFFIX:function(){return we.IpH},abs:function(){return we.a2b},acos:function(){return we.mEb},acosh:function(){return we.c5J},add:function(){return we.WQq},addN:function(){return we.OiD},all:function(){return we.Q7R},any:function(){return we.uWw},argMax:function(){return we.E9L},argMin:function(){return we.QT8},asin:function(){return we.qRo},asinh:function(){return we.AHs},atan:function(){return we.MQ0},atan2:function(){return we.WEK},atanh:function(){return we.IsS},avgPool:function(){return we.q2x},avgPool3d:function(){return we.k$b},basicLSTMCell:function(){return we.WKV},batchNorm:function(){return we.QtV},batchNorm2d:function(){return we.oLn},batchNorm3d:function(){return we.Ulu},batchNorm4d:function(){return we.KyW},batchToSpaceND:function(){return we.UtN},bincount:function(){return we.aej},bitwiseAnd:function(){return we.Q7g},booleanMaskAsync:function(){return we.mWy},broadcastArgs:function(){return we.MBr},broadcastTo:function(){return we.Cet},buffer:function(){return we.cz0},cast:function(){return we.WM5},ceil:function(){return we.KmW},clipByValue:function(){return we.Qjg},clone:function(){return we.ctR},complex:function(){return we.c$h},concat:function(){return we.WUr},concat1d:function(){return we.e8l},concat2d:function(){return we.Yrn},concat3d:function(){return we.w7n},concat4d:function(){return we.Y3R},conv1d:function(){return we.G_J},conv2d:function(){return we.QlL},conv2dTranspose:function(){return we.m_y},conv3d:function(){return we._oS},conv3dTranspose:function(){return we.sLq},cos:function(){return we.W8e},cosh:function(){return we.o7c},cosineWindow:function(){return we.Sy6},cumprod:function(){return we.cP9},cumsum:function(){return we.kt$},denseBincount:function(){return we.obE},depthToSpace:function(){return we.eM6},depthwiseConv2d:function(){return we.gLu},diag:function(){return we.KCo},dilation2d:function(){return we.s5H},div:function(){return we.MbH},divNoNan:function(){return we.aGi},dot:function(){return we.eAo},dropout:function(){return we.U7y},einsum:function(){return we.Mry},elu:function(){return we.w54},enclosingPowerOfTwo:function(){return we.mYz},ensureShape:function(){return we.vuS},equal:function(){return we.yyq},erf:function(){return we.Y12},euclideanNorm:function(){return we.qgr},exp:function(){return we.oNF},expandDims:function(){return we.aW5},expm1:function(){return we.K0Z},eye:function(){return we.iOb},fft:function(){return we.Ccp},fill:function(){return we.ymW},floor:function(){return we.wxi},floorDiv:function(){return we.Ks0},fused:function(){return we.Ckv},gather:function(){return we.cJu},gatherND:function(){return we.YGD},greater:function(){return we.aqr},greaterEqual:function(){return we.QHi},ifft:function(){return we.KGM},imag:function(){return we.gXe},image:function(){return we.c$0},inTopKAsync:function(){return we.Suf},irfft:function(){return we.uOu},isFinite:function(){return we.W0A},isInf:function(){return we.CoA},isNaN:function(){return we.WOs},leakyRelu:function(){return we.CEm},less:function(){return we.SwJ},lessEqual:function(){return we.Kcv},linalg:function(){return we.rhK},linspace:function(){return we.cv1},localResponseNormalization:function(){return we.sHn},log:function(){return we.YzJ},log1p:function(){return we.OwK},logSigmoid:function(){return we.Uv2},logSoftmax:function(){return we.SmB},logSumExp:function(){return we.a4N},logicalAnd:function(){return we.KYp},logicalNot:function(){return we.WyF},logicalOr:function(){return we.KDS},logicalXor:function(){return we.YV},losses:function(){return we.kXy},lowerBound:function(){return we.Ogf},matMul:function(){return we._o$},max:function(){return we.kvL},maxPool:function(){return we._SL},maxPool3d:function(){return we.s1D},maxPoolWithArgmax:function(){return we.SIj},maximum:function(){return we.Win},mean:function(){return we.moX},meshgrid:function(){return we.ArG},min:function(){return we.SYq},minimum:function(){return we.OCI},mirrorPad:function(){return we.c1V},mod:function(){return we.gXk},moments:function(){return we.wJ8}
2,movingAverage:function(){return we.EFC},mul:function(){return we.E7T},multiRNNCell:function(){return we.aCm},multinomial:function(){return we.MtA},neg:function(){return we.KUd},norm:function(){return we.Cyy},notEqual:function(){return we.UWg},oneHot:function(){return we.ktM},ones:function(){return we.eGt},onesLike:function(){return we.W4q},op:function(){return we.op},outerProduct:function(){return we._A_},pad:function(){return we.eui},pad1d:function(){return we.Kqt},pad2d:function(){return we.g1E},pad3d:function(){return we.aaf},pad4d:function(){return we.E50},pool:function(){return we.isx},pow:function(){return we.g39},prelu:function(){return we.SCD},print:function(){return we.S4e},prod:function(){return we.iOQ},raggedGather:function(){return we.InV},raggedRange:function(){return we.ZX5},raggedTensorToTensor:function(){return we.kPy},rand:function(){return we.ySJ},randomGamma:function(){return we.MH6},randomNormal:function(){return we.Ogc},randomStandardNormal:function(){return we.e6k},randomUniform:function(){return we.QNb},randomUniformInt:function(){return we.AXY},range:function(){return we.ikV},real:function(){return we.gvH},reciprocal:function(){return we.M7P},relu:function(){return we.wDQ},relu6:function(){return we.aqo},reshape:function(){return we.OoG},reverse:function(){return we.uGn},reverse1d:function(){return we.CWo},reverse2d:function(){return we.wrC},reverse3d:function(){return we.Eht},reverse4d:function(){return we.s$$},rfft:function(){return we.Ile},round:function(){return we.kLe},rsqrt:function(){return we.Qoo},scalar:function(){return we.SgB},scatterND:function(){return we._mR},searchSorted:function(){return we.c92},selu:function(){return we.kpW},separableConv2d:function(){return we.Kd4},setdiff1dAsync:function(){return we.cPK},sigmoid:function(){return we._CL},sign:function(){return we.kqB},signal:function(){return we.OCB},sin:function(){return we.g$V},sinh:function(){return we.MBb},slice:function(){return we.SME},slice1d:function(){return we.UfB},slice2d:function(){return we.Ehh},slice3d:function(){return we.msk},slice4d:function(){return we.WuO},softmax:function(){return we.UhY},softplus:function(){return we.uYt},spaceToBatchND:function(){return we.qYv},sparse:function(){return we.CQ_},sparseToDense:function(){return we.eIE},spectral:function(){return we.CGt},split:function(){return we.SGy},sqrt:function(){return we._Im},square:function(){return we.Qri},squaredDifference:function(){return we.uCq},squeeze:function(){return we.sLr},stack:function(){return we.Qfh},step:function(){return we.WYO},stridedSlice:function(){return we.c7v},string:function(){return we.QbE},sub:function(){return we.AT$},sum:function(){return we.ohi},tan:function(){return we.a6P},tanh:function(){return we.SyI},tensor:function(){return we.mwg},tensor1d:function(){return we.SC3},tensor2d:function(){return we.Enf},tensor3d:function(){return we.Av9},tensor4d:function(){return we.IFH},tensor5d:function(){return we.Qvy},tensor6d:function(){return we.olQ},tensorScatterUpdate:function(){return we.CgD},tile:function(){return we.CUy},topk:function(){return we.GER},transpose:function(){return we.oLj},truncatedNormal:function(){return we.KEu},unique:function(){return we.Swr},unsortedSegmentSum:function(){return we.szS},unstack:function(){return we.iqB},upperBound:function(){return we.MZf},variable:function(){return we.QRA},where:function(){return we.A9N},whereAsync:function(){return we.i0p},zeros:function(){return we.DjU},zerosLike:function(){return we.Exq}});var _,I,S=n(66280),N=n(42840);(0,N._K2)().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(e=>{e&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")})),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=2
vendor: 4,132 bytes, line 2
21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(_||(_={})),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={}))}(I||(I={}));const M={};function T(e){return M[e]}function E(e,t,n,r,a){const o=t.inputParams[e];if(o&&void 0!==o.inputIndexStart){const e=o.inputIndexStart,s=0===o.inputIndexEnd?void 0:void 0===o.inputIndexEnd?e+1:o.inputIndexEnd,i=e<0?t.inputNames.length+e:e;if("tensor"===o.type)return A(t.inputNames[i],n,r,a);if("tensors"===o.type){const o=t.inputs.slice(e,s);return t.inputNames.slice(e,s).filter(((e,t)=>{var n;return"NoOp"!==(null===(n=o[t])||void 0===n?void 0:n.op)})).map((e=>A(e,n,r,a)))}const u=A(t.inputNames[i],n,r,a),c=u.dataSync();return"number"===o.type?c[0]:N.euu.toNestedArray(u.shape,c)}const s=t.attrParams[e];return s&&s.value}function A(e,t,n,r){const[a,o]=C(e,n);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const s=n.currentContextIds.find((e=>!!t[O(a,e)]));return void 0!==s?t[O(a,s)][o]:void 0}function F(e,t,n){return t[O(e,n.currentContextId)]}function D(e,t){const[n,r,a]=C(e,t);return[O(n,t&&t.currentContextId),r,a]}function O(e,t){return t?`${e}-${t}`:e}function C(e,t){if(""===e)return["",0,void 0];const n=null!=t&&null!=t.parseNodeNameCache;if(n){const n=t.parseNodeNameCache.get(e);if(null!=n)return n}const r=e.split(":");let a;if(1===r.length)a=[e,0,void 0];else{const e=r[0],t=3===r.length?r[1]:void 0;a=[e,Number(r[r.length-1]),t]}return n&&t.parseNodeNameCache.set(e,a),a}function P(e,t,n){let r=E("pad",e,t,n);if("explicit"===r){r=E("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 R(e){return e.kept?e:(0,N.ctR)(e)}const $=[{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}
2]},{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}]}],L=
vendor: 6,808 bytes, line 2
2[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsFinite",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsInf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]
2,W=[{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"}]}
2,{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],z=
vendor: 6,566 bytes, line 2
2[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{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"}]}]
2,B=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniformInt",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number"},{tfName:"maxval",name:"maxval",type:"number"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],U=[{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}
2,{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}]}],H=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],V=[{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"}]}],G=[{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}
2,{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],q=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}],j=[{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}
2]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BitwiseAnd",category:"logical",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}]}],K=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"MatrixBandPart",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"numLower",type:"tensor"},{start:1,name:"numUpper",type:"tensor"}]}],Q=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{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}
2]},{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"}]}],Y=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],J=[{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}
vendor: 6,620 bytes, line 2
2]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]},{tfOpName:"TensorScatterUpdate",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],Z=[{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"}]}],X=[{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}]}],ee=[{tfOpName:"StaticRegexReplace",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"pattern",name:"pattern",type:"string"},{tfName:"rewrite",name:"rewrite",type:"string"},{tfName:"replace_global",name:"replaceGlobal",type:"bool"}]},{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],te=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"EnsureShape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];var ne=n(33296).Buffer;class re{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[].concat(...[r,a,o,s,i,u,c,l,p,d,h,f,m,g,y,b,w,v,k].map((e=>e.json)));this.opMappers=e.reduce(((e,t)=>(e[t.tfOpName]=t,e)),{})}transformGraph(e,t={}){const n=e.node,r=[],a=[],o=[],s=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||o.push(e[t.name]),e)),{});let i=[];const u=[];let c={},l={};null!=t&&(c=this.mapSignatureEntries(t.inputs),l=this.mapSignatureEntries(t.outputs));const p=Object.keys(s);p.forEach((e=>{const t=s[e];
vendor: 7,990 bytes, line 2
2t.inputNames.forEach(((e,n)=>{const[r,,a]=D(e),o=s[r];if(null!=o.outputs){const e=o.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(o),o.children.push(t)}))})),0===Object.keys(l).length?p.forEach((e=>{const t=s[e];0===t.children.length&&u.push(t)})):Object.keys(l).forEach((e=>{const[t]=D(e),n=s[t];null!=n&&(n.signatureKey=l[e],u.push(n))})),Object.keys(c).length>0?Object.keys(c).forEach((e=>{const[t]=D(e),n=s[t];n&&(n.signatureKey=c[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:s,inputs:i,outputs:u,weights:a,placeholders:r,signature:t,functions:d};return o.length>0&&(h.initNodes=o),h}mapSignatureEntries(e){return Object.keys(e||{}).reduce(((t,n)=>(t[e[n].name]=n,t)),{})}mapNode(e){const t=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.slice(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=oe(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=oe(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=me(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=me(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=ie(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=ie(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=fe(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=fe(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=se(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=se(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=ye(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ye(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=he(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=he(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=ge(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ge(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"dtype[]":a=pe(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=pe(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=ce(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ce(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=[],o=[];e.signature.inputArg.forEach((e=>{const[t]=D(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:ue(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,,o]=D(e),s=r[a];if(null!=s.outputs){const e=s.outputs.indexOf(o);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(s),s.children.push(t)}))}));const s=e.ret;e.signature.outputArg.forEach((e=>{const[t,n]=D(s[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,o.push(a))}));const i=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:o,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 ae(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=(0,N._K2)().global;if(void 0!==t.atob)return t.atob(e);if(void 0!==ne)return new ne(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 oe(e,t,n,r=!1){const a=e[t];return null!=a?ae(a.s,r):n}function se(e,t,n){const r=e[t];return r?r.b:n}function ie(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 ue(e){switch("string"==typeof e&&(e=_[e]),e){case _.DT_FLOAT:case _.DT_HALF:return"float32";case _.DT_INT32:case _.DT_INT64:case _.DT_INT8:case _.DT_UINT8:return"int32";case _.DT_BOOL:return"bool";case _.DT_DOUBLE:return"float32";case _.DT_STRING:return"string";default:return null}}function ce(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function le(e,t,n){const r=e[t];return r&&r.type?ue(r.type):n}function pe(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map((e=>ue(e))):n}function de(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((e=>"number"==typeof e.size?e.size:parseInt(e.size,10))):[]}function he(e,t,n){const r=e[t];return r&&r.shape?de(r.shape):n}function fe(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 me(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map((e=>ae(e,r))):n}function ge(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((e=>de(e))):n}function ye(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class be{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 A(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return A(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return ie(this.node.rawAttrs,e,t);if(null!=n.s)return oe(this.node.rawAttrs,e,t);if(null!=n.b)return se(this.node.rawAttrs,e,t);if(null!=n.shape)return he(this.node.rawAttrs,e,t);if(null!=n.type)return le(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return fe(this.node.rawAttrs,e,t);if(null!=n.list.s)return me(this.node.rawAttrs,e,t);if(null!=n.list.shape)return ge(this.node.rawAttrs,e,t);if(null!=n.list.b)return ye(this.node.rawAttrs,e,t);if(null!=n.list.type)return pe(this.node.rawAttrs,e,t)}return t}}var we=n(41932);function ve(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){N.euu.assert(e.length===t.length,(()=>n+` Shapes ${e} and ${t} must match`));for(let r=0;r<e.length;r++){const a=e[r],o=t[r];N.euu.assert(a<0||o<0||a===o,(()=>n+` Shapes ${e} and ${t} must match`))}}}function ke(e){return"number"!=typeof e&&!e.some((e=>e<0))}function xe(e,t,n){let r=_e(e,n);const a=!ke(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=_e(e.shape,r)})),!ke(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function _e(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<e.length;++r){const a=e[r],o=t[r];if(a>=0&&o>=0&&a!==o)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:o}return n}class Ie{constructor(e,t,n,r,a,o,s){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=o,this.clearAfterRead=s,this.tensors=[],this.closed_
2=!1,this.idTensor=(0,N.SgB)(0),(0,N.Oi1)(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),ve(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,N.Oi1)(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.size();t++)e.push(t)}if(0===e.length)return(0,N.mwg)([],[0].concat(this.elementShape));const n=this.readMany(e);return ve(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),(0,N.Qfh)(n,0)}concat(e){if(e&&e!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`);if(0===this.size())return(0,N.mwg)([],[0].concat(this.elementShape));const t=[];for(let e=0;e<this.size();e++)t.push(e);const n=this.readMany(t);return ve(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),(0,N.WUr)(n,0)}scatter(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);if(e.length!==t.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);const n=Math.max(...e);if(!this.dynamicSize&&n>=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,(0,N.iqB)(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,o=[];(0,N.G6I)((()=>{t=(0,N.OoG)(t,[1,n,a]);for(let n=0;n<e.length;++n){const s=[0,0===n?0:r[n-1],0],i=[1,e[n],a];o[n]=(0,N.OoG)((0,N.SME)(t,s,i),this.elementShape)}return o}));const s=[];for(let t=0;t<e.length;t++)s[t]=t;this.writeMany(s,o)}}class Se{get id(){return this.idTensor.id}constructor(e,t,n,r=-1){this.tensors=e,this.elementShape=t,this.elementDtype=n,null!=e&&e.forEach((e=>{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);ve(t,e.shape,"TensorList shape mismatch: "),(0,N.Oi1)(e)})),this.idTensor=(0,N.SgB)(0),this.maxNumElements=r,(0,N.Oi1)(this.idTensor)}copy(){return new Se([...this.tensors],this.elementShape,this.elementDtype)}
2clearAndClose(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.`);ve(e,this.elementShape,"TensorList shape mismatch: ");const r=xe(this.elementShape,this.tensors,e);return(0,N.G6I)((()=>{const e=this.tensors.map((e=>(0,N.OoG)(e,r)));return(0,N.Qfh)(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=xe(this.elementShape,this.tensors,e),r=this.tensors.pop();return r.kept=!1,ve(r.shape,e,"TensorList shape mismatch: "),(0,N.OoG)(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(ve(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");(0,N.Oi1)(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}.`);const t=new Se([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let n=0;n<Math.min(this.tensors.length,e);++n)t.tensors[n]=this.tensors[n];return t}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.`);ve(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=xe(this.elementShape,this.tensors,t);return(0,N.OoG)(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.`);ve(this.elementShape,t.shape,"TensorList shape mismatch: "),(0,N.Oi1)(t),null!=this.tensors[e]&&(this.tensors[e].kept=!1),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}`);ve(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=xe(this.elementShape,this.tensors,n);return 0===e.length?(0,N.mwg)([],[0].concat(r)):(0,N.G6I)((()=>{const t=e.map((e=>(0,N.OoG)(this.tensors[e],r)));return(0,N.Qfh)(t,0)}))}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);ve(this.elementShape,t,"TensorList shape mismatch: ");const n=xe(this.elementShape,this.tensors,t);return 0===this.size()?(0,N.mwg)([],[0].concat(n)):(0,N.G6I)((()=>{const e=this.tensors.map((e=>(0,N.OoG)(e,n)));return(0,N.WUr)(e,0)}))}}function Ne(e,t,n){const[r,a]=E("fusedOps",e,t,n),o="biasadd"===r,s=!o,i="prelu"===a,u="fusedbatchnorm"===r,c=E("numArgs",e,t,n);if(o){if(i&&2!==c)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&o&&1!==c)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const l=E("strides",e,t,n),p=P(e,t,n),d=E("dataFormat",e,t,n).toUpperCase(),h=E("dilations",e,t,n);let[f,m]=E("args",e,t,n);return s&&(m=f,f=void 0),{stride:l,pad:p,dataFormat:d,dilations:h,biasArg:f,preluArg:m,activationFunc:a,leakyreluAlpha:E("leakyreluAlpha",e,t,n)}}function Me(e,t,n){return{boxes:E("boxes",e,t,n),scores:E("scores",e,t,n),maxOutputSize:E("maxOutputSize",e,t,n),iouThreshold:E("iouThreshold",e,t,n),scoreThreshold:E("scoreThreshold",e,t,n),softNmsSigma:E("softNmsSigma",e,t,n)}}var Te=n(12988);class Ee{get id(){return this.handle.id}constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=(0,N.SgB)(0),this.tensorMap=new Map,(0,N.Oi1)(this.handle)}
2clearAndClose(){this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Te.S(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,N.G6I)((()=>{const e=(0,N.iqB)(t),r=n.length,a=e.length;N.euu.assert(r===a,(()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`));for(let t=0;t<r;t++){const r=n[t],a=e[t];(0,N.Oi1)(a),this.tensorMap.set(r,a)}return this.handle}))}async find(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return(0,N.G6I)((()=>{const e=[];for(let r=0;r<n.length;r++){const a=n[r],o=this.findWithDefault(a,t);e.push(o)}return(0,N.Qfh)(e)}))}findWithDefault(e,t){const n=this.tensorMap.get(e);return null!=n?n:t}checkKeyAndValueTensor(e,t){if(e.dtype!==this.keyDType)throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);if(t.dtype!==this.valueDType)throw new Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`)}}function Ae(e,t,n,r,a=N.G6I){const o=((e,t,n)=>{switch(e.category){case"arithmetic":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(E("a",e,t,n),E("b",e,t,n))];case"AddN":return[r.addN(E("tensors",e,t,n))];case"FloorMod":case"Mod":return[r.mod(E("a",e,t,n),E("b",e,t,n))];case"Mul":return[r.mul(E("a",e,t,n),E("b",e,t,n))];case"RealDiv":case"Div":return[r.div(E("a",e,t,n),E("b",e,t,n))];case"DivNoNan":return[r.divNoNan(E("a",e,t,n),E("b",e,t,n))];case"FloorDiv":return[r.floorDiv(E("a",e,t,n),E("b",e,t,n))];case"Sub":return[r.sub(E("a",e,t,n),E("b",e,t,n))];case"Minimum":return[r.minimum(E("a",e,t,n),E("b",e,t,n))];case"Maximum":return[r.maximum(E("a",e,t,n),E("b",e,t,n))];case"Pow":return[r.pow(E("a",e,t,n),E("b",e,t,n))];case"SquaredDifference":return[r.squaredDifference(E("a",e,t,n),E("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"basic_math":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"Abs":case"ComplexAbs":return[r.abs(E("x",e,t,n))];case"Acos":return[r.acos(E("x",e,t,n))];case"Acosh":return[r.acosh(E("x",e,t,n))];case"Asin":return[r.asin(E("x",e,t,n))];case"Asinh":return[r.asinh(E("x",e,t,n))];case"Atan":return[r.atan(E("x",e,t,n))];case"Atan2":return[r.atan2(E("x",e,t,n),E("y",e,t,n))];case"Atanh":return[r.atanh(E("x",e,t,n))];case"Ceil":return[r.ceil(E("x",e,t,n))];case"Complex":return[r.complex(E("real",e,t,n),E("imag",e,t,n))];case"Cos":return[r.cos(E("x",e,t,n))];case"Cosh":return[r.cosh(E("x",e,t,n))];case"Elu":return[r.elu(E("x",e,t,n))];case"Erf":return[r.erf(E("x",e,t,n))];case"Exp":return[r.exp(E("x",e,t,n))];case"Expm1":return[r.expm1(E("x",e,t,n))];case"Floor":return[r.floor(E("x",e,t,n))];case"Log":return[r.log(E("x",e,t,n))];case"Log1p":return[r.log1p(E("x",e,t,n))];case"Imag":return[r.imag(E("x",e,t,n))];case"Neg":return[r.neg(E("x",e,t,n))];case"Reciprocal":return[r.reciprocal(E("x",e,t,n))];case"Real":return[r.real(E("x",e,t,n))];case"Relu":return[r.relu(E("x",e,t,n))];case"Round":return[r.round(E("x",e,t,n))];case"Selu":return[r.selu(E("x",e,t,n))];case"Sigmoid":return[r.sigmoid(E("x",e,t,n))];case"Sin":return[r.sin(E("x",e,t,n))];case"Sign":return[r.sign(E("x",e,t,n))];case"Sinh":return[r.sinh(E("x",e,t,n))];case"Softplus":return[r.softplus(E("x",e,t,n))];case"Sqrt":return[r.sqrt(E("x",e,t,n))];case"Square":return[r.square(E("x",e,t,n))];case"Tanh":return[r.tanh(E("x",e,t,n))];case"Tan":return[r.tan(E("x",e,t,n))];case"ClipByValue":return[r.clipByValue(E("x",e,t,n),E("clipValueMin",e,t,n),E("clipValueMax",e,t,n))];case"Relu6":return[r.relu6(E("x",e,t,n))];case"Rsqrt":return[r.rsqrt(A(e.inputNames[0],t,n))];case"LeakyRelu":return[r.leakyRelu(E("x",e,t,n),E("alpha",e,t,n))];case"Prelu":return[r.prelu(E("x",e,t,n),E("alpha",e,t,n))];case"IsNan":return[r.isNaN(A(e.inputNames[0],t,n))];case"IsInf":return[r.isInf(A(e.inputNames[0],t,n))];case"IsFinite":return[r.isFinite(A(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"control":return(async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=E("thenBranch",e,t,n),a=E("elseBranch",e,t,n),o=E("cond",e,t,n),s=E("args",e,t,n);return(await o.data())[0]?n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=E("body",e,t,n),a=E("cond",e,t,n),o=E("args",e,t,n),s=await n.functionMap[a].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap),i=o.map((e=>e.id));let u=await s[0].data();
vendor: 14,199 bytes, line 2
2s.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||e.dispose()}));let c=o;for(;u[0];){const e=c;c=await n.functionMap[r].executeFunctionAsync(c,n.tensorArrayMap,n.tensorListMap);const t=c.map((e=>e.id));e.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}));const o=await n.functionMap[a].executeFunctionAsync(c,n.tensorArrayMap,n.tensorListMap);u=await o[0].data(),o.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}))}return c}case"LoopCond":return[R(E("pred",e,t,n))];case"Switch":{const r=E("pred",e,t,n);let a=E("data",e,t,n);return a.kept||(a=R(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find((e=>void 0!==A(e,t,n)));return r?[R(A(r,t,n))]:void 0}case"Enter":{const r=E("frameName",e,t,n),a=E("tensor",e,t,n);return n.enterFrame(r),[R(a)]}case"Exit":{const r=E("tensor",e,t,n);return n.exitFrame(),[R(r)]}case"NextIteration":{const r=E("tensor",e,t,n);return n.nextIteration(),[R(r)]}case"TensorArrayV3":{const r=E("size",e,t,n),a=E("dtype",e,t,n),o=E("elementShape",e,t,n),s=E("dynamicSize",e,t,n),i=E("clearAfterRead",e,t,n),u=E("identicalElementShapes",e,t,n),c=E("name",e,t,n),l=new Ie(c,a,r,o,u,s,i);return n.addTensorArray(l),[l.idTensor,(0,N.SgB)(1)]}case"TensorArrayWriteV3":{const r=E("tensorArrayId",e,t,n),a=E("index",e,t,n),o=E("tensor",e,t,n),s=n.getTensorArray(r.id);return s.write(a,o),[s.idTensor]}case"TensorArrayReadV3":{const r=E("tensorArrayId",e,t,n),a=E("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=E("tensorArrayId",e,t,n),a=E("indices",e,t,n),o=E("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,o)]}case"TensorArrayScatterV3":{const r=E("tensorArrayId",e,t,n),a=E("indices",e,t,n),o=E("tensor",e,t,n),s=n.getTensorArray(r.id);return s.scatter(a,o),[s.idTensor]}case"TensorArrayConcatV3":{const r=E("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),o=E("dtype",e,t,n);return[a.concat(o)]}case"TensorArraySplitV3":{const r=E("tensorArrayId",e,t,n),a=E("tensor",e,t,n),o=E("lengths",e,t,n),s=n.getTensorArray(r.id);return s.split(o,a),[s.idTensor]}case"TensorArraySizeV3":{const r=E("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return[(0,N.SgB)(a.size(),"int32")]}case"TensorArrayCloseV3":{const r=E("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=E("tensorListId",e,t,n),a=E("index",e,t,n),o=E("tensor",e,t,n),s=n.getTensorList(r.id);return s.setItem(a,o),[s.idTensor]}case"TensorListGetItem":{const r=E("tensorListId",e,t,n),a=E("index",e,t,n),o=E("elementShape",e,t,n),s=E("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,o,s)]}case"TensorListScatterV2":case"TensorListScatter":{const r=E("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 o=new Se([],n,e.dtype,r),s=(0,N.iqB)(e,0);return t.forEach(((e,t)=>{o.setItem(e,s[t])})),o}(E("tensor",e,t,n),r,E("elementShape",e,t,n),E("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=E("elementShape",e,t,n),a=E("elementDType",e,t,n);let o;o="TensorListReserve"===e.op?"numElements":"maxNumElements";const s=E(o,e,t,n),i=function(e,t,n,r){return new Se([],e,t,r)}(r,a,0,"TensorListReserve"===e.op?-1:s);return n.addTensorList(i),[i.idTensor]}case"TensorListGather":{const r=E("tensorListId",e,t,n),a=E("indices",e,t,n),o=E("elementShape",e,t,n),s=E("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,s,o)]}case"TensorListStack":{const r=E("tensorListId",e,t,n),a=E("elementShape",e,t,n),o=E("elementDType",e,t,n),s=E("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,o,s)]}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}`);ve(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=(0,N.iqB)(e);return new Se(a,t,r)}(E("tensor",e,t,n),E("elementShape",e,t,n),E("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=E("tensorListId",e,t,n),a=n.getTensorList(r.id),o=E("dtype",e,t,n),s=E("elementShape",e,t,n);return[a.concat(o,s)]}case"TensorListPushBack":{const r=E("tensorListId",e,t,n),a=E("tensor",e,t,n),o=n.getTensorList(r.id);return o.pushBack(a),[o.idTensor]}case"TensorListPopBack":{const r=E("tensorListId",e,t,n),a=E("elementShape",e,t,n),o=E("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,o)]}case"TensorListSplit":{const r=E("tensor",e,t,n),a=E("elementShape",e,t,n),o=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 o=_e(e.shape.slice(1),n),s=0===r?0:e.size/r,i=(0,N.G6I)((()=>{const n=[];e=(0,N.OoG)(e,[1,r,s]);for(let r=0;r<t.length;++r){const i=[0,0===r?0:a[r-1],0],u=[1,t[r],s];n[r]=(0,N.OoG)((0,N.SME)(e,i,u),o)}return e.dispose(),n})),u=new Se([],n,e.dtype,t.length);for(let e=0;e<i.length;e++)u.setItem(e,i[e]);return u}(r,E("lengths",e,t,n),a);return n.addTensorList(o),[o.idTensor]}case"TensorListLength":{const r=E("tensorListId",e,t,n),a=n.getTensorList(r.id);return[(0,N.SgB)(a.size(),"int32")]}case"TensorListResize":{const r=E("tensorListId",e,t,n),a=E("size",e,t,n),o=n.getTensorList(r.id).resize(a);return n.addTensorList(o),[o.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"convolution":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"Conv1D":{const a=E("stride",e,t,n),o=E("pad",e,t,n),s=E("dataFormat",e,t,n).toUpperCase(),i=E("dilation",e,t,n);return[r.conv1d(E("x",e,t,n),E("filter",e,t,n),a,o,s,i)]}case"Conv2D":{const a=E("strides",e,t,n),o=P(e,t,n),s=E("dataFormat",e,t,n).toUpperCase(),i=E("dilations",e,t,n);return[r.conv2d(E("x",e,t,n),E("filter",e,t,n),[a[1],a[2]],o,s,[i[1],i[2]])]}case"_FusedConv2D":{const{stride:a,pad:o,dataFormat:s,dilations:i,biasArg:u,preluArg:c,activationFunc:l,leakyreluAlpha:p}=Ne(e,t,n);return[r.fused.conv2d({x:E("x",e,t,n),filter:E("filter",e,t,n),strides:[a[1],a[2]],pad:o,dataFormat:s,dilations:[i[1],i[2]],bias:u,activation:l,preluActivationWeights:c,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:a,pad:o,dataFormat:s,dilations:i,biasArg:u,preluArg:c,activationFunc:l,leakyreluAlpha:p}=Ne(e,t,n);return[r.fused.depthwiseConv2d({x:E("x",e,t,n),filter:E("filter",e,t,n),strides:[a[1],a[2]],pad:o,dataFormat:s,dilations:[i[1],i[2]],bias:u,activation:l,preluActivationWeights:c,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const a=E("outputShape",e,t,n),o=E("strides",e,t,n),s=P(e,t,n);return[r.conv2dTranspose(E("x",e,t,n),E("filter",e,t,n),a,[o[1],o[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const a=E("strides",e,t,n),o=P(e,t,n),s=E("dilations",e,t,n),i=E("dataFormat",e,t,n).toUpperCase();return[r.depthwiseConv2d(E("input",e,t,n),E("filter",e,t,n),[a[1],a[2]],o,i,[s[1],s[2]])]}case"Conv3D":{const a=E("strides",e,t,n),o=E("pad",e,t,n),s=E("dataFormat",e,t,n).toUpperCase(),i=E("dilations",e,t,n);return[r.conv3d(E("x",e,t,n),E("filter",e,t,n),[a[1],a[2],a[3]],o,s,[i[1],i[2],i[3]])]}case"AvgPool":{const a=E("strides",e,t,n),o=E("pad",e,t,n),s=E("kernelSize",e,t,n);return[r.avgPool(E("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o)]}case"MaxPool":{const a=E("strides",e,t,n),o=E("pad",e,t,n),s=E("kernelSize",e,t,n);return[r.maxPool(E("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o)]}case"MaxPoolWithArgmax":{const a=E("strides",e,t,n),o=E("pad",e,t,n),s=E("kernelSize",e,t,n),i=E("includeBatchInIndex",e,t,n),{result:u,indexes:c}=r.maxPoolWithArgmax(E("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o,i);return[u,c]}case"AvgPool3D":{const a=E("strides",e,t,n),o=E("pad",e,t,n),s=E("kernelSize",e,t,n);return[r.avgPool3d(E("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],o)]}case"MaxPool3D":{const a=E("strides",e,t,n),o=E("pad",e,t,n),s=E("kernelSize",e,t,n);return[r.maxPool3d(E("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],o)]}case"Dilation2D":{const a=E("strides",e,t,n),o=E("pad",e,t,n),s=E("dilations",e,t,n),i=a[1],u=a[2],c=s[1],l=s[2];return[r.dilation2d(E("x",e,t,n),E("filter",e,t,n),[i,u],o,[c,l],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"creation":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"Fill":{const a=E("shape",e,t,n),o=E("dtype",e,t,n),s=E("value",e,t,n);return[r.fill(a,s,o)]}case"LinSpace":{const a=E("start",e,t,n),o=E("stop",e,t,n),s=E("num",e,t,n);return[r.linspace(a,o,s)]}case"Multinomial":{const a=E("logits",e,t,n),o=E("numSamples",e,t,n),s=E("seed",e,t,n);return[r.multinomial(a,o,s)]}case"OneHot":{const a=E("indices",e,t,n),o=E("depth",e,t,n),s=E("onValue",e,t,n),i=E("offValue",e,t,n),u=E("dtype",e,t,n);return[r.oneHot(a,o,s,i,u)]}case"Ones":return[r.ones(E("shape",e,t,n),E("dtype",e,t,n))];case"OnesLike":return[r.onesLike(E("x",e,t,n))];case"RandomStandardNormal":return[r.randomStandardNormal(E("shape",e,t,n),E("dtype",e,t,n),E("seed",e,t,n))];case"RandomUniform":return[r.randomUniform(E("shape",e,t,n),E("minval",e,t,n),E("maxval",e,t,n),E("dtype",e,t,n))];case"RandomUniformInt":return[r.randomUniformInt(E("shape",e,t,n),E("minval",e,t,n),E("maxval",e,t,n),E("seed",e,t,n))];case"Range":{const a=E("start",e,t,n),o=E("stop",e,t,n),s=E("step",e,t,n);return[r.range(a,o,s,E("dtype",e,t,n))]}case"TruncatedNormal":{const a=E("shape",e,t,n),o=E("mean",e,t,n),s=E("stdDev",e,t,n),i=E("seed",e,t,n);return[r.truncatedNormal(a,o,s,E("dtype",e,t,n),i)]}case"Zeros":return[r.zeros(E("shape",e,t,n),E("dtype",e,t,n))];case"ZerosLike":return[r.zerosLike(E("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"dynamic":return(async(e,t,n,r,a=x)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u,softNmsSigma:c}=Me(e,t,n),l=await a.image.nonMaxSuppressionWithScoreAsync(r,o,s,i,u,c);return[l.selectedIndices,l.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u}=Me(e,t,n),c=E("padToMaxOutputSize",e,t,n),l=await a.image.nonMaxSuppressionPaddedAsync(r,o,s,i,u,c);return[l.selectedIndices,l.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u}=Me(e,t,n);return[await a.image.nonMaxSuppressionAsync(r,o,s,i,u)]}case"Where":{const r=a.cast(E("condition",e,t,n),"bool"),o=[await a.whereAsync(r)];return r.dispose(),o}case"ListDiff":return a.setdiff1dAsync(E("x",e,t,n),E("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"LowerBound":{const a=E("sortedSequence",e,t,n),o=E("values",e,t,n);return[r.lowerBound(a,o)]}case"TopKV2":{const a=E("x",e,t,n),o=E("k",e,t,n),s=E("sorted",e,t,n),i=r.topk(a,o,s);return[i.values,i.indices]}case"UpperBound":{const a=E("sortedSequence",e,t,n),o=E("values",e,t,n);return[r.upperBound(a,o)]}case"Unique":{const a=E("x",e,t,n),o=r.unique(a);return[o.values,o.indices]}case"UniqueV2":{const a=E("x",e,t,n),o=E("axis",e,t,n),s=r.unique(a,o);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"image":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"ResizeBilinear":{const a=E("images",e,t,n),o=E("size",e,t,n),s=E("alignCorners",e,t,n),i=E("halfPixelCenters",e,t,n);return[r.image.resizeBilinear(a,[o[0],o[1]],s,i)]}case"ResizeNearestNeighbor":{const a=E("images",e,t,n),o=E("size",e,t,n),s=E("alignCorners",e,t,n),i=E("halfPixelCenters",e,t,n);return[r.image.resizeNearestNeighbor(a,[o[0],o[1]],s,i)]}case"CropAndResize":{const a=E("image",e,t,n),o=E("boxes",e,t,n),s=E("boxInd",e,t,n),i=E("cropSize",e,t,n),u=E("method",e,t,n),c=E("extrapolationValue",e,t,n);return[r.image.cropAndResize(a,o,s,i,u,c)]}case"ImageProjectiveTransformV3":{const a=E("images",e,t,n),o=E("transforms",e,t,n),s=E("outputShape",e,t,n),i=E("fillValue",e,t,n),u=E("interpolation",e,t,n),c=E("fillMode",e,t,n);return[r.image.transform(a,o,u.toLowerCase(),c.toLowerCase(),i,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"graph":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const a=E("default",e,t,n);return[A(e.name,t,n)||a];case"Placeholder":return[A(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[R(E("x",e,t,n))];case"IdentityN":return E("x",e,t,n).map((e=>R(e)));case"Shape":return[r.tensor1d(E("x",e,t,n).shape,"int32")];case"ShapeN":return E("x",e,t,n).map((e=>r.tensor1d(e.shape)));case"Size":return[r.scalar(E("x",e,t,n).size,"int32")];case"Rank":return[r.scalar(E("x",e,t,n).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":const o=E("x",e,t,n),s=E("data",e,t,n),i=E("message",e,t,n),u=E("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(i);for(let e=0;e<s.length;e++)console.log(Array.prototype.slice.call(s[e].dataSync()).slice(0,u));return[o];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"logical":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"Equal":return[r.equal(E("a",e,t,n),E("b",e,t,n))];case"NotEqual":return[r.notEqual(E("a",e,t,n),E("b",e,t,n))];case"Greater":return[r.greater(E("a",e,t,n),E("b",e,t,n))];case"GreaterEqual":return[r.greaterEqual(E("a",e,t,n),E("b",e,t,n))];case"Less":return[r.less(E("a",e,t,n),E("b",e,t,n))];case"LessEqual":return[r.lessEqual(E("a",e,t,n),E("b",e,t,n))];case"LogicalAnd":return[r.logicalAnd(E("a",e,t,n),E("b",e,t,n))];case"LogicalNot":return[r.logicalNot(E("a",e,t,n))];case"LogicalOr":return[r.logicalOr(E("a",e,t,n),E("b",e,t,n))];
vendor: 4,717 bytes, line 2
2case"Select":case"SelectV2":return[r.where(E("condition",e,t,n),E("a",e,t,n),E("b",e,t,n))];case"BitwiseAnd":return[r.bitwiseAnd(E("a",e,t,n),E("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"matrices":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(E("a",e,t,n),E("b",e,t,n),E("transposeA",e,t,n),E("transposeB",e,t,n))];case"Einsum":return[r.einsum(E("equation",e,t,n),...E("tensors",e,t,n))];case"Transpose":return[r.transpose(E("x",e,t,n),E("perm",e,t,n))];case"_FusedMatMul":const[a,o]=E("fusedOps",e,t,n),s="biasadd"===a,i="prelu"===o,u=E("numArgs",e,t,n),c=E("leakyreluAlpha",e,t,n);if(s){if(i&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[l,p]=E("args",e,t,n);return[r.fused.matMul({a:E("a",e,t,n),b:E("b",e,t,n),transposeA:E("transposeA",e,t,n),transposeB:E("transposeB",e,t,n),bias:l,activation:o,preluActivationWeights:p,leakyreluAlpha:c})];case"MatrixBandPart":return[r.linalg.bandPart(E("a",e,t,n),E("numLower",e,t,n),E("numUpper",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"normalization":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"EuclideanNorm":return[r.euclideanNorm(E("x",e,t,n),E("axis",e,t,n),E("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[r.batchNorm(E("x",e,t,n),E("mean",e,t,n),E("variance",e,t,n),E("offset",e,t,n),E("scale",e,t,n),E("epsilon",e,t,n))];case"LRN":return[r.localResponseNormalization(E("x",e,t,n),E("radius",e,t,n),E("bias",e,t,n),E("alpha",e,t,n),E("beta",e,t,n))];case"Softmax":return[r.softmax(E("x",e,t,n))];case"LogSoftmax":return[r.logSoftmax(E("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"ragged":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"RaggedGather":{const{outputNestedSplits:a,outputDenseValues:o}=r.raggedGather(E("paramsNestedSplits",e,t,n),E("paramsDenseValues",e,t,n),E("indices",e,t,n),E("outputRaggedRank",e,t,n));return a.concat(o)}case"RaggedRange":{const{rtNestedSplits:a,rtDenseValues:o}=r.raggedRange(E("starts",e,t,n),E("limits",e,t,n),E("splits",e,t,n));return[a,o]}case"RaggedTensorToTensor":return[r.raggedTensorToTensor(E("shape",e,t,n),E("values",e,t,n),E("defaultValue",e,t,n),E("rowPartitionTensors",e,t,n),E("rowPartitionTypes",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"reduction":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"Max":{const a=E("axis",e,t,n),o=E("keepDims",e,t,n);return[r.max(E("x",e,t,n),a,o)]}case"Mean":{const a=E("axis",e,t,n),o=E("keepDims",e,t,n);return[r.mean(E("x",e,t,n),a,o)]}case"Min":{const a=E("axis",e,t,n),o=E("keepDims",e,t,n);return[r.min(E("x",e,t,n),a,o)]}case"Sum":{const a=E("axis",e,t,n),o=E("keepDims",e,t,n);return[r.sum(E("x",e,t,n),a,o)]}case"All":{const a=E("axis",e,t,n),o=E("keepDims",e,t,n);return[r.all(E("x",e,t,n),a,o)]}case"Any":{const a=E("axis",e,t,n),o=E("keepDims",e,t,n);return[r.any(E("x",e,t,n),a,o)]}case"ArgMax":{const a=E("axis",e,t,n);return[r.argMax(E("x",e,t,n),a)]}case"ArgMin":{const a=E("axis",e,t,n);return[r.argMin(E("x",e,t,n),a)]}case"Prod":{const a=E("axis",e,t,n),o=E("keepDims",e,t,n);return[r.prod(E("x",e,t,n),a,o)]}case"Cumprod":{const a=E("axis",e,t,n),o=E("exclusive",e,t,n),s=E("reverse",e,t,n);return[r.cumprod(E("x",e,t,n),a,o,s)]}case"Cumsum":{const a=E("axis",e,t,n),o=E("exclusive",e,t,n),s=E("reverse",e,t,n);return[r.cumsum(E("x",e,t,n),a,o,s)]}case"Bincount":const a=E("x",e,t,n),o=E("weights",e,t,n),s=E("size",e,t,n);return[r.bincount(a,o,s)];case"DenseBincount":{const a=E("x",e,t,n),o=E("weights",e,t,n),s=E("size",e,t,n),i=E("binaryOutput",e,t,n);return[r.denseBincount(a,o,s,i)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"slice_join":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"ConcatV2":case"Concat":{const a=E("n",e,t,n),o=E("axis",e,t,n);let s=E("tensors",e,t,n);return s=s.slice(0,a),[r.concat(s,o)]}case"Gather":{const a=E("x",e,t,n),o=E("indices",e,t,n);return[r.gather(a,r.cast(o,"int32"),0)]}case"GatherV2":{const a=E("axis",e,t,n),o=E("batchDims",e,t,n),s=E("x",e,t,n),i=E("indices",e,t,n);return[r.gather(s,r.cast(i,"int32"),a,o)]}case"Reverse":{const a=E("dims",e,t,n),o=[];for(let e=0;e<a.length;e++)a[e]&&o.push(e);const s=E("x",e,t,n);return[r.reverse(s,o)]}case"ReverseV2":{const a=E("axis",e,t,n),o=E("x",e,t,n);return[r.reverse(o,a)]}case"Slice":{const a=E("begin",e,t,n),o=E("size",e,t,n);return[r.slice(E("x",e,t,n),a,o)]}
vendor: 5,318 bytes, line 2
2case"StridedSlice":{const a=E("begin",e,t,n),o=E("end",e,t,n),s=E("strides",e,t,n),i=E("beginMask",e,t,n),u=E("endMask",e,t,n),c=E("ellipsisMask",e,t,n),l=E("newAxisMask",e,t,n),p=E("shrinkAxisMask",e,t,n),d=E("x",e,t,n);return[r.stridedSlice(d,a,o,s,i,u,c,l,p)]}case"Pack":return(0,N.G6I)((()=>{const a=E("axis",e,t,n),o=E("tensors",e,t,n),s=o[0].shape,i=r.squeeze(o[0]).shape,u=o.map((e=>{const t=N.euu.arraysEqual(e.shape,s);if(!t&&!N.euu.arraysEqual(r.squeeze(e).shape,i))throw new Error("the input tensors shape does not match");return t?e:r.reshape(e,s)}));return[r.stack(u,a)]}));case"Unpack":{const a=E("axis",e,t,n),o=E("tensor",e,t,n);return r.unstack(o,a)}case"Tile":{const a=E("reps",e,t,n);return[r.tile(E("x",e,t,n),a)]}case"Split":case"SplitV":{const a=E("axis",e,t,n),o=E("numOrSizeSplits",e,t,n),s=E("x",e,t,n);return r.split(s,o,a)}case"ScatterNd":{const a=E("indices",e,t,n),o=E("values",e,t,n),s=E("shape",e,t,n);return[r.scatterND(a,o,s)]}case"GatherNd":{const a=E("x",e,t,n),o=E("indices",e,t,n);return[r.gatherND(a,o)]}case"SparseToDense":{const a=E("sparseIndices",e,t,n),o=E("outputShape",e,t,n),s=E("sparseValues",e,t,n),i=E("defaultValue",e,t,n);return[r.sparseToDense(a,s,o,s.dtype===i.dtype?i:r.cast(i,s.dtype))]}case"TensorScatterUpdate":{const a=E("indices",e,t,n),o=E("values",e,t,n),s=E("tensor",e,t,n);return[r.tensorScatterUpdate(s,a,o)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"sparse":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:a,outputValues:o,emptyRowIndicator:s,reverseIndexMap:i}=r.sparse.sparseFillEmptyRows(E("indices",e,t,n),E("values",e,t,n),E("denseShape",e,t,n),E("defaultValue",e,t,n));return[a,o,s,i]}case"SparseReshape":{const{outputIndices:a,outputShape:o}=r.sparse.sparseReshape(E("inputIndices",e,t,n),E("inputShape",e,t,n),E("newShape",e,t,n));return[a,o]}case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(E("data",e,t,n),E("indices",e,t,n),E("segmentIds",e,t,n))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(E("data",e,t,n),E("indices",e,t,n),E("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"spectral":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"FFT":return[r.fft(E("x",e,t,n))];case"IFFT":return[r.ifft(E("x",e,t,n))];case"RFFT":return[r.rfft(E("x",e,t,n))];case"IRFFT":return[r.irfft(E("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"string":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"StaticRegexReplace":return[r.string.staticRegexReplace(E("input",e,t,n),E("pattern",e,t,n),E("rewrite",e,t,n),E("replaceGlobal",e,t,n))];case"StringNGrams":{const{nGrams:a,nGramsSplits:o}=r.string.stringNGrams(E("data",e,t,n),E("dataSplits",e,t,n),E("separator",e,t,n),E("nGramWidths",e,t,n),E("leftPad",e,t,n),E("rightPad",e,t,n),E("padWidth",e,t,n),E("preserveShortSequences",e,t,n));return[a,o]}case"StringSplit":{const{indices:a,values:o,shape:s}=r.string.stringSplit(E("input",e,t,n),E("delimiter",e,t,n),E("skipEmpty",e,t,n));return[a,o,s]}case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(E("input",e,t,n),E("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"transformation":return a((()=>((e,t,n,r=x)=>{switch(e.op){case"Cast":return[r.cast(E("x",e,t,n),E("dtype",e,t,n))];case"ExpandDims":{const a=E("axis",e,t,n);return[r.expandDims(E("x",e,t,n),a)]}case"Squeeze":{const a=E("axis",e,t,n);return[r.squeeze(E("x",e,t,n),a)]}case"Reshape":return[r.reshape(E("x",e,t,n),E("shape",e,t,n))];case"EnsureShape":return[r.ensureShape(E("x",e,t,n),E("shape",e,t,n))];case"MirrorPad":return[r.mirrorPad(E("x",e,t,n),E("padding",e,t,n),E("mode",e,t,n))];case"PadV2":case"Pad":return[r.pad(E("x",e,t,n),E("padding",e,t,n),E("constantValue",e,t,n))];case"SpaceToBatchND":{const a=E("blockShape",e,t,n),o=E("paddings",e,t,n);return[r.spaceToBatchND(E("x",e,t,n),a,o)]}case"BatchToSpaceND":{const a=E("blockShape",e,t,n),o=E("crops",e,t,n);return[r.batchToSpaceND(E("x",e,t,n),a,o)]}case"DepthToSpace":{const a=E("blockSize",e,t,n),o=E("dataFormat",e,t,n).toUpperCase();return[r.depthToSpace(E("x",e,t,n),a,o)]}case"BroadcastTo":return[r.broadcastTo(E("x",e,t,n),E("shape",e,t,n))];case"BroadcastArgs":return[r.broadcastArgs(E("s0",e,t,n),E("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=r.getHashTableHandleByName(e.name);if(null!=a)return[a];{const a=E("keyDType",e,t,n),o=E("valueDType",e,t,n),s=new Ee(a,o);return r.addHashTable(e.name,s),[s.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{const a=E("tableHandle",e,t,n,r),o=E("keys",e,t,n),s=E("values",e,t,n),i=r.getHashTableById(a.id);return[await i.import(o,s)]}case"LookupTableFind":case"LookupTableFindV2":{const a=E("tableHandle",e,t,n,r),o=E("keys",e,t,n),s=E("defaultValue",e,t,n),i=r.getHashTableById(a.id);return[await i.find(o,s)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=E("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);
vendor: 9,720 bytes, line 2
2case"custom":const o=T(e.op);if(o&&o.customExecutor)return o.customExecutor(new be(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 N.euu.isPromise(o)?o.then((e=>[].concat(e))):[].concat(o)}class Fe{constructor(e={},t={},n={},r={},a){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.parseNodeNameCache=a,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t<this.contexts.length-1;t++){const n=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(n))}e.push(""),this._currentContextIds=e}contextIdforContexts(e){return e?e.map((e=>0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`)).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))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 De(e,t,n,r){const a=new Set,o=[];let s=null,i=null;const u=new Set,c=new Set(Object.keys(e).map((e=>C(e)[0])));r=r||[];const l=new Set(r.map((e=>C(e.name)[0]))),p=[...t];for(;p.length>0;){const e=p.pop();($e(e)||Le(e)||We(e))&&null==s&&(s=e,i=s.children.map((e=>e.name)).filter((e=>a.has(e)))),a.add(e.name),null==n[e.name]&&(c.has(e.name)||l.has(e.name)||(0!==e.inputs.length?e.inputs.forEach((e=>{u.has(e.name)||(u.add(e.name),p.push(e))})):o.push(e.name)))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:o,dynamicNode:s,syncInputs:i}}class Oe extends Error{constructor(e){super(`NodesExecutionOrderError: ${e}`)}}const Ce=new Set(["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"]),Pe=new Set(["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"]),Re=new Set(["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"]);function $e(e){return Ce.has(e.op)}function Le(e){return Pe.has(e.op)}function We(e){return Re.has(e.op)}class ze{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)),{})}constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this.parseNodeNameCache=new Map,this._weightMap={},this.SEPARATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach((t=>{this._functionExecutorMap[t]=new ze(e.functions[t],this)}))}getCompilationKey(e,t){const n=e.map((e=>e.name)).sort(),r=t.map((e=>e.name)).sort();return n.join(this.SEPARATOR)+"--"+r.join(this.SEPARATOR)}compile(e,t){const n=De(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:o}=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 [${o}]`);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}]`)}const s=function(e,t){const{usedNodes:n,inputs:r}=t,a=Object.keys(r).map((e=>C(e)[0])).map((t=>e.nodes[t])),o=e.initNodes||[],s=e=>n.has("string"==typeof e?e:e.name);function i(e){return[...new Map(e.map((e=>[e.name,e]))).values()]}const u=i([...a,...e.weights,...o]).filter(s),c=i([...u,...Object.values(e.nodes)]).filter(s),l=new Map(c.map((e=>[e.name,e]))),p={};for(const e of c){p[e.name]=p[e.name]||0;for(const t of e.children)s(t)||(p[t.name]=Number.POSITIVE_INFINITY),p[t.name]=(p[t.name]||0)+1}const d=Object.entries(p).filter((([,e])=>0===e)).map((([e])=>e)),h=[...d];for(;d.length>0;){const e=d.pop(),t=l.get(e);for(const e of t.children.filter(s))0==--p[e.name]&&(h.push(e.name),d.push(e.name))}const f=function(e,t){const n=new Map(e.map((e=>[e.name,e]))),r=t.map((e=>e.name)),a=new Set(r);for(;r.length>0;){const e=r.pop(),t=n.get(e);for(const e of t.children)n.has(e.name)&&!a.has(e.name)&&(a.add(e.name),r.push(e.name))}return e.filter((e=>a.has(e.name)))}(h.map((e=>l.get(e))),u);return function(e,t){const n=new Map(e.map(((e,t)=>[e.name,t]))),r=new Set(t.map((e=>e.name))),a=e=>r.has("string"==typeof e?e:e.name),o=new Set(e.map((e=>e.name))),s=e=>o.has("string"==typeof e?e:e.name);for(const t of e){for(const e of t.children.filter(s)){if(!n.has(e.name))throw new Oe(`Child ${e.name} of node ${t.name} is unreachable.`);if(n.get(t.name)>n.get(e.name))throw new Oe(`Node ${t.name} is scheduled to run after its child ${e.name}.`)}if(!a(t))for(const e of t.inputs){if(!n.has(e.name))throw new Oe(`Input ${e.name} of node ${t.name} is unreachable.`);if(n.get(e.name)>n.get(t.name))throw new Oe(`Node ${t.name} is scheduled to run before its input ${e.name}.`)}}}(f,u),f}(this.graph,n),i=function(e){const t=new Map(e.map(((e,t)=>[e.name,t]))),n=Number.MAX_SAFE_INTEGER,r=e.map(((e,t)=>$e(e)?n:t)),a=e=>{const n=r[t.get(e.name)];return null==n?-1:n},o=e.map(((e,t)=>e.children.map(a).reduce(((e,t)=>Math.max(e,t)),r[t]))),s=new Map;for(let t=0;t<e.length;++t){const r=o[t];if(r===n)continue;const a=e[t],i=e[r];s.has(i.name)||s.set(i.name,[]),s.get(i.name).push(a)}return s}(s);return{orderedNodes:s,nodeLiveUntilMap:i}}cloneAndKeepTensor(e){if(null==e)return null;const t=e.clone();return(0,N.Oi1)(t),t}cloneTensorList(e){return e?e.map((e=>this.cloneAndKeepTensor(e))):null}cloneTensorMap(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,this.cloneTensorList(t)])))}execute(e,t){this.disposeIntermediateTensors(),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[C(e)[0]])),a=t.map((e=>C(e)[0])),o=new Set(a);let s=a.map((e=>this.graph.nodes[e]));0===s.length&&(s=this._outputs);const i=this.getCompilationKey(r,s);let u=this.compiledMap.get(i);null==u&&(u=this.compile(e,s),this.compiledMap.set(i,u));try{this.keepIntermediateTensors=(0,N._K2)().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}const c={},l={};return(0,N.G6I)((()=>{const n=new Fe(this.weightMap,c,l,this.functionExecutorMap,this.parseNodeNameCache),r=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(e).forEach((t=>{const[a,o]=C(t,n),s=[];s[o]=e[t],r[a]=s,this.keepIntermediateTensors&&(this.clonedTensorsMap[a]=this.cloneTensorList(s))}));const a=this.getFrozenTensorIds(r),{orderedNodes:s,nodeLiveUntilMap:i}=u;for(const e of s){if(r[e.name])continue;const t=Ae(e,r,n,this._resourceManager);if(N.euu.isPromise(t))throw new Error(`The execution of the op '${e.op}' returned a promise. Please use model.executeAsync() instead.`);r[e.name]=t,this.keepIntermediateTensors&&(this.clonedTensorsMap[e.name]=this.cloneTensorList(t)),this.checkTensorForDisposalWithNodeLiveUntilInfo(e,r,n,a,o,i.get(e.name))}return null==this.parent&&n.dispose(a),t.map((e=>A(e,r,n)))}
vendor: 12,200 bytes, line 2
2))}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,o,s){if(!$e(t)&&!o.has(e)){for(const r of n[e])null!=r&&(s[r.id]=(s[r.id]||0)+t.children.length);for(const e of t.inputs){if($e(e))continue;const t=F(e.name,n,r);if(null!=t)for(const e of t){if(!e||e.kept||a.has(e.id))continue;const t=s[e.id];1===t?(e.dispose(),delete s[e.id]):null!=t&&s[e.id]--}}}}checkTensorForDisposalWithNodeLiveUntilInfo(e,t,n,r,a,o){function s(e){return $e(e)||a.has(e.name)}if(!$e(e)&&null!=o)for(const e of o){if(s(e))continue;const a=F(e.name,t,n);for(const e of a)!e||e.kept||r.has(e.id)||e.dispose()}}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.clonedTensorsMap&&(Object.values(this.clonedTensorsMap).forEach((e=>{for(const t of e)t&&!t.isDisposed&&t.dispose()})),this.clonedTensorsMap=null)}getIntermediateTensors(){return this.clonedTensorsMap}async _executeAsync(e,t,n=!1,r={},a={}){this.disposeIntermediateTensors(),n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepIntermediateTensors=(0,N._K2)().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}const o=new Fe(this.weightMap,r,a,this.functionExecutorMap,this.parseNodeNameCache);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));const s=await this.executeWithControlFlow(e,o,t,n),i=t.map((e=>A(e,s,o))),u=i.map((e=>e.id)),c=Object.keys(e).map((t=>e[t].id)),l=new Set([...u,...c,...this.weightIds]);return Object.values(s).forEach((e=>{e.forEach((e=>{!e||e.isDisposed||l.has(e.id)||e.dispose()}))})),null==this.parent&&o.dispose(l),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),o=a.map((e=>this.graph.nodes[C(e)[0]])),s=n.map((e=>C(e)[0])),i=new Set(s);let u=s.map((e=>this.graph.nodes[e]));0===u.length&&(u=this._outputs);const{usedNodes:c,missingInputs:l,dynamicNode:p,syncInputs:d}=De(e,u,this.weightMap,this._initNodes),h=[...o,...this.graph.weights,...this._initNodes||[]].map((e=>({node:e,contexts:t.currentContext}))),f=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,r]=C(t),a=[];a[r]=e[t],f[n]=a}));const m={},g=this.getFrozenTensorIds(f),y={};for(;h.length>0;){const e=this.processStack(o,h,t,f,y,g,i,m,c);await Promise.all(e)}null!=p||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 b=u.filter((e=>!$e(e)&&!A(e.name,f,t))).map((e=>e.name));if(b.length>0){let e="";throw null!=p&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${d}]`),new Error(`Cannot compute the outputs [${b}] from the provided inputs [${a}]. Consider providing the following inputs: [${l}]. ${e}`)}return f}processStack(e,t,n,r,a,o,s,i,u){const c=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let l="";if("Enter"===e.node.op&&E("isConstant",e.node,r,n)&&([l]=D(e.node.name,n)),null==r[e.node.name]){const p=Ae(e.node,r,n,this._resourceManager);l||([l]=D(e.node.name,n));const d=n.currentContext;N.euu.isPromise(p)?c.push(p.then((c=>(r[l]=c,this.keepIntermediateTensors&&(this.clonedTensorsMap[l]=this.cloneTensorList(c)),n.currentContext=d,this.checkTensorForDisposal(l,e.node,r,n,o,s,i),this.processChildNodes(e.node,t,n,r,a,u),c)))):(r[l]=p,this.keepIntermediateTensors&&(this.clonedTensorsMap[l]=this.cloneTensorList(p)),this.checkTensorForDisposal(l,e.node,r,n,o,s,i),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return c}processChildNodes(e,t,n,r,a,o){e.children.forEach((e=>{const[s]=D(e.name,n);!a[s]&&o.has(e.name)&&("Merge"===e.op?e.inputNames.some((e=>!!A(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((e=>!!A(e,r,n)))&&(a[s]=!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]=C(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));N.euu.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&&N.euu.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){var t,n;const r={};for(const a in e){const o=null===(n=null===(t=this._signature)||void 0===t?void 0:t.inputs)||void 0===n?void 0:n[a];null!=o?r[o.name]=e[a]:r[a]=e[a]}return r}checkInputs(e){const t=Object.keys(e).filter((e=>{const[t]=C(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=>{var t,n;const r=null===(n=null===(t=this._signature)||void 0===t?void 0:t.outputs)||void 0===n?void 0:n[e];return null!=r?r.name:e}),{})}checkOutputs(e){e.forEach((e=>{const[t]=C(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)}))}}class Be{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]}}const Ue="?tfjs-format=file",He="model.json";class Ve{get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}constructor(e,t={},n=N.io){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=n,null==t&&(this.loadOptions={}),this.resourceManager=new Be}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{const t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return N.euu.isPromise(e)?e.then((e=>this.loadSync(e))):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new ze(re.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=re.Instance.transformGraph(e.modelInitializer);this.initializer=new ze(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=e.initializerSignature}return!0}async save(e,t){if("string"==typeof e){const t=this.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)}addStructuredOutputNames(e){if(this.structuredOutputKeys){const t=e instanceof N.w3A?[e]:e,n={};return t.forEach(((e,t)=>n[this.structuredOutputKeys[t]]=e)),n}return e}predict(e,t){const n=this.execute(e,this.outputNodes);return this.addStructuredOutputNames(n)}async predictAsync(e,t){const n=await this.executeAsync(e,this.outputNodes);return this.addStructuredOutputNames(n)}normalizeInputs(e){var t;if(!(e instanceof N.w3A||Array.isArray(e))){const n=null===(t=this.signature)||void 0===t?void 0:t.inputs;if(null!=n)for(const t in n){const r=n[t];null!=r.resourceId&&(e[t]=this.resourceIdToCapturedInput[r.resourceId])}return e}e=Array.isArray(e)?e:[e];const n=Object.keys(this.resourceIdToCapturedInput).length;if(e.length+n!==this.inputNodes.length)throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-n} non-resource placeholders, while there are ${e.length} input tensors provided.`);let r=0;return this.inputNodes.reduce(((t,n)=>{var a,o,s;const i=null===(s=null===(o=null===(a=this.signature)||void 0===a?void 0:a.inputs)||void 0===o?void 0:o[n])||void 0===s?void 0:s.resourceId;return t[n]=null!=i?this.resourceIdToCapturedInput[i]:e[r++],t}),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}executeInitializerGraph(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))}async executeInitializerGraphAsync(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.executeAsync({},[]):this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs))}setResourceIdToCapturedInput(e){if(this.resourceIdToCapturedInput={},this.initializerSignature){const t=this.initializerSignature.outputs,n=Object.keys(t);for(let r=0;r<n.length;r++){const a=t[n[r]];this.resourceIdToCapturedInput[a.resourceId]=e[r]}}}execute(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),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){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce(((t,n)=>(t[n]=[e[n]],t)),{})}dispose(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&(0,N.Mtx)(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function Ge(e,t={},n=N.io){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&&"string"==typeof e&&(e=function(e){return e.endsWith("/")||(e+="/"),`${e}${He}${Ue}`}(e));const r=new Ve(e,t,n);return await r.load(),r}var qe=function(){return qe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},qe.apply(this,arguments)};
vendor: 5,971 bytes, line 2
2function je(e,t,n,r){return new(n||(n=Promise))((function(t,a){function o(e){try{i(r.next(e))}catch(e){a(e)}}function s(e){try{i(r.throw(e))}catch(e){a(e)}}function i(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}i((r=r.apply(e,[])).next())}))}function Ke(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}var Qe=["rightEye","leftEye","noseTip","mouthCenter","rightEarTragion","leftEarTragion"],Ye={modelType:"short",runtime:"mediapipe",maxFaces:1},Je=function(){function e(e){var t=this;this.width=0,this.height=0,this.selfieMode=!1,this.faceDetectorSolution=new S.c({locateFile:function(t,n){if(e.solutionPath){var r=e.solutionPath.replace(/\/+$/,"");return"".concat(r,"/").concat(t)}return"".concat(n,"/").concat(t)}}),this.faceDetectorSolution.setOptions({selfieMode:this.selfieMode,model:e.modelType}),this.faceDetectorSolution.onResults((function(e){if(t.height=e.image.height,t.width=e.image.width,t.faces=[],null!==e.detections)for(var n=0,r=e.detections;n<r.length;n++){var a=r[n];t.faces.push(t.normalizedToAbsolute(a.landmarks,{xMin:s=(o=a.boundingBox).xCenter-o.width/2,xMax:s+o.width,yMin:i=o.yCenter-o.height/2,yMax:i+o.height,width:o.width,height:o.height}))}var o,s,i}))}return e.prototype.normalizedToAbsolute=function(e,t){var n=this;return{keypoints:e.map((function(e,t){return{x:e.x*n.width,y:e.y*n.height,name:Qe[t]}})),box:{xMin:t.xMin*this.width,yMin:t.yMin*this.height,xMax:t.xMax*this.width,yMax:t.yMax*this.height,width:t.width*this.width,height:t.height*this.height}}},e.prototype.estimateFaces=function(e,t){return je(this,0,void 0,(function(){var n,r;return Ke(this,(function(a){switch(a.label){case 0:return t&&t.flipHorizontal&&t.flipHorizontal!==this.selfieMode&&(this.selfieMode=t.flipHorizontal,this.faceDetectorSolution.setOptions({selfieMode:this.selfieMode})),e instanceof N.w3A?(r=ImageData.bind,[4,N.aW8.toPixels(e)]):[3,2];case 1:return n=new(r.apply(ImageData,[void 0,a.sent(),e.shape[1],e.shape[0]])),[3,3];case 2:n=e,a.label=3;case 3:return e=n,[4,this.faceDetectorSolution.send({image:e})];case 4:return a.sent(),[2,this.faces]}}))}))},e.prototype.dispose=function(){this.faceDetectorSolution.close()},e.prototype.reset=function(){this.faceDetectorSolution.reset(),this.width=0,this.height=0,this.faces=null,this.selfieMode=!1},e.prototype.initialize=function(){return this.faceDetectorSolution.initialize()},e}();function Ze(e){return je(this,0,void 0,(function(){var t,n;return Ke(this,(function(r){switch(r.label){case 0:return t=function(e){if(null==e)return qe({},Ye);var t=qe({},e);return t.runtime="mediapipe",null==t.modelType&&(t.modelType=Ye.modelType),null==t.maxFaces&&(t.maxFaces=Ye.maxFaces),t}(e),[4,(n=new Je(t)).initialize()];case 1:return r.sent(),[2,n]}}))}))}function Xe(e){return e instanceof N.w3A?{height:e.shape[0],width:e.shape[1]}:{height:e.height,width:e.width}}function et(e){return e instanceof N.w3A?e:N.aW8.fromPixels(e)}function tt(e,t){N.euu.assert(0!==e.width,(function(){return"".concat(t," width cannot be 0.")})),N.euu.assert(0!==e.height,(function(){return"".concat(t," height cannot be 0.")}))}function nt(e){null==e.reduceBoxesInLowestLayer&&(e.reduceBoxesInLowestLayer=!1),null==e.interpolatedScaleAspectRatio&&(e.interpolatedScaleAspectRatio=1),null==e.fixedAnchorSize&&(e.fixedAnchorSize=!1);for(var t=[],n=0;n<e.numLayers;){for(var r=[],a=[],o=[],s=[],i=n;i<e.strides.length&&e.strides[i]===e.strides[n];){var u=rt(e.minScale,e.maxScale,i,e.strides.length);if(0===i&&e.reduceBoxesInLowestLayer)o.push(1),o.push(2),o.push(.5),s.push(.1),s.push(u),s.push(u);else{for(var c=0;c<e.aspectRatios.length;++c)o.push(e.aspectRatios[c]),s.push(u);if(e.interpolatedScaleAspectRatio>0){var l=i===e.strides.length-1?1:rt(e.minScale,e.maxScale,i+1,e.strides.length);s.push(Math.sqrt(u*l)),o.push(e.interpolatedScaleAspectRatio)}}i++}for(var p=0;p<o.length;++p){var d=Math.sqrt(o[p]);r.push(s[p]/d),a.push(s[p]*d)}var h=0,f=0;if(e.featureMapHeight.length>0)h=e.featureMapHeight[n],f=e.featureMapWidth[n];else{var m=e.strides[n];h=Math.ceil(e.inputSizeHeight/m),f=Math.ceil(e.inputSizeWidth/m)}for(var g=0;g<h;++g)for(var y=0;y<f;++y)for(var b=0;b<r.length;++b){var w={xCenter:(y+e.anchorOffsetX)/f,yCenter:(g+e.anchorOffsetY)/h,width:0,height:0};e.fixedAnchorSize?(w.width=1,w.height=1):(w.width=a[b],w.height=r[b]),t.push(w)}n=i}return t}function rt(e,t,n,r){return 1===r?.5*(e+t):e+(t-e)*n/(r-1)}function at(e,t){var n=t[0],r=t[1];return[n*e[0]+r*e[1]+e[3],n*e[4]+r*e[5]+e[7]]}function ot(e,t,n,r){return je(this,0,void 0,(function(){var r,a,o,s,i;return Ke(this,(function(u){switch(u.label){case 0:return e.sort((function(e,t){return Math.max.apply(Math,t.score)-Math.max.apply(Math,e.score)})),r=(0,N.Enf)(e.map((function(e){return[e.locationData.relativeBoundingBox.yMin,e.locationData.relativeBoundingBox.xMin,e.locationData.relativeBoundingBox.yMax,e.locationData.relativeBoundingBox.xMax]}))),a=(0,N.SC3)(e.map((function(e){return e.score[0]}
2))),[4,N.c$0.nonMaxSuppressionAsync(r,a,t,n)];case 1:return[4,(o=u.sent()).array()];case 2:return s=u.sent(),i=e.filter((function(e,t){return s.indexOf(t)>-1})),(0,N.Mtx)([r,a,o]),[2,i]}}))}))}function st(e,t,n){return je(this,0,void 0,(function(){var r,a,o,s,i;return Ke(this,(function(u){switch(u.label){case 0:return r=e[0],a=e[1],o=function(e,t,n){return(0,N.G6I)((function(){var r,a,o,s;n.reverseOutputOrder?(a=(0,N.sLr)((0,N.SME)(e,[0,n.boxCoordOffset+0],[-1,1])),r=(0,N.sLr)((0,N.SME)(e,[0,n.boxCoordOffset+1],[-1,1])),s=(0,N.sLr)((0,N.SME)(e,[0,n.boxCoordOffset+2],[-1,1])),o=(0,N.sLr)((0,N.SME)(e,[0,n.boxCoordOffset+3],[-1,1]))):(r=(0,N.sLr)((0,N.SME)(e,[0,n.boxCoordOffset+0],[-1,1])),a=(0,N.sLr)((0,N.SME)(e,[0,n.boxCoordOffset+1],[-1,1])),o=(0,N.sLr)((0,N.SME)(e,[0,n.boxCoordOffset+2],[-1,1])),s=(0,N.sLr)((0,N.SME)(e,[0,n.boxCoordOffset+3],[-1,1]))),a=(0,N.WQq)((0,N.E7T)((0,N.MbH)(a,n.xScale),t.w),t.x),r=(0,N.WQq)((0,N.E7T)((0,N.MbH)(r,n.yScale),t.h),t.y),n.applyExponentialOnBoxSize?(o=(0,N.E7T)((0,N.oNF)((0,N.MbH)(o,n.hScale)),t.h),s=(0,N.E7T)((0,N.oNF)((0,N.MbH)(s,n.wScale)),t.w)):(o=(0,N.E7T)((0,N.MbH)(o,n.hScale),t.h),s=(0,N.E7T)((0,N.MbH)(s,n.wScale),t.h));var i=(0,N.AT$)(r,(0,N.MbH)(o,2)),u=(0,N.AT$)(a,(0,N.MbH)(s,2)),c=(0,N.WQq)(r,(0,N.MbH)(o,2)),l=(0,N.WQq)(a,(0,N.MbH)(s,2)),p=(0,N.WUr)([(0,N.OoG)(i,[n.numBoxes,1]),(0,N.OoG)(u,[
2n.numBoxes,1]),(0,N.OoG)(c,[n.numBoxes,1]),(0,N.OoG)(l,[n.numBoxes,1])],1);if(n.numKeypoints)for(var d=0;d<n.numKeypoints;++d){var h=n.keypointCoordOffset+d*n.numValuesPerKeypoint,f=void 0,m=void 0;n.reverseOutputOrder?(f=(0,N.sLr)((0,N.SME)(e,[0,h],[-1,1])),m=(0,N.sLr)((0,N.SME)(e,[0,h+1],[-1,1]))):(m=(0,N.sLr)((0,N.SME)(e,[0,h],[-1,1])),f=(0,N.sLr)((0,N.SME)(e,[0,h+1],[-1,1])));var g=(0,N.WQq)((0,N.E7T)((0,N.MbH)(f,n.xScale),t.w),t.x),y=(0,N.WQq)((0,N.E7T)((0,N.MbH)(m,n.yScale),t.h),t.y);p=(0,N.WUr)([p,(0,N.OoG)(g,[n.numBoxes,1]),(0,N.OoG)(y,[n.numBoxes,1])],1)}return p}))}(a,t,n),s=(0,N.G6I)((function(){var e=r;return n.sigmoidScore?(null!=n.scoreClippingThresh&&(e=(0,N.Qjg)(r,-n.scoreClippingThresh,n.scoreClippingThresh)),e=(0,N._CL)(e)):e})),[4,it(o,s,n)];case 1:return i=u.sent(),(0,N.Mtx)([o,s]),[2,i]}}))}))}function it(e,t,n){return je(this,0,void 0,(function(){var r,a,o,s,i,u,c,l,p,d,h,f;return Ke(this,(function(m){switch(m.label){case 0:return r=[],[4,e.data()];case 1:return a=m.sent(),[4,t.data()];case 2:for(o=m.sent(),s=0;s<n.numBoxes;++s)if(!(null!=n.minScoreThresh&&o[s]<n.minScoreThresh||(i=s*n.numCoords,u=ut(a[i+0],a[i+1],a[i+2],a[i+3],o[s],n.flipVertically,s),(c=u.locationData.relativeBoundingBox).width<0||c.height<0))){if(n.numKeypoints>0)for((l=u.locationData).relativeKeypoints=[],p=n.numKeypoints*n.numValuesPerKeypoint,d=0;d<p;d+=n.numValuesPerKeypoint)h=i+n.keypointCoordOffset+d,f={x:a[h+0],y:n.flipVertically?1-a[h+1]:a[h+1]},l.relativeKeypoints.push(f);r.push(u)}return[2,r]}}))}))}function ut(e,t,n,r,a,o,s){return{score:[a],ind:s,locationData:{relativeBoundingBox:{xMin:t,yMin:o?1-n:e,xMax:r,yMax:o?1-e:n,width:r-t,height:n-e}}}}var ct,lt={reduceBoxesInLowestLayer:!1,interpolatedScaleAspectRatio:1,featureMapHeight:[],featureMapWidth:[],numLayers:4,minScale:.1484375,maxScale:.75,inputSizeHeight:128,inputSizeWidth:128,anchorOffsetX:.5,anchorOffsetY:.5,strides:[8,16,16,16],aspectRatios:[1],fixedAnchorSize:!0},pt={reduceBoxesInLowestLayer:!1,interpolatedScaleAspectRatio:0,featureMapHeight:[],featureMapWidth:[],numLayers:1,minScale:.1484375,maxScale:.75,inputSizeHeight:192,inputSizeWidth:192,anchorOffsetX:.5,anchorOffsetY:.5,strides:[4],aspectRatios:[1],fixedAnchorSize:!0},dt={runtime:"tfjs",modelType:"short",maxFaces:1,detectorModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1"},ht={applyExponentialOnBoxSize:!1,flipVertically:!1,ignoreClasses:[],numClasses:1,numBoxes:896,numCoords:16,boxCoordOffset:0,keypointCoordOffset:4,numKeypoints:6,numValuesPerKeypoint:2,sigmoidScore:!0,scoreClippingThresh:100,reverseOutputOrder:!0,xScale:128,yScale:128,hScale:128,wScale:128,minScoreThresh:.5},ft={applyExponentialOnBoxSize:!1,flipVertically:!1,ignoreClasses:[],numClasses:1,numBoxes:2304,numCoords:16,boxCoordOffset:0,keypointCoordOffset:4,numKeypoints:6,numValuesPerKeypoint:2,sigmoidScore:!0,scoreClippingThresh:100,reverseOutputOrder:!0,xScale:192,yScale:192,hScale:192,wScale:192,minScoreThresh:.6},mt={outputTensorSize:{width:128,height:128},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},gt={outputTensorSize:{width:192,height:192},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},yt=function(){function e(e,t,n){this.detectorModel=t,this.maxFaces=n,"full"===e?(this.imageToTensorConfig=gt,this.tensorsToDetectionConfig=ft,this.anchors=nt(pt)):(this.imageToTensorConfig=mt,this.tensorsToDetectionConfig=ht,this.anchors=nt(lt));var r=(0,N.SC3)(this.anchors.map((function(e){return e.width}))),a=(0,N.SC3)(this.anchors.map((function(e){return e.height}))),o=(0,N.SC3)(this.anchors.map((function(e){return e.xCenter}))),s=(0,N.SC3)(this.anchors.map((function(e){return e.yCenter})));this.anchorTensor={x:o,y:s,w:r,h:a}}return e.prototype.dispose=function(){this.detectorModel.dispose(),(0,N.Mtx)([this.anchorTensor.x,this.anchorTensor.y,this.anchorTensor.
2w,this.anchorTensor.h])},e.prototype.reset=function(){},e.prototype.detectFaces=function(e,t){return void 0===t&&(t=!1),je(this,0,void 0,(function(){var n,r,a,o,s,i,u,c,l,p,d;return Ke(this,(function(h){switch(h.label){case 0:return null==e?(this.reset(),[2,[]]):(n=(0,N.G6I)((function(){var n=(0,N.WM5)(et(e),"float32");return t&&(n=(0,N.sLr)(N.c$0.flipLeftRight((0,N.aW5)(n,0)),[0])),n})),r=function(e,t,n){var r=t.outputTensorSize,a=t.keepAspectRatio,o=t.borderMode,s=t.outputTensorFloatRange,i=Xe(e),u=function(e,t){return{xCenter:.5*e.width,yCenter:.5*e.height,width:e.width,height:e.height,rotation:0}}(i),c=function(e,t,n){if(void 0===n&&(n=!1),!n)return{top:0,left:0,right:0,bottom:0};var r=t.height,a=t.width;tt(t,"targetSize"),tt(e,"roi");var o,s,i=r/a,u=e.height/e.width,c=0,l=0;return i>u?(o=e.width,s=e.width*i,l=(1-u/i)/2):(o=e.height/i,s=e.height,c=(1-i/u)/2),e.width=o,e.height=s,{top:l,left:c,right:c,bottom:l}}(u,r,a),l=function(e,t,n,r){var a=e.width,o=e.height,s=Math.cos(e.rotation),i=Math.sin(e.rotation),u=e.xCenter,c=e.yCenter,l=1/t,p=1/n,d=new Array(16);return d[0]=a*s*1*l,d[1]=-o*i*l,d[2]=0,d[3]=(-.5*a*s*1+.5*o*i+u)*l,d[4]=a*i*1*p,d[5]=o*s*p,d[6]=0,d[7]=(-.5*o*s-.5*a*i*1+c)*p,d[8]=0,d[9]=0,d[10]=a*l,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,function(e){if(16!==e.length)throw new Error("Array length must be 16 but got ".concat(e.length));return[[e[0],e[1],e[2],e[3]],[e[4],e[5],e[6],e[7]],[e[8],e[9],e[10],e[11]],[e[12],e[13],e[14],e[15]]]}(d)}(u,i.width,i.height),p=(0,N.G6I)((function(){var t=et(e),n=(0,N.Enf)(function(e,t,n){return tt(n,"inputResolution"),[1/n.width*e[0][0]*t.width,1/n.height*e[0][1]*t.width,e[0][3]*t.width,1/n.width*e[1][0]*t.height,1/n.height*e[1][1]*t.height,e[1][3]*t.height,0,0]}(l,i,r),[1,8]),a="zero"===o?"constant":"nearest",u=N.c$0.transform((0,N.aW5)((0,N.WM5)(t,"float32")),n,"bilinear",a,0,[r.height,r.width]);return null!=s?function(e,t){var n=function(e,t,n,r){var a=(r-n)/255;return{scale:a,offset:n-0*a}}(0,0,t[0],t[1]);return(0,N.G6I)((function(){return(0,N.WQq)((0,N.E7T)(e,n.scale),n.offset)}))}(u,s):u}));return{imageTensor:p,padding:c,transformationMatrix:l}}(n,this.imageToTensorConfig),a=r.imageTensor,o=r.transformationMatrix,s=this.detectorModel.execute(a,"Identity:0"),i=function(e){return(0,N.G6I)((function(){var t=function(e){return(0,N.G6I)((function(){return[(0,N.SME)(e,[0,0,0],[1,-1,1]),(0,N.SME)(e,[0,0,1],[1,-1,-1])]}))}(e),n=t[0],r=t[1];return{boxes:(0,N.sLr)(r),logits:(0,N.sLr)(n)}}))}(s),u=i.boxes,[4,st([c=i.logits,u],this.anchorTensor,this.tensorsToDetectionConfig)]);case 1:return 0===(l=h.sent()).length?((0,N.Mtx)([n,a,s,c,u]),[2,l]):[4,ot(l,this.maxFaces,.3)];case 2:return p=h.sent(),d=function(e,t){void 0===e&&(e=[]);var n,r=(n=t,[].concat.apply([],n));return e.forEach((function(e){var t=e.locationData;t.relativeKeypoints.forEach((function(e){var t=at(r,[e.x,e.y]),n=t[0],a=t[1];e.x=n,e.y=a}));var n=t.relativeBoundingBox,a=Number.MAX_VALUE,o=Number.MAX_VALUE,s=Number.MIN_VALUE,i=Number.MIN_VALUE;[[n.xMin,n.yMin],[n.xMin+n.width,n.yMin],[n.xMin+n.width,n.yMin+n.height],[n.xMin,n.yMin+n.height]].forEach((function(e){var t=at(r,e),n=t[0],u=t[1];a=Math.min(a,n),s=Math.max(s,n),o=Math.min(o,u),i=Math.max(i,u)})),t.relativeBoundingBox={xMin:a,xMax:s,yMin:o,yMax:i,width:s-a,height:i-o}})),e}(p,o),(0,N.Mtx)([n,a,s,c,u]),[2,d]}}))}))},e.prototype.estimateFaces=function(e,t){return je(this,0,void 0,(function(){var n,r;return Ke(this,(function(a){return n=Xe(e),r=!!t&&t.flipHorizontal,[2,this.detectFaces(e,r).then((function(e){return e.map((function(e){for(var t=e.locationData.relativeKeypoints.map((function(e,t){return qe(qe({},e),{x:e.x*n.width,y:e.y*n.height,name:Qe[t]})})),r=e.locationData.relativeBoundingBox,a=0,o=["width","xMax","xMin"];a<o.length;a++)r[o[a]]*=n.width;for(var s=0,i=["height","yMax","yMin"];s<i.length;s++)r[i[s]]*=n.height;return{keypoints:t,box:r}}))}))]}))}))},e}();function bt(e){return je(this,0,void 0,(function(){var t,n,r;return Ke(this,(function(a){switch(a.label){case 0:return t=function(e){if(null==e)return qe({},dt);var t=qe({},e);return null==t.modelType&&(t.modelType=dt.modelType),null==t.maxFaces&&(t.maxFaces=dt.maxFaces),null==t.detectorModelUrl&&("full"===t.modelType?t.detectorModelUrl="https://tfhub.dev/mediapipe/tfjs-model/face_detection/full/1":t.detectorModelUrl="https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1"),t}(e),n="string"==typeof t.detectorModelUrl&&t.detectorModelUrl.indexOf("https://tfhub.dev")>-1,[4,Ge(t.detectorModelUrl,{fromTFHub:n})];case 1:return r=a.sent(),[2,new yt(t.modelType,r,t.maxFaces)]}}))}))}function wt(e,t){return je(this,0,void 0,(function(){var n,r;
2return Ke(this,(function(a){if(e===ct.MediaPipeFaceDetector){if(r=void 0,null!=(n=t)){if("tfjs"===n.runtime)return[2,bt(n)];if("mediapipe"===n.runtime)return[2,Ze(n)];r=n.runtime}throw new Error("Expect modelConfig.runtime to be either 'tfjs' "+"or 'mediapipe', but got ".concat(r))}throw new Error("".concat(e," is not a supported model name."))}))}))}(ct||(ct={})).MediaPipeFaceDetector="MediaPipeFaceDetector"}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.