human/dist/demo-browser-index.js

4210 lines
1.3 MiB

var pf=Object.defineProperty,ng=N=>pf(N,"__esModule",{value:!0}),Mr=(N,i)=>()=>(i||(i={exports:{}},N(i.exports,i)),i.exports),Kh=(N,i)=>{ng(N);for(var ke in i)pf(N,ke,{get:i[ke],enumerable:!0})},ag=Mr(()=>{}),ig=Mr(()=>{}),Pp=Mr(()=>{}),ml=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,a){n.__proto__=a}||function(n,a){for(var c in a)a.hasOwnProperty(c)&&(n[c]=a[c])},i(t,e)};function ke(t,e){i(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function O(t,e,n,a){return new(n||(n=Promise))(function(c,d){function y(C){try{_(a.next(C))}catch(D){d(D)}}function v(C){try{_(a.throw(C))}catch(D){d(D)}}function _(C){C.done?c(C.value):new n(function(D){D(C.value)}).then(y,v)}_((a=a.apply(t,e||[])).next())})}function H(t,e){var n={label:0,sent:function(){if(d[0]&1)throw d[1];return d[1]},trys:[],ops:[]},a,c,d,y;return y={next:v(0),throw:v(1),return:v(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function v(C){return function(D){return _([C,D])}}function _(C){if(a)throw new TypeError("Generator is already executing.");for(;n;)try{if(a=1,c&&(d=C[0]&2?c.return:C[0]?c.throw||((d=c.return)&&d.call(c),0):c.next)&&!(d=d.call(c,C[1])).done)return d;(c=0,d)&&(C=[C[0]&2,d.value]);switch(C[0]){case 0:case 1:d=C;break;case 4:return n.label++,{value:C[1],done:!1};case 5:n.label++,c=C[1],C=[0];continue;case 7:C=n.ops.pop(),n.trys.pop();continue;default:if(!(d=n.trys,d=d.length>0&&d[d.length-1])&&(C[0]===6||C[0]===2)){n=0;continue}if(C[0]===3&&(!d||C[1]>d[0]&&C[1]<d[3])){n.label=C[1];break}if(C[0]===6&&n.label<d[1]){n.label=d[1],d=C;break}if(d&&n.label<d[2]){n.label=d[2],n.ops.push(C);break}d[2]&&n.ops.pop(),n.trys.pop();continue}C=e.call(t,n)}catch(D){C=[6,D],c=0}finally{a=d=0}if(C[0]&5)throw C[1];return{value:C[0]?C[1]:void 0,done:!0}}}var se=1e-7,xe=1e-4,Q=function(){function t(e,n){this.backend=e,this.dataMover=n,this.data=new WeakMap,this.dataIdsCount=0}return t.prototype.get=function(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)},t.prototype.set=function(e,n){this.dataIdsCount++,this.data.set(e,n)},t.prototype.has=function(e){return this.data.has(e)},t.prototype.delete=function(e){return this.dataIdsCount--,this.data.delete(e)},t.prototype.numDataIds=function(){return this.dataIdsCount},t}(),Ae=function(){function t(){}return t.prototype.time=function(e){return P("time")},t.prototype.read=function(e){return P("read")},t.prototype.readSync=function(e){return P("readSync")},t.prototype.numDataIds=function(){return P("numDataIds")},t.prototype.disposeData=function(e){return P("disposeData")},t.prototype.write=function(e,n,a){return P("write")},t.prototype.move=function(e,n,a,c){return P("move")},t.prototype.memory=function(){return P("memory")},t.prototype.floatPrecision=function(){return P("floatPrecision")},t.prototype.epsilon=function(){return this.floatPrecision()===32?se:xe},t.prototype.batchMatMul=function(e,n,a,c){return P("batchMatMul")},t.prototype.fusedBatchMatMul=function(e){var n=e.a,a=e.b,c=e.transposeA,d=e.transposeB,y=e.bias,v=e.activation,_=e.preluActivationWeights;return P("fusedBatchMatMul")},t.prototype.slice=function(e,n,a){return P("slice")},t.prototype.stridedSlice=function(e,n,a,c){return P("stridedSlice")},t.prototype.unstack=function(e,n){return P("unstack")},t.prototype.reverse=function(e,n){return P("reverse")},t.prototype.concat=function(e,n){return P("concat")},t.prototype.neg=function(e){return P("neg")},t.prototype.add=function(e,n){return P("add")},t.prototype.addN=function(e){return P("addN")},t.prototype.subtract=function(e,n){return P("subtract")},t.prototype.multiply=function(e,n){return P("multiply")},t.prototype.realDivide=function(e,n){return P("realDivide")},t.prototype.floorDiv=function(e,n){return P("floorDiv")},t.prototype.sum=function(e,n){return P("sum")},t.prototype.prod=function(e,n){return P("prod")},t.prototype.unsortedSegmentSum=function(e,n,a){return P("unsortedSegmentSum")},t.prototype.argMin=function(e,n){return P("argMin")},t.prototype.argMax=function(e,n){return P("argMax")},t.prototype.equal=function(e,n){return P("equal")},t.prototype.notEqual=function(e,n){return P("notEqual")},t.prototype.less=function(e,n){return P("less")},t.prototype.lessEqual=function(e,n){return P("lessEqual")},t.prototype.greater=function(e,n){return P("greater")},t.prototype.greaterEqual=function(e,n){return P("greaterEqual")},t.prototype.logicalNot=function(e){return P("logicalNot")},t.prototype.logicalAnd=function(e,n){return P("logicalAnd")},t.prototype.logicalOr=function(e,n){return P("logicalOr")},t.prototype.where=function(e){return P("where")},t.prototype.select=function(e,n,a){return P("select")},t.prototype.topk=function(e,n,a){return P("topk")},t.prototype.min=function(e,n){return P("min")},t.prototype.minimum=function(e,n){return P("minimum")},t.prototype.mod=function(e,n){return P("mod")},t.prototype.max=function(e,n){return P("max")},t.prototype.maximum=function(e,n){return P("maximum")},t.prototype.all=function(e,n){return P("all")},t.prototype.any=function(e,n){return P("any")},t.prototype.squaredDifference=function(e,n){return P("squaredDifference")},t.prototype.ceil=function(e){return P("ceil")},t.prototype.floor=function(e){return P("floor")},t.prototype.round=function(e){return P("round")},t.prototype.sign=function(e){return P("sign")},t.prototype.isNaN=function(e){return P("isNaN")},t.prototype.isInf=function(e){return P("isInf")},t.prototype.isFinite=function(e){return P("isFinite")},t.prototype.pow=function(e,n){return P("pow")},t.prototype.exp=function(e){return P("exp")},t.prototype.expm1=function(e){return P("expm1")},t.prototype.softmax=function(e,n){return P("softmax")},t.prototype.log=function(e){return P("log")},t.prototype.log1p=function(e){return P("log1p")},t.prototype.sqrt=function(e){return P("sqrt")},t.prototype.rsqrt=function(e){return P("rsqrt")},t.prototype.square=function(e){return P("square")},t.prototype.reciprocal=function(e){return P("reciprocal")},t.prototype.relu=function(e){return P("relu")},t.prototype.relu6=function(e){return P("relu6")},t.prototype.prelu=function(e,n){return P("prelu")},t.prototype.elu=function(e){return P("elu")},t.prototype.eluDer=function(e,n){return P("eluDer")},t.prototype.selu=function(e){return P("selu")},t.prototype.int=function(e){return P("int")},t.prototype.clip=function(e,n,a){return P("clip")},t.prototype.abs=function(e){return P("abs")},t.prototype.complexAbs=function(e){return P("complexAbs")},t.prototype.sigmoid=function(e){return P("sigmoid")},t.prototype.softplus=function(e){return P("softplus")},t.prototype.sin=function(e){return P("sin")},t.prototype.cos=function(e){return P("cos")},t.prototype.tan=function(e){return P("tan")},t.prototype.asin=function(e){return P("asin")},t.prototype.acos=function(e){return P("acos")},t.prototype.atan=function(e){return P("atan")},t.prototype.atan2=function(e,n){return P("atan2")},t.prototype.sinh=function(e){return P("sinh")},t.prototype.cosh=function(e){return P("cosh")},t.prototype.tanh=function(e){return P("tanh")},t.prototype.asinh=function(e){return P("asinh")},t.prototype.acosh=function(e){return P("acosh")},t.prototype.atanh=function(e){return P("atanh")},t.prototype.erf=function(e){return P("erf")},t.prototype.step=function(e,n){return P("step")},t.prototype.fusedConv2d=function(e){var n=e.input,a=e.filter,c=e.convInfo,d=e.bias,y=e.activation,v=e.preluActivationWeights;return P("fusedConv2d")},t.prototype.conv2d=function(e,n,a){return P("conv2d")},t.prototype.conv2dDerInput=function(e,n,a){return P("conv2dDerInput")},t.prototype.conv2dDerFilter=function(e,n,a){return P("conv2dDerFilter")},t.prototype.fusedDepthwiseConv2D=function(e){var n=e.input,a=e.filter,c=e.convInfo,d=e.bias,y=e.activation,v=e.preluActivationWeights;return P("fusedDepthwiseConv2D")},t.prototype.depthwiseConv2D=function(e,n,a){return P("depthwiseConv2D")},t.prototype.depthwiseConv2DDerInput=function(e,n,a){return P("depthwiseConv2DDerInput")},t.prototype.depthwiseConv2DDerFilter=function(e,n,a){return P("depthwiseConv2DDerFilter")},t.prototype.conv3d=function(e,n,a){return P("conv3d")},t.prototype.conv3dDerInput=function(e,n,a){return P("conv3dDerInput")},t.prototype.conv3dDerFilter=function(e,n,a){return P("conv3dDerFilter")},t.prototype.maxPool=function(e,n){return P("maxPool")},t.prototype.maxPoolBackprop=function(e,n,a,c){return P("maxPoolBackprop")},t.prototype.avgPool=function(e,n){return P("avgPool")},t.prototype.avgPoolBackprop=function(e,n,a){return P("avgPoolBackprop")},t.prototype.avgPool3d=function(e,n){return P("avgPool3d")},t.prototype.avgPool3dBackprop=function(e,n,a){return P("avgPool3dBackprop")},t.prototype.maxPool3d=function(e,n){return P("maxPool3d")},t.prototype.maxPool3dBackprop=function(e,n,a,c){return P("maxPool3dBackprop")},t.prototype.reshape=function(e,n){return P("reshape")},t.prototype.cast=function(e,n){return P("cast")},t.prototype.tile=function(e,n){return P("tile")},t.prototype.pad=function(e,n,a){return P("pad")},t.prototype.transpose=function(e,n){return P("transpose")},t.prototype.gather=function(e,n,a){return P("gather")},t.prototype.gatherND=function(e,n){return P("gatherND")},t.prototype.scatterND=function(e,n,a){return P("scatterND")},t.prototype.batchToSpaceND=function(e,n,a){return P("batchToSpaceND")},t.prototype.spaceToBatchND=function(e,n,a){return P("spaceToBatchND")},t.prototype.resizeBilinear=function(e,n,a,c){return P("resizeBilinear")},t.prototype.resizeBilinearBackprop=function(e,n,a){return P("resizeBilinearBackprop")},t.prototype.resizeNearestNeighbor=function(e,n,a,c){return P("resizeNearestNeighbor")},t.prototype.resizeNearestNeighborBackprop=function(e,n,a){return P("resizeNearestNeighborBackprop")},t.prototype.batchNorm=function(e,n,a,c,d,y){return P("batchNorm")},t.prototype.localResponseNormalization4D=function(e,n,a,c,d){return P("localResponseNormalization4D")},t.prototype.LRNGrad=function(e,n,a,c,d,y,v){return P("LRNGrad")},t.prototype.multinomial=function(e,n,a,c){return P("multinomial")},t.prototype.oneHot=function(e,n,a,c){return P("oneHot")},t.prototype.cumsum=function(e,n,a,c){return P("cumsum")},t.prototype.nonMaxSuppression=function(e,n,a,c,d){return P("nonMaxSuppression")},t.prototype.fft=function(e){return P("fft")},t.prototype.ifft=function(e){return P("ifft")},t.prototype.complex=function(e,n){return P("complex")},t.prototype.real=function(e){return P("real")},t.prototype.imag=function(e){return P("imag")},t.prototype.cropAndResize=function(e,n,a,c,d,y){return P("cropAndResize")},t.prototype.depthToSpace=function(e,n,a){return P("depthToSpace")},t.prototype.split=function(e,n,a){return P("split")},t.prototype.sparseToDense=function(e,n,a,c){return P("sparseToDense")},t.prototype.diag=function(e){return P("diag")},t.prototype.fill=function(e,n,a){return P("fill")},t.prototype.onesLike=function(e){return P("onesLike")},t.prototype.zerosLike=function(e){return P("zerosLike")},t.prototype.linspace=function(e,n,a){return P("linspace")},t.prototype.dispose=function(){return P("dispose")},t}();function P(t){throw new Error("'"+t+"' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen")}function he(t){for(var e=t.length,n=0,a=0;e>0;)a=Math.random()*e|0,e--,n=t[e],t[e]=t[a],t[a]=n}function me(t,e,n){return Math.max(t,Math.min(e,n))}function ae(t){return t%2===0?t:t+1}function w(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return e}function ge(t,e){var n=Math.random();return e*n+(1-n)*t}function ze(t,e){for(var n=0,a=0;a<t.length;a++){var c=Number(t[a])-Number(e[a]);n+=c*c}return n}function W(t,e){if(!t)throw new Error(typeof e=="string"?e:e())}function nt(t,e,n){n===void 0&&(n=""),W(it(t,e),function(){return n+(" Shapes "+t+" and "+e+" must match")})}function tt(t){W(t!=null,function(){return"The input to the tensor constructor must be a non-null value."})}function nr(t,e,n){if(e===void 0&&(e=[]),n===void 0&&(n=!1),e==null&&(e=[]),Array.isArray(t)||Tn(t)&&!n)for(var a=0;a<t.length;++a)nr(t[a],e,n);else e.push(t);return e}function Tt(t){if(t.length===0)return 1;for(var e=t[0],n=1;n<t.length;n++)e*=t[n];return e}function Qe(t){return t.length===0}function it(t,e){if(t===e)return!0;if(t==null||e==null)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function xt(t){return t%1===0}function ot(t){if(Math.tanh!=null)return Math.tanh(t);if(t===Infinity)return 1;if(t===-Infinity)return-1;var e=Math.exp(2*t);return(e-1)/(e+1)}function ht(t){var e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}function ut(t){for(var e=new Uint32Array(t),n=0;n<t;++n)e[n]=n;return he(e),e}function yt(t,e){return e<=t.length?t:t+" ".repeat(e-t.length)}function Zt(t,e,n){return e===void 0&&(e=function(a){return 0}),new Promise(function(a,c){var d=0,y=function(){if(t()){a();return}d++;var v=e(d);if(n!=null&&d>=n){c();return}setTimeout(y,v)};y()})}function ar(t,e){for(var n=1,a=-1,c=0;c<t.length;++c)if(t[c]>=0)n*=t[c];else if(t[c]===-1){if(a!==-1)throw Error("Shapes can only have 1 implicit size. "+("Found -1 at dim "+a+" and dim "+c));a=c}else if(t[c]<0)throw Error("Shapes can not be < 0. Found "+t[c]+" at dim "+c);if(a===-1){if(e>0&&e!==n)throw Error("Size("+e+") must match the product of shape "+t);return t}if(n===0)throw Error("Cannot infer the missing size in ["+t+"] when there are 0 elements");if(e%n!==0)throw Error("The implicit shape can't be a fractional number. "+("Got "+e+" / "+n));var d=t.slice();return d[a]=e/n,d}function qt(t,e){var n=e.length;return t=t==null?e.map(function(a,c){return c}):[].concat(t),W(t.every(function(a){return a>=-n&&a<n}),function(){return"All values in axis param must be in range [-"+n+", "+n+") but "+("got axis "+t)}),W(t.every(function(a){return xt(a)}),function(){return"All values in axis param must be integers but "+("got axis "+t)}),t.map(function(a){return a<0?n+a:a})}function Ur(t,e){for(var n=[],a=[],c=e!=null&&Array.isArray(e)&&e.length===0,d=e==null||c?null:qt(e,t).sort(),y=0,v=0;v<t.length;++v){if(d!=null){if(d[y]===v&&t[v]!==1)throw new Error("Can't squeeze axis "+v+" since its dim '"+t[v]+"' is not 1");(d[y]==null||d[y]>v)&&t[v]===1&&(n.push(t[v]),a.push(v)),d[y]<=v&&y++}t[v]!==1&&(n.push(t[v]),a.push(v))}return{newShape:n,keptDims:a}}function jr(t,e){var n=null;if(t==null||t==="float32")n=new Float32Array(e);else if(t==="int32")n=new Int32Array(e);else if(t==="bool")n=new Uint8Array(e);else throw new Error("Unknown data type "+t);return n}function _r(t,e){var n=null;if(t==null||t==="float32")n=new Float32Array(e);else if(t==="int32")n=new Int32Array(e);else if(t==="bool")n=new Uint8Array(e);else if(t==="string")n=new Array(e);else throw new Error("Unknown data type "+t);return n}function tr(t,e){for(var n=0;n<t.length;n++){var a=t[n];if(isNaN(a)||!isFinite(a))throw Error("A tensor of type "+e+" being uploaded contains "+a+".")}}function Fa(t){return t==="bool"||t==="complex64"||t==="float32"||t==="int32"||t==="string"}function Oa(t,e){return e==="complex64"||e==="float32"&&t!=="complex64"||e==="int32"&&t!=="float32"&&t!=="complex64"?!1:!(e==="bool"&&t==="bool")}function Tn(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array}function Wa(t){if(t==="float32"||t==="int32")return 4;if(t==="complex64")return 8;if(t==="bool")return 1;throw new Error("Unknown dtype "+t)}function Na(t){if(t==null)return 0;var e=0;return t.forEach(function(n){return e+=n.length}),e}function yn(t){return typeof t=="string"||t instanceof String}function Ma(t){return typeof t=="boolean"}function li(t){return typeof t=="number"}function hi(t){return Array.isArray(t)?hi(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":li(t)?"float32":yn(t)?"string":Ma(t)?"bool":"float32"}function la(t){return!!(t&&t.constructor&&t.call&&t.apply)}function rn(t,e){for(var n=e;n<t;++n)if(t%n===0)return n;return t}function Ca(t){var e=t.length;if(e<2)return[];var n=new Array(e-1);n[e-2]=t[e-1];for(var a=e-3;a>=0;--a)n[a]=n[a+1]*t[a+1];return n}function xn(t,e,n){var a=new Array;if(e.length===1)for(var c=e[0],d=0;d<c;d++)a[d]=n[t+d];else for(var c=e[0],y=e.slice(1),v=y.reduce(function(D,B){return D*B}),d=0;d<c;d++)a[d]=xn(t+d*v,y,n);return a}function Hn(t,e){if(t.length===0)return e[0];var n=t.reduce(function(a,c){return a*c});if(n===0)return[];if(n!==e.length)throw new Error("["+t+"] does not match the input size "+e.length+".");return xn(0,t,e)}function _i(t,e){for(var n=ha(t,e),a=0;a<n.length;a++)n[a]=1;return n}function ha(t,e){if(e==null||e==="float32"||e==="complex64")return new Float32Array(t);if(e==="int32")return new Int32Array(t);if(e==="bool")return new Uint8Array(t);throw new Error("Unknown data type "+e)}function Ei(t,e){var n=t.reduce(function(a,c){return a*c},1);if(e==null||e==="float32")return Hn(t,new Float32Array(n));if(e==="int32")return Hn(t,new Int32Array(n));if(e==="bool")return Hn(t,new Uint8Array(n));throw new Error("Unknown data type "+e)}function Gn(t){t.forEach(function(e){W(Number.isInteger(e)&&e>=0,function(){return"Tensor must have a shape comprised of positive integers but got "+("shape ["+t+"].")})})}function jn(t,e,n){if(e===0)return 0;if(e===1)return t[0];for(var a=t[t.length-1],c=0;c<t.length-1;++c)a+=n[c]*t[c];return a}function Ua(t,e,n){if(e===0)return[];if(e===1)return[t];for(var a=new Array(e),c=0;c<a.length-1;++c)a[c]=Math.floor(t/n[c]),t-=a[c]*n[c];return a[a.length-1]=t,a}function ga(t){return t&&t.then&&typeof t.then=="function"}var wi="tfjsflags",Ta=function(){function t(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags()}return t.prototype.setPlatform=function(e,n){this.platform!=null&&console.warn("Platform "+this.platformName+" has already been set. "+("Overwriting the platform with "+n+".")),this.platformName=e,this.platform=n},t.prototype.registerFlag=function(e,n,a){if(this.flagRegistry[e]={evaluationFn:n,setHook:a},this.urlFlags[e]!=null){var c=this.urlFlags[e];console.warn("Setting feature override from URL "+e+": "+c+"."),this.set(e,c)}},t.prototype.getAsync=function(e){return O(this,void 0,void 0,function(){var n,a;return H(this,function(c){switch(c.label){case 0:return e in this.flags?[2,this.flags[e]]:(n=this.flags,a=e,[4,this.evaluateFlag(e)]);case 1:return n[a]=c.sent(),[2,this.flags[e]]}})})},t.prototype.get=function(e){if(e in this.flags)return this.flags[e];var n=this.evaluateFlag(e);if(ga(n))throw new Error("Flag "+e+" cannot be synchronously evaluated. Please use getAsync() instead.");return this.flags[e]=n,this.flags[e]},t.prototype.getNumber=function(e){return this.get(e)},t.prototype.getBool=function(e){return this.get(e)},t.prototype.getFlags=function(){return this.flags},Object.defineProperty(t.prototype,"features",{get:function(){return this.flags},enumerable:!0,configurable:!0}),t.prototype.set=function(e,n){if(this.flagRegistry[e]==null)throw new Error("Cannot set flag "+e+" as it has not been registered.");this.flags[e]=n,this.flagRegistry[e].setHook!=null&&this.flagRegistry[e].setHook(n)},t.prototype.evaluateFlag=function(e){if(this.flagRegistry[e]==null)throw new Error("Cannot evaluate flag '"+e+"': no evaluation function found.");return this.flagRegistry[e].evaluationFn()},t.prototype.setFlags=function(e){this.flags=Object.assign({},e)},t.prototype.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags()},t.prototype.populateURLFlags=function(){var e=this;if(typeof this.global=="undefined"||typeof this.global.location=="undefined"||typeof this.global.location.search=="undefined")return;var n=on(this.global.location.search);if(wi in n){var a=n[wi].split(",");a.forEach(function(c){var d=c.split(":"),y=d[0],v=d[1];e.urlFlags[y]=xa(y,v)})}},t}();function on(t){var e={};return t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,function(n){for(var a=[],c=1;c<arguments.length;c++)a[c-1]=arguments[c];return _n(e,a[0],a[1]),a.join("=")}),e}function _n(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}function xa(t,e){if(e=e.toLowerCase(),e==="true"||e==="false")return e==="true";if(""+ +e===e)return+e;throw new Error("Could not parse value flag value "+e+" for flag "+t+".")}function Rr(){return N.ENV}N.ENV=null;function ti(t){N.ENV=t}var _a;function Ri(){if(_a==null){var t=void 0;if(typeof window!="undefined")t=window;else if(typeof global!="undefined")t=global;else if(typeof process!="undefined")t=process;else if(typeof self!="undefined")t=self;else throw new Error("Could not find a global object");_a=t}return _a}function Hi(){var t=Ri();return t._tfGlobals==null&&(t._tfGlobals=new Map),t._tfGlobals}function Ai(t,e){var n=Hi();if(n.has(t))return n.get(t);var a=e();return n.set(t,a),n.get(t)}var qn="Abs",ri="Acos",pi="Acosh",pa="Add",di="AddN",fi="All",Va="Any",ln="ArgMax",ni="ArgMin",gr="Asin",Di="Asinh",bi="Atan",ro="Atanh",Zn="Atan2",Gi="AvgPool",Fi="AvgPoolBackprop",ji="AvgPool3D",Oi="AvgPool3DBackprop",da="BatchMatMul",Mi="BatchToSpaceND",pe="BroadcastTo",X="Cast",j="Ceil",re="ClipByValue",te="Complex",Ue="Concat",kt="Conv2D",$e="Conv2DBackpropFilter",Le="Conv2DBackpropInput",Ye="Conv3D",Ft="Conv3DBackpropFilterV2",St="Conv3DBackpropInputV2",Mt="Cos",dr="Cosh",ir="Cumsum",ta="CropAndResize",fa="DepthToSpace",ra="DepthwiseConv2dNative",Ha="DepthwiseConv2dNativeBackpropFilter",ki="DepthwiseConv2dNativeBackpropInput",sn="Diag",hn="Dilation2D",na="Dilation2DBackpropInput",Jr="Dilation2DBackpropFilter",Vr="Div",Jn="Elu",tn="EluGrad",Rn="Erf",Kn="Equal",aa="Exp",ma="Expm1",Li="FFT",Ea="Fill",S="FlipLeftRight",x="Floor",k="FloorDiv",K="FusedBatchNorm",Se="GatherV2",we="GatherNd",Je="Greater",Be="GreaterEqual",vt="Identity",ft="IFFT",zt="Imag",Wt="IsFinite",Gt="IsInf",Qt="IsNan",wr="Less",Ar="LessEqual",Yt="LinSpace",xr="Log",Sn="Log1p",pn="LogicalAnd",zn="LogicalNot",Fr="LogicalOr",wa="LogSoftmax",In="LRN",ur="LRNBackprop",$r="Max",Ra="Maximum",mi="MaxPool",Ga="MaxPoolBackprop",ja="MaxPool3D",ai="MaxPool3DBackprop",zi="MaxPoolWithArgmax",An="Mean",ba="Min",qi="Minimum",yi="MirrorPad",ii="Mod",qr="Multiply",Io="Negate",nn="NotEqual",qa="NonMaxSuppressionV3",La="NonMaxSuppressionV4",Ki="NonMaxSuppressionV5",oi="OnesLike",Pi="OneHot",no="PadV2",mo="Pool",Ka="Pow",ao="Prelu",Ko="Prod",No="Range",Co="Real",io="Reciprocal",ia="Relu",Pr="Reshape",oa="ResizeNearestNeighbor",Xa="ResizeNearestNeighborGrad",Qn="ResizeBilinear",oo="ResizeBilinearGrad",ka="Relu6",vn="Reverse",Bi="Round",yo="Rsqrt",vo="ScatterNd",Aa="SelectV2",go="Selu",To="Slice",Rs="Sin",Eo="Sinh",As="Sign",Ds="Sigmoid",Xo="Softplus",Ro="Sqrt",Yo="Sum",Ao="SpaceToBatchND",Qo="SplitV",vi="Softmax",Fs="SquaredDifference",tu="Square",ps="Sub",ru="SparseToDense",Os="StridedSlice",ds="Tan",Ms="Tanh",Ls="Tile",nu="TopK",fs="Transpose",au="Unique",ms="Unpack",Do="UnsortedSegmentSum",zs="ZerosLike",Zo="Step",xo="FromPixels",ys="RotateWithOffset",Fo="_FusedMatMul",Ps="FusedConv2D",Jo="FusedDepthwiseConv2D",_o=Ai("kernelRegistry",function(){return new Map}),wo=Ai("gradRegistry",function(){return new Map});function Bs(t,e){var n=Mo(t,e);return _o.get(n)}function Ws(t){return wo.get(t)}function vs(t){for(var e=_o.entries(),n=[];;){var a=e.next(),c=a.done,d=a.value;if(c)break;var y=d[0],v=d[1],_=y.split("_")[0];_===t&&n.push(v)}return n}function $o(t){var e=t.kernelName,n=t.backendName,a=Mo(e,n);_o.has(a)&&console.warn("The kernel '"+e+"' for backend "+("'"+n+"' is already registered")),_o.set(a,t)}function iu(t){var e=t.kernelName;wo.has(e)&&Rr().getBool("DEBUG")&&console.warn("Overriding the gradient for '"+e+"'"),wo.set(e,t)}function ku(t,e){var n=Mo(t,e);if(!_o.has(n))throw new Error("The kernel '"+t+"' for backend "+("'"+e+"' is not registered"));_o.delete(n)}function ou(t){if(!wo.has(t))throw new Error("The gradient '"+t+"' for backend is not registered");wo.delete(t)}function Oo(t,e){var n=vs(t);n.forEach(function(a){var c=Object.assign({},a,{backendName:e});$o(c)})}function Mo(t,e){return e+"_"+t}function gs(t,e){return e==="string"?Xi(t):Si([t],e)}function es(t,e){return t instanceof Float32Array&&e==="float32"||t instanceof Int32Array&&e==="int32"||t instanceof Uint8Array&&e==="bool"}function Si(t,e){if(e==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=nr(t)),Rr().getBool("DEBUG")&&tr(t,e),es(t,e))return t;if(e==null||e==="float32"||e==="complex64")return new Float32Array(t);if(e==="int32")return new Int32Array(t);if(e==="bool"){for(var n=new Uint8Array(t.length),a=0;a<n.length;++a)Math.round(t[a])!==0&&(n[a]=1);return n}else throw new Error("Unknown data type "+e)}function Lo(){return Rr().platform.now()}function zo(t,e){return Rr().platform.fetch(t,e)}function Xi(t,e){return e===void 0&&(e="utf-8"),e=e||"utf-8",Rr().platform.encode(t,e)}function ts(t,e){return e===void 0&&(e="utf-8"),e=e||"utf-8",Rr().platform.decode(t,e)}var ne={__proto__:null,createScalarValue:gs,toTypedArray:Si,now:Lo,fetch:zo,encodeString:Xi,decodeString:ts,shuffle:he,clamp:me,nearestLargerEven:ae,sum:w,randUniform:ge,distSquared:ze,assert:W,assertShapesMatch:nt,assertNonNull:tt,flatten:nr,sizeFromShape:Tt,isScalarShape:Qe,arraysEqual:it,isInt:xt,tanh:ot,sizeToSquarishShape:ht,createShuffledIndices:ut,rightPad:yt,repeatedTry:Zt,inferFromImplicitShape:ar,parseAxisParam:qt,squeezeShape:Ur,getTypedArrayFromDType:jr,getArrayFromDType:_r,checkConversionForErrors:tr,isValidDtype:Fa,hasEncodingLoss:Oa,isTypedArray:Tn,bytesPerElement:Wa,bytesFromStringArray:Na,isString:yn,isBoolean:Ma,isNumber:li,inferDtype:hi,isFunction:la,nearestDivisor:rn,computeStrides:Ca,toNestedArray:Hn,makeOnesTypedArray:_i,makeZerosTypedArray:ha,makeZerosNestedTypedArray:Ei,assertNonNegativeIntegerDimensions:Gn,locToIndex:jn,indexToLoc:Ua,isPromise:ga},ue=function(){function t(e,n){this.backendTimer=e,this.logger=n,n==null&&(this.logger=new F)}return t.prototype.profileKernel=function(e,n,a){for(var c,d=function(){c=a()},y=this.backendTimer.time(d),v=function(D){var B=c[D];B.data().then(function(U){E(U,B.dtype,e)})},_=0;_<c.length;_++)v(_);var C={kernelName:e,outputs:c,inputs:n,timeMs:y.then(function(D){return D.kernelMs}),extraInfo:y.then(function(D){return D.getExtraProfileInfo!=null?D.getExtraProfileInfo():""})};return C},t.prototype.logKernelProfile=function(e){var n=this,a=e.kernelName,c=e.outputs,d=e.timeMs,y=e.inputs,v=e.extraInfo;c.forEach(function(_){Promise.all([_.data(),d,v]).then(function(C){n.logger.logKernelProfile(a,_,C[0],C[1],y,C[2])})})},t}();function E(t,e,n){if(e!=="float32")return!1;for(var a=0;a<t.length;a++){var c=t[a];if(isNaN(c)||!isFinite(c))return console.warn("Found "+c+" in the result of '"+n+"'"),!0}return!1}var F=function(){function t(){}return t.prototype.logKernelProfile=function(e,n,a,c,d,y){var v=typeof c=="number"?yt(c+"ms",9):c.error,_=yt(e,25),C=n.rank,D=n.size,B=yt(n.shape.toString(),14),U="";for(var J in d){var fe=d[J];if(fe!=null){var Pe=fe.shape||n.shape,Me=Pe.length;U+=J+": "+Me+"D "+(Me>0?Pe:"")+" "}}console.log("%c"+_+" %c"+v+" %c"+C+"D "+B+" %c"+D+" %c"+U+" %c"+y,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")},t}();function A(t,e,n){for(var a={},c={},d=0;d<e.length;d++)a[e[d].id]=!0;for(var d=0;d<t.length;d++){var y=t[d],v=y.inputs;for(var _ in v){for(var C=v[_],D=!1,B=0;B<e.length;B++)if(a[C.id]){y.outputs.forEach(function(It){return a[It.id]=!0}),D=!0,c[y.id]=!0;break}if(D)break}}var U={};U[n.id]=!0;for(var J={},d=t.length-1;d>=0;d--)for(var y=t[d],v=y.inputs,B=0;B<y.outputs.length;B++)if(U[y.outputs[B].id]){for(var _ in v)U[v[_].id]=!0,J[y.id]=!0;break}for(var fe=[],d=0;d<t.length;d++){var y=t[d];if(c[y.id]&&J[y.id]){var Pe={};for(var _ in y.inputs){var Me=y.inputs[_];a[Me.id]&&(Pe[_]=Me)}var He=Object.assign({},y);He.inputs=Pe,He.outputs=y.outputs,fe.push(He)}}return fe}function V(t,e,n,a){for(var c=function(y){var v=e[y],_=[];if(v.outputs.forEach(function(U){var J=t[U.id];J!=null?_.push(J):_.push(null)}),v.gradient==null)throw new Error("Cannot compute gradient: gradient function not found "+("for "+v.kernelName+"."));var C=v.gradient(_),D=function(U){if(!(U in C))throw new Error("Cannot backprop through input "+U+". "+("Available gradients found: "+Object.keys(C)+"."));var J=n(function(){return C[U]()});if(J.dtype!=="float32")throw new Error("Error in gradient for op "+v.kernelName+". The gradient of input "+(U+" must have 'float32' dtype, but has '"+J.dtype+"'"));var fe=v.inputs[U];if(!it(J.shape,fe.shape))throw new Error("Error in gradient for op "+v.kernelName+". The gradient of input "+("'"+U+"' has shape '"+J.shape+"', which does not match ")+("the shape of the input '"+fe.shape+"'"));if(t[fe.id]==null)t[fe.id]=J;else{var Pe=t[fe.id];t[fe.id]=a(Pe,J),Pe.dispose()}};for(var B in v.inputs)D(B)},d=e.length-1;d>=0;d--)c(d)}var oe=20,ee=3,_e=7;function ce(t,e,n,a){var c=Ca(e),d=de(t,e,n,c),y=e.length,v=Re(t,e,n,c,d),_=["Tensor"];return a&&(_.push(" dtype: "+n),_.push(" rank: "+y),_.push(" shape: ["+e+"]"),_.push(" values:")),_.push(v.map(function(C){return" "+C}).join(`
`)),_.join(`
`)}function de(t,e,n,a){var c=Tt(e),d=a[a.length-1],y=new Array(d).fill(0),v=e.length,_=n==="complex64"?Oe(t):t;if(v>1)for(var C=0;C<c/d;C++)for(var D=C*d,B=0;B<d;B++)y[B]=Math.max(y[B],ye(_[D+B],0,n).length);return y}function ye(t,e,n){var a;return Array.isArray(t)?a=parseFloat(t[0].toFixed(_e))+" + "+(parseFloat(t[1].toFixed(_e))+"j"):yn(t)?a="'"+t+"'":n==="bool"?a=ve(t):a=parseFloat(t.toFixed(_e)).toString(),yt(a,e)}function ve(t){return t===0?"false":"true"}function Re(t,e,n,a,c,d){d===void 0&&(d=!0);var y=n==="complex64"?2:1,v=e[0],_=e.length;if(_===0){if(n==="complex64"){var C=Oe(t);return[ye(C[0],0,n)]}return n==="bool"?[ve(t[0])]:[t[0].toString()]}if(_===1){if(v>oe){var D=ee*y,B=Array.from(t.slice(0,D)),U=Array.from(t.slice((v-ee)*y,v*y));return n==="complex64"&&(B=Oe(B),U=Oe(U)),["["+B.map(function(er,mr){return ye(er,c[mr],n)}).join(", ")+", ..., "+U.map(function(er,mr){return ye(er,c[v-ee+mr],n)}).join(", ")+"]"]}var J=n==="complex64"?Oe(t):Array.from(t);return["["+J.map(function(er,mr){return ye(er,c[mr],n)}).join(", ")+"]"]}var fe=e.slice(1),Pe=a.slice(1),Me=a[0]*y,He=[];if(v>oe){for(var ct=0;ct<ee;ct++){var It=ct*Me,Ct=It+Me;He.push.apply(He,Re(t.slice(It,Ct),fe,n,Pe,c,!1))}He.push("...");for(var ct=v-ee;ct<v;ct++){var It=ct*Me,Ct=It+Me;He.push.apply(He,Re(t.slice(It,Ct),fe,n,Pe,c,ct===v-1))}}else for(var ct=0;ct<v;ct++){var It=ct*Me,Ct=It+Me;He.push.apply(He,Re(t.slice(It,Ct),fe,n,Pe,c,ct===v-1))}var Bt=_===2?",":"";He[0]="["+He[0]+Bt;for(var ct=1;ct<He.length-1;ct++)He[ct]=" "+He[ct]+Bt;for(var sr=`,
`,ct=2;ct<_;ct++)sr+=`
`;return He[He.length-1]=" "+He[He.length-1]+"]"+(d?"":sr),He}function Oe(t){for(var e=[],n=0;n<t.length;n+=2)e.push([t[n],t[n+1]]);return e}var Fe=function(){function t(e,n,a){var c=this;if(this.dtype=n,this.shape=e.slice(),this.size=Tt(e),a!=null){var d=a.length;W(d===this.size,function(){return"Length of values '"+d+"' does not match the size "+("inferred by the shape '"+c.size+"'.")})}if(n==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=a||_r(n,this.size),this.strides=Ca(e)}return t.prototype.set=function(e){for(var n=this,a=[],c=1;c<arguments.length;c++)a[c-1]=arguments[c];a.length===0&&(a=[0]),W(a.length===this.rank,function(){return"The number of provided coordinates ("+a.length+") must "+("match the rank ("+n.rank+")")});var d=this.locToIndex(a);this.values[d]=e},t.prototype.get=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.length===0&&(e=[0]);for(var a=0,c=0,d=e;c<d.length;c++){var y=d[c];if(y<0||y>=this.shape[a]){var v="Requested out of range element at "+e+". "+(" Buffer shape="+this.shape);throw new Error(v)}a++}for(var _=e[e.length-1],C=0;C<e.length-1;++C)_+=this.strides[C]*e[C];return this.values[_]},t.prototype.locToIndex=function(e){if(this.rank===0)return 0;if(this.rank===1)return e[0];for(var n=e[e.length-1],a=0;a<e.length-1;++a)n+=this.strides[a]*e[a];return n},t.prototype.indexToLoc=function(e){if(this.rank===0)return[];if(this.rank===1)return[e];for(var n=new Array(this.shape.length),a=0;a<n.length-1;++a)n[a]=Math.floor(e/this.strides[a]),e-=n[a]*this.strides[a];return n[n.length-1]=e,n},Object.defineProperty(t.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),t.prototype.toTensor=function(){return Ve().makeTensor(this.values,this.shape,this.dtype)},t}(),Ve=null,Xe=null;function rt(t){Ve=t}function at(t){Xe=t}var $=function(){function t(e,n,a,c){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=n||"float32",this.size=Tt(e),this.strides=Ca(e),this.dataId=a,this.id=c,this.rankType=this.rank<5?this.rank.toString():"higher"}return Object.defineProperty(t.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),t.prototype.buffer=function(){return O(this,void 0,void 0,function(){var e;return H(this,function(n){switch(n.label){case 0:return[4,this.data()];case 1:return e=n.sent(),[2,Xe.buffer(this.shape,this.dtype,e)]}})})},t.prototype.bufferSync=function(){return Xe.buffer(this.shape,this.dtype,this.dataSync())},t.prototype.array=function(){return O(this,void 0,void 0,function(){var e;return H(this,function(n){switch(n.label){case 0:return[4,this.data()];case 1:return e=n.sent(),[2,Hn(this.shape,e)]}})})},t.prototype.arraySync=function(){return Hn(this.shape,this.dataSync())},t.prototype.data=function(){return O(this,void 0,void 0,function(){var e,n;return H(this,function(a){switch(a.label){case 0:return this.throwIfDisposed(),e=Ve().read(this.dataId),this.dtype==="string"?[4,e]:[3,2];case 1:n=a.sent();try{return[2,n.map(function(c){return ts(c)})]}catch(c){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}a.label=2;case 2:return[2,e]}})})},t.prototype.dataSync=function(){this.throwIfDisposed();var e=Ve().readSync(this.dataId);if(this.dtype==="string")try{return e.map(function(n){return ts(n)})}catch(n){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e},t.prototype.bytes=function(){return O(this,void 0,void 0,function(){var e;return H(this,function(n){switch(n.label){case 0:return this.throwIfDisposed(),[4,Ve().read(this.dataId)];case 1:return e=n.sent(),this.dtype==="string"?[2,e]:[2,new Uint8Array(e.buffer)]}})})},t.prototype.dispose=function(){if(this.isDisposed)return;Ve().disposeTensor(this),this.isDisposedInternal=!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this.isDisposedInternal},enumerable:!0,configurable:!0}),t.prototype.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.")},t.prototype.print=function(e){return e===void 0&&(e=!1),Xe.print(this,e)},t.prototype.clone=function(){return this.throwIfDisposed(),Xe.clone(this)},t.prototype.toString=function(e){e===void 0&&(e=!1);var n=this.dataSync();return ce(n,this.shape,this.dtype,e)},t.prototype.cast=function(e){return this.throwIfDisposed(),Xe.cast(this,e)},t.prototype.variable=function(e,n,a){return e===void 0&&(e=!0),this.throwIfDisposed(),Ve().makeVariable(this,e,n,a)},t}();Object.defineProperty($,Symbol.hasInstance,{value:function(t){return!!t&&t.data!=null&&t.dataSync!=null&&t.throwIfDisposed!=null}});var et=function(t){ke(e,t);function e(n,a,c,d){var y=t.call(this,n.shape,n.dtype,n.dataId,d)||this;return y.trainable=a,y.name=c,y}return e.prototype.assign=function(n){if(n.dtype!==this.dtype)throw new Error("dtype of the new value ("+n.dtype+") and "+("previous value ("+this.dtype+") must match"));if(!it(n.shape,this.shape))throw new Error("shape of the new value ("+n.shape+") and "+("previous value ("+this.shape+") must match"));Ve().disposeTensor(this),this.dataId=n.dataId,Ve().incRef(this,null)},e.prototype.dispose=function(){Ve().disposeVariable(this),this.isDisposedInternal=!0},e}($);Object.defineProperty(et,Symbol.hasInstance,{value:function(t){return t instanceof $&&t.assign!=null&&t.assign instanceof Function}}),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"}(N.Rank||(N.Rank={}));var gt;(function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"})(gt||(gt={}));var lt;(function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"})(lt||(lt={}));var _t;(function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"})(_t||(_t={}));var At;(function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"})(At||(At={}));var Lt={float32:_t,int32:gt,bool:lt,complex64:At};function Pt(t,e){if(t==="string"||e==="string"){if(t==="string"&&e==="string")return"string";throw new Error("Can not upcast "+t+" with "+e)}return Lt[t][e]}function Ut(t){return Pt(t,"int32")}function Nt(t,e){if(t.dtype===e.dtype)return[t,e];var n=Pt(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function Kt(t,e){W(t.dtype===e.dtype,function(){return"The dtypes of the first("+t.dtype+") and"+(" second("+e.dtype+") input must match")})}function Ht(t,e){return e.some(function(n){return n.id===t.id})}function Ot(t){var e=[],n=new Set;return Rt(t,e,n),e}function Rt(t,e,n){if(t==null)return;if(t instanceof $){e.push(t);return}if(!wt(t))return;var a=t;for(var c in a){var d=a[c];n.has(d)||(n.add(d),Rt(d,e,n))}}function wt(t){return Array.isArray(t)||typeof t=="object"}var Et={__proto__:null,makeTypesMatch:Nt,assertTypesMatch:Kt,isTensorInList:Ht,getTensorsInContainer:Ot},Vt=function(){function t(){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}}return t.prototype.dispose=function(){for(var e in this.registeredVariables)this.registeredVariables[e].dispose()},t}(),jt=function(){function t(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Vt}return t.prototype.ready=function(){return O(this,void 0,void 0,function(){var e,n,a,c;return H(this,function(d){switch(d.label){case 0:if(this.pendingBackendInit!=null)return[2,this.pendingBackendInit.then(function(){})];if(this.backendInstance!=null)return[2];e=this.getSortedBackends(),n=0,d.label=1;case 1:return n<e.length?(a=e[n],[4,this.initializeBackend(a).success]):[3,5];case 2:return c=d.sent(),c?[4,this.setBackend(a)]:[3,4];case 3:return d.sent(),[2];case 4:return n++,[3,1];case 5:throw new Error("Could not initialize any backends, all backend initializations failed.")}})})},Object.defineProperty(t.prototype,"backend",{get:function(){if(this.pendingBackendInit!=null)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(this.backendInstance==null){var e=this.initializeBackendsAndReturnBest(),n=e.name,a=e.asyncInit;if(a)throw new Error("The highest priority backend '"+n+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");this.setBackend(n)}return this.backendInstance},enumerable:!0,configurable:!0}),t.prototype.backendNames=function(){return Object.keys(this.registryFactory)},t.prototype.findBackend=function(e){if(!(e in this.registry))if(e in this.registryFactory){var n=this.initializeBackend(e).asyncInit;if(n)return null}else return null;return this.registry[e]},t.prototype.findBackendFactory=function(e){return e in this.registryFactory?this.registryFactory[e].factory:null},t.prototype.registerBackend=function(e,n,a){return a===void 0&&(a=1),e in this.registryFactory?(console.warn(e+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[e]={factory:n,priority:a},!0)},t.prototype.setBackend=function(e){return O(this,void 0,void 0,function(){var n,a,c,d,y;return H(this,function(v){switch(v.label){case 0:if(this.registryFactory[e]==null)throw new Error("Backend name '"+e+"' not found in registry");return this.backendName=e,this.registry[e]==null?(this.backendInstance=null,n=this.initializeBackend(e),a=n.success,c=n.asyncInit,c?[4,a]:[3,2]):[3,4];case 1:return y=v.sent(),[3,3];case 2:y=a,v.label=3;case 3:if(d=y,!d)return[2,!1];v.label=4;case 4:return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new ue(this.backendInstance),[2,!0]}})})},t.prototype.setupRegisteredKernels=function(){var e=this,n=vs(this.backendName);n.forEach(function(a){a.setupFunc!=null&&a.setupFunc(e.backendInstance)})},t.prototype.disposeRegisteredKernels=function(e){var n=this,a=vs(e);a.forEach(function(c){c.disposeFunc!=null&&c.disposeFunc(n.registry[e])})},t.prototype.initializeBackend=function(e){var n=this,a=this.registryFactory[e];if(a==null)throw new Error("Cannot initialize backend "+e+", no registration found.");try{var c=a.factory();if(c&&!(c instanceof Ae)&&typeof c.then=="function"){var d=++this.pendingBackendInitId,y=c.then(function(v){return d<n.pendingBackendInitId?!1:(n.registry[e]=v,n.pendingBackendInit=null,!0)}).catch(function(v){return d<n.pendingBackendInitId||(n.pendingBackendInit=null,console.warn("Initialization of backend "+e+" failed"),console.warn(v.stack||v.message)),!1});return this.pendingBackendInit=y,{success:y,asyncInit:!0}}else return this.registry[e]=c,{success:!0,asyncInit:!1}}catch(v){return console.warn("Initialization of backend "+e+" failed"),console.warn(v.stack||v.message),{success:!1,asyncInit:!1}}},t.prototype.removeBackend=function(e){if(!(e in this.registryFactory))throw new Error(e+" backend not found in registry");this.backendName===e&&this.pendingBackendInit!=null&&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)},t.prototype.getSortedBackends=function(){var e=this;if(Object.keys(this.registryFactory).length===0)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(function(n,a){return e.registryFactory[a].priority-e.registryFactory[n].priority})},t.prototype.initializeBackendsAndReturnBest=function(){for(var e=this.getSortedBackends(),n=0;n<e.length;n++){var a=e[n],c=this.initializeBackend(a),d=c.success,y=c.asyncInit;if(y||d)return{name:a,asyncInit:y}}throw new Error("Could not initialize any backends, all backend initializations failed.")},t.prototype.moveData=function(e,n){var a=this.state.tensorInfo.get(n),c=a.backend,d=this.readSync(n);c.disposeData(n),a.backend=e,e.move(n,d,a.shape,a.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++},t.prototype.tidy=function(e,n){var a=this,c=null;if(n==null){if(typeof e!="function")throw new Error("Please provide a function to tidy()");n=e}else{if(typeof e!="string"&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if(typeof n!="function")throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");c=e}var d;return this.scopedRun(function(){return a.startScope(c)},function(){return a.endScope(d)},function(){return d=n(),d instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),d})},t.prototype.scopedRun=function(e,n,a){e();try{var c=a();return n(),c}catch(d){throw n(),d}},t.prototype.nextTensorId=function(){return t.nextTensorId++},t.prototype.nextVariableId=function(){return t.nextVariableId++},t.prototype.clone=function(e){var n=this.makeTensorFromDataId(e.dataId,e.shape,e.dtype),a={x:e},c=function(y){return{x:function(){var v="float32",_={x:y},C={dtype:v};return Ie.runKernelFunc(function(D){return D.cast(y,v)},_,null,X,C)}}},d=[];return this.addTapeNode(this.state.activeScope.name,a,[n],c,d,{}),n},t.prototype.runKernel=function(e,n,a,c,d){var y=null,v=null;return this.runKernelFunc(y,n,v,e,a,c,d)},t.prototype.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST")},t.prototype.checkKernelForMemLeak=function(e,n,a){var c=this.backend.numDataIds(),d=0;a.forEach(function(_){d+=_.dtype==="complex64"?3:1});var y=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],v=c-n-d-y;if(v>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak "+("("+v+" data ids) after running '"+e+"'"))},t.prototype.runKernelFunc=function(e,n,a,c,d,y,v){var _=this,C,D=[],B=this.isTapeOn();c==null&&(c=this.state.activeScope!=null?this.state.activeScope.name:"");var U=this.state.numBytes,J=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var fe,Pe=Bs(c,this.backendName),Me;if(Pe!=null)fe=function(){var It=_.backend.numDataIds();Me=Pe.kernelFunc({inputs:n,attrs:d,backend:_.backend});var Ct=Array.isArray(Me)?Me:[Me];_.shouldCheckForMemLeaks()&&_.checkKernelForMemLeak(c,It,Ct);var Bt=Ct.map(function(mr){var Gr=mr.dataId,en=mr.shape,Qr=mr.dtype;return _.makeTensorFromDataId(Gr,en,Qr)});if(B){var sr=_.getTensorsForGradient(c,n,Bt);if(sr==null){v==null&&(v=[]);var er=Bt.filter(function(mr,Gr){return v[Gr]});sr=(y||[]).slice().concat(er)}D=_.saveTensorsForBackwardMode(sr)}return Bt};else{var He=function(It){if(!B)return;D=It.map(function(Ct){return _.keep(_.clone(Ct))})};fe=function(){var It=_.backend.numDataIds();Me=_.tidy(function(){return e(_.backend,He)});var Ct=Array.isArray(Me)?Me:[Me];return _.shouldCheckForMemLeaks()&&_.checkKernelForMemLeak(c,It,Ct),Ct}}var ct;return this.scopedRun(function(){return _.state.kernelDepth++},function(){return _.state.kernelDepth--},function(){!_.ENV.getBool("DEBUG")&&!_.state.profiling?C=fe():(ct=_.profiler.profileKernel(c,n,function(){return fe()}),_.ENV.getBool("DEBUG")&&_.profiler.logKernelProfile(ct),C=ct.outputs)}),B&&this.addTapeNode(c,n,C,a,D,d),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-U,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-J,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(n).map(function(It){return n[It]!=null?n[It].shape:null}),outputShapes:C.map(function(It){return It.shape}),kernelTimeMs:ct.timeMs,extraInfo:ct.extraInfo}),Array.isArray(Me)?C:C[0]},t.prototype.saveTensorsForBackwardMode=function(e){var n=this,a=e.map(function(c){return n.keep(n.clone(c))});return a},t.prototype.getTensorsForGradient=function(e,n,a){var c=Ws(e);if(c!=null){var d=c.inputsToSave||[],y=c.outputsToSave||[],v=void 0;c.saveAllInputs?(W(Array.isArray(n),function(){return"saveAllInputs is true, expected inputs to be an array."}),v=Object.keys(n).map(function(C){return n[C]})):v=d.map(function(C){return n[C]});var _=a.filter(function(C,D){return y[D]});return v.concat(_)}return null},t.prototype.makeTensor=function(e,n,a,c){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");a=a||"float32",c=c||this.backend;var d=e;a==="string"&&yn(e[0])&&(d=e.map(function(D){return Xi(D)}));var y=c.write(d,n,a),v=new $(n,a,y,this.nextTensorId());if(this.incRef(v,c),a==="string"){var _=this.state.tensorInfo.get(y),C=Na(d);this.state.numBytes+=C-_.bytes,_.bytes=C}return v},t.prototype.makeTensorFromDataId=function(e,n,a,c){a=a||"float32";var d=new $(n,a,e,this.nextTensorId());return this.incRef(d,c),d},t.prototype.makeVariable=function(e,n,a,c){n===void 0&&(n=!0),a=a||this.nextVariableId().toString(),c!=null&&c!==e.dtype&&(e=e.cast(c));var d=new et(e,n,a,this.nextTensorId());if(this.state.registeredVariables[d.name]!=null)throw new Error("Variable with name "+d.name+" was already registered");return this.state.registeredVariables[d.name]=d,this.incRef(d,this.backend),d},t.prototype.incRef=function(e,n){var a=this.state.tensorInfo.has(e.dataId)?this.state.tensorInfo.get(e.dataId).refCount:0;if(this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++,a===0){this.state.numDataBuffers++;var c=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(c=e.size*Wa(e.dtype)),this.state.tensorInfo.set(e.dataId,{backend:n||this.backend,dtype:e.dtype,shape:e.shape,bytes:c,refCount:0}),this.state.numBytes+=c}this.state.tensorInfo.get(e.dataId).refCount++,e instanceof et||this.track(e)},t.prototype.disposeTensor=function(e){if(!this.state.tensorInfo.has(e.dataId))return;this.state.numTensors--,e.dtype==="string"&&this.state.numStringTensors--;var n=this.state.tensorInfo.get(e.dataId),a=n.refCount;a<=1?(e.dtype!=="complex64"&&(this.state.numBytes-=n.bytes),this.state.numDataBuffers--,n.backend.disposeData(e.dataId),this.state.tensorInfo.delete(e.dataId)):this.state.tensorInfo.get(e.dataId).refCount--},t.prototype.disposeVariables=function(){for(var e in this.state.registeredVariables){var n=this.state.registeredVariables[e];this.disposeVariable(n)}},t.prototype.disposeVariable=function(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&delete this.state.registeredVariables[e.name]},t.prototype.memory=function(){var 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,e.reasons==null&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e},t.prototype.profile=function(e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C;return H(this,function(D){switch(D.label){case 0:return this.state.profiling=!0,n=this.state.numBytes,a=this.state.numTensors,this.state.activeProfile.kernels=[],c=this.state.activeProfile,[4,e()];case 1:c.result=D.sent(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map(function(B){return B.totalBytesSnapshot})),this.state.activeProfile.newBytes=this.state.numBytes-n,this.state.activeProfile.newTensors=this.state.numTensors-a,d=0,y=this.state.activeProfile.kernels,D.label=2;case 2:return d<y.length?(v=y[d],_=v,[4,v.kernelTimeMs]):[3,6];case 3:return _.kernelTimeMs=D.sent(),C=v,[4,v.extraInfo];case 4:C.extraInfo=D.sent(),D.label=5;case 5:return d++,[3,2];case 6:return[2,this.state.activeProfile]}})})},t.prototype.isTapeOn=function(){return this.state.gradientDepth>0&&this.state.kernelDepth===0},t.prototype.addTapeNode=function(e,n,a,c,d,y){var v=this,_={id:this.state.nextTapeNodeId++,kernelName:e,inputs:n,outputs:a,saved:d},C=Ws(e);C!=null&&(c=C.gradFunc),c!=null&&(_.gradient=function(D){return D=D.map(function(B,U){if(B==null){var J=a[U],fe=ha(J.size,J.dtype);return v.makeTensor(fe,J.shape,J.dtype)}return B}),c(D.length>1?D:D[0],d,y)}),this.state.activeTape.push(_)},t.prototype.keep=function(e){return e.kept=!0,e},t.prototype.startTape=function(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++},t.prototype.endTape=function(){this.state.gradientDepth--},t.prototype.startScope=function(e){var n={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(n.name=e),this.state.scopeStack.push(n),this.state.activeScope=n},t.prototype.endScope=function(e){for(var n=this,a=Ot(e),c=new Set(a.map(function(_){return _.id})),d=0;d<this.state.activeScope.track.length;d++){var y=this.state.activeScope.track[d];!y.kept&&!c.has(y.id)&&y.dispose()}var v=this.state.scopeStack.pop();this.state.activeScope=this.state.scopeStack.length===0?null:this.state.scopeStack[this.state.scopeStack.length-1],a.forEach(function(_){!_.kept&&_.scopeId===v.id&&n.track(_)})},t.prototype.gradients=function(e,n,a,c){var d=this;if(c===void 0&&(c=!1),W(n.length>0,function(){return"gradients() received an empty list of xs."}),a!=null&&a.dtype!=="float32")throw new Error("dy must have 'float32' dtype, but has '"+a.dtype+"'");var y=this.scopedRun(function(){return d.startTape()},function(){return d.endTape()},function(){return d.tidy("forward",e)});W(y instanceof $,function(){return"The result y returned by f() must be a tensor."});var v=A(this.state.activeTape,n,y);if(!c&&v.length===0&&n.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",function(){var _={};_[y.id]=a??cr(y.shape),V(_,v,function(D){return d.tidy(D)},br);var C=n.map(function(D){return _[D.id]});return d.state.gradientDepth===0&&(d.state.activeTape.forEach(function(D){for(var B=0,U=D.saved;B<U.length;B++){var J=U[B];J.dispose()}}),d.state.activeTape=null),{value:y,grads:C}})},t.prototype.customGrad=function(e){var n=this;return W(la(e),function(){return"The f passed in customGrad(f) must be a function."}),function(){for(var a=[],c=0;c<arguments.length;c++)a[c]=arguments[c];W(a.every(function(v){return v instanceof $}),function(){return"The args passed in customGrad(f)(x1, x2,...) must all be tensors"});var d,y={};return a.forEach(function(v,_){y[_]=v}),n.runKernelFunc(function(v,_){return d=e.apply(void 0,a.concat([_])),W(d.value instanceof $,function(){return"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"}),W(la(d.gradFunc),function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."}),d.value},y,function(v,_){var C=d.gradFunc(v,_),D=Array.isArray(C)?C:[C];W(D.length===a.length,function(){return"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(...)."}),W(D.every(function(U){return U instanceof $}),function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."});var B={};return D.forEach(function(U,J){B[J]=function(){return U}}),B})}},t.prototype.readSync=function(e){var n=this.state.tensorInfo.get(e);return n.backend.readSync(e)},t.prototype.read=function(e){var n=this.state.tensorInfo.get(e);return n.backend.read(e)},t.prototype.time=function(e){return O(this,void 0,void 0,function(){var n,a;return H(this,function(c){switch(c.label){case 0:return n=Lo(),[4,this.backend.time(e)];case 1:return a=c.sent(),a.wallMs=Lo()-n,[2,a]}})})},t.prototype.track=function(e){return this.state.activeScope!=null&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e},Object.defineProperty(t.prototype,"registeredVariables",{get:function(){return this.state.registeredVariables},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new Vt;for(var e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null},t.nextTensorId=0,t.nextVariableId=0,t}();function cr(t){var e=_i(Tt(t),"float32");return Ie.makeTensor(e,t,"float32")}function rr(){var t=Ri();if(t._tfengine==null){var e=new Ta(t);t._tfengine=new jt(e)}return ti(t._tfengine.ENV),rt(function(){return t._tfengine}),t._tfengine}var Ie=rr();function br(t,e){var n={a:t,b:e};return Ie.runKernelFunc(function(a,c){var d=a.add(t,e);return c([t,e]),d},n,null,pa)}function Nr(){return typeof navigator!="undefined"&&navigator!=null}function Tr(){if(Nr()){var t=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function hr(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Dr={__proto__:null,isMobile:Tr,isBrowser:hr},fr=Rr();fr.registerFlag("DEBUG",function(){return!1},function(t){t&&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.")}),fr.registerFlag("IS_BROWSER",function(){return hr()}),fr.registerFlag("IS_NODE",function(){return typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined"}),fr.registerFlag("IS_CHROME",function(){return typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}),fr.registerFlag("PROD",function(){return!1}),fr.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",function(){return fr.getBool("DEBUG")}),fr.registerFlag("DEPRECATION_WARNINGS_ENABLED",function(){return!0}),fr.registerFlag("IS_TEST",function(){return!1});function Er(t,e){var n=t;if(Tn(t))return e==="string"?[]:[t.length];if(!Array.isArray(t))return[];for(var a=[];Array.isArray(n)||Tn(n)&&e!=="string";)a.push(n.length),n=n[0];return Array.isArray(t)&&Rr().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&an(t,a,[]),a}function an(t,e,n){if(n=n||[],!Array.isArray(t)&&!Tn(t)){W(e.length===0,function(){return"Element arr["+n.join("][")+"] is a primitive, "+("but should be an array/TypedArray of "+e[0]+" elements")});return}W(e.length>0,function(){return"Element arr["+n.join("][")+"] should be a primitive, "+("but is an array of "+t.length+" elements")}),W(t.length===e[0],function(){return"Element arr["+n.join("][")+"] should have "+e[0]+" "+("elements, but has "+t.length+" elements")});for(var a=e.slice(1),c=0;c<t.length;++c)an(t[c],a,n.concat(c))}function wn(t,e,n,a){if(t==null)return;if(t!=="numeric"&&t!==e||t==="numeric"&&e==="string")throw new Error("Argument '"+n+"' passed to '"+a+"' must "+("be "+t+" tensor, but got "+e+" tensor"))}function ie(t,e,n,a){if(a===void 0&&(a="numeric"),t instanceof $)return wn(a,t.dtype,e,n),t;var c=hi(t);if(c!=="string"&&["bool","int32","float32"].indexOf(a)>=0&&(c=a),wn(a,c,e,n),t==null||!Tn(t)&&!Array.isArray(t)&&typeof t!="number"&&typeof t!="boolean"&&typeof t!="string"){var d=t==null?"null":t.constructor.name;throw new Error("Argument '"+e+"' passed to '"+n+"' must be a "+("Tensor or TensorLike, but got '"+d+"'"))}var y=Er(t,c);!Tn(t)&&!Array.isArray(t)&&(t=[t]);var v=!0,_=c!=="string"?Si(t,c):nr(t,[],v);return Ie.makeTensor(_,y,c)}function Nn(t,e,n,a){if(a===void 0&&(a="numeric"),!Array.isArray(t))throw new Error("Argument "+e+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");var c=t;return c.map(function(d,y){return ie(d,e+"["+y+"]",n)},a)}var bn="__op";function Ee(t){var e=Object.keys(t);if(e.length!==1)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+(e.length+" keys."));var n=e[0],a=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+bn;var c=function(){for(var d=[],y=0;y<arguments.length;y++)d[y]=arguments[y];Ie.startScope(n);try{var v=a.apply(void 0,d);return ga(v)&&console.error("Cannot return a Promise inside of tidy."),Ie.endScope(v),v}catch(_){throw Ie.endScope(null),_}};return Object.defineProperty(c,"name",{value:n,configurable:!0}),c}function Bn(t,e){var n=ie(t,"real","complex"),a=ie(e,"imag","complex");nt(n.shape,a.shape,"real and imag shapes, "+n.shape+" and "+a.shape+", must match in call to tf.complex().");var c=function(y){return y.complex(n,a)},d={real:n,imag:a};return Ie.runKernelFunc(c,d,null,te)}var Pn=Ee({complex_:Bn});function Da(t,e,n,a){if(a==null&&(a=hi(t)),a==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Tn(t)&&!Array.isArray(t)&&typeof t!="number"&&typeof t!="boolean"&&typeof t!="string")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(e!=null){Gn(e);var c=Tt(e),d=Tt(n);W(c===d,function(){return"Based on the provided shape, ["+e+"], the tensor should have "+(c+" values but has "+d)});for(var y=0;y<n.length;++y){var v=n[y],_=y===n.length-1?v!==Tt(e.slice(y)):!0;W(n[y]===e[y]||!_,function(){return"Error creating a new Tensor. Inferred shape "+("("+n+") does not match the provided ")+("shape ("+e+"). ")})}}return!Tn(t)&&!Array.isArray(t)&&(t=[t]),e=e||n,t=a!=="string"?Si(t,a):nr(t,[],!0),Ie.makeTensor(t,e,a)}function Dn(t,e,n){var a=Er(t,n);return Da(t,e,a,n)}var Ya={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},za=4;function Qa(t,e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_=this;return H(this,function(C){switch(C.label){case 0:for(n=[],a=[],c=Array.isArray(t)?t.map(function(D){return D.name}):Object.keys(t),d=function(D){var B=c[D],U=Array.isArray(t)?t[D].tensor:t[B];if(U.dtype!=="float32"&&U.dtype!=="int32"&&U.dtype!=="bool"&&U.dtype!=="string"&&U.dtype!=="complex64")throw new Error("Unsupported dtype in weight '"+B+"': "+U.dtype);var J={name:B,shape:U.shape,dtype:U.dtype};if(U.dtype==="string"){var fe=new Promise(function(Pe){return O(_,void 0,void 0,function(){var Me,He,ct,It,Ct,Bt,sr;return H(this,function(er){switch(er.label){case 0:return[4,U.bytes()];case 1:for(Me=er.sent(),He=Me.reduce(function(mr,Gr){return mr+Gr.length},0)+za*Me.length,ct=new Uint8Array(He),It=0,Ct=0;Ct<Me.length;Ct++)Bt=Me[Ct],sr=new Uint8Array(new Uint32Array([Bt.length]).buffer),ct.set(sr,It),It+=za,ct.set(Bt,It),It+=Bt.length;return Pe(ct),[2]}})})});a.push(fe)}else a.push(U.data());e!=null&&(J.group=e),n.push(J)},y=0;y<c.length;++y)d(y);return[4,Promise.all(a)];case 1:return v=C.sent(),[2,{data:va(v),specs:n}]}})})}function ya(t,e){for(var n={},a,c=0,d=0,y=e;d<y.length;d++){var v=y[d],_=v.name,C=v.dtype,D=v.shape,B=Tt(D),U=void 0;if("quantization"in v){var J=v.quantization;if(J.dtype==="uint8"||J.dtype==="uint16"){if(!("min"in J&&"scale"in J))throw new Error("Weight "+v.name+" with quantization "+J.dtype+" doesn't have corresponding metadata min and scale.")}else if(J.dtype==="float16"){if(C!=="float32")throw new Error("Weight "+v.name+" is quantized with "+J.dtype+" "+("which only supports weights of type float32 not "+C+"."))}else throw new Error("Weight "+v.name+" has unknown "+("quantization dtype "+J.dtype+". ")+"Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.");var fe=Ya[J.dtype],Pe=t.slice(c,c+B*fe),Me=J.dtype==="uint8"?new Uint8Array(Pe):new Uint16Array(Pe);if(C==="float32")if(J.dtype==="uint8"||J.dtype==="uint16"){U=new Float32Array(Me.length);for(var He=0;He<Me.length;He++){var ct=Me[He];U[He]=ct*J.scale+J.min}}else if(J.dtype==="float16")a===void 0&&(a=cc()),U=a(Me);else throw new Error("Unsupported quantization type "+J.dtype+" for weight type float32.");else if(C==="int32"){if(J.dtype!=="uint8"&&J.dtype!=="uint16")throw new Error("Unsupported quantization type "+J.dtype+" for weight type int32.");U=new Int32Array(Me.length);for(var He=0;He<Me.length;He++){var ct=Me[He];U[He]=Math.round(ct*J.scale+J.min)}}else throw new Error("Unsupported dtype in weight '"+_+"': "+C);c+=B*fe}else if(C==="string"){var It=Tt(v.shape);U=[];for(var He=0;He<It;He++){var Ct=new Uint32Array(t.slice(c,c+za))[0];c+=za;var Bt=new Uint8Array(t.slice(c,c+Ct));U.push(Bt),c+=Ct}}else{var sr=Ya[C],Pe=t.slice(c,c+B*sr);if(C==="float32")U=new Float32Array(Pe);else if(C==="int32")U=new Int32Array(Pe);else if(C==="bool")U=new Uint8Array(Pe);else if(C==="complex64"){U=new Float32Array(Pe);for(var er=new Float32Array(U.length/2),mr=new Float32Array(U.length/2),He=0;He<er.length;He++)er[He]=U[He*2],mr[He]=U[He*2+1];var Gr=Dn(er,D,"float32"),en=Dn(mr,D,"float32");n[_]=Pn(Gr,en),Gr.dispose(),en.dispose()}else throw new Error("Unsupported dtype in weight '"+_+"': "+C);c+=B*sr}C!=="complex64"&&(n[_]=Dn(U,D,C))}return n}function va(t){if(t===null)throw new Error("Invalid input value: "+JSON.stringify(t));var e=0,n=[];t.forEach(function(d){if(e+=d.byteLength,n.push(d.byteLength===d.buffer.byteLength?d:new d.constructor(d)),!(d instanceof Float32Array||d instanceof Int32Array||d instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+d.constructor.name)});var a=new Uint8Array(e),c=0;return n.forEach(function(d){a.set(new Uint8Array(d.buffer),c),c+=d.byteLength}),a.buffer}var Yi=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function Wi(t){return Yi?Buffer.byteLength(t):new Blob([t]).size}function Or(t){if(Yi)return Buffer.from(t).toString("base64");for(var e=new Uint8Array(t),n="",a=0,c=e.length;a<c;a++)n+=String.fromCharCode(e[a]);return btoa(n)}function Za(t){if(Yi){var e=Buffer.from(t,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}for(var n=atob(t),a=new Uint8Array(n.length),c=0;c<n.length;++c)a.set([n.charCodeAt(c)],c);return a.buffer}function rs(t){if(t.length===1)return t[0];var e=0;t.forEach(function(c){e+=c.byteLength});var n=new Uint8Array(e),a=0;return t.forEach(function(c){n.set(new Uint8Array(c),a),a+=c.byteLength}),n.buffer}function Po(t){var e="/";for(t=t.trim();t.endsWith(e);)t=t.slice(0,t.length-1);var n=t.split(e);return n[n.length-1]}function dn(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:t.modelTopology==null?0:Wi(JSON.stringify(t.modelTopology)),weightSpecsBytes:t.weightSpecs==null?0:Wi(JSON.stringify(t.weightSpecs)),weightDataBytes:t.weightData==null?0:t.weightData.byteLength}}function Bo(){var t=function(a){for(var c=a<<13,d=0;(c&8388608)===0;)d-=8388608,c<<=1;return c&=~8388608,d+=947912704,c|d},e=new Uint32Array(2048);e[0]=0;for(var n=1;n<1024;n++)e[n]=t(n);for(var n=1024;n<2048;n++)e[n]=939524096+(n-1024<<13);return e}function Fn(){var t=new Uint32Array(64);t[0]=0,t[31]=1199570944,t[32]=2147483648,t[63]=3347054592;for(var e=1;e<31;e++)t[e]=e<<23;for(var e=33;e<63;e++)t[e]=2147483648+(e-32<<23);return t}function su(){for(var t=new Uint32Array(64),e=0;e<64;e++)t[e]=1024;return t[0]=t[32]=0,t}function cc(){var t=Bo(),e=Fn(),n=su();return function(a){for(var c=new ArrayBuffer(4*a.length),d=new Uint32Array(c),y=0;y<a.length;y++){var v=a[y],_=t[n[v>>10]+(v&1023)]+e[v>>10];d[y]=_}return new Float32Array(c)}}var si=function(){function t(){this.saveRouters=[],this.loadRouters=[]}return t.getInstance=function(){return t.instance==null&&(t.instance=new t),t.instance},t.registerSaveRouter=function(e){t.getInstance().saveRouters.push(e)},t.registerLoadRouter=function(e){t.getInstance().loadRouters.push(e)},t.getSaveHandlers=function(e){return t.getHandlers(e,"save")},t.getLoadHandlers=function(e,n){return t.getHandlers(e,"load",n)},t.getHandlers=function(e,n,a){var c=[],d=n==="load"?t.getInstance().loadRouters:t.getInstance().saveRouters;return d.forEach(function(y){var v=y(e,a);v!==null&&c.push(v)}),c},t}(),Su=function(t){return si.registerSaveRouter(t)},Iu=function(t){return si.registerLoadRouter(t)},lc=function(t){return si.getSaveHandlers(t)},xs=function(t,e){return si.getLoadHandlers(t,e)},Ii="tensorflowjs",_s=1,bo="models_store",so="model_info_store";function Nu(){if(!Rr().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var t=typeof window=="undefined"?self:window,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(e==null)throw new Error("The current browser does not appear to support IndexedDB.");return e}function uu(t){var e=t.result;e.createObjectStore(bo,{keyPath:"modelPath"}),e.createObjectStore(so,{keyPath:"modelPath"})}var ws=function(){function t(e){if(this.indexedDB=Nu(),e==null||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}return t.prototype.save=function(e){return O(this,void 0,void 0,function(){return H(this,function(n){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return[2,this.databaseAction(this.modelPath,e)]})})},t.prototype.load=function(){return O(this,void 0,void 0,function(){return H(this,function(e){return[2,this.databaseAction(this.modelPath)]})})},t.prototype.databaseAction=function(e,n){var a=this;return new Promise(function(c,d){var y=a.indexedDB.open(Ii,_s);y.onupgradeneeded=function(){return uu(y)},y.onsuccess=function(){var v=y.result;if(n==null){var _=v.transaction(bo,"readonly"),C=_.objectStore(bo),D=C.get(a.modelPath);D.onsuccess=function(){if(D.result==null)return v.close(),d(new Error("Cannot find model with path '"+a.modelPath+"' in IndexedDB."));c(D.result.modelArtifacts)},D.onerror=function(Me){return v.close(),d(D.error)},_.oncomplete=function(){return v.close()}}else{var B=dn(n),U=v.transaction(so,"readwrite"),J=U.objectStore(so),fe=J.put({modelPath:a.modelPath,modelArtifactsInfo:B}),Pe;fe.onsuccess=function(){Pe=v.transaction(bo,"readwrite");var Me=Pe.objectStore(bo),He=Me.put({modelPath:a.modelPath,modelArtifacts:n,modelArtifactsInfo:B});He.onsuccess=function(){return c({modelArtifactsInfo:B})},He.onerror=function(ct){J=U.objectStore(so);var It=J.delete(a.modelPath);It.onsuccess=function(){return v.close(),d(He.error)},It.onerror=function(Ct){return v.close(),d(He.error)}}},fe.onerror=function(Me){return v.close(),d(fe.error)},U.oncomplete=function(){Pe==null?v.close():Pe.oncomplete=function(){return v.close()}}}},y.onerror=function(v){return d(y.error)}})},t.URL_SCHEME="indexeddb://",t}(),Cu=function(t){return Rr().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(ws.URL_SCHEME)?cu(t.slice(ws.URL_SCHEME.length)):null};si.registerSaveRouter(Cu),si.registerLoadRouter(Cu);function cu(t){return new ws(t)}function Tu(t){return t.startsWith(ws.URL_SCHEME)?t.slice(ws.URL_SCHEME.length):t}var hc=function(){function t(){this.indexedDB=Nu()}return t.prototype.listModels=function(){return O(this,void 0,void 0,function(){var e=this;return H(this,function(n){return[2,new Promise(function(a,c){var d=e.indexedDB.open(Ii,_s);d.onupgradeneeded=function(){return uu(d)},d.onsuccess=function(){var y=d.result,v=y.transaction(so,"readonly"),_=v.objectStore(so),C=_.getAll();C.onsuccess=function(){for(var D={},B=0,U=C.result;B<U.length;B++){var J=U[B];D[J.modelPath]=J.modelArtifactsInfo}a(D)},C.onerror=function(D){return y.close(),c(C.error)},v.oncomplete=function(){return y.close()}},d.onerror=function(y){return c(d.error)}})]})})},t.prototype.removeModel=function(e){return O(this,void 0,void 0,function(){var n=this;return H(this,function(a){return e=Tu(e),[2,new Promise(function(c,d){var y=n.indexedDB.open(Ii,_s);y.onupgradeneeded=function(){return uu(y)},y.onsuccess=function(){var v=y.result,_=v.transaction(so,"readwrite"),C=_.objectStore(so),D=C.get(e),B;D.onsuccess=function(){if(D.result==null)return v.close(),d(new Error("Cannot find model with path '"+e+"' in IndexedDB."));var U=C.delete(e),J=function(){B=v.transaction(bo,"readwrite");var fe=B.objectStore(bo),Pe=fe.delete(e);Pe.onsuccess=function(){return c(D.result.modelArtifactsInfo)},Pe.onerror=function(Me){return d(D.error)}};U.onsuccess=J,U.onerror=function(fe){return J(),v.close(),d(D.error)}},D.onerror=function(U){return v.close(),d(D.error)},_.oncomplete=function(){B==null?v.close():B.oncomplete=function(){return v.close()}}},y.onerror=function(v){return d(y.error)}})]})})},t}(),uo="/",bs="tensorflowjs_models",Eu="info",pc="model_topology",dc="weight_specs",fc="weight_data",vl="model_metadata";function Ru(t){return{info:[bs,t,Eu].join(uo),topology:[bs,t,pc].join(uo),weightSpecs:[bs,t,dc].join(uo),weightData:[bs,t,fc].join(uo),modelMetadata:[bs,t,vl].join(uo)}}function mc(t){var e=t.split(uo);if(e.length<3)throw new Error("Invalid key format: "+t);return e.slice(1,e.length-1).join(uo)}function yc(t){return t.startsWith(Ni.URL_SCHEME)?t.slice(Ni.URL_SCHEME.length):t}var Ni=function(){function t(e){if(!Rr().getBool("IS_BROWSER")||typeof window=="undefined"||typeof window.localStorage=="undefined")throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,e==null||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=Ru(this.modelPath)}return t.prototype.save=function(e){return O(this,void 0,void 0,function(){var n,a,c;return H(this,function(d){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");n=JSON.stringify(e.modelTopology),a=JSON.stringify(e.weightSpecs),c=dn(e);try{return this.LS.setItem(this.keys.info,JSON.stringify(c)),this.LS.setItem(this.keys.topology,n),this.LS.setItem(this.keys.weightSpecs,a),this.LS.setItem(this.keys.weightData,Or(e.weightData)),this.LS.setItem(this.keys.modelMetadata,JSON.stringify({format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,userDefinedMetadata:e.userDefinedMetadata})),[2,{modelArtifactsInfo:c}]}catch(y){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error("Failed to save model '"+this.modelPath+"' to local storage: size quota being exceeded is a possible cause of this failure: "+("modelTopologyBytes="+c.modelTopologyBytes+", ")+("weightSpecsBytes="+c.weightSpecsBytes+", ")+("weightDataBytes="+c.weightDataBytes+"."))}return[2]})})},t.prototype.load=function(){return O(this,void 0,void 0,function(){var e,n,a,c,d,y,v;return H(this,function(_){if(e=JSON.parse(this.LS.getItem(this.keys.info)),e==null)throw new Error("In local storage, there is no model with name '"+this.modelPath+"'");if(e.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");if(n={},a=JSON.parse(this.LS.getItem(this.keys.topology)),a==null)throw new Error("In local storage, the topology of model '"+this.modelPath+"' is missing.");if(n.modelTopology=a,c=JSON.parse(this.LS.getItem(this.keys.weightSpecs)),c==null)throw new Error("In local storage, the weight specs of model '"+this.modelPath+"' are missing.");if(n.weightSpecs=c,d=this.LS.getItem(this.keys.modelMetadata),d!=null&&(y=JSON.parse(d),n.format=y.format,n.generatedBy=y.generatedBy,n.convertedBy=y.convertedBy,n.userDefinedMetadata=y.userDefinedMetadata),v=this.LS.getItem(this.keys.weightData),v==null)throw new Error("In local storage, the binary weight values of model "+("'"+this.modelPath+"' are missing."));return n.weightData=Za(v),[2,n]})})},t.URL_SCHEME="localstorage://",t}(),ns=function(t){return Rr().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Ni.URL_SCHEME)?ks(t.slice(Ni.URL_SCHEME.length)):null};si.registerSaveRouter(ns),si.registerLoadRouter(ns);function ks(t){return new Ni(t)}var vc=function(){function t(){W(Rr().getBool("IS_BROWSER"),function(){return"Current environment is not a web browser"}),W(typeof window=="undefined"||typeof window.localStorage!="undefined",function(){return"Current browser does not appear to support localStorage"}),this.LS=window.localStorage}return t.prototype.listModels=function(){return O(this,void 0,void 0,function(){var e,n,a,c,d,y;return H(this,function(v){for(e={},n=bs+uo,a=uo+Eu,c=0;c<this.LS.length;++c)d=this.LS.key(c),d.startsWith(n)&&d.endsWith(a)&&(y=mc(d),e[y]=JSON.parse(this.LS.getItem(d)));return[2,e]})})},t.prototype.removeModel=function(e){return O(this,void 0,void 0,function(){var n,a;return H(this,function(c){if(e=yc(e),n=Ru(e),this.LS.getItem(n.info)==null)throw new Error("Cannot find model at path '"+e+"'");return a=JSON.parse(this.LS.getItem(n.info)),this.LS.removeItem(n.info),this.LS.removeItem(n.topology),this.LS.removeItem(n.weightSpecs),this.LS.removeItem(n.weightData),[2,a]})})},t}(),Wo="://",co=function(){function t(){this.managers={}}return t.getInstance=function(){return t.instance==null&&(t.instance=new t),t.instance},t.registerManager=function(e,n){W(e!=null,function(){return"scheme must not be undefined or null."}),e.endsWith(Wo)&&(e=e.slice(0,e.indexOf(Wo))),W(e.length>0,function(){return"scheme must not be an empty string."});var a=t.getInstance();W(a.managers[e]==null,function(){return"A model store manager is already registered for scheme '"+e+"'."}),a.managers[e]=n},t.getManager=function(e){var n=this.getInstance().managers[e];if(n==null)throw new Error("Cannot find model manager for scheme '"+e+"'");return n},t.getSchemes=function(){return Object.keys(this.getInstance().managers)},t}();function Uo(t){if(t.indexOf(Wo)===-1)throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+(""+co.getSchemes().join(",")));return{scheme:t.split(Wo)[0],path:t.split(Wo)[1]}}function lu(t,e,n){return n===void 0&&(n=!1),O(this,void 0,void 0,function(){var a,c,d,y,v,_,C,D,B;return H(this,function(U){switch(U.label){case 0:return W(t!==e,function(){return"Old path and new path are the same: '"+t+"'"}),a=si.getLoadHandlers(t),W(a.length>0,function(){return"Copying failed because no load handler is found for source URL "+t+"."}),W(a.length<2,function(){return"Copying failed because more than one ("+a.length+") "+("load handlers for source URL "+t+".")}),c=a[0],d=si.getSaveHandlers(e),W(d.length>0,function(){return"Copying failed because no save handler is found for destination "+("URL "+e+".")}),W(d.length<2,function(){return"Copying failed because more than one ("+a.length+") "+("save handlers for destination URL "+e+".")}),y=d[0],v=Uo(t).scheme,_=Uo(t).path,C=v===Uo(t).scheme,[4,c.load()];case 1:return D=U.sent(),n&&C?[4,co.getManager(v).removeModel(_)]:[3,3];case 2:U.sent(),U.label=3;case 3:return[4,y.save(D)];case 4:return B=U.sent(),n&&!C?[4,co.getManager(v).removeModel(_)]:[3,6];case 5:U.sent(),U.label=6;case 6:return[2,B.modelArtifactsInfo]}})})}function as(){return O(this,void 0,void 0,function(){var t,e,n,a,c,d,y,v;return H(this,function(_){switch(_.label){case 0:t=co.getSchemes(),e={},n=0,a=t,_.label=1;case 1:return n<a.length?(c=a[n],[4,co.getManager(c).listModels()]):[3,4];case 2:d=_.sent();for(y in d)v=c+Wo+y,e[v]=d[y];_.label=3;case 3:return n++,[3,1];case 4:return[2,e]}})})}function Vo(t){return O(this,void 0,void 0,function(){var e,n;return H(this,function(a){return e=Uo(t),n=co.getManager(e.scheme),[2,n.removeModel(e.path)]})})}function gl(t,e){return O(this,void 0,void 0,function(){var n;return H(this,function(a){return n=!1,[2,lu(t,e,n)]})})}function xl(t,e){return O(this,void 0,void 0,function(){var n;return H(this,function(a){return n=!0,[2,lu(t,e,n)]})})}var Au=function(){function t(){}return t.prototype.fetch=function(e,n){return fetch(e,n)},t.prototype.now=function(){return performance.now()},t.prototype.encode=function(e,n){if(n!=="utf-8"&&n!=="utf8")throw new Error("Browser's encoder only supports utf-8, but got "+n);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)},t.prototype.decode=function(e,n){return new TextDecoder(n).decode(e)},t}();if(Rr().get("IS_BROWSER")){Rr().setPlatform("browser",new Au);try{co.registerManager(Ni.URL_SCHEME,new vc)}catch(t){}try{co.registerManager(ws.URL_SCHEME,new hc)}catch(t){}}var gc={importFetch:function(){return ag()}},Us,xc=function(){function t(){this.util=ig(),this.textEncoder=new this.util.TextEncoder}return t.prototype.fetch=function(e,n){return Rr().global.fetch!=null?Rr().global.fetch(e,n):(Us==null&&(Us=gc.importFetch()),Us(e,n))},t.prototype.now=function(){var e=process.hrtime();return e[0]*1e3+e[1]/1e6},t.prototype.encode=function(e,n){if(n!=="utf-8"&&n!=="utf8")throw new Error("Node built-in encoder only supports utf-8, but got "+n);return this.textEncoder.encode(e)},t.prototype.decode=function(e,n){return e.length===0?"":new this.util.TextDecoder(n).decode(e)},t}();Rr().get("IS_NODE")&&Rr().setPlatform("node",new xc);function Qi(t,e,n){return e===void 0&&(e="float32"),e=e||"float32",Gn(t),new Fe(t,e,n)}function hu(t,e){var n=ie(t,"x","cast");if(!Fa(e))throw new Error("Failed to cast to unknown dtype "+e);if(e==="string"&&n.dtype!=="string"||e!=="string"&&n.dtype==="string")throw new Error("Only strings can be casted to strings");var a={x:n},c={dtype:e};return Ie.runKernelFunc(function(d){return d.cast(n,e)},a,null,X,c)}var pr=Ee({cast_:hu});function Vs(t){var e=ie(t,"x","clone",null),n=function(){return Ie.makeTensorFromDataId(e.dataId,e.shape,e.dtype)},a={x:e};return Ie.runKernelFunc(n,a,null,vt)}var Ho=Ee({clone_:Vs});function Du(t,e){e===void 0&&(e=!1),console.log(t.toString(e))}rr();var _c={buffer:Qi,cast:pr,clone:Ho,print:Du};at(_c);var Fu="model",Go=".json",wc=".weights.bin";function Ou(t){return new Promise(function(e){return setTimeout(e)}).then(t)}var Hs=function(){function t(e){if(!Rr().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(t.URL_SCHEME)&&(e=e.slice(t.URL_SCHEME.length)),(e==null||e.length===0)&&(e=Fu),this.modelTopologyFileName=e+Go,this.weightDataFileName=e+wc}return t.prototype.save=function(e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v;return H(this,function(_){switch(_.label){case 0:if(typeof document=="undefined")throw new Error("Browser downloads are not supported in this environment since `document` is not present");if(n=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"})),!(e.modelTopology instanceof ArrayBuffer))return[3,1];throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");case 1:return a=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],c={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:a},d=window.URL.createObjectURL(new Blob([JSON.stringify(c)],{type:"application/json"})),y=this.jsonAnchor==null?document.createElement("a"):this.jsonAnchor,y.download=this.modelTopologyFileName,y.href=d,[4,Ou(function(){return y.dispatchEvent(new MouseEvent("click"))})];case 2:return _.sent(),e.weightData!=null?(v=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor,v.download=this.weightDataFileName,v.href=n,[4,Ou(function(){return v.dispatchEvent(new MouseEvent("click"))})]):[3,4];case 3:_.sent(),_.label=4;case 4:return[2,{modelArtifactsInfo:dn(e)}]}})})},t.URL_SCHEME="downloads://",t}(),bc=function(){function t(e){if(e==null||e.length<1)throw new Error("When calling browserFiles, at least 1 file is required, "+("but received "+e));this.files=e}return t.prototype.load=function(){return O(this,void 0,void 0,function(){var e,n,a=this;return H(this,function(c){return e=this.files[0],n=this.files.slice(1),[2,new Promise(function(d,y){var v=new FileReader;v.onload=function(_){var C=JSON.parse(_.target.result),D=C.modelTopology;if(D==null){y(new Error("modelTopology field is missing from file "+e.name));return}n.length===0&&d({modelTopology:D});var B=C.weightsManifest;if(B==null){y(new Error("weightManifest field is missing from file "+e.name));return}var U;try{U=a.checkManifestAndWeightFiles(B,n)}catch(Me){y(Me);return}var J=[],fe=[],Pe=[];B.forEach(function(Me){Me.paths.forEach(function(He){fe.push(He),Pe.push(null)}),J.push.apply(J,Me.weights)}),B.forEach(function(Me){Me.paths.forEach(function(He){var ct=new FileReader;ct.onload=function(It){var Ct=It.target.result,Bt=fe.indexOf(He);Pe[Bt]=Ct,Pe.indexOf(null)===-1&&d({modelTopology:D,weightSpecs:J,weightData:rs(Pe),format:C.format,generatedBy:C.generatedBy,convertedBy:C.convertedBy,userDefinedMetadata:C.userDefinedMetadata})},ct.onerror=function(It){return y("Failed to weights data from file of path '"+He+"'.")},ct.readAsArrayBuffer(U[He])})})},v.onerror=function(_){return y("Failed to read model topology and weights manifest JSON "+("from file '"+e.name+"'. BrowserFiles supports loading ")+"Keras-style tf.Model artifacts only.")},v.readAsText(e)})]})})},t.prototype.checkManifestAndWeightFiles=function(e,n){for(var a=[],c=n.map(function(C){return Po(C.name)}),d={},y=0,v=e;y<v.length;y++){var _=v[y];_.paths.forEach(function(C){var D=Po(C);if(a.indexOf(D)!==-1)throw new Error("Duplicate file basename found in weights manifest: "+("'"+D+"'"));if(a.push(D),c.indexOf(D)===-1)throw new Error("Weight file with basename '"+D+"' is not provided.");d[C]=n[c.indexOf(D)]})}if(a.length!==n.length)throw new Error("Mismatch in the number of files in weights manifest "+("("+a.length+") and the number of weight files provided ")+("("+n.length+")."));return d},t}(),lo=function(t){return Rr().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Hs.URL_SCHEME)?kc(t.slice(Hs.URL_SCHEME.length)):null};si.registerSaveRouter(lo);function kc(t){return t===void 0&&(t="model"),new Hs(t)}function ho(t){return new bc(t)}function Sc(t,e,n,a){y(t),n=n??0,a=a??1,v(n,a);var c=0,d=function(_){return _.then(function(C){var D=n+ ++c/t.length*(a-n);return e(D),C}),_};function y(_){W(_!=null&&Array.isArray(_)&&_.length>0,function(){return"promises must be a none empty array"})}function v(_,C){W(_>=0&&_<=1,function(){return"Progress fraction must be in range [0, 1], but "+("got startFraction "+_)}),W(C>=0&&C<=1,function(){return"Progress fraction must be in range [0, 1], but "+("got endFraction "+C)}),W(C>=_,function(){return"startFraction must be no more than endFraction, but "+("got startFraction "+_+" and endFraction ")+(""+C)})}return Promise.all(t.map(d))}function pu(t,e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,D,B,U;return H(this,function(J){switch(J.label){case 0:return e==null&&(e={}),n=e.fetchFunc==null?Rr().platform.fetch:e.fetchFunc,a=t.map(function(fe){return n(fe,e.requestInit,{isBinary:!0})}),c=0,d=.5,e.onProgress==null?[4,Promise.all(a)]:[3,2];case 1:return v=J.sent(),[3,4];case 2:return[4,Sc(a,e.onProgress,c,d)];case 3:v=J.sent(),J.label=4;case 4:return y=v,_=y.map(function(fe){return fe.arrayBuffer()}),C=.5,D=1,e.onProgress==null?[4,Promise.all(_)]:[3,6];case 5:return U=J.sent(),[3,8];case 6:return[4,Sc(_,e.onProgress,C,D)];case 7:U=J.sent(),J.label=8;case 8:return B=U,[2,B]}})})}function Ic(t,e,n,a){return e===void 0&&(e=""),O(this,void 0,void 0,function(){var c,d;return H(this,function(y){return c=function(v){return pu(v,{requestInit:a})},d=Mu(c),[2,d(t,e,n)]})})}function Mu(t){var e=this;return function(n,a,c){return a===void 0&&(a=""),O(e,void 0,void 0,function(){var d,y,v,_,C,D,B,U,J,fe;return H(this,function(Pe){switch(Pe.label){case 0:if(d=n.map(function(){return!1}),y={},v=c!=null?c.map(function(){return!1}):[],_=[],n.forEach(function(Me,He){var ct=0;Me.weights.forEach(function(It){var Ct="quantization"in It?It.quantization.dtype:It.dtype,Bt=Ya[Ct]*Tt(It.shape),sr=function(){d[He]=!0,y[He]==null&&(y[He]=[]),y[He].push({manifestEntry:It,groupOffset:ct,sizeBytes:Bt})};c!=null?c.forEach(function(er,mr){er===It.name&&(sr(),v[mr]=!0)}):sr(),_.push(It.name),ct+=Bt})}),!v.every(function(Me){return Me}))throw C=c.filter(function(Me,He){return!v[He]}),new Error("Could not find weights in manifest with names: "+(C.join(", ")+`.
`)+"Manifest JSON has weights with names: "+(_.join(", ")+"."));return D=d.reduce(function(Me,He,ct){return He&&Me.push(ct),Me},[]),B=[],D.forEach(function(Me){n[Me].paths.forEach(function(He){var ct=a+(a.endsWith("/")?"":"/")+He;B.push(ct)})}),[4,t(B)];case 1:return U=Pe.sent(),J={},fe=0,D.forEach(function(Me){for(var He=n[Me].paths.length,ct=0,It=0;It<He;It++)ct+=U[fe+It].byteLength;for(var Ct=new ArrayBuffer(ct),Bt=new Uint8Array(Ct),sr=0,er=0;er<He;er++){var mr=new Uint8Array(U[fe+er]);Bt.set(mr,sr),sr+=mr.byteLength}var Gr=y[Me];Gr.forEach(function(en){var Qr=Ct.slice(en.groupOffset,en.groupOffset+en.sizeBytes),Zr=ya(Qr,[en.manifestEntry]);for(var Kr in Zr)J[Kr]=Zr[Kr]}),fe+=He}),[2,J]}})})}}var Gs="application/octet-stream",po="application/json",Lu=function(){function t(e,n){if(this.DEFAULT_METHOD="POST",n==null&&(n={}),this.weightPathPrefix=n.weightPathPrefix,this.onProgress=n.onProgress,this.weightUrlConverter=n.weightUrlConverter,n.fetchFunc!=null?(W(typeof n.fetchFunc=="function",function(){return"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"}),this.fetch=n.fetchFunc):this.fetch=Rr().platform.fetch,W(e!=null&&e.length>0,function(){return"URL path for http must not be null, undefined or empty."}),Array.isArray(e)&&W(e.length===2,function(){return"URL paths for http must have a length of 2, "+("(actual length is "+e.length+").")}),this.path=e,n.requestInit!=null&&n.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=n.requestInit||{}}return t.prototype.save=function(e){return O(this,void 0,void 0,function(){var n,a,c,d;return H(this,function(y){switch(y.label){case 0:if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return n=Object.assign({method:this.DEFAULT_METHOD},this.requestInit),n.body=new FormData,a=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],c={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,userDefinedMetadata:e.userDefinedMetadata,weightsManifest:a},n.body.append("model.json",new Blob([JSON.stringify(c)],{type:po}),"model.json"),e.weightData!=null&&n.body.append("model.weights.bin",new Blob([e.weightData],{type:Gs}),"model.weights.bin"),[4,this.fetch(this.path,n)];case 1:if(d=y.sent(),d.ok)return[2,{modelArtifactsInfo:dn(e),responses:[d]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+(d.status+"."))}})})},t.prototype.load=function(){return O(this,void 0,void 0,function(){var e,n,a,c,d,y,v,_,C,D,B,U,J,fe,Pe;return H(this,function(Me){switch(Me.label){case 0:return[4,this.fetch(this.path,this.requestInit)];case 1:if(e=Me.sent(),!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.");Me.label=2;case 2:return Me.trys.push([2,4,,5]),[4,e.json()];case 3:return n=Me.sent(),[3,5];case 4:throw a=Me.sent(),c="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?c+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":c+=" Please make sure the server is serving valid JSON for this request.",new Error(c);case 5:if(d=n.modelTopology,y=n.weightsManifest,v=n.generatedBy,_=n.convertedBy,C=n.format,D=n.userDefinedMetadata,d==null&&y==null)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return y!=null?[4,this.loadWeights(y)]:[3,7];case 6:J=Me.sent(),B=J[0],U=J[1],Me.label=7;case 7:return fe={modelTopology:d,weightSpecs:B,weightData:U,userDefinedMetadata:D,generatedBy:v,convertedBy:_,format:C},Pe=n.modelInitializer,Pe&&(fe.modelInitializer=Pe),[2,fe]}})})},t.prototype.loadWeights=function(e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,D,B,U,J,fe,Pe,Me,He,ct,It,Ct,Bt,sr;return H(this,function(er){switch(er.label){case 0:for(n=Array.isArray(this.path)?this.path[1]:this.path,a=_l(n),c=a[0],d=a[1],y=this.weightPathPrefix||c,v=[],_=0,C=e;_<C.length;_++)D=C[_],v.push.apply(v,D.weights);for(B=[],U=[],J=0,fe=e;J<fe.length;J++)for(Pe=fe[J],Me=0,He=Pe.paths;Me<He.length;Me++)ct=He[Me],this.weightUrlConverter!=null?U.push(this.weightUrlConverter(ct)):B.push(y+ct+d);return this.weightUrlConverter?(Ct=(It=B.push).apply,Bt=[B],[4,Promise.all(U)]):[3,2];case 1:Ct.apply(It,Bt.concat([er.sent()])),er.label=2;case 2:return[4,pu(B,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress})];case 3:return sr=er.sent(),[2,[v,rs(sr)]]}})})},t.URL_SCHEME_REGEX=/^https?:\/\//,t}();function _l(t){var e=t.lastIndexOf("/"),n=t.lastIndexOf("?"),a=t.substring(0,e),c=n>e?t.substring(n):"";return[a+"/",c]}function zu(t){return t.match(Lu.URL_SCHEME_REGEX)!=null}var Pu=function(t,e){if(typeof fetch=="undefined"&&(e==null||e.fetchFunc==null))return null;var n=!0;return Array.isArray(t)?n=t.every(function(a){return zu(a)}):n=zu(t),n?du(t,e):null};si.registerSaveRouter(Pu),si.registerLoadRouter(Pu);function du(t,e){return new Lu(t,e)}function wl(t,e){return du(t,e)}var fu=function(){function t(e){this.modelArtifacts=e}return t.prototype.load=function(){return O(this,void 0,void 0,function(){return H(this,function(e){return[2,this.modelArtifacts]})})},t}(),mu=function(){function t(e){this.saveHandler=e}return t.prototype.save=function(e){return O(this,void 0,void 0,function(){return H(this,function(n){return[2,this.saveHandler(e)]})})},t}();function Nc(t,e,n,a){if(arguments.length===1){var c=t.modelTopology!=null||t.weightSpecs!=null;return c?new fu(t):(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 fu({modelTopology:t}))}else return console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new fu({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:a})}function Cc(t){return new mu(t)}var Tc={__proto__:null,browserFiles:ho,browserHTTPRequest:wl,concatenateArrayBuffers:rs,decodeWeights:ya,encodeWeights:Qa,fromMemory:Nc,getLoadHandlers:xs,getModelArtifactsInfoForJSON:dn,getSaveHandlers:lc,http:du,isHTTPScheme:zu,loadWeights:Ic,registerLoadRouter:Iu,registerSaveRouter:Su,weightsLoaderFactory:Mu,withSaveHandler:Cc,copyModel:gl,listModels:as,moveModel:xl,removeModel:Vo};function Ec(t,e){var n=ie(t,"x","reshape",null),a={x:n},c={shape:e},d=function(y,v){return e=ar(e,n.size),W(n.size===Tt(e),function(){return"new shape and old shape must have the same number of elements."}),v([n]),y.reshape(n,e)};return Ie.runKernelFunc(d,a,null,Pr,c)}var Ke=Ee({reshape_:Ec});function Rc(t,e,n,a){var c;n===void 0&&(n=!1),a===void 0&&(a=!1);var d=ie(t,"a","matMul"),y=ie(e,"b","matMul");c=Nt(d,y),d=c[0],y=c[1];var v=function(D,B){B([d,y]);var U=n?d.shape[d.rank-2]:d.shape[d.rank-1],J=a?y.shape[y.rank-1]:y.shape[y.rank-2],fe=n?d.shape[d.rank-1]:d.shape[d.rank-2],Pe=a?y.shape[y.rank-2]:y.shape[y.rank-1],Me=d.shape.slice(0,-2),He=y.shape.slice(0,-2),ct=Tt(Me),It=Tt(He),Ct=ct===It||ct===1||It===1;W(d.rank>=2&&y.rank>=2&&Ct,function(){return"Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input "+("batch dimensions of ("+Me+") and ("+He+").")}),W(U===J,function(){return"Error in matMul: inner shapes ("+U+") and ("+(J+") of Tensors with shapes "+d.shape+" and ")+(y.shape+" and transposeA="+n)+(" and transposeB="+a+" must match.")});var Bt=ct>It?Me:He,sr=Bt.concat([fe,Pe]),er=n?Ke(d,[ct,U,fe]):Ke(d,[ct,fe,U]),mr=a?Ke(y,[It,Pe,J]):Ke(y,[It,J,Pe]),Gr=D.batchMatMul(er,mr,n,a);return Ke(Gr,sr)},_={a:d,b:y},C={transposeA:n,transposeB:a};return Ie.runKernelFunc(v,_,null,da,C)}var un=Ee({matMul_:Rc});function Ac(t,e,n,a){if(n===void 0&&(n=1),a===void 0&&(a=0),e<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+e);var c=ie(t,"indices","oneHot","int32"),d=c.shape.concat([e]),y=function(C,D){return D([c]),Ke(C.oneHot(Ke(c,[c.size]),e,n,a),d)},v={indices:c},_={depth:e,onValue:n,offValue:a};return Ie.runKernelFunc(y,v,null,Pi,_)}var Ss=Ee({oneHot_:Ac});function Dc(t,e){var n=ie(t,"x","transpose");if(e==null&&(e=n.shape.map(function(d,y){return y}).reverse()),W(n.rank===e.length,function(){return"Error in transpose: rank of input "+n.rank+" "+("must match length of perm "+e+".")}),e.forEach(function(d){W(d>=0&&d<n.rank,function(){return"All entries in 'perm' must be between 0 and "+(n.rank-1)+(" but got "+e)})}),n.rank<=1)return n.clone();var a={x:n},c={perm:e};return Ie.runKernelFunc(function(d){return d.transpose(n,e)},a,null,fs,c)}var $n=Ee({transpose_:Dc});function Fc(t,e,n){var a=ie(t,"labels","confusionMatrix"),c=ie(e,"predictions","confusionMatrix");W(n==null||n>0&&Number.isInteger(n),function(){return"If provided, numClasses must be a positive integer, "+("but got "+n)}),W(a.rank===1,function(){return"Expected the rank of labels to be 1, but got "+a.rank}),W(c.rank===1,function(){return"Expected the rank of predictions to be 1, "+("but got "+c.rank)}),W(a.shape[0]===c.shape[0],function(){return"Mismatch in the number of examples: "+(a.shape[0]+" vs. "+c.shape[0]+". ")+"Labels and predictions should have the same number of elements."}),W(n>0&&Number.isInteger(n),function(){return"numClasses is required to be a positive integer, but got "+(""+n)});var d=Ss(pr(a,"int32"),n),y=Ss(pr(c,"int32"),n),v=$n(d),_=un(v,y);return pr(_,"int32")}var Oc=Ee({confusionMatrix_:Fc}),Mc={__proto__:null,confusionMatrix:Oc};function js(t,e,n){if(tt(t),e!=null&&e.length!==3)throw new Error("tensor3d() requires shape to have three numbers");var a=Er(t,n);if(a.length!==3&&a.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Da(t,e,a,n)}var is;function Lc(t,e){if(e===void 0&&(e=3),e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(t==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,a=!1,c=!1,d=!1,y=!1;if(t.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&t instanceof ImageData)a=!0;else if(typeof HTMLVideoElement!="undefined"&&t instanceof HTMLVideoElement)c=!0;else if(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement)d=!0;else if(t.getContext!=null)y=!0;else 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 "+t.constructor.name));if(c){var v=2;if(c&&t.readyState<v)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.")}var _=Bs(xo,Ie.backendName);if(_!=null){var C={pixels:t},D={numChannels:e};return Ie.runKernel(xo,C,D)}var B=c?[t.videoWidth,t.videoHeight]:[t.width,t.height],U=B[0],J=B[1],fe;y?fe=t.getContext("2d").getImageData(0,0,U,J).data:a||n?fe=t.data:(d||c)&&(is==null&&(is=document.createElement("canvas").getContext("2d")),is.canvas.width=U,is.canvas.height=J,is.drawImage(t,0,0,U,J),fe=is.getImageData(0,0,U,J).data);var Pe;if(e===4)Pe=new Int32Array(fe);else{var Me=U*J;Pe=new Int32Array(Me*e);for(var He=0;He<Me;He++)for(var ct=0;ct<e;++ct)Pe[He*e+ct]=fe[He*4+ct]}var It=[J,U,e];return js(Pe,It,"int32")}function zc(t,e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,D,B,U,J,fe,Pe,Me,He;return H(this,function(ct){switch(ct.label){case 0:if(n=ie(t,"img","toPixels"),t instanceof $||(a=n,n=pr(a,"int32"),a.dispose()),n.rank!==2&&n.rank!==3)throw new Error("toPixels only supports rank 2 or 3 tensors, got rank "+n.rank+".");if(c=n.shape.slice(0,2),d=c[0],y=c[1],v=n.rank===2?1:n.shape[2],v>4||v===2)throw new Error("toPixels only supports depth of size "+("1, 3 or 4 but got "+v));if(n.dtype!=="float32"&&n.dtype!=="int32")throw new Error("Unsupported type for toPixels: "+n.dtype+". Please use float32 or int32 tensors.");return[4,n.data()];case 1:for(_=ct.sent(),C=n.dtype==="float32"?255:1,D=new Uint8ClampedArray(y*d*4),B=0;B<d*y;++B){for(U=[0,0,0,255],J=0;J<v;J++){if(fe=_[B*v+J],n.dtype==="float32"){if(fe<0||fe>1)throw new Error("Tensor values for a float32 Tensor must be in the "+("range [0 - 1] but encountered "+fe+"."))}else if(n.dtype==="int32"&&(fe<0||fe>255))throw new Error("Tensor values for a int32 Tensor must be in the "+("range [0 - 255] but encountered "+fe+"."));v===1?(U[0]=fe*C,U[1]=fe*C,U[2]=fe*C):U[J]=fe*C}Pe=B*4,D[Pe+0]=Math.round(U[0]),D[Pe+1]=Math.round(U[1]),D[Pe+2]=Math.round(U[2]),D[Pe+3]=Math.round(U[3])}return e!=null&&(e.width=y,e.height=d,Me=e.getContext("2d"),He=new ImageData(D,y,d),Me.putImageData(He,0,0)),n!==t&&n.dispose(),[2,D]}})})}var yu=Ee({fromPixels_:Lc}),Pc={__proto__:null,toPixels:zc,fromPixels:yu};function Bu(t,e){if(t.rank<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher,"+(" but the rank was "+t.rank+"."));if(e.rank<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher,"+(" but the rank was "+e.rank+"."));if(e.dtype!=="int32")throw new Error("tf.gatherND() expects the indices to be int32 type,"+(" but the dtype was "+e.dtype+"."));if(e.shape[e.rank-1]>t.rank)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+(e.shape[e.rank-1]+" vs. "+t.rank));if(t.size===0)throw new Error("Requested more than 0 entries, but input is empty."+(" Input shape: "+t.shape+"."));for(var n=e.shape,a=n[n.length-1],c=1,d=0;d<n.length-1;++d)c*=n[d];var y=t.shape,v=n.slice();v.pop();for(var _=1,d=a;d<t.rank;++d)_*=y[d],v.push(y[d]);var C=Ca(t.shape).map(function(D){return D/_}).concat([1]).slice(0,a);return[v,c,_,C]}var bl={__proto__:null,prepareAndValidate:Bu};function Zi(t,e,n){var a=e.rank>1?e.shape[e.rank-1]:1,c=e.rank>1?e.rank-1:1,d="Must have updates.shape = indices.shape[:batchDim] + "+("shape[sliceDim:], got updates.shape: "+n.shape)+(", indices.shape: "+e.shape+", shape: "+t)+(", sliceDim: "+a+", and batchDim: "+c+".");if(n.rank<c)throw new Error(d+(" update.rank < "+c+". "));if(t.length<a+(n.rank-c))throw new Error(d+(" Output shape length < "+(a+(n.rank-c))));if(n.rank!==c+t.length-a)throw new Error(d+(" update.rank != "+(c+t.length-a)));for(var y=0;y<c;++y)if(n.shape[y]!==e.shape[y])throw new Error(d+(" updates.shape["+y+"] ("+n.shape[y]+") != indices.shape["+y+"] ("+e.shape[y]+")."));for(var y=0;y<n.rank-c;++y)if(n.shape[y+c]!==t[y+a])throw new Error(d+(" updates.shape["+(y+c)+"] ("+n.shape[y+c]+") != shape["+(y+c)+"] ("+t[y+c]+")"))}function Wu(t,e,n){if(e.rank<1)throw new Error("tf.scatterND() expects the indices to be rank 1 or higher,"+(" but the rank was "+e.rank+"."));if(t.rank<1)throw new Error("tf.scatterND() expects the updates to be rank 1 or higher,"+(" but the rank was "+t.rank+"."));if(e.dtype!=="int32")throw new Error("The dtype of 'indices' should be int32, but got dtype: "+e.dtype);if(n.length<1)throw new Error("Output rank must be greater or equal to 1, but got shape: "+n);if(n.length===0){if(e.size===0)throw new Error("Indices specified for empty output. indices shape: "+e.shape);if(t.size===0)throw new Error("Updates specified for empty output. updates shape: "+t.shape)}Zi(n,e,t)}function os(t,e,n){for(var a=e.shape.length,c=a>1?e.shape[a-1]:1,d=n.length,y=1,v=c;v<d;++v)y*=n[v];var _=c<1?1:c,C=Tt(e.shape)/_,D=Ca(n.slice(0,c)).concat([1]),B=Tt(n);return{sliceRank:c,numUpdates:C,sliceSize:y,strides:D,outputSize:B}}var kl={__proto__:null,validateUpdateShape:Zi,validateInput:Wu,calculateShapes:os};function Bc(t,e,n){var a=t.shape.length;W(a===e.length,function(){return"Error in slice"+a+"D: Length of begin "+e+" must "+("match the rank of the array ("+a+").")}),W(a===n.length,function(){return"Error in slice"+a+"D: Length of size "+n+" must "+("match the rank of the array ("+a+").")});for(var c=function(y){W(e[y]+n[y]<=t.shape[y],function(){return"Error in slice"+a+"D: begin["+y+"] + size["+y+"] "+("("+(e[y]+n[y])+") would overflow input.shape["+y+"] ("+t.shape[y]+")")})},d=0;d<a;++d)c(d)}function vu(t){for(var e=[],n=0;t>0;)t&1&&e.push(n),t/=2,n++;return e}function Wc(t,e,n){for(var a=[],c=0;c<t.length;c++)a[c]=Math.ceil((e[c]-t[c])/n[c]);return a}function Uc(t,e,n,a){for(var c=t.slice(),d=c.length;d<a.length;d++)c.push(1);for(var d=0;d<n;d++)d===0?c[e]=1:(c.splice(e,0,1),c.pop());return c}function Vc(t,e,n){return n<=t?n:n-(e-1)}function Hc(t,e){for(var n=[],a=0;a<t;a++)n.push(e+a);return n}function Gc(t,e,n,a,c,d,y,v,_){var C=t.length,D=new Array(C),B=new Array(C),U=new Array(C);if(e.length&&n>0){var J=e[0],fe=n+1;D=jc(y,J,fe,a,t),B=Uu(v,J,fe,c,t),U=Uc(d,J,fe,t)}else for(var Pe=0;Pe<C;Pe++)D[Pe]=qc(y,a,d,t,Pe,_),B[Pe]=Kc(v,c,d,t,Pe,_),U[Pe]=Vu(d,Pe,_);return{begin:D,end:B,strides:U}}function jc(t,e,n,a,c){for(var d=c.slice(),y=Hc(n,e),v=0;v<d.length;v++)if(y.indexOf(v)>-1)d[v]=0;else{var _=Vc(e,n,v),C=a[_];t&1<<_&&(C=0),d[v]=C}return d}function Uu(t,e,n,a,c){for(var d=c.slice(),y=Hc(n,e),v=0;v<d.length;v++)if(y.indexOf(v)>-1)d[v]=Number.MAX_SAFE_INTEGER;else{var _=Vc(e,n,v),C=a[_];t&1<<_&&(C=Number.MAX_SAFE_INTEGER),d[v]=C}for(var D=0;D<d.length;D++){var B=c[D];d[D]<0&&(d[D]+=B),d[D]=me(0,d[D],c[D])}return d}function Vu(t,e,n){var a=t[e];return(n&1<<e||a==null)&&(a=1),a}function qc(t,e,n,a,c,d){var y=e[c],v=n[c]||1;(t&1<<c||d&1<<c||y==null)&&(v>0?y=Number.MIN_SAFE_INTEGER:y=Number.MAX_SAFE_INTEGER);var _=a[c];return y<0&&(y+=_),y=me(0,y,_-1),y}function Kc(t,e,n,a,c,d){var y=e[c],v=n[c]||1;(t&1<<c||d&1<<c||y==null)&&(v>0?y=Number.MAX_SAFE_INTEGER:y=Number.MIN_SAFE_INTEGER);var _=a[c];return y<0&&(y+=_),v>0?y=me(0,y,_):y=me(-1,y,_-1),y}function Sl(t,e,n){for(var a=n.length,c=0;c<n.length;c++)if(n[c]>1){a=c;break}for(var c=a+1;c<n.length;c++)if(e[c]>0||n[c]!==t[c])return!1;return!0}function Il(t,e){for(var n=t.length>0?t[t.length-1]:1,a=0;a<t.length-1;a++)n+=t[a]*e[a];return n}function Hu(t,e,n){var a,c=t.shape.length;typeof e=="number"?a=[e].concat(new Array(c-1).fill(0)):e.length<c?a=e.concat(new Array(c-e.length).fill(0)):a=e.slice(),a.forEach(function(y){W(y!==-1,function(){return"slice() does not support negative begin indexing."})});var d;return n==null?d=new Array(c).fill(-1):typeof n=="number"?d=[n].concat(new Array(c-1).fill(-1)):n.length<c?d=n.concat(new Array(c-n.length).fill(-1)):d=n,d=d.map(function(y,v){return y>=0?y:(W(y===-1,function(){return"Negative size values should be exactly -1 but got "+(y+" for the slice() size at index "+v+".")}),t.shape[v]-a[v])}),[a,d]}var Xc={__proto__:null,assertParamsValid:Bc,maskToAxes:vu,computeOutShape:Wc,stridesWithElidedDims:Uc,getNormalizedAxes:Gc,startIndicesWithElidedDims:jc,stopIndicesWithElidedDims:Uu,stridesForAxis:Vu,startForAxis:qc,stopForAxis:Kc,isSliceContinous:Sl,computeFlatOffset:Il,parseSliceParams:Hu},Yc=function(){function t(){}return t.prototype.getClassName=function(){return this.constructor.className},t.fromConfig=function(e,n){return new e(n)},t}(),ss=function(){function t(){this.classNameMap={}}return t.getMap=function(){return t.instance==null&&(t.instance=new t),t.instance},t.register=function(e){t.getMap().classNameMap[e.className]=[e,e.fromConfig]},t}();function jo(t){W(t.className!=null,function(){return"Class being registered does not have the static className property defined."}),W(typeof t.className=="string",function(){return"className is required to be a string, but got type "+typeof t.className}),W(t.className.length>0,function(){return"Class being registered has an empty-string as its className, which is disallowed."}),ss.register(t)}var Nl={__proto__:null,Serializable:Yc,SerializationMap:ss,registerClass:jo},Cl=.001,Gu=.1;function Tl(t,e,n){return n==null&&(n=gu()),ju(t,e,function(a,c){return qs(a,c,n)})}function gu(){return Ie.backend.floatPrecision()===32?Cl:Gu}function ju(t,e,n){var a=!0;if((Tn(t)||Tn(e))&&(a=!1),Tn(t)&&Tn(e)&&(a=!0),a){var c=t.constructor.name,d=e.constructor.name;if(c!==d)throw new Error("Arrays are of different type. Actual: "+c+". "+("Expected: "+d))}if(Array.isArray(t)&&Array.isArray(e)){var y=Er(t),v=Er(e);if(!it(y,v))throw new Error("Arrays have different shapes. "+("Actual: ["+y+"]. Expected: ["+v+"]"))}var _=Tn(t)?t:nr(t),C=Tn(e)?e:nr(e);if(_.length!==C.length)throw new Error("Arrays have different lengths actual: "+_.length+" vs "+("expected: "+C.length+`.
`)+("Actual: "+_+`.
`)+("Expected: "+C+"."));for(var D=0;D<C.length;++D){var B=_[D],U=C[D];if(!n(B,U))throw new Error("Arrays differ: actual["+D+"] = "+B+", expected["+D+"] = "+U+`.
`+("Actual: "+_+`.
`)+("Expected: "+C+"."))}}function El(t,e){t().then(function(){return e.fail()},function(){return e()})}function Rl(t,e){var n=typeof e=="string"||typeof e=="number"||typeof e=="boolean"?[e]:e;return yn(t)||yn(t[0])||yn(e)||yn(e[0])?ju(t,n,function(a,c){return a==c}):ju(t,e,function(a,c){return qs(a,c,0)})}function Al(t,e,n){if(n==null&&(n=gu()),!qs(t,e,n))throw new Error("Numbers differ: actual === "+t+", expected === "+e)}function qs(t,e,n){return!isFinite(t)&&!isFinite(e)?!0:!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n)}function qu(t,e,n){for(var a=0;a<t.length;a++)if(t[a]<e||t[a]>n)throw new Error("Value out of range:"+t[a]+" low: "+e+", high: "+n)}function Dl(t,e){expect(new Float32Array(t)).toEqual(new Float32Array(e))}var Fl={__proto__:null,TEST_EPSILON_FLOAT16:Gu,expectArraysClose:Tl,testEpsilon:gu,expectPromiseToFail:El,expectArraysEqual:Rl,expectNumbersClose:Al,expectValuesInRange:qu,expectArrayBuffersEqual:Dl},Ku="2.7.0";function Ol(){Rr().set("PROD",!0)}function Ml(){Rr().set("DEBUG",!0)}function Xu(){Rr().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Sa(t){Rr().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function Ll(){Ie.disposeVariables()}function zl(){return Ie}function Pl(){return Ie.memory()}function Qc(t){return Ie.profile(t)}function sa(t,e){return Ie.tidy(t,e)}function Pa(t){var e=Ot(t);e.forEach(function(n){return n.dispose()})}function xu(t){return Ie.keep(t)}function Zc(t){return Ie.time(t)}function Bl(t){return Ie.setBackend(t)}function Wl(){return Ie.ready()}function Ul(){return Ie.backendName}function Vl(t){Ie.removeBackend(t)}function Hl(t){return Ie.findBackend(t)}function Gl(t){return Ie.findBackendFactory(t)}function jl(t,e,n){return n===void 0&&(n=1),Ie.registerBackend(t,e,n)}function ql(){return Ie.backend}function Kl(t,e){Rr().setPlatform(t,e)}function Xl(t,e){var n,a=ie(t,"a","add"),c=ie(e,"b","add");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.add(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,pa)}var Cr=Ee({add_:Xl});function Yl(t,e){var n,a=ie(t,"a","floorDiv"),c=ie(e,"b","floorDiv");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.floorDiv(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,k)}var Yu=Ee({floorDiv_:Yl});function Ql(t,e){var n,a=ie(t,"a","div"),c=ie(e,"b","div");if(n=Nt(a,c),a=n[0],c=n[1],a.dtype==="int32"&&c.dtype==="int32")return Yu(a,c);var d=function(_,C){var D=_.realDivide(a,c);return C([a,c]),D},y={a,b:c},v={};return Ie.runKernelFunc(d,y,null,Vr,v)}var Br=Ee({div_:Ql});function Jc(t,e){var n,a=ie(t,"a","mul"),c=ie(e,"b","mul");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.multiply(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,qr)}var bt=Ee({mul_:Jc});function Zl(t){var e=ie(t,"x","abs"),n={x:e};return Ie.runKernelFunc(function(a,c){return c([e]),e.dtype==="complex64"?a.complexAbs(e):a.abs(e)},n,null,qn)}var ui=Ee({abs_:Zl});function Jl(t){var e=ie(t,"x","acos"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.acos(e);return c([e]),d},n,null,ri)}var $c=Ee({acos_:Jl});function $l(t){var e=ie(t,"x","acosh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.acosh(e);return c([e]),d},n,null,pi)}var el=Ee({acosh_:$l});function eh(t){W(Array.isArray(t),function(){return"The argument passed to tf.addN() must be a list of tensors"}),W(t.length>=1,function(){return"Must pass at least one tensor to tf.addN(), but got "+(""+t.length)});var e=t.map(function(d,y){return ie(d,"tensors"+y,"addN")}),n=e[0];e.forEach(function(d){if(d.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),e.forEach(function(d){if(!it(d.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});var a=function(d,y){var v=d.addN(e);return y(e),v},c=e;return Ie.runKernelFunc(a,c,null,di)}var th=Ee({addN_:eh});function Qu(t,e){for(var n=0;n<t.length;++n)if(t[t.length-n-1]!==e-1-n)return!1;return!0}function tl(t,e,n){for(var a=t.length+e.length,c=[],d=0,y=0,v=0;v<a;v++)n.indexOf(v)===-1?c.push(t[d++]):c.push(e[y++]);return c}function rl(t,e){for(var n=[],a=t.length,c=0;c<a;c++)e.indexOf(c)===-1&&n.push(t[c]);var d=e.map(function(y){return t[y]});return[n,d]}function ci(t,e){var n=e.map(function(a){return 1});return tl(t,n,e)}function nl(t,e,n){W(Qu(e,n),function(){return t+" supports only inner-most axes for now. "+("Got axes "+e+" and rank-"+n+" input.")})}function Ji(t,e){if(Qu(t,e))return null;for(var n=[],a=0;a<e;++a)t.indexOf(a)===-1&&n.push(a);return t.forEach(function(c){return n.push(c)}),n}function f(t){return t.map(function(e,n){return[n,e]}).sort(function(e,n){return e[1]-n[1]}).map(function(e){return e[0]})}function p(t,e){for(var n=[],a=e-t;a<e;++a)n.push(a);return n}function l(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","all","bool"),c=function(v){var _=qt(e,a.shape),C=_,D=Ji(C,a.rank);D!=null&&(a=$n(a,D),C=p(C.length,a.rank));var B=v.all(a,C);if(n){var U=ci(B.shape,_);return Ke(B,U)}return B},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,fi,y)}var m=Ee({all_:l});function g(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","any","bool"),c=function(v){var _=qt(e,a.shape),C=_,D=Ji(C,a.rank);D!=null&&(a=$n(a,D),C=p(C.length,a.rank));var B=v.any(a,C);if(n){var U=ci(B.shape,_);return Ke(B,U)}return B},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,Va,y)}var I=Ee({any_:g});function R(t,e){e===void 0&&(e=0);var n=ie(t,"x","argMax"),a=function(y,v){v([n]);var _=qt(e,n.shape),C=Ji(_,n.rank);return C!=null&&(n=$n(n,C),_=p(_.length,n.rank)),y.argMax(n,_[0])},c={x:n},d={axis:e};return Ie.runKernelFunc(a,c,null,ln,d)}var z=Ee({argMax_:R});function L(t,e){e===void 0&&(e=0);var n=ie(t,"x","argMin"),a=function(y,v){v([n]),e==null&&(e=0);var _=qt(e,n.shape),C=Ji(_,n.rank);return C!=null&&(n=$n(n,C),_=p(_.length,n.rank)),y.argMin(n,_[0])},c={x:n},d={axis:e};return Ie.runKernelFunc(a,c,null,ni,d)}var G=Ee({argMin_:L});function Z(t){var e=ie(t,"x","asin"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.asin(e);return c([e]),d},n,null,gr)}var be=Ee({asin_:Z});function Ce(t){var e=ie(t,"x","asinh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.asinh(e);return c([e]),d},n,null,Di)}var De=Ee({asinh_:Ce});function Te(t){var e=ie(t,"x","atan"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.atan(e);return c([e]),d},n,null,bi)}var Ge=Ee({atan_:Te});function Ze(t,e){var n,a=ie(t,"a","atan2"),c=ie(e,"b","atan2");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.atan2(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,Zn)}var s=Ee({atan2_:Ze});function u(t){var e=ie(t,"x","atanh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.atanh(e);return c([e]),d},n,null,ro)}var r=Ee({atanh_:u});function o(t,e,n,a,c,d){c===void 0&&(c="NHWC");var y=t[3],v=e.concat([y]),_=Dt(c);return T(t,v,n,d,a,null,null,_)}function h(t,e,n,a,c,d,y){y===void 0&&(y="channelsLast");var v=Ne(e),_=v[0],C=v[1],D;if(y==="channelsLast")D=[_,C,t[3],t[3]];else if(y==="channelsFirst")D=[_,C,t[1],t[1]];else throw new Error("Unknown dataFormat "+y);return T(t,D,n,a,c,d,!1,y)}function b(t,e,n,a,c,d,y){y===void 0&&(y="NDHWC");var v=We(e),_=v[0],C=v[1],D=v[2],B,U;if(y==="NDHWC")U="channelsLast",B=[_,C,D,t[4],t[4]];else if(y==="NCDHW")U="channelsFirst",B=[_,C,D,t[1],t[1]];else throw new Error("Unknown dataFormat "+y);return M(t,B,n,a,c,!1,U,d)}function T(t,e,n,a,c,d,y,v){y===void 0&&(y=!1),v===void 0&&(v="channelsLast");var _=[-1,-1,-1,-1],C=_[0],D=_[1],B=_[2],U=_[3];if(v==="channelsLast")C=t[0],D=t[1],B=t[2],U=t[3];else if(v==="channelsFirst")C=t[0],U=t[1],D=t[2],B=t[3];else throw new Error("Unknown dataFormat "+v);var J=e[0],fe=e[1],Pe=e[3],Me=Ne(n),He=Me[0],ct=Me[1],It=Ne(a),Ct=It[0],Bt=It[1],sr=je(J,Ct),er=je(fe,Bt),mr=qe(c,D,B,He,ct,sr,er,d,v),Gr=mr.padInfo,en=mr.outHeight,Qr=mr.outWidth,Zr=y?Pe*U:Pe,Kr;return v==="channelsFirst"?Kr=[C,Zr,en,Qr]:v==="channelsLast"&&(Kr=[C,en,Qr,Zr]),{batchSize:C,dataFormat:v,inHeight:D,inWidth:B,inChannels:U,outHeight:en,outWidth:Qr,outChannels:Zr,padInfo:Gr,strideHeight:He,strideWidth:ct,filterHeight:J,filterWidth:fe,effectiveFilterHeight:sr,effectiveFilterWidth:er,dilationHeight:Ct,dilationWidth:Bt,inShape:t,outShape:Kr,filterShape:e}}function M(t,e,n,a,c,d,y,v){d===void 0&&(d=!1),y===void 0&&(y="channelsLast");var _=[-1,-1,-1,-1,-1],C=_[0],D=_[1],B=_[2],U=_[3],J=_[4];if(y==="channelsLast")C=t[0],D=t[1],B=t[2],U=t[3],J=t[4];else if(y==="channelsFirst")C=t[0],J=t[1],D=t[2],B=t[3],U=t[4];else throw new Error("Unknown dataFormat "+y);var fe=e[0],Pe=e[1],Me=e[2],He=e[4],ct=We(n),It=ct[0],Ct=ct[1],Bt=ct[2],sr=We(a),er=sr[0],mr=sr[1],Gr=sr[2],en=je(fe,er),Qr=je(Pe,mr),Zr=je(Me,Gr),Kr=mt(c,D,B,U,It,Ct,Bt,en,Qr,Zr,v),Un=Kr.padInfo,mn=Kr.outDepth,Ln=Kr.outHeight,$s=Kr.outWidth,xi=d?He*J:He,Ba;return y==="channelsFirst"?Ba=[C,xi,mn,Ln,$s]:y==="channelsLast"&&(Ba=[C,mn,Ln,$s,xi]),{batchSize:C,dataFormat:y,inDepth:D,inHeight:B,inWidth:U,inChannels:J,outDepth:mn,outHeight:Ln,outWidth:$s,outChannels:xi,padInfo:Un,strideDepth:It,strideHeight:Ct,strideWidth:Bt,filterDepth:fe,filterHeight:Pe,filterWidth:Me,effectiveFilterDepth:en,effectiveFilterHeight:Qr,effectiveFilterWidth:Zr,dilationDepth:er,dilationHeight:mr,dilationWidth:Gr,inShape:t,outShape:Ba,filterShape:e}}function q(t,e,n,a,c){a==null&&(a=le(t,e,n));var d=t[0],y=t[1],v=pt((d-e+2*a)/n+1,c);W(xt(v),function(){return"The output # of rows ("+v+") must be an integer. Change the stride and/or zero pad parameters"});var _=pt((y-e+2*a)/n+1,c);return W(xt(_),function(){return"The output # of columns ("+_+") must be an integer. Change the stride and/or zero pad parameters"}),[v,_]}function Y(t,e,n,a,c,d){c==null&&(c=le(t,e,a));var y=t[0],v=t[1],_=t[2],C=pt((y-e+2*c)/a+1,d);W(xt(C),function(){return"The output # of depths ("+C+") must be an integer. Change the stride and/or zero pad parameters"});var D=pt((v-e+2*c)/a+1,d);W(xt(D),function(){return"The output # of rows ("+D+") must be an integer. Change the stride and/or zero pad parameters"});var B=pt((_-e+2*c)/a+1,d);return W(xt(B),function(){return"The output # of columns ("+B+") must be an integer. Change the stride and/or zero pad parameters"}),[C,D,B,n]}function le(t,e,n,a){a===void 0&&(a=1);var c=je(e,a);return Math.floor((t[0]*(n-1)-n+c)/2)}function Ne(t){return typeof t=="number"?[t,t,t]:t.length===2?[t[0],t[1],1]:t}function We(t){return typeof t=="number"?[t,t,t]:t}function je(t,e){return e<=1?t:t+(t-1)*(e-1)}function qe(t,e,n,a,c,d,y,v,_){var C,D,B;if(typeof t=="number"){var U=t===0?"VALID":"NUMBER";C={top:t,bottom:t,left:t,right:t,type:U};var J=q([e,n],d,a,t,v);D=J[0],B=J[1]}else if(t==="same"){D=Math.ceil(e/a),B=Math.ceil(n/c);var fe=Math.max(0,(D-1)*a+d-e),Pe=Math.max(0,(B-1)*c+y-n),Me=Math.floor(fe/2),He=fe-Me,ct=Math.floor(Pe/2),It=Pe-ct;C={top:Me,bottom:He,left:ct,right:It,type:"SAME"}}else if(t==="valid")C={top:0,bottom:0,left:0,right:0,type:"VALID"},D=Math.ceil((e-d+1)/a),B=Math.ceil((n-y+1)/c);else if(typeof t=="object"){var Ct=_==="channelsLast"?t[1][0]:t[2][0],He=_==="channelsLast"?t[1][1]:t[2][1],ct=_==="channelsLast"?t[2][0]:t[3][0],It=_==="channelsLast"?t[2][1]:t[3][1],U=Ct===0&&He===0&&ct===0&&It===0?"VALID":"EXPLICIT";C={top:Ct,bottom:He,left:ct,right:It,type:U},D=pt((e-d+Ct+He)/a+1,v),B=pt((n-y+ct+It)/c+1,v)}else throw Error("Unknown padding parameter: "+t);return{padInfo:C,outHeight:D,outWidth:B}}function mt(t,e,n,a,c,d,y,v,_,C,D){var B,U,J,fe;if(typeof t=="number"){var Pe=t===0?"VALID":"NUMBER";B={top:t,bottom:t,left:t,right:t,front:t,back:t,type:Pe};var Me=Y([e,n,a,1],v,1,c,t,D);U=Me[0],J=Me[1],fe=Me[2]}else if(t==="same"){U=Math.ceil(e/c),J=Math.ceil(n/d),fe=Math.ceil(a/y);var He=(U-1)*c+v-e,ct=(J-1)*d+_-n,It=(fe-1)*y+C-a,Ct=Math.floor(He/2),Bt=He-Ct,sr=Math.floor(ct/2),er=ct-sr,mr=Math.floor(It/2),Gr=It-mr;B={top:sr,bottom:er,left:mr,right:Gr,front:Ct,back:Bt,type:"SAME"}}else if(t==="valid")B={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},U=Math.ceil((e-v+1)/c),J=Math.ceil((n-_+1)/d),fe=Math.ceil((a-C+1)/y);else throw Error("Unknown padding parameter: "+t);return{padInfo:B,outDepth:U,outHeight:J,outWidth:fe}}function pt(t,e){if(!e)return t;switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error("Unknown roundingMode "+e)}}function st(t){var e=Ne(t),n=e[0],a=e[1],c=e[2];return n===1&&a===1&&c===1}function dt(t,e){return st(t)||st(e)}function Dt(t){if(t==="NHWC")return"channelsLast";if(t==="NCHW")return"channelsFirst";throw new Error("Unknown dataFormat "+t)}function or(t,e,n,a,c){var d=ie(t,"x","avgPool","float32"),y=1;W(dt(n,y),function(){return"Error in avgPool: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+y+"'")});var v=d,_=!1;d.rank===3&&(_=!0,v=Ke(d,[1,d.shape[0],d.shape[1],d.shape[2]])),W(v.rank===4,function(){return"Error in avgPool: x must be rank 4 but got rank "+v.rank+"."}),c!=null&&W(xt(a),function(){return"Error in avgPool: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var C=function(J,fe){var Pe=h(v.shape,e,n,1,a,c);return fe([v]),Pe.filterWidth===1&&Pe.filterHeight===1&&it(Pe.inShape,Pe.outShape)?v.clone():J.avgPool(v,Pe)},D={x:v},B={filterSize:e,strides:n,pad:a,dimRoundingMode:c},U=Ie.runKernelFunc(C,D,null,Gi,B);return U=pr(U,d.dtype),_?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var Xt=Ee({avgPool_:or});function Jt(t,e,n,a,c,d,y){d===void 0&&(d="NDHWC"),y==null?y=[1,1,1]:Sa("dilations is deprecated, this field will be gone in v3.0.0.");var v=ie(t,"x","avgPool3d","float32"),_=v,C=!1;v.rank===4&&(C=!0,_=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2],v.shape[3]])),W(_.rank===5,function(){return"Error in avgPool3d: x must be rank 5 but got rank "+_.rank+"."}),W(d==="NDHWC",function(){return"Error in avgPool3d: Only NDHWC is currently supported, "+("but got dataFormat of "+d)}),W(dt(n,y),function(){return"Error in avgPool3d: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+y+"'")}),c!=null&&W(xt(a),function(){return"Error in avgPool3d: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var D=function(fe,Pe){y==null&&(y=[1,1,1]);var Me=b(_.shape,e,n,y,a,c,d);return Pe([_]),fe.avgPool3d(_,Me)},B={x:_},U={filterSize:e,strides:n,pad:a,dimRoundingMode:c,dataFormat:d,dilations:y},J=Ie.runKernelFunc(D,B,null,ji,U);return J=pr(J,_.dtype),C?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var vr=Ee({avgPool3d_:Jt});function lr(t,e){var n=t[0].length;t.forEach(function(c,d){W(c.length===n,function(){return"Error in concat"+n+"D: rank of tensors["+d+"] must be the same "+("as the rank of the rest ("+n+")")})}),W(e>=0&&e<n,function(){return"Error in concat"+n+"D: axis must be between 0 and "+(n-1)+"."});var a=t[0];t.forEach(function(c,d){for(var y=0;y<n;y++)W(y===e||c[y]===a[y],function(){return"Error in concat"+n+"D: Shape of tensors["+d+"] ("+c+") "+("does not match the shape of the rest ("+a+") ")+("along the non-concatenated axis "+d+".")})})}function Ir(t,e){for(var n=t[0].slice(),a=1;a<t.length;a++)n[e]+=t[a][e];return n}function Lr(t,e){e===void 0&&(e=0),W(t.length>=1,function(){return"Pass at least one tensor to concat"});var n=Nn(t,"tensors","concat");n[0].dtype==="complex64"&&n.forEach(function(y){if(y.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor
with dtype `+y.dtype+". ")});var a=function(y,v){var _=qt(e,n[0].shape)[0],C=Ir(n.map(function(U){return U.shape}),_);if(Tt(C)===0)return Dn([],C);if(n=n.filter(function(U){return U.size>0}),n.length===1)return n[0];var D=n.map(function(U){return U.shape});lr(D,_);var B=y.concat(n,_);return v(n),B},c=n,d={axis:e};return Ie.runKernelFunc(a,c,null,Ue,d)}var kr=Ee({concat_:Lr});function Sr(t){var e=ie(t,"x","sigmoid"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.sigmoid(e);return c([d]),d},n,null,Ds)}var fn=Ee({sigmoid_:Sr});function Xr(t,e,n){var a=ie(t,"x","slice");if(a.rank===0)throw new Error("Slicing scalar is not possible");var c=function(v,_){var C=Hu(a,e,n),D=C[0],B=C[1];return Bc(a,D,B),_([a]),v.slice(a,D,B)},d={x:a},y={begin:e,size:n};return Ie.runKernelFunc(c,d,null,To,y)}var $t=Ee({slice_:Xr});function On(t){var e=ie(t,"x","tanh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.tanh(e);return c([d]),d},n,null,Ms)}var En=Ee({tanh_:On});function kn(t,e,n,a,c,d){var y=ie(t,"forgetBias","basicLSTMCell"),v=ie(e,"lstmKernel","basicLSTMCell"),_=ie(n,"lstmBias","basicLSTMCell"),C=ie(a,"data","basicLSTMCell"),D=ie(c,"c","basicLSTMCell"),B=ie(d,"h","basicLSTMCell"),U=kr([C,B],1),J=un(U,v),fe=Cr(J,_),Pe=fe.shape[0],Me=fe.shape[1]/4,He=[Pe,Me],ct=$t(fe,[0,0],He),It=$t(fe,[0,Me],He),Ct=$t(fe,[0,Me*2],He),Bt=$t(fe,[0,Me*3],He),sr=Cr(bt(fn(ct),En(It)),bt(D,fn(Cr(y,Ct)))),er=bt(En(sr),fn(Bt));return[sr,er]}var cn=Ee({basicLSTMCell_:kn});function Mn(t,e,n){var a=ie(t,"x","batchToSpaceND"),c=e.reduce(function(_,C){return _*C});W(a.rank>=1+e.length,function(){return"input rank is "+a.rank+" but should be > than blockShape.length "+e.length}),W(n.length===e.length,function(){return"crops.length is "+n.length+" but should be equal to blockShape.length "+e.length}),W(a.shape[0]%c===0,function(){return"input tensor batch is "+a.shape[0]+" but is not divisible by the product of "+("the elements of blockShape "+e.join(" * ")+" === "+c)});var d=function(_){return _.batchToSpaceND(a,e,n)},y={x:a},v={blockShape:e,crops:n};return Ie.runKernelFunc(d,y,null,Mi,v)}var Hr=Ee({batchToSpaceND_:Mn});function ua(t){var e;return t.rank===0||t.rank===1?e=Ke(t,[1,1,1,t.size]):t.rank===2?e=Ke(t,[1,1,t.shape[0],t.shape[1]]):t.rank===3?e=Ke(t,[1,t.shape[0],t.shape[1],t.shape[2]]):e=t,e}function Ci(t,e,n,a,c,d){d==null&&(d=.001);var y=ie(t,"x","batchNorm"),v=ie(e,"mean","batchNorm"),_=ie(n,"variance","batchNorm"),C;c!=null&&(C=ie(c,"scale","batchNorm"));var D;a!=null&&(D=ie(a,"offset","batchNorm")),W(v.rank===_.rank,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),W(D==null||v.rank===D.rank,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),W(C==null||v.rank===C.rank,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var B=ua(y),U=function(Me,He){return He([B,v,_,C]),Me.batchNorm(B,Ui(v),Ui(_),Ui(D),Ui(C),d)},J={x:B,scale:C,offset:D,mean:v,variance:_},fe={varianceEpsilon:d},Pe=Ie.runKernelFunc(U,J,null,K,fe);return Ke(Pe,y.shape)}function Ui(t){return t==null?null:t.rank===0?Ke(t,[t.size]):t.rank===1?t:t.rank===2?Ke(t,[1,1,t.shape[0],t.shape[1]]):t.rank===3?Ke(t,[1,t.shape[0],t.shape[1],t.shape[2]]):t}var Xn=Ee({batchNorm_:Ci});function $i(t,e,n,a,c,d){var y=ie(t,"x","batchNorm"),v=ie(e,"mean","batchNorm"),_=ie(n,"variance","batchNorm"),C;c!=null&&(C=ie(c,"scale","batchNorm"));var D;return a!=null&&(D=ie(a,"offset","batchNorm")),W(y.rank===2,function(){return"Error in batchNorm2D: x must be rank 2 but got rank "+(y.rank+".")}),W(v.rank===2||v.rank===1,function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but "+("got rank "+v.rank+".")}),W(_.rank===2||_.rank===1,function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 "+("but got rank "+_.rank+".")}),C!=null&&W(C.rank===2||C.rank===1,function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 "+("but got rank "+C.rank+".")}),D!=null&&W(D.rank===2||D.rank===1,function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 "+("but got rank "+D.rank+".")}),Xn(y,v,_,D,C,d)}var Vi=Ee({batchNorm2d_:$i});function Ks(t,e,n,a,c,d){var y=ie(t,"x","batchNorm"),v=ie(e,"mean","batchNorm"),_=ie(n,"variance","batchNorm"),C;c!=null&&(C=ie(c,"scale","batchNorm"));var D;return a!=null&&(D=ie(a,"offset","batchNorm")),W(y.rank===3,function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+(y.rank+".")}),W(v.rank===3||v.rank===1,function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but "+("got rank "+v.rank+".")}),W(_.rank===3||_.rank===1,function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 "+("but got rank "+_.rank+".")}),C!=null&&W(C.rank===3||C.rank===1,function(){return"Error in batchNorm3D: scale must be rank 3 or rank 1 "+("but got rank "+C.rank+".")}),D!=null&&W(D.rank===3||D.rank===1,function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 "+("but got rank "+D.rank+".")}),Xn(y,v,_,D,C,d)}var Zu=Ee({batchNorm3d_:Ks});function al(t,e,n,a,c,d){var y=ie(t,"x","batchNorm"),v=ie(e,"mean","batchNorm"),_=ie(n,"variance","batchNorm"),C;c!=null&&(C=ie(c,"scale","batchNorm"));var D;return a!=null&&(D=ie(a,"offset","batchNorm")),W(y.rank===4,function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+(y.rank+".")}),W(v.rank===4||v.rank===1,function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but "+("got rank "+v.rank+".")}),W(_.rank===4||_.rank===1,function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 "+("but got rank "+_.rank+".")}),C!=null&&W(C.rank===4||C.rank===1,function(){return"Error in batchNorm4D: scale must be rank 4 or rank 1 "+("but got rank "+C.rank+".")}),D!=null&&W(D.rank===4||D.rank===1,function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 "+("but got rank "+D.rank+".")}),Xn(y,v,_,D,C,d)}var _h=Ee({batchNorm4d_:al});function rh(t,e){var n=ie(t,"broadcastTo","x"),a=n.shape;if(e.some(function(U){return!(U>0)||U%1!==0}))throw new Error("broadcastTo(): Invalid broadcast shape ["+e+"].");if(e.length<n.rank)throw new Error("broadcastTo(): shape.length="+e.length+" < input.rank="+n.rank+".");if(e.length>n.rank){for(var c=n.shape.slice();c.length<e.length;)c.unshift(1);n=Ke(n,c)}for(var d=n.shape,y=Array.from(e),v=e.length-1;v>=0;v--)if(d[v]===e[v])y[v]=1;else if(n.shape[v]!==1)throw new Error("broadcastTo(): ["+a+"] cannot be broadcast to ["+e+"].");var _=y.map(function(U,J){return U>1?J:-1}).filter(function(U){return U>=0});if(_.length===0)return Ho(n);var C=function(U){return U.tile(n,y)},D={x:n},B={shape:e,inputShape:d};return Ie.runKernelFunc(C,D,null,pe,B)}var Ju=Ee({broadcastTo_:rh});function nh(t){var e=ie(t,"x","ceil"),n={x:e};return Ie.runKernelFunc(function(a){return a.ceil(e)},n,null,j)}var ah=Ee({ceil_:nh});function ih(t,e,n){var a=ie(t,"x","clipByValue");W(e<=n,function(){return"Error in clip: min ("+e+") must be "+("less than or equal to max ("+n+").")});var c={x:a},d={clipValueMin:e,clipValueMax:n};return Ie.runKernelFunc(function(y,v){var _=y.clip(a,e,n);return v([a]),_},c,null,re,d)}var oh=Ee({clipByValue_:ih});function sh(t){return kr(t,0)}var wh=Ee({concat1d_:sh});function uh(t,e){return kr(t,e)}var $h=Ee({concat2d_:uh});function ch(t,e){return kr(t,e)}var bh=Ee({concat3d_:ch});function ep(t,e){return kr(t,e)}var Wn=Ee({concat4d_:ep});function Is(t,e,n,a,c,d,y){c===void 0&&(c="NHWC"),d===void 0&&(d=[1,1]);var v=ie(t,"x","conv2d"),_=ie(e,"filter","conv2d"),C=v,D=!1;v.rank===3&&(D=!0,C=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2]])),W(C.rank===4,function(){return"Error in conv2d: input must be rank 4, but got rank "+C.rank+"."}),W(_.rank===4,function(){return"Error in conv2d: filter must be rank 4, but got rank "+(_.rank+".")}),y!=null&&W(xt(a),function(){return"Error in conv2d: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+a+".")});var B=c==="NHWC"?C.shape[3]:C.shape[1];W(B===_.shape[2],function(){return"Error in conv2d: depth of input ("+B+") must match "+("input depth for filter "+_.shape[2]+".")}),W(dt(n,d),function(){return"Error in conv2D: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+d+"'")});var U=function(Me,He){var ct=Dt(c),It=T(C.shape,_.shape,n,d,a,y,!1,ct),Ct=Me.conv2d(C,_,It);return He([C,_]),Ct},J={x:C,filter:_},fe={strides:n,pad:a,dataFormat:c,dilations:d,dimRoundingMode:y},Pe=Ie.runKernelFunc(U,J,null,kt,fe);return D?Ke(Pe,[Pe.shape[1],Pe.shape[2],Pe.shape[3]]):Pe}var gi=Ee({conv2d_:Is});function qo(t,e,n,a,c,d,y){c===void 0&&(c="NWC"),d===void 0&&(d=1);var v=ie(t,"x","conv1d"),_=ie(e,"filter","conv1d"),C=v,D=!1;v.rank===2&&(D=!0,C=Ke(v,[1,v.shape[0],v.shape[1]])),W(C.rank===3,function(){return"Error in conv1d: input must be rank 3, but got rank "+C.rank+"."}),W(_.rank===3,function(){return"Error in conv1d: filter must be rank 3, but got rank "+(_.rank+".")}),y!=null&&W(xt(a),function(){return"Error in conv1d: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+a+".")}),W(C.shape[2]===_.shape[1],function(){return"Error in conv1d: depth of input ("+C.shape[2]+") must match "+("input depth for filter "+_.shape[1]+".")}),W(dt(n,d),function(){return"Error in conv1D: Either stride or dilation must be 1. "+("Got stride "+n+" and dilation '"+d+"'")}),W(c==="NWC",function(){return"Error in conv1d: got dataFormat of "+c+" but only NWC is currently supported."});var B=Ke(_,[1,_.shape[0],_.shape[1],_.shape[2]]),U=Ke(C,[C.shape[0],1,C.shape[1],C.shape[2]]),J=[1,n],fe=[1,d],Pe="NHWC",Me=gi(U,B,J,a,Pe,fe,y);return D?Ke(Me,[Me.shape[2],Me.shape[3]]):Ke(Me,[Me.shape[0],Me.shape[2],Me.shape[3]])}var Ns=Ee({conv1d_:qo});function kh(t,e,n,a,c,d,y){d===void 0&&(d="NHWC"),W(t.length===e.rank,function(){return"Length of inShape "+("("+t.length+") and rank of dy ("+e.rank+") must match")});var v=t,_=e,C=!1;e.rank===3&&(C=!0,_=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2]]),v=[1,t[0],t[1],t[2]]),W(v.length===4,function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+(v.length+".")}),W(_.rank===4,function(){return"Error in conv2dDerInput: dy must be rank 4, but got "+("rank "+_.rank)}),W(n.rank===4,function(){return"Error in conv2dDerInput: filter must be rank 4, but got "+("rank "+n.rank)});var D=d==="NHWC"?v[3]:v[1],B=d==="NHWC"?_.shape[3]:_.shape[1];W(D===n.shape[2],function(){return"Error in conv2dDerInput: depth of input ("+D+") must "+("match input depth for filter "+n.shape[2]+".")}),W(B===n.shape[3],function(){return"Error in conv2dDerInput: depth of output ("+B+") must "+("match output depth for filter "+n.shape[3]+".")}),y!=null&&W(xt(c),function(){return"Error in conv2dDerInput: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+c+".")});var U=function(Me,He){var ct=1,It=Dt(d),Ct=T(v,n.shape,a,ct,c,y,!1,It),Bt=Me.conv2dDerInput(_,n,Ct);return He([_,n]),Bt},J={dy:_,filter:n},fe={strides:a,pad:c,dataFormat:d,dimRoundingMode:y,inputShape:v},Pe=Ie.runKernelFunc(U,J,null,Le,fe);return C?Ke(Pe,[Pe.shape[1],Pe.shape[2],Pe.shape[3]]):Pe}var Ti=Ee({conv2DBackpropInput_:kh});function tp(t,e,n,a,c,d){var y=ie(t,"x","conv2dTranspose"),v=ie(e,"filter","conv2dTranspose");return Ti(n,y,v,a,c,"NHWC",d)}var Xs=Ee({conv2dTranspose_:tp});function rp(t,e,n,a,c,d){c===void 0&&(c="NDHWC"),d===void 0&&(d=[1,1,1]);var y=ie(t,"x","conv3d"),v=ie(e,"filter","conv3d"),_=y,C=!1;y.rank===4&&(C=!0,_=Ke(y,[1,y.shape[0],y.shape[1],y.shape[2],y.shape[3]])),W(_.rank===5,function(){return"Error in conv3d: input must be rank 5, but got rank "+_.rank+"."}),W(v.rank===5,function(){return"Error in conv3d: filter must be rank 5, but got rank "+(v.rank+".")}),W(_.shape[4]===v.shape[3],function(){return"Error in conv3d: depth of input ("+_.shape[4]+") must match "+("input depth for filter "+v.shape[3]+".")}),W(dt(n,d),function(){return"Error in conv3D: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+d+"'")}),W(c==="NDHWC",function(){return"Error in conv3d: got dataFormat of "+c+" but only NDHWC is currently supported."});var D=function(fe,Pe){var Me=M(_.shape,v.shape,n,d,a),He=fe.conv3d(_,v,Me);return Pe([_,v]),He},B={x:_,filter:v},U={strides:n,pad:a,dataFormat:c,dilations:d},J=Ie.runKernelFunc(D,B,null,Ye,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var np=Ee({conv3d_:rp});function ap(t,e,n,a,c){W(t.length===e.rank,function(){return"Length of inShape "+("("+t.length+") and rank of dy ("+e.rank+") must match")});var d=t,y=e,v=!1;e.rank===4&&(v=!0,y=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),d=[1,t[0],t[1],t[2],t[3]]);var _=d[4],C=y.shape[4];W(d.length===5,function(){return"Error in conv3dDerInput: inShape must be length 5, but got length "+(d.length+".")}),W(y.rank===5,function(){return"Error in conv3dDerInput: dy must be rank 5, but got "+("rank "+y.rank)}),W(n.rank===5,function(){return"Error in conv3dDerInput: filter must be rank 5, but got "+("rank "+n.rank)}),W(_===n.shape[3],function(){return"Error in conv3dDerInput: depth of input ("+_+") must "+("match input depth for filter "+n.shape[3]+".")}),W(C===n.shape[4],function(){return"Error in conv3dDerInput: depth of output ("+C+") must "+("match output depth for filter "+n.shape[4]+".")});var D=function(fe){var Pe=1,Me=M(d,n.shape,a,Pe,c);return fe.conv3dDerInput(y,n,Me)},B={dy:y,filter:n},U={pad:c,strides:a,inputShape:d},J=Ie.runKernelFunc(D,B,null,St,U);return v?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var Sh=Ee({conv3DBackpropInput_:ap});function If(t,e,n,a,c){var d=ie(t,"x","conv3dTranspose"),y=ie(e,"filter","conv3dTranspose");return Sh(n,d,y,a,c)}var Nf=Ee({conv3dTranspose_:If});function Cf(t){var e=ie(t,"x","cos"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.cos(e);return c([e]),d},n,null,Mt)}var Ih=Ee({cos_:Cf});function Tf(t){var e=ie(t,"x","cosh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.cosh(e);return c([e]),d},n,null,dr)}var ip=Ee({cosh_:Tf});function Ef(t,e,n,a){e===void 0&&(e=0),n===void 0&&(n=!1),a===void 0&&(a=!1);var c=ie(t,"x","cumsum"),d=function(_,C){var D=Ji([e],c.rank),B=c;D!=null&&(B=$n(c,D));var U=p(1,c.rank)[0],J=_.cumsum(B,U,n,a);if(C([c]),D!=null){var fe=f(D);J=$n(J,fe)}return J},y={x:c},v={axis:e,exclusive:n,reverse:a};return Ie.runKernelFunc(d,y,null,ir,v)}var op=Ee({cumsum_:Ef});function Rf(t,e,n){n===void 0&&(n="NHWC");var a=ie(t,"x","depthToSpace"),c=n==="NHWC"?a.shape[1]:a.shape[2],d=n==="NHWC"?a.shape[2]:a.shape[3],y=n==="NHWC"?a.shape[3]:a.shape[1];W(c*e>=0,function(){return`Negative dimension size caused by overflow when multiplying
`+c+" and "+e+` for depthToSpace with input shape
`+a.shape}),W(d*e>=0,function(){return`Negative dimension size caused by overflow when multiplying
`+d+" and "+e+` for depthToSpace with input shape
`+a.shape}),W(y%(e*e)===0,function(){return"Dimension size must be evenly divisible by "+e*e+" but is "+y+" for depthToSpace with input shape "+a.shape});var v=function(D){return D.depthToSpace(a,e,n)},_={x:a},C={blockSize:e,dataFormat:n};return Ie.runKernelFunc(v,_,null,fa,C)}var Kp=Ee({depthToSpace_:Rf});function Af(t,e,n,a,c,d,y){c===void 0&&(c="NHWC"),d===void 0&&(d=[1,1]);var v=ie(t,"x","depthwiseConv2d"),_=ie(e,"filter","depthwiseConv2d"),C=v,D=!1;v.rank===3&&(D=!0,C=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2]])),W(C.rank===4,function(){return"Error in depthwiseConv2d: input must be rank 4, but got "+("rank "+C.rank+".")}),W(_.rank===4,function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+(_.rank+".")}),W(C.shape[3]===_.shape[2],function(){return"Error in depthwiseConv2d: number of input channels "+("("+C.shape[3]+") must match the inChannels dimension in ")+("filter "+_.shape[2]+".")}),y!=null&&W(xt(a),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+a+".")});var B=function(Pe,Me){d==null&&(d=[1,1]),W(dt(n,d),function(){return"Error in depthwiseConv2d: Either strides or dilations must be "+("1. Got strides "+n+" and dilations '"+d+"'")});var He=T(C.shape,_.shape,n,d,a,y,!0),ct=Pe.depthwiseConv2D(C,_,He);return Me([C,_]),ct},U={x:C,filter:_},J={strides:n,pad:a,dataFormat:c,dilations:d,dimRoundingMode:y},fe=Ie.runKernelFunc(B,U,null,ra,J);return D?Ke(fe,[fe.shape[1],fe.shape[2],fe.shape[3]]):fe}var lh=Ee({depthwiseConv2d_:Af});function Df(t){var e=ie(t,"x","diag"),n=function(c){var d=Ke(e,[e.size]),y=c.diag(d),v=t.shape.concat(t.shape);return Ke(y,v)},a={x:e};return Ie.runKernelFunc(n,a,null,sn)}var Ff=Ee({diag_:Df});function Of(t,e,n,a,c,d){c===void 0&&(c=[1,1]),d===void 0&&(d="NHWC");var y=ie(t,"x","dilation2d"),v=ie(e,"filter","dilation2d");W(y.rank===3||y.rank===4,function(){return"Error in dilation2d: input must be rank 3 or 4, but got rank "+(y.rank+".")}),W(v.rank===3,function(){return"Error in dilation2d: filter must be rank 3, but got rank "+(v.rank+".")}),W(d==="NHWC",function(){return"Error in dilation2d: Only NHWC is currently supported, "+("but got dataFormat of "+d)});var _=y,C=!1;y.rank===3&&(_=Ke(y,[1,y.shape[0],y.shape[1],y.shape[2]]),C=!0);var D={x:_,filter:v},B={strides:n,pad:a,dilations:c},U=Ie.runKernel(hn,D,B);return C?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var Xp=Ee({dilation2d_:Of});function Mf(t,e){for(var n=t.length,a=[],c=0;c<n;c++){var d=n-1-c,y=t[d]||1,v=e[e.length-1-c]||1;v>1&&y===1&&a.unshift(d)}return a}function Ja(t,e){for(var n=[],a=0;a<e.length;a++){var c=t[t.length-a-1],d=e.length-a-1,y=e[d];(c==null||c===1&&y>1)&&n.unshift(d)}return n}function ca(t,e){for(var n=[],a=Math.max(t.length,e.length),c=0;c<a;c++){var d=t[t.length-c-1];d==null&&(d=1);var y=e[e.length-c-1];if(y==null&&(y=1),d===1)n.unshift(y);else if(y===1)n.unshift(d);else if(d!==y){var v="Operands could not be broadcast together with shapes "+(t+" and "+e+".");throw Error(v)}else n.unshift(d)}return n}function Lf(t,e){var n,a=ie(t,"a","equal"),c=ie(e,"b","equal");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(v){return v.equal(a,c)},y={a,b:c};return Ie.runKernelFunc(d,y,null,Kn)}var hh=Ee({equal_:Lf});function zf(t,e,n){var a=ie(e,"a","where"),c=ie(n,"b","where"),d=ie(t,"condition","where","bool"),y=ca(a.shape,c.shape),v=Ju(a,y),_=Ju(c,y);d.rank===1&&W(d.shape[0]===a.shape[0],function(){return"The first dimension of `a` must match the size of `condition`."}),d.rank!==1&&nt(d.shape,_.shape,"Error in where: ");var C=function(B,U){var J=B.select(d,v,_);return U([d]),J},D={condition:d,t:v,e:_};return Ie.runKernelFunc(C,D,null,Aa)}var us=Ee({where_:zf});function Pf(t){var e=ie(t,"x","zerosLike"),n={x:e};return Ie.runKernelFunc(function(a){return a.zerosLike(e)},n,null,zs)}var gn=Ee({zerosLike_:Pf});function Bf(t,e){var n,a=ie(t,"a","div"),c=ie(e,"b","div");n=Nt(a,c),a=n[0],c=n[1];var d=Br(a,c),y=gn(d),v=hh(c,y);return us(v,y,d)}var Yp=Ee({divNoNan_:Bf});function Wf(t,e){var n=ie(t,"t1","dot"),a=ie(e,"t2","dot");W((n.rank===1||n.rank===2)&&(a.rank===1||a.rank===2),function(){return"Error in dot: inputs must all be rank 1 or 2, but got ranks "+(n.rank+" and "+a.rank+".")});var c=n.rank===1?n.size:n.shape[1],d=a.rank===1?a.size:a.shape[0];if(W(c===d,function(){return"Error in dot: inner dimensions of inputs must match, but got "+(c+" and "+d+".")}),n.rank===1&&a.rank===1){var y=Ke(n,[1,-1]),v=Ke(a,[-1,1]),_=un(y,v);return Ke(_,[])}else if(n.rank===1&&a.rank===2){var y=Ke(n,[1,-1]),v=Ke(a,[a.shape[0],a.shape[1]]),_=un(y,v);return Ke(_,[_.size])}else if(n.rank===2&&a.rank===1){var v=Ke(a,[-1,1]),_=un(n,v);return Ke(_,[_.size])}else{var v=Ke(a,[a.shape[0],a.shape[1]]),_=un(n,v);return _}}var Qp=Ee({dot_:Wf});function Uf(t){var e=ie(t,"x","elu"),n=function(c,d){var y=c.elu(e);return d([y]),y},a={x:e};return Ie.runKernelFunc(n,a,null,Jn)}var sp=Ee({elu_:Uf});function Vf(t){var e=ie(t,"x","erf");W(e.dtype==="int32"||e.dtype==="float32",function(){return"Input dtype must be `int32` or `float32`."}),e.dtype==="int32"&&(e=pr(e,"float32"));var n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.erf(e);return c([e]),d},n,null,Rn)}var Zp=Ee({erf_:Vf});function Hf(t){var e=ie(t,"x","exp"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.exp(e);return c([d]),d},n,null,aa)}var cs=Ee({exp_:Hf});function Gf(t,e){e===void 0&&(e=0);var n=null,a=ie(t,"x","expandDims",n);W(e<=a.rank,function(){return"Axis must be <= rank of the tensor"});var c=a.shape.slice();return e<0&&(W(-(a.rank+1)<=e,function(){return"Axis must be in the interval ["+-(a.rank+1)+", "+a.rank+"]"}),e=a.rank+e+1),c.splice(e,0,1),Ke(a,c)}var ls=Ee({expandDims_:Gf});function jf(t){var e=ie(t,"x","expm1"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.expm1(e);return c([e]),d},n,null,ma)}var Jp=Ee({expm1_:jf});function qf(t,e){var n=null,a=ie(t,"x","tile",n);W(a.rank===e.length,function(){return"Error in transpose: rank of input "+a.rank+" "+("must match length of reps "+e+".")});var c=function(_,C){var D=_.tile(a,e);return C([a]),D},d=[a],y={x:a},v={reps:e};return Ie.runKernelFunc(c,y,null,Ls,v,d)}var il=Ee({tile_:qf});function Kf(t,e,n,a){a===void 0&&(a="float32"),e==null&&(e=t);for(var c=Qi([t,e],a),d=t<=e?t:e,y=0;y<d;++y)c.set(1,y,y);var v=Ke(c.toTensor(),[t,e]);if(n==null)return v;if(n.length===1)return il(ls(v,0),[n[0],1,1]);if(n.length===2)return il(ls(ls(v,0),0),[n[0],n[1],1,1]);if(n.length===3)return il(ls(ls(ls(v,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."))}var $p=Ee({eye_:Kf});function up(t,e,n){var a={shape:t,value:e,dtype:n};return Ie.runKernelFunc(function(c){return c.fill(t,e,n)},{},null,Ea,a)}function Xf(t){var e=ie(t,"x","floor"),n={x:e};return Ie.runKernelFunc(function(a){return a.floor(e)},n,null,x)}var Nh=Ee({floor_:Xf}),cp=30;function Yf(t){return t<=cp?t:rn(t,Math.floor(Math.sqrt(t)))}function Qf(t,e){var n=!1,a;for(t<=cp?(a=t,n=!0):a=rn(t,Math.floor(Math.sqrt(t)));!n;)a>e||a===t?n=!0:a=rn(t,a+1);return a}function Zf(t,e,n){for(var a=[],c=t.length,d=0;d<c;d++)d!==e?a.push(t[d]):a.push(n);return a}function ed(t,e,n){for(var a=t.shape[n],c=[],d=1,y=1,v=0;v<n;v++)c.push(t.shape[v]),d*=t.shape[v];for(var v=0;v<e.rank;v++)c.push(e.shape[v]);for(var v=n+1;v<t.rank;v++)c.push(t.shape[v]),y*=t.shape[v];return{batchSize:d,sliceSize:y,dimSize:a,outputShape:c}}var Jf={__proto__:null,segOpComputeOptimalWindowSize:Qf,computeOutShape:Zf,collectGatherOpShapeInfo:ed};function $f(t,e,n){n===void 0&&(n=0);var a=ie(t,"x","gather"),c=ie(e,"indices","gather","int32"),d={x:a,indices:c},y={axis:n},v=function(_,C){var D=qt(n,a.shape)[0],B=ed(a,c,D),U=_.gather(a,Ke(c,[c.size]),D);return C([a,c]),Ke(U,B.outputShape)};return Ie.runKernelFunc(v,d,null,Se,y)}var Ch=Ee({gather_:$f});function e1(t,e){var n,a=ie(t,"a","greater"),c=ie(e,"b","greater");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(v){return v.greater(a,c)},y={a,b:c};return Ie.runKernelFunc(d,y,null,Je)}var _u=Ee({greater_:e1});function t1(t,e){var n,a=ie(t,"a","greaterEqual"),c=ie(e,"b","greaterEqual");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(v,_){var C=v.greaterEqual(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,Be)}var $u=Ee({greaterEqual_:t1});function r1(t){var e=ie(t,"input","imag"),n=function(c){return c.imag(e)},a={input:e};return Ie.runKernelFunc(n,a,null,zt)}var Th=Ee({imag_:r1});function n1(t){var e=ie(t,"x","isFinite"),n={x:e};return Ie.runKernelFunc(function(a){return a.isFinite(e)},n,null,Wt)}var td=Ee({isFinite_:n1});function a1(t){var e=ie(t,"x","isInf"),n={x:e};return Ie.runKernelFunc(function(a){return a.isInf(e)},n,null,Gt)}var rd=Ee({isInf_:a1});function i1(t){var e=ie(t,"x","isNaN"),n={x:e};return Ie.runKernelFunc(function(a){return a.isNaN(e)},n,null,Qt)}var nd=Ee({isNaN_:i1});function o1(t,e){var n,a=ie(t,"a","maximum"),c=ie(e,"b","maximum");n=Nt(a,c),a=n[0],c=n[1],a.dtype==="bool"&&(a=pr(a,"int32"),c=pr(c,"int32")),ca(a.shape,c.shape);var d=function(v,_){var C=v.maximum(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,Ra)}var ol=Ee({maximum_:o1});function Wr(t,e){if((Tn(t)&&e!=="string"||Array.isArray(t))&&e!=="complex64")throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if(e==="string"&&Tn(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");var n=[],a=[];return Da(t,n,a,e)}function s1(t,e){e===void 0&&(e=.2);var n=ie(t,"x","leakyRelu");return ol(bt(Wr(e),n),n)}var ad=Ee({leakyRelu_:s1});function u1(t,e){var n,a=ie(t,"a","less"),c=ie(e,"b","less");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(v){return v.less(a,c)},y={a,b:c};return Ie.runKernelFunc(d,y,null,wr)}var Eh=Ee({less_:u1});function c1(t,e){var n,a=ie(t,"a","lessEqual"),c=ie(e,"b","lessEqual");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(v,_){var C=v.lessEqual(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,Ar)}var ec=Ee({lessEqual_:c1});function l1(t,e,n){if(n<=0)throw new Error("The number of values should be positive.");var a={start:t,stop:e,num:n};return Ie.runKernelFunc(function(c){return c.linspace(t,e,n)},{},null,Yt,a)}function h1(t,e,n,a,c){e===void 0&&(e=5),n===void 0&&(n=1),a===void 0&&(a=1),c===void 0&&(c=.5);var d=ie(t,"x","localResponseNormalization");W(d.rank===4||d.rank===3,function(){return`Error in localResponseNormalization: x must be rank 3 or 4 but got
rank `+d.rank+"."}),W(xt(e),function(){return"Error in localResponseNormalization: depthRadius must be an "+("integer but got depthRadius "+e+".")});var y=d,v=!1;d.rank===3&&(v=!0,y=Ke(d,[1,d.shape[0],d.shape[1],d.shape[2]]));var _=function(U,J){var fe=U.localResponseNormalization4D(y,e,n,a,c);return J([y,fe]),fe},C={x:y},D={depthRadius:e,bias:n,alpha:a,beta:c},B=Ie.runKernelFunc(_,C,null,In,D);return v?Ke(B,[B.shape[1],B.shape[2],B.shape[3]]):B}var id=Ee({localResponseNormalization_:h1});function p1(t){var e=ie(t,"x","log"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.log(e);return c([e]),d},n,null,xr)}var tc=Ee({log_:p1});function d1(t){var e=ie(t,"x","log1p"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.log1p(e);return c([e]),d},n,null,Sn)}var lp=Ee({log1p_:d1});function f1(t){return W(la(t),function(){return"The f passed in grad(f) must be a function"}),function(e,n){var a=ie(e,"x","tf.grad",null),c=n!=null?ie(n,"dy","tf.grad"):null;return Ie.tidy(function(){var d=Ie.gradients(function(){return t(a)},[a],c),y=d.value,v=d.grads;return c!=null&&nt(y.shape,c.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Rh(v),v[0]})}}function m1(t){return W(la(t),function(){return"The f passed in grads(f) must be a function"}),function(e,n){W(Array.isArray(e),function(){return"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"});var a=Nn(e,"args","tf.grads",null),c=n!=null?ie(n,"dy","tf.grads"):null;return Ie.tidy(function(){var d=Ie.gradients(function(){return t.apply(void 0,a)},a,c),y=d.value,v=d.grads;return c!=null&&nt(y.shape,c.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Rh(v),v})}}function y1(t){return W(la(t),function(){return"The f passed in valueAndGrad(f) must be a function"}),function(e,n){W(e instanceof $,function(){return"The x passed in valueAndGrad(f)(x) must be a tensor"}),W(n==null||n instanceof $,function(){return"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"});var a=Ie.gradients(function(){return t(e)},[e],n),c=a.grads,d=a.value;return Rh(c),{grad:c[0],value:d}}}function v1(t){return W(la(t),function(){return"The f passed in valueAndGrads(f) must be a function"}),function(e,n){W(Array.isArray(e)&&e.every(function(c){return c instanceof $}),function(){return"The args passed in valueAndGrads(f)(args) must be array of tensors"}),W(n==null||n instanceof $,function(){return"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"});var a=Ie.gradients(function(){return t.apply(void 0,e)},e,n);return n!=null&&nt(a.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Rh(a.grads),a}}function od(t,e){W(la(t),function(){return"The f passed in variableGrads(f) must be a function"}),W(e==null||Array.isArray(e)&&e.every(function(B){return B instanceof et}),function(){return"The varList passed in variableGrads(f, varList) must be an array of variables"});var n=e!=null;if(!n){e=[];for(var a in Ie.registeredVariables)e.push(Ie.registeredVariables[a])}var c=n?e.filter(function(B){return!B.trainable}):null,d=e.length;e=e.filter(function(B){return B.trainable}),W(e.length>0,function(){return"variableGrads() expects at least one of the input variables to "+("be trainable, but none of the "+d+" variables is ")+"trainable."});var y=!0,v=Ie.gradients(t,e,null,y),_=v.value,C=v.grads;W(C.some(function(B){return B!=null}),function(){return"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."}),W(_.rank===0,function(){return"The f passed in variableGrads(f) must return a scalar, but it "+("returned a rank-"+_.rank+" tensor")});var D={};return e.forEach(function(B,U){C[U]!=null&&(D[B.name]=C[U])}),c!=null&&c.forEach(function(B){return D[B.name]=null}),{value:_,grads:D}}function Cs(t){return Ie.customGrad(t)}function Rh(t){var e=t.filter(function(n){return n==null}).length;if(e>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.`)}function g1(t){var e=ie(t,"x","neg"),n={x:e};return Ie.runKernelFunc(function(a){return a.neg(e)},n,null,Io)}var $a=Ee({neg_:g1});function x1(t){var e=ie(t,"x","softplus"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.softplus(e);return c([e]),d},n,null,Xo)}var hp=Ee({softplus_:x1});function _1(t){var e=ie(t,"x","logSigmoid"),n=Cs(function(a){var c=$a(hp($a(a))),d=function(y){var v=bt(y,fn($a(a)));return v};return{value:c,gradFunc:d}});return n(e)}var sd=Ee({logSigmoid_:_1});function w1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","max"),c=function(v,_){var C=qt(e,a.shape),D=C,B=Ji(D,a.rank),U=a;B!=null&&(U=$n(a,B),D=p(D.length,U.rank));var J=v.max(U,D);B!=null&&U.dispose();var fe=J;if(n){var Pe=ci(fe.shape,qt(e,a.shape));fe=Ke(fe,Pe),J.dispose()}return _([a,fe]),fe},d={x:a},y={reductionIndices:e,keepDims:n};return Ie.runKernelFunc(c,d,null,$r,y)}var rc=Ee({max_:w1});function b1(t,e){var n,a=ie(t,"a","sub"),c=ie(e,"b","sub");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.subtract(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,ps)}var zr=Ee({sub_:b1});function k1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","sum");a.dtype==="bool"&&(a=pr(a,"int32"));var c=function(v,_){_([a]);var C=qt(e,a.shape),D=Ji(C,a.rank),B=C,U=a;D!=null&&(U=$n(a,D),B=p(B.length,a.rank));var J=v.sum(U,B);if(n){var fe=ci(J.shape,C);J=Ke(J,fe)}return J},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,Yo,y)}var Yr=Ee({sum_:k1});function S1(t,e){e===void 0&&(e=-1);var n=ie(t,"logits","logSoftmax");if(e===-1&&(e=n.rank-1),e!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. "+("Logits was rank "+n.rank+" and axis was "+e));var a=function(y,v){var _=!0,C=rc(t,e,!0),D=zr(t,C),B=zr(pr(D,"float32"),tc(Yr(cs(D),e,_)));return v([B]),B},c={logits:n},d={axis:e};return Ie.runKernelFunc(a,c,null,wa,d)}var ud=Ee({logSoftmax_:S1});function I1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","logSumExp"),c=qt(e,a.shape),d=rc(a,c,!0),y=zr(a,d),v=cs(y),_=Yr(v,c),C=tc(_),D=Cr(Ke(d,C.shape),C);if(n){var B=ci(D.shape,c);return Ke(D,B)}return D}var pp=Ee({logSumExp_:I1});function N1(t,e){var n=ie(t,"a","logicalAnd","bool"),a=ie(e,"b","logicalAnd","bool");ca(n.shape,a.shape);var c={a:n,b:a};return Ie.runKernelFunc(function(d){return d.logicalAnd(n,a)},c,null,pn)}var nc=Ee({logicalAnd_:N1});function C1(t){var e=ie(t,"x","logicalNot","bool"),n={x:e};return Ie.runKernelFunc(function(a){return a.logicalNot(e)},n,null,zn)}var Ah=Ee({logicalNot_:C1});function T1(t,e){var n=ie(t,"a","logicalOr","bool"),a=ie(e,"b","logicalOr","bool");ca(n.shape,a.shape);var c={a:n,b:a};return Ie.runKernelFunc(function(d){return d.logicalOr(n,a)},c,null,Fr)}var dp=Ee({logicalOr_:T1});function E1(t,e){var n=ie(t,"a","logicalXor","bool"),a=ie(e,"b","logicalXor","bool");return ca(n.shape,a.shape),nc(dp(t,e),Ah(nc(t,e)))}var cd=Ee({logicalXor_:E1});function R1(t,e,n,a,c){var d=ie(t,"x","maxPool"),y=1,v=d,_=!1;d.rank===3&&(_=!0,v=Ke(d,[1,d.shape[0],d.shape[1],d.shape[2]])),W(v.rank===4,function(){return"Error in maxPool: input must be rank 4 but got rank "+v.rank+"."}),W(dt(n,y),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+y+"'")}),c!=null&&W(xt(a),function(){return"Error in maxPool: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var C=function(J,fe){var Pe=h(v.shape,e,n,1,a,c),Me;return Pe.filterWidth===1&&Pe.filterHeight===1&&it(Pe.inShape,Pe.outShape)?Me=v.clone():Me=J.maxPool(v,Pe),fe([v,Me]),Me},D={x:v},B={filterSize:e,strides:n,pad:a,dimRoundingMode:c},U=Ie.runKernelFunc(C,D,null,mi,B);return _?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var fp=Ee({maxPool_:R1});function A1(t,e,n,a,c,d,y){e===void 0&&(e=[1,1,1]),d===void 0&&(d="NDHWC"),y==null?y=[1,1,1]:Sa("dilations is deprecated, this field will be gone in v3.0.0.");var v=ie(t,"x","maxPool3d"),_=v,C=!1;v.rank===4&&(C=!0,_=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2],v.shape[3]])),W(_.rank===5,function(){return"Error in maxPool3d: x must be rank 5 but got rank "+_.rank+"."}),W(d==="NDHWC",function(){return"Error in maxPool3d: Only NDHWC is currently supported, "+("but got dataFormat of "+d)}),W(dt(n,y),function(){return"Error in maxPool3d: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+y+"'")}),c!=null&&W(xt(a),function(){return"Error in maxPool3d: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var D=function(fe,Pe){y==null&&(y=[1,1,1]);var Me=b(_.shape,e,n,y,a,c,d),He=fe.maxPool3d(_,Me);return Pe([_,He]),He},B={x:_},U={filterSize:e,strides:n,pad:a,dimRoundingMode:c,dataFormat:d,dilations:y},J=Ie.runKernelFunc(D,B,null,ja,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var D1=Ee({maxPool3d_:A1});function F1(t,e,n,a,c){c===void 0&&(c=!1);var d=ie(t,"x","maxPoolWithArgmax"),y={x:d},v={filterSize:e,strides:n,pad:a,includeBatchInIndex:c},_=Ie.runKernel(zi,y,v);return{result:_[0],indexes:_[1]}}var O1=Ee({maxPoolWithArgmax_:F1});function Ys(t,e){if(e===void 0&&(e="float32"),e==="complex64"){var n=Ys(t,"float32"),a=Ys(t,"float32");return Pn(n,a)}var c=ha(Tt(t),e);return Ie.makeTensor(c,t,e)}function sl(t,e){if(e===void 0&&(e="float32"),e==="complex64"){var n=sl(t,"float32"),a=Ys(t,"float32");return Pn(n,a)}var c=_i(Tt(t),e);return Ie.makeTensor(c,t,e)}function M1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","mean"),c=qt(e,a.shape),d=rl(a.shape,c),y=d[1],v=Tt(y),_={x:a},C={axis:e,keepDims:n},D=function(){var U=Wr(v),J=U.dtype===a.dtype?a:pr(a,U.dtype),fe=Br(J,U);return Yr(fe,e,n)},B=Cs(function(U){var J=Ie.runKernelFunc(D,_,null,An,C),fe=function(Pe){var Me=U.shape.slice();c.forEach(function(It){Me[It]=1});var He=Ke(Pe,Me),ct=Br(bt(He,sl(U.shape,"float32")),v);return ct};return{value:J,gradFunc:fe}});return B(a)}var ph=Ee({mean_:M1});function L1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","min"),c=function(v,_){var C=qt(e,a.shape),D=C,B=Ji(D,a.rank),U=a;B!=null&&(U=$n(a,B),D=p(D.length,a.rank));var J=v.min(U,D);B!=null&&U.dispose();var fe=J;if(n){var Pe=ci(fe.shape,C);fe=Ke(J,Pe),J.dispose()}return _([a,fe]),fe},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,ba,y)}var Dh=Ee({min_:L1});function z1(t,e){var n,a=ie(t,"a","minimum"),c=ie(e,"b","minimum");n=Nt(a,c),a=n[0],c=n[1],a.dtype==="bool"&&(a=pr(a,"int32"),c=pr(c,"int32")),ca(a.shape,c.shape);var d=function(v,_){var C=v.minimum(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,qi)}var Fh=Ee({minimum_:z1});function P1(t,e,n){W(n==="reflect"||n==="symmetric",function(){return"Invalid mode. Mode must be either reflect or symmetric. "+("Got "+n+".")});var a=ie(t,"x","mirrorPad");if(a.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");W(e.length===a.rank,function(){return"Padding doesn't match input. Must be "+a.rank+". "+("Got "+e.length+".")});for(var c=n==="reflect"?1:0,d=function(C){W(e[C].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),W(e[C][0]>=0&&e[C][0]<=a.shape[C]-c&&e[C][1]>=0&&e[C][1]<=a.shape[C]-c,function(){return"Padding in dimension "+C+" cannot be greater than or equal "+("to "+(a.shape[C]-c)+" or less than 0 for input of ")+("shape "+a.shape)})},y=0;y<a.rank;y++)d(y);var v={paddings:e,mode:n},_={x:a};return Ie.runKernel(yi,_,v)}var ld=Ee({mirrorPad_:P1});function B1(t,e){var n,a=ie(t,"a","mod"),c=ie(e,"b","mod");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.mod(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,ii)}var mp=Ee({mod_:B1});function W1(t){var e=ie(t,"x","square"),n={},a=[e],c=[];return Ie.runKernelFunc(function(d,y){return y([e]),d.square(e)},{x:e},null,"Square",n,a,c)}var Yn=Ee({square_:W1});function U1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1),t=ie(t,"x","moments");var a=qt(e,t.shape),c=ph(t,a,n),d=c.shape;n||(d=ci(c.shape,a));var y=Yn(zr(pr(t,"float32"),Ke(c,d))),v=ph(y,a,n);return{mean:c,variance:v}}var V1=Ee({moments_:U1});function H1(t,e,n,a){for(var c=ie(e,"data","multiRNNCell"),d=Nn(n,"c","multiRNNCell"),y=Nn(a,"h","multiRNNCell"),v=c,_=[],C=0;C<t.length;C++){var D=t[C](v,d[C],y[C]);_.push(D[0]),_.push(D[1]),v=D[1]}for(var B=[],U=[],C=0;C<_.length;C+=2)B.push(_[C]),U.push(_[C+1]);return[B,U]}var G1=Ee({multiRNNCell_:H1});function j1(t,e,n,a){a===void 0&&(a=!1);var c=ie(t,"logits","multinomial"),d=c.size,y=c.rank;if(d<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+(d+"."));if(y>2)throw new Error("Rank of probabilities must be 1 or 2, but is "+y);n=n||Math.random();var v=y===1?Ke(c,[1,-1]):c,_=Ie.runKernelFunc(function(C){return C.multinomial(v,a,e,n)},{logits2D:v});return y===1?Ke(_,[_.size]):_}var q1=Ee({multinomial_:j1});function K1(t,e){var n,a=ie(t,"a","notEqual"),c=ie(e,"b","notEqual");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(v){return v.notEqual(a,c)},y={a,b:c};return Ie.runKernelFunc(d,y,null,nn)}var Oh=Ee({notEqual_:K1});function X1(t){var e=ie(t,"input","real"),n=function(c){return c.real(e)},a={input:e};return Ie.runKernelFunc(n,a,null,Co)}var dh=Ee({real_:X1});function Y1(t){var e=ie(t,"x","onesLike"),n=function(c,d){if(e.dtype==="complex64"){var y=yp(dh(e)),v=gn(Th(e));return Pn(y,v)}return c.onesLike(e)},a={x:e};return Ie.runKernelFunc(n,a,null,oi)}var yp=Ee({onesLike_:Y1});function Q1(t,e){var n=ie(t,"v1","outerProduct"),a=ie(e,"v2","outerProduct");W(n.rank===1&&a.rank===1,function(){return"Error in outerProduct: inputs must be rank 1, but got ranks "+(n.rank+" and "+a.rank+".")});var c=Ke(n,[-1,1]),d=Ke(a,[1,-1]);return un(c,d)}var Z1=Ee({outerProduct_:Q1});function J1(t,e,n){n===void 0&&(n=0);var a=ie(t,"x","pad");if(a.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var c=function(v,_){return _([a]),v.pad(a,e,n)},d={paddings:e,constantValue:n},y={x:a};return Ie.runKernelFunc(c,y,null,no,d)}var ac=Ee({pad_:J1});function $1(t,e,n){return n===void 0&&(n=0),W(e.length===2,function(){return"Invalid number of paddings. Must be length of 2."}),ac(t,[e],n)}var em=Ee({pad1d_:$1});function tm(t,e,n){return n===void 0&&(n=0),W(e.length===2&&e[0].length===2&&e[1].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),ac(t,e,n)}var rm=Ee({pad2d_:tm});function nm(t,e,n){return n===void 0&&(n=0),W(e.length===3&&e[0].length===2&&e[1].length===2&&e[2].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),ac(t,e,n)}var am=Ee({pad3d_:nm});function im(t,e,n){return n===void 0&&(n=0),W(e.length===4&&e[0].length===2&&e[1].length===2&&e[2].length===2&&e[3].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),ac(t,e,n)}var om=Ee({pad4d_:im});function sm(t,e,n){var a=ie(t,"x","spaceToBatchND");W(a.rank>=1+e.length,function(){return"input rank "+a.rank+" should be > than [blockShape] "+e.length}),W(n.length===e.length,function(){return"paddings.shape[0] "+n.length+" must be equal to [blockShape] "+e.length}),W(a.shape.reduce(function(v,_,C){return C>0&&C<=e.length?v&&(_+n[C-1][0]+n[C-1][1])%e[C-1]===0:v},!0),function(){return"input spatial dimensions "+a.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+e.toString()});var c=function(v){return v.spaceToBatchND(a,e,n)},d={x:a},y={blockShape:e,paddings:n};return Ie.runKernelFunc(c,d,null,Ao,y)}var Mh=Ee({spaceToBatchND_:sm});function um(t,e,n,a,c,d){c==null&&(c=[1,1]),d==null&&(d=1),a===0&&(a="valid");var y=ie(t,"x","maxPool"),v=y,_=!1;y.rank===3&&(_=!0,v=Ke(y,[1,y.shape[0],y.shape[1],y.shape[2]])),W(dt(d,c),function(){return"Error in pool: Either strides or dilations must be 1. "+("Got strides "+d+" and dilations '"+c+"'")});var C=h(v.shape,e,d,c,a),D=[C.dilationHeight,C.dilationWidth],B;a==="same"?B=lm([C.filterHeight,C.filterWidth],D):B=[[0,0],[0,0]];var U=D[0]===1&&D[1]===1,J=cm([C.inHeight,C.inWidth],D,B),fe=J[0],Pe=J[1],Me=U?a:"valid",He=U?v:Mh(v,D,fe),ct=n==="avg"?function(){return Xt(He,e,d,Me)}:function(){return fp(He,e,d,Me)},It=ct(),Ct=U?It:Hr(It,D,Pe);return _?Ke(Ct,[Ct.shape[1],Ct.shape[2],Ct.shape[3]]):Ct}function cm(t,e,n){var a=n.map(function(D){return D[0]}),c=n.map(function(D){return D[1]}),d=t.concat(a,c),y=e.map(function(D,B){return(D-d[B]%D)%D}),v=c.map(function(D,B){return D+y[B]}),_=e.map(function(D,B){return[a[B],v[B]]}),C=e.map(function(D,B){return[0,y[B]]});return[_,C]}function lm(t,e){var n=t.map(function(y,v){return y+(y-1)*(e[v]-1)}),a=n.map(function(y){return y-1}),c=a.map(function(y){return Math.floor(y/2)}),d=a.map(function(y,v){return y-c[v]});return a.map(function(y,v){return[c[v],d[v]]})}var hd=Ee({pool_:um});function hm(t,e){var n,a=ie(t,"base","pow"),c=ie(e,"exp","pow");n=Nt(a,c),a=n[0],c=n[1];var d={a,b:c},y=function(v,_){var C=v.pow(a,c);return _([a,c,C]),C};return Ie.runKernelFunc(y,d,null,Ka)}var Qs=Ee({pow_:hm});function pm(t,e){var n=ie(t,"x","prelu"),a=ie(e,"alpha","prelu"),c=function(y,v){var _=y.prelu(n,a);return v([n,a]),_},d={x:n,alpha:a};return Ie.runKernelFunc(c,d,null,ao)}var vp=Ee({prelu_:pm});function dm(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","prod");a.dtype==="bool"&&(a=pr(a,"int32"));var c=function(v){var _=qt(e,a.shape),C=Ji(_,a.rank),D=_,B=a;C!=null&&(B=$n(a,C),D=p(D.length,a.rank));var U=v.prod(B,D);if(n){var J=ci(U.shape,_);U=Ke(U,J)}return U},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,Ko,y)}var pd=Ee({prod_:dm});function fm(t,e,n){var a=Tt(t),c=null;if(n==null||n==="float32")c=new Float32Array(a);else if(n==="int32")c=new Int32Array(a);else if(n==="bool")c=new Uint8Array(a);else throw new Error("Unknown data type "+n);for(var d=0;d<a;d++)c[d]=e();return Ie.makeTensor(c,t,n)}var mm=Ee({rand_:fm}),ul=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ic(t,e){return e={exports:{}},t(e,e.exports),e.exports}var ym=ic(function(t){(function(e,n,a){function c(_){var C=this,D=v();C.next=function(){var B=2091639*C.s0+C.c*23283064365386963e-26;return C.s0=C.s1,C.s1=C.s2,C.s2=B-(C.c=B|0)},C.c=1,C.s0=D(" "),C.s1=D(" "),C.s2=D(" "),C.s0-=D(_),C.s0<0&&(C.s0+=1),C.s1-=D(_),C.s1<0&&(C.s1+=1),C.s2-=D(_),C.s2<0&&(C.s2+=1),D=null}function d(_,C){return C.c=_.c,C.s0=_.s0,C.s1=_.s1,C.s2=_.s2,C}function y(_,C){var D=new c(_),B=C&&C.state,U=D.next;return U.int32=function(){return D.next()*4294967296|0},U.double=function(){return U()+(U()*2097152|0)*11102230246251565e-32},U.quick=U,B&&(typeof B=="object"&&d(B,D),U.state=function(){return d(D,{})}),U}function v(){var _=4022871197,C=function(D){D=D.toString();for(var B=0;B<D.length;B++){_+=D.charCodeAt(B);var U=.02519603282416938*_;_=U>>>0,U-=_,U*=_,_=U>>>0,U-=_,_+=U*4294967296}return(_>>>0)*23283064365386963e-26};return C}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.alea=y})(ul,t,!1)}),vm=ic(function(t){(function(e,n,a){function c(v){var _=this,C="";_.x=0,_.y=0,_.z=0,_.w=0,_.next=function(){var B=_.x^_.x<<11;return _.x=_.y,_.y=_.z,_.z=_.w,_.w^=_.w>>>19^B^B>>>8},v===(v|0)?_.x=v:C+=v;for(var D=0;D<C.length+64;D++)_.x^=C.charCodeAt(D)|0,_.next()}function d(v,_){return _.x=v.x,_.y=v.y,_.z=v.z,_.w=v.w,_}function y(v,_){var C=new c(v),D=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(typeof D=="object"&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.xor128=y})(ul,t,!1)}),gm=ic(function(t){(function(e,n,a){function c(v){var _=this,C="";_.next=function(){var B=_.x^_.x>>>2;return _.x=_.y,_.y=_.z,_.z=_.w,_.w=_.v,(_.d=_.d+362437|0)+(_.v=_.v^_.v<<4^(B^B<<1))|0},_.x=0,_.y=0,_.z=0,_.w=0,_.v=0,v===(v|0)?_.x=v:C+=v;for(var D=0;D<C.length+64;D++)_.x^=C.charCodeAt(D)|0,D==C.length&&(_.d=_.x<<10^_.x>>>4),_.next()}function d(v,_){return _.x=v.x,_.y=v.y,_.z=v.z,_.w=v.w,_.v=v.v,_.d=v.d,_}function y(v,_){var C=new c(v),D=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(typeof D=="object"&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.xorwow=y})(ul,t,!1)}),xm=ic(function(t){(function(e,n,a){function c(v){var _=this;_.next=function(){var D=_.x,B=_.i,U,J;return U=D[B],U^=U>>>7,J=U^U<<24,U=D[B+1&7],J^=U^U>>>10,U=D[B+3&7],J^=U^U>>>3,U=D[B+4&7],J^=U^U<<7,U=D[B+7&7],U=U^U<<13,J^=U^U<<9,D[B]=J,_.i=B+1&7,J};function C(D,B){var U,J,fe=[];if(B===(B|0))J=fe[0]=B;else for(B=""+B,U=0;U<B.length;++U)fe[U&7]=fe[U&7]<<15^B.charCodeAt(U)+fe[U+1&7]<<13;for(;fe.length<8;)fe.push(0);for(U=0;U<8&&fe[U]===0;++U);for(U==8?J=fe[7]=-1:J=fe[U],D.x=fe,D.i=0,U=256;U>0;--U)D.next()}C(_,v)}function d(v,_){return _.x=v.x.slice(),_.i=v.i,_}function y(v,_){v==null&&(v=+new Date);var C=new c(v),D=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(D.x&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.xorshift7=y})(ul,t,!1)}),_m=ic(function(t){(function(e,n,a){function c(v){var _=this;_.next=function(){var D=_.w,B=_.X,U=_.i,J,fe;return _.w=D=D+1640531527|0,fe=B[U+34&127],J=B[U=U+1&127],fe^=fe<<13,J^=J<<17,fe^=fe>>>15,J^=J>>>12,fe=B[U]=fe^J,_.i=U,fe+(D^D>>>16)|0};function C(D,B){var U,J,fe,Pe,Me,He=[],ct=128;for(B===(B|0)?(J=B,B=null):(B=B+"\0",J=0,ct=Math.max(ct,B.length)),fe=0,Pe=-32;Pe<ct;++Pe)B&&(J^=B.charCodeAt((Pe+32)%B.length)),Pe===0&&(Me=J),J^=J<<10,J^=J>>>15,J^=J<<4,J^=J>>>13,Pe>=0&&(Me=Me+1640531527|0,U=He[Pe&127]^=J+Me,fe=U==0?fe+1:0);for(fe>=128&&(He[(B&&B.length||0)&127]=-1),fe=127,Pe=4*128;Pe>0;--Pe)J=He[fe+34&127],U=He[fe=fe+1&127],J^=J<<13,U^=U<<17,J^=J>>>15,U^=U>>>12,He[fe]=J^U;D.w=Me,D.X=He,D.i=fe}C(_,v)}function d(v,_){return _.i=v.i,_.w=v.w,_.X=v.X.slice(),_}function y(v,_){v==null&&(v=+new Date);var C=new c(v),D=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(D.X&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.xor4096=y})(ul,t,!1)}),wm=ic(function(t){(function(e,n,a){function c(v){var _=this,C="";_.next=function(){var B=_.b,U=_.c,J=_.d,fe=_.a;return B=B<<25^B>>>7^U,U=U-J|0,J=J<<24^J>>>8^fe,fe=fe-B|0,_.b=B=B<<20^B>>>12^U,_.c=U=U-J|0,_.d=J<<16^U>>>16^fe,_.a=fe-B|0},_.a=0,_.b=0,_.c=2654435769|0,_.d=1367130551,v===Math.floor(v)?(_.a=v/4294967296|0,_.b=v|0):C+=v;for(var D=0;D<C.length+20;D++)_.b^=C.charCodeAt(D)|0,_.next()}function d(v,_){return _.a=v.a,_.b=v.b,_.c=v.c,_.d=v.d,_}function y(v,_){var C=new c(v),D=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(typeof D=="object"&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.tychei=y})(ul,t,!1)}),oc=ic(function(t){(function(e,n){var a=this,c=256,d=6,y=52,v="random",_=n.pow(c,d),C=n.pow(2,y),D=C*2,B=c-1,U;function J(Ct,Bt,sr){var er=[];Bt=Bt==!0?{entropy:!0}:Bt||{};var mr=He(Me(Bt.entropy?[Ct,It(e)]:Ct??ct(),3),er),Gr=new fe(er),en=function(){for(var Qr=Gr.g(d),Zr=_,Kr=0;Qr<C;)Qr=(Qr+Kr)*c,Zr*=c,Kr=Gr.g(1);for(;Qr>=D;)Qr/=2,Zr/=2,Kr>>>=1;return(Qr+Kr)/Zr};return en.int32=function(){return Gr.g(4)|0},en.quick=function(){return Gr.g(4)/4294967296},en.double=en,He(It(Gr.S),e),(Bt.pass||sr||function(Qr,Zr,Kr,Un){return Un&&(Un.S&&Pe(Un,Gr),Qr.state=function(){return Pe(Gr,{})}),Kr?(n[v]=Qr,Zr):Qr})(en,mr,"global"in Bt?Bt.global:this==n,Bt.state)}n["seed"+v]=J;function fe(Ct){var Bt,sr=Ct.length,er=this,mr=0,Gr=er.i=er.j=0,en=er.S=[];for(sr||(Ct=[sr++]);mr<c;)en[mr]=mr++;for(mr=0;mr<c;mr++)en[mr]=en[Gr=B&Gr+Ct[mr%sr]+(Bt=en[mr])],en[Gr]=Bt;(er.g=function(Qr){for(var Zr,Kr=0,Un=er.i,mn=er.j,Ln=er.S;Qr--;)Zr=Ln[Un=B&Un+1],Kr=Kr*c+Ln[B&(Ln[Un]=Ln[mn=B&mn+Zr])+(Ln[mn]=Zr)];return er.i=Un,er.j=mn,Kr})(c)}function Pe(Ct,Bt){return Bt.i=Ct.i,Bt.j=Ct.j,Bt.S=Ct.S.slice(),Bt}function Me(Ct,Bt){var sr=[],er=typeof Ct,mr;if(Bt&&er=="object")for(mr in Ct)try{sr.push(Me(Ct[mr],Bt-1))}catch(Gr){}return sr.length?sr:er=="string"?Ct:Ct+"\0"}function He(Ct,Bt){for(var sr=Ct+"",er,mr=0;mr<sr.length;)Bt[B&mr]=B&(er^=Bt[B&mr]*19)+sr.charCodeAt(mr++);return It(Bt)}function ct(){try{var Ct;return U&&(Ct=U.randomBytes)?Ct=Ct(c):(Ct=new Uint8Array(c),(a.crypto||a.msCrypto).getRandomValues(Ct)),It(Ct)}catch(er){var Bt=a.navigator,sr=Bt&&Bt.plugins;return[+new Date,a,sr,a.screen,It(e)]}}function It(Ct){return String.fromCharCode.apply(0,Ct)}if(He(n.random(),e),t.exports){t.exports=J;try{U=Pp()}catch(Ct){}}})([],Math)});oc.alea=ym,oc.xor128=vm,oc.xorwow=gm,oc.xorshift7=xm,oc.xor4096=_m,oc.tychei=wm;var bm=oc,gp=bm.alea,xp=function(){function t(e,n,a,c,d){this.mean=e,this.stdDev=n,this.dtype=a,this.nextVal=NaN,this.truncated=c,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);var y=d||Math.random();this.random=gp(y.toString())}return t.prototype.nextValue=function(){if(!isNaN(this.nextVal)){var e=this.nextVal;return this.nextVal=NaN,e}for(var n,a,c=!1;!c;){var d=void 0,y=void 0,v=void 0;do d=2*this.random()-1,y=2*this.random()-1,v=d*d+y*y;while(v>=1||v===0);var _=Math.sqrt(-2*Math.log(v)/v);n=this.mean+this.stdDev*d*_,a=this.mean+this.stdDev*y*_,(!this.truncated||this.isValidTruncated(n))&&(c=!0)}return(!this.truncated||this.isValidTruncated(a))&&(this.nextVal=this.convertValue(a)),this.convertValue(n)},t.prototype.convertValue=function(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)},t.prototype.isValidTruncated=function(e){return e<=this.upper&&e>=this.lower},t}(),km=function(){function t(e,n,a,c){this.alpha=e,this.beta=1/n,this.dtype=a;var d=c||Math.random();this.randu=gp(d.toString()),this.randn=new xp(0,1,a,!1,this.randu()),e<1?this.d=e+2/3:this.d=e-1/3,this.c=1/Math.sqrt(9*this.d)}return t.prototype.nextValue=function(){for(var e,n,a,c,d,y;;){do c=this.randn.nextValue(),y=1+this.c*c;while(y<=0);if(y*=y*y,e=c*c,n=1-.331*e*e,a=.5*e+this.d*(1-y+Math.log(y)),d=this.randu(),d<n||Math.log(d)<a)break}return y=1/this.beta*this.d*y,this.alpha<1&&(y*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(y)},t.prototype.convertValue=function(e){return this.dtype==="float32"?e:Math.round(e)},t}(),Sm=function(){function t(e,n,a,c){var d=this;if(e===void 0&&(e=0),n===void 0&&(n=1),this.canReturnFloat=function(){return d.dtype==null||d.dtype==="float32"},this.min=e,this.range=n-e,this.dtype=a,c==null&&(c=Math.random()),typeof c=="number"&&(c=c.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error("The difference between "+e+" - "+n+" <= 1 and dtype is not float");this.random=gp(c)}return t.prototype.convertValue=function(e){return this.canReturnFloat()?e:Math.round(e)},t.prototype.nextValue=function(){return this.convertValue(this.min+this.range*this.random())},t}();function Im(t,e,n,a,c){if(n===void 0&&(n=1),a===void 0&&(a="float32"),n==null&&(n=1),a==null&&(a="float32"),a!=="float32"&&a!=="int32")throw new Error("Unsupported data type "+a);for(var d=new km(e,n,a,c),y=Qi(t,a),v=0;v<y.values.length;v++)y.values[v]=d.nextValue();return y.toTensor()}var Nm=Ee({randomGamma_:Im});function Cm(t,e,n,a,c){if(e===void 0&&(e=0),n===void 0&&(n=1),a!=null&&a==="bool")throw new Error("Unsupported data type "+a);for(var d=new xp(e,n,a,!1,c),y=Qi(t,a),v=0;v<y.values.length;v++)y.values[v]=d.nextValue();return y.toTensor()}var Tm=Ee({randomNormal_:Cm});function Em(t,e,n,a,c){e===void 0&&(e=0),n===void 0&&(n=1),a===void 0&&(a="float32");for(var d=Qi(t,a),y=new Sm(e,n,null,c),v=0;v<d.values.length;v++)d.values[v]=y.nextValue();return d.toTensor()}var dd=Ee({randomUniform_:Em});function cl(t,e){tt(t);var n=Er(t,e);if(n.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");var a=null;return Da(t,a,n,e)}function _p(t,e,n,a){if(n===void 0&&(n=1),a===void 0&&(a="float32"),n===0)throw new Error("Cannot have a step of zero");var c=function(){var y=t===e,v=t<e&&n<0,_=e<t&&n>1;if(y||v||_)return Ys([0],a);var C=Math.abs(Math.ceil((e-t)/n)),D=ha(C,a);e<t&&n===1&&(n=-1),D[0]=t;for(var B=1;B<D.length;B++)D[B]=D[B-1]+n;return cl(D,a)},d={start:t,stop:e,step:n,dtype:a};return Ie.runKernelFunc(c,{},null,No,d)}function Rm(t){var e=ie(t,"x","reciprocal"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.reciprocal(e);return c([e]),d},n,null,io)}var fd=Ee({reciprocal_:Rm});function Am(t){var e=ie(t,"x","relu"),n=function(c,d){return d([e]),e.dtype==="bool"?pr(e,"int32"):c.relu(e)},a={x:e};return Ie.runKernelFunc(n,a,null,ia)}var fh=Ee({relu_:Am});function Dm(t){var e=ie(t,"x","relu6"),n=function(c,d){return d([e]),e.dtype==="bool"?pr(e,"int32"):c.relu6(e)},a={x:e};return Ie.runKernelFunc(n,a,null,ka)}var wp=Ee({relu6_:Dm});function Fm(t,e){var n=ie(t,"x","reverse"),a=function(y){var v=qt(e,n.shape);if(n.rank===0)return Ho(n);var _=y.reverse(n,v);return Ke(_,n.shape)},c={x:n},d={dims:e};return Ie.runKernelFunc(a,c,null,vn,d)}var Zs=Ee({reverse_:Fm});function Om(t){var e=ie(t,"x","reverse");return W(e.rank===1,function(){return"Error in reverse1D: x must be rank 1 but got rank "+e.rank+"."}),Zs(e,0)}var Mm=Ee({reverse1d_:Om});function Lm(t,e){var n=ie(t,"x","reverse");return W(n.rank===2,function(){return"Error in reverse2D: x must be rank 2 but got rank "+n.rank+"."}),Zs(n,e)}var zm=Ee({reverse2d_:Lm});function Pm(t,e){var n=ie(t,"x","reverse");return W(n.rank===3,function(){return"Error in reverse3D: x must be rank 3 but got rank "+n.rank+"."}),Zs(n,e)}var Bm=Ee({reverse3d_:Pm});function Wm(t,e){var n=ie(t,"x","reverse");return W(n.rank===4,function(){return"Error in reverse4D: x must be rank 4 but got rank "+n.rank+"."}),Zs(n,e)}var Um=Ee({reverse4d_:Wm});function Vm(t){var e=ie(t,"x","round"),n={x:e};return Ie.runKernelFunc(function(a){return a.round(e)},n,null,Bi)}var md=Ee({round_:Vm});function Hm(t){var e=ie(t,"x","rsqrt"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.rsqrt(e);return c([e]),d},n,null,yo)}var bp=Ee({rsqrt_:Hm});function Gm(t){var e=ie(t,"x","selu"),n=function(c,d){var y=c.selu(e);return d([e]),y},a={x:e};return Ie.runKernelFunc(n,a,null,go)}var yd=Ee({selu_:Gm});function jm(t,e,n,a,c,d,y){d===void 0&&(d=[1,1]),y===void 0&&(y="NHWC");var v=ie(t,"x","separableConv2d"),_=ie(e,"depthwiseFilter","separableConv2d"),C=ie(n,"pointwiseFilter","separableConv2d"),D=v,B=!1;if(v.rank===3&&(B=!0,D=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2]])),y==="NCHW")throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");W(D.rank===4,function(){return"Error in separableConv2d: input must be rank 4, but got "+("rank "+D.rank+".")}),W(_.rank===4,function(){return"Error in separableConv2d: depthwise filter must be rank 4, but "+("got rank "+_.rank+".")}),W(C.rank===4,function(){return"Error in separableConv2d: pointwise filter must be rank 4, but "+("got rank "+_.rank+".")}),W(C.shape[0]===1,function(){return"Error in separableConv2d: the first dimension of pointwise filter "+(" must be 1, but got "+C.shape[0]+".")}),W(C.shape[1]===1,function(){return"Error in separableConv2d: the second dimension of pointwise "+("filter must be 1, but got "+C.shape[1]+".")});var U=_.shape[2],J=_.shape[3];W(C.shape[2]===U*J,function(){return"Error in separableConv2d: the third dimension of pointwise filter "+("must be "+U*J+", ")+("but got "+C.shape[2]+".")});var fe=lh(D,_,a,c,y,d),Pe=1,Me=gi(fe,C,Pe,"valid",y);return B?Ke(Me,[Me.shape[1],Me.shape[2],Me.shape[3]]):Me}var vd=Ee({separableConv2d_:jm});function qm(t,e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,D,_,B;return H(this,function(U){switch(U.label){case 0:return n=ie(t,"x","setdiff1d"),a=ie(e,"y","setdiff1d"),W(n.dtype===a.dtype,function(){return"x and y should have the same dtype, but got x ("+n.dtype+") and y ("+a.dtype+")."}),W(n.rank===1,function(){return"x should be 1D tensor, but got x ("+n.shape+")."}),W(a.rank===1,function(){return"y should be 1D tensor, but got y ("+a.shape+")."}),[4,n.data()];case 1:return c=U.sent(),[4,a.data()];case 2:for(d=U.sent(),y=new Set(d),v=0,_=0;_<c.length;_++)y.has(c[_])||v++;for(C=new Fe([v],n.dtype),D=new Fe([v],"int32"),_=0,B=0;_<c.length;_++)y.has(c[_])||(C.values[B]=c[_],D.values[B]=_,B++);return[2,[C.toTensor(),D.toTensor()]]}})})}var Km=qm;function Xm(t){var e=ie(t,"x","sign"),n={x:e};return Ie.runKernelFunc(function(a){return a.sign(e)},n,null,As)}var gd=Ee({sign_:Xm});function Ym(t){var e=ie(t,"x","sin"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.sin(e);return c([e]),d},n,null,Rs)}var kp=Ee({sin_:Ym});function Qm(t){var e=ie(t,"x","sinh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.sinh(e);return c([e]),d},n,null,Eo)}var Sp=Ee({sinh_:Qm});function Zm(t,e,n){var a=ie(t,"x","slice1d");return W(a.rank===1,function(){return"slice1d expects a rank-1 tensor, but got a rank-"+a.rank+" tensor"}),$t(a,[e],[n])}var Jm=Ee({slice1d_:Zm});function $m(t,e,n){var a=ie(t,"x","slice2d");return W(a.rank===2,function(){return"slice2d expects a rank-2 tensor, but got a rank-"+a.rank+" tensor"}),$t(a,e,n)}var ey=Ee({slice2d_:$m});function ty(t,e,n){var a=ie(t,"x","slice3d");return W(a.rank===3,function(){return"slice3d expects a rank-3 tensor, but got a rank-"+a.rank+" tensor"}),$t(a,e,n)}var ry=Ee({slice3d_:ty});function ny(t,e,n){var a=ie(t,"x","slice4d");return W(a.rank===4,function(){return"slice4d expects a rank-4 tensor, but got a rank-"+a.rank+" tensor"}),$t(a,e,n)}var ay=Ee({slice4d_:ny});function iy(t,e){e===void 0&&(e=-1);var n=ie(t,"logits","softmax","float32");if(e===-1&&(e=n.rank-1),e!==n.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. "+("Logits was rank "+n.rank+" and dim was "+e));var a={logits:n},c={dim:e};return Ie.runKernelFunc(function(d,y){var v=d.softmax(n,e);return y([v]),v},a,null,vi,c)}var xd=Ee({softmax_:iy});function oy(t){W(t.dtype==="complex64",function(){return"The dtype for tf.spectral.fft() must be complex64 "+("but got "+t.dtype+".")});var e={input:t};return Ie.runKernelFunc(function(n){var a=t.shape[t.shape.length-1],c=t.size/a,d=t.as2D(c,a),y=n.fft(d);return y.reshape(t.shape)},e,null,Li)}var Lh=Ee({fft_:oy});function sy(t){W(t.dtype==="complex64",function(){return"The dtype for tf.spectral.ifft() must be complex64 "+("but got "+t.dtype+".")});var e={input:t};return Ie.runKernelFunc(function(n){var a=t.shape[t.shape.length-1],c=t.size/a,d=Ke(t,[c,a]),y=n.ifft(d);return Ke(y,t.shape)},e,null,ft)}var mh=Ee({ifft_:sy});function uy(t){var e=t.shape[t.shape.length-1],n=t.size/e,a;if(e<=2){var c=Ke(t,[n,e]);a=mh(c)}else{var d=[n,2*(e-1)],y=Ke(dh(t),[n,e]),v=Ke(Th(t),[n,e]),_=Zs($t(y,[0,1],[n,e-2]),1),C=bt(Zs($t(v,[0,1],[n,e-2]),1),Wr(-1)),D=kr([y,_],1),B=kr([v,C],1),c=Ke(Pn(D,B),[d[0],d[1]]);a=mh(c)}if(a=dh(a),t.rank===3&&t.shape[0]!==0){var U=a,J=t.shape[0];a=Ke(a,[J,a.shape[0]/J,a.shape[1]]),U.dispose()}return a}var Ip=Ee({irfft_:uy});function _d(t,e,n){n===void 0&&(n=0);var a=[];if(typeof e=="number")W(t.shape[n]%e===0,function(){return"Number of splits must evenly divide the axis."}),a=new Array(e).fill(t.shape[n]/e);else{var c=e.reduce(function(v,_){return _===-1&&(v+=1),v},0);W(c<=1,function(){return"There should be only one negative value in split array."});var d=e.indexOf(-1);if(d!==-1){var y=e.reduce(function(v,_){return _>0?v+_:v});e[d]=t.shape[n]-y}W(t.shape[n]===e.reduce(function(v,_){return v+_}),function(){return"The sum of sizes must match the size of the axis dimension."}),a=e}return a}function cy(t,e,n){n===void 0&&(n=0);var a=ie(t,"x","split"),c=function(v,_){var C=qt(n,a.shape)[0],D=_d(a,e,C);return v.split(a,D,C)},d={x:a},y={numOrSizeSplits:e,axis:n};return Ie.runKernelFunc(c,d,null,Qo,y)}var ll=Ee({split_:cy});function ly(t,e){W(t.dtype==="float32",function(){return"The dtype for rfft() must be real value but got "+t.dtype});var n=t.shape[t.shape.length-1],a=t.size/n,c;if(e!=null&&e<n){var d=t.shape.map(function(He){return 0}),y=t.shape.map(function(He){return He});y[t.shape.length-1]=e,c=$t(t,d,y),n=e}else if(e!=null&&e>n){var v=t.shape.map(function(He){return He});v[t.shape.length-1]=e-n,c=kr([t,Ys(v)],t.shape.length-1),n=e}else c=t;var _=gn(c),C=Ke(Pn(c,_),[a,n]),D=Lh(C),B=Math.floor(n/2)+1,U=dh(D),J=Th(D),fe=ll(U,[B,n-B],U.shape.length-1),Pe=ll(J,[B,n-B],J.shape.length-1),Me=c.shape.slice();return Me[c.shape.length-1]=B,Ke(Pn(fe[0],Pe[0]),Me)}var zh=Ee({rfft_:ly});function hy(t){var e=ie(t,"x","sqrt"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.sqrt(e);return c([e]),d},n,null,Ro)}var eo=Ee({sqrt_:hy});function py(t,e){var n,a=ie(t,"a","squaredDifference"),c=ie(e,"b","squaredDifference");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(_,C){var D=_.squaredDifference(a,c);return C([a,c]),D},y={a,b:c},v={};return Ie.runKernelFunc(d,y,null,Fs,v)}var Ph=Ee({squaredDifference_:py});function dy(t,e){var n=ie(t,"x","squeeze");return Ke(n,Ur(n.shape,e).newShape)}var Bh=Ee({squeeze_:dy});function fy(t,e){e===void 0&&(e=0);var n=Nn(t,"tensors","stack");if(W(n.length>=1,function(){return"Pass at least one tensor to tf.stack"}),n.length===1)return ls(n[0],e);var a=n[0].rank,c=n[0].shape,d=n[0].dtype;W(e<=a,function(){return"Axis must be <= rank of the tensor"}),n.forEach(function(v){nt(c,v.shape,"All tensors passed to stack must have matching shapes"),W(d===v.dtype,function(){return"All tensors passed to stack must have matching dtypes"})});var y=n.map(function(v){return ls(v,e)});return kr(y,e)}var sc=Ee({stack_:fy});function my(t,e){e===void 0&&(e=0);var n=ie(t,"x","step"),a={x:n},c={alpha:e};return Ie.runKernelFunc(function(d){return d.step(n,e)},a,null,Zo,c)}var hl=Ee({step_:my});function yy(t,e,n,a,c,d,y,v,_){c===void 0&&(c=0),d===void 0&&(d=0),y===void 0&&(y=0),v===void 0&&(v=0),_===void 0&&(_=0);var C=ie(t,"x","stridedSlice"),D=function(J){a==null&&(a=new Array(e.length));var fe=vu(y);if(fe.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(y!==0&&v!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(y!==0&&_!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");var Pe=C.rank-e.length,Me=vu(v),He=C.shape.slice();Me.forEach(function(Qr){e[Qr]=0,n[Qr]=1,He.splice(Qr,0,1)}),C=Ke(C,He);var ct=Gc(C.shape,fe,Pe,e,n,a,c,d,y),It=ct.begin,Ct=ct.end,Bt=ct.strides;e=It,n=Ct,a=Bt;var sr=vu(_);sr.forEach(function(Qr){n[Qr]=e[Qr]+1,a[Qr]=1});var er=Wc(e,n,a),mr=er.filter(function(Qr,Zr){return sr.indexOf(Zr)===-1}),Gr=a.every(function(Qr){return Qr===1});if(Gr)return Ke($t(C,e,er),mr);var en=J.stridedSlice(C,e,n,a);return Ke(en,mr)},B={x:C},U={begin:e,end:n,strides:a,beginMask:c,endMask:d,ellipsisMask:y,newAxisMask:v,shrinkAxisMask:_};return Ie.runKernelFunc(D,B,null,Os,U)}var wd=Ee({stridedSlice_:yy});function vy(t){var e=ie(t,"x","tan"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.tan(e);return c([e]),d},n,null,ds)}var bd=Ee({tan_:vy});function yh(t,e,n){if(tt(t),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");var a=Er(t,n);if(a.length!==2&&a.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Da(t,e,a,n)}function gy(t,e,n){if(tt(t),e!=null&&e.length!==4)throw new Error("tensor4d() requires shape to have four numbers");var a=Er(t,n);if(a.length!==4&&a.length!==1)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Da(t,e,a,n)}function xy(t,e,n){if(tt(t),e!=null&&e.length!==5)throw new Error("tensor5d() requires shape to have five numbers");var a=Er(t,n);if(a.length!==5&&a.length!==1)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Da(t,e,a,n)}function _y(t,e,n){if(tt(t),e!=null&&e.length!==6)throw new Error("tensor6d() requires shape to have six numbers");var a=Er(t,n);if(a.length!==6&&a.length!==1)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return e=e||a,Da(t,e,a,n)}function wy(t,e,n){e===void 0&&(e=1),n===void 0&&(n=!0);var a=ie(t,"x","topk");if(a.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");var c=a.shape[a.shape.length-1];if(e>c)throw new Error("'k' passed to topk() must be <= the last dimension ("+c+") "+("but got "+e));var d={x:a},y={k:e,sorted:n},v=Ie.runKernelFunc(function(D){return D.topk(a,e,n)},d,null,nu,y),_=v[0],C=v[1];return{values:_,indices:C}}var kd=Ee({topk_:wy});function by(t,e,n,a,c){if(e===void 0&&(e=0),n===void 0&&(n=1),a!=null&&a==="bool")throw new Error("Unsupported data type $ { dtype }");for(var d=new xp(e,n,a,!0,c),y=Qi(t,a),v=0;v<y.values.length;v++)y.values[v]=d.nextValue();return y.toTensor()}var ky=Ee({truncatedNormal_:by});function Sy(t,e){e===void 0&&(e=0);var n=ie(t,"x","unique",null);W(n.rank>0,function(){return"The input tensor must be at least 1D"});var a={x:n},c={axis:e},d=Ie.runKernel(au,a,c),y=d[0],v=d[1];return{values:y,indices:v}}var Sd=Ee({unique_:Sy});function Iy(t,e,n){var a=ie(t,"x","unsortedSegmentSum"),c=ie(e,"segmentIds","unsortedSegmentSum","int32");W(xt(n),function(){return"numSegments must be of dtype int"});var d={x:a,segmentIds:c},y={numSegments:n},v=function(_,C){var D=_.unsortedSegmentSum(a,c,n);return C([c]),D};return Ie.runKernelFunc(v,d,null,Do,y)}var Np=Ee({unsortedSegmentSum_:Iy});function Ny(t,e){e===void 0&&(e=0);var n=ie(t,"x","unstack");W(e>=-n.shape.length&&e<n.shape.length,function(){return"Axis = "+e+" is not in [-"+n.shape.length+", "+n.shape.length+")"}),e<0&&(e+=n.shape.length);var a={value:n},c={axis:e},d=function(y){return y.unstack(n,e)};return Ie.runKernelFunc(d,a,null,ms,c)}var Wh=Ee({unstack_:Ny});function Cy(t,e,n,a){return e===void 0&&(e=!0),Ie.makeVariable(t,e,n,a)}function Id(t,e){for(var n=[],a=0;a<e.length;a++)e[a]&&n.push(a);for(var c=Qi(t,"int32"),d=Qi([n.length,t.length],"int32"),a=0;a<n.length;a++){var y=c.indexToLoc(n[a]),v=a*t.length;d.values.set(y,v)}return d.toTensor()}function Ty(t){return O(this,void 0,void 0,function(){var e,n,a;return H(this,function(c){switch(c.label){case 0:return e=ie(t,"condition","whereAsync","bool"),[4,e.data()];case 1:return n=c.sent(),a=Id(e.shape,n),t!==e&&e.dispose(),[2,a]}})})}var Nd=Ty;function Ey(t,e,n){return O(this,void 0,void 0,function(){var a,c,d,y,v,_,C,D,B,U,J,fe,Pe;return H(this,function(Me){switch(Me.label){case 0:for(a=ie(t,"tensor","boolMask"),c=ie(e,"mask","boolMask","bool"),d=n??0,y=c.rank,v=a.shape,W(y>0,function(){return"mask cannot be scalar"}),nt(v.slice(d,d+y),c.shape,"mask's shape must match the first K dimensions of tensor's shape,"),_=1,C=d;C<d+y;C++)_*=v[C];return D=v.slice(0,d).concat([_],v.slice(d+y)),B=Ke(a,D),U=Ke(c,[-1]),[4,Nd(U)];case 1:return J=Me.sent(),fe=Bh(J,[1]),Pe=Ch(B,fe,d),t!==a&&a.dispose(),e!==c&&c.dispose(),fe.dispose(),B.dispose(),U.dispose(),J.dispose(),[2,Pe]}})})}var Ry=Ey;function Ay(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","notEqualStrict"),a=ie(e,"b","notEqualStrict");return nt(n.shape,a.shape,"Error in notEqualStrict: "),Oh(n,a)}function Dy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","lessStrict"),a=ie(e,"b","lessStrict");return nt(n.shape,a.shape,"Error in lessStrict: "),Eh(n,a)}function Fy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","equalStrict"),a=ie(e,"b","equalStrict");return nt(n.shape,a.shape,"Error in equalStrict: "),hh(n,a)}function Oy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","lessEqualStrict"),a=ie(e,"b","lessEqualStrict");return nt(n.shape,a.shape,"Error in lessEqualStrict: "),ec(n,a)}function My(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","greaterStrict"),a=ie(e,"b","greaterStrict");return nt(n.shape,a.shape,"Error in greaterStrict: "),_u(n,a)}function Ly(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","greaterEqualStrict"),a=ie(e,"b","greaterEqualStrict");return nt(n.shape,a.shape,"Error in greaterEqualStrict: "),$u(n,a)}var Cd=Ee({equalStrict_:Fy}),Td=Ee({greaterEqualStrict_:Ly}),Ed=Ee({greaterStrict_:My}),Rd=Ee({lessEqualStrict_:Oy}),Ad=Ee({lessStrict_:Dy}),Dd=Ee({notEqualStrict_:Ay});function zy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","addStrict"),a=ie(e,"b","addStrict");return nt(n.shape,a.shape,"Error in addStrict: "),Cr(n,a)}function Py(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","subStrict"),a=ie(e,"b","subStrict");return nt(n.shape,a.shape,"Error in subStrict: "),zr(n,a)}function By(t,e){return Sa("strict variants of ops have been deprecated and will be removed in future"),nt(t.shape,e.shape,"Error in powStrict: "),Qs(t,e)}function Wy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","mul"),a=ie(e,"b","mul");return nt(n.shape,a.shape,"Error in multiplyStrict: "),bt(n,a)}function Uy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","div"),a=ie(e,"b","div");return nt(n.shape,a.shape,"Error in divideStrict: "),Br(n,a)}function Vy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","modStrict"),a=ie(e,"b","modStrict");return nt(n.shape,a.shape,"Error in modStrict: "),mp(n,a)}function Hy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","minimumStrict"),a=ie(e,"b","minimumStrict");return nt(n.shape,a.shape,"Error in minimumStrict: "),Fh(n,a)}function Gy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","maximumStrict"),a=ie(e,"b","maximumStrict");return nt(n.shape,a.shape,"Error in maximumStrict: "),ol(n,a)}function jy(t,e){Sa("strict variants of ops have been deprecated and will be removed in future");var n=ie(t,"a","squaredDifferenceStrict"),a=ie(e,"b","squaredDifferenceStrict");return nt(n.shape,a.shape,"Error in squaredDifferenceStrict: "),Ph(n,a)}var Fd=Ee({addStrict_:zy}),Od=Ee({divStrict_:Uy}),Md=Ee({maximumStrict_:Gy}),Ld=Ee({minimumStrict_:Hy}),zd=Ee({modStrict_:Vy}),Pd=Ee({mulStrict_:Wy}),Bd=Ee({powStrict_:By}),Wd=Ee({squaredDifferenceStrict_:jy}),Ud=Ee({subStrict_:Py});function qy(t,e,n,a){e===void 0&&(e="euclidean"),n===void 0&&(n=null),a===void 0&&(a=!1),t=ie(t,"x","norm");var c=Vd(t,e,n),d=c.shape;if(a){var y=qt(n,t.shape);d=ci(c.shape,y)}return Ke(c,d)}function Vd(t,e,n){if(n===void 0&&(n=null),t.rank===0)return ui(t);if(t.rank!==1&&n===null)return Vd(Ke(t,[-1]),e,n);if(t.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(e===1)return Yr(ui(t),n);if(e===Infinity)return rc(ui(t),n);if(e===-Infinity)return Dh(ui(t),n);if(e==="euclidean"||e===2)return eo(Yr(Qs(ui(t),Wr(2,"int32")),n));throw new Error("Error in norm: invalid ord value: "+e)}if(Array.isArray(n)&&n.length===2){if(e===1)return rc(Yr(ui(t),n[0]),n[1]-1);if(e===Infinity)return rc(Yr(ui(t),n[1]),n[0]);if(e===-Infinity)return Dh(Yr(ui(t),n[1]),n[0]);if(e==="fro"||e==="euclidean")return eo(Yr(Yn(t),n));throw new Error("Error in norm: invalid ord value: "+e)}throw new Error("Error in norm: invalid axis: "+n)}var Uh=Ee({norm_:qy});function Ky(t,e,n,a,c){c===void 0&&(c=!0);var d=ie(t,"v","movingAverage"),y=ie(e,"x","movingAverage"),v=ie(n,"decay","movingAverage");Kt(d,y),W(it(d.shape,y.shape),function(){return"Shape mismatch in v and x"});var _=Wr(1),C=zr(_,v),D=bt(zr(y,d),C);if(c){W(a!=null,function(){return"When using zeroDebias: true, step is required."});var B=ie(a,"step","movingAverage");D=Br(D,zr(_,Qs(v,B)))}return Cr(d,D)}var Xy=Ee({movingAverage_:Ky});function Yy(t,e,n){var a=ie(t,"indices","scatterND","int32"),c=ie(e,"updates","scatterND");Wu(c,a,n);var d=function(_){return _.scatterND(a,c,n)},y={indices:a,updates:c},v={shape:n};return Ie.runKernelFunc(d,y,null,vo,v)}var Qy=Ee({scatterND_:Yy});function Zy(t,e,n,a){if(t.dtype!=="int32")throw new Error("tf.sparseToDense() expects the indices to be int32 type,"+(" but the dtype was "+t.dtype+"."));if(t.rank>2)throw new Error("sparseIndices should be a scalar, vector, or matrix,"+(" but got shape "+t.shape+"."));var c=t.rank>0?t.shape[0]:1,d=t.rank>1?t.shape[1]:1;if(n.length!==d)throw new Error("outputShape has incorrect number of elements:,"+(" "+n.length+", should be: "+d+"."));var y=e.size;if(!(e.rank===0||e.rank===1&&y===c))throw new Error("sparseValues has incorrect shape "+(e.shape+", should be [] or ["+c+"]"));if(e.dtype!==a.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}function Jy(t,e,n,a){a===void 0&&(a=0);var c=ie(t,"sparseIndices","sparseToDense","int32"),d=ie(e,"sparseValues","sparseToDense"),y=ie(a,"defaultValue","sparseToDense",d.dtype);Zy(c,d,n,y);var v={sparseIndices:c,sparseValues:d,defaultValue:y},_={outputShape:n};return Ie.runKernelFunc(function(C){return C.sparseToDense(c,d,n,y)},v,null,ru,_)}var $y=Ee({sparseToDense_:Jy});function e0(t,e){var n=ie(e,"indices","gatherND","int32"),a=ie(t,"x","gatherND"),c=function(y){return y.gatherND(a,n)},d={params:a,indices:n};return Ie.runKernelFunc(c,d,null,we)}var t0=Ee({gatherND_:e0});function r0(t,e){if(e==null)return t.shape.slice();if(it(t.shape,e))return e;if(t.shape.length===e.length){for(var n=[],a=0;a<t.shape.length;a++)e[a]==null&&t.shape[a]!=null?n.push(t.shape[a]):n.push(e[a]);return n}return e}function n0(t,e,n,a){var c=ie(t,"x","dropout");if(W(c.dtype==="float32",function(){return"x has to be a floating point tensor since it's going to be "+("scaled, but got a "+c.dtype+" tensor instead.")}),W(e>=0&&e<1,function(){return"rate must be a float in the range [0, 1), but got "+e+"."}),e===0)return t instanceof $?c.clone():c;var d=r0(c,n),y=1-e,v=Br(Nh(Cr(dd(d,0,1,"float32",a),y)),y);return bt(c,v)}var a0=Ee({dropout_:n0});function Hd(t){return Math.floor(Math.pow(2,Math.ceil(Math.log(t)/Math.log(2))))}function Cp(t,e,n){for(var a=1-t%2,c=new Float32Array(t),d=0;d<t;++d){var y=2*Math.PI*d/(t+a-1);c[d]=e-n*Math.cos(y)}return cl(c,"float32")}function i0(t,e,n){return n===void 0&&(n=1),O(this,void 0,void 0,function(){var a,c,d,y,v,_,C,D,B,U,J,fe,Pe,Me,Me;return H(this,function(He){switch(He.label){case 0:return a=ie(t,"predictions","inTopK"),c=ie(e,"targets","inTopK"),W(a.rank>1,function(){return"inTopK() expects the predictions to be of rank 2 or higher, "+("but got "+a.rank)}),W(a.rank-1===c.rank,function(){return"predictions rank should be 1 larger than targets rank, but got predictions rank "+(a.rank+" and targets rank "+c.rank)}),nt(a.shape.slice(0,a.shape.length-1),c.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),d=a.shape[a.shape.length-1],W(n>0&&n<=d,function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last "+("dimension ("+d+"), but got "+n)}),[4,a.data()];case 1:return y=He.sent(),[4,c.data()];case 2:for(v=He.sent(),_=[y.length/d,d],C=_[0],D=_[1],B=jr("bool",C),U=0;U<C;U++){for(J=U*D,fe=y.subarray(J,J+D),Pe=[],Me=0;Me<fe.length;Me++)Pe.push({value:fe[Me],index:Me});for(Pe.sort(function(ct,It){return It.value-ct.value}),B[U]=0,Me=0;Me<n;Me++)if(Pe[Me].index===v[U]){B[U]=1;break}}return t!==a&&a.dispose(),e!==c&&c.dispose(),[2,Dn(B,c.shape,"bool")]}})})}var o0=i0;function s0(t,e,n,a,c,d,y){d===void 0&&(d="NHWC");var v=t;t.rank===3&&(v=Ke(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var _=e;_.rank===3&&(_=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2]])),W(v.rank===4,function(){return"Error in conv2dDerFilter: input must be rank 4, but got shape "+(v.shape+".")}),W(_.rank===4,function(){return"Error in conv2dDerFilter: dy must be rank 4, but got shape "+(_.shape+".")}),W(n.length===4,function(){return"Error in conv2dDerFilter: filterShape must be length 4, but got "+(n+".")});var C=d==="NHWC"?v.shape[3]:v.shape[1],D=d==="NHWC"?_.shape[3]:_.shape[1];W(C===n[2],function(){return"Error in conv2dDerFilter: depth of input "+C+") must "+("match input depth in filter ("+n[2]+".")}),W(D===n[3],function(){return"Error in conv2dDerFilter: depth of dy ("+D+") must "+("match output depth for filter ("+n[3]+").")}),y!=null&&W(xt(c),function(){return"Error in conv2dDerFilter: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+c+".")});var B=function(fe){var Pe=1,Me=Dt(d),He=T(v.shape,n,a,Pe,c,y,!1,Me);return fe.conv2dDerFilter(v,_,He)},U={x:v,dy:_},J={strides:a,pad:c,dataFormat:d,dimRoundingMode:y,filterShape:n};return Ie.runKernelFunc(B,U,null,$e,J)}var Tp=Ee({conv2DBackpropFilter_:s0});function Vh(t,e,n){if(n==null||n==="linear")return t;if(n==="relu")return bt(t,hl(e));throw new Error("Cannot compute gradient for fused activation "+n+".")}function Hh(t,e){var n=e,a=Ja(t.shape,e.shape);return a.length>0&&(n=Yr(n,a)),Ke(n,t.shape)}function Gh(t,e,n){if(e==="linear")return t;if(e==="relu")return fh(t);if(e==="elu")return sp(t);if(e==="relu6")return wp(t);if(e==="prelu")return vp(t,n);throw new Error("Unknown fused activation "+e+".")}var jh=function(t,e){var n=t>0;return!n||e==="linear"};function u0(t){var e=t.x,n=t.filter,a=t.strides,c=t.pad,d=t.dataFormat,y=d===void 0?"NHWC":d,v=t.dilations,_=v===void 0?[1,1]:v,C=t.dimRoundingMode,D=t.bias,B=t.activation,U=B===void 0?"linear":B,J=t.preluActivationWeights;if(U=U||"linear",jh(Ie.state.gradientDepth,U)===!1){var fe=gi(e,n,a,c,y,_,C);return D!=null&&(fe=Cr(fe,D)),Gh(fe,U,J)}var Pe=ie(e,"x","conv2d"),Me=ie(n,"filter","conv2d"),He=Pe,ct=!1;Pe.rank===3&&(ct=!0,He=Ke(Pe,[1,Pe.shape[0],Pe.shape[1],Pe.shape[2]])),W(He.rank===4,function(){return"Error in fused conv2d: input must be rank 4, but got rank "+(He.rank+".")}),W(Me.rank===4,function(){return"Error in fused conv2d: filter must be rank 4, but got rank "+(Me.rank+".")}),C!=null&&W(xt(c),function(){return"Error in fused conv2d: pad must be an integer when using, "+("dimRoundingMode "+C+" but got pad "+c+".")}),W(He.shape[3]===Me.shape[2],function(){return"Error in conv2d: depth of input ("+He.shape[3]+") must match "+("input depth for filter "+Me.shape[2]+".")}),W(dt(a,_),function(){return"Error in conv2D: Either strides or dilations must be 1. "+("Got strides "+a+" and dilations '"+_+"'")}),W(y==="NHWC",function(){return"Error in conv2d: got dataFormat of "+y+" but only NHWC is currently supported."});var It=T(He.shape,Me.shape,a,_,c,C),Ct;D!=null&&(Ct=ie(D,"bias","fused conv2d"),Ct=Nt(Ct,Pe)[0],ca(It.outShape,Ct.shape));var Bt;J!=null&&(Bt=ie(J,"prelu weights","fused conv2d"));var sr=function(Zr,Kr){var Un=Kr,mn=Un[0],Ln=Un[1],$s=Un[2],xi=Un[3],Ba=Vh(Zr,$s,U);W(st(_),function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 "+("are not yet supported in gradients. Got dilations '"+_+"'")});var ko=Ti(Ln.shape,Ba,mn,a,c),So=Tp(Ln,Ba,mn.shape,a,c),bu=[ko,So];if(xi!=null){var zp=Hh(xi,Ba);bu.push(zp)}return bu},er=function(Zr){var Kr=Zr.fusedConv2d({input:He,filter:Me,convInfo:It,bias:Ct,activation:U,preluActivationWeights:Bt});return Kr},mr={x:He,filter:Me,bias:Ct,preluActivationWeights:Bt},Gr={strides:a,pad:c,dataFormat:y,dilations:_,dimRoundingMode:C,activation:U};if(D==null){var en=Cs(function(Zr,Kr,Un){var mn=Ie.runKernelFunc(er,mr,null,Ps,Gr);return Un([Kr,Zr,mn]),ct&&(mn=Ke(mn,[mn.shape[1],mn.shape[2],mn.shape[3]])),{value:mn,gradFunc:sr}});return en(He,Me)}else{var Qr=Cs(function(Zr,Kr,Un,mn){var Ln=Ie.runKernelFunc(er,mr,null,Ps,Gr);return mn([Kr,Zr,Ln,Un]),ct&&(Ln=Ke(Ln,[Ln.shape[1],Ln.shape[2],Ln.shape[3]])),{value:Ln,gradFunc:sr}});return Qr(He,Me,Ct)}}var c0=Ee({fusedConv2d_:u0});function l0(t,e,n,a,c,d,y){d===void 0&&(d=[1,1]);var v=t;t.rank===3&&(v=Ke(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var _=e;_.rank===3&&(_=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var C=function(U){var J=T(t.shape,n,a,d,c,y,!0);return U.depthwiseConv2DDerFilter(v,_,J)},D={x:v,dy:_},B={strides:a,pad:c,dimRoundingMode:y,dilations:d,filterShape:n};return Ie.runKernelFunc(C,D,null,Ha,B)}var Gd=Ee({depthwiseConv2dNativeBackpropFilter_:l0});function h0(t,e,n,a,c,d,y){d===void 0&&(d=[1,1]);var v=e,_=!1;e.rank===3&&(_=!0,v=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var C=function(J){var fe=T(t,n.shape,a,d,c,y,!0);return J.depthwiseConv2DDerInput(v,n,fe)},D={dy:v,filter:n},B={strides:a,pad:c,dimRoundingMode:y,dilations:d,inputShape:t},U=Ie.runKernelFunc(C,D,null,ki,B);return _?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var jd=Ee({depthwiseConv2dNativeBackpropInput_:h0});function p0(t){var e=t.x,n=t.filter,a=t.strides,c=t.pad,d=t.dataFormat,y=d===void 0?"NHWC":d,v=t.dilations,_=v===void 0?[1,1]:v,C=t.dimRoundingMode,D=t.bias,B=t.activation,U=B===void 0?"linear":B,J=t.preluActivationWeights;if(jh(Ie.state.gradientDepth,U)===!1){var fe=lh(e,n,a,c,y,_,C);return D!=null&&(fe=Cr(fe,D)),Gh(fe,U,J)}var Pe=ie(e,"x","depthwiseConv2d"),Me=ie(n,"filter","depthwiseConv2d"),He=Pe,ct=!1;Pe.rank===3&&(ct=!0,He=Ke(Pe,[1,Pe.shape[0],Pe.shape[1],Pe.shape[2]])),W(He.rank===4,function(){return"Error in fused depthwiseConv2d: input must be rank 4, but got "+("rank "+He.rank+".")}),W(Me.rank===4,function(){return"Error in fused depthwiseConv2d: filter must be rank 4, "+("but got rank "+Me.rank+".")}),W(He.shape[3]===Me.shape[2],function(){return"Error in fused depthwiseConv2d: number of input channels "+("("+He.shape[3]+") must match the inChannels dimension in ")+("filter "+Me.shape[2]+".")}),_==null&&(_=[1,1]),W(dt(a,_),function(){return"Error in fused depthwiseConv2d: Either strides or dilations must "+("be 1. Got strides "+a+" and dilations '"+_+"'")}),C!=null&&W(xt(c),function(){return"Error in fused depthwiseConv2d: pad must be an integer when "+("using dimRoundingMode "+C+" but got pad "+c+".")});var It=T(He.shape,Me.shape,a,_,c,C,!0),Ct;D!=null&&(Ct=ie(D,"bias","fused conv2d"),Ct=Nt(Ct,Pe)[0],ca(It.outShape,Ct.shape));var Bt;J!=null&&(Bt=ie(J,"prelu weights","fused depthwiseConv2d"));var sr=function(Zr,Kr){W(st(_),function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations "+("'"+_+"'")});var Un=Kr[0],mn=Kr[1],Ln=Kr[2],$s=Kr[3],xi=Vh(Zr,Ln,U),Ba=jd(mn.shape,xi,Un,a,c,_,C),ko=Gd(mn,xi,Un.shape,a,c,_,C);if($s!=null){var So=Hh(Ct,xi);return[Ba,ko,So]}return[Ba,ko]},er=function(Zr){var Kr=Zr.fusedDepthwiseConv2D({input:He,filter:Me,convInfo:It,bias:Ct,activation:U,preluActivationWeights:Bt});return Kr},mr={x:He,filter:Me,bias:Ct,preluActivationWeights:Bt},Gr={strides:a,pad:c,dataFormat:y,dilations:_,dimRoundingMode:C,activation:U};if(D==null){var en=Cs(function(Zr,Kr,Un){var mn=Ie.runKernelFunc(er,mr,null,Jo,Gr);return Un([Kr,Zr,mn]),ct&&(mn=Ke(mn,[mn.shape[1],mn.shape[2],mn.shape[3]])),{value:mn,gradFunc:sr}});return en(He,Me)}else{var Qr=Cs(function(Zr,Kr,Un,mn){var Ln=Ie.runKernelFunc(er,mr,null,Jo,Gr);return mn([Kr,Zr,Ln,Un]),ct&&(Ln=Ke(Ln,[Ln.shape[1],Ln.shape[2],Ln.shape[3]])),{value:Ln,gradFunc:sr}});return Qr(He,Me,Ct)}}var d0=Ee({fusedDepthwiseConv2d_:p0});function f0(t){var e,n=t.a,a=t.b,c=t.transposeA,d=c===void 0?!1:c,y=t.transposeB,v=y===void 0?!1:y,_=t.bias,C=t.activation,D=C===void 0?"linear":C,B=t.preluActivationWeights;if(jh(Ie.state.gradientDepth,D)===!1){var U=un(n,a,d,v);return _!=null&&(U=Cr(U,_)),Gh(U,D,B)}var J=ie(n,"a","fused matMul"),fe=ie(a,"b","fused matMul");e=Nt(J,fe),J=e[0],fe=e[1];var Pe=d?J.shape[J.rank-2]:J.shape[J.rank-1],Me=v?fe.shape[fe.rank-1]:fe.shape[fe.rank-2],He=d?J.shape[J.rank-1]:J.shape[J.rank-2],ct=v?fe.shape[fe.rank-2]:fe.shape[fe.rank-1],It=J.shape.slice(0,-2),Ct=fe.shape.slice(0,-2),Bt=Tt(It),sr=Tt(Ct);W(J.rank>=2&&fe.rank>=2&&J.rank===fe.rank,function(){return"Error in fused matMul: inputs must have the same rank of at least "+("2, got ranks "+J.rank+" and "+fe.rank+".")}),W(it(It,Ct),function(){return"Error in fused matMul: outer dimensions ("+It+") and ("+(Ct+") of Tensors with shapes "+J.shape+" and ")+(fe.shape+" must match.")}),W(Pe===Me,function(){return"Error in fused matMul: inner shapes ("+Pe+") and ("+(Me+") of Tensors with shapes "+J.shape+" and ")+(fe.shape+" and transposeA="+d)+(" and transposeB="+v+" must match.")});var er=J.shape.slice(0,-2).concat([He,ct]),mr=d?Ke(J,[Bt,Pe,He]):Ke(J,[Bt,He,Pe]),Gr=v?Ke(fe,[sr,ct,Me]):Ke(fe,[sr,Me,ct]),en;_!=null&&(en=ie(_,"bias","fused matMul"),en=Nt(en,J)[0],ca(er,en.shape));var Qr;B!=null&&(Qr=ie(B,"prelu weights","fused matMul"));var Zr=function(xi,Ba){var ko=Ba[0],So=Ba[1],bu=Ba[2],zp=Ba[3],eu=Vh(Ke(xi,bu.shape),bu,D),dl,fl;if(!d&&!v?(dl=un(eu,So,!1,!0),fl=un(ko,eu,!0,!1)):!d&&v?(dl=un(eu,So,!1,!1),fl=un(eu,ko,!0,!1)):d&&!v?(dl=un(So,eu,!1,!0),fl=un(ko,eu,!1,!1)):(dl=un(So,eu,!0,!0),fl=un(eu,ko,!0,!0)),_!=null){var rg=Hh(zp,eu);return[dl,fl,rg]}else return[dl,fl]},Kr=function(xi){var Ba=xi.fusedBatchMatMul({a:mr,b:Gr,transposeA:d,transposeB:v,bias:en,activation:D,preluActivationWeights:Qr});return Ba},Un={a:mr,b:Gr,bias:en,preluActivationWeights:Qr},mn={transposeA:d,transposeB:v,activation:D};if(_==null){var Ln=Cs(function(xi,Ba,ko){var So=Ie.runKernelFunc(Kr,Un,null,Fo,mn);return ko([xi,Ba,So]),{value:Ke(So,er),gradFunc:Zr}});return Ln(mr,Gr)}else{var $s=Cs(function(xi,Ba,ko,So){var bu=Ie.runKernelFunc(Kr,Un,null,Fo,mn);return So([xi,Ba,bu,ko]),{value:Ke(bu,er),gradFunc:Zr}});return $s(mr,Gr,en)}}var m0=Ee({fusedMatMul_:f0}),y0={__proto__:null,conv2d:c0,depthwiseConv2d:d0,matMul:m0};function v0(t){return Cp(t,.54,.46)}var g0=Ee({hammingWindow_:v0});function x0(t){return Cp(t,.5,.5)}var qd=Ee({hannWindow_:x0});function _0(t,e,n,a,c){a===void 0&&(a=!1),c===void 0&&(c=0);for(var d=0,y=[];d+e<=t.size;)y.push($t(t,d,e)),d+=n;if(a)for(;d<t.size;){var v=d+e-t.size,_=kr([$t(t,d,e-v),up([v],c)]);y.push(_),d+=n}return y.length===0?yh([],[0,e]):Ke(kr(y),[y.length,e])}var Kd=Ee({frame_:_0});function w0(t,e,n,a,c){c===void 0&&(c=qd),a==null&&(a=Hd(e));for(var d=Kd(t,e,n),y=bt(d,c(e)),v=[],_=0;_<d.shape[0];_++)v.push(zh($t(y,[_,0],[1,e]),a));return kr(v)}var b0=Ee({stft_:w0});function k0(t,e,n,a,c,d){var y=ie(t,"image","cropAndResize"),v=ie(e,"boxes","cropAndResize","float32"),_=ie(n,"boxInd","cropAndResize","int32");c=c||"bilinear",d=d||0;var C=v.shape[0];W(y.rank===4,function(){return"Error in cropAndResize: image must be rank 4,"+("but got rank "+y.rank+".")}),W(v.rank===2&&v.shape[1]===4,function(){return"Error in cropAndResize: boxes must be have size ["+C+",4] "+("but had shape "+v.shape+".")}),W(_.rank===1&&_.shape[0]===C,function(){return"Error in cropAndResize: boxInd must be have size ["+C+"] "+("but had shape "+v.shape+".")}),W(a.length===2,function(){return"Error in cropAndResize: cropSize must be of length 2, but got "+("length "+a.length+".")}),W(a[0]>=1&&a[1]>=1,function(){return"cropSize must be atleast [1,1], but was "+a}),W(c==="bilinear"||c==="nearest",function(){return"method must be bilinear or nearest, but was "+c});var D=function(fe){return fe.cropAndResize(y,v,_,a,c,d)},B={image:y,boxes:v,boxInd:_},U={method:c,extrapolationValue:d,cropSize:a},J=Ie.runKernelFunc(D,B,null,ta,U);return J}var S0=Ee({cropAndResize_:k0});function I0(t){var e=ie(t,"image","flipLeftRight","float32");W(e.rank===4,function(){return"Error in flipLeftRight: image must be rank 4,"+("but got rank "+e.rank+".")});var n={image:e},a=Ie.runKernel(S,n,{});return a}var N0=Ee({flipLeftRight_:I0});function C0(t,e,n,a){n===void 0&&(n=0),a===void 0&&(a=.5);var c=ie(t,"image","rotateWithOffset","float32");W(c.rank===4,function(){return"Error in rotateWithOffset: image must be rank 4,"+("but got rank "+c.rank+".")});var d={image:c},y={radians:e,fillValue:n,center:a},v=Ie.runKernel(ys,d,y);return v}var T0=Ee({rotateWithOffset_:C0});function pl(t,e,n,a,c,d){a==null&&(a=.5),c==null&&(c=Number.NEGATIVE_INFINITY),d==null&&(d=0);var y=t.shape[0];return n=Math.min(n,y),W(0<=a&&a<=1,function(){return"iouThreshold must be in [0, 1], but was '"+a+"'"}),W(t.rank===2,function(){return"boxes must be a 2D tensor, but was of rank '"+t.rank+"'"}),W(t.shape[1]===4,function(){return"boxes must have 4 columns, but 2nd dimension was "+t.shape[1]}),W(e.rank===1,function(){return"scores must be a 1D tensor"}),W(e.shape[0]===y,function(){return"scores has incompatible shape with boxes. Expected "+y+", "+("but was "+e.shape[0])}),W(0<=d&&d<=1,function(){return"softNmsSigma must be in [0, 1], but was '"+d+"'"}),{maxOutputSize:n,iouThreshold:a,scoreThreshold:c,softNmsSigma:d}}function E0(t,e,n,a,c){a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY);var d=ie(t,"boxes","nonMaxSuppression"),y=ie(e,"scores","nonMaxSuppression"),v=pl(d,y,n,a,c);n=v.maxOutputSize,a=v.iouThreshold,c=v.scoreThreshold;var _={maxOutputSize:n,iouThreshold:a,scoreThreshold:c};return Ie.runKernelFunc(function(C){return C.nonMaxSuppression(d,y,n,a,c)},{boxes:d,scores:y},null,qa,_)}var R0=Ee({nonMaxSuppression_:E0});function A0(t,e,n){var a=D0(t,e,n),c=a<0?-(a+1):a;t.splice(c,0,e)}function D0(t,e,n){return O0(t,e,n||F0)}function F0(t,e){return t>e?1:t<e?-1:0}function O0(t,e,n){for(var a=0,c=t.length,d=0,y=!1;a<c;){d=a+(c-a>>>1);var v=n(e,t[d]);v>0?a=d+1:(c=d,y=!v)}return y?a:-a-1}function Xd(t,e,n,a,c){return Ep(t,e,n,a,c,0).selectedIndices}function Yd(t,e,n,a,c,d){return Ep(t,e,n,a,c,0,!1,d,!0)}function Qd(t,e,n,a,c,d){return Ep(t,e,n,a,c,d,!0)}function Ep(t,e,n,a,c,d,y,v,_){y===void 0&&(y=!1),v===void 0&&(v=!1),_===void 0&&(_=!1);for(var C=[],D=0;D<e.length;D++)e[D]>c&&C.push({score:e[D],boxIndex:D,suppressBeginIndex:0});C.sort(Zd);for(var B=d>0?-.5/d:0,U=[],J=[];U.length<n&&C.length>0;){var fe=C.pop(),Pe=fe.score,Me=fe.boxIndex,He=fe.suppressBeginIndex;if(Pe<c)break;for(var ct=!1,It=U.length-1;It>=He;--It){var Ct=M0(t,Me,U[It]);if(Ct>=a){ct=!0;break}if(fe.score=fe.score*L0(a,B,Ct),fe.score<=c)break}fe.suppressBeginIndex=U.length,ct||(fe.score===Pe?(U.push(Me),J.push(fe.score)):fe.score>c&&A0(C,fe,Zd))}var Bt=U.length,sr=n-Bt;v&&sr>0&&(U.push.apply(U,new Array(sr).fill(0)),J.push.apply(J,new Array(sr).fill(0)));var er={selectedIndices:cl(U,"int32")};return y&&(er.selectedScores=cl(J,"float32")),_&&(er.validOutputs=Wr(Bt,"int32")),er}function M0(t,e,n){var a=t.subarray(e*4,e*4+4),c=t.subarray(n*4,n*4+4),d=Math.min(a[0],a[2]),y=Math.min(a[1],a[3]),v=Math.max(a[0],a[2]),_=Math.max(a[1],a[3]),C=Math.min(c[0],c[2]),D=Math.min(c[1],c[3]),B=Math.max(c[0],c[2]),U=Math.max(c[1],c[3]),J=(v-d)*(_-y),fe=(B-C)*(U-D);if(J<=0||fe<=0)return 0;var Pe=Math.max(d,C),Me=Math.max(y,D),He=Math.min(v,B),ct=Math.min(_,U),It=Math.max(He-Pe,0)*Math.max(ct-Me,0);return It/(J+fe-It)}function L0(t,e,n){var a=Math.exp(e*n*n);return n<=t?a:0}function Zd(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}function z0(t,e,n,a,c){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),O(this,void 0,void 0,function(){var d,y,v,_,C,D,B;return H(this,function(U){switch(U.label){case 0:return d=ie(t,"boxes","nonMaxSuppressionAsync"),y=ie(e,"scores","nonMaxSuppressionAsync"),v=pl(d,y,n,a,c),n=v.maxOutputSize,a=v.iouThreshold,c=v.scoreThreshold,[4,Promise.all([d.data(),y.data()])];case 1:return _=U.sent(),C=_[0],D=_[1],B=Xd(C,D,n,a,c),d!==t&&d.dispose(),y!==e&&y.dispose(),[2,B]}})})}var P0=z0;function B0(t,e,n,a,c,d){a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=0);var y=ie(t,"boxes","nonMaxSuppression"),v=ie(e,"scores","nonMaxSuppression"),_=pl(y,v,n,a,c,d);n=_.maxOutputSize,a=_.iouThreshold,c=_.scoreThreshold,d=_.softNmsSigma;var C={boxes:y,scores:v},D={maxOutputSize:n,iouThreshold:a,scoreThreshold:c,softNmsSigma:d},B=Ie.runKernel(Ki,C,D);return{selectedIndices:B[0],selectedScores:B[1]}}var W0=Ee({nonMaxSuppressionWithScore_:B0});function U0(t,e,n,a,c,d){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=0),O(this,void 0,void 0,function(){var y,v,_,C,D,B,U;return H(this,function(J){switch(J.label){case 0:return y=ie(t,"boxes","nonMaxSuppressionAsync"),v=ie(e,"scores","nonMaxSuppressionAsync"),_=pl(y,v,n,a,c,d),n=_.maxOutputSize,a=_.iouThreshold,c=_.scoreThreshold,d=_.softNmsSigma,[4,Promise.all([y.data(),v.data()])];case 1:return C=J.sent(),D=C[0],B=C[1],U=Qd(D,B,n,a,c,d),y!==t&&y.dispose(),v!==e&&v.dispose(),[2,U]}})})}var V0=U0;function H0(t,e,n,a,c,d){a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=!1);var y=ie(t,"boxes","nonMaxSuppression"),v=ie(e,"scores","nonMaxSuppression"),_=pl(y,v,n,a,c,null),C=_.maxOutputSize,D=_.iouThreshold,B=_.scoreThreshold,U={boxes:y,scores:v},J={maxOutputSize:C,iouThreshold:D,scoreThreshold:B,padToMaxOutputSize:d},fe=Ie.runKernel(La,U,J);return{selectedIndices:fe[0],validOutputs:fe[1]}}var G0=Ee({nonMaxSuppressionPadded_:H0});function j0(t,e,n,a,c,d){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=!1),O(this,void 0,void 0,function(){var y,v,_,C,D,B,U,J,fe,Pe;return H(this,function(Me){switch(Me.label){case 0:return y=ie(t,"boxes","nonMaxSuppressionAsync"),v=ie(e,"scores","nonMaxSuppressionAsync"),_=pl(y,v,n,a,c,null),C=_.maxOutputSize,D=_.iouThreshold,B=_.scoreThreshold,[4,Promise.all([y.data(),v.data()])];case 1:return U=Me.sent(),J=U[0],fe=U[1],Pe=Yd(J,fe,C,D,B,d),y!==t&&y.dispose(),v!==e&&v.dispose(),[2,Pe]}})})}var q0=j0;function K0(t,e,n){n===void 0&&(n=!1);var a=ie(t,"images","resizeBilinear");W(a.rank===3||a.rank===4,function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got "+("rank "+a.rank+".")}),W(e.length===2,function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+(e+".")});var c=a,d=!1;a.rank===3&&(d=!0,c=Ke(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var y=e[0],v=e[1],_=function(U,J){return J([c]),U.resizeBilinear(c,y,v,n)},C={images:c},D={alignCorners:n,size:e},B=Ie.runKernelFunc(_,C,null,Qn,D);return d?Ke(B,[B.shape[1],B.shape[2],B.shape[3]]):B}var Jd=Ee({resizeBilinear_:K0});function X0(t,e,n){n===void 0&&(n=!1);var a=ie(t,"images","resizeNearestNeighbor");W(a.rank===3||a.rank===4,function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got "+("rank "+a.rank+".")}),W(e.length===2,function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+(e+".")}),W(a.dtype==="float32"||a.dtype==="int32",function(){return"`images` must have `int32` or `float32` as dtype"});var c=a,d=!1;a.rank===3&&(d=!0,c=Ke(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var y=e[0],v=e[1],_={images:c},C={alignCorners:n,size:e},D=function(U,J){return J([c]),U.resizeNearestNeighbor(c,y,v,n)},B=Ie.runKernelFunc(D,_,null,oa,C);return d?Ke(B,[B.shape[1],B.shape[2],B.shape[3]]):B}var $d=Ee({resizeNearestNeighbor_:X0});function Y0(t,e,n){W(e%1===0,function(){return"bandPart(): numLower must be an integer, got "+e+"."}),W(n%1===0,function(){return"bandPart(): numUpper must be an integer, got "+n+"."});var a=ie(t,"a","bandPart");W(a.rank>=2,function(){return"bandPart(): Rank must be at least 2, got "+a.rank+"."});var c=a.shape,d=a.shape.slice(-2),y=d[0],v=d[1];if(!(e<=y))throw new Error("bandPart(): numLower ("+e+")"+(" must not be greater than the number of rows ("+y+")."));if(!(n<=v))throw new Error("bandPart(): numUpper ("+n+")"+(" must not be greater than the number of columns ("+v+")."));e<0&&(e=y),n<0&&(n=v);var _=Ke(_p(0,y,1,"int32"),[-1,1]),C=_p(0,v,1,"int32"),D=zr(_,C),B=nc(ec(D,Wr(+e,"int32")),$u(D,Wr(-n,"int32"))),U=Ys([y,v],a.dtype);return Ke(sc(Wh(Ke(a,[-1,y,v])).map(function(J){return us(B,J,U)})),c)}var Q0=Ee({bandPart_:Y0});function Z0(t){var e;if(Array.isArray(t)){e=!1,W(t!=null&&t.length>0,function(){return"Gram-Schmidt process: input must not be null, undefined, or empty"});for(var n=t[0].shape[0],a=function(_){W(t[_].shape[0]===n,function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: "+("("+t[_].shape[0]+" vs. "+n+")")})},c=1;c<t.length;++c)a(c)}else e=!0,t=ll(t,t.shape[0],0).map(function(_){return Bh(_,[0])});W(t.length<=t[0].shape[0],function(){return"Gram-Schmidt: Number of vectors ("+t.length+") exceeds "+("number of dimensions ("+t[0].shape[0]+").")});for(var d=[],y=t,v=function(C){d.push(Ie.tidy(function(){var D=y[C];if(C>0)for(var B=0;B<C;++B){var U=bt(Yr(bt(d[B],D)),d[B]);D=zr(D,U)}return Br(D,Uh(D,"euclidean"))}))},c=0;c<t.length;++c)v(c);return e?sc(d,0):d}var J0=Ee({gramSchmidt_:Z0});function $0(t,e){if(e===void 0&&(e=!1),W(t.rank>=2,function(){return"qr() requires input tensor to have a rank >= 2, but got rank "+t.rank}),t.rank===2)return ef(t,e);var n=t.shape.slice(0,t.shape.length-2).reduce(function(_,C){return _*C}),a=Wh(Ke(t,[n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),c=[],d=[];a.forEach(function(_){var C=ef(_,e),D=C[0],B=C[1];c.push(D),d.push(B)});var y=Ke(sc(c,0),t.shape),v=Ke(sc(d,0),t.shape);return[y,v]}function ef(t,e){return e===void 0&&(e=!1),Ie.tidy(function(){W(t.shape.length===2,function(){return"qr2d() requires a 2D Tensor, but got a "+t.shape.length+"D Tensor."});for(var n=t.shape[0],a=t.shape[1],c=$p(n),d=Ho(t),y=yh([[1]],[1,1]),v=Ho(y),_=n>=a?a:n,C=function(B){var U,J=d,fe=v,Pe=c;U=Ie.tidy(function(){var Me=$t(d,[B,B],[n-B,1]),He=Uh(Me),ct=$t(d,[B,B],[1,1]),It=us(_u(ct,0),yh([[-1]]),yh([[1]])),Ct=zr(ct,bt(It,He)),Bt=Br(Me,Ct);Bt.shape[0]===1?v=Ho(y):v=kr([y,$t(Bt,[1,0],[Bt.shape[0]-1,Bt.shape[1]])],0);var sr=$a(Br(un(It,Ct),He)),er=$t(d,[B,0],[n-B,a]),mr=bt(sr,v),Gr=$n(v);if(B===0)d=zr(er,un(mr,un(Gr,er)));else{var en=zr(er,un(mr,un(Gr,er)));d=kr([$t(d,[0,0],[B,a]),en],0)}var Qr=$n(mr),Zr=$t(c,[0,B],[n,c.shape[1]-B]);if(B===0)c=zr(Zr,un(un(Zr,v),Qr));else{var Kr=zr(Zr,un(un(Zr,v),Qr));c=kr([$t(c,[0,0],[n,B]),Kr],1)}return[v,d,c]}),v=U[0],d=U[1],c=U[2],Pa([J,fe,Pe])},D=0;D<_;++D)C(D);return!e&&n>a&&(c=$t(c,[0,0],[n,a]),d=$t(d,[0,0],[a,a])),[c,d]})}var e2=Ee({qr_:$0});(function(t){t[t.NONE=0]="NONE",t[t.MEAN=1]="MEAN",t[t.SUM=2]="SUM",t[t.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"})(N.Reduction||(N.Reduction={}));function t2(t,e,n){n===void 0&&(n=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=ie(t,"losses","computeWeightedLoss"),c=null;e!=null&&(c=ie(e,"weights","computeWeightedLoss"));var d=c==null?a:bt(a,c);if(n===N.Reduction.NONE)return d;if(n===N.Reduction.SUM)return Yr(d);if(n===N.Reduction.MEAN){if(c==null)return ph(d);var y=a.size/c.size,v=Br(Yr(d),Yr(c));return y>1?Br(v,Wr(y)):v}if(n===N.Reduction.SUM_BY_NONZERO_WEIGHTS){if(c==null)return Br(Yr(d),Wr(a.size));var _=bt(c,sl(a.shape)),C=pr(Yr(Oh(_,Wr(0))),"float32");return Br(Yr(d),C)}throw Error("Unknown reduction: "+n)}var Js=Ee({computeWeightedLoss_:t2});function r2(t,e,n,a){a===void 0&&(a=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var c=ie(t,"labels","absoluteDifference"),d=ie(e,"predictions","absoluteDifference"),y=null;n!=null&&(y=ie(n,"weights","absoluteDifference")),nt(c.shape,d.shape,"Error in absoluteDifference: ");var v=ui(zr(c,d));return Js(v,y,a)}var n2=Ee({absoluteDifference_:r2});function a2(t,e,n,a,c){c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"labels","cosineDistance"),y=ie(e,"predictions","cosineDistance"),v=null;a!=null&&(v=ie(a,"weights","cosineDistance")),nt(d.shape,y.shape,"Error in cosineDistance: ");var _=Wr(1),C=zr(_,Yr(bt(d,y),n,!0));return Js(C,v,c)}var i2=Ee({cosineDistance_:a2});function o2(t,e,n,a){a===void 0&&(a=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var c=ie(t,"labels","hingeLoss"),d=ie(e,"predictions","hingeLoss"),y=null;n!=null&&(y=ie(n,"weights","hingeLoss")),nt(c.shape,d.shape,"Error in hingeLoss: ");var v=Wr(1);c=zr(bt(Wr(2),c),v);var _=fh(zr(v,bt(c,d)));return Js(_,y,a)}var s2=Ee({hingeLoss_:o2});function u2(t,e,n,a,c){a===void 0&&(a=1),c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"labels","huberLoss"),y=ie(e,"predictions","huberLoss"),v=null;n!=null&&(v=ie(n,"weights","huberLoss")),nt(d.shape,y.shape,"Error in huberLoss: ");var _=Wr(a),C=ui(zr(y,d)),D=Fh(C,_),B=zr(C,D),U=Cr(bt(Wr(.5),Yn(D)),bt(_,B));return Js(U,v,c)}var c2=Ee({huberLoss_:u2});function l2(t,e,n,a,c){a===void 0&&(a=1e-7),c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"labels","logLoss"),y=ie(e,"predictions","logLoss"),v=null;n!=null&&(v=ie(n,"weights","logLoss")),nt(d.shape,y.shape,"Error in logLoss: ");var _=Wr(1),C=Wr(a),D=$a(bt(d,tc(Cr(y,C)))),B=bt(zr(_,d),tc(Cr(zr(_,y),C))),U=zr(D,B);return Js(U,v,c)}var h2=Ee({logLoss_:l2});function p2(t,e,n,a){a===void 0&&(a=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var c=ie(t,"labels","meanSquaredError"),d=ie(e,"predictions","meanSquaredError"),y=null;n!=null&&(y=ie(n,"weights","meanSquaredError")),nt(c.shape,d.shape,"Error in meanSquaredError: ");var v=Ph(c,d);return Js(v,y,a)}var d2=Ee({meanSquaredError_:p2});function f2(t,e){var n=ie(t,"labels","sigmoidCrossEntropyWithLogits"),a=ie(e,"logits","sigmoidCrossEntropyWithLogits");nt(n.shape,a.shape,"Error in sigmoidCrossEntropyWithLogits: ");var c=fh(a),d=bt(a,n),y=lp(cs($a(ui(a))));return Cr(zr(c,d),y)}function m2(t,e,n,a,c){a===void 0&&(a=0),c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"multiClassLabels","sigmoidCrossEntropy"),y=ie(e,"logits","sigmoidCrossEntropy"),v=null;if(n!=null&&(v=ie(n,"weights","sigmoidCrossEntropy")),nt(d.shape,y.shape,"Error in sigmoidCrossEntropy: "),a>0){var _=Wr(a),C=Wr(1),D=Wr(.5);d=Cr(bt(d,zr(C,_)),bt(D,_))}var B=f2(d,y);return Js(B,v,c)}var y2=Ee({sigmoidCrossEntropy_:m2});function v2(t,e,n){if(n===void 0&&(n=-1),n===-1&&(n=e.rank-1),n!==e.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet "+("supported. Labels / logits was rank "+e.rank+" ")+("and dim was "+n));var a=Cs(function(c,d,y){var v=!0,_=pp(d,[n],v),C=zr(pr(d,"float32"),_);y([c,C]);var D=$a(bt(C,c)),B=Yr(D,[n]),U=function(J,fe){var Pe=fe[0],Me=fe[1],He=ci(J.shape,[n]);return[bt(Ke(J,He),zr(pr(Pe,"float32"),cs(Me))),bt(Ke(J,He),zr(cs(Me),pr(Pe,"float32")))]};return{value:B,gradFunc:U}});return a(t,e)}function g2(t,e,n,a,c){a===void 0&&(a=0),c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"onehotLabels","softmaxCrossEntropy"),y=ie(e,"logits","softmaxCrossEntropy"),v=null;if(n!=null&&(v=ie(n,"weights","softmaxCrossEntropy")),nt(d.shape,y.shape,"Error in softmaxCrossEntropy: "),a>0){var _=Wr(a),C=Wr(1),D=Wr(d.shape[1]);d=Cr(bt(d,zr(C,_)),Br(_,D))}var B=v2(d,y);return Js(B,v,c)}var x2=Ee({softmaxCrossEntropy_:g2}),_2={fft:Lh,ifft:mh,rfft:zh,irfft:Ip},w2={hammingWindow:g0,hannWindow:qd,frame:Kd,stft:b0},b2={flipLeftRight:N0,resizeNearestNeighbor:$d,resizeBilinear:Jd,rotateWithOffset:T0,cropAndResize:S0,nonMaxSuppression:R0,nonMaxSuppressionAsync:P0,nonMaxSuppressionWithScore:W0,nonMaxSuppressionWithScoreAsync:V0,nonMaxSuppressionPadded:G0,nonMaxSuppressionPaddedAsync:q0},k2={bandPart:Q0,gramSchmidt:J0,qr:e2},S2={absoluteDifference:n2,computeWeightedLoss:Js,cosineDistance:i2,hingeLoss:s2,huberLoss:c2,logLoss:h2,meanSquaredError:d2,sigmoidCrossEntropy:y2,softmaxCrossEntropy:x2},wu=function(t){ke(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.minimize=function(n,a,c){a===void 0&&(a=!1);var d=this.computeGradients(n,c),y=d.value,v=d.grads;if(c!=null){var _=c.map(function(C){return{name:C.name,tensor:v[C.name]}});this.applyGradients(_)}else this.applyGradients(v);return Pa(v),a?y:(y.dispose(),null)},Object.defineProperty(e.prototype,"iterations",{get:function(){return this.iterations_==null&&(this.iterations_=0),this.iterations_},enumerable:!0,configurable:!0}),e.prototype.incrementIterations=function(){this.iterations_=this.iterations+1},e.prototype.computeGradients=function(n,a){return od(n,a)},e.prototype.dispose=function(){this.iterations_!=null&&Pa(this.iterations_)},e.prototype.saveIterations=function(){return O(this,void 0,void 0,function(){return H(this,function(n){return this.iterations_==null&&(this.iterations_=0),[2,{name:"iter",tensor:Wr(this.iterations_,"int32")}]})})},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){throw new Error("getWeights() is not implemented for this optimizer yet.")})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){return H(this,function(a){throw new Error("setWeights() is not implemented for this optimizer class "+(""+this.getClassName()))})})},e.prototype.extractIterations=function(n){return O(this,void 0,void 0,function(){var a;return H(this,function(c){switch(c.label){case 0:return a=this,[4,n[0].tensor.data()];case 1:return a.iterations_=c.sent()[0],[2,n.slice(1)]}})})},e}(Yc);Object.defineProperty(wu,Symbol.hasInstance,{value:function(t){return t.minimize!=null&&t.computeGradients!=null&&t.applyGradients!=null}});var Rp=function(t){ke(e,t);function e(n,a,c){c===void 0&&(c=null);var d=t.call(this)||this;return d.learningRate=n,d.rho=a,d.epsilon=c,d.accumulatedGrads=[],d.accumulatedUpdates=[],c==null&&(d.epsilon=Ie.backend.epsilon()),d}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Ie.registeredVariables[d],_=!1;a.accumulatedGrads[y]==null&&(a.accumulatedGrads[y]={originalName:d+"/accum_grad",variable:sa(function(){return gn(v).variable(_)})}),a.accumulatedUpdates[y]==null&&(a.accumulatedUpdates[y]={originalName:d+"/accum_var",variable:sa(function(){return gn(v).variable(_)})});var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var D=a.accumulatedGrads[y].variable,B=a.accumulatedUpdates[y].variable;sa(function(){var U=Cr(bt(D,a.rho),bt(Yn(C),1-a.rho)),J=bt(Br(eo(Cr(B,a.epsilon)),eo(Cr(D,a.epsilon))),C),fe=Cr(bt(B,a.rho),bt(Yn(J),1-a.rho));D.assign(U),B.assign(fe);var Pe=Cr(bt(J,-a.learningRate),v);v.assign(Pe)})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedUpdates!=null&&(Pa(this.accumulatedGrads.map(function(n){return n.variable})),Pa(this.accumulatedUpdates.map(function(n){return n.variable})))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){var n;return H(this,function(a){switch(a.label){case 0:return n=this.accumulatedGrads.concat(this.accumulatedUpdates),[4,this.saveIterations()];case 1:return[2,[a.sent()].concat(n.map(function(c){return{name:c.originalName,tensor:c.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a,c;return H(this,function(d){switch(d.label){case 0:return[4,this.extractIterations(n)];case 1:return n=d.sent(),a=n.length/2,c=!1,this.accumulatedGrads=n.slice(0,a).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}}),this.accumulatedUpdates=n.slice(a,a*2).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}}),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}},e.fromConfig=function(n,a){return new n(a.learningRate,a.rho,a.epsilon)},e.className="Adadelta",e}(wu);jo(Rp);var Ap=function(t){ke(e,t);function e(n,a){a===void 0&&(a=.1);var c=t.call(this)||this;return c.learningRate=n,c.initialAccumulatorValue=a,c.accumulatedGrads=[],c}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Ie.registeredVariables[d];if(a.accumulatedGrads[y]==null){var _=!1;a.accumulatedGrads[y]={originalName:d+"/accumulator",variable:sa(function(){return up(v.shape,a.initialAccumulatorValue).variable(_)})}}var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var D=a.accumulatedGrads[y].variable;sa(function(){var B=Cr(D,Yn(C));D.assign(B);var U=Cr(bt(Br(C,eo(Cr(B,Ie.backend.epsilon()))),-a.learningRate),v);v.assign(U)})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedGrads!=null&&Pa(this.accumulatedGrads.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){switch(n.label){case 0:return[4,this.saveIterations()];case 1:return[2,[n.sent()].concat(this.accumulatedGrads.map(function(a){return{name:a.originalName,tensor:a.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a;return H(this,function(c){switch(c.label){case 0:return[4,this.extractIterations(n)];case 1:return n=c.sent(),a=!1,this.accumulatedGrads=n.map(function(d){return{originalName:d.name,variable:d.tensor.variable(a)}}),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}},e.fromConfig=function(n,a){return new n(a.learningRate,a.initialAccumulatorValue)},e.className="Adagrad",e}(wu);jo(Ap);var Dp=function(t){ke(e,t);function e(n,a,c,d){d===void 0&&(d=null);var y=t.call(this)||this;return y.learningRate=n,y.beta1=a,y.beta2=c,y.epsilon=d,y.accumulatedFirstMoment=[],y.accumulatedSecondMoment=[],sa(function(){y.accBeta1=Wr(a).variable(),y.accBeta2=Wr(c).variable()}),d==null&&(y.epsilon=Ie.backend.epsilon()),y}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);sa(function(){var d=zr(1,a.accBeta1),y=zr(1,a.accBeta2);c.forEach(function(v,_){var C=Ie.registeredVariables[v],D=!1;a.accumulatedFirstMoment[_]==null&&(a.accumulatedFirstMoment[_]={originalName:v+"/m",variable:sa(function(){return gn(C).variable(D)})}),a.accumulatedSecondMoment[_]==null&&(a.accumulatedSecondMoment[_]={originalName:v+"/v",variable:sa(function(){return gn(C).variable(D)})});var B=Array.isArray(n)?n[_].tensor:n[v];if(B==null)return;var U=a.accumulatedFirstMoment[_].variable,J=a.accumulatedSecondMoment[_].variable,fe=Cr(bt(U,a.beta1),bt(B,1-a.beta1)),Pe=Cr(bt(J,a.beta2),bt(Yn(B),1-a.beta2)),Me=Br(fe,d),He=Br(Pe,y);U.assign(fe),J.assign(Pe);var ct=Cr(bt(Br(Me,Cr(eo(He),a.epsilon)),-a.learningRate),C);C.assign(ct)}),a.accBeta1.assign(bt(a.accBeta1,a.beta1)),a.accBeta2.assign(bt(a.accBeta2,a.beta2))}),this.incrementIterations()},e.prototype.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&Pa(this.accumulatedFirstMoment.map(function(n){return n.variable})),this.accumulatedSecondMoment!=null&&Pa(this.accumulatedSecondMoment.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){var n;return H(this,function(a){switch(a.label){case 0:return n=this.accumulatedFirstMoment.concat(this.accumulatedSecondMoment),[4,this.saveIterations()];case 1:return[2,[a.sent()].concat(n.map(function(c){return{name:c.originalName,tensor:c.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a,c,d=this;return H(this,function(y){switch(y.label){case 0:return[4,this.extractIterations(n)];case 1:return n=y.sent(),sa(function(){d.accBeta1.assign(Qs(d.beta1,d.iterations_+1)),d.accBeta2.assign(Qs(d.beta2,d.iterations_+1))}),a=n.length/2,c=!1,this.accumulatedFirstMoment=n.slice(0,a).map(function(v){return{originalName:v.name,variable:v.tensor.variable(c)}}),this.accumulatedSecondMoment=n.slice(a,a*2).map(function(v){return{originalName:v.name,variable:v.tensor.variable(c)}}),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}},e.fromConfig=function(n,a){return new n(a.learningRate,a.beta1,a.beta2,a.epsilon)},e.className="Adam",e}(wu);jo(Dp);var Fp=function(t){ke(e,t);function e(n,a,c,d,y){d===void 0&&(d=null),y===void 0&&(y=0);var v=t.call(this)||this;return v.learningRate=n,v.beta1=a,v.beta2=c,v.epsilon=d,v.decay=y,v.accumulatedFirstMoment=[],v.accumulatedWeightedInfNorm=[],sa(function(){v.iteration=Wr(0).variable(),v.accBeta1=Wr(a).variable()}),d==null&&(v.epsilon=Ie.backend.epsilon()),v}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);sa(function(){var d=zr(1,a.accBeta1),y=Br(-a.learningRate,Cr(bt(a.iteration,a.decay),1));c.forEach(function(v,_){var C=Ie.registeredVariables[v],D=!1;a.accumulatedFirstMoment[_]==null&&(a.accumulatedFirstMoment[_]={originalName:v+"/m",variable:gn(C).variable(D)}),a.accumulatedWeightedInfNorm[_]==null&&(a.accumulatedWeightedInfNorm[_]={originalName:v+"/v",variable:gn(C).variable(D)});var B=Array.isArray(n)?n[_].tensor:n[v];if(B==null)return;var U=a.accumulatedFirstMoment[_].variable,J=a.accumulatedWeightedInfNorm[_].variable,fe=Cr(bt(U,a.beta1),bt(B,1-a.beta1)),Pe=bt(J,a.beta2),Me=ui(B),He=ol(Pe,Me);U.assign(fe),J.assign(He);var ct=Cr(bt(Br(y,d),Br(fe,Cr(He,a.epsilon))),C);C.assign(ct)}),a.iteration.assign(Cr(a.iteration,1)),a.accBeta1.assign(bt(a.accBeta1,a.beta1))}),this.incrementIterations()},e.prototype.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&Pa(this.accumulatedFirstMoment.map(function(n){return n.variable})),this.accumulatedWeightedInfNorm!=null&&Pa(this.accumulatedWeightedInfNorm.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){throw new Error("getWeights() is not implemented for Adamax yet.")})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){return H(this,function(a){throw new Error("setWeights() is not implemented for Adamax yet.")})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}},e.fromConfig=function(n,a){return new n(a.learningRate,a.beta1,a.beta2,a.epsilon,a.decay)},e.className="Adamax",e}(wu);jo(Fp);var qh=function(t){ke(e,t);function e(n){var a=t.call(this)||this;return a.learningRate=n,a.setLearningRate(n),a}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Array.isArray(n)?n[y].tensor:n[d];if(v==null)return;var _=Ie.registeredVariables[d];sa(function(){var C=Cr(bt(a.c,v),_);_.assign(C)})}),this.incrementIterations()},e.prototype.setLearningRate=function(n){this.learningRate=n,this.c!=null&&this.c.dispose(),this.c=xu(Wr(-n))},e.prototype.dispose=function(){this.c.dispose()},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){switch(n.label){case 0:return[4,this.saveIterations()];case 1:return[2,[n.sent()]]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){return H(this,function(a){switch(a.label){case 0:return[4,this.extractIterations(n)];case 1:if(n=a.sent(),n.length!==0)throw new Error("SGD optimizer does not have settable weights.");return[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate}},e.fromConfig=function(n,a){return new n(a.learningRate)},e.className="SGD",e}(wu);jo(qh);var Op=function(t){ke(e,t);function e(n,a,c){c===void 0&&(c=!1);var d=t.call(this,n)||this;return d.learningRate=n,d.momentum=a,d.useNesterov=c,d.accumulations=[],d.m=Wr(d.momentum),d}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Ie.registeredVariables[d];if(a.accumulations[y]==null){var _=!1;a.accumulations[y]={originalName:d+"/momentum",variable:sa(function(){return gn(v).variable(_)})}}var C=a.accumulations[y].variable,D=Array.isArray(n)?n[y].tensor:n[d];if(D==null)return;sa(function(){var B,U=Cr(bt(a.m,C),D);a.useNesterov?B=Cr(bt(a.c,Cr(D,bt(U,a.m))),v):B=Cr(bt(a.c,U),v),C.assign(U),v.assign(B)})}),this.incrementIterations()},e.prototype.dispose=function(){this.m.dispose(),this.accumulations!=null&&Pa(this.accumulations.map(function(n){return n.variable}))},e.prototype.setMomentum=function(n){this.momentum=n},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){switch(n.label){case 0:return[4,this.saveIterations()];case 1:return[2,[n.sent()].concat(this.accumulations.map(function(a){return{name:a.originalName,tensor:a.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a;return H(this,function(c){switch(c.label){case 0:return[4,this.extractIterations(n)];case 1:return n=c.sent(),a=!1,this.accumulations=n.map(function(d){return{originalName:d.name,variable:d.tensor.variable(a)}}),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}},e.fromConfig=function(n,a){return new n(a.learningRate,a.momentum,a.useNesterov)},e.className="Momentum",e}(qh);jo(Op);var Mp=function(t){ke(e,t);function e(n,a,c,d,y){a===void 0&&(a=.9),c===void 0&&(c=0),d===void 0&&(d=null),y===void 0&&(y=!1);var v=t.call(this)||this;if(v.learningRate=n,v.decay=a,v.momentum=c,v.epsilon=d,v.accumulatedMeanSquares=[],v.accumulatedMoments=[],v.accumulatedMeanGrads=[],v.centered=y,d==null&&(v.epsilon=Ie.backend.epsilon()),n==null)throw new Error("learningRate for RMSPropOptimizer must be defined.");return v}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Ie.registeredVariables[d],_=!1;a.accumulatedMeanSquares[y]==null&&(a.accumulatedMeanSquares[y]={originalName:d+"/rms",variable:sa(function(){return gn(v).variable(_)})}),a.accumulatedMoments[y]==null&&(a.accumulatedMoments[y]={originalName:d+"/momentum",variable:sa(function(){return gn(v).variable(_)})}),a.accumulatedMeanGrads[y]==null&&a.centered&&(a.accumulatedMeanGrads[y]={originalName:d+"/mg",variable:sa(function(){return gn(v).variable(_)})});var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var D=a.accumulatedMeanSquares[y].variable,B=a.accumulatedMoments[y].variable;sa(function(){var U=Cr(bt(D,a.decay),bt(Yn(C),1-a.decay));if(a.centered){var J=a.accumulatedMeanGrads[y].variable,fe=Cr(bt(J,a.decay),bt(C,1-a.decay)),Pe=Br(bt(C,a.learningRate),eo(zr(U,Cr(Yn(fe),a.epsilon)))),Me=Cr(bt(B,a.momentum),Pe);D.assign(U),J.assign(fe),B.assign(Me);var He=zr(v,Me);v.assign(He)}else{var ct=Cr(bt(D,a.decay),bt(Yn(C),1-a.decay)),Me=Cr(bt(B,a.momentum),Br(bt(C,a.learningRate),eo(Cr(ct,a.epsilon))));D.assign(ct),B.assign(Me);var He=zr(v,Me);v.assign(He)}})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedMeanSquares!=null&&Pa(this.accumulatedMeanSquares.map(function(n){return n.variable})),this.accumulatedMeanGrads!=null&&this.centered&&Pa(this.accumulatedMeanGrads.map(function(n){return n.variable})),this.accumulatedMoments!=null&&Pa(this.accumulatedMoments.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){var n;return H(this,function(a){switch(a.label){case 0:return n=this.accumulatedMeanSquares.concat(this.accumulatedMoments),this.centered&&n.push.apply(n,this.accumulatedMeanGrads),[4,this.saveIterations()];case 1:return[2,[a.sent()].concat(n.map(function(c){return{name:c.originalName,tensor:c.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a,c;return H(this,function(d){switch(d.label){case 0:return[4,this.extractIterations(n)];case 1:return n=d.sent(),a=this.centered?n.length/3:n.length/2,c=!1,this.accumulatedMeanSquares=n.slice(0,a).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}}),this.accumulatedMoments=n.slice(a,a*2).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}}),this.centered&&(this.accumulatedMeanGrads=n.slice(a*2,a*3).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}})),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}},e.fromConfig=function(n,a){return new n(a.learningRate,a.decay,a.momentum,a.epsilon,a.centered)},e.className="RMSProp",e}(wu);jo(Mp);var uc=function(){function t(){}return t.sgd=function(e){return new qh(e)},t.momentum=function(e,n,a){return a===void 0&&(a=!1),new Op(e,n,a)},t.rmsprop=function(e,n,a,c,d){return n===void 0&&(n=.9),a===void 0&&(a=0),c===void 0&&(c=null),d===void 0&&(d=!1),new Mp(e,n,a,c,d)},t.adam=function(e,n,a,c){return e===void 0&&(e=.001),n===void 0&&(n=.9),a===void 0&&(a=.999),c===void 0&&(c=null),new Dp(e,n,a,c)},t.adadelta=function(e,n,a){return e===void 0&&(e=.001),n===void 0&&(n=.95),a===void 0&&(a=null),new Rp(e,n,a)},t.adamax=function(e,n,a,c,d){return e===void 0&&(e=.002),n===void 0&&(n=.9),a===void 0&&(a=.999),c===void 0&&(c=null),d===void 0&&(d=0),new Fp(e,n,a,c,d)},t.adagrad=function(e,n){return n===void 0&&(n=.1),new Ap(e,n)},t}(),I2={sgd:uc.sgd,momentum:uc.momentum,adadelta:uc.adadelta,adagrad:uc.adagrad,rmsprop:uc.rmsprop,adamax:uc.adamax,adam:uc.adam},N2=function(){return typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:function(t){return t()}}();function C2(){return new Promise(function(t){return N2(function(){return t()})})}function T2(t,e,n){var a=n*(typeof t=="number"?t:t[0]),c=e*(typeof t=="number"?t:t[1]);return[a,c]}function E2(t,e,n,a){a===void 0&&(a=!0);var c=[];if(a)c=c.concat(e.slice(0)),c.push(t[0]/n),c=c.concat(t.slice(1));else{c=c.concat(t[0]);for(var d=e.length,y=0;y<d;++y)c=c.concat([t[y+1]/e[y],e[y]]);c=c.concat(t.slice(d+1))}return c}function R2(t,e,n){n===void 0&&(n=!0);var a=[];if(n){a.push(e);for(var c=e+1;c<t;++c)c<=2*e?(a.push(c),a.push(c-(e+1))):a.push(c)}else{for(var d=[],y=[],c=1;c<t;++c)c>=e*2+1||c%2===1?y.push(c):d.push(c);a.push.apply(a,d),a.push(0),a.push.apply(a,y)}return a}function A2(t,e,n,a){a===void 0&&(a=!0);var c=[];a?c.push(t[0]/n):c.push(t[0]*n);for(var d=1;d<t.length;++d)d<=e.length?a?c.push(e[d-1]*t[d]):c.push(t[d]/e[d-1]):c.push(t[d]);return c}function D2(t,e){for(var n=[0],a=0;a<e;++a)n.push(t[a][0]);return n}function F2(t,e,n){for(var a=t.slice(0,1),c=0;c<n;++c)a.push(t[c+1]-e[c][0]-e[c][1]);return a}var tf=1.7580993408473768,rf=1.0507009873554805,O2=.3275911,M2=.254829592,L2=-.284496736,z2=1.421413741,P2=-1.453152027,B2=1.061405429;function W2(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Rr().getBool("IS_TEST")||console.warn.apply(console,t)}function U2(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Rr().getBool("IS_TEST")||console.log.apply(console,t)}function V2(t,e){if(t.length!==e.length)throw new Error("Cannot merge real and imag arrays of different lengths. real:"+(t.length+", imag: "+e.length+"."));for(var n=new Float32Array(t.length*2),a=0;a<n.length;a+=2)n[a]=t[a/2],n[a+1]=e[a/2];return n}function H2(t){for(var e=new Float32Array(t.length/2),n=new Float32Array(t.length/2),a=0;a<t.length;a+=2)e[a/2]=t[a],n[a/2]=t[a+1];return{real:e,imag:n}}function G2(t){for(var e=Math.ceil(t.length/4),n=new Float32Array(e),a=new Float32Array(e),c=0;c<t.length;c+=4)n[Math.floor(c/4)]=t[c],a[Math.floor(c/4)]=t[c+1];return{real:n,imag:a}}function j2(t){for(var e=Math.floor(t.length/4),n=new Float32Array(e),a=new Float32Array(e),c=2;c<t.length;c+=4)n[Math.floor(c/4)]=t[c],a[Math.floor(c/4)]=t[c+1];return{real:n,imag:a}}function q2(t,e){var n=t[e*2],a=t[e*2+1];return{real:n,imag:a}}function K2(t,e,n,a){t[a*2]=e,t[a*2+1]=n}function X2(t,e){for(var n=new Float32Array(t/2),a=new Float32Array(t/2),c=0;c<Math.ceil(t/2);c++){var d=(e?2:-2)*Math.PI*(c/t);n[c]=Math.cos(d),a[c]=Math.sin(d)}return{real:n,imag:a}}function Y2(t,e,n){var a=(n?2:-2)*Math.PI*(t/e),c=Math.cos(a),d=Math.sin(a);return{real:c,imag:d}}function Q2(t,e,n){if(e==="complex64"){if(t.dtype==="complex64")return t.clone();var a=Ys(t.shape),c=pr(t,"float32"),d=n.complex(c,a);return a.dispose(),c.dispose(),d}if(!Oa(t.dtype,e))return Ie.makeTensorFromDataId(t.dataId,t.shape,e);if(t.dtype==="complex64"){var y=n.real(t),d=pr(y,e);return y.dispose(),d}if(e==="int32")return n.int(t);if(e==="bool"){var v=Wr(0,t.dtype),d=n.notEqual(t,v);return v.dispose(),d}else throw new Error("Error in Cast: failed to cast "+t.dtype+" to "+e)}function Z2(t,e){return Ie.makeTensorFromDataId(t.dataId,e,t.dtype)}function J2(t,e,n){var a=(e-t)/(n-1),c=ha(n,"float32");c[0]=t;for(var d=1;d<c.length;d++)c[d]=c[d-1]+a;return cl(c,"float32")}var $2={__proto__:null,slice_util:Xc,segment_util:Jf,castTensor:Q2,reshapeTensor:Z2,linspaceImpl:J2,upcastType:Pt,axesAreInnerMostDims:Qu,combineLocations:tl,computeOutAndReduceShapes:rl,expandShapeToKeepDim:ci,assertAxesAreInnerMostDims:nl,getAxesPermutation:Ji,getUndoAxesPermutation:f,getInnerMostAxes:p,getBroadcastDims:Mf,getReductionAxes:Ja,assertAndGetBroadcastShape:ca,assertParamsConsistent:lr,computeOutShape:Ir,computeDilation2DInfo:o,computePool2DInfo:h,computePool3DInfo:b,computeConv2DInfo:T,computeConv3DInfo:M,computeDefaultPad:le,tupleValuesAreOne:st,eitherStridesOrDilationsAreOne:dt,convertConv2DDataFormat:Dt,getFusedDyActivation:Vh,getFusedBiasGradient:Hh,applyActivation:Gh,shouldFuse:jh,PARALLELIZE_THRESHOLD:cp,computeOptimalWindowSize:Yf,getImageCenter:T2,getReshaped:E2,getPermuted:R2,getReshapedPermuted:A2,getSliceBeginCoords:D2,getSliceSize:F2,prepareAndValidate:Bu,validateUpdateShape:Zi,validateInput:Wu,calculateShapes:os,SELU_SCALEALPHA:tf,SELU_SCALE:rf,ERF_P:O2,ERF_A1:M2,ERF_A2:L2,ERF_A3:z2,ERF_A4:P2,ERF_A5:B2,warn:W2,log:U2,mergeRealAndImagArrays:V2,splitRealAndImagArrays:H2,complexWithEvenIndex:G2,complexWithOddIndex:j2,getComplexWithIndex:q2,assignToTypedArray:K2,exponents:X2,exponent:Y2,prepareSplitSize:_d};function ev(t,e,n){var a=new Array(t.rank).fill(0),c=t.shape.slice();return e.map(function(d){var y=c.slice();y[n]=d;var v=$t(t,a,y);return a[n]+=d,v})}function tv(t,e){for(var n=new Array(t.rank),a=0;a<n.length;a++)n[a]=t.shape[a]*e[a];for(var c=Qi(n,t.dtype),a=0;a<c.values.length;++a){for(var d=c.indexToLoc(a),y=new Array(t.rank),v=0;v<y.length;v++)y[v]=d[v]%t.shape[v];var _=t.locToIndex(y);c.values[a]=t.values[_]}return c.toTensor()}function rv(t,e,n,a,c){for(var d=e[e.length-1],y=[t.length/d,d],v=y[0],_=y[1],C=jr(n,v*a),D=jr("int32",v*a),B=0;B<v;B++){for(var U=B*_,J=t.subarray(U,U+_),fe=[],Pe=0;Pe<J.length;Pe++)fe.push({value:J[Pe],index:Pe});fe.sort(function(Ct,Bt){return Bt.value-Ct.value});for(var Me=B*a,He=C.subarray(Me,Me+a),ct=D.subarray(Me,Me+a),Pe=0;Pe<a;Pe++)He[Pe]=fe[Pe].value,ct[Pe]=fe[Pe].index}var It=e.slice();return It[It.length-1]=a,[Dn(C,It,n),Dn(D,It,"int32")]}var nv={__proto__:null,nonMaxSuppressionV3Impl:Xd,nonMaxSuppressionV4Impl:Yd,nonMaxSuppressionV5Impl:Qd,split:ev,tile:tv,topkImpl:rv,whereImpl:Id},av={kernelName:qn,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,hl(pr(n,"float32"),-1))}}}},iv={kernelName:ri,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=Yn(pr(n,"float32")),c=eo(zr(Wr(1),a));return $a(Br(t,c))}}}},ov={kernelName:pi,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=eo(zr(Yn(pr(n,"float32")),1));return Br(t,a)}}}},sv={kernelName:pa,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=t,_=Ja(n.shape,c);return _.length>0&&(v=Yr(v,_)),Ke(v,n.shape)},y=function(){var v=t,_=Ja(a.shape,c);return _.length>0&&(v=Yr(v,_)),Ke(v,a.shape)};return{a:d,b:y}}},uv={kernelName:di,saveAllInputs:!0,gradFunc:function(t,e){var n={};return e.forEach(function(a,c){n[c]=function(){return t.clone()}}),n}},cv={kernelName:ln,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return gn(n)}}}},lv={kernelName:ni,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return gn(n)}}}},hv={kernelName:gr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,eo(zr(Wr(1),Yn(pr(n,"float32")))))}}}},pv={kernelName:Di,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=eo(Cr(Wr(1),Yn(pr(n,"float32"))));return Br(t,a)}}}},dv={kernelName:Zn,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=Cr(Yn(n),Yn(a)),_=bt(t,Br(a,v)),C=Ja(n.shape,c);return C.length>0&&(_=Yr(_,C)),Ke(_,n.shape)},y=function(){var v=Cr(Yn(n),Yn(a)),_=$a(bt(t,Br(n,v))),C=Ja(a.shape,c);return C.length>0&&(_=Yr(_,C)),Ke(_,a.shape)};return{a:d,b:y}}},fv={kernelName:bi,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,Cr(Yn(pr(n,"float32")),1))}}}},mv={kernelName:ro,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,zr(Wr(1),Yn(pr(n,"float32"))))}}}};function yv(t,e,n,a,c,d,y){c===void 0&&(c=[1,1,1]);var v=ie(t,"dy","avgPool3dBackprop"),_=ie(e,"input","avgPool3dBackprop"),C=v,D=_,B=!1;_.rank===4&&(B=!0,C=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2],v.shape[3]]),D=Ke(_,[1,_.shape[0],_.shape[1],_.shape[2],_.shape[3]])),W(C.rank===5,function(){return"Error in avgPool3dBackprop: dy must be rank 5 but got rank "+(C.rank+".")}),W(D.rank===5,function(){return"Error in avgPool3dBackprop: input must be rank 5 but got rank "+(D.rank+".")}),W(dt(a,c),function(){return"Error in avgPool3dBackprop: Either strides or dilations "+("must be 1. Got strides "+a+" and dilations '"+c+"'")}),y!=null&&W(xt(d),function(){return"Error in maxPool3dBackprop: pad must be an integer when "+("using, dimRoundingMode "+y+" but got pad "+d+".")});var U=function(Me){var He=b(D.shape,n,a,c,d,y);return Me.avgPool3dBackprop(C,D,He)},J={dy:C,input:D},fe={filterSize:n,strides:a,dilations:c,pad:d,dimRoundingMode:y},Pe=Ie.runKernelFunc(U,J,null,Oi,fe);return B?Ke(Pe,[Pe.shape[1],Pe.shape[2],Pe.shape[3],Pe.shape[4]]):Pe}var vv=Ee({avgPool3dBackprop_:yv}),gv={kernelName:ji,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.filterSize,y=c.strides,v=c.dilations,_=c.pad,C=c.dimRoundingMode,D=v??[1,1,1];return{x:function(){return vv(t,a,d,y,D,_,C)}}}};function xv(t,e,n,a,c){var d=ie(t,"dy","avgPoolBackprop"),y=ie(e,"input","avgPoolBackprop");W(y.rank===d.rank,function(){return"Rank of input ("+y.rank+") does not match rank of dy ("+d.rank+")"});var v=y,_=d,C=!1;y.rank===3&&(C=!0,v=Ke(y,[1,y.shape[0],y.shape[1],y.shape[2]]),_=Ke(d,[1,d.shape[0],d.shape[1],d.shape[2]])),W(_.rank===4,function(){return"Error in avgPoolBackprop: dy must be rank 4 but got rank "+(_.rank+".")}),W(v.rank===4,function(){return"Error in avgPoolBackprop: input must be rank 4 but got rank "+(v.rank+".")});var D=function(fe){var Pe=h(v.shape,n,a,1,c);return fe.avgPoolBackprop(_,v,Pe)},B={dy:_,input:v},U={filterSize:n,strides:a,pad:c},J=Ie.runKernelFunc(D,B,null,Fi,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3]]):J}var _v=Ee({avgPoolBackprop_:xv}),wv={kernelName:Gi,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.filterSize,y=c.strides,v=c.pad;return{x:function(){return _v(t,a,d,y,v)}}}},bv={kernelName:da,inputsToSave:["a","b"],gradFunc:function(t,e,n){var a=e[0],c=e[1],d=n,y=d.transposeA,v=d.transposeB;return!y&&!v?{a:function(){return un(t,c,!1,!0)},b:function(){return un(a,t,!0,!1)}}:!y&&v?{a:function(){return un(t,c,!1,!1)},b:function(){return un(t,a,!0,!1)}}:y&&!v?{a:function(){return un(c,t,!1,!0)},b:function(){return un(a,t,!1,!1)}}:{a:function(){return un(c,t,!0,!0)},b:function(){return un(t,a,!0,!0)}}}},kv={kernelName:Mi,gradFunc:function(t,e,n){var a=n,c=a.blockShape,d=a.crops;return{x:function(){return Mh(t,c,d)}}}},Sv={kernelName:pe,gradFunc:function(t,e,n){for(var a=n,c=a.inputShape,d=a.shape,y=Array.from(d),v=c.length-1;v>=0;v--)if(c[v]===d[v])y[v]=1;else if(c[v]!==1)throw new Error("broadcastTo(): ["+c+"] cannot be broadcast to ["+d+"].");for(var _=[],v=0;v<y.length;v++)y[v]>1&&_.push(v);return{x:function(){return Yr(t,_,!0)}}}},Iv={kernelName:X,gradFunc:function(t){return{x:function(){return t.clone()}}}},Nv={kernelName:j,gradFunc:function(t){return{x:function(){return gn(t)}}}},Cv={kernelName:re,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.clipValueMin,y=c.clipValueMax;return{x:function(){return us(nc($u(a,d),ec(a,y)),t,gn(t))}}}},Tv={kernelName:Ue,saveAllInputs:!0,gradFunc:function(t,e,n){var a=e.map(function(_){return _.shape}),c=n.axis,d=qt(c,e[0].shape)[0],y=a.map(function(_){return _[d]}),v=ll(t,y,d);return v.map(function(_){return function(){return _}})}},Ev={kernelName:kt,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y=n,v=y.dilations,_=y.strides,C=y.pad,D=y.dataFormat;return W(st(v),function(){return"Error in gradient of conv2D: dilation rates greater than 1 "+("are not yet supported in gradients. Got dilations '"+v+"'")}),{x:function(){return Ti(c.shape,t,d,_,C,D)},filter:function(){return Tp(c,t,d.shape,_,C,D)}}}},Rv={kernelName:Le,inputsToSave:["dy","filter"],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y=n,v=y.strides,_=y.pad,C=y.dataFormat,D=y.dimRoundingMode;return{dy:function(){return gi(t,d,v,_,C,1,D)},filter:function(){return Tp(t,c,d.shape,v,_,C,D)}}}};function Av(t,e,n,a,c){var d=t;t.rank===4&&(d=Ke(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]));var y=e;y.rank===4&&(y=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),W(d.rank===5,function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+(d.shape+".")}),W(y.rank===5,function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+(y.shape+".")}),W(n.length===5,function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+(n+".")}),W(d.shape[4]===n[3],function(){return"Error in conv3dDerFilter: depth of input "+d.shape[4]+") must "+("match input depth in filter ("+n[3]+".")}),W(y.shape[4]===n[4],function(){return"Error in conv3dDerFilter: depth of dy ("+y.shape[4]+") must "+("match output depth for filter ("+n[4]+").")});var v=function(D){var B=1,U=M(d.shape,n,a,B,c);return D.conv3dDerFilter(d,y,U)},_={x:d,dy:y},C={strides:a,pad:c,filterShape:n};return Ie.runKernelFunc(v,_,null,Ft,C)}var Dv=Ee({conv3DBackpropFilter_:Av}),Fv={kernelName:Ye,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=n,c=a.dilations,d=a.strides,y=a.pad;W(st(c),function(){return"Error in gradient of conv3D: dilation rates greater than 1 are "+("not yet supported in gradients. Got dilations '"+c+"'")});var v=e[0],_=e[1];return{x:function(){return Sh(v.shape,t,_,d,y)},filter:function(){return Dv(v,t,_.shape,d,y)}}}},Ov={kernelName:Mt,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt($a(kp(pr(n,"float32"))),t)}}}},Mv={kernelName:dr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(Sp(pr(n,"float32")),t)}}}},Lv={kernelName:ir,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.axis,y=c.exclusive,v=c.reverse;return{x:function(){var _=Ji([d],a.rank),C=op(t,d,y,!v);return _!=null&&(C=$n(C,_)),C}}}},zv={kernelName:ra,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=n,c=a.dilations,d=a.strides,y=a.pad,v=a.dimRoundingMode,_=c??[1,1];W(st(_),function(){return"Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations "+("'"+_+"'")});var C=e,D=C[0],B=C[1];return W(D.rank===4,function(){return"Error in gradient of depthwiseConv2dNative: input must be "+("rank 4, but got rank "+D.rank+".")}),W(B.rank===4,function(){return"Error in gradient of depthwiseConv2dNative: filter must be "+("rank 4, but got rank "+B.rank+".")}),W(D.shape[3]===B.shape[2],function(){return"Error in gradient of depthwiseConv2d: number of input "+("channels ("+D.shape[3]+") must match the inChannels dimension ")+("in filter "+B.shape[2]+".")}),W(dt(d,_),function(){return"Error in gradient of depthwiseConv2d: Either strides or "+("dilations must be 1. Got strides "+d+" and dilations ")+("'"+_+"'.")}),v!=null&&W(xt(y),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+v+" but got pad "+y+".")}),{x:function(){return jd(D.shape,t,B,d,y,c,v)},filter:function(){return Gd(D,t,B.shape,d,y,c,v)}}}},Pv={kernelName:hn,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y={x:c,filter:d,dy:t},v={x:c,filter:d,dy:t};return{x:function(){return Ie.runKernel(na,y,n)},filter:function(){return Ie.runKernel(Jr,v,n)}}}},Bv={kernelName:Vr,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=Br(t,pr(a,"float32")),_=Ja(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,pr(n,"float32")),_=Ja(a.shape,c);_.length>0&&(v=Ke(Yr(v,_),a.shape));var C=Yn(a);return $a(Br(v,pr(C,"float32")))};return{a:d,b:y}}},Wv={kernelName:Jn,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0],a=function(d){return d.eluDer(t,n)},c={dy:t,y:n};return{x:function(){return Ie.runKernelFunc(a,c,null,tn)}}}},Uv={kernelName:Rn,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0],a=bt(cs($a(Yn(n))),2/Math.sqrt(Math.PI));return{x:function(){return bt(t,a)}}}},Vv={kernelName:aa,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,n)}}}},Hv={kernelName:ma,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,cs(n))}}}},Gv={kernelName:x,gradFunc:function(t){return{x:function(){return gn(t)}}}},jv={kernelName:k,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=Br(t,pr(a,"float32")),_=Ja(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,pr(n,"float32")),_=Ja(a.shape,c);_.length>0&&(v=Ke(Yr(v,_),a.shape));var C=Yn(a);return $a(Br(v,pr(C,"float32")))};return{a:d,b:y}}},qv={kernelName:K,inputsToSave:["x","mean","variance","scale"],gradFunc:function(t,e,n){var a=n.varianceEpsilon,c=e[0],d=e[1],y=e[2],v=e[3],_=v??Wr(1),C=Ja(d.shape,c.shape),D=[];if(d.rank===1){for(var B=0;B<c.shape.length-1;++B)D.push(c.shape[B]);D.push(1)}var U=zr(c,d),J=bt(t,_),fe=bp(Cr(y,Wr(a))),Pe=bt(bt(bt(fe,fe),fe),Wr(-.5)),Me=function(){return d.rank===1?Ke(bt(bt(t,il(Ke(fe,[1,1,1,d.shape[0]]),D)),_),c.shape):Ke(bt(bt(t,fe),_),c.shape)},He=function(){var Bt=bt(bt(fe,Wr(-1)),J);return d.rank===1&&(Bt=Yr(Bt,C)),Ke(Bt,d.shape)},ct=function(){var Bt=bt(bt(Pe,U),J);return d.rank===1&&(Bt=Yr(Bt,C)),Ke(Bt,d.shape)},It=function(){var Bt=bt(U,fe),sr=bt(t,Bt);return d.rank===1&&(sr=Yr(sr,C)),Ke(sr,d.shape)},Ct=function(){var Bt=t;return d.rank===1&&(Bt=Yr(Bt,C)),Ke(Bt,d.shape)};return{x:Me,mean:He,variance:ct,scale:It,offset:Ct}}},Kv={kernelName:Se,inputsToSave:["x","indices"],gradFunc:function(t,e,n){var a=e[0],c=e[1],d=n.axis,y=qt(d,a.shape)[0],v=function(){var _=a.shape,C=c.size,D=_.slice(0,y),B=D.length,U=_.slice(d,_.length).slice(1),J=U.length,fe=nf(0,B),Pe=nf(B+1,B+1+J),Me=af([D,[C],U]),He=Ke(t,Me),ct=Ke(c,[C]),It=af([[B],fe,Pe]),Ct=$n(He,It),Bt=Np(Ct,ct,a.shape[y]),sr=f(It);return Bt=$n(Bt,sr),Bt};return{x:v,indices:function(){return c}}}};function nf(t,e){for(var n=[],a=t;a<e;++a)n.push(a);return n}function af(t){for(var e=[],n=0;n<t.length;++n)for(var a=0;a<t[n].length;++a)e.push(t[n][a]);return e}var Xv={kernelName:Be,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1];return{a:function(){return gn(n)},b:function(){return gn(a)}}}},Yv={kernelName:vt,gradFunc:function(t){return{x:function(){return pr(t,"float32")}}}},Qv={kernelName:Wt,gradFunc:function(t){return{x:function(){return gn(t)}}}},Zv={kernelName:Gt,gradFunc:function(t){return{x:function(){return gn(t)}}}},Jv={kernelName:Qt,gradFunc:function(t){return{x:function(){return gn(t)}}}},$v={kernelName:Sn,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,Cr(n,1))}}}},e5={kernelName:xr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,pr(n,"float32"))}}}},t5={kernelName:wa,inputsToSave:[],outputsToSave:[!0],gradFunc:function(t,e,n){var a=e[0],c=n.axis;return{logits:function(){var d=!0,y=cs(a);return zr(t,bt(Yr(t,c,d),y))}}}};function r5(t,e,n,a,c,d,y){a===void 0&&(a=5),c===void 0&&(c=1),d===void 0&&(d=1),y===void 0&&(y=.5);var v=function(D){return D.LRNGrad(n,t,e,a,c,d,y)},_={x:t,y:e,dy:n},C={depthRadius:a,bias:c,alpha:d,beta:y};return Ie.runKernelFunc(v,_,null,ur,C)}var n5=Ee({localResponseNormalizationBackprop_:r5}),a5={kernelName:In,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y=n,v=y.depthRadius,_=y.bias,C=y.alpha,D=y.beta;return{x:function(){return n5(c,d,t,v,_,C,D)}}}};function of(t,e,n,a){return e.rank<n.rank&&(e=Ke(e,ci(e.shape,a))),t.rank<n.rank&&(t=Ke(t,ci(t.shape,a))),{x:function(){var c=bt(t,pr(hh(n,e),t.dtype));return c}}}var sf={kernelName:$r,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var a=n,c=a.reductionIndices,d=e[0],y=e[1],v=qt(c,d.shape),_=of(t,y,d,v);return{x:function(){return _.x()}}}},i5={kernelName:Ra,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=function(){return bt(t,pr($u(n,a),"float32"))},d=function(){return bt(t,pr(Eh(n,a),"float32"))};return{a:c,b:d}}};function o5(t,e,n,a,c,d,y,v){d===void 0&&(d=[1,1,1]);var _=ie(t,"dy","maxPool3dBackprop"),C=ie(e,"input","maxPool3dBackprop"),D=ie(n,"output","maxPool3dBackprop"),B=_,U=C,J=D,fe=!1;C.rank===4&&(fe=!0,B=Ke(_,[1,_.shape[0],_.shape[1],_.shape[2],_.shape[3]]),U=Ke(C,[1,C.shape[0],C.shape[1],C.shape[2],C.shape[3]]),J=Ke(D,[1,D.shape[0],D.shape[1],D.shape[2],D.shape[3]])),W(B.rank===5,function(){return"Error in maxPool3dBackprop: dy must be rank 5 but got rank "+(B.rank+".")}),W(U.rank===5,function(){return"Error in maxPool3dBackprop: input must be rank 5 but got rank "+(U.rank+".")}),W(J.rank===5,function(){return"Error in maxPool3dBackprop: output must be rank 5 but got rank "+(J.rank+".")}),W(dt(c,d),function(){return"Error in maxPool3dBackprop: Either strides or dilations "+("must be 1. Got strides "+c+" and dilations '"+d+"'")}),v!=null&&W(xt(y),function(){return"Error in maxPool3dBackprop: pad must be an integer when "+("using, dimRoundingMode "+v+" but got pad "+y+".")});var Pe=function(It){var Ct=b(U.shape,a,c,d,y,v);return It.maxPool3dBackprop(B,U,J,Ct)},Me={dy:B,input:U,output:J},He={filterSize:a,strides:c,dilations:d,pad:y,dimRoundingMode:v},ct=Ie.runKernelFunc(Pe,Me,null,ai,He);return fe?Ke(ct,[ct.shape[1],ct.shape[2],ct.shape[3],ct.shape[4]]):ct}var s5=Ee({maxPool3dBackprop_:o5}),u5={kernelName:ja,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y=n,v=y.filterSize,_=y.strides,C=y.dilations,D=y.pad,B=y.dimRoundingMode,U=C??[1,1,1];return{x:function(){return s5(t,c,d,v,_,U,D,B)}}}};function c5(t,e,n,a,c,d,y){var v=ie(t,"dy","maxPoolBackprop"),_=ie(e,"input","maxPoolBackprop"),C=ie(n,"output","maxPoolBackprop");W(_.rank===v.rank,function(){return"Rank of input ("+_.rank+") does not match rank of dy "+("("+v.rank+")")}),W(v.rank===4,function(){return"Error in maxPoolBackprop: dy must be rank 4 but got rank "+(v.rank+".")}),W(_.rank===4,function(){return"Error in maxPoolBackprop: input must be rank 4 but got rank "+(_.rank+".")}),y!=null&&W(xt(d),function(){return"Error in maxPoolBackprop: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+d+".")});var D=function(J){var fe=h(_.shape,a,c,1,d,y);return J.maxPoolBackprop(v,_,C,fe)},B={dy:v,input:_,output:C},U={filterSize:a,strides:c,pad:d,dimRoundingMode:y};return Ie.runKernelFunc(D,B,null,Ga,U)}var l5=Ee({maxPoolBackprop_:c5}),h5={kernelName:mi,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y=n,v=y.filterSize,_=y.strides,C=y.pad;return{x:function(){return l5(t,c,d,v,_,C)}}}},p5={kernelName:ba,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var a=n,c=a.axis,d=e[0],y=e[1],v=qt(c,d.shape),_=of(t,y,d,v);return{x:function(){return _.x()}}}},d5={kernelName:qi,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=function(){return bt(t,pr(ec(n,a),"float32"))},d=function(){return bt(t,pr(_u(n,a),"float32"))};return{a:c,b:d}}},f5={kernelName:yi,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n.paddings,d=c.map(function(y){return y[0]});return{x:function(){return $t(t,d,a.shape)}}}},m5={kernelName:ii,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=Ja(n.shape,c);return v.length>0?Ke(Yr(t,v),n.shape):t},y=function(){var v=bt(t,$a(Nh(Br(n,a)))),_=Ja(a.shape,c);return _.length>0?Ke(Yr(v,_),a.shape):v};return{a:d,b:y}}},y5={kernelName:qr,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=bt(t,pr(a,"float32")),_=Ja(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,pr(n,"float32")),_=Ja(a.shape,c);return _.length>0?Ke(Yr(v,_),a.shape):v};return{a:d,b:y}}},v5={kernelName:Io,gradFunc:function(t){return{x:function(){return $a(t)}}}},g5={kernelName:Pi,inputsToSave:["indices"],gradFunc:function(t,e){var n=e[0];return{indices:function(){return Ys(n.shape,"float32")}}}},x5={kernelName:oi,gradFunc:function(t){return{x:function(){return gn(t)}}}},uf={kernelName:no,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n.paddings,d=c.map(function(y){return y[0]});return{x:function(){return $t(t,d,a.shape)}}}},_5={kernelName:Ka,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:function(t,e){var n=e[0],a=e[1],c=e[2],d=n,y=a,v=ca(d.shape,y.shape),_=function(){var D=pr(y,"float32"),B=bt(t,bt(D,Qs(d,zr(D,Wr(1))))),U=Ja(d.shape,v);return U.length>0&&(B=Yr(B,U)),Ke(B,d.shape)},C=function(){var D=_u(d,0),B=us(D,tc(d),gn(d)),U=bt(t,bt(c,B)),J=Ja(y.shape,v);return J.length>0&&(U=Yr(U,J)),Ke(U,y.shape)};return{a:_,b:C}}},w5={kernelName:ao,inputsToSave:["x","alpha"],gradFunc:function(t,e){var n=e[0],a=e[1],c=_u(n,0);return{x:function(){return us(c,t,bt(t,a))},alpha:function(){var d=us(c,gn(t),bt(t,n)),y=Ja(a.shape,t.shape);return y.length>0&&(d=Yr(d,y)),Ke(d,a.shape)}}}},b5={kernelName:io,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,$a(Yn(n)))}}}},k5={kernelName:ka,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0],a=bt(ec(n,6),hl(n));return{x:function(){return bt(t,pr(a,"float32"))}}}},S5={kernelName:ia,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,pr(hl(n),"float32"))}}}},I5={kernelName:Pr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Ke(t,n.shape)}}}},N5={kernelName:Qn,inputsToSave:["images"],gradFunc:function(t,e,n){var a=e[0],c=function(v){var _=n.alignCorners;return v.resizeBilinearBackprop(t,a,_)},d={images:a},y=function(){return Ie.runKernelFunc(c,d,null,oo,n)};return{images:y}}},C5={kernelName:oa,inputsToSave:["images"],gradFunc:function(t,e,n){var a=e[0],c=function(v){var _=n.alignCorners;return v.resizeNearestNeighborBackprop(t,a,_)},d={images:a},y=function(){return Ie.runKernelFunc(c,d,null,Xa,n)};return{images:y}}},T5={kernelName:vn,gradFunc:function(t,e,n){var a=n.dims,c=qt(a,t.shape);return{x:function(){return Zs(t,c)}}}},E5={kernelName:Bi,gradFunc:function(t){return{x:function(){return gn(t)}}}},R5={kernelName:yo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return $a(Br(t,bt(Qs(n,1.5),2)))}}}},A5={kernelName:Aa,inputsToSave:["condition"],gradFunc:function(t,e){var n=e[0];return{condition:function(){return pr(gn(n),"float32")},t:function(){return bt(t,pr(n,t.dtype))},e:function(){return bt(t,pr(Ah(n),t.dtype))}}}},D5={kernelName:go,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=_u(n,Wr(0)),c=Wr(tf),d=Wr(rf),y=bt(t,d),v=bt(bt(t,c),cs(pr(n,"float32")));return us(a,y,v)}}}},F5={kernelName:Ds,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,bt(n,zr(Wr(1),n)))}}}},O5={kernelName:As,gradFunc:function(t){return{x:function(){return gn(t)}}}},M5={kernelName:Rs,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(Ih(pr(n,"float32")),t)}}}},L5={kernelName:Eo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(ip(pr(n,"float32")),t)}}}},z5={kernelName:To,inputsToSave:["x"],gradFunc:function(t,e,n){for(var a=e[0],c=n,d=c.begin,y=c.size,v=a.shape,_=Hu(a,d,y),C=_[0],D=_[1],B=[],U=0;U<t.rank;U++)B.push([C[U],v[U]-C[U]-D[U]]);return{x:function(){return ac(t,B)}}}},P5={kernelName:vi,outputsToSave:[!0],gradFunc:function(t,e,n){var a=e[0],c=n.dim,d=!0,y=bt(t,a);return{logits:function(){return zr(y,bt(Yr(y,[c],d),a))}}}},B5={kernelName:Xo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,fn(n))}}}},cf={kernelName:Ao,gradFunc:function(t,e,n){var a=n,c=a.blockShape,d=a.paddings;return{x:function(){return Hr(t,c,d)}}}},lf={kernelName:Qo,gradFunc:function(t,e,n){var a=n.axis;return{x:function(){return kr(t,a)}}}},W5={kernelName:Ro,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,bt(eo(pr(n,"float32")),2))}}}},U5={kernelName:tu,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,bt(pr(n,"float32"),2))}}}},V5={kernelName:Fs,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=Wr(2),d=function(){return bt(t,bt(c,zr(n,a)))},y=function(){return bt(t,bt(c,zr(a,n)))};return{a:d,b:y}}},H5={kernelName:Zo,gradFunc:function(t){return{x:function(){return gn(t)}}}},G5={kernelName:ps,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=t,_=Ja(n.shape,c);return _.length>0&&(v=Yr(v,_)),Ke(v,n.shape)},y=function(){var v=t,_=Ja(a.shape,c);return _.length>0&&(v=Yr(v,_)),Ke($a(v),a.shape)};return{a:d,b:y}}},j5={kernelName:Yo,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=a.shape.slice(),d=n.axis,y=qt(d,a.shape);y.forEach(function(C){c[C]=1});var v=Ke(t,c),_=bt(v,sl(a.shape,"float32"));return{x:function(){return _}}}},q5={kernelName:ds,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,Yn(Ih(n)))}}}},K5={kernelName:Ms,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(zr(Wr(1),Yn(n)),t)}}}},X5={kernelName:Ls,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n.reps,d=function(){var y=gn(a);if(a.rank===1)for(var v=0;v<c[0];++v)y=Cr(y,$t(t,[v*a.shape[0]],[a.shape[0]]));else if(a.rank===2)for(var v=0;v<c[0];++v)for(var _=0;_<c[1];++_)y=Cr(y,$t(t,[v*a.shape[0],_*a.shape[1]],[a.shape[0],a.shape[1]]));else if(a.rank===3)for(var v=0;v<c[0];++v)for(var _=0;_<c[1];++_)for(var C=0;C<c[2];++C)y=Cr(y,$t(t,[v*a.shape[0],_*a.shape[1],C*a.shape[2]],[a.shape[0],a.shape[1],a.shape[2]]));else if(a.rank===4)for(var v=0;v<c[0];++v)for(var _=0;_<c[1];++_)for(var C=0;C<c[2];++C)for(var D=0;D<c[3];++D)y=Cr(y,$t(t,[v*a.shape[0],_*a.shape[1],C*a.shape[2],D*a.shape[3]],[a.shape[0],a.shape[1],a.shape[2],a.shape[3]]));else throw new Error("Gradient for tile operation is not implemented for rank-"+(a.rank+" tensors yet."));return y};return{x:d}}},Y5={kernelName:fs,gradFunc:function(t,e,n){var a=n,c=a.perm,d=f(c);return{x:function(){return $n(t,d)}}}},Q5={kernelName:ms,gradFunc:function(t,e,n){var a=n,c=a.axis;return{value:function(){return sc(t,c)}}}},Z5={kernelName:Do,inputsToSave:["segmentIds"],gradFunc:function(t,e){var n=e[0],a=function(){return J5(t,n)};return{x:a}}};function J5(t,e){for(var n=ol(e,gn(e)),a=Ch(t,n),c=$u(e,Wr(0,"int32")),d=a.rank-c.rank,y=0;y<d;++y)c=ls(c,y+1);c=nc(c,sl(a.shape,"bool"));var v=gn(a);return us(c,a,v)}for(var $5={kernelName:zs,gradFunc:function(t){return{x:function(){return gn(t)}}}},eg=[av,iv,ov,sv,uv,cv,lv,hv,pv,dv,fv,mv,gv,wv,bv,kv,Sv,Iv,Nv,Cv,Tv,Rv,Ev,Fv,Ov,Mv,Lv,zv,Pv,Bv,Wv,Uv,Vv,Hv,jv,Gv,qv,Kv,Xv,Yv,Qv,Zv,Jv,$v,e5,t5,a5,sf,sf,i5,u5,h5,p5,d5,f5,m5,y5,v5,g5,x5,uf,uf,_5,w5,b5,k5,S5,I5,N5,C5,T5,E5,R5,A5,D5,F5,O5,M5,L5,z5,P5,B5,cf,cf,lf,lf,W5,V5,U5,H5,G5,j5,q5,K5,X5,Y5,Q5,Z5,$5],Lp=0,hf=eg;Lp<hf.length;Lp++){var tg=hf[Lp];iu(tg)}$.prototype.abs=function(){return this.throwIfDisposed(),ui(this)},$.prototype.acos=function(){return this.throwIfDisposed(),$c(this)},$.prototype.acosh=function(){return this.throwIfDisposed(),el(this)},$.prototype.addStrict=function(t){return this.throwIfDisposed(),Fd(this,t)},$.prototype.add=function(t){return this.throwIfDisposed(),Cr(this,t)},$.prototype.all=function(t,e){return this.throwIfDisposed(),m(this,t,e)},$.prototype.any=function(t,e){return this.throwIfDisposed(),I(this,t,e)},$.prototype.argMax=function(t){return this.throwIfDisposed(),z(this,t)},$.prototype.argMin=function(t){return this.throwIfDisposed(),G(this,t)},$.prototype.asScalar=function(){return this.throwIfDisposed(),W(this.size===1,function(){return"The array must have only 1 element."}),Ke(this,[])},$.prototype.asType=function(t){return this.throwIfDisposed(),pr(this,t)},$.prototype.as1D=function(){return this.throwIfDisposed(),Ke(this,[this.size])},$.prototype.as2D=function(t,e){return this.throwIfDisposed(),Ke(this,[t,e])},$.prototype.as3D=function(t,e,n){return this.throwIfDisposed(),Ke(this,[t,e,n])},$.prototype.as4D=function(t,e,n,a){return this.throwIfDisposed(),Ke(this,[t,e,n,a])},$.prototype.as5D=function(t,e,n,a,c){return this.throwIfDisposed(),Ke(this,[t,e,n,a,c])},$.prototype.asin=function(){return this.throwIfDisposed(),be(this)},$.prototype.asinh=function(){return this.throwIfDisposed(),De(this)},$.prototype.atan=function(){return this.throwIfDisposed(),Ge(this)},$.prototype.atan2=function(t){return this.throwIfDisposed(),s(this,t)},$.prototype.atanh=function(){return this.throwIfDisposed(),r(this)},$.prototype.avgPool=function(t,e,n,a){return this.throwIfDisposed(),Xt(this,t,e,n,a)},$.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),Hr(this,t,e)},$.prototype.batchNorm=function(t,e,n,a,c){return this.throwIfDisposed(),Xn(this,t,e,n,a,c)},$.prototype.broadcastTo=function(t){return this.throwIfDisposed(),Ju(this,t)},$.prototype.cast=function(t){return this.throwIfDisposed(),pr(this,t)},$.prototype.ceil=function(){return this.throwIfDisposed(),ah(this)},$.prototype.clipByValue=function(t,e){return this.throwIfDisposed(),oh(this,t,e)},$.prototype.concat=function(t,e){return this.throwIfDisposed(),t instanceof $&&(t=[t]),kr([this].concat(t),e)},$.prototype.conv1d=function(t,e,n,a,c,d){return this.throwIfDisposed(),Ns(this,t,e,n,a,c,d)},$.prototype.conv2dTranspose=function(t,e,n,a,c){return this.throwIfDisposed(),Xs(this,t,e,n,a,c)},$.prototype.conv2d=function(t,e,n,a,c,d){return this.throwIfDisposed(),gi(this,t,e,n,a,c,d)},$.prototype.cos=function(){return this.throwIfDisposed(),Ih(this)},$.prototype.cosh=function(){return this.throwIfDisposed(),ip(this)},$.prototype.cumsum=function(t,e,n){return this.throwIfDisposed(),op(this,t,e,n)},$.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),Kp(this,t,e)},$.prototype.depthwiseConv2D=function(t,e,n,a,c,d){return Sa("depthwiseConv2D is deprecated, use depthwiseConv2d instead"),this.throwIfDisposed(),lh(this,t,e,n,a,c,d)},$.prototype.depthwiseConv2d=function(t,e,n,a,c,d){return this.throwIfDisposed(),lh(this,t,e,n,a,c,d)},$.prototype.dilation2d=function(t,e,n,a,c){return this.throwIfDisposed(),Xp(this,t,e,n,a,c)},$.prototype.divNoNan=function(t){return this.throwIfDisposed(),Yp(this,t)},$.prototype.divStrict=function(t){return this.throwIfDisposed(),Od(this,t)},$.prototype.div=function(t){return this.throwIfDisposed(),Br(this,t)},$.prototype.dot=function(t){return this.throwIfDisposed(),Qp(this,t)},$.prototype.elu=function(){return this.throwIfDisposed(),sp(this)},$.prototype.equalStrict=function(t){return this.throwIfDisposed(),Cd(this,t)},$.prototype.equal=function(t){return this.throwIfDisposed(),hh(this,t)},$.prototype.erf=function(){return this.throwIfDisposed(),Zp(this)},$.prototype.exp=function(){return this.throwIfDisposed(),cs(this)},$.prototype.expandDims=function(t){return this.throwIfDisposed(),ls(this,t)},$.prototype.expm1=function(){return this.throwIfDisposed(),Jp(this)},$.prototype.fft=function(){return this.throwIfDisposed(),Lh(this)},$.prototype.flatten=function(){return this.throwIfDisposed(),Ke(this,[this.size])},$.prototype.floor=function(){return this.throwIfDisposed(),Nh(this)},$.prototype.floorDiv=function(t){return this.throwIfDisposed(),Yu(this,t)},$.prototype.gather=function(t,e){return this.throwIfDisposed(),Ch(this,t,e)},$.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),Td(this,t)},$.prototype.greaterEqual=function(t){return this.throwIfDisposed(),$u(this,t)},$.prototype.greaterStrict=function(t){return this.throwIfDisposed(),Ed(this,t)},$.prototype.greater=function(t){return this.throwIfDisposed(),_u(this,t)},$.prototype.ifft=function(){return this.throwIfDisposed(),mh(this)},$.prototype.irfft=function(){return this.throwIfDisposed(),Ip(this)},$.prototype.isFinite=function(){return this.throwIfDisposed(),td(this)},$.prototype.isInf=function(){return this.throwIfDisposed(),rd(this)},$.prototype.isNaN=function(){return this.throwIfDisposed(),nd(this)},$.prototype.leakyRelu=function(t){return this.throwIfDisposed(),ad(this,t)},$.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),Rd(this,t)},$.prototype.lessEqual=function(t){return this.throwIfDisposed(),ec(this,t)},$.prototype.lessStrict=function(t){return this.throwIfDisposed(),Ad(this,t)},$.prototype.less=function(t){return this.throwIfDisposed(),Eh(this,t)},$.prototype.localResponseNormalization=function(t,e,n,a){return this.throwIfDisposed(),id(this,t,e,n,a)},$.prototype.logSigmoid=function(){return this.throwIfDisposed(),sd(this)},$.prototype.logSoftmax=function(t){return this.throwIfDisposed(),ud(this,t)},$.prototype.logSumExp=function(t,e){return this.throwIfDisposed(),pp(this,t,e)},$.prototype.log=function(){return this.throwIfDisposed(),tc(this)},$.prototype.log1p=function(){return this.throwIfDisposed(),lp(this)},$.prototype.logicalAnd=function(t){return this.throwIfDisposed(),nc(this,t)},$.prototype.logicalNot=function(){return this.throwIfDisposed(),Ah(this)},$.prototype.logicalOr=function(t){return this.throwIfDisposed(),dp(this,t)},$.prototype.logicalXor=function(t){return this.throwIfDisposed(),cd(this,t)},$.prototype.matMul=function(t,e,n){return this.throwIfDisposed(),un(this,t,e,n)},$.prototype.maxPool=function(t,e,n,a){return this.throwIfDisposed(),fp(this,t,e,n,a)},$.prototype.max=function(t,e){return this.throwIfDisposed(),rc(this,t,e)},$.prototype.maximumStrict=function(t){return this.throwIfDisposed(),Md(this,t)},$.prototype.maximum=function(t){return this.throwIfDisposed(),ol(this,t)},$.prototype.mean=function(t,e){return this.throwIfDisposed(),ph(this,t,e)},$.prototype.min=function(t,e){return this.throwIfDisposed(),Dh(this,t,e)},$.prototype.minimumStrict=function(t){return this.throwIfDisposed(),Ld(this,t)},$.prototype.minimum=function(t){return this.throwIfDisposed(),Fh(this,t)},$.prototype.mirrorPad=function(t,e){return this.throwIfDisposed(),ld(this,t,e)},$.prototype.modStrict=function(t){return this.throwIfDisposed(),zd(this,t)},$.prototype.mod=function(t){return this.throwIfDisposed(),mp(this,t)},$.prototype.mulStrict=function(t){return this.throwIfDisposed(),Pd(this,t)},$.prototype.mul=function(t){return this.throwIfDisposed(),bt(this,t)},$.prototype.neg=function(){return this.throwIfDisposed(),$a(this)},$.prototype.norm=function(t,e,n){return this.throwIfDisposed(),Uh(this,t,e,n)},$.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),Dd(this,t)},$.prototype.notEqual=function(t){return this.throwIfDisposed(),Oh(this,t)},$.prototype.oneHot=function(t,e,n){return e===void 0&&(e=1),n===void 0&&(n=0),this.throwIfDisposed(),Ss(this,t,e,n)},$.prototype.onesLike=function(){return this.throwIfDisposed(),yp(this)},$.prototype.pad=function(t,e){return this.throwIfDisposed(),ac(this,t,e)},$.prototype.pool=function(t,e,n,a,c){return this.throwIfDisposed(),hd(this,t,e,n,a,c)},$.prototype.powStrict=function(t){return this.throwIfDisposed(),Bd(this,t)},$.prototype.pow=function(t){return this.throwIfDisposed(),Qs(this,t)},$.prototype.prelu=function(t){return this.throwIfDisposed(),vp(this,t)},$.prototype.prod=function(t,e){return this.throwIfDisposed(),pd(this,t,e)},$.prototype.reciprocal=function(){return this.throwIfDisposed(),fd(this)},$.prototype.relu=function(){return this.throwIfDisposed(),fh(this)},$.prototype.relu6=function(){return this.throwIfDisposed(),wp(this)},$.prototype.reshapeAs=function(t){return this.throwIfDisposed(),Ke(this,t.shape)},$.prototype.reshape=function(t){return this.throwIfDisposed(),Ke(this,t)},$.prototype.resizeBilinear=function(t,e){return this.throwIfDisposed(),Jd(this,t,e)},$.prototype.resizeNearestNeighbor=function(t,e){return this.throwIfDisposed(),$d(this,t,e)},$.prototype.reverse=function(t){return this.throwIfDisposed(),Zs(this,t)},$.prototype.rfft=function(){return this.throwIfDisposed(),zh(this)},$.prototype.round=function(){return this.throwIfDisposed(),md(this)},$.prototype.rsqrt=function(){return this.throwIfDisposed(),bp(this)},$.prototype.selu=function(){return this.throwIfDisposed(),yd(this)},$.prototype.separableConv2d=function(t,e,n,a,c,d){return this.throwIfDisposed(),vd(this,t,e,n,a,c,d)},$.prototype.sigmoid=function(){return this.throwIfDisposed(),fn(this)},$.prototype.sign=function(){return this.throwIfDisposed(),gd(this)},$.prototype.sin=function(){return this.throwIfDisposed(),kp(this)},$.prototype.sinh=function(){return this.throwIfDisposed(),Sp(this)},$.prototype.slice=function(t,e){return this.throwIfDisposed(),$t(this,t,e)},$.prototype.softmax=function(t){return this.throwIfDisposed(),xd(this,t)},$.prototype.softplus=function(){return this.throwIfDisposed(),hp(this)},$.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),Mh(this,t,e)},$.prototype.split=function(t,e){return this.throwIfDisposed(),ll(this,t,e)},$.prototype.sqrt=function(){return this.throwIfDisposed(),eo(this)},$.prototype.square=function(){return this.throwIfDisposed(),Yn(this)},$.prototype.squaredDifference=function(t){return this.throwIfDisposed(),Ph(this,t)},$.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),Wd(this,t)},$.prototype.squeeze=function(t){return this.throwIfDisposed(),Bh(this,t)},$.prototype.stack=function(t,e){this.throwIfDisposed();var n=t instanceof $?[this,t]:[this].concat(t);return sc(n,e)},$.prototype.step=function(t){return this.throwIfDisposed(),hl(this,t)},$.prototype.stridedSlice=function(t,e,n,a,c,d,y,v){return this.throwIfDisposed(),wd(this,t,e,n,a,c,d,y,v)},$.prototype.subStrict=function(t){return this.throwIfDisposed(),Ud(this,t)},$.prototype.sub=function(t){return this.throwIfDisposed(),zr(this,t)},$.prototype.sum=function(t,e){return this.throwIfDisposed(),Yr(this,t,e)},$.prototype.tan=function(){return this.throwIfDisposed(),bd(this)},$.prototype.tanh=function(){return this.throwIfDisposed(),En(this)},$.prototype.tile=function(t){return this.throwIfDisposed(),il(this,t)},$.prototype.toBool=function(){return this.throwIfDisposed(),pr(this,"bool")},$.prototype.toFloat=function(){return this.throwIfDisposed(),pr(this,"float32")},$.prototype.toInt=function(){return this.throwIfDisposed(),pr(this,"int32")},$.prototype.topk=function(t,e){return this.throwIfDisposed(),kd(this,t,e)},$.prototype.transpose=function(t){return this.throwIfDisposed(),$n(this,t)},$.prototype.unique=function(t){return this.throwIfDisposed(),Sd(this,t)},$.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),Np(this,t,e)},$.prototype.unstack=function(t){return this.throwIfDisposed(),Wh(this,t)},$.prototype.where=function(t,e){return this.throwIfDisposed(),us(t,this,e)},$.prototype.zerosLike=function(){return this.throwIfDisposed(),gn(this)},N.Abs=qn,N.Acos=ri,N.Acosh=pi,N.AdadeltaOptimizer=Rp,N.AdagradOptimizer=Ap,N.AdamOptimizer=Dp,N.AdamaxOptimizer=Fp,N.Add=pa,N.AddN=di,N.All=fi,N.Any=Va,N.ArgMax=ln,N.ArgMin=ni,N.Asin=gr,N.Asinh=Di,N.Atan=bi,N.Atan2=Zn,N.Atanh=ro,N.AvgPool=Gi,N.AvgPool3D=ji,N.AvgPool3DBackprop=Oi,N.AvgPoolBackprop=Fi,N.BatchMatMul=da,N.BatchToSpaceND=Mi,N.BroadcastTo=pe,N.Cast=X,N.Ceil=j,N.ClipByValue=re,N.Complex=te,N.Concat=Ue,N.Conv2D=kt,N.Conv2DBackpropFilter=$e,N.Conv2DBackpropInput=Le,N.Conv3D=Ye,N.Conv3DBackpropFilterV2=Ft,N.Conv3DBackpropInputV2=St,N.Cos=Mt,N.Cosh=dr,N.CropAndResize=ta,N.Cumsum=ir,N.DataStorage=Q,N.DepthToSpace=fa,N.DepthwiseConv2dNative=ra,N.DepthwiseConv2dNativeBackpropFilter=Ha,N.DepthwiseConv2dNativeBackpropInput=ki,N.Diag=sn,N.Dilation2D=hn,N.Dilation2DBackpropFilter=Jr,N.Dilation2DBackpropInput=na,N.Div=Vr,N.Elu=Jn,N.EluGrad=tn,N.Environment=Ta,N.Equal=Kn,N.Erf=Rn,N.Exp=aa,N.Expm1=ma,N.FFT=Li,N.Fill=Ea,N.FlipLeftRight=S,N.Floor=x,N.FloorDiv=k,N.FromPixels=xo,N.FusedBatchNorm=K,N.FusedConv2D=Ps,N.FusedDepthwiseConv2D=Jo,N.GatherNd=we,N.GatherV2=Se,N.Greater=Je,N.GreaterEqual=Be,N.IFFT=ft,N.Identity=vt,N.Imag=zt,N.IsFinite=Wt,N.IsInf=Gt,N.IsNan=Qt,N.KernelBackend=Ae,N.LRN=In,N.LRNBackprop=ur,N.Less=wr,N.LessEqual=Ar,N.LinSpace=Yt,N.Log=xr,N.Log1p=Sn,N.LogSoftmax=wa,N.LogicalAnd=pn,N.LogicalNot=zn,N.LogicalOr=Fr,N.Max=$r,N.MaxPool=mi,N.MaxPool3D=ja,N.MaxPool3DBackprop=ai,N.MaxPoolBackprop=Ga,N.MaxPoolWithArgmax=zi,N.Maximum=Ra,N.Mean=An,N.Min=ba,N.Minimum=qi,N.MirrorPad=yi,N.Mod=ii,N.MomentumOptimizer=Op,N.Multiply=qr,N.Negate=Io,N.NonMaxSuppressionV3=qa,N.NonMaxSuppressionV4=La,N.NonMaxSuppressionV5=Ki,N.NotEqual=nn,N.OP_SCOPE_SUFFIX=bn,N.OneHot=Pi,N.OnesLike=oi,N.Optimizer=wu,N.PadV2=no,N.Pool=mo,N.Pow=Ka,N.Prelu=ao,N.Prod=Ko,N.RMSPropOptimizer=Mp,N.Range=No,N.Real=Co,N.Reciprocal=io,N.Relu=ia,N.Relu6=ka,N.Reshape=Pr,N.ResizeBilinear=Qn,N.ResizeBilinearGrad=oo,N.ResizeNearestNeighbor=oa,N.ResizeNearestNeighborGrad=Xa,N.Reverse=vn,N.RotateWithOffset=ys,N.Round=Bi,N.Rsqrt=yo,N.SGDOptimizer=qh,N.ScatterNd=vo,N.SelectV2=Aa,N.Selu=go,N.Sigmoid=Ds,N.Sign=As,N.Sin=Rs,N.Sinh=Eo,N.Slice=To,N.Softmax=vi,N.Softplus=Xo,N.SpaceToBatchND=Ao,N.SparseToDense=ru,N.SplitV=Qo,N.Sqrt=Ro,N.Square=tu,N.SquaredDifference=Fs,N.Step=Zo,N.StridedSlice=Os,N.Sub=ps,N.Sum=Yo,N.Tan=ds,N.Tanh=Ms,N.Tensor=$,N.TensorBuffer=Fe,N.Tile=Ls,N.TopK=nu,N.Transpose=fs,N.Unique=au,N.Unpack=ms,N.UnsortedSegmentSum=Do,N.Variable=et,N.ZerosLike=zs,N._FusedMatMul=Fo,N.abs=ui,N.acos=$c,N.acosh=el,N.add=Cr,N.addN=th,N.addStrict=Fd,N.all=m,N.any=I,N.argMax=z,N.argMin=G,N.asin=be,N.asinh=De,N.atan=Ge,N.atan2=s,N.atanh=r,N.avgPool=Xt,N.avgPool3d=vr,N.backend=ql,N.backend_util=$2,N.basicLSTMCell=cn,N.batchNorm=Xn,N.batchNorm2d=Vi,N.batchNorm3d=Zu,N.batchNorm4d=_h,N.batchToSpaceND=Hr,N.booleanMaskAsync=Ry,N.broadcastTo=Ju,N.browser=Pc,N.buffer=Qi,N.cast=pr,N.ceil=ah,N.clipByValue=oh,N.clone=Ho,N.complex=Pn,N.concat=kr,N.concat1d=wh,N.concat2d=$h,N.concat3d=bh,N.concat4d=Wn,N.conv1d=Ns,N.conv2d=gi,N.conv2dTranspose=Xs,N.conv3d=np,N.conv3dTranspose=Nf,N.copyRegisteredKernels=Oo,N.cos=Ih,N.cosh=ip,N.cosineWindow=Cp,N.cumsum=op,N.customGrad=Cs,N.deprecationWarn=Sa,N.depthToSpace=Kp,N.depthwiseConv2d=lh,N.device_util=Dr,N.diag=Ff,N.dilation2d=Xp,N.disableDeprecationWarnings=Xu,N.dispose=Pa,N.disposeVariables=Ll,N.div=Br,N.divNoNan=Yp,N.divStrict=Od,N.dot=Qp,N.dropout=a0,N.elu=sp,N.enableDebugMode=Ml,N.enableProdMode=Ol,N.enclosingPowerOfTwo=Hd,N.engine=zl,N.env=Rr,N.equal=hh,N.equalStrict=Cd,N.erf=Zp,N.exp=cs,N.expandDims=ls,N.expm1=Jp,N.eye=$p,N.fft=Lh,N.fill=up,N.findBackend=Hl,N.findBackendFactory=Gl,N.floor=Nh,N.floorDiv=Yu,N.fused=y0,N.gather=Ch,N.gatherND=t0,N.gather_util=bl,N.getBackend=Ul,N.getGradient=Ws,N.getKernel=Bs,N.getKernelsForBackend=vs,N.grad=f1,N.grads=m1,N.greater=_u,N.greaterEqual=$u,N.greaterEqualStrict=Td,N.greaterStrict=Ed,N.ifft=mh,N.imag=Th,N.image=b2,N.inTopKAsync=o0,N.io=Tc,N.irfft=Ip,N.isFinite=td,N.isInf=rd,N.isNaN=nd,N.keep=xu,N.kernel_impls=nv,N.leakyRelu=ad,N.less=Eh,N.lessEqual=ec,N.lessEqualStrict=Rd,N.lessStrict=Ad,N.linalg=k2,N.linspace=l1,N.localResponseNormalization=id,N.log=tc,N.log1p=lp,N.logSigmoid=sd,N.logSoftmax=ud,N.logSumExp=pp,N.logicalAnd=nc,N.logicalNot=Ah,N.logicalOr=dp,N.logicalXor=cd,N.losses=S2,N.matMul=un,N.math=Mc,N.max=rc,N.maxPool=fp,N.maxPool3d=D1,N.maxPoolWithArgmax=O1,N.maximum=ol,N.maximumStrict=Md,N.mean=ph,N.memory=Pl,N.min=Dh,N.minimum=Fh,N.minimumStrict=Ld,N.mirrorPad=ld,N.mod=mp,N.modStrict=zd,N.moments=V1,N.movingAverage=Xy,N.mul=bt,N.mulStrict=Pd,N.multiRNNCell=G1,N.multinomial=q1,N.neg=$a,N.nextFrame=C2,N.norm=Uh,N.notEqual=Oh,N.notEqualStrict=Dd,N.oneHot=Ss,N.ones=sl,N.onesLike=yp,N.op=Ee,N.outerProduct=Z1,N.pad=ac,N.pad1d=em,N.pad2d=rm,N.pad3d=am,N.pad4d=om,N.pool=hd,N.pow=Qs,N.powStrict=Bd,N.prelu=vp,N.print=Du,N.prod=pd,N.profile=Qc,N.rand=mm,N.randomGamma=Nm,N.randomNormal=Tm,N.randomUniform=dd,N.range=_p,N.ready=Wl,N.real=dh,N.reciprocal=fd,N.registerBackend=jl,N.registerGradient=iu,N.registerKernel=$o,N.relu=fh,N.relu6=wp,N.removeBackend=Vl,N.reshape=Ke,N.reverse=Zs,N.reverse1d=Mm,N.reverse2d=zm,N.reverse3d=Bm,N.reverse4d=Um,N.rfft=zh,N.round=md,N.rsqrt=bp,N.scalar=Wr,N.scatterND=Qy,N.scatter_util=kl,N.selu=yd,N.separableConv2d=vd,N.serialization=Nl,N.setBackend=Bl,N.setPlatform=Kl,N.setdiff1dAsync=Km,N.sigmoid=fn,N.sign=gd,N.signal=w2,N.sin=kp,N.sinh=Sp,N.slice=$t,N.slice1d=Jm,N.slice2d=ey,N.slice3d=ry,N.slice4d=ay,N.slice_util=Xc,N.softmax=xd,N.softplus=hp,N.spaceToBatchND=Mh,N.sparseToDense=$y,N.spectral=_2,N.split=ll,N.sqrt=eo,N.square=Yn,N.squaredDifference=Ph,N.squaredDifferenceStrict=Wd,N.squeeze=Bh,N.stack=sc,N.step=hl,N.stridedSlice=wd,N.sub=zr,N.subStrict=Ud,N.sum=Yr,N.sumOutType=Ut,N.tan=bd,N.tanh=En,N.tensor=Dn,N.tensor1d=cl,N.tensor2d=yh,N.tensor3d=js,N.tensor4d=gy,N.tensor5d=xy,N.tensor6d=_y,N.tensor_util=Et,N.test_util=Fl,N.tidy=sa,N.tile=il,N.time=Zc,N.topk=kd,N.train=I2,N.transpose=$n,N.truncatedNormal=ky,N.unique=Sd,N.unregisterGradient=ou,N.unregisterKernel=ku,N.unsortedSegmentSum=Np,N.unstack=Wh,N.upcastType=Pt,N.util=ne,N.valueAndGrad=y1,N.valueAndGrads=v1,N.variable=Cy,N.variableGrads=od,N.version_core=Ku,N.where=us,N.whereAsync=Nd,N.zeros=Ys,N.zerosLike=gn}),og=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=function(s,u){return ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var h in o)o.hasOwnProperty(h)&&(r[h]=o[h])},ke(s,u)};function O(s,u){ke(s,u);function r(){this.constructor=s}s.prototype=u===null?Object.create(u):(r.prototype=u.prototype,new r)}var H=function(){return H=Object.assign||function(s){for(var u,r=1,o=arguments.length;r<o;r++){u=arguments[r];for(var h in u)Object.prototype.hasOwnProperty.call(u,h)&&(s[h]=u[h])}return s},H.apply(this,arguments)};function se(s,u){var r={};for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&u.indexOf(o)<0&&(r[o]=s[o]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var h=0,o=Object.getOwnPropertySymbols(s);h<o.length;h++)u.indexOf(o[h])<0&&(r[o[h]]=s[o[h]]);return r}function xe(s,u,r,o){return new(r||(r=Promise))(function(h,b){function T(Y){try{q(o.next(Y))}catch(le){b(le)}}function M(Y){try{q(o.throw(Y))}catch(le){b(le)}}function q(Y){Y.done?h(Y.value):new r(function(le){le(Y.value)}).then(T,M)}q((o=o.apply(s,u||[])).next())})}function Q(s,u){var r={label:0,sent:function(){if(b[0]&1)throw b[1];return b[1]},trys:[],ops:[]},o,h,b,T;return T={next:M(0),throw:M(1),return:M(2)},typeof Symbol=="function"&&(T[Symbol.iterator]=function(){return this}),T;function M(Y){return function(le){return q([Y,le])}}function q(Y){if(o)throw new TypeError("Generator is already executing.");for(;r;)try{if(o=1,h&&(b=Y[0]&2?h.return:Y[0]?h.throw||((b=h.return)&&b.call(h),0):h.next)&&!(b=b.call(h,Y[1])).done)return b;(h=0,b)&&(Y=[Y[0]&2,b.value]);switch(Y[0]){case 0:case 1:b=Y;break;case 4:return r.label++,{value:Y[1],done:!1};case 5:r.label++,h=Y[1],Y=[0];continue;case 7:Y=r.ops.pop(),r.trys.pop();continue;default:if(!(b=r.trys,b=b.length>0&&b[b.length-1])&&(Y[0]===6||Y[0]===2)){r=0;continue}if(Y[0]===3&&(!b||Y[1]>b[0]&&Y[1]<b[3])){r.label=Y[1];break}if(Y[0]===6&&r.label<b[1]){r.label=b[1],b=Y;break}if(b&&r.label<b[2]){r.label=b[2],r.ops.push(Y);break}b[2]&&r.ops.pop(),r.trys.pop();continue}Y=u.call(s,r)}catch(le){Y=[6,le],h=0}finally{o=b=0}if(Y[0]&5)throw Y[1];return{value:Y[0]?Y[1]:void 0,done:!0}}}var Ae;function P(){return Ae==null&&(Ae=i.backend().epsilon()),Ae}function he(){return"channelsLast"}var me=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error),ae=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error),w=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error),ge=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error),ze=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error),W=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error);function nt(s,u){if(Array.isArray(s)){for(var r=[],o=0;o<u;o++)r=r.concat(s);return r}else{var r=new Array(u);return r.fill(s),r}}function tt(s,u){if(!s)throw new ze(u)}function nr(s,u){for(var r=0,o=0,h=s;o<h.length;o++){var b=h[o];b===u&&r++}return r}function Tt(s){return s.length===1?s[0]:s}function Qe(s){return Array.isArray(s)?s:[s]}function it(s){var u=s.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2"),r=u.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return r[0]!=="_"?r:"private"+r}function xt(s){return s.length<=1||s.indexOf("_")===-1?s:s.replace(/[_]+(\w|$)/g,function(u,r){return r.toUpperCase()})}var ot={};function ht(s){if(s==null)return null;var u={};return u.className=s.getClassName(),u.config=s.getConfig(),u}function ut(s){if(s==null||typeof s!="object")return;if(Array.isArray(s))s.forEach(function(T){return ut(T)});else for(var u=Object.keys(s),r=0,o=u;r<o.length;r++){var h=o[r],b=s[h];b!=null&&typeof b=="object"&&(!Array.isArray(b)&&b.type==="ndarray"&&typeof b.value=="number"?s[h]=b.value:ut(b))}}function yt(s,u,r,o,h){var b,T,M;if(u===void 0&&(u={}),r===void 0&&(r={}),o===void 0&&(o="object"),h===void 0&&(h=!1),typeof s=="string"){var q=s,Y=void 0;if(q in r)Y=r[q];else if(q in ot)Y=ot[q];else if(Y=u[q],Y==null)throw new w("Unknown "+o+": "+s+`. This may be due to one of the following reasons:
`+("1. The "+o+" is defined in Python, in which ")+`case it needs to be ported to TensorFlow.js or your JavaScript code.
`+("2. The custom "+o+" is defined in JavaScript, ")+"but is not registered properly with tf.serialization.registerClass().");return Y}else{var le=s;if(le.className==null||le.config==null)throw new w(o+": Improper config format: "+(JSON.stringify(le)+`.
`)+"'className' and 'config' must set.");var Ne=le.className,We=void 0,je=void 0;if(Ne in r?(b=r[Ne],We=b[0],je=b[1]):Ne in ot?(T=ot.className,We=T[0],je=T[1]):Ne in u&&(M=u[Ne],We=M[0],je=M[1]),We==null)throw new w("Unknown "+o+": "+Ne+`. This may be due to one of the following reasons:
`+("1. The "+o+" is defined in Python, in which ")+`case it needs to be ported to TensorFlow.js or your JavaScript code.
`+("2. The custom "+o+" is defined in JavaScript, ")+"but is not registered properly with tf.serialization.registerClass().");if(je!=null){for(var qe={},mt=0,pt=Object.keys(ot);mt<pt.length;mt++){var st=pt[mt];qe[st]=ot[st]}for(var dt=0,Dt=Object.keys(r);dt<Dt.length;dt++){var st=Dt[dt];qe[st]=r[st]}var or=le.config;or.customObjects=qe;for(var Xt=H({},ot),Jt=0,vr=Object.keys(r);Jt<vr.length;Jt++){var st=vr[Jt];ot[st]=r[st]}ut(le.config);var lr=je(We,le.config,r,h);return ot=H({},Xt),lr}else{for(var Xt=H({},ot),Ir=0,Lr=Object.keys(r);Ir<Lr.length;Ir++){var st=Lr[Ir];ot[st]=r[st]}var lr=new We(le.config);return ot=H({},Xt),lr}}}function Zt(s,u){return s<u?-1:s>u?1:0}function ar(s,u){return-1*Zt(s,u)}function qt(s){if(s==null)return s;for(var u=[],r=0,o=s;r<o.length;r++){var h=o[r];u.indexOf(h)===-1&&u.push(h)}return u}function Ur(s){if(s==null)throw new w("Invalid value in obj: "+JSON.stringify(s));for(var u in s)if(s.hasOwnProperty(u))return!1;return!0}function jr(s,u,r){if(r==null)return;if(s.indexOf(r)<0)throw new w(r+" is not a valid "+u+". Valid values are "+s+" or null/undefined.")}function _r(s,u,r,o){return r===void 0&&(r=0),o===void 0&&(o=Infinity),tt(r>=0),tt(o>=r),Array.isArray(s)&&s.length>=r&&s.length<=o&&s.every(function(h){return typeof h===u})}function tr(s,u){Array.isArray(s)?(i.util.assert(s.length>0,function(){return u+" is unexpectedly an empty array."}),s.forEach(function(r,o){return tr(r,"element "+(o+1)+" of "+u)})):i.util.assert(Number.isInteger(s)&&s>0,function(){return"Expected "+u+" to be a positive integer, but got "+(Fa(s)+".")})}function Fa(s){return s===null?"null":Array.isArray(s)?"["+s.map(function(u){return Fa(u)}).join(",")+"]":typeof s=="string"?'"'+s+'"':""+s}function Oa(s,u){var r=i.util.now(),o,h=function(){for(var b=[],T=0;T<arguments.length;T++)b[T]=arguments[T];var M=i.util.now();return M-r<u||(r=M,o=s.apply(void 0,b)),o};return h}function Tn(s){return s==="relu"?"relu":s==="linear"?"linear":s==="elu"?"elu":null}function Wa(s,u){return i.tidy(function(){return i.sqrt(i.sum(i.mul(s,s),u,!0))})}var Na=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.getConfig=function(){return{}},u}(i.serialization.Serializable),yn=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.defaultMaxValue=2,o.defaultAxis=0,o.maxValue=r.maxValue!=null?r.maxValue:o.defaultMaxValue,o.axis=r.axis!=null?r.axis:o.defaultAxis,o}return u.prototype.apply=function(r){var o=this;return i.tidy(function(){var h=Wa(r,o.axis),b=i.clipByValue(h,0,o.maxValue);return i.mul(r,i.div(b,i.add(P(),h)))})},u.prototype.getConfig=function(){return{maxValue:this.maxValue,axis:this.axis}},u.className="MaxNorm",u}(Na);i.serialization.registerClass(yn);var Ma=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.defaultAxis=0,o.axis=r.axis!=null?r.axis:o.defaultAxis,o}return u.prototype.apply=function(r){var o=this;return i.tidy(function(){return i.div(r,i.add(P(),Wa(r,o.axis)))})},u.prototype.getConfig=function(){return{axis:this.axis}},u.className="UnitNorm",u}(Na);i.serialization.registerClass(Ma);var li=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return i.relu(r)},u.className="NonNeg",u}(Na);i.serialization.registerClass(li);var hi=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.defaultMinValue=0,o.defaultMaxValue=1,o.defaultRate=1,o.defaultAxis=0,o.minValue=r.minValue!=null?r.minValue:o.defaultMinValue,o.maxValue=r.maxValue!=null?r.maxValue:o.defaultMaxValue,o.rate=r.rate!=null?r.rate:o.defaultRate,o.axis=r.axis!=null?r.axis:o.defaultAxis,o}return u.prototype.apply=function(r){var o=this;return i.tidy(function(){var h=Wa(r,o.axis),b=i.add(i.mul(o.rate,i.clipByValue(h,o.minValue,o.maxValue)),i.mul(1-o.rate,h));return i.mul(r,i.div(b,i.add(P(),h)))})},u.prototype.getConfig=function(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}},u.className="MinMaxNorm",u}(Na);i.serialization.registerClass(hi);var la={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function rn(s){return ht(s)}function Ca(s,u){return u===void 0&&(u={}),yt(s,i.serialization.SerializationMap.getMap().classNameMap,u,"constraint")}function xn(s){if(s==null)return null;if(typeof s=="string"){var u=s in la?la[s]:s,r={className:u,config:{}};return Ca(r)}else return s instanceof Na?s:Ca(s)}function Hn(s){return new yn(s)}function _i(s){return new Ma(s)}function ha(){return new li}function Ei(s){return new hi(s)}var Gn={__proto__:null,maxNorm:Hn,unitNorm:_i,nonNeg:ha,minMaxNorm:Ei},jn=["channelsFirst","channelsLast"],Ua=["valid","same","causal"],ga=["max","avg"],wi=["sum","mul","concat","ave"],Ta=new Map;function on(s){jr(jn,"DataFormat",s)}function _n(s){jr(Ua,"PaddingMode",s)}function xa(s){jr(ga,"PoolMode",s)}var Rr=[],ti="/";function _a(s,u){Rr.push(s);try{var r=u();return Rr.pop(),r}catch(o){throw Rr.pop(),o}}function Ri(){return Rr.length===0?"":Rr.join(ti)+ti}function Hi(s){if(!ri(s))throw new Error("Not a valid tensor name: '"+s+"'");return Ri()+s}function Ai(s){if(!ri(s))throw new Error("Not a valid tensor name: '"+s+"'");Ta.has(s)||Ta.set(s,0);var u=Ta.get(s);if(Ta.set(s,Ta.get(s)+1),u>0){var r=s+"_"+u;return Ta.set(r,1),r}else return s}var qn=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function ri(s){return!!s.match(qn)}function pi(s){return s===parseInt(s.toString(),10)}function pa(s,u,r){u==null&&(u=0),r==null&&(r=s.length);for(var o=1,h=u;h<r;++h)o*=s[h];return o}function di(s){return s=Array.isArray(s)?new Float32Array(s):s,i.tensor1d(s)}function fi(s){return i.min(di(s)).dataSync()[0]}function Va(s){return i.max(di(s)).dataSync()[0]}function ln(s,u){if(u<s)throw new w("end ("+u+") < begin ("+s+") is forbidden.");for(var r=[],o=s;o<u;++o)r.push(o);return r}function ni(s,u){return s.asType(u)}function gr(s,u){u===void 0&&(u=-1);var r=s.shape.slice();return u<0&&(u=r.length+u+1),r.splice(u,0,1),s.reshape(r)}function Di(s,u){return i.tidy(function(){if(s.shape.length!==2)throw new w("repeat() expects a rank-2 tensor, but received a "+("rank-"+s.shape.length+" tensor."));var r=gr(s,1);return da(r,[1,u,1])})}function bi(s){var u=[pa(s.shape)];return s.reshape(u)}function ro(s){if(s.rank<=1)throw new w("batchFlatten requires a minimum rank of 2. Got rank: "+s.rank+".");var u=[s.shape[0],pa(s.shape,1)];return s.reshape(u)}function Zn(s,u,r){return i.tidy(function(){switch(s.rank){case 1:return i.slice1d(s,u,r);case 2:return i.slice2d(s,[u,0],[r,s.shape[1]]);case 3:return i.slice3d(s,[u,0,0],[r,s.shape[1],s.shape[2]]);case 4:return i.slice4d(s,[u,0,0,0],[r,s.shape[1],s.shape[2],s.shape[3]]);case 5:return i.slice(s,[u,0,0,0,0],[r,s.shape[1],s.shape[2],s.shape[3],s.shape[4]]);case 6:return i.slice(s,[u,0,0,0,0,0],[r,s.shape[1],s.shape[2],s.shape[3],s.shape[4],s.shape[5]]);default:throw new w("sliceAlongFirstAxis() received an unsupported tensor rank: "+(""+s.rank))}})}function Gi(s,u,r){return i.tidy(function(){switch(s.rank){case 1:return i.slice1d(s,u,r);case 2:return i.slice2d(s,[0,u],[s.shape[0],r]);case 3:return i.slice3d(s,[0,0,u],[s.shape[0],s.shape[1],r]);case 4:return i.slice4d(s,[0,0,0,u],[s.shape[0],s.shape[1],s.shape[2],r]);default:throw new w("sliceAlongLastAxis() received an unsupported tensor rank: "+(""+s.rank))}})}function Fi(s,u,r,o){return i.tidy(function(){switch(s.rank){case 1:return i.slice1d(s,u,r);case 2:switch(o){case 1:return Zn(s,u,r);case 2:return Gi(s,u,r);default:throw new w("The axis is not within the rank of the tensor "+(""+o))}case 3:switch(o){case 1:return Zn(s,u,r);case 2:return i.slice3d(s,[0,u,0],[s.shape[0],r,s.shape[2]]);case 3:return Gi(s,u,r);default:throw new w("The axis is not within the rank of the tensor "+(""+o))}case 4:switch(o){case 1:return Zn(s,u,r);case 2:return i.slice4d(s,[0,u,0,0],[s.shape[0],r,s.shape[2],s.shape[3]]);case 3:return i.slice4d(s,[0,0,u,0],[s.shape[0],s.shape[1],r,s.shape[3]]);case 4:return Gi(s,u,r);default:throw new w("The axis is not within the rank of the tensor "+(""+o))}default:throw new w("sliceAlongLastAxis() received an unsupported tensor rank: "+(""+s.rank))}})}function ji(s,u){u===void 0&&(u=-1);var r;return u<0&&(r=s[0].rank,r!==0?u=r:u=0),u===s[0].rank&&(u=-1),i.concat(s,u)}function Oi(s,u){switch(s.rank){case 1:return i.concat1d([s,u]);case 2:return i.concat2d([s,u],0);case 3:return i.concat3d([s,u],0);case 4:return i.concat4d([s,u],0);default:throw new w("concatAlongFirstAxis() received an unsupported "+("tensor rank: "+s.rank))}}function da(s,u){if(Array.isArray(u)||(u=[u]),s.rank!==u.length)throw new w("The length of input n ("+u.length+") does not match "+("the number of dimensions in input x ("+s.rank+")"));return i.tile(s,u)}function Mi(s,u,r,o,h){return u===void 0&&(u=0),r===void 0&&(r=1),i.randomNormal(s,u,r,o,h)}function pe(s,u,r,o){if(s.rank<2||u.rank<2)throw new ge("dot requires both inputs to be rank >= 2"+(" but got x shape = "+s.shape+" and y shape = "+u.shape));if(u.rank>=3){var h=s.shape.slice(-1)[0],b=u.shape.slice(-2)[0];if(h!==b)throw new ge("If rank y >= 3, then the second last dim"+(" of y must equal the last dim of x but got x shape = "+s.shape+" and ")+(" y shape = "+u.shape))}if(s.rank===2&&u.rank===2){var T=!1,M=!1;return i.fused.matMul({a:s,b:u,transposeA:T,transposeB:M,bias:o?re(s.rank,o,he()):null,activation:r})}else{var q=s.shape.slice(),Y=q.pop();s=s.reshape([-1,Y]);var le=u.shape.slice(),Ne=le.pop(),b=le.pop(),We=le.concat([Ne]),je=Array.from({length:u.rank},function(dt,Dt){return Dt===0?u.rank-2:Dt<=u.rank-2?Dt-1:Dt});u=u.transpose(je).reshape([b,-1]);var qe=q.concat(We),T=!1,M=!1;return i.fused.matMul({a:s,b:u,transposeA:T,transposeB:M,bias:o?re(s.rank,o,he()):null,activation:r}).reshape(qe)}}function X(s,u,r){return i.tidy(function(){return Array.isArray(u)?u=i.tensor1d(u,"int32"):u=u.toInt(),i.gather(s,u,r)})}function j(s){return i.mul(s,s)}function re(s,u,r){var o=u.shape;if(u.rank!==1&&u.rank!==s)throw new w("Unexpected bias dimensions: "+u.rank+("; expected it to be 1 or "+s));if(s===5){if(r==="channelsFirst")return o.length===1?u.reshape([1,o[0],1,1,1]):u.reshape([1,o[3],o[0],o[1],o[2]]);if(r==="channelsLast")return o.length===1?u.reshape([1,1,1,1,o[0]]):u.reshape([1].concat(o))}else if(s===4){if(r==="channelsFirst")return o.length===1?u.reshape([1,o[0],1,1]):u.reshape([1,o[2],o[0],o[1]]);if(r==="channelsLast")return o.length===1?u.reshape([1,1,1,o[0]]):u.reshape([1].concat(o))}else if(s===3){if(r==="channelsFirst")return o.length===1?u.reshape([1,o[0],1]):u.reshape([1,o[1],o[0]]);if(r==="channelsLast")return o.length===1?u.reshape([1,1,o[0]]):u.reshape([1].concat(o))}else if(s<3)return u;throw new w("Unsupported input rank by biasAdd: "+u.rank)}function te(s,u,r){return i.tidy(function(){return r==null&&(r=he()),on(r),s.add(re(s.rank,u,r))})}function Ue(s,u){if(u===void 0&&(u=1),u!==1)throw new ge("Support for alpha values other than 1 ("+u+") is not implemented yet.");return i.elu(s)}function kt(s){return i.tidy(function(){return i.div(s,i.abs(s).add(1))})}function $e(s,u,r,o){return i.tidy(function(){return i.dropout(s,u,r,o)})}function Le(s){return i.tidy(function(){var u=i.add(.5,i.mul(.2,s));return i.clipByValue(u,0,1)})}function Ye(s,u,r){return r===void 0&&(r=!1),r?s():u()}var Ft=["fanIn","fanOut","fanAvg"],St=["normal","uniform","truncatedNormal"];function Mt(s){jr(Ft,"FanMode",s)}function dr(s){jr(St,"Distribution",s)}var ir=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.fromConfigUsesCustomObjects=function(){return!1},u.prototype.getConfig=function(){return{}},u}(i.serialization.Serializable),ta=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r,o){return i.zeros(r,o)},u.className="Zeros",u}(ir);i.serialization.registerClass(ta);var fa=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r,o){return i.ones(r,o)},u.className="Ones",u}(ir);i.serialization.registerClass(fa);var ra=function(s){O(u,s);function u(r){var o=s.call(this)||this;if(typeof r!="object")throw new w("Expected argument of type ConstantConfig but got "+r);if(r.value===void 0)throw new w("config must have value set but got "+r);return o.value=r.value,o}return u.prototype.apply=function(r,o){var h=this;return i.tidy(function(){return i.mul(i.scalar(h.value),i.ones(r,o))})},u.prototype.getConfig=function(){return{value:this.value}},u.className="Constant",u}(ir);i.serialization.registerClass(ra);var Ha=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.DEFAULT_MINVAL=-.05,o.DEFAULT_MAXVAL=.05,o.minval=r.minval||o.DEFAULT_MINVAL,o.maxval=r.maxval||o.DEFAULT_MAXVAL,o.seed=r.seed,o}return u.prototype.apply=function(r,o){return i.randomUniform(r,this.minval,this.maxval,o)},u.prototype.getConfig=function(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}},u.className="RandomUniform",u}(ir);i.serialization.registerClass(Ha);var ki=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.DEFAULT_MEAN=0,o.DEFAULT_STDDEV=.05,o.mean=r.mean||o.DEFAULT_MEAN,o.stddev=r.stddev||o.DEFAULT_STDDEV,o.seed=r.seed,o}return u.prototype.apply=function(r,o){if(o=o||"float32",o!=="float32"&&o!=="int32")throw new ge("randomNormal does not support dType "+o+".");return Mi(r,this.mean,this.stddev,o,this.seed)},u.prototype.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},u.className="RandomNormal",u}(ir);i.serialization.registerClass(ki);var sn=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.DEFAULT_MEAN=0,o.DEFAULT_STDDEV=.05,o.mean=r.mean||o.DEFAULT_MEAN,o.stddev=r.stddev||o.DEFAULT_STDDEV,o.seed=r.seed,o}return u.prototype.apply=function(r,o){if(o=o||"float32",o!=="float32"&&o!=="int32")throw new ge("truncatedNormal does not support dType "+o+".");return i.truncatedNormal(r,this.mean,this.stddev,o,this.seed)},u.prototype.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},u.className="TruncatedNormal",u}(ir);i.serialization.registerClass(sn);var hn=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.gain=r.gain!=null?r.gain:1,o}return u.prototype.apply=function(r,o){var h=this;return i.tidy(function(){if(r.length!==2||r[0]!==r[1])throw new w("Identity matrix initializer can only be used for 2D square matrices.");return i.mul(h.gain,i.eye(r[0]))})},u.prototype.getConfig=function(){return{gain:this.gain}},u.className="Identity",u}(ir);i.serialization.registerClass(hn);function na(s,u){u===void 0&&(u="channelsLast");var r,o;if(on(u),s.length===2)r=s[0],o=s[1];else if([3,4,5].indexOf(s.length)!==-1){if(u==="channelsFirst"){var h=pa(s,2);r=s[1]*h,o=s[0]*h}else if(u==="channelsLast"){var h=pa(s,0,s.length-2);r=s[s.length-2]*h,o=s[s.length-1]*h}}else{var b=pa(s);r=Math.sqrt(b),o=Math.sqrt(b)}return[r,o]}var Jr=function(s){O(u,s);function u(r){var o=s.call(this)||this;if(r.scale<0)throw new w("scale must be a positive float. Got: "+r.scale);return o.scale=r.scale==null?1:r.scale,o.mode=r.mode==null?"fanIn":r.mode,Mt(o.mode),o.distribution=r.distribution==null?"normal":r.distribution,dr(o.distribution),o.seed=r.seed,o}return u.prototype.apply=function(r,o){var h=na(r),b=h[0],T=h[1],M=this.scale;if(this.mode==="fanIn"?M/=Math.max(1,b):this.mode==="fanOut"?M/=Math.max(1,T):M/=Math.max(1,(b+T)/2),this.distribution==="normal"){var q=Math.sqrt(M);if(o=o||"float32",o!=="float32"&&o!=="int32")throw new ge(this.getClassName()+" does not support dType "+o+".");return i.truncatedNormal(r,0,q,o,this.seed)}else{var Y=Math.sqrt(3*M);return i.randomUniform(r,-Y,Y,o)}},u.prototype.getConfig=function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}},u.className="VarianceScaling",u}(ir);i.serialization.registerClass(Jr);var Vr=function(s){O(u,s);function u(r){return s.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="GlorotUniform",u}(Jr);i.serialization.registerClass(Vr);var Jn=function(s){O(u,s);function u(r){return s.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="GlorotNormal",u}(Jr);i.serialization.registerClass(Jn);var tn=function(s){O(u,s);function u(r){return s.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="HeNormal",u}(Jr);i.serialization.registerClass(tn);var Rn=function(s){O(u,s);function u(r){return s.call(this,{scale:2,mode:"fanIn",distribution:"uniform",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="HeUniform",u}(Jr);i.serialization.registerClass(Rn);var Kn=function(s){O(u,s);function u(r){return s.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="LeCunNormal",u}(Jr);i.serialization.registerClass(Kn);var aa=function(s){O(u,s);function u(r){return s.call(this,{scale:1,mode:"fanIn",distribution:"uniform",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="LeCunNormal",u}(Jr);i.serialization.registerClass(aa);var ma=function(s){O(u,s);function u(r){var o=s.call(this)||this;if(o.DEFAULT_GAIN=1,o.gain=r.gain==null?o.DEFAULT_GAIN:r.gain,o.seed=r.seed,o.seed!=null)throw new ge("Random seed is not implemented for Orthogonal Initializer yet.");return o}return u.prototype.apply=function(r,o){var h=this;return i.tidy(function(){if(r.length<2)throw new ge("Shape must be at least 2D.");r[0]*r[1]>2e3&&console.warn("Orthogonal initializer is being called on a matrix with more "+("than 2000 ("+r[0]*r[1]+") elements: ")+"Slowness may result.");var b=r[0]>r[1]?[r[1],r[0]]:r,T=Mi(b,0,1,"float32"),M=i.linalg.gramSchmidt(T);return r[0]>r[1]&&(M=M.transpose()),i.mul(h.gain,M)})},u.prototype.getConfig=function(){return{gain:this.gain,seed:this.seed}},u.className="Orthogonal",u}(ir);i.serialization.registerClass(ma);var Li={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Ea(s,u){return u===void 0&&(u={}),yt(s,i.serialization.SerializationMap.getMap().classNameMap,u,"initializer")}function S(s){return ht(s)}function x(s){if(typeof s=="string"){var u=s in Li?Li[s]:s;if(u==="GlorotNormal")return new Jn;if(u==="GlorotUniform")return new Vr;if(u==="HeNormal")return new tn;if(u==="HeUniform")return new Rn;if(u==="LeCunNormal")return new Kn;if(u==="LeCunUniform")return new aa;var r={};return r.className=u,r.config={},Ea(r)}else return s instanceof ir?s:Ea(s)}function k(){return new ta}function K(){return new fa}function Se(s){return new ra(s)}function we(s){return new Ha(s)}function Je(s){return new ki(s)}function Be(s){return new sn(s)}function vt(s){return new hn(s)}function ft(s){return new Jr(s)}function zt(s){return new Vr(s)}function Wt(s){return new Jn(s)}function Gt(s){return new tn(s)}function Qt(s){return new Rn(s)}function wr(s){return new Kn(s)}function Ar(s){return new aa(s)}function Yt(s){return new ma(s)}var xr={__proto__:null,zeros:k,ones:K,constant:Se,randomUniform:we,randomNormal:Je,truncatedNormal:Be,identity:vt,varianceScaling:ft,glorotUniform:zt,glorotNormal:Wt,heNormal:Gt,heUniform:Qt,leCunNormal:wr,leCunUniform:Ar,orthogonal:Yt},Sn=0;function pn(){return Sn++}var zn={};function Fr(s){return s===void 0&&(s=""),s in zn||(zn[s]=0),zn[s]+=1,s+zn[s].toString()}function wa(s){return Array.isArray(s)&&Array.isArray(s[0])}function In(s){return s.length===0?[]:Array.isArray(s[0])?s:[s]}function ur(s){var u;if(Array.isArray(s)){if(s.length!==1)throw new w("Expected Tensor length to be 1; got "+s.length);u=s[0]}else u=s;return u}function $r(s){if(Array.isArray(s)&&Array.isArray(s[0])){if(s.length===1)return s=s,s[0];throw new w("Expected exactly 1 Shape; got "+s.length)}else return s}function Ra(s){for(var u=0,r=0,o=s;r<o.length;r++){var h=o[r];h.shape.length===0?u+=1:u+=h.shape.reduce(function(b,T){return b*T})}return u}var mi="Variable",Ga=function(){function s(u,r,o,h,b){r===void 0&&(r="float32"),o===void 0&&(o=mi),h===void 0&&(h=!0),b===void 0&&(b=null),this.dtype=r??"float32",this.shape=u.shape,this.id=pn(),o=o??mi,this.originalName=Hi(o),this.name=Ai(this.originalName),this.trainable_=h,this.constraint=b,this.val=i.variable(u,this.trainable_,this.name,this.dtype)}return s.prototype.read=function(){return this.assertNotDisposed(),this.val},s.prototype.write=function(u){return this.assertNotDisposed(),ja(this.val,u),this.val.id!==u.id&&(this.val.assign(u),this.constraint!=null&&this.val.assign(this.constraint.apply(this.val))),this},s.prototype.dispose=function(){this.assertNotDisposed(),this.val.dispose()},s.prototype.assertNotDisposed=function(){if(this.val.isDisposed)throw new Error("LayersVariable "+this.name+" is already disposed.")},Object.defineProperty(s.prototype,"trainable",{get:function(){return this.trainable_},set:function(u){this.trainable_=u,this.val.trainable=u},enumerable:!0,configurable:!0}),s}();function ja(s,u){if(s.shape.toString()!==u.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(s.shape)+" vs. "+JSON.stringify(u.shape))}function ai(s){return s.map(function(u){return u.read()})}function zi(s){s.forEach(function(u){var r=u[0];r.write(u[1])})}var An=function(){function s(u){this.dtype=u.dtype,this.shape=u.shape,u.shape!=null?this.ndim=u.shape.length:this.ndim=u.ndim,this.maxNDim=u.maxNDim,this.minNDim=u.minNDim,this.axes=u.axes||{}}return s}(),ba=function(){function s(u,r,o,h,b,T,M){this.dtype=u,this.shape=r,this.sourceLayer=o,this.inputs=h,this.callArgs=b,this.outputTensorIndex=M,this.id=pn(),T!=null&&(this.originalName=Hi(T),this.name=Ai(this.originalName)),this.rank=r.length}return s}(),qi=0,yi=function(){function s(u,r){this.callArgs=r,this.id=qi++,this.outboundLayer=u.outboundLayer,this.inboundLayers=u.inboundLayers,this.nodeIndices=u.nodeIndices,this.tensorIndices=u.tensorIndices,this.inputTensors=u.inputTensors,this.outputTensors=u.outputTensors,this.inputMasks=u.inputMasks,this.outputMasks=u.outputMasks,this.inputShapes=u.inputShapes,this.outputShapes=u.outputShapes;for(var o=0,h=u.inboundLayers;o<h.length;o++){var b=h[o];b!=null&&b.outboundNodes.push(this)}u.outboundLayer.inboundNodes.push(this)}return s.prototype.getConfig=function(){for(var u=[],r=0,o=this.inboundLayers;r<o.length;r++){var h=o[r];h!=null?u.push(h.name):u.push(null)}return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:u,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}},s}(),ii=0,qr=function(s){O(u,s);function u(r){r===void 0&&(r={});var o=s.call(this)||this;o._callHook=null,o._addedWeightNames=[],o._stateful=!1,o.id=ii++,o.activityRegularizer=null,o.inputSpec=null,o.supportsMasking=!1,o._trainableWeights=[],o._nonTrainableWeights=[],o._losses=[],o._updates=[],o._built=!1,o.inboundNodes=[],o.outboundNodes=[];var h=r.name;if(!h){var b=o.getClassName();h=it(b)+"_"+Fr(b)}if(o.name=h,o.trainable_=r.trainable==null?!0:r.trainable,r.inputShape!=null||r.batchInputShape!=null){var T=void 0;if(r.batchInputShape!=null)T=r.batchInputShape;else if(r.inputShape!=null){var M=null;r.batchSize!=null&&(M=r.batchSize),T=[M].concat(r.inputShape)}o.batchInputShape=T;var q=r.dtype;q==null&&(q=r.inputDType),q==null&&(q="float32"),o.dtype=q}return r.weights!=null?o.initialWeights=r.weights:o.initialWeights=null,o._refCount=null,o.fastWeightInitDuringBuild=!1,o}return u.nodeKey=function(r,o){return r.name+"_ib-"+o.toString()},u.prototype.getNodeAtIndex=function(r,o){if(this.inboundNodes.length===0)throw new ae("The layer has never been called "+("and thus has no defined "+o+"."));if(this.inboundNodes.length<=r)throw new w("Asked to get "+o+" at node "+r+", "+("but the layer has only "+this.inboundNodes.length+" inbound nodes."));return this.inboundNodes[r]},u.prototype.getInputAt=function(r){return Tt(this.getNodeAtIndex(r,"input").inputTensors)},u.prototype.getOutputAt=function(r){return Tt(this.getNodeAtIndex(r,"output").outputTensors)},Object.defineProperty(u.prototype,"input",{get:function(){if(this.inboundNodes.length>1)throw new me("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use `getInputAt(nodeIndex)` instead.');if(this.inboundNodes.length===0)throw new me("Layer "+this.name+" is not connected, no input to return.");return Tt(this.getNodeAtIndex(0,"input").inputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"output",{get:function(){if(this.inboundNodes.length===0)throw new me("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new me("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return Tt(this.getNodeAtIndex(0,"output").outputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"losses",{get:function(){return this._losses},enumerable:!0,configurable:!0}),u.prototype.calculateLosses=function(){return this.losses.map(function(r){return r()})},Object.defineProperty(u.prototype,"updates",{get:function(){return this._updates},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"built",{get:function(){return this._built},set:function(r){this._built=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"trainable",{get:function(){return this.trainable_},set:function(r){this._trainableWeights.forEach(function(o){return o.trainable=r}),this.trainable_=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"trainableWeights",{get:function(){return this.trainable_?this._trainableWeights.filter(function(r){return r.trainable}):[]},set:function(r){this._trainableWeights=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){return this.trainable?this._trainableWeights.filter(function(r){return!r.trainable}).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)},set:function(r){this._nonTrainableWeights=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"weights",{get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"stateful",{get:function(){return this._stateful},enumerable:!0,configurable:!0}),u.prototype.resetStates=function(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")},u.prototype.assertInputCompatibility=function(r){if(r=Qe(r),this.inputSpec==null||this.inputSpec.length===0)return;var o=Qe(this.inputSpec);if(r.length!==o.length)throw new w("Layer "+this.name+" expects "+o.length+" inputs, "+("but it received "+r.length+" input tensors. ")+("Input received: "+r));for(var h=0;h<r.length;h++){var b=r[h],T=o[h];if(T==null)continue;var M=b.rank;if(T.ndim!=null&&M!==T.ndim)throw new w("Input "+h+" is incompatible with layer "+this.name+": "+("expected ndim="+T.ndim+", found ndim="+M));if(T.maxNDim!=null&&M>T.maxNDim)throw new w("Input "+h+" is incompatible with layer "+this.name+(": expected max_ndim="+T.maxNDim+", found ndim="+M));if(T.minNDim!=null&&M<T.minNDim)throw new w("Input "+h+" is incompatible with layer "+this.name+(": expected min_ndim="+T.minNDim+", found ndim="+M+"."));if(T.dtype!=null&&b.dtype!==T.dtype)throw new w("Input "+h+" is incompatible with layer "+this.name+" "+(": expected dtype="+T.dtype+", found dtype="+b.dtype+"."));if(T.axes){var q=b.shape;for(var Y in T.axes){var le=Number(Y),Ne=T.axes[Y],We=le>=0?q[le]:q[q.length+le];if(Ne!=null&&[Ne,null].indexOf(We)===-1)throw new w("Input "+h+" is incompatible with layer "+(this.name+": expected axis "+le+" of input shape to ")+("have value "+Ne+" but got shape "+q+"."))}}if(T.shape!=null)for(var je=0;je<T.shape.length;++je){var qe=T.shape[je],mt=b.shape[je];if(qe!=null&&mt!=null&&qe!==mt)throw new w("Input "+h+" is incompatible with layer "+(this.name+": expected shape="+T.shape+", ")+("found shape="+b.shape+"."))}}},u.prototype.call=function(r,o){return r},u.prototype.invokeCallHook=function(r,o){this._callHook!=null&&this._callHook(r,o)},u.prototype.setCallHook=function(r){this._callHook=r},u.prototype.clearCallHook=function(){this._callHook=null},u.prototype.apply=function(r,o){var h=this;o=o||{},this.assertNotDisposed();for(var b=Qe(r),T=!0,M=0,q=b;M<q.length;M++){var Y=q[M];if(!(Y instanceof ba)){T=!1;break}}for(var le=!0,Ne=0,We=b;Ne<We.length;Ne++){var Y=We[Ne];if(Y instanceof ba){le=!1;break}}if(T===le)throw new w("Arguments to apply() must be all SymbolicTensors or all Tensors");return _a(this.name,function(){if(!h.built){h.assertInputCompatibility(r);for(var je=[],qe=0,mt=Qe(r);qe<mt.length;qe++){var pt=mt[qe];je.push(pt.shape)}h.build(Tt(je)),h.built=!0,h.initialWeights&&h.setWeights(h.initialWeights),h._refCount===null&&le&&(h._refCount=1)}if(h.assertInputCompatibility(r),le){for(var st=h.call(r,o),dt=Qe(st),Dt=[],or=0,Xt=dt;or<Xt.length;or++){var Jt=Xt[or];b.indexOf(Jt)!==-1&&(Jt=Jt.clone()),Dt.push(Jt)}if(st=Tt(Dt),h.activityRegularizer!=null)throw new ge("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return st}else{var vr=Io(r),lr=h.computeOutputShape(vr),st=void 0,Ir=nn(r);if(h.warnOnIncompatibleInputShape(Array.isArray(r)?vr[0]:vr),lr!=null&&lr.length>0&&Array.isArray(lr[0])?st=lr.map(function(kr,Sr){return new ba(Ir,kr,h,Qe(r),o,h.name,Sr)}):st=new ba(Ir,lr,h,Qe(r),o,h.name),h.addInboundNode(r,st,null,null,vr,lr,o),h._refCount++,h.activityRegularizer!=null)throw new ge("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return st}})},u.prototype.warnOnIncompatibleInputShape=function(r){if(this.batchInputShape==null)return;if(r.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+(JSON.stringify(r)+") does not match that of the ")+("batchInputShape ("+JSON.stringify(this.batchInputShape)+") ")+("of the layer "+this.name));else{var o=!1;this.batchInputShape.forEach(function(h,b){h!=null&&r[b]!=null&&r[b]!==h&&(o=!0)}),o&&console.warn("The shape of the input tensor "+("("+JSON.stringify(r)+") does not ")+("match the expectation of layer "+this.name+": ")+(""+JSON.stringify(this.batchInputShape)))}},Object.defineProperty(u.prototype,"outputShape",{get:function(){if(this.inboundNodes==null||this.inboundNodes.length===0)throw new me("The layer "+this.name+" has never been called and thus has no defined output shape.");for(var r=[],o=0,h=this.inboundNodes;o<h.length;o++){var b=h[o],T=JSON.stringify(b.outputShapes);r.indexOf(T)===-1&&r.push(T)}if(r.length===1){var M=this.inboundNodes[0].outputShapes;return Array.isArray(M)&&Array.isArray(M[0])&&M.length===1?M[0]:M}else throw new me("The layer "+this.name+' has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.')},enumerable:!0,configurable:!0}),u.prototype.countParams=function(){if(!this.built)throw new ae("You tried to call countParams() on "+this.name+", but the layer is not built yet. Build it first by calling build(batchInputShape).");return Ra(this.weights)},u.prototype.build=function(r){this.built=!0},u.prototype.getWeights=function(r){return r===void 0&&(r=!1),ai(r?this.trainableWeights:this.weights)},u.prototype.setWeights=function(r){var o=this;i.tidy(function(){var h=o.weights;if(h.length!==r.length)throw new w('You called setWeights(weights) on layer "'+o.name+'" '+("with a weight list of length "+r.length+", ")+("but the layer was expecting "+h.length+" weights. ")+("Provided weights: "+r+"..."));if(h.length===0)return;for(var b=[],T=ai(h),M=0;M<T.length;++M){var q=T[M],Y=h[M],le=r[M];if(!i.util.arraysEqual(q.shape,le.shape))throw new w("Layer weight shape "+q.shape+" "+("not compatible with provided weight shape "+le.shape));b.push([Y,le])}zi(b)})},u.prototype.addWeight=function(r,o,h,b,T,M,q){if(this._addedWeightNames.indexOf(r)!==-1)throw new w("Duplicate weight name "+r+" for layer "+this.name);this._addedWeightNames.push(r),h==null&&(h="float32"),this.fastWeightInitDuringBuild&&(b=x("zeros"));var Y=b.apply(o,h),le=new Ga(Y,h,r,M,q);return Y.dispose(),T!=null&&this.addLoss(function(){return T.apply(le.read())}),M==null&&(M=!0),M?this._trainableWeights.push(le):this._nonTrainableWeights.push(le),le},u.prototype.setFastWeightInitDuringBuild=function(r){this.fastWeightInitDuringBuild=r},u.prototype.addLoss=function(r){var o;if(r==null||Array.isArray(r)&&r.length===0)return;r=Qe(r),this._losses!==void 0&&this._losses!==null&&(o=this.losses).push.apply(o,r)},u.prototype.computeOutputShape=function(r){return r},u.prototype.computeMask=function(r,o){var h=this;if(!this.supportsMasking){if(o!=null)if(Array.isArray(o))o.forEach(function(b){if(b!=null)throw new TypeError("Layer "+h.name+" does not support masking, but was passed an inputMask.")});else throw new TypeError("Layer "+this.name+" does not support masking, but was passed an inputMask.");return null}return o},u.prototype.addInboundNode=function(r,o,h,b,T,M,q){q===void 0&&(q=null);var Y=Qe(r);o=Qe(o),h=Qe(h),b=Qe(b),T=In(T),M=In(M);for(var le=[],Ne=[],We=[],je=0,qe=Y;je<qe.length;je++){var mt=qe[je];le.push(mt.sourceLayer),Ne.push(mt.nodeIndex),We.push(mt.tensorIndex)}new yi({outboundLayer:this,inboundLayers:le,nodeIndices:Ne,tensorIndices:We,inputTensors:Y,outputTensors:o,inputMasks:h,outputMasks:b,inputShapes:T,outputShapes:M},q);for(var pt=0;pt<o.length;pt++)o[pt].sourceLayer=this,o[pt].nodeIndex=this.inboundNodes.length-1,o[pt].tensorIndex=pt},u.prototype.getConfig=function(){var r={name:this.name,trainable:this.trainable};return this.batchInputShape!=null&&(r.batchInputShape=this.batchInputShape),this.dtype!=null&&(r.dtype=this.dtype),r},u.prototype.disposeWeights=function(){return this.weights.forEach(function(r){return r.dispose()}),this.weights.length},u.prototype.assertNotDisposed=function(){if(this._refCount===0)throw new Error("Layer '"+this.name+"' is already disposed.")},u.prototype.dispose=function(){if(!this.built)throw new Error("Cannot dispose Layer "+this.name+" because it has not been built yet.");if(this._refCount===null)throw new Error("Cannot dispose Layer "+this.name+" because it has not been used yet.");this.assertNotDisposed();var r=0;return--this._refCount===0&&(r=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:r}},u}(i.serialization.Serializable);function Io(s){s=Qe(s);for(var u=[],r=0,o=s;r<o.length;r++){var h=o[r];u.push(h.shape)}return Tt(u)}function nn(s){return"float32"}function qa(s,u,r){if((u==null||r!=null&&r>0)&&(u=s.sourceLayer,r=s.nodeIndex),u.inboundNodes.length===0)return[s];var o=u.inboundNodes[r];if(o.inboundLayers.length===0)return o.inputTensors;for(var h=[],b=0;b<o.inboundLayers.length;b++)for(var T=o.inputTensors[b],M=o.inboundLayers[b],q=o.nodeIndices[b],Y=qa(T,M,q),le=0,Ne=Y;le<Ne.length;le++){var We=Ne[le];h.indexOf(We)===-1&&h.push(We)}return h}var La=function(s){O(u,s);function u(r){var o=s.call(this,{dtype:r.dtype,name:r.name!=null?r.name:Fr("input").toString()})||this;if(r.batchSize==null&&(r.batchSize=null),r.sparse==null&&(r.sparse=!1),o.trainable=!1,o.built=!0,o.sparse=r.sparse,r.inputShape!=null&&r.batchInputShape!=null)throw new w("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");var h=r.batchInputShape;if(h==null){if(r.inputShape==null)throw new w("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");h=[r.batchSize].concat(r.inputShape)}else if(r.batchSize!=null)throw new w("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");var b=r.dtype||"float32";o.batchInputShape=h,o.dtype=b,o.inputSpec=[{shape:h}];var T=new ba(o.dtype,o.batchInputShape,o,[],{},o.name);return T.nodeIndex=0,T.tensorIndex=0,new yi({outboundLayer:o,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[T],outputTensors:[T],inputMasks:[null],outputMasks:[null],inputShapes:[h],outputShapes:[h]}),o}return u.prototype.apply=function(r,o){throw new w("Cannot pass any input to an "+("InputLayer's apply() method. InputLayer name: "+this.name))},u.prototype.dispose=function(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}},u.prototype.getConfig=function(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}},u.className="InputLayer",u}(qr);i.serialization.registerClass(La);function Ki(s){if(s.batchShape==null&&s.shape==null)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(s.batchShape!=null&&s.shape!=null)throw new w("Please provide either a `shape` or `batchShape` argument to Input, but not both.");var u=s.batchShape;s.shape!=null&&u==null&&(u=[null].concat(s.shape));var r=s.dtype;r==null&&(r="float32");var o=new La({batchInputShape:u,name:s.name,dtype:r,sparse:s.sparse}),h=o.inboundNodes[0].outputTensors;return h[0]}function oi(s){return xe(this,void 0,void 0,function(){var u,r,o,h,b,T,M,q;return Q(this,function(Y){switch(Y.label){case 0:if(s==null)return[2];u=[],r=[],o=[];for(h in s)b=s[h],typeof b!="number"&&(T=b,u.push(T.data()),r.push(h),o.push(T));return u.length>0?[4,Promise.all(u)]:[3,2];case 1:for(M=Y.sent(),q=0;q<M.length;++q)s[r[q]]=M[q][0];i.dispose(o),Y.label=2;case 2:return[2]}})})}function Pi(s){if(s==null)return;for(var u in s){var r=s[u];typeof r!="number"&&r.dispose()}}var no;(function(s){s[s.SILENT=0]="SILENT",s[s.VERBOSE=1]="VERBOSE"})(no||(no={}));var mo=125,Ka=function(){function s(){this.validationData=null}return s.prototype.setParams=function(u){this.params=u},s.prototype.onEpochBegin=function(u,r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return[2]})})},s.prototype.onEpochEnd=function(u,r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return[2]})})},s.prototype.onBatchBegin=function(u,r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return[2]})})},s.prototype.onBatchEnd=function(u,r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return[2]})})},s.prototype.onTrainBegin=function(u){return xe(this,void 0,void 0,function(){return Q(this,function(r){return[2]})})},s.prototype.onTrainEnd=function(u){return xe(this,void 0,void 0,function(){return Q(this,function(r){return[2]})})},s.prototype.setModel=function(u){},s}(),ao=function(){function s(u,r){r===void 0&&(r=10),u==null&&(u=[]),this.callbacks=u,this.queueLength=r}return s.prototype.append=function(u){this.callbacks.push(u)},s.prototype.setParams=function(u){for(var r=0,o=this.callbacks;r<o.length;r++){var h=o[r];h.setParams(u)}},s.prototype.setModel=function(u){for(var r=0,o=this.callbacks;r<o.length;r++){var h=o[r];h.setModel(u)}},s.prototype.onEpochBegin=function(u,r){return xe(this,void 0,void 0,function(){var o,h,b;return Q(this,function(T){switch(T.label){case 0:r==null&&(r={}),o=0,h=this.callbacks,T.label=1;case 1:return o<h.length?(b=h[o],[4,b.onEpochBegin(u,r)]):[3,4];case 2:T.sent(),T.label=3;case 3:return o++,[3,1];case 4:return[2]}})})},s.prototype.onEpochEnd=function(u,r){return xe(this,void 0,void 0,function(){var o,h,b;return Q(this,function(T){switch(T.label){case 0:r==null&&(r={}),o=0,h=this.callbacks,T.label=1;case 1:return o<h.length?(b=h[o],[4,b.onEpochEnd(u,r)]):[3,4];case 2:T.sent(),T.label=3;case 3:return o++,[3,1];case 4:return[2]}})})},s.prototype.onBatchBegin=function(u,r){return xe(this,void 0,void 0,function(){var o,h,b;return Q(this,function(T){switch(T.label){case 0:r==null&&(r={}),o=0,h=this.callbacks,T.label=1;case 1:return o<h.length?(b=h[o],[4,b.onBatchBegin(u,r)]):[3,4];case 2:T.sent(),T.label=3;case 3:return o++,[3,1];case 4:return[2]}})})},s.prototype.onBatchEnd=function(u,r){return xe(this,void 0,void 0,function(){var o,h,b;return Q(this,function(T){switch(T.label){case 0:r==null&&(r={}),o=0,h=this.callbacks,T.label=1;case 1:return o<h.length?(b=h[o],[4,b.onBatchEnd(u,r)]):[3,4];case 2:T.sent(),T.label=3;case 3:return o++,[3,1];case 4:return[2]}})})},s.prototype.onTrainBegin=function(u){return xe(this,void 0,void 0,function(){var r,o,h;return Q(this,function(b){switch(b.label){case 0:u==null&&(u={}),r=0,o=this.callbacks,b.label=1;case 1:return r<o.length?(h=o[r],[4,h.onTrainBegin(u)]):[3,4];case 2:b.sent(),b.label=3;case 3:return r++,[3,1];case 4:return[2]}})})},s.prototype.onTrainEnd=function(u){return xe(this,void 0,void 0,function(){var r,o,h;return Q(this,function(b){switch(b.label){case 0:u==null&&(u={}),r=0,o=this.callbacks,b.label=1;case 1:return r<o.length?(h=o[r],[4,h.onTrainEnd(u)]):[3,4];case 2:b.sent(),b.label=3;case 3:return r++,[3,1];case 4:return[2]}})})},s}(),Ko=function(s){O(u,s);function u(){return s.call(this)||this}return u.prototype.onEpochBegin=function(r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return this.seen=0,this.totals={},[2]})})},u.prototype.onBatchEnd=function(r,o){return xe(this,void 0,void 0,function(){var h,b,T,M,q=this;return Q(this,function(Y){o==null&&(o={}),h=o.size==null?0:o.size,this.seen+=h,b=function(le){var Ne=o[le];if(typeof Ne=="number")T.totals.hasOwnProperty(le)||(T.totals[le]=0),T.totals[le]=T.totals[le]+Ne*h;else{var We=void 0;le in T.totals?We=T.totals[le]:T.totals[le]=0;var je=i.tidy(function(){return i.add(q.totals[le],i.mul(Ne,h))});T.totals[le]=je,We!=null&&We.dispose()}},T=this;for(M in o)b(M);return[2]})})},u.prototype.onEpochEnd=function(r,o){return xe(this,void 0,void 0,function(){var h,b,T,M,q,Y=this;return Q(this,function(le){if(o!=null)for(h=function(Ne){if(b.totals[Ne]==null)return"continue";typeof b.totals[Ne]=="number"?o[Ne]=b.totals[Ne]/b.seen:i.tidy(function(){var We=i.mul(i.div(1,Y.seen),Y.totals[Ne]);o[Ne]=We,Y.totals[Ne].dispose(),i.keep(o[Ne])})},b=this,T=0,M=this.params.metrics;T<M.length;T++)q=M[T],h(q);return[2]})})},u}(Ka),No=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.onTrainBegin=function(r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return this.epoch=[],this.history={},[2]})})},u.prototype.onEpochEnd=function(r,o){return xe(this,void 0,void 0,function(){var h;return Q(this,function(b){o==null&&(o={}),this.epoch.push(r);for(h in o)this.history[h]==null&&(this.history[h]=[]),this.history[h].push(o[h]);return[2]})})},u.prototype.syncData=function(){return xe(this,void 0,void 0,function(){var r,o,h,b,T,M,q,Y,le,Ne;return Q(this,function(We){switch(We.label){case 0:r=[],o=[],h=[];for(b in this.history)for(T=this.history[b],M=0;M<T.length;++M)typeof T[M]!="number"&&(q=T[M],r.push(q.data()),o.push(b),h.push(M));return[4,Promise.all(r)];case 1:for(Y=We.sent(),le=0;le<Y.length;++le)Ne=this.history[o[le]][h[le]],Ne.dispose(),this.history[o[le]][h[le]]=Y[le][0];return[2]}})})},u}(Ka),Co=function(s){O(u,s);function u(r,o){var h=s.call(this)||this;if(h.currentEpoch=0,h.yieldEvery=o||"auto",h.yieldEvery==="auto"&&(h.yieldEvery=mo),h.yieldEvery==="never"&&r.onYield!=null)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");return i.util.isNumber(h.yieldEvery)&&(h.maybeWait=Oa(h.maybeWait.bind(h),h.yieldEvery)),h.trainBegin=r.onTrainBegin,h.trainEnd=r.onTrainEnd,h.epochBegin=r.onEpochBegin,h.epochEnd=r.onEpochEnd,h.batchBegin=r.onBatchBegin,h.batchEnd=r.onBatchEnd,h.yield=r.onYield,h}return u.prototype.maybeWait=function(r,o,h){return xe(this,void 0,void 0,function(){var b;return Q(this,function(T){switch(T.label){case 0:return b=[],this.yield!=null?[4,oi(h)]:[3,2];case 1:T.sent(),b.push(this.yield(r,o,h)),T.label=2;case 2:return b.push(i.nextFrame()),[4,Promise.all(b)];case 3:return T.sent(),[2]}})})},u.prototype.onEpochBegin=function(r,o){return xe(this,void 0,void 0,function(){return Q(this,function(h){switch(h.label){case 0:return this.currentEpoch=r,this.epochBegin!=null?[4,oi(o)]:[3,3];case 1:return h.sent(),[4,this.epochBegin(r,o)];case 2:h.sent(),h.label=3;case 3:return[2]}})})},u.prototype.onEpochEnd=function(r,o){return xe(this,void 0,void 0,function(){var h;return Q(this,function(b){switch(b.label){case 0:return h=[],this.epochEnd!=null?[4,oi(o)]:[3,2];case 1:b.sent(),h.push(this.epochEnd(r,o)),b.label=2;case 2:return this.yieldEvery==="epoch"&&h.push(i.nextFrame()),[4,Promise.all(h)];case 3:return b.sent(),[2]}})})},u.prototype.onBatchBegin=function(r,o){return xe(this,void 0,void 0,function(){return Q(this,function(h){switch(h.label){case 0:return this.batchBegin!=null?[4,oi(o)]:[3,3];case 1:return h.sent(),[4,this.batchBegin(r,o)];case 2:h.sent(),h.label=3;case 3:return[2]}})})},u.prototype.onBatchEnd=function(r,o){return xe(this,void 0,void 0,function(){var h;return Q(this,function(b){switch(b.label){case 0:return h=[],this.batchEnd!=null?[4,oi(o)]:[3,2];case 1:b.sent(),h.push(this.batchEnd(r,o)),b.label=2;case 2:return this.yieldEvery==="batch"?h.push(i.nextFrame()):i.util.isNumber(this.yieldEvery)&&h.push(this.maybeWait(this.currentEpoch,r,o)),[4,Promise.all(h)];case 3:return b.sent(),[2]}})})},u.prototype.onTrainBegin=function(r){return xe(this,void 0,void 0,function(){return Q(this,function(o){switch(o.label){case 0:return this.trainBegin!=null?[4,oi(r)]:[3,3];case 1:return o.sent(),[4,this.trainBegin(r)];case 2:o.sent(),o.label=3;case 3:return[2]}})})},u.prototype.onTrainEnd=function(r){return xe(this,void 0,void 0,function(){return Q(this,function(o){switch(o.label){case 0:return this.trainEnd!=null?[4,oi(r)]:[3,3];case 1:return o.sent(),[4,this.trainEnd(r)];case 2:o.sent(),o.label=3;case 3:return[2]}})})},u}(Ka);function io(s,u){if(s==null&&(s={}),s instanceof Ka)return[s];if(Array.isArray(s)&&s[0]instanceof Ka)return s;var r=Qe(s);return r.map(function(o){return new Co(o,u)})}var ia=function(){function s(){}return s.registerCallbackConstructor=function(u,r){i.util.assert(u>=0&&Number.isInteger(u),function(){return"Verbosity level is expected to be an integer >= 0, "+("but got "+u)}),s.checkForDuplicate(r),s.constructors[u]==null&&(s.constructors[u]=[]),s.constructors[u].push(r)},s.checkForDuplicate=function(u){for(var r in s.constructors){var o=s.constructors[+r];o.forEach(function(h){if(h===u)throw new w("Duplicate callback constructor.")})}},s.clear=function(){s.constructors={}},s.createCallbacks=function(u){var r=[];for(var o in s.constructors){var h=+o;u>=h&&r.push.apply(r,s.constructors[h])}return r.map(function(b){return new b})},s.constructors={},s}();function Pr(s,u,r,o,h,b,T,M,q){var Y=new No,le=[new Ko].concat(ia.createCallbacks(u));s!=null&&le.push.apply(le,s),le.push(Y);var Ne=new ao(le);return Ne.setParams({epochs:r,initialEpoch:o,samples:h,steps:b,batchSize:T,verbose:u,doValidation:M,metrics:q}),{callbackList:Ne,history:Y}}function oa(s,u,r){return u===void 0&&(u={}),r===void 0&&(r=!1),yt(s,i.serialization.SerializationMap.getMap().classNameMap,u,"layer",r)}function Xa(s,u){return i.tidy(function(){s.dtype!=="float32"&&(s=s.asType("float32"));var r=i.sum(j(s),u,!0),o=i.fill(r.shape,P()),h=i.sqrt(i.maximum(r,o));return i.div(s,h)})}function Qn(s,u){return i.tidy(function(){return i.mean(j(i.sub(u,s)),-1)})}function oo(s,u){return i.tidy(function(){return i.mean(i.abs(i.sub(u,s)),-1)})}function ka(s,u){return i.tidy(function(){var r=i.sub(s,u),o=i.clipByValue(i.abs(s),P(),Number.MAX_VALUE),h=i.abs(i.div(r,o));return i.mul(100,i.mean(h,-1))})}function vn(s,u){return i.tidy(function(){var r=i.clipByValue(u,P(),Number.MAX_VALUE),o=i.log(i.add(1,r)),h=i.clipByValue(s,P(),Number.MAX_VALUE),b=i.log(i.add(1,h));return i.mean(j(i.sub(o,b)),-1)})}function Bi(s,u){return i.tidy(function(){var r=i.maximum(0,i.sub(1,i.mul(s,u)));return i.mean(j(r),-1)})}function yo(s,u){return i.tidy(function(){var r=i.maximum(0,i.sub(1,i.mul(s,u)));return i.mean(r,-1)})}function vo(s,u){return i.tidy(function(){var r=i.sum(i.mul(s,u),-1),o=i.max(i.mul(i.sub(1,s),u),-1);return i.maximum(0,i.add(1,i.sub(o,r)))})}function Aa(s,u){return i.tidy(function(){var r=Math.log(2),o=i.sub(u,s),h=i.sub(i.add(o,i.softplus(i.mul(-2,o))),r);return i.mean(h,-1)})}function go(s,u,r){return r===void 0&&(r=!1),i.tidy(function(){if(r)u=i.softmax(u);else{var o=i.sum(u,u.shape.length-1,!0);u=i.div(u,o)}return u=i.clipByValue(u,P(),1-P()),i.neg(i.sum(i.mul(s.toFloat(),i.log(u)),u.shape.length-1))})}function To(s,u,r){return r===void 0&&(r=!1),i.tidy(function(){var o=i.floor(bi(s)).toInt();u=i.clipByValue(u,P(),1-P());var h=u.shape,b=i.oneHot(o,h[h.length-1]).reshape(h);return go(b,u,r)})}function Rs(s,u){if(!i.util.arraysEqual(s.shape,u.shape))throw new w("logits and labels must have the same shape, but got shapes "+(JSON.stringify(s.shape)+" and "+JSON.stringify(u.shape)));return i.tidy(function(){var r=u.relu(),o=u.abs().neg();return r.sub(u.mul(s)).add(o.exp().log1p())})}function Eo(s,u){return i.tidy(function(){var r;return r=i.clipByValue(u,P(),1-P()),r=i.log(i.div(r,i.sub(1,r))),i.mean(Rs(s,r),-1)})}function As(s,u){return i.tidy(function(){var r=i.clipByValue(s,P(),1),o=i.clipByValue(u,P(),1);return i.sum(i.mul(s,i.log(i.div(r,o))),-1)})}function Ds(s,u){return i.tidy(function(){var r=i.log(i.add(P(),u));return i.mean(i.sub(u,i.mul(s,r)),-1)})}function Xo(s,u){return i.tidy(function(){var r=Xa(s,-1),o=Xa(u,-1),h=i.mul(r,o);return i.neg(i.sum(h,-1))})}var Ro={meanSquaredError:Qn,meanAbsoluteError:oo,meanAbsolutePercentageError:ka,meanSquaredLogarithmicError:vn,squaredHinge:Bi,hinge:yo,categoricalHinge:vo,logcosh:Aa,categoricalCrossentropy:go,sparseCategoricalCrossentropy:To,binaryCrossentropy:Eo,kullbackLeiblerDivergence:As,poisson:Ds,cosineProximity:Xo};function Yo(s){if(typeof s=="string"){if(s in Ro)return Ro[s];var u="Unknown loss "+s;throw s.toLowerCase().includes("softmaxcrossentropy")&&(u="Unknown loss "+s+'. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'),new w(u)}else return s}function Ao(s,u){return i.tidy(function(){var r=i.mul(.5,i.onesLike(u)),o=ni(i.greater(u,r),s.dtype);return i.mean(i.equal(s,o),-1)})}function Qo(s,u){return i.tidy(function(){return ni(i.equal(i.argMax(s,-1),i.argMax(u,-1)),"float32")})}function vi(s,u){return i.tidy(function(){return i.logicalAnd(s.equal(1),u.equal(1)).sum().cast("float32")})}function Fs(s,u){return i.tidy(function(){return i.logicalAnd(s.equal(1),u.equal(0)).sum().cast("float32")})}function tu(s,u){return i.tidy(function(){return i.logicalAnd(s.equal(0),u.equal(1)).sum().cast("float32")})}function ps(s,u){return i.tidy(function(){var r=vi(s,u),o=tu(s,u),h=r.add(o);return i.where(i.greater(h,0),r.div(h),0).cast("float32")})}function ru(s,u){return i.tidy(function(){var r=vi(s,u),o=Fs(s,u),h=r.add(o);return i.where(i.greater(h,0),r.div(h),0).cast("float32")})}function Os(s,u){return Eo(s,u)}function ds(s,u){return s.rank===u.rank&&(s=s.squeeze([s.rank-1])),u=u.argMax(-1),u.dtype!==s.dtype&&(u=u.asType(s.dtype)),i.equal(s,u).asType("float32")}var Ms=Qn,Ls=Qn,nu=oo,fs=oo,au=ka,ms=ka,Do=go,zs=Xo,Zo=To,xo={binaryAccuracy:Ao,categoricalAccuracy:Qo,precision:ps,categoricalCrossentropy:Do,sparseCategoricalCrossentropy:Zo,mse:Ms,MSE:Ls,mae:nu,MAE:fs,mape:au,MAPE:ms,cosine:zs};function ys(s){if(typeof s=="string"&&s in xo)return xo[s];if(typeof s!="string"&&s!=null)return s;throw new w("Unknown metric "+s)}function Fo(s){if(tt(s!==null,"Unknown LossOrMetricFn "+s),typeof s=="string")return s;for(var u=void 0,r=0,o=Object.keys(Ro);r<o.length;r++){var h=o[r];if(Ro[h]===s){u=h;break}}if(u!==void 0)return u;for(var b=0,T=Object.keys(xo);b<T.length;b++){var h=T[b];if(xo[h]===s){u=h;break}}return u!==void 0?u:s.name}function Ps(s){var u={Adagrad:function(){return i.train.adagrad(.01)},Adadelta:function(){return i.train.adadelta(1,.95,P())},Adam:function(){return i.train.adam(.001,.9,.999,P())},Adamax:function(){return i.train.adamax(.002,.9,.999,P(),0)},RMSProp:function(){return i.train.rmsprop(.001,.9,0,P())},SGD:function(){return i.train.sgd(.01)}};if(u.adagrad=u.Adagrad,u.adadelta=u.Adadelta,u.adam=u.Adam,u.adamax=u.Adamax,u.rmsprop=u.RMSProp,u.sgd=u.SGD,s in u)return u[s]();throw new w("Unknown Optimizer "+s)}var Jo=1*1024*1024;function _o(s,u,r){if(r===void 0&&(r=!1),s==null||typeof s!="object"||Object.getPrototypeOf(s)!==Object.prototype||!wo(s))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(r){var o=JSON.stringify(s);o.length>Jo&&console.warn('User-defined metadata of model "'+u+'" is too large in '+("size (length="+o.length+" when serialized). It is not ")+"recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= "+(Jo+"."))}}function wo(s){if(s===null)return!0;if(typeof s=="object")if(Object.getPrototypeOf(s)===Object.prototype){for(var u=Object.keys(s),r=0,o=u;r<o.length;r++){var h=o[r];if(typeof h!="string")return!1;if(!wo(s[h]))return!1}return!0}else if(Array.isArray(s)){for(var b=0,T=s;b<T.length;b++){var M=T[b];if(!wo(M))return!1}return!0}else return!1;else{var q=typeof s;return q==="string"||q==="number"||q==="boolean"}}function Bs(s,u,r,o){o===void 0&&(o=console.log);var h=vs(s),b=["Layer (type)","Output shape","Param #"];h?(u=u||65,r=r||[.45,.85,1]):(u=u||98,r=r||[.33,.55,.67,1]),r[r.length-1]<=1&&(r=r.map(function(We){return Math.floor(u*We)}));var T;if(!h){b.push("Receives inputs"),T=[];for(var M in s.nodesByDepth)T.push.apply(T,s.nodesByDepth[M])}o("_".repeat(u)),$o(b,r,o),o("=".repeat(u));for(var q=s.layers,Y=0;Y<q.length;++Y)h?iu(q[Y],r,o):ku(q[Y],r,T,o),o((Y===q.length-1?"=":"_").repeat(u));s.checkTrainableWeightsConsistency();var le=Ws(s),Ne=Ra(s.nonTrainableWeights);o("Total params: "+(le+Ne)),o("Trainable params: "+le),o("Non-trainable params: "+Ne),o("_".repeat(u))}function Ws(s){var u;return s.collectedTrainableWeights!=null?u=Ra(s.collectedTrainableWeights):u=Ra(s.trainableWeights),u}function vs(s){var u=!0,r=[],o=[];for(var h in s.nodesByDepth)r.push(s.nodesByDepth[h]);for(var b=0,T=r;b<T.length;b++){var M=T[b];if(M.length>1||M.length===1&&M[0].inboundLayers.length>1){u=!1;break}o.push.apply(o,M)}if(u)for(var q=0,Y=s.layers;q<Y.length;q++){for(var le=Y[q],Ne=!1,We=0,je=le.inboundNodes;We<je.length;We++){var qe=je[We];if(o.indexOf(qe)!==-1)if(Ne){u=!1;break}else Ne=!0}if(!u)break}return u}function $o(s,u,r){r===void 0&&(r=console.log);for(var o="",h=0;h<s.length;++h)h>0&&(o=o.slice(0,o.length-1)+" "),o+=s[h],o=o.slice(0,u[h]),o+=" ".repeat(u[h]-o.length);r(o)}function iu(s,u,r){var o;try{o=JSON.stringify(s.outputShape)}catch(M){o="multiple"}var h=s.name,b=s.getClassName(),T=[h+" ("+b+")",o,s.countParams().toString()];$o(T,u,r)}function ku(s,u,r,o){var h;try{h=JSON.stringify(s.outputShape)}catch(st){h="multiple"}for(var b=[],T=0,M=s.inboundNodes;T<M.length;T++){var q=M[T];if(r!=null&&r.length>0&&r.indexOf(q)===-1)continue;for(var Y=0;Y<q.inboundLayers.length;++Y){var le=q.inboundLayers[Y].name,Ne=q.nodeIndices[Y],We=q.tensorIndices[Y];b.push(le+"["+Ne+"]["+We+"]")}}var je=s.name,qe=s.getClassName(),mt=b.length===0?"":b[0],pt=[je+" ("+qe+")",h,s.countParams().toString(),mt];$o(pt,u,o);for(var Y=1;Y<b.length;++Y)$o(["","","",b[Y]],u,o)}function ou(s,u,r){return(s==="inboundNodes"||s==="outputLayers"||s==="inputLayers")&&u===0&&typeof r=="string"}function Oo(s,u){if(s===null)return null;if(typeof s=="string")return xt(s);if(typeof s=="number"||typeof s=="boolean")return s;if(s instanceof Array){for(var r=[],o=s.length,h=0;h<o;++h){var b=s[h];ou(u,h,b)?r.push(b):r.push(Oo(b,u))}return r}else{for(var T={},M=0,q=Object.keys(s);M<q.length;M++){var Y=q[M],le=s[Y];if(Y==="name"&&typeof le=="string")T[Y]=le;else{var Ne=xt(Y);T[Ne]=Oo(le,Ne)}}return T}}function Mo(s,u){if(s==null)return null;if(typeof s=="string")return it(s);if(typeof s=="number"||typeof s=="boolean")return s;if(s instanceof Array){for(var r=[],o=s.length,h=0;h<o;++h){var b=s[h];ou(u,h,b)?r.push(b):r.push(Mo(b,u))}return r}else{for(var T={},M=0,q=Object.keys(s);M<q.length;M++){var Y=q[M],le=s[Y],Ne=it(Y);(Y==="name"||Y==="className")&&typeof le=="string"?T[Ne]=le:T[Ne]=Mo(le,Y)}return T}}var gs="2.7.0";function es(s,u){if(s.dtype==null||s.dtype===u.dtype)return u;try{return i.cast(u,s.dtype)}catch(r){throw new w("The dtype of the feed ("+u.dtype+") can not be cast to the dtype "+("of the key '"+s.name+"' ("+s.dtype+")."))}}var Si=function(){function s(u){if(this.id2Value={},this.id2Mask={},this.name2Id={},u instanceof s)for(var r in u.id2Value)this.id2Value[r]=u.id2Value[r],r in u.id2Mask&&(this.id2Mask[r]=u.id2Mask[r]);else{if(u==null)return;for(var o=0,h=u;o<h.length;o++){var b=h[o];this.add(b.key,b.value)}}}return s.prototype.add=function(u,r,o){if(this.id2Value[u.id]==null)this.id2Value[u.id]=es(u,r),this.name2Id[u.name]=u.id,o!=null&&(this.id2Mask[u.id]=o);else throw new w("Duplicate key: name="+u.name+", id="+u.id);return this},s.prototype.addFeed=function(u){this.add(u.key,u.value)},s.prototype.hasKey=function(u){return this.id2Value[u.id]!=null},s.prototype.names=function(){return Object.keys(this.name2Id)},s.prototype.getValue=function(u){if(u instanceof ba){if(this.id2Value[u.id]==null)throw new w("Nonexistent key: "+u.name);return this.id2Value[u.id]}else{var r=this.name2Id[u];if(r==null)throw new w("Feed dict has no SymbolicTensor name: "+u);return this.id2Value[r]}},s.prototype.getMask=function(u){if(u instanceof ba){if(this.id2Value[u.id]==null)throw new w("Nonexistent key: "+u.name);return this.id2Mask[u.id]}else{var r=this.name2Id[u];if(r==null)throw new w("Feed dict has no SymbolicTensor name: "+u);return this.id2Mask[r]}},s.prototype.disposeMasks=function(){this.id2Mask!=null&&i.dispose(this.id2Mask)},s}(),Lo={},zo={};function Xi(s,u,r,o){for(var h=r==null?!1:r.training,b=Array.isArray(s),T=b?s:[s],M=T.map(function(Hr){return Hr.name}),q=[],Y=u.names(),le=0,Ne=M;le<Ne.length;le++){var We=Ne[le];Y.indexOf(We)!==-1?q.push(u.getValue(We)):q.push(null)}o!=null&&(o.maxNumTensors=-Infinity,o.minNumTensors=Infinity);var je=M.join(",")+"|"+u.names().join(","),qe,mt;if(Lo[je]==null){var pt=ts(T,u);qe=pt.sorted,mt=pt.recipientCounts,Lo[je]=qe,zo[je]=mt}qe=Lo[je],mt={},h||Object.assign(mt,zo[je]);for(var st=new Si(u),dt=0;dt<qe.length;++dt){if(o!=null){var Dt=i.memory().numTensors;Dt>o.maxNumTensors&&(o.maxNumTensors=Dt),Dt<o.minNumTensors&&(o.minNumTensors=Dt)}var or=qe[dt],Xt=or.sourceLayer;if(Xt instanceof La)continue;for(var Jt=[],vr=[],lr=[],Ir=!1,Lr=0,kr=or.inputs;Lr<kr.length;Lr++){var Sr=kr[Lr],fn=st.getValue(Sr),Xr=st.getMask(Sr);Jt.push(fn),vr.push(Xr),Xr!=null&&(Ir=!0),h||(mt[Sr.name]--,mt[Sr.name]===0&&!u.hasKey(Sr)&&M.indexOf(Sr.name)===-1&&!fn.isDisposed&&Sr.sourceLayer.stateful!==!0&&lr.push(fn))}Ir&&(r=r||{},r.mask=vr[0]);var $t=Qe(Xt.apply(Jt,r)),On=null;Xt.supportsMasking&&(On=Xt.computeMask(Jt,vr));for(var En=E(or),kn=Array.isArray(En)?En:[En],cn=0;cn<kn.length;++cn){st.hasKey(kn[cn])||st.add(kn[cn],$t[cn],Array.isArray(On)?On[0]:On);var Mn=M.indexOf(kn[cn].name);Mn!==-1&&(q[Mn]=$t[cn])}h||i.dispose(lr)}return st.disposeMasks(),b?q:q[0]}function ts(s,u){i.util.assert(s!=null&&s.length>0,function(){return"Expected at least one fetch, got none"});var r=[],o={};if(s.length===1){var h=ue(s[0],u);r=h.sorted,o=h.recipientMap}else for(var b=new Set,T=0,M=s;T<M.length;T++){for(var q=M[T],Y=ue(q,u),le=Y.sorted,Ne=Y.recipientMap,We=0,je=le;We<je.length;We++){var qe=je[We];b.has(qe.name)||(r.push(qe),b.add(qe.name))}var mt=function(st){o[st]==null&&(o[st]=new Set),Ne[st].forEach(function(dt){return o[st].add(dt)})};for(var pt in Ne)mt(pt)}return{sorted:r,recipientCounts:ne(o)}}function ne(s){var u={};for(var r in s)u[r]=s[r].size;return u}function ue(s,u){for(var r=new Set,o=[],h={},b=0,T=u.names();b<T.length;b++){var M=T[b];r.add(M)}var q=[],Y=[];for(q.push(s);q.length>0;){var le=q[q.length-1];if(r.has(le.name)){q.pop();continue}var Ne=Y[Y.length-1]===q.length-1;if(le.inputs.length===0||Ne)q.pop(),o.push(le),r.add(le.name),Ne&&Y.pop();else{Y.push(q.length-1);for(var We=0,je=le.inputs;We<je.length;We++){var qe=je[We];if(h[qe.name]==null&&(h[qe.name]=new Set),h[qe.name].add(le.name),r.has(qe.name))continue;q.push(qe)}}}return{sorted:o,recipientMap:h}}function E(s){var u;if(s.sourceLayer.inboundNodes.length===1)u=s.sourceLayer.output;else{for(var r=null,o=0;o<s.sourceLayer.inboundNodes.length;++o)for(var h=0,b=s.sourceLayer.inboundNodes[o].outputTensors;h<b.length;h++){var T=b[h];if(T.id===s.id){r=o;break}}u=s.sourceLayer.getOutputAt(r)}return u}var F=function(s){O(u,s);function u(r){var o=s.call(this,{})||this;if(o.containerNodes=new Set,o.name=r.name,o.name==null){var h=o.getClassName().toLowerCase();o.name=Fr(h)}if(o.supportsMasking=!1,o.trainable_=!0,Array.isArray(r.inputs)?o.inputs=r.inputs.slice():o.inputs=[r.inputs],Array.isArray(r.outputs)?o.outputs=r.outputs.slice():o.outputs=[r.outputs],qt(o.inputs).length!==o.inputs.length)throw new w("The list of inputs passed to the model is redundant. All inputs should only appear once. Found: "+(""+o.inputs.map(function(Wn){return Wn.name})));qt(o.outputs).length!==o.outputs.length&&console.warn("The list of outputs passed to the model is redundant. All outputs should only appear once. Found: "+(""+o.outputs.map(function(Wn){return Wn.name}))),o.inputLayers=[],o.inputLayersNodeIndices=[],o.inputLayersTensorIndices=[],o.outputLayers=[],o.outputLayersNodeIndices=[],o.outputLayersTensorIndices=[],o.layers=[],o.internalContainerRefs=[];for(var b=0,T=o.outputs;b<T.length;b++){var M=T[b],q=M.sourceLayer,Y=M.nodeIndex,le=M.tensorIndex;o.outputLayers.push(q),o.outputLayersNodeIndices.push(Y),o.outputLayersTensorIndices.push(le)}for(var Ne=0,We=o.inputs;Ne<We.length;Ne++){var M=We[Ne],q=M.sourceLayer,Y=M.nodeIndex,le=M.tensorIndex;tt(Y===0,"input layer has >1 nodes"),tt(le===0,"input layer has >1 tensors"),o.inputLayers.push(q),o.inputLayersNodeIndices.push(Y),o.inputLayersTensorIndices.push(le)}o.inputNames=[],o.outputNames=[],o.feedInputShapes=[],o.feedInputNames=[],o.feedOutputNames=[];for(var je=0;je<o.inputLayers.length;je++){var q=o.inputLayers[je];if(!(q instanceof La))throw new TypeError("Input layers to a LayersModel must be InputLayer objects. "+("Received inputs: "+r.inputs+". ")+("Input "+je+" (0-based) originates ")+("from layer type "+q.getClassName()+"."));o.inputNames.push(q.name),o.feedInputShapes.push(q.batchInputShape),o.feedInputNames.push(q.name)}for(var qe=0,mt=o.outputLayers;qe<mt.length;qe++){var q=mt[qe];o.outputNames.push(q.name)}o.internalInputShapes=o.inputs.map(function(Wn){return Wn.shape}),o.internalOutputShapes=o.outputs.map(function(Wn){return Wn.shape});for(var pt={},st={},dt={},Dt={},or={},Xt=[],Jt=function(Wn,Is,gi,qo,Ns,kh){(qo==null||Ns==null||kh==null)&&(qo=Wn.sourceLayer,Ns=Wn.nodeIndex,kh=Wn.tensorIndex);var Ti=qo.inboundNodes[Ns];if(gi.indexOf(Ti)!==-1)throw new ae("The tensor "+Wn.name+' at layer "'+qo.name+'" is part of a cycle.');if(Is.indexOf(Ti)!==-1)return;o.containerNodes.add(u.nodeKey(qo,Ns)),qo.id in or||(or[qo.id]=Object.keys(or).length),gi.indexOf(Ti)===-1&&gi.push(Ti);for(var tp=Ti.inboundLayers.length,Xs=0;Xs<tp;Xs++){var rp=Ti.inputTensors[Xs],np=Ti.inboundLayers[Xs],ap=Ti.nodeIndices[Xs],Sh=Ti.tensorIndices[Xs];Jt(rp,Is,gi,np,ap,Sh)}for(Is.push(Ti);gi.indexOf(Ti)>=0;)gi.splice(gi.indexOf(Ti),1);Xt.push(Ti)},vr=[],lr=[],Ir=0,Lr=o.outputs;Ir<Lr.length;Ir++){var M=Lr[Ir];Jt(M,vr,lr)}for(var kr=Xt.slice().reverse(),Sr=0,fn=kr;Sr<fn.length;Sr++){var Xr=fn[Sr];st[Xr.id]=Xr,Xr.id in pt||(pt[Xr.id]=0);var $t=pt[Xr.id],On=dt[Xr.outboundLayer.id]==null?0:dt[Xr.outboundLayer.id];$t=Math.max($t,On),dt[Xr.outboundLayer.id]=$t,Dt[Xr.outboundLayer.id]=Xr.outboundLayer,pt[Xr.id]=$t;for(var je=0;je<Xr.inboundLayers.length;je++){var En=Xr.inboundLayers[je],Y=Xr.nodeIndices[je],kn=En.inboundNodes[Y],cn=pt[kn.id]==null?0:pt[kn.id];pt[kn.id]=Math.max($t+1,cn),st[kn.id]=kn}}var Mn={};for(var Hr in pt){var $t=pt[Hr];$t in Mn||(Mn[$t]=[]),Mn[$t].push(st[Hr])}var ua={};for(var Ci in dt){var $t=dt[Ci];$t in ua||(ua[$t]=[]),ua[$t].push(Dt[Ci])}var Ui=Object.keys(ua).map(function(Wn){return parseInt(Wn,10)}).sort(ar);o.layers=[];for(var Xn=0,$i=Ui;Xn<$i.length;Xn++){var $t=$i[Xn],Vi=ua[$t];Vi.sort(function(Is,gi){var qo=or[Is.id],Ns=or[gi.id];return qo<Ns?-1:qo>Ns?1:0});for(var Ks=0,Zu=Vi;Ks<Zu.length;Ks++){var q=Zu[Ks];q instanceof u&&o.internalContainerRefs.push(q),o.layers.push(q)}}o.layersByDepth=ua,Ui=Object.keys(Mn).map(function(Wn){return parseInt(Wn,10)}).sort(ar);for(var al=o.inputs.slice(),_h=[],rh=0,Ju=Ui;rh<Ju.length;rh++)for(var $t=Ju[rh],nh=0,ah=Mn[$t];nh<ah.length;nh++){var Xr=ah[nh],q=Xr.outboundLayer;if(q!=null){for(var ih=0,oh=Xr.inputTensors;ih<oh.length;ih++){var M=oh[ih];if(al.indexOf(M)===-1)throw new ae("Graph disconnected: cannot obtain value for tensor "+M+(' at layer "'+q.name+'". ')+"The following previous layers were accessed without "+("issue: "+_h))}for(var sh=0,wh=Xr.outputTensors;sh<wh.length;sh++){var M=wh[sh];al.push(M)}_h.push(q.name)}}o.nodesByDepth=Mn;for(var uh=o.layers.map(function(Wn){return Wn.name}),$h=function(Wn){var Is=uh.filter(function(gi){return gi===Wn}).length;if(Is!==1)throw new ae('The name "'+Wn+'" is used '+Is+" times in the model. All layer names should be unique. Layer names: "+JSON.stringify(uh))},ch=0,bh=uh;ch<bh.length;ch++){var ep=bh[ch];$h(ep)}return o.outboundNodes=[],o.inboundNodes=[],new yi({outboundLayer:o,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:o.inputs,outputTensors:o.outputs,inputMasks:o.inputs.map(function(Wn){return null}),outputMasks:o.outputs.map(function(Wn){return null}),inputShapes:o.inputs.map(function(Wn){return Wn.shape}),outputShapes:o.outputs.map(function(Wn){return Wn.shape})}),o.built=!0,o._refCount=1,o}return u.prototype.assertNotDisposed=function(){if(this._refCount===0)throw new Error("Container '"+this.name+"' is already disposed.")},u.prototype.dispose=function(){this.assertNotDisposed();var r={refCountAfterDispose:null,numDisposedVariables:0};if(--this._refCount===0){for(var o=0,h=this.layers;o<h.length;o++){var b=h[o];r.numDisposedVariables+=b.dispose().numDisposedVariables}for(var T=0,M=this.internalContainerRefs;T<M.length;T++){var q=M[T];r.numDisposedVariables+=q.dispose().numDisposedVariables}}return r.refCountAfterDispose=this._refCount,r},Object.defineProperty(u.prototype,"trainable",{get:function(){return this.trainable_},set:function(r){this.layers.forEach(function(o){o._trainableWeights.forEach(function(h){return h.trainable=r})}),this.trainable_=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"trainableWeights",{get:function(){if(this._trainableWeights.length>0)throw new w("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];for(var r=[],o=0,h=this.layers;o<h.length;o++){var b=h[o];r=r.concat(b.trainableWeights)}return r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){for(var r=[],o=0,h=this.layers;o<h.length;o++){var b=h[o];r.push.apply(r,b.nonTrainableWeights)}if(!this.trainable){for(var T=[],M=0,q=this.layers;M<q.length;M++){var b=q[M];T.push.apply(T,b.trainableWeights)}return T.concat(r)}return r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"weights",{get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)},enumerable:!0,configurable:!0}),u.prototype.loadWeights=function(r,o){o===void 0&&(o=!0);for(var h={},b=0,T=0,M=this.layers;T<M.length;T++)for(var q=M[T],Y=0,le=q.weights;Y<le.length;Y++){var Ne=le[Y];if(h[Ne.originalName]!=null)throw new w("Duplicate weight name: "+Ne.originalName);h[Ne.originalName]=Ne,b++}var We=[];for(var je in r){var qe=je;if(h[je]==null){var mt=je.split("/"),pt=mt.slice(0,-2).concat([mt[mt.length-1]]);qe=pt.join("/")}if(h[qe]!=null)We.push([h[qe],r[je]]);else if(o)throw new w("Provided weight data has no target variable: "+je);delete h[qe]}if(o){var st=[];for(var dt in h)st.push(dt);if(st.length>0)throw new w(st.length+" of "+b+" weights are not set: "+(""+st))}zi(We)},u.prototype.updatedConfig=function(){var r=this.getConfig(),o={};return o.className=this.getClassName(),o.config=r,o.kerasVersion="tfjs-layers "+gs,o.backend="TensorFlow.js",o},u.prototype.toJSON=function(r,o){o===void 0&&(o=!0);var h=Mo(this.updatedConfig());return o?JSON.stringify(h):h},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){r=Qe(r);for(var b=new Si,T=0;T<h.inputs.length;++T)b.add(h.inputs[T],r[T]);return Xi(h.outputs,b,o)})},u.prototype.computeMask=function(r,o){var h=this;return i.tidy(function(){r=Qe(r);var b;return o==null?b=nt(null,r.length):b=Qe(o),h.runInternalGraph(r,b)[1]})},u.prototype.computeOutputShape=function(r){var o=In(r);if(o.length!==this.inputLayers.length)throw new w("Invalid inputShape argument "+r+": "+("model has "+this.inputLayers.length+" tensor inputs."));for(var h={},b=0;b<o.length;b++){var T=this.inputLayers[b],M=o[b],q=T.name+"_0_0";h[q]=M}var Y=Object.keys(this.nodesByDepth).map(function(fn){return parseInt(fn,10)}).sort(ar);if(Y.length>1)for(var le=0,Ne=Y;le<Ne.length;le++)for(var We=Ne[le],je=this.nodesByDepth[We],qe=0,mt=je;qe<mt.length;qe++){var pt=mt[qe],T=pt.outboundLayer;if(this.inputLayers.map(function(Xr){return Xr.id}).indexOf(T.id)!==-1)continue;for(var st=[],dt=0;dt<pt.inboundLayers.length;dt++){var Dt=pt.inboundLayers[dt],or=pt.nodeIndices[dt],Xt=pt.tensorIndices[dt],q=Dt.name+"_"+or+"_"+Xt,Jt=h[q];st.push(Jt)}for(var vr=T.computeOutputShape(Tt(st)),lr=In(vr),Ir=T.inboundNodes.indexOf(pt),dt=0;dt<lr.length;dt++){var q=T.name+"_"+Ir+"_"+dt;h[q]=lr[dt]}}for(var Lr=[],kr=[],b=0;b<this.outputLayers.length;b++){var T=this.outputLayers[b],Ir=this.outputLayersNodeIndices[b],Xt=this.outputLayersTensorIndices[b],q=T.name+"_"+Ir+"_"+Xt;kr.push(q)}for(var b=0;b<kr.length;b++){var Sr=kr[b];tt(Sr in h),Lr.push(h[Sr])}return Tt(Lr)},u.prototype.runInternalGraph=function(r,o){o==null&&(o=nt(null,r.length));for(var h={},b=0;b<this.inputs.length;++b){var T=this.inputs[b],M=r[b],q=o[b];h[T.id]=[M,q]}for(var Y=Object.keys(this.nodesByDepth).map(function(ua){return parseInt(ua,10)}).sort(ar),le=0,Ne=Y;le<Ne.length;le++)for(var We=Ne[le],je=this.nodesByDepth[We],qe=0,mt=je;qe<mt.length;qe++){for(var pt=mt[qe],st=pt.outboundLayer,dt=pt.inputTensors,Dt=pt.outputTensors,or=new Array,Xt=0,Jt=dt;Xt<Jt.length;Xt++){var T=Jt[Xt];T.id in h&&or.push(h[T.id])}if(or.length===dt.length){var vr={},lr=void 0,Ir=void 0,Lr=void 0,kr=void 0;if(pt.callArgs!=null&&(vr=pt.callArgs),or.length===1){var Sr=or[0],fn=Sr[0],Xr=Sr[1];vr.mask==null&&(vr.mask=Xr),Lr=Qe(st.call(fn,vr)),kr=Qe(st.computeMask(fn,Xr)),lr=[fn],Ir=[Xr]}else lr=or.map(function(ua){return ua[0]}),Ir=or.map(function(ua){return ua[1]}),vr.mask==null&&(vr.mask=Ir),Lr=Qe(st.call(lr,vr)),kr=Qe(st.computeMask(lr,Ir));if(st.activityRegularizer)throw new ge("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(var b=0;b<Dt.length;++b){var T=Dt[b],M=Lr[b],q=kr[b];h[T.id]=[M,q]}}}for(var $t=[],On=[],En=[],kn=0,cn=this.outputs;kn<cn.length;kn++){var T=cn[kn];tt(T.id in h,"Could not compute output "+T.name+" : "+T.id);var Mn=h[T.id],Hr=Mn[0],q=Mn[1];En.push(Hr.shape),$t.push(Hr),On.push(q)}return[$t,On,En]},u.prototype.buildNodeConversionMap=function(r){for(var o={},h,b=0,T=this.layers;b<T.length;b++){var M=T[b];h=M instanceof u?1:0;for(var q=0;q<M.inboundNodes.length;q++){var Y=u.nodeKey(M,q);this.containerNodes.has(Y)&&(o[Y]=h,h+=1)}}return o},u.prototype.getLayer=function(r,o){if(o!=null){if(this.layers.length<=o)throw new w("Was asked to retrieve layer at index "+o+", but model only "+("has "+this.layers.length+" layer(s)."));return this.layers[o]}else if(r==null)throw new w("Provide either a layer name or layer index");for(var h=0,b=this.layers;h<b.length;h++){var T=b[h];if(T.name===r)return T}throw new w("No such layer: "+r)},u.prototype.calculateLosses=function(){var r=this;return i.tidy(function(){for(var o=[],h=0,b=r.layers;h<b.length;h++)for(var T=b[h],M=0;M<T.inboundNodes.length;++M){var q=u.nodeKey(T,M);r.containerNodes.has(q)&&o.push.apply(o,T.calculateLosses())}return o})},u.prototype.getConfig=function(){for(var r={name:this.name},o=this.buildNodeConversionMap(this.layers),h=[],b=0,T=this.layers;b<T.length;b++){for(var M=T[b],q=M.getClassName(),Y=M.getConfig(),le=[],Ne=0;Ne<M.inboundNodes.length;Ne++){var We=M.inboundNodes[Ne],je=u.nodeKey(M,Ne),qe={};if(this.containerNodes.has(je)){if(We.callArgs)try{JSON.stringify(We.callArgs),qe=We.callArgs}catch(Ir){console.warn("Layer "+M.name+" was passed non-serializable keyword arguments: "+(We.callArgs+". They will not be included ")+"in the serialized model (and thus will be missing at deserialization time)."),qe={}}if(We.inboundLayers.length>0){for(var mt=[],pt=0;pt<We.inboundLayers.length;pt++){var st=We.inboundLayers[pt],dt=We.nodeIndices[pt],Dt=We.tensorIndices[pt],or=u.nodeKey(st,dt),Xt=o[or];Xt==null&&(Xt=0),mt.push([st.name,Xt,Dt,qe])}le.push(mt)}}}var Jt={};Jt.name=M.name,Jt.className=q,Jt.config=Y,Jt.inboundNodes=le,h.push(Jt)}r.layers=h;for(var vr=[],pt=0;pt<this.inputLayers.length;pt++){var M=this.inputLayers[pt],dt=this.inputLayersNodeIndices[pt],je=u.nodeKey(M,dt);if(!this.containerNodes.has(je))continue;var Xt=o[je];Xt==null&&(Xt=0);var Dt=this.inputLayersTensorIndices[pt];vr.push([M.name,Xt,Dt])}r.inputLayers=vr;for(var lr=[],pt=0;pt<this.outputLayers.length;pt++){var M=this.outputLayers[pt],dt=this.outputLayersNodeIndices[pt],je=u.nodeKey(M,dt);if(!this.containerNodes.has(je))continue;var Xt=o[je];Xt==null&&(Xt=0);var Dt=this.outputLayersTensorIndices[pt];lr.push([M.name,Xt,Dt])}return r.outputLayers=lr,r},u.fromConfig=function(r,o,h,b){b===void 0&&(b=!1);var T={},M={};function q(cn,Mn){cn.name in M?M[cn.name].push(Mn):M[cn.name]=[Mn]}function Y(cn,Mn){for(var Hr=[],ua,Ci=0,Ui=Mn;Ci<Ui.length;Ci++){var Xn=Ui[Ci],$i=Xn[0],Vi=Xn[1],Ks=Xn[2];if(ua=Xn[3]==null?{}:Xn[3],!($i in T)){q(cn,Mn);return}var Zu=T[$i];if(Zu.inboundNodes.length<=Vi){q(cn,Mn);return}var al=Zu.inboundNodes[Vi];Hr.push(al.outputTensors[Ks])}Hr.length>0&&cn.apply(Tt(Hr),ua)}function le(cn){var Mn=cn.name,Hr=oa(cn,o.customObjects!=null?o.customObjects:{});Hr.setFastWeightInitDuringBuild(b),T[Mn]=Hr;var ua=cn.inboundNodes;ua.forEach(function(Ci){if(!(Ci instanceof Array))throw new w("Corrupted configuration, expected array for nodeData: "+Ci);q(Hr,Ci)})}for(var Ne=o.name,We=o.layers,je=0,qe=We;je<qe.length;je++){var mt=qe[je];le(mt)}for(;!Ur(M);)for(var pt=0,st=We;pt<st.length;pt++){var mt=st[pt],dt=T[mt.name];if(dt.name in M){var Dt=M[dt.name];delete M[dt.name];for(var or=0,Xt=Dt;or<Xt.length;or++){var Jt=Xt[or];Y(dt,Jt)}}}for(var vr=[],lr=[],Ir=o.inputLayers,Lr=0,kr=Ir;Lr<kr.length;Lr++){var mt=kr[Lr],Sr=mt[0],fn=mt[1],Xr=mt[2];tt(Sr in T);var dt=T[Sr],$t=dt.inboundNodes[fn].outputTensors;vr.push($t[Xr])}for(var On=o.outputLayers,En=0,kn=On;En<kn.length;En++){var mt=kn[En],Sr=mt[0],fn=mt[1],Xr=mt[2];tt(Sr in T);var dt=T[Sr],$t=dt.inboundNodes[fn].outputTensors;lr.push($t[Xr])}return new r({inputs:vr,outputs:lr,name:Ne})},Object.defineProperty(u.prototype,"stateful",{get:function(){if(this._stateful)throw new w("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(var r=0,o=this.layers;r<o.length;r++){var h=o[r];if(h.stateful)return!0}return!1},enumerable:!0,configurable:!0}),u.prototype.resetStates=function(){var r=this;i.tidy(function(){r.layers.forEach(function(o){o.stateful&&o.resetStates()})})},u}(qr);function A(s,u,r){var o=u.length;if(s==null||Array.isArray(s)&&s.length===0)return u.map(function(b){return null});if(o===1)return Array.isArray(s)&&s.length===1?s:typeof s=="object"&&u[0]in s?[s[u[0]]]:[s];if(Array.isArray(s)){if(s.length!==o)throw new Error("Provided "+r+" is an array of "+s.length+" "+("element(s), but the model has "+o+" outputs. ")+"Make sure a set of weights is provided for each model output.");return s}else if(typeof s=="object"&&Object.keys(s).length>0&&typeof s[Object.keys(s)[0]]=="object"){var h=[];return u.forEach(function(b){b in s?h.push(s[b]):h.push(null)}),h}else throw new Error("The model has multiple ("+o+") outputs, "+("so "+r+" must be either an array with ")+(o+" elements or an object with "+u+" keys. ")+("Provided "+r+" not understood: "+JSON.stringify(s)))}function V(s,u){return A(s,u,"classWeight")}function oe(s,u,r,o){return xe(this,void 0,void 0,function(){var h,b,T,M,q;return Q(this,function(Y){switch(Y.label){case 0:if(u!=null||o!=null)throw new Error("Support sampleWeight is not implemented yet");return r!=null?(h=i.tidy(function(){if(s.shape.length===1)return s.clone();if(s.shape.length===2)if(s.shape[1]>1){var le=1;return s.argMax(le)}else{if(s.shape[1]===1)return s.reshape([s.shape[0]]);throw new Error("Encountered unexpected last-dimension size ("+s.shape[1]+") during handling of class weights. The size is expected to be >= 1.")}else throw new Error("Unexpected rank of target (y) tensor ("+s.rank+") during handling of class weights. The rank is expected to be 1 or 2.")}),M=(T=Array).from,[4,h.data()]):[3,2];case 1:return b=M.apply(T,[Y.sent()]),i.dispose(h),q=[],b.forEach(function(le){if(r[le]==null)throw new Error("classWeight must contain all classes in the training data. "+("The class "+le+" exists in the data but not in ")+"classWeight");q.push(r[le])}),[2,i.tensor1d(q,"float32")];case 2:return[2,null]}})})}function ee(s,u){return i.mul(s,u)}var _e=32;function ce(s,u){var r,o,h=u;r=h.xs,o=h.ys,i.util.assert(r!=null&&o!=null,function(){return"A Dataset iterator for fitDataset() is expected to generate objects of the form `{xs: xVal, ys: yVal}`, where the two values may be `tf.Tensor`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates "+(""+u)});var b=de("input",s.inputNames,r),T=de("output",s.outputNames,o),M=b[0].shape[0];i.util.assert(b.length===s.inputs.length,function(){return"LayersModel has "+s.inputs.length+" inputs, but the dataset "+("provides "+b.length+" inputs. (Expected input keys: ")+(JSON.stringify(s.inputNames)+")")}),i.util.assert(T.length===s.outputs.length,function(){return"LayersModel has "+s.outputs.length+" outputs, but the dataset "+("provides "+T.length+" outputs. (Expected output keys: ")+(JSON.stringify(s.outputNames)+")")});for(var q=function(We){i.util.assert(b[We].shape[0]===M,function(){return"Batch size mismatch: input "+(s.inputNames[We]+" has "+b[We].shape[0]+"; ")+("expected "+M+" based on input "+s.inputNames[0]+".")})},Y=0;Y<b.length;Y++)q(Y);for(var le=function(We){i.util.assert(T[We].shape[0]===M,function(){return"Batch size mismatch: output "+(s.outputNames[We]+" has "+T[We].shape[0]+"; ")+("expected "+M+" based on input "+s.inputNames[0]+".")})},Ne=0;Ne<T.length;Ne++)le(Ne);return{xs:b,ys:T}}function de(s,u,r){if(r instanceof i.Tensor)return[r];if(Array.isArray(r))return i.util.assert(r.length===u.length,function(){return"Received an array of "+r.length+" Tensors, but expected "+u.length+" to match the "+s+" keys "+u+"."}),r;for(var o=[],h=0,b=u;h<b.length;h++){var T=b[h];if(r[T]==null)throw new w("The feature data generated by the dataset lacks the required "+(s+" key '"+T+"'."));o.push(r[T])}return o}function ye(s){if(s.length===3)throw new ge("Validation with sample weights is not implemented yet.");return{xs:s[0],ys:s[1]}}function ve(s,u,r){return xe(this,void 0,void 0,function(){var o,h,b,T,M,q,Y,le,Ne,We,je,qe,mt,pt,st,dt,Dt,or,Xt,Jt,vr,lr,Ir,Lr,kr,Sr,fn,Xr,$t,On,Sr,En,kn,cn,Mn,Sr;return Q(this,function(Hr){switch(Hr.label){case 0:if(o=r.batchesPerEpoch!=null,i.util.assert(s.optimizer!=null,function(){return"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."}),i.util.assert(r!=null,function(){return"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."}),i.util.assert(r.epochs!=null&&r.epochs>0&&Number.isInteger(r.epochs),function(){return"For fitDataset(), config.epochs is expected to be a positive "+("integer, but got "+r.epochs)}),i.util.assert(!o||r.batchesPerEpoch>0&&Number.isInteger(r.batchesPerEpoch),function(){return"For fitDataset(), config.batchesPerEpoch is expected to be a "+("positive integer if specified, but got "+r.batchesPerEpoch)}),i.util.assert(r.validationSplit==null,function(){return"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."}),s.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");s.isTraining=!0,Hr.label=1;case 1:return Hr.trys.push([1,,26,27]),h=r.validationData!=null,b=void 0,T=void 0,h&&(Oe(r.validationData)?i.util.assert(r.validationBatches==null||r.validationBatches>0&&Number.isInteger(r.validationBatches),function(){return"For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, "+("but got "+r.validationBatches)}):(M=ye(r.validationData),b=M.xs,T=M.ys)),q=s.makeTrainFunction(),Y=s.getDedupedMetricsNames(),le=void 0,h?le=Y.slice().concat(Y.map(function(ua){return"val_"+ua})):le=Y.slice(),Ne=io(r.callbacks,r.yieldEvery),We=r.verbose==null?1:r.verbose,je=Pr(Ne,We,r.epochs,null,null,Re(u,r),null,h,le),qe=je.callbackList,mt=je.history,qe.setModel(s),s.history=mt,[4,qe.onTrainBegin()];case 2:return Hr.sent(),s.stopTraining_=!1,pt=r.initialEpoch==null?0:r.initialEpoch,[4,u.iterator()];case 3:st=Hr.sent(),Hr.label=4;case 4:return pt<r.epochs?(dt={},[4,qe.onEpochBegin(pt)]):[3,23];case 5:return Hr.sent(),Dt=0,or=0,o?[3,7]:[4,u.iterator()];case 6:st=Hr.sent(),Hr.label=7;case 7:return(o?Dt<r.batchesPerEpoch:!0)?[4,st.next()]:[3,21];case 8:return Xt=Hr.sent(),o&&Xt.done?(console.warn("You provided `batchesPerEpoch` as "+(r.batchesPerEpoch+", ")+"but your dataset iterator ran out of data after "+(Dt+" batches; ")+"interrupting training. Make sure that your dataset can generate at least `batchesPerEpoch * epochs` batches (in this case, "+(r.batchesPerEpoch*r.epochs+" batches). ")+"You may need to use the repeat() function when building your dataset."),[3,21]):Xt.value!=null?(Jt=ce(s,Xt.value),vr=Jt.xs,lr=Jt.ys,Ir={},Ir.batch=or,Ir.size=vr[0].shape[0],[4,qe.onBatchBegin(or,Ir)]):[3,15];case 9:if(Hr.sent(),Lr=[],!(r.classWeight!=null))return[3,13];kr=V(r.classWeight,s.outputNames),Sr=0,Hr.label=10;case 10:return Sr<kr.length?(Xr=(fn=Lr).push,[4,oe(lr[Sr],null,kr[Sr])]):[3,13];case 11:Xr.apply(fn,[Hr.sent()]),Hr.label=12;case 12:return++Sr,[3,10];case 13:for($t=vr.concat(lr).concat(Lr),On=q($t),i.dispose($t),Sr=0;Sr<Y.length;++Sr)En=Y[Sr],kn=On[Sr],Ir[En]=kn,i.keep(kn);return[4,qe.onBatchEnd(or,Ir)];case 14:Hr.sent(),Pi(Ir),or++,Dt++,Hr.label=15;case 15:return(o?Dt>=r.batchesPerEpoch:Xt.done)?h?(cn=void 0,Oe(r.validationData)?(Mn=Qe,[4,s.evaluateDataset(r.validationData,{batches:r.validationBatches})]):[3,17]):[3,19]:[3,20];case 16:return cn=Mn.apply(void 0,[Hr.sent()]),[3,18];case 17:cn=Qe(s.evaluate(b,T,{batchSize:r.validationBatchSize==null?_e:r.validationBatchSize,verbose:0})),Hr.label=18;case 18:for(Sr=0;Sr<s.metricsNames.length;++Sr)dt["val_"+s.metricsNames[Sr]]=cn[Sr];Hr.label=19;case 19:return[3,21];case 20:return s.stopTraining_?[3,21]:[3,7];case 21:return[4,qe.onEpochEnd(pt,dt)];case 22:return Hr.sent(),pt++,s.stopTraining_?[3,23]:[3,4];case 23:return[4,qe.onTrainEnd()];case 24:return Hr.sent(),[4,s.history.syncData()];case 25:return Hr.sent(),[2,s.history];case 26:return s.isTraining=!1,[7];case 27:return[2]}})})}function Re(s,u){var r=null;return u.batchesPerEpoch!=null?r=u.batchesPerEpoch:Number.isFinite(s.size)&&(r=s.size),r}function Oe(s){return typeof s.iterator=="function"}function Fe(s){return typeof s.next=="function"}function Ve(s,u,r){return xe(this,void 0,void 0,function(){var o,h,b,T,M,q,Y,le,Ne,We,je;return Q(this,function(qe){switch(qe.label){case 0:if(r=r||{},o=r.batches!=null,h=s.testFunction,b=[],r.verbose>0)throw new ge("Verbose mode is not implemented yet.");return i.util.assert(!o||r.batches>0&&Number.isInteger(r.batches),function(){return"Test loop expects `batches` to be a positive integer, but "+("received "+JSON.stringify(r.batches))}),Fe(u)?(M=u,[3,3]):[3,1];case 1:return[4,u.iterator()];case 2:M=qe.sent(),qe.label=3;case 3:T=M,q=0,Y=0,le=function(){var mt;return Q(this,function(pt){switch(pt.label){case 0:return[4,T.next()];case 1:return mt=pt.sent(),b=i.tidy(function(){if(mt.value){var st=ce(s,mt.value),dt=st.xs,Dt=st.ys,or=dt.concat(Dt),Xt=i.tidy(function(){return h(or)});if(i.dispose(or),Y===0)for(var Jt=0;Jt<Xt.length;++Jt)b.push(i.scalar(0));for(var vr=or[0].shape[0],lr=function(Lr){var kr=Xt[Lr],Sr=b[Lr];b[Lr]=i.tidy(function(){return i.add(b[Lr],i.mul(vr,kr))}),Y>0&&i.dispose(Sr)},Jt=0;Jt<Xt.length;++Jt)lr(Jt);i.dispose(Xt),q+=vr,++Y}return b}),mt.done?(o&&console.warn("Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least `batches` "+("batches (in this case, "+r.batches+" batches). ")+"You may need to use the repeat() function when building your dataset."),[2,"break"]):[2]}})},qe.label=4;case 4:return(o?Y<r.batches:!0)?[5,le()]:[3,6];case 5:return Ne=qe.sent(),Ne==="break"?[3,6]:[3,4];case 6:for(We=0;We<b.length;++We)je=b[We],b[We]=i.div(b[We],q),i.dispose(je);return[2,Tt(b)]}})})}function Xe(s){i.util.assert(s>0&&Number.isInteger(s),function(){return"batchSize is required to be a positive integer, but got "+s})}function rt(s,u,r){return s==null?[null]:Array.isArray(s)?s.map(function(o){return Zn(o,u,r-u)}):Zn(s,u,r-u)}function at(s,u){return i.tidy(function(){return s==null?null:Array.isArray(s)?s.map(function(r){return at(r,u)}):X(s,u.dtype==="int32"?u:u.toInt())})}function $(s,u){for(var r=[],o=0,h=null;o<s;)h=o+u,h>=s&&(h=s),r.push([o,h]),o=h;return r}function et(s,u,r,o,h,b,T,M,q,Y,le,Ne,We,je,qe){return xe(this,void 0,void 0,function(){var mt,pt,st,dt,Dt,or,Xt,Jt,vr;return Q(this,function(lr){switch(lr.label){case 0:if(h==null&&(h=32),b==null&&(b=1),le==null&&(le=!0),We==null&&(We=0),mt=!1,q!=null&&Y!=null&&(mt=!0),qe!=null&&(mt=!0,je==null))throw new w("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");return pt=s.checkNumSamples(r,h,je,"steps_per_epoch"),pt!=null&&(st=ln(0,pt)),T==null&&(T=1),dt=Pr(M,T,b,We,pt,je,h,mt,Ne),Dt=dt.callbackList,or=dt.history,Dt.setModel(s),s.history=or,[4,Dt.onTrainBegin()];case 1:lr.sent(),s.stopTraining_=!1,Xt=function(Ir){var Lr,kr,Sr,fn,Xr,$t;return Q(this,function(On){switch(On.label){case 0:return[4,Dt.onEpochBegin(Ir)];case 1:if(On.sent(),Lr={},!(je!=null))return[3,2];throw new ge("stepsPerEpoch mode is not implemented yet.");case 2:if(le==="batch")throw new ge("batch shuffling is not implemneted yet");le&&i.util.shuffle(st),kr=i.tensor1d(st),Sr=$(pt,h),fn=function(En){var kn;return Q(this,function(cn){switch(cn.label){case 0:return kn={},[4,Dt.onBatchBegin(En,kn)];case 1:return cn.sent(),i.tidy(function(){var Mn=Sr[En][0],Hr=Sr[En][1],ua=Zn(kr,Mn,Hr-Mn);kn.batch=En,kn.size=Hr-Mn;for(var Ci=at(r,ua),Ui=u(Ci),Xn=0;Xn<o.length;++Xn){var $i=o[Xn],Vi=Ui[Xn];kn[$i]=Vi,i.keep(Vi)}if(En===Sr.length-1&&mt)for(var Ks=s.testLoop(q,Y,h),Xn=0;Xn<o.length;++Xn){var $i=o[Xn],Vi=Ks[Xn];i.keep(Vi),Lr["val_"+$i]=Vi}}),[4,Dt.onBatchEnd(En,kn)];case 2:return cn.sent(),Pi(kn),s.stopTraining_?[2,"break"]:[2]}})},Xr=0,On.label=3;case 3:return Xr<Sr.length?[5,fn(Xr)]:[3,6];case 4:if($t=On.sent(),$t==="break")return[3,6];On.label=5;case 5:return++Xr,[3,3];case 6:kr.dispose(),On.label=7;case 7:return[4,Dt.onEpochEnd(Ir,Lr)];case 8:return On.sent(),s.stopTraining_?[2,"break"]:[2]}})},Jt=We,lr.label=2;case 2:return Jt<b?[5,Xt(Jt)]:[3,5];case 3:if(vr=lr.sent(),vr==="break")return[3,5];lr.label=4;case 4:return++Jt,[3,2];case 5:return[4,Dt.onTrainEnd()];case 6:return lr.sent(),[4,s.history.syncData()];case 7:return lr.sent(),[2,s.history]}})})}function gt(s,u,r,o){return o===void 0&&(o={}),xe(this,void 0,void 0,function(){var h,b,T,M,q,Y,le,Ne,We,je,qe,mt,pt,st,dt,Dt,or,Xt,Jt,vr,lr,Ir,Lr;return Q(this,function(kr){switch(kr.label){case 0:if(s.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");s.isTraining=!0,kr.label=1;case 1:return kr.trys.push([1,,7,8]),Ne=o.batchSize==null?32:o.batchSize,Xe(Ne),We=!1,[4,s.standardizeUserData(u,r,o.sampleWeight,o.classWeight,We,Ne)];case 2:if(je=kr.sent(),h=je[0],b=je[1],le=je[2],qe=!1,mt=void 0,!(o.validationData!=null&&o.validationData.length>0))return[3,4];if(qe=!0,o.validationData.length===2)T=o.validationData[0],M=o.validationData[1];else throw o.validationData.length===3?new ge("validationData including sample weights is not supported yet."):new w("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+(o.validationData+" is invalid."));return pt=!0,[4,s.standardizeUserData(T,M,null,null,pt,Ne)];case 3:return st=kr.sent(),q=st[0],Y=st[1],mt=q.concat(Y),[3,5];case 4:o.validationSplit!=null&&o.validationSplit>0&&o.validationSplit<1?(qe=!0,dt=Math.floor(h[0].shape[0]*(1-o.validationSplit)),Dt=h[0].shape[0],q=rt(h,dt,Dt),h=rt(h,0,dt),Y=rt(b,dt,Dt),b=rt(b,0,dt),mt=q.concat(Y)):o.validationSteps!=null&&(qe=!0),kr.label=5;case 5:return or=h.concat(b).concat(le),s.checkTrainableWeightsConsistency(),Xt=s.makeTrainFunction(),Jt=s.getDedupedMetricsNames(),vr=void 0,lr=void 0,qe?(s.makeTestFunction(),vr=s.testFunction,lr=Jt.slice().concat(Jt.map(function(Sr){return"val_"+Sr}))):(vr=null,mt=[],lr=Jt.slice()),Ir=io(o.callbacks,o.yieldEvery),[4,et(s,Xt,or,Jt,Ne,o.epochs,o.verbose,Ir,vr,mt,o.shuffle,lr,o.initialEpoch,null,null)];case 6:return Lr=kr.sent(),[2,Lr];case 7:return s.isTraining=!1,_t(h,u),_t(b,r),_t(q,T),_t(Y,M),le!=null&&i.dispose(le),[7];case 8:return[2]}})})}function lt(s){var u=[];s instanceof i.Tensor&&(s=[s]);for(var r=0;r<s.length;++r){var o=s[r];if(o.rank===1)u.push(gr(o,1));else{if(o.rank===0)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");u.push(o)}}return u}function _t(s,u){if(s==null)return;var r=[];if(u instanceof i.Tensor)r.push(u.id);else if(Array.isArray(u))u.forEach(function(q){return r.push(q.id)});else if(u!=null)for(var o in u){var h=u[o];r.push(h.id)}var b=[];if(s instanceof i.Tensor)r.indexOf(s.id)===-1&&b.push(s);else if(Array.isArray(s))s.forEach(function(q){r.indexOf(q.id)===-1&&b.push(q)});else if(s!=null)for(var T in s){var M=s[T];r.indexOf(M.id)===-1&&b.push(M)}b.forEach(function(q){q.isDisposed||q.dispose()})}function At(s){return s instanceof i.Tensor}function Lt(s){return Array.isArray(s)}function Pt(s){return!At(s)&&!Lt(s)}function Ut(s,u,r,o,h){if(o===void 0&&(o=!0),h===void 0&&(h=""),u==null||u.length===0){if(s!=null){var b=!1;if(Lt(s)&&s.length>0)b=!0;else if(Pt(s)){for(var T in s)if(s.hasOwnProperty(T)){b=!0;break}}else b=!0;if(b)throw new w("Error when checking model "+h+" expected no data, "+("but got "+s))}return[]}if(s==null)return u.map(function(pt){return null});var M;if(Pt(s)){s=s,M=[];for(var q=0,Y=u;q<Y.length;q++){var le=Y[q];if(s[le]==null)throw new w('No data provided for "'+le+'". Need data for each key in: '+(""+u));M.push(s[le])}}else if(Lt(s)){if(s=s,s.length!==u.length)throw new w("Error when checking model "+h+": the Array of Tensors that you are passing to your model is not the size the "+("model expected. Expected to see "+u.length+" Tensor(s), but ")+("instead got the following list of Tensor(s): "+s));M=s}else{if(s=s,u.length>1)throw new w("The model "+h+" expects "+u.length+" Tensor(s), "+("but only received one Tensor. Found: Tensor with shape "+s.shape));M=[s]}if(M=lt(M),r!=null)for(var Ne=0;Ne<u.length;++Ne){if(r[Ne]==null)continue;var We=M[Ne];if(We.shape.length!==r[Ne].length)throw new w("Error when checking "+h+": expected "+u[Ne]+" "+("to have "+r[Ne].length+" dimension(s). but got array with ")+("shape "+We.shape));for(var je=0;je<r[Ne].length;++je){if(je===0&&!o)continue;var qe=We.shape[je],mt=r[Ne][je];if(mt!=null&&mt>=0&&qe!==mt)throw new w("Error when checking "+h+": expected "+u[Ne]+" "+("to have shape ["+r[Ne]+"], but got array with shape ")+("["+We.shape+"]."))}}return M}function Nt(s,u,r){var o=qt(s.map(function(b){return b.shape[0]}));o.sort();var h=qt(u.map(function(b){return b.shape[0]}));if(h.sort(),o.length>1)throw new w("All input Tensors (x) should have the same number of samples. Got array shapes: "+(""+JSON.stringify(s.map(function(b){return b.shape}))));if(h.length>1)throw new w("All target Tensors (y) should have the same number of samples. Got array shapes: "+(""+JSON.stringify(u.map(function(b){return b.shape}))));if(o.length>0&&h.length>0&&!i.util.arraysEqual(o,h))throw new w("Input Tensors should have the same number of samples as target "+("Tensors. Found "+o[0]+" input sample(s) and "+h[0]+" target ")+"sample(s).")}function Kt(s,u,r){for(var o=[Qn,Eo,go],h=0;h<s.length;++h){var b=s[h],T=u[h],M=r[h];if(T==null)continue;if(T===go&&b.shape[b.shape.length-1]===1)throw new w("You are passing a target array of shape "+b.shape+" while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].");if(o.indexOf(T)!==-1)for(var q=b.shape.slice(1),Y=M.slice(1),le=0;le<q.length;++le){var Ne=q[le],We=Y[le];if(We!=null&&Ne!==We)throw new w("A target Tensor with shape "+b.shape+" was passed for an "+("output of shape "+M+", while using a loss function that ")+"expects targets to have the same shape as the output.")}}}function Ht(s,u,r,o,h){o===void 0&&(o=!0),h===void 0&&(h="");var b;if(Array.isArray(s)){if(s.length!==u.length)throw new w("Error when checking model "+h+": the Array of Tensors that you are passing to your model is not the size the "+("the model expected. Expected to see "+u.length+" Tensor(s),")+(" but instead got "+s.length+" Tensors(s)."));b=s}else{if(u.length>1)throw new w("The model expects "+u.length+" "+h+" Tensors, but only received one Tensor. Found: array with shape "+(JSON.stringify(s.shape)+"."));b=[s]}if(r!=null)for(var T=0;T<u.length;++T){if(r[T]==null)continue;var M=b[T];if(M.shape.length!==r[T].length)throw new w("Error when checking "+h+": expected "+u[T]+" "+("to have "+r[T].length+" dimension(s), but got array with ")+("shape "+JSON.stringify(M.shape)));for(var q=0;q<r[T].length;++q){if(q===0&&!o)continue;var Y=M.shape[q],le=r[T][q];if(le!=null&&le!==Y)throw new w("Error when checking "+h+": expected "+(u[T]+" to have shape "+JSON.stringify(r[T])+" but ")+("got array with shape "+JSON.stringify(M.shape)+"."))}}}function Ot(s,u){if(s==null||Array.isArray(s)&&s.length===0)return u.map(function(q){return[]});var r;if(typeof s=="string"||typeof s=="function")r=[s];else if(Array.isArray(s)||typeof s=="object")r=s;else throw new TypeError("Type of metrics argument not understood. Expected an string,"+("function, Array, or Object, found: "+s));if(Array.isArray(r))return u.map(function(q){return r});for(var o=[],h=0,b=u;h<b.length;h++){var T=b[h],M=r.hasOwnProperty(T)?r[T]:[];Array.isArray(M)||(M=[M]),o.push(M)}return o}var Rt="layers-model",wt=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.isTraining=!1,o}return u.prototype.summary=function(r,o,h){if(h===void 0&&(h=console.log),!this.built)throw new w("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");Bs(this,r,o,h)},u.prototype.compile=function(r){var o=this;if(r.loss==null&&(r.loss=[]),this.loss=r.loss,typeof r.optimizer=="string")this.optimizer_=Ps(r.optimizer),this.isOptimizerOwned=!0;else{if(!(r.optimizer instanceof i.Optimizer))throw new w("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=r.optimizer,this.isOptimizerOwned=!1}var h=[];if(!Array.isArray(r.loss)&&typeof r.loss!="string"&&typeof r.loss!="function"){r.loss=r.loss;for(var b in r.loss)if(this.outputNames.indexOf(b)===-1)throw new w('Unknown entry in loss dictionary: "'+b+'". '+("Only expected the following keys: "+this.outputNames));for(var T=0,M=this.outputNames;T<M.length;T++){var q=M[T];r.loss[q]==null&&console.warn('Output "'+q+'" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data '+("to be passed to "+q+" during training")),h.push(Yo(r.loss[q]))}}else if(Array.isArray(r.loss)){if(r.loss.length!==this.outputs.length)throw new w("When passing an Array as loss, it should have one entry per "+("model output. The model has "+this.outputs.length+" output(s), ")+("but you passed loss="+r.loss+"."));var Y=r.loss;h=Y.map(function(st){return Yo(st)})}else{var le=Yo(r.loss);this.outputs.forEach(function(st){h.push(le)})}this.lossFunctions=h,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(var Ne=0;Ne<this.outputs.length;++Ne){var We=this.internalOutputShapes[Ne],je=this.outputNames[Ne];this.feedOutputNames.push(je),this.feedOutputShapes.push(We),this.feedLossFns.push(this.lossFunctions[Ne])}var qe=[];this.metrics=r.metrics,this.metricsNames=["loss"],this.metricsTensors=[],_a("loss",function(){for(var st=0;st<o.outputs.length;++st){if(qe.indexOf(st)!==-1)continue;var dt=o.lossFunctions[st];o.outputs.length>1&&(o.metricsTensors.push([dt,st]),o.metricsNames.push(o.outputNames[st]+"_loss"))}});var mt=Ot(r.metrics,this.outputNames),pt=function(st,dt,Dt){o.outputNames.length>1&&(dt=o.outputNames[st]+"_"+dt),o.metricsNames.push(dt),o.metricsTensors.push([Dt,st])};_a("metric",function(){for(var st=function(Dt){if(qe.indexOf(Dt)!==-1)return"continue";var or=mt[Dt],Xt=function(Jt){for(var vr="",lr,Ir,Lr,kr=function($t){if(typeof $t=="string"&&["accuracy","acc","crossentropy","ce"].indexOf($t)!==-1){var On=o.internalOutputShapes[Dt];On[On.length-1]===1||o.lossFunctions[Dt]===Eo?["accuracy","acc"].indexOf($t)!==-1?Ir=Ao:["crossentropy","ce"].indexOf($t)!==-1&&(Ir=Os):o.lossFunctions[Dt]===To?["accuracy","acc"].indexOf($t)!==-1?Ir=ds:["crossentropy","ce"].indexOf($t)!==-1&&(Ir=Zo):["accuracy","acc"].indexOf($t)!==-1?Ir=Qo:["crossentropy","ce"].indexOf($t)!==-1&&(Ir=Do);var En=void 0;["accuracy","acc"].indexOf($t)!==-1?En="acc":["crossentropy","ce"].indexOf($t)!==-1&&(En="ce"),Lr=Ir,lr=vr+En}else{var kn=ys($t);Lr=kn,lr=vr+Fo($t)}var cn;_a(lr,function(){cn=Lr}),pt(Dt,lr,cn)},Sr=0,fn=Jt;Sr<fn.length;Sr++){var Xr=fn[Sr];kr(Xr)}};Xt(or)},dt=0;dt<o.outputs.length;++dt)st(dt)}),this.collectedTrainableWeights=this.trainableWeights},u.prototype.checkTrainableWeightsConsistency=function(){if(this.collectedTrainableWeights==null)return;this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")},u.prototype.evaluate=function(r,o,h){h===void 0&&(h={});var b=h.batchSize==null?32:h.batchSize;Xe(b);var T=!0,M=this.standardizeUserDataXY(r,o,T,b);try{var q=M[0].concat(M[1]);this.makeTestFunction();var Y=this.testFunction,le=this.testLoop(Y,q,b,h.verbose,h.steps);return Tt(le)}finally{_t(M[0],r),_t(M[1],o)}},u.prototype.evaluateDataset=function(r,o){return xe(this,void 0,void 0,function(){return Q(this,function(h){return this.makeTestFunction(),[2,Ve(this,r,o)]})})},u.prototype.checkNumSamples=function(r,o,h,b){b===void 0&&(b="steps");var T;if(h!=null){if(T=null,o!=null)throw new w("If "+b+" is set, batchSize must be null or undefined."+("Got batchSize = "+o))}else if(r!=null)Array.isArray(r)?T=r[0].shape[0]:T=r.shape[0];else throw new w("Either the input data should have a defined shape, or "+(b+" shoud be specified."));return T},u.prototype.execute=function(r,o){if(Array.isArray(o)&&o.length===0)throw new w("`outputs` is an empty Array, which is not allowed.");var h=Array.isArray(o),b=h?o:[o],T=this.retrieveSymbolicTensors(b),M=new Si;if(r instanceof i.Tensor&&(r=[r]),Array.isArray(r)){if(r.length!==this.inputs.length)throw new w("The number of inputs provided ("+r.length+") does not match the number of inputs of this model "+("("+this.inputs.length+")."));for(var q=0;q<this.inputs.length;++q)M.add(this.inputs[q],r[q])}else for(var Y=0,le=this.inputs;Y<le.length;Y++){var Ne=le[Y],We=r[Ne.name];if(We==null)throw new w("No value is provided for the model's input "+Ne.name);M.add(Ne,We)}var je=Xi(T,M);return h?je:je[0]},u.prototype.retrieveSymbolicTensors=function(r){for(var o=nt(null,r.length),h=r.length,b=0,T=this.layers;b<T.length;b++){for(var M=T[b],q=Array.isArray(M.output)?M.output:[M.output],Y=q.map(function(je){return je.name}),le=0;le<r.length;++le){var Ne=Y.indexOf(r[le]);if(Ne!==-1&&(o[le]=q[Ne],h--),h===0)break}if(h===0)break}if(h>0){var We=[];throw o.forEach(function(je,qe){je==null&&We.push(r[qe])}),new w("Cannot find SymbolicTensors for output name(s): "+(""+JSON.stringify(We)))}return o},u.prototype.predictLoop=function(r,o,h){var b=this;return o===void 0&&(o=32),h===void 0&&(h=!1),i.tidy(function(){var T=b.checkNumSamples(r);if(h)throw new ge("Verbose predictLoop() is not implemented yet.");for(var M=$(T,o),q=b.outputs.map(function(Ne){return[]}),Y=function(Ne){var We=i.tidy(function(){var je=M[Ne][0],qe=M[Ne][1],mt=rt(r,je,qe),pt=[];if(Array.isArray(mt))for(var st=0;st<mt.length;++st)pt.push({key:b.inputs[st],value:mt[st]});else pt.push({key:b.inputs[0],value:mt});var dt=new Si(pt);return Xi(b.outputs,dt)});We.forEach(function(je,qe){return q[qe].push(je)})},le=0;le<M.length;++le)Y(le);return Tt(q.map(function(Ne){return i.concat(Ne,0)}))})},u.prototype.predict=function(r,o){o===void 0&&(o={});var h=lt(r);Ht(h,this.inputNames,this.feedInputShapes,!1);try{var b=o.batchSize==null?32:o.batchSize;return Xe(b),this.predictLoop(h,b)}finally{_t(h,r)}},u.prototype.predictOnBatch=function(r){Ht(r,this.inputNames,this.feedInputShapes,!0);var o=(Array.isArray(r)?r[0]:r).shape[0];return this.predictLoop(r,o)},u.prototype.standardizeUserDataXY=function(r,o,h,b){if(this.optimizer_==null)throw new ae("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");for(var T=[],M=0;M<this.feedOutputShapes.length;++M){var q=this.feedOutputShapes[M],Y=this.feedLossFns[M];Y===To?T.push(q.slice(0,q.length-1).concat([1])):T.push(q)}if(r=Ut(r,this.feedInputNames,this.feedInputShapes,!1,"input"),o=Ut(o,this.feedOutputNames,T,!1,"target"),Nt(r,o),Kt(o,this.feedLossFns,this.feedOutputShapes),this.stateful&&b!=null&&b>0&&r[0].shape[0]%b!==0)throw new w("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+(b+". Found: "+r[0].shape[0]+" sample(s)."));return[r,o]},u.prototype.standardizeUserData=function(r,o,h,b,T,M){return T===void 0&&(T=!0),xe(this,void 0,void 0,function(){var q,Y,le,Ne,We,je,qe,mt;return Q(this,function(pt){switch(pt.label){case 0:if(q=this.standardizeUserDataXY(r,o,T,M),Y=q[0],le=q[1],h!=null)throw new Error("sample weight is not supported yet.");if(Ne=null,!(b!=null))return[3,4];We=V(b,this.outputNames),Ne=[],je=0,pt.label=1;case 1:return je<We.length?(mt=(qe=Ne).push,[4,oe(le[je],null,We[je])]):[3,4];case 2:mt.apply(qe,[pt.sent()]),pt.label=3;case 3:return++je,[3,1];case 4:return[2,[Y,le,Ne]]}})})},u.prototype.testLoop=function(r,o,h,b,T){var M=this;return b===void 0&&(b=0),i.tidy(function(){var q=M.checkNumSamples(o,h,T,"steps"),Y=[];if(b>0)throw new ge("Verbose mode is not implemented yet.");if(T!=null)throw new ge("steps mode in testLoop() is not implemented yet");for(var le=$(q,h),Ne=i.tensor1d(ln(0,q)),We=0;We<le.length;++We){var je=le[We][0],qe=le[We][1],mt=Zn(Ne,je,qe-je),pt=at(o,mt),st=r(pt);if(We===0)for(var dt=0;dt<st.length;++dt)Y.push(i.scalar(0));for(var dt=0;dt<st.length;++dt){var Dt=st[dt];Y[dt]=i.add(Y[dt],i.mul(qe-je,Dt))}}for(var dt=0;dt<Y.length;++dt)Y[dt]=i.div(Y[dt],q);return Y})},u.prototype.getDedupedMetricsNames=function(){for(var r=this.metricsNames,o=[],h=0;h<r.length;++h){var b=r[h],T=b;if(nr(r,b)>1){var M=nr(r.slice(0,h),b);T+="_"+M}o.push(T)}return o},u.prototype.makeTrainFunction=function(){var r=this;return function(o){var h=[],b=o.slice(0,r.inputs.length),T=o.slice(r.inputs.length,r.inputs.length+r.outputs.length),M=o.slice(r.inputs.length+r.outputs.length,r.inputs.length+r.outputs.length*2),q=[],Y=function(){for(var je=[],qe=0;qe<r.inputs.length;++qe)je.push({key:r.inputs[qe],value:b[qe]});for(var mt=new Si(je),pt=Xi(r.outputs,mt,{training:!0}),st,qe=0;qe<r.lossFunctions.length;++qe){var dt=r.lossFunctions[qe],Dt=dt(T[qe],pt[qe]);M[qe]!=null&&(Dt=ee(Dt,M[qe]));var or=i.mean(Dt);h.push(or),qe===0?st=Dt:st=i.add(st,Dt)}for(var qe=0;qe<r.metricsTensors.length;++qe){var Xt=void 0;if(r.outputs.length>1&&qe<r.outputs.length)Xt=h[qe];else{var Jt=r.metricsTensors[qe][0],vr=r.metricsTensors[qe][1];Xt=i.mean(Jt(T[vr],pt[vr]))}i.keep(Xt),q.push(Xt)}return st=i.mean(st),r.calculateLosses().forEach(function(lr){st=i.add(st,lr)}),st},le=r.collectedTrainableWeights.map(function(je){return je.read()}),Ne=!0,We=r.optimizer_.minimize(Y,Ne,le);return[We].concat(q)}},u.prototype.makeTestFunction=function(){var r=this;this.testFunction=function(o){return i.tidy(function(){for(var h=[],b,T=o.slice(0,r.inputs.length),M=o.slice(r.inputs.length,r.inputs.length+r.outputs.length),q=[],Y=0;Y<r.inputs.length;++Y)q.push({key:r.inputs[Y],value:T[Y]});for(var le=new Si(q),Ne=Xi(r.outputs,le),Y=0;Y<r.lossFunctions.length;++Y){var We=r.lossFunctions[Y],je=i.mean(We(M[Y],Ne[Y]));Y===0?b=je:b=i.add(b,je),h.push(b)}for(var Y=0;Y<r.metricsTensors.length;++Y){var qe=r.metricsTensors[Y][0],mt=r.metricsTensors[Y][1],pt=i.mean(qe(M[mt],Ne[mt]));h.push(pt)}return h})}},u.prototype.fit=function(r,o,h){return h===void 0&&(h={}),xe(this,void 0,void 0,function(){return Q(this,function(b){return[2,gt(this,r,o,h)]})})},u.prototype.fitDataset=function(r,o){return xe(this,void 0,void 0,function(){return Q(this,function(h){return[2,ve(this,r,o)]})})},u.prototype.trainOnBatch=function(r,o){return xe(this,void 0,void 0,function(){var h,b,T,M,q,Y,le,Ne,We,je;return Q(this,function(qe){switch(qe.label){case 0:return[4,this.standardizeUserData(r,o)];case 1:h=qe.sent(),b=h[0],T=h[1],M=this.makeTrainFunction(),q=M(b.concat(T)),Y=[],le=0,Ne=q,qe.label=2;case 2:return le<Ne.length?(We=Ne[le],[4,We.data()]):[3,5];case 3:je=qe.sent(),Y.push(je[0]),qe.label=4;case 4:return le++,[3,2];case 5:return i.dispose(q),[2,Tt(Y)]}})})},u.prototype.getNamedWeights=function(r){for(var o=[],h=r!=null&&r.trainableOnly,b=h?this.trainableWeights:this.weights,T=this.getWeights(h),M=0;M<b.length;++M){if(h&&!b[M].trainable)continue;o.push({name:b[M].originalName,tensor:T[M]})}return o},Object.defineProperty(u.prototype,"stopTraining",{get:function(){return this.stopTraining_},set:function(r){this.stopTraining_=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"optimizer",{get:function(){return this.optimizer_},set:function(r){this.optimizer_!==r&&(this.optimizer_=r,this.isOptimizerOwned=!1)},enumerable:!0,configurable:!0}),u.prototype.dispose=function(){var r=s.prototype.dispose.call(this);if(r.refCountAfterDispose===0&&this.optimizer!=null&&this.isOptimizerOwned){var o=i.memory().numTensors;this.optimizer_.dispose(),r.numDisposedVariables+=o-i.memory().numTensors}return r},u.prototype.getLossIdentifiers=function(){var r;if(typeof this.loss=="string")r=it(this.loss);else if(Array.isArray(this.loss)){for(var o=0,h=this.loss;o<h.length;o++){var b=h[o];if(typeof b!="string")throw new Error("Serialization of non-string loss is not supported.")}r=this.loss.map(function(Ne){return it(Ne)})}else{var T=Object.keys(this.loss);r={};for(var M=this.loss,q=0,Y=T;q<Y.length;q++){var le=Y[q];if(typeof M[le]=="string")r[le]=it(M[le]);else throw new Error("Serialization of non-string loss is not supported.")}}return r},u.prototype.getMetricIdentifiers=function(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[it(Fo(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(function(h){return it(Fo(h))});var r={};for(var o in this.metrics)r[o]=it(Fo(this.metrics[o]));return r},u.prototype.getTrainingConfig=function(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}},u.prototype.loadTrainingConfig=function(r){if(r.weighted_metrics!=null)throw new Error("Loading weight_metrics is not supported yet.");if(r.loss_weights!=null)throw new Error("Loading loss_weights is not supported yet.");if(r.sample_weight_mode!=null)throw new Error("Loading sample_weight_mode is not supported yet.");var o=Oo(r.optimizer_config),h=oa(o),b;if(typeof r.loss=="string")b=xt(r.loss);else if(Array.isArray(r.loss))b=r.loss.map(function(q){return xt(q)});else if(r.loss!=null){b={};for(var T in r.loss)b[T]=xt(r.loss[T])}var M;if(Array.isArray(r.metrics))M=r.metrics.map(function(q){return xt(q)});else if(r.metrics!=null){M={};for(var T in r.metrics)M[T]=xt(r.metrics[T])}this.compile({loss:b,metrics:M,optimizer:h})},u.prototype.save=function(r,o){return xe(this,void 0,void 0,function(){var h,b,T,M,q,Y,le,Ne,We,je,qe,mt,pt,st,dt;return Q(this,function(Dt){switch(Dt.label){case 0:if(typeof r=="string"){if(h=i.io.getSaveHandlers(r),h.length===0)throw new w("Cannot find any save handlers for URL '"+r+"'");if(h.length>1)throw new w("Found more than one ("+h.length+") save handlers for "+("URL '"+r+"'"));r=h[0]}if(r.save==null)throw new w("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return[4,i.io.encodeWeights(this.getNamedWeights(o))];case 1:return b=Dt.sent(),T=!1,M=null,q=this.toJSON(M,T),Y={modelTopology:q,format:Rt,generatedBy:"TensorFlow.js tfjs-layers v"+gs,convertedBy:null},le=o==null?!1:o.includeOptimizer,le&&this.optimizer!=null?(Y.trainingConfig=this.getTrainingConfig(),Ne="optimizer",pt=(mt=i.io).encodeWeights,[4,this.optimizer.getWeights()]):[3,4];case 2:return[4,pt.apply(mt,[Dt.sent(),Ne])];case 3:We=Dt.sent(),je=We.data,qe=We.specs,(dt=b.specs).push.apply(dt,qe),b.data=i.io.concatenateArrayBuffers([b.data,je]),Dt.label=4;case 4:return this.userDefinedMetadata!=null&&(st=!0,_o(this.userDefinedMetadata,this.name,st),Y.userDefinedMetadata=this.userDefinedMetadata),Y.weightData=b.data,Y.weightSpecs=b.specs,[2,r.save(Y)]}})})},u.prototype.setUserDefinedMetadata=function(r){_o(r,this.name),this.userDefinedMetadata=r},u.prototype.getUserDefinedMetadata=function(){return this.userDefinedMetadata},u.className="Model",u}(F);i.serialization.registerClass(wt);var Et=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.className="Functional",u}(wt);i.serialization.registerClass(Et);function Vt(s,u){return xe(this,void 0,void 0,function(){var r,o,h,b,T,M,q,Y;return Q(this,function(le){switch(le.label){case 0:return"modelTopology"in s||(s={modelTopology:s}),s=s,r=s.modelTopology,r.model_config!=null&&(r=r.model_config),o=Oo(r),h=oa(o,u),s.weightsManifest!=null?[4,i.io.loadWeights(s.weightsManifest,s.pathPrefix,h.weights.map(function(Ne){return Ne.originalName}))]:[3,2];case 1:for(b=le.sent(),T={},M=0,q=h.weights;M<q.length;M++)Y=q[M],T[Y.originalName]=b[Y.originalName];h.loadWeights(T),i.dispose(b),le.label=2;case 2:return[2,h]}})})}function jt(s,u){return xe(this,void 0,void 0,function(){var r;return Q(this,function(o){if(u==null&&(u={}),typeof s=="string"){if(r=i.io.getLoadHandlers(s,u),r.length===0)r.push(i.io.browserHTTPRequest(s,u));else if(r.length>1)throw new w("Found more than one ("+r.length+") load handlers for "+("URL '"+s+"'"));s=r[0]}return[2,cr(s,void 0,u)]})})}function cr(s,u,r){return xe(this,void 0,void 0,function(){var o,h,b,T,M,q,Y,le,Ne;return Q(this,function(We){switch(We.label){case 0:if(r==null&&(r={}),s.load==null)throw new w("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");return[4,s.load()];case 1:if(o=We.sent(),h=o.modelTopology,h.model_config!=null&&(h=h.model_config),b=r.strict==null?!0:r.strict,T=o.weightData!=null&&o.weightSpecs!=null&&b,M=oa(Oo(h),u,T),q=o.trainingConfig,q!=null&&M.loadTrainingConfig(q),o.userDefinedMetadata!=null&&M.setUserDefinedMetadata(o.userDefinedMetadata),!(o.weightData!=null))return[3,4];if(o.weightSpecs==null)throw new w("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");return Y=rr(o.weightData,o.weightSpecs),le=Y.modelWeights,Ne=Y.optimizerWeights,M.loadWeights(le,b),M.optimizer!=null&&Ne.length>0?[4,M.optimizer.setWeights(Ne)]:[3,3];case 2:We.sent(),We.label=3;case 3:i.dispose(le),i.dispose(Ne.map(function(je){return je.tensor})),We.label=4;case 4:return[2,M]}})})}function rr(s,u){var r=i.io.decodeWeights(s,u),o={},h=[];return u.forEach(function(b){b.group==="optimizer"?h.push({name:b.name,tensor:r[b.name]}):o[b.name]=r[b.name]}),{modelWeights:o,optimizerWeights:h}}var Ie=function(s){O(u,s);function u(r){var o=s.call(this,{inputs:[],outputs:[]})||this;if(r=r||{},o.trainable=!0,o.built=!1,o.name=r.name!=null?r.name:Fr("sequential_"),r.layers!=null)for(var h=0,b=r.layers;h<b.length;h++){var T=b[h];o.add(T)}return o}return u.prototype.checkShape=function(r){var o=r.inboundNodes[0].outputTensors[0].shape;if(o.some(function(h){return h<0}))throw new w("Negative dimension size caused by adding layer "+(r.name+" with input shape [")+(r.inboundNodes[0].inputTensors[0].shape+"]"))},u.prototype.add=function(r){var o=r instanceof u||r instanceof wt,h;if(o){if(h=r,h.outputs.length!==1)throw new w("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(h.inputs.length!==1)throw new w("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(this.outputs.length===0){if(r.inboundNodes.length===0){if(r.batchInputShape==null)throw new w("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");var b=Ki({batchShape:r.batchInputShape,dtype:r.dtype,name:r.name+"_input"});r.apply(b)}if(o)this.outputs=h.outputs,this.inputs=h.inputs;else{if(r.inboundNodes.length!==1)throw new w("A layer added to a Sequential model must not already be "+("connected somewhere else. LayersModel received layer "+r.name+" ")+("which has "+r.inboundNodes.length+" pre-existing inbound ")+"connections.");if(r.inboundNodes[0].outputTensors.length!==1)throw new w("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(r),this.outputs=[r.inboundNodes[0].outputTensors[0]],this.inputs=qa(this.outputs[0])}this.inboundNodes=[],new yi({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:nt(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(function(M){return M.shape}),outputShapes:this.outputs[0].shape})}else{var T=r.apply(this.outputs[0]);if(Array.isArray(T))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(r),this.outputs=[T],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(r),this.built=!1},u.prototype.pop=function(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{var r=this.layers.length-1;this.layers[r].outboundNodes=[],this.outputs=[this.layers[r].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}},u.prototype.call=function(r,o){return this.model==null&&this.build(),this.model.call(r,o)},u.prototype.build=function(r){if($r(r),this.inputs.length===0||this.outputs.length===0)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new wt({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0},u.prototype.countParams=function(){return this.built||this.build(),s.prototype.countParams.call(this)},u.prototype.summary=function(r,o,h){h===void 0&&(h=console.log),this.built||this.build(),s.prototype.summary.call(this,r,o,h)},u.prototype.setWeights=function(r){this.model==null&&this.build(),this.model.setWeights(r)},u.prototype.evaluate=function(r,o,h){if(h===void 0&&(h={}),!this.built)throw new ae("The model needs to be compiled before being used.");return this.model.evaluate(r,o,h)},u.prototype.evaluateDataset=function(r,o){return xe(this,void 0,void 0,function(){return Q(this,function(h){if(!this.built)throw new ae("The model needs to be compiled before being used.");return[2,this.model.evaluateDataset(r,o)]})})},u.prototype.predict=function(r,o){return o===void 0&&(o={}),this.model==null&&this.build(),this.model.predict(r,o)},u.prototype.predictOnBatch=function(r){return this.model==null&&this.build(),this.model.predictOnBatch(r)},u.prototype.compile=function(r){this.build(),this.model.compile(r),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames},Object.defineProperty(u.prototype,"optimizer",{get:function(){return this.model==null?void 0:this.model.optimizer},set:function(r){this.model.optimizer=r},enumerable:!0,configurable:!0}),u.prototype.fit=function(r,o,h){return h===void 0&&(h={}),xe(this,void 0,void 0,function(){return Q(this,function(b){if(!this.built)throw new ae("The model needs to be compiled before being used.");return[2,this.model.fit(r,o,h)]})})},u.prototype.fitDataset=function(r,o){return xe(this,void 0,void 0,function(){return Q(this,function(h){if(!this.built)throw new ae("The model needs to be compiled before being used.");return[2,this.model.fitDataset(r,o)]})})},u.prototype.trainOnBatch=function(r,o){return xe(this,void 0,void 0,function(){return Q(this,function(h){return[2,this.model.trainOnBatch(r,o)]})})},u.fromConfig=function(r,o,h,b){b===void 0&&(b=!1);var T,M={};if(o instanceof Array){if(!(o[0].className!=null)||o[0].className==="Merge")throw new w("Legacy serialization format not supported yet.");T=o}else i.util.assert(o.layers!=null,function(){return"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."}),T=o.layers,delete o.layers,M=o;var q=new r(M);if(!(q instanceof u))throw new ge("Sequential.fromConfig called on non-Sequential input: "+q);for(var Y=0,le=T;Y<le.length;Y++){var Ne=le[Y],We=void 0,je=oa(Ne,We,b);b&&je.setFastWeightInitDuringBuild(!0),q.add(je)}return q},Object.defineProperty(u.prototype,"stopTraining",{get:function(){if(this.model==null)throw new w("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining},set:function(r){if(this.model==null)throw new w("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=r},enumerable:!0,configurable:!0}),u.prototype.getConfig=function(){for(var r=[],o=0,h=this.layers;o<h.length;o++){var b=h[o],T={};T.className=b.getClassName(),T.config=b.getConfig(),r.push(T)}return{name:this.name,layers:r}},u.className="Sequential",u}(wt);i.serialization.registerClass(Ie);function br(s){return new wt(s)}function Nr(s){return new Ie(s)}function Tr(s,u){return u==null&&(u={}),jt(s,u)}function hr(s){return Ki(s)}function Dr(s,u){ia.registerCallbackConstructor(s,u)}var fr=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.getConfig=function(){return{}},u}(i.serialization.Serializable),Er=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r,o){return o===void 0&&(o=1),Ue(r,o)},u.className="elu",u}(fr);i.serialization.registerClass(Er);var an=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return i.selu(r)},u.className="selu",u}(fr);i.serialization.registerClass(an);var wn=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return i.relu(r)},u.className="relu",u}(fr);i.serialization.registerClass(wn);var ie=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return i.tidy(function(){return i.minimum(6,i.relu(r))})},u.className="relu6",u}(fr);i.serialization.registerClass(ie);var Nn=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return r},u.className="linear",u}(fr);i.serialization.registerClass(Nn);var bn=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return i.sigmoid(r)},u.className="sigmoid",u}(fr);i.serialization.registerClass(bn);var Ee=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return Le(r)},u.className="hardSigmoid",u}(fr);i.serialization.registerClass(Ee);var Bn=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return i.softplus(r)},u.className="softplus",u}(fr);i.serialization.registerClass(Bn);var Pn=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return kt(r)},u.className="softsign",u}(fr);i.serialization.registerClass(Pn);var Da=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return i.tanh(r)},u.className="tanh",u}(fr);i.serialization.registerClass(Da);var Dn=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r,o){return o===void 0&&(o=-1),i.softmax(r,o)},u.className="softmax",u}(fr);i.serialization.registerClass(Dn);var Ya=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r,o){return o===void 0&&(o=-1),i.logSoftmax(r,o)},u.className="logSoftmax",u}(fr);i.serialization.registerClass(Ya);var za=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r,o){return o===void 0&&(o=1),i.tidy(function(){return i.sigmoid(r.mul(o)).mul(r)})},u.className="swish",u}(fr);i.serialization.registerClass(za);function Qa(s){return s.getClassName()}function ya(s,u){return u===void 0&&(u={}),yt(s,i.serialization.SerializationMap.getMap().classNameMap,u,"activation")}function va(s){if(s==null){var u={};return u.className="linear",u.config={},ya(u)}if(typeof s=="string"){var u={};return u.className=s,u.config={},ya(u)}else return s instanceof fr?s:ya(s)}function Yi(s){if(s!=null&&typeof s!="object")throw new Error("Argument to L1L2 regularizer's constructor is expected to be an "+("object, but received: "+s))}var Wi=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u}(i.serialization.Serializable),Or=function(s){O(u,s);function u(r){var o=s.call(this)||this;return Yi(r),o.l1=r==null||r.l1==null?.01:r.l1,o.l2=r==null||r.l2==null?.01:r.l2,o.hasL1=o.l1!==0,o.hasL2=o.l2!==0,o}return u.prototype.apply=function(r){var o=this;return i.tidy(function(){var h=i.zeros([1]);return o.hasL1&&(h=i.add(h,i.sum(i.mul(o.l1,i.abs(r))))),o.hasL2&&(h=i.add(h,i.sum(i.mul(o.l2,j(r))))),h.asScalar()})},u.prototype.getConfig=function(){return{l1:this.l1,l2:this.l2}},u.fromConfig=function(r,o){return new r({l1:o.l1,l2:o.l2})},u.className="L1L2",u}(Wi);i.serialization.registerClass(Or);function Za(s){return Yi(s),new Or({l1:s!=null?s.l1:null,l2:0})}function rs(s){return Yi(s),new Or({l2:s!=null?s.l2:null,l1:0})}var Po={l1l2:"L1L2"};function dn(s){return ht(s)}function Bo(s,u){return u===void 0&&(u={}),yt(s,i.serialization.SerializationMap.getMap().classNameMap,u,"regularizer")}function Fn(s){if(s==null)return null;if(typeof s=="string"){var u=s in Po?Po[s]:s,r={className:u,config:{}};return Bo(r)}else return s instanceof Wi?s:Bo(s)}var su=function(s){O(u,s);function u(r){var o=s.call(this,r??{})||this;return o.supportsMasking=!0,r!=null&&(o.maxValue=r.maxValue),o}return u.prototype.call=function(r,o){r=ur(r);var h=i.relu(r);return this.maxValue!=null&&(h=i.clipByValue(h,0,this.maxValue)),h},u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r={maxValue:this.maxValue},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="ReLU",u}(qr);i.serialization.registerClass(su);var cc=function(s){O(u,s);function u(r){var o=s.call(this,r??{})||this;return o.DEFAULT_ALPHA=.3,r==null&&(r={}),o.alpha=r.alpha==null?o.DEFAULT_ALPHA:r.alpha,o}return u.prototype.call=function(r,o){var h=ur(r);return i.leakyRelu(h,this.alpha)},u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r={alpha:this.alpha},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="LeakyReLU",u}(qr);i.serialization.registerClass(cc);var si=function(s){O(u,s);function u(r){var o=s.call(this,r??{})||this;if(o.DEFAULT_ALPHA_INITIALIZER="zeros",r==null&&(r={}),o.supportsMasking=!0,o.alphaInitializer=x(r.alphaInitializer||o.DEFAULT_ALPHA_INITIALIZER),o.alphaRegularizer=Fn(r.alphaRegularizer),o.alphaConstraint=xn(r.alphaConstraint),r.sharedAxes==null)o.sharedAxes=null;else if(Array.isArray(r.sharedAxes))o.sharedAxes=r.sharedAxes;else if(typeof r.sharedAxes=="number")o.sharedAxes=[r.sharedAxes];else throw new w("Expected sharedAxes to be a number or an array of numbers, "+("but got "+r.sharedAxes));return o}return u.prototype.build=function(r){r=$r(r);var o=r.slice(1);if(this.sharedAxes!=null)for(var h=0,b=this.sharedAxes;h<b.length;h++){var T=b[h];o[T-1]=1}this.alpha=this.addWeight("alpha",o,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);var M={};if(this.sharedAxes!=null)for(var T=1;T<r.length;++T)M[T]=r[T];this.inputSpec=[new An({ndim:r.length,axes:M})],this.built=!0},u.prototype.call=function(r,o){return r=ur(r),i.prelu(r,this.alpha.read())},u.prototype.getConfig=function(){var r={alphaInitializer:S(this.alphaInitializer),alphaRegularizer:dn(this.alphaRegularizer),alphaConstraint:rn(this.alphaConstraint),sharedAxes:this.sharedAxes},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="PReLU",u}(qr);i.serialization.registerClass(si);var Su=function(s){O(u,s);function u(r){var o=s.call(this,r??{})||this;if(o.DEFAULT_ALPHA=1,r==null&&(r={}),r.alpha!=null&&r.alpha!==o.DEFAULT_ALPHA)throw new ge("Non-default alpha value ("+r.alpha+") is not supported by the ELU layer yet.");return o.alpha=r.alpha==null?o.DEFAULT_ALPHA:r.alpha,o}return u.prototype.call=function(r,o){var h=ur(r);return i.elu(h)},u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r={alpha:this.alpha},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="ELU",u}(qr);i.serialization.registerClass(Su);var Iu=function(s){O(u,s);function u(r){var o=s.call(this,r??{})||this;return o.DEFAULT_THETA=1,r==null&&(r={}),o.theta=r.theta==null?o.DEFAULT_THETA:r.theta,o}return u.prototype.call=function(r,o){var h=ur(r);return h.mul(ni(h.greater(this.theta),"float32"))},u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r={theta:this.theta},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="ThresholdedReLU",u}(qr);i.serialization.registerClass(Iu);var lc=function(s){O(u,s);function u(r){var o=s.call(this,r??{})||this;return o.DEFAULT_AXIS=1,r==null&&(r={}),o.softmax=new Dn().apply,o.axis=r.axis==null?o.DEFAULT_AXIS:r.axis,o}return u.prototype.call=function(r,o){var h=ur(r);return this.softmax(h,this.axis)},u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r={axis:this.axis},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Softmax",u}(qr);i.serialization.registerClass(lc);function xs(s,u,r){if(typeof s=="number")return nt(s,u);if(s.length!==u)throw new w("The "+r+" argument must be an integer or tuple of "+u+" integers."+(" Received: "+s.length+" elements."));for(var o=0;o<u;++o){var h=s[o];if(!pi(h))throw new w("The "+r+" argument must be an integer or tuple of "+u+(" integers. Received: "+JSON.stringify(s)+" including a")+(" non-integer number "+h))}return s}function Ii(s,u,r,o,h){if(h===void 0&&(h=1),s==null)return s;var b=u+(u-1)*(h-1),T;return r==="same"?T=s:T=s-b+1,Math.floor((T+o-1)/o)}function _s(s,u,r,o){if(s==null)return null;if(o==="valid")s=s*u+Va([r-u,0]);else if(o==="same")s=s*u;else throw new w("Unsupport padding mode: "+o+".");return s}function bo(s,u){return i.tidy(function(){return on(u),u==="channelsFirst"?i.transpose(s,[0,2,3,1]):s})}function so(s,u){return i.tidy(function(){return on(u),u==="channelsFirst"?i.transpose(s,[0,2,3,4,1]):s})}function Nu(s,u,r,o,h,b,T){return o===void 0&&(o=1),h===void 0&&(h="valid"),T===void 0&&(T=1),i.tidy(function(){if(b==null&&(b=he()),on(b),s.shape.length!==3)throw new w("The input of a conv1dWithBias operation should be 3, but is "+(s.shape.length+" instead."));if(u.shape.length!==3)throw new w("The kernel for a conv1dWithBias operation should be 3, but is "+(u.shape.length+" instead"));if(r!=null&&r.shape.length!==1)throw new w("The bias for a conv1dWithBias operation should be 1, but is "+(u.shape.length+" instead"));if(b==="channelsFirst"&&(s=i.transpose(s,[0,2,1])),h==="causal")throw new ge("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");var M=i.conv1d(s,u,o,h==="same"?"same":"valid","NWC",T);return r!=null&&(M=te(M,r)),M})}function uu(s,u,r,o,h,b,T,M){return o===void 0&&(o=[1,1]),h===void 0&&(h="valid"),M===void 0&&(M=null),i.tidy(function(){if(b==null&&(b=he()),on(b),s.rank!==3&&s.rank!==4)throw new w("conv2dWithBiasActivation expects input to be of rank 3 or 4, "+("but received "+s.rank+"."));if(u.rank!==3&&u.rank!==4)throw new w("conv2dWithBiasActivation expects kernel to be of rank 3 or 4, "+("but received "+s.rank+"."));var q=bo(s,b);if(h==="causal")throw new ge("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return q=i.fused.conv2d({x:q,filter:u,strides:o,pad:h==="same"?"same":"valid",dilations:T,dataFormat:"NHWC",bias:r,activation:M}),b==="channelsFirst"&&(q=i.transpose(q,[0,3,1,2])),q})}function ws(s,u,r,o,h,b,T){return o===void 0&&(o=[1,1,1]),h===void 0&&(h="valid"),i.tidy(function(){if(b==null&&(b=he()),on(b),s.rank!==4&&s.rank!==5)throw new w("conv3dWithBias expects input to be of rank 4 or 5, but received "+(s.rank+"."));if(u.rank!==4&&u.rank!==5)throw new w("conv3dWithBias expects kernel to be of rank 4 or 5, but received "+(s.rank+"."));var M=so(s,b);if(h==="causal")throw new ge("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return M=i.conv3d(M,u,o,h==="same"?"same":"valid","NDHWC",T),r!=null&&(M=te(M,r)),b==="channelsFirst"&&(M=i.transpose(M,[0,4,1,2,3])),M})}var Cu=function(s){O(u,s);function u(r,o){var h=s.call(this,o)||this;if(h.bias=null,h.DEFAULT_KERNEL_INITIALIZER="glorotNormal",h.DEFAULT_BIAS_INITIALIZER="zeros",u.verifyArgs(o),h.rank=r,tr(h.rank,"rank"),h.rank!==1&&h.rank!==2&&h.rank!==3)throw new ge("Convolution layer for rank other than 1, 2, or 3 ("+h.rank+") is not implemented yet.");if(h.kernelSize=xs(o.kernelSize,r,"kernelSize"),h.strides=xs(o.strides==null?1:o.strides,r,"strides"),h.padding=o.padding==null?"valid":o.padding,_n(h.padding),h.dataFormat=o.dataFormat==null?"channelsLast":o.dataFormat,on(h.dataFormat),h.activation=va(o.activation),h.useBias=o.useBias==null?!0:o.useBias,h.biasInitializer=x(o.biasInitializer||h.DEFAULT_BIAS_INITIALIZER),h.biasConstraint=xn(o.biasConstraint),h.biasRegularizer=Fn(o.biasRegularizer),h.activityRegularizer=Fn(o.activityRegularizer),h.dilationRate=xs(o.dilationRate==null?1:o.dilationRate,r,"dilationRate"),h.rank===1&&Array.isArray(h.dilationRate)&&h.dilationRate.length!==1)throw new w("dilationRate must be a number or an array of a single number for 1D convolution, but received "+(""+JSON.stringify(h.dilationRate)));if(h.rank===2){if(typeof h.dilationRate=="number")h.dilationRate=[h.dilationRate,h.dilationRate];else if(h.dilationRate.length!==2)throw new w("dilationRate must be a number or array of two numbers for 2D "+("convolution, but received "+JSON.stringify(h.dilationRate)))}else if(h.rank===3){if(typeof h.dilationRate=="number")h.dilationRate=[h.dilationRate,h.dilationRate,h.dilationRate];else if(h.dilationRate.length!==3)throw new w("dilationRate must be a number or array of three numbers for 3D "+("convolution, but received "+JSON.stringify(h.dilationRate)))}return h}return u.verifyArgs=function(r){if(tt("kernelSize"in r,"required key 'kernelSize' not in config"),typeof r.kernelSize!="number"&&!_r(r.kernelSize,"number",1,3))throw new w("BaseConv expects config.kernelSize to be number or number[] with "+("length 1, 2, or 3, but received "+JSON.stringify(r.kernelSize)+"."))},u.prototype.getConfig=function(){var r={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:Qa(this.activation),useBias:this.useBias,biasInitializer:S(this.biasInitializer),biasRegularizer:dn(this.biasRegularizer),activityRegularizer:dn(this.activityRegularizer),biasConstraint:rn(this.biasConstraint)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),cu=function(s){O(u,s);function u(r,o){var h=s.call(this,r,o)||this;return h.kernel=null,u.verifyArgs(o),h.filters=o.filters,tr(h.filters,"filters"),h.kernelInitializer=x(o.kernelInitializer||h.DEFAULT_KERNEL_INITIALIZER),h.kernelConstraint=xn(o.kernelConstraint),h.kernelRegularizer=Fn(o.kernelRegularizer),h}return u.prototype.build=function(r){var o;r=$r(r);var h=this.dataFormat==="channelsFirst"?1:r.length-1;if(r[h]==null)throw new w("The channel dimension of the input should be defined. "+("Found "+r[h]));var b=r[h],T=this.kernelSize.concat([b,this.filters]);this.kernel=this.addWeight("kernel",T,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:(o={},o[h]=b,o)}],this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){r=ur(r);var b,T=h.bias==null?null:h.bias.read(),M=Tn(h.activation.getClassName());if(M!=null&&h.rank===2)b=uu(r,h.kernel.read(),T,h.strides,h.padding,h.dataFormat,h.dilationRate,M);else{if(h.rank===1)b=Nu(r,h.kernel.read(),T,h.strides[0],h.padding,h.dataFormat,h.dilationRate[0]);else if(h.rank===2)b=uu(r,h.kernel.read(),T,h.strides,h.padding,h.dataFormat,h.dilationRate);else if(h.rank===3)b=ws(r,h.kernel.read(),T,h.strides,h.padding,h.dataFormat,h.dilationRate);else throw new ge("convolutions greater than 3D are not implemented yet.");h.activation!=null&&(b=h.activation.apply(b))}return b})},u.prototype.computeOutputShape=function(r){r=$r(r);for(var o=[],h=this.dataFormat==="channelsLast"?r.slice(1,r.length-1):r.slice(2),b=0;b<h.length;++b){var T=Ii(h[b],this.kernelSize[b],this.padding,this.strides[b],typeof this.dilationRate=="number"?this.dilationRate:this.dilationRate[b]);o.push(T)}var M=[r[0]];return this.dataFormat==="channelsLast"?(M=M.concat(o),M.push(this.filters)):(M.push(this.filters),M=M.concat(o)),M},u.prototype.getConfig=function(){var r={filters:this.filters,kernelInitializer:S(this.kernelInitializer),kernelRegularizer:dn(this.kernelRegularizer),kernelConstraint:rn(this.kernelConstraint)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.verifyArgs=function(r){if(!("filters"in r)||typeof r.filters!="number"||r.filters<1)throw new w("Convolution layer expected config.filters to be a 'number' > 0 "+("but got "+JSON.stringify(r.filters)))},u}(Cu),Tu=function(s){O(u,s);function u(r){var o=s.call(this,2,r)||this;return u.verifyArgs(r),o}return u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return delete r.rank,r},u.verifyArgs=function(r){if(typeof r.kernelSize!="number"&&!_r(r.kernelSize,"number",1,2))throw new w("Conv2D expects config.kernelSize to be number or number[] with "+("length 1 or 2, but received "+JSON.stringify(r.kernelSize)+"."))},u.className="Conv2D",u}(cu);i.serialization.registerClass(Tu);var hc=function(s){O(u,s);function u(r){var o=s.call(this,3,r)||this;return u.verifyArgs(r),o}return u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return delete r.rank,r},u.verifyArgs=function(r){if(typeof r.kernelSize!="number"&&!(Array.isArray(r.kernelSize)&&(r.kernelSize.length===1||r.kernelSize.length===3)))throw new w("Conv3D expects config.kernelSize to be number or"+(" [number, number, number], but received "+JSON.stringify(r.kernelSize)+"."))},u.className="Conv3D",u}(cu);i.serialization.registerClass(hc);var uo=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;if(o.inputSpec=[new An({ndim:4})],o.padding!=="same"&&o.padding!=="valid")throw new w("Conv2DTranspose currently supports only padding modes 'same' "+("and 'valid', but received padding mode "+o.padding));return o}return u.prototype.build=function(r){var o;if(r=$r(r),r.length!==4)throw new w("Input should have rank 4; Received input shape: "+JSON.stringify(r));var h=this.dataFormat==="channelsFirst"?1:r.length-1;if(r[h]==null)throw new w("The channel dimension of the inputs should be defined. Found `None`.");var b=r[h],T=this.kernelSize.concat([this.filters,b]);this.kernel=this.addWeight("kernel",T,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new An({ndim:4,axes:(o={},o[h]=b,o)})],this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=ur(r);if(b.shape.length!==4)throw new w("Conv2DTranspose.call() expects input tensor to be rank-4, but "+("received a tensor of rank-"+b.shape.length));var T=b.shape,M=T[0],q,Y;h.dataFormat==="channelsFirst"?(q=2,Y=3):(q=1,Y=2);var le=T[q],Ne=T[Y],We=h.kernelSize[0],je=h.kernelSize[1],qe=h.strides[0],mt=h.strides[1],pt=_s(le,qe,We,h.padding),st=_s(Ne,mt,je,h.padding),dt=[M,pt,st,h.filters];h.dataFormat!=="channelsLast"&&(b=i.transpose(b,[0,2,3,1]));var Dt=i.conv2dTranspose(b,h.kernel.read(),dt,h.strides,h.padding);return h.dataFormat!=="channelsLast"&&(Dt=i.transpose(Dt,[0,3,1,2])),h.bias!=null&&(Dt=te(Dt,h.bias.read(),h.dataFormat)),h.activation!=null&&(Dt=h.activation.apply(Dt)),Dt})},u.prototype.computeOutputShape=function(r){r=$r(r);var o=r.slice(),h,b,T;this.dataFormat==="channelsFirst"?(h=1,b=2,T=3):(h=3,b=1,T=2);var M=this.kernelSize[0],q=this.kernelSize[1],Y=this.strides[0],le=this.strides[1];return o[h]=this.filters,o[b]=_s(o[b],Y,M,this.padding),o[T]=_s(o[T],le,q,this.padding),o},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return delete r.dilationRate,r},u.className="Conv2DTranspose",u}(Tu);i.serialization.registerClass(uo);var bs=function(s){O(u,s);function u(r,o){var h=s.call(this,r,o)||this;if(h.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",h.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",h.depthwiseKernel=null,h.pointwiseKernel=null,o.filters==null)throw new w("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(o.kernelInitializer!=null||o.kernelRegularizer!=null||o.kernelConstraint!=null)throw new w("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(o.padding!=null&&o.padding!=="same"&&o.padding!=="valid")throw new w("SeparableConv"+h.rank+"D supports only padding modes: "+("'same' and 'valid', but received "+JSON.stringify(o.padding)));return h.depthMultiplier=o.depthMultiplier==null?1:o.depthMultiplier,h.depthwiseInitializer=x(o.depthwiseInitializer||h.DEFAULT_DEPTHWISE_INITIALIZER),h.depthwiseRegularizer=Fn(o.depthwiseRegularizer),h.depthwiseConstraint=xn(o.depthwiseConstraint),h.pointwiseInitializer=x(o.depthwiseInitializer||h.DEFAULT_POINTWISE_INITIALIZER),h.pointwiseRegularizer=Fn(o.pointwiseRegularizer),h.pointwiseConstraint=xn(o.pointwiseConstraint),h}return u.prototype.build=function(r){var o;if(r=$r(r),r.length<this.rank+2)throw new w("Inputs to SeparableConv"+this.rank+"D should have rank "+(this.rank+2+", but received input shape: ")+(""+JSON.stringify(r)));var h=this.dataFormat==="channelsFirst"?1:r.length-1;if(r[h]==null||r[h]<0)throw new w("The channel dimension of the inputs should be defined, "+("but found "+JSON.stringify(r[h])));for(var b=r[h],T=this.kernelSize.concat([b,this.depthMultiplier]),M=[],q=0;q<this.rank;++q)M.push(1);M.push(b*this.depthMultiplier,this.filters);var Y=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",T,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,Y,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",M,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,Y,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,Y,this.biasConstraint):this.bias=null,this.inputSpec=[new An({ndim:this.rank+2,axes:(o={},o[h]=b,o)})],this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){r=ur(r);var b;if(h.rank===1)throw new ge("1D separable convolution is not implemented yet.");return h.rank===2&&(h.dataFormat==="channelsFirst"&&(r=i.transpose(r,[0,2,3,1])),b=i.separableConv2d(r,h.depthwiseKernel.read(),h.pointwiseKernel.read(),h.strides,h.padding,h.dilationRate,"NHWC")),h.useBias&&(b=te(b,h.bias.read(),h.dataFormat)),h.activation!=null&&(b=h.activation.apply(b)),h.dataFormat==="channelsFirst"&&(b=i.transpose(b,[0,3,1,2])),b})},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return delete r.rank,delete r.kernelInitializer,delete r.kernelRegularizer,delete r.kernelConstraint,r.depthwiseInitializer=S(this.depthwiseInitializer),r.pointwiseInitializer=S(this.pointwiseInitializer),r.depthwiseRegularizer=dn(this.depthwiseRegularizer),r.pointwiseRegularizer=dn(this.pointwiseRegularizer),r.depthwiseConstraint=rn(this.depthwiseConstraint),r.pointwiseConstraint=rn(this.pointwiseConstraint),r},u.className="SeparableConv",u}(cu),Eu=function(s){O(u,s);function u(r){return s.call(this,2,r)||this}return u.className="SeparableConv2D",u}(bs);i.serialization.registerClass(Eu);var pc=function(s){O(u,s);function u(r){var o=s.call(this,1,r)||this;return u.verifyArgs(r),o.inputSpec=[{ndim:3}],o}return u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return delete r.rank,delete r.dataFormat,r},u.verifyArgs=function(r){if(typeof r.kernelSize!="number"&&!_r(r.kernelSize,"number",1,1))throw new w("Conv1D expects config.kernelSize to be number or number[] with "+("length 1, but received "+JSON.stringify(r.kernelSize)+"."))},u.className="Conv1D",u}(cu);i.serialization.registerClass(pc);var dc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return typeof r.cropping=="number"?o.cropping=[[r.cropping,r.cropping],[r.cropping,r.cropping]]:typeof r.cropping[0]=="number"?o.cropping=[[r.cropping[0],r.cropping[0]],[r.cropping[1],r.cropping[1]]]:o.cropping=r.cropping,o.dataFormat=r.dataFormat===void 0?"channelsLast":r.dataFormat,o.inputSpec=[{ndim:4}],o}return u.prototype.computeOutputShape=function(r){return this.dataFormat==="channelsFirst"?[r[0],r[1],r[2]-this.cropping[0][0]-this.cropping[0][1],r[3]-this.cropping[1][0]-this.cropping[1][1]]:[r[0],r[1]-this.cropping[0][0]-this.cropping[0][1],r[2]-this.cropping[1][0]-this.cropping[1][1],r[3]]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(r=ur(r),h.dataFormat==="channelsLast"){var b=Fi(r,h.cropping[0][0],r.shape[1]-h.cropping[0][0]-h.cropping[0][1],2);return Fi(b,h.cropping[1][0],r.shape[2]-h.cropping[1][1]-h.cropping[1][0],3)}else{var b=Fi(r,h.cropping[0][0],r.shape[2]-h.cropping[0][0]-h.cropping[0][1],3);return Fi(b,h.cropping[1][0],r.shape[3]-h.cropping[1][1]-h.cropping[1][0],4)}})},u.prototype.getConfig=function(){var r={cropping:this.cropping,dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Cropping2D",u}(qr);i.serialization.registerClass(dc);var fc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.DEFAULT_SIZE=[2,2],o.inputSpec=[{ndim:4}],o.size=r.size==null?o.DEFAULT_SIZE:r.size,o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,o}return u.prototype.computeOutputShape=function(r){if(this.dataFormat==="channelsFirst"){var o=r[2]==null?null:this.size[0]*r[2],h=r[3]==null?null:this.size[1]*r[3];return[r[0],r[1],o,h]}else{var o=r[1]==null?null:this.size[0]*r[1],h=r[2]==null?null:this.size[1]*r[2];return[r[0],o,h,r[3]]}},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=ur(r),T=b.shape;if(h.dataFormat==="channelsFirst"){b=i.transpose(b,[0,2,3,1]);var M=h.size[0]*T[2],q=h.size[1]*T[3],Y=b.resizeNearestNeighbor([M,q]);return i.transpose(Y,[0,3,1,2])}else{var M=h.size[0]*T[1],q=h.size[1]*T[2];return b.resizeNearestNeighbor([M,q])}})},u.prototype.getConfig=function(){var r={size:this.size,dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="UpSampling2D",u}(qr);i.serialization.registerClass(fc);function vl(s,u,r,o,h,b){return r===void 0&&(r=[1,1]),o===void 0&&(o="valid"),i.tidy(function(){h==null&&(h=he()),on(h);var T=bo(s,h);if(s.rank!==4)throw new w("Input for depthwiseConv2d is required to be 4-D, but is instead "+(s.rank+"-D"));if(u.rank!==4)throw new w("depthwiseKernel is required to be 4-D, but is instead "+(u.rank+"-D"));return T=i.depthwiseConv2d(T,u,r,o==="same"?"same":"valid","NHWC",b),h==="channelsFirst"&&(T=i.transpose(T,[0,3,1,2])),T})}var Ru=function(s){O(u,s);function u(r){var o=s.call(this,2,r)||this;return o.depthwiseKernel=null,o.depthMultiplier=r.depthMultiplier==null?1:r.depthMultiplier,o.depthwiseInitializer=x(r.depthwiseInitializer||o.DEFAULT_KERNEL_INITIALIZER),o.depthwiseConstraint=xn(r.depthwiseConstraint),o.depthwiseRegularizer=Fn(r.depthwiseRegularizer),o}return u.prototype.build=function(r){if(r=$r(r),r.length<4)throw new w("Inputs to DepthwiseConv2D should have rank 4. "+("Received input shape: "+JSON.stringify(r)+"."));var o=this.dataFormat==="channelsFirst"?1:3;if(r[o]==null||r[o]<0)throw new w("The channel dimension of the inputs to DepthwiseConv2D should "+("be defined, but is not ("+r[o]+")."));var h=r[o],b=[this.kernelSize[0],this.kernelSize[1],h,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",b,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[h*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){r=ur(r);var b=vl(r,h.depthwiseKernel.read(),h.strides,h.padding,h.dataFormat,null);return h.useBias&&(b=te(b,h.bias.read(),h.dataFormat)),h.activation!=null&&(b=h.activation.apply(b)),b})},u.prototype.computeOutputShape=function(r){r=$r(r);var o=this.dataFormat==="channelsFirst"?r[2]:r[1],h=this.dataFormat==="channelsFirst"?r[3]:r[2],b=this.dataFormat==="channelsFirst"?r[1]*this.depthMultiplier:r[3]*this.depthMultiplier,T=Ii(o,this.kernelSize[0],this.padding,this.strides[0]),M=Ii(h,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[r[0],b,T,M]:[r[0],T,M,b]},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return r.depthMultiplier=this.depthMultiplier,r.depthwiseInitializer=S(this.depthwiseInitializer),r.depthwiseRegularizer=dn(this.depthwiseRegularizer),r.depthwiseConstraint=rn(this.depthwiseRegularizer),r},u.className="DepthwiseConv2D",u}(Cu);i.serialization.registerClass(Ru);function mc(s,u,r,o){if(Array.isArray(s)){if(u!=null||r!=null)throw new w("When inputs is an array, neither initialState or constants should be provided");o!=null&&(r=s.slice(s.length-o,s.length),s=s.slice(0,s.length-o)),s.length>1&&(u=s.slice(1,s.length)),s=s[0]}function h(b){return b==null||Array.isArray(b)?b:[b]}return u=h(u),r=h(r),{inputs:s,initialState:u,constants:r}}function yc(s,u,r,o,h,b,T,M){return o===void 0&&(o=!1),T===void 0&&(T=!1),M===void 0&&(M=!1),i.tidy(function(){var q=u.shape.length;if(q<3)throw new w("Input should be at least 3D, but is "+q+"D.");var Y=[1,0].concat(ln(2,q));if(u=i.transpose(u,Y),b!=null)throw new ge("The rnn() functoin of the deeplearn.js backend does not support constants yet.");T&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),h!=null&&(h=h.asType("bool").asType("float32"),h.rank===q-1&&(h=i.expandDims(h,-1)),h=i.transpose(h,Y)),o&&(u=i.reverse(u,0),h!=null&&(h=i.reverse(h,0)));var le=[],Ne,We=r,je=u.shape[0],qe=i.unstack(u),mt;h!=null&&(mt=i.unstack(h));for(var pt=function(or){var Xt=qe[or],Jt=i.tidy(function(){return s(Xt,We)});if(h==null)Ne=Jt[0],We=Jt[1];else{var vr=i.tidy(function(){var lr=mt[or],Ir=i.onesLike(lr).sub(lr),Lr=Jt[0].mul(lr).add(We[0].mul(Ir)),kr=We.map(function(Sr,fn){return Jt[1][fn].mul(lr).add(Sr.mul(Ir))});return{output:Lr,newStates:kr}});Ne=vr.output,We=vr.newStates}M&&le.push(Ne)},st=0;st<je;++st)pt(st);var dt;if(M){var Dt=1;dt=i.stack(le,Dt)}return[Ne,dt,We]})}var Ni=function(s){O(u,s);function u(r){var o=s.call(this,r)||this,h;if(r.cell==null)throw new w("cell property is missing for the constructor of RNN.");if(Array.isArray(r.cell)?h=new as({cells:r.cell}):h=r.cell,h.stateSize==null)throw new w("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");return o.cell=h,o.returnSequences=r.returnSequences==null?!1:r.returnSequences,o.returnState=r.returnState==null?!1:r.returnState,o.goBackwards=r.goBackwards==null?!1:r.goBackwards,o._stateful=r.stateful==null?!1:r.stateful,o.unroll=r.unroll==null?!1:r.unroll,o.supportsMasking=!0,o.inputSpec=[new An({ndim:3})],o.stateSpec=null,o.states_=null,o.numConstants=null,o.keptStates=[],o}return u.prototype.getStates=function(){if(this.states_==null){var r=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return ln(0,r).map(function(o){return null})}else return this.states_},u.prototype.setStates=function(r){this.states_=r},u.prototype.computeOutputShape=function(r){wa(r)&&(r=r[0]),r=r;var o=this.cell.stateSize;Array.isArray(o)||(o=[o]);var h=o[0],b;if(this.returnSequences?b=[r[0],r[1],h]:b=[r[0],h],this.returnState){for(var T=[],M=0,q=o;M<q.length;M++){var Y=q[M];T.push([r[0],Y])}return[b].concat(T)}else return b},u.prototype.computeMask=function(r,o){var h=this;return i.tidy(function(){Array.isArray(o)&&(o=o[0]);var b=h.returnSequences?o:null;if(h.returnState){var T=h.states.map(function(M){return null});return[b].concat(T)}else return b})},Object.defineProperty(u.prototype,"states",{get:function(){if(this.states_==null){for(var r=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,o=[],h=0;h<r;++h)o.push(null);return o}else return this.states_},set:function(r){this.states_=r},enumerable:!0,configurable:!0}),u.prototype.build=function(r){if(this.numConstants!=null)throw new ge("Constants support is not implemented in RNN yet.");wa(r)&&(r=r[0]),r=r;var o=this.stateful?r[0]:null,h=r.slice(2);this.inputSpec[0]=new An({shape:[o,null].concat(h)});var b=[r[0]].concat(r.slice(2));this.cell.build(b);var T;if(Array.isArray(this.cell.stateSize)?T=this.cell.stateSize:T=[this.cell.stateSize],this.stateSpec!=null){if(!i.util.arraysEqual(this.stateSpec.map(function(M){return M.shape[M.shape.length-1]}),T))throw new w("An initialState was passed that is not compatible with "+("cell.stateSize. Received stateSpec="+this.stateSpec+"; ")+("However cell.stateSize is "+this.cell.stateSize))}else this.stateSpec=T.map(function(M){return new An({shape:[null,M]})});this.stateful&&this.resetStates()},u.prototype.resetStates=function(r,o){var h=this;o===void 0&&(o=!1),i.tidy(function(){if(!h.stateful)throw new me("Cannot call resetStates() on an RNN Layer that is not stateful.");var b=h.inputSpec[0].shape[0];if(b==null)throw new w("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(h.states_==null)Array.isArray(h.cell.stateSize)?h.states_=h.cell.stateSize.map(function(le){return i.zeros([b,le])}):h.states_=[i.zeros([b,h.cell.stateSize])];else if(r==null)i.dispose(h.states_),h.keptStates!=null&&(i.dispose(h.keptStates),h.keptStates=[]),Array.isArray(h.cell.stateSize)?h.states_=h.cell.stateSize.map(function(le){return i.zeros([b,le])}):h.states_[0]=i.zeros([b,h.cell.stateSize]);else{if(Array.isArray(r)||(r=[r]),r.length!==h.states_.length)throw new w("Layer "+h.name+" expects "+h.states_.length+" state(s), "+("but it received "+r.length+" state value(s). Input ")+("received: "+r));o===!0?h.keptStates.push(h.states_.slice()):i.dispose(h.states_);for(var T=0;T<h.states_.length;++T){var M=r[T],q=Array.isArray(h.cell.stateSize)?h.cell.stateSize[T]:h.cell.stateSize,Y=[b,q];if(!i.util.arraysEqual(M.shape,Y))throw new w("State "+T+" is incompatible with layer "+h.name+": "+("expected shape="+Y+", received shape="+M.shape));h.states_[T]=M}}h.states_=h.states_.map(function(le){return i.keep(le.clone())})})},u.prototype.apply=function(r,o){var h=o==null?null:o.initialState,b=o==null?null:o.constants;o==null&&(o={});var T=mc(r,h,b,this.numConstants);r=T.inputs,h=T.initialState,b=T.constants;var M=[],q=[];if(h!=null){o.initialState=h,M=M.concat(h),this.stateSpec=[];for(var Y=0,le=h;Y<le.length;Y++){var Ne=le[Y];this.stateSpec.push(new An({shape:Ne.shape}))}q=q.concat(this.stateSpec)}b!=null&&(o.constants=b,M=M.concat(b),this.numConstants=b.length);var We=M[0]instanceof ba;if(We){var je=[r].concat(M),qe=this.inputSpec.concat(q),mt=this.inputSpec;this.inputSpec=qe;var pt=s.prototype.apply.call(this,je,o);return this.inputSpec=mt,pt}else return s.prototype.apply.call(this,r,o)},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=o==null?null:o.mask,T=o==null?null:o.training,M=o==null?null:o.initialState;r=ur(r),M==null&&(h.stateful?M=h.states_:M=h.getInitialState(r));var q=Array.isArray(h.cell.stateSize)?h.cell.stateSize.length:1;if(M.length!==q)throw new w("RNN Layer has "+q+" state(s) but was passed "+(M.length+" initial state(s)."));h.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");var Y={training:T},le=function(pt,st){var dt=h.cell.call([pt].concat(st),Y);return[dt[0],dt.slice(1)]},Ne=yc(le,r,M,h.goBackwards,b,null,h.unroll,h.returnSequences),We=Ne[0],je=Ne[1],qe=Ne[2];h.stateful&&h.resetStates(qe,T);var mt=h.returnSequences?je:We;return h.returnState?[mt].concat(qe):mt})},u.prototype.getInitialState=function(r){var o=this;return i.tidy(function(){var h=i.zeros(r.shape);return h=i.sum(h,[1,2]),h=gr(h),Array.isArray(o.cell.stateSize)?o.cell.stateSize.map(function(b){return b>1?da(h,[1,b]):h}):o.cell.stateSize>1?[da(h,[1,o.cell.stateSize])]:[h]})},Object.defineProperty(u.prototype,"trainableWeights",{get:function(){return this.trainable?this.cell.trainableWeights:[]},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights},enumerable:!0,configurable:!0}),u.prototype.setFastWeightInitDuringBuild=function(r){s.prototype.setFastWeightInitDuringBuild.call(this,r),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(r)},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(o.numConstants=this.numConstants);var h=this.cell.getConfig();return this.getClassName()===u.className&&(o.cell={className:this.cell.getClassName(),config:h}),H({},h,r,o)},u.fromConfig=function(r,o,h){h===void 0&&(h={});var b=o.cell,T=oa(b,h);return new r(Object.assign(o,{cell:T}))},u.className="RNN",u}(qr);i.serialization.registerClass(Ni);var ns=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u}(qr),ks=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.DEFAULT_ACTIVATION="tanh",o.DEFAULT_KERNEL_INITIALIZER="glorotNormal",o.DEFAULT_RECURRENT_INITIALIZER="orthogonal",o.DEFAULT_BIAS_INITIALIZER="zeros",o.units=r.units,tr(o.units,"units"),o.activation=va(r.activation==null?o.DEFAULT_ACTIVATION:r.activation),o.useBias=r.useBias==null?!0:r.useBias,o.kernelInitializer=x(r.kernelInitializer||o.DEFAULT_KERNEL_INITIALIZER),o.recurrentInitializer=x(r.recurrentInitializer||o.DEFAULT_RECURRENT_INITIALIZER),o.biasInitializer=x(r.biasInitializer||o.DEFAULT_BIAS_INITIALIZER),o.kernelRegularizer=Fn(r.kernelRegularizer),o.recurrentRegularizer=Fn(r.recurrentRegularizer),o.biasRegularizer=Fn(r.biasRegularizer),o.kernelConstraint=xn(r.kernelConstraint),o.recurrentConstraint=xn(r.recurrentConstraint),o.biasConstraint=xn(r.biasConstraint),o.dropout=fi([1,Va([0,r.dropout==null?0:r.dropout])]),o.recurrentDropout=fi([1,Va([0,r.recurrentDropout==null?0:r.recurrentDropout])]),o.stateSize=o.units,o.dropoutMask=null,o.recurrentDropoutMask=null,o}return u.prototype.build=function(r){r=$r(r),this.kernel=this.addWeight("kernel",[r[r.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(r=r,r.length!==2)throw new w("SimpleRNNCell expects 2 input Tensors, got "+r.length+".");var b=r[1];r=r[0];var T=o.training==null?!1:o.training;0<h.dropout&&h.dropout<1&&h.dropoutMask==null&&(h.dropoutMask=Vo({ones:function(){return i.onesLike(r)},rate:h.dropout,training:T})),0<h.recurrentDropout&&h.recurrentDropout<1&&h.recurrentDropoutMask==null&&(h.recurrentDropoutMask=Vo({ones:function(){return i.onesLike(b)},rate:h.recurrentDropout,training:T}));var M,q=h.dropoutMask,Y=h.recurrentDropoutMask;q!=null?M=pe(i.mul(r,q),h.kernel.read()):M=pe(r,h.kernel.read()),h.bias!=null&&(M=te(M,h.bias.read())),Y!=null&&(b=i.mul(b,Y));var le=i.add(M,pe(b,h.recurrentKernel.read()));return h.activation!=null&&(le=h.activation.apply(le)),[le,le]})},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={units:this.units,activation:Qa(this.activation),useBias:this.useBias,kernelInitializer:S(this.kernelInitializer),recurrentInitializer:S(this.recurrentInitializer),biasInitializer:S(this.biasInitializer),kernelRegularizer:dn(this.kernelRegularizer),recurrentRegularizer:dn(this.recurrentRegularizer),biasRegularizer:dn(this.biasRegularizer),activityRegularizer:dn(this.activityRegularizer),kernelConstraint:rn(this.kernelConstraint),recurrentConstraint:rn(this.recurrentConstraint),biasConstraint:rn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return H({},r,o)},u.className="SimpleRNNCell",u}(ns);i.serialization.registerClass(ks);var vc=function(s){O(u,s);function u(r){var o=this;return r.cell=new ks(r),o=s.call(this,r)||this,o}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.cell.dropoutMask!=null&&(i.dispose(h.cell.dropoutMask),h.cell.dropoutMask=null),h.cell.recurrentDropoutMask!=null&&(i.dispose(h.cell.recurrentDropoutMask),h.cell.recurrentDropoutMask=null);var b=o==null?null:o.mask,T=o==null?null:o.training,M=o==null?null:o.initialState;return s.prototype.call.call(h,r,{mask:b,training:T,initialState:M})})},u.fromConfig=function(r,o){return new r(o)},u.className="SimpleRNN",u}(Ni);i.serialization.registerClass(vc);var Wo=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;if(o.DEFAULT_ACTIVATION="tanh",o.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",o.DEFAULT_KERNEL_INITIALIZER="glorotNormal",o.DEFAULT_RECURRENT_INITIALIZER="orthogonal",o.DEFAULT_BIAS_INITIALIZER="zeros",r.resetAfter)throw new w("GRUCell does not support reset_after parameter set to true.");return o.units=r.units,tr(o.units,"units"),o.activation=va(r.activation===void 0?o.DEFAULT_ACTIVATION:r.activation),o.recurrentActivation=va(r.recurrentActivation===void 0?o.DEFAULT_RECURRENT_ACTIVATION:r.recurrentActivation),o.useBias=r.useBias==null?!0:r.useBias,o.kernelInitializer=x(r.kernelInitializer||o.DEFAULT_KERNEL_INITIALIZER),o.recurrentInitializer=x(r.recurrentInitializer||o.DEFAULT_RECURRENT_INITIALIZER),o.biasInitializer=x(r.biasInitializer||o.DEFAULT_BIAS_INITIALIZER),o.kernelRegularizer=Fn(r.kernelRegularizer),o.recurrentRegularizer=Fn(r.recurrentRegularizer),o.biasRegularizer=Fn(r.biasRegularizer),o.kernelConstraint=xn(r.kernelConstraint),o.recurrentConstraint=xn(r.recurrentConstraint),o.biasConstraint=xn(r.biasConstraint),o.dropout=fi([1,Va([0,r.dropout==null?0:r.dropout])]),o.recurrentDropout=fi([1,Va([0,r.recurrentDropout==null?0:r.recurrentDropout])]),o.implementation=r.implementation,o.stateSize=o.units,o.dropoutMask=null,o.recurrentDropoutMask=null,o}return u.prototype.build=function(r){r=$r(r);var o=r[r.length-1];this.kernel=this.addWeight("kernel",[o,this.units*3],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*3],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units*3],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(r=r,r.length!==2)throw new w("GRUCell expects 2 input Tensors (inputs, h, c), got "+(r.length+"."));var b=o.training==null?!1:o.training,T=r[1];r=r[0],0<h.dropout&&h.dropout<1&&h.dropoutMask==null&&(h.dropoutMask=Vo({ones:function(){return i.onesLike(r)},rate:h.dropout,training:b,count:3})),0<h.recurrentDropout&&h.recurrentDropout<1&&h.recurrentDropoutMask==null&&(h.recurrentDropoutMask=Vo({ones:function(){return i.onesLike(T)},rate:h.recurrentDropout,training:b,count:3}));var M=h.dropoutMask,q=h.recurrentDropoutMask,Y,le,Ne;0<h.dropout&&h.dropout<1&&(r=i.mul(r,M[0]));var We=pe(r,h.kernel.read());h.useBias&&(We=te(We,h.bias.read())),0<h.recurrentDropout&&h.recurrentDropout<1&&(T=i.mul(T,q[0]));var je=h.recurrentKernel.read(),qe=i.split(je,[2*h.units,h.units],je.rank-1),mt=qe[0],pt=qe[1],st=pe(T,mt),dt=i.split(We,3,We.rank-1),Dt=dt[0],or=dt[1],Xt=dt[2],Jt=i.split(st,2,st.rank-1),vr=Jt[0],lr=Jt[1];Y=h.recurrentActivation.apply(i.add(Dt,vr)),le=h.recurrentActivation.apply(i.add(or,lr));var Ir=pe(i.mul(le,T),pt);Ne=h.activation.apply(i.add(Xt,Ir));var Lr=i.add(i.mul(Y,T),i.mul(i.add(1,i.neg(Y)),Ne));return[Lr,Lr]})},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={units:this.units,activation:Qa(this.activation),recurrentActivation:Qa(this.recurrentActivation),useBias:this.useBias,kernelInitializer:S(this.kernelInitializer),recurrentInitializer:S(this.recurrentInitializer),biasInitializer:S(this.biasInitializer),kernelRegularizer:dn(this.kernelRegularizer),recurrentRegularizer:dn(this.recurrentRegularizer),biasRegularizer:dn(this.biasRegularizer),activityRegularizer:dn(this.activityRegularizer),kernelConstraint:rn(this.kernelConstraint),recurrentConstraint:rn(this.recurrentConstraint),biasConstraint:rn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return H({},r,o)},u.className="GRUCell",u}(ns);i.serialization.registerClass(Wo);var co=function(s){O(u,s);function u(r){var o=this;return r.implementation===0&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),r.cell=new Wo(r),o=s.call(this,r)||this,o}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.cell.dropoutMask!=null&&(i.dispose(h.cell.dropoutMask),h.cell.dropoutMask=null),h.cell.recurrentDropoutMask!=null&&(i.dispose(h.cell.recurrentDropoutMask),h.cell.recurrentDropoutMask=null);var b=o==null?null:o.mask,T=o==null?null:o.training,M=o==null?null:o.initialState;return s.prototype.call.call(h,r,{mask:b,training:T,initialState:M})})},u.fromConfig=function(r,o){return o.implmentation===0&&(o.implementation=1),new r(o)},u.className="GRU",u}(Ni);i.serialization.registerClass(co);var Uo=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.DEFAULT_ACTIVATION="tanh",o.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",o.DEFAULT_KERNEL_INITIALIZER="glorotNormal",o.DEFAULT_RECURRENT_INITIALIZER="orthogonal",o.DEFAULT_BIAS_INITIALIZER="zeros",o.units=r.units,tr(o.units,"units"),o.activation=va(r.activation===void 0?o.DEFAULT_ACTIVATION:r.activation),o.recurrentActivation=va(r.recurrentActivation===void 0?o.DEFAULT_RECURRENT_ACTIVATION:r.recurrentActivation),o.useBias=r.useBias==null?!0:r.useBias,o.kernelInitializer=x(r.kernelInitializer||o.DEFAULT_KERNEL_INITIALIZER),o.recurrentInitializer=x(r.recurrentInitializer||o.DEFAULT_RECURRENT_INITIALIZER),o.biasInitializer=x(r.biasInitializer||o.DEFAULT_BIAS_INITIALIZER),o.unitForgetBias=r.unitForgetBias,o.kernelRegularizer=Fn(r.kernelRegularizer),o.recurrentRegularizer=Fn(r.recurrentRegularizer),o.biasRegularizer=Fn(r.biasRegularizer),o.kernelConstraint=xn(r.kernelConstraint),o.recurrentConstraint=xn(r.recurrentConstraint),o.biasConstraint=xn(r.biasConstraint),o.dropout=fi([1,Va([0,r.dropout==null?0:r.dropout])]),o.recurrentDropout=fi([1,Va([0,r.recurrentDropout==null?0:r.recurrentDropout])]),o.implementation=r.implementation,o.stateSize=[o.units,o.units],o.dropoutMask=null,o.recurrentDropoutMask=null,o}return u.prototype.build=function(r){var o;r=$r(r);var h=r[r.length-1];this.kernel=this.addWeight("kernel",[h,this.units*4],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*4],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);var b;if(this.useBias){if(this.unitForgetBias){var T=this.biasInitializer,M=this.units;b=new(o=function(q){O(Y,q);function Y(){return q!==null&&q.apply(this,arguments)||this}return Y.prototype.apply=function(le,Ne){var We=T.apply([M]),je=new fa().apply([M]),qe=T.apply([M*2]);return Oi(Oi(We,je),qe)},Y}(ir),o.className="CustomInit",o)}else b=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,b,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=o.training==null?!1:o.training;if(r=r,r.length!==3)throw new w("LSTMCell expects 3 input Tensors (inputs, h, c), got "+(r.length+"."));var T=r[1],M=r[2];r=r[0],0<h.dropout&&h.dropout<1&&h.dropoutMask==null&&(h.dropoutMask=Vo({ones:function(){return i.onesLike(r)},rate:h.dropout,training:b,count:4})),0<h.recurrentDropout&&h.recurrentDropout<1&&h.recurrentDropoutMask==null&&(h.recurrentDropoutMask=Vo({ones:function(){return i.onesLike(T)},rate:h.recurrentDropout,training:b,count:4}));var q=h.dropoutMask,Y=h.recurrentDropoutMask,le,Ne,We,je;0<h.dropout&&h.dropout<1&&(r=i.mul(r,q[0]));var qe=pe(r,h.kernel.read());0<h.recurrentDropout&&h.recurrentDropout<1&&(T=i.mul(T,Y[0])),qe=i.add(qe,pe(T,h.recurrentKernel.read())),h.useBias&&(qe=te(qe,h.bias.read()));var mt=i.split(qe,4,qe.rank-1),pt=mt[0],st=mt[1],dt=mt[2],Dt=mt[3];le=h.recurrentActivation.apply(pt),Ne=h.recurrentActivation.apply(st),We=i.add(i.mul(Ne,M),i.mul(le,h.activation.apply(dt))),je=h.recurrentActivation.apply(Dt);var or=i.mul(je,h.activation.apply(We));return[or,or,We]})},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={units:this.units,activation:Qa(this.activation),recurrentActivation:Qa(this.recurrentActivation),useBias:this.useBias,kernelInitializer:S(this.kernelInitializer),recurrentInitializer:S(this.recurrentInitializer),biasInitializer:S(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:dn(this.kernelRegularizer),recurrentRegularizer:dn(this.recurrentRegularizer),biasRegularizer:dn(this.biasRegularizer),activityRegularizer:dn(this.activityRegularizer),kernelConstraint:rn(this.kernelConstraint),recurrentConstraint:rn(this.recurrentConstraint),biasConstraint:rn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return H({},r,o)},u.className="LSTMCell",u}(ns);i.serialization.registerClass(Uo);var lu=function(s){O(u,s);function u(r){var o=this;return r.implementation===0&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),r.cell=new Uo(r),o=s.call(this,r)||this,o}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.cell.dropoutMask!=null&&(i.dispose(h.cell.dropoutMask),h.cell.dropoutMask=null),h.cell.recurrentDropoutMask!=null&&(i.dispose(h.cell.recurrentDropoutMask),h.cell.recurrentDropoutMask=null);var b=o==null?null:o.mask,T=o==null?null:o.training,M=o==null?null:o.initialState;return s.prototype.call.call(h,r,{mask:b,training:T,initialState:M})})},u.fromConfig=function(r,o){return o.implmentation===0&&(o.implementation=1),new r(o)},u.className="LSTM",u}(Ni);i.serialization.registerClass(lu);var as=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.cells=r.cells,o}return Object.defineProperty(u.prototype,"stateSize",{get:function(){for(var r=[],o=0,h=this.cells.slice().reverse();o<h.length;o++){var b=h[o];Array.isArray(b.stateSize)?r.push.apply(r,b.stateSize):r.push(b.stateSize)}return r},enumerable:!0,configurable:!0}),u.prototype.call=function(r,o){var h=this;return i.tidy(function(){r=r;for(var b=r.slice(1),T=[],M=0,q=h.cells.slice().reverse();M<q.length;M++){var Y=q[M];Array.isArray(Y.stateSize)?T.push(b.splice(0,Y.stateSize.length)):T.push(b.splice(0,1))}T.reverse();for(var le=[],Ne,We=0;We<h.cells.length;++We){var Y=h.cells[We];b=T[We],We===0?Ne=[r[0]].concat(b):Ne=[Ne[0]].concat(b),Ne=Y.call(Ne,o),le.push(Ne.slice(1))}b=[];for(var je=0,qe=le.slice().reverse();je<qe.length;je++){var mt=qe[je];b.push.apply(b,mt)}return[Ne[0]].concat(b)})},u.prototype.build=function(r){wa(r)&&(r=r[0]),r=r;var o;this.cells.forEach(function(h,b){_a("RNNCell_"+b,function(){h.build(r),Array.isArray(h.stateSize)?o=h.stateSize[0]:o=h.stateSize,r=[r[0],o]})}),this.built=!0},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o=function(T){return{className:T.getClassName(),config:T.getConfig()}},h=this.cells.map(o),b={cells:h};return H({},r,b)},u.fromConfig=function(r,o,h){h===void 0&&(h={});for(var b=[],T=0,M=o.cells;T<M.length;T++){var q=M[T];b.push(oa(q,h))}return new r({cells:b})},Object.defineProperty(u.prototype,"trainableWeights",{get:function(){if(!this.trainable)return[];for(var r=[],o=0,h=this.cells;o<h.length;o++){var b=h[o];r.push.apply(r,b.trainableWeights)}return r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){for(var r=[],o=0,h=this.cells;o<h.length;o++){var b=h[o];r.push.apply(r,b.nonTrainableWeights)}if(!this.trainable){for(var T=[],M=0,q=this.cells;M<q.length;M++){var b=q[M];T.push.apply(T,b.trainableWeights)}return T.concat(r)}return r},enumerable:!0,configurable:!0}),u.prototype.getWeights=function(){for(var r=[],o=0,h=this.cells;o<h.length;o++){var b=h[o];r.push.apply(r,b.weights)}return ai(r)},u.prototype.setWeights=function(r){for(var o=[],h=0,b=this.cells;h<b.length;h++)for(var T=b[h],M=T.weights.length,q=r.splice(M),Y=0;Y<T.weights.length;++Y)o.push([T.weights[Y],q[Y]]);zi(o)},u.className="StackedRNNCells",u}(ns);i.serialization.registerClass(as);function Vo(s){var u=s.ones,r=s.rate,o=s.training,h=o===void 0?!1:o,b=s.count,T=b===void 0?1:b,M=function(){return $e(u(),r)},q=function(){return Ye(M,u,h)};if(!T||T<=1)return i.keep(q().clone());var Y=Array(T).fill(void 0).map(q);return Y.map(function(le){return i.keep(le.clone())})}var gl=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u}(ns),xl=function(s){O(u,s);function u(r){var o=this;if(r.unroll)throw new ge("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(r.cell))throw new ge("It is not possible at the moment to stack convolutional cells.");return o=s.call(this,r)||this,o.inputSpec=[new An({ndim:5})],o}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(h.cell.dropoutMask!=null&&(i.dispose(h.cell.dropoutMask),h.cell.dropoutMask=null),h.cell.recurrentDropoutMask!=null&&(i.dispose(h.cell.recurrentDropoutMask),h.cell.recurrentDropoutMask=null),o&&o.constants)throw new w("ConvRNN2D cell does not support constants");var b=o==null?null:o.mask,T=o==null?null:o.training,M=o==null?null:o.initialState;return s.prototype.call.call(h,r,{mask:b,training:T,initialState:M})})},u.prototype.computeOutputShape=function(r){var o=this.computeSingleOutputShape(r);return this.returnSequences||(o=[o[0]].concat(o.slice(2))),this.returnState&&(o=[o].concat(Array(2).fill([r[0]].concat(o.slice(-3))))),o},u.prototype.getInitialState=function(r){var o=this;return i.tidy(function(){var h=o.cell.stateSize,b=r.shape,T=o.computeSingleOutputShape(b),M=[T[0]].concat(T.slice(2)),q=i.zeros(M);return Array.isArray(h)?Array(h.length).fill(q):[q]})},u.prototype.resetStates=function(r,o){var h=this;o===void 0&&(o=!1),i.tidy(function(){if(!h.stateful)throw new me("Cannot call resetStates() on an RNN Layer that is not stateful.");var b=h.inputSpec[0].shape,T=h.computeSingleOutputShape(b),M=[T[0]].concat(T.slice(2)),q=b[0];if(q==null)throw new w("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(h.getStates()==null)Array.isArray(h.cell.stateSize)?h.states_=h.cell.stateSize.map(function(){return i.zeros(M)}):h.states_=[i.zeros(M)];else if(r==null)i.dispose(h.states_),h.keptStates!=null&&(i.dispose(h.keptStates),h.keptStates=[]),Array.isArray(h.cell.stateSize)?h.states_=h.cell.stateSize.map(function(){return i.zeros(M)}):h.states_[0]=i.zeros(M);else{if(Array.isArray(r)||(r=[r]),r.length!==h.states_.length)throw new w("Layer "+h.name+" expects "+h.states_.length+" state(s), "+("but it received "+r.length+" state value(s). Input ")+("received: "+r));o?h.keptStates.push(h.states_.slice()):i.dispose(h.states_);for(var Y=0;Y<h.states_.length;++Y){var le=r[Y],Ne=M;if(!i.util.arraysEqual(le.shape,Ne))throw new w("State "+Y+" is incompatible with layer "+h.name+": "+("expected shape="+Ne+", received shape="+le.shape));h.states_[Y]=le}}h.states_=h.states_.map(function(We){return i.keep(We.clone())})})},u.prototype.computeSingleOutputShape=function(r){var o=this.cell,h=o.dataFormat,b=o.filters,T=o.kernelSize,M=o.padding,q=o.strides,Y=o.dilationRate,le=h==="channelsFirst",Ne=r[le?3:2],We=r[le?4:3],je=Ii(Ne,T[0],M,q[0],Y[0]),qe=Ii(We,T[1],M,q[1],Y[1]),mt=r.slice(0,2).concat(le?[b,je,qe]:[je,qe,b]);return mt},u.className="ConvRNN2D",u}(Ni),Au=function(s){O(u,s);function u(r){var o=this,h=r.filters,b=r.kernelSize,T=r.strides,M=r.padding,q=r.dataFormat,Y=r.dilationRate;return o=s.call(this,H({},r,{units:h}))||this,o.filters=h,tr(o.filters,"filters"),o.kernelSize=xs(b,2,"kernelSize"),o.kernelSize.forEach(function(le){return tr(le,"kernelSize")}),o.strides=xs(T||1,2,"strides"),o.strides.forEach(function(le){return tr(le,"strides")}),o.padding=M||"valid",_n(o.padding),o.dataFormat=q||"channelsLast",on(o.dataFormat),o.dilationRate=xs(Y||1,2,"dilationRate"),o.dilationRate.forEach(function(le){return tr(le,"dilationRate")}),o}return u.prototype.build=function(r){var o;r=$r(r);var h=this.dataFormat==="channelsFirst"?1:r.length-1;if(r[h]==null)throw new w("The channel dimension of the input should be defined. "+("Found "+r[h]));var b=r[h],T=4,M=this.kernelSize.concat([b,this.filters*T]);this.kernel=this.addWeight("kernel",M,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);var q=this.kernelSize.concat([this.filters,this.filters*T]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",q,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){var Y=void 0;if(this.unitForgetBias){var le=this.biasInitializer,Ne=this.filters;Y=new(o=function(We){O(je,We);function je(){return We!==null&&We.apply(this,arguments)||this}return je.prototype.apply=function(qe,mt){var pt=le.apply([Ne]),st=i.ones([Ne]),dt=le.apply([Ne*2]);return ji([pt,st,dt])},je}(ir),o.className="CustomInit",o)}else Y=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*T],null,Y,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(r.length!==3)throw new w("ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got "+(r.length+"."));var b=o.training||!1,T=r[0],M=r[1],q=r[2],Y=4;0<h.dropout&&h.dropout<1&&h.dropoutMask==null&&(h.dropoutMask=Vo({ones:function(){return i.onesLike(T)},rate:h.dropout,training:b,count:Y}));var le=h.dropoutMask,Ne=function(Xn,$i,Vi){return!$i||!$i[Vi]?Xn:i.mul($i[Vi],Xn)},We=Ne(T,le,0),je=Ne(T,le,1),qe=Ne(T,le,2),mt=Ne(T,le,3);0<h.recurrentDropout&&h.recurrentDropout<1&&h.recurrentDropoutMask==null&&(h.recurrentDropoutMask=Vo({ones:function(){return i.onesLike(M)},rate:h.recurrentDropout,training:b,count:Y}));var pt=h.recurrentDropoutMask,st=Ne(M,pt,0),dt=Ne(M,pt,1),Dt=Ne(M,pt,2),or=Ne(M,pt,3),Xt=3,Jt=i.split(h.kernel.read(),Y,Xt),vr=Jt[0],lr=Jt[1],Ir=Jt[2],Lr=Jt[3],kr=h.useBias?i.split(h.bias.read(),Y):[null,null,null,null],Sr=kr[0],fn=kr[1],Xr=kr[2],$t=kr[3];We=h.inputConv(We,vr,Sr,h.padding),je=h.inputConv(je,lr,fn,h.padding),qe=h.inputConv(qe,Ir,Xr,h.padding),mt=h.inputConv(mt,Lr,$t,h.padding);var On=i.split(h.recurrentKernel.read(),Y,Xt),En=On[0],kn=On[1],cn=On[2],Mn=On[3];st=h.recurrentConv(st,En),dt=h.recurrentConv(dt,kn),Dt=h.recurrentConv(Dt,cn),or=h.recurrentConv(or,Mn);var Hr=h.recurrentActivation.apply(i.add(We,st)),ua=h.recurrentActivation.apply(i.add(je,dt)),Ci=i.add(i.mul(ua,q),i.mul(Hr,h.activation.apply(i.add(qe,Dt)))),Ui=i.mul(h.recurrentActivation.apply(i.add(mt,or)),h.activation.apply(Ci));return[Ui,Ui,Ci]})},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o=r.units,h=se(r,["units"]),b={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return H({},h,b)},u.prototype.inputConv=function(r,o,h,b){var T=i.conv2d(r,o,this.strides,b||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return h?te(T,h,this.dataFormat):T},u.prototype.recurrentConv=function(r,o){var h=1;return i.conv2d(r,o,h,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")},u.className="ConvLSTM2DCell",u}(Uo);i.serialization.registerClass(Au);var gc=function(s){O(u,s);function u(r){var o=this,h=new Au(r);return o=s.call(this,H({},r,{cell:h}))||this,o}return u.fromConfig=function(r,o){return new r(o)},u.className="ConvLSTM2D",u}(xl);i.serialization.registerClass(gc);var Us=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.rate=Math.max(Math.min(r.rate,1),0),o.noiseShape=r.noiseShape,o.seed=r.seed,o.supportsMasking=!0,o}return u.prototype.getNoiseShape=function(r){if(this.noiseShape==null)return this.noiseShape;for(var o=r.shape,h=[],b=0;b<this.noiseShape.length;++b)h.push(this.noiseShape[b]==null?o[b]:this.noiseShape[b]);return h},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r);if(0<h.rate&&h.rate<1){var T=o.training==null?!1:o.training,M=h.getNoiseShape(b),q=Ye(function(){return $e(b,h.rate,M,h.seed)},function(){return b},T);return q}return r})},u.prototype.getConfig=function(){var r={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.prototype.dispose=function(){return s.prototype.dispose.call(this)},u.className="Dropout",u}(qr);i.serialization.registerClass(Us);var xc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.inputSpec=[{ndim:3}],o}return u.prototype.getNoiseShape=function(r){var o=r.shape;return[o[0],1,o[2]]},u.className="SpatialDropout1D",u}(Us);i.serialization.registerClass(xc);var Qi=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;if(o.activation=null,o.useBias=!0,o.kernel=null,o.bias=null,o.DEFAULT_KERNEL_INITIALIZER="glorotNormal",o.DEFAULT_BIAS_INITIALIZER="zeros",r.batchInputShape==null&&r.inputShape==null&&r.inputDim!=null){var h=null;r.batchSize!=null&&(h=r.batchSize),o.batchInputShape=[h,r.inputDim]}return o.units=r.units,tr(o.units,"units"),o.activation=va(r.activation),r.useBias!=null&&(o.useBias=r.useBias),o.kernelInitializer=x(r.kernelInitializer||o.DEFAULT_KERNEL_INITIALIZER),o.biasInitializer=x(r.biasInitializer||o.DEFAULT_BIAS_INITIALIZER),o.kernelConstraint=xn(r.kernelConstraint),o.biasConstraint=xn(r.biasConstraint),o.kernelRegularizer=Fn(r.kernelRegularizer),o.biasRegularizer=Fn(r.biasRegularizer),o.activityRegularizer=Fn(r.activityRegularizer),o.supportsMasking=!0,o.inputSpec=[{minNDim:2}],o}return u.prototype.build=function(r){var o;r=$r(r);var h=r[r.length-1];this.kernel==null&&(this.kernel=this.addWeight("kernel",[h,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:(o={},o[-1]=h,o)}],this.built=!0},u.prototype.computeOutputShape=function(r){r=$r(r);var o=r.slice();return o[o.length-1]=this.units,o},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r),T=Tn(h.activation.getClassName()),M;return T!=null?M=pe(b,h.kernel.read(),T,h.bias?h.bias.read():null):(M=pe(b,h.kernel.read()),h.bias!=null&&(M=te(M,h.bias.read())),h.activation!=null&&(M=h.activation.apply(M))),M})},u.prototype.getConfig=function(){var r={units:this.units,activation:Qa(this.activation),useBias:this.useBias,kernelInitializer:S(this.kernelInitializer),biasInitializer:S(this.biasInitializer),kernelRegularizer:dn(this.kernelRegularizer),biasRegularizer:dn(this.biasRegularizer),activityRegularizer:dn(this.activityRegularizer),kernelConstraint:rn(this.kernelConstraint),biasConstraint:rn(this.biasConstraint)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Dense",u}(qr);i.serialization.registerClass(Qi);var hu=function(s){O(u,s);function u(r){var o=this;return r=r||{},o=s.call(this,r)||this,o.inputSpec=[{minNDim:3}],o.dataFormat=r.dataFormat,o}return u.prototype.computeOutputShape=function(r){r=$r(r);for(var o=0,h=r.slice(1);o<h.length;o++){var b=h[o];if(b==null)throw new w('The shape of the input to "Flatten" is not fully defined '+("(got "+r.slice(1)+"). Make sure to pass a complete ")+'"input_shape" or "batch_input_shape" argument to the first layer in your model.')}return[r[0],pa(r,1)]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r);if(h.dataFormat==="channelsFirst"&&b.rank>1){for(var T=[0],M=2;M<b.rank;++M)T.push(M);T.push(1),b=b.transpose(T)}return ro(b)})},u.prototype.getConfig=function(){var r={};this.dataFormat!=null&&(r.dataFormat=this.dataFormat);var o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Flatten",u}(qr);i.serialization.registerClass(hu);var pr=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o.activation=va(r.activation),o}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r);return h.activation.apply(b)})},u.prototype.getConfig=function(){var r={activation:Qa(this.activation)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Activation",u}(qr);i.serialization.registerClass(pr);var Vs=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.n=r.n,o.inputSpec=[{ndim:2}],o}return u.prototype.computeOutputShape=function(r){return[r[0],this.n,r[1]]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){return r=ur(r),Di(r,h.n)})},u.prototype.getConfig=function(){var r={n:this.n},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="RepeatVector",u}(qr);i.serialization.registerClass(Vs);var Ho=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;o.targetShape=r.targetShape;for(var h=0;h<o.targetShape.length;++h)o.isUnknown(o.targetShape[h])&&(o.targetShape[h]=null);return o}return u.prototype.isUnknown=function(r){return r<0||r==null},u.prototype.fixUnknownDimension=function(r,o){for(var h="Total size of new array must be unchanged.",b=o.slice(),T=1,M=null,q=0;q<b.length;++q){var Y=b[q];if(this.isUnknown(Y))if(M===null)M=q;else throw new w("Can only specifiy one unknown dimension.");else T*=Y}var le=pa(r);if(M!==null){if(T===0||le%T!==0)throw new w(h);b[M]=le/T}else if(le!==T)throw new w(h);return b},u.prototype.computeOutputShape=function(r){for(var o=!1,h=0;h<r.length;++h)if(this.isUnknown(r[h])){o=!0;break}return o?r.slice(0,1).concat(this.targetShape):r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape))},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r),T=b.shape,M=T.slice(0,1).concat(h.fixUnknownDimension(T.slice(1),h.targetShape));return b.reshape(M)})},u.prototype.getConfig=function(){var r={targetShape:this.targetShape},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Reshape",u}(qr);i.serialization.registerClass(Ho);var Du=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;if(r.dims==null)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(r.dims))throw new Error("Permute constructor requires `dims` to be an Array, but received "+(r.dims+" instead."));var h=ln(1,r.dims.length+1);if(!i.util.arraysEqual(r.dims.slice().sort(),h))throw new Error("Invalid permutation `dims`: "+JSON.stringify(r.dims)+" `dims` must contain consecutive integers starting from 1.");return o.dims=r.dims,o.dimsIncludingBatch=[0].concat(o.dims),o.inputSpec=[new An({ndim:o.dims.length+1})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o=r.slice();return this.dims.forEach(function(h,b){o[b+1]=r[h]}),o},u.prototype.call=function(r,o){return i.transpose(ur(r),this.dimsIncludingBatch)},u.prototype.getConfig=function(){var r={dims:this.dims},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Permute",u}(qr);i.serialization.registerClass(Du);var _c=function(s){O(u,s);function u(r){var o=s.call(this,r??{})||this;return o.supportsMasking=!0,r!=null?o.maskValue=r.maskValue==null?0:r.maskValue:o.maskValue=0,o}return u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={maskValue:this.maskValue};return Object.assign(o,r),o},u.prototype.computeMask=function(r,o){var h=ur(r),b=-1;return i.any(i.notEqual(h,this.maskValue),b)},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r),T=-1,M=!0,q=i.any(i.notEqual(b,h.maskValue),T,M),Y=b.mul(q.asType(b.dtype));return Y})},u.className="Masking",u}(qr);i.serialization.registerClass(_c);var Fu=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;if(o.embeddings=null,o.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",r.batchInputShape==null&&r.inputShape==null){var h=null;r.batchSize!=null&&(h=r.batchSize),r.inputLength==null?o.batchInputShape=[h,null]:o.batchInputShape=[h].concat(Qe(r.inputLength))}return o.inputDim=r.inputDim,tr(o.inputDim,"inputDim"),o.outputDim=r.outputDim,tr(o.outputDim,"outputDim"),o.embeddingsInitializer=x(r.embeddingsInitializer||o.DEFAULT_EMBEDDINGS_INITIALIZER),o.embeddingsRegularizer=Fn(r.embeddingsRegularizer),o.activityRegularizer=Fn(r.activityRegularizer),o.embeddingsConstraint=xn(r.embeddingsConstraint),o.maskZero=r.maskZero,o.supportsMasking=r.maskZero,o.inputLength=r.inputLength,o}return u.prototype.build=function(r){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0},u.prototype.warnOnIncompatibleInputShape=function(r){},u.prototype.computeMask=function(r,o){var h=this;return i.tidy(function(){return h.maskZero?(r=ur(r),i.notEqual(r,i.zerosLike(r))):null})},u.prototype.computeOutputShape=function(r){if(r=$r(r),this.inputLength==null)return r.concat([this.outputDim]);var o=Qe(this.inputLength);if(o.length!==r.length-1)throw new w('"inputLength" is '+this.inputLength+", but received "+("input shape has shape "+r));for(var h=0,b=0;b<o.length;++b){var T=o[b],M=r[b+1];if(T!=null&&M!=null&&T!==M)throw new w('"inputLength" is '+this.inputLength+", but received "+("input shape has shape "+r));T==null&&(o[h]=M),h++}return[r[0]].concat(o,[this.outputDim])},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r);b.dtype!=="int32"&&(b=ni(b,"int32"));var T=X(h.embeddings.read(),b.as1D());return T.reshape($r(h.computeOutputShape(b.shape)))})},u.prototype.getConfig=function(){var r={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:S(this.embeddingsInitializer),embeddingsRegularizer:dn(this.embeddingsRegularizer),activityRegularizer:dn(this.activityRegularizer),embeddingsConstraint:rn(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Embedding",u}(qr);i.serialization.registerClass(Fu);var Go=function(s){O(u,s);function u(r){var o=s.call(this,r||{})||this;return o.supportsMasking=!0,o}return u.prototype.mergeFunction=function(r){throw new ge},u.prototype.computeElementwiseOpOutputShape=function(r,o){if(r==null||o==null)return null;if(r.length<o.length)return this.computeElementwiseOpOutputShape(o,r);if(o.length===0)return r;for(var h=r.slice(0,r.length-o.length),b=0;b<o.length;++b){var T=r[r.length-o.length+b],M=o[b];if(T==null||M==null||T<0||M<0)h.push(null);else if(T===1)h.push(M);else if(M===1)h.push(T);else{if(T!==M)throw new w("Operands could not be broadcast together with shapes "+JSON.stringify(r)+" "+JSON.stringify(o));h.push(T)}}return h},u.prototype.build=function(r){if(Array.isArray(r)&&!Array.isArray(r[0])&&(r=[$r(r)]),r=r,r.length<2)throw new w("A merge layer should be called on an Array of at least 2 inputs."+(" Got "+r.length+" input(s)."));for(var o=[],h=0,b=r;h<b.length;h++){var T=b[h];T!=null&&T[0]!==null&&o.push(T[0])}if(o=qt(o),o.length>1)throw new w("Can not merge tensors with different batch sizes. "+("Got tensors with shapes: "+JSON.stringify(r)+"."));for(var M=r[0]==null?null:r[0].slice(1),q=1;q<r.length;++q){var T=r[q]==null?null:r[q].slice(1);M=this.computeElementwiseOpOutputShape(M,T)}var Y=r.map(function(le){return le.length});r.indexOf(null)===-1&&qt(Y).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(r=r,h.reshapeRequired){var b=[],T=r.map(function(Ir){return Ir.rank});if(T.indexOf(null)===-1){for(var M=Va(T),q=0,Y=r;q<Y.length;q++){for(var le=Y[q],Ne=le.rank,We=0;We<M-Ne;++We)le=gr(le,1);b.push(le)}return h.mergeFunction(b)}else{for(var je=!1,qe=0,mt=r;qe<mt.length;qe++){var le=mt[qe],Ne=le.rank;if(Ne==null){var pt=le.shape,st=pt[0],dt=pt.slice(1).concat([st]),Dt=le.reshape([st].concat(pa(pt.slice(1))));Dt=i.transpose(Dt,[1,0]),Dt=Dt.reshape(dt),b.push(Dt),je=!0}else if(Ne>1){var or=ln(1,Ne).concat([0]);b.push(i.transpose(le,or)),je=!0}else b.push(le)}var Xt=h.mergeFunction(b),Jt=Xt.rank;if(je){if(Jt==null){var vr=Xt.shape,lr=vr.length,st=vr[lr-1],dt=[st].concat(vr.slice(0,vr.length-1));Xt=i.transpose(Xt.reshape([-1,st]),[1,0]).reshape(dt)}else if(Jt>1){var or=[Jt-1].concat(ln(0,Jt-1));Xt=i.transpose(Xt,or)}}return Xt}}else return h.mergeFunction(r)})},u.prototype.computeOutputShape=function(r){r=r;var o;r[0]==null?o=null:o=r[0].slice(1);for(var h=1;h<r.length;++h){var b=r[h]==null?null:r[h].slice(1);o=this.computeElementwiseOpOutputShape(o,b)}for(var T=[],M=0,q=r;M<q.length;M++){var b=q[M];b!=null&&b[0]!==null&&T.push(b[0])}return T=qt(T),T.length===1?o=T.concat(o):o=[null].concat(o),o},u.prototype.computeMask=function(r,o){return i.tidy(function(){if(o==null)return null;if(!Array.isArray(o))throw new w("`mask` should be an Array");if(!Array.isArray(r))throw new w("`inputs` should be an Array");if(o.length!==r.length)throw new w("The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths "+("("+r.length+" vs "+o.length+")"));if(o.every(function(T){return T==null}))return null;o=o.map(function(T){return T==null?T:i.expandDims(T,0)});for(var h=o[0],b=1;b<o.length-1;++b)h=i.logicalAnd(h,o[b]);return h})},u}(qr),wc=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.mergeFunction=function(r){return i.tidy(function(){for(var o=r[0].clone(),h=1;h<r.length;++h)o=i.add(o,r[h]);return o})},u.className="Add",u}(Go);i.serialization.registerClass(wc);var Ou=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.mergeFunction=function(r){return i.tidy(function(){for(var o=r[0].clone(),h=1;h<r.length;++h)o=i.mul(o,r[h]);return o})},u.className="Multiply",u}(Go);i.serialization.registerClass(Ou);var Hs=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.mergeFunction=function(r){return i.tidy(function(){for(var o=r[0].clone(),h=1;h<r.length;++h)o=i.add(o,r[h]);return i.mul(1/r.length,o)})},u.className="Average",u}(Go);i.serialization.registerClass(Hs);var bc=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.mergeFunction=function(r){return i.tidy(function(){for(var o=r[0],h=1;h<r.length;++h)o=i.maximum(o,r[h]);return o})},u.className="Maximum",u}(Go);i.serialization.registerClass(bc);var lo=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.mergeFunction=function(r){return i.tidy(function(){for(var o=r[0],h=1;h<r.length;++h)o=i.minimum(o,r[h]);return o})},u.className="Minimum",u}(Go);i.serialization.registerClass(lo);var kc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.DEFAULT_AXIS=-1,r==null&&(r={}),o.axis=r.axis==null?o.DEFAULT_AXIS:r.axis,o.supportsMasking=!0,o.reshapeRequired=!1,o}return u.prototype.build=function(r){if(!(Array.isArray(r)&&Array.isArray(r[0]))||r.length===1)throw new w("A `Concatenate` layer should be called on a list of at least 2 inputs");r=r;for(var o=!0,h=0,b=r;h<b.length;h++){var T=b[h];if(T!=null){o=!1;break}}if(o)return;for(var M=[],q=0;q<r.length;++q){var Y=r[q].slice();Y.splice(this.axis,1);for(var le=!1,Ne=0,We=M;Ne<We.length;Ne++){var T=We[Ne];if(i.util.arraysEqual(T,Y)){le=!0;break}}le||M.push(Y)}if(M.length>1)throw new w("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(r))},u.prototype.mergeFunction=function(r){var o=this;return i.tidy(function(){return ji(r,o.axis)})},u.prototype.computeOutputShape=function(r){if(!(Array.isArray(r)&&Array.isArray(r[0])))throw new w("A `Concatenate` layer should be called on a list of inputs.");for(var o=r,h=o[0].slice(),b=this.axis<0?h.length+this.axis:this.axis,T=0,M=o.slice(1);T<M.length;T++){var q=M[T];if(h[b]==null||q[b]==null){h[b]=null;break}h[b]+=q[b]}return h},u.prototype.computeMask=function(r,o){var h=this;if(o==null)return null;if(!Array.isArray(o))throw new w("`mask` should be an array for Concatenate");if(!Array.isArray(r))throw new w("`inputs` should be an array for Concatenate");if(o.length!==r.length)throw new w("Mismatch in the length of mask ("+o.length+") "+("and the legnth of inputs ("+r.length+")"));return i.tidy(function(){var b=!0;if(o.forEach(function(Y){if(Y!=null){b=!1;return}}),b)return null;for(var T=[],M=0;M<r.length;++M)o[M]==null?T.push(i.onesLike(r[M]).asType("bool")):o[M].rank<r[M].rank?T.push(i.expandDims(o[M],-1)):T.push(o[M]);var q=i.concat(T,h.axis);return i.all(q,-1,!1)})},u.prototype.getConfig=function(){var r={axis:this.axis},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Concatenate",u}(Go);i.serialization.registerClass(kc);function ho(s,u){for(;s<0;)s+=u;return s}function Sc(s,u,r){if(s.shape.length>3||u.shape.length>3)throw new ge("batchDot is not implemented for tensors of 4D or higher rank yet");if(i.util.assert(s.shape.length>=2,function(){return"batchDot requires the rank of x to be >= 2, "+("but got "+s.shape.length)}),i.util.assert(s.shape.length>=2,function(){return"batchDot requires the rank of y to be >= 2, "+("but got "+u.shape.length)}),typeof r=="number"&&(r=[r,r]),s.dtype==="complex64"||u.dtype==="complex64")throw new ge("batchDot is not implemented for complex64-type Tensors yet.");var o=s.shape.length,h=u.shape.length;r==null&&(r=[o-1,h-2]);var b=r;return i.tidy(function(){var T;if(o>h){T=o-h;for(var M=[],q=0;q<T;++q)M.push(1);u=u.reshape(u.shape.concat(M))}else if(h>o){T=h-o;for(var M=[],q=0;q<T;++q)M.push(1);s=s.reshape(s.shape.concat(M))}else T=0;var Y;if(s.shape.length===2&&u.shape.length===2)b[0]===b[1]?Y=s.mul(u).sum(b[0]):Y=s.transpose([1,0]).mul(u).sum(b[1]);else{var le=b[0]!==s.shape.length-1,Ne=b[1]===u.shape.length-1;Y=s.matMul(u,le,Ne)}if(T>0){var We=void 0;o>h?We=o+h-3:We=o-1;for(var je=[],q=We;q<We+T;++q)je.push(q);Y=Y.squeeze(je)}return Y.shape.length===1&&(Y=Y.expandDims(1)),Y})}var pu=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.axes=r.axes,o.normalize=r.normalize==null?!1:r.normalize,o.supportsMasking=!0,o.reshapeRequired=!1,o}return u.prototype.build=function(r){i.util.assert(Array.isArray(r)&&r.length===2&&Array.isArray(r[0])&&Array.isArray(r[1]),function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."});var o=r[0],h=r[1];if(o.length>3||h.length>3)throw new ge("Dot layer does not support tensors of 4D or higher rank yet.");var b=this.interpretAxes(o,h);if(o[b[0]]!==h[b[1]])throw new w("Dimension incompatibility: "+(o[b[0]]+" !== "+h[b[1]]))},u.prototype.mergeFunction=function(r){if(r.length!==2)throw new w("A `Dot` layer must be called on exactly 2 inputs, "+("but received "+r.length+" input(s)."));var o=r[0],h=r[1],b;return Array.isArray(this.axes)?b=this.axes.map(function(T,M){return ho(T,r[M].shape.length)}):b=[ho(this.axes,o.shape.length),ho(this.axes,h.shape.length)],this.normalize&&(o=Xa(o,b[0]),h=Xa(h,b[1])),Sc(o,h,b)},u.prototype.interpretAxes=function(r,o){var h;return Array.isArray(this.axes)?h=this.axes:h=[ho(this.axes,r.length),ho(this.axes,o.length)],h},u.prototype.computeOutputShape=function(r){i.util.assert(Array.isArray(r)&&r.length===2&&Array.isArray(r[0])&&Array.isArray(r[1]),function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."});var o=r[0].slice(),h=r[1].slice();if(o.length>3||h.length>3)throw new ge("Dot layer does not support tensors of 4D or higher rank yet.");var b=this.interpretAxes(o,h);o.splice(b[0],1),h.splice(b[1],1),h.splice(0,1);var T=o.concat(h);return T.length===1&&T.push(1),T},u.prototype.computeMask=function(r,o){return null},u.prototype.getConfig=function(){var r={axes:this.axes,normalize:this.normalize},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Dot",u}(Go);i.serialization.registerClass(pu);var Ic=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o.stddev=r.stddev,o}return u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={stddev:this.stddev};return Object.assign(o,r),o},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r),T=function(){return Mi(b.shape,0,h.stddev).add(b)},M=Ye(T,function(){return b},o.training||!1);return M})},u.className="GaussianNoise",u}(qr);i.serialization.registerClass(Ic);var Mu=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o.rate=r.rate,o}return u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={rate:this.rate};return Object.assign(o,r),o},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r);if(h.rate>0&&h.rate<1){var T=function(){var M=Math.sqrt(h.rate/(1-h.rate));return b.mul(Mi(b.shape,1,M))};return Ye(T,function(){return b},o.training||!1)}return b})},u.className="GaussianDropout",u}(qr);i.serialization.registerClass(Mu);var Gs=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o.rate=r.rate,o.noiseShape=r.noiseShape,o}return u.prototype._getNoiseShape=function(r){return this.noiseShape||ur(r).shape},u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={rate:this.rate};return Object.assign(o,r),o},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(h.rate<1&&h.rate>0){var b=h._getNoiseShape(r),T=function(){var M=ur(r),q=1.6732632423543772,Y=1.0507009873554805,le=-q*Y,Ne=i.greaterEqual(i.randomUniform(b),h.rate);Ne=ni(Ne,"float32");var We=Math.pow((1-h.rate)*(1+h.rate*Math.pow(le,2)),-.5),je=-We*le*h.rate,qe=M.mul(Ne).add(Ne.add(-1).mul(le));return qe.mul(We).add(je)};return Ye(T,function(){return ur(r)},o.training||!1)}return r})},u.className="AlphaDropout",u}(qr);i.serialization.registerClass(Gs);function po(s,u,r,o,h,b){b===void 0&&(b=.001);var T;if(s.rank===2)T=i.batchNorm2d(s,u,r,o,h,b);else if(s.rank===3)T=i.batchNorm3d(s,u,r,o,h,b);else if(s.rank===4)T=i.batchNorm4d(s,u,r,o,h,b);else throw new ge("batchNormalization is not implemented for array of rank "+s.rank+" yet");return T}function Lu(s,u,r,o,h){return h===void 0&&(h=.001),i.tidy(function(){var b=i.moments(s,o),T=b.mean,M=b.variance,q=po(s,T,M,r,u,h);return[q,T,M]})}function _l(s,u,r,o,h){return h===void 0&&(h=.001),i.tidy(function(){for(var b=i.moments(s,o),T=b.mean,M=b.variance,q=[],Y=0,le=ln(0,s.rank);Y<le.length;Y++){var Ne=le[Y];o.indexOf(Ne)!==-1?q.push(1):q.push(s.shape[Ne])}var We=T.reshape(q),je=M.reshape(q),qe=u==null?null:u.reshape(q),mt=r==null?null:r.reshape(q),pt=po(s,We,je,mt,qe,h);return[pt,T,M]})}function zu(s,u,r,o,h){return h===void 0&&(h=.001),i.util.arraysEqual(o.slice().sort(),ln(0,s.rank-1))?Lu(s,u,r,o,h):_l(s,u,r,o,h)}var Pu=function(s){O(u,s);function u(r){var o=this;return r==null&&(r={}),o=s.call(this,r)||this,o.supportsMasking=!0,o.axis=r.axis==null?-1:r.axis,o.momentum=r.momentum==null?.99:r.momentum,o.epsilon=r.epsilon==null?.001:r.epsilon,o.center=r.center==null?!0:r.center,o.scale=r.scale==null?!0:r.scale,o.betaInitializer=x(r.betaInitializer||"zeros"),o.gammaInitializer=x(r.gammaInitializer||"ones"),o.movingMeanInitializer=x(r.movingMeanInitializer||"zeros"),o.movingVarianceInitializer=x(r.movingVarianceInitializer||"ones"),o.betaConstraint=xn(r.betaConstraint),o.gammaConstraint=xn(r.gammaConstraint),o.betaRegularizer=Fn(r.betaRegularizer),o.gammaRegularizer=Fn(r.gammaRegularizer),o}return u.prototype.build=function(r){var o;r=$r(r);var h=this.axis>=0?this.axis:this.axis+r.length,b=r[h];if(b==null)throw new w("Axis "+h+" of input tensor should have a defined dimension but the layer received an input with shape "+(JSON.stringify(r)+"."));this.inputSpec=[new An({ndim:r.length,axes:(o={},o[h]=b,o)})];var T=[b];this.scale&&(this.gamma=this.addWeight("gamma",T,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",T,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",T,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",T,null,this.movingVarianceInitializer,null,!1),this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=o.training==null?!1:o.training,T=ur(r),M=T.shape,q=M.length,Y=ln(0,q),le=h.axis>=0?h.axis:h.axis+q;Y.splice(le,1);var Ne=nt(1,q);Ne[le]=M[le];var We=Y.slice();We.sort();var je=!i.util.arraysEqual(We,ln(0,q).slice(0,q-1)),qe=function(){if(je){var Xt=h.movingMean.read().reshape(Ne),Jt=h.movingVariance.read().reshape(Ne),vr=h.center?h.beta.read().reshape(Ne):null,lr=h.scale?h.gamma.read().reshape(Ne):null;return po(T,Xt,Jt,vr,lr,h.epsilon)}else return po(T,h.movingMean.read(),h.movingVariance.read(),h.beta==null?null:h.beta.read(),h.gamma==null?null:h.gamma.read(),h.epsilon)};if(!b)return qe();var mt=zu(T,h.gamma.read(),h.beta.read(),Y,h.epsilon),pt=mt[0],st=mt[1],dt=mt[2],Dt=function(Xt,Jt,vr){i.tidy(function(){var lr=1-vr,Ir=Xt.read(),Lr=Ir.sub(Jt).mul(lr);Xt.write(Ir.sub(Lr))})},or=function(){Dt(h.movingMean,st,h.momentum),Dt(h.movingVariance,dt,h.momentum)};return or(),pt})},u.prototype.getConfig=function(){var r={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:S(this.betaInitializer),gammaInitializer:S(this.gammaInitializer),movingMeanInitializer:S(this.movingMeanInitializer),movingVarianceInitializer:S(this.movingVarianceInitializer),betaRegularizer:dn(this.betaRegularizer),gammaRegularizer:dn(this.gammaRegularizer),betaConstraint:rn(this.betaConstraint),gammaConstraint:rn(this.gammaConstraint)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="BatchNormalization",u}(qr);i.serialization.registerClass(Pu);var du=function(s){O(u,s);function u(r){var o=this;if(r==null&&(r={}),o=s.call(this,r)||this,o.axis=r.axis==null?-1:r.axis,typeof o.axis=="number"){if(!Number.isInteger(o.axis))throw new Error("Expected axis to be an integer, but received "+o.axis)}else if(Array.isArray(o.axis))for(var h=0,b=o.axis;h<b.length;h++){var T=b[h];if(!Number.isInteger(T))throw new Error("Expected axis to be an array of integers, "+("but received "+JSON.stringify(o.axis)))}else throw new Error("Expected axis to be an integer or an array of integers, "+("but received "+JSON.stringify(o.axis)));return o.epsilon=r.epsilon==null?.001:r.epsilon,o.center=r.center==null?!0:r.center,o.scale=r.scale==null?!0:r.scale,o.betaInitializer=x(r.betaInitializer||"zeros"),o.gammaInitializer=x(r.gammaInitializer||"ones"),o.betaRegularizer=Fn(r.betaRegularizer),o.gammaRegularizer=Fn(r.gammaRegularizer),o.supportsMasking=!0,o}return u.prototype.build=function(r){r=$r(r);var o=r.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(var h=0;h<this.axis.length;++h)this.axis[h]<0&&(this.axis[h]+=o);for(var b=0,T=this.axis;b<T.length;b++){var M=T[b];if(M<0||M>=o)throw new Error("Invalid axis: "+M)}if(this.axis.length!==qt(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);var q=this.axis.map(function(le){return r[le]}),Y=!0;this.scale?this.gamma=this.addWeight("gamma",q,"float32",this.gammaInitializer,this.gammaRegularizer,Y):this.gamma=null,this.center?this.beta=this.addWeight("beta",q,"float32",this.betaInitializer,this.betaRegularizer,Y):this.beta=null,this.built=!0},u.prototype.call=function(r,o){var h=this,b=ur(r),T=b.shape,M=T.length;return i.tidy(function(){for(var q=!0,Y=i.moments(b,h.axis,q),le=Y.mean,Ne=Y.variance,We=nt(1,M),je=0,qe=h.axis;je<qe.length;je++){var mt=qe[je];We[mt]=T[mt]}for(var pt=function(Jt){return Jt!=null&&Jt.shape.length!==M&&h.axis!==[M-1]?Jt.reshape(We):Jt},st=pt(h.gamma.read()),dt=pt(h.beta.read()),Dt=[],or=[],Xt=0;Xt<M;++Xt)h.axis.indexOf(Xt)!==-1?(Dt.push(T[Xt]),or.push(1)):(Dt.push(1),or.push(T[Xt]));return le=le.tile(Dt),Ne=Ne.tile(Dt),st=st.tile(or),dt=dt.tile(or),po(b,le,Ne,dt,st,h.epsilon)})},u.prototype.getConfig=function(){var r={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:S(this.betaInitializer),gammaInitializer:S(this.gammaInitializer),betaRegularizer:dn(this.betaRegularizer),gammaRegularizer:dn(this.gammaRegularizer)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="LayerNormalization",u}(qr);i.serialization.registerClass(du);function wl(s,u,r){return i.tidy(function(){if(s.rank!==4)throw new w("temporalPadding expects input tensor to be 4-D, but received a "+(s.rank+"-D tensor."));if(u==null&&(u=[[1,1],[1,1]]),u.length!==2||u[0].length!==2||u[1].length!==2)throw new w("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(r==null&&(r=he()),r!=="channelsLast"&&r!=="channelsFirst")throw new w("Unknown data format: "+r+". Supported data formats are 'channelsLast' and 'channelsFirst.");var o;return r==="channelsFirst"?o=[[0,0],[0,0],u[0],u[1]]:o=[[0,0],u[0],u[1],[0,0]],i.pad(s,o)})}var fu=function(s){O(u,s);function u(r){var o=this;if(r==null&&(r={}),o=s.call(this,r)||this,o.dataFormat=r.dataFormat==null?he():r.dataFormat,r.padding==null)o.padding=[[1,1],[1,1]];else if(typeof r.padding=="number")o.padding=[[r.padding,r.padding],[r.padding,r.padding]];else{if(r.padding=r.padding,r.padding.length!==2)throw new w("ZeroPadding2D expects padding to be a length-2 array, but "+("received a length-"+r.padding.length+" array."));var h=void 0,b=void 0;if(typeof r.padding[0]=="number")h=[r.padding[0],r.padding[0]],b=[r.padding[1],r.padding[1]];else{if(r.padding=r.padding,r.padding[0].length!==2)throw new w("ZeroPadding2D expects height padding to be a length-2 array, "+("but received a length-"+r.padding[0].length+" array."));if(h=r.padding[0],r.padding[1].length!==2)throw new w("ZeroPadding2D expects width padding to be a length-2 array, "+("but received a length-"+r.padding[1].length+" array."));b=r.padding[1]}o.padding=[h,b]}return o.inputSpec=[new An({ndim:4})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o,h;return this.dataFormat==="channelsFirst"?(r[2]!=null&&r[2]>=0?o=r[2]+this.padding[0][0]+this.padding[0][1]:o=null,r[3]!=null&&r[3]>=0?h=r[3]+this.padding[1][0]+this.padding[1][1]:h=null,[r[0],r[1],o,h]):(r[1]!=null&&r[1]>=0?o=r[1]+this.padding[0][0]+this.padding[0][1]:o=null,r[2]!=null&&r[2]>=0?h=r[2]+this.padding[1][0]+this.padding[1][1]:h=null,[r[0],o,h,r[3]])},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){return wl(ur(r),h.padding,h.dataFormat)})},u.prototype.getConfig=function(){var r={padding:this.padding,dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="ZeroPadding2D",u}(qr);i.serialization.registerClass(fu);function mu(s,u,r,o,h,b){return i.tidy(function(){on(h),xa(b),_n(o),r==null&&(r=[1,1]),o==null&&(o="valid"),h==null&&(h=he()),b==null&&(b="max"),s=bo(s,h);var T,M=o==="same"?"same":"valid";return b==="max"?T=i.maxPool(s,u,r,M):T=i.avgPool(s,u,r,M),h==="channelsFirst"&&(T=i.transpose(T,[0,3,1,2])),T})}function Nc(s,u,r,o,h,b){return i.tidy(function(){on(h),xa(b),_n(o),r==null&&(r=[1,1,1]),o==null&&(o="valid"),h==null&&(h=he()),b==null&&(b="max"),s=so(s,h);var T,M=o==="same"?"same":"valid";return b==="max"?T=i.maxPool3d(s,u,r,M):T=i.avgPool3d(s,u,r,M),h==="channelsFirst"&&(T=i.transpose(T,[0,4,1,2,3])),T})}var Cc=function(s){O(u,s);function u(r){var o=this;if(r.poolSize==null&&(r.poolSize=2),o=s.call(this,r)||this,typeof r.poolSize=="number")o.poolSize=[r.poolSize];else if(Array.isArray(r.poolSize)&&r.poolSize.length===1&&typeof r.poolSize[0]=="number")o.poolSize=r.poolSize;else throw new w("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+(""+JSON.stringify(r.poolSize)));if(tr(o.poolSize,"poolSize"),r.strides==null)o.strides=o.poolSize;else if(typeof r.strides=="number")o.strides=[r.strides];else if(Array.isArray(r.strides)&&r.strides.length===1&&typeof r.strides[0]=="number")o.strides=r.strides;else throw new w("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+(""+JSON.stringify(r.strides)));return tr(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,_n(o.padding),o.inputSpec=[new An({ndim:3})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o=Ii(r[1],this.poolSize[0],this.padding,this.strides[0]);return[r[0],o,r[2]]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o),r=gr(ur(r),2);var b=h.poolingFunction(ur(r),[h.poolSize[0],1],[h.strides[0],1],h.padding,"channelsLast");return i.squeeze(b,[2])})},u.prototype.getConfig=function(){var r={poolSize:this.poolSize,padding:this.padding,strides:this.strides},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),Tc=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),mu(r,o,h,b,T,"max")},u.className="MaxPooling1D",u}(Cc);i.serialization.registerClass(Tc);var Ec=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),mu(r,o,h,b,T,"avg")},u.className="AveragePooling1D",u}(Cc);i.serialization.registerClass(Ec);var Ke=function(s){O(u,s);function u(r){var o=this;if(r.poolSize==null&&(r.poolSize=[2,2]),o=s.call(this,r)||this,o.poolSize=Array.isArray(r.poolSize)?r.poolSize:[r.poolSize,r.poolSize],r.strides==null)o.strides=o.poolSize;else if(Array.isArray(r.strides)){if(r.strides.length!==2)throw new w("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length "+(r.strides.length+"."));o.strides=r.strides}else o.strides=[r.strides,r.strides];return tr(o.poolSize,"poolSize"),tr(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,on(o.dataFormat),_n(o.padding),o.inputSpec=[new An({ndim:4})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o=this.dataFormat==="channelsFirst"?r[2]:r[1],h=this.dataFormat==="channelsFirst"?r[3]:r[2];return o=Ii(o,this.poolSize[0],this.padding,this.strides[0]),h=Ii(h,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[r[0],r[1],o,h]:[r[0],o,h,r[3]]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){return h.invokeCallHook(r,o),h.poolingFunction(ur(r),h.poolSize,h.strides,h.padding,h.dataFormat)})},u.prototype.getConfig=function(){var r={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),Rc=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),mu(r,o,h,b,T,"max")},u.className="MaxPooling2D",u}(Ke);i.serialization.registerClass(Rc);var un=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),mu(r,o,h,b,T,"avg")},u.className="AveragePooling2D",u}(Ke);i.serialization.registerClass(un);var Ac=function(s){O(u,s);function u(r){var o=this;if(r.poolSize==null&&(r.poolSize=[2,2,2]),o=s.call(this,r)||this,o.poolSize=Array.isArray(r.poolSize)?r.poolSize:[r.poolSize,r.poolSize,r.poolSize],r.strides==null)o.strides=o.poolSize;else if(Array.isArray(r.strides)){if(r.strides.length!==3)throw new w("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length "+(r.strides.length+"."));o.strides=r.strides}else o.strides=[r.strides,r.strides,r.strides];return tr(o.poolSize,"poolSize"),tr(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,on(o.dataFormat),_n(o.padding),o.inputSpec=[new An({ndim:5})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o=this.dataFormat==="channelsFirst"?r[2]:r[1],h=this.dataFormat==="channelsFirst"?r[3]:r[2],b=this.dataFormat==="channelsFirst"?r[4]:r[3];return o=Ii(o,this.poolSize[0],this.padding,this.strides[0]),h=Ii(h,this.poolSize[1],this.padding,this.strides[1]),b=Ii(b,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[r[0],r[1],o,h,b]:[r[0],o,h,b,r[4]]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){return h.invokeCallHook(r,o),h.poolingFunction(ur(r),h.poolSize,h.strides,h.padding,h.dataFormat)})},u.prototype.getConfig=function(){var r={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),Ss=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),Nc(r,o,h,b,T,"max")},u.className="MaxPooling3D",u}(Ac);i.serialization.registerClass(Ss);var Dc=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),Nc(r,o,h,b,T,"avg")},u.className="AveragePooling3D",u}(Ac);i.serialization.registerClass(Dc);var $n=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.inputSpec=[new An({ndim:3})],o}return u.prototype.computeOutputShape=function(r){return[r[0],r[2]]},u.prototype.call=function(r,o){throw new ge},u}(qr),Fc=function(s){O(u,s);function u(r){return s.call(this,r||{})||this}return u.prototype.call=function(r,o){return i.tidy(function(){var h=ur(r);return i.mean(h,1)})},u.className="GlobalAveragePooling1D",u}($n);i.serialization.registerClass(Fc);var Oc=function(s){O(u,s);function u(r){return s.call(this,r||{})||this}return u.prototype.call=function(r,o){return i.tidy(function(){var h=ur(r);return i.max(h,1)})},u.className="GlobalMaxPooling1D",u}($n);i.serialization.registerClass(Oc);var Mc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,on(o.dataFormat),o.inputSpec=[new An({ndim:4})],o}return u.prototype.computeOutputShape=function(r){return r=r,this.dataFormat==="channelsLast"?[r[0],r[3]]:[r[0],r[1]]},u.prototype.call=function(r,o){throw new ge},u.prototype.getConfig=function(){var r={dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),js=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=ur(r);return h.dataFormat==="channelsLast"?i.mean(b,[1,2]):i.mean(b,[2,3])})},u.className="GlobalAveragePooling2D",u}(Mc);i.serialization.registerClass(js);var is=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=ur(r);return h.dataFormat==="channelsLast"?i.max(b,[1,2]):i.max(b,[2,3])})},u.className="GlobalMaxPooling2D",u}(Mc);i.serialization.registerClass(is);var Lc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.layer=r.layer,o}return u.prototype.build=function(r){this.built=!0},Object.defineProperty(u.prototype,"trainable",{get:function(){return this.layer!=null?this.layer.trainable:!1},set:function(r){this.layer!=null&&(this.layer.trainable=r)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"trainableWeights",{get:function(){return this.layer.trainableWeights},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){return this.layer.nonTrainableWeights},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"updates",{get:function(){return this.layer._updates},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"losses",{get:function(){return this.layer.losses},enumerable:!0,configurable:!0}),u.prototype.getWeights=function(){return this.layer.getWeights()},u.prototype.setWeights=function(r){this.layer.setWeights(r)},u.prototype.getConfig=function(){var r={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.prototype.setFastWeightInitDuringBuild=function(r){s.prototype.setFastWeightInitDuringBuild.call(this,r),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(r)},u.fromConfig=function(r,o,h){h===void 0&&(h={});var b=o.layer,T=oa(b,h);delete o.layer;var M={layer:T};return Object.assign(M,o),new r(M)},u}(qr),zc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o}return u.prototype.build=function(r){if(r=$r(r),r.length<3)throw new w("TimeDistributed layer expects an input shape >= 3D, but received "+("input shape "+JSON.stringify(r)));this.inputSpec=[{shape:r}];var o=[r[0]].concat(r.slice(2));this.layer.built||(this.layer.build(o),this.layer.built=!0),s.prototype.build.call(this,r)},u.prototype.computeOutputShape=function(r){r=$r(r);var o=[r[0]].concat(r.slice(2)),h=this.layer.computeOutputShape(o),b=r[1];return[h[0],b].concat(h.slice(1))},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){r=ur(r);var b=function(q,Y){var le=ur(h.layer.call(q,o));return[le,[]]},T=yc(b,r,[],!1,null,null,!1,!0),M=T[1];return M})},u.className="TimeDistributed",u}(Lc);i.serialization.registerClass(zc);function yu(s){jr(wi,"BidirectionalMergeMode",s)}var Pc="concat",Bu=function(s){O(u,s);function u(r){var o=s.call(this,r)||this,h=r.layer.getConfig(),b={};b.className=r.layer.getClassName(),b.config=h,o.forwardLayer=oa(b),h.goBackwards=!(h.goBackwards===!0);var T={};if(T.className=r.layer.getClassName(),T.config=h,o.backwardLayer=oa(T),o.forwardLayer.name="forward_"+o.forwardLayer.name,o.backwardLayer.name="backward_"+o.backwardLayer.name,o.mergeMode=r.mergeMode===void 0?Pc:r.mergeMode,yu(o.mergeMode),r.weights)throw new ge("weights support is not implemented for Bidirectional layer yet.");return o._stateful=r.layer.stateful,o.returnSequences=r.layer.returnSequences,o.returnState=r.layer.returnState,o.supportsMasking=!0,o._trainable=!0,o.inputSpec=r.layer.inputSpec,o.numConstants=null,o}return Object.defineProperty(u.prototype,"trainable",{get:function(){return this._trainable},set:function(r){this._trainable=r,this.forwardLayer!=null&&(this.forwardLayer.trainable=r),this.backwardLayer!=null&&(this.backwardLayer.trainable=r)},enumerable:!0,configurable:!0}),u.prototype.getWeights=function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())},u.prototype.setWeights=function(r){var o=r.length,h=Math.floor(o/2);this.forwardLayer.setWeights(r.slice(0,h)),this.backwardLayer.setWeights(r.slice(h))},u.prototype.computeOutputShape=function(r){var o=this.forwardLayer.computeOutputShape(r);Array.isArray(o)&&Array.isArray(o[0])||(o=[o]),o=o;var h,b,T;return this.returnState&&(T=o.slice(1)),h=o[0],h=h,this.mergeMode==="concat"?(h[h.length-1]*=2,b=[h]):this.mergeMode==null?b=[h,h.slice()]:b=[h],this.returnState?this.mergeMode==null?b.concat(T).concat(T.slice()):[h].concat(T).concat(T.slice()):Tt(b)},u.prototype.apply=function(r,o){var h=o==null?null:o.initialState,b=o==null?null:o.constants;o==null&&(o={});var T=mc(r,h,b,this.numConstants);if(r=T.inputs,h=T.initialState,b=T.constants,Array.isArray(r)&&(h=r.slice(1),r=r[0]),(h==null||h.length===0)&&b==null)return s.prototype.apply.call(this,r,o);var M=[],q=[];if(h!=null){var Y=h.length;if(Y%2>0)throw new w("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");o.initialState=h,M.push.apply(M,h);var le=h.map(function(Dt){return new An({shape:Dt.shape})});this.forwardLayer.stateSpec=le.slice(0,Y/2),this.backwardLayer.stateSpec=le.slice(Y/2),q.push.apply(q,le)}if(b!=null)throw new ge("Support for constants in Bidirectional layers is not implemented yet.");for(var Ne=M[0]instanceof ba,We=0,je=M;We<je.length;We++){var qe=je[We];if(qe instanceof ba!==Ne)throw new w("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors")}if(Ne){var mt=[r].concat(M),pt=this.inputSpec.concat(q),st=this.inputSpec;this.inputSpec=pt;var dt=s.prototype.apply.call(this,mt,o);return this.inputSpec=st,dt}else return s.prototype.apply.call(this,r,o)},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=o.initialState,T,M;if(b==null)T=h.forwardLayer.call(r,o),M=h.backwardLayer.call(r,o);else{var q=b.slice(0,b.length/2),Y=b.slice(b.length/2);T=h.forwardLayer.call(r,Object.assign(o,{initialState:q})),M=h.backwardLayer.call(r,Object.assign(o,{initialState:Y}))}var le;h.returnState&&(Array.isArray(T)&&(le=T.slice(1).concat(M.slice(1))),T=T[0],M=M[0]),h.returnSequences&&(M=i.reverse(M,1));var Ne;return h.mergeMode==="concat"?Ne=ji([T,M]):h.mergeMode==="sum"?Ne=i.add(T,M):h.mergeMode==="ave"?Ne=i.mul(.5,i.add(T,M)):h.mergeMode==="mul"?Ne=i.mul(T,M):h.mergeMode==null&&(Ne=[T,M]),h.returnState?h.mergeMode==null?Ne.concat(le):[Ne].concat(le):Ne})},u.prototype.resetStates=function(r){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()},u.prototype.build=function(r){var o=this;_a(this.forwardLayer.name,function(){o.forwardLayer.build(r)}),_a(this.backwardLayer.name,function(){o.backwardLayer.build(r)}),this.built=!0},u.prototype.computeMask=function(r,o){Array.isArray(o)&&(o=o[0]);var h;if(this.returnSequences?this.mergeMode==null?h=[o,o]:h=o:this.mergeMode==null?h=[null,null]:h=null,this.returnState){var b=this.forwardLayer.states,T=b.map(function(M){return null});return Array.isArray(h)?h.concat(T).concat(T):[h].concat(T).concat(T)}else return h},Object.defineProperty(u.prototype,"trainableWeights",{get:function(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)},enumerable:!0,configurable:!0}),u.prototype.setFastWeightInitDuringBuild=function(r){s.prototype.setFastWeightInitDuringBuild.call(this,r),this.forwardLayer!=null&&this.forwardLayer.setFastWeightInitDuringBuild(r),this.backwardLayer!=null&&this.backwardLayer.setFastWeightInitDuringBuild(r)},u.prototype.getConfig=function(){var r={mergeMode:this.mergeMode},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.fromConfig=function(r,o){var h=oa(o.layer);if(delete o.layer,o.numConstants!=null)throw new ge("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");var b=o;return b.layer=h,new r(b)},u.className="Bidirectional",u}(Lc);i.serialization.registerClass(Bu);function bl(s){return new La(s)}function Zi(s){return new Su(s)}function Wu(s){return new su(s)}function os(s){return new cc(s)}function kl(s){return new si(s)}function Bc(s){return new lc(s)}function vu(s){return new Iu(s)}function Wc(s){return new pc(s)}function Uc(s){return new Tu(s)}function Vc(s){return new uo(s)}function Hc(s){return new hc(s)}function Gc(s){return new Eu(s)}function jc(s){return new dc(s)}function Uu(s){return new fc(s)}function Vu(s){return new Ru(s)}function qc(s){return new pr(s)}function Kc(s){return new Qi(s)}function Sl(s){return new Us(s)}function Il(s){return new xc(s)}function Hu(s){return new hu(s)}function Xc(s){return new Vs(s)}function Yc(s){return new Ho(s)}function ss(s){return new Du(s)}function jo(s){return new Fu(s)}function Nl(s){return new wc(s)}function Cl(s){return new Hs(s)}function Gu(s){return new kc(s)}function Tl(s){return new bc(s)}function gu(s){return new lo(s)}function ju(s){return new Ou(s)}function El(s){return new pu(s)}function Rl(s){return new Pu(s)}function Al(s){return new du(s)}function qs(s){return new fu(s)}function qu(s){return new Ec(s)}function Dl(s){return qu(s)}function Fl(s){return qu(s)}function Ku(s){return new un(s)}function Ol(s){return Ku(s)}function Ml(s){return Ku(s)}function Xu(s){return new Dc(s)}function Sa(s){return Xu(s)}function Ll(s){return Xu(s)}function zl(s){return new Fc(s)}function Pl(s){return new js(s)}function Qc(s){return new Oc(s)}function sa(s){return new is(s)}function Pa(s){return new Tc(s)}function xu(s){return new Rc(s)}function Zc(s){return new Ss(s)}function Bl(s){return new co(s)}function Wl(s){return new Wo(s)}function Ul(s){return new lu(s)}function Vl(s){return new Uo(s)}function Hl(s){return new vc(s)}function Gl(s){return new ks(s)}function jl(s){return new gc(s)}function ql(s){return new Au(s)}function Kl(s){return new Ni(s)}function Xl(s){return new as(s)}function Cr(s){return new Bu(s)}function Yl(s){return new zc(s)}var Yu=Qc,Ql=sa,Br=Pa,Jc=xu;function bt(s){return new Ic(s)}function Zl(s){return new Mu(s)}function ui(s){return new Gs(s)}function Jl(s){return new _c(s)}var $c={__proto__:null,inputLayer:bl,elu:Zi,reLU:Wu,leakyReLU:os,prelu:kl,softmax:Bc,thresholdedReLU:vu,conv1d:Wc,conv2d:Uc,conv2dTranspose:Vc,conv3d:Hc,separableConv2d:Gc,cropping2D:jc,upSampling2d:Uu,depthwiseConv2d:Vu,activation:qc,dense:Kc,dropout:Sl,spatialDropout1d:Il,flatten:Hu,repeatVector:Xc,reshape:Yc,permute:ss,embedding:jo,add:Nl,average:Cl,concatenate:Gu,maximum:Tl,minimum:gu,multiply:ju,dot:El,batchNormalization:Rl,layerNormalization:Al,zeroPadding2d:qs,averagePooling1d:qu,avgPool1d:Dl,avgPooling1d:Fl,averagePooling2d:Ku,avgPool2d:Ol,avgPooling2d:Ml,averagePooling3d:Xu,avgPool3d:Sa,avgPooling3d:Ll,globalAveragePooling1d:zl,globalAveragePooling2d:Pl,globalMaxPooling1d:Qc,globalMaxPooling2d:sa,maxPooling1d:Pa,maxPooling2d:xu,maxPooling3d:Zc,gru:Bl,gruCell:Wl,lstm:Ul,lstmCell:Vl,simpleRNN:Hl,simpleRNNCell:Gl,convLstm2d:jl,convLstm2dCell:ql,rnn:Kl,stackedRNNCells:Xl,bidirectional:Cr,timeDistributed:Yl,globalMaxPool1d:Yu,globalMaxPool2d:Ql,maxPool1d:Br,maxPool2d:Jc,Layer:qr,RNN:Ni,RNNCell:ns,input:hr,gaussianNoise:bt,gaussianDropout:Zl,alphaDropout:ui,masking:Jl};function $l(s,u){return Ao(s,u)}function el(s,u){return Os(s,u)}function eh(s,u){return ds(s,u)}function th(s,u){return Qo(s,u)}function Qu(s,u){return Do(s,u)}function tl(s,u){return ps(s,u)}function rl(s,u){return ru(s,u)}function ci(s,u){return Xo(s,u)}function nl(s,u){return oo(s,u)}function Ji(s,u){return ka(s,u)}function f(s,u){return ka(s,u)}function p(s,u){return ka(s,u)}function l(s,u){return Qn(s,u)}function m(s,u){return Qn(s,u)}function g(s,u){return Qn(s,u)}var I={__proto__:null,binaryAccuracy:$l,binaryCrossentropy:el,sparseCategoricalAccuracy:eh,categoricalAccuracy:th,categoricalCrossentropy:Qu,precision:tl,recall:rl,cosineProximity:ci,meanAbsoluteError:nl,meanAbsolutePercentageError:Ji,MAPE:f,mape:p,meanSquaredError:l,MSE:m,mse:g},R={__proto__:null,modelFromJSON:Vt};function z(s){return new Or(s)}function L(s){return Za(s)}function G(s){return rs(s)}var Z={__proto__:null,l1l2:z,l1:L,l2:G},be=function(s){O(u,s);function u(){var r=s!==null&&s.apply(this,arguments)||this;return r.model=null,r}return u.prototype.setModel=function(r){if(!(r instanceof wt))throw new Error("model must be a LayersModel, not some other Container");this.model=r},u}(Ka);function Ce(s,u){return s<u}function De(s,u){return s>u}var Te=function(s){O(u,s);function u(r){var o=s.call(this)||this;if(r==null&&(r={}),r.restoreBestWeights)throw new ge("restoreBestWeights = True is not implemented in EarlyStopping yet.");return o.monitor=r.monitor||"val_loss",o.minDelta=Math.abs(r.minDelta||0),o.patience=r.patience||0,o.verbose=r.verbose||0,o.mode=r.mode||"auto",o.baseline=r.baseline,["auto","min","max"].indexOf(o.mode)===-1&&(console.warn("EarlyStopping mode '"+o.mode+"' is invalid. Falling back to mode 'auto'."),o.mode="auto"),o.mode==="min"?o.monitorFunc=Ce:o.mode==="max"||o.monitor.indexOf("acc")!==-1?o.monitorFunc=De:o.monitorFunc=Ce,o.monitorFunc===Ce&&(o.minDelta*=-1),o}return u.prototype.onTrainBegin=function(r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return this.wait=0,this.stoppedEpoch=0,this.baseline!=null?this.best=this.baseline:this.best=this.monitorFunc===Ce?Infinity:-Infinity,[2]})})},u.prototype.onEpochEnd=function(r,o){return xe(this,void 0,void 0,function(){var h;return Q(this,function(b){switch(b.label){case 0:return[4,oi(o)];case 1:return b.sent(),h=this.getMonitorValue(o),h==null?[2]:(this.monitorFunc(h-this.minDelta,this.best)?(this.best=h,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=r,this.model.stopTraining=!0)),[2])}})})},u.prototype.onTrainEnd=function(r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return this.stoppedEpoch>0&&this.verbose&&console.log("Epoch "+this.stoppedEpoch+": early stopping."),[2]})})},u.prototype.getMonitorValue=function(r){r==null&&(r={});var o=r[this.monitor];return o==null&&console.warn("Metric for EarlyStopping "+this.monitor+" is not available. "+("Available metrics are: "+Object.keys(r))),o},u}(be);function Ge(s){return new Te(s)}var Ze={earlyStopping:Ge};N.Callback=be,N.CallbackList=ao,N.CustomCallback=Co,N.EarlyStopping=Te,N.History=No,N.InputSpec=An,N.LayerVariable=Ga,N.LayersModel=wt,N.RNN=Ni,N.Sequential=Ie,N.SymbolicTensor=ba,N.callbacks=Ze,N.constraints=Gn,N.initializers=xr,N.input=hr,N.layers=$c,N.loadLayersModel=Tr,N.metrics=I,N.model=br,N.models=R,N.registerCallbackConstructor=Dr,N.regularizers=Z,N.sequential=Nr,N.version_layers=gs}),sg=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=Object.assign||function(S){for(var x,k=1,K=arguments.length;k<K;k++){x=arguments[k];for(var Se in x)Object.prototype.hasOwnProperty.call(x,Se)&&(S[Se]=x[Se])}return S};function O(S,x,k,K){return new(k||(k=Promise))(function(Se,we){function Je(ft){try{vt(K.next(ft))}catch(zt){we(zt)}}function Be(ft){try{vt(K.throw(ft))}catch(zt){we(zt)}}function vt(ft){ft.done?Se(ft.value):new k(function(zt){zt(ft.value)}).then(Je,Be)}vt((K=K.apply(S,x||[])).next())})}function H(S,x){var k={label:0,sent:function(){if(we[0]&1)throw we[1];return we[1]},trys:[],ops:[]},K,Se,we,Je;return Je={next:Be(0),throw:Be(1),return:Be(2)},typeof Symbol=="function"&&(Je[Symbol.iterator]=function(){return this}),Je;function Be(ft){return function(zt){return vt([ft,zt])}}function vt(ft){if(K)throw new TypeError("Generator is already executing.");for(;k;)try{if(K=1,Se&&(we=Se[ft[0]&2?"return":ft[0]?"throw":"next"])&&!(we=we.call(Se,ft[1])).done)return we;(Se=0,we)&&(ft=[0,we.value]);switch(ft[0]){case 0:case 1:we=ft;break;case 4:return k.label++,{value:ft[1],done:!1};case 5:k.label++,Se=ft[1],ft=[0];continue;case 7:ft=k.ops.pop(),k.trys.pop();continue;default:if(!(we=k.trys,we=we.length>0&&we[we.length-1])&&(ft[0]===6||ft[0]===2)){k=0;continue}if(ft[0]===3&&(!we||ft[1]>we[0]&&ft[1]<we[3])){k.label=ft[1];break}if(ft[0]===6&&k.label<we[1]){k.label=we[1],we=ft;break}if(we&&k.label<we[2]){k.label=we[2],k.ops.push(ft);break}we[2]&&k.ops.pop(),k.trys.pop();continue}ft=x.call(S,k)}catch(zt){ft=[6,zt],Se=0}finally{K=we=0}if(ft[0]&5)throw ft[1];return{value:ft[0]?ft[1]:void 0,done:!0}}}function se(S,x){var k=typeof Symbol=="function"&&S[Symbol.iterator];if(!k)return S;var K=k.call(S),Se,we=[],Je;try{for(;(x===void 0||x-- >0)&&!(Se=K.next()).done;)we.push(Se.value)}catch(Be){Je={error:Be}}finally{try{Se&&!Se.done&&(k=K.return)&&k.call(K)}finally{if(Je)throw Je.error}}return we}function xe(){for(var S=[],x=0;x<arguments.length;x++)S=S.concat(se(arguments[x]));return S}var Q;(function(S){S[S.DT_INVALID=0]="DT_INVALID",S[S.DT_FLOAT=1]="DT_FLOAT",S[S.DT_DOUBLE=2]="DT_DOUBLE",S[S.DT_INT32=3]="DT_INT32",S[S.DT_UINT8=4]="DT_UINT8",S[S.DT_INT16=5]="DT_INT16",S[S.DT_INT8=6]="DT_INT8",S[S.DT_STRING=7]="DT_STRING",S[S.DT_COMPLEX64=8]="DT_COMPLEX64",S[S.DT_INT64=9]="DT_INT64",S[S.DT_BOOL=10]="DT_BOOL",S[S.DT_QINT8=11]="DT_QINT8",S[S.DT_QUINT8=12]="DT_QUINT8",S[S.DT_QINT32=13]="DT_QINT32",S[S.DT_BFLOAT16=14]="DT_BFLOAT16",S[S.DT_FLOAT_REF=101]="DT_FLOAT_REF",S[S.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",S[S.DT_INT32_REF=103]="DT_INT32_REF",S[S.DT_UINT8_REF=104]="DT_UINT8_REF",S[S.DT_INT16_REF=105]="DT_INT16_REF",S[S.DT_INT8_REF=106]="DT_INT8_REF",S[S.DT_STRING_REF=107]="DT_STRING_REF",S[S.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",S[S.DT_INT64_REF=109]="DT_INT64_REF",S[S.DT_BOOL_REF=110]="DT_BOOL_REF",S[S.DT_QINT8_REF=111]="DT_QINT8_REF",S[S.DT_QUINT8_REF=112]="DT_QUINT8_REF",S[S.DT_QINT32_REF=113]="DT_QINT32_REF",S[S.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF"})(Q||(Q={}));var Ae;(function(S){var x;(function(k){k[k.LEGACY=0]="LEGACY",k[k.V1=1]="V1",k[k.V2=2]="V2"})(x=S.CheckpointFormatVersion||(S.CheckpointFormatVersion={}))})(Ae||(Ae={}));var P={};function he(S,x){var k={tfOpName:S,category:"custom",inputs:[],attrs:[],customExecutor:x};P[S]=k}function me(S){return P[S]}function ae(S){delete P[S]}function w(S,x,k,K,Se){var we=x.inputParams[S];if(we&&we.inputIndexStart!==void 0){var Je=we.inputIndexStart,Be=we.inputIndexEnd===0?void 0:we.inputIndexEnd===void 0?Je+1:we.inputIndexEnd;if(we.type==="tensor")return ge(x.inputNames[we.inputIndexStart],k,K,Se);if(we.type==="tensors"){var vt=x.inputNames.slice(Je,Be);return vt.map(function(Gt){return ge(Gt,k,K,Se)})}var ft=ge(x.inputNames.slice(Je)[0],k,K,Se),zt=ft.dataSync();return we.type==="number"?zt[0]:i.util.toNestedArray(ft.shape,zt)}var Wt=x.attrParams[S];return Wt&&Wt.value}function ge(S,x,k,K){var Se=se(tt(S),2),we=Se[0],Je=Se[1];if(K!=null){var Be=K.getHashTableHandleByName(we);if(Be!=null)return Be}var vt=k.currentContextIds.find(function(ft){return!!x[nt(we,ft)]});return vt!==void 0?x[nt(we,vt)][Je]:void 0}function ze(S,x,k){return x[nt(S,k.currentContextId)]}function W(S,x){var k=se(tt(S),2),K=k[0],Se=k[1];return[nt(K,x&&x.currentContextId),Se]}function nt(S,x){return x?S+"-"+x:S}function tt(S){var x=S.split(":");if(x.length===1)return[S,0];var k=x[0];return[k,Number(x[x.length-1])]}function nr(S,x,k){var K=w("pad",S,x,k);if(K==="explicit"){K=w("explicitPaddings",S,x,k);for(var Se=[[0,0],[0,0],[0,0],[0,0]],we=0;we<4;we++)Se[we][0]=K[we*2],Se[we][1]=K[we*2+1];return Se}return K}function Tt(S){return S.kept?S:i.clone(S)}var Qe=[{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}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}]},{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}]}],it={__proto__:null,json:Qe},xt=[{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"}],attrs:[{tfName:"clip_value_min",name:"clipValueMin",type:"number"},{tfName:"clip_value_max",name:"clipValueMax",type:"number"}]},{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},{tfName:"clipValueMin",name:"clipValueMin",type:"number",defaultValue:0},{tfName:"clipValueMax",name:"clipValueMax",type:"number",defaultValue:6}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],ot={__proto__:null,json:xt},ht=[{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]}],ut={__proto__:null,json:ht},yt=[{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:"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}]},{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:[]}]},{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:[]}]},{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"}]}],Zt={__proto__:null,json:yt},ar=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],qt={__proto__:null,json:ar},Ur=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],jr={__proto__:null,json:Ur},_r=[{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],tr={__proto__:null,json:_r},Fa=[{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"}]}],Oa={__proto__:null,json:Fa},Tn=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]}],Wa={__proto__:null,json:Tn},Na=[{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:"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:"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"}]}],yn={__proto__:null,json:Na},Ma=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],li={__proto__:null,json:Ma},hi=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],la={__proto__:null,json:hi},rn=[{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}],Ca={__proto__:null,json:rn},xn=[{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],Hn={__proto__:null,json:xn},_i=[{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}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{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",notSupported:!0}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],ha={__proto__:null,json:_i},Ei=[{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}]}],Gn={__proto__:null,json:Ei},jn=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]}],Ua={__proto__:null,json:jn},ga=function(){function S(){var x=[it,ot,ut,Zt,qt,jr,tr,li,yn,Oa,la,Ca,Hn,ha,Gn,Ua,Wa],k=[].concat.apply([],xe(x.map(function(K){return K.json})));this.opMappers=k.reduce(function(K,Se){return K[Se.tfOpName]=Se,K},{})}return Object.defineProperty(S,"Instance",{get:function(){return this._instance||(this._instance=new this)},enumerable:!0,configurable:!0}),S.prototype.transformGraph=function(x,k){var K=this;k===void 0&&(k={});var Se=x.node,we=[],Je=[],Be=[],vt=Se.reduce(function(Yt,xr){return Yt[xr.name]=K.mapNode(xr),xr.op.startsWith("Placeholder")?we.push(Yt[xr.name]):xr.op==="Const"?Je.push(Yt[xr.name]):(xr.input==null||xr.input.length===0)&&Be.push(Yt[xr.name]),Yt},{}),ft=[],zt=[],Wt={},Gt={};k!=null&&(Wt=this.mapSignatureEntries(k.inputs),Gt=this.mapSignatureEntries(k.outputs));var Qt=Object.keys(vt);Qt.forEach(function(Yt){var xr=vt[Yt];xr.inputNames.forEach(function(Sn){var pn=se(W(Sn),1),zn=pn[0];xr.inputs.push(vt[zn]),vt[zn].children.push(xr)})}),Object.keys(Gt).length===0?Qt.forEach(function(Yt){var xr=vt[Yt];xr.children.length===0&&zt.push(xr)}):Object.keys(Gt).forEach(function(Yt){var xr=se(W(Yt),1),Sn=xr[0],pn=vt[Sn];pn!=null&&(pn.signatureKey=Gt[Yt],zt.push(pn))}),Object.keys(Wt).length>0?Object.keys(Wt).forEach(function(Yt){var xr=se(W(Yt),1),Sn=xr[0],pn=vt[Sn];pn&&(pn.signatureKey=Wt[Yt],ft.push(pn))}):ft=we;var wr={};x.library!=null&&x.library.function!=null&&(wr=x.library.function.reduce(function(Yt,xr){return Yt[xr.signature.name]=K.mapFunction(xr),Yt},{}));var Ar={nodes:vt,inputs:ft,outputs:zt,weights:Je,placeholders:we,signature:k,functions:wr};return Be.length>0&&(Ar.initNodes=Be),Ar},S.prototype.mapSignatureEntries=function(x){return Object.keys(x||{}).reduce(function(k,K){return k[x[K].name]=K,k},{})},S.prototype.mapNode=function(x){var k=me(x.op)||this.opMappers[x.op]||{};x.attr==null&&(x.attr={});var K={name:x.name,op:x.op,category:k.category,inputNames:(x.input||[]).map(function(Se){return Se.startsWith("^")?Se.substr(1):Se}),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:x.attr};return k.inputs!=null&&(K.inputParams=k.inputs.reduce(function(Se,we){return Se[we.name]={type:we.type,inputIndexStart:we.start,inputIndexEnd:we.end},Se},{})),k.attrs!=null&&(K.attrParams=k.attrs.reduce(function(Se,we){var Je=we.type,Be=void 0;switch(we.type){case"string":Be=on(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=on(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"string[]":Be=ri(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=ri(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"number":Be=xa(x.attr,we.tfName,we.defaultValue||0),Be===void 0&&!!we.tfDeprecatedName&&(Be=xa(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"number[]":Be=qn(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=qn(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"bool":Be=_n(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=_n(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"bool[]":Be=pa(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=pa(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"shape":Be=Ai(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=Ai(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"shape[]":Be=pi(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=pi(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"dtype":Be=_a(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=_a(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"dtype[]":Be=Ri(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=Ri(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"func":Be=ti(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=ti(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: "+we.type+" for op: "+x.op)}return Se[we.name]={value:Be,type:Je},Se},{})),K},S.prototype.mapFunction=function(x){var k=this,K=x.nodeDef,Se=[],we=[],Je={};K!=null&&(Je=K.reduce(function(Gt,Qt){return Gt[Qt.name]=k.mapNode(Qt),Qt.op==="Const"&&we.push(Gt[Qt.name]),Gt},{}));var Be=[],vt=[];x.signature.inputArg.forEach(function(Gt){var Qt=se(W(Gt.name),1),wr=Qt[0],Ar={name:wr,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:Rr(Gt.type),type:"dtype"}},children:[]};Ar.signatureKey=Gt.name,Be.push(Ar),Je[wr]=Ar});var ft=Object.keys(Je);ft.forEach(function(Gt){var Qt=Je[Gt];Qt.inputNames.forEach(function(wr){var Ar=se(W(wr),1),Yt=Ar[0];Qt.inputs.push(Je[Yt]),Je[Yt].children.push(Qt)})});var zt=x.ret;x.signature.outputArg.forEach(function(Gt){var Qt=se(W(zt[Gt.name]),2),wr=Qt[0],Ar=Qt[1],Yt=Je[wr];Yt!=null&&(Yt.defaultOutput=Ar,vt.push(Yt))});var Wt=this.mapArgsToSignature(x);return{nodes:Je,inputs:Be,outputs:vt,weights:we,placeholders:Se,signature:Wt}},S.prototype.mapArgsToSignature=function(x){var k=this;return{methodName:x.signature.name,inputs:x.signature.inputArg.reduce(function(K,Se){return K[Se.name]=k.mapArgToTensorInfo(Se),K},{}),outputs:x.signature.outputArg.reduce(function(K,Se){return K[Se.name]=k.mapArgToTensorInfo(Se,x.ret),K},{})}},S.prototype.mapArgToTensorInfo=function(x,k){var K=x.name;return k!=null&&(K=k[K]),{name:K,dtype:x.type}},S}();function wi(S){var x=i.env().global;if(typeof x.atob!="undefined")return x.atob(S);if(typeof Buffer!="undefined")return new Buffer(S,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}function Ta(S,x){var k=Array.isArray(S)?String.fromCharCode.apply(null,S):wi(S);return x?k:k.toLowerCase()}function on(S,x,k,K){K===void 0&&(K=!1);var Se=S[x];return Se!=null?Ta(Se.s,K):k}function _n(S,x,k){var K=S[x];return K?K.b:k}function xa(S,x,k){var K=S[x]||{},Se=K.i!=null?K.i:K.f!=null?K.f:k;return typeof Se=="number"?Se:parseInt(Se,10)}function Rr(S){typeof S=="string"&&(S=Q[S]);switch(S){case Q.DT_FLOAT:return"float32";case Q.DT_INT32:case Q.DT_INT64:case Q.DT_INT8:case Q.DT_UINT8:return"int32";case Q.DT_BOOL:return"bool";case Q.DT_DOUBLE:return"float32";case Q.DT_STRING:return"string";default:return null}}function ti(S,x,k){var K=S[x];return K&&K.func?K.func.name:k}function _a(S,x,k){var K=S[x];return K&&K.type?Rr(K.type):k}function Ri(S,x,k){var K=S[x];return K&&K.list&&K.list.type?K.list.type.map(function(Se){return Rr(Se)}):k}function Hi(S){return S.unknownRank?void 0:S.dim!=null?S.dim.map(function(x){return typeof x.size=="number"?x.size:parseInt(x.size,10)}):[]}function Ai(S,x,k){var K=S[x];return K&&K.shape?Hi(K.shape):k}function qn(S,x,k){var K=S[x];return K?((K.list.f&&K.list.f.length?K.list.f:K.list.i)||[]).map(function(Se){return typeof Se=="number"?Se:parseInt(Se,10)}):k}function ri(S,x,k,K){K===void 0&&(K=!1);var Se=S[x];return Se&&Se.list&&Se.list.s?Se.list.s.map(function(we){return Ta(we,K)}):k}function pi(S,x,k){var K=S[x];return K&&K.list&&K.list.shape?K.list.shape.map(function(Se){return Hi(Se)}):k}function pa(S,x,k){var K=S[x];return K&&K.list&&K.list.b?K.list.b:k}var di=function(){function S(x,k,K){var Se=this;this.node=x,this.tensorMap=k,this.context=K,this.inputs=[],this.attrs={},this.inputs=x.inputNames.map(function(we){return Se.getInput(we)}),x.rawAttrs!=null&&(this.attrs=Object.keys(x.rawAttrs).reduce(function(we,Je){return we[Je]=Se.getAttr(Je),we},{}))}return S.prototype.getInput=function(x){return ge(x,this.tensorMap,this.context)},S.prototype.getAttr=function(x,k){var K=this.node.rawAttrs[x];if(K.tensor!=null)return ge(x,this.tensorMap,this.context);if(K.i!=null||K.f!=null)return xa(this.node.rawAttrs,x,k);if(K.s!=null)return on(this.node.rawAttrs,x,k);if(K.b!=null)return _n(this.node.rawAttrs,x,k);if(K.shape!=null)return Ai(this.node.rawAttrs,x,k);if(K.type!=null)return _a(this.node.rawAttrs,x,k);if(K.list!=null){if(K.list.i!=null||K.list.f!=null)return qn(this.node.rawAttrs,x,k);if(K.list.s!=null)return ri(this.node.rawAttrs,x,k);if(K.list.shape!=null)return pi(this.node.rawAttrs,x,k);if(K.list.b!=null)return pa(this.node.rawAttrs,x,k);if(K.list.type!=null)return Ri(this.node.rawAttrs,x,k)}return k},S}(),fi=function(S,x,k){switch(S.op){case"BiasAdd":case"AddV2":case"Add":return[i.add(w("a",S,x,k),w("b",S,x,k))];case"AddN":return[i.addN(w("tensors",S,x,k))];case"FloorMod":case"Mod":return[i.mod(w("a",S,x,k),w("b",S,x,k))];case"Mul":return[i.mul(w("a",S,x,k),w("b",S,x,k))];case"RealDiv":case"Div":return[i.div(w("a",S,x,k),w("b",S,x,k))];case"DivNoNan":return[i.divNoNan(w("a",S,x,k),w("b",S,x,k))];case"FloorDiv":return[i.floorDiv(w("a",S,x,k),w("b",S,x,k))];case"Sub":return[i.sub(w("a",S,x,k),w("b",S,x,k))];case"Minimum":return[i.minimum(w("a",S,x,k),w("b",S,x,k))];case"Maximum":return[i.maximum(w("a",S,x,k),w("b",S,x,k))];case"Pow":return[i.pow(w("a",S,x,k),w("b",S,x,k))];case"SquaredDifference":return[i.squaredDifference(w("a",S,x,k),w("b",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}},Va=function(S,x,k){switch(S.op){case"Abs":case"ComplexAbs":return[i.abs(w("x",S,x,k))];case"Acos":return[i.acos(w("x",S,x,k))];case"Acosh":return[i.acosh(w("x",S,x,k))];case"Asin":return[i.asin(w("x",S,x,k))];case"Asinh":return[i.asinh(w("x",S,x,k))];case"Atan":return[i.atan(w("x",S,x,k))];case"Atan2":return[i.atan2(w("x",S,x,k),w("y",S,x,k))];case"Atanh":return[i.atanh(w("x",S,x,k))];case"Ceil":return[i.ceil(w("x",S,x,k))];case"Complex":return[i.complex(w("real",S,x,k),w("imag",S,x,k))];case"Cos":return[i.cos(w("x",S,x,k))];case"Cosh":return[i.cosh(w("x",S,x,k))];case"Elu":return[i.elu(w("x",S,x,k))];case"Erf":return[i.erf(w("x",S,x,k))];case"Exp":return[i.exp(w("x",S,x,k))];case"Expm1":return[i.expm1(w("x",S,x,k))];case"Floor":return[i.floor(w("x",S,x,k))];case"Log":return[i.log(w("x",S,x,k))];case"Log1p":return[i.log1p(w("x",S,x,k))];case"Imag":return[i.imag(w("x",S,x,k))];case"Neg":return[i.neg(w("x",S,x,k))];case"Reciprocal":return[i.reciprocal(w("x",S,x,k))];case"Real":return[i.real(w("x",S,x,k))];case"Relu":return[i.relu(w("x",S,x,k))];case"Round":return[i.round(w("x",S,x,k))];case"Selu":return[i.selu(w("x",S,x,k))];case"Sigmoid":return[i.sigmoid(w("x",S,x,k))];case"Sin":return[i.sin(w("x",S,x,k))];case"Sign":return[i.sign(w("x",S,x,k))];case"Sinh":return[i.sinh(w("x",S,x,k))];case"Softplus":return[i.softplus(w("x",S,x,k))];case"Sqrt":return[i.sqrt(w("x",S,x,k))];case"Square":return[i.square(w("x",S,x,k))];case"Tanh":return[i.tanh(w("x",S,x,k))];case"Tan":return[i.tan(w("x",S,x,k))];case"Relu6":case"ClipByValue":return[i.clipByValue(w("x",S,x,k),w("clipValueMin",S,x,k),w("clipValueMax",S,x,k))];case"Rsqrt":return[i.rsqrt(ge(S.inputNames[0],x,k))];case"Prod":return[i.prod(w("x",S,x,k),w("axes",S,x,k))];case"LeakyRelu":return[i.leakyRelu(w("x",S,x,k),w("alpha",S,x,k))];case"Prelu":return[i.prelu(w("x",S,x,k),w("alpha",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}};function ln(S,x,k){k===void 0&&(k=""),i.util.assert(ni(S,x),function(){return k+(" Shapes "+S+" and "+x+" must match")})}function ni(S,x){if(S.length!==x.length)return!1;for(var k=0;k<S.length;k++)if(S[k]!==-1&&x[k]!==-1&&S[k]!==x[k])return!1;return!0}var gr=function(){function S(x,k,K,Se,we,Je,Be){this.name=x,this.dtype=k,this.maxSize=K,this.elementShape=Se,this.identicalElementShapes=we,this.dynamicSize=Je,this.clearAfterRead=Be,this.tensors=[],this.closed_=!1,this.idTensor=i.scalar(0),i.keep(this.idTensor)}return Object.defineProperty(S.prototype,"id",{get:function(){return this.idTensor.id},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"closed",{get:function(){return this.closed_},enumerable:!0,configurable:!0}),S.prototype.clearAndClose=function(x){this.tensors.forEach(function(k){(x==null||!x.has(k.tensor.id))&&k.tensor.dispose()}),this.tensors=[],this.closed_=!0,this.idTensor.dispose()},S.prototype.size=function(){return this.tensors.length},S.prototype.read=function(x){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(x<0||x>=this.size())throw new Error("Tried to read from index "+x+", but array size is: "+this.size());var k=this.tensors[x];if(k.cleared)throw new Error("TensorArray "+this.name+": Could not read index "+x+" twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).");return this.clearAfterRead&&(k.cleared=!0),k.read=!0,k.tensor},S.prototype.readMany=function(x){var k=this;return x.map(function(K){return k.read(K)})},S.prototype.write=function(x,k){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(x<0||!this.dynamicSize&&x>=this.maxSize)throw new Error("Tried to write to index "+x+", but array is not resizeable and size is: "+this.maxSize);var K=this.tensors[x]||{};if(k.dtype!==this.dtype)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+x+`,
because the value dtype is `+k.dtype+", but TensorArray dtype is "+this.dtype+".");if(this.size()===0&&(this.elementShape==null||this.elementShape.length===0)&&(this.elementShape=k.shape),ln(this.elementShape,k.shape,"TensorArray "+this.name+": Could not write to TensorArray index "+x+"."),K.read)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+x+", because it has already been read.");if(K.written)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+x+", because it has already been written.");K.tensor=k,i.keep(k),K.written=!0,this.tensors[x]=K},S.prototype.writeMany=function(x,k){var K=this;if(x.length!==k.length)throw new Error("TensorArray "+this.name+": could not write multiple tensors,"+("because the index size: "+x.length+" is not the same as tensors size: "+k.length+"."));x.forEach(function(Se,we){return K.write(Se,k[we])})},S.prototype.gather=function(x,k){if(!!k&&k!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but gather requested dtype "+k);if(x)x=x.slice(0,this.size());else{x=[];for(var K=0;K<this.size();K++)x.push(K)}if(x.length===0)return i.tensor([],[0].concat(this.elementShape));var Se=this.readMany(x);return ln(this.elementShape,Se[0].shape,"TensorArray shape mismatch: "),i.stack(Se,0)},S.prototype.concat=function(x){if(!!x&&x!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but concat requested dtype "+x);if(this.size()===0)return i.tensor([],[0].concat(this.elementShape));for(var k=[],K=0;K<this.size();K++)k.push(K);var Se=this.readMany(k);return ln(this.elementShape,Se[0].shape,"TensorArray shape mismatch: tensor array shape ("+this.elementShape+") vs first tensor shape ("+Se[0].shape+")"),i.concat(Se,0)},S.prototype.scatter=function(x,k){if(k.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+k.dtype);if(x.length!==k.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+x.length+" vs. "+k.shape[0]);var K=Math.max.apply(Math,xe(x));if(!this.dynamicSize&&K>=this.maxSize)throw new Error("Max index must be < array size ("+K+" vs. "+this.maxSize+")");this.writeMany(x,i.unstack(k,0))},S.prototype.split=function(x,k){var K=this;if(k.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+k.dtype);var Se=0,we=x.map(function(zt){return Se+=zt,Se});if(Se!==k.shape[0])throw new Error(`Expected sum of lengths to be equal to
tensor.shape[0], but sum of lengths is
`+Se+", and tensor's shape is: "+k.shape);if(!this.dynamicSize&&x.length!==this.maxSize)throw new Error("TensorArray's size is not equal to the size of lengths ("+this.maxSize+" vs. "+x.length+"), and the TensorArray is not marked as dynamically resizeable");var Je=Se===0?0:k.size/Se,Be=[];i.tidy(function(){k=i.reshape(k,[1,Se,Je]);for(var zt=0;zt<x.length;++zt){var Wt=zt===0?0:we[zt-1],Gt=[0,Wt,0],Qt=[1,x[zt],Je];Be[zt]=i.reshape(i.slice(k,Gt,Qt),K.elementShape)}return Be});for(var vt=[],ft=0;ft<x.length;ft++)vt[ft]=ft;this.writeMany(vt,Be)},S}(),Di=function(){function S(x,k,K,Se){Se===void 0&&(Se=-1),this.tensors=x,this.elementShape=k,this.elementDtype=K,x!=null&&x.forEach(function(we){if(K!==we.dtype)throw new Error("Invalid data types; op elements "+K+", but list elements "+we.dtype);ln(k,we.shape,"TensorList shape mismatch: "),i.keep(we)}),this.idTensor=i.scalar(0),this.maxNumElements=Se,i.keep(this.idTensor)}return Object.defineProperty(S.prototype,"id",{get:function(){return this.idTensor.id},enumerable:!0,configurable:!0}),S.prototype.copy=function(){return new S(xe(this.tensors),this.elementShape,this.elementDtype)},S.prototype.clearAndClose=function(x){this.tensors.forEach(function(k){(x==null||!x.has(k.id))&&k.dispose()}),this.tensors.length=0,this.idTensor.dispose()},S.prototype.size=function(){return this.tensors.length},S.prototype.stack=function(x,k,K){var Se=this;if(K===void 0&&(K=-1),k!==this.elementDtype)throw new Error("Invalid data types; op elements "+k+", but list elements "+this.elementDtype);if(K!==-1&&this.tensors.length!==K)throw new Error("Operation expected a list with "+K+" elements but got a list with "+this.tensors.length+" elements.");return ln(x,this.elementShape,"TensorList shape mismatch: "),i.tidy(function(){var we=Se.tensors.map(function(Je){return i.reshape(Je,x)});return i.stack(we,0)})},S.prototype.popBack=function(x,k){if(k!==this.elementDtype)throw new Error("Invalid data types; op elements "+k+", but list elements "+this.elementDtype);if(this.size()===0)throw new Error("Trying to pop from an empty list.");var K=this.tensors.pop();return ln(K.shape,x,"TensorList shape mismatch: "),i.reshape(K,x)},S.prototype.pushBack=function(x){if(x.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+x.dtype+", but list elements "+this.elementDtype);if(ln(x.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");i.keep(x),this.tensors.push(x)},S.prototype.resize=function(x){if(x<0)throw new Error("TensorListResize expects size to be non-negative. Got: "+x);if(this.maxNumElements!==-1&&x>this.maxNumElements)throw new Error("TensorListResize input size "+x+" is greater maxNumElement "+this.maxNumElements+".");this.tensors.length=x},S.prototype.getItem=function(x,k,K){if(K!==this.elementDtype)throw new Error("Invalid data types; op elements "+K+", but list elements "+this.elementDtype);if(x<0||x>this.tensors.length)throw new Error("Trying to access element "+x+" in a list with "+this.tensors.length+" elements.");if(this.tensors[x]==null)throw new Error("element at index "+x+" is null.");return ln(this.tensors[x].shape,k,"TensorList shape mismatch: "),this.tensors[x]},S.prototype.setItem=function(x,k){if(k.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+k.dtype+", but list elements "+this.elementDtype);if(x<0||this.maxNumElements!==-1&&x>=this.maxNumElements)throw new Error("Trying to set element "+x+" in a list with max "+this.maxNumElements+" elements.");ln(this.elementShape,k.shape,"TensorList shape mismatch: "),i.keep(k),this.tensors[x]=k},S.prototype.gather=function(x,k,K){var Se=this;if(k!==this.elementDtype)throw new Error("Invalid data types; op elements "+k+", but list elements "+this.elementDtype);return ln(this.elementShape,K,"TensorList shape mismatch: "),x=x.slice(0,this.size()),x.length===0?i.tensor([],[0].concat(this.elementShape)):i.tidy(function(){var we=x.map(function(Je){return i.reshape(Se.tensors[Je],K)});return i.stack(we,0)})},S.prototype.concat=function(x,k){var K=this;if(!!x&&x!==this.elementDtype)throw new Error("TensorList dtype is "+this.elementDtype+" but concat requested dtype "+x);return ln(this.elementShape,k,"TensorList shape mismatch: "),this.size()===0?i.tensor([],[0].concat(this.elementShape)):i.tidy(function(){var Se=K.tensors.map(function(we){return i.reshape(we,k)});return i.concat(Se,0)})},S}();function bi(S,x,k){var K=S.dtype;if(S.shape.length<1)throw new Error("Tensor must be at least a vector, but saw shape: "+S.shape);if(S.dtype!==k)throw new Error("Invalid data types; op elements "+S.dtype+", but list elements "+k);var Se=S.shape.slice(1);ln(Se,x,"TensorList shape mismatch: ");var we=i.unstack(S);return new Di(we,x,K)}function ro(S,x,k){return new Di([],S,x,k)}function Zn(S,x,k,K){if(x.length!==S.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+x.length+" vs. "+S.shape[0]);var Se=Math.max.apply(Math,xe(x));if(K!=null&&K!==-1&&Se>=K)throw new Error("Max index must be < array size ("+Se+" vs. "+K+")");var we=new Di([],k,S.dtype,K),Je=i.unstack(S,0);return x.forEach(function(Be,vt){we.setItem(Be,Je[vt])}),we}function Gi(S,x,k){var K=0,Se=x.map(function(ft){return K+=ft,K});if(K!==S.shape[0])throw new Error(`Expected sum of lengths to be equal to
tensor.shape[0], but sum of lengths is
`+K+", and tensor's shape is: "+S.shape);for(var we=K===0?0:S.size/K,Je=i.tidy(function(){var ft=[];S=i.reshape(S,[1,K,we]);for(var zt=0;zt<x.length;++zt){var Wt=zt===0?0:Se[zt-1],Gt=[0,Wt,0],Qt=[1,x[zt],we];ft[zt]=i.reshape(i.slice(S,Gt,Qt),k)}return S.dispose(),ft}),Be=new Di([],k,S.dtype,x.length),vt=0;vt<Je.length;vt++)Be.setItem(vt,Je[vt]);return Be}var Fi=void 0,ji=function(S,x,k){return O(Fi,void 0,void 0,function(){var K,Se,we,Je,Be,vt,ft,zt,Be,Wt,Gt,vt,Qt,wr,Ar,Ar,Yt,xr,Yt,Sn,Yt,Yt,Yt,pn,zn,Fr,wa,In,ur,$r,Ra,mi,Ga,ja,ai,zi,An,ba,qi,yi,ii,qr,Io,nn,qa,La,Ki,oi,Pi,no,mo,Ka,ao,Ko,No,Co,io,ia,Ga,ja,Pr,ia,An,Fr,oa,Pr,nn,qa,Fr,Xa,Pr,Fr,Qn,Xa,Pr,qi,yi,Fr,Qn,Pr,ia,Fr,Qn,Xa,Pr,oo,Fr,Qn,Pr,Ki,Pr,Pi,Fr,ia,ja,Pr,ia,Fr,oa,Pr,mo,Fr,Ka,Pr;return H(this,function(ka){switch(ka.label){case 0:K=S.op;switch(K){case"If":return[3,1];case"StatelessIf":return[3,1];case"While":return[3,3];case"StatelessWhile":return[3,3];case"LoopCond":return[3,9];case"Switch":return[3,10];case"Merge":return[3,12];case"Enter":return[3,13];case"Exit":return[3,14];case"NextIteration":return[3,15];case"TensorArrayV3":return[3,16];case"TensorArrayWriteV3":return[3,17];case"TensorArrayReadV3":return[3,18];case"TensorArrayGatherV3":return[3,19];case"TensorArrayScatterV3":return[3,20];case"TensorArrayConcatV3":return[3,21];case"TensorArraySplitV3":return[3,22];case"TensorArraySizeV3":return[3,23];case"TensorArrayCloseV3":return[3,24];case"TensorListSetItem":return[3,25];case"TensorListGetItem":return[3,26];case"TensorListScatterV2":return[3,27];case"TensorListScatter":return[3,27];case"TensorListReserve":return[3,28];case"TensorListGather":return[3,29];case"TensorListStack":return[3,30];case"TensorListFromTensor":return[3,31];case"TensorListConcat":return[3,32];case"TensorListPushBack":return[3,33];case"TensorListPopBack":return[3,34];case"TensorListSplit":return[3,35]}return[3,36];case 1:return Se=w("thenBranch",S,x,k),we=w("elseBranch",S,x,k),Je=w("cond",S,x,k),Be=w("args",S,x,k),[4,Je.data()];case 2:return vt=ka.sent(),vt[0]?[2,k.functionMap[Se].executeFunctionAsync(Be,k.tensorArrayMap,k.tensorListMap)]:[2,k.functionMap[we].executeFunctionAsync(Be,k.tensorArrayMap,k.tensorListMap)];case 3:return ft=w("body",S,x,k),zt=w("cond",S,x,k),Be=w("args",S,x,k),[4,k.functionMap[zt].executeFunctionAsync(Be,k.tensorArrayMap,k.tensorListMap)];case 4:return Wt=ka.sent(),Gt=Be.map(function(vn){return vn.id}),[4,Wt[0].data()];case 5:vt=ka.sent(),Wt.forEach(function(vn){!vn.kept&&Gt.indexOf(vn.id)===-1&&vn.dispose()}),Qt=Be,wr=function(){var vn,Bi,yo;return H(this,function(vo){switch(vo.label){case 0:return vn=Qt,[4,k.functionMap[ft].executeFunctionAsync(Qt,k.tensorArrayMap,k.tensorListMap)];case 1:return Qt=vo.sent(),Bi=Qt.map(function(Aa){return Aa.id}),vn.forEach(function(Aa){!Aa.kept&&Gt.indexOf(Aa.id)===-1&&Bi.indexOf(Aa.id)===-1&&Aa.dispose()}),[4,k.functionMap[zt].executeFunctionAsync(Qt,k.tensorArrayMap,k.tensorListMap)];case 2:return yo=vo.sent(),[4,yo[0].data()];case 3:return vt=vo.sent(),yo.forEach(function(Aa){!Aa.kept&&Gt.indexOf(Aa.id)===-1&&Bi.indexOf(Aa.id)===-1&&Aa.dispose()}),[2]}})},ka.label=6;case 6:return vt[0]?[5,wr()]:[3,8];case 7:return ka.sent(),[3,6];case 8:return[2,Qt];case 9:return Ar=w("pred",S,x,k),[2,[Tt(Ar)]];case 10:return Ar=w("pred",S,x,k),Yt=w("data",S,x,k),Yt.kept||(Yt=Tt(Yt)),[4,Ar.data()];case 11:return[2,ka.sent()[0]?[void 0,Yt]:[Yt,void 0]];case 12:return xr=S.inputNames.find(function(vn){return ge(vn,x,k)!==void 0}),xr?(Yt=ge(xr,x,k),[2,[Tt(Yt)]]):[2,void 0];case 13:return Sn=w("frameName",S,x,k),Yt=w("tensor",S,x,k),k.enterFrame(Sn),[2,[Tt(Yt)]];case 14:return Yt=w("tensor",S,x,k),k.exitFrame(),[2,[Tt(Yt)]];case 15:return Yt=w("tensor",S,x,k),k.nextIteration(),[2,[Tt(Yt)]];case 16:return pn=w("size",S,x,k),zn=w("dtype",S,x,k),Fr=w("elementShape",S,x,k),wa=w("dynamicSize",S,x,k),In=w("clearAfterRead",S,x,k),ur=w("identicalElementShapes",S,x,k),$r=w("name",S,x,k),Ra=new gr($r,zn,pn,Fr,ur,wa,In),k.addTensorArray(Ra),[2,[Ra.idTensor,i.scalar(1)]];case 17:return mi=w("tensorArrayId",S,x,k),Ga=w("index",S,x,k),ja=w("tensor",S,x,k),ai=k.getTensorArray(mi.id),ai.write(Ga,ja),[2,[ai.idTensor]];case 18:return zi=w("tensorArrayId",S,x,k),An=w("index",S,x,k),ba=k.getTensorArray(zi.id),[2,[ba.read(An)]];case 19:return qi=w("tensorArrayId",S,x,k),yi=w("indices",S,x,k),ii=w("dtype",S,x,k),qr=k.getTensorArray(qi.id),[2,[qr.gather(yi,ii)]];case 20:return Io=w("tensorArrayId",S,x,k),nn=w("indices",S,x,k),qa=w("tensor",S,x,k),La=k.getTensorArray(Io.id),La.scatter(nn,qa),[2,[La.idTensor]];case 21:return Ki=w("tensorArrayId",S,x,k),oi=k.getTensorArray(Ki.id),Pi=w("dtype",S,x,k),[2,[oi.concat(Pi)]];case 22:return no=w("tensorArrayId",S,x,k),mo=w("tensor",S,x,k),Ka=w("lengths",S,x,k),ao=k.getTensorArray(no.id),ao.split(Ka,mo),[2,[ao.idTensor]];case 23:return Ko=w("tensorArrayId",S,x,k),No=k.getTensorArray(Ko.id),[2,[i.scalar(No.size(),"int32")]];case 24:return Co=w("tensorArrayId",S,x,k),io=k.getTensorArray(Co.id),io.clearAndClose(),[2,[io.idTensor]];case 25:return ia=w("tensorListId",S,x,k),Ga=w("index",S,x,k),ja=w("tensor",S,x,k),Pr=k.getTensorList(ia.id),Pr.setItem(Ga,ja),[2,[Pr.idTensor]];case 26:return ia=w("tensorListId",S,x,k),An=w("index",S,x,k),Fr=w("elementShape",S,x,k),oa=w("elementDType",S,x,k),Pr=k.getTensorList(ia.id),[2,[Pr.getItem(An,Fr,oa)]];case 27:return nn=w("indices",S,x,k),qa=w("tensor",S,x,k),Fr=w("elementShape",S,x,k),Xa=w("numElements",S,x,k),Pr=Zn(qa,nn,Fr,Xa),k.addTensorList(Pr),[2,[Pr.idTensor]];case 28:return Fr=w("elementShape",S,x,k),Qn=w("elementDType",S,x,k),Xa=w("numElements",S,x,k),Pr=ro(Fr,Qn,Xa),k.addTensorList(Pr),[2,[Pr.idTensor]];case 29:return qi=w("tensorListId",S,x,k),yi=w("indices",S,x,k),Fr=w("elementShape",S,x,k),Qn=w("elementDType",S,x,k),Pr=k.getTensorList(qi.id),[2,[Pr.gather(yi,Qn,Fr)]];case 30:return ia=w("tensorListId",S,x,k),Fr=w("elementShape",S,x,k),Qn=w("elementDType",S,x,k),Xa=w("numElements",S,x,k),Pr=k.getTensorList(ia.id),[2,[Pr.stack(Fr,Qn,Xa)]];case 31:return oo=w("tensor",S,x,k),Fr=w("elementShape",S,x,k),Qn=w("elementDType",S,x,k),Pr=bi(oo,Fr,Qn),k.addTensorList(Pr),[2,[Pr.idTensor]];case 32:return Ki=w("tensorListId",S,x,k),Pr=k.getTensorList(Ki.id),Pi=w("dtype",S,x,k),Fr=w("elementShape",S,x,k),[2,[Pr.concat(Pi,Fr)]];case 33:return ia=w("tensorListId",S,x,k),ja=w("tensor",S,x,k),Pr=k.getTensorList(ia.id),Pr.pushBack(ja),[2,[Pr.idTensor]];case 34:return ia=w("tensorListId",S,x,k),Fr=w("elementShape",S,x,k),oa=w("elementDType",S,x,k),Pr=k.getTensorList(ia.id),[2,[Pr.popBack(Fr,oa)]];case 35:return mo=w("tensor",S,x,k),Fr=w("elementShape",S,x,k),Ka=w("lengths",S,x,k),Pr=Gi(mo,Ka,Fr),k.addTensorList(Pr),[2,[Pr.idTensor]];case 36:throw TypeError("Node type "+S.op+" is not implemented")}})})};function Oi(S,x,k){var K=se(w("fusedOps",S,x,k),2),Se=K[0],we=K[1],Je=Se==="biasadd",Be=we==="prelu",vt=Se==="fusedbatchnorm",ft=w("numArgs",S,x,k);if(Je){if(Be&&ft!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!Be&&ft!==1)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(vt)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.");var zt=w("strides",S,x,k),Wt=nr(S,x,k),Gt=w("dataFormat",S,x,k).toUpperCase(),Qt=w("dilations",S,x,k),wr=se(w("args",S,x,k),2),Ar=wr[0],Yt=wr[1];return{stride:zt,pad:Wt,dataFormat:Gt,dilations:Qt,biasArg:Ar,preluArg:Yt,activationFunc:we}}var da=function(S,x,k){switch(S.op){case"Conv1D":{var K=w("stride",S,x,k),Se=w("pad",S,x,k),we=w("dataFormat",S,x,k).toUpperCase(),Je=w("dilation",S,x,k);return[i.conv1d(w("x",S,x,k),w("filter",S,x,k),K,Se,we,Je)]}case"Conv2D":{var K=w("strides",S,x,k),Se=nr(S,x,k),we=w("dataFormat",S,x,k).toUpperCase(),Be=w("dilations",S,x,k);return[i.conv2d(w("x",S,x,k),w("filter",S,x,k),[K[1],K[2]],Se,we,[Be[1],Be[2]])]}case"_FusedConv2D":{var vt=Oi(S,x,k),K=vt.stride,Se=vt.pad,we=vt.dataFormat,Be=vt.dilations,ft=vt.biasArg,zt=vt.preluArg,Wt=vt.activationFunc;return[i.fused.conv2d({x:w("x",S,x,k),filter:w("filter",S,x,k),strides:[K[1],K[2]],pad:Se,dataFormat:we,dilations:[Be[1],Be[2]],bias:ft,activation:Wt,preluActivationWeights:zt})]}case"FusedDepthwiseConv2dNative":{var Gt=Oi(S,x,k),K=Gt.stride,Se=Gt.pad,we=Gt.dataFormat,Be=Gt.dilations,ft=Gt.biasArg,zt=Gt.preluArg,Wt=Gt.activationFunc;return[i.fused.depthwiseConv2d({x:w("x",S,x,k),filter:w("filter",S,x,k),strides:[K[1],K[2]],pad:Se,dataFormat:we,dilations:[Be[1],Be[2]],bias:ft,activation:Wt,preluActivationWeights:zt})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{var Qt=w("outputShape",S,x,k),K=w("strides",S,x,k),Se=nr(S,x,k);return[i.conv2dTranspose(w("x",S,x,k),w("filter",S,x,k),Qt,[K[1],K[2]],Se)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{var K=w("strides",S,x,k),Se=nr(S,x,k),Be=w("dilations",S,x,k),we=w("dataFormat",S,x,k).toUpperCase();return[i.depthwiseConv2d(w("input",S,x,k),w("filter",S,x,k),[K[1],K[2]],Se,we,[Be[1],Be[2]])]}case"Conv3D":{var K=w("strides",S,x,k),Se=w("pad",S,x,k),we=w("dataFormat",S,x,k).toUpperCase(),Be=w("dilations",S,x,k);return[i.conv3d(w("x",S,x,k),w("filter",S,x,k),[K[1],K[2],K[3]],Se,we,[Be[1],Be[2],Be[3]])]}case"AvgPool":{var K=w("strides",S,x,k),Se=w("pad",S,x,k),wr=w("kernelSize",S,x,k);return[i.avgPool(w("x",S,x,k),[wr[1],wr[2]],[K[1],K[2]],Se)]}case"MaxPool":{var K=w("strides",S,x,k),Se=w("pad",S,x,k),wr=w("kernelSize",S,x,k);return[i.maxPool(w("x",S,x,k),[wr[1],wr[2]],[K[1],K[2]],Se)]}case"MaxPoolWithArgmax":{var K=w("strides",S,x,k),Se=w("pad",S,x,k),wr=w("kernelSize",S,x,k),Ar=w("includeBatchInIndex",S,x,k),Yt=i.maxPoolWithArgmax(w("x",S,x,k),[wr[1],wr[2]],[K[1],K[2]],Se,Ar),xr=Yt.result,Sn=Yt.indexes;return[xr,Sn]}case"AvgPool3D":{var K=w("strides",S,x,k),Se=w("pad",S,x,k),wr=w("kernelSize",S,x,k);return[i.avgPool3d(w("x",S,x,k),[wr[1],wr[2],wr[3]],[K[1],K[2],K[3]],Se)]}case"MaxPool3D":{var K=w("strides",S,x,k),Se=w("pad",S,x,k),wr=w("kernelSize",S,x,k);return[i.maxPool3d(w("x",S,x,k),[wr[1],wr[2],wr[3]],[K[1],K[2],K[3]],Se)]}case"Dilation2D":{var pn=w("strides",S,x,k),Se=w("pad",S,x,k),Be=w("dilations",S,x,k),zn=pn[1],Fr=pn[2],wa=Be[1],In=Be[2];return[i.dilation2d(w("x",S,x,k),w("filter",S,x,k),[zn,Fr],Se,[wa,In],"NHWC")]}default:throw TypeError("Node type "+S.op+" is not implemented")}},Mi=function(S,x,k){switch(S.op){case"Fill":{var K=w("shape",S,x,k),Se=w("dtype",S,x,k),we=w("value",S,x,k);return[i.fill(K,we,Se)]}case"LinSpace":{var Je=w("start",S,x,k),Be=w("stop",S,x,k),vt=w("num",S,x,k);return[i.linspace(Je,Be,vt)]}case"Multinomial":{var ft=w("logits",S,x,k),zt=w("numSamples",S,x,k),Wt=w("seed",S,x,k);return[i.multinomial(ft,zt,Wt)]}case"OneHot":{var Gt=w("indices",S,x,k),Qt=w("depth",S,x,k),wr=w("onValue",S,x,k),Ar=w("offValue",S,x,k);return[i.oneHot(Gt,Qt,wr,Ar)]}case"Ones":return[i.ones(w("shape",S,x,k),w("dtype",S,x,k))];case"OnesLike":return[i.onesLike(w("x",S,x,k))];case"RandomUniform":return[i.randomUniform(w("shape",S,x,k),w("minval",S,x,k),w("maxval",S,x,k),w("dtype",S,x,k))];case"Range":{var Je=w("start",S,x,k),Yt=w("stop",S,x,k),xr=w("step",S,x,k);return[i.range(Je,Yt,xr,w("dtype",S,x,k))]}case"TruncatedNormal":{var K=w("shape",S,x,k),Sn=w("mean",S,x,k),pn=w("stdDev",S,x,k),Wt=w("seed",S,x,k);return[i.truncatedNormal(K,Sn,pn,w("dtype",S,x,k),Wt)]}case"Zeros":return[i.zeros(w("shape",S,x,k),w("dtype",S,x,k))];case"ZerosLike":return[i.zerosLike(w("x",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}},pe=void 0;function X(S,x,k){var K=w("boxes",S,x,k),Se=w("scores",S,x,k),we=w("maxOutputSize",S,x,k),Je=w("iouThreshold",S,x,k),Be=w("scoreThreshold",S,x,k),vt=w("softNmsSigma",S,x,k);return{boxes:K,scores:Se,maxOutputSize:we,iouThreshold:Je,scoreThreshold:Be,softNmsSigma:vt}}var j=function(S,x,k){return O(pe,void 0,void 0,function(){var K,Se,we,Je,Be,vt,ft,zt,Wt,Gt,we,Je,Be,vt,ft,Qt,Wt,wr,we,Je,Be,vt,ft,Ar,Wt;return H(this,function(Yt){switch(Yt.label){case 0:K=S.op;switch(K){case"NonMaxSuppressionV5":return[3,1];case"NonMaxSuppressionV4":return[3,3];case"NonMaxSuppressionV3":return[3,5];case"NonMaxSuppressionV2":return[3,5];case"Where":return[3,7];case"ListDiff":return[3,9]}return[3,10];case 1:return Se=X(S,x,k),we=Se.boxes,Je=Se.scores,Be=Se.maxOutputSize,vt=Se.iouThreshold,ft=Se.scoreThreshold,zt=Se.softNmsSigma,[4,i.image.nonMaxSuppressionWithScoreAsync(we,Je,Be,vt,ft,zt)];case 2:return Wt=Yt.sent(),[2,[Wt.selectedIndices,Wt.selectedScores]];case 3:return Gt=X(S,x,k),we=Gt.boxes,Je=Gt.scores,Be=Gt.maxOutputSize,vt=Gt.iouThreshold,ft=Gt.scoreThreshold,Qt=w("padToMaxOutputSize",S,x,k),[4,i.image.nonMaxSuppressionPaddedAsync(we,Je,Be,vt,ft,Qt)];case 4:return Wt=Yt.sent(),[2,[Wt.selectedIndices,Wt.validOutputs]];case 5:return wr=X(S,x,k),we=wr.boxes,Je=wr.scores,Be=wr.maxOutputSize,vt=wr.iouThreshold,ft=wr.scoreThreshold,[4,i.image.nonMaxSuppressionAsync(we,Je,Be,vt,ft)];case 6:return[2,[Yt.sent()]];case 7:return Ar=i.cast(w("condition",S,x,k),"bool"),[4,i.whereAsync(Ar)];case 8:return Wt=[Yt.sent()],Ar.dispose(),[2,Wt];case 9:return[2,i.setdiff1dAsync(w("x",S,x,k),w("y",S,x,k))];case 10:throw TypeError("Node type "+S.op+" is not implemented")}})})},re=function(S,x,k){switch(S.op){case"TopKV2":{var K=w("x",S,x,k),Se=w("k",S,x,k),we=w("sorted",S,x,k),Je=i.topk(K,Se,we);return[Je.values,Je.indices]}case"Unique":{var K=w("x",S,x,k),Je=i.unique(K);return[Je.values,Je.indices]}case"UniqueV2":{var K=w("x",S,x,k),Be=w("axis",S,x,k),Je=i.unique(K,Be);return[Je.values,Je.indices]}default:throw TypeError("Node type "+S.op+" is not implemented")}},te=function(S,x,k){switch(S.op){case"Const":return x[S.name];case"PlaceholderWithDefault":var K=w("default",S,x,k);return[ge(S.name,x,k)||K];case"Placeholder":return[ge(S.name,x,k)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{var Se=w("x",S,x,k);return[Tt(Se)]}case"IdentityN":return w("x",S,x,k).map(function(Wt){return Tt(Wt)});case"Snapshot":var we=w("x",S,x,k);return[Tt(we)];case"Shape":return[i.tensor1d(w("x",S,x,k).shape,"int32")];case"ShapeN":return w("x",S,x,k).map(function(Wt){return i.tensor1d(Wt.shape)});case"Size":return[i.scalar(w("x",S,x,k).size,"int32")];case"Rank":return[i.scalar(w("x",S,x,k).rank,"int32")];case"NoOp":return[i.scalar(1)];case"Print":var Je=w("x",S,x,k),Be=w("data",S,x,k),vt=w("message",S,x,k),ft=w("summarize",S,x,k);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(vt);for(var zt=0;zt<Be.length;zt++)console.log(Array.prototype.slice.call(Be[zt].dataSync()).slice(0,ft));return[Je];default:throw TypeError("Node type "+S.op+" is not implemented")}},Ue=function(){function S(x,k){this.keyDType=x,this.valueDType=k,this.handle=i.scalar(0),this.tensorMap=new Map,i.keep(this.handle)}return Object.defineProperty(S.prototype,"id",{get:function(){return this.handle.id},enumerable:!0,configurable:!0}),S.prototype.clearAndClose=function(){this.tensorMap.forEach(function(x){return x.dispose()}),this.tensorMap.clear(),this.handle.dispose()},S.prototype.size=function(){return this.tensorMap.size},S.prototype.import=function(x,k){return O(this,void 0,void 0,function(){var K,Se=this;return H(this,function(we){switch(we.label){case 0:return this.checkKeyAndValueTensor(x,k),[4,x.data()];case 1:return K=we.sent(),this.tensorMap.forEach(function(Je){return Je.dispose()}),this.tensorMap.clear(),[2,i.tidy(function(){var Je=i.unstack(k),Be=K.length,vt=Je.length;i.util.assert(Be===vt,function(){return"The number of elements doesn't match, keys has "+(Be+" elements, the values has "+vt+" ")+"elements."});for(var ft=0;ft<Be;ft++){var zt=K[ft],Wt=Je[ft];i.keep(Wt),Se.tensorMap.set(zt,Wt)}return Se.handle})]}})})},S.prototype.find=function(x,k){return O(this,void 0,void 0,function(){var K,Se=this;return H(this,function(we){switch(we.label){case 0:return this.checkKeyAndValueTensor(x,k),[4,x.data()];case 1:return K=we.sent(),[2,i.tidy(function(){for(var Je=[],Be=0;Be<K.length;Be++){var vt=K[Be],ft=Se.findWithDefault(vt,k);Je.push(ft)}return i.stack(Je)})]}})})},S.prototype.findWithDefault=function(x,k){var K=this.tensorMap.get(x);return K??k},S.prototype.checkKeyAndValueTensor=function(x,k){if(x.dtype!==this.keyDType)throw new Error("Expect key dtype "+this.keyDType+", but got "+(""+x.dtype));if(k.dtype!==this.valueDType)throw new Error("Expect value dtype "+this.valueDType+", but got "+(""+k.dtype))},S}(),kt=void 0,$e=function(S,x,k,K){return O(kt,void 0,void 0,function(){var Se,we,Je,Be,vt,ft,zt,Be,vt,ft,Wt,Be;return H(this,function(Gt){switch(Gt.label){case 0:Se=S.op;switch(Se){case"HashTable":return[3,1];case"HashTableV2":return[3,1];case"LookupTableImport":return[3,2];case"LookupTableImportV2":return[3,2];case"LookupTableFind":return[3,4];case"LookupTableFindV2":return[3,4]}return[3,6];case 1:return we=w("keyDType",S,x,k),Je=w("valueDType",S,x,k),Be=new Ue(we,Je),K.addHashTable(S.name,Be),[2,[Be.handle]];case 2:return vt=w("tableHandle",S,x,k,K),ft=w("keys",S,x,k),zt=w("values",S,x,k),Be=K.getHashTableById(vt.id),[4,Be.import(ft,zt)];case 3:return[2,[Gt.sent()]];case 4:return vt=w("tableHandle",S,x,k,K),ft=w("keys",S,x,k),Wt=w("defaultValue",S,x,k),Be=K.getHashTableById(vt.id),[4,Be.find(ft,Wt)];case 5:return[2,[Gt.sent()]];case 6:throw TypeError("Node type "+S.op+" is not implemented")}})})},Le=function(S,x,k){switch(S.op){case"ResizeBilinear":{var K=w("images",S,x,k),Se=w("size",S,x,k),we=w("alignCorners",S,x,k);return[i.image.resizeBilinear(K,[Se[0],Se[1]],we)]}case"ResizeNearestNeighbor":{var K=w("images",S,x,k),Se=w("size",S,x,k),we=w("alignCorners",S,x,k);return[i.image.resizeNearestNeighbor(K,[Se[0],Se[1]],we)]}case"CropAndResize":{var Je=w("image",S,x,k),Be=w("boxes",S,x,k),vt=w("boxInd",S,x,k),ft=w("cropSize",S,x,k),zt=w("method",S,x,k),Wt=w("extrapolationValue",S,x,k);return[i.image.cropAndResize(Je,Be,vt,ft,zt,Wt)]}default:throw TypeError("Node type "+S.op+" is not implemented")}},Ye=function(S,x,k){switch(S.op){case"Equal":return[i.equal(w("a",S,x,k),w("b",S,x,k))];case"NotEqual":return[i.notEqual(w("a",S,x,k),w("b",S,x,k))];case"Greater":return[i.greater(w("a",S,x,k),w("b",S,x,k))];case"GreaterEqual":return[i.greaterEqual(w("a",S,x,k),w("b",S,x,k))];case"Less":return[i.less(w("a",S,x,k),w("b",S,x,k))];case"LessEqual":return[i.lessEqual(w("a",S,x,k),w("b",S,x,k))];case"LogicalAnd":return[i.logicalAnd(w("a",S,x,k),w("b",S,x,k))];case"LogicalNot":return[i.logicalNot(w("a",S,x,k))];case"LogicalOr":return[i.logicalOr(w("a",S,x,k),w("b",S,x,k))];case"Select":case"SelectV2":return[i.where(w("condition",S,x,k),w("a",S,x,k),w("b",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}},Ft=function(S,x,k){switch(S.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[i.matMul(w("a",S,x,k),w("b",S,x,k),w("transposeA",S,x,k),w("transposeB",S,x,k))];case"Transpose":return[i.transpose(w("x",S,x,k),w("perm",S,x,k))];case"_FusedMatMul":var K=se(w("fusedOps",S,x,k),2),Se=K[0],we=K[1],Je=Se==="biasadd",Be=we==="prelu",vt=w("numArgs",S,x,k);if(Je){if(Be&&vt!==2)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!Be&&vt!==1)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}var ft=se(w("args",S,x,k),2),zt=ft[0],Wt=ft[1];return[i.fused.matMul({a:w("a",S,x,k),b:w("b",S,x,k),transposeA:w("transposeA",S,x,k),transposeB:w("transposeB",S,x,k),bias:zt,activation:we,preluActivationWeights:Wt})];default:throw TypeError("Node type "+S.op+" is not implemented")}},St=function(S,x,k){switch(S.op){case"FusedBatchNorm":case"FusedBatchNormV2":return[i.batchNorm(w("x",S,x,k),w("mean",S,x,k),w("variance",S,x,k),w("offset",S,x,k),w("scale",S,x,k),w("epsilon",S,x,k))];case"FusedBatchNormV3":return[i.batchNorm(w("x",S,x,k),w("mean",S,x,k),w("variance",S,x,k),w("offset",S,x,k),w("scale",S,x,k),w("epsilon",S,x,k))];case"LRN":return[i.localResponseNormalization(w("x",S,x,k),w("radius",S,x,k),w("bias",S,x,k),w("alpha",S,x,k),w("beta",S,x,k))];case"Softmax":return[i.softmax(w("x",S,x,k))];case"LogSoftmax":return[i.logSoftmax(w("x",S,x,k))];case"SparseToDense":return[i.sparseToDense(w("sparseIndices",S,x,k),w("outputShape",S,x,k),w("sparseValues",S,x,k),w("defaultValue",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}},Mt=function(S,x,k){switch(S.op){case"Max":{var K=w("axis",S,x,k),Se=w("keepDims",S,x,k);return[i.max(w("x",S,x,k),K,Se)]}case"Mean":{var K=w("axis",S,x,k),Se=w("keepDims",S,x,k);return[i.mean(w("x",S,x,k),K,Se)]}case"Min":{var K=w("axis",S,x,k),Se=w("keepDims",S,x,k);return[i.min(w("x",S,x,k),K,Se)]}case"Sum":{var K=w("axis",S,x,k),Se=w("keepDims",S,x,k);return[i.sum(w("x",S,x,k),K,Se)]}case"All":{var K=w("axis",S,x,k),Se=w("keepDims",S,x,k);return[i.all(w("x",S,x,k),K,Se)]}case"Any":{var K=w("axis",S,x,k),Se=w("keepDims",S,x,k);return[i.any(w("x",S,x,k),K,Se)]}case"ArgMax":{var K=w("axis",S,x,k);return[i.argMax(w("x",S,x,k),K)]}case"ArgMin":{var K=w("axis",S,x,k);return[i.argMin(w("x",S,x,k),K)]}case"Prod":{var K=w("axis",S,x,k),Se=w("keepDims",S,x,k);return[i.prod(w("x",S,x,k),K,Se)]}case"Cumsum":{var K=w("axis",S,x,k),we=w("exclusive",S,x,k),Je=w("reverse",S,x,k);return[i.cumsum(w("x",S,x,k),K,we,Je)]}default:throw TypeError("Node type "+S.op+" is not implemented")}},dr=function(S,x,k){switch(S.op){case"ConcatV2":case"Concat":{var K=w("n",S,x,k),Se=w("axis",S,x,k),we=w("tensors",S,x,k);return we=we.slice(0,K),[i.concat(we,Se)]}case"GatherV2":case"Gather":{var Se=w("axis",S,x,k),Je=w("x",S,x,k),Be=w("indices",S,x,k);return[i.gather(Je,i.cast(Be,"int32"),Se)]}case"ReverseV2":case"Reverse":{var Se=w("axis",S,x,k),Je=w("x",S,x,k);return[i.reverse(Je,Se)]}case"Slice":{var vt=w("begin",S,x,k),ft=w("size",S,x,k);return[i.slice(w("x",S,x,k),vt,ft)]}case"StridedSlice":{var vt=w("begin",S,x,k),zt=w("end",S,x,k),Wt=w("strides",S,x,k),Gt=w("beginMask",S,x,k),Qt=w("endMask",S,x,k),wr=w("ellipsisMask",S,x,k),Ar=w("newAxisMask",S,x,k),Yt=w("shrinkAxisMask",S,x,k),xr=w("x",S,x,k);return[i.stridedSlice(xr,vt,zt,Wt,Gt,Qt,wr,Ar,Yt)]}case"Pack":return i.tidy(function(){var $r=w("axis",S,x,k),Ra=w("tensors",S,x,k),mi=Ra[0].shape,Ga=i.squeeze(Ra[0]).shape,ja=Ra.map(function(ai){var zi=i.util.arraysEqual(ai.shape,mi);if(!zi&&!i.util.arraysEqual(i.squeeze(ai).shape,Ga))throw new Error("the input tensors shape does not match");return zi?ai:i.reshape(ai,mi)});return[i.stack(ja,$r)]});case"Unpack":{var Se=w("axis",S,x,k),xr=w("tensor",S,x,k);return i.unstack(xr,Se)}case"Tile":{var Sn=w("reps",S,x,k);return[i.tile(w("x",S,x,k),Sn)]}case"Split":case"SplitV":{var Se=w("axis",S,x,k),pn=w("numOrSizeSplits",S,x,k),xr=w("x",S,x,k);return i.split(xr,pn,Se)}case"ScatterNd":{var Be=w("indices",S,x,k),zn=w("values",S,x,k),Fr=w("shape",S,x,k);return[i.scatterND(Be,zn,Fr)]}case"GatherNd":{var wa=w("x",S,x,k),Be=w("indices",S,x,k);return[i.gatherND(wa,Be)]}case"SparseToDense":{var Be=w("sparseIndices",S,x,k),Fr=w("outputShape",S,x,k),In=w("sparseValues",S,x,k),ur=w("defaultValue",S,x,k);return[i.sparseToDense(Be,In,Fr,In.dtype===ur.dtype?ur:i.cast(ur,In.dtype))]}default:throw TypeError("Node type "+S.op+" is not implemented")}},ir=function(S,x,k){switch(S.op){case"FFT":return[i.fft(w("x",S,x,k))];case"IFFT":return[i.ifft(w("x",S,x,k))];case"RFFT":return[i.rfft(w("x",S,x,k))];case"IRFFT":return[i.irfft(w("x",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}},ta=function(S,x,k){switch(S.op){case"Cast":return[i.cast(w("x",S,x,k),w("dtype",S,x,k))];case"ExpandDims":{var K=w("axis",S,x,k);return[i.expandDims(w("x",S,x,k),K)]}case"Squeeze":{var K=w("axis",S,x,k);return[i.squeeze(w("x",S,x,k),K)]}case"Reshape":return[i.reshape(w("x",S,x,k),w("shape",S,x,k))];case"MirrorPad":return[i.mirrorPad(w("x",S,x,k),w("padding",S,x,k),w("mode",S,x,k))];case"PadV2":case"Pad":return[i.pad(w("x",S,x,k),w("padding",S,x,k),w("constantValue",S,x,k))];case"SpaceToBatchND":{var Se=w("blockShape",S,x,k),we=w("paddings",S,x,k);return[i.spaceToBatchND(w("x",S,x,k),Se,we)]}case"BatchToSpaceND":{var Se=w("blockShape",S,x,k),Je=w("crops",S,x,k);return[i.batchToSpaceND(w("x",S,x,k),Se,Je)]}case"DepthToSpace":{var Be=w("blockSize",S,x,k),vt=w("dataFormat",S,x,k).toUpperCase();return[i.depthToSpace(w("x",S,x,k),Be,vt)]}case"BroadcastTo":return[i.broadcastTo(w("x",S,x,k),w("shape",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}};function fa(S,x,k,K){var Se=function(we,Je,Be){switch(we.category){case"arithmetic":return i.tidy(function(){return fi(we,Je,Be)});case"basic_math":return i.tidy(function(){return Va(we,Je,Be)});case"control":return ji(we,Je,Be);case"convolution":return i.tidy(function(){return da(we,Je,Be)});case"creation":return i.tidy(function(){return Mi(we,Je,Be)});case"dynamic":return j(we,Je,Be);case"evaluation":return i.tidy(function(){return re(we,Je,Be)});case"image":return i.tidy(function(){return Le(we,Je,Be)});case"graph":return i.tidy(function(){return te(we,Je,Be)});case"logical":return i.tidy(function(){return Ye(we,Je,Be)});case"matrices":return i.tidy(function(){return Ft(we,Je,Be)});case"normalization":return i.tidy(function(){return St(we,Je,Be)});case"reduction":return i.tidy(function(){return Mt(we,Je,Be)});case"slice_join":return i.tidy(function(){return dr(we,Je,Be)});case"spectral":return i.tidy(function(){return ir(we,Je,Be)});case"transformation":return i.tidy(function(){return ta(we,Je,Be)});case"hash_table":return $e(we,Je,Be,K);case"custom":var vt=me(we.op);if(vt&&vt.customExecutor)return vt.customExecutor(new di(we,Je,Be));throw TypeError("Custom op "+we.op+" is not registered.");default:throw TypeError("Unknown op '"+we.op+"'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()")}}(S,x,k);return i.util.isPromise(Se)?Se.then(function(we){return[].concat(we)}):[].concat(Se)}var ra=function(){function S(x,k,K,Se){x===void 0&&(x={}),k===void 0&&(k={}),K===void 0&&(K={}),Se===void 0&&(Se={}),this.weightMap=x,this.tensorArrayMap=k,this.tensorListMap=K,this.functionMap=Se,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}return S.prototype.newFrame=function(x,k){return{id:x,frameName:k,iterationId:0}},Object.defineProperty(S.prototype,"currentContext",{get:function(){return this.contexts},set:function(x){this.contexts!==x&&(this.contexts=x,this.generateCurrentContextIds())},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"currentContextId",{get:function(){return this._currentContextIds[0]},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"currentContextIds",{get:function(){return this._currentContextIds},enumerable:!0,configurable:!0}),S.prototype.generateCurrentContextIds=function(){for(var x=[],k=0;k<this.contexts.length-1;k++){var K=this.contexts.slice(0,this.contexts.length-k);x.push(this.contextIdforContexts(K))}x.push(""),this._currentContextIds=x},S.prototype.contextIdforContexts=function(x){return x?x.map(function(k){return k.id===0&&k.iterationId===0?"":k.frameName+"-"+k.iterationId}).join("/"):""},S.prototype.enterFrame=function(x){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,x)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))},S.prototype.exitFrame=function(){if(this.contexts&&this.contexts.length>1)this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift();else throw new Error("Cannot exit frame, the context is empty")},S.prototype.nextIteration=function(){if(this.contexts&&this.contexts.length>0){this.contexts=this.contexts.slice(),this.lastId++;var x=Object.assign({},this.contexts[this.contexts.length-1]);x.iterationId+=1,x.id=this.lastId,this.contexts.splice(-1,1,x),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}else throw new Error("Cannot increase frame iteration, the context is empty")},S.prototype.getWeight=function(x){return this.weightMap[x]},S.prototype.addTensorArray=function(x){this.tensorArrayMap[x.id]=x},S.prototype.getTensorArray=function(x){return this.tensorArrayMap[x]},S.prototype.addTensorList=function(x){this.tensorListMap[x.id]=x},S.prototype.getTensorList=function(x){return this.tensorListMap[x]},S.prototype.dispose=function(x){for(var k in this.tensorArrayMap)this.tensorArrayMap[k].clearAndClose(x);for(var k in this.tensorListMap)this.tensorListMap[k].clearAndClose(x)},S}();function Ha(S,x,k,K){var Se=new Set,we=[],Je=null,Be=null,vt=new Set,ft=Object.keys(S).map(function(Qt){return tt(Qt)[0]}),zt=[];K!=null&&(zt=K.map(function(Qt){return tt(Qt.name)[0]}));for(var Wt=xe(x);Wt.length>0;){var Gt=Wt.pop();if((Jr(Gt)||Vr(Gt)||Jn(Gt))&&Je==null&&(Je=Gt,Be=Je.children.map(function(Qt){return Qt.name}).filter(function(Qt){return Se.has(Qt)})),Se.add(Gt.name),k[Gt.name]!=null)continue;if(ft.indexOf(Gt.name)!==-1)continue;if(zt.indexOf(Gt.name)!==-1)continue;if(Gt.inputs.length===0){we.push(Gt.name);continue}Gt.inputs.forEach(function(Qt){if(vt.has(Qt.name))return;vt.add(Qt.name),Wt.push(Qt)})}return{inputs:S,outputs:x,usedNodes:Se,missingInputs:we,dynamicNode:Je,syncInputs:Be}}function ki(S,x,k){var K=k.usedNodes,Se=k.inputs,we=[],Je=Object.keys(Se).map(function(Wt){return tt(Wt)[0]}).map(function(Wt){return S.nodes[Wt]}),Be=S.initNodes;Je.forEach(function(Wt){K.has(Wt.name)&&we.push(Wt)}),S.weights.forEach(function(Wt){K.has(Wt.name)&&we.push(Wt)}),Be!=null&&Be.forEach(function(Wt){K.has(Wt.name)&&we.push(Wt)});for(var vt=new Set,ft=[];we.length>0;){var zt=we.pop();vt.add(zt.name),x[zt.name]||ft.push(zt),zt.children.forEach(function(Wt){!vt.has(Wt.name)&&K.has(Wt.name)&&Wt.inputs.every(function(Gt){return vt.has(Gt.name)})&&we.push(Wt)})}return ft}var sn=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],hn=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],na=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2"];function Jr(S){return sn.indexOf(S.op)>=0}function Vr(S){return hn.indexOf(S.op)>=0}function Jn(S){return na.indexOf(S.op)>=0}var tn=function(){function S(x,k){var K=this;this.graph=x,this.parent=k,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this._outputs=x.outputs,this._inputs=x.inputs,this._initNodes=x.initNodes,this._signature=x.signature,this._functions=x.functions,x.functions!=null&&Object.keys(x.functions).forEach(function(Se){K._functionExecutorMap[Se]=new S(x.functions[Se],K)})}return Object.defineProperty(S.prototype,"weightIds",{get:function(){return this.parent?this.parent.weightIds:this._weightIds},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"functionExecutorMap",{get:function(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"weightMap",{get:function(){return this.parent?this.parent.weightMap:this._weightMap},set:function(x){var k=Object.keys(x).map(function(K){return x[K].map(function(Se){return Se.id})});this._weightIds=[].concat.apply([],xe(k)),this._weightMap=x},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"resourceManager",{set:function(x){this._resourceManager=x},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"inputs",{get:function(){return this._inputs.map(function(x){return{name:x.name,shape:x.attrParams.shape?x.attrParams.shape.value:void 0,dtype:x.attrParams.dtype?x.attrParams.dtype.value:void 0}})},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"outputs",{get:function(){return this._outputs.map(function(x){return{name:x.name,shape:x.attrParams.shape?x.attrParams.shape.value:void 0,dtype:x.attrParams.dtype?x.attrParams.dtype.value:void 0}})},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"inputNodes",{get:function(){return this._inputs.map(function(x){return x.signatureKey||x.name})},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"outputNodes",{get:function(){return this._outputs.map(function(x){var k=x.signatureKey||x.name;return x.defaultOutput?k+":"+x.defaultOutput:k})},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"functions",{get:function(){var x=this;return Object.keys(this._functions).reduce(function(k,K){return k[K]=x._functions[K].signature,k},{})},enumerable:!0,configurable:!0}),S.prototype.getCompilationKey=function(x,k){var K=x.map(function(we){return we.name}).sort(),Se=k.map(function(we){return we.name}).sort();return K.join(this.SEPERATOR)+"--"+Se.join(this.SEPERATOR)},S.prototype.compile=function(x,k){var K=Ha(x,k,this.weightMap,this._initNodes),Se=K.missingInputs,we=K.dynamicNode,Je=K.syncInputs;if(we!=null)throw new Error("This execution contains the node '"+we.name+"', which has "+("the dynamic op '"+we.op+"'. Please use ")+"model.executeAsync() instead. Alternatively, to avoid the "+("dynamic ops, specify the inputs ["+Je+"]"));if(Se.length>0){var Be=k.map(function(ft){return ft.name}),vt=Object.keys(x);throw new Error("Cannot compute the outputs ["+Be+"] from the provided inputs "+("["+vt+"]. Missing the following inputs: ["+Se+"]"))}return ki(this.graph,this.weightMap,K)},S.prototype.execute=function(x,k){var K=this;x=this.mapInputs(x);var Se=Object.keys(x).sort();this.checkInputs(x),this.checkInputShapeAndType(x),k=this.mapOutputs(k),this.checkOutputs(k);var we=Se.map(function(Gt){return K.graph.nodes[tt(Gt)[0]]}),Je=k.map(function(Gt){return tt(Gt)[0]}),Be=Je.map(function(Gt){return K.graph.nodes[Gt]});Be.length===0&&(Be=this._outputs);var vt=this.getCompilationKey(we,Be),ft=this.compiledMap.get(vt);ft==null&&(ft=this.compile(x,Be),this.compiledMap.set(vt,ft));var zt={},Wt={};return i.tidy(function(){var Gt=new ra(K.weightMap,zt,Wt,K.functionExecutorMap),Qt=ke({},K.weightMap);Object.keys(x).forEach(function(pn){var zn=se(tt(pn),2),Fr=zn[0],wa=zn[1],In=[];In[wa]=x[pn],Qt[Fr]=In});for(var wr=K.getFrozenTensorIds(Qt),Ar={},Yt=0;Yt<ft.length;Yt++){var xr=ft[Yt];if(!Qt[xr.name]){var Sn=fa(xr,Qt,Gt,K._resourceManager);if(i.util.isPromise(Sn))throw new Error("The execution of the op '"+xr.op+"' returned a promise. Please use model.executeAsync() instead.");Qt[xr.name]=Sn,K.checkTensorForDisposal(xr.name,xr,Qt,Gt,wr,Je,Ar)}}return K.parent==null&&Gt.dispose(wr),k.map(function(pn){return ge(pn,Qt,Gt)})})},S.prototype.getFrozenTensorIds=function(x){var k=[].concat.apply([],Object.keys(x).map(function(K){return x[K]}).map(function(K){return K.map(function(Se){return Se.id})}));return new Set(k)},S.prototype.checkTensorForDisposal=function(x,k,K,Se,we,Je,Be){if(k.category==="control"||Je.indexOf(x)!==-1)return;K[x].forEach(function(vt){vt!=null&&(Be[vt.id]=(Be[vt.id]||0)+k.children.length)}),k.inputs.forEach(function(vt){if(vt.category!=="control"){var ft=ze(vt.name,K,Se);ft!=null&&ft.forEach(function(zt){if(zt&&!we.has(zt.id)){var Wt=Be[zt.id];Wt===1?(zt.dispose(),delete Be[zt.id]):Wt!=null&&Be[zt.id]--}})}})},S.prototype.executeAsync=function(x,k){return O(this,void 0,void 0,function(){return H(this,function(K){return[2,this._executeAsync(x,k)]})})},S.prototype._executeAsync=function(x,k,K,Se,we){return K===void 0&&(K=!1),Se===void 0&&(Se={}),we===void 0&&(we={}),O(this,void 0,void 0,function(){var Je,Be,vt,ft,zt,Wt;return H(this,function(Gt){switch(Gt.label){case 0:return K||(x=this.mapInputs(x),this.checkInputs(x),this.checkInputShapeAndType(x),k=this.mapOutputs(k),this.checkOutputs(k)),Je=new ra(this.weightMap,Se,we,this.functionExecutorMap),[4,this.executeWithControlFlow(x,Je,k,K)];case 1:return Be=Gt.sent(),vt=k.map(function(Qt){return ge(Qt,Be,Je)}),ft=vt.map(function(Qt){return Qt.id}),zt=Object.keys(x).map(function(Qt){return x[Qt].id}),Wt=new Set(xe(ft,zt,this.weightIds)),Object.keys(Be).forEach(function(Qt){var wr=Be[Qt];wr.forEach(function(Ar){Ar&&!Ar.isDisposed&&!Wt.has(Ar.id)&&Ar.dispose()})}),this.parent==null&&Je.dispose(Wt),[2,vt]}})})},S.prototype.executeFunctionAsync=function(x,k,K){return O(this,void 0,void 0,function(){var Se,we=this;return H(this,function(Je){return Se=x.reduce(function(Be,vt,ft){return Be[we.inputs[ft].name]=vt,Be},{}),[2,this._executeAsync(Se,this.outputNodes,!0,k,K)]})})},S.prototype.executeWithControlFlow=function(x,k,K,Se){return O(this,void 0,void 0,function(){var we,Je,Be,vt,ft,zt,Wt,Gt,Qt,wr,Ar,Yt,xr,Sn,pn,zn,Fr,wa=this;return H(this,function(In){switch(In.label){case 0:we=Object.keys(x),Je=we.map(function(ur){return wa.graph.nodes[tt(ur)[0]]}),Be=K.map(function(ur){return tt(ur)[0]}),vt=Be.map(function(ur){return wa.graph.nodes[ur]}),vt.length===0&&(vt=this._outputs),ft=Ha(x,vt,this.weightMap,this._initNodes),zt=ft.usedNodes,Wt=ft.missingInputs,Gt=ft.dynamicNode,Qt=ft.syncInputs,wr=xe(Je,this.graph.weights,this._initNodes||[]).map(function(ur){return{node:ur,contexts:k.currentContext}}),Ar=ke({},this.weightMap),Object.keys(x).forEach(function(ur){var $r=se(tt(ur),2),Ra=$r[0],mi=$r[1],Ga=[];Ga[mi]=x[ur],Ar[Ra]=Ga}),Yt={},xr=this.getFrozenTensorIds(Ar),Sn={},In.label=1;case 1:return wr.length>0?(pn=this.processStack(Je,wr,k,Ar,Sn,xr,Be,Yt,zt),[4,Promise.all(pn)]):[3,3];case 2:return In.sent(),[3,1];case 3:if(Gt==null&&!Se&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."),zn=vt.filter(function(ur){return!Jr(ur)&&!ge(ur.name,Ar,k)}).map(function(ur){return ur.name}),zn.length>0)throw Fr="",Gt!=null&&(Fr="Alternatively, to avoid the dynamic ops, use model.execute() "+("and specify the inputs ["+Qt+"]")),new Error("Cannot compute the outputs ["+zn+"] from the provided "+("inputs ["+we+"]. Consider providing the following inputs: ")+("["+Wt+"]. "+Fr));return[2,Ar]}})})},S.prototype.processStack=function(x,k,K,Se,we,Je,Be,vt,ft){for(var zt=this,Wt=[],Gt=function(){var wr,Ar,Yt=k.pop();K.currentContext=Yt.contexts;var xr="";if(Yt.node.op==="Enter"&&w("isConstant",Yt.node,Se,K)&&(wr=se(W(Yt.node.name,K),1),xr=wr[0]),Se[Yt.node.name]==null){var Sn=fa(Yt.node,Se,K,Qt._resourceManager);xr||(Ar=se(W(Yt.node.name,K),1),xr=Ar[0]);var pn=K.currentContext;i.util.isPromise(Sn)?Wt.push(Sn.then(function(zn){return Se[xr]=zn,K.currentContext=pn,zt.checkTensorForDisposal(xr,Yt.node,Se,K,Je,Be,vt),zt.processChildNodes(Yt.node,k,K,Se,we,ft),zn})):(Se[xr]=Sn,Qt.checkTensorForDisposal(xr,Yt.node,Se,K,Je,Be,vt),Qt.processChildNodes(Yt.node,k,K,Se,we,ft))}else Qt.processChildNodes(Yt.node,k,K,Se,we,ft)},Qt=this;k.length>0;)Gt();return Wt},S.prototype.processChildNodes=function(x,k,K,Se,we,Je){x.children.forEach(function(Be){var vt=se(W(Be.name,K),1),ft=vt[0];if(we[ft]||!Je.has(Be.name))return;Be.op==="Merge"?Be.inputNames.some(function(zt){return!!ge(zt,Se,K)})&&(we[ft]=!0,k.push({contexts:K.currentContext,node:Be})):Be.inputNames.every(function(zt){return!!ge(zt,Se,K)})&&(we[ft]=!0,k.push({contexts:K.currentContext,node:Be}))})},S.prototype.dispose=function(){var x=this;Object.keys(this.weightMap).forEach(function(k){return x.weightMap[k].forEach(function(K){return K.dispose()})})},S.prototype.checkInputShapeAndType=function(x){var k=this;Object.keys(x).forEach(function(K){var Se=x[K],we=se(tt(K),1),Je=we[0],Be=k.graph.nodes[Je];if(Be.attrParams.shape&&Be.attrParams.shape.value){var vt=Be.attrParams.shape.value,ft=vt.length===Se.shape.length&&Se.shape.every(function(zt,Wt){return vt[Wt]===-1||vt[Wt]===zt});i.util.assert(ft,function(){return"The shape of dict['"+Be.name+"'] provided in "+("model.execute(dict) must be ["+vt+"], but was ")+("["+Se.shape+"]")})}Be.attrParams.dtype&&Be.attrParams.dtype.value&&i.util.assert(Se.dtype===Be.attrParams.dtype.value,function(){return"The dtype of dict['"+Be.name+"'] provided in model.execute(dict) must be "+(Be.attrParams.dtype.value+", but was "+Se.dtype)})})},S.prototype.mapInputs=function(x){var k={};for(var K in x)if(this._signature!=null&&this._signature.inputs!=null&&this._signature.inputs[K]!=null){var Se=this._signature.inputs[K];k[Se.name]=x[K]}else k[K]=x[K];return k},S.prototype.checkInputs=function(x){var k=this,K=Object.keys(x).filter(function(Se){var we=se(tt(Se),1),Je=we[0];return k.graph.nodes[Je]==null});if(K.length>0)throw new Error("The dict provided in model.execute(dict) has "+("keys: ["+K+"] that are not part of graph"))},S.prototype.mapOutputs=function(x){var k=this;return x.map(function(K){if(k._signature!=null&&k._signature.outputs!=null&&k._signature.outputs[K]!=null){var Se=k._signature.outputs[K];return Se.name}return K},{})},S.prototype.checkOutputs=function(x){var k=this;x.forEach(function(K){var Se=se(tt(K),1),we=Se[0];if(!k.graph.nodes[we])throw new Error("The output '"+K+"' is not found in the graph")})},S}(),Rn=function(){function S(x,k){x===void 0&&(x={}),k===void 0&&(k={}),this.hashTableNameToHandle=x,this.hashTableMap=k}return S.prototype.addHashTable=function(x,k){this.hashTableNameToHandle[x]=k.handle,this.hashTableMap[k.id]=k},S.prototype.getHashTableHandleByName=function(x){return this.hashTableNameToHandle[x]},S.prototype.getHashTableById=function(x){return this.hashTableMap[x]},S.prototype.dispose=function(){for(var x in this.hashTableMap)this.hashTableMap[x].clearAndClose(),delete this.hashTableMap[x];for(var k in this.hashTableNameToHandle)this.hashTableNameToHandle[k].dispose(),delete this.hashTableNameToHandle[k]},S}(),Kn="?tfjs-format=file",aa="model.json",ma=function(){function S(x,k){k===void 0&&(k={}),this.modelUrl=x,this.loadOptions=k,this.version="n/a",k==null&&(this.loadOptions={}),this.resourceManager=new Rn}return Object.defineProperty(S.prototype,"modelVersion",{get:function(){return this.version},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"inputNodes",{get:function(){return this.executor.inputNodes},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"outputNodes",{get:function(){return this.executor.outputNodes},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"inputs",{get:function(){return this.executor.inputs},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"outputs",{get:function(){return this.executor.outputs},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"weights",{get:function(){return this.executor.weightMap},enumerable:!0,configurable:!0}),S.prototype.findIOHandler=function(){var x=this.modelUrl;if(x.load!=null)this.handler=x;else if(this.loadOptions.requestInit!=null)this.handler=i.io.browserHTTPRequest(x,this.loadOptions);else{var k=i.io.getLoadHandlers(x,this.loadOptions);if(k.length===0)k.push(i.io.browserHTTPRequest(x,this.loadOptions));else if(k.length>1)throw new Error("Found more than one ("+k.length+") load handlers for "+("URL '"+[x]+"'"));this.handler=k[0]}},S.prototype.load=function(){return O(this,void 0,void 0,function(){var x;return H(this,function(k){switch(k.label){case 0:if(this.findIOHandler(),this.handler.load==null)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");return[4,this.handler.load()];case 1:return x=k.sent(),[2,this.loadSync(x)]}})})},S.prototype.loadSync=function(x){this.artifacts=x;var k=this.artifacts.modelTopology,K={};this.artifacts.userDefinedMetadata!=null&&(K=this.artifacts.userDefinedMetadata.signature),this.version=k.versions.producer+"."+k.versions.minConsumer;var Se=i.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new tn(ga.Instance.transformGraph(k,K)),this.executor.weightMap=this.convertTensorMapToTensorsMap(Se),this.executor.resourceManager=this.resourceManager,x.modelInitializer!=null){var we=ga.Instance.transformGraph(x.modelInitializer);this.initializer=new tn(we),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0},S.prototype.save=function(x,k){return O(this,void 0,void 0,function(){var K;return H(this,function(Se){if(typeof x=="string"){if(K=i.io.getSaveHandlers(x),K.length===0)throw new Error("Cannot find any save handlers for URL '"+x+"'");if(K.length>1)throw new Error("Found more than one ("+K.length+") save handlers for "+("URL '"+x+"'"));x=K[0]}if(x.save==null)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return[2,x.save(this.artifacts)]})})},S.prototype.predict=function(x,k){return this.execute(x,this.outputNodes)},S.prototype.normalizeInputs=function(x){if(!(x instanceof i.Tensor)&&!Array.isArray(x))return x;if(x=Array.isArray(x)?x:[x],x.length!==this.inputNodes.length)throw new Error("Input tensor count mismatch,"+("the graph model has "+this.inputNodes.length+" placeholders, ")+("while there are "+x.length+" input tensors."));return this.inputNodes.reduce(function(k,K,Se){return k[K]=x[Se],k},{})},S.prototype.normalizeOutputs=function(x){return x=x||this.outputNodes,Array.isArray(x)?x:[x]},S.prototype.execute=function(x,k){x=this.normalizeInputs(x),k=this.normalizeOutputs(k);var K=this.executor.execute(x,k);return K.length>1?K:K[0]},S.prototype.executeAsync=function(x,k){return O(this,void 0,void 0,function(){var K;return H(this,function(Se){switch(Se.label){case 0:return x=this.normalizeInputs(x),k=this.normalizeOutputs(k),[4,this.executor.executeAsync(x,k)];case 1:return K=Se.sent(),[2,K.length>1?K:K[0]]}})})},S.prototype.convertTensorMapToTensorsMap=function(x){return Object.keys(x).reduce(function(k,K){return k[K]=[x[K]],k},{})},S.prototype.dispose=function(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()},S}();function Li(S,x){return x===void 0&&(x={}),O(this,void 0,void 0,function(){var k;return H(this,function(K){switch(K.label){case 0:if(S==null)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");return x==null&&(x={}),x.fromTFHub&&S.load==null&&(S.endsWith("/")||(S=S+"/"),S=""+S+aa+Kn),k=new ma(S,x),[4,k.load()];case 1:return K.sent(),[2,k]}})})}var Ea="2.7.0";N.GraphModel=ma,N.deregisterOp=ae,N.loadGraphModel=Li,N.registerOp=he,N.version_converter=Ea}),ug=Mr(()=>{}),cg=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=function(pe,X){return ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,re){j.__proto__=re}||function(j,re){for(var te in re)re.hasOwnProperty(te)&&(j[te]=re[te])},ke(pe,X)};function O(pe,X){ke(pe,X);function j(){this.constructor=pe}pe.prototype=X===null?Object.create(X):(j.prototype=X.prototype,new j)}function H(pe,X,j,re){return new(j||(j=Promise))(function(te,Ue){function kt(Ye){try{Le(re.next(Ye))}catch(Ft){Ue(Ft)}}function $e(Ye){try{Le(re.throw(Ye))}catch(Ft){Ue(Ft)}}function Le(Ye){Ye.done?te(Ye.value):new j(function(Ft){Ft(Ye.value)}).then(kt,$e)}Le((re=re.apply(pe,X||[])).next())})}function se(pe,X){var j={label:0,sent:function(){if(Ue[0]&1)throw Ue[1];return Ue[1]},trys:[],ops:[]},re,te,Ue,kt;return kt={next:$e(0),throw:$e(1),return:$e(2)},typeof Symbol=="function"&&(kt[Symbol.iterator]=function(){return this}),kt;function $e(Ye){return function(Ft){return Le([Ye,Ft])}}function Le(Ye){if(re)throw new TypeError("Generator is already executing.");for(;j;)try{if(re=1,te&&(Ue=Ye[0]&2?te.return:Ye[0]?te.throw||((Ue=te.return)&&Ue.call(te),0):te.next)&&!(Ue=Ue.call(te,Ye[1])).done)return Ue;(te=0,Ue)&&(Ye=[Ye[0]&2,Ue.value]);switch(Ye[0]){case 0:case 1:Ue=Ye;break;case 4:return j.label++,{value:Ye[1],done:!1};case 5:j.label++,te=Ye[1],Ye=[0];continue;case 7:Ye=j.ops.pop(),j.trys.pop();continue;default:if(!(Ue=j.trys,Ue=Ue.length>0&&Ue[Ue.length-1])&&(Ye[0]===6||Ye[0]===2)){j=0;continue}if(Ye[0]===3&&(!Ue||Ye[1]>Ue[0]&&Ye[1]<Ue[3])){j.label=Ye[1];break}if(Ye[0]===6&&j.label<Ue[1]){j.label=Ue[1],Ue=Ye;break}if(Ue&&j.label<Ue[2]){j.label=Ue[2],j.ops.push(Ye);break}Ue[2]&&j.ops.pop(),j.trys.pop();continue}Ye=X.call(pe,j)}catch(Ft){Ye=[6,Ft],te=0}finally{re=Ue=0}if(Ye[0]&5)throw Ye[1];return{value:Ye[0]?Ye[1]:void 0,done:!0}}}var xe=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Q(pe,X){return X={exports:{}},pe(X,X.exports),X.exports}var Ae=Q(function(pe){(function(X,j,re){function te(Le){var Ye=this,Ft=$e();Ye.next=function(){var St=2091639*Ye.s0+Ye.c*23283064365386963e-26;return Ye.s0=Ye.s1,Ye.s1=Ye.s2,Ye.s2=St-(Ye.c=St|0)},Ye.c=1,Ye.s0=Ft(" "),Ye.s1=Ft(" "),Ye.s2=Ft(" "),Ye.s0-=Ft(Le),Ye.s0<0&&(Ye.s0+=1),Ye.s1-=Ft(Le),Ye.s1<0&&(Ye.s1+=1),Ye.s2-=Ft(Le),Ye.s2<0&&(Ye.s2+=1),Ft=null}function Ue(Le,Ye){return Ye.c=Le.c,Ye.s0=Le.s0,Ye.s1=Le.s1,Ye.s2=Le.s2,Ye}function kt(Le,Ye){var Ft=new te(Le),St=Ye&&Ye.state,Mt=Ft.next;return Mt.int32=function(){return Ft.next()*4294967296|0},Mt.double=function(){return Mt()+(Mt()*2097152|0)*11102230246251565e-32},Mt.quick=Mt,St&&(typeof St=="object"&&Ue(St,Ft),Mt.state=function(){return Ue(Ft,{})}),Mt}function $e(){var Le=4022871197,Ye=function(Ft){Ft=Ft.toString();for(var St=0;St<Ft.length;St++){Le+=Ft.charCodeAt(St);var Mt=.02519603282416938*Le;Le=Mt>>>0,Mt-=Le,Mt*=Le,Le=Mt>>>0,Mt-=Le,Le+=Mt*4294967296}return(Le>>>0)*23283064365386963e-26};return Ye}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.alea=kt})(xe,pe,!1)}),P=Q(function(pe){(function(X,j,re){function te($e){var Le=this,Ye="";Le.x=0,Le.y=0,Le.z=0,Le.w=0,Le.next=function(){var St=Le.x^Le.x<<11;return Le.x=Le.y,Le.y=Le.z,Le.z=Le.w,Le.w^=Le.w>>>19^St^St>>>8},$e===($e|0)?Le.x=$e:Ye+=$e;for(var Ft=0;Ft<Ye.length+64;Ft++)Le.x^=Ye.charCodeAt(Ft)|0,Le.next()}function Ue($e,Le){return Le.x=$e.x,Le.y=$e.y,Le.z=$e.z,Le.w=$e.w,Le}function kt($e,Le){var Ye=new te($e),Ft=Le&&Le.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(typeof Ft=="object"&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.xor128=kt})(xe,pe,!1)}),he=Q(function(pe){(function(X,j,re){function te($e){var Le=this,Ye="";Le.next=function(){var St=Le.x^Le.x>>>2;return Le.x=Le.y,Le.y=Le.z,Le.z=Le.w,Le.w=Le.v,(Le.d=Le.d+362437|0)+(Le.v=Le.v^Le.v<<4^(St^St<<1))|0},Le.x=0,Le.y=0,Le.z=0,Le.w=0,Le.v=0,$e===($e|0)?Le.x=$e:Ye+=$e;for(var Ft=0;Ft<Ye.length+64;Ft++)Le.x^=Ye.charCodeAt(Ft)|0,Ft==Ye.length&&(Le.d=Le.x<<10^Le.x>>>4),Le.next()}function Ue($e,Le){return Le.x=$e.x,Le.y=$e.y,Le.z=$e.z,Le.w=$e.w,Le.v=$e.v,Le.d=$e.d,Le}function kt($e,Le){var Ye=new te($e),Ft=Le&&Le.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(typeof Ft=="object"&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.xorwow=kt})(xe,pe,!1)}),me=Q(function(pe){(function(X,j,re){function te($e){var Le=this;Le.next=function(){var Ft=Le.x,St=Le.i,Mt,dr;return Mt=Ft[St],Mt^=Mt>>>7,dr=Mt^Mt<<24,Mt=Ft[St+1&7],dr^=Mt^Mt>>>10,Mt=Ft[St+3&7],dr^=Mt^Mt>>>3,Mt=Ft[St+4&7],dr^=Mt^Mt<<7,Mt=Ft[St+7&7],Mt=Mt^Mt<<13,dr^=Mt^Mt<<9,Ft[St]=dr,Le.i=St+1&7,dr};function Ye(Ft,St){var Mt,dr,ir=[];if(St===(St|0))dr=ir[0]=St;else for(St=""+St,Mt=0;Mt<St.length;++Mt)ir[Mt&7]=ir[Mt&7]<<15^St.charCodeAt(Mt)+ir[Mt+1&7]<<13;for(;ir.length<8;)ir.push(0);for(Mt=0;Mt<8&&ir[Mt]===0;++Mt);for(Mt==8?dr=ir[7]=-1:dr=ir[Mt],Ft.x=ir,Ft.i=0,Mt=256;Mt>0;--Mt)Ft.next()}Ye(Le,$e)}function Ue($e,Le){return Le.x=$e.x.slice(),Le.i=$e.i,Le}function kt($e,Le){$e==null&&($e=+new Date);var Ye=new te($e),Ft=Le&&Le.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(Ft.x&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.xorshift7=kt})(xe,pe,!1)}),ae=Q(function(pe){(function(X,j,re){function te($e){var Le=this;Le.next=function(){var Ft=Le.w,St=Le.X,Mt=Le.i,dr,ir;return Le.w=Ft=Ft+1640531527|0,ir=St[Mt+34&127],dr=St[Mt=Mt+1&127],ir^=ir<<13,dr^=dr<<17,ir^=ir>>>15,dr^=dr>>>12,ir=St[Mt]=ir^dr,Le.i=Mt,ir+(Ft^Ft>>>16)|0};function Ye(Ft,St){var Mt,dr,ir,ta,fa,ra=[],Ha=128;for(St===(St|0)?(dr=St,St=null):(St=St+"\0",dr=0,Ha=Math.max(Ha,St.length)),ir=0,ta=-32;ta<Ha;++ta)St&&(dr^=St.charCodeAt((ta+32)%St.length)),ta===0&&(fa=dr),dr^=dr<<10,dr^=dr>>>15,dr^=dr<<4,dr^=dr>>>13,ta>=0&&(fa=fa+1640531527|0,Mt=ra[ta&127]^=dr+fa,ir=Mt==0?ir+1:0);for(ir>=128&&(ra[(St&&St.length||0)&127]=-1),ir=127,ta=4*128;ta>0;--ta)dr=ra[ir+34&127],Mt=ra[ir=ir+1&127],dr^=dr<<13,Mt^=Mt<<17,dr^=dr>>>15,Mt^=Mt>>>12,ra[ir]=dr^Mt;Ft.w=fa,Ft.X=ra,Ft.i=ir}Ye(Le,$e)}function Ue($e,Le){return Le.i=$e.i,Le.w=$e.w,Le.X=$e.X.slice(),Le}function kt($e,Le){$e==null&&($e=+new Date);var Ye=new te($e),Ft=Le&&Le.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(Ft.X&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.xor4096=kt})(xe,pe,!1)}),w=Q(function(pe){(function(X,j,re){function te($e){var Le=this,Ye="";Le.next=function(){var St=Le.b,Mt=Le.c,dr=Le.d,ir=Le.a;return St=St<<25^St>>>7^Mt,Mt=Mt-dr|0,dr=dr<<24^dr>>>8^ir,ir=ir-St|0,Le.b=St=St<<20^St>>>12^Mt,Le.c=Mt=Mt-dr|0,Le.d=dr<<16^Mt>>>16^ir,Le.a=ir-St|0},Le.a=0,Le.b=0,Le.c=2654435769|0,Le.d=1367130551,$e===Math.floor($e)?(Le.a=$e/4294967296|0,Le.b=$e|0):Ye+=$e;for(var Ft=0;Ft<Ye.length+20;Ft++)Le.b^=Ye.charCodeAt(Ft)|0,Le.next()}function Ue($e,Le){return Le.a=$e.a,Le.b=$e.b,Le.c=$e.c,Le.d=$e.d,Le}function kt($e,Le){var Ye=new te($e),Ft=Le&&Le.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(typeof Ft=="object"&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.tychei=kt})(xe,pe,!1)}),ge=Q(function(pe){(function(X,j){var re=this,te=256,Ue=6,kt=52,$e="random",Le=j.pow(te,Ue),Ye=j.pow(2,kt),Ft=Ye*2,St=te-1,Mt;function dr(sn,hn,na){var Jr=[];hn=hn==!0?{entropy:!0}:hn||{};var Vr=ra(fa(hn.entropy?[sn,ki(X)]:sn??Ha(),3),Jr),Jn=new ir(Jr),tn=function(){for(var Rn=Jn.g(Ue),Kn=Le,aa=0;Rn<Ye;)Rn=(Rn+aa)*te,Kn*=te,aa=Jn.g(1);for(;Rn>=Ft;)Rn/=2,Kn/=2,aa>>>=1;return(Rn+aa)/Kn};return tn.int32=function(){return Jn.g(4)|0},tn.quick=function(){return Jn.g(4)/4294967296},tn.double=tn,ra(ki(Jn.S),X),(hn.pass||na||function(Rn,Kn,aa,ma){return ma&&(ma.S&&ta(ma,Jn),Rn.state=function(){return ta(Jn,{})}),aa?(j[$e]=Rn,Kn):Rn})(tn,Vr,"global"in hn?hn.global:this==j,hn.state)}j["seed"+$e]=dr;function ir(sn){var hn,na=sn.length,Jr=this,Vr=0,Jn=Jr.i=Jr.j=0,tn=Jr.S=[];for(na||(sn=[na++]);Vr<te;)tn[Vr]=Vr++;for(Vr=0;Vr<te;Vr++)tn[Vr]=tn[Jn=St&Jn+sn[Vr%na]+(hn=tn[Vr])],tn[Jn]=hn;(Jr.g=function(Rn){for(var Kn,aa=0,ma=Jr.i,Li=Jr.j,Ea=Jr.S;Rn--;)Kn=Ea[ma=St&ma+1],aa=aa*te+Ea[St&(Ea[ma]=Ea[Li=St&Li+Kn])+(Ea[Li]=Kn)];return Jr.i=ma,Jr.j=Li,aa})(te)}function ta(sn,hn){return hn.i=sn.i,hn.j=sn.j,hn.S=sn.S.slice(),hn}function fa(sn,hn){var na=[],Jr=typeof sn,Vr;if(hn&&Jr=="object")for(Vr in sn)try{na.push(fa(sn[Vr],hn-1))}catch(Jn){}return na.length?na:Jr=="string"?sn:sn+"\0"}function ra(sn,hn){for(var na=sn+"",Jr,Vr=0;Vr<na.length;)hn[St&Vr]=St&(Jr^=hn[St&Vr]*19)+na.charCodeAt(Vr++);return ki(hn)}function Ha(){try{var sn;return Mt&&(sn=Mt.randomBytes)?sn=sn(te):(sn=new Uint8Array(te),(re.crypto||re.msCrypto).getRandomValues(sn)),ki(sn)}catch(Jr){var hn=re.navigator,na=hn&&hn.plugins;return[+new Date,re,na,re.screen,ki(X)]}}function ki(sn){return String.fromCharCode.apply(0,sn)}if(ra(j.random(),X),pe.exports){pe.exports=dr;try{Mt=Pp()}catch(sn){}}})([],Math)});ge.alea=Ae,ge.xor128=P,ge.xorwow=he,ge.xorshift7=me,ge.xor4096=ae,ge.tychei=w;var ze=ge,W=ze.alea;function nt(pe,X){return tt(pe,X)}function tt(pe,X,j,re){if(j===void 0&&(j=new Map),re===void 0&&(re=new Set),pe==null)return null;if(re.has(pe))throw new Error("Circular references are not supported.");if(j.has(pe))return j.get(pe);var te=X(pe);if(te.recurse&&te.value!==null)throw new Error("A deep map function may not return both a value and recurse=true.");if(te.recurse)if(xt(pe)){var Ue=Array.isArray(pe)?[]:{};re.add(pe);for(var kt in pe){var $e=pe[kt],Le=tt($e,X,j,re);Ue[kt]=Le}return re.delete(pe),Ue}else throw new Error("Can't recurse into non-iterable type: "+pe);else return j.set(pe,te.value),te.value}function nr(pe,X){return X===void 0&&(X=Qe),Tt(pe,X)}function Tt(pe,X,j){j===void 0&&(j=new Set);var re=pe[0];if(j.has(re))throw new Error("Circular references are not supported.");var te=X(pe);if(te.recurse&&te.value!==null)throw new Error("A deep zip function may not return both a value and recurse=true.");if(te.recurse)if(xt(re)){var Ue=Array.isArray(re)?[]:{};j.add(re);var kt=function(Le){var Ye=pe.map(function(St){return St[Le]}),Ft=Tt(Ye,X,j);Ue[Le]=Ft};for(var $e in re)kt($e);return j.delete(re),Ue}else throw new Error("Can't recurse into non-iterable type: "+re);else return te.value}function Qe(pe){return pe===null?null:xt(pe[0])?{value:null,recurse:!0}:{value:pe,recurse:!1}}function it(pe,X){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt,$e,Le;return se(this,function(Ye){switch(Ye.label){case 0:j=new Map,tt(pe,X,j),re=0,te=Array.from(j.keys()),Ye.label=1;case 1:return re<te.length?(Ue=te[re],kt=j.get(Ue),i.util.isPromise(kt)?[4,kt]:[3,3]):[3,4];case 2:$e=Ye.sent(),j.set(Ue,$e),Ye.label=3;case 3:return re++,[3,1];case 4:return Le=tt(pe,X,j),[2,Le]}})})}function xt(pe){return pe!=null&&!ArrayBuffer.isView(pe)&&(Array.isArray(pe)||typeof pe=="object"&&!(pe instanceof i.Tensor))}function ot(pe){return pe==null||ht(pe)||Array.isArray(pe)||typeof pe=="object"&&pe instanceof i.Tensor||i.util.isTypedArray(pe)}function ht(pe){return pe===null||typeof pe!="object"&&typeof pe!="function"}function ut(pe){return nt(pe,yt)}function yt(pe){return pe instanceof i.Tensor?{value:pe.clone(),recurse:!1}:xt(pe)?{value:null,recurse:!0}:{value:pe,recurse:!1}}var Zt=function(){function pe(X){if(this.capacity=X,this.begin=0,this.end=0,X==null)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(X<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(X),this.doubledCapacity=2*X}return pe.prototype.wrap=function(X){for(;X<0;)X+=this.doubledCapacity;return X%this.doubledCapacity},pe.prototype.get=function(X){if(X<0)throw new RangeError("Can't get item at a negative index.");return this.data[X%this.capacity]},pe.prototype.set=function(X,j){if(X<0)throw new RangeError("Can't set item at a negative index.");this.data[X%this.capacity]=j},pe.prototype.length=function(){var X=this.end-this.begin;return X<0&&(X=this.doubledCapacity+X),X},pe.prototype.isFull=function(){return this.length()===this.capacity},pe.prototype.isEmpty=function(){return this.length()===0},pe.prototype.push=function(X){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,X),this.end=this.wrap(this.end+1)},pe.prototype.pushAll=function(X){for(var j=0,re=X;j<re.length;j++){var te=re[j];this.push(te)}},pe.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var X=this.get(this.end);return this.set(this.end,void 0),X},pe.prototype.unshift=function(X){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,X)},pe.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var X=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),X},pe.prototype.shuffleExcise=function(X){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var j=this.wrap(this.begin+X),re=this.get(j);return this.set(j,this.pop()),re},pe}(),ar=function(pe){O(X,pe);function X(){return pe.call(this,X.INITIAL_CAPACITY)||this}return X.prototype.isFull=function(){return!1},X.prototype.push=function(j){pe.prototype.isFull.call(this)&&this.expand(),pe.prototype.push.call(this,j)},X.prototype.unshift=function(j){pe.prototype.isFull.call(this)&&this.expand(),pe.prototype.unshift.call(this,j)},X.prototype.expand=function(){for(var j=this.capacity*2,re=new Array(j),te=this.length(),Ue=0;Ue<te;Ue++)re[Ue]=this.get(this.wrap(this.begin+Ue));this.data=re,this.capacity=j,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=te},X.INITIAL_CAPACITY=32,X}(Zt);function qt(pe){return new Fa(pe)}function Ur(pe){return new Oa(pe)}function jr(pe,X){return new xn(pe,X)}function _r(pe,X){return X===void 0&&(X=Hn.FAIL),new _i(pe,X)}var tr=function(){function pe(){}return pe.prototype.toArray=function(){return H(this,void 0,void 0,function(){var X,j;return se(this,function(re){switch(re.label){case 0:return X=[],[4,this.next()];case 1:j=re.sent(),re.label=2;case 2:return j.done?[3,4]:(X.push(j.value),[4,this.next()]);case 3:return j=re.sent(),[3,2];case 4:return[2,X]}})})},pe.prototype.toArrayForTest=function(){return H(this,void 0,void 0,function(){var X,j,re;return se(this,function(te){switch(te.label){case 0:return X=this.prefetch(100),j=[],[4,X.next()];case 1:re=te.sent(),te.label=2;case 2:return re.done?[3,4]:(j.push(re.value),[4,X.next()]);case 3:return re=te.sent(),[3,2];case 4:return[2,j]}})})},pe.prototype.resolveFully=function(){return H(this,void 0,void 0,function(){var X;return se(this,function(j){switch(j.label){case 0:return[4,this.next()];case 1:X=j.sent(),j.label=2;case 2:return X.done?[3,4]:[4,this.next()];case 3:return X=j.sent(),[3,2];case 4:return[2]}})})},pe.prototype.resolveWhile=function(X){return H(this,void 0,void 0,function(){var j,re;return se(this,function(te){switch(te.label){case 0:return[4,this.next()];case 1:j=te.sent(),re=X(j.value),te.label=2;case 2:return!j.done&&re?[4,this.next()]:[3,4];case 3:return j=te.sent(),re=X(j.value),[3,2];case 4:return[2]}})})},pe.prototype.handleErrors=function(X){return new hi(this,X)},pe.prototype.filter=function(X){return new Ma(this,X)},pe.prototype.map=function(X){return new li(this,X)},pe.prototype.mapAsync=function(X){return new la(this,X)},pe.prototype.serialMapAsync=function(X){return new la(this,X).serial()},pe.prototype.flatmap=function(X){return new Ca(this,X)},pe.prototype.forEachAsync=function(X){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,this.map(X).resolveFully()]})})},pe.prototype.serialForEach=function(X){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,this.serialMapAsync(X).resolveWhile(function(re){return re===!0})]})})},pe.prototype.rowMajorBatch=function(X,j){return j===void 0&&(j=!0),new yn(this,X,j)},pe.prototype.columnMajorBatch=function(X,j,re){j===void 0&&(j=!0),re===void 0&&(re=Qe);var te=this.rowMajorBatch(X,j);return te.map(function(Ue){return nr(Ue,re)})},pe.prototype.concatenate=function(X,j){return new xn(qt([this,X]),j)},pe.prototype.take=function(X){return X<0||X==null?this:new Na(this,X)},pe.prototype.skip=function(X){return X<0||X==null?this:new Wa(this,X)},pe.prototype.prefetch=function(X){return new ha(this,X)},pe.prototype.shuffle=function(X,j){return new Ei(this,X,j)},pe.prototype.serial=function(){return new Tn(this)},pe}(),Fa=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;return re.items=j,re.trav=0,re}return X.prototype.summary=function(){return"Array of "+this.items.length+" items"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(j=this.items[this.trav],this.trav++,[2,{value:ut(j),done:!1}])})})},X}(tr),Oa=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;return re.nextFn=j,re}return X.prototype.summary=function(){return"Function call"},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){try{return[2,this.nextFn()]}catch(re){throw re.message="Error thrown while iterating through a dataset: "+re.message,re}return[2]})})},X}(tr),Tn=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;return re.upstream=j,re.lastRead=Promise.resolve({value:null,done:!1}),re}return X.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,this.upstream.next()]})})},X}(tr),Wa=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.maxCount=re,te.count=0,te.lastRead=Promise.resolve({value:null,done:!1}),te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){switch(re.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return j=re.sent(),j.done?[2,j]:(i.dispose(j.value),[3,0]);case 2:return[2,this.upstream.next()]}})})},X}(tr),Na=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.maxCount=re,te.count=0,te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Take"},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},X}(tr),yn=function(pe){O(X,pe);function X(j,re,te){te===void 0&&(te=!0);var Ue=pe.call(this)||this;return Ue.upstream=j,Ue.batchSize=re,Ue.enableSmallLastBatch=te,Ue.lastRead=Promise.resolve({value:null,done:!1}),Ue}return X.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j,re;return se(this,function(te){switch(te.label){case 0:j=[],te.label=1;case 1:return j.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return re=te.sent(),re.done?this.enableSmallLastBatch&&j.length>0?[2,{value:j,done:!1}]:[2,{value:null,done:!0}]:(j.push(re.value),[3,1]);case 3:return[2,{value:j,done:!1}]}})})},X}(tr),Ma=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.predicate=re,te.lastRead=Promise.resolve({value:null,done:!1}),te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){switch(re.label){case 0:return[4,this.upstream.next()];case 1:return j=re.sent(),j.done||this.predicate(j.value)?[2,j]:(i.dispose(j.value),[3,0]);case 2:return[2]}})})},X}(tr),li=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.transform=re,te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Map"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt,$e,Le;return se(this,function(Ye){switch(Ye.label){case 0:return[4,this.upstream.next()];case 1:if(j=Ye.sent(),j.done)return[2,{value:null,done:!0}];for(re=i.tensor_util.getTensorsInContainer(j.value),te=this.transform(j.value),Ue=i.tensor_util.getTensorsInContainer(te),kt=0,$e=re;kt<$e.length;kt++)Le=$e[kt],i.tensor_util.isTensorInList(Le,Ue)||Le.dispose();return[2,{value:te,done:!1}]}})})},X}(tr),hi=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.handler=re,te.count=0,te.lastRead=Promise.resolve({value:null,done:!1}),te}return X.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){switch(re.label){case 0:re.label=1;case 1:return re.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,re.sent()];case 3:return j=re.sent(),this.handler(j)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},X}(tr),la=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.transform=re,te}return X.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt,$e,Le;return se(this,function(Ye){switch(Ye.label){case 0:return[4,this.upstream.next()];case 1:return j=Ye.sent(),j.done?[2,{value:null,done:!0}]:(re=i.tensor_util.getTensorsInContainer(j.value),[4,this.transform(j.value)]);case 2:for(te=Ye.sent(),Ue=i.tensor_util.getTensorsInContainer(te),kt=0,$e=re;kt<$e.length;kt++)Le=$e[kt],i.tensor_util.isTensorInList(Le,Ue)||Le.dispose();return[2,{value:te,done:!1}]}})})},X}(tr),rn=function(pe){O(X,pe);function X(){var j=pe.call(this)||this;return j.outputQueue=new ar,j.lastRead=Promise.resolve({value:null,done:!1}),j}return X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return this.outputQueue.length()===0?[4,this.pump()]:[3,2];case 1:return j.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}})})},X}(tr),Ca=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.transform=re,te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},X.prototype.pump=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt,$e,Le;return se(this,function(Ye){switch(Ye.label){case 0:return[4,this.upstream.next()];case 1:if(j=Ye.sent(),j.done)return[2,!1];for(re=i.tensor_util.getTensorsInContainer(j.value),te=this.transform(j.value),Ue=i.tensor_util.getTensorsInContainer(te),this.outputQueue.pushAll(te),kt=0,$e=re;kt<$e.length;kt++)Le=$e[kt],i.tensor_util.isTensorInList(Le,Ue)||Le.dispose();return[2,!0]}})})},X}(rn),xn=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.baseErrorHandler=re,te.lastRead=null,te.iterator=null,te.moreIterators=j,te}return X.prototype.summary=function(){var j="TODO: fill in upstream of chained summaries";return j+" -> Chained"},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},X.prototype.readFromChain=function(j){return H(this,void 0,void 0,function(){var re,te;return se(this,function(Ue){switch(Ue.label){case 0:return[4,j];case 1:return Ue.sent(),this.iterator==null?[4,this.moreIterators.next()]:[3,3];case 2:if(re=Ue.sent(),re.done)return[2,{value:null,done:!0}];this.iterator=re.value,this.baseErrorHandler!=null&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),Ue.label=3;case 3:return[4,this.iterator.next()];case 4:return te=Ue.sent(),te.done?(this.iterator=null,[2,this.readFromChain(j)]):[2,te]}})})},X}(tr),Hn;(function(pe){pe[pe.FAIL=0]="FAIL",pe[pe.SHORTEST=1]="SHORTEST",pe[pe.LONGEST=2]="LONGEST"})(Hn||(Hn={}));var _i=function(pe){O(X,pe);function X(j,re){re===void 0&&(re=Hn.FAIL);var te=pe.call(this)||this;return te.iterators=j,te.mismatchMode=re,te.count=0,te.currentPromise=null,te}return X.prototype.summary=function(){var j="TODO: fill in upstream of zip summaries";return"{"+j+"} -> Zip"},X.prototype.nextState=function(j){return H(this,void 0,void 0,function(){function re($e){if($e instanceof tr){var Le=$e.next();return{value:Le.then(function(Ye){return te++,Ye.done&&Ue++,Ye.value}),recurse:!1}}else return{value:null,recurse:!0}}var te,Ue,kt;return se(this,function($e){switch($e.label){case 0:return[4,j];case 1:return $e.sent(),te=0,Ue=0,[4,it(this.iterators,re)];case 2:if(kt=$e.sent(),te===Ue)return[2,{value:null,done:!0}];if(Ue>0)switch(this.mismatchMode){case Hn.FAIL:throw new Error("Zipped streams should have the same length. "+("Mismatched at element "+this.count+"."));case Hn.SHORTEST:return[2,{value:null,done:!0}];case Hn.LONGEST:}return this.count++,[2,{value:kt,done:!1}]}})})},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]})})},X}(tr),ha=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.bufferSize=re,te.buffer=new Zt(re),te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},X.prototype.refill=function(){for(;!this.buffer.isFull();){var j=this.upstream.next();this.buffer.push(j)}},X.prototype.next=function(){return this.refill(),this.buffer.shift()},X}(tr),Ei=function(pe){O(X,pe);function X(j,re,te){var Ue=pe.call(this,j,re)||this;return Ue.upstream=j,Ue.windowSize=re,Ue.upstreamExhausted=!1,Ue.random=W(te||i.util.now().toString()),Ue.lastRead=Promise.resolve({value:null,done:!1}),Ue}return X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.randomInt=function(j){return Math.floor(this.random()*j)},X.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j,re;return se(this,function(te){switch(te.label){case 0:this.upstreamExhausted||this.refill(),te.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(j=this.chooseIndex(),[4,this.buffer.shuffleExcise(j)]);case 2:if(re=te.sent(),re.done)this.upstreamExhausted=!0;else return this.refill(),[2,re];return[3,1];case 3:return[2,{value:null,done:!0}]}})})},X}(ha),Gn=function(){function pe(){this.size=null}return pe.prototype.batch=function(X,j){var re=this;j===void 0&&(j=!0);var te=this;i.util.assert(X>0,function(){return`batchSize needs to be positive, but it is
`+X});var Ue;return this.size===Infinity||this.size==null?Ue=this.size:j?Ue=Math.ceil(this.size/X):Ue=Math.floor(this.size/X),jn(function(){return H(re,void 0,void 0,function(){return se(this,function(kt){switch(kt.label){case 0:return[4,te.iterator()];case 1:return[2,kt.sent().columnMajorBatch(X,j,wi)]}})})},Ue)},pe.prototype.concatenate=function(X){var j=this,re=this,te;return this.size===Infinity||X.size===Infinity?te=Infinity:this.size!=null&&X.size!=null?te=this.size+X.size:te=null,jn(function(){return H(j,void 0,void 0,function(){var Ue,kt;return se(this,function($e){switch($e.label){case 0:return[4,re.iterator()];case 1:return kt=(Ue=$e.sent()).concatenate,[4,X.iterator()];case 2:return[2,kt.apply(Ue,[$e.sent()])]}})})},te)},pe.prototype.filter=function(X){var j=this,re=this,te;return this.size===Infinity?te=Infinity:te=null,jn(function(){return H(j,void 0,void 0,function(){return se(this,function(Ue){switch(Ue.label){case 0:return[4,re.iterator()];case 1:return[2,Ue.sent().filter(function(kt){return i.tidy(function(){return X(kt)})})]}})})},te)},pe.prototype.forEachAsync=function(X){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return[4,this.iterator()];case 1:return[2,j.sent().forEachAsync(X)]}})})},pe.prototype.map=function(X){var j=this,re=this;return jn(function(){return H(j,void 0,void 0,function(){return se(this,function(te){switch(te.label){case 0:return[4,re.iterator()];case 1:return[2,te.sent().map(function(Ue){return i.tidy(function(){return X(Ue)})})]}})})},this.size)},pe.prototype.mapAsync=function(X){var j=this,re=this;return jn(function(){return H(j,void 0,void 0,function(){return se(this,function(te){switch(te.label){case 0:return[4,re.iterator()];case 1:return[2,te.sent().mapAsync(X)]}})})},this.size)},pe.prototype.prefetch=function(X){var j=this;if(X==null)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var re=this;return jn(function(){return H(j,void 0,void 0,function(){return se(this,function(te){switch(te.label){case 0:return[4,re.iterator()];case 1:return[2,te.sent().prefetch(X)]}})})},this.size)},pe.prototype.repeat=function(X){var j=this,re=this,te;return this.size!=null&&X>0?te=this.size*X:X===0?te=0:this.size!=null&&(X===void 0||X<0)?te=Infinity:te=null,jn(function(){return H(j,void 0,void 0,function(){var Ue,kt=this;return se(this,function($e){return Ue=Ur(function(){return H(kt,void 0,void 0,function(){var Le;return se(this,function(Ye){switch(Ye.label){case 0:return Le={},[4,re.iterator()];case 1:return[2,(Le.value=Ye.sent(),Le.done=!1,Le)]}})})}),[2,jr(Ue.take(X))]})})},te)},pe.prototype.skip=function(X){var j=this,re=this,te;return this.size!=null&&X>=0&&this.size>=X?te=this.size-X:this.size!=null&&(this.size<X||X===void 0||X<0)?te=0:te=null,jn(function(){return H(j,void 0,void 0,function(){return se(this,function(Ue){switch(Ue.label){case 0:return[4,re.iterator()];case 1:return[2,Ue.sent().skip(X)]}})})},te)},pe.prototype.shuffle=function(X,j,re){var te=this;if(re===void 0&&(re=!0),X==null||X<0)throw this.size==null?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError("`Dataset.shuffle()` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for `tf.Tensor`s), consider setting "+("bufferSize to the dataset size ("+this.size+" elements)"));var Ue=this,kt=W(j||i.util.now().toString());return jn(function(){return H(te,void 0,void 0,function(){var $e;return se(this,function(Le){switch(Le.label){case 0:return $e=kt.int32(),re&&($e+=kt.int32()),[4,Ue.iterator()];case 1:return[2,Le.sent().shuffle(X,$e.toString())]}})})},this.size)},pe.prototype.take=function(X){var j=this,re=this,te;return this.size!=null&&this.size>X?te=X:this.size!=null&&this.size<=X?te=this.size:te=null,jn(function(){return H(j,void 0,void 0,function(){return se(this,function(Ue){switch(Ue.label){case 0:return[4,re.iterator()];case 1:return[2,Ue.sent().take(X)]}})})},te)},pe.prototype.toArray=function(){return H(this,void 0,void 0,function(){return se(this,function(X){switch(X.label){case 0:if(this.size===Infinity)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,X.sent().toArray()]}})})},pe.prototype.toArrayForTest=function(){return H(this,void 0,void 0,function(){return se(this,function(X){switch(X.label){case 0:if(this.size===Infinity)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,X.sent().toArrayForTest()]}})})},pe.MAX_BUFFER_SIZE=1e4,pe}();function jn(pe,X){return X===void 0&&(X=null),new(function(j){O(re,j);function re(){var te=j!==null&&j.apply(this,arguments)||this;return te.size=X,te}return re.prototype.iterator=function(){return H(this,void 0,void 0,function(){return se(this,function(te){return[2,pe()]})})},re}(Gn))}function Ua(pe){var X=this;return jn(function(){return H(X,void 0,void 0,function(){return se(this,function(j){return[2,qt(pe)]})})},pe.length)}function ga(pe){var X=this;if(!xt(pe))throw new Error("The argument to zip() must be an object or array.");var j;if(Array.isArray(pe))for(var re=0;re<pe.length;re++)j=j==null?pe[re].size:Math.min(j,pe[re].size);else if(pe instanceof Object)for(var te in pe)j=j==null?pe[te].size:Math.min(j,pe[te].size);return jn(function(){return H(X,void 0,void 0,function(){var Ue;return se(this,function(kt){switch(kt.label){case 0:return[4,it(pe,function($e){if($e instanceof Gn)return{value:$e.iterator(),recurse:!1};if(xt($e))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})];case 1:return Ue=kt.sent(),[2,_r(Ue,Hn.SHORTEST)]}})})},j)}function wi(pe){if(pe===null)return null;var X=pe[0];if(ot(X)){var j=Ta(pe);return{value:j,recurse:!1}}return{value:null,recurse:!0}}function Ta(pe){if(pe.length===0)throw new Error("Can't make a batch of zero elements.");return pe[0]instanceof i.Tensor?i.stack(pe):i.tensor(pe)}var on=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;return re.input=j,re}return X.prototype.iterator=function(){return H(this,void 0,void 0,function(){var j,re,te;return se(this,function(Ue){switch(Ue.label){case 0:return[4,this.input.iterator()];case 1:return j=Ue.sent(),re=j.decodeUTF8(),te=re.split(`
`).map(function(kt){return kt.endsWith("\r")&&(kt=kt.slice(0,-1)),kt}),[2,te]}})})},X}(Gn),_n='"',xa=Symbol("out"),Rr=Symbol("field"),ti=Symbol("quote"),_a=Symbol("quoteafterquote"),Ri=Symbol("quoteinquote"),Hi=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.input=j,te.hasHeader=!0,te.fullColumnNames=null,te.columnNamesValidated=!1,te.columnConfigs=null,te.configuredColumnsOnly=!1,te.delimiter=",",te.delimWhitespace=!1,te.base=new on(j),re||(re={}),te.hasHeader=!(re.hasHeader===!1),te.fullColumnNames=re.columnNames,te.columnConfigs=re.columnConfigs,te.configuredColumnsOnly=re.configuredColumnsOnly,re.delimWhitespace?(i.util.assert(re.delimiter==null,function(){return"Delimiter should not be provided when delimWhitespace is true."}),te.delimWhitespace=!0,te.delimiter=" "):te.delimiter=re.delimiter?re.delimiter:",",te}return X.prototype.columnNames=function(){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:j.sent(),j.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}})})},X.prototype.setColumnNames=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt,$e,Le,Ye=this;return se(this,function(Ft){switch(Ft.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(j=Ft.sent(),!this.fullColumnNames&&!j)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&j&&i.util.assert(j.length===this.fullColumnNames.length,function(){return"The length of provided columnNames ("+Ye.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+j.length.toString()+")."}),this.fullColumnNames||(this.fullColumnNames=j),re=this.fullColumnNames.reduce(function(St,Mt){return St[Mt]=St[Mt]+1||1,St},{}),te=Object.keys(re).filter(function(St){return re[St]>1}),i.util.assert(te.length===0,function(){return"Duplicate column names found: "+te.toString()}),this.columnConfigs){for(Ue=0,kt=Object.keys(this.columnConfigs);Ue<kt.length;Ue++)if($e=kt[Ue],Le=this.fullColumnNames.indexOf($e),Le===-1)throw new Error('The key "'+$e+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}return this.columnNamesValidated=!0,[2]}})})},X.prototype.maybeReadHeaderLine=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue;return se(this,function(kt){switch(kt.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return j=kt.sent(),[4,j.next()];case 2:if(re=kt.sent(),re.done)throw new Error("No data was found for CSV parsing.");return te=re.value,Ue=this.parseRow(te,!1),[2,Ue];case 3:return[2,null]}})})},X.prototype.iterator=function(){return H(this,void 0,void 0,function(){var j,re=this;return se(this,function(te){switch(te.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:te.sent(),te.label=2;case 2:return[4,this.base.iterator()];case 3:return j=te.sent(),this.hasHeader&&(j=j.skip(1)),[2,j.map(function(Ue){return re.makeDataElement(Ue)})]}})})},X.prototype.makeDataElement=function(j){for(var re=this.parseRow(j),te={},Ue={},kt=0;kt<this.fullColumnNames.length;kt++){var $e=this.fullColumnNames[kt],Le=this.columnConfigs?this.columnConfigs[$e]:null;if(this.configuredColumnsOnly&&!Le)continue;var Ye=re[kt],Ft=null;if(Ye==="")if(Le&&Le.default!==void 0)Ft=Le.default;else{if(Le&&(Le.required||Le.isLabel))throw new Error("Required column "+$e+" is empty in this line: "+j);Ft=void 0}else{var St=Number(Ye);if(isNaN(St))Le&&Le.dtype==="bool"?Ft=this.getBoolean(Ye):Ft=Ye;else if(!Le||!Le.dtype)Ft=St;else switch(Le.dtype){case"float32":Ft=St;break;case"int32":Ft=Math.floor(St);break;case"bool":Ft=this.getBoolean(Ye);break;default:Ft=St}}Le&&Le.isLabel?Ue[$e]=Ft:te[$e]=Ft}return Object.keys(Ue).length===0?te:{xs:te,ys:Ue}},X.prototype.getBoolean=function(j){return j==="1"||j.toLowerCase()==="true"?1:0},X.prototype.parseRow=function(j,re){re===void 0&&(re=!0);for(var te=[],Ue=0,kt=j.length,$e=xa,Le=0;Le<kt;Le++)switch($e){case xa:switch(j.charAt(Le)){case _n:Ue=Le+1,$e=ti;break;case this.delimiter:if(Ue=Le+1,this.delimiter===" "&&this.delimWhitespace)break;te.push(""),$e=xa;break;default:$e=Rr,Ue=Le;break}break;case Rr:switch(j.charAt(Le)){case this.delimiter:te.push(j.substring(Ue,Le)),$e=xa,Ue=Le+1;break}break;case ti:switch(j.charAt(Le)){case _n:$e=_a;break}break;case _a:switch(j.charAt(Le)){case this.delimiter:te.push(j.substring(Ue,Le-1)),$e=xa,Ue=Le+1;break;case _n:$e=ti;break;default:$e=Ri;break}break;case Ri:switch(j.charAt(Le)){case _n:$e=ti;break}break}if($e===_a?te.push(j.substring(Ue,kt-1)):te.push(j.substring(Ue)),re&&te.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+te);return te},X}(Gn),Ai=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;re.microphoneConfig=j,re.isClosed=!1,re.fftSize=j.fftSize||1024;var te=Math.log2(re.fftSize);if(re.fftSize<0||te<4||te>14||!Number.isInteger(te))throw new Error("Invalid fftSize: it must be a power of 2 between "+("2 to 4 and 2 to 14, but got "+re.fftSize));if(re.numFrames=j.numFramesPerSpectrogram||43,re.sampleRateHz=j.sampleRateHz,re.columnTruncateLength=j.columnTruncateLength||re.fftSize,re.audioTrackConstraints=j.audioTrackConstraints,re.smoothingTimeConstant=j.smoothingTimeConstant||0,re.includeSpectrogram=!(j.includeSpectrogram===!1),re.includeWaveform=j.includeWaveform===!0,!re.includeSpectrogram&&!re.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return re}return X.prototype.summary=function(){return"microphone"},X.create=function(j){return j===void 0&&(j={}),H(this,void 0,void 0,function(){var re;return se(this,function(te){switch(te.label){case 0:if(i.env().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return re=new X(j),[4,re.start()];case 1:return te.sent(),[2,re]}})})},X.prototype.start=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue;return se(this,function(kt){switch(kt.label){case 0:return kt.trys.push([0,2,,3]),j=this,[4,navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints==null?!0:this.audioTrackConstraints,video:!1})];case 1:return j.stream=kt.sent(),[3,3];case 2:throw re=kt.sent(),new Error("Error thrown while initializing video stream: "+re.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(te=window.AudioContext||window.webkitAudioContext,this.audioContext=new te,!this.sampleRateHz)this.sampleRateHz=this.audioContext.sampleRate;else if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error("Mismatch in sampling rate: "+("Expected: "+this.sampleRateHz+"; ")+("Actual: "+this.audioContext.sampleRate));return Ue=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=this.fftSize*2,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,Ue.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt;return se(this,function($e){switch($e.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return te=$e.sent(),this.includeSpectrogram&&(Ue=this.flattenQueue(te.freqDataQueue),j=this.getTensorFromAudioDataArray(Ue,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(kt=this.flattenQueue(te.timeDataQueue),re=this.getTensorFromAudioDataArray(kt,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:j,waveform:re},done:!1}]}})})},X.prototype.capture=function(){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return[4,this.next()];case 1:return[2,j.sent().value]}})})},X.prototype.getAudioData=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue=this;return se(this,function(kt){return j=[],re=[],te=0,[2,new Promise(function($e){var Le=setInterval(function(){Ue.includeSpectrogram&&(Ue.analyser.getFloatFrequencyData(Ue.freqData),Ue.freqData[0]===-Infinity&&$e({freqDataQueue:j,timeDataQueue:re}),j.push(Ue.freqData.slice(0,Ue.columnTruncateLength))),Ue.includeWaveform&&(Ue.analyser.getFloatTimeDomainData(Ue.timeData),re.push(Ue.timeData.slice())),++te===Ue.numFrames&&(clearInterval(Le),$e({freqDataQueue:j,timeDataQueue:re}))},Ue.fftSize/Ue.sampleRateHz*1e3)})]})})},X.prototype.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),this.stream!=null&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())},X.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},X.prototype.getSampleRate=function(){return this.sampleRateHz},X.prototype.flattenQueue=function(j){var re=j[0].length,te=new Float32Array(j.length*re);return j.forEach(function(Ue,kt){return te.set(Ue,kt*re)}),te},X.prototype.getTensorFromAudioDataArray=function(j,re){var te=new Float32Array(i.util.sizeFromShape(re));return te.set(j,te.length-j.length),i.tensor(te,re)},X}(tr),qn=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;if(te.webcamVideoElement=j,te.webcamConfig=re,te.isClosed=!0,te.resize=!1,te.needToResize())if(te.resize=!0,te.cropSize=[te.webcamConfig.resizeHeight,te.webcamConfig.resizeWidth],te.cropBoxInd=i.tensor1d([0],"int32"),te.webcamConfig.centerCrop){var Ue=te.webcamConfig.resizeWidth*1/te.webcamVideoElement.width,kt=te.webcamConfig.resizeHeight*1/te.webcamVideoElement.height,$e=(1-Ue)/2,Le=(1-kt)/2,Ye=$e+Ue,Ft=kt+Le;te.cropBox=i.tensor2d([Le,$e,Ft,Ye],[1,4])}else te.cropBox=i.tensor2d([0,0,1,1],[1,4]);return te}return X.prototype.summary=function(){return"webcam"},X.create=function(j,re){return re===void 0&&(re={}),H(this,void 0,void 0,function(){var te;return se(this,function(Ue){switch(Ue.label){case 0:if(i.env().get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!j){if(j=document.createElement("video"),!re.resizeWidth||!re.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");j.width=re.resizeWidth,j.height=re.resizeHeight}return te=new X(j,re),[4,te.start()];case 1:return Ue.sent(),[2,te]}})})},X.prototype.start=function(){return H(this,void 0,void 0,function(){var j,re,te=this;return se(this,function(Ue){switch(Ue.label){case 0:this.webcamConfig.facingMode&&i.util.assert(this.webcamConfig.facingMode==="user"||this.webcamConfig.facingMode==="environment",function(){return"Invalid webcam facing mode: "+te.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),Ue.label=1;case 1:return Ue.trys.push([1,3,,4]),j=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return j.stream=Ue.sent(),[3,4];case 3:throw re=Ue.sent(),re.message="Error thrown while initializing video stream: "+re.message,re;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(kt){console.log(kt),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(kt){te.webcamVideoElement.onloadedmetadata=function(){kt()}})]}})})},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){if(this.isClosed)return[2,{value:null,done:!0}];try{j=i.browser.fromPixels(this.webcamVideoElement)}catch(te){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(te))}if(this.resize)try{return[2,{value:this.cropAndResizeFrame(j),done:!1}]}catch(te){throw new Error("Error thrown cropping the video: "+te.message)}finally{j.dispose()}else return[2,{value:j,done:!1}];return[2]})})},X.prototype.needToResize=function(){return!!(this.webcamConfig.resizeWidth&&this.webcamConfig.resizeHeight&&(this.webcamVideoElement.width!==this.webcamConfig.resizeWidth||this.webcamVideoElement.height!==this.webcamConfig.resizeHeight))},X.prototype.cropAndResizeFrame=function(j){var re=this;return i.tidy(function(){var te=j.toFloat().expandDims(0),Ue;Ue=i.image.cropAndResize(te,re.cropBox,re.cropBoxInd,re.cropSize,"bilinear");var kt=Ue.shape;return Ue.reshape(kt.slice(1))})},X.prototype.capture=function(){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return[4,this.next()];case 1:return[2,j.sent().value]}})})},X.prototype.stop=function(){var j=this.stream.getTracks();j.forEach(function(re){return re.stop()});try{this.webcamVideoElement.srcObject=null}catch(re){console.log(re),this.webcamVideoElement.src=null}this.isClosed=!0},X.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},X}(tr),ri=function(){function pe(){}return pe}(),pi=function(pe){O(X,pe);function X(){return pe!==null&&pe.apply(this,arguments)||this}return X.prototype.split=function(j){return new pa(this,j)},X}(tr),pa=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.impl=new di(j,re),te}return X.prototype.summary=function(){return this.impl.summary()},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,this.impl.next()]})})},X}(pi),di=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.separator=re,te.carryover="",te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},X.prototype.pump=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt;return se(this,function($e){switch($e.label){case 0:return[4,this.upstream.next()];case 1:if(j=$e.sent(),j.done)return this.carryover===""?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for(re=j.value.split(this.separator),re[0]=this.carryover+re[0],te=0,Ue=re.slice(0,-1);te<Ue.length;te++)kt=Ue[te],this.outputQueue.push(kt);return this.carryover=re[re.length-1],[2,!0]}})})},X}(rn),fi=function(pe){O(X,pe);function X(){return pe!==null&&pe.apply(this,arguments)||this}return X.prototype.decodeUTF8=function(){return new Va(this)},X}(tr),Va=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;return re.upstream=j,re.impl=new ln(j),re}return X.prototype.summary=function(){return this.impl.summary()},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,this.impl.next()]})})},X}(pi),ln=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;if(re.upstream=j,i.env().get("IS_BROWSER"))re.decoder=new TextDecoder("utf-8");else{var te=ug().StringDecoder;re.decoder=new te("utf8")}return re}return X.prototype.summary=function(){return this.upstream.summary()+" -> Utf8"},X.prototype.pump=function(){return H(this,void 0,void 0,function(){var j,re,te;return se(this,function(Ue){switch(Ue.label){case 0:return[4,this.upstream.next()];case 1:return j=Ue.sent(),j.done?[2,!1]:(re=j.value,i.env().get("IS_BROWSER")?te=this.decoder.decode(re,{stream:!0}):te=this.decoder.write(Buffer.from(re.buffer)),this.outputQueue.push(te),[2,!0])}})})},X}(rn),ni=function(pe){O(X,pe);function X(j,re){re===void 0&&(re={});var te=pe.call(this)||this;return te.file=j,te.options=re,i.util.assert(j instanceof Uint8Array||(i.env().get("IS_BROWSER")?j instanceof File||j instanceof Blob:!1),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),te.offset=re.offset||0,te.chunkSize=re.chunkSize||1024*1024,te}return X.prototype.summary=function(){return"FileChunks "+this.file},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j,re,te=this;return se(this,function(Ue){switch(Ue.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(j=new Promise(function(kt,$e){var Le=te.offset+te.chunkSize;if(te.file instanceof Uint8Array)kt(new Uint8Array(te.file.slice(te.offset,Le)));else{var Ye=new FileReader;Ye.onload=function(St){var Mt=Ye.result;if(Mt instanceof ArrayBuffer&&(Mt=new Uint8Array(Mt)),!(Mt instanceof Uint8Array))return $e(new TypeError("FileReader returned unknown type."));kt(Mt)},Ye.onabort=function(St){return $e(new Error("Aborted"))},Ye.onerror=function(St){return $e(new Error(St.type))};var Ft=te.file.slice(te.offset,Le);Ye.readAsArrayBuffer(Ft)}te.offset=Le}),re={},[4,j]);case 1:return[2,(re.value=Ue.sent(),re.done=!1,re)]}})})},X}(fi);function gr(pe,X){return X===void 0&&(X={}),H(this,void 0,void 0,function(){var j,re,te,Ue,kt;return se(this,function($e){switch($e.label){case 0:return typeof pe=="string"?j=pe:(j=pe.url,re=Di(pe)),[4,i.util.fetch(j,re)];case 1:return te=$e.sent(),te.ok?(kt=Uint8Array.bind,[4,te.arrayBuffer()]):[3,3];case 2:return Ue=new(kt.apply(Uint8Array,[void 0,$e.sent()])),[2,new ni(Ue,X)];case 3:throw new Error(te.statusText)}})})}var Di=function(pe){var X={method:pe.method,headers:pe.headers,body:pe.body,mode:pe.mode,credentials:pe.credentials,cache:pe.cache,redirect:pe.redirect,referrer:pe.referrer,integrity:pe.integrity};return X};function bi(pe){return typeof pe=="string"&&pe.substr(0,7)==="file://"}var ro=function(pe){O(X,pe);function X(j,re){re===void 0&&(re={});var te=pe.call(this)||this;return te.input=j,te.options=re,te}return X.prototype.iterator=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){return bi(this.input)&&i.env().get("IS_NODE")&&(j=require("fs"),this.input=j.readFileSync(this.input.substr(7))),[2,new ni(this.input,this.options)]})})},X}(ri),Zn=function(pe){O(X,pe);function X(j,re){re===void 0&&(re={});var te=pe.call(this)||this;return te.url=j,te.fileOptions=re,te}return X.prototype.iterator=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return bi(this.url)?[2,new ro(this.url,this.fileOptions).iterator()]:[2,gr(this.url,this.fileOptions)]})})},X}(ri);function Gi(pe,X){return X===void 0&&(X={}),new Hi(new Zn(pe),X)}function Fi(pe){var X=this,j=Ur(pe);return jn(function(){return H(X,void 0,void 0,function(){return se(this,function(re){return[2,j]})})})}function ji(pe){var X=this;return jn(function(){return H(X,void 0,void 0,function(){var j;return se(this,function(re){switch(re.label){case 0:return[4,pe()];case 1:return j=re.sent(),[2,Ur(function(){return j.next()})]}})})})}function Oi(pe,X){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,qn.create(pe,X)]})})}function da(pe){return H(this,void 0,void 0,function(){return se(this,function(X){return[2,Ai.create(pe)]})})}var Mi="2.7.0";N.CSVDataset=Hi,N.Dataset=Gn,N.FileDataSource=ro,N.TextLineDataset=on,N.URLDataSource=Zn,N.array=Ua,N.csv=Gi,N.func=Fi,N.generator=ji,N.microphone=da,N.version_data=Mi,N.webcam=Oi,N.zip=ga}),lg=Mr((N,i)=>{(function(ke,O,H){function se(P){var he=this,me=Ae();he.next=function(){var ae=2091639*he.s0+he.c*23283064365386963e-26;return he.s0=he.s1,he.s1=he.s2,he.s2=ae-(he.c=ae|0)},he.c=1,he.s0=me(" "),he.s1=me(" "),he.s2=me(" "),he.s0-=me(P),he.s0<0&&(he.s0+=1),he.s1-=me(P),he.s1<0&&(he.s1+=1),he.s2-=me(P),he.s2<0&&(he.s2+=1),me=null}function xe(P,he){return he.c=P.c,he.s0=P.s0,he.s1=P.s1,he.s2=P.s2,he}function Q(P,he){var me=new se(P),ae=he&&he.state,w=me.next;return w.int32=function(){return me.next()*4294967296|0},w.double=function(){return w()+(w()*2097152|0)*11102230246251565e-32},w.quick=w,ae&&(typeof ae=="object"&&xe(ae,me),w.state=function(){return xe(me,{})}),w}function Ae(){var P=4022871197,he=function(me){me=me.toString();for(var ae=0;ae<me.length;ae++){P+=me.charCodeAt(ae);var w=.02519603282416938*P;P=w>>>0,w-=P,w*=P,P=w>>>0,w-=P,P+=w*4294967296}return(P>>>0)*23283064365386963e-26};return he}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.alea=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),hg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this,he="";P.x=0,P.y=0,P.z=0,P.w=0,P.next=function(){var ae=P.x^P.x<<11;return P.x=P.y,P.y=P.z,P.z=P.w,P.w^=P.w>>>19^ae^ae>>>8},Ae===(Ae|0)?P.x=Ae:he+=Ae;for(var me=0;me<he.length+64;me++)P.x^=he.charCodeAt(me)|0,P.next()}function xe(Ae,P){return P.x=Ae.x,P.y=Ae.y,P.z=Ae.z,P.w=Ae.w,P}function Q(Ae,P){var he=new se(Ae),me=P&&P.state,ae=function(){return(he.next()>>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(typeof me=="object"&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.xor128=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),pg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this,he="";P.next=function(){var ae=P.x^P.x>>>2;return P.x=P.y,P.y=P.z,P.z=P.w,P.w=P.v,(P.d=P.d+362437|0)+(P.v=P.v^P.v<<4^(ae^ae<<1))|0},P.x=0,P.y=0,P.z=0,P.w=0,P.v=0,Ae===(Ae|0)?P.x=Ae:he+=Ae;for(var me=0;me<he.length+64;me++)P.x^=he.charCodeAt(me)|0,me==he.length&&(P.d=P.x<<10^P.x>>>4),P.next()}function xe(Ae,P){return P.x=Ae.x,P.y=Ae.y,P.z=Ae.z,P.w=Ae.w,P.v=Ae.v,P.d=Ae.d,P}function Q(Ae,P){var he=new se(Ae),me=P&&P.state,ae=function(){return(he.next()>>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(typeof me=="object"&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.xorwow=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),dg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this;P.next=function(){var me=P.x,ae=P.i,w,ge,ze;return w=me[ae],w^=w>>>7,ge=w^w<<24,w=me[ae+1&7],ge^=w^w>>>10,w=me[ae+3&7],ge^=w^w>>>3,w=me[ae+4&7],ge^=w^w<<7,w=me[ae+7&7],w=w^w<<13,ge^=w^w<<9,me[ae]=ge,P.i=ae+1&7,ge};function he(me,ae){var w,ge,ze=[];if(ae===(ae|0))ge=ze[0]=ae;else for(ae=""+ae,w=0;w<ae.length;++w)ze[w&7]=ze[w&7]<<15^ae.charCodeAt(w)+ze[w+1&7]<<13;for(;ze.length<8;)ze.push(0);for(w=0;w<8&&ze[w]===0;++w);for(w==8?ge=ze[7]=-1:ge=ze[w],me.x=ze,me.i=0,w=256;w>0;--w)me.next()}he(P,Ae)}function xe(Ae,P){return P.x=Ae.x.slice(),P.i=Ae.i,P}function Q(Ae,P){Ae==null&&(Ae=+new Date);var he=new se(Ae),me=P&&P.state,ae=function(){return(he.next()>>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(me.x&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.xorshift7=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),fg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this;P.next=function(){var me=P.w,ae=P.X,w=P.i,ge,ze;return P.w=me=me+1640531527|0,ze=ae[w+34&127],ge=ae[w=w+1&127],ze^=ze<<13,ge^=ge<<17,ze^=ze>>>15,ge^=ge>>>12,ze=ae[w]=ze^ge,P.i=w,ze+(me^me>>>16)|0};function he(me,ae){var w,ge,ze,W,nt,tt=[],nr=128;for(ae===(ae|0)?(ge=ae,ae=null):(ae=ae+"\0",ge=0,nr=Math.max(nr,ae.length)),ze=0,W=-32;W<nr;++W)ae&&(ge^=ae.charCodeAt((W+32)%ae.length)),W===0&&(nt=ge),ge^=ge<<10,ge^=ge>>>15,ge^=ge<<4,ge^=ge>>>13,W>=0&&(nt=nt+1640531527|0,w=tt[W&127]^=ge+nt,ze=w==0?ze+1:0);for(ze>=128&&(tt[(ae&&ae.length||0)&127]=-1),ze=127,W=4*128;W>0;--W)ge=tt[ze+34&127],w=tt[ze=ze+1&127],ge^=ge<<13,w^=w<<17,ge^=ge>>>15,w^=w>>>12,tt[ze]=ge^w;me.w=nt,me.X=tt,me.i=ze}he(P,Ae)}function xe(Ae,P){return P.i=Ae.i,P.w=Ae.w,P.X=Ae.X.slice(),P}function Q(Ae,P){Ae==null&&(Ae=+new Date);var he=new se(Ae),me=P&&P.state,ae=function(){return(he.next()>>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(me.X&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.xor4096=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),mg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this,he="";P.next=function(){var ae=P.b,w=P.c,ge=P.d,ze=P.a;return ae=ae<<25^ae>>>7^w,w=w-ge|0,ge=ge<<24^ge>>>8^ze,ze=ze-ae|0,P.b=ae=ae<<20^ae>>>12^w,P.c=w=w-ge|0,P.d=ge<<16^w>>>16^ze,P.a=ze-ae|0},P.a=0,P.b=0,P.c=2654435769|0,P.d=1367130551,Ae===Math.floor(Ae)?(P.a=Ae/4294967296|0,P.b=Ae|0):he+=Ae;for(var me=0;me<he.length+20;me++)P.b^=he.charCodeAt(me)|0,P.next()}function xe(Ae,P){return P.a=Ae.a,P.b=Ae.b,P.c=Ae.c,P.d=Ae.d,P}function Q(Ae,P){var he=new se(Ae),me=P&&P.state,ae=function(){return(he.next()>>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(typeof me=="object"&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.tychei=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),yg=Mr((N,i)=>{(function(ke,O){var H=this,se=256,xe=6,Q=52,Ae="random",P=O.pow(se,xe),he=O.pow(2,Q),me=he*2,ae=se-1,w;function ge(Qe,it,xt){var ot=[];it=it==!0?{entropy:!0}:it||{};var ht=tt(nt(it.entropy?[Qe,Tt(ke)]:Qe??nr(),3),ot),ut=new ze(ot),yt=function(){for(var Zt=ut.g(xe),ar=P,qt=0;Zt<he;)Zt=(Zt+qt)*se,ar*=se,qt=ut.g(1);for(;Zt>=me;)Zt/=2,ar/=2,qt>>>=1;return(Zt+qt)/ar};return yt.int32=function(){return ut.g(4)|0},yt.quick=function(){return ut.g(4)/4294967296},yt.double=yt,tt(Tt(ut.S),ke),(it.pass||xt||function(Zt,ar,qt,Ur){return Ur&&(Ur.S&&W(Ur,ut),Zt.state=function(){return W(ut,{})}),qt?(O[Ae]=Zt,ar):Zt})(yt,ht,"global"in it?it.global:this==O,it.state)}O["seed"+Ae]=ge;function ze(Qe){var it,xt=Qe.length,ot=this,ht=0,ut=ot.i=ot.j=0,yt=ot.S=[];for(xt||(Qe=[xt++]);ht<se;)yt[ht]=ht++;for(ht=0;ht<se;ht++)yt[ht]=yt[ut=ae&ut+Qe[ht%xt]+(it=yt[ht])],yt[ut]=it;(ot.g=function(Zt){for(var ar,qt=0,Ur=ot.i,jr=ot.j,_r=ot.S;Zt--;)ar=_r[Ur=ae&Ur+1],qt=qt*se+_r[ae&(_r[Ur]=_r[jr=ae&jr+ar])+(_r[jr]=ar)];return ot.i=Ur,ot.j=jr,qt})(se)}function W(Qe,it){return it.i=Qe.i,it.j=Qe.j,it.S=Qe.S.slice(),it}function nt(Qe,it){var xt=[],ot=typeof Qe,ht;if(it&&ot=="object")for(ht in Qe)try{xt.push(nt(Qe[ht],it-1))}catch(ut){}return xt.length?xt:ot=="string"?Qe:Qe+"\0"}function tt(Qe,it){for(var xt=Qe+"",ot,ht=0;ht<xt.length;)it[ae&ht]=ae&(ot^=it[ae&ht]*19)+xt.charCodeAt(ht++);return Tt(it)}function nr(){try{var Qe;return w&&(Qe=w.randomBytes)?Qe=Qe(se):(Qe=new Uint8Array(se),(H.crypto||H.msCrypto).getRandomValues(Qe)),Tt(Qe)}catch(ot){var it=H.navigator,xt=it&&it.plugins;return[+new Date,H,xt,H.screen,Tt(ke)]}}function Tt(Qe){return String.fromCharCode.apply(0,Qe)}if(tt(O.random(),ke),typeof i=="object"&&i.exports){i.exports=ge;try{w=Pp()}catch(Qe){}}else typeof define=="function"&&define.amd&&define(function(){return ge})})([],Math)}),vg=Mr((N,i)=>{var ke=lg(),O=hg(),H=pg(),se=dg(),xe=fg(),Q=mg(),Ae=yg();Ae.alea=ke,Ae.xor128=O,Ae.xorwow=H,Ae.xorshift7=se,Ae.xor4096=xe,Ae.tychei=Q,i.exports=Ae}),gg=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=vg(),O=function(ne,ue){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,F){E.__proto__=F}||function(E,F){for(var A in F)F.hasOwnProperty(A)&&(E[A]=F[A])},O(ne,ue)};function H(ne,ue){O(ne,ue);function E(){this.constructor=ne}ne.prototype=ue===null?Object.create(ue):(E.prototype=ue.prototype,new E)}function se(ne,ue,E,F){function A(V){return V instanceof E?V:new E(function(oe){oe(V)})}return new(E||(E=Promise))(function(V,oe){function ee(de){try{ce(F.next(de))}catch(ye){oe(ye)}}function _e(de){try{ce(F.throw(de))}catch(ye){oe(ye)}}function ce(de){de.done?V(de.value):A(de.value).then(ee,_e)}ce((F=F.apply(ne,ue||[])).next())})}function xe(ne,ue){var E={label:0,sent:function(){if(V[0]&1)throw V[1];return V[1]},trys:[],ops:[]},F,A,V,oe;return oe={next:ee(0),throw:ee(1),return:ee(2)},typeof Symbol=="function"&&(oe[Symbol.iterator]=function(){return this}),oe;function ee(ce){return function(de){return _e([ce,de])}}function _e(ce){if(F)throw new TypeError("Generator is already executing.");for(;E;)try{if(F=1,A&&(V=ce[0]&2?A.return:ce[0]?A.throw||((V=A.return)&&V.call(A),0):A.next)&&!(V=V.call(A,ce[1])).done)return V;(A=0,V)&&(ce=[ce[0]&2,V.value]);switch(ce[0]){case 0:case 1:V=ce;break;case 4:return E.label++,{value:ce[1],done:!1};case 5:E.label++,A=ce[1],ce=[0];continue;case 7:ce=E.ops.pop(),E.trys.pop();continue;default:if(!(V=E.trys,V=V.length>0&&V[V.length-1])&&(ce[0]===6||ce[0]===2)){E=0;continue}if(ce[0]===3&&(!V||ce[1]>V[0]&&ce[1]<V[3])){E.label=ce[1];break}if(ce[0]===6&&E.label<V[1]){E.label=V[1],V=ce;break}if(V&&E.label<V[2]){E.label=V[2],E.ops.push(ce);break}V[2]&&E.ops.pop(),E.trys.pop();continue}ce=ue.call(ne,E)}catch(de){ce=[6,de],A=0}finally{F=V=0}if(ce[0]&5)throw ce[1];return{value:ce[0]?ce[1]:void 0,done:!0}}}function Q(ne,ue){Array.isArray(ne)||(ne=[ne]),ne.forEach(function(E){E!=null&&i.util.assert(E.dtype!=="complex64",function(){return ue+" does not support complex64 tensors in the CPU backend."})})}var Ae=i.kernel_impls.nonMaxSuppressionV3Impl,P=i.kernel_impls.split,he=i.kernel_impls.tile,me=i.kernel_impls.topkImpl,ae=i.kernel_impls.whereImpl,w=function(ne){H(ue,ne);function ue(){var E=ne.call(this)||this;return E.blockSize=48,E.firstUse=!0,E.data=new i.DataStorage(E,i.engine()),E}return ue.prototype.write=function(E,F,A){this.firstUse&&(this.firstUse=!1,i.env().get("IS_NODE")&&i.backend_util.warn(`
============================
Hi there \u{1F44B}. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.
============================`));var V={};return this.data.set(V,{values:E,dtype:A,refCount:1}),V},ue.prototype.makeTensorInfo=function(E,F,A){var V;if(F==="string"&&A!=null&&A.length>0&&i.util.isString(A[0])){var oe=A.map(function(ee){return i.util.encodeString(ee)});V=this.write(oe,E,F)}else V=this.write(A,E,F);return{dataId:V,shape:E,dtype:F}},ue.prototype.incRef=function(E){var F=this.data.get(E);F.refCount++},ue.prototype.decRef=function(E){if(this.data.has(E)){var F=this.data.get(E);F.refCount--}},ue.prototype.move=function(E,F,A,V){this.data.set(E,{values:F,dtype:V,refCount:1})},ue.prototype.numDataIds=function(){return this.data.numDataIds()},ue.prototype.read=function(E){return se(this,void 0,void 0,function(){return xe(this,function(F){return[2,this.readSync(E)]})})},ue.prototype.readSync=function(E){var F=this.data.get(E),A=F.dtype,V=F.complexTensorInfos;if(A==="complex64"){var oe=this.readSync(V.real.dataId),ee=this.readSync(V.imag.dataId);return i.backend_util.mergeRealAndImagArrays(oe,ee)}return this.data.get(E).values},ue.prototype.bufferSync=function(E){var F=this.readSync(E.dataId),A=F;if(E.dtype==="string")try{A=F.map(function(V){return i.util.decodeString(V)})}catch(V){throw new Error("Failed to decode encoded string bytes into utf-8")}return i.buffer(E.shape,E.dtype,A)},ue.prototype.makeOutput=function(E,F,A){var V=this.write(E,F,A);return i.engine().makeTensorFromDataId(V,F,A,this)},ue.prototype.disposeData=function(E){if(this.data.has(E)){var F=this.data.get(E).complexTensorInfos;F!=null&&(this.disposeData(F.real.dataId),this.disposeData(F.imag.dataId)),this.data.delete(E)}},ue.prototype.disposeIntermediateTensorInfo=function(E){var F=E.dataId;if(this.data.has(F)){var A=this.data.get(F);A.refCount--,A.refCount<1&&this.disposeData(F)}},ue.prototype.time=function(E){return se(this,void 0,void 0,function(){var F,A;return xe(this,function(V){return F=i.util.now(),E(),A=i.util.now()-F,[2,{kernelMs:A}]})})},ue.prototype.memory=function(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}},ue.prototype.stridedSlice=function(E,F,A,V){Q(E,"stridedSlice");var oe=i.slice_util.computeOutShape(F,A,V);if(oe.some(function(Re){return Re===0}))return i.tensor([],oe);for(var ee=i.buffer(oe,E.dtype),_e=this.bufferSync(E),ce=0;ce<ee.size;ce++){for(var de=ee.indexToLoc(ce),ye=new Array(de.length),ve=0;ve<ye.length;ve++)ye[ve]=de[ve]*V[ve]+F[ve];ee.set.apply(ee,[_e.get.apply(_e,ye)].concat(de))}return ee.toTensor()},ue.prototype.diag=function(E){for(var F=this.readSync(E.dataId),A=i.buffer([E.size,E.size],E.dtype),V=A.values,oe=0;oe<F.length;oe++)V[oe*E.size+oe]=F[oe];return A.toTensor()},ue.prototype.unstack=function(E,F){for(var A=E.shape[F],V=new Array(E.rank-1),oe=0,ee=0;ee<E.rank;ee++)ee!==F&&(V[oe++]=E.shape[ee]);var _e=new Array(E.rank).fill(0),ce=E.shape.slice();ce[F]=1;for(var de=new Array(A),ee=0;ee<de.length;ee++)_e[F]=ee,de[ee]=i.slice(E,_e,ce).reshape(V);return de},ue.prototype.reverse=function(E,F){Q(E,"reverse");for(var A=i.buffer(E.shape,E.dtype),V=this.bufferSync(E),oe=function(_e){var ce=A.indexToLoc(_e),de=ce.slice();F.forEach(function(ye){return de[ye]=E.shape[ye]-1-de[ye]}),A.set.apply(A,[V.get.apply(V,de)].concat(ce))},ee=0;ee<A.size;ee++)oe(ee);return A.toTensor()},ue.prototype.neg=function(E){return Q(E,"neg"),i.mul(i.scalar(-1),E)},ue.prototype.addN=function(E){var F=this;Q(E,"addN");for(var A=E.map(function(de){return F.readSync(de.dataId)}),V=i.buffer(E[0].shape,E[0].dtype),oe=V.values,ee=0;ee<E.length;ee++)for(var _e=A[ee],ce=0;ce<oe.length;ce++)oe[ce]+=_e[ce];return V.toTensor()},ue.prototype.softmax=function(E,F){var A=i.util.parseAxisParam([F],E.shape),V=i.max(E,A),oe=i.backend_util.expandShapeToKeepDim(V.shape,A),ee=i.sub(E,V.reshape(oe)),_e=i.exp(ee),ce=this.sum(_e,A).reshape(oe);return i.div(_e,ce)},ue.prototype.pow=function(E,F){return Q([E,F],"pow"),this.broadcastedBinaryOp(E,F,E.dtype,function(A,V){return Math.pow(A,V)})},ue.prototype.floorDiv=function(E,F){Q([E,F],"floorDiv");var A=function(oe,ee){return Math.floor(oe/ee)},V="int32";return this.broadcastedBinaryOp(E,F,V,A)},ue.prototype.sum=function(E,F){Q(E,"sum"),i.backend_util.assertAxesAreInnerMostDims("sum",F,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,F),V=A[0],oe=A[1],ee=i.upcastType(E.dtype,"int32"),_e=i.zeros(V,ee),ce=i.util.sizeFromShape(oe),de=this.readSync(_e.dataId),ye=this.readSync(E.dataId),ve=0;ve<de.length;++ve){for(var Re=ve*ce,Oe=0,Fe=0;Fe<ce;++Fe)Oe+=ye[Re+Fe];de[ve]=Oe}return _e},ue.prototype.prod=function(E,F){Q(E,"sum");for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,F),V=A[0],oe=A[1],ee=i.upcastType(E.dtype,"int32"),_e=i.zeros(V,ee),ce=i.util.sizeFromShape(oe),de=this.readSync(_e.dataId),ye=this.readSync(E.dataId),ve=0;ve<de.length;++ve){for(var Re=ve*ce,Oe=1,Fe=0;Fe<ce;++Fe)Oe*=ye[Re+Fe];de[ve]=Oe}return _e},ue.prototype.unsortedSegmentSum=function(E,F,A){Q(E,"unsortedSegmentSum");for(var V=[],oe=E.rank-F.rank,ee=0;ee<oe;++ee)F=F.expandDims(ee+1);for(var ee=0;ee<A;++ee){var _e=i.scalar(ee,"int32"),ce=i.equal(_e,F).asType("float32"),de=ce.mul(E).sum(0);V.push(de)}return i.stack(V)},ue.prototype.argMin=function(E,F){Q(E,"argMin");var A=[F];i.backend_util.assertAxesAreInnerMostDims("argMin",A,E.rank);for(var V=i.backend_util.computeOutAndReduceShapes(E.shape,A),oe=V[0],ee=V[1],_e=i.zeros(oe,"int32"),ce=i.util.sizeFromShape(ee),de=this.readSync(_e.dataId),ye=this.readSync(E.dataId),ve=0;ve<de.length;++ve){for(var Re=ve*ce,Oe=ye[Re],Fe=0,Ve=0;Ve<ce;++Ve){var Xe=ye[Re+Ve];Xe<Oe&&(Oe=Xe,Fe=Ve)}de[ve]=Fe}return _e},ue.prototype.argMax=function(E,F){Q(E,"argMax");var A=[F];i.backend_util.assertAxesAreInnerMostDims("argMax",A,E.rank);for(var V=i.backend_util.computeOutAndReduceShapes(E.shape,A),oe=V[0],ee=V[1],_e=i.zeros(oe,"int32"),ce=i.util.sizeFromShape(ee),de=this.readSync(_e.dataId),ye=this.readSync(E.dataId),ve=0;ve<de.length;++ve){for(var Re=ve*ce,Oe=ye[Re],Fe=0,Ve=0;Ve<ce;++Ve){var Xe=ye[Re+Ve];Xe>Oe&&(Oe=Xe,Fe=Ve)}de[ve]=Fe}return _e},ue.prototype.cumsum=function(E,F,A,V){if(Q(E,"cumsum"),F!==E.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(E.rank-1)+" "+("but got axis="+F));for(var oe=i.upcastType(E.dtype,"int32"),ee=i.zeros(E.shape,oe),_e=this.readSync(ee.dataId),ce=this.readSync(E.dataId),de=E.shape[E.rank-1],ye=V?function(Ve,Xe){return Ve+de-Xe-1}:function(Ve,Xe){return Ve+Xe},ve=0;ve<ce.length;ve+=de)for(var Re=0;Re<de;Re++){var Oe=ye(ve,Re);if(Re===0)_e[Oe]=A?0:ce[Oe];else{var Fe=ye(ve,Re-1);_e[Oe]=A?ce[Fe]+_e[Fe]:ce[Oe]+_e[Fe]}}return ee},ue.prototype.equal=function(E,F){return Q([E,F],"equal"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A===V?1:0})},ue.prototype.notEqual=function(E,F){return Q([E,F],"notEqual"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A!==V?1:0})},ue.prototype.less=function(E,F){return Q([E,F],"less"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A<V?1:0})},ue.prototype.lessEqual=function(E,F){return Q([E,F],"lessEqual"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A<=V?1:0})},ue.prototype.greater=function(E,F){return Q([E,F],"greater"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A>V?1:0})},ue.prototype.greaterEqual=function(E,F){return Q([E,F],"greaterEqual"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A>=V?1:0})},ue.prototype.logicalAnd=function(E,F){return Q([E,F],"logicalAnd"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A&&V})},ue.prototype.logicalOr=function(E,F){return Q([E,F],"logicalOr"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A||V})},ue.prototype.select=function(E,F,A){Q([E,F,A],"select");for(var V=this.readSync(E.dataId),oe=this.readSync(F.dataId),ee=this.readSync(A.dataId),_e=i.zeros(F.shape,i.upcastType(F.dtype,A.dtype)),ce=this.readSync(_e.dataId),de=0,ye=E.rank===0||E.rank>1||F.rank===1?1:i.util.sizeFromShape(F.shape.slice(1)),ve=0;ve<V.length;ve++)for(var Re=0;Re<ye;Re++)V[ve]===1?ce[de++]=oe[ve]:ce[de++]=ee[ve];return _e},ue.prototype.where=function(E){Q([E],"where");var F=this.readSync(E.dataId);return ae(E.shape,F)},ue.prototype.topk=function(E,F,A){Q(E,"topk");var V=this.readSync(E.dataId);return me(V,E.shape,E.dtype,F,A)},ue.prototype.min=function(E,F){Q(E,"min"),i.backend_util.assertAxesAreInnerMostDims("min",F,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,F),V=A[0],oe=A[1],ee=i.zeros(V,E.dtype),_e=i.util.sizeFromShape(oe),ce=this.readSync(ee.dataId),de=this.readSync(E.dataId),ye=0;ye<ce.length;++ye){for(var ve=ye*_e,Re=de[ve],Oe=0;Oe<_e;++Oe){var Fe=de[ve+Oe];Fe<Re&&(Re=Fe)}ce[ye]=Re}return ee},ue.prototype.minimum=function(E,F){return Q([E,F],"minimum"),this.broadcastedBinaryOp(E,F,E.dtype,function(A,V){return Math.min(A,V)})},ue.prototype.mod=function(E,F){return Q([E,F],"mod"),this.broadcastedBinaryOp(E,F,E.dtype,function(A,V){var oe=A%V;return A<0&&V<0||A>=0&&V>=0?oe:(oe+V)%V})},ue.prototype.maximum=function(E,F){return Q([E,F],"maximum"),this.broadcastedBinaryOp(E,F,E.dtype,function(A,V){return Math.max(A,V)})},ue.prototype.all=function(E,F){Q(E,"all"),i.backend_util.assertAxesAreInnerMostDims("all",F,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,F),V=A[0],oe=A[1],ee=i.zeros(V,E.dtype),_e=i.util.sizeFromShape(oe),ce=this.readSync(ee.dataId),de=this.readSync(E.dataId),ye=0;ye<ce.length;++ye){for(var ve=ye*_e,Re=de[ve],Oe=0;Oe<_e;++Oe){var Fe=de[ve+Oe];Re=Re&&Fe}ce[ye]=Re}return ee},ue.prototype.any=function(E,F){Q(E,"any"),i.backend_util.assertAxesAreInnerMostDims("any",F,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,F),V=A[0],oe=A[1],ee=i.zeros(V,E.dtype),_e=i.util.sizeFromShape(oe),ce=this.readSync(ee.dataId),de=this.readSync(E.dataId),ye=0;ye<ce.length;++ye){for(var ve=ye*_e,Re=de[ve],Oe=0;Oe<_e;++Oe){var Fe=de[ve+Oe];Re=Re||Fe}ce[ye]=Re}return ee},ue.prototype.squaredDifference=function(E,F){return Q([E,F],"squaredDifference"),this.broadcastedBinaryOp(E,F,E.dtype,function(A,V){var oe=A-V;return oe*oe})},ue.prototype.eluDer=function(E,F){Q([E,F],"eluDer");for(var A=new Float32Array(F.size),V=this.readSync(F.dataId),oe=this.readSync(E.dataId),ee=0;ee<V.length;++ee){var _e=V[ee];_e>=1?A[ee]=oe[ee]:A[ee]=oe[ee]*(_e+1)}return this.makeOutput(A,F.shape,"float32")},ue.prototype.atan2=function(E,F){return Q([E,F],"atan2"),this.broadcastedBinaryOp(E,F,E.dtype,function(A,V){return Math.atan2(A,V)})},ue.prototype.tile=function(E,F){return Q(E,"tile"),he(this.bufferSync(E),F)},ue.prototype.gather=function(E,F,A){Q([E,F],"gather");var V=E.shape.slice(),oe=this.readSync(F.dataId);V[A]=oe.length;for(var ee=i.buffer(V,E.dtype),_e=this.bufferSync(E),ce=0;ce<ee.size;++ce){var de=ee.indexToLoc(ce),ye=de.slice();ye[A]=oe[de[A]];var ve=_e.locToIndex(ye);ee.values[ce]=_e.values[ve]}return ee.toTensor()},ue.prototype.batchToSpaceND=function(E,F,A){Q([E],"batchToSpaceND");var V=F.reduce(function(ye,ve){return ye*ve}),oe=i.backend_util.getReshaped(E.shape,F,V),ee=i.backend_util.getPermuted(oe.length,F.length),_e=i.backend_util.getReshapedPermuted(E.shape,F,V),ce=i.backend_util.getSliceBeginCoords(A,F.length),de=i.backend_util.getSliceSize(_e,A,F.length);return i.transpose(E.reshape(oe),ee).reshape(_e).slice(ce,de)},ue.prototype.pool3d=function(E,F,A){Q(E,"pool3d");for(var V=F.strideDepth,oe=F.strideHeight,ee=F.strideWidth,_e=F.dilationDepth,ce=F.dilationHeight,de=F.dilationWidth,ye=F.effectiveFilterDepth,ve=F.effectiveFilterHeight,Re=F.effectiveFilterWidth,Oe=F.padInfo.front,Fe=F.padInfo.top,Ve=F.padInfo.left,Xe=A==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,rt=this.readSync(E.dataId),at=i.buffer(F.outShape,E.dtype),$=at.values,et=F.outShape[1]*F.outShape[2]*F.outShape[3]*F.outShape[4],gt=F.outShape[2]*F.outShape[3]*F.outShape[4],lt=F.outShape[3]*F.outShape[4],_t=F.outShape[4],At=0;At<F.batchSize;++At)for(var Lt=At*et,Pt=At*E.strides[0],Ut=0;Ut<F.inChannels;++Ut)for(var Nt=0;Nt<F.outDepth;++Nt){for(var Kt=Nt*V-Oe,Ht=Kt;Ht<0;)Ht+=_e;for(var Ot=Math.min(F.inDepth,ye+Kt),Rt=Lt+Nt*gt,wt=0;wt<F.outHeight;++wt){for(var Et=wt*oe-Fe,Vt=Et;Vt<0;)Vt+=ce;for(var jt=Math.min(F.inHeight,ve+Et),cr=Rt+wt*lt,rr=0;rr<F.outWidth;++rr){for(var Ie=rr*ee-Ve,br=Ie;br<0;)br+=de;for(var Nr=Math.min(F.inWidth,Re+Ie),Tr=cr+rr*_t,hr=Xe,Dr=0,fr=0,Er=Ht;Er<Ot;Er+=_e){for(var an=Pt+Er*E.strides[1],wn=Vt;wn<jt;wn+=ce){for(var ie=an+wn*E.strides[2],Nn=br;Nn<Nr;Nn+=de){var bn=ie+Nn*E.strides[3],Ee=rt[bn+Ut];if(A==="max"&&Ee>hr?hr=Ee:A==="avg"&&(Dr+=Ee,fr++),isNaN(hr))break}if(isNaN(hr))break}if(isNaN(hr))break}var Bn=Tr+Ut;$[Bn]=A==="avg"?Dr/fr:hr}}}return at.toTensor()},ue.prototype.avgPool3d=function(E,F){return Q(E,"avgPool3d"),this.pool3d(E,F,"avg").toFloat()},ue.prototype.avgPool3dBackprop=function(E,F,A){Q([E,F],"avgPool3dBackprop");for(var V=A.strideDepth,oe=A.strideHeight,ee=A.strideWidth,_e=A.filterDepth,ce=A.filterHeight,de=A.filterWidth,ye=A.dilationDepth,ve=A.dilationHeight,Re=A.dilationWidth,Oe=A.effectiveFilterDepth,Fe=A.effectiveFilterHeight,Ve=A.effectiveFilterWidth,Xe=Oe-1-A.padInfo.front,rt=Ve-1-A.padInfo.left,at=Fe-1-A.padInfo.top,$=i.buffer(F.shape,"float32"),et=1/(_e*ce*de),gt=this.bufferSync(E),lt=0;lt<A.batchSize;++lt)for(var _t=0;_t<A.inChannels;++_t)for(var At=0;At<A.inDepth;++At)for(var Lt=0;Lt<A.inHeight;++Lt)for(var Pt=0;Pt<A.inWidth;++Pt){for(var Ut=At-Xe,Nt=Lt-at,Kt=Pt-rt,Ht=0,Ot=0;Ot<Oe;Ot+=ye){var Rt=(Ut+Ot)/V;if(Rt<0||Rt>=A.outDepth||Math.floor(Rt)!==Rt)continue;for(var wt=0;wt<Fe;wt+=ve){var Et=(Nt+wt)/oe;if(Et<0||Et>=A.outHeight||Math.floor(Et)!==Et)continue;for(var Vt=0;Vt<Ve;Vt+=Re){var jt=(Kt+Vt)/ee;if(jt<0||jt>=A.outWidth||Math.floor(jt)!==jt)continue;var cr=gt.get(lt,Rt,Et,jt,_t);Ht+=cr}}}$.set(Ht*et,lt,At,Lt,Pt,_t)}return $.toTensor()},ue.prototype.maxPool3d=function(E,F){return Q(E,"maxPool3d"),this.pool3d(E,F,"max").toFloat()},ue.prototype.maxPool3dPositions=function(E,F){for(var A=i.buffer(F.outShape,"int32"),V=F.strideDepth,oe=F.strideHeight,ee=F.strideWidth,_e=F.dilationDepth,ce=F.dilationHeight,de=F.dilationWidth,ye=F.effectiveFilterDepth,ve=F.effectiveFilterHeight,Re=F.effectiveFilterWidth,Oe=F.padInfo.front,Fe=F.padInfo.top,Ve=F.padInfo.left,Xe=this.bufferSync(E),rt=0;rt<F.batchSize;++rt)for(var at=0;at<F.inChannels;++at)for(var $=0;$<F.outDepth;++$){for(var et=$*V-Oe,gt=et;gt<0;)gt+=_e;for(var lt=Math.min(F.inDepth,ye+et),_t=0;_t<F.outHeight;++_t){for(var At=_t*oe-Fe,Lt=At;Lt<0;)Lt+=ce;for(var Pt=Math.min(F.inHeight,ve+At),Ut=0;Ut<F.outWidth;++Ut){for(var Nt=Ut*ee-Ve,Kt=Nt;Kt<0;)Kt+=de;for(var Ht=Math.min(F.inWidth,Re+Nt),Ot=Number.NEGATIVE_INFINITY,Rt=-1,wt=gt;wt<lt;wt+=_e)for(var Et=wt-et,Vt=Lt;Vt<Pt;Vt+=ce)for(var jt=Vt-At,cr=Kt;cr<Ht;cr+=de){var rr=cr-Nt,Ie=Xe.get(rt,wt,Vt,cr,at);Ie>=Ot&&(Ot=Ie,Rt=Et*ve*Re+jt*ve+rr)}A.set(Rt,rt,$,_t,Ut,at)}}}return A.toTensor()},ue.prototype.maxPool3dBackprop=function(E,F,A,V){Q([F,A],"maxPool3dBackprop");for(var oe=this.maxPool3dPositions(F,V),ee=V.strideDepth,_e=V.strideHeight,ce=V.strideWidth,de=V.dilationDepth,ye=V.dilationHeight,ve=V.dilationWidth,Re=V.effectiveFilterDepth,Oe=V.effectiveFilterHeight,Fe=V.effectiveFilterWidth,Ve=Re-1-V.padInfo.front,Xe=Fe-1-V.padInfo.left,rt=Oe-1-V.padInfo.top,at=i.buffer(F.shape,"float32"),$=this.bufferSync(oe),et=this.bufferSync(E),gt=0;gt<V.batchSize;++gt)for(var lt=0;lt<V.inChannels;++lt)for(var _t=0;_t<V.inDepth;++_t)for(var At=0;At<V.inHeight;++At)for(var Lt=0;Lt<V.inWidth;++Lt){for(var Pt=_t-Ve,Ut=At-rt,Nt=Lt-Xe,Kt=0,Ht=0;Ht<Re;Ht+=de){var Ot=(Pt+Ht)/ee;if(Ot<0||Ot>=V.outDepth||Math.floor(Ot)!==Ot)continue;for(var Rt=0;Rt<Oe;Rt+=ye){var wt=(Ut+Rt)/_e;if(wt<0||wt>=V.outHeight||Math.floor(wt)!==wt)continue;for(var Et=0;Et<Fe;Et+=ve){var Vt=(Nt+Et)/ce;if(Vt<0||Vt>=V.outWidth||Math.floor(Vt)!==Vt)continue;var jt=Re*Oe*Fe-1-$.get(gt,Ot,wt,Vt,lt),cr=Ht*Oe*Fe+Rt*Fe+Et,rr=jt===cr?1:0;if(rr===0)continue;var Ie=et.get(gt,Ot,wt,Vt,lt);Kt+=Ie*rr}}}at.set(Kt,gt,_t,At,Lt,lt)}return at.toTensor()},ue.prototype.resizeBilinear=function(E,F,A,V){Q(E,"resizeBilinear");for(var oe=E.shape,ee=oe[0],_e=oe[1],ce=oe[2],de=oe[3],ye=this.readSync(E.dataId),ve=new Float32Array(i.util.sizeFromShape([ee,F,A,de])),Re=[V&&F>1?_e-1:_e,V&&A>1?ce-1:ce],Oe=[V&&F>1?F-1:F,V&&A>1?A-1:A],Fe=0,Ve=Re[0]/Oe[0],Xe=Re[1]/Oe[1],rt=0;rt<ee;rt++)for(var at=0;at<F;at++)for(var $=Ve*at,et=Math.floor($),gt=$-et,lt=Math.min(_e-1,Math.ceil($)),_t=rt*E.strides[0]+et*E.strides[1],At=rt*E.strides[0]+lt*E.strides[1],Lt=0;Lt<A;Lt++)for(var Pt=Xe*Lt,Ut=Math.floor(Pt),Nt=Pt-Ut,Kt=Math.min(ce-1,Math.ceil(Pt)),Ht=_t+Ut*E.strides[2],Ot=At+Ut*E.strides[2],Rt=_t+Kt*E.strides[2],wt=At+Kt*E.strides[2],Et=0;Et<de;Et++){var Vt=ye[Ht+Et],jt=ye[Ot+Et],cr=ye[Rt+Et],rr=ye[wt+Et],Ie=Vt+(cr-Vt)*Nt,br=jt+(rr-jt)*Nt,Nr=Ie+(br-Ie)*gt;ve[Fe++]=Nr}return i.tensor(ve,[ee,F,A,de])},ue.prototype.resizeBilinearBackprop=function(E,F,A){Q([E,F],"resizeBilinearBackprop");for(var V=F.shape,oe=V[0],ee=V[1],_e=V[2],ce=V[3],de=E.shape,ye=de[1],ve=de[2],Re=new Float32Array(oe*ee*_e*ce),Oe=[A&&ye>1?ee-1:ee,A&&ve>1?_e-1:_e],Fe=[A&&ye>1?ye-1:ye,A&&ve>1?ve-1:ve],Ve=Oe[0]/Fe[0],Xe=Oe[1]/Fe[1],rt=this.readSync(E.dataId),at=0,$=0;$<oe;$++)for(var et=$*F.strides[0],gt=0;gt<ye;gt++)for(var lt=gt*Ve,_t=Math.floor(lt),At=Math.min(Math.ceil(lt),ee-1),Lt=et+_t*F.strides[1],Pt=et+At*F.strides[1],Ut=lt-_t,Nt=1-Ut,Kt=0;Kt<ve;Kt++)for(var Ht=Kt*Xe,Ot=Math.floor(Ht),Rt=Math.min(Math.ceil(Ht),_e-1),wt=Ht-Ot,Et=1-wt,Vt=Lt+Ot*F.strides[2],jt=Lt+Rt*F.strides[2],cr=Pt+Ot*F.strides[2],rr=Pt+Rt*F.strides[2],Ie=Nt*Et,br=Nt*wt,Nr=Ut*Et,Tr=Ut*wt,hr=0;hr<ce;hr++){var Dr=rt[at++];Re[Vt+hr]+=Dr*Ie,Re[jt+hr]+=Dr*br,Re[cr+hr]+=Dr*Nr,Re[rr+hr]+=Dr*Tr}return i.tensor4d(Re,[oe,_e,ee,ce],F.dtype)},ue.prototype.resizeNearestNeighbor=function(E,F,A,V){Q(E,"resizeNearestNeighbor");for(var oe=E.shape,ee=oe[0],_e=oe[1],ce=oe[2],de=oe[3],ye=this.readSync(E.dataId),ve=new Float32Array(ee*F*A*de),Re=[V&&F>1?_e-1:_e,V&&A>1?ce-1:ce],Oe=[V&&F>1?F-1:F,V&&A>1?A-1:A],Fe=Re[0]/Oe[0],Ve=Re[1]/Oe[1],Xe=0,rt=0;rt<ee;rt++)for(var at=rt*E.strides[0],$=0;$<F;$++)for(var et=Fe*$,gt=Math.min(_e-1,V?Math.round(et):Math.floor(et)),lt=at+gt*E.strides[1],_t=0;_t<A;_t++)for(var At=Ve*_t,Lt=Math.min(ce-1,V?Math.round(At):Math.floor(At)),Pt=lt+Lt*E.strides[2],Ut=0;Ut<de;Ut++){var Nt=ye[Pt+Ut];ve[Xe++]=Nt}return i.tensor(ve,[ee,F,A,de],E.dtype)},ue.prototype.resizeNearestNeighborBackprop=function(E,F,A){Q([E,F],"resizeNearestNeighborBackprop");for(var V=F.shape,oe=V[0],ee=V[1],_e=V[2],ce=V[3],de=E.shape,ye=de[1],ve=de[2],Re=new Float32Array(oe*ee*_e*ce),Oe=this.readSync(E.dataId),Fe=[A&&ye>1?ee-1:ee,A&&ve>1?_e-1:_e],Ve=[A&&ye>1?ye-1:ye,A&&ve>1?ve-1:ve],Xe=Fe[0]/Ve[0],rt=Fe[1]/Ve[1],at=1/Xe,$=1/rt,et=Math.ceil(at)*2+2,gt=Math.ceil($)*2+2,lt=0;lt<oe;lt++)for(var _t=lt*F.strides[0],At=0;At<ee;At++)for(var Lt=_t+At*F.strides[1],Pt=Math.floor(At*at),Ut=Math.floor(Pt-et/2),Nt=0;Nt<_e;Nt++)for(var Kt=Lt+Nt*F.strides[2],Ht=Math.floor(Nt*$),Ot=Math.floor(Ht-gt/2),Rt=0;Rt<ce;Rt++){for(var wt=0,Et=0;Et<et;Et++){var Vt=Et+Ut;if(Vt<0||Vt>=ye)continue;var jt=_t+Vt*E.strides[1],cr=Vt*Xe,rr=Math.min(ee-1,A?Math.round(cr):Math.floor(cr));if(At!==rr)continue;for(var Ie=0;Ie<gt;Ie++){var br=Ie+Ot;if(br<0||br>=ve)continue;var Nr=jt+br*E.strides[2],Tr=br*rt,hr=Math.min(_e-1,A?Math.round(Tr):Math.floor(Tr));Nt===hr&&(wt+=Oe[Nr+Rt])}}Re[Kt+Rt]=wt}return i.tensor4d(Re,F.shape,F.dtype)},ue.prototype.localResponseNormalization4D=function(E,F,A,V,oe){Q(E,"localResponseNormalization4D");var ee=E.shape[3],_e=ee-1,ce=this.readSync(E.dataId),de=E.size,ye=new Float32Array(de);function ve(Ve){for(var Xe=Ve%ee,rt=Ve-Xe+Math.max(0,Xe-F),at=Ve-Xe+Math.min(Xe+F,_e),$=0;rt<=at;rt++){var et=ce[rt];$+=et*et}return $}for(var Re=0;Re<de;Re++){var Oe=ve(Re),Fe=ce[Re]*Math.pow(A+V*Oe,-oe);ye[Re]=Fe}return i.tensor4d(ye,E.shape)},ue.prototype.LRNGrad=function(E,F,A,V,oe,ee,_e){Q(E,"LRNGrad");for(var ce=E.shape[3],de=this.readSync(E.dataId),ye=this.readSync(F.dataId),ve=this.readSync(A.dataId),Re=new Float32Array(E.size),Oe=E.size,Fe=0;Fe<Oe;Fe++){for(var Ve=Fe%ce,Xe=Fe-Ve+Math.max(0,Ve-V),rt=Fe-Ve+Math.min(ce,Ve+V+1),at=0,$=Xe;$<rt;$++)at+=Math.pow(ye[$],2);at=ee*at+oe;for(var $=Xe;$<rt;$++){var et=-2*ee*_e*ye[$]*ve[Fe]/at;Fe===$&&(et+=Math.pow(at,-_e)),et*=de[Fe],Re[$]+=et}}return i.tensor4d(Re,E.shape)},ue.prototype.multinomial=function(E,F,A,V){Q(E,"multinomial");for(var oe=F?E:i.softmax(E),ee=oe.shape[0],_e=oe.shape[1],ce=i.zeros([ee,A],"int32"),de=this.readSync(ce.dataId),ye=this.readSync(oe.dataId),ve=0;ve<ee;++ve){var Re=ve*_e,Oe=new Float32Array(_e-1);Oe[0]=ye[Re];for(var Fe=1;Fe<Oe.length;++Fe)Oe[Fe]=Oe[Fe-1]+ye[Re+Fe];for(var Ve=ke.alea(V.toString()),Xe=ve*A,rt=0;rt<A;++rt){var at=Ve();de[Xe+rt]=Oe.length;for(var $=0;$<Oe.length;$++)if(at<Oe[$]){de[Xe+rt]=$;break}}}return ce},ue.prototype.oneHot=function(E,F,A,V){Q(E,"oneHot");var oe=new Float32Array(E.size*F);oe.fill(V);for(var ee=this.readSync(E.dataId),_e=0;_e<E.size;++_e)ee[_e]>=0&&ee[_e]<F&&(oe[_e*F+ee[_e]]=A);return i.tensor2d(oe,[E.size,F],"int32")},ue.prototype.nonMaxSuppression=function(E,F,A,V,oe){Q(E,"nonMaxSuppression");var ee=this.readSync(E.dataId),_e=this.readSync(F.dataId);return Ae(ee,_e,A,V,oe)},ue.prototype.depthToSpace=function(E,F,A){i.util.assert(A==="NHWC",function(){return"Only NHWC dataFormat supported on CPU for depthToSpace. Got "+A}),i.util.assert(F>1,function(){return"blockSize should be > 1 for depthToSpace, but was: "+F});for(var V=E.shape[0],oe=E.shape[1],ee=E.shape[2],_e=E.shape[3],ce=oe*F,de=ee*F,ye=_e/(F*F),ve=this.readSync(E.dataId),Re=new Float32Array(V*ce*de*ye),Oe=0,Fe=0;Fe<V;++Fe)for(var Ve=0;Ve<ce;++Ve)for(var Xe=Math.floor(Ve/F),rt=Ve%F,at=0;at<de;++at)for(var $=Math.floor(at/F),et=at%F,gt=(rt*F+et)*ye,lt=0;lt<ye;++lt){var _t=lt+gt,At=_t+_e*($+ee*(Xe+oe*Fe));Re[Oe++]=ve[At]}return i.tensor4d(Re,[V,ce,de,ye])},ue.prototype.broadcastedBinaryOp=function(E,F,A,V){var oe=i.backend_util.assertAndGetBroadcastShape(E.shape,F.shape),ee=i.buffer(oe,A),_e=this.readSync(E.dataId),ce=this.readSync(F.dataId),de=i.backend_util.getBroadcastDims(E.shape,oe),ye=i.backend_util.getBroadcastDims(F.shape,oe),ve=ee.values;if(de.length+ye.length===0)for(var Re=0;Re<ve.length;++Re)ve[Re]=V(_e[Re%_e.length],ce[Re%ce.length]);else for(var Oe=this.bufferSync(E),Fe=this.bufferSync(F),Ve=function(rt){var at=ee.indexToLoc(rt),$=at.slice(-E.rank);de.forEach(function(_t){return $[_t]=0});var et=Oe.locToIndex($),gt=at.slice(-F.rank);ye.forEach(function(_t){return gt[_t]=0});var lt=Fe.locToIndex(gt);ve[rt]=V(_e[et],ce[lt])},Re=0;Re<ve.length;++Re)Ve(Re);return ee.toTensor()},ue.prototype.split=function(E,F,A){return P(E,F,A)},ue.prototype.dispose=function(){},ue.prototype.floatPrecision=function(){return 32},ue.prototype.epsilon=function(){return ne.prototype.epsilon.call(this)},ue.prototype.cropAndResize=function(E,F,A,V,oe,ee){for(var _e=E.shape,ce=_e[0],de=_e[1],ye=_e[2],ve=_e[3],Re=F.shape[0],Oe=V[0],Fe=V[1],Ve=i.buffer([Re,Oe,Fe,ve],"float32"),Xe=this.readSync(F.dataId),rt=this.readSync(A.dataId),at=this.readSync(E.dataId),$=E.strides,et=Ve.strides,gt=0;gt<Re;gt++){var lt=gt*4,_t=Xe[lt],At=Xe[lt+1],Lt=Xe[lt+2],Pt=Xe[lt+3],Ut=rt[gt];if(Ut>=ce)continue;for(var Nt=Oe>1?(Lt-_t)*(de-1)/(Oe-1):0,Kt=Fe>1?(Pt-At)*(ye-1)/(Fe-1):0,Ht=0;Ht<Oe;Ht++){var Ot=Oe>1?_t*(de-1)+Ht*Nt:.5*(_t+Lt)*(de-1);if(Ot<0||Ot>de-1){for(var Rt=0;Rt<Fe;Rt++)for(var wt=0;wt<ve;wt++){var Et=wt+Rt*et[2]+Ht*et[1]+gt*et[0];Ve.values[Et]=ee}continue}if(oe==="bilinear")for(var Vt=Math.floor(Ot),jt=Math.ceil(Ot),cr=Ot-Vt,Rt=0;Rt<Fe;Rt++){var rr=Fe>1?At*(ye-1)+Rt*Kt:.5*(At+Pt)*(ye-1);if(rr<0||rr>ye-1){for(var wt=0;wt<ve;wt++){var Et=wt+Rt*et[2]+Ht*et[1]+gt*et[0];Ve.values[Et]=ee}continue}for(var Ie=Math.floor(rr),br=Math.ceil(rr),Nr=rr-Ie,wt=0;wt<ve;wt++){var Et=wt+Ie*$[2]+Vt*$[1]+Ut*$[0],Tr=at[Et];Et=wt+br*$[2]+Vt*$[1]+Ut*$[0];var hr=at[Et];Et=wt+Ie*$[2]+jt*$[1]+Ut*$[0];var Dr=at[Et];Et=wt+br*$[2]+jt*$[1]+Ut*$[0];var fr=at[Et],Er=Tr+(hr-Tr)*Nr,an=Dr+(fr-Dr)*Nr;Et=wt+Rt*et[2]+Ht*et[1]+gt*et[0],Ve.values[Et]=Er+(an-Er)*cr}}else for(var Rt=0;Rt<Fe;++Rt){var rr=Fe>1?At*(ye-1)+Rt*Kt:.5*(At+Pt)*(ye-1);if(rr<0||rr>ye-1){for(var wt=0;wt<ve;wt++){var Et=wt+Rt*et[2]+Ht*et[1]+gt*et[0];Ve.values[Et]=ee}continue}for(var wn=Math.round(rr),ie=Math.round(Ot),wt=0;wt<ve;wt++){var Nn=wt+wn*$[2]+ie*$[1]+Ut*$[0],bn=wt+Rt*et[2]+Ht*et[1]+gt*et[0];Ve.values[bn]=at[Nn]}}}}return Ve.toTensor()},ue.prototype.sparseToDense=function(E,F,A,V){var oe=i.backend_util.calculateShapes(F,E,A),ee=oe.sliceRank,_e=oe.numUpdates,ce=oe.sliceSize,de=oe.strides,ye=oe.outputSize,ve=!1;return this.scatter(E,F,A,ye,ce,_e,ee,de,V,ve)},ue.prototype.gatherND=function(E,F){var A=F.shape,V=A[A.length-1],oe=i.backend_util.prepareAndValidate(E,F),ee=oe[0],_e=oe[1],ce=oe[2],de=oe[3];if(_e===0)return i.tensor([],ee,E.dtype);for(var ye=new i.TensorBuffer([_e,ce],E.dtype),ve=this.readSync(F.dataId),Re=this.readSync(E.dataId),Oe=0;Oe<_e;Oe++){for(var Fe=[],Ve=0,Xe=0;Xe<V;Xe++){var rt=ve[Oe*V+Xe];Ve+=rt*de[Xe],Fe.push(rt)}if(Ve<0||Ve>=E.size/ce)throw new Error("Invalid indices: "+Fe+" does not index into "+E.shape);for(var at=0;at<ce;at++)ye.values[Oe*ce+at]=Re[Ve*ce+at]}return ye.toTensor().reshape(ee)},ue.prototype.scatterND=function(E,F,A){var V=i.backend_util.calculateShapes(F,E,A),oe=V.sliceRank,ee=V.numUpdates,_e=V.sliceSize,ce=V.strides,de=V.outputSize,ye=i.scalar(0),ve=!0;return this.scatter(E,F,A,de,_e,ee,oe,ce,ye,ve)},ue.prototype.onesLike=function(E){if(E.dtype==="string")throw new Error("onesLike is not supported for string tensors");return i.fill(E.shape,1,E.dtype)},ue.prototype.zerosLike=function(E){var F=i.util.getArrayFromDType(E.dtype,i.util.sizeFromShape(E.shape));return this.makeOutput(F,E.shape,E.dtype)},ue.prototype.linspace=function(E,F,A){return i.backend_util.linspaceImpl(E,F,A)},ue.prototype.scatter=function(E,F,A,V,oe,ee,_e,ce,de,ye){var ve=[V/oe,oe],Re=this.readSync(E.dataId),Oe=this.readSync(F.dataId);if(V===0)return i.tensor([],A,F.dtype);var Fe=new i.TensorBuffer(ve,F.dtype);Fe.values.fill(this.readSync(de.dataId)[0]);for(var Ve=0;Ve<ee;Ve++){for(var Xe=[],rt=0,at=0;at<_e;at++){var $=Re[Ve*_e+at];Xe.push($),rt+=$*ce[at]}if(rt<0||rt>=V/oe)throw new Error("Invalid indices: "+Xe+" does not index into "+A);for(var et=0;et<oe;et++)ye?Fe.values[rt*oe+et]+=Oe[Ve*oe+et]:Fe.values[rt*oe+et]=F.rank===0?Oe[0]:Oe[Ve*oe+et]}return Fe.toTensor().reshape(A)},ue}(i.KernelBackend);function ge(ne){for(var ue=new Float32Array(ne.length),E=0;E<ne.length;++E)ue[E]=Math.abs(ne[E]);return ue}var ze=function(ne){var ue=ne.inputs.x,E=ne.backend,F=new Float32Array(i.util.sizeFromShape(ue.shape));if(ue.dtype!=="complex64"){var A=E.data.get(ue.dataId).values;F=ge(A)}else for(var V=E.data.get(ue.dataId),oe=V.complexTensorInfos.real,ee=V.complexTensorInfos.imag,_e=E.data.get(oe.dataId).values,ce=E.data.get(ee.dataId).values,de=0;de<_e.length;de++){var ye=_e[de],ve=ce[de];F[de]=Math.hypot(ye,ve)}return E.makeOutput(F,ue.shape,"float32")},W={kernelName:i.Abs,backendName:"cpu",kernelFunc:ze};function nt(ne){return function(ue,E,F,A,V){var oe=i.backend_util.assertAndGetBroadcastShape(ue,E),ee=oe.length,_e=i.util.computeStrides(oe),ce=i.util.sizeFromShape(oe),de=i.util.getTypedArrayFromDType(V,ce),ye=ue.length,ve=E.length,Re=i.util.computeStrides(ue),Oe=i.util.computeStrides(E),Fe=i.backend_util.getBroadcastDims(ue,oe),Ve=i.backend_util.getBroadcastDims(E,oe);if(Fe.length+Ve.length===0)for(var Xe=0;Xe<de.length;++Xe)de[Xe]=ne(F[Xe%F.length],A[Xe%A.length]);else for(var rt=function($){var et=i.util.indexToLoc($,ee,_e),gt=et.slice(-ye);Fe.forEach(function(Lt){return gt[Lt]=0});var lt=i.util.locToIndex(gt,ye,Re),_t=et.slice(-ve);Ve.forEach(function(Lt){return _t[Lt]=0});var At=i.util.locToIndex(_t,ve,Oe);de[$]=ne(F[lt],A[At])},Xe=0;Xe<de.length;++Xe)rt(Xe);return[de,oe]}}function tt(ne){var ue=ne.inputs,E=ne.backend,F=ue.real,A=ue.imag,V=E.data.get(F.dataId).values,oe=E.data.get(A.dataId).values,ee=E.makeTensorInfo(F.shape,"complex64"),_e=E.data.get(ee.dataId);return _e.complexTensorInfos={real:E.makeTensorInfo(F.shape,"float32",V),imag:E.makeTensorInfo(A.shape,"float32",oe)},ee}var nr={kernelName:i.Complex,backendName:"cpu",kernelFunc:tt};function Tt(ne){var ue=ne.inputs,E=ne.backend,F=ue.x;return E.incRef(F.dataId),{dataId:F.dataId,shape:F.shape,dtype:F.dtype}}var Qe={kernelName:i.Identity,backendName:"cpu",kernelFunc:Tt};function it(ne){var ue=ne.inputs,E=ne.backend,F=ue.input,A=E.data.get(F.dataId).complexTensorInfos.real,V=E.data.get(A.dataId).values;return E.makeTensorInfo(A.shape,A.dtype,V)}var xt={kernelName:i.Real,backendName:"cpu",kernelFunc:it};function ot(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.dtype;if(V==="complex64"){if(A.dtype==="complex64")return Tt({inputs:{x:A},backend:E});var oe=i.zeros(A.shape),ee=ot({inputs:{x:A},backend:E,attrs:{dtype:"float32"}}),_e=tt({inputs:{real:ee,imag:oe},backend:E});return oe.dispose(),E.disposeIntermediateTensorInfo(ee),_e}if(A.dtype==="complex64"){var ce=it({inputs:{input:A},backend:E}),_e=ot({inputs:{x:ce},backend:E,attrs:{dtype:V}});return E.disposeIntermediateTensorInfo(ce),_e}if(!i.util.hasEncodingLoss(A.dtype,V)){var _e=Tt({inputs:{x:A},backend:E});return{dataId:_e.dataId,shape:_e.shape,dtype:V}}if(V==="int32"){var de=E.data.get(A.dataId).values,ye=Int32Array.from(de);return E.makeTensorInfo(A.shape,"int32",ye)}if(V==="bool"){var ve=E.data.get(A.dataId).values,Re=i.util.toTypedArray([0],A.dtype),Oe=nt(function(Xe,rt){return Xe!==rt?1:0})(A.shape,[],ve,Re,"bool"),Fe=Oe[0],Ve=Oe[1];return E.makeTensorInfo(Ve,"bool",Fe)}throw new Error("Error in Cast: failed to cast "+A.dtype+" to "+V)}var ht={kernelName:i.Cast,backendName:"cpu",kernelFunc:ot};function ut(ne,ue,E,F){return E==null?function(A){var V=A.inputs,oe=A.backend,ee=V,_e=ee.a,ce=ee.b,de=oe;Q([_e,ce],ne);var ye=de.data.get(_e.dataId).values,ve=de.data.get(ce.dataId).values,Re=F||_e.dtype,Oe=ue(_e.shape,ce.shape,ye,ve,Re),Fe=Oe[0],Ve=Oe[1];return de.makeTensorInfo(Ve,Re,Fe)}:function(A){var V=A.inputs,oe=A.backend,ee=V,_e=ee.a,ce=ee.b,de=oe;if(_e.dtype==="complex64"||ce.dtype==="complex64"){var ye=ot({inputs:{x:_e},backend:de,attrs:{dtype:"complex64"}}),ve=de.data.get(ye.dataId),Re=ve.complexTensorInfos.real,Oe=ve.complexTensorInfos.imag,Fe=de.data.get(Re.dataId).values,Ve=de.data.get(Oe.dataId).values,Xe=ot({inputs:{x:ce},backend:de,attrs:{dtype:"complex64"}}),rt=de.data.get(Xe.dataId),at=rt.complexTensorInfos.real,$=rt.complexTensorInfos.imag,et=de.data.get(at.dataId).values,gt=de.data.get($.dataId).values,lt=E(_e.shape,ce.shape,Fe,Ve,et,gt),_t=lt[0],At=lt[1],Lt=lt[2],Pt=de.makeTensorInfo(Lt,"float32",_t),Ut=de.makeTensorInfo(Lt,"float32",At),Nt=tt({inputs:{real:Pt,imag:Ut},backend:de});return de.disposeIntermediateTensorInfo(ye),de.disposeIntermediateTensorInfo(Xe),de.disposeIntermediateTensorInfo(Pt),de.disposeIntermediateTensorInfo(Ut),Nt}else{var Kt=de.data.get(_e.dataId).values,Ht=de.data.get(ce.dataId).values,Ot=F||_e.dtype,Rt=ue(_e.shape,ce.shape,Kt,Ht,Ot),wt=Rt[0],Lt=Rt[1];return de.makeTensorInfo(Lt,Ot,wt)}}}function yt(ne){return function(ue,E,F,A,V,oe){var ee=i.backend_util.assertAndGetBroadcastShape(ue,E),_e=i.util.sizeFromShape(ee),ce=ee.length,de=i.util.computeStrides(ee),ye=i.util.getTypedArrayFromDType("float32",_e),ve=i.util.getTypedArrayFromDType("float32",_e),Re=i.backend_util.getBroadcastDims(ue,ee),Oe=i.backend_util.getBroadcastDims(E,ee),Fe=i.backend_util.mergeRealAndImagArrays(F,A),Ve=i.backend_util.mergeRealAndImagArrays(V,oe),Xe=ue.length,rt=i.util.computeStrides(ue),at=E.length,$=i.util.computeStrides(E);if(Re.length+Oe.length===0)for(var et=0;et<ye.length;et++){var gt=et%Fe.length,lt=et%Ve.length,_t=ne(Fe[gt*2],Fe[gt*2+1],Ve[lt*2],Ve[lt*2+1]);ye[et]=_t.real,ve[et]=_t.imag}else for(var At=function(Pt){var Ut=i.util.indexToLoc(Pt,ce,de),Nt=Ut.slice(-Xe);Re.forEach(function(wt){return Nt[wt]=0});var Kt=i.util.locToIndex(Nt,Xe,rt),Ht=Ut.slice(-at);Oe.forEach(function(wt){return Ht[wt]=0});var Ot=i.util.locToIndex(Ht,at,$),Rt=ne(Fe[Kt*2],Fe[Kt*2+1],Ve[Ot*2],Ve[Ot*2+1]);ye[Pt]=Rt.real,ve[Pt]=Rt.imag},et=0;et<ye.length;et++)At(et);return[ye,ve,ee]}}var Zt=nt(function(ne,ue){return ne+ue}),ar=yt(function(ne,ue,E,F){return{real:ne+E,imag:ue+F}}),qt=ut(i.Add,Zt,ar),Ur={kernelName:i.Add,backendName:"cpu",kernelFunc:qt};function jr(ne){return function(ue,E,F){for(var A=i.util.getTypedArrayFromDType(E,ue.length),V=0;V<ue.length;++V)A[V]=ne(ue[V],F);return A}}function _r(ne,ue,E){return function(F){var A=F.inputs,V=F.attrs,oe=F.backend,ee=A.x;if(Q(ee,ne),ee.dtype==="string"||E==="string")throw new Error("unaryKernelFunc does not support string input/output");for(var _e=oe,ce=_e.data.get(ee.dataId).values,de=i.util.sizeFromShape(ee.shape),ye=E||ee.dtype,ve=i.util.getArrayFromDType(ye,de),Re=0;Re<de;++Re)ve[Re]=ue(ce[Re],V);return _e.makeTensorInfo(ee.shape,ye,ve)}}function tr(ne,ue,E){return function(F){var A=F.inputs,V=F.attrs,oe=F.backend,ee=A.x;if(Q(ee,ne),ee.dtype==="string"||E==="string")throw new Error("unaryKernelFunc does not support string input/output");var _e=oe,ce=_e.data.get(ee.dataId).values,de=E||ee.dtype,ye=ue(ce,de,V);return _e.makeTensorInfo(ee.shape,de,ye)}}var Fa=jr(function(ne){return Math.ceil(ne)}),Oa=tr(i.Ceil,Fa),Tn={kernelName:i.Ceil,backendName:"cpu",kernelFunc:Oa},Wa=jr(function(ne){return Math.exp(ne)}),Na=tr(i.Exp,Wa),yn={kernelName:i.Exp,backendName:"cpu",kernelFunc:Na},Ma=jr(function(ne){return Math.expm1(ne)}),li=tr(i.Expm1,Ma),hi={kernelName:i.Expm1,backendName:"cpu",kernelFunc:li},la=jr(function(ne){return Math.floor(ne)}),rn=tr(i.Floor,la),Ca={kernelName:i.Floor,backendName:"cpu",kernelFunc:rn},xn=jr(function(ne){return Math.log(ne)}),Hn=tr(i.Log,xn),_i={kernelName:i.Log,backendName:"cpu",kernelFunc:Hn};function ha(ne,ue,E,F){for(var A=i.util.getTypedArrayFromDType(F,i.util.sizeFromShape(E)),V=0;V<A.length;++V){for(var oe=V*ue,ee=ne[oe],_e=0;_e<ue;++_e){var ce=ne[oe+_e];ce>ee&&(ee=ce)}A[V]=ee}return A}var Ei=nt(function(ne,ue){return ne*ue}),Gn=yt(function(ne,ue,E,F){return{real:ne*E-ue*F,imag:ne*F+ue*E}}),jn=ut(i.Multiply,Ei,Gn),Ua={kernelName:i.Multiply,backendName:"cpu",kernelFunc:jn},ga=nt(function(ne,ue){return ne!==ue?1:0}),wi=ut(i.NotEqual,ga,null,"bool"),Ta={kernelName:i.NotEqual,backendName:"cpu",kernelFunc:wi},on=jr(function(ne){return 1/Math.sqrt(ne)}),_n=tr(i.Rsqrt,on),xa={kernelName:i.Rsqrt,backendName:"cpu",kernelFunc:_n};function Rr(ne,ue,E,F,A){var V=i.slice_util.isSliceContinous(F,ue,E),oe=i.util.sizeFromShape(E),ee=i.util.computeStrides(F);if(V){var _e=i.slice_util.computeFlatOffset(ue,ee);return ne.subarray(_e,_e+oe)}for(var ce=i.util.getTypedArrayFromDType(A,oe),de=0;de<oe;++de){var ye=E.length,ve=i.util.computeStrides(E),Re=i.util.indexToLoc(de,ye,ve),Oe=Re.map(function(Ve,Xe){return Ve+ue[Xe]}),Fe=i.util.locToIndex(Oe,F.length,ee);ce[de]=ne[Fe]}return ce}function ti(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.begin,oe=F.size;Q(A,"slice");var ee=i.slice_util.parseSliceParams(A,V,oe),_e=ee[0],ce=ee[1];i.slice_util.assertParamsValid(A,_e,ce);var de=E.data.get(A.dataId).values,ye=Rr(de,_e,ce,A.shape,A.dtype);return E.makeTensorInfo(ce,A.dtype,ye)}var _a={kernelName:i.Slice,backendName:"cpu",kernelFunc:ti},Ri=nt(function(ne,ue){var E=ne-ue;return E*E}),Hi=ut(i.SquaredDifference,Ri),Ai={kernelName:i.SquaredDifference,backendName:"cpu",kernelFunc:Hi},qn=nt(function(ne,ue){return ne-ue}),ri=yt(function(ne,ue,E,F){return{real:ne-E,imag:ue-F}}),pi=ut(i.Sub,qn,ri),pa={kernelName:i.Sub,backendName:"cpu",kernelFunc:pi};function di(ne,ue,E,F,A){for(var V=ue.length,oe=i.util.sizeFromShape(ue),ee=i.util.computeStrides(ue),_e=i.util.computeStrides(A),ce=i.util.getTypedArrayFromDType(E,i.util.sizeFromShape(A)),de=0;de<oe;++de){for(var ye=i.util.indexToLoc(de,V,ee),ve=new Array(ye.length),Re=0;Re<ve.length;Re++)ve[Re]=ye[F[Re]];var Oe=i.util.locToIndex(ve,V,_e);ce[Oe]=ne[de]}return ce}function fi(ne,ue,E,F){for(var A=i.util.parseAxisParam(ue,E)[0],V=[1,E[0],1],oe=0;oe<A;oe++)V[0]*=E[oe];V[1]=E[A];for(var oe=A+1;oe<E.length;oe++)V[2]*=E[oe];for(var ee={},_e=new Int32Array(E[A]),ce=new i.TensorBuffer(V,F,ne),de=[],ye=V[0]===1&&V[2]===1,oe=0;oe<E[A];oe++){var ve=void 0;if(ye)ve=ne[oe].toString();else{for(var Re=[],Oe=0;Oe<V[0];Oe++)for(var Fe=0;Fe<V[2];Fe++)Re.push(ce.get(Oe,oe,Fe));ve=Re.join(",")}if(ee[ve]!==void 0)_e[oe]=ee[ve];else{var Ve=Object.keys(ee).length;ee[ve]=Ve,_e[oe]=Ve,de.push(oe)}}var Xe=V.slice();Xe[1]=Object.keys(ee).length;var rt=new i.TensorBuffer(Xe,F);de.forEach(function($,et){for(var gt=0;gt<V[0];gt++)for(var lt=0;lt<V[2];lt++)rt.set(ce.get(gt,$,lt),gt,et,lt)});var at=E.slice();return at[A]=Xe[1],{outputValues:rt.values,outputShape:at,indices:_e}}var Va={__proto__:null,simpleAbsImpl:ge,addImpl:Zt,ceilImpl:Fa,expImpl:Wa,expm1Impl:Ma,floorImpl:la,logImpl:xn,maxImpl:ha,multiplyImpl:Ei,notEqualImpl:ga,rsqrtImpl:on,sliceImpl:Rr,squaredDifferenceImpl:Ri,subImpl:qn,transposeImpl:di,uniqueImpl:fi},ln="2.7.0";i.registerBackend("cpu",function(){return new w},1);var ni=_r(i.Elu,function(ne){return ne>=0?ne:Math.exp(ne)-1}),gr={kernelName:i.Elu,backendName:"cpu",kernelFunc:ni},Di=nt(function(ne,ue){return ne<0?ue*ne:ne});function bi(ne){var ue=ne.inputs,E=ne.backend,F=ue.x,A=ue.alpha;Q([F,A],"prelu");var V=E.data.get(F.dataId).values,oe=E.data.get(A.dataId).values,ee=Di(F.shape,A.shape,V,oe,F.dtype),_e=ee[0],ce=ee[1];return E.makeTensorInfo(ce,F.dtype,_e)}var ro={kernelName:i.Prelu,backendName:"cpu",kernelFunc:bi},Zn=_r(i.Relu,function(ne){return Math.max(0,ne)}),Gi={kernelName:i.Relu,backendName:"cpu",kernelFunc:Zn},Fi=_r(i.Relu6,function(ne){return Math.min(Math.max(0,ne),6)}),ji={kernelName:i.Relu6,backendName:"cpu",kernelFunc:Fi};function Oi(ne,ue,E,F){if(E==="linear")return Tt({inputs:{x:ue},backend:ne});if(E==="relu")return Zn({inputs:{x:ue},backend:ne});if(E==="elu")return ni({inputs:{x:ue},backend:ne});if(E==="relu6")return Fi({inputs:{x:ue},backend:ne});if(E==="prelu")return bi({inputs:{x:ue,alpha:F},backend:ne});throw new Error("Activation "+E+" has not been implemented for the CPU backend.")}function da(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.shape,oe=i.util.sizeFromShape(A.shape),ee=i.util.inferFromImplicitShape(V,oe),_e=i.util.sizeFromShape(ee);i.util.assert(oe===_e,function(){return"The new shape ("+ee+") has "+_e+" elements and the old "+("shape ("+A.shape+") has "+oe+" elements. The new shape and old ")+"shape must have the same number of elements."}),E.incRef(A.dataId);var ce=E.data.get(A.dataId);if(ce.complexTensorInfos!=null){var de=ce.complexTensorInfos.real,ye=ce.complexTensorInfos.imag;de.shape=ee,ye.shape=ee}return{dataId:A.dataId,shape:ee,dtype:A.dtype}}var Mi={kernelName:i.Reshape,backendName:"cpu",kernelFunc:da};function pe(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.a,V=ue.b,oe=F.transposeA,ee=F.transposeB;Q([A,V],"matMul");var _e=A.shape.length,ce=V.shape.length,de=oe?A.shape[_e-2]:A.shape[_e-1],ye=ee?V.shape[ce-1]:V.shape[ce-2],ve=oe?A.shape[_e-1]:A.shape[_e-2],Re=ee?V.shape[ce-2]:V.shape[ce-1],Oe=A.shape.slice(0,-2),Fe=V.shape.slice(0,-2),Ve=i.util.sizeFromShape(Oe),Xe=i.util.sizeFromShape(Fe),rt=Ve===Xe||Ve===1||Xe===1;i.util.assert(_e>=2&&ce>=2&&rt,function(){return"Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input "+("batch dimensions of ("+Oe+") and ("+Fe+").")});var at=Ve>Xe?A.shape.slice(0,-2):V.shape.slice(0,-2),$=at.concat([ve,Re]);i.util.assert(de===ye,function(){return"Error in matMul: inner shapes ("+de+") and ("+(ye+") of Tensors with shapes "+A.shape+" and ")+(V.shape+" and transposeA="+oe)+(" and transposeB="+ee+" must match.")});for(var et=oe?[Ve,de,ve]:[Ve,ve,de],gt=ee?[Xe,Re,ye]:[Xe,ye,Re],lt=da({inputs:{x:A},backend:E,attrs:{shape:et}}),_t=da({inputs:{x:V},backend:E,attrs:{shape:gt}}),At=oe?lt.shape[1]:lt.shape[2],Lt=oe?lt.shape[2]:lt.shape[1],Pt=ee?_t.shape[1]:_t.shape[2],Ut=Math.max(Ve,Xe),Nt=E.data.get(lt.dataId).values,Kt=E.data.get(_t.dataId).values,Ht=i.util.computeStrides(lt.shape),Ot=i.util.computeStrides(_t.shape),Rt=oe?[Ht[0],1,Ht[1]]:[Ht[0],Ht[1],1],wt=Rt[0],Et=Rt[1],Vt=Rt[2],jt=ee?[1,Ot[1],Ot[0]]:[Ot[1],1,Ot[0]],cr=jt[0],rr=jt[1],Ie=jt[2],br=Lt*Pt,Nr=i.buffer([Ut,Lt,Pt],lt.dtype),Tr=Nr.values,hr=E.blockSize,Dr=0;Dr<Ut;Dr++)for(var fr=0;fr<Lt;fr+=hr)for(var Er=0;Er<Pt;Er+=hr)for(var an=0;an<At;an+=hr)for(var wn=Math.min(fr+hr,Lt),ie=Math.min(Er+hr,Pt),Nn=Math.min(an+hr,At),bn=fr;bn<wn;bn++)for(var Ee=Er;Ee<ie;Ee++){for(var Bn=0,Pn=an;Pn<Nn;Pn++){var Da=Math.min(Dr,Ve-1)*wt,Dn=Math.min(Dr,Xe-1)*Ie,Ya=Nt[Da+bn*Et+Pn*Vt],za=Kt[Pn*cr+Ee*rr+Dn];Bn+=Ya*za}Tr[Dr*br+(bn*Pt+Ee)]+=Bn}return E.disposeIntermediateTensorInfo(lt),E.disposeIntermediateTensorInfo(_t),E.makeTensorInfo($,Nr.dtype,Nr.values)}var X={kernelName:i.BatchMatMul,backendName:"cpu",kernelFunc:pe};function j(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.a,V=ue.b,oe=ue.bias,ee=ue.preluActivationWeights,_e=F.transposeA,ce=F.transposeB,de=F.activation,ye,ve,Re,Oe=[],Fe=pe({inputs:{a:A,b:V},attrs:{transposeA:_e,transposeB:ce},backend:E});ye=Fe,oe&&(ve=qt({inputs:{a:ye,b:oe},backend:E}),Oe.push(ye),ye=ve),de&&(Re=Oi(E,ye,de,ee),Oe.push(ye),ye=Re);for(var Ve=0,Xe=Oe;Ve<Xe.length;Ve++){var rt=Xe[Ve];E.disposeIntermediateTensorInfo(rt)}return ye}var re={kernelName:i._FusedMatMul,backendName:"cpu",kernelFunc:j},te=_r(i.Acos,function(ne){return Math.acos(ne)}),Ue={kernelName:i.Acos,backendName:"cpu",kernelFunc:te},kt=_r(i.Acosh,function(ne){return Math.acosh(ne)}),$e={kernelName:i.Acosh,backendName:"cpu",kernelFunc:kt},Le=_r(i.Asin,function(ne){return Math.asin(ne)}),Ye={kernelName:i.Asin,backendName:"cpu",kernelFunc:Le},Ft=_r(i.Asinh,function(ne){return Math.asinh(ne)}),St={kernelName:i.Asinh,backendName:"cpu",kernelFunc:Ft},Mt=_r(i.Atan,function(ne){return Math.atan(ne)}),dr={kernelName:i.Atan,backendName:"cpu",kernelFunc:Mt},ir=_r(i.Atanh,function(ne){return Math.atanh(ne)}),ta={kernelName:i.Atanh,backendName:"cpu",kernelFunc:ir};function fa(ne,ue,E,F,A,V){for(var oe=A.strideHeight,ee=A.strideWidth,_e=A.dilationHeight,ce=A.dilationWidth,de=A.effectiveFilterHeight,ye=A.effectiveFilterWidth,ve=A.padInfo.top,Re=A.padInfo.left,Oe=V==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,Fe=i.buffer(A.outShape,E),Ve=Fe.values,Xe=A.outShape[1]*A.outShape[2]*A.outShape[3],rt=A.outShape[2]*A.outShape[3],at=A.outShape[3],$=0;$<A.batchSize;++$)for(var et=$*Xe,gt=$*F[0],lt=0;lt<A.inChannels;++lt)for(var _t=0;_t<A.outHeight;++_t)for(var At=_t*oe-ve,Lt=Math.max(0,At),Pt=Math.min(A.inHeight,de+At),Ut=et+_t*rt,Nt=0;Nt<A.outWidth;++Nt){for(var Kt=Nt*ee-Re,Ht=Math.max(0,Kt),Ot=Math.min(A.inWidth,ye+Kt),Rt=Oe,wt=0,Et=0,Vt=Lt;Vt<Pt;Vt+=_e){for(var jt=gt+Vt*F[1],cr=Ht;cr<Ot;cr+=ce){var rr=jt+cr*F[2],Ie=ne[rr+lt];V==="max"&&Ie>Rt?Rt=Ie:V==="avg"&&(wt+=Ie,Et++)}if(isNaN(Rt))break}var br=Ut+Nt*at+lt;Ve[br]=V==="avg"?wt/Et:Rt}return Fe}function ra(ne,ue,E,F,A,V){A===void 0&&(A=!1),V===void 0&&(V=!1);for(var oe=i.buffer(F.outShape,"int32"),ee=F.strideHeight,_e=F.strideWidth,ce=F.dilationHeight,de=F.dilationWidth,ye=F.effectiveFilterHeight,ve=F.effectiveFilterWidth,Re=F.padInfo.top,Oe=F.padInfo.left,Fe=i.buffer(ue,E,ne),Ve=0;Ve<F.batchSize;++Ve)for(var Xe=0;Xe<F.inChannels;++Xe)for(var rt=0;rt<F.outHeight;++rt){for(var at=rt*ee-Re,$=at;$<0;)$+=ce;for(var et=Math.min(F.inHeight,ye+at),gt=0;gt<F.outWidth;++gt){for(var lt=gt*_e-Oe,_t=lt;_t<0;)_t+=de;for(var At=Math.min(F.inWidth,ve+lt),Lt=Number.NEGATIVE_INFINITY,Pt=-1,Ut=$;Ut<et;Ut+=ce)for(var Nt=Ut-at,Kt=_t;Kt<At;Kt+=de){var Ht=Kt-lt,Ot=Fe.get(Ve,Ut,Kt,Xe);Ot>Lt&&(Lt=Ot,A?Pt=V?((Ve*F.inHeight+Ut)*F.inWidth+Kt)*F.inChannels+Xe:(Ut*F.inWidth+Kt)*F.inChannels+Xe:Pt=Nt*ve+Ht)}oe.set(Pt,Ve,rt,gt,Xe)}}return oe}function Ha(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x;Q(A,"avgPool");var V=F.filterSize,oe=F.strides,ee=F.pad,_e=F.dimRoundingMode,ce=1;i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(oe,ce),function(){return"Error in avgPool: Either strides or dilations must be 1. "+("Got strides "+oe+" and dilations '"+ce+"'")});var de=i.backend_util.computePool2DInfo(A.shape,V,oe,ce,ee,_e),ye;if(de.filterWidth===1&&de.filterHeight===1&&i.util.arraysEqual(de.inShape,de.outShape))ye=Tt({inputs:{x:A},backend:E});else{var ve=E.data.get(A.dataId).values,Re=i.util.computeStrides(A.shape),Oe=fa(ve,A.shape,A.dtype,Re,de,"avg");ye=E.makeTensorInfo(de.outShape,A.dtype,Oe.values)}return ye}var ki={kernelName:i.AvgPool,backendName:"cpu",kernelFunc:Ha};function sn(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.dy,V=ue.input,oe=V;Q([A,V],"avgPoolBackprop");for(var ee=F.filterSize,_e=F.strides,ce=F.pad,de=i.backend_util.computePool2DInfo(oe.shape,ee,_e,1,ce),ye=de.strideHeight,ve=de.strideWidth,Re=de.filterHeight,Oe=de.filterWidth,Fe=de.dilationHeight,Ve=de.dilationWidth,Xe=de.effectiveFilterHeight,rt=de.effectiveFilterWidth,at=rt-1-de.padInfo.left,$=Xe-1-de.padInfo.top,et=i.buffer(oe.shape,"float32"),gt=1/(Re*Oe),lt=E.data.get(A.dataId).values,_t=i.buffer(A.shape,"float32",lt),At=0;At<de.batchSize;++At)for(var Lt=0;Lt<de.inChannels;++Lt)for(var Pt=0;Pt<de.inHeight;++Pt)for(var Ut=0;Ut<de.inWidth;++Ut){for(var Nt=Pt-$,Kt=Ut-at,Ht=0,Ot=0;Ot<Xe;Ot+=Fe){var Rt=(Nt+Ot)/ye;if(Rt<0||Rt>=de.outHeight||Math.floor(Rt)!==Rt)continue;for(var wt=0;wt<rt;wt+=Ve){var Et=(Kt+wt)/ve;if(Et<0||Et>=de.outWidth||Math.floor(Et)!==Et)continue;var Vt=_t.get(At,Rt,Et,Lt);Ht+=Vt}}et.set(Ht*gt,At,Pt,Ut,Lt)}return E.makeTensorInfo(et.shape,et.dtype,et.values)}var hn={kernelName:i.AvgPoolBackprop,backendName:"cpu",kernelFunc:sn};function na(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.scale,oe=ue.offset,ee=ue.mean,_e=ue.variance;i.util.assert(ee.shape.length===_e.shape.length,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),i.util.assert(oe==null||ee.shape.length===oe.shape.length,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),i.util.assert(V==null||ee.shape.length===V.shape.length,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}),Q([A,ee,_e,V,oe],"batchNorm");var ce=F.varianceEpsilon;ce==null&&(ce=.001);for(var de=E.data.get(A.dataId).values,ye=E.data.get(ee.dataId).values,ve=E.data.get(_e.dataId).values,Re=V?E.data.get(V.dataId).values:new Float32Array([1]),Oe=oe?E.data.get(oe.dataId).values:new Float32Array([0]),Fe=new Float32Array(de.length),Ve=Oe.length,Xe=Re.length,rt=ve.length,at=ye.length,$=0,et=0,gt=0,lt=0,_t=0;_t<de.length;++_t)Fe[_t]=Oe[$++]+(de[_t]-ye[et++])*Re[gt++]/Math.sqrt(ve[lt++]+ce),$>=Ve&&($=0),et>=at&&(et=0),gt>=Xe&&(gt=0),lt>=rt&&(lt=0);return E.makeTensorInfo(A.shape,A.dtype,Fe)}var Jr={kernelName:i.FusedBatchNorm,backendName:"cpu",kernelFunc:na},Vr=_r(i.ClipByValue,function(ne,ue){var E=ue;return ne>E.clipValueMax?E.clipValueMax:ne<E.clipValueMin?E.clipValueMin:ne}),Jn={kernelName:i.ClipByValue,backendName:"cpu",kernelFunc:Vr};function tn(ne){var ue=ne.inputs,E=ne.backend,F=ue.input,A=E.data.get(F.dataId).complexTensorInfos.imag,V=E.data.get(A.dataId).values;return E.makeTensorInfo(A.shape,A.dtype,V)}var Rn={kernelName:i.Imag,backendName:"cpu",kernelFunc:tn};function Kn(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=F.axis,V=i.util.parseAxisParam(A,ue[0].shape)[0],oe=i.backend_util.computeOutShape(ue.map(function($){return $.shape}),V);if(i.util.sizeFromShape(oe)===0)return E.makeTensorInfo(oe,ue[0].dtype,[]);var ee=ue.filter(function($){return i.util.sizeFromShape($.shape)>0});if(ee.length===1)return ee[0];var _e=ee.map(function($){return $.shape});if(i.backend_util.assertParamsConsistent(_e,V),ee[0].dtype==="complex64"){var ce=ee.map(function($){return it({inputs:{input:$},backend:E})}),de=ee.map(function($){return tn({inputs:{input:$},backend:E})}),ye=Kn({inputs:ce,backend:E,attrs:{axis:V}}),ve=Kn({inputs:de,backend:E,attrs:{axis:V}}),Re=tt({inputs:{real:ye,imag:ve},backend:E});return ce.forEach(function($){return E.disposeIntermediateTensorInfo($)}),de.forEach(function($){return E.disposeIntermediateTensorInfo($)}),E.disposeIntermediateTensorInfo(ye),E.disposeIntermediateTensorInfo(ve),Re}var Oe=ee.map(function($){var et=i.util.sizeFromShape($.shape.slice(V)),gt=[-1,et];return da({inputs:{x:$},backend:E,attrs:{shape:gt}})});oe=i.backend_util.computeOutShape(Oe.map(function($){return $.shape}),1);var Fe=i.util.getTypedArrayFromDType(ee[0].dtype,i.util.sizeFromShape(oe));if(Oe[0].shape[0]===1){var Ve=0;Oe.forEach(function($){var et=E.data.get($.dataId).values,gt=i.util.sizeFromShape($.shape);Fe.set(et,Ve),Ve+=gt})}else{var Xe=0;Oe.forEach(function($){for(var et=E.data.get($.dataId).values,gt=0,lt=0;lt<$.shape[0];++lt)for(var _t=lt*oe[1]+Xe,At=0;At<$.shape[1];++At)Fe[_t+At]=et[gt++];Xe+=$.shape[1]})}var rt=i.backend_util.computeOutShape(ee.map(function($){return $.shape}),V),at=E.makeTensorInfo(rt,ue[0].dtype,Fe);return Oe.forEach(function($){return E.disposeIntermediateTensorInfo($)}),at}var aa={kernelName:i.Concat,backendName:"cpu",kernelFunc:Kn};function ma(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.filter,oe=F.strides,ee=F.pad,_e=F.dataFormat,ce=F.dilations,de=F.dimRoundingMode;Q([A,V],"conv2d");for(var ye=i.backend_util.convertConv2DDataFormat(_e),ve=i.backend_util.computeConv2DInfo(A.shape,V.shape,oe,ce,ee,de,!1,ye),Re=ve.filterHeight,Oe=ve.filterWidth,Fe=ve.dilationHeight,Ve=ve.dilationWidth,Xe=ve.padInfo.left,rt=ve.padInfo.top,at=ve.dataFormat==="channelsLast",$=new i.TensorBuffer(ve.outShape,A.dtype),et=i.util.computeStrides(A.shape),gt=i.util.computeStrides(V.shape),lt=et[0],_t=at?et[1]:et[2],At=at?et[2]:1,Lt=at?1:et[1],Pt=$.strides[0],Ut=at?$.strides[1]:$.strides[2],Nt=at?$.strides[2]:1,Kt=at?1:$.strides[1],Ht=E.data.get(A.dataId).values,Ot=E.data.get(V.dataId).values,Rt=$.values,wt=0;wt<ve.batchSize;++wt)for(var Et=wt*lt,Vt=wt*Pt,jt=0;jt<ve.outHeight;++jt)for(var cr=Vt+jt*Ut,rr=jt*ve.strideHeight-rt,Ie=0;Ie<Re;++Ie){var br=rr+Ie*Fe;if(br<0||br>=ve.inHeight)continue;for(var Nr=Ie*gt[0],Tr=Et+br*_t,hr=0;hr<ve.outWidth;++hr)for(var Dr=cr+hr*Nt,fr=hr*ve.strideWidth-Xe,Er=0;Er<Oe;++Er){var an=fr+Er*Ve;if(an<0||an>=ve.inWidth)continue;for(var wn=Nr+Er*gt[1],ie=Tr+an*At,Nn=wn,bn=0;bn<ve.inChannels;++bn){for(var Ee=Ht[ie+bn*Lt],Bn=0;Bn<ve.outChannels;++Bn)Rt[Dr+Bn*Kt]+=Ee*Ot[Nn+Bn];Nn+=ve.outChannels}}}return E.makeTensorInfo($.shape,$.dtype,Rt)}var Li={kernelName:i.Conv2D,backendName:"cpu",kernelFunc:ma};function Ea(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.dy,oe=F.strides,ee=F.pad,_e=F.dataFormat,ce=F.dimRoundingMode,de=F.filterShape;Q([A,V],"conv2dBackpropFilter");for(var ye=i.backend_util.convertConv2DDataFormat(_e),ve=i.backend_util.computeConv2DInfo(A.shape,de,oe,1,ee,ce,!1,ye),Re=ve.strideHeight,Oe=ve.strideWidth,Fe=ve.filterHeight,Ve=ve.filterWidth,Xe=ve.dataFormat==="channelsLast",rt=new i.TensorBuffer(ve.filterShape,"float32"),at=ve.padInfo.left,$=ve.padInfo.top,et=E.data.get(A.dataId).values,gt=E.data.get(V.dataId).values,lt=new i.TensorBuffer(A.shape,A.dtype,et),_t=new i.TensorBuffer(V.shape,V.dtype,gt),At=0;At<Fe;++At)for(var Lt=Math.max(0,Math.ceil(($-At)/Re)),Pt=Math.min(ve.outHeight,(ve.inHeight+$-At)/Re),Ut=0;Ut<Ve;++Ut)for(var Nt=Math.max(0,Math.ceil((at-Ut)/Oe)),Kt=Math.min(ve.outWidth,(ve.inWidth+at-Ut)/Oe),Ht=0;Ht<ve.inChannels;++Ht)for(var Ot=0;Ot<ve.outChannels;++Ot){for(var Rt=0,wt=0;wt<ve.batchSize;++wt)for(var Et=Lt;Et<Pt;++Et)for(var Vt=At+Et*Re-$,jt=Nt;jt<Kt;++jt){var cr=Ut+jt*Oe-at;Xe?Rt+=lt.get(wt,Vt,cr,Ht)*_t.get(wt,Et,jt,Ot):Rt+=lt.get(wt,Ht,Vt,cr)*_t.get(wt,Ot,Et,jt)}rt.set(Rt,At,Ut,Ht,Ot)}return E.makeTensorInfo(rt.shape,rt.dtype,rt.values)}var S={kernelName:i.Conv2DBackpropFilter,backendName:"cpu",kernelFunc:Ea};function x(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.dy,V=ue.filter,oe=F.inputShape,ee=F.strides,_e=F.pad,ce=F.dataFormat,de=F.dimRoundingMode;Q([A,V],"conv2dBackpropInput");var ye=i.util.computeStrides(V.shape),ve=i.util.computeStrides(A.shape),Re=i.backend_util.convertConv2DDataFormat(ce),Oe=i.backend_util.computeConv2DInfo(oe,V.shape,ee,1,_e,de,!1,Re),Fe=new i.TensorBuffer(Oe.inShape,"float32"),Ve=Fe.values,Xe=E.data.get(A.dataId).values,rt=E.data.get(V.dataId).values,at=ye[0],$=ye[1],et=ye[2],gt=Oe.batchSize,lt=Oe.filterHeight,_t=Oe.filterWidth,At=Oe.inChannels,Lt=Oe.inHeight,Pt=Oe.inWidth,Ut=Oe.outChannels,Nt=Oe.outHeight,Kt=Oe.outWidth,Ht=Oe.strideHeight,Ot=Oe.strideWidth;Re=Oe.dataFormat;for(var Rt=lt-1-Oe.padInfo.top,wt=_t-1-Oe.padInfo.left,Et=Re==="channelsLast",Vt=Fe.strides[0],jt=Et?Fe.strides[1]:Fe.strides[2],cr=Et?Fe.strides[2]:1,rr=Et?1:Fe.strides[1],Ie=ve[0],br=Et?ve[1]:ve[2],Nr=Et?ve[2]:1,Tr=Et?1:ve[1],hr=0;hr<gt;++hr)for(var Dr=0;Dr<At;++Dr)for(var fr=0;fr<Lt;++fr)for(var Er=fr-Rt,an=Math.max(0,Math.ceil(Er/Ht)),wn=Math.min(Nt,(lt+Er)/Ht),ie=0;ie<Pt;++ie){for(var Nn=ie-wt,bn=Math.max(0,Math.ceil(Nn/Ot)),Ee=Math.min(Kt,(_t+Nn)/Ot),Bn=0,Pn=an;Pn<wn;++Pn)for(var Da=Pn*Ht-Er,Dn=bn;Dn<Ee;++Dn)for(var Ya=Dn*Ot-Nn,za=Ie*hr+br*Pn+Nr*Dn,Qa=at*(lt-1-Da)+$*(_t-1-Ya)+et*Dr,ya=0;ya<Ut;++ya){var va=Xe[za+Tr*ya],Yi=rt[Qa+ya];Bn+=va*Yi}var Wi=Vt*hr+jt*fr+cr*ie+rr*Dr;Ve[Wi]=Bn}return E.makeTensorInfo(Fe.shape,Fe.dtype,Fe.values)}var k={kernelName:i.Conv2DBackpropInput,backendName:"cpu",kernelFunc:x};function K(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.filter,oe=F.strides,ee=F.pad,_e=F.dilations;Q([A,V],"conv3d");for(var ce=i.backend_util.computeConv3DInfo(A.shape,V.shape,oe,_e,ee),de=ce.filterDepth,ye=ce.filterHeight,ve=ce.filterWidth,Re=ce.dilationDepth,Oe=ce.dilationHeight,Fe=ce.dilationWidth,Ve=ce.padInfo,Xe=Ve.front,rt=Ve.left,at=Ve.top,$=new i.TensorBuffer(ce.outShape,A.dtype),et=E.data.get(A.dataId).values,gt=E.data.get(V.dataId).values,lt=$.values,_t=i.util.computeStrides(A.shape),At=i.util.computeStrides(V.shape),Lt=0;Lt<ce.batchSize;++Lt)for(var Pt=Lt*_t[0],Ut=Lt*$.strides[0],Nt=0;Nt<ce.outDepth;++Nt)for(var Kt=Ut+Nt*$.strides[1],Ht=Nt*ce.strideDepth-Xe,Ot=0;Ot<de;++Ot){var Rt=Ht+Ot*Re;if(Rt<0||Rt>=ce.inDepth)continue;for(var wt=Ot*At[0],Et=Pt+Rt*_t[1],Vt=0;Vt<ce.outHeight;++Vt)for(var jt=Kt+Vt*$.strides[2],cr=Vt*ce.strideHeight-at,rr=0;rr<ye;++rr){var Ie=cr+rr*Oe;if(Ie<0||Ie>=ce.inHeight)continue;for(var br=wt+rr*At[1],Nr=Et+Ie*_t[2],Tr=0;Tr<ce.outWidth;++Tr)for(var hr=jt+Tr*ce.outChannels,Dr=Tr*ce.strideWidth-rt,fr=0;fr<ve;++fr){var Er=Dr+fr*Fe;if(Er<0||Er>=ce.inWidth)continue;for(var an=br+fr*At[2],wn=Nr+Er*ce.inChannels,ie=an,Nn=0;Nn<ce.inChannels;++Nn){for(var bn=et[wn+Nn],Ee=0;Ee<ce.outChannels;++Ee)lt[hr+Ee]+=bn*gt[ie+Ee];ie+=ce.outChannels}}}}return E.makeTensorInfo($.shape,$.dtype,$.values)}var Se={kernelName:i.Conv3D,backendName:"cpu",kernelFunc:K};function we(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.dy,oe=F.strides,ee=F.pad,_e=F.filterShape;Q([A,V],"conv3dBackpropFilterV2");for(var ce=i.util.computeStrides(A.shape),de=i.util.computeStrides(V.shape),ye=i.backend_util.computeConv3DInfo(A.shape,_e,oe,1,ee),ve=ye.strideDepth,Re=ye.strideHeight,Oe=ye.strideWidth,Fe=ye.filterDepth,Ve=ye.filterHeight,Xe=ye.filterWidth,rt=new i.TensorBuffer(ye.filterShape,"float32"),at=rt.values,$=rt.strides,et=$[0],gt=$[1],lt=$[2],_t=$[3],At=E.data.get(V.dataId).values,Lt=de[0],Pt=de[1],Ut=de[2],Nt=de[3],Kt=E.data.get(A.dataId).values,Ht=ce[0],Ot=ce[1],Rt=ce[2],wt=ce[3],Et=ye.padInfo.front,Vt=ye.padInfo.left,jt=ye.padInfo.top,cr=0;cr<Fe;++cr)for(var rr=Math.max(0,Math.ceil((Et-cr)/ve)),Ie=Math.min(ye.outDepth,(ye.inDepth+Et-cr)/ve),br=cr*et,Nr=0;Nr<Ve;++Nr)for(var Tr=Math.max(0,Math.ceil((jt-Nr)/Re)),hr=Math.min(ye.outHeight,(ye.inHeight+jt-Nr)/Re),Dr=Nr*gt+br,fr=0;fr<Xe;++fr)for(var Er=Math.max(0,Math.ceil((Vt-fr)/Oe)),an=Math.min(ye.outWidth,(ye.inWidth+Vt-fr)/Oe),wn=fr*lt+Dr,ie=0;ie<ye.inChannels;++ie)for(var Nn=ie*_t+wn,bn=0;bn<ye.outChannels;++bn){for(var Ee=0,Bn=0;Bn<ye.batchSize;++Bn)for(var Pn=Bn*Ht,Da=Bn*Lt,Dn=rr;Dn<Ie;++Dn)for(var Ya=cr+Dn*ve-Et,za=Ya*Ot+Pn,Qa=Dn*Pt+Da,ya=Tr;ya<hr;++ya)for(var va=Nr+ya*Re-jt,Yi=va*Rt+za,Wi=ya*Ut+Qa,Or=Er;Or<an;++Or){var Za=fr+Or*Oe-Vt,rs=Za*wt+Yi,Po=Or*Nt+Wi;Ee+=Kt[rs+ie]*At[Po+bn]}at[Nn+bn]=Ee}return E.makeTensorInfo(rt.shape,rt.dtype,rt.values)}var Je={kernelName:i.Conv3DBackpropFilterV2,backendName:"cpu",kernelFunc:we};function Be(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.dy,V=ue.filter,oe=F.pad,ee=F.strides,_e=F.inputShape;Q([A],"conv3dBackpropInputV2");for(var ce=i.util.computeStrides(A.shape),de=i.util.computeStrides(V.shape),ye=i.backend_util.computeConv3DInfo(_e,V.shape,ee,1,oe),ve=new i.TensorBuffer(ye.inShape,"float32"),Re=ve.values,Oe=ve.strides,Fe=Oe[0],Ve=Oe[1],Xe=Oe[2],rt=Oe[3],at=E.data.get(A.dataId).values,$=ce[0],et=ce[1],gt=ce[2],lt=ce[3],_t=E.data.get(V.dataId).values,At=de[0],Lt=de[1],Pt=de[2],Ut=de[3],Nt=ye.batchSize,Kt=ye.filterDepth,Ht=ye.filterHeight,Ot=ye.filterWidth,Rt=ye.inChannels,wt=ye.inDepth,Et=ye.inHeight,Vt=ye.inWidth,jt=ye.outChannels,cr=ye.outDepth,rr=ye.outHeight,Ie=ye.outWidth,br=ye.strideDepth,Nr=ye.strideHeight,Tr=ye.strideWidth,hr=Kt-1-ye.padInfo.front,Dr=Ht-1-ye.padInfo.top,fr=Ot-1-ye.padInfo.left,Er=0;Er<Nt;++Er)for(var an=0;an<Rt;++an)for(var wn=0;wn<wt;++wn)for(var ie=wn-hr,Nn=Math.max(0,Math.ceil(ie/br)),bn=Math.min(cr,(Kt+ie)/br),Ee=0;Ee<Et;++Ee)for(var Bn=Ee-Dr,Pn=Math.max(0,Math.ceil(Bn/Nr)),Da=Math.min(rr,(Ht+Bn)/Nr),Dn=0;Dn<Vt;++Dn){for(var Ya=Dn-fr,za=Math.max(0,Math.ceil(Ya/Tr)),Qa=Math.min(Ie,(Ot+Ya)/Tr),ya=0,va=Nn;va<bn;++va)for(var Yi=va*br-ie,Wi=Pn;Wi<Da;++Wi)for(var Or=Wi*Nr-Bn,Za=za;Za<Qa;++Za)for(var rs=Za*Tr-Ya,Po=$*Er+et*va+gt*Wi+lt*Za,dn=At*(Kt-1-Yi)+Lt*(Ht-1-Or)+Pt*(Ot-1-rs)+Ut*an,Bo=0;Bo<jt;++Bo){var Fn=at[Po+Bo],su=_t[dn+Bo];ya+=Fn*su}Re[Fe*Er+Ve*wn+Xe*Ee+rt*Dn+an]=ya}return E.makeTensorInfo(ve.shape,ve.dtype,ve.values)}var vt={kernelName:i.Conv3DBackpropInputV2,backendName:"cpu",kernelFunc:Be},ft=_r(i.Cos,function(ne){return Math.cos(ne)}),zt={kernelName:i.Cos,backendName:"cpu",kernelFunc:ft},Wt=_r(i.Cosh,function(ne){return Math.cosh(ne)}),Gt={kernelName:i.Cosh,backendName:"cpu",kernelFunc:Wt};function Qt(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.filter,oe=F.strides,ee=F.pad,_e=F.dilations,ce=F.dimRoundingMode;Q([A,V],"depthwiseConv2DNative");var de=i.util.computeStrides(A.shape),ye=i.util.computeStrides(V.shape),ve=_e;ve==null&&(ve=[1,1]),i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(oe,ve),function(){return"Error in depthwiseConv2d: Either strides or dilations must be "+("1. Got strides "+oe+" and dilations '"+ve+"'")});for(var Re=i.backend_util.computeConv2DInfo(A.shape,V.shape,oe,ve,ee,ce,!0),Oe=Re.filterHeight,Fe=Re.filterWidth,Ve=Re.dilationHeight,Xe=Re.dilationWidth,rt=Re.padInfo,at=rt.left,$=rt.top,et=Re.outChannels/Re.inChannels,gt=new i.TensorBuffer(Re.outShape,A.dtype),lt=E.data.get(A.dataId).values,_t=E.data.get(V.dataId).values,At=gt.values,Lt=0;Lt<Re.batchSize;++Lt)for(var Pt=Lt*de[0],Ut=Lt*gt.strides[0],Nt=0;Nt<Re.outHeight;++Nt)for(var Kt=Ut+Nt*gt.strides[1],Ht=Nt*Re.strideHeight-at,Ot=0;Ot<Oe;++Ot){var Rt=Ht+Ot*Ve;if(Rt<0||Rt>=Re.inHeight)continue;for(var wt=Ot*ye[0],Et=Pt+Rt*de[1],Vt=0;Vt<Re.outWidth;++Vt)for(var jt=Kt+Vt*gt.strides[2],cr=Vt*Re.strideWidth-$,rr=0;rr<Fe;++rr){var Ie=cr+rr*Xe;if(Ie<0||Ie>=Re.inWidth)continue;for(var br=wt+rr*ye[1],Nr=Et+Ie*Re.inChannels,Tr=jt,hr=br,Dr=0;Dr<Re.inChannels;++Dr){for(var fr=lt[Nr+Dr],Er=0;Er<et;++Er)At[Tr+Er]+=fr*_t[hr+Er];Tr+=et,hr+=et}}}return E.makeTensorInfo(gt.shape,gt.dtype,gt.values)}var wr={kernelName:i.DepthwiseConv2dNative,backendName:"cpu",kernelFunc:Qt};function Ar(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.dy,oe=F.strides,ee=F.dilations,_e=F.pad,ce=F.dimRoundingMode,de=F.filterShape;Q([A,V],"depthwiseConv2dNativeBackpropFilter");for(var ye=i.backend_util.computeConv2DInfo(A.shape,de,oe,ee,_e,ce,!0),ve=ye.strideHeight,Re=ye.strideWidth,Oe=ye.filterHeight,Fe=ye.filterWidth,Ve=new i.TensorBuffer(ye.filterShape,"float32"),Xe=ye.padInfo.left,rt=ye.padInfo.top,at=ye.outChannels/ye.inChannels,$=E.data.get(A.dataId).values,et=new i.TensorBuffer(A.shape,A.dtype,$),gt=E.data.get(V.dataId).values,lt=new i.TensorBuffer(V.shape,V.dtype,gt),_t=0;_t<Oe;++_t)for(var At=Math.max(0,Math.ceil((rt-_t)/ve)),Lt=Math.min(ye.outHeight,(ye.inHeight+rt-_t)/ve),Pt=0;Pt<Fe;++Pt)for(var Ut=Math.max(0,Math.ceil((Xe-Pt)/Re)),Nt=Math.min(ye.outWidth,(ye.inWidth+Xe-Pt)/Re),Kt=0;Kt<ye.outChannels;++Kt){for(var Ht=Math.trunc(Kt/at),Ot=Kt%at,Rt=0,wt=0;wt<ye.batchSize;++wt)for(var Et=At;Et<Lt;++Et)for(var Vt=_t+Et*ve-rt,jt=Ut;jt<Nt;++jt){var cr=Pt+jt*Re-Xe;Rt+=et.get(wt,Vt,cr,Ht)*lt.get(wt,Et,jt,Kt)}Ve.set(Rt,_t,Pt,Ht,Ot)}return E.makeTensorInfo(Ve.shape,Ve.dtype,Ve.values)}var Yt={kernelName:i.DepthwiseConv2dNativeBackpropFilter,backendName:"cpu",kernelFunc:Ar};function xr(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.dy,V=ue.filter,oe=F.strides,ee=F.dilations,_e=F.pad,ce=F.dimRoundingMode,de=F.inputShape;Q([A,V],"depthwiseConv2DNativeBackpropInput");for(var ye=i.util.computeStrides(A.shape),ve=i.util.computeStrides(V.shape),Re=i.backend_util.computeConv2DInfo(de,V.shape,oe,ee,_e,ce,!0),Oe=new i.TensorBuffer(Re.inShape,"float32"),Fe=Oe.values,Ve=Oe.strides,Xe=Ve[0],rt=Ve[1],at=Ve[2],$=E.data.get(A.dataId).values,et=ye[0],gt=ye[1],lt=ye[2],_t=E.data.get(V.dataId).values,At=ve[0],Lt=ve[1],Pt=ve[2],Ut=Re.batchSize,Nt=Re.filterHeight,Kt=Re.filterWidth,Ht=Re.inChannels,Ot=Re.inHeight,Rt=Re.inWidth,wt=Re.outChannels,Et=Re.outHeight,Vt=Re.outWidth,jt=Re.strideHeight,cr=Re.strideWidth,rr=Nt-1-Re.padInfo.top,Ie=Kt-1-Re.padInfo.left,br=wt/Ht,Nr=0;Nr<Ut;++Nr)for(var Tr=0;Tr<Ht;++Tr)for(var hr=0;hr<Ot;++hr)for(var Dr=hr-rr,fr=Math.max(0,Math.ceil(Dr/jt)),Er=Math.min(Et,(Nt+Dr)/jt),an=0;an<Rt;++an){for(var wn=an-Ie,ie=Math.max(0,Math.ceil(wn/cr)),Nn=Math.min(Vt,(Kt+wn)/cr),bn=0,Ee=fr;Ee<Er;++Ee)for(var Bn=Ee*jt-Dr,Pn=ie;Pn<Nn;++Pn)for(var Da=Pn*cr-wn,Dn=et*Nr+gt*Ee+lt*Pn,Ya=At*(Nt-1-Bn)+Lt*(Kt-1-Da)+Pt*Tr,za=0;za<br;++za){var Qa=Tr*br+za,ya=$[Dn+Qa],va=_t[Ya+za];bn+=ya*va}Fe[Xe*Nr+rt*hr+at*an+Tr]=bn}return E.makeTensorInfo(Oe.shape,Oe.dtype,Oe.values)}var Sn={kernelName:i.DepthwiseConv2dNativeBackpropInput,backendName:"cpu",kernelFunc:xr},pn={kernelName:i.Dilation2D,backendName:"cpu",kernelFunc:function(ne){for(var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.x,oe=A.filter,ee=F,_e=ee.strides,ce=ee.pad,de=ee.dilations,ye=E,ve=ye.data.get(V.dataId).values,Re=V.shape.length,Oe=ye.data.get(oe.dataId).values,Fe=oe.shape.length,Ve=i.backend_util.computeDilation2DInfo(V.shape,oe.shape,_e,ce,"NHWC",de),Xe=Ve.batchSize,rt=Ve.inHeight,at=Ve.inWidth,$=Ve.inChannels,et=Ve.outHeight,gt=Ve.outWidth,lt=Ve.padInfo,_t=Ve.strideHeight,At=Ve.strideWidth,Lt=Ve.filterHeight,Pt=Ve.filterWidth,Ut=Ve.dilationHeight,Nt=Ve.dilationWidth,Kt=Ve.outShape,Ht=i.util.sizeFromShape(Kt),Ot=Kt.length,Rt=i.util.getArrayFromDType(V.dtype,Ht),wt=0;wt<Xe;++wt)for(var Et=0;Et<et;++Et)for(var Vt=Et*_t-lt.top,jt=0;jt<gt;++jt)for(var cr=jt*At-lt.left,rr=0;rr<$;++rr){for(var Ie=Number.MIN_SAFE_INTEGER,br=0;br<Lt;++br){var Nr=Vt+br*Ut;if(Nr>=0&&Nr<rt)for(var Tr=0;Tr<Pt;++Tr){var hr=cr+Tr*Nt;if(hr>=0&&hr<at){var Dr=i.util.locToIndex([wt,Nr,hr,rr],Re,i.util.computeStrides(V.shape)),fr=i.util.locToIndex([br,Tr,rr],Fe,i.util.computeStrides(oe.shape)),Er=ve[Dr]+Oe[fr];Er>Ie&&(Ie=Er)}}}var an=i.util.locToIndex([wt,Et,jt,rr],Ot,i.util.computeStrides(Kt));Rt[an]=Ie}var wn=ye.write(i.util.toTypedArray(Rt,V.dtype),Kt,V.dtype);return{dataId:wn,shape:Kt,dtype:V.dtype}}},zn={kernelName:i.Dilation2DBackpropFilter,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.x,oe=A.filter,ee=A.dy,_e=F,ce=_e.strides,de=_e.pad,ye=_e.dilations,ve=E,Re=i.util.toNestedArray(V.shape,ve.data.get(V.dataId).values),Oe=i.util.toNestedArray(oe.shape,ve.data.get(oe.dataId).values),Fe=i.backend_util.computeDilation2DInfo(V.shape,oe.shape,ce,de,"NHWC",ye),Ve=Fe.batchSize,Xe=Fe.inHeight,rt=Fe.inWidth,at=Fe.inChannels,$=Fe.outHeight,et=Fe.outWidth,gt=Fe.padInfo,lt=Fe.strideHeight,_t=Fe.strideWidth,At=Fe.filterHeight,Lt=Fe.filterWidth,Pt=Fe.dilationHeight,Ut=Fe.dilationWidth,Nt=Fe.outShape;i.util.assert(ee.rank===Nt.length,function(){return"Error in "+i.Dilation2DBackpropFilter+", dy "+("must have the same rank as output "+Nt.length+", but got ")+(""+ee.rank)});for(var Kt=i.util.toNestedArray(Nt,ve.data.get(ee.dataId).values),Ht=i.util.makeZerosNestedTypedArray(oe.shape,oe.dtype),Ot=0;Ot<Ve;++Ot)for(var Rt=0;Rt<$;++Rt)for(var wt=Rt*lt-gt.top,Et=0;Et<et;++Et)for(var Vt=Et*_t-gt.left,jt=0;jt<at;++jt){for(var cr=Number.MIN_SAFE_INTEGER,rr=0,Ie=0,br=0;br<At;++br){var Nr=wt+br*Pt;if(Nr>=0&&Nr<Xe)for(var Tr=0;Tr<Lt;++Tr){var hr=Vt+Tr*Ut;if(hr>=0&&hr<rt){var Dr=Re[Ot][Nr][hr][jt]+Oe[br][Tr][jt];Dr>cr&&(cr=Dr,rr=br,Ie=Tr)}}}Ht[rr][Ie][jt]+=Kt[Ot][Rt][Et][jt]}var fr=ve.write(i.util.toTypedArray(Ht,V.dtype),oe.shape,oe.dtype);return{dataId:fr,shape:oe.shape,dtype:oe.dtype}}},Fr={kernelName:i.Dilation2DBackpropInput,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.x,oe=A.filter,ee=A.dy,_e=F,ce=_e.strides,de=_e.pad,ye=_e.dilations,ve=E,Re=i.util.toNestedArray(V.shape,ve.data.get(V.dataId).values),Oe=i.util.toNestedArray(oe.shape,ve.data.get(oe.dataId).values),Fe=i.backend_util.computeDilation2DInfo(V.shape,oe.shape,ce,de,"NHWC",ye),Ve=Fe.batchSize,Xe=Fe.inHeight,rt=Fe.inWidth,at=Fe.inChannels,$=Fe.outHeight,et=Fe.outWidth,gt=Fe.padInfo,lt=Fe.strideHeight,_t=Fe.strideWidth,At=Fe.filterHeight,Lt=Fe.filterWidth,Pt=Fe.dilationHeight,Ut=Fe.dilationWidth,Nt=Fe.outShape;i.util.assert(ee.rank===Nt.length,function(){return"Error in "+i.Dilation2DBackpropInput+", dy "+("must have the same rank as output "+Nt.length+", but got ")+(""+ee.rank)});for(var Kt=i.util.toNestedArray(Nt,ve.data.get(ee.dataId).values),Ht=i.util.makeZerosNestedTypedArray(V.shape,V.dtype),Ot=0;Ot<Ve;++Ot)for(var Rt=0;Rt<$;++Rt)for(var wt=Rt*lt-gt.top,Et=0;Et<et;++Et)for(var Vt=Et*_t-gt.left,jt=0;jt<at;++jt){for(var cr=Number.MIN_SAFE_INTEGER,rr=wt<0?0:wt,Ie=Vt<0?0:Vt,br=0;br<At;++br){var Nr=wt+br*Pt;if(Nr>=0&&Nr<Xe)for(var Tr=0;Tr<Lt;++Tr){var hr=Vt+Tr*Ut;if(hr>=0&&hr<rt){var Dr=Re[Ot][Nr][hr][jt]+Oe[br][Tr][jt];Dr>cr&&(cr=Dr,rr=Nr,Ie=hr)}}}Ht[Ot][rr][Ie][jt]+=Kt[Ot][Rt][Et][jt]}var fr=ve.write(i.util.toTypedArray(Ht,V.dtype),V.shape,V.dtype);return{dataId:fr,shape:V.shape,dtype:V.dtype}}},wa=nt(function(ne,ue){return ne/ue}),In=ut(i.Div,wa),ur={kernelName:i.Div,backendName:"cpu",kernelFunc:In},$r=i.backend_util.ERF_P,Ra=i.backend_util.ERF_A1,mi=i.backend_util.ERF_A2,Ga=i.backend_util.ERF_A3,ja=i.backend_util.ERF_A4,ai=i.backend_util.ERF_A5,zi=_r(i.Erf,function(ne){var ue=Math.sign(ne),E=Math.abs(ne),F=1/(1+$r*E);return ue*(1-((((ai*F+ja)*F+Ga)*F+mi)*F+Ra)*F*Math.exp(-E*E))}),An={kernelName:i.Erf,backendName:"cpu",kernelFunc:zi};function ba(ne,ue,E){for(var F=ne.shape,A=F[0],V=F[1],oe=E.data.get(ne.dataId),ee=oe.complexTensorInfos.real,_e=oe.complexTensorInfos.imag,ce=[A,V],de=i.util.sizeFromShape(ce),ye=i.util.getTypedArrayFromDType("float32",de),ve=i.util.getTypedArrayFromDType("float32",de),Re=0;Re<A;Re++){for(var Oe=ti({inputs:{x:ee},backend:E,attrs:{begin:[Re,0],size:[1,V]}}),Fe=ti({inputs:{x:_e},backend:E,attrs:{begin:[Re,0],size:[1,V]}}),Ve=tt({inputs:{real:Oe,imag:Fe},backend:E}),Xe=qi(Ve,ue,E),rt=Xe.real,at=Xe.imag,$=i.backend_util.mergeRealAndImagArrays(rt,at),et=0;et<V;et++){var gt=i.backend_util.getComplexWithIndex($,et);ye[Re*V+et]=gt.real,ve[Re*V+et]=gt.imag}E.disposeIntermediateTensorInfo(Oe),E.disposeIntermediateTensorInfo(Fe),E.disposeIntermediateTensorInfo(Ve)}var lt=E.makeTensorInfo(ce,"float32",ye),_t=E.makeTensorInfo(ce,"float32",ve),At=tt({inputs:{real:lt,imag:_t},backend:E});return E.disposeIntermediateTensorInfo(lt),E.disposeIntermediateTensorInfo(_t),At}function qi(ne,ue,E){var F=i.util.sizeFromShape(ne.shape),A=E.data.get(ne.dataId),V=E.data.get(A.complexTensorInfos.real.dataId).values,oe=E.data.get(A.complexTensorInfos.imag.dataId).values;if(yi(F)){var ee=ii(V,oe,F,ue,E),_e=[ne.shape[0],ne.shape[1]];if(ue){var ce=E.makeTensorInfo(_e,"float32",ee.real),de=E.makeTensorInfo(_e,"float32",ee.imag),ye=E.makeTensorInfo([],"float32",i.util.createScalarValue(F,"float32")),ve=Tt({inputs:{x:ye},backend:E}),Re=ur.kernelFunc({inputs:{a:ce,b:ye},backend:E}),Oe=ur.kernelFunc({inputs:{a:de,b:ve},backend:E}),Fe=E.data.get(Re.dataId).values,Ve=E.data.get(Oe.dataId).values;return E.disposeIntermediateTensorInfo(ce),E.disposeIntermediateTensorInfo(de),E.disposeIntermediateTensorInfo(ye),E.disposeIntermediateTensorInfo(ve),E.disposeIntermediateTensorInfo(Re),E.disposeIntermediateTensorInfo(Oe),{real:Fe,imag:Ve}}return ee}else{var Xe=i.backend_util.mergeRealAndImagArrays(V,oe),rt=qr(Xe,F,ue);return i.backend_util.splitRealAndImagArrays(rt)}}function yi(ne){return(ne&ne-1)===0}function ii(ne,ue,E,F,A){if(E===1)return{real:ne,imag:ue};var V=i.backend_util.mergeRealAndImagArrays(ne,ue),oe=E/2,ee=i.backend_util.complexWithEvenIndex(V),_e=ee.real,ce=ee.imag,de=[_e.length],ye=A.makeTensorInfo(de,"float32",_e),ve=A.makeTensorInfo(de,"float32",ce),Re=tt({inputs:{real:ye,imag:ve},backend:A}),Oe=i.backend_util.complexWithOddIndex(V),Fe=Oe.real,Ve=Oe.imag,Xe=[Fe.length],rt=A.makeTensorInfo(Xe,"float32",Fe),at=A.makeTensorInfo(Xe,"float32",Ve),$=tt({inputs:{real:rt,imag:at},backend:A}),et=ii(_e,ce,oe,F,A),gt=et.real,lt=et.imag,_t=[gt.length],At=A.makeTensorInfo(_t,"float32",gt),Lt=A.makeTensorInfo(_t,"float32",lt),Pt=tt({inputs:{real:At,imag:Lt},backend:A}),Ut=ii(Fe,Ve,oe,F,A),Nt=Ut.real,Kt=Ut.imag,Ht=[Nt.length],Ot=A.makeTensorInfo(Ht,"float32",Nt),Rt=A.makeTensorInfo(Ht,"float32",Kt),wt=tt({inputs:{real:Ot,imag:Rt},backend:A}),Et=i.backend_util.exponents(E,F),Vt=[Et.real.length],jt=A.makeTensorInfo(Vt,"float32",Et.real),cr=A.makeTensorInfo(Vt,"float32",Et.imag),rr=tt({inputs:{real:jt,imag:cr},backend:A}),Ie=jn({inputs:{a:rr,b:wt},backend:A}),br=qt({inputs:{a:Pt,b:Ie},backend:A}),Nr=pi({inputs:{a:Pt,b:Ie},backend:A}),Tr=it({inputs:{input:br},backend:A}),hr=it({inputs:{input:Nr},backend:A}),Dr=tn({inputs:{input:br},backend:A}),fr=tn({inputs:{input:Nr},backend:A}),Er=Kn({inputs:[Tr,hr],backend:A,attrs:{axis:0}}),an=Kn({inputs:[Dr,fr],backend:A,attrs:{axis:0}}),wn=A.data.get(Er.dataId).values,ie=A.data.get(an.dataId).values;return A.disposeIntermediateTensorInfo(ye),A.disposeIntermediateTensorInfo(ve),A.disposeIntermediateTensorInfo(Re),A.disposeIntermediateTensorInfo(rt),A.disposeIntermediateTensorInfo(at),A.disposeIntermediateTensorInfo($),A.disposeIntermediateTensorInfo(At),A.disposeIntermediateTensorInfo(Lt),A.disposeIntermediateTensorInfo(Pt),A.disposeIntermediateTensorInfo(Ot),A.disposeIntermediateTensorInfo(Rt),A.disposeIntermediateTensorInfo(wt),A.disposeIntermediateTensorInfo(jt),A.disposeIntermediateTensorInfo(cr),A.disposeIntermediateTensorInfo(rr),A.disposeIntermediateTensorInfo(Ie),A.disposeIntermediateTensorInfo(br),A.disposeIntermediateTensorInfo(Nr),A.disposeIntermediateTensorInfo(Tr),A.disposeIntermediateTensorInfo(Dr),A.disposeIntermediateTensorInfo(hr),A.disposeIntermediateTensorInfo(fr),A.disposeIntermediateTensorInfo(Er),A.disposeIntermediateTensorInfo(an),{real:wn,imag:ie}}function qr(ne,ue,E){for(var F=new Float32Array(ue*2),A=0;A<ue;A++){for(var V=0,oe=0,ee=0;ee<ue;ee++){var _e=i.backend_util.exponent(A*ee,ue,E),ce=i.backend_util.getComplexWithIndex(ne,ee);V+=ce.real*_e.real-ce.imag*_e.imag,oe+=ce.real*_e.imag+ce.imag*_e.real}E&&(V/=ue,oe/=ue),i.backend_util.assignToTypedArray(F,V,oe,A)}return F}function Io(ne){var ue=ne.inputs,E=ne.backend,F=ue.input,A=i.util.sizeFromShape(F.shape),V=F.shape[F.shape.length-1],oe=A/V,ee=da({inputs:{x:F},backend:E,attrs:{shape:[oe,V]}}),_e=ba(ee,!1,E),ce=da({inputs:{x:_e},backend:E,attrs:{shape:F.shape}});return E.disposeIntermediateTensorInfo(ee),E.disposeIntermediateTensorInfo(_e),ce}var nn={kernelName:i.FFT,backendName:"cpu",kernelFunc:Io};function qa(ne){var ue=ne.backend,E=ne.attrs,F=E.shape,A=E.value,V=E.dtype,oe=V||i.util.inferDtype(A),ee=i.util.getArrayFromDType(oe,i.util.sizeFromShape(F));return Ki(ee,A,oe),ue.makeTensorInfo(F,oe,ee)}var La={kernelName:i.Fill,backendName:"cpu",kernelFunc:qa};function Ki(ne,ue,E){E==="string",ne.fill(ue)}var oi={kernelName:i.FlipLeftRight,backendName:"cpu",kernelFunc:function(ne){for(var ue=ne.inputs,E=ne.attrs,F=ne.backend,A=ue.image,V=F,oe=i.util.getTypedArrayFromDType(A.dtype,i.util.sizeFromShape(A.shape)),ee=A.shape,_e=ee[0],ce=ee[1],de=ee[2],ye=ee[3],ve=V.data.get(A.dataId).values,Re=0;Re<_e;Re++)for(var Oe=Re*de*ce*ye,Fe=0;Fe<ce;Fe++)for(var Ve=Fe*(de*ye),Xe=0;Xe<de;Xe++)for(var rt=Xe*ye,at=0;at<ye;at++){var $=[_e,Fe,Xe,at],et=$[2],gt=Math.round(de-et),lt=Oe+Ve+rt+at,_t=ve[lt];if(gt>=0&&gt<de){var At=gt*ye,Lt=Oe+Ve+At+at;_t=ve[Lt]}oe[lt]=_t}var Pt=V.write(oe,A.shape,A.dtype);return{dataId:Pt,shape:A.shape,dtype:A.dtype}}};function Pi(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.filter,oe=ue.bias,ee=ue.preluActivationWeights,_e=F.strides,ce=F.pad,de=F.dataFormat,ye=F.dilations,ve=F.dimRoundingMode,Re=F.activation,Oe=ma({inputs:{x:A,filter:V},backend:E,attrs:{strides:_e,pad:ce,dataFormat:de,dilations:ye,dimRoundingMode:ve}});if(oe){var Fe=Oe;Oe=qt({inputs:{a:Oe,b:oe},backend:E}),E.disposeIntermediateTensorInfo(Fe)}if(Re){var Fe=Oe;Oe=Oi(E,Oe,Re,ee),E.disposeIntermediateTensorInfo(Fe)}return Oe}var no={kernelName:i.FusedConv2D,backendName:"cpu",kernelFunc:Pi};function mo(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.filter,oe=ue.bias,ee=ue.preluActivationWeights,_e=F.strides,ce=F.pad,de=F.dataFormat,ye=F.dilations,ve=F.dimRoundingMode,Re=F.activation,Oe=Qt({inputs:{x:A,filter:V},backend:E,attrs:{strides:_e,pad:ce,dataFormat:de,dilations:ye,dimRoundingMode:ve}});if(oe){var Fe=Oe;Oe=qt({inputs:{a:Oe,b:oe},backend:E}),E.disposeIntermediateTensorInfo(Fe)}if(Re){var Fe=Oe;Oe=Oi(E,Oe,Re,ee),E.disposeIntermediateTensorInfo(Fe)}return Oe}var Ka={kernelName:i.FusedDepthwiseConv2D,backendName:"cpu",kernelFunc:mo};function ao(ne){var ue=ne.inputs,E=ne.backend,F=ue.input,A=i.util.sizeFromShape(F.shape),V=F.shape[F.shape.length-1],oe=A/V,ee=da({inputs:{x:F},backend:E,attrs:{shape:[oe,V]}}),_e=ba(ee,!0,E),ce=da({inputs:{x:_e},backend:E,attrs:{shape:F.shape}});return E.disposeIntermediateTensorInfo(ee),E.disposeIntermediateTensorInfo(_e),ce}var Ko={kernelName:i.IFFT,backendName:"cpu",kernelFunc:ao},No=_r(i.IsFinite,function(ne){return Number.isFinite(ne)?1:0},"bool"),Co={kernelName:i.IsFinite,backendName:"cpu",kernelFunc:No},io=_r(i.IsInf,function(ne){return Math.abs(ne)===Infinity?1:0},"bool"),ia={kernelName:i.IsInf,backendName:"cpu",kernelFunc:io},Pr=_r(i.IsNan,function(ne){return Number.isNaN(ne)?1:0},"bool"),oa={kernelName:i.IsNan,backendName:"cpu",kernelFunc:Pr},Xa=_r(i.Log1p,function(ne){return Math.log1p(ne)}),Qn={kernelName:i.Log1p,backendName:"cpu",kernelFunc:Xa},oo=_r(i.LogicalNot,function(ne){return ne?0:1},"bool"),ka={kernelName:i.LogicalNot,backendName:"cpu",kernelFunc:oo},vn={kernelName:i.Max,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.attrs,F=ne.backend,A=ue.x,V=E,oe=V.reductionIndices,ee=V.keepDims,_e=F,ce=A.shape,de=ce.length,ye=i.util.parseAxisParam(oe,ce),ve=ye,Re=i.backend_util.getAxesPermutation(ve,de),Oe=_e.data.get(A.dataId).values;if(Re!=null){for(var Fe=new Array(de),Ve=0;Ve<Fe.length;Ve++)Fe[Ve]=ce[Re[Ve]];Oe=di(Oe,ce,A.dtype,Re,Fe),ve=i.backend_util.getInnerMostAxes(ve.length,de),ce=Fe}Q(A,"max"),i.backend_util.assertAxesAreInnerMostDims("max",ve,de);var Xe=i.backend_util.computeOutAndReduceShapes(ce,ve),rt=Xe[0],at=Xe[1],$=i.util.sizeFromShape(at),et=ha(Oe,$,rt,A.dtype),gt=_e.write(et,rt,A.dtype),lt=rt;if(ee){var Fe=i.backend_util.expandShapeToKeepDim(rt,ye);lt=Fe}return{dataId:gt,shape:lt,dtype:A.dtype}}};function Bi(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x;Q(A,"maxPool");var V=F.filterSize,oe=F.strides,ee=F.pad,_e=F.dimRoundingMode,ce=1;i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(oe,ce),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+oe+" and dilations '"+ce+"'")});var de=i.backend_util.computePool2DInfo(A.shape,V,oe,ce,ee,_e),ye;if(de.filterWidth===1&&de.filterHeight===1&&i.util.arraysEqual(de.inShape,de.outShape))ye=Tt({inputs:{x:A},backend:E});else{var ve=E.data.get(A.dataId).values,Re=i.util.computeStrides(A.shape),Oe=fa(ve,A.shape,A.dtype,Re,de,"max");ye=E.makeTensorInfo(de.outShape,A.dtype,Oe.values)}return ye}var yo={kernelName:i.MaxPool,backendName:"cpu",kernelFunc:Bi};function vo(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.dy,V=ue.input,oe=ue.output,ee=V;Q([V,oe],"maxPoolBackprop");for(var _e=F.filterSize,ce=F.strides,de=F.pad,ye=F.dimRoundingMode,ve=i.backend_util.computePool2DInfo(ee.shape,_e,ce,1,de,ye),Re=E.data.get(ee.dataId).values,Oe=i.buffer(ve.outShape,ee.dtype,ra(Re,ee.shape,ee.dtype,ve).values),Fe=ve.strideHeight,Ve=ve.strideWidth,Xe=ve.dilationHeight,rt=ve.dilationWidth,at=ve.effectiveFilterHeight,$=ve.effectiveFilterWidth,et=$-1-ve.padInfo.left,gt=at-1-ve.padInfo.top,lt=i.buffer(ee.shape,"float32"),_t=E.data.get(A.dataId).values,At=i.buffer(A.shape,"float32",_t),Lt=0;Lt<ve.batchSize;++Lt)for(var Pt=0;Pt<ve.inChannels;++Pt)for(var Ut=0;Ut<ve.inHeight;++Ut)for(var Nt=0;Nt<ve.inWidth;++Nt){for(var Kt=Ut-gt,Ht=Nt-et,Ot=0,Rt=0;Rt<at;Rt+=Xe){var wt=(Kt+Rt)/Fe;if(wt<0||wt>=ve.outHeight||Math.floor(wt)!==wt)continue;for(var Et=0;Et<$;Et+=rt){var Vt=(Ht+Et)/Ve;if(Vt<0||Vt>=ve.outWidth||Math.floor(Vt)!==Vt)continue;var jt=at*$-1-Oe.get(Lt,wt,Vt,Pt),cr=Rt*$+Et,rr=jt===cr?1:0;if(rr===0)continue;var Ie=At.get(Lt,wt,Vt,Pt);Ot+=Ie*rr}}lt.set(Ot,Lt,Ut,Nt,Pt)}return E.makeTensorInfo(lt.shape,lt.dtype,lt.values)}var Aa={kernelName:i.MaxPoolBackprop,backendName:"cpu",kernelFunc:vo};function go(ne,ue,E,F,A){var V=i.util.computeStrides(ue),oe=fa(ne,ue,E,V,A,"max"),ee=ra(ne,ue,E,A,!0,F);return[oe.values,ee.values]}var To={kernelName:i.MaxPoolWithArgmax,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.attrs,F=ne.backend,A=ue.x,V=E,oe=V.filterSize,ee=V.strides,_e=V.pad,ce=V.includeBatchInIndex,de=F;Q(A,"MaxPoolWithArgmax");var ye=de.data.get(A.dataId).values,ve=i.backend_util.computePool2DInfo(A.shape,oe,ee,[1,1],_e),Re=go(ye,A.shape,A.dtype,ce,ve),Oe=Re[0],Fe=Re[1],Ve=de.write(Oe,ve.outShape,A.dtype),Xe=de.write(Fe,ve.outShape,A.dtype);return[{dataId:Ve,shape:ve.outShape,dtype:A.dtype},{dataId:Xe,shape:ve.outShape,dtype:"int32"}]}};function Rs(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.paddings,oe=F.mode;Q(A,"mirrorPad");for(var ee=V.map(function(lt,_t){return lt[0]+A.shape[_t]+lt[1]}),_e=V.map(function(lt){return lt[0]}),ce=V.map(function(lt,_t){return lt[0]+A.shape[_t]}),de=oe==="reflect"?0:1,ye=E.data.get(A.dataId).values,ve=A.shape.length,Re=i.util.computeStrides(A.shape),Oe=i.util.sizeFromShape(ee),Fe=ee.length,Ve=i.util.computeStrides(ee),Xe=i.util.getTypedArrayFromDType(A.dtype,Oe),rt=0;rt<Oe;rt++){for(var at=i.util.indexToLoc(rt,Fe,Ve),$=0;$<Fe;$++)at[$]<_e[$]?at[$]=_e[$]*2-at[$]-de:at[$]>=ce[$]&&(at[$]=(ce[$]-1)*2-at[$]+de);at=at.map(function(lt,_t){return lt-_e[_t]});var et=i.util.locToIndex(at,ve,Re);Xe[rt]=ye[et]}var gt=E.write(Xe,ee,A.dtype);return{dataId:gt,shape:ee,dtype:A.dtype}}var Eo={kernelName:i.MirrorPad,backendName:"cpu",kernelFunc:Rs},As=i.kernel_impls.nonMaxSuppressionV4Impl,Ds={kernelName:i.NonMaxSuppressionV4,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.boxes,oe=A.scores,ee=F,_e=ee.maxOutputSize,ce=ee.iouThreshold,de=ee.scoreThreshold,ye=ee.padToMaxOutputSize,ve=E;Q(V,"NonMaxSuppressionPadded");var Re=ve.data.get(V.dataId).values,Oe=ve.data.get(oe.dataId).values,Fe=As(Re,Oe,_e,ce,de,ye),Ve=Fe.selectedIndices,Xe=Fe.validOutputs;return[Ve,Xe]}},Xo=i.kernel_impls.nonMaxSuppressionV5Impl,Ro={kernelName:i.NonMaxSuppressionV5,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.boxes,oe=A.scores,ee=F,_e=ee.maxOutputSize,ce=ee.iouThreshold,de=ee.scoreThreshold,ye=ee.softNmsSigma,ve=E;Q(V,"NonMaxSuppressionWithScore");var Re=ve.data.get(V.dataId).values,Oe=ve.data.get(oe.dataId).values,Fe=_e,Ve=ce,Xe=de,rt=ye,at=Xo(Re,Oe,Fe,Ve,Xe,rt),$=at.selectedIndices,et=at.selectedScores;return[$,et]}};function Yo(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.paddings,oe=F.constantValue;Q(A,"pad");var ee=V.map(function(gt,lt){return gt[0]+A.shape[lt]+gt[1]}),_e=V.map(function(gt){return gt[0]}),ce=E.data.get(A.dataId).values,de=i.util.sizeFromShape(A.shape),ye=A.shape.length,ve=i.util.computeStrides(A.shape),Re=i.util.sizeFromShape(ee),Oe=ee.length,Fe=i.util.computeStrides(ee),Ve=i.util.getTypedArrayFromDType(A.dtype,Re);oe!==0&&Ve.fill(oe);for(var Xe=0;Xe<de;Xe++){var rt=i.util.indexToLoc(Xe,ye,ve),at=rt.map(function(gt,lt){return gt+_e[lt]}),$=i.util.locToIndex(at,Oe,Fe);Ve[$]=ce[Xe]}var et=E.write(Ve,ee,A.dtype);return{dataId:et,shape:ee,dtype:A.dtype}}var Ao={kernelName:i.PadV2,backendName:"cpu",kernelFunc:Yo},Qo=_r(i.Reciprocal,function(ne){return 1/ne}),vi={kernelName:i.Reciprocal,backendName:"cpu",kernelFunc:Qo},Fs={kernelName:i.RotateWithOffset,backendName:"cpu",kernelFunc:function(ne){for(var ue=ne.inputs,E=ne.attrs,F=ne.backend,A=ue.image,V=E,oe=V.radians,ee=V.fillValue,_e=V.center,ce=F,de=i.util.getTypedArrayFromDType(A.dtype,i.util.sizeFromShape(A.shape)),ye=A.shape,ve=ye[0],Re=ye[1],Oe=ye[2],Fe=ye[3],Ve=i.backend_util.getImageCenter(_e,Re,Oe),Xe=Ve[0],rt=Ve[1],at=255,$=Math.sin(oe),et=Math.cos(oe),gt=ce.data.get(A.dataId).values,lt=0;lt<ve;lt++)for(var _t=lt*Oe*Re*Fe,At=0;At<Re;At++)for(var Lt=At*(Oe*Fe),Pt=0;Pt<Oe;Pt++)for(var Ut=Pt*Fe,Nt=0;Nt<Fe;Nt++){var Kt=[ve,At,Pt,Nt],Ht=Kt[2],Ot=Kt[1],Rt=(Ht-Xe)*et-(Ot-rt)*$,wt=(Ht-Xe)*$+(Ot-rt)*et;Rt=Math.round(Rt+Xe),wt=Math.round(wt+rt);var Et=ee;if(typeof ee!="number"&&(Nt===3?Et=at:Et=ee[Nt]),Rt>=0&&Rt<Oe&&wt>=0&&wt<Re){var Vt=wt*(Oe*Fe),jt=Rt*Fe,cr=_t+Vt+jt+Nt;Et=gt[cr]}var rr=_t+Lt+Ut+Nt;de[rr]=Et}var Ie=ce.write(de,A.shape,A.dtype);return{dataId:Ie,shape:A.shape,dtype:A.dtype}}},tu=_r(i.Round,function(ne){var ue=Math.floor(ne);return ne-ue<.5?Math.floor(ne):ne-ue>.5?Math.ceil(ne):ue%2===0?ue:ue+1}),ps={kernelName:i.Round,backendName:"cpu",kernelFunc:tu},ru=i.backend_util.SELU_SCALEALPHA,Os=i.backend_util.SELU_SCALE,ds=_r(i.Selu,function(ne){return ne>=0?Os*ne:ru*(Math.exp(ne)-1)}),Ms={kernelName:i.Selu,backendName:"cpu",kernelFunc:ds},Ls=_r(i.Sigmoid,function(ne){return 1/(1+Math.exp(-ne))}),nu={kernelName:i.Sigmoid,backendName:"cpu",kernelFunc:Ls},fs=_r(i.Sign,function(ne){return ne<0?-1:ne>0?1:0}),au={kernelName:i.Sign,backendName:"cpu",kernelFunc:fs},ms=_r(i.Sin,function(ne){return Math.sin(ne)}),Do={kernelName:i.Sin,backendName:"cpu",kernelFunc:ms},zs=_r(i.Sinh,function(ne){return Math.sinh(ne)}),Zo={kernelName:i.Sinh,backendName:"cpu",kernelFunc:zs},xo=11920928955078125e-23,ys=Math.log(xo)+2,Fo=_r(i.Softplus,function(ne){var ue=ne>-ys,E=ne<ys,F=Math.exp(ne),A;return E?A=F:ue?A=ne:A=Math.log(1+F),A}),Ps={kernelName:i.Softplus,backendName:"cpu",kernelFunc:Fo};function Jo(ne){var ue=ne.inputs,E=ne.attrs,F=ne.backend,A=ue.x,V=E.perm;Q(A,"transpose");for(var oe=A.shape.length,ee=new Array(oe),_e=0;_e<ee.length;_e++)ee[_e]=A.shape[V[_e]];var ce=F.data.get(A.dataId).values,de=di(ce,A.shape,A.dtype,V,ee),ye=F.write(de,ee,A.dtype);return{dataId:ye,shape:ee,dtype:A.dtype}}var _o={kernelName:i.Transpose,backendName:"cpu",kernelFunc:Jo};function wo(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.blockShape,oe=F.paddings;Q([A],"spaceToBatchND");var ee=i.util.sizeFromShape(V),_e=[[0,0]];_e.push.apply(_e,oe);for(var ce=1+V.length;ce<A.shape.length;++ce)_e.push([0,0]);var de=Ao.kernelFunc({inputs:{x:A},backend:E,attrs:{paddings:_e,constantValue:0}}),ye=i.backend_util.getReshaped(de.shape,V,ee,!1),ve=i.backend_util.getPermuted(ye.length,V.length,!1),Re=i.backend_util.getReshapedPermuted(de.shape,V,ee,!1),Oe={x:de},Fe={shape:ye},Ve=da({inputs:Oe,backend:E,attrs:Fe}),Xe={x:Ve},rt={perm:ve},at=Jo({inputs:Xe,backend:E,attrs:rt}),$={x:at},et={shape:Re},gt=da({inputs:$,backend:E,attrs:et});return E.disposeIntermediateTensorInfo(de),E.disposeIntermediateTensorInfo(Ve),E.disposeIntermediateTensorInfo(at),gt}var Bs={kernelName:i.SpaceToBatchND,backendName:"cpu",kernelFunc:wo},Ws=_r(i.Sqrt,function(ne){return Math.sqrt(ne)}),vs={kernelName:i.Sqrt,backendName:"cpu",kernelFunc:Ws},$o={kernelName:i.Square,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ue.x,A=E;Q(F,"square");for(var V=A.data.get(F.dataId).values,oe=new Float32Array(V.length),ee=0;ee<V.length;++ee){var _e=V[ee];oe[ee]=_e*_e}var ce=A.write(oe,F.shape,F.dtype);return{dataId:ce,shape:F.shape,dtype:F.dtype}}},iu=_r(i.Step,function(ne,ue){var E=ue;return isNaN(ne)?NaN:ne>0?1:E.alpha}),ku={kernelName:i.Step,backendName:"cpu",kernelFunc:iu},ou=_r(i.Tan,function(ne){return Math.tan(ne)}),Oo={kernelName:i.Tan,backendName:"cpu",kernelFunc:ou},Mo=_r(i.Tanh,function(ne){return Math.tanh(ne)}),gs={kernelName:i.Tanh,backendName:"cpu",kernelFunc:Mo};function es(ne){var ue=ne.inputs,E=ne.attrs,F=ne.backend,A=E.axis,V=ue.x;Q(V,"unique");var oe=F.data.get(V.dataId).values,ee=fi(oe,A,V.shape,V.dtype),_e=ee.outputValues,ce=ee.outputShape,de=ee.indices;return[F.makeTensorInfo(ce,V.dtype,_e),F.makeTensorInfo([de.length],"int32",de)]}for(var Si={kernelName:i.Unique,backendName:"cpu",kernelFunc:es},Lo=[re,W,Ue,$e,Ur,Ye,St,dr,ta,ki,hn,X,Jr,ht,Tn,Jn,nr,aa,S,k,Li,Je,vt,Se,zt,Gt,wr,Yt,Sn,pn,Fr,zn,ur,gr,An,yn,hi,nn,La,oi,Ca,no,Ka,Qe,Ko,Rn,Co,ia,oa,_i,Qn,ka,yo,Aa,To,vn,Eo,Ua,Ds,Ro,Ta,Ao,ro,xt,vi,Gi,ji,Mi,Fs,ps,xa,Ms,nu,au,Do,Zo,_a,Ps,Bs,vs,$o,Ai,ku,pa,Oo,gs,_o,Si],zo=0,Xi=Lo;zo<Xi.length;zo++){var ts=Xi[zo];i.registerKernel(ts)}N.MathBackendCPU=w,N.shared=Va,N.version_cpu=ln}),xg=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=function(f,p){return ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,m){l.__proto__=m}||function(l,m){for(var g in m)m.hasOwnProperty(g)&&(l[g]=m[g])},ke(f,p)};function O(f,p){ke(f,p);function l(){this.constructor=f}f.prototype=p===null?Object.create(p):(l.prototype=p.prototype,new l)}function H(f,p,l,m){function g(I){return I instanceof l?I:new l(function(R){R(I)})}return new(l||(l=Promise))(function(I,R){function z(Z){try{G(m.next(Z))}catch(be){R(be)}}function L(Z){try{G(m.throw(Z))}catch(be){R(be)}}function G(Z){Z.done?I(Z.value):g(Z.value).then(z,L)}G((m=m.apply(f,p||[])).next())})}function se(f,p){var l={label:0,sent:function(){if(I[0]&1)throw I[1];return I[1]},trys:[],ops:[]},m,g,I,R;return R={next:z(0),throw:z(1),return:z(2)},typeof Symbol=="function"&&(R[Symbol.iterator]=function(){return this}),R;function z(G){return function(Z){return L([G,Z])}}function L(G){if(m)throw new TypeError("Generator is already executing.");for(;l;)try{if(m=1,g&&(I=G[0]&2?g.return:G[0]?g.throw||((I=g.return)&&I.call(g),0):g.next)&&!(I=I.call(g,G[1])).done)return I;(g=0,I)&&(G=[G[0]&2,I.value]);switch(G[0]){case 0:case 1:I=G;break;case 4:return l.label++,{value:G[1],done:!1};case 5:l.label++,g=G[1],G=[0];continue;case 7:G=l.ops.pop(),l.trys.pop();continue;default:if(!(I=l.trys,I=I.length>0&&I[I.length-1])&&(G[0]===6||G[0]===2)){l=0;continue}if(G[0]===3&&(!I||G[1]>I[0]&&G[1]<I[3])){l.label=G[1];break}if(G[0]===6&&l.label<I[1]){l.label=I[1],I=G;break}if(I&&l.label<I[2]){l.label=I[2],l.ops.push(G);break}I[2]&&l.ops.pop(),l.trys.pop();continue}G=p.call(f,l)}catch(Z){G=[6,Z],g=0}finally{m=I=0}if(G[0]&5)throw G[1];return{value:G[0]?G[1]:void 0,done:!0}}}var xe={},Q={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Ae(f,p){xe[f]=p}function P(f){if(!(f in xe)){var p=me(f);if(p!==null)xe[f]=p;else return console.log("Could not get context for WebGL version",f),null}var l=xe[f];return l.isContextLost()?(delete xe[f],P(f)):(l.disable(l.DEPTH_TEST),l.disable(l.STENCIL_TEST),l.disable(l.BLEND),l.disable(l.DITHER),l.disable(l.POLYGON_OFFSET_FILL),l.disable(l.SAMPLE_COVERAGE),l.enable(l.SCISSOR_TEST),l.enable(l.CULL_FACE),l.cullFace(l.BACK),xe[f])}function he(f){if(typeof OffscreenCanvas!="undefined"&&f===2)return new OffscreenCanvas(300,150);if(typeof document!="undefined")return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function me(f){if(f!==1&&f!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var p=he(f);return p.addEventListener("webglcontextlost",function(l){l.preventDefault(),delete xe[f]},!1),f===1?p.getContext("webgl",Q)||p.getContext("experimental-webgl",Q):p.getContext("webgl2",Q)}var ae;(function(f){f[f.DENSE=0]="DENSE",f[f.SHARED_BATCH=1]="SHARED_BATCH"})(ae||(ae={}));var w;(function(f){f[f.RENDER=0]="RENDER",f[f.UPLOAD=1]="UPLOAD",f[f.PIXELS=2]="PIXELS",f[f.DOWNLOAD=3]="DOWNLOAD"})(w||(w={}));var ge;(function(f){f[f.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",f[f.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",f[f.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",f[f.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",f[f.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})(ge||(ge={}));function ze(f,p){return[p,f]}function W(f,p){return f*p}function nt(f){var p=i.util.sizeFromShape(f),l=Math.ceil(p/4);return i.util.sizeToSquarishShape(l)}function tt(f,p){return[Math.max(1,Math.ceil(p/2)),Math.max(1,Math.ceil(f/2))]}function nr(f,p){var l=tt(f,p),m=l[0],g=l[1];return m*g*4}function Tt(f,p){var l=f,m,g,I,R,z,L,G,Z,be,Ce;return i.env().getNumber("WEBGL_VERSION")===2?(m=l.R32F,g=l.R16F,I=l.RGBA16F,R=l.RGBA32F,z=l.RED,G=4,Z=1,be=l.HALF_FLOAT,Ce=l.FLOAT):(m=f.RGBA,g=f.RGBA,I=f.RGBA,R=l.RGBA,z=f.RGBA,G=4,Z=4,be=p!=null?p.HALF_FLOAT_OES:null,Ce=f.FLOAT),L=f.RGBA,{internalFormatFloat:m,internalFormatHalfFloat:g,internalFormatPackedHalfFloat:I,internalFormatPackedFloat:R,textureFormatFloat:z,downloadTextureFormat:L,downloadUnpackNumChannels:G,defaultNumChannels:Z,textureTypeHalfFloat:be,textureTypeFloat:Ce}}function Qe(f,p){var l=p();return i.env().getBool("DEBUG")&&it(f),l}function it(f){var p=f.getError();if(p!==f.NO_ERROR)throw new Error("WebGL Error: "+ut(f,p))}var xt=596e-10,ot=65504;function ht(f){return!!(i.env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||f===0||xt<Math.abs(f)&&Math.abs(f)<ot)}function ut(f,p){switch(p){case f.NO_ERROR:return"NO_ERROR";case f.INVALID_ENUM:return"INVALID_ENUM";case f.INVALID_VALUE:return"INVALID_VALUE";case f.INVALID_OPERATION:return"INVALID_OPERATION";case f.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case f.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case f.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"Unknown error code "+p}}function yt(f,p){return Gn(f,function(){return f.getExtension(p)},'Extension "'+p+'" not supported on this browser.')}function Zt(f,p){var l=Gn(f,function(){return f.createShader(f.VERTEX_SHADER)},"Unable to create vertex WebGLShader.");if(Qe(f,function(){return f.shaderSource(l,p)}),Qe(f,function(){return f.compileShader(l)}),f.getShaderParameter(l,f.COMPILE_STATUS)===!1)throw console.log(f.getShaderInfoLog(l)),new Error("Failed to compile vertex shader.");return l}function ar(f,p){var l=Gn(f,function(){return f.createShader(f.FRAGMENT_SHADER)},"Unable to create fragment WebGLShader.");if(Qe(f,function(){return f.shaderSource(l,p)}),Qe(f,function(){return f.compileShader(l)}),f.getShaderParameter(l,f.COMPILE_STATUS)===!1)throw Ur(p,f.getShaderInfoLog(l)),new Error("Failed to compile fragment shader.");return l}var qt=/ERROR: [0-9]+:([0-9]+):/g;function Ur(f,p){var l=qt.exec(p);if(l==null){console.log("Couldn't parse line number in error: "+p),console.log(f);return}for(var m=+l[1],g=f.split(`
`),I=g.length.toString().length+2,R=g.map(function(Ce,De){return i.util.rightPad((De+1).toString(),I)+Ce}),z=0,L=0;L<R.length;L++)z=Math.max(R[L].length,z);var G=R.slice(0,m-1),Z=R.slice(m-1,m),be=R.slice(m);console.log(G.join(`
`)),console.log(p.split(`
`)[0]),console.log("%c "+i.util.rightPad(Z[0],z),"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(be.join(`
`))}function jr(f){return Gn(f,function(){return f.createProgram()},"Unable to create WebGLProgram.")}function _r(f,p){if(Qe(f,function(){return f.linkProgram(p)}),f.getProgramParameter(p,f.LINK_STATUS)===!1)throw console.log(f.getProgramInfoLog(p)),new Error("Failed to link vertex and fragment shaders.")}function tr(f,p){if(Qe(f,function(){return f.validateProgram(p)}),f.getProgramParameter(p,f.VALIDATE_STATUS)===!1)throw console.log(f.getProgramInfoLog(p)),new Error("Shader program validation failed.")}function Fa(f,p){var l=Gn(f,function(){return f.createBuffer()},"Unable to create WebGLBuffer");return Qe(f,function(){return f.bindBuffer(f.ARRAY_BUFFER,l)}),Qe(f,function(){return f.bufferData(f.ARRAY_BUFFER,p,f.STATIC_DRAW)}),l}function Oa(f,p){var l=Gn(f,function(){return f.createBuffer()},"Unable to create WebGLBuffer");return Qe(f,function(){return f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,l)}),Qe(f,function(){return f.bufferData(f.ELEMENT_ARRAY_BUFFER,p,f.STATIC_DRAW)}),l}function Tn(){return i.env().getNumber("WEBGL_VERSION")===2?1:4}function Wa(f){return Gn(f,function(){return f.createTexture()},"Unable to create WebGLTexture.")}function Na(f,p){var l=i.env().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(f<=0||p<=0){var m="["+f+"x"+p+"]";throw new Error("Requested texture size "+m+" is invalid.")}if(f>l||p>l){var m="["+f+"x"+p+"]",g="["+l+"x"+l+"]";throw new Error("Requested texture size "+m+" greater than WebGL maximum on this browser / GPU "+g+".")}}function yn(f){return Gn(f,function(){return f.createFramebuffer()},"Unable to create WebGLFramebuffer.")}function Ma(f,p,l,m,g,I,R){var z=f.getAttribLocation(p,l);return z===-1?!1:(Qe(f,function(){return f.bindBuffer(f.ARRAY_BUFFER,m)}),Qe(f,function(){return f.vertexAttribPointer(z,g,f.FLOAT,!1,I,R)}),Qe(f,function(){return f.enableVertexAttribArray(z)}),!0)}function li(f,p,l){jn(f,l),Qe(f,function(){return f.activeTexture(f.TEXTURE0+l)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,p)})}function hi(f,p){jn(f,p),Qe(f,function(){return f.activeTexture(f.TEXTURE0+p)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function la(f,p,l){return Gn(f,function(){return f.getUniformLocation(p,l)},'uniform "'+l+'" not present in program.')}function rn(f,p,l){return f.getUniformLocation(p,l)}function Ca(f,p,l,m){Qe(f,function(){return li(f,p,m)}),Qe(f,function(){return f.uniform1i(l,m)})}function xn(f){Qe(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,null)}),Qe(f,function(){return f.viewport(0,0,f.canvas.width,f.canvas.height)}),Qe(f,function(){return f.scissor(0,0,f.canvas.width,f.canvas.height)})}function Hn(f,p,l){Qe(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,l)}),Qe(f,function(){return f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,p,0)})}function _i(f,p){Qe(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,p)}),Qe(f,function(){return f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,null,0)})}function ha(f){var p=f.checkFramebufferStatus(f.FRAMEBUFFER);if(p!==f.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+Ei(f,p))}function Ei(f,p){switch(p){case f.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case f.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case f.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case f.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+p}}function Gn(f,p,l){var m=Qe(f,function(){return p()});if(m==null)throw new Error(l);return m}function jn(f,p){var l=f.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,m=p+f.TEXTURE0;if(m<f.TEXTURE0||m>l){var g="[gl.TEXTURE0, gl.TEXTURE"+l+"]";throw new Error("textureUnit must be in "+g+".")}}function Ua(f,p){return p===void 0&&(p=2),i.util.sizeFromShape(f.slice(0,f.length-p))}function ga(f){if(f.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[f.length>1?f[f.length-2]:1,f[f.length-1]]}function wi(f){var p=[1,1,1],l=f.length===0||f.length===1&&f[0]===1;return l||(p=[Ua(f)].concat(ga(f))),p}function Ta(f,p){var l;p===void 0&&(p=!1);var m=i.env().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(p&&(m=m*2,f=f.map(function(G,Z){return Z>=f.length-2?i.util.nearestLargerEven(f[Z]):f[Z]}),f.length===1&&(f=[2,f[0]])),f.length!==2){var g=i.util.squeezeShape(f);f=g.newShape}var I=i.util.sizeFromShape(f);if(f.length<=1&&I<=m)return[1,I];if(f.length===2&&f[0]<=m&&f[1]<=m)return f;if(f.length===3&&f[0]*f[1]<=m&&f[2]<=m)return[f[0]*f[1],f[2]];if(f.length===3&&f[0]<=m&&f[1]*f[2]<=m)return[f[0],f[1]*f[2]];if(f.length===4&&f[0]*f[1]*f[2]<=m&&f[3]<=m)return[f[0]*f[1]*f[2],f[3]];if(f.length===4&&f[0]<=m&&f[1]*f[2]*f[3]<=m)return[f[0],f[1]*f[2]*f[3]];if(p){var R=Ua(f),z=2,L=2;return f.length&&(l=ga(f),z=l[0],L=l[1]),I=R*(z/2)*(L/2),i.util.sizeToSquarishShape(I).map(function(G){return G*2})}return i.util.sizeToSquarishShape(I)}function on(f){return f%2===0}function _n(f,p){if(f=f.slice(-2),p=p.slice(-2),i.util.arraysEqual(f,p))return!0;if(!f.length||!p.length)return!0;if(f[0]===0||f[1]===0||p[0]===0||p[1]===0)return!0;if(f.length!==p.length){var l=f.slice(-1)[0],m=p.slice(-1)[0];if(l===m)return!0;if(on(l)&&on(m)&&(f[0]===1||p[0]===1))return!0}return f[1]===p[1]&&on(f[0])&&on(p[0])}var xa,Rr;function ti(f){if(xa==null){var p=P(f);xa=p.getParameter(p.MAX_TEXTURE_SIZE)}return xa}function _a(){xa=null}function Ri(){Rr=null}function Hi(f){if(Rr==null){var p=P(f);Rr=p.getParameter(p.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Rr)}function Ai(f){if(f===0)return 0;var p,l=P(f);return qn(l,"EXT_disjoint_timer_query_webgl2")&&f===2?p=2:qn(l,"EXT_disjoint_timer_query")?p=1:p=0,p}function qn(f,p){var l=f.getExtension(p);return l!=null}function ri(f){try{var p=P(f);if(p!=null)return!0}catch(l){return console.log("Error when getting WebGL context: ",l),!1}return!1}function pi(f){if(f===0)return!1;var p=P(f);if(f===1){if(!qn(p,"OES_texture_float"))return!1}else if(!qn(p,"EXT_color_buffer_float"))return!1;var l=di(p);return l}function pa(f){if(f===0)return!1;var p=P(f);if(f===1){if(!qn(p,"OES_texture_float"))return!1;if(!qn(p,"WEBGL_color_buffer_float"))return!1}else{if(qn(p,"EXT_color_buffer_float"))return di(p);var l="EXT_color_buffer_half_float";if(qn(p,l)){var m=p.getExtension(l);return fi(p,m)}return!1}var g=di(p);return g}function di(f){var p=Tt(f),l=f.createTexture();f.bindTexture(f.TEXTURE_2D,l);var m=1,g=1;f.texImage2D(f.TEXTURE_2D,0,p.internalFormatFloat,m,g,0,p.textureFormatFloat,p.textureTypeFloat,null);var I=f.createFramebuffer();f.bindFramebuffer(f.FRAMEBUFFER,I),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l,0);var R=f.checkFramebufferStatus(f.FRAMEBUFFER)===f.FRAMEBUFFER_COMPLETE;return f.bindTexture(f.TEXTURE_2D,null),f.bindFramebuffer(f.FRAMEBUFFER,null),f.deleteTexture(l),f.deleteFramebuffer(I),R}function fi(f,p){var l=Tt(f,p),m=f.createTexture();f.bindTexture(f.TEXTURE_2D,m);var g=1,I=1;f.texImage2D(f.TEXTURE_2D,0,l.internalFormatHalfFloat,g,I,0,l.textureFormatFloat,l.textureTypeHalfFloat,null);var R=f.createFramebuffer();f.bindFramebuffer(f.FRAMEBUFFER,R),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,m,0);var z=f.checkFramebufferStatus(f.FRAMEBUFFER)===f.FRAMEBUFFER_COMPLETE;return f.bindTexture(f.TEXTURE_2D,null),f.bindFramebuffer(f.FRAMEBUFFER,null),f.deleteTexture(m),f.deleteFramebuffer(R),z}function Va(f){if(f!==2)return!1;var p=P(f),l=p.fenceSync!=null;return l}function ln(f,p){Array.isArray(f)||(f=[f]),f.forEach(function(l){l!=null&&i.util.assert(l.dtype!=="complex64",function(){return p+" does not support complex64 tensors in the WebGL backend."})})}var ni={__proto__:null,callAndCheck:Qe,canBeRepresented:ht,getWebGLErrorMessage:ut,getExtensionOrThrow:yt,createVertexShader:Zt,createFragmentShader:ar,createProgram:jr,linkProgram:_r,validateProgram:tr,createStaticVertexBuffer:Fa,createStaticIndexBuffer:Oa,getNumChannels:Tn,createTexture:Wa,validateTextureSize:Na,createFramebuffer:yn,bindVertexBufferToProgramAttribute:Ma,bindTextureUnit:li,unbindTextureUnit:hi,getProgramUniformLocationOrThrow:la,getProgramUniformLocation:rn,bindTextureToProgramUniformSampler:Ca,bindCanvasToFramebuffer:xn,bindColorTextureToFramebuffer:Hn,unbindColorTextureFromFramebuffer:_i,validateFramebuffer:ha,getFramebufferErrorMessage:Ei,getBatchDim:Ua,getRowsCols:ga,getShapeAs3D:wi,getTextureShapeFromLogicalShape:Ta,isReshapeFree:_n,getWebGLMaxTextureSize:ti,resetMaxTextureSize:_a,resetMaxTexturesInShader:Ri,getMaxTexturesInShader:Hi,getWebGLDisjointQueryTimerVersion:Ai,hasExtension:qn,isWebGLVersionEnabled:ri,isCapableOfRenderingToFloatTexture:pi,isDownloadFloatTextureEnabled:pa,isWebGLFenceEnabled:Va,assertNotComplex:ln},gr=i.env();gr.registerFlag("HAS_WEBGL",function(){return gr.getNumber("WEBGL_VERSION")>0}),gr.registerFlag("WEBGL_VERSION",function(){return ri(2)?2:ri(1)?1:0}),gr.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",function(){return!1}),gr.registerFlag("WEBGL_BUFFER_SUPPORTED",function(){return gr.get("WEBGL_VERSION")===2}),gr.registerFlag("WEBGL_CPU_FORWARD",function(){return!0}),gr.registerFlag("WEBGL_FORCE_F16_TEXTURES",function(){return!1}),gr.registerFlag("WEBGL_PACK",function(){return gr.getBool("HAS_WEBGL")}),gr.registerFlag("WEBGL_PACK_NORMALIZATION",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_CLIP",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_DEPTHWISECONV",function(){return!1}),gr.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_REDUCE",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_LAZILY_UNPACK",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_CONV_IM2COL",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_MAX_TEXTURE_SIZE",function(){return ti(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",function(){return Hi(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",function(){var f=gr.getNumber("WEBGL_VERSION");return f===0?0:Ai(f)}),gr.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",function(){return gr.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!i.device_util.isMobile()}),gr.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",function(){return pi(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",function(){return gr.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:gr.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")}),gr.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",function(){return pa(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_FENCE_API_ENABLED",function(){return Va(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",function(){var f=gr.getBool("WEBGL_RENDER_FLOAT32_ENABLED");return f?4:0}),gr.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",function(){return-1},function(f){if(f<0&&f!==-1)throw new Error("WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never "+("delete) or at least 0, but got "+f+"."))});function Di(f){const p=new Float32Array(f.length);for(let l=0;l<f.length;++l)p[l]=Math.abs(f[l]);return p}function bi(f){return(p,l,m,g,I)=>{const R=i.backend_util.assertAndGetBroadcastShape(p,l),z=R.length,L=i.util.computeStrides(R),G=i.util.sizeFromShape(R),Z=i.util.getTypedArrayFromDType(I,G),be=p.length,Ce=l.length,De=i.util.computeStrides(p),Te=i.util.computeStrides(l),Ge=i.backend_util.getBroadcastDims(p,R),Ze=i.backend_util.getBroadcastDims(l,R);if(Ge.length+Ze.length===0)for(let s=0;s<Z.length;++s)Z[s]=f(m[s%m.length],g[s%g.length]);else for(let s=0;s<Z.length;++s){const u=i.util.indexToLoc(s,z,L),r=u.slice(-be);Ge.forEach(T=>r[T]=0);const o=i.util.locToIndex(r,be,De),h=u.slice(-Ce);Ze.forEach(T=>h[T]=0);const b=i.util.locToIndex(h,Ce,Te);Z[s]=f(m[o],g[b])}return[Z,R]}}const ro=bi((f,p)=>f+p);function Zn(f){return(p,l,m)=>{const g=i.util.getTypedArrayFromDType(l,p.length);for(let I=0;I<p.length;++I)g[I]=f(p[I],m);return g}}const Gi=Zn(f=>Math.ceil(f)),Fi=Zn(f=>Math.exp(f)),ji=Zn(f=>Math.expm1(f)),Oi=Zn(f=>Math.floor(f)),da=Zn(f=>Math.log(f));function Mi(f,p,l,m){const g=i.util.getTypedArrayFromDType(m,i.util.sizeFromShape(l));for(let I=0;I<g.length;++I){const R=I*p;let z=f[R];for(let L=0;L<p;++L){const G=f[R+L];G>z&&(z=G)}g[I]=z}return g}const pe=bi((f,p)=>f*p),X=Zn(f=>1/Math.sqrt(f));function j(f,p,l,m,g){const I=i.slice_util.isSliceContinous(m,p,l),R=i.util.sizeFromShape(l),z=i.util.computeStrides(m);if(I){const G=i.slice_util.computeFlatOffset(p,z);return f.subarray(G,G+R)}const L=i.util.getTypedArrayFromDType(g,R);for(let G=0;G<R;++G){const Z=l.length,be=i.util.computeStrides(l),Ce=i.util.indexToLoc(G,Z,be),De=Ce.map((Ge,Ze)=>Ge+p[Ze]),Te=i.util.locToIndex(De,m.length,z);L[G]=f[Te]}return L}const re=bi((f,p)=>f-p);function te(f,p,l,m,g){const I=p.length,R=i.util.sizeFromShape(p),z=i.util.computeStrides(p),L=i.util.computeStrides(g),G=i.util.getTypedArrayFromDType(l,i.util.sizeFromShape(g));for(let Z=0;Z<R;++Z){const be=i.util.indexToLoc(Z,I,z),Ce=new Array(be.length);for(let Te=0;Te<Ce.length;Te++)Ce[Te]=be[m[Te]];const De=i.util.locToIndex(Ce,I,L);G[De]=f[Z]}return G}function Ue(f,p,l,m){const g=i.util.parseAxisParam(p,l)[0],I=[1,l[0],1];for(let Te=0;Te<g;Te++)I[0]*=l[Te];I[1]=l[g];for(let Te=g+1;Te<l.length;Te++)I[2]*=l[Te];const R={},z=new Int32Array(l[g]),L=new i.TensorBuffer(I,m,f),G=[],Z=I[0]===1&&I[2]===1;for(let Te=0;Te<l[g];Te++){let Ge;if(Z)Ge=f[Te].toString();else{const Ze=[];for(let s=0;s<I[0];s++)for(let u=0;u<I[2];u++)Ze.push(L.get(s,Te,u));Ge=Ze.join(",")}if(R[Ge]!==void 0)z[Te]=R[Ge];else{const Ze=Object.keys(R).length;R[Ge]=Ze,z[Te]=Ze,G.push(Te)}}const be=I.slice();be[1]=Object.keys(R).length;const Ce=new i.TensorBuffer(be,m);G.forEach((Te,Ge)=>{for(let Ze=0;Ze<I[0];Ze++)for(let s=0;s<I[2];s++)Ce.set(L.get(Ze,Te,s),Ze,Ge,s)});const De=l.slice();return De[g]=be[1],{outputValues:Ce.values,outputShape:De,indices:z}}var kt=Di,$e=ro,Le=Gi,Ye=Fi,Ft=ji,St=Oi,Mt=da,dr=Mi,ir=pe,ta=X,fa=j,ra=re,Ha=te,ki=Ue,sn=function(){function f(p,l){this.outputShape=[],this.outputShape=p,this.variableNames=l.map(function(I,R){return"T"+R});var m=[];this.variableNames.forEach(function(I){m.push("float v"+I+" = get"+I+"AtOutCoords();")});var g=this.variableNames.map(function(I){return"v"+I}).join(" + ");this.userCode=`
void main() {
`+m.join(`
`)+`
float result = `+g+`;
setOutput(result);
}
`}return f}(),hn=function(){function f(p,l){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p,this.variableNames=l.map(function(I,R){return"T"+R});var m=[];this.variableNames.forEach(function(I){m.push("vec4 v"+I+" = get"+I+"AtOutCoords();")});var g=this.variableNames.map(function(I){return"v"+I}).join(" + ");this.userCode=`
void main() {
`+m.join(`
`)+`
vec4 result = `+g+`;
setOutput(result);
}
`}return f}(),na=function(){function f(p,l,m){this.variableNames=["A"];var g=p.windowSize,I=p.batchSize,R=p.outSize;m||this.variableNames.push("bestIndicesA"),this.outputShape=[I,R];var z=l==="max"?">":"<",L=m?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * `+g+`;
int bestIndex = inOffset;
float bestValue = getA(batch, bestIndex);
for (int i = 0; i < `+g+`; i++) {
int inIdx = `+L+`;
float candidate = getA(batch, inIdx);
if (candidate `+z+` bestValue) {
bestValue = candidate;
bestIndex = inIdx;
}
}
setOutput(float(bestIndex));
}
`}return f}();function Jr(f,p){return["x","y","z","w","u","v"].slice(0,p).map(function(l){return f+"."+l})}function Vr(f,p){return p===1?[f]:Jr(f,p)}function Jn(f,p){if(f===1)return"rc";for(var l="",m=0;m<f;m++)l+=p[m],m<f-1&&(l+=",");return l}function tn(){var f,p,l,m,g,I,R,z,L,G;return i.env().getNumber("WEBGL_VERSION")===2?(f="#version 300 es",p="in",l="out",m="in",g="texture",I="outputColor",R="out vec4 outputColor;",z=`
bool isnan_custom(float val) {
return (val > 0.0 || val < 0.0) ? false : val != 0.0;
}
bvec4 isnan_custom(vec4 val) {
return bvec4(isnan_custom(val.x),
isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));
}
#define isnan(value) isnan_custom(value)
`,L="",G=`
#define round(value) newRound(value)
int newRound(float value) {
return int(floor(value + 0.5));
}
ivec4 newRound(vec4 value) {
return ivec4(floor(value + vec4(0.5)));
}
`):(f="",p="attribute",l="varying",m="varying",g="texture2D",I="gl_FragColor",R="",z=`
#define isnan(value) isnan_custom(value)
bool isnan_custom(float val) {
return (val > 0. || val < 1. || val == 0.) ? false : true;
}
bvec4 isnan_custom(vec4 val) {
return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));
}
`,L=`
uniform float INFINITY;
bool isinf(float val) {
return abs(val) == INFINITY;
}
bvec4 isinf(vec4 val) {
return equal(abs(val), vec4(INFINITY));
}
`,G=`
int round(float value) {
return int(floor(value + 0.5));
}
ivec4 round(vec4 value) {
return ivec4(floor(value + vec4(0.5)));
}
`),{version:f,attribute:p,varyingVs:l,varyingFs:m,texture2D:g,output:I,defineOutput:R,defineSpecialNaN:z,defineSpecialInf:L,defineRound:G}}function Rn(f,p,l){l===void 0&&(l="index");var m=i.util.computeStrides(p);return m.map(function(g,I){var R="int "+f[I]+" = "+l+" / "+g,z=I===m.length-1?"int "+f[I+1]+" = "+l+" - "+f[I]+" * "+g:"index -= "+f[I]+" * "+g;return R+"; "+z+";"}).join("")}function Kn(f){var p=i.util.computeStrides(f).map(function(l){return l.toString()});return`
int getFlatIndex(ivec3 coords) {
return coords.x * `+p[0]+" + coords.y * "+p[1]+` + coords.z;
}
`}var aa=`
const float FLOAT_MAX = 1.70141184e38;
const float FLOAT_MIN = 1.17549435e-38;
lowp vec4 encode_float(highp float v) {
if (isnan(v)) {
return vec4(255, 255, 255, 255);
}
highp float av = abs(v);
if(av < FLOAT_MIN) {
return vec4(0.0, 0.0, 0.0, 0.0);
} else if(v > FLOAT_MAX) {
return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
} else if(v < -FLOAT_MAX) {
return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;
}
highp vec4 c = vec4(0,0,0,0);
highp float e = floor(log2(av));
highp float m = exp2(fract(log2(av))) - 1.0;
c[2] = floor(128.0 * m);
m -= c[2] / 128.0;
c[1] = floor(32768.0 * m);
m -= c[1] / 32768.0;
c[0] = floor(8388608.0 * m);
highp float ebias = e + 127.0;
c[3] = floor(ebias / 2.0);
ebias -= c[3] * 2.0;
c[2] += floor(ebias) * 128.0;
c[3] += 128.0 * step(0.0, -v);
return c / 255.0;
}
`,ma=i.backend_util.getBroadcastDims;function Li(f,p,l,m){var g=[];f.forEach(function(Te){var Ge=i.util.sizeFromShape(Te.shapeInfo.logicalShape);Te.shapeInfo.isUniform?g.push("uniform float "+Te.name+(Ge>1?"["+Ge+"]":"")+";"):(g.push("uniform sampler2D "+Te.name+";"),g.push("uniform int offset"+Te.name+";"))});var I=g.join(`
`),R=f.map(function(Te){return x(Te,p,m)}).join(`
`),z=p.texShape,L=tn(),G=Se(L),Z,be,Ce=Be(L);p.isPacked?(Z=k(p.logicalShape,z),be=Je(L)):(Z=K(p.logicalShape,z),be=we(L)),m&&(Ce+=Wt);var De=[Ce,G,be,I,Z,R,l].join(`
`);return De}function Ea(f){var p=f.shapeInfo.logicalShape;switch(p.length){case 0:return $r(f);case 1:return mi(f);case 2:return ja(f);case 3:return zi(f);case 4:return ba(f);case 5:return qi(f);case 6:return yi(f);default:throw new Error(p.length+"-D input sampling is not yet supported")}}function S(f){var p=f.shapeInfo.logicalShape;switch(p.length){case 0:return ur(f);case 1:return Ra(f);case 2:return Ga(f);case 3:return ai(f);default:return An(f)}}function x(f,p,l){l===void 0&&(l=!1);var m="";l?m+=S(f):m+=Ea(f);var g=f.shapeInfo.logicalShape,I=p.logicalShape;return g.length<=I.length&&(l?m+=qr(f,p):m+=Io(f,p)),m}function k(f,p){switch(f.length){case 0:return Gt();case 1:return Qt(f,p);case 2:return Fr(f,p);case 3:return Ar(f,p);default:return xr(f,p)}}function K(f,p){switch(f.length){case 0:return Gt();case 1:return wr(f,p);case 2:return wa(f,p);case 3:return Yt(f,p);case 4:return Sn(f,p);case 5:return pn(f,p);case 6:return zn(f,p);default:throw new Error(f.length+"-D output sampling is not yet supported")}}function Se(f){return`
float sampleTexture(sampler2D textureSampler, vec2 uv) {
return `+f.texture2D+`(textureSampler, uv).r;
}
`}function we(f){return`
void setOutput(float val) {
`+f.output+` = vec4(val, 0, 0, 0);
}
`}function Je(f){return`
void setOutput(vec4 val) {
`+f.output+` = val;
}
`}function Be(f){var p=f.version+`
precision highp float;
precision highp int;
precision highp sampler2D;
`+f.varyingFs+` vec2 resultUV;
`+f.defineOutput+`
const vec2 halfCR = vec2(0.5, 0.5);
struct ivec5
{
int x;
int y;
int z;
int w;
int u;
};
struct ivec6
{
int x;
int y;
int z;
int w;
int u;
int v;
};
uniform float NAN;
`+f.defineSpecialNaN+`
`+f.defineSpecialInf+`
`+f.defineRound+`
int imod(int x, int y) {
return x - y * (x / y);
}
int idiv(int a, int b, float sign) {
int res = a / b;
int mod = imod(a, b);
if (sign < 0. && mod != 0) {
res -= 1;
}
return res;
}
//Based on the work of Dave Hoskins
//https://www.shadertoy.com/view/4djSRW
#define HASHSCALE1 443.8975
float random(float seed){
vec2 p = resultUV * seed;
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.x + p3.y) * p3.z);
}
`+vt+`
`+ft+`
`+zt+`
`;return p}var vt=`
vec2 uvFromFlat(int texNumR, int texNumC, int index) {
int texR = index / texNumC;
int texC = index - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
int texelIndex = index / 2;
int texR = texelIndex / texNumC;
int texC = texelIndex - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`,ft=`
vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
int texNumC, int row, int col) {
int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
int texR = texelIndex / texNumC;
int texC = texelIndex - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`,zt=`
vec2 packedUVfrom3D(int texNumR, int texNumC,
int texelsInBatch, int texelsInLogicalRow, int b,
int row, int col) {
int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
int texR = index / texNumC;
int texC = index - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
`,Wt=`
float getChannel(vec4 frag, vec2 innerDims) {
vec2 modCoord = mod(innerDims, 2.);
return modCoord.x == 0. ?
(modCoord.y == 0. ? frag.r : frag.g) :
(modCoord.y == 0. ? frag.b : frag.a);
}
float getChannel(vec4 frag, int dim) {
float modCoord = mod(float(dim), 2.);
return modCoord == 0. ? frag.r : frag.g;
}
`;function Gt(){return`
int getOutputCoords() {
return 0;
}
`}function Qt(f,p){var l=[Math.ceil(p[0]/2),Math.ceil(p[1]/2)];return l[0]===1?`
int getOutputCoords() {
return 2 * int(resultUV.x * `+l[1]+`.0);
}
`:l[1]===1?`
int getOutputCoords() {
return 2 * int(resultUV.y * `+l[0]+`.0);
}
`:`
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+l[0]+", "+l[1]+`));
return 2 * (resTexRC.x * `+l[1]+` + resTexRC.y);
}
`}function wr(f,p){return p[0]===1?`
int getOutputCoords() {
return int(resultUV.x * `+p[1]+`.0);
}
`:p[1]===1?`
int getOutputCoords() {
return int(resultUV.y * `+p[0]+`.0);
}
`:`
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+p[0]+", "+p[1]+`));
return resTexRC.x * `+p[1]+` + resTexRC.y;
}
`}function Ar(f,p){var l=[Math.ceil(p[0]/2),Math.ceil(p[1]/2)],m=Math.ceil(f[2]/2),g=m*Math.ceil(f[1]/2);return`
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+l[0]+", "+l[1]+`));
int index = resTexRC.x * `+l[1]+` + resTexRC.y;
int b = index / `+g+`;
index -= b * `+g+`;
int r = 2 * (index / `+m+`);
int c = imod(index, `+m+`) * 2;
return ivec3(b, r, c);
}
`}function Yt(f,p){var l=Rn(["r","c","d"],f);return`
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+p[0]+", "+p[1]+`));
int index = resTexRC.x * `+p[1]+` + resTexRC.y;
`+l+`
return ivec3(r, c, d);
}
`}function xr(f,p){for(var l=[Math.ceil(p[0]/2),Math.ceil(p[1]/2)],m=Math.ceil(f[f.length-1]/2),g=m*Math.ceil(f[f.length-2]/2),I=g,R="",z="b, r, c",L=2;L<f.length-1;L++)I*=f[f.length-L-1],R=`
int b`+L+" = index / "+I+`;
index -= b`+L+" * "+I+`;
`+R,z="b"+L+", "+z;return`
ivec`+f.length+` getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+l[0]+", "+l[1]+`));
int index = resTexRC.x * `+l[1]+` + resTexRC.y;
`+R+`
int b = index / `+g+`;
index -= b * `+g+`;
int r = 2 * (index / `+m+`);
int c = imod(index, `+m+`) * 2;
return ivec`+f.length+"("+z+`);
}
`}function Sn(f,p){var l=Rn(["r","c","d","d2"],f);return`
ivec4 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+p[0]+", "+p[1]+`));
int index = resTexRC.x * `+p[1]+` + resTexRC.y;
`+l+`
return ivec4(r, c, d, d2);
}
`}function pn(f,p){var l=Rn(["r","c","d","d2","d3"],f);return`
ivec5 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+p[0]+`,
`+p[1]+`));
int index = resTexRC.x * `+p[1]+` + resTexRC.y;
`+l+`
ivec5 outShape = ivec5(r, c, d, d2, d3);
return outShape;
}
`}function zn(f,p){var l=Rn(["r","c","d","d2","d3","d4"],f);return`
ivec6 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+p[0]+", "+p[1]+`));
int index = resTexRC.x * `+p[1]+` + resTexRC.y;
`+l+`
ivec6 result = ivec6(r, c, d, d2, d3, d4);
return result;
}
`}function Fr(f,p){var l=[Math.ceil(p[0]/2),Math.ceil(p[1]/2)];if(i.util.arraysEqual(f,p))return`
ivec2 getOutputCoords() {
return 2 * ivec2(resultUV.yx * vec2(`+l[0]+", "+l[1]+`));
}
`;var m=Math.ceil(f[1]/2);return`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+l[0]+", "+l[1]+`));
int index = resTexRC.x * `+l[1]+` + resTexRC.y;
int r = 2 * (index / `+m+`);
int c = imod(index, `+m+`) * 2;
return ivec2(r, c);
}
`}function wa(f,p){return i.util.arraysEqual(f,p)?`
ivec2 getOutputCoords() {
return ivec2(resultUV.yx * vec2(`+p[0]+", "+p[1]+`));
}
`:f[1]===1?`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+p[0]+", "+p[1]+`));
int index = resTexRC.x * `+p[1]+` + resTexRC.y;
return ivec2(index, 0);
}
`:f[0]===1?`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+p[0]+", "+p[1]+`));
int index = resTexRC.x * `+p[1]+` + resTexRC.y;
return ivec2(0, index);
}
`:`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+p[0]+", "+p[1]+`));
int index = resTexRC.x * `+p[1]+` + resTexRC.y;
int r = index / `+f[1]+`;
int c = index - r * `+f[1]+`;
return ivec2(r, c);
}
`}function In(f){return"offset"+f}function ur(f){var p=f.name,l="get"+p.charAt(0).toUpperCase()+p.slice(1),m=tn();return`
vec4 `+l+`() {
return `+m.texture2D+"("+p+`, halfCR);
}
`}function $r(f){var p=f.name,l="get"+p.charAt(0).toUpperCase()+p.slice(1);if(f.shapeInfo.isUniform)return"float "+l+"() {return "+p+";}";var m=f.shapeInfo.texShape,g=m[0],I=m[1];if(g===1&&I===1)return`
float `+l+`() {
return sampleTexture(`+p+`, halfCR);
}
`;var R=f.shapeInfo.texShape,z=R[0],L=R[1],G=In(p);return`
float `+l+`() {
vec2 uv = uvFromFlat(`+z+", "+L+", "+G+`);
return sampleTexture(`+p+`, uv);
}
`}function Ra(f){var p=f.name,l="get"+p.charAt(0).toUpperCase()+p.slice(1),m=f.shapeInfo.texShape,g=[Math.ceil(m[0]/2),Math.ceil(m[1]/2)],I=tn();return`
vec4 `+l+`(int index) {
vec2 uv = packedUVfrom1D(
`+g[0]+", "+g[1]+`, index);
return `+I.texture2D+"("+p+`, uv);
}
`}function mi(f){var p=f.name,l="get"+p.charAt(0).toUpperCase()+p.slice(1);if(f.shapeInfo.isUniform)return`
float `+l+`(int index) {
`+ii(f)+`
}
`;var m=f.shapeInfo.texShape,g=m[0],I=m[1];if(I===1&&g===1)return`
float `+l+`(int index) {
return sampleTexture(`+p+`, halfCR);
}
`;var R=In(p);return I===1?`
float `+l+`(int index) {
vec2 uv = vec2(0.5, (float(index + `+R+") + 0.5) / "+g+`.0);
return sampleTexture(`+p+`, uv);
}
`:g===1?`
float `+l+`(int index) {
vec2 uv = vec2((float(index + `+R+") + 0.5) / "+I+`.0, 0.5);
return sampleTexture(`+p+`, uv);
}
`:`
float `+l+`(int index) {
vec2 uv = uvFromFlat(`+g+", "+I+", index + "+R+`);
return sampleTexture(`+p+`, uv);
}
`}function Ga(f){var p=f.shapeInfo.logicalShape,l=f.name,m="get"+l.charAt(0).toUpperCase()+l.slice(1),g=f.shapeInfo.texShape,I=g[0],R=g[1],z=tn();if(g!=null&&i.util.arraysEqual(p,g))return`
vec4 `+m+`(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(`+R+".0, "+I+`.0);
return `+z.texture2D+"("+l+`, uv);
}
`;var L=[Math.ceil(g[0]/2),Math.ceil(g[1]/2)],G=Math.ceil(p[1]/2);return`
vec4 `+m+`(int row, int col) {
vec2 uv = packedUVfrom2D(`+G+", "+L[0]+", "+L[1]+`, row, col);
return `+z.texture2D+"("+l+`, uv);
}
`}function ja(f){var p=f.shapeInfo.logicalShape,l=f.name,m="get"+l.charAt(0).toUpperCase()+l.slice(1),g=f.shapeInfo.texShape;if(g!=null&&i.util.arraysEqual(p,g)){var I=g[0],R=g[1];return`
float `+m+`(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(`+R+".0, "+I+`.0);
return sampleTexture(`+l+`, uv);
}
`}var z=i.util.squeezeShape(p),L=z.newShape,G=z.keptDims,Z=L;if(Z.length<p.length){var be=qa(f,Z),Ce=["row","col"];return`
`+Ea(be)+`
float `+m+`(int row, int col) {
return `+m+"("+La(Ce,G)+`);
}
`}if(f.shapeInfo.isUniform)return`
float `+m+`(int row, int col) {
int index = round(dot(vec2(row, col), vec2(`+p[1]+`, 1)));
`+ii(f)+`
}
`;var De=g[0],Te=g[1],Ge=In(l);return Te===1?`
float `+m+`(int row, int col) {
float index = dot(vec3(row, col, `+Ge+"), vec3("+p[1]+`, 1, 1));
vec2 uv = vec2(0.5, (index + 0.5) / `+De+`.0);
return sampleTexture(`+l+`, uv);
}
`:De===1?`
float `+m+`(int row, int col) {
float index = dot(vec3(row, col, `+Ge+"), vec3("+p[1]+`, 1, 1));
vec2 uv = vec2((index + 0.5) / `+Te+`.0, 0.5);
return sampleTexture(`+l+`, uv);
}
`:`
float `+m+`(int row, int col) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * `+p[1]+" + col + "+Ge+`;
vec2 uv = uvFromFlat(`+De+", "+Te+`, index);
return sampleTexture(`+l+`, uv);
}
`}function ai(f){var p=f.shapeInfo.logicalShape,l=f.name,m="get"+l.charAt(0).toUpperCase()+l.slice(1),g=f.shapeInfo.texShape,I=[Math.ceil(g[0]/2),Math.ceil(g[1]/2)];if(p[0]===1){var R=p.slice(1),z=[1,2],L=qa(f,R),G=["b","row","col"];return`
`+S(L)+`
vec4 `+m+`(int b, int row, int col) {
return `+m+"("+La(G,z)+`);
}
`}var Z=I[0],be=I[1],Ce=Math.ceil(p[2]/2),De=Ce*Math.ceil(p[1]/2),Te=tn();return`
vec4 `+m+`(int b, int row, int col) {
vec2 uv = packedUVfrom3D(
`+Z+", "+be+", "+De+", "+Ce+`, b, row, col);
return `+Te.texture2D+"("+l+`, uv);
}
`}function zi(f){var p=f.shapeInfo.logicalShape,l=f.name,m="get"+l.charAt(0).toUpperCase()+l.slice(1),g=p[1]*p[2],I=p[2],R=i.util.squeezeShape(p),z=R.newShape,L=R.keptDims,G=z;if(G.length<p.length){var Z=qa(f,G),be=["row","col","depth"];return`
`+Ea(Z)+`
float `+m+`(int row, int col, int depth) {
return `+m+"("+La(be,L)+`);
}
`}if(f.shapeInfo.isUniform)return`
float `+m+`(int row, int col, int depth) {
int index = round(dot(vec3(row, col, depth),
vec3(`+g+", "+I+`, 1)));
`+ii(f)+`
}
`;var Ce=f.shapeInfo.texShape,De=Ce[0],Te=Ce[1],Ge=f.shapeInfo.flatOffset;if(Te===g&&Ge==null)return`
float `+m+`(int row, int col, int depth) {
float texR = float(row);
float texC = dot(vec2(col, depth), vec2(`+I+`, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+Te+".0, "+De+`.0);
return sampleTexture(`+l+`, uv);
}
`;if(Te===I&&Ge==null)return`
float `+m+`(int row, int col, int depth) {
float texR = dot(vec2(row, col), vec2(`+p[1]+`, 1));
float texC = float(depth);
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(`+Te+".0, "+De+`.0);
return sampleTexture(`+l+`, uv);
}
`;var Ze=In(l);return`
float `+m+`(int row, int col, int depth) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * `+g+" + col * "+I+" + depth + "+Ze+`;
vec2 uv = uvFromFlat(`+De+", "+Te+`, index);
return sampleTexture(`+l+`, uv);
}
`}function An(f){for(var p=f.shapeInfo.logicalShape,l=p.length,m=f.name,g="get"+m.charAt(0).toUpperCase()+m.slice(1),I=f.shapeInfo.texShape,R=[Math.ceil(I[0]/2),Math.ceil(I[1]/2)],z=R[0],L=R[1],G=Math.ceil(p[l-1]/2),Z=G*Math.ceil(p[l-2]/2),be="int b, int row, int col",Ce="b * "+Z+" + (row / 2) * "+G+" + (col / 2)",De=2;De<l-1;De++)be="int b"+De+", "+be,Z*=p[l-De-1],Ce="b"+De+" * "+Z+" + "+Ce;var Te=tn();return`
vec4 `+g+"("+be+`) {
int index = `+Ce+`;
int texR = index / `+L+`;
int texC = index - texR * `+L+`;
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(`+L+", "+z+`);
return `+Te.texture2D+"("+m+`, uv);
}
`}function ba(f){var p=f.shapeInfo.logicalShape,l=f.name,m="get"+l.charAt(0).toUpperCase()+l.slice(1),g=p[3],I=p[2]*g,R=p[1]*I,z=i.util.squeezeShape(p),L=z.newShape,G=z.keptDims;if(L.length<p.length){var Z=qa(f,L),be=["row","col","depth","depth2"];return`
`+Ea(Z)+`
float `+m+`(int row, int col, int depth, int depth2) {
return `+m+"("+La(be,G)+`);
}
`}if(f.shapeInfo.isUniform)return`
float `+m+`(int row, int col, int depth, int depth2) {
int index = round(dot(vec4(row, col, depth, depth2),
vec4(`+R+", "+I+", "+g+`, 1)));
`+ii(f)+`
}
`;var Ce=f.shapeInfo.flatOffset,De=f.shapeInfo.texShape,Te=De[0],Ge=De[1];if(Ge===R&&Ce==null)return`
float `+m+`(int row, int col, int depth, int depth2) {
float texR = float(row);
float texC =
dot(vec3(col, depth, depth2),
vec3(`+I+", "+g+`, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+Ge+".0, "+Te+`.0);
return sampleTexture(`+l+`, uv);
}
`;if(Ge===g&&Ce==null)return`
float `+m+`(int row, int col, int depth, int depth2) {
float texR = dot(vec3(row, col, depth),
vec3(`+p[1]*p[2]+", "+p[2]+`, 1));
float texC = float(depth2);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+Ge+".0, "+Te+`.0);
return sampleTexture(`+l+`, uv);
}
`;var Ze=In(l);return`
float `+m+`(int row, int col, int depth, int depth2) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * `+R+" + col * "+I+` +
depth * `+g+` + depth2;
vec2 uv = uvFromFlat(`+Te+", "+Ge+", index + "+Ze+`);
return sampleTexture(`+l+`, uv);
}
`}function qi(f){var p=f.shapeInfo.logicalShape,l=f.name,m="get"+l.charAt(0).toUpperCase()+l.slice(1),g=p[4],I=p[3]*g,R=p[2]*I,z=p[1]*R,L=i.util.squeezeShape(p),G=L.newShape,Z=L.keptDims;if(G.length<p.length){var be=qa(f,G),Ce=["row","col","depth","depth2","depth3"];return`
`+Ea(be)+`
float `+m+`(int row, int col, int depth, int depth2, int depth3) {
return `+m+"("+La(Ce,Z)+`);
}
`}if(f.shapeInfo.isUniform)return`
float `+m+`(int row, int col, int depth, int depth2, int depth3) {
float index = dot(
vec4(row, col, depth, depth2),
vec4(`+z+", "+R+", "+I+", "+g+`)) +
depth3;
`+ii(f)+`
}
`;var De=f.shapeInfo.flatOffset,Te=f.shapeInfo.texShape,Ge=Te[0],Ze=Te[1];if(Ze===z&&De==null)return`
float `+m+`(int row, int col, int depth, int depth2, int depth3) {
int texR = row;
float texC = dot(vec4(col, depth, depth2, depth3),
vec4(`+R+", "+I+", "+g+`, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+Ze+".0, "+Ge+`.0);
return sampleTexture(`+l+`, uv);
}
`;if(Ze===g&&De==null)return`
float `+m+`(int row, int col, int depth, int depth2, int depth3) {
float texR = dot(
vec4(row, col, depth, depth2),
vec4(`+p[1]*p[2]*p[3]+`,
`+p[2]*p[3]+", "+p[3]+`, 1));
int texC = depth3;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+Ze+".0, "+Ge+`.0);
return sampleTexture(`+l+`, uv);
}
`;var s=In(l);return`
float `+m+`(int row, int col, int depth, int depth2, int depth3) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * `+z+" + col * "+R+" + depth * "+I+` +
depth2 * `+g+" + depth3 + "+s+`;
vec2 uv = uvFromFlat(`+Ge+", "+Ze+`, index);
return sampleTexture(`+l+`, uv);
}
`}function yi(f){var p=f.shapeInfo.logicalShape,l=f.name,m="get"+l.charAt(0).toUpperCase()+l.slice(1),g=i.util.squeezeShape(p),I=g.newShape,R=g.keptDims;if(I.length<p.length){var z=qa(f,I),L=["row","col","depth","depth2","depth3","depth4"];return`
`+Ea(z)+`
float `+m+`(int row, int col, int depth,
int depth2, int depth3, int depth4) {
return `+m+"("+La(L,R)+`);
}
`}var G=p[5],Z=p[4]*G,be=p[3]*Z,Ce=p[2]*be,De=p[1]*Ce;if(f.shapeInfo.isUniform)return`
float `+m+`(int row, int col, int depth,
int depth2, int depth3, int depth4) {
int index = round(dot(
vec4(row, col, depth, depth2),
vec4(`+De+", "+Ce+", "+be+", "+Z+`)) +
dot(
vec2(depth3, depth4),
vec2(`+G+`, 1)));
`+ii(f)+`
}
`;var Te=f.shapeInfo.flatOffset,Ge=f.shapeInfo.texShape,Ze=Ge[0],s=Ge[1];if(s===De&&Te==null)return`
float `+m+`(int row, int col, int depth,
int depth2, int depth3, int depth4) {
int texR = row;
float texC = dot(vec4(col, depth, depth2, depth3),
vec4(`+Ce+", "+be+", "+Z+", "+G+`)) +
float(depth4);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+s+".0, "+Ze+`.0);
return sampleTexture(`+l+`, uv);
}
`;if(s===G&&Te==null)return`
float `+m+`(int row, int col, int depth,
int depth2, int depth3, int depth4) {
float texR = dot(vec4(row, col, depth, depth2),
vec4(`+p[1]*p[2]*p[3]*p[4]+`,
`+p[2]*p[3]*p[4]+`,
`+p[3]*p[4]+`,
`+p[4]+`)) + float(depth3);
int texC = depth4;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+s+".0, "+Ze+`.0);
return sampleTexture(`+l+`, uv);
}
`;var u=In(l);return`
float `+m+`(int row, int col, int depth,
int depth2, int depth3, int depth4) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * `+De+" + col * "+Ce+" + depth * "+be+` +
depth2 * `+Z+" + depth3 * "+G+" + depth4 + "+u+`;
vec2 uv = uvFromFlat(`+Ze+", "+s+`, index);
return sampleTexture(`+l+`, uv);
}
`}function ii(f){var p=f.name,l=i.util.sizeFromShape(f.shapeInfo.logicalShape);return l<2?"return "+p+";":`
for (int i = 0; i < `+l+`; i++) {
if (i == index) {
return `+p+`[i];
}
}
`}function qr(f,p){var l=f.name,m=l.charAt(0).toUpperCase()+l.slice(1),g="get"+m+"AtOutCoords",I=f.shapeInfo.logicalShape.length,R=p.logicalShape.length,z=ma(f.shapeInfo.logicalShape,p.logicalShape),L=nn(R),G=R-I,Z,be=["x","y","z","w","u","v"];I===0?Z="":R<2&&z.length>=1?Z="coords = 0;":Z=z.map(function(o){return"coords."+be[o+G]+" = 0;"}).join(`
`);var Ce="";R<2&&I>0?Ce="coords":Ce=f.shapeInfo.logicalShape.map(function(o,h){return"coords."+be[h+G]}).join(", ");var De="return outputValue;",Te=i.util.sizeFromShape(f.shapeInfo.logicalShape),Ge=Te===1,Ze=i.util.sizeFromShape(p.logicalShape),s=Ze===1;if(I===1&&!Ge&&!s)De=`
return vec4(outputValue.xy, outputValue.xy);
`;else if(Ge&&!s)R===1?De=`
return vec4(outputValue.x, outputValue.x, 0., 0.);
`:De=`
return vec4(outputValue.x);
`;else if(z.length){var u=I-2,r=I-1;z.indexOf(u)>-1&&z.indexOf(r)>-1?De="return vec4(outputValue.x);":z.indexOf(u)>-1?De="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":z.indexOf(r)>-1&&(De="return vec4(outputValue.xx, outputValue.zz);")}return`
vec4 `+g+`() {
`+L+` coords = getOutputCoords();
`+Z+`
vec4 outputValue = get`+m+"("+Ce+`);
`+De+`
}
`}function Io(f,p){var l=f.name,m=l.charAt(0).toUpperCase()+l.slice(1),g="get"+m+"AtOutCoords",I=p.texShape,R=f.shapeInfo.texShape,z=f.shapeInfo.logicalShape.length,L=p.logicalShape.length;if(!f.shapeInfo.isUniform&&z===L&&f.shapeInfo.flatOffset==null&&i.util.arraysEqual(R,I))return`
float `+g+`() {
return sampleTexture(`+l+`, resultUV);
}
`;var G=nn(L),Z=ma(f.shapeInfo.logicalShape,p.logicalShape),be=L-z,Ce,De=["x","y","z","w","u","v"];z===0?Ce="":L<2&&Z.length>=1?Ce="coords = 0;":Ce=Z.map(function(Ge){return"coords."+De[Ge+be]+" = 0;"}).join(`
`);var Te="";return L<2&&z>0?Te="coords":Te=f.shapeInfo.logicalShape.map(function(Ge,Ze){return"coords."+De[Ze+be]}).join(", "),`
float `+g+`() {
`+G+` coords = getOutputCoords();
`+Ce+`
return get`+m+"("+Te+`);
}
`}function nn(f){if(f<=1)return"int";if(f===2)return"ivec2";if(f===3)return"ivec3";if(f===4)return"ivec4";if(f===5)return"ivec5";if(f===6)return"ivec6";throw Error("GPU for rank "+f+" is not yet supported")}function qa(f,p){var l=JSON.parse(JSON.stringify(f));return l.shapeInfo.logicalShape=p,l}function La(f,p){return p.map(function(l){return f[l]}).join(", ")}var Ki=function(){function f(p,l,m,g){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,i.util.assert(p.length>2,function(){return"Packed arg"+(m.charAt(0).toUpperCase()+m.slice(1))+" supports only inputs with rank above 2."});var I=p[p.length-1],R=Math.ceil(I/l);this.outputShape=p.slice(0,-1),R>1&&this.outputShape.push(R),g||this.variableNames.push("bestIndicesA");var z=this.outputShape,L=z.length,G=nn(L),Z=Vr("coords",L),be,Ce;if(R===1){Ce=L+1;var De=nn(Ce);be=`
`+De+" sourceLocR = "+De+"("+Z.join()+`, 0);
++`+Z[L-1]+`;
`+De+" sourceLocG = "+De+"("+Z.join()+`, 0);
++`+Z[L-2]+`;
`+De+" sourceLocA = "+De+"("+Z.join()+`, 0);
--`+Z[L-1]+`;
`+De+" sourceLocB = "+De+"("+Z.join()+`, 0);
--`+Z[L-2]+";"}else Ce=L,be=`
`+G+` sourceLocR = coords;
++`+Z[L-1]+`;
`+G+` sourceLocG = coords;
++`+Z[L-2]+`;
`+G+` sourceLocA = coords;
--`+Z[L-1]+`;
`+G+` sourceLocB = coords;
--`+Z[L-2]+";";var Te=["x","y","z","w","u","v"].slice(0,Ce),Ge="."+Te[Ce-1],Ze=Te.map(function(q){return"int "+q}),s=Vr("sourceLocR",Ce-1).concat("inIdx.r"),u=Vr("sourceLocG",Ce-1).concat("inIdx.g"),r=Vr("sourceLocB",Ce-1).concat("inIdx.b"),o=Vr("sourceLocA",Ce-1).concat("inIdx.a"),h=m==="max"?"greaterThan":"lessThan",b=g?"":`
inIdx = round(vec4(getBestIndicesAChannel(`+s.join()+`),
getBestIndicesAChannel(`+u.join()+`),
getBestIndicesAChannel(`+r.join()+`),
getBestIndicesAChannel(`+o.join()+")));",T=`vec4(
getAChannel(`+s.join()+`),
hasNextCol ? getAChannel(`+u.join()+`) : 0.,
hasNextRow ? getAChannel(`+r.join()+`) : 0.,
hasNextRow && hasNextCol ? getAChannel(`+o.join()+") : 0.)",M=g?"":`
float getBestIndicesAChannel(`+Ze.join()+`) {
return getChannel(getBestIndicesA(`+Te.join()+`),
vec2(`+Te.slice(-2).join()+`));
}`;this.userCode=`
float getAChannel(`+Ze.join()+`) {
return getChannel(getA(`+Te.join()+`),
vec2(`+Te.slice(-2).join()+`));
}
`+M+`
void main() {
`+G+` coords = getOutputCoords();
bool hasNextCol = `+Z[L-1]+" < "+(z[L-1]-1)+`;
bool hasNextRow = `+Z[L-2]+" < "+(z[L-2]-1)+`;
`+be+`
ivec4 srcIdx = ivec4(sourceLocR`+Ge+", sourceLocG"+Ge+`,
sourceLocB`+Ge+", sourceLocA"+Ge+") * "+l+`;
ivec4 inIdx = srcIdx;
vec4 bestIndex = vec4(inIdx);
vec4 bestValue = `+T+`;
for (int i = 0; i < `+l+`; i++) {
inIdx = srcIdx;
`+b+`
vec4 candidate = `+T+`;
bvec4 nan = isnan(candidate);
bvec4 replace = bvec4(
vec4(`+h+`(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));
bestValue = vec4(replace.x ? candidate.x : bestValue.x,
replace.y ? candidate.y : bestValue.y,
replace.z ? candidate.z : bestValue.z,
replace.w ? candidate.w : bestValue.w);
bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));
srcIdx++;
}
setOutput(bestIndex);
}
`}return f}(),oi=function(){function f(p){this.variableNames=["dy"],this.outputShape=p.inShape;var l=p.filterHeight,m=p.filterWidth,g=p.strideHeight,I=p.strideWidth,R=p.dilationHeight,z=p.dilationWidth,L=p.effectiveFilterHeight,G=p.effectiveFilterWidth,Z=L-1-p.padInfo.top,be=G-1-p.padInfo.left,Ce=1/(l*m);this.userCode=`
const ivec2 pads = ivec2(`+Z+", "+be+`);
const float avgMultiplier = float(`+Ce+`);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 dyRCCorner = coords.yz - pads;
int dyRCorner = dyRCCorner.x;
int dyCCorner = dyRCCorner.y;
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < `+L+`;
wR += `+R+`) {
float dyR = float(dyRCorner + wR) / `+g+`.0;
if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < `+G+`;
wC+= `+z+`) {
float dyC = float(dyCCorner + wC) / `+I+`.0;
if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(b, idyR, idyC, d);
dotProd += dyValue * avgMultiplier;
}
}
setOutput(dotProd);
}
`}return f}(),Pi=function(){function f(p){this.variableNames=["dy"],this.outputShape=p.inShape;var l=p.filterDepth,m=p.filterHeight,g=p.filterWidth,I=p.strideDepth,R=p.strideHeight,z=p.strideWidth,L=p.dilationDepth,G=p.dilationHeight,Z=p.dilationWidth,be=p.effectiveFilterDepth,Ce=p.effectiveFilterHeight,De=p.effectiveFilterWidth,Te=be-1-p.padInfo.front,Ge=Ce-1-p.padInfo.top,Ze=De-1-p.padInfo.left,s=1/(l*m*g);this.userCode=`
const ivec3 pads = ivec3(`+Te+", "+Ge+", "+Ze+`);
const float avgMultiplier = float(`+s+`);
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
int dyDCorner = dyCorner.x;
int dyRCorner = dyCorner.y;
int dyCCorner = dyCorner.z;
// Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
// dx(xD, xR, xC, ch).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wD = 0; wD < `+be+`;
wD += `+L+`) {
float dyD = float(dyDCorner + wD) / `+I+`.0;
if (dyD < 0.0 || dyD >= `+p.outDepth+`.0 || fract(dyD) > 0.0) {
continue;
}
int idyD = int(dyD);
for (int wR = 0; wR < `+Ce+`;
wR += `+G+`) {
float dyR = float(dyRCorner + wR) / `+R+`.0;
if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 ||
fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < `+De+`;
wC += `+Z+`) {
float dyC = float(dyCCorner + wC) / `+z+`.0;
if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
dotProd += dyValue * avgMultiplier;
}
}
}
setOutput(dotProd);
}
`}return f}(),no=`
if (isnan(a)) return a;
if (isnan(b)) return b;
`,mo=`
float s = sign(a) * sign(b);
int ia = round(a);
int ib = round(b);
if (ib != 0) {
// Windows (D3D) wants guaranteed non-zero int division at compile-time.
return float(idiv(ia, ib, s));
} else {
return NAN;
}
`,Ka=`
if(a < 0.0 && floor(b) < b){
return NAN;
}
if (b == 0.0) {
return 1.0;
}
return (round(mod(b, 2.0)) != 1) ?
pow(abs(a), b) : sign(a) * pow(abs(a), b);
`,ao="return float(a == b);",Ko="return float(a < b);",No="return float(a <= b);",Co="return float(a > b);",io="return float(a >= b);",ia="return float(a >= 1.0 && b >= 1.0);",Pr="return float(a >= 1.0 || b >= 1.0);",oa=no+`
return max(a, b);
`,Xa=no+`
return min(a, b);
`,Qn=`if (b == 0.0) return NAN;
return mod(a, b);`,oo="return (b >= 1.0) ? a : a * (b + 1.0);",ka="return (a < 0.) ? b * a : a;",vn=function(){function f(p,l,m){this.variableNames=["A","B"],this.outputShape=i.backend_util.assertAndGetBroadcastShape(l,m),this.userCode=`
float binaryOperation(float a, float b) {
`+p+`
}
void main() {
float a = getAAtOutCoords();
float b = getBAtOutCoords();
setOutput(binaryOperation(a, b));
}
`}return f}(),Bi=`
result.r = isNaN.r > 0. ? NAN : result.r;
result.g = isNaN.g > 0. ? NAN : result.g;
result.b = isNaN.b > 0. ? NAN : result.b;
result.a = isNaN.a > 0. ? NAN : result.a;
`,yo=`
ivec4 ia = round(a);
ivec4 ib = round(b);
bvec4 cond = notEqual(ib, ivec4(0));
ivec4 result = ivec4(0);
vec4 s = sign(a) * sign(b);
// Windows (D3D) wants guaranteed non-zero int division at compile-time.
if (cond[0]) {
result[0] = idiv(ia[0], ib[0], s[0]);
}
if (cond[1]) {
result[1] = idiv(ia[1], ib[1], s[1]);
}
if (cond[2]) {
result[2] = idiv(ia[2], ib[2], s[2]);
}
if (cond[3]) {
result[3] = idiv(ia[3], ib[3], s[3]);
}
return vec4(result);
`,vo=`
// isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.
vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));
vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);
vec4 result = multiplier * pow(abs(a), b);
// Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS
bvec4 isExpZero = equal(b, vec4(0.0));
result.r = isExpZero.r ? 1.0 : result.r;
result.g = isExpZero.g ? 1.0 : result.g;
result.b = isExpZero.b ? 1.0 : result.b;
result.a = isExpZero.a ? 1.0 : result.a;
vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));
`+Bi+`
return result;
`,Aa=`
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
`,go=`
vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
`,To=`
return vec4(equal(a, b));
`,Rs=`
return vec4(lessThan(a, b));
`,Eo=`
return vec4(lessThanEqual(a, b));
`,As=`
return vec4(greaterThan(a, b));
`,Ds=`
return vec4(greaterThanEqual(a, b));
`,Xo=`
return vec4(
vec4(greaterThanEqual(a, vec4(1.0))) *
vec4(greaterThanEqual(b, vec4(1.0))));
`,Ro=`
return min(
vec4(greaterThanEqual(a, vec4(1.0))) +
vec4(greaterThanEqual(b, vec4(1.0))),
vec4(1.0));
`,Yo=`
vec4 result = vec4(max(a, b));
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
`+Bi+`
return result;
`,Ao=`
vec4 result = vec4(min(a, b));
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
`+Bi+`
return result;
`,Qo=`
vec4 result = mod(a, b);
vec4 isNaN = vec4(equal(b, vec4(0.0)));
`+Bi+`
return result;
`,vi=function(){function f(p,l,m,g){g===void 0&&(g=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i.backend_util.assertAndGetBroadcastShape(l,m);var I=this.outputShape.length,R="";if(g)if(I===0||i.util.sizeFromShape(this.outputShape)===1)R=`
result.y = 0.;
result.z = 0.;
result.w = 0.;
`;else{var z=nn(I);if(R=`
`+z+` coords = getOutputCoords();
`,I===1)R+=`
result.y = (coords + 1) >= `+this.outputShape[0]+` ? 0. : result.y;
result.z = 0.;
result.w = 0.;
`;else{var L=Vr("coords",I);R+=`
bool nextRowOutOfBounds =
(`+L[I-2]+" + 1) >= "+this.outputShape[I-2]+`;
bool nextColOutOfBounds =
(`+L[I-1]+" + 1) >= "+this.outputShape[I-1]+`;
result.y = nextColOutOfBounds ? 0. : result.y;
result.z = nextRowOutOfBounds ? 0. : result.z;
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
`}}this.userCode=`
vec4 binaryOperation(vec4 a, vec4 b) {
`+p+`
}
void main() {
vec4 a = getAAtOutCoords();
vec4 b = getBAtOutCoords();
vec4 result = binaryOperation(a, b);
`+R+`
setOutput(result);
}
`}return f}(),Fs=function(){function f(p){this.variableNames=["A"],this.outputShape=p,this.userCode=`
uniform float minVal;
uniform float maxVal;
void main() {
float value = getAAtOutCoords();
if (isnan(value)) {
setOutput(value);
return;
}
setOutput(clamp(value, minVal, maxVal));
}
`}return f.prototype.getCustomSetupFunc=function(p,l){var m=this;return function(g,I){m.minLoc==null&&(m.minLoc=g.getUniformLocationNoThrow(I,"minVal"),m.maxLoc=g.getUniformLocationNoThrow(I,"maxVal")),g.gl.uniform1f(m.minLoc,p),g.gl.uniform1f(m.maxLoc,l)}},f}(),tu=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p,this.userCode=`
uniform float minVal;
uniform float maxVal;
void main() {
vec4 value = getAAtOutCoords();
if (any(isnan(value))) {
setOutput(value);
return;
}
setOutput(clamp(value, vec4(minVal), vec4(maxVal)));
}
`}return f.prototype.getCustomSetupFunc=function(p,l){var m=this;return function(g,I){m.minLoc==null&&(m.minLoc=g.getUniformLocationNoThrow(I,"minVal"),m.maxLoc=g.getUniformLocationNoThrow(I,"maxVal")),g.gl.uniform1f(m.minLoc,p),g.gl.uniform1f(m.maxLoc,l)}},f}(),ps=function(){function f(p){this.variableNames=["real","imag"],this.outputShape=p,this.userCode=`
void main() {
float re = abs(getRealAtOutCoords());
float im = abs(getImagAtOutCoords());
float mx = max(re, im);
// sadly the length function in glsl is not underflow-safe
// (at least not on Intel GPUs). So the safe solution is
// to ensure underflow-safety in all cases.
setOutput(
mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))
);
}
`}return f}(),ru=function(){function f(p){this.variableNames=["x","dy"],this.outputShape=p.filterShape;var l=p.strideHeight,m=p.strideWidth,g=p.padInfo.top,I=p.padInfo.left,R=p.dataFormat==="channelsLast";this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int wR = coords.x;
int wC = coords.y;
int d1 = coords.z;
int d2 = coords.w;
// Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int b = 0; b < `+p.batchSize+`; b++) {
for (int yR = 0; yR < `+p.outHeight+`; yR++) {
int xR = wR + yR * `+l+" - "+g+`;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int yC = 0; yC < `+p.outWidth+`; yC++) {
int xC = wC + yC * `+m+" - "+I+`;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
if (`+R+`) {
float dyValue = getDy(b, yR, yC, d2);
float xValue = getX(b, xR, xC, d1);
dotProd += (xValue * dyValue);
} else {
float dyValue = getDy(b, d2, yR, yC);
float xValue = getX(b, d1, xR, xC);
dotProd += (xValue * dyValue);
}
}
}
}
setOutput(dotProd);
}
`}return f}(),Os=function(){function f(p){this.variableNames=["dy","W"],this.outputShape=p.inShape;var l=p.filterHeight,m=p.filterWidth,g=p.strideHeight,I=p.strideWidth,R=p.dataFormat==="channelsLast",z=l-1-p.padInfo.top,L=m-1-p.padInfo.left,G=R?1:2,Z=R?2:3,be=R?3:1;this.userCode=`
const ivec2 pads = ivec2(`+z+", "+L+`);
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d1 = coords[`+be+`];
ivec2 dyCorner = ivec2(coords[`+G+"], coords["+Z+`]) - pads;
int dyRCorner = dyCorner.x;
int dyCCorner = dyCorner.y;
// Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < `+l+`; wR++) {
float dyR = float(dyRCorner + wR) / `+g+`.0;
if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = `+l+` - 1 - wR;
for (int wC = 0; wC < `+m+`; wC++) {
float dyC = float(dyCCorner + wC) / `+I+`.0;
if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = `+m+` - 1 - wC;
for (int d2 = 0; d2 < `+p.outChannels+`; d2++) {
if (`+R+`) {
float xValue = getDy(batch, idyR, idyC, d2);
float wValue = getW(wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
} else {
float xValue = getDy(batch, d2, idyR, idyC);
float wValue = getW(wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
}
}
}
}
setOutput(dotProd);
}
`}return f}(),ds=function(){function f(p){this.variableNames=["x","dy"],this.outputShape=p.filterShape;var l=p.strideDepth,m=p.strideHeight,g=p.strideWidth,I=p.padInfo.front,R=p.padInfo.top,z=p.padInfo.left;this.userCode=`
void main() {
ivec5 coords = getOutputCoords();
int wF = coords.x;
int wR = coords.y;
int wC = coords.z;
int d1 = coords.w;
int d2 = coords.u;
float dotProd = 0.0;
for (int b = 0; b < `+p.batchSize+`; b++) {
for (int yF = 0; yF < `+p.outDepth+`; yF++) {
int xF = wF + yF * `+l+" - "+I+`;
if (xF < 0 || xF >= `+p.inDepth+`) {
continue;
}
for (int yR = 0; yR < `+p.outHeight+`; yR++) {
int xR = wR + yR * `+m+" - "+R+`;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int yC = 0; yC < `+p.outWidth+`; yC++) {
int xC = wC + yC * `+g+" - "+z+`;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
float dyValue = getDy(b, yF, yR, yC, d2);
float xValue = getX(b, xF, xR, xC, d1);
dotProd += (xValue * dyValue);
}
}
}
}
setOutput(dotProd);
}
`}return f}(),Ms=function(){function f(p){this.variableNames=["dy","W"],this.outputShape=p.inShape;var l=p.filterDepth,m=p.filterHeight,g=p.filterWidth,I=p.strideDepth,R=p.strideHeight,z=p.strideWidth,L=l-1-p.padInfo.front,G=m-1-p.padInfo.top,Z=g-1-p.padInfo.left;this.userCode=`
const ivec3 pads = ivec3(`+L+", "+G+", "+Z+`);
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int d1 = coords.u;
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
int dyFCorner = dyCorner.x;
int dyRCorner = dyCorner.y;
int dyCCorner = dyCorner.z;
float dotProd = 0.0;
for (int wF = 0; wF < `+l+`; wF++) {
float dyF = float(dyFCorner + wF) / `+I+`.0;
if (dyF < 0.0 || dyF >= `+p.outDepth+`.0 || fract(dyF) > 0.0) {
continue;
}
int idyF = int(dyF);
int wFPerm = `+l+` - 1 - wF;
for (int wR = 0; wR < `+m+`; wR++) {
float dyR = float(dyRCorner + wR) / `+R+`.0;
if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 ||
fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = `+m+` - 1 - wR;
for (int wC = 0; wC < `+g+`; wC++) {
float dyC = float(dyCCorner + wC) / `+z+`.0;
if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = `+g+` - 1 - wC;
for (int d2 = 0; d2 < `+p.outChannels+`; d2++) {
float xValue = getDy(batch, idyF, idyR, idyC, d2);
float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
}
}
}
}
setOutput(dotProd);
}
`}return f}(),Ls=function(){function f(p){this.variableNames=["x","dy"],this.outputShape=p.filterShape;var l=p.strideHeight,m=p.strideWidth,g=p.padInfo.top,I=p.padInfo.left,R=p.outChannels/p.inChannels;this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int wR = coords.x;
int wC = coords.y;
int d1 = coords.z;
int dm = coords.w;
int d2 = d1 * `+R+` + dm;
float dotProd = 0.0;
// TO DO: Vec4 over the batch size
for (int b = 0; b < `+p.batchSize+`; b++) {
for (int yR = 0; yR < `+p.outHeight+`; yR++) {
int xR = wR + yR * `+l+" - "+g+`;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int yC = 0; yC < `+p.outWidth+`; yC++) {
int xC = wC + yC * `+m+" - "+I+`;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
float dyValue = getDy(b, yR, yC, d2);
float xValue = getX(b, xR, xC, d1);
dotProd += (xValue * dyValue);
}
}
}
setOutput(dotProd);
}
`}return f}(),nu=function(){function f(p){this.variableNames=["dy","W"],this.outputShape=p.inShape;var l=p.filterHeight,m=p.filterWidth,g=p.strideHeight,I=p.strideWidth,R=l-1-p.padInfo.top,z=m-1-p.padInfo.left,L=p.outChannels/p.inChannels;this.userCode=`
const ivec2 pads = ivec2(`+R+", "+z+`);
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d1 = coords[3];
ivec2 dyCorner = coords.yz - pads;
int dyRCorner = dyCorner.x;
int dyCCorner = dyCorner.y;
float dotProd = 0.0;
for (int wR = 0; wR < `+l+`; wR++) {
float dyR = float(dyRCorner + wR) / `+g+`.0;
if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = `+l+` - 1 - wR;
for (int wC = 0; wC < `+m+`; wC++) {
float dyC = float(dyCCorner + wC) / `+I+`.0;
if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = `+m+` - 1 - wC;
// TO DO: Vec4 over the channelMul
for (int dm = 0; dm < `+L+`; dm++) {
int d2 = d1 * `+L+` + dm;
float xValue = getDy(batch, idyR, idyC, d2);
float wValue = getW(wRPerm, wCPerm, d1, dm);
dotProd += xValue * wValue;
}
}
}
setOutput(dotProd);
}
`}return f}(),fs=function(){function f(p,l,m,g){l===void 0&&(l=!1),m===void 0&&(m=null),g===void 0&&(g=!1),this.variableNames=["x","W"],this.outputShape=p.outShape;var I=p.padInfo.top,R=p.padInfo.left,z=p.strideHeight,L=p.strideWidth,G=p.dilationHeight,Z=p.dilationWidth,be=p.filterHeight,Ce=p.filterWidth,De=Math.floor(p.inChannels/4)*4,Te=p.inChannels%4,Ge=p.dataFormat==="channelsLast",Ze=Ge?1:2,s=Ge?2:3,u=Ge?3:1,r="",o="";m&&(g?r=`float activation(float a) {
float b = getPreluActivationWeightsAtOutCoords();
`+m+`
}`:r=`
float activation(float x) {
`+m+`
}
`,o="result = activation(result);");var h=l?"result += getBiasAtOutCoords();":"";l&&this.variableNames.push("bias"),g&&this.variableNames.push("preluActivationWeights"),this.userCode=`
`+r+`
const ivec2 strides = ivec2(`+z+", "+L+`);
const ivec2 pads = ivec2(`+I+", "+R+`);
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d2 = coords[`+u+`];
ivec2 xRCCorner =
ivec2(coords[`+Ze+"], coords["+s+`]) * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < `+be+`; wR++) {
int xR = xRCorner + wR * `+G+`;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+Ce+`; wC++) {
int xC = xCCorner + wC * `+Z+`;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
for (int d1 = 0; d1 < `+De+`; d1 += 4) {
vec4 wValues = vec4(
getW(wR, wC, d1, d2),
getW(wR, wC, d1 + 1, d2),
getW(wR, wC, d1 + 2, d2),
getW(wR, wC, d1 + 3, d2)
);
if (`+Ge+`) {
vec4 xValues = vec4(
getX(batch, xR, xC, d1),
getX(batch, xR, xC, d1 + 1),
getX(batch, xR, xC, d1 + 2),
getX(batch, xR, xC, d1 + 3)
);
dotProd += dot(xValues, wValues);
} else {
vec4 xValues = vec4(
getX(batch, d1, xR, xC),
getX(batch, d1 + 1, xR, xC),
getX(batch, d1 + 2, xR, xC),
getX(batch, d1 + 3, xR, xC)
);
dotProd += dot(xValues, wValues);
}
}
if (`+(Te===1)+`) {
if (`+Ge+`) {
dotProd +=
getX(batch, xR, xC, `+De+`) *
getW(wR, wC, `+De+`, d2);
} else {
dotProd +=
getX(batch, `+De+`, xR, xC) *
getW(wR, wC, `+De+`, d2);
}
} else if (`+(Te===2)+`) {
vec2 wValues = vec2(
getW(wR, wC, `+De+`, d2),
getW(wR, wC, `+De+` + 1, d2)
);
if (`+Ge+`) {
vec2 xValues = vec2(
getX(batch, xR, xC, `+De+`),
getX(batch, xR, xC, `+De+` + 1)
);
dotProd += dot(xValues, wValues);
} else {
vec2 xValues = vec2(
getX(batch, `+De+`, xR, xC),
getX(batch, `+De+` + 1, xR, xC)
);
dotProd += dot(xValues, wValues);
}
} else if (`+(Te===3)+`) {
vec3 wValues = vec3(
getW(wR, wC, `+De+`, d2),
getW(wR, wC, `+De+` + 1, d2),
getW(wR, wC, `+De+` + 2, d2)
);
if (`+Ge+`) {
vec3 xValues = vec3(
getX(batch, xR, xC, `+De+`),
getX(batch, xR, xC, `+De+` + 1),
getX(batch, xR, xC, `+De+` + 2)
);
dotProd += dot(xValues, wValues);
} else {
vec3 xValues = vec3(
getX(batch, `+De+`, xR, xC),
getX(batch, `+De+` + 1, xR, xC),
getX(batch, `+De+` + 2, xR, xC)
);
dotProd += dot(xValues, wValues);
}
}
}
}
float result = dotProd;
`+h+`
`+o+`
setOutput(result);
}
`}return f}(),au=function(){function f(p){this.variableNames=["x","W"],this.outputShape=p.outShape;var l=p.padInfo.front,m=p.padInfo.top,g=p.padInfo.left,I=p.strideDepth,R=p.strideHeight,z=p.strideWidth,L=p.dilationDepth,G=p.dilationHeight,Z=p.dilationWidth,be=p.filterDepth,Ce=p.filterHeight,De=p.filterWidth,Te=Math.floor(p.inChannels/4)*4,Ge=p.inChannels%4;this.userCode=`
const ivec3 strides = ivec3(`+I+", "+R+", "+z+`);
const ivec3 pads = ivec3(`+l+", "+m+", "+g+`);
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int d2 = coords.u;
ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
int xFCorner = xFRCCorner.x;
int xRCorner = xFRCCorner.y;
int xCCorner = xFRCCorner.z;
// Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get
// y(yF, yR, yC, d2). ? = to be determined. : = across all
// values in that axis.
float dotProd = 0.0;
for (int wF = 0; wF < `+be+`; wF++) {
int xF = xFCorner + wF * `+L+`;
if (xF < 0 || xF >= `+p.inDepth+`) {
continue;
}
for (int wR = 0; wR < `+Ce+`; wR++) {
int xR = xRCorner + wR * `+G+`;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+De+`; wC++) {
int xC = xCCorner + wC * `+Z+`;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
for (int d1 = 0; d1 < `+Te+`; d1 += 4) {
vec4 xValues = vec4(
getX(batch, xF, xR, xC, d1),
getX(batch, xF, xR, xC, d1 + 1),
getX(batch, xF, xR, xC, d1 + 2),
getX(batch, xF, xR, xC, d1 + 3)
);
vec4 wValues = vec4(
getW(wF, wR, wC, d1, d2),
getW(wF, wR, wC, d1 + 1, d2),
getW(wF, wR, wC, d1 + 2, d2),
getW(wF, wR, wC, d1 + 3, d2)
);
dotProd += dot(xValues, wValues);
}
if (`+(Ge===1)+`) {
dotProd +=
getX(batch, xF, xR, xC, `+Te+`) *
getW(wF, wR, wC, `+Te+`, d2);
} else if (`+(Ge===2)+`) {
vec2 xValues = vec2(
getX(batch, xF, xR, xC, `+Te+`),
getX(batch, xF, xR, xC, `+Te+` + 1)
);
vec2 wValues = vec2(
getW(wF, wR, wC, `+Te+`, d2),
getW(wF, wR, wC, `+Te+` + 1, d2)
);
dotProd += dot(xValues, wValues);
} else if (`+(Ge===3)+`) {
vec3 xValues = vec3(
getX(batch, xF, xR, xC, `+Te+`),
getX(batch, xF, xR, xC, `+Te+` + 1),
getX(batch, xF, xR, xC, `+Te+` + 2)
);
vec3 wValues = vec3(
getW(wF, wR, wC, `+Te+`, d2),
getW(wF, wR, wC, `+Te+` + 1, d2),
getW(wF, wR, wC, `+Te+` + 2, d2)
);
dotProd += dot(xValues, wValues);
}
}
}
}
setOutput(dotProd);
}
`}return f}(),ms=function(){function f(p,l,m,g){l===void 0&&(l=!1),m===void 0&&(m=null),g===void 0&&(g=!1),this.variableNames=["x","W"],this.outputShape=p.outShape;var I=p.inHeight,R=p.inWidth,z=p.padInfo.top,L=p.padInfo.left,G=p.strideHeight,Z=p.strideWidth,be=p.dilationHeight,Ce=p.dilationWidth,De=p.filterHeight,Te=p.filterWidth,Ge=p.outChannels/p.inChannels,Ze="",s="";m&&(g?Ze=`float activation(float a) {
float b = getPreluActivationWeightsAtOutCoords();
`+m+`
}`:Ze=`
float activation(float x) {
`+m+`
}
`,s="result = activation(result);");var u=l?"result += getBiasAtOutCoords();":"";l&&this.variableNames.push("bias"),g&&this.variableNames.push("preluActivationWeights"),this.userCode=`
`+Ze+`
const ivec2 strides = ivec2(`+G+", "+Z+`);
const ivec2 pads = ivec2(`+z+", "+L+`);
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
ivec2 xRCCorner = coords.yz * strides - pads;
int d2 = coords.w;
int d1 = d2 / `+Ge+`;
int q = d2 - d1 * `+Ge+`;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
// TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.
for (int wR = 0; wR < `+De+`; wR++) {
int xR = xRCorner + wR * `+be+`;
if (xR < 0 || xR >= `+I+`) {
continue;
}
for (int wC = 0; wC < `+Te+`; wC++) {
int xC = xCCorner + wC * `+Ce+`;
if (xC < 0 || xC >= `+R+`) {
continue;
}
float xVal = getX(batch, xR, xC, d1);
float wVal = getW(wR, wC, d1, q);
dotProd += xVal * wVal;
}
}
float result = dotProd;
`+u+`
`+s+`
setOutput(result);
}
`}return f}(),Do=function(){function f(p,l,m,g){l===void 0&&(l=!1),m===void 0&&(m=null),g===void 0&&(g=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p.outShape;for(var I=p.inHeight,R=p.inWidth,z=p.padInfo.top,L=p.padInfo.left,G=p.strideHeight,Z=p.strideWidth,be=p.dilationHeight,Ce=p.dilationWidth,De=p.filterHeight,Te=p.filterWidth,Ge=Te,Ze="int xR; int xC; int xCOffset;",s=0;s<De;s++)for(var u=0;u<Te;u++)Ze+=`
vec4 xTexelR`+s+"C"+u*2+` = vec4(0.);
vec4 wR`+s+"C"+u+` = vec4(0.);
vec4 xR`+s+"C"+u+" = vec4(0.);";for(var s=0;s<De;s++)for(var r=0;r<Ge;r++){var u=r*2;if(Ze+=`
xR = xRCorner + `+s*be+`;
xC = xCCorner + `+u*Ce+`;
`,Z===1){if(u<Te&&(L%2===1?Ze+=`
xCOffset = xC + 1;
if(xR >= 0 && xR < `+I+" && xCOffset >= 0 && xCOffset < "+R+`) {
xTexelR`+s+"C"+u+` = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if(xCOffset + 1 >= `+R+`) {
xTexelR`+s+"C"+u+`.zw = vec2(0.);
}
} else {
xTexelR`+s+"C"+u+` = vec4(0.);
}
xCOffset = xC + 1 - 2;
if(xR >= 0 && xR < `+I+" && xCOffset >= 0 && xCOffset < "+R+`) {
vec4 previous = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if(xCOffset + 1 >= `+R+`) {
previous.zw = vec2(0.);
}
xR`+s+"C"+u+" = vec4(previous.zw, xTexelR"+s+"C"+u+`.xy);
} else {
xR`+s+"C"+u+" = vec4(0, 0, xTexelR"+s+"C"+u+`.xy);
}
`:Ze+=`
if(xR >= 0 && xR < `+I+" && xC >= 0 && xC < "+R+`) {
xTexelR`+s+"C"+u+` = getX(batch, xR, xC, d1);
} else {
xTexelR`+s+"C"+u+` = vec4(0.);
}
xR`+s+"C"+u+" = xTexelR"+s+"C"+u+`;
`,u+1<Te)){var o=L%2===0?i.util.nearestLargerEven(Ce):Ce;Ce%2===0&&L%2===1||Ce%2!==0&&L%2!==1?(Ze+=`
xCOffset = xC + `+L%2+" + "+o+`;
if(xR >= 0 && xR < `+I+` &&
xCOffset >= 0 && xCOffset < `+R+`) {
xTexelR`+s+"C"+(u+2)+` = getX(batch, xR, xCOffset, d1);
}
`,Ce>1&&(Ze+=`
xCOffset -= 2;
if(xR >= 0 && xR < `+I+` &&
xCOffset >= 0 && xCOffset < `+R+`) {
xTexelR`+s+"C"+u+` = getX(batch, xR, xCOffset, d1);
} else {
xTexelR`+s+"C"+u+` = vec4(0.);
}
`),Ze+=`
xR`+s+"C"+(u+1)+` = vec4(
xTexelR`+s+"C"+u+".zw, xTexelR"+s+"C"+(u+2)+`.xy);
`):Ze+=`
xCOffset = xC + `+o+`;
if(xR >= 0 && xR < `+I+` &&
xCOffset >= 0 && xCOffset < `+R+`) {
xTexelR`+s+"C"+(u+2)+` = getX(batch, xR, xCOffset, d1);
}
xR`+s+"C"+(u+1)+" = xTexelR"+s+"C"+(u+2)+`;
`}}else u<Te&&(Ze+=`
if(xR >= 0 && xR < `+I+`) {
`,L%2===1?(Ze+=`
xCOffset = xC + 1 - `+Z+`;
if(xCOffset >= 0 && xCOffset < `+R+`) {
xTexelR`+s+"C"+u+` = getX(batch, xR, xCOffset, d1);
} else {
xTexelR`+s+"C"+u+` = vec4(0.);
}
if(xC + 1 >= 0 && xC + 1 < `+R+`) {
xTexelR`+s+"C"+(u+2)+` = getX(batch, xR, xC + 1, d1);
} else {
xTexelR`+s+"C"+(u+2)+` = vec4(0.);
}
xR`+s+"C"+u+` = vec4(
xTexelR`+s+"C"+u+".zw, xTexelR"+s+"C"+(u+2)+`.zw);
`,u+1<Te&&(Ze+=`
vec4 final = vec4(0.);
xCOffset = xC + 1 + `+Z+`;
if(xCOffset >= 0 && xCOffset < `+R+`) {
final = getX(batch, xR, xCOffset, d1);
}
xR`+s+"C"+(u+1)+" = vec4(xTexelR"+s+"C"+(u+2)+`.xy, final.xy);
`)):(Ze+=`
if(xC >= 0 && xC < `+R+`) {
xTexelR`+s+"C"+u+` = getX(batch, xR, xC, d1);
} else {
xTexelR`+s+"C"+u+` = vec4(0.);
}
xCOffset = xC + `+Z+`;
if(xCOffset >= 0 && xCOffset < `+R+`) {
xTexelR`+s+"C"+(u+2)+` = getX(batch, xR, xCOffset, d1);
} else {
xTexelR`+s+"C"+(u+2)+` = vec4(0.);
}
xR`+s+"C"+u+` = vec4(
xTexelR`+s+"C"+u+".xy, xTexelR"+s+"C"+(u+2)+`.xy);
`,u+1<Te&&(Ze+=`
xR`+s+"C"+(u+1)+` = vec4(
xTexelR`+s+"C"+u+".zw, xTexelR"+s+"C"+(u+2)+`.zw);
`)),Ze+="}");u<Te&&(Ze+=`
vec4 wTexelR`+s+"C"+u+" = getW("+s+", "+u+`, d1, q);
wR`+s+"C"+u+" = vec4(wTexelR"+s+"C"+u+".xz, wTexelR"+s+"C"+u+`.xz);
`,u+1<Te&&(Ze+=`
vec4 wTexelR`+s+"C"+(u+1)+" = getW("+s+", "+(u+1)+`, d1, q);
wR`+s+"C"+(u+1)+` =
vec4(wTexelR`+s+"C"+(u+1)+".xz, wTexelR"+s+"C"+(u+1)+".xz);"))}for(var s=0;s<De;s++)for(var u=0;u<Te;u++)Ze+="dotProd += xR"+s+"C"+u+" * wR"+s+"C"+u+";";var h="",b="";m&&(g?h=`vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
`+m+`
}`:h=`vec4 activation(vec4 x) {
`+m+`
}`,b="result = activation(result);");var T=l?"result += getBiasAtOutCoords();":"";l&&this.variableNames.push("bias"),g&&this.variableNames.push("preluActivationWeights"),this.userCode=`
`+h+`
const ivec2 strides = ivec2(`+G+", "+Z+`);
const ivec2 pads = ivec2(`+z+", "+L+`);
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
ivec2 xRCCorner = coords.yz * strides - pads;
int d2 = coords.w;
int d1 = d2;
int q = 0;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
vec4 dotProd = vec4(0.);
`+Ze+`
vec4 result = dotProd;
`+T+`
`+b+`
setOutput(result);
}
`}return f}(),zs=function(){function f(p,l,m,g,I){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var R=p[0],z=p[1],L=p[2],G=p[3],Z=l[0],be=m[0],Ce=m[1];this.outputShape=[Z,be,Ce,G];var De=g==="bilinear"?1:0,Te=[z-1+".0",L-1+".0"],Ge=Te[0],Ze=Te[1],s=be>1?[""+(z-1)/(be-1),"(y2-y1) * height_ratio","y1*"+Ge+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+Ge],u=s[0],r=s[1],o=s[2],h=Ce>1?[""+(L-1)/(Ce-1),"(x2-x1) * width_ratio","x1*"+Ze+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+Ze],b=h[0],T=h[1],M=h[2];this.userCode=`
const float height_ratio = float(`+u+`);
const float width_ratio = float(`+b+`);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int y = coords[1];
int x = coords[2];
int d = coords[3];
// get box vals
float y1 = getBoxes(b,0);
float x1 = getBoxes(b,1);
float y2 = getBoxes(b,2);
float x2 = getBoxes(b,3);
// get image in batch index
int bInd = round(getBoxInd(b));
if(bInd < 0 || bInd >= `+R+`) {
return;
}
float height_scale = `+r+`;
float width_scale = `+T+`;
float in_y = `+o+`;
if( in_y < 0.0 || in_y > `+Ge+` ) {
setOutput(float(`+I+`));
return;
}
float in_x = `+M+`;
if( in_x < 0.0 || in_x > `+Ze+` ) {
setOutput(float(`+I+`));
return;
}
vec2 sourceFracIndexCR = vec2(in_x,in_y);
if(`+De+` == 1) {
// Compute the four integer indices.
ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);
ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));
float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);
float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);
float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);
float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);
vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);
float top = topLeft + (topRight - topLeft) * fracCR.x;
float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;
float newValue = top + (bottom - top) * fracCR.y;
setOutput(newValue);
} else {
// Compute the coordinators of nearest neighbor point.
ivec2 sourceNearestCR = ivec2(floor(
sourceFracIndexCR + vec2(0.5,0.5)));
float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);
setOutput(newValue);
}
}
`}return f}(),Zo=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=p;var g=p.length,I=l?"0.0":"getX("+xo(g,"coords")+")",R=p[p.length-1],z="",L="";l?(z=m?"end != "+(R-1):"end != 0",L=m?"end + 1":"end - 1"):(z=m?"end + pow2 < "+R:"end >= pow2",L=m?"end + pow2":"end - pow2"),this.userCode=`
uniform float index;
void main() {
`+nn(g)+` coords = getOutputCoords();
int end = `+ys(g,"coords")+`;
float val = `+I+`;
int pow2 = int(pow(2.0, index));
if (`+z+`) {
int idx = `+L+`;
`+ys(g,"coords")+` = idx;
val += getX(`+xo(g,"coords")+`);
}
setOutput(val);
}
`}return f.prototype.getCustomSetupFunc=function(p){var l=this;return function(m,g){l.index==null&&(l.index=m.getUniformLocation(g,"index")),m.gl.uniform1f(l.index,p)}},f}();function xo(f,p){if(f===1)return""+p;if(f===2)return p+".x, "+p+".y";if(f===3)return p+".x, "+p+".y, "+p+".z";if(f===4)return p+".x, "+p+".y, "+p+".z, "+p+".w";throw Error("Cumulative sum for rank "+f+" is not yet supported")}function ys(f,p){if(f===1)return""+p;if(f===2)return p+".y";if(f===3)return p+".z";if(f===4)return p+".w";throw Error("Cumulative sum for rank "+f+" is not yet supported")}var Fo=function(){function f(p){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=ae.DENSE;var l=nt(p),m=tn();this.outputShape=p,this.userCode=`
ivec3 outCoordsFromFlatIndex(int index) {
`+Rn(["r","c","d"],p)+`
return ivec3(r, c, d);
}
void main() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+l[0]+", "+l[1]+`));
int index = 4 * (resTexRC.x * `+l[1]+` + resTexRC.y);
vec4 result = vec4(0.);
for (int i=0; i<4; i++) {
int flatIndex = index + i;
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
result[i] = getA(rc.x, rc.y, rc.z);
}
`+m.output+` = result;
}
`}return f}(),Ps=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=ae.DENSE;var l=nt(p),m=tn();this.outputShape=p,this.userCode=`
ivec3 outCoordsFromFlatIndex(int index) {
`+Rn(["r","c","d"],p)+`
return ivec3(r, c, d);
}
void main() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(`+l[0]+", "+l[1]+`));
int index = 4 * (resTexRC.x * `+l[1]+` + resTexRC.y);
vec4 result = vec4(0.);
for (int i=0; i<4; i++) {
int flatIndex = index + i;
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));
}
`+m.output+` = result;
}
`}return f}(),Jo=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=[],this.outputShape=p,this.blockSize=l,this.dataFormat=m,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int h = `+this.getHeightCoordString()+`;
int w = `+this.getWidthCoordString()+`;
int d = `+this.getDepthCoordString()+`;
int in_h = h / `+l+`;
int offset_h = imod(h, `+l+`);
int in_w = w / `+l+`;
int offset_w = imod(w, `+l+`);
int offset_d = (offset_h * `+l+` + offset_w) *
`+this.getOutputDepthSize()+`;
int in_d = d + offset_d;
float result = `+this.getInputSamplingString()+`;
setOutput(result);
}
`}return f.prototype.getHeightCoordString=function(){return this.dataFormat==="NHWC"?"coords[1]":"coords[2]"},f.prototype.getWidthCoordString=function(){return this.dataFormat==="NHWC"?"coords[2]":"coords[3]"},f.prototype.getDepthCoordString=function(){return this.dataFormat==="NHWC"?"coords[3]":"coords[1]"},f.prototype.getOutputDepthSize=function(){return this.dataFormat==="NHWC"?this.outputShape[3]:this.outputShape[1]},f.prototype.getInputSamplingString=function(){return this.dataFormat==="NHWC"?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"},f}(),_o=function(){function f(p){this.variableNames=["X"],this.outputShape=[p,p],this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;
setOutput(val);
}
`}return f}(),wo=function(){function f(p){this.variableNames=["A"],this.outTexUsage=w.DOWNLOAD;var l=tn();this.outputShape=p,this.userCode=`
`+aa+`
void main() {
float x = getAAtOutCoords();
`+l.output+` = encode_float(x);
}
`}return f}(),Bs=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=w.DOWNLOAD;var l=tn();this.outputShape=p,this.userCode=`
`+aa+`
void main() {
ivec3 coords = getOutputCoords();
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
`+l.output+` = encode_float(x);
}
`}return f}(),Ws=function(){function f(p,l,m){m===void 0&&(m=!1),this.variableNames=["A"];var g=tn(),I=l[0],R=l[1];this.outputShape=p;var z="result";m&&(z="floor(result * 255. + 0.5)"),this.userCode=`
`+Kn(p)+`
void main() {
ivec3 coords = getOutputCoords();
int flatIndex = getFlatIndex(coords);
int offset = imod(flatIndex, 4);
flatIndex = idiv(flatIndex, 4, 1.);
int r = flatIndex / `+R+`;
int c = imod(flatIndex, `+R+`);
vec2 uv = (vec2(c, r) + halfCR) / vec2(`+R+".0, "+I+`.0);
vec4 values = `+g.texture2D+`(A, uv);
float result;
if(offset == 0) {
result = values[0];
} else if(offset == 1) {
result = values[1];
} else if(offset == 2) {
result = values[2];
} else {
result = values[3];
}
`+g.output+" = vec4("+z+`, 0., 0., 0.);
}
`}return f}(),vs=function(){function f(p,l,m){m===void 0&&(m=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var g=tn(),I=l[0],R=l[1];this.outputShape=p;var z="",L="result";m&&(L="floor(result * 255. + 0.5)");for(var G=0;G<=1;G++)for(var Z=0;Z<=1;Z++){var be=G*2+Z;z+=`
localCoords = coords;
if(localCoords[2] + `+Z+" < "+p[2]+`) {
localCoords[2] += `+Z+`;
if(localCoords[1] + `+G+" < "+p[1]+`) {
localCoords[1] += `+G+`;
flatIndex = getFlatIndex(localCoords);
offset = imod(flatIndex, 4);
flatIndex = idiv(flatIndex, 4, 1.);
r = flatIndex / `+R+`;
c = imod(flatIndex, `+R+`);
uv = (vec2(c, r) + halfCR) / vec2(`+R+".0, "+I+`.0);
values = `+g.texture2D+`(A, uv);
if(offset == 0) {
result[`+be+`] = values[0];
} else if(offset == 1) {
result[`+be+`] = values[1];
} else if(offset == 2) {
result[`+be+`] = values[2];
} else {
result[`+be+`] = values[3];
}
}
}
`}this.userCode=`
`+Kn(p)+`
void main() {
ivec3 coords = getOutputCoords();
vec4 result = vec4(0.);
int flatIndex, r, c, offset;
ivec3 localCoords;
vec2 uv;
vec4 values;
`+z+`
`+g.output+" = "+L+`;
}
`}return f}(),$o=function(){function f(p,l){this.outputShape=[],this.variableNames=["x"],this.outputShape=p,this.userCode=`
uniform float value;
void main() {
// Input can be obtained from uniform value.
setOutput(value);
}
`}return f.prototype.getCustomSetupFunc=function(p){var l=this;return function(m,g){l.valueLoc==null&&(l.valueLoc=m.getUniformLocationNoThrow(g,"value")),m.gl.uniform1f(l.valueLoc,p)}},f}(),iu=function(){function f(p,l,m){this.variableNames=["A","indices"];var g=p.slice();g[m]=l,this.outputShape=g,this.rank=g.length;var I=nn(this.rank),R=ku(p,m);this.userCode=`
void main() {
`+I+` resRC = getOutputCoords();
setOutput(getA(`+R+`));
}
`}return f}();function ku(f,p){var l=f.length;if(l>4)throw Error("Gather for rank "+l+" is not yet supported");if(l===1)return"int(getIndices(resRC))";for(var m=["resRC.x","resRC.y","resRC.z","resRC.w"],g=[],I=0;I<f.length;I++)I===p?g.push("int(getIndices("+m[I]+"))"):g.push(""+m[I]);return g.join()}var ou=function(){function f(p,l,m){this.sliceDim=p,this.strides=l,this.variableNames=["x","indices"],this.outputShape=m;var g=nn(l.length),I=nn(m.length),R=this.sliceDim>1?"strides[j]":"strides";this.userCode=`
`+g+" strides = "+g+"("+this.strides+`);
void main() {
`+I+` coords = getOutputCoords();
int flattenIndex = 0;
for (int j = 0; j < `+this.sliceDim+`; j++) {
int index = round(getIndices(coords[0], j));
flattenIndex += index * `+R+`;
}
setOutput(getX(flattenIndex, coords[1]));
}
`}return f}();function Oo(f){var p=tn(),l=p.version+`
precision highp float;
`+p.attribute+` vec3 clipSpacePos;
`+p.attribute+` vec2 uv;
`+p.varyingVs+` vec2 resultUV;
void main() {
gl_Position = vec4(clipSpacePos, 1);
resultUV = uv;
}`;return Zt(f,l)}function Mo(f){var p=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return Fa(f,p)}function gs(f){var p=new Uint16Array([0,1,2,2,1,3]);return Oa(f,p)}function es(f,p,l,m,g,I){Na(p,l);var R=Wa(f),z=f.TEXTURE_2D;return Qe(f,function(){return f.bindTexture(z,R)}),Qe(f,function(){return f.texParameteri(z,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE)}),Qe(f,function(){return f.texParameteri(z,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE)}),Qe(f,function(){return f.texParameteri(z,f.TEXTURE_MIN_FILTER,f.NEAREST)}),Qe(f,function(){return f.texParameteri(z,f.TEXTURE_MAG_FILTER,f.NEAREST)}),Qe(f,function(){return f.texImage2D(z,0,m,p,l,0,g,I,null)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,null)}),R}function Si(f){return f.internalFormatFloat}function Lo(f,p,l,m){var g=ze(p,l),I=g[0],R=g[1];return es(f,I,R,Si(m),m.textureFormatFloat,f.FLOAT)}function zo(f){return f.internalFormatHalfFloat}function Xi(f,p,l,m){var g=ze(p,l),I=g[0],R=g[1];return es(f,I,R,zo(m),m.textureFormatFloat,m.textureTypeHalfFloat)}function ts(f){return f.downloadTextureFormat}function ne(f,p,l,m){var g=ze(p,l),I=g[0],R=g[1];return es(f,I,R,ts(m),f.RGBA,f.UNSIGNED_BYTE)}function ue(f){return f.internalFormatPackedFloat}function E(f,p,l,m){var g=tt(p,l),I=g[0],R=g[1];return es(f,I,R,ue(m),f.RGBA,f.FLOAT)}function F(f){return f.internalFormatPackedHalfFloat}function A(f,p,l,m){var g=tt(p,l),I=g[0],R=g[1];return es(f,I,R,F(m),f.RGBA,m.textureTypeHalfFloat)}function V(f,p,l){var m=0,g=3*4,I=3*4+2*4;Qe(f,function(){return f.bindBuffer(f.ARRAY_BUFFER,l)});var R=Ma(f,p,"clipSpacePos",l,3,I,m);return R&&Ma(f,p,"uv",l,2,I,g)}function oe(f,p,l,m,g,I){Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,p)});var R,z,L;g instanceof Uint8Array?(R=new Uint8Array(l*m*4),z=f.UNSIGNED_BYTE,L=f.RGBA):(R=new Float32Array(l*m*4),z=f.FLOAT,L=I.internalFormatPackedFloat),R.set(g),Qe(f,function(){return f.texImage2D(f.TEXTURE_2D,0,L,l,m,0,f.RGBA,z,R)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function ee(f,p,l){Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,p)}),l.data instanceof Uint8Array?Qe(f,function(){return f.texImage2D(f.TEXTURE_2D,0,f.RGBA,l.width,l.height,0,f.RGBA,f.UNSIGNED_BYTE,l.data)}):Qe(f,function(){return f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,l)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function _e(f,p,l,m){var g=f.createBuffer();Qe(f,function(){return f.bindBuffer(f.PIXEL_PACK_BUFFER,g)});var I=4,R=4,z=I*R*p*l;return Qe(f,function(){return f.bufferData(f.PIXEL_PACK_BUFFER,z,f.STREAM_READ)}),Qe(f,function(){return f.readPixels(0,0,l,p,f.RGBA,f.FLOAT,0)}),Qe(f,function(){return f.bindBuffer(f.PIXEL_PACK_BUFFER,null)}),g}function ce(f,p,l){var m=f,g=new Float32Array(l);return m.bindBuffer(m.PIXEL_PACK_BUFFER,p),m.getBufferSubData(m.PIXEL_PACK_BUFFER,0,g),m.bindBuffer(m.PIXEL_PACK_BUFFER,null),g}function de(f,p,l,m){var g=ze(p,l),I=g[0],R=g[1],z=4,L=new Uint8Array(W(p*l,z));return Qe(f,function(){return f.readPixels(0,0,I,R,m.downloadTextureFormat,f.UNSIGNED_BYTE,L)}),new Float32Array(L.buffer)}function ye(f,p,l,m,g,I,R,z){var L=f,G=new Float32Array(nr(I,R));return L.bindBuffer(L.PIXEL_PACK_BUFFER,p),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,G),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),G}function ve(f,p,l){var m=new Float32Array(p*l*4);return Qe(f,function(){return f.readPixels(0,0,l,p,f.RGBA,f.FLOAT,m)}),m}var Re={__proto__:null,createVertexShader:Oo,createVertexBuffer:Mo,createIndexBuffer:gs,getInternalFormatForFloat32MatrixTexture:Si,createFloat32MatrixTexture:Lo,getInternalFormatForFloat16MatrixTexture:zo,createFloat16MatrixTexture:Xi,getInternalFormatForUnsignedBytesMatrixTexture:ts,createUnsignedBytesMatrixTexture:ne,getInternalFormatForPackedMatrixTexture:ue,createPackedMatrixTexture:E,getInternalFormatForFloat16PackedMatrixTexture:F,createFloat16PackedMatrixTexture:A,bindVertexProgramAttributeStreams:V,uploadDenseMatrixToTexture:oe,uploadPixelDataToTexture:ee,createBufferFromOutputTexture:_e,downloadFloat32MatrixFromBuffer:ce,downloadByteEncodedFloatMatrixFromOutputTexture:de,downloadPackedMatrixFromBuffer:ye,downloadMatrixFromPackedOutputTexture:ve},Oe=function(){function f(p){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var l=i.env().getNumber("WEBGL_VERSION");p!=null?(this.gl=p,Ae(l,p)):this.gl=P(l);var m="WEBGL_color_buffer_float",g="EXT_color_buffer_half_float";if(i.env().getNumber("WEBGL_VERSION")===1){var I="OES_texture_float",R="OES_texture_half_float";if(this.textureFloatExtension=yt(this.gl,I),qn(this.gl,R))this.textureHalfFloatExtension=yt(this.gl,R);else if(i.env().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(m),qn(this.gl,g))this.colorBufferHalfFloatExtension=yt(this.gl,g);else if(i.env().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(m="EXT_color_buffer_float",qn(this.gl,m))this.colorBufferFloatExtension=this.gl.getExtension(m);else if(qn(this.gl,g))this.colorBufferHalfFloatExtension=this.gl.getExtension(g);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=Mo(this.gl),this.indexBuffer=gs(this.gl),this.framebuffer=yn(this.gl),this.textureConfig=Tt(this.gl,this.textureHalfFloatExtension)}return Object.defineProperty(f.prototype,"debug",{get:function(){return i.env().getBool("DEBUG")},enumerable:!0,configurable:!0}),f.prototype.dispose=function(){var p=this;if(this.disposed)return;this.program!=null&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),this.outputTexture!=null&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");var l=this.gl;Qe(l,function(){return l.finish()}),Qe(l,function(){return l.bindFramebuffer(l.FRAMEBUFFER,null)}),Qe(l,function(){return l.deleteFramebuffer(p.framebuffer)}),Qe(l,function(){return l.bindBuffer(l.ARRAY_BUFFER,null)}),Qe(l,function(){return l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)}),Qe(l,function(){return l.deleteBuffer(p.indexBuffer)}),this.disposed=!0},f.prototype.createFloat32MatrixTexture=function(p,l){return this.throwIfDisposed(),Lo(this.gl,p,l,this.textureConfig)},f.prototype.createFloat16MatrixTexture=function(p,l){return this.throwIfDisposed(),Xi(this.gl,p,l,this.textureConfig)},f.prototype.createUnsignedBytesMatrixTexture=function(p,l){return this.throwIfDisposed(),ne(this.gl,p,l,this.textureConfig)},f.prototype.uploadPixelDataToTexture=function(p,l){this.throwIfDisposed(),ee(this.gl,p,l)},f.prototype.uploadDenseMatrixToTexture=function(p,l,m,g){this.throwIfDisposed(),oe(this.gl,p,l,m,g,this.textureConfig)},f.prototype.createFloat16PackedMatrixTexture=function(p,l){return this.throwIfDisposed(),A(this.gl,p,l,this.textureConfig)},f.prototype.createPackedMatrixTexture=function(p,l){return this.throwIfDisposed(),E(this.gl,p,l,this.textureConfig)},f.prototype.deleteMatrixTexture=function(p){var l=this;this.throwIfDisposed(),this.outputTexture===p&&(_i(this.gl,this.framebuffer),this.outputTexture=null),Qe(this.gl,function(){return l.gl.deleteTexture(p)})},f.prototype.downloadByteEncodedFloatMatrixFromOutputTexture=function(p,l,m){var g=this;return this.downloadMatrixDriver(p,function(){return de(g.gl,l,m,g.textureConfig)})},f.prototype.downloadPackedMatrixFromBuffer=function(p,l,m,g,I,R){return ye(this.gl,p,l,m,g,I,R,this.textureConfig)},f.prototype.downloadFloat32MatrixFromBuffer=function(p,l){return ce(this.gl,p,l)},f.prototype.createBufferFromTexture=function(p,l,m){this.bindTextureToFrameBuffer(p);var g=_e(this.gl,l,m,this.textureConfig);return this.unbindTextureToFrameBuffer(),g},f.prototype.createAndWaitForFence=function(){var p=this.createFence(this.gl);return this.pollFence(p)},f.prototype.createFence=function(p){var l=this,m,g;if(i.env().getBool("WEBGL_FENCE_API_ENABLED")){var I=p,R=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);p.flush(),g=function(){var z=I.clientWaitSync(R,0,0);return z===I.ALREADY_SIGNALED||z===I.CONDITION_SATISFIED},m=R}else i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(m=this.beginQuery(),this.endQuery(),g=function(){return l.isQueryAvailable(m,i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):g=function(){return!0};return{query:m,isFencePassed:g}},f.prototype.downloadMatrixFromPackedTexture=function(p,l,m){var g=this;return this.downloadMatrixDriver(p,function(){return ve(g.gl,l,m)})},f.prototype.createProgram=function(p){this.throwIfDisposed();var l=this.gl,m=ar(l,p),g=Oo(l),I=jr(l);return Qe(l,function(){return l.attachShader(I,g)}),Qe(l,function(){return l.attachShader(I,m)}),_r(l,I),this.debug&&tr(l,I),this.vertexAttrsAreBound||(this.setProgram(I),this.vertexAttrsAreBound=V(l,this.program,this.vertexBuffer)),I},f.prototype.deleteProgram=function(p){var l=this;this.throwIfDisposed(),p===this.program&&(this.program=null),p!=null&&Qe(this.gl,function(){return l.gl.deleteProgram(p)})},f.prototype.setProgram=function(p){var l=this;this.throwIfDisposed(),this.program=p,this.program!=null&&this.debug&&tr(this.gl,this.program),Qe(this.gl,function(){return l.gl.useProgram(p)})},f.prototype.getUniformLocation=function(p,l,m){return m===void 0&&(m=!0),this.throwIfDisposed(),m?la(this.gl,p,l):rn(this.gl,p,l)},f.prototype.getAttributeLocation=function(p,l){var m=this;return this.throwIfDisposed(),Qe(this.gl,function(){return m.gl.getAttribLocation(p,l)})},f.prototype.getUniformLocationNoThrow=function(p,l){return this.throwIfDisposed(),this.gl.getUniformLocation(p,l)},f.prototype.setInputMatrixTexture=function(p,l,m){this.throwIfDisposed(),this.throwIfNoProgram(),Ca(this.gl,p,l,m)},f.prototype.setOutputMatrixTexture=function(p,l,m){this.setOutputMatrixTextureDriver(p,m,l)},f.prototype.setOutputPackedMatrixTexture=function(p,l,m){this.throwIfDisposed();var g=tt(l,m),I=g[0],R=g[1];this.setOutputMatrixTextureDriver(p,I,R)},f.prototype.setOutputMatrixWriteRegion=function(p,l,m,g){this.setOutputMatrixWriteRegionDriver(m,p,g,l)},f.prototype.setOutputPackedMatrixWriteRegion=function(p,l,m,g){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")},f.prototype.debugValidate=function(){this.program!=null&&tr(this.gl,this.program),ha(this.gl)},f.prototype.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var p=this.gl;this.debug&&this.debugValidate(),Qe(p,function(){return p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0)})},f.prototype.blockUntilAllProgramsCompleted=function(){var p=this;this.throwIfDisposed(),Qe(this.gl,function(){return p.gl.finish()})},f.prototype.getQueryTimerExtension=function(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=yt(this.gl,i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension},f.prototype.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension()},f.prototype.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension()},f.prototype.beginQuery=function(){if(i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){var p=this.gl,l=this.getQueryTimerExtensionWebGL2(),m=p.createQuery();return p.beginQuery(l.TIME_ELAPSED_EXT,m),m}var g=this.getQueryTimerExtensionWebGL1(),I=g.createQueryEXT();return g.beginQueryEXT(g.TIME_ELAPSED_EXT,I),I},f.prototype.endQuery=function(){if(i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){var p=this.gl,l=this.getQueryTimerExtensionWebGL2();p.endQuery(l.TIME_ELAPSED_EXT);return}var m=this.getQueryTimerExtensionWebGL1();m.endQueryEXT(m.TIME_ELAPSED_EXT)},f.prototype.waitForQueryAndGetTime=function(p){return H(this,void 0,void 0,function(){var l=this;return se(this,function(m){switch(m.label){case 0:return[4,i.util.repeatedTry(function(){return l.disposed||l.isQueryAvailable(p,i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))})];case 1:return m.sent(),[2,this.getQueryTime(p,i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))]}})})},f.prototype.getQueryTime=function(p,l){if(l===0)return null;if(l===2){var m=this.gl,g=m.getQueryParameter(p,m.QUERY_RESULT);return g/1e6}else{var I=this.getQueryTimerExtensionWebGL1(),g=I.getQueryObjectEXT(p,I.QUERY_RESULT_EXT);return g/1e6}},f.prototype.isQueryAvailable=function(p,l){if(l===0)return!0;if(l===2){var m=this.gl,g=this.getQueryTimerExtensionWebGL2(),I=m.getQueryParameter(p,m.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(g.GPU_DISJOINT_EXT)),I&&!this.disjoint}else{var g=this.getQueryTimerExtensionWebGL1(),I=g.getQueryObjectEXT(p,g.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(g.GPU_DISJOINT_EXT)),I&&!this.disjoint}},f.prototype.pollFence=function(p){var l=this;return new Promise(function(m){l.addItemToPoll(function(){return p.isFencePassed()},function(){return m()})})},f.prototype.pollItems=function(){for(var p=Fe(this.itemsToPoll.map(function(g){return g.isDoneFn})),l=0;l<=p;++l){var m=this.itemsToPoll[l].resolveFn;m()}this.itemsToPoll=this.itemsToPoll.slice(p+1)},f.prototype.addItemToPoll=function(p,l){var m=this;if(this.itemsToPoll.push({isDoneFn:p,resolveFn:l}),this.itemsToPoll.length>1)return;i.util.repeatedTry(function(){return m.pollItems(),m.itemsToPoll.length===0})},f.prototype.bindTextureToFrameBuffer=function(p){this.throwIfDisposed(),Hn(this.gl,p,this.framebuffer),this.debug&&ha(this.gl)},f.prototype.unbindTextureToFrameBuffer=function(){this.outputTexture!=null?(Hn(this.gl,this.outputTexture,this.framebuffer),this.debug&&ha(this.gl)):_i(this.gl,this.framebuffer)},f.prototype.downloadMatrixDriver=function(p,l){this.bindTextureToFrameBuffer(p);var m=l();return this.unbindTextureToFrameBuffer(),m},f.prototype.setOutputMatrixTextureDriver=function(p,l,m){this.throwIfDisposed();var g=this.gl;Hn(g,p,this.framebuffer),this.debug&&ha(g),this.outputTexture=p,Qe(g,function(){return g.viewport(0,0,l,m)}),Qe(g,function(){return g.scissor(0,0,l,m)})},f.prototype.setOutputMatrixWriteRegionDriver=function(p,l,m,g){var I=this;this.throwIfDisposed(),Qe(this.gl,function(){return I.gl.scissor(p,l,m,g)})},f.prototype.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")},f.prototype.throwIfNoProgram=function(){if(this.program==null)throw new Error("No GPU program is currently set.")},f}();function Fe(f){for(var p=0;p<f.length;++p){var l=f[p]();if(!l)break}return p-1}function Ve(f,p,l,m){var g=p.userCode,I=l.map(function(Ze,s){var u={logicalShape:Ze.shape,texShape:Ze.isUniform?null:Ze.texData.texShape,isUniform:Ze.isUniform,isPacked:Ze.isUniform?!1:Ze.texData.isPacked,flatOffset:null};return Ze.texData!=null&&Ze.texData.slice!=null&&Ze.texData.slice.flatOffset>0&&(u.flatOffset=Ze.texData.slice.flatOffset),{name:p.variableNames[s],shapeInfo:u}}),R=I.map(function(Ze){return Ze.shapeInfo}),z={logicalShape:m.shape,texShape:m.texData.texShape,isUniform:!1,isPacked:m.texData.isPacked,flatOffset:null},L=Li(I,z,g,p.packedInputs),G=f.createProgram(L),Z=null,be=f.getUniformLocation(G,"NAN",!1);i.env().getNumber("WEBGL_VERSION")===1&&(Z=f.getUniformLocation(G,"INFINITY",!1));for(var Ce={},De=0;De<p.variableNames.length;De++){var Te=p.variableNames[De],Ge=!1;Ce[Te]=f.getUniformLocation(G,Te,Ge),Ce["offset"+Te]=f.getUniformLocation(G,"offset"+Te,Ge)}return{program:p,source:L,webGLProgram:G,uniformLocations:Ce,inShapeInfos:R,outShapeInfo:z,infLoc:Z,nanLoc:be}}function Xe(f,p){if(f.length!==p.length)throw Error("Binary was compiled with "+f.length+" inputs, but "+("was executed with "+p.length+" inputs"));f.forEach(function(l,m){var g=l.logicalShape,I=p[m],R=I.shape;if(!i.util.arraysEqual(g,R))throw Error("Binary was compiled with different shapes than "+("the current args. Shapes "+g+" and "+R+" must match"));if(l.isUniform&&I.isUniform)return;var z=l.texShape,L=I.isUniform?null:I.texData.texShape;if(!i.util.arraysEqual(z,L))throw Error("Binary was compiled with different texture shapes than the"+(" current args. Shape "+z+" and "+L+" must match"))})}function rt(f,p,l,m,g){Xe(p.inShapeInfos,l),Xe([p.outShapeInfo],[m]);var I=m.texData.texture,R=m.texData.texShape;m.texData.isPacked?f.setOutputPackedMatrixTexture(I,R[0],R[1]):f.setOutputMatrixTexture(I,R[0],R[1]),f.setProgram(p.webGLProgram),i.env().getNumber("WEBGL_VERSION")===1&&p.infLoc!==null&&f.gl.uniform1f(p.infLoc,Infinity),p.nanLoc!==null&&f.gl.uniform1f(p.nanLoc,NaN),l.forEach(function(z,L){var G=p.program.variableNames[L],Z=p.uniformLocations[G],be=p.uniformLocations["offset"+G];if(Z==null)return;if(z.isUniform){if(i.util.sizeFromShape(z.shape)<2)f.gl.uniform1f(Z,z.uniformValues[0]);else{var Ce=z.uniformValues;Ce instanceof Float32Array||(Ce=new Float32Array(Ce)),f.gl.uniform1fv(Z,Ce)}return}z.texData.slice!=null&&be!=null&&f.gl.uniform1i(be,z.texData.slice.flatOffset),f.setInputMatrixTexture(z.texData.texture,Z,L)}),g!=null&&g(f,p.webGLProgram),f.executeProgram()}function at(f,p,l){var m="";p.concat(l).forEach(function(R){var z=R.texData!=null&&R.texData.slice!=null&&R.texData.slice.flatOffset>0,L=R.isUniform?"uniform":R.texData.texShape;m+=R.shape+"_"+L+"_"+z});var g=f.userCode,I=f.constructor.name;return I+="_"+m+"_"+g,I}var $=function(){function f(p,l,m){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p;for(var g=m.filterWidth,I=m.inChannels,R=m.strideWidth,z=m.strideHeight,L=m.padInfo,G=m.outWidth,Z=m.dilationWidth,be=m.dilationHeight,Ce=m.dataFormat,De=L.left,Te=L.top,Ge=I*g,Ze=tn(),s=Ce==="channelsLast",u=s?0:1,r=s?1:2,o="",h=0;h<=1;h++)for(var b=0;b<=1;b++)o+=`
blockIndex = rc.y + `+b+`;
pos = rc.x + `+h+`;
if(blockIndex < `+p[1]+" && pos < "+p[0]+`) {
offsetY = int(blockIndex / (`+G+")) * "+z+" - "+Te+`;
d0 = offsetY + `+be+" * (pos / "+Ge+`);
if(d0 < `+l[u]+` && d0 >= 0) {
offsetX = int(mod(float(blockIndex), `+G+".) * "+R+". - "+De+`.);
d1 = offsetX + `+Z+" * (int(mod(float(pos), "+Ge+".) / "+I+`.));
if(d1 < `+l[r]+` && d1 >= 0) {
ch = int(mod(float(pos), `+I+`.));
if (`+s+`) {
innerDims = vec2(d1, ch);
result[`+(h*2+b)+`] = getChannel(
getA(d0, int(innerDims.x),
int(innerDims.y)), innerDims);
} else {
innerDims = vec2(d0, d1);
result[`+(h*2+b)+`] = getChannel(
getA(ch, int(innerDims.x),
int(innerDims.y)), innerDims);
}
}
}
}
`;this.userCode=`
void main() {
ivec2 rc = getOutputCoords();
vec4 result = vec4(0);
int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
vec2 innerDims;
`+o+`
`+Ze.output+` = result;
}
`}return f}(),et=function(){function f(p,l,m,g,I){this.variableNames=["x"],this.outputShape=[];var R=l,z=p[3]-1;this.outputShape=p;var L,G="float("+m+") + float("+g+") * sum";I===.5?L="inversesqrt("+G+")":I===1?L="1.0/("+G+")":L="exp(log("+G+") * float(-"+I+"));",this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int r = coords[1];
int c = coords[2];
int d = coords[3];
float x = getX(b, r, c, d);
float sum = 0.0;
for (int j = -`+R+"; j <= "+R+`; j++) {
int idx = d + j;
if (idx >= 0 && idx <= `+z+`) {
float z = getX(b, r, c, idx);
sum += z * z;
}
}
float val = x * `+L+`;
setOutput(val);
}
`}return f}(),gt=function(){function f(p,l,m,g,I){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=p,this.depth=p[3],this.depthRadius=l,this.bias=m,this.alpha=g,this.beta=I,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int r = coords[1];
int c = coords[2];
float result = 0.0;
for (int d = 0; d < `+this.depth+`; ++d) {
int depthBegin = int(max(0.0, float(d - `+l+`)));
int depthEnd = int(min(float(`+this.depth+`),
float(d + `+l+` + 1)));
const int MIN_DEPTH_BEGIN = 0;
const int MAX_DEPTH_END = `+this.depth+`;
float norm = 0.0;
for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {
if (k < depthBegin){
continue;
}
else if (k >= depthBegin && k < depthEnd) {
norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);
}
else {
break;
}
}
norm = float(`+g+") * norm + float("+m+`);
for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){
if (k < depthBegin){
continue;
}
else if (k >= depthBegin && k < depthEnd){
float dyi = -2.0 * float(`+g+`)
* float(`+I+`)
* getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)
/ norm;
if (k == d) {
dyi += pow(norm, -1.0 * `+I+`);
}
if (k == coords[3]) {
dyi *= getDy(b, r, c, d);
result += dyi;
}
}
else {
break;
}
}
}
setOutput(result);
}
`}return f}(),lt=function(){function f(p,l,m,g,I){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var R=l,z=p[3]-1;this.outputShape=p;var L,G="float("+m+") + float("+g+") * sum";I===.5?L="inversesqrt("+G+")":I===1?L="1.0/("+G+")":L="exp(log("+G+") * float(-"+I+"));",this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords.x;
int r = coords.y;
int c = coords.z;
int d = coords.w;
bool hasNextCol = d < `+this.outputShape[3]+`;
bool hasNextRow = c < `+this.outputShape[2]+`;
vec4 sum = vec4(0.);
vec4 xFragAtOutputCoords = getX(b, r, c, d);
vec4 xAtOutputCoords = vec4(
getChannel(xFragAtOutputCoords, vec2(c, d)),
hasNextCol ?
getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,
hasNextRow ?
getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,
(hasNextRow && hasNextCol) ?
getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0
);
int firstChannel = d - `+R+`;
vec2 cache = vec2(0.);
if(firstChannel >= 0){
vec4 firstChannelFrag = getX(b, r, c, firstChannel);
cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));
if(hasNextRow){
cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));
}
}
ivec2 depth = ivec2(d, d + 1);
for (int j = - `+R+"; j <= "+R+`; j++) {
ivec2 idx = depth + j;
bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));
bvec2 belowUpperBound = lessThanEqual(idx, ivec2(`+z+`));
bool depthInRange = aboveLowerBound.x && belowUpperBound.x;
bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;
if(depthInRange || depthPlusOneInRange){
vec4 z = vec4(0.);
vec4 xFragAtCurrentDepth;
z.xz = cache.xy;
if(depthPlusOneInRange && hasNextCol){
xFragAtCurrentDepth = idx.y != d ?
getX(b, r, c, idx.y) : xFragAtOutputCoords;
z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));
if(hasNextRow){
z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));
}
}
cache.xy = z.yw;
sum += z * z;
}
}
vec4 result = xAtOutputCoords * `+L+`;
setOutput(result);
}
`}return f}(),_t=function(){function f(p){this.variableNames=["dy","maxPos"],this.outputShape=p.inShape;var l=p.strideHeight,m=p.strideWidth,g=p.dilationHeight,I=p.effectiveFilterHeight,R=p.effectiveFilterWidth,z=I-1-p.padInfo.top,L=R-1-p.padInfo.left,G=I*R-1;this.userCode=`
const ivec2 pads = ivec2(`+z+", "+L+`);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 dyRCCorner = coords.yz - pads;
int dyRCorner = dyRCCorner.x;
int dyCCorner = dyRCCorner.y;
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < `+I+`;
wR += `+g+`) {
float dyR = float(dyRCorner + wR) / `+l+`.0;
if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < `+R+`; wC++) {
float dyC = float(dyCCorner + wC) / `+m+`.0;
if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(b, idyR, idyC, d);
int maxPosValue = `+G+` - int(getMaxPos(b, idyR, idyC, d));
// Get the current value, check it against the value from the
// position matrix.
int curPosValue = wR * `+R+` + wC;
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
dotProd += dyValue * mask;
}
}
setOutput(dotProd);
}
`}return f}(),At=function(){function f(p){this.variableNames=["dy","maxPos"],this.outputShape=p.inShape;var l=p.strideDepth,m=p.strideHeight,g=p.strideWidth,I=p.dilationDepth,R=p.dilationHeight,z=p.dilationWidth,L=p.effectiveFilterDepth,G=p.effectiveFilterHeight,Z=p.effectiveFilterWidth,be=L-1-p.padInfo.front,Ce=G-1-p.padInfo.top,De=Z-1-p.padInfo.left,Te=L*G*Z-1;this.userCode=`
const ivec3 pads = ivec3(`+be+", "+Ce+", "+De+`);
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
int dyDCorner = dyCorner.x;
int dyRCorner = dyCorner.y;
int dyCCorner = dyCorner.z;
// Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get
// dx(xD, xR, xC, ch).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wD = 0; wD < `+L+`;
wD += `+I+`) {
float dyD = float(dyDCorner + wD) / `+l+`.0;
if (dyD < 0.0 || dyD >= `+p.outDepth+`.0 || fract(dyD) > 0.0) {
continue;
}
int idyD = int(dyD);
for (int wR = 0; wR < `+G+`;
wR += `+R+`) {
float dyR = float(dyRCorner + wR) / `+m+`.0;
if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 ||
fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < `+Z+`;
wC += `+z+`) {
float dyC = float(dyCCorner + wC) / `+g+`.0;
if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
int maxPosValue = `+Te+` -
int(getMaxPos(batch, idyD, idyR, idyC, ch));
// Get the current value, check it against the value from the
// position matrix.
int curPosValue =
wD * `+G+" * "+Z+` +
wR * `+Z+` + wC;
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
dotProd += dyValue * mask;
}
}
}
setOutput(dotProd);
}
`}return f}(),Lt=function(){function f(p,l,m,g,I,R,z,L){g===void 0&&(g=!1),I===void 0&&(I=!1),R===void 0&&(R=!1),z===void 0&&(z=null),L===void 0&&(L=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=m;var G=g?p[1]:p[2],Z=Math.ceil(G/2),be=g?"i * 2, rc.y":"rc.y, i * 2",Ce=I?"rc.z, i * 2":"i * 2, rc.z",De=g?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],Te=I?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],Ge="",Ze="";z&&(L?Ge=`vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
`+z+`
}`:Ge=`vec4 activation(vec4 x) {
`+z+`
}`,Ze="result = activation(result);");var s=R?"result += getBiasAtOutCoords();":"";R&&this.variableNames.push("bias"),L&&this.variableNames.push("preluActivationWeights");var u="rc.x",r="rc.x";p[0]<l[0]?u="int(min(float(rc.x), "+(p[0]-1)+".))":l[0]<p[0]&&(r="int(min(float(rc.x), "+(l[0]-1)+".))"),this.userCode=`
`+Ge+`
const float sharedDimension = `+Z+`.0;
vec4 dot2x2ARowBCol(ivec3 rc) {
vec4 result = vec4(0);
for (int i = 0; i < `+Z+`; i++) {
int batchA = `+u+`;
int batchB = `+r+`;
vec4 a = getMatrixA(batchA, `+be+`);
vec4 b = getMatrixB(batchB, `+Ce+`);
// These swizzled products need to be separately added.
// See: https://github.com/tensorflow/tfjs/issues/1735
result += (`+De[0]+" * "+Te[0]+`);
result += (`+De[1]+" * "+Te[1]+`);
}
return result;
}
void main() {
ivec3 rc = getOutputCoords();
vec4 result = dot2x2ARowBCol(rc);
`+s+`
`+Ze+`
setOutput(result);
}
`}return f}(),Pt=function(){function f(p,l,m){this.variableNames=["probs"],this.outputShape=[p,m],this.userCode=`
uniform float seed;
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
float r = random(seed);
float cdf = 0.0;
for (int i = 0; i < `+(l-1)+`; i++) {
cdf += getProbs(batch, i);
if (r < cdf) {
setOutput(float(i));
return;
}
}
// If no other event happened, last event happened.
setOutput(float(`+(l-1)+`));
}
`}return f.prototype.getCustomSetupFunc=function(p){var l=this;return function(m,g){l.seedLoc==null&&(l.seedLoc=m.getUniformLocation(g,"seed")),m.gl.uniform1f(l.seedLoc,p)}},f}(),Ut=function(){function f(p,l,m,g){this.variableNames=["indices"],this.outputShape=[p,l],this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int index = round(getIndices(coords.x));
setOutput(mix(float(`+g+"), float("+m+`),
float(index == coords.y)));
}
`}return f}(),Nt=function(){function f(p){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=p;var l=p.length;if(l===0)this.userCode=`
void main() {
setOutput(vec4(getA(), 0., 0., 0.));
}
`;else{var m=Vr("rc",l),g=nn(l),I=Ht(l,p,m),R=Ot(l,p[p.length-1],p[p.length-2],m),z=Rt(p,m);this.userCode=`
void main() {
`+g+` rc = getOutputCoords();
if(`+I+`) {
setOutput(vec4(0));
} else {
`+R+`
setOutput(vec4(`+z+`));
}
}
`}}return f}();function Kt(f,p){for(var l=[],m=0;m<=1;m++)for(var g=0;g<=1;g++){for(var I=(m===0?"r":"rp1")+", "+(g===0?"c":"cp1"),R=2;R<f;R++)I=p[p.length-1-R]+","+I;l.push(I)}return l}function Ht(f,p,l){if(f===1)return"rc > "+p[0];for(var m="",g=f-2;g<f;g++)m+=l[g]+" >= "+p[g],g<f-1&&(m+="||");return m}function Ot(f,p,l,m){if(f===1)return"";var g=m.slice(-2);return`
int r = `+g[0]+`;
int c = `+g[1]+`;
int rp1 = r + 1;
int cp1 = c + 1;
bool cEdge = cp1 >= `+p+`;
bool rEdge = rp1 >= `+l+`;
`}function Rt(f,p){var l=f.length,m=Kt(l,p);return l===1?`getA(rc),
rc + 1 >= `+f[0]+` ? 0. : getA(rc + 1),
0, 0`:"getA("+m[0]+`),
cEdge ? 0. : getA(`+m[1]+`),
rEdge ? 0. : getA(`+m[2]+`),
rEdge || cEdge ? 0. : getA(`+m[3]+")"}var wt=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=l.map(function(G,Z){return G[0]+p[Z]+G[1]});var g=p.length,I=nn(g),R=l.map(function(G){return G[0]}).join(","),z=l.map(function(G,Z){return G[0]+p[Z]}).join(","),L=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,g);if(g===1){this.userCode=`
int start = `+R+`;
int end = `+z+`;
void main() {
int outC = getOutputCoords();
if (outC < start || outC >= end) {
setOutput(float(`+m+`));
} else {
setOutput(getX(outC - start));
}
}
`;return}this.userCode=`
`+I+" start = "+I+"("+R+`);
`+I+" end = "+I+"("+z+`);
void main() {
`+I+` outC = getOutputCoords();
if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {
setOutput(float(`+m+`));
} else {
`+I+` coords = outC - start;
setOutput(getX(`+L+`));
}
}
`}return f}(),Et=function(){function f(p,l,m){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=l.map(function(s,u){return s[0]+p[u]+s[1]});for(var g=p.length,I=nn(g),R=l.map(function(s){return s[0]}).join(","),z=l.map(function(s,u){return s[0]+p[u]}).join(","),L=Vr("rc",g),G=Vr("source",g),Z=L[g-1]+" < "+this.outputShape[g-1],be=g===1?"source":"vec2("+G.slice(-2).join()+")",Ce=[I+" rc = outputLoc;",L[g-1]+` += 1;
if(`+Z+`) {
`,g===1?"":`}
rc = outputLoc;
`+L[g-2]+` += 1;
if(`+L[g-2]+" < "+this.outputShape[g-2]+") {",g===1?"":" "+L[g-1]+` += 1;
if(`+Z+") {"],De=g===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",Te="",Ge=0,Ze=g===1?2:4;Ge<Ze;Ge++)Te+=`
`+Ce[Ge]+`
if (`+De+`) {
result[`+Ge+"] = float("+m+`);
} else {
`+I+` source = rc - start;
result[`+Ge+"] = getChannel(getX("+G.join()+"), "+be+`);
}
`;Te+=g===1?"} ":"}}",this.userCode=`
const `+I+" start = "+I+"("+R+`);
const `+I+" end = "+I+"("+z+`);
void main() {
`+I+` outputLoc = getOutputCoords();
vec4 result = vec4(0.);
`+Te+`
setOutput(result);
}
`}return f}(),Vt=function(){function f(p,l,m,g,I){if(g===void 0&&(g=!1),I===void 0&&(I=!1),this.variableNames=["x"],l==="avg"&&m)throw new Error("Cannot compute positions for average pool.");var R=p.filterWidth,z=p.strideHeight,L=p.strideWidth,G=p.dilationHeight,Z=p.dilationWidth,be=p.effectiveFilterHeight,Ce=p.effectiveFilterWidth,De=p.padInfo.top,Te=p.padInfo.left;this.outputShape=p.outShape;var Ge=l==="avg",Ze="((batch * "+p.inHeight+" + xR) * "+p.inWidth+" + xC) * "+p.inChannels+" + d",s="(xR * "+p.inWidth+" + xC) * "+p.inChannels+" + d",u="0.0";if(Ge||(u="-1.0 / 1e-20"),m){var r=">=";this.userCode=`
const ivec2 strides = ivec2(`+z+", "+L+`);
const ivec2 pads = ivec2(`+De+", "+Te+`);
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d = coords[3];
ivec2 xRCCorner = coords.yz * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// max/min x(?, ?, d) to get y(yR, yC, d).
// ? = to be determined
float minMaxValue = 0.0;
float minMaxValueFound = 0.0;
int minMaxPosition = 0;
float avgValue = 0.0;
for (int wR = 0; wR < `+be+`;
wR += `+G+`) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+Ce+`;
wC += `+Z+`) {
int xC = xCCorner + wC;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
float value = getX(batch, xR, xC, d);
// If a min / max value has already been found, use it. If not,
// use the current value.
float currMinMaxValue = mix(
value, minMaxValue, minMaxValueFound);
if (value `+r+` currMinMaxValue) {
minMaxValue = value;
minMaxValueFound = 1.0;
minMaxPosition = `+(g?I?Ze:s:"wR * "+Ce+" + wC")+`;
}
}
}
setOutput(float(minMaxPosition));
}
`;return}var o="max",h=l+"("+l+"("+l+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";l==="avg"&&(h="avgValue / count");var b=Math.floor(R/4)*4,T=R%4,M=`
if (`+Ge+`) {
avgValue += dot(values, ones);
} else {
minMaxValue = `+o+`(values, minMaxValue);
}
`;this.userCode=`
const ivec2 strides = ivec2(`+z+", "+L+`);
const ivec2 pads = ivec2(`+De+", "+Te+`);
const float initializationValue = `+u+`;
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float count = 0.0;
float getValue(int batch, int xR, int xC, int d) {
if (xC < 0 || xC >= `+p.inWidth+`) {
return initializationValue;
}
count += 1.0;
return getX(batch, xR, xC, d);
}
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d = coords[3];
ivec2 xRCCorner = coords.yz * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// max/min x(?, ?, d) to get y(yR, yC, d).
// ? = to be determined
vec4 minMaxValue = vec4(`+u+`);
float avgValue = 0.0;
count = 0.0;
for (int wR = 0; wR < `+be+`;
wR += `+G+`) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+b+`; wC += 4) {
int xC = xCCorner + wC * `+Z+`;
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + `+Z+`, d),
getValue(batch, xR, xC + 2 * `+Z+`, d),
getValue(batch, xR, xC + 3 * `+Z+`, d)
);
`+M+`
}
int xC = xCCorner + `+b+`;
if (`+(T===1)+`) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
initializationValue,
initializationValue,
initializationValue
);
`+M+`
} else if (`+(T===2)+`) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + `+Z+`, d),
initializationValue,
initializationValue
);
`+M+`
} else if (`+(T===3)+`) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + `+Z+`, d),
getValue(batch, xR, xC + 2 * `+Z+`, d),
initializationValue
);
`+M+`
}
}
setOutput(`+h+`);
}
`}return f}(),jt=function(){function f(p,l,m,g,I){if(g===void 0&&(g=!1),I===void 0&&(I=!1),this.variableNames=["x"],l==="avg"&&m)throw new Error("Cannot compute positions for average pool.");var R=p.filterWidth,z=p.strideDepth,L=p.strideHeight,G=p.strideWidth,Z=p.dilationDepth,be=p.dilationHeight,Ce=p.dilationWidth,De=p.effectiveFilterDepth,Te=p.effectiveFilterHeight,Ge=p.effectiveFilterWidth,Ze=p.padInfo.front,s=p.padInfo.top,u=p.padInfo.left;this.outputShape=p.outShape;var r=l==="avg",o="0.0";if(r||(o="-1.0 / 1e-20"),m){var h=">=";this.userCode=`
const ivec3 strides =
ivec3(`+z+", "+L+", "+G+`);
const ivec3 pads = ivec3(`+Ze+", "+s+", "+u+`);
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
int xDCorner = xCorner.x;
int xRCorner = xCorner.y;
int xCCorner = xCorner.z;
// max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).
// ? = to be determined
float minMaxValue = 0.0;
float minMaxValueFound = 0.0;
int minMaxPosition = 0;
for (int wD = 0; wD < `+De+`;
wD += `+Z+`) {
int xD = xDCorner + wD;
if (xD < 0 || xD >= `+p.inDepth+`) {
continue;
}
for (int wR = 0; wR < `+Te+`;
wR += `+be+`) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+Ge+`;
wC += `+Ce+`) {
int xC = xCCorner + wC;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
float value = getX(batch, xD, xR, xC, ch);
// If a min / max value has already been found, use it. If not,
// use the current value.
float currMinMaxValue = mix(
value, minMaxValue, minMaxValueFound);
if (value `+h+` currMinMaxValue) {
minMaxValue = value;
minMaxValueFound = 1.0;
minMaxPosition = `+(g?I?"(((batch * "+p.inDepth+" + xD) * "+p.inHeight+" + xR) * "+p.inWidth+" + xC) * "+p.inChannels+" + ch":"((xD * "+p.inHeight+" + xR) * "+p.inWidth+" + xC) * "+p.inChannels+" + ch":"wD * "+Te+" * "+Ge+` +
wR * `+Ge+" + wC")+`;
}
}
}
}
setOutput(float(minMaxPosition));
}
`;return}var b="max",T=l+"("+l+"("+l+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";l==="avg"&&(T="avgValue / count");var M=Math.floor(R/4)*4,q=R%4,Y=`
if (`+r+`) {
avgValue += dot(values, ones);
} else {
minMaxValue = `+b+`(values, minMaxValue);
}
`;this.userCode=`
const ivec3 strides =
ivec3(`+z+", "+L+", "+G+`);
const ivec3 pads = ivec3(`+Ze+", "+s+", "+u+`);
const float initializationValue = `+o+`;
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float count = 0.0;
float getValue(int batch, int xD, int xR, int xC, int ch) {
if (xC < 0 || xC >= `+p.inWidth+`) {
return initializationValue;
}
count += 1.0;
return getX(batch, xD, xR, xC, ch);
}
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
int xDCorner = xCorner.x;
int xRCorner = xCorner.y;
int xCCorner = xCorner.z;
// max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).
// ? = to be determined
vec4 minMaxValue = vec4(`+o+`);
float avgValue = 0.0;
count = 0.0;
for (int wD = 0; wD < `+De+`;
wD += `+Z+`) {
int xD = xDCorner + wD;
if (xD < 0 || xD >= `+p.inDepth+`) {
continue;
}
for (int wR = 0; wR < `+Te+`;
wR += `+be+`) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+M+`; wC += 4) {
int xC = xCCorner + wC * `+Ce+`;
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + `+Ce+`, ch),
getValue(batch, xD, xR, xC + 2 * `+Ce+`, ch),
getValue(batch, xD, xR, xC + 3 * `+Ce+`, ch)
);
`+Y+`
}
int xC = xCCorner + `+M+`;
if (`+(q===1)+`) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
initializationValue,
initializationValue,
initializationValue
);
`+Y+`
} else if (`+(q===2)+`) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + `+Ce+`, ch),
initializationValue,
initializationValue
);
`+Y+`
} else if (`+(q===3)+`) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + `+Ce+`, ch),
getValue(batch, xD, xR, xC + 2 * `+Ce+`, ch),
initializationValue
);
`+Y+`
}
}
setOutput(`+T+`);
}
}
`}return f}(),cr=function(){function f(p,l){this.variableNames=["x"];var m=p.windowSize,g=p.batchSize,I=p.inSize,R=p.outSize;this.outputShape=[g,R];var z="0.0",L="";l==="prod"?z="1.0":l==="min"?(z="1.0 / 1e-20",L="min"):l==="max"&&(z="-1.0 / 1e-20",L="max");var G=l+"("+l+"("+l+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";l==="sum"?G="sumValue":l==="prod"?G="prodValue":l==="all"?G="allValue":l==="any"&&(G="anyValue");var Z=Math.floor(m/4)*4,be=m%4,Ce=`
if (`+(l==="sum")+`) {
sumValue += dot(values, ones);
} else if (`+(l==="prod")+`) {
vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);
prodValue *= tmp[0] * tmp[1];
} else {
minMaxValue = `+L+`(values, minMaxValue);
}
`,De="vec4";l==="all"?(z="1.0",Ce=`
bool reducedAllValue = all(values);
float floatedReducedAllValue = float(reducedAllValue);
allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
`,De="bvec4"):l==="any"&&(z="0.0",Ce=`
bool reducedAnyValue = any(values);
float floatedReducedAnyValue = float(reducedAnyValue);
anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
`,De="bvec4");var Te="";I%m>0&&(Te=`
if (inIdx < 0 || inIdx >= `+I+`) {
return initializationValue;
}
`),this.userCode=`
const float initializationValue = `+z+`;
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float getValue(int batch, int inIdx) {
`+Te+`
return getX(batch, inIdx);
}
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * `+m+`;
vec4 minMaxValue = vec4(`+z+`);
float prodValue = 1.0;
float sumValue = 0.0;
float allValue = 1.0;
float anyValue = 0.0;
for (int i = 0; i < `+Z+`; i += 4) {
int inIdx = inOffset + i;
`+De+" values = "+De+`(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
`+Ce+`
}
int inIdx = inOffset + `+Z+`;
if (`+(be===1)+`) {
`+De+" values = "+De+`(
getValue(batch, inIdx),
initializationValue,
initializationValue,
initializationValue
);
`+Ce+`
} else if (`+(be===2)+`) {
`+De+" values = "+De+`(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
initializationValue,
initializationValue
);
`+Ce+`
} else if (`+(be===3)+`) {
`+De+" values = "+De+`(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
initializationValue
);
`+Ce+`
}
setOutput(`+G+`);
}
`}return f}(),rr=function(){function f(p,l){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p;for(var m="",g=0;g<4;g++){var I="thisRC = rc;";g%2===1&&(I+="thisRC.z += 1;"),g>1&&(I+="thisRC.y += 1;"),m+=`
`+I+`
`+(g>0?"if(thisRC.y < rows && thisRC.z < cols){":"")+`
int flatIndex = getFlatIndex(thisRC);
ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);
vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));
result[`+g+`] =
getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
`+(g>0?"}":"")+`
`}this.userCode=`
`+Ie(l)+`
`+Kn(p)+`
void main() {
ivec3 rc = getOutputCoords();
vec4 result = vec4(0.);
ivec3 thisRC;
int rows = `+p[1]+`;
int cols = `+p[2]+`;
`+m+`
setOutput(result);
}
`}return f}();function Ie(f){var p=Rn(["r","c","d"],f);return`
ivec3 inputCoordsFromReshapedOutCoords(int index) {
`+p+`
return ivec3(r, c, d);
}
`}var br=function(){function f(p,l,m){this.variableNames=["dy"],this.outputShape=[],this.outputShape=l.shape;var g=l.shape,I=g[1],R=g[2],z=p.shape,L=z[1],G=z[2],Z=[m&&L>1?I-1:I,m&&G>1?R-1:R],be=[m&&L>1?L-1:L,m&&G>1?G-1:G],Ce=Z[0]/be[0],De=Z[1]/be[1],Te=1/Ce,Ge=1/De,Ze=Math.ceil(Te)*2+2,s=Math.ceil(Ge)*2+2;this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
int r = coords[1];
int c = coords[2];
float accumulator = 0.0;
const float heightScale = float(`+Ce+`);
const float widthScale = float(`+De+`);
const float invHeightScale = float(`+Te+`);
const float invWidthScale = float(`+Ge+`);
const int winHeight = int(`+Ze+`);
const int winWidth = int(`+s+`);
// Compute bounds for where in dy we will look
float startRLerp = floor(float(r) * invHeightScale);
int startDyR = int(startRLerp - float(winHeight / 2));
float startCLerp = floor(float(c) * invWidthScale);
int startDyC = int(startCLerp - float(winWidth / 2));
// Loop over dy
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
int dyR = dyROffset + startDyR;
// Guard against the window exceeding the bounds of dy
if (dyR < 0 || dyR >= `+L+`) {
continue;
}
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
int dyC = dyCOffset + startDyC;
// Guard against the window exceeding the bounds of dy
if (dyC < 0 || dyC >= `+G+`) {
continue;
}
float dxR = float(dyR) * heightScale;
int topDxRIndex = int(floor(dxR));
int bottomDxRIndex = int(min(ceil(dxR), `+(I-1)+`.0));
float dxRLerp = dxR - float(topDxRIndex);
float inverseDxRLerp = 1.0 - dxRLerp;
float dxC = float(dyC) * widthScale;
int leftDxCIndex = int(floor(dxC));
int rightDxCIndex = int(min(ceil(dxC), `+(R-1)+`.0));
float dxCLerp = dxC - float(leftDxCIndex);
float inverseDxCLerp = 1.0 - dxCLerp;
if (r == topDxRIndex && c == leftDxCIndex) {
// topLeft
accumulator +=
getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;
}
if (r == topDxRIndex && c == rightDxCIndex) {
// topRight
accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;
}
if (r == bottomDxRIndex && c == leftDxCIndex) {
// bottomLeft
accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;
}
if (r == bottomDxRIndex && c == rightDxCIndex) {
// bottomRight
accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;
}
}
}
// End loop over dy
setOutput(accumulator);
}
`}return f}(),Nr=function(){function f(p,l,m,g){this.variableNames=["A"],this.outputShape=[];var I=p[0],R=p[1],z=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?z-1:z],Z=[g&&l>1?l-1:l,g&&m>1?m-1:m];this.userCode=`
const vec2 effectiveInputOverOutputRatioRC = vec2(
`+G[0]/Z[0]+`,
`+G[1]/Z[1]+`);
const vec2 inputShapeRC = vec2(`+R+".0, "+z+`.0);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 yRC = coords.yz;
// Fractional source index.
vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;
// Compute the four integer indices.
ivec2 sourceFloorRC = ivec2(sourceFracIndexRC);
ivec2 sourceCeilRC = ivec2(
min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);
float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);
float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);
float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);
vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);
float top = topLeft + (topRight - topLeft) * fracRC.y;
float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;
float newValue = top + (bottom - top) * fracRC.x;
setOutput(newValue);
}
`}return f}(),Tr=function(){function f(p,l,m,g){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var I=p[0],R=p[1],z=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?z-1:z],Z=[g&&l>1?l-1:l,g&&m>1?m-1:m];this.userCode=`
const vec3 effectiveInputOverOutputRatioRC = vec3(
`+G[0]/Z[0]+`,
`+G[1]/Z[1]+`,
`+G[1]/Z[1]+`);
const vec3 inputShapeRC = vec3(`+R+".0, "+z+`.0,
`+z+`.0);
float getAValue(int b, int r, int c, int d) {
return getChannel(getA(b, r, c, d), vec2(c, d));
}
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
// Calculate values for next column in yRC.z.
ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
// Fractional source index.
vec3 sourceFracIndexRC = vec3(yRC) * effectiveInputOverOutputRatioRC;
// Compute the four integer indices.
ivec3 sourceFloorRC = ivec3(sourceFracIndexRC);
ivec3 sourceCeilRC = ivec3(
min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
// Should we calculate next column and row elements in 2x2 packed cell.
bool hasNextCol = d < `+(L-1)+`;
bool hasNextRow = coords.z < `+(m-1)+`;
// In parallel, construct four corners for all four components in
// packed 2x2 cell.
vec4 topLeft = vec4(
getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),
hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);
vec4 bottomLeft = vec4(
getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),
hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);
vec4 topRight = vec4(
getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),
hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);
vec4 bottomRight = vec4(
getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),
hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);
vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);
vec4 top = mix(topLeft, topRight, fracRC.yyzz);
vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);
vec4 newValue = mix(top, bottom, fracRC.x);
setOutput(newValue);
}
`}return f}(),hr=function(){function f(p,l,m){this.variableNames=["dy"],this.outputShape=[],this.outputShape=l.shape;var g=l.shape,I=g[1],R=g[2],z=p.shape,L=z[1],G=z[2],Z=[m&&L>1?I-1:I,m&&G>1?R-1:R],be=[m&&L>1?L-1:L,m&&G>1?G-1:G],Ce=Z[0]/be[0],De=Z[1]/be[1],Te=1/Ce,Ge=1/De,Ze=Math.ceil(Te)*2+2,s=Math.ceil(Ge)*2+2;this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
int r = coords[1];
int c = coords[2];
float accumulator = 0.0;
const float heightScale = float(`+Ce+`);
const float widthScale = float(`+De+`);
const float invHeightScale = float(`+Te+`);
const float invWidthScale = float(`+Ge+`);
const int winHeight = int(`+Ze+`);
const int winWidth = int(`+s+`);
// Compute bounds for where in dy we will look
float startRLerp = floor(float(r) * invHeightScale);
int startDyR = int(floor(startRLerp - float(winHeight / 2)));
float startCLerp = floor(float(c) * invWidthScale);
int startDyC = int(floor(startCLerp - float(winWidth / 2)));
// Loop over dy
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
int dyR = dyROffset + startDyR;
// Guard against the window exceeding the bounds of dy
if (dyR < 0 || dyR >= `+L+`) {
continue;
}
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
int dyC = dyCOffset + startDyC;
// Guard against the window exceeding the bounds of dy
if (dyC < 0 || dyC >= `+G+`) {
continue;
}
float sourceFracRow =
float(`+Z[0]+`) *
(float(dyR) / float(`+be[0]+`));
float sourceFracCol =
float(`+Z[1]+`) *
(float(dyC) / float(`+be[1]+`));
int sourceNearestRow = int(min(
float(int(`+I+`) - 1),
`+m+` ? float(round(sourceFracRow)) :
float(floor(sourceFracRow))));
int sourceNearestCol = int(min(
float(int(`+R+`) - 1),
`+m+` ? float(round(sourceFracCol)) :
float(floor(sourceFracCol))));
if (r == sourceNearestRow && c == sourceNearestCol) {
accumulator += getDy(b, dyR, dyC, d);
}
}
}
// End loop over dy
setOutput(accumulator);
}
`}return f}(),Dr=function(){function f(p,l,m,g){this.variableNames=["A"],this.outputShape=[];var I=p[0],R=p[1],z=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?z-1:z],Z=[g&&l>1?l-1:l,g&&m>1?m-1:m],be=g?"0.5":"0.0";this.userCode=`
const vec2 effectiveInputOverOutputRatioRC = vec2(
`+G[0]/Z[0]+`,
`+G[1]/Z[1]+`);
const vec2 inputShapeRC = vec2(`+R+".0, "+z+`.0);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 yRC = coords.yz;
// Fractional source index.
vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;
// Compute the coordinators of nearest neighbor point.
ivec2 sourceNearestRC = ivec2(
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + `+be+`)));
float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);
setOutput(newValue);
}
`}return f}(),fr=function(){function f(p,l){this.variableNames=["x"];var m=p.length;if(m>4)throw new Error("WebGL backend: Reverse of rank-"+m+" tensor is not yet supported");if(this.outputShape=p,m===1){this.userCode=`
void main() {
int coord = getOutputCoords();
setOutput(getX(`+p[0]+` - coord - 1));
}
`;return}var g=function(z){return l.indexOf(z)!==-1&&p[z]!==1?p[z]+" - coords["+z+"] - 1":"coords["+z+"]"},I=p.map(function(z,L){return g(L)}).join(","),R=nn(m);this.userCode=`
void main() {
`+R+` coords = getOutputCoords();
setOutput(getX(`+I+`));
}
`}return f}(),Er=function(){function f(p,l){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var m=p.length;if(m>4)throw new Error("WebGL backend: Reverse of rank-"+m+" tensor is not yet supported");this.outputShape=p;var g=Vr("rc",m),I=g[m-1]+" + 1 < "+this.outputShape[m-1],R=g[m-2]+" + 1 < "+this.outputShape[m-2],z=nn(m);m===1?this.userCode=`
void main(){
int rc = getOutputCoords();
vec4 result = vec4(0.);
result.r = getChannel(getX(`+p[0]+` - rc - 1),
`+p[0]+` - rc - 1);
if(`+I+`){
result.g = getChannel(getX(`+p[0]+` - (rc + 1) - 1),
`+p[0]+` - (rc + 1) - 1);
}
setOutput(result);
}
`:this.userCode=`
void main() {
`+z+` rc = getOutputCoords();
vec4 result = vec4(0.);
result.r = `+L(g.slice())+`;
if(`+I+`){
result.g = `+G(g.slice())+`;
}
if(`+R+`) {
result.b = `+Z(g.slice())+`;
if(`+I+`) {
result.a = `+be(g.slice())+`;
}
}
setOutput(result);
}
`;function L(Te){return Ce(Te)}function G(Te){return Te[m-1]="("+Te[m-1]+" + 1)",Ce(Te)}function Z(Te){return Te[m-2]="("+Te[m-2]+" + 1)",Ce(Te)}function be(Te){return Te[m-1]="("+Te[m-1]+" + 1)",Te[m-2]="("+Te[m-2]+" + 1)",Ce(Te)}function Ce(Te){var Ge=p.map(function(u,r){return De(r,Te)}),Ze=Ge.join(","),s=Ge.slice(-2).join(",");return"getChannel(getX("+Ze+"), vec2("+s+"))"}function De(Te,Ge){return l.indexOf(Te)!==-1&&p[Te]!==1?p[Te]+" - "+Ge[Te]+" - 1":""+Ge[Te]}}return f}(),an=function(){function f(p,l,m,g,I,R,z){this.variableNames=["updates","indices","defaultValue"],this.outputShape=R;var L=nn(I.length),G=nn(R.length),Z="";m===1?Z="i":m===2&&(Z="i, j");var be="getIndices("+Z+")",Ce="";g===1?Ce="i":g===2&&(Ce="i, coords[1]");var De="getUpdates("+Ce+")",Te=l>1?"strides[j]":"strides";this.userCode=`
`+L+" strides = "+L+"("+I+`);
void main() {
`+G+` coords = getOutputCoords();
float sum = 0.0;
bool found = false;
for (int i = 0; i < `+p+`; i++) {
int flattenedIndex = 0;
for (int j = 0; j < `+l+`; j++) {
int index = round(`+be+`);
flattenedIndex += index * `+Te+`;
}
if (flattenedIndex == coords[0]) {
sum += `+De+`;
found = true;
}
}
setOutput(mix(getDefaultValue(), sum, float(found)));
}
`}return f}(),wn=function(){function f(p,l){this.variableNames=["x","segmentIds"];var m=p.windowSize,g=p.batchSize,I=p.inSize,R=p.numSegments,z=R*Math.ceil(I/m);this.outputShape=[g,z];var L="0.0",G="sumValue",Z=Math.floor(m/4)*4,be=m%4,Ce=`
sumValue += dot(values, segFilter);
`,De="";I%m>0&&(De=`
if (inIdx < 0 || inIdx >= `+I+`) {
return initializationValue;
}
`);var Te="";I%m>0&&(Te=`
if (inIdx < 0 || inIdx >= `+I+`) {
return -1.0;
}
`),this.userCode=`
const float initializationValue = `+L+`;
float getValue(int batch, int inIdx) {
`+De+`
return getX(batch, inIdx);
}
float getSegmentIdAtIndex(int inIdx) {
`+Te+`
return getSegmentIds(inIdx);
}
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = int(floor(float(outIdx) / float(
`+R+")) * float("+m+`));
int currentSeg = int(mod(float(outIdx), float(`+R+`)));
float sumValue = 0.0;
for (int i = 0; i < `+Z+`; i += 4) {
int inIdx = inOffset + i;
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0
);
`+Ce+`
}
int inIdx = inOffset + `+Z+`;
if (`+(be===1)+`) {
vec4 values = vec4(
getValue(batch, inIdx),
initializationValue,
initializationValue,
initializationValue
);
int inIdxSeg = int(getSegmentIdAtIndex(inIdx));
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
0,
0,
0
);
`+Ce+`
} else if (`+(be===2)+`) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
initializationValue,
initializationValue
);
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
0,
0
);
`+Ce+`
} else if (`+(be===3)+`) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
initializationValue
);
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
0
);
`+Ce+`
}
setOutput(`+G+`);
}
`}return f}(),ie=function(){function f(p,l,m){this.variableNames=["c","a","b"],this.outputShape=l;var g,I;if(m>4)throw Error("Where for rank "+m+" is not yet supported");if(m===1)I="resRC",g="resRC";else{for(var R=["resRC.x","resRC.y","resRC.z","resRC.w"],z=[],L=[],G=0;G<l.length;G++)L.push(""+R[G]),G<p&&z.push(""+R[G]);g=z.join(),I=L.join()}var Z=nn(m);this.userCode=`
void main() {
`+Z+` resRC = getOutputCoords();
float cVal = getC(`+g+`);
if (cVal >= 1.0) {
setOutput(getA(`+I+`));
} else {
setOutput(getB(`+I+`));
}
}
`}return f}(),Nn=function(){function f(p){this.variableNames=["source"],this.outputShape=p,this.rank=p.length;var l=nn(this.rank),m="uniform int start["+this.rank+"];",g=Ee(this.rank),I,R=p.map(function(z,L){return"sourceLoc."+bn[L]+" = start["+L+"] + coords."+bn[L]+";"});I=`
`+l+` sourceLoc;
`+l+` coords = getOutputCoords();
`+R.join(`
`)+`
`,this.userCode=`
`+m+`
void main() {
`+I+`
setOutput(getSource(`+g+`));
}
`}return f.prototype.getCustomSetupFunc=function(p){var l=this;if(p.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the "+("length of start ("+p.length+")"));return function(m,g){if(l.startLoc==null&&(l.startLoc=m.getUniformLocationNoThrow(g,"start"),l.startLoc==null))return;m.gl.uniform1iv(l.startLoc,p)}},f}(),bn=["x","y","z","w","u","v"];function Ee(f){if(f===1)return"sourceLoc";if(f<=6)return bn.slice(0,f).map(function(p){return"sourceLoc."+p}).join(",");throw Error("Slicing for rank "+f+" is not yet supported")}var Bn=function(){function f(p){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p,this.rank=p.length;var l=nn(this.rank),m=Vr("coords",this.rank),g=Vr("sourceLoc",this.rank),I=this.rank===1?"sourceLoc":"vec2("+g.slice(-2).join()+")",R="getChannel(getSource("+g.join()+"), "+I+")",z=`
result.x = `+R+`;
if (++`+m[this.rank-1]+" < "+p[this.rank-1]+`) {
++`+g[this.rank-1]+`;
result.y = `+R+`;
--`+g[this.rank-1]+`;
}
`,L=this.rank===1?"":`
--`+m[this.rank-1]+`;
if (++`+m[this.rank-2]+" < "+p[this.rank-2]+`) {
++`+g[this.rank-2]+`;
result.z = `+R+`;
if (++`+m[this.rank-1]+" < "+p[this.rank-1]+`) {
++`+g[this.rank-1]+`;
result.w = `+R+`;
}
}
`,G=this.rank<=4?`sourceLoc = coords +
`+l+"("+p.map(function(Z,be){return"start["+be+"]"}).join()+");":p.map(function(Z,be){return g[be]+" = "+m[be]+" + start["+be+"];"}).join(`
`);this.userCode=`
uniform int start[`+this.rank+`];
void main() {
`+l+` coords = getOutputCoords();
`+l+` sourceLoc;
`+G+`
vec4 result = vec4(0.);
`+z+`
`+L+`
setOutput(result);
}
`}return f.prototype.getCustomSetupFunc=function(p){var l=this;if(p.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the "+("length of start ("+p.length+")"));return function(m,g){if(l.startLoc==null&&(l.startLoc=m.getUniformLocationNoThrow(g,"start"),l.startLoc==null))return;m.gl.uniform1iv(l.startLoc,p)}},f}(),Pn=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=m;var g=m.length,I=nn(m.length),R=nn(m.length),z="";if(g===1)z="coords * strides + begin";else{var L=0;z=m.map(function(G,Z){return L++,m.length===1?"coords * strides["+Z+"] + begin["+Z+"]":"coords["+(L-1)+"] * strides["+Z+"] + begin["+Z+"]"}).join(",")}this.userCode=`
`+I+" begin = "+I+"("+p+`);
`+I+" strides = "+I+"("+l+`);
void main() {
`+R+` coords = getOutputCoords();
setOutput(getX(`+z+`));
}
`}return f}(),Da=function(){function f(p){this.gpgpu=p,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}return f.prototype.acquireTexture=function(p,l,m){var g=ya(l,m),I=va(p,g,m);I in this.freeTextures||(this.freeTextures[I]=[]),I in this.usedTextures||(this.usedTextures[I]=[]);var R=Ya(p,g,this.gpgpu.gl,this.gpgpu.textureConfig,m);if(this.freeTextures[I].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=R,this.log();var z=this.freeTextures[I].shift();return this.usedTextures[I].push(z),z}var L;return g===ge.PACKED_2X2_FLOAT32?L=this.gpgpu.createPackedMatrixTexture(p[0],p[1]):g===ge.PACKED_2X2_FLOAT16?L=this.gpgpu.createFloat16PackedMatrixTexture(p[0],p[1]):g===ge.UNPACKED_FLOAT32?L=this.gpgpu.createFloat32MatrixTexture(p[0],p[1]):g===ge.UNPACKED_FLOAT16?L=this.gpgpu.createFloat16MatrixTexture(p[0],p[1]):g===ge.PACKED_4X1_UNSIGNED_BYTE&&(L=this.gpgpu.createUnsignedBytesMatrixTexture(p[0],p[1])),this.usedTextures[I].push(L),this.numUsedTextures++,this._numBytesAllocated+=R,this.log(),L},f.prototype.releaseTexture=function(p,l,m,g){if(this.freeTextures==null)return;var I=ya(m,g),R=va(l,I,g);R in this.freeTextures||(this.freeTextures[R]=[]);var z=Ya(l,I,this.gpgpu.gl,this.gpgpu.textureConfig,g),L=i.env().get("WEBGL_DELETE_TEXTURE_THRESHOLD");L!==-1&&this._numBytesAllocated>L?(this.gpgpu.deleteMatrixTexture(p),this._numBytesAllocated-=z):(this.freeTextures[R].push(p),this.numFreeTextures++,this._numBytesFree+=z),this.numUsedTextures--;var G=this.usedTextures[R],Z=G.indexOf(p);if(Z<0)throw new Error("Cannot release a texture that was never provided by this texture manager");G.splice(Z,1),this.log()},f.prototype.log=function(){if(!this.logEnabled)return;var p=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+p+")");var l=this._numBytesFree/this._numBytesAllocated;console.log("Bytes allocated: "+this._numBytesAllocated),console.log("Bytes unused: "+this._numBytesFree+" ("+Math.round(100*l)+"%)")},Object.defineProperty(f.prototype,"numBytesAllocated",{get:function(){return this._numBytesAllocated},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"numBytesFree",{get:function(){return this._numBytesFree},enumerable:!0,configurable:!0}),f.prototype.getNumUsedTextures=function(){return this.numUsedTextures},f.prototype.getNumFreeTextures=function(){return this.numFreeTextures},f.prototype.dispose=function(){var p=this;if(this.freeTextures==null)return;for(var l in this.freeTextures)this.freeTextures[l].forEach(function(m){p.gpgpu.deleteMatrixTexture(m)});for(var l in this.usedTextures)this.usedTextures[l].forEach(function(g){p.gpgpu.deleteMatrixTexture(g)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0},f}();function Dn(f,p){var l=f;if(p===l.R32F)return 4;if(p===l.R16F)return 2;if(p===l.RGBA32F)return 16;if(p===f.RGBA)return 16;if(p===l.RGBA16F)return 8;throw new Error("Unknown internal format "+p)}function Ya(f,p,l,m,g){var I=za(p,m),R;if(g){var z=tt(f[0],f[1]),L=z[0],G=z[1];R=L*G}else{var Z=ze(f[0],f[1]),be=Z[0],Ce=Z[1];R=be*Ce}var De=Dn(l,I);return R*De}function za(f,p){switch(f){case ge.PACKED_2X2_FLOAT32:return ue(p);case ge.PACKED_2X2_FLOAT16:return F(p);case ge.UNPACKED_FLOAT32:return Si(p);case ge.UNPACKED_FLOAT16:return zo(p);case ge.PACKED_4X1_UNSIGNED_BYTE:return ts(p);default:throw new Error("Unknown physical texture type "+f)}}function Qa(f){return i.env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?f?ge.PACKED_2X2_FLOAT32:ge.UNPACKED_FLOAT32:f?ge.PACKED_2X2_FLOAT16:ge.UNPACKED_FLOAT16}function ya(f,p){if(f===w.UPLOAD)return ge.PACKED_2X2_FLOAT32;if(f===w.RENDER||f==null)return Qa(p);if(f===w.DOWNLOAD||f===w.PIXELS)return ge.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+f)}function va(f,p,l){return f[0]+"_"+f[1]+"_"+p+"_"+l}var Yi=function(){function f(p,l){this.variableNames=["A"];for(var m=new Array(p.length),g=0;g<m.length;g++)m[g]=p[g]*l[g];this.outputShape=m,this.rank=m.length;var I=nn(this.rank),R=Wi(p);this.userCode=`
void main() {
`+I+` resRC = getOutputCoords();
setOutput(getA(`+R+`));
}
`}return f}();function Wi(f){var p=f.length;if(p>5)throw Error("Tile for rank "+p+" is not yet supported");if(p===1)return"imod(resRC, "+f[0]+")";for(var l=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],m=[],g=0;g<f.length;g++)m.push("imod("+l[g]+", "+f[g]+")");return m.join()}var Or=function(){function f(p,l){this.variableNames=["A"],this.outputShape=p,this.userCode=`
float unaryOperation(float x) {
`+l+`
}
void main() {
float x = getAAtOutCoords();
float y = unaryOperation(x);
setOutput(y);
}
`}return f}(),Za="if (isnan(x)) return x;",rs="return x;",Po="return abs(x);",dn=Za+`
return (x < 0.0) ? 0.0 : x;
`,Bo=Za+`
return (x < 0.0) ? 0.0 : min(6.0, x);
`,Fn="return (x >= 0.0) ? x : (exp(x) - 1.0);",su=`
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
// see: https://arxiv.org/abs/1706.02515
float scaleAlpha = `+i.backend_util.SELU_SCALEALPHA+`;
float scale = `+i.backend_util.SELU_SCALE+`;
return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
`;function cc(f){return f===void 0&&(f=0),Za+(`
return x > 0.0 ? 1.0 : float(`+f+`);
`)}var si="return -x;",Su="return ceil(x);",Iu="return floor(x);",lc=`
if (isnan(x)) { return 0.0; }
return sign(x);
`,xs="return float(isnan(x));",Ii="return float(isinf(x));",_s="return float(!isnan(x) && !isinf(x));",bo=`
// OpenGL ES does not support round function.
// The algorithm is based on banker's rounding.
float base = floor(x);
if ((x - base) < 0.5) {
return floor(x);
} else if ((x - base) > 0.5) {
return ceil(x);
} else {
if (mod(base, 2.0) == 0.0) {
return base;
} else {
return base + 1.0;
}
}
`,so="return exp(x);",Nu="return exp(x) - 1.0;",uu=`if (x < 0.0) return NAN;
return log(x);`,ws="return log(1.0 + x);",Cu="return sqrt(x);",cu="return inversesqrt(x);",Tu="return 1.0 / (1.0 + exp(-1.0 * x));",hc=`
float epsilon = 1.1920928955078125e-7;
float threshold = log(epsilon) + 2.0;
bool too_large = x > -threshold;
bool too_small = x < threshold;
float result;
float exp_x = exp(x);
if (too_large){
result = x;
}
else if (too_small){
result = exp_x;
}
else{
result = log(exp_x + 1.0);
}
return result;
`,uo=Za+`
if (abs(x) > 1.) {
return NAN;
}
return asin(x);
`,bs=Za+`
if (abs(x) > 1.) {
return NAN;
}
return acos(x);
`,Eu=Za+`
return atan(x);
`,pc=`
float e2x = exp(x);
return (e2x - 1.0 / e2x) / 2.0;
`,dc=`
float e2x = exp(-x);
return (e2x + 1.0 / e2x) / 2.0;
`,fc=`
float e2x = exp(-2.0 * abs(x));
return sign(x) * (1.0 - e2x) / (1.0 + e2x);
`,vl=Za+"return log(x + sqrt(x * x + 1.0));",Ru=Za+`
if (x < 1.0) return NAN;
return log(x + sqrt(x * x - 1.0));`,mc=Za+`
if ((x < -1.0) || (x > 1.0)) return NAN;
return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,yc=`
// Error function is calculated approximately with elementary function.
// See "Handbook of Mathematical Functions with Formulas,
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
float p = `+i.backend_util.ERF_P+`;
float a1 = `+i.backend_util.ERF_A1+`;
float a2 = `+i.backend_util.ERF_A2+`;
float a3 = `+i.backend_util.ERF_A3+`;
float a4 = `+i.backend_util.ERF_A4+`;
float a5 = `+i.backend_util.ERF_A5+`;
float sign = sign(x);
x = abs(x);
float t = 1.0 / (1.0 + p * x);
return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));
`,Ni="return 1.0 / x;",ns="return float(!(x >= 1.0));",ks="return x;",vc="return x;",Wo=`
vec4 result = log(x);
vec4 isNaN = vec4(lessThan(x, vec4(0.0)));
result.r = isNaN.r == 1.0 ? NAN : result.r;
result.g = isNaN.g == 1.0 ? NAN : result.g;
result.b = isNaN.b == 1.0 ? NAN : result.b;
result.a = isNaN.a == 1.0 ? NAN : result.a;
return result;
`,co=`
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`,Uo=`
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`,lu=`
vec4 result;
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
return result;
`,as=function(){function f(p,l){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p,this.userCode=`
vec4 unaryOperation(vec4 x) {
`+l+`
}
void main() {
vec4 x = getAAtOutCoords();
vec4 y = unaryOperation(x);
setOutput(y);
}
`}return f}(),Vo=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=p;var l=p.length,m=Vr("rc",l),g=nn(l),I=Jn(l,m),R=m.slice(-2),z=l<=1?"rc":"vec2("+R.join(",")+")";this.userCode=`
void main() {
`+g+` rc = getOutputCoords();
vec4 packedInput = getA(`+I+`);
setOutput(getChannel(packedInput, `+z+`));
}
`}return f}(),gl=i.backend_util.segment_util,xl=i.kernel_impls.split,Au=i.kernel_impls.tile,gc=i.kernel_impls.topkImpl,Us=i.kernel_impls.whereImpl,xc=1e-7,Qi=1e-4,hu={};function pr(f){return f in hu||(hu[f]={}),hu[f]}function Vs(f,p){if(p===void 0&&(p=!1),f==="linear")return p?vc:rs;if(f==="relu")return p?co:dn;if(f==="elu")return p?lu:Fn;if(f==="relu6")return p?Uo:Bo;if(f==="prelu")return p?Aa:ka;throw new Error("Activation "+f+" has not been implemented for the WebGL backend.")}var Ho=128,Du=600;function _c(){return i.env().global.screen==null?1024:i.env().global.screen.height*i.env().global.screen.width*window.devicePixelRatio*Du/1024/1024}var Fu=1e3,Go=function(f){O(p,f);function p(l){var m=f.call(this)||this;if(m.pendingRead=new WeakMap,m.pendingDisposal=new WeakSet,m.dataRefCount=new WeakMap,m.numBytesInGPU=0,m.uploadWaitMs=0,m.downloadWaitMs=0,m.warnedAboutMemory=!1,m.warnedAboutCPUBackend=!1,m.pendingDeletes=0,m.disposed=!1,!i.env().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(l==null){var g=P(i.env().getNumber("WEBGL_VERSION"));m.binaryCache=pr(i.env().getNumber("WEBGL_VERSION")),m.gpgpu=new Oe(g),m.canvas=g.canvas,m.gpgpuCreatedLocally=!0}else m.gpgpu=l,m.binaryCache={},m.gpgpuCreatedLocally=!1,m.canvas=l.gl.canvas;return m.textureManager=new Da(m.gpgpu),m.numMBBeforeWarning=_c(),m.texData=new i.DataStorage(m,i.engine()),m}return p.prototype.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes},p.prototype.write=function(l,m,g){if((i.env().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||i.env().getBool("DEBUG"))&&this.checkNumericalProblems(l),g==="complex64"&&l!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var I={};return this.texData.set(I,{shape:m,dtype:g,values:l,usage:w.UPLOAD,refCount:1,complexParentRefCount:0}),I},p.prototype.incRef=function(l){var m=this.texData.get(l);m.refCount++},p.prototype.decRef=function(l){if(this.texData.has(l)){var m=this.texData.get(l);m.refCount--}},p.prototype.move=function(l,m,g,I){if(i.env().getBool("DEBUG")&&this.checkNumericalProblems(m),I==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(l,{shape:g,dtype:I,values:m,usage:w.UPLOAD,refCount:1,complexParentRefCount:0})},p.prototype.disposeIntermediateTensorInfo=function(l){var m=l.dataId;if(this.texData.has(m)){var g=this.texData.get(m);g.refCount--,g.refCount<1&&this.disposeData(m)}},p.prototype.readSync=function(l){var m=this.texData.get(l),g=m.values,I=m.dtype,R=m.complexTensorInfos,z=m.slice,L=m.shape,G=m.isPacked;if(z!=null){var Z=void 0;G?Z=new as(L,ks):Z=new Or(L,ks);var be=this.runWebGLProgram(Z,[{dataId:l,shape:L,dtype:I}],I),Ce=this.readSync(be.dataId);return this.disposeIntermediateTensorInfo(be),Ce}if(g!=null)return this.convertAndCacheOnCPU(l);if(I==="string")return g;var De=this.activeTimers!=null,Te;De&&(Te=i.util.now());var Ge;if(I==="complex64"){var Ze=this.readSync(R.real.dataId),s=this.readSync(R.imag.dataId);Ge=i.backend_util.mergeRealAndImagArrays(Ze,s)}else Ge=this.getValuesFromTexture(l);return De&&(this.downloadWaitMs+=i.util.now()-Te),this.convertAndCacheOnCPU(l,Ge)},p.prototype.read=function(l){return H(this,void 0,void 0,function(){var m,g,I,R,z,L,G,Z,be,Ce,De,Te,Ge,Ze,s,u,r,o,h,b,T,M;return se(this,function(q){switch(q.label){case 0:if(this.pendingRead.has(l))return m=this.pendingRead.get(l),[2,new Promise(function(Y){return m.push(Y)})];if(g=this.texData.get(l),I=g.values,R=g.shape,z=g.slice,L=g.dtype,G=g.complexTensorInfos,Z=g.isPacked,z!=null)return be=void 0,Z?be=new as(R,ks):be=new Or(R,ks),Ce=this.runWebGLProgram(be,[{dataId:l,shape:R,dtype:L}],L),De=this.read(Ce.dataId),this.disposeIntermediateTensorInfo(Ce),[2,De];if(I!=null)return[2,this.convertAndCacheOnCPU(l)];if(!i.env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&i.env().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");return Te=null,L!=="complex64"&&i.env().get("WEBGL_BUFFER_SUPPORTED")&&(Ge=this.decode(l),Ze=this.texData.get(Ge.dataId),Te=(M=this.gpgpu).createBufferFromTexture.apply(M,[Ze.texture].concat(nt(R)))),this.pendingRead.set(l,[]),L!=="complex64"?[4,this.gpgpu.createAndWaitForFence()]:[3,2];case 1:q.sent(),q.label=2;case 2:return L==="complex64"?[4,Promise.all([this.read(G.real.dataId),this.read(G.imag.dataId)])]:[3,4];case 3:return u=q.sent(),r=u[0],o=u[1],s=i.backend_util.mergeRealAndImagArrays(r,o),[3,5];case 4:Te==null?s=this.getValuesFromTexture(l):(h=i.util.sizeFromShape(R),s=this.gpgpu.downloadFloat32MatrixFromBuffer(Te,h)),q.label=5;case 5:return Ge!=null&&this.disposeIntermediateTensorInfo(Ge),b=this.convertAndCacheOnCPU(l,s),T=this.pendingRead.get(l),this.pendingRead.delete(l),T.forEach(function(Y){return Y(b)}),this.pendingDisposal.has(l)&&(this.pendingDisposal.delete(l),this.disposeData(l),this.pendingDeletes--),[2,b]}})})},p.prototype.checkNumericalProblems=function(l){if(l==null)return;for(var m=0;m<l.length;m++){var g=l[m];if(!ht(g))throw i.env().getBool("WEBGL_RENDER_FLOAT32_CAPABLE")?Error("The value "+g+" cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'"):Error("The value "+g+" cannot be represented on this device.")}},p.prototype.getValuesFromTexture=function(l){var m,g=this.texData.get(l),I=g.shape,R=g.dtype,z=g.isPacked,L=i.util.sizeFromShape(I);if(i.env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var G=this.decode(l),Z=this.texData.get(G.dataId),be=(m=this.gpgpu).downloadMatrixFromPackedTexture.apply(m,[Z.texture].concat(nt(I))).subarray(0,L);return this.disposeIntermediateTensorInfo(G),be}var Ce=i.env().getBool("WEBGL_PACK")&&z===!0,De=Ce?wi(I):I,Te=Ce?new Bs(De):new wo(De),Ge=this.runWebGLProgram(Te,[{shape:De,dtype:R,dataId:l}],"float32"),Ze=this.texData.get(Ge.dataId),s=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(Ze.texture,Ze.texShape[0],Ze.texShape[1]).subarray(0,L);return this.disposeIntermediateTensorInfo(Ge),s},p.prototype.time=function(l){return H(this,void 0,void 0,function(){var m,g,I,R,z,L,G;return se(this,function(Z){switch(Z.label){case 0:return m=this.activeTimers,g=[],I=!1,this.programTimersStack==null?(this.programTimersStack=g,I=!0):this.activeTimers.push(g),this.activeTimers=g,l(),R=i.util.flatten(this.activeTimers.map(function(be){return be.query})).filter(function(be){return be!=null}),z=i.util.flatten(this.activeTimers.map(function(be){return be.name})).filter(function(be){return be!=null}),this.activeTimers=m,I&&(this.programTimersStack=null),L={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null},i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?[4,Promise.all(R)]:[3,2];case 1:return G=Z.sent(),L.kernelMs=i.util.sum(G),L.getExtraProfileInfo=function(){return G.map(function(be,Ce){return{name:z[Ce],ms:be}}).map(function(be){return be.name+": "+be.ms}).join(", ")},[3,3];case 2:L.kernelMs={error:"WebGL query timers are not supported in this environment."},Z.label=3;case 3:return this.uploadWaitMs=0,this.downloadWaitMs=0,[2,L]}})})},p.prototype.memory=function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}},p.prototype.startTimer=function(){return i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:i.util.now(),endMs:null}},p.prototype.endTimer=function(l){return i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),l):(l.endMs=i.util.now(),l)},p.prototype.getQueryTime=function(l){return H(this,void 0,void 0,function(){var m;return se(this,function(g){return i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?[2,this.gpgpu.waitForQueryAndGetTime(l)]:(m=l,[2,m.endMs-m.startMs])})})},p.prototype.disposeData=function(l){if(this.pendingDisposal.has(l))return;if(this.pendingRead.has(l)){this.pendingDisposal.add(l),this.pendingDeletes++;return}if(!this.texData.has(l))return;if(this.texData.get(l).complexParentRefCount>0){this.texData.get(l).refCount--;return}this.releaseGPUData(l);var m=this.texData.get(l).complexTensorInfos;m!=null&&(this.texData.get(m.real.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(m.real),this.texData.get(m.imag.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(m.imag)),this.texData.delete(l)},p.prototype.releaseGPUData=function(l){var m=this.texData.get(l),g=m.texture,I=m.dtype,R=m.texShape,z=m.usage,L=m.isPacked,G=m.slice,Z=G&&G.origDataId||l,be=this.dataRefCount.get(Z);be>1?this.dataRefCount.set(Z,be-1):(this.dataRefCount.delete(Z),g!=null&&(this.numBytesInGPU-=this.computeBytes(R,I),this.textureManager.releaseTexture(g,R,z,L)));var Ce=this.texData.get(l);Ce.texture=null,Ce.texShape=null,Ce.isPacked=!1,Ce.slice=null},p.prototype.getTexture=function(l){return this.uploadToGPU(l),this.texData.get(l).texture},p.prototype.getDataInfo=function(l){return this.texData.get(l)},p.prototype.getCPUBackend=function(){return i.env().getBool("WEBGL_CPU_FORWARD")?(this.cpuBackend==null&&(this.cpuBackend=i.engine().findBackend("cpu")),this.cpuBackend):null},p.prototype.shouldExecuteOnCPU=function(l,m){var g=this;m===void 0&&(m=Ho);var I=this.getCPUBackend();return!this.warnedAboutCPUBackend&&I==null&&(console.warn("Your application contains ops that are small enough to be executed on the CPU backend, however the CPU backend cannot be found. Consider importing the CPU backend (@tensorflow/tfjs-backend-cpu) for better performance."),this.warnedAboutCPUBackend=!0),I!=null&&l.every(function(R){return g.texData.get(R.dataId).texture==null&&i.util.sizeFromShape(R.shape)<m})},p.prototype.getGPGPUContext=function(){return this.gpgpu},p.prototype.slice=function(l,m,g){if(this.shouldExecuteOnCPU([l])){var I=fa(this.texData.get(l.dataId).values,m,g,l.shape,l.dtype);return this.makeOutput(g,l.dtype,I)}if(i.util.sizeFromShape(g)===0)return i.tensor([],g,l.dtype);var R=this.texData.get(l.dataId).isPacked,z=i.slice_util.isSliceContinous(l.shape,m,g);if(R||!z){var L=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Bn(g):new Nn(g),G=L.getCustomSetupFunc(m);return this.compileAndRun(L,[l],null,G)}return this.uploadToGPU(l.dataId),this.shallowSlice(l,m,g)},p.prototype.shallowSlice=function(l,m,g){var I=this.texData.get(l.dataId),R=this.makeOutput(g,l.dtype),z=this.texData.get(R.dataId);Object.assign(z,I),z.shape=g,z.dtype=l.dtype;var L=i.slice_util.computeFlatOffset(m,l.strides);I.slice&&(L+=I.slice.flatOffset),z.slice={flatOffset:L,origDataId:I.slice&&I.slice.origDataId||l.dataId};var G=this.dataRefCount.get(z.slice.origDataId)||1;return this.dataRefCount.set(z.slice.origDataId,G+1),R},p.prototype.stridedSlice=function(l,m,g,I){var R=this,z=this.tryRunOnCpuOrThrow([l],function(){return R.cpuBackend.stridedSlice(l,m,g,I)});if(z)return z;var L=i.slice_util.computeOutShape(m,g,I);if(L.some(function(Z){return Z===0}))return i.tensor([],L);var G=new Pn(m,I,L);return this.compileAndRun(G,[l])},p.prototype.reverse=function(l,m){var g=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Er(l.shape,m):new fr(l.shape,m);return this.compileAndRun(g,[l])},p.prototype.neg=function(l){var m=this,g=this.tryRunOnCpuOrThrow([l],function(){return m.cpuBackend.neg(l)});if(g)return g;if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,si,l.dtype);var I=new Or(l.shape,si);return this.compileAndRun(I,[l])},p.prototype.batchMatMul=function(l,m,g,I){var R=g?l.shape[2]:l.shape[1],z=I?m.shape[1]:m.shape[2],L=g?l.shape[1]:l.shape[2],G=Math.max(l.shape[0],m.shape[0]);if((R===1||z===1)&&L>Fu){g&&(l=i.transpose(l,[0,2,1])),I&&(m=i.transpose(m,[0,2,1]));var Z=z===1?l:l.as3D(G,L,1),be=z===1?2:1,Ce=z===1?m.as3D(G,1,L):m,De=i.mul(Z,Ce);return De.sum(be,!0)}var Te=i.upcastType(l.dtype,m.dtype),Ge=new Lt(l.shape,m.shape,[G,R,z],g,I);return this.compileAndRun(Ge,[l,m],Te)},p.prototype.fusedBatchMatMul=function(l){var m=l.a,g=l.b,I=l.transposeA,R=l.transposeB,z=l.bias,L=l.activation,G=l.preluActivationWeights,Z=I?m.shape[2]:m.shape[1],be=R?g.shape[1]:g.shape[2],Ce=Math.max(m.shape[0],g.shape[0]),De=i.upcastType(m.dtype,g.dtype),Te=z!=null,Ge=G!=null,Ze=L?Vs(L,!0):null,s=new Lt(m.shape,g.shape,[Ce,Z,be],I,R,Te,Ze,Ge),u=[m,g];return z&&u.push(z),G&&u.push(G),this.compileAndRun(s,u,De)},p.prototype.localResponseNormalization4D=function(l,m,g,I,R){var z=i.env().getBool("WEBGL_PACK_NORMALIZATION")?new lt(l.shape,m,g,I,R):new et(l.shape,m,g,I,R);return this.compileAndRun(z,[l])},p.prototype.LRNGrad=function(l,m,g,I,R,z,L){var G=new gt(m.shape,I,R,z,L);return this.compileAndRun(G,[m,g,l])},p.prototype.tile=function(l,m){if(l.dtype==="string"){var g=this.readSync(l.dataId),I=g.map(function(L){return i.util.decodeString(L)}),R=i.buffer(l.shape,l.dtype,I);return Au(R,m)}var z=new Yi(l.shape,m);return this.compileAndRun(z,[l])},p.prototype.pad=function(l,m,g){var I=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Et(l.shape,m,g):new wt(l.shape,m,g);return this.compileAndRun(I,[l])},p.prototype.gather=function(l,m,g){var I=this,R=this.tryRunOnCpuOrThrow([l,m],function(){return I.cpuBackend.gather(l,m,g)});if(R)return R;var z=new iu(l.shape,m.size,g);return this.compileAndRun(z,[l,m])},p.prototype.batchToSpaceND=function(l,m,g){i.util.assert(l.rank<=4,function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"});var I=m.reduce(function(be,Ce){return be*Ce}),R=i.backend_util.getReshaped(l.shape,m,I),z=i.backend_util.getPermuted(R.length,m.length),L=i.backend_util.getReshapedPermuted(l.shape,m,I),G=i.backend_util.getSliceBeginCoords(g,m.length),Z=i.backend_util.getSliceSize(L,g,m.length);return i.transpose(l.reshape(R),z).reshape(L).slice(G,Z)},p.prototype.spaceToBatchND=function(l,m,g){i.util.assert(l.rank<=4,function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"});var I=m.reduce(function(De,Te){return De*Te}),R=[[0,0]];R.push.apply(R,g);for(var z=1+m.length;z<l.shape.length;++z)R.push([0,0]);var L=l.pad(R),G=i.backend_util.getReshaped(L.shape,m,I,!1),Z=i.backend_util.getPermuted(G.length,m.length,!1),be=i.backend_util.getReshapedPermuted(L.shape,m,I,!1),Ce=i.transpose(L.reshape(G),Z);return i.reshape(Ce,be)},p.prototype.reduce=function(l,m,g){var I=l.shape[0],R=l.shape[1],z=i.backend_util.computeOptimalWindowSize(R),L=Math.ceil(R/z),G={windowSize:z,inSize:R,batchSize:I,outSize:L},Z=new cr(G,m),be=this.compileAndRun(Z,[l],g);return be.shape[1]===1?be:this.reduce(be,m,g)},p.prototype.argReduce=function(l,m,g){g===void 0&&(g=null);var I=l.shape[0],R=l.shape[1];g!=null&&(I=g.shape[0],R=g.shape[1]);var z=i.backend_util.computeOptimalWindowSize(R),L={windowSize:z,inSize:R,batchSize:I,outSize:Math.ceil(R/z)},G=new na(L,m,g==null),Z=[l];g!=null&&Z.push(g);var be=this.compileAndRun(G,Z,"int32");return be.shape[1]===1?be:this.argReduce(l,m,be)},p.prototype.argReducePacked=function(l,m,g){g===void 0&&(g=null);var I=g!=null?g.shape:l.shape,R=I[I.length-1],z=i.backend_util.computeOptimalWindowSize(R),L=new Ki(I,z,m,g==null),G=g==null?[l]:[l,g],Z=this.compileAndRun(L,G,"int32");return Z.rank===l.rank?this.argReducePacked(l,m,Z):Z},p.prototype.sum=function(l,m){i.backend_util.assertAxesAreInnerMostDims("sum",m,l.rank);var g=i.backend_util.computeOutAndReduceShapes(l.shape,m),I=g[0],R=g[1],z=i.util.sizeFromShape(R),L=l.as2D(-1,z),G=i.sumOutType(l.dtype);return this.reduce(L,"sum",G).reshape(I)},p.prototype.prod=function(l,m){var g=this,I=this.tryRunOnCpuOrThrow([l],function(){return g.cpuBackend.prod(l,m)});if(I)return I;var R=i.backend_util.computeOutAndReduceShapes(l.shape,m),z=R[0],L=R[1],G=i.util.sizeFromShape(L),Z=l.as2D(-1,G),be=i.sumOutType(l.dtype);return this.reduce(Z,"prod",be).reshape(z)},p.prototype.unsortedSegmentSum=function(l,m,g){var I=0,R=i.backend_util.getAxesPermutation([I],l.rank),z=l;R!=null&&(z=i.transpose(l,R),I=i.backend_util.getInnerMostAxes(1,l.rank)[0]);var L=gl.computeOutShape(z.shape,I,g),G=i.util.sizeFromShape([z.shape[I]]),Z=z.as2D(-1,G),be=i.sumOutType(l.dtype),Ce=this.segOpCompute(Z,"unsortedSegmentSum",m,be,g).reshape(L);return R!=null&&(Ce=i.transpose(Ce,i.backend_util.getUndoAxesPermutation(R))),Ce},p.prototype.segOpCompute=function(l,m,g,I,R){var z=l.shape[0],L=l.shape[1],G=gl.segOpComputeOptimalWindowSize(L,R),Z={windowSize:G,inSize:L,batchSize:z,numSegments:R},be=new wn(Z,m),Ce=this.compileAndRun(be,[l,g],I);return Ce.shape[1]===R?Ce:(g=i.range(0,R).tile([L/G]),this.segOpCompute(Ce,m,g,I,R))},p.prototype.argMinMaxReduce=function(l,m,g){var I=[m];if(i.backend_util.assertAxesAreInnerMostDims("arg"+g.charAt(0).toUpperCase()+g.slice(1),I,l.rank),!i.env().getBool("WEBGL_PACK_REDUCE")||l.rank<=2){var R=i.backend_util.computeOutAndReduceShapes(l.shape,I),z=R[0],L=R[1],G=i.util.sizeFromShape(L),Z=l.as2D(-1,G);return this.argReduce(Z,g).reshape(z)}return this.argReducePacked(l,g)},p.prototype.argMin=function(l,m){return this.argMinMaxReduce(l,m,"min")},p.prototype.argMax=function(l,m){return this.argMinMaxReduce(l,m,"max")},p.prototype.cumsum=function(l,m,g,I){if(m!==l.rank-1)throw new Error("WebGL cumsum shader expects an inner-most axis="+(l.rank-1)+" "+("but got axis="+m));for(var R=l.shape[m],z=l,L=0;L<=Math.ceil(Math.log2(R))-1;L++){var G=new Zo(l.shape,!1,I),Z=G.getCustomSetupFunc(L),be=z;z=this.compileAndRun(G,[z],z.dtype,Z),be.dispose()}if(g){var G=new Zo(l.shape,g,I),be=z;z=this.compileAndRun(G,[z]),be.dispose()}return z},p.prototype.equal=function(l,m){if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,To,"bool");var g=new vn(ao,l.shape,m.shape);return this.compileAndRun(g,[l,m],"bool")},p.prototype.less=function(l,m){var g=this,I=this.tryRunOnCpuOrThrow([l,m],function(){return g.cpuBackend.less(l,m)});if(I)return I;if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,Rs,"bool");var R=new vn(Ko,l.shape,m.shape);return this.compileAndRun(R,[l,m],"bool")},p.prototype.lessEqual=function(l,m){if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,Eo,"bool");var g=new vn(No,l.shape,m.shape);return this.compileAndRun(g,[l,m],"bool")},p.prototype.greater=function(l,m){var g=this,I=this.tryRunOnCpuOrThrow([l,m],function(){return g.cpuBackend.greater(l,m)});if(I)return I;if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,As,"bool");var R=new vn(Co,l.shape,m.shape);return this.compileAndRun(R,[l,m],"bool")},p.prototype.greaterEqual=function(l,m){if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,Ds,"bool");var g=new vn(io,l.shape,m.shape);return this.compileAndRun(g,[l,m],"bool")},p.prototype.logicalNot=function(l){var m=new Or(l.shape,ns);return this.compileAndRun(m,[l])},p.prototype.logicalAnd=function(l,m){if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,Xo,"bool");var g=new vn(ia,l.shape,m.shape);return this.compileAndRun(g,[l,m],"bool")},p.prototype.logicalOr=function(l,m){if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,Ro,"bool");var g=new vn(Pr,l.shape,m.shape);return this.compileAndRun(g,[l,m],"bool")},p.prototype.select=function(l,m,g){var I=new ie(l.rank,m.shape,m.rank);return this.compileAndRun(I,[l,m,g],i.upcastType(m.dtype,g.dtype))},p.prototype.where=function(l){i.backend_util.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");var m=l.dataSync();return Us(l.shape,m)},p.prototype.topk=function(l,m,g){var I=l.dataSync();return gc(I,l.shape,l.dtype,m,g)},p.prototype.min=function(l,m){i.backend_util.assertAxesAreInnerMostDims("min",m,l.rank);var g=i.backend_util.computeOutAndReduceShapes(l.shape,m),I=g[0],R=g[1],z=i.util.sizeFromShape(R),L=l.as2D(-1,z);return this.reduce(L,"min",L.dtype).reshape(I)},p.prototype.minimum=function(l,m){var g=this,I=this.tryRunOnCpuOrThrow([l,m],function(){return g.cpuBackend.minimum(l,m)});if(I)return I;var R=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vi(Ao,l.shape,m.shape):new vn(Xa,l.shape,m.shape);return this.compileAndRun(R,[l,m])},p.prototype.mod=function(l,m){var g=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vi(Qo,l.shape,m.shape):new vn(Qn,l.shape,m.shape);return this.compileAndRun(g,[l,m])},p.prototype.maximum=function(l,m){var g=this,I=this.tryRunOnCpuOrThrow([l,m],function(){return g.cpuBackend.maximum(l,m)});if(I)return I;var R=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vi(Yo,l.shape,m.shape):new vn(oa,l.shape,m.shape);return this.compileAndRun(R,[l,m])},p.prototype.all=function(l,m){i.backend_util.assertAxesAreInnerMostDims("all",m,l.rank);var g=i.backend_util.computeOutAndReduceShapes(l.shape,m),I=g[0],R=g[1],z=i.util.sizeFromShape(R),L=l.as2D(-1,z);return this.reduce(L,"all",L.dtype).reshape(I)},p.prototype.any=function(l,m){i.backend_util.assertAxesAreInnerMostDims("any",m,l.rank);var g=i.backend_util.computeOutAndReduceShapes(l.shape,m),I=g[0],R=g[1],z=i.util.sizeFromShape(R),L=l.as2D(-1,z);return this.reduce(L,"any",L.dtype).reshape(I)},p.prototype.floorDiv=function(l,m){var g=mo,I="int32";if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,yo,I);var R=new vn(g,l.shape,m.shape);return this.compileAndRun(R,[l,m],I)},p.prototype.packedUnaryOp=function(l,m,g){var I=new as(l.shape,m);return this.compileAndRun(I,[l],g)},p.prototype.packedBinaryOp=function(l,m,g,I,R){R===void 0&&(R=!1);var z=new vi(g,l.shape,m.shape,R);return this.compileAndRun(z,[l,m],I)},p.prototype.makeComplexComponentTensorInfo=function(l,m){return{dataId:m.dataId,dtype:m.dtype,shape:l.shape}},p.prototype.addN=function(l){if(l.length===1)return l[0];if(l.length>i.env().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var m=Math.floor(l.length/2),g=this.addN(l.slice(0,m)),I=this.addN(l.slice(m));return this.addN([g,I])}var R=l.map(function(Z){return Z.dtype}).reduce(function(Z,be){return i.upcastType(Z,be)}),z=l.map(function(Z){return Z.shape}),L=i.env().getBool("WEBGL_PACK"),G=L?new hn(l[0].shape,z):new sn(l[0].shape,z);return this.compileAndRun(G,l,R)},p.prototype.pow=function(l,m){var g=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"),I=g?new vi(vo,l.shape,m.shape):new vn(Ka,l.shape,m.shape),R=i.upcastType(l.dtype,m.dtype);return this.compileAndRun(I,[l,m],R)},p.prototype.ceil=function(l){if(this.shouldExecuteOnCPU([l])){var m=Le(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Su,l.dtype);var g=new Or(l.shape,Su);return this.compileAndRun(g,[l])},p.prototype.floor=function(l){if(this.shouldExecuteOnCPU([l])){var m=St(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Iu,l.dtype);var g=new Or(l.shape,Iu);return this.compileAndRun(g,[l])},p.prototype.sign=function(l){var m=new Or(l.shape,lc);return this.compileAndRun(m,[l])},p.prototype.isNaN=function(l){var m=new Or(l.shape,xs);return this.compileAndRun(m,[l],"bool")},p.prototype.isInf=function(l){var m=new Or(l.shape,Ii);return this.compileAndRun(m,[l],"bool")},p.prototype.isFinite=function(l){var m=new Or(l.shape,_s);return this.compileAndRun(m,[l],"bool")},p.prototype.round=function(l){var m=new Or(l.shape,bo);return this.compileAndRun(m,[l])},p.prototype.exp=function(l){if(this.shouldExecuteOnCPU([l])){var m=Ye(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,so,l.dtype);var g=new Or(l.shape,so);return this.compileAndRun(g,[l])},p.prototype.expm1=function(l){if(this.shouldExecuteOnCPU([l])){var m=Ft(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Nu,l.dtype);var g=new Or(l.shape,Nu);return this.compileAndRun(g,[l])},p.prototype.softmax=function(l,m){var g=i.util.parseAxisParam([m],l.shape),I=i.max(l,g),R=i.backend_util.expandShapeToKeepDim(I.shape,g),z=i.sub(l,I.reshape(R)),L=this.exp(z),G=this.sum(L,g).reshape(R);return i.div(L,G)},p.prototype.log=function(l){if(this.shouldExecuteOnCPU([l])){var m=Mt(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Wo,l.dtype);var g=new Or(l.shape,uu);return this.compileAndRun(g,[l])},p.prototype.log1p=function(l){var m=new Or(l.shape,ws);return this.compileAndRun(m,[l])},p.prototype.sqrt=function(l){var m=new Or(l.shape,Cu);return this.compileAndRun(m,[l])},p.prototype.rsqrt=function(l){if(this.shouldExecuteOnCPU([l])){var m=ta(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}var g=new Or(l.shape,cu);return this.compileAndRun(g,[l])},p.prototype.reciprocal=function(l){var m=new Or(l.shape,Ni);return this.compileAndRun(m,[l])},p.prototype.relu=function(l){var m;return i.env().getBool("WEBGL_PACK")?m=new as(l.shape,co):m=new Or(l.shape,dn),this.compileAndRun(m,[l])},p.prototype.relu6=function(l){var m;return i.env().getBool("WEBGL_PACK")?m=new as(l.shape,Uo):m=new Or(l.shape,Bo),this.compileAndRun(m,[l])},p.prototype.prelu=function(l,m){var g=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vi(Aa,l.shape,m.shape):new vn(ka,l.shape,m.shape);return this.compileAndRun(g,[l,m])},p.prototype.elu=function(l){if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,lu,l.dtype);var m=new Or(l.shape,Fn);return this.compileAndRun(m,[l])},p.prototype.eluDer=function(l,m){var g=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vi(go,l.shape,m.shape):new vn(oo,l.shape,m.shape);return this.compileAndRun(g,[l,m])},p.prototype.selu=function(l){var m=new Or(l.shape,su);return this.compileAndRun(m,[l])},p.prototype.clip=function(l,m,g){var I;i.env().getBool("WEBGL_PACK_CLIP")?I=new tu(l.shape):I=new Fs(l.shape);var R=I.getCustomSetupFunc(m,g);return this.compileAndRun(I,[l],null,R)},p.prototype.abs=function(l){if(this.shouldExecuteOnCPU([l])&&l.dtype!=="complex64"){var m=kt(this.texData.get(l.dataId).values);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Po,l.dtype);var g=new Or(l.shape,Po);return this.compileAndRun(g,[l])},p.prototype.complexAbs=function(l){var m=this.texData.get(l.dataId),g=new ps(l.shape),I=[this.makeComplexComponentTensorInfo(l,m.complexTensorInfos.real),this.makeComplexComponentTensorInfo(l,m.complexTensorInfos.imag)];return this.compileAndRun(g,I)},p.prototype.sigmoid=function(l){var m=new Or(l.shape,Tu);return this.compileAndRun(m,[l])},p.prototype.softplus=function(l){var m=new Or(l.shape,hc);return this.compileAndRun(m,[l])},p.prototype.asin=function(l){var m=new Or(l.shape,uo);return this.compileAndRun(m,[l])},p.prototype.acos=function(l){var m=new Or(l.shape,bs);return this.compileAndRun(m,[l])},p.prototype.atan=function(l){var m=new Or(l.shape,Eu);return this.compileAndRun(m,[l])},p.prototype.sinh=function(l){var m=new Or(l.shape,pc);return this.compileAndRun(m,[l])},p.prototype.cosh=function(l){var m=new Or(l.shape,dc);return this.compileAndRun(m,[l])},p.prototype.tanh=function(l){var m=new Or(l.shape,fc);return this.compileAndRun(m,[l])},p.prototype.asinh=function(l){var m=new Or(l.shape,vl);return this.compileAndRun(m,[l])},p.prototype.acosh=function(l){var m=new Or(l.shape,Ru);return this.compileAndRun(m,[l])},p.prototype.atanh=function(l){var m=new Or(l.shape,mc);return this.compileAndRun(m,[l])},p.prototype.erf=function(l){var m=new Or(l.shape,yc);return this.compileAndRun(m,[l])},p.prototype.step=function(l,m){var g=new Or(l.shape,cc(m));return this.compileAndRun(g,[l])},p.prototype.conv2dByMatMul=function(l,m,g,I,R,z){var L=l.shape,G=this.texData.get(l.dataId),Z=g.inChannels,be=L[0]*L[1]*L[2],Ce=g.outChannels,De=g.dataFormat==="channelsLast",Te=!1,Ge=!1,Ze=(be===1||Ce===1)&&Z>Fu,s=L[2]%2!==0&&!!G.isPacked;if(Ze||!i.env().getBool("WEBGL_LAZILY_UNPACK")||!i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!s){var u=De?L[0]*L[1]*L[2]:L[0]*L[2]*L[3],r=i.reshape(l,[1,u,g.inChannels]),o=i.reshape(m,[1,g.inChannels,g.outChannels]),h=this.fusedBatchMatMul({a:r,b:o,transposeA:Te,transposeB:Ge,bias:I,activation:R,preluActivationWeights:z});return i.reshape(h,g.outShape)}var b=De?L[0]*L[1]*(L[2]+1):L[0]*L[2]*(L[3]+1),T={dataId:l.dataId,shape:[1,b,g.inChannels],dtype:l.dtype},M=G.shape;G.shape=G.shape.slice(),G.shape[G.shape.length-2]++,i.util.assert(_n(G.shape,T.shape),function(){return"packed reshape "+G.shape+" to "+T.shape+" isn't free"});var q=i.reshape(m,[1,g.inChannels,g.outChannels]),Y=this.fusedBatchMatMul({a:T,b:q,transposeA:Te,transposeB:Ge,bias:I,activation:R,preluActivationWeights:z}),le=this.texData.get(Y.dataId);return i.util.assert(le.isPacked,function(){return"batchMatMul result is expected to be packed"}),G.shape=M,le.shape=g.outShape,i.engine().makeTensorFromDataId(Y.dataId,g.outShape,Y.dtype)},p.prototype.conv2dWithIm2Row=function(l,m,g,I,R,z){var L=g.filterWidth,G=g.filterHeight,Z=g.inChannels,be=g.outWidth,Ce=g.outHeight,De=g.dataFormat,Te=De==="channelsLast",Ge=L*G*Z,Ze=Ce*be,s=[Ge,Ze],u=!0,r=!1,o=l.squeeze([0]),h=m.reshape([1,Ge,-1]),b=new $(s,o.shape,g),T=this.compileAndRun(b,[o]).reshape([1,s[0],s[1]]),M=I!=null,q=z!=null,Y=R?Vs(R,!0):null,le=new Lt(T.shape,h.shape,[1,Ze,g.outChannels],u,r,M,Y,q),Ne=[T,h];I&&Ne.push(I),q&&Ne.push(z);var We=this.compileAndRun(le,Ne);return Te?We.reshape([1,Ce,be,g.outChannels]):We.reshape([1,g.outChannels,Ce,be])},p.prototype.fusedConv2d=function(l){var m=l.input,g=l.filter,I=l.convInfo,R=l.bias,z=l.activation,L=l.preluActivationWeights;if(I.filterHeight===1&&I.filterWidth===1&&I.dilationHeight===1&&I.dilationWidth===1&&I.strideHeight===1&&I.strideWidth===1&&(I.padInfo.type==="SAME"||I.padInfo.type==="VALID"))return this.conv2dByMatMul(m,g,I,R,z,L);if(i.env().getBool("WEBGL_CONV_IM2COL")&&m.shape[0]===1)return this.conv2dWithIm2Row(m,g,I,R,z,L);var G=R!=null,Z=L!=null,be=z?Vs(z,!1):null,Ce=new fs(I,G,be,Z),De=[m,g];return R&&De.push(R),L&&De.push(L),this.compileAndRun(Ce,De)},p.prototype.conv2d=function(l,m,g){if(g.filterHeight===1&&g.filterWidth===1&&g.dilationHeight===1&&g.dilationWidth===1&&g.strideHeight===1&&g.strideWidth===1&&(g.padInfo.type==="SAME"||g.padInfo.type==="VALID"))return this.conv2dByMatMul(l,m,g);if(i.env().getBool("WEBGL_CONV_IM2COL")&&l.shape[0]===1)return this.conv2dWithIm2Row(l,m,g);var I=new fs(g);return this.compileAndRun(I,[l,m])},p.prototype.conv2dDerInput=function(l,m,g){var I=new Os(g);return this.compileAndRun(I,[l,m])},p.prototype.conv2dDerFilter=function(l,m,g){var I=new ru(g);return this.compileAndRun(I,[l,m])},p.prototype.fusedDepthwiseConv2D=function(l){var m=l.input,g=l.filter,I=l.convInfo,R=l.bias,z=l.activation,L=l.preluActivationWeights,G=i.env().getBool("WEBGL_PACK_DEPTHWISECONV")&&I.strideWidth<=2&&I.outChannels/I.inChannels===1,Z=z?Vs(z,G):null,be=[m,g],Ce=R!=null,De=L!=null;Ce&&be.push(R),De&&be.push(L);var Te;return G?(Te=new Do(I,Ce,Z,De),this.compileAndRun(Te,be)):(Te=new ms(I,Ce,Z,De),this.compileAndRun(Te,be))},p.prototype.depthwiseConv2D=function(l,m,g){var I;return i.env().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels===1?(I=new Do(g),this.compileAndRun(I,[l,m])):(I=new ms(g),this.compileAndRun(I,[l,m]))},p.prototype.depthwiseConv2DDerInput=function(l,m,g){var I=new nu(g);return this.compileAndRun(I,[l,m])},p.prototype.depthwiseConv2DDerFilter=function(l,m,g){var I=new Ls(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3d=function(l,m,g){var I=new au(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3dDerInput=function(l,m,g){var I=new Ms(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3dDerFilter=function(l,m,g){var I=new ds(g);return this.compileAndRun(I,[l,m])},p.prototype.unstack=function(l,m){for(var g=l.shape[m],I=new Array(l.rank-1),R=0,z=0;z<l.rank;z++)z!==m&&(I[R++]=l.shape[z]);var L=new Array(l.rank).fill(0),G=l.shape.slice();G[m]=1;for(var Z=new Array(g),z=0;z<Z.length;z++)L[m]=z,Z[z]=this.slice(l,L,G).reshape(I);return Z},p.prototype.avgPool3d=function(l,m){var g=new jt(m,"avg",!1);return this.compileAndRun(g,[l],"float32")},p.prototype.avgPool3dBackprop=function(l,m,g){var I=new Pi(g);return this.compileAndRun(I,[l],m.dtype)},p.prototype.maxPool3d=function(l,m){var g=new jt(m,"max",!1);return this.compileAndRun(g,[l],"float32")},p.prototype.maxPool3dBackprop=function(l,m,g,I){var R=!0,z=new jt(I,"max",R),L=this.compileAndRun(z,[m]),G=new At(I),Z=this.compileAndRun(G,[l,L],m.dtype);return L.dispose(),Z},p.prototype.resizeBilinear=function(l,m,g,I){var R=i.env().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Tr(l.shape,m,g,I):new Nr(l.shape,m,g,I);return this.compileAndRun(R,[l],"float32")},p.prototype.resizeBilinearBackprop=function(l,m,g){var I=new br(l,m,g);return this.compileAndRun(I,[l])},p.prototype.resizeNearestNeighbor=function(l,m,g,I){var R=new Dr(l.shape,m,g,I);return this.compileAndRun(R,[l])},p.prototype.resizeNearestNeighborBackprop=function(l,m,g){var I=new hr(l,m,g);return this.compileAndRun(I,[l])},p.prototype.multinomial=function(l,m,g,I){var R=m?l:i.softmax(l),z=R.shape[0],L=R.shape[1],G=new Pt(z,L,g),Z=G.getCustomSetupFunc(I);return this.compileAndRun(G,[R],"int32",Z)},p.prototype.oneHot=function(l,m,g,I){var R=new Ut(l.size,m,g,I);return this.compileAndRun(R,[l])},p.prototype.diag=function(l){var m=new _o(l.size);return this.compileAndRun(m,[l])},p.prototype.cropAndResize=function(l,m,g,I,R,z){var L=new zs(l.shape,m.shape,I,R,z);return this.compileAndRun(L,[l,m,g],"float32")},p.prototype.depthToSpace=function(l,m,g){i.util.assert(m>1,function(){return"blockSize should be > 1 for depthToSpace, but was: "+m});var I=l.shape[0],R=g==="NHWC"?l.shape[1]:l.shape[2],z=g==="NHWC"?l.shape[2]:l.shape[3],L=g==="NHWC"?l.shape[3]:l.shape[1],G=R*m,Z=z*m,be=L/(m*m),Ce=g==="NHWC"?[I,G,Z,be]:[I,be,G,Z],De=new Jo(Ce,m,g);return this.compileAndRun(De,[l])},p.prototype.split=function(l,m,g){return xl(l,m,g)},p.prototype.scatterND=function(l,m,g){var I=i.backend_util.calculateShapes(m,l,g),R=I.sliceRank,z=I.numUpdates,L=I.sliceSize,G=I.strides,Z=I.outputSize,be=[Z/L,L],Ce=l.reshape([z,R]),De=m.reshape([z,L]);if(Z===0)return i.backend_util.reshapeTensor(i.tensor([]),g);var Te=i.scalar(0),Ge=new an(z,R,Ce.rank,De.rank,G,be),Ze=this.compileAndRun(Ge,[De,Ce,Te]);return Ze.reshape(g)},p.prototype.sparseToDense=function(l,m,g,I){var R=i.backend_util.calculateShapes(m,l,g),z=R.sliceRank,L=R.numUpdates,G=R.strides,Z=R.outputSize,be=!1,Ce=new an(L,z,l.rank,m.rank,G,[Z,1],be),De=this.compileAndRun(Ce,[m,l,I]);return De.reshape(g)},p.prototype.gatherND=function(l,m){var g=m.shape,I=g[g.length-1],R=i.backend_util.prepareAndValidate(l,m),z=R[0],L=R[1],G=R[2],Z=R[3],be=m.reshape([L,I]),Ce=l.reshape([l.size/G,G]),De=new ou(I,Z,[L,G]),Te=this.compileAndRun(De,[Ce,be]);return Te.reshape(z)},p.prototype.fill=function(l,m,g){if(g=g||i.util.inferDtype(m),g==="string"){var I=i.util.getArrayFromDType(g,i.util.sizeFromShape(l));return I.fill(m),i.engine().makeTensor(I,l,g,this)}else{var R=new $o(l,m),z=R.getCustomSetupFunc(m);return this.compileAndRun(R,[],g,z)}},p.prototype.onesLike=function(l){if(l.dtype==="string")throw new Error("onesLike is not supported under string dtype");return this.fill(l.shape,1,l.dtype)},p.prototype.zerosLike=function(l){return this.fill(l.shape,l.dtype==="string"?"":0,l.dtype)},p.prototype.linspace=function(l,m,g){return i.backend_util.linspaceImpl(l,m,g)},p.prototype.makeTensorInfo=function(l,m,g){var I=this.write(g,l,m);return this.texData.get(I).usage=null,{dataId:I,shape:l,dtype:m}},p.prototype.makeOutput=function(l,m,g){var I=this.makeTensorInfo(l,m,g).dataId;return i.engine().makeTensorFromDataId(I,l,m,this)},p.prototype.unpackTensor=function(l){var m=new Vo(l.shape);return this.runWebGLProgram(m,[l],l.dtype)},p.prototype.packTensor=function(l){var m=new Nt(l.shape),g=!0;return this.runWebGLProgram(m,[l],l.dtype,null,g)},p.prototype.packedReshape=function(l,m){var g=[Ua(l.shape)].concat(ga(l.shape)),I={dtype:l.dtype,shape:g,dataId:l.dataId},R=[Ua(m)].concat(ga(m)),z=new rr(R,g),L=!0,G=this.runWebGLProgram(z,[I],l.dtype,null,L);return{dataId:G.dataId,shape:m,dtype:G.dtype}},p.prototype.decode=function(l){var m=this.texData.get(l),g=m.isPacked,I=m.shape,R=m.dtype,z=wi(I),L;g?L=new Ps(z):L=new Fo(z);var G=!0,Z=this.runWebGLProgram(L,[{shape:z,dtype:R,dataId:l}],R,null,G);return{dtype:R,shape:I,dataId:Z.dataId}},p.prototype.runWebGLProgram=function(l,m,g,I,R){var z=this;R===void 0&&(R=!1);var L=this.makeTensorInfo(l.outputShape,g),G=this.texData.get(L.dataId);if(l.packedOutput&&(G.isPacked=!0),l.outPackingScheme===ae.DENSE){var Z=nt(l.outputShape);G.texShape=Z.map(function(r){return r*2})}if(l.outTexUsage!=null&&(G.usage=l.outTexUsage),i.util.sizeFromShape(L.shape)===0)return G.values=i.util.getTypedArrayFromDType(L.dtype,0),L;var be=[],Ce=m.map(function(r){if(r.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var o=z.texData.get(r.dataId);if(o.texture==null){if(!l.packedInputs&&i.util.sizeFromShape(r.shape)<=i.env().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:r.shape,texData:null,isUniform:!0,uniformValues:o.values};l.packedInputs&&(o.isPacked=!0,o.shape=r.shape)}else if(!!o.isPacked!==!!l.packedInputs)r=o.isPacked?z.unpackTensor(r):z.packTensor(r),be.push(r),o=z.texData.get(r.dataId);else if(o.isPacked&&!_n(o.shape,r.shape)){var h=r,b=r.shape;r.shape=o.shape,r=z.packedReshape(r,b),be.push(r),o=z.texData.get(r.dataId),h.shape=b}return z.uploadToGPU(r.dataId),{shape:r.shape,texData:o,isUniform:!1}});this.uploadToGPU(L.dataId);var De={shape:L.shape,texData:G,isUniform:!1},Te=at(l,Ce,De),Ge=this.getAndSaveBinary(Te,function(){return Ve(z.gpgpu,l,Ce,De)}),Ze=this.activeTimers!=null,s;if(Ze&&(s=this.startTimer()),rt(this.gpgpu,Ge,Ce,De,I),be.forEach(function(r){return z.disposeIntermediateTensorInfo(r)}),Ze&&(s=this.endTimer(s),this.activeTimers.push({name:l.constructor.name,query:this.getQueryTime(s)})),!i.env().getBool("WEBGL_LAZILY_UNPACK")&&G.isPacked&&R===!1){var u=this.unpackTensor(L);return this.disposeIntermediateTensorInfo(L),u}return L},p.prototype.compileAndRun=function(l,m,g,I,R){R===void 0&&(R=!1),g=g||m[0].dtype;var z=this.runWebGLProgram(l,m,g,I,R);return i.engine().makeTensorFromDataId(z.dataId,z.shape,z.dtype)},p.prototype.getAndSaveBinary=function(l,m){return l in this.binaryCache||(this.binaryCache[l]=m()),this.binaryCache[l]},p.prototype.getTextureManager=function(){return this.textureManager},p.prototype.dispose=function(){var l=this;if(this.disposed)return;if(!i.env().getBool("IS_TEST")){var m=Object.keys(this.binaryCache);m.forEach(function(g){l.gpgpu.deleteProgram(l.binaryCache[g].webGLProgram),delete l.binaryCache[g]})}this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement!="undefined"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0},p.prototype.floatPrecision=function(){var l=this;return this.floatPrecisionValue==null&&(this.floatPrecisionValue=i.tidy(function(){if(!i.env().get("WEBGL_RENDER_FLOAT32_ENABLED")){var m=i.env().getBool("DEBUG");i.env().set("DEBUG",!1);var g=l.abs(i.scalar(1e-8)).dataSync()[0];if(i.env().set("DEBUG",m),g>0)return 32}return 16})),this.floatPrecisionValue},p.prototype.epsilon=function(){return this.floatPrecision()===32?xc:Qi},p.prototype.uploadToGPU=function(l){var m,g=this.texData.get(l),I=g.shape,R=g.dtype,z=g.values,L=g.texture,G=g.usage,Z=g.isPacked;if(L!=null)return;var be=this.activeTimers!=null,Ce;be&&(Ce=i.util.now());var De=g.texShape;if(De==null&&(De=Ta(I,Z),g.texShape=De),z!=null){var Te=wi(I),Ge=void 0,Ze=De[1],s=De[0],u=z instanceof Uint8Array;Z?(m=tt(De[0],De[1]),Ze=m[0],s=m[1],Ge=new vs(Te,[s,Ze],u)):Ge=new Ws(Te,[s,Ze],u);var r=this.makeTensorInfo([s,Ze],R);u?this.texData.get(r.dataId).usage=w.PIXELS:this.texData.get(r.dataId).usage=w.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(r.dataId),Ze,s,z);var o=!0,h=this.runWebGLProgram(Ge,[r],R,null,o),b=this.texData.get(h.dataId);g.texture=b.texture,g.texShape=b.texShape,g.isPacked=b.isPacked,g.usage=b.usage,this.disposeIntermediateTensorInfo(r),this.texData.delete(h.dataId),g.values=null,be&&(this.uploadWaitMs+=i.util.now()-Ce)}else{var T=this.acquireTexture(De,G,R,Z);g.texture=T}},p.prototype.convertAndCacheOnCPU=function(l,m){var g=this.texData.get(l),I=g.dtype;return this.releaseGPUData(l),m!=null&&(g.values=wc(m,I)),g.values},p.prototype.acquireTexture=function(l,m,g,I){if(this.numBytesInGPU+=this.computeBytes(l,g),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){var R=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: "+R+" MB, most likely due to a memory leak")}return this.textureManager.acquireTexture(l,m,I)},p.prototype.computeBytes=function(l,m){return l[0]*l[1]*i.util.bytesPerElement(m)},p.prototype.tryRunOnCpuOrThrow=function(l,m){if(this.shouldExecuteOnCPU(l))try{return m()}catch(g){if(i.env().getBool("IS_TEST"))throw new Error("CPU forwarding failed")}return null},p}(i.KernelBackend);function wc(f,p){if(p==="float32"||p==="complex64")return f;if(p==="int32"||p==="bool"){for(var l=p==="int32"?new Int32Array(f.length):new Uint8Array(f.length),m=0;m<l.length;++m)l[m]=Math.round(f[m]);return l}else throw new Error("Unknown dtype "+p)}var Ou="2.7.0";function Hs(){i.env().set("WEBGL_FORCE_F16_TEXTURES",!0)}i.device_util.isBrowser()&&i.registerBackend("webgl",function(){return new Go},2);var bc={forceHalfFloat:Hs};function lo(f){var p=f.inputs,l=f.backend,m=p.x;return l.incRef(m.dataId),{dataId:m.dataId,shape:m.shape,dtype:m.dtype}}var kc={kernelName:i.Identity,backendName:"webgl",kernelFunc:lo};function ho(f){var p=f.inputs,l=f.backend,m=p.real,g=p.imag,I=l.makeTensorInfo(m.shape,"complex64"),R=l.texData.get(I.dataId),z=lo({inputs:{x:m},backend:l}),L=l.texData.get(z.dataId);L.complexParentRefCount++;var G=lo({inputs:{x:g},backend:l}),Z=l.texData.get(G.dataId);return Z.complexParentRefCount++,R.complexTensorInfos={real:z,imag:G},I}var Sc={kernelName:i.Complex,backendName:"webgl",kernelFunc:ho},pu="if (isnan(x)) return x;",Ic=`
if (isnan(a)) return a;
if (isnan(b)) return b;
`,Mu=`
result.r = isNaN.r > 0. ? NAN : result.r;
result.g = isNaN.g > 0. ? NAN : result.g;
result.b = isNaN.b > 0. ? NAN : result.b;
result.a = isNaN.a > 0. ? NAN : result.a;
`;function Gs(f){return function(p){var l=p.inputs,m=p.backend,g=l.x,I=m,R=new Or(g.shape,f);return I.runWebGLProgram(R,[g],g.dtype)}}function po(f){var p=f.opSnippet,l=f.packedOpSnippet,m=f.checkOutOfBounds,g=m===void 0?!1:m,I=f.supportsComplex,R=I===void 0?!1:I,z=f.cpuKernelImpl,L=f.dtype;return function(G){var Z=G.inputs,be=G.backend,Ce=Z,De=Ce.a,Te=Ce.b,Ge=be;if(R&&De.dtype==="complex64"){var Ze=Ge.texData.get(De.dataId),s=Ge.texData.get(Te.dataId),u=[[Ze.complexTensorInfos.real,s.complexTensorInfos.real],[Ze.complexTensorInfos.imag,s.complexTensorInfos.imag]].map(function(je){var qe=je[0],mt=je[1],pt={dataId:qe.dataId,dtype:qe.dtype,shape:De.shape},st={dataId:mt.dataId,dtype:mt.dtype,shape:Te.shape},dt=new vn(p,De.shape,Te.shape);return Ge.runWebGLProgram(dt,[pt,st],i.upcastType(qe.dtype,mt.dtype))}),r=u[0],o=u[1],h=ho({inputs:{real:r,imag:o},backend:Ge});return Ge.disposeIntermediateTensorInfo(r),Ge.disposeIntermediateTensorInfo(o),h}var b=L||i.upcastType(De.dtype,Te.dtype);if(Ge.shouldExecuteOnCPU([De,Te])&&z!=null){var Ze=Ge.texData.get(De.dataId),s=Ge.texData.get(Te.dataId),T=z(De.shape,Te.shape,Ze.values,s.values,b),M=T[0],q=T[1],Y=Ge.makeTensorInfo(q,b),le=Ge.texData.get(Y.dataId);return le.values=M,Y}var Ne=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&l!=null,We;return Ne?We=new vi(l,De.shape,Te.shape,g):We=new vn(p,De.shape,Te.shape),Ge.runWebGLProgram(We,[De,Te],b)}}var Lu="return a + b;",_l=po({opSnippet:Lu,packedOpSnippet:Lu,supportsComplex:!0,cpuKernelImpl:$e}),zu={kernelName:i.Add,backendName:"webgl",kernelFunc:_l},Pu=Ic+`
return atan(a, b);
`,du=`
vec4 result = atan(a, b);
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
`+Mu+`
return result;
`,wl=po({opSnippet:Pu,packedOpSnippet:du}),fu={kernelName:i.Atan2,backendName:"webgl",kernelFunc:wl};function mu(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x;ln(g,"avgPool");var I=m.filterSize,R=m.strides,z=m.pad,L=m.dimRoundingMode,G=1;i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(R,G),function(){return"Error in avgPool: Either strides or dilations must be 1. "+("Got strides "+R+" and dilations '"+G+"'")});var Z=i.backend_util.computePool2DInfo(g.shape,I,R,G,z,L);if(Z.filterWidth===1&&Z.filterHeight===1&&i.util.arraysEqual(Z.inShape,Z.outShape))return lo({inputs:{x:g},backend:l});var be=new Vt(Z,"avg",!1);return l.runWebGLProgram(be,[g],"float32")}var Nc={kernelName:i.AvgPool,backendName:"webgl",kernelFunc:mu};function Cc(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.dy,I=p.input,R=I;ln([g,I],"avgPoolBackprop");var z=m.filterSize,L=m.strides,G=m.pad,Z=i.backend_util.computePool2DInfo(R.shape,z,L,1,G),be=new oi(Z);return l.runWebGLProgram(be,[g],R.dtype)}var Tc={kernelName:i.AvgPoolBackprop,backendName:"webgl",kernelFunc:Cc},Ec=function(){function f(p,l,m,g,I,R){this.outputShape=[],this.variableNames=["x","mean","variance"],i.backend_util.assertAndGetBroadcastShape(p,l),i.backend_util.assertAndGetBroadcastShape(p,m);var z="0.0";g!=null&&(i.backend_util.assertAndGetBroadcastShape(p,g),this.variableNames.push("offset"),z="getOffsetAtOutCoords()");var L="1.0";I!=null&&(i.backend_util.assertAndGetBroadcastShape(p,I),this.variableNames.push("scale"),L="getScaleAtOutCoords()"),this.outputShape=p,this.userCode=`
void main() {
float x = getXAtOutCoords();
float mean = getMeanAtOutCoords();
float variance = getVarianceAtOutCoords();
float offset = `+z+`;
float scale = `+L+`;
float inv = scale * inversesqrt(variance + float(`+R+`));
setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));
}
`}return f}(),Ke=function(){function f(p,l,m,g,I,R){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],i.backend_util.assertAndGetBroadcastShape(p,l),i.backend_util.assertAndGetBroadcastShape(p,m);var z="vec4(0.0)";g!=null&&(i.backend_util.assertAndGetBroadcastShape(p,g),this.variableNames.push("offset"),z="getOffsetAtOutCoords()");var L="vec4(1.0)";I!=null&&(i.backend_util.assertAndGetBroadcastShape(p,I),this.variableNames.push("scale"),L="getScaleAtOutCoords()"),this.outputShape=p,this.userCode=`
void main() {
vec4 offset = `+z+`;
vec4 scale = `+L+`;
vec4 x = getXAtOutCoords();
vec4 mean = getMeanAtOutCoords();
vec4 variance = getVarianceAtOutCoords();
vec4 inv = scale * inversesqrt(variance + vec4(`+R+`));
setOutput((x - mean) * inv + offset);
}
`}return f}(),Rc=function(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=p.mean,R=p.variance,z=p.offset,L=p.scale;i.util.assert(I.shape.length===R.shape.length,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),i.util.assert(z==null||I.shape.length===z.shape.length,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),i.util.assert(L==null||I.shape.length===L.shape.length,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var G=m.varianceEpsilon;G==null&&(G=.001);var Z=[g,I,R],be=null;z!=null&&(be=z.shape,Z.push(z));var Ce=null;L!=null&&(Ce=L.shape,Z.push(L));var De=i.env().getBool("WEBGL_PACK_NORMALIZATION")?new Ke(g.shape,I.shape,R.shape,be,Ce,G):new Ec(g.shape,I.shape,R.shape,be,Ce,G),Te=l.runWebGLProgram(De,Z,Z[0].dtype);return Te},un={kernelName:i.FusedBatchNorm,backendName:"webgl",kernelFunc:Rc},Ac="return float(a != b);",Ss=po({opSnippet:Ac,dtype:"bool"}),Dc={kernelName:i.NotEqual,backendName:"webgl",kernelFunc:Ss};function $n(f){var p=f.inputs,l=f.backend,m=p.input,g=l.texData.get(m.dataId);return lo({inputs:{x:g.complexTensorInfos.real},backend:l})}var Fc={kernelName:i.Real,backendName:"webgl",kernelFunc:$n},Oc="return float(int(x));";function Mc(f,p){var l=new Or(f.shape,Oc),m=p.runWebGLProgram(l,[f],"int32");return{dataId:m.dataId,shape:m.shape,dtype:m.dtype}}function js(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=m.dtype;if(I==="complex64"){if(g.dtype==="complex64")return lo({inputs:{x:g},backend:l});var R=i.zeros(g.shape),z=js({inputs:{x:g},backend:l,attrs:{dtype:"float32"}}),L=ho({inputs:{real:z,imag:R},backend:l});return R.dispose(),l.disposeIntermediateTensorInfo(z),L}if(g.dtype==="complex64"){var G=$n({inputs:{input:g},backend:l}),L=js({inputs:{x:G},backend:l,attrs:{dtype:I}});return l.disposeIntermediateTensorInfo(G),L}if(!i.util.hasEncodingLoss(g.dtype,I)){var L=lo({inputs:{x:g},backend:l});return{dataId:L.dataId,shape:L.shape,dtype:I}}if(I==="int32")return Mc(g,l);if(I==="bool"){var Z=l.makeTensorInfo([],"bool",i.util.getTypedArrayFromDType("bool",1)),be={a:g,b:Z},L=Ss({inputs:be,backend:l});return l.disposeIntermediateTensorInfo(Z),L}throw new Error("Error in Cast: failed to cast "+g.dtype+" to "+I)}var is={kernelName:i.Cast,backendName:"webgl",kernelFunc:js},Lc=function(){function f(p){this.outputShape=[],this.outputShape=i.backend_util.computeOutShape(p,1),this.variableNames=p.map(function(L,G){return"T"+G});var l=new Array(p.length-1);l[0]=p[0][1];for(var m=1;m<l.length;m++)l[m]=l[m-1]+p[m][1];for(var g=["if (yC < "+l[0]+") setOutput(getT0(yR, yC));"],m=1;m<l.length;m++){var I=l[m-1];g.push("else if (yC < "+l[m]+") "+("setOutput(getT"+m+"(yR, yC-"+I+"));"))}var R=l.length,z=l[l.length-1];g.push("else setOutput(getT"+R+"(yR, yC-"+z+"));"),this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int yR = coords.x;
int yC = coords.y;
`+g.join(`
`)+`
}
`}return f}(),zc=function(){function f(p,l){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=i.backend_util.computeOutShape(p,l);var m=this.outputShape,g=m.length,I=nn(g),R=Vr("coords",g),z=["x","y","z","w","u","v"].slice(0,g);this.variableNames=p.map(function(s,u){return"T"+u});var L=new Array(p.length-1);L[0]=p[0][l];for(var G=1;G<L.length;G++)L[G]=L[G-1]+p[G][l];for(var Z=z[l],be=z.slice(-2),Ce=z.join(),De="if ("+Z+" < "+L[0]+`) {
return getChannel(
getT0(`+Ce+"), vec2("+be.join()+`));
}`,G=1;G<L.length;G++){var Te=L[G-1];De+=`
if (`+Z+" < "+L[G]+" && "+Z+" >= "+L[G-1]+`) {
return getChannel(
getT`+G+"("+yu(z,Z,Te)+`),
vec2(`+yu(be,Z,Te)+`));
}`}var Ge=L.length,Ze=L[L.length-1];De+=`
return getChannel(
getT`+Ge+"("+yu(z,Z,Ze)+`),
vec2(`+yu(be,Z,Ze)+"));",this.userCode=`
float getValue(`+z.map(function(s){return"int "+s})+`) {
`+De+`
}
void main() {
`+I+` coords = getOutputCoords();
vec4 result = vec4(getValue(`+R+`), 0., 0., 0.);
`+R[g-1]+" = "+R[g-1]+` + 1;
if (`+R[g-1]+" < "+m[g-1]+`) {
result.g = getValue(`+R+`);
}
`+R[g-2]+" = "+R[g-2]+` + 1;
if (`+R[g-2]+" < "+m[g-2]+`) {
result.a = getValue(`+R+`);
}
`+R[g-1]+" = "+R[g-1]+` - 1;
if (`+R[g-2]+" < "+m[g-2]+` &&
`+R[g-1]+" < "+m[g-1]+`) {
result.b = getValue(`+R+`);
}
setOutput(result);
}
`}return f}();function yu(f,p,l){var m=f.indexOf(p),g=f.map(function(I,R){return R===m?I+" - "+l:I});return g.join()}function Pc(f){var p=f.inputs,l=f.backend,m=p.input,g=l.texData.get(m.dataId);return lo({inputs:{x:g.complexTensorInfos.imag},backend:l})}var Bu={kernelName:i.Imag,backendName:"webgl",kernelFunc:Pc};function bl(f,p,l){var m=[Ua(f.shape)].concat(ga(f.shape)),g={dtype:f.dtype,shape:m,dataId:f.dataId},I=[Ua(p)].concat(ga(p)),R=new rr(I,m),z=!0,L=l.runWebGLProgram(R,[g],f.dtype,null,z);return{dataId:L.dataId,shape:p,dtype:L.dtype}}function Zi(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=m.shape,R=l,z=i.util.sizeFromShape(g.shape),L=i.util.inferFromImplicitShape(I,z),G=i.util.sizeFromShape(L);i.util.assert(z===G,function(){return"The new shape ("+L+") has "+G+" elements and the old "+("shape ("+g.shape+") has "+z+" elements. The new shape and old ")+"shape must have the same number of elements."});var Z=R.texData.get(g.dataId);return Z.isPacked&&!_n(g.shape,L)&&!(Z.texture!==null&&_n(Z.shape,L))?bl(g,L,R):(R.incRef(g.dataId),{dataId:g.dataId,shape:L,dtype:g.dtype})}var Wu={kernelName:i.Reshape,backendName:"webgl",kernelFunc:Zi};function os(f,p,l){var m=f[0].dtype;if(m==="complex64"){var g=f.map(function(r){return $n({inputs:{input:r},backend:l})}),I=f.map(function(r){return Pc({inputs:{input:r},backend:l})}),R=os(g,p,l),z=os(I,p,l),L=ho({inputs:{real:R,imag:z},backend:l});return g.forEach(function(r){return l.disposeIntermediateTensorInfo(r)}),I.forEach(function(r){return l.disposeIntermediateTensorInfo(r)}),l.disposeIntermediateTensorInfo(R),l.disposeIntermediateTensorInfo(z),L}if(f.length>i.env().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var G=Math.floor(f.length/2),Z=os(f.slice(0,G),p,l),be=os(f.slice(G),p,l),Ce=os([Z,be],p,l);return l.disposeIntermediateTensorInfo(Z),l.disposeIntermediateTensorInfo(be),Ce}if(i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&f[0].shape.length>1){var De=new zc(f.map(function(r){return r.shape}),p);return l.runWebGLProgram(De,f,m)}var Te=i.backend_util.computeOutShape(f.map(function(r){return r.shape}),p),Ge=f.map(function(r){return Zi({inputs:{x:r},attrs:{shape:[-1,i.util.sizeFromShape(r.shape.slice(p))]},backend:l})}),Ze=new Lc(Ge.map(function(r){return r.shape})),s=l.runWebGLProgram(Ze,Ge,m);Ge.forEach(function(r){return l.disposeIntermediateTensorInfo(r)});var u=Zi({inputs:{x:s},attrs:{shape:Te},backend:l});return l.disposeIntermediateTensorInfo(s),u}function kl(f){var p=f.inputs,l=f.backend,m=f.attrs,g=m.axis,I=i.util.parseAxisParam(g,p[0].shape)[0],R=i.backend_util.computeOutShape(p.map(function(G){return G.shape}),I);if(i.util.sizeFromShape(R)===0)return l.makeTensorInfo(R,p[0].dtype,[]);var z=p.filter(function(G){return i.util.sizeFromShape(G.shape)>0});if(z.length===1)return z[0];var L=z.map(function(G){return G.shape});return i.backend_util.assertParamsConsistent(L,I),os(z,I,l)}var Bc={kernelName:i.Concat,backendName:"webgl",kernelFunc:kl},vu=pu+`
return cos(x);
`,Wc=Gs(vu),Uc={kernelName:i.Cos,backendName:"webgl",kernelFunc:Wc},Vc=`
if (a == b) {
return 1.0;
};
return a / b;`,Hc=`
// vec4 one = vec4(equal(a, b));
// return one + (vec4(1.0) - one) * a / b;
vec4 result = a / b;
if(a.x == b.x) {
result.x = 1.;
}
if(a.y == b.y) {
result.y = 1.;
}
if(a.z == b.z) {
result.z = 1.;
}
if(a.w == b.w) {
result.w = 1.;
}
return result;
`,Gc=po({opSnippet:Vc,packedOpSnippet:Hc,checkOutOfBounds:!0}),jc={kernelName:i.Div,backendName:"webgl",kernelFunc:Gc},Uu=function(){function f(p,l,m){this.variableNames=["real","imag"];var g=l[1];this.outputShape=l;var I=m?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,R=m?g+".0":"1.0",z;if(p==="real")z="return real * expR - imag * expI;";else if(p==="imag")z="return real * expI + imag * expR;";else throw new Error('FFT component must be either "real" or "imag", got '+p+".");this.userCode=`
const float exponentMultiplier = `+I+`;
float unaryOpComplex(float real, float expR, float imag, float expI) {
`+z+`
}
float mulMatDFT(int batch, int index) {
float indexRatio = float(index) / float(`+g+`);
float exponentMultiplierTimesIndexRatio =
exponentMultiplier * indexRatio;
float result = 0.0;
for (int i = 0; i < `+g+`; i++) {
// x = (-2|2 * PI / N) * index * i;
float x = exponentMultiplierTimesIndexRatio * float(i);
float expR = cos(x);
float expI = sin(x);
float real = getReal(batch, i);
float imag = getImag(batch, i);
result +=
unaryOpComplex(real, expR, imag, expI) / `+R+`;
}
return result;
}
void main() {
ivec2 coords = getOutputCoords();
setOutput(mulMatDFT(coords[0], coords[1]));
}
`}return f}();function Vu(f,p,l){var m=l.texData.get(f.dataId),g=i.util.sizeFromShape(f.shape),I=f.shape[f.shape.length-1],R=g/I,z=Zi({inputs:{x:f},backend:l,attrs:{shape:[R,I]}}),L=z.shape,G=new Uu("real",L,p),Z=new Uu("imag",L,p),be=[{dataId:m.complexTensorInfos.real.dataId,dtype:m.complexTensorInfos.real.dtype,shape:L},{dataId:m.complexTensorInfos.imag.dataId,dtype:m.complexTensorInfos.imag.dtype,shape:L}],Ce=l.runWebGLProgram(G,be,"float32"),De=l.runWebGLProgram(Z,be,"float32"),Te=ho({inputs:{real:Ce,imag:De},backend:l});l.disposeIntermediateTensorInfo(Ce),l.disposeIntermediateTensorInfo(De);var Ge=Zi({inputs:{x:Te},backend:l,attrs:{shape:f.shape}});return l.disposeIntermediateTensorInfo(Ge),Ge}function qc(f){var p=f.inputs,l=f.backend,m=p.input;return Vu(m,!1,l)}var Kc={kernelName:i.FFT,backendName:"webgl",kernelFunc:qc},Sl=function(){function f(p){this.variableNames=["Image"],this.outputShape=[];var l=p[2];this.outputShape=p,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int x = coords[2];
int coordX = `+l+` - x;
float outputValue;
if(coordX >= 0 && coordX < `+l+`) {
outputValue = getImage(coords[0], coords[1], coordX, coords[3]);
} else {
outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);
}
setOutput(outputValue);
}
`}return f}(),Il={kernelName:i.FlipLeftRight,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.backend,m=p.image,g=l,I=new Sl(m.shape),R=g.runWebGLProgram(I,[m],m.dtype);return R}},Hu=function(){function f(p){this.variableNames=["A"];var l=tn(),m=p[0],g=p[1];this.outputShape=p,this.userCode=`
void main() {
ivec3 coords = getOutputCoords();
int texR = coords[0];
int texC = coords[1];
int depth = coords[2];
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(`+g+".0, "+m+`.0);
vec4 values = `+l.texture2D+`(A, uv);
float value;
if (depth == 0) {
value = values.r;
} else if (depth == 1) {
value = values.g;
} else if (depth == 2) {
value = values.b;
} else if (depth == 3) {
value = values.a;
}
setOutput(floor(value * 255.0 + 0.5));
}
`}return f}(),Xc=function(){function f(p){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var l=tn(),m=p[0],g=p[1];this.outputShape=p,this.userCode=`
void main() {
ivec3 coords = getOutputCoords();
int texR = coords[0];
int texC = coords[1];
int depth = coords[2];
vec4 result = vec4(0.);
for(int row=0; row<=1; row++) {
for(int col=0; col<=1; col++) {
texC = coords[1] + row;
depth = coords[2] + col;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+g+".0, "+m+`.0);
vec4 values = `+l.texture2D+`(A, uv);
float value;
if (depth == 0) {
value = values.r;
} else if (depth == 1) {
value = values.g;
} else if (depth == 2) {
value = values.b;
} else if (depth == 3) {
value = values.a;
}
result[row * 2 + col] = floor(value * 255.0 + 0.5);
}
}
`+l.output+` = result;
}
`}return f}(),Yc={kernelName:i.FromPixels,backendName:"webgl",kernelFunc:jo},ss;function jo(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.pixels,I=m.numChannels,R=typeof HTMLVideoElement!="undefined"&&g instanceof HTMLVideoElement,z=typeof HTMLImageElement!="undefined"&&g instanceof HTMLImageElement,L=R?[g.videoWidth,g.videoHeight]:[g.width,g.height],G=L[0],Z=L[1],be=[Z,G],Ce=[Z,G,I];(z||R)&&(ss==null&&(ss=document.createElement("canvas").getContext("2d")),ss.canvas.width=G,ss.canvas.height=Z,ss.drawImage(g,0,0,G,Z),g=ss.canvas);var De=l.makeTensorInfo(be,"int32");l.texData.get(De.dataId).usage=w.PIXELS,l.gpgpu.uploadPixelDataToTexture(l.getTexture(De.dataId),g);var Te=i.env().getBool("WEBGL_PACK")?new Xc(Ce):new Hu(Ce),Ge=l.runWebGLProgram(Te,[De],"int32");return l.disposeData(De.dataId),Ge}function Nl(f){var p=f.inputs,l=f.backend,m=p.input;return Vu(m,!0,l)}var Cl={kernelName:i.IFFT,backendName:"webgl",kernelFunc:Nl},Gu=function(){function f(p,l){this.variableNames=["x"];var m=p.windowSize,g=p.batchSize,I=p.inSize,R=p.outSize;this.outputShape=[g,R];var z=Math.floor(m/4)*4,L=m%4,G="sumValue += dot(values, ones);";if(l!=null){var Z=1/l;G="sumValue += dot(values * "+(i.util.isInt(Z)?Z.toPrecision(2):Z)+", ones);"}var be="";I%m>0&&(be=`
if (inIdx < 0 || inIdx >= `+I+`) {
return 0.0;
}
`),this.userCode=`
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float getValue(int batch, int inIdx) {
`+be+`
return getX(batch, inIdx);
}
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * `+m+`;
float sumValue = 0.0;
for (int i = 0; i < `+z+`; i += 4) {
int inIdx = inOffset + i;
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
`+G+`
}
int inIdx = inOffset + `+z+`;
if (`+(L===1)+`) {
vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);
`+G+`
} else if (`+(L===2)+`) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1), 0.0, 0.0);
`+G+`
} else if (`+(L===3)+`) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2), 0.0);
`+G+`
}
setOutput(sumValue);
}
`}return f}();function Tl(f){for(var p=[];p.length===0||p[p.length-1].outSize!==1;){var l=p.length?p[p.length-1].outSize:f[1],m=i.backend_util.computeOptimalWindowSize(l);p.push({inSize:l,windowSize:m,outSize:Math.ceil(l/m)})}return p}function gu(f,p,l,m){for(var g=Tl(f.shape),I=f,R=0;R<g.length;R++){var z=g[R],L=z.inSize,G=z.windowSize,Z=z.outSize,be=void 0,Ce=void 0;l==="mean"?be=R===0?new Gu({windowSize:G,inSize:L,batchSize:f.shape[0],outSize:Z},L):new Gu({windowSize:G,inSize:L,batchSize:f.shape[0],outSize:Z}):be=new cr({windowSize:G,inSize:L,batchSize:f.shape[0],outSize:Z},l),Ce=I,I=m.runWebGLProgram(be,[I],p),Ce.dataId!==f.dataId&&m.disposeIntermediateTensorInfo(Ce)}return I}function ju(f,p,l,m){var g=i.util.sizeFromShape(p),I=i.util.sizeFromShape(f.shape),R=I/g,z=Zi({inputs:{x:f},attrs:{shape:[R,g]},backend:m}),L=gu(z,f.dtype,"max",m),G=Zi({inputs:{x:L},attrs:{shape:l},backend:m});return m.disposeIntermediateTensorInfo(z),m.disposeIntermediateTensorInfo(L),G}var El=function(){function f(p,l){this.variableNames=["A"];for(var m=new Array(p.length),g=0;g<m.length;g++)m[g]=p[l[g]];this.outputShape=m,this.rank=m.length;var I=nn(this.rank),R=Rl(l);this.userCode=`
void main() {
`+I+` resRC = getOutputCoords();
setOutput(getA(`+R+`));
}
`}return f}();function Rl(f){var p=f.length;if(p>6)throw Error("Transpose for rank "+p+" is not yet supported");for(var l=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],m=new Array(p),g=0;g<f.length;g++)m[f[g]]=l[g];return m.join()}var Al=function(){function f(p,l){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var m=new Array(p.length),g=0;g<m.length;g++)m[g]=p[l[g]];if(this.outputShape=m,this.rank=m.length,this.rank>6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");for(var I=nn(this.rank),R=Jr("rc",this.rank),z=new Array(this.rank),g=0;g<l.length;g++)z[l[g]]=R[g];var L="vec2("+z.slice(-2).join()+")",G="++"+R[this.rank-1]+" < "+m[this.rank-1],Z="getChannel(getA("+z.join()+"), "+L+")";this.userCode=`
void main() {
`+I+` rc = getOutputCoords();
vec4 result = vec4(0.);
result[0] = `+Z+`;
if(`+G+`) {
result[1] = `+Z+`;
}
--`+R[this.rank-1]+`;
if(++`+R[this.rank-2]+" < "+m[this.rank-2]+`) {
result[2] = `+Z+`;
if(`+G+`) {
result[3] = `+Z+`;
}
}
setOutput(result);
}
`}return f}();function qs(f,p,l){var m=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Al(f.shape,p):new El(f.shape,p);return l.runWebGLProgram(m,[f],f.dtype)}var qu={kernelName:i.Max,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.attrs,m=f.backend,g=p.x,I=l,R=I.reductionIndices,z=I.keepDims,L=m,G=g.shape.length,Z=i.util.parseAxisParam(R,g.shape),be=Z,Ce=i.backend_util.getAxesPermutation(be,G),De=Ce!=null,Te=L.shouldExecuteOnCPU([g]),Ge=g;if(De){if(Te){for(var Ze=L.texData.get(Ge.dataId),s=Ze.values,u=new Array(G),r=0;r<u.length;r++)u[r]=g.shape[Ce[r]];var o=Ha(s,g.shape,g.dtype,Ce,u);Ge=L.makeTensorInfo(u,g.dtype);var h=L.texData.get(Ge.dataId);h.values=o}else Ge=qs(g,Ce,L);be=i.backend_util.getInnerMostAxes(be.length,G)}i.backend_util.assertAxesAreInnerMostDims("max",be,G);var b=i.backend_util.computeOutAndReduceShapes(Ge.shape,be),T=b[0],M=b[1],q=T;z&&(q=i.backend_util.expandShapeToKeepDim(T,Z));var Y;if(Te){var Ze=L.texData.get(Ge.dataId),s=Ze.values,le=dr(s,i.util.sizeFromShape(M),q,g.dtype);Y=L.makeTensorInfo(q,g.dtype);var Ne=L.texData.get(Y.dataId);Ne.values=le}else Y=ju(Ge,M,q,L);return De&&L.disposeIntermediateTensorInfo(Ge),Y}};function Dl(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x;ln(g,"maxPool");var I=m.filterSize,R=m.strides,z=m.pad,L=m.dimRoundingMode,G=1;i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(R,G),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+R+" and dilations '"+G+"'")});var Z=i.backend_util.computePool2DInfo(g.shape,I,R,G,z,L);if(Z.filterWidth===1&&Z.filterHeight===1&&i.util.arraysEqual(Z.inShape,Z.outShape))return lo({inputs:{x:g},backend:l});var be=new Vt(Z,"max",!1);return l.runWebGLProgram(be,[g],g.dtype)}var Fl={kernelName:i.MaxPool,backendName:"webgl",kernelFunc:Dl};function Ku(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.dy,I=p.input,R=p.output,z=I;ln([I,R],"maxPoolBackprop");var L=m.filterSize,G=m.strides,Z=m.pad,be=m.dimRoundingMode,Ce=i.backend_util.computePool2DInfo(z.shape,L,G,1,Z,be),De=!0,Te=new Vt(Ce,"max",De),Ge=l.runWebGLProgram(Te,[z],z.dtype),Ze=new _t(Ce),s=l.runWebGLProgram(Ze,[g,Ge],z.dtype);return l.disposeIntermediateTensorInfo(Ge),s}var Ol={kernelName:i.MaxPoolBackprop,backendName:"webgl",kernelFunc:Ku};function Ml(f,p,l,m){var g=new Vt(l,"max",!1),I=m.runWebGLProgram(g,[f],"float32");g=new Vt(l,"max",!0,!0,p);var R=m.runWebGLProgram(g,[f],"float32");return[I,R]}var Xu={kernelName:i.MaxPoolWithArgmax,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.attrs,m=f.backend,g=p.x,I=l,R=I.filterSize,z=I.strides,L=I.pad,G=I.includeBatchInIndex,Z=m;i.util.assert(g.shape.length===4,function(){return"Error in maxPool: input must be rank 4 but got rank "+g.shape.length+"."});var be=[1,1];i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(z,be),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+z+" and dilations '"+be+"'")});var Ce=i.backend_util.computePool2DInfo(g.shape,R,z,be,L),De=Ml(g,G,Ce,Z),Te=De[0],Ge=De[1];return[Te,Ge]}};function Sa(f,p,l,m){var g=i.util.sizeFromShape(p),I=i.util.sizeFromShape(f.shape),R=I/g,z=Zi({inputs:{x:f},attrs:{shape:[R,g]},backend:m}),L=gu(z,"float32","mean",m),G=Zi({inputs:{x:L},attrs:{shape:l},backend:m});return m.disposeIntermediateTensorInfo(z),m.disposeIntermediateTensorInfo(L),G}var Ll={kernelName:i.Mean,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.attrs,m=f.backend,g=p.x,I=l,R=I.keepDims,z=I.axis,L=m,G=g.shape.length,Z=i.util.parseAxisParam(z,g.shape),be=Z,Ce=i.backend_util.getAxesPermutation(be,G),De=Ce!=null,Te=L.shouldExecuteOnCPU([g]),Ge=[],Ze=g;if(De){if(Te){for(var s=L.texData.get(Ze.dataId),u=s.values,r=new Array(G),o=0;o<r.length;o++)r[o]=g.shape[Ce[o]];var h=Ha(u,g.shape,g.dtype,Ce,r);Ze=L.makeTensorInfo(r,g.dtype);var b=L.texData.get(Ze.dataId);b.values=h}else Ze=qs(g,Ce,L);Ge.push(Ze),be=i.backend_util.getInnerMostAxes(be.length,G)}i.backend_util.assertAxesAreInnerMostDims("sum",be,G);var T=i.backend_util.computeOutAndReduceShapes(Ze.shape,be),M=T[0],q=T[1],Y=M;R&&(Y=i.backend_util.expandShapeToKeepDim(M,Z));for(var le=Sa(Ze,q,Y,L),Ne=0,We=Ge;Ne<We.length;Ne++){var o=We[Ne];L.disposeIntermediateTensorInfo(o)}return le}},zl=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=l.map(function(Z,be){return Z[0]+p[be]+Z[1]});var g=p.length,I=nn(g),R=l.map(function(Z){return Z[0]}).join(","),z=l.map(function(Z,be){return Z[0]+p[be]}).join(","),L=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,g),G=m==="reflect"?0:1;if(g===1){this.userCode=`
int start = `+R+`;
int end = `+z+`;
void main() {
int outC = getOutputCoords();
if (outC < start) {
outC = start * 2 - outC - `+G+`;
} else if(outC >= end) {
outC = (end - 1) * 2 - outC + `+G+`;
}
setOutput(getX(outC - start));
}
`;return}this.userCode=`
`+I+" start = "+I+"("+R+`);
`+I+" end = "+I+"("+z+`);
void main() {
`+I+` outC = getOutputCoords();
for (int i = 0; i < `+g+`; i++) {
if (outC[i] < start[i]) {
outC[i] = start[i] * 2 - outC[i] - `+G+`;
} else if(outC[i] >= end[i]) {
outC[i] = (end[i] - 1) * 2 - outC[i] + `+G+`;
}
}
`+I+` coords = outC - start;
setOutput(getX(`+L+`));
}
`}return f}(),Pl=function(){function f(p,l,m){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=l.map(function(Ge,Ze){return Ge[0]+p[Ze]+Ge[1]});var g=p.length,I=nn(g),R=l.map(function(Ge){return Ge[0]}).join(","),z=l.map(function(Ge,Ze){return Ge[0]+p[Ze]}).join(","),L=Vr("rc",g),G=Vr("source",g),Z=L[g-1]+" < "+this.outputShape[g-1],be=g===1?"source":"vec2("+G.slice(-2).join()+")",Ce=m==="reflect"?0:1,De="";if(g===1){var Te=`
`+I+` source = rc;
if (source < start) {
source = start * 2 - source - `+Ce+`;
} else if (source >= end) {
source = (end - 1) * 2 - source + `+Ce+`;
}
source -= start;
`;De=`
`+I+` rc = outputLoc;
`+Te+`
result[0] = getChannel(getX(`+G.join()+"), "+be+`);
`+L[g-1]+` += 1;
if(`+Z+`) {
`+Te+`
result[1] = getChannel(getX(`+G.join()+"), "+be+`);
}
`}else{var Te=`
`+I+` source = rc;
`+I+" lt = "+I+`(lessThan(source, start));
`+I+" gte = "+I+`(greaterThanEqual(source, end));
`+I+` orig = 1 - (lt + gte);
source = orig * source +
lt * (start * 2 - source - `+Ce+`) +
gte * ((end - 1) * 2 - source + `+Ce+`);
source -= start;
`;De=`
`+I+` rc = outputLoc;
`+Te+`
result[0] = getChannel(getX(`+G.join()+"), "+be+`);
`+L[g-1]+` += 1;
if(`+Z+`) {
`+Te+`
result[1] = getChannel(getX(`+G.join()+"), "+be+`);
}
rc = outputLoc;
`+L[g-2]+` += 1;
if(`+L[g-2]+" < "+this.outputShape[g-2]+`) {
`+Te+`
result[2] = getChannel(getX(`+G.join()+"), "+be+`);
`+L[g-1]+` += 1;
if(`+Z+`) {
`+Te+`
result[3] = getChannel(getX(`+G.join()+"), "+be+`);
}
}
`}this.userCode=`
const `+I+" start = "+I+"("+R+`);
const `+I+" end = "+I+"("+z+`);
void main() {
`+I+` outputLoc = getOutputCoords();
vec4 result = vec4(0.);
`+De+`
setOutput(result);
}
`}return f}(),Qc=function(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=m.paddings,R=m.mode,z=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Pl(g.shape,I,R):new zl(g.shape,I,R),L=l.runWebGLProgram(z,[g],g.dtype);return L},sa={kernelName:i.MirrorPad,backendName:"webgl",kernelFunc:Qc},Pa={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},xu=function(){function f(p,l,m){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=i.backend_util.assertAndGetBroadcastShape(l,m),this.userCode=`
float binaryOpComplex(
float areal, float aimag, float breal, float bimag) {
`+p+`
}
void main() {
float areal = getARealAtOutCoords();
float aimag = getAImagAtOutCoords();
float breal = getBRealAtOutCoords();
float bimag = getBImagAtOutCoords();
setOutput(binaryOpComplex(areal, aimag, breal, bimag));
}
`}return f}(),Zc="return a * b;";function Bl(f){var p=f.inputs,l=f.backend,m=p.a,g=p.b,I=i.backend_util.upcastType(m.dtype,g.dtype);if(m.dtype==="complex64"){var R=l.texData.get(m.dataId),z=l.texData.get(g.dataId),L=new xu(Pa.REAL,m.shape,g.shape),G=new xu(Pa.IMAG,m.shape,g.shape),Z=[{dataId:R.complexTensorInfos.real.dataId,dtype:R.complexTensorInfos.real.dtype,shape:m.shape},{dataId:R.complexTensorInfos.imag.dataId,dtype:R.complexTensorInfos.imag.dtype,shape:m.shape},{dataId:z.complexTensorInfos.real.dataId,dtype:z.complexTensorInfos.real.dtype,shape:g.shape},{dataId:z.complexTensorInfos.imag.dataId,dtype:z.complexTensorInfos.imag.dtype,shape:g.shape}],be=l.runWebGLProgram(L,Z,"float32"),Ce=l.runWebGLProgram(G,Z,"float32"),De=ho({inputs:{real:be,imag:Ce},backend:l});return l.disposeIntermediateTensorInfo(be),l.disposeIntermediateTensorInfo(Ce),De}if(l.shouldExecuteOnCPU([m,g])){var R=l.texData.get(m.dataId),z=l.texData.get(g.dataId),Te=ir(m.shape,g.shape,R.values,z.values,I),Ge=Te[0],Ze=Te[1],s=l.makeTensorInfo(Ze,I),u=l.texData.get(s.dataId);return u.values=Ge,s}var r;return i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?r=new vi(Zc,m.shape,g.shape):r=new vn(Zc,m.shape,g.shape),l.runWebGLProgram(r,[m,g],I)}var Wl={kernelName:i.Multiply,backendName:"webgl",kernelFunc:Bl},Ul={kernelName:i.NonMaxSuppressionV3,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.backend,m=f.attrs;i.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var g=p,I=g.boxes,R=g.scores,z=m,L=z.maxOutputSize,G=z.iouThreshold,Z=z.scoreThreshold,be=l,Ce=be.readSync(I.dataId),De=be.readSync(R.dataId),Te=L,Ge=G,Ze=Z;return i.kernel_impls.nonMaxSuppressionV3Impl(Ce,De,Te,Ge,Ze)}},Vl=i.kernel_impls.nonMaxSuppressionV4Impl,Hl={kernelName:i.NonMaxSuppressionV4,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.backend,m=f.attrs;i.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var g=p,I=g.boxes,R=g.scores,z=m,L=z.maxOutputSize,G=z.iouThreshold,Z=z.scoreThreshold,be=z.padToMaxOutputSize,Ce=l,De=Ce.readSync(I.dataId),Te=Ce.readSync(R.dataId),Ge=Vl(De,Te,L,G,Z,be),Ze=Ge.selectedIndices,s=Ge.validOutputs;return[Ze,s]}},Gl=i.kernel_impls.nonMaxSuppressionV5Impl,jl={kernelName:i.NonMaxSuppressionV5,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.backend,m=f.attrs;i.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var g=p,I=g.boxes,R=g.scores,z=m,L=z.maxOutputSize,G=z.iouThreshold,Z=z.scoreThreshold,be=z.softNmsSigma,Ce=l,De=Ce.readSync(I.dataId),Te=Ce.readSync(R.dataId),Ge=L,Ze=G,s=Z,u=be,r=Gl(De,Te,Ge,Ze,s,u),o=r.selectedIndices,h=r.selectedScores;return[o,h]}},ql=function(){function f(p,l,m,g){this.variableNames=["Image"],this.outputShape=[];var I=p[1],R=p[2],z=Math.sin(l).toFixed(3),L=Math.cos(l).toFixed(3);this.outputShape=p;var G=i.backend_util.getImageCenter(g,I,R),Z=G[0],be=G[1],Ce=Z.toFixed(3),De=be.toFixed(3),Te="";typeof m=="number"?Te="float outputValue = "+m.toFixed(2)+";":Te=`
vec3 fill = vec3(`+m.join(",")+`);
float outputValue = fill[coords[3]];`,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int x = coords[2];
int y = coords[1];
float coordXFloat = (float(x) - `+Ce+") * "+L+" - (float(y) - "+De+") * "+z+`;
float coordYFloat = (float(x) - `+Ce+") * "+z+" + (float(y) - "+De+") * "+L+`;
int coordX = int(round(coordXFloat + `+Ce+`));
int coordY = int(round(coordYFloat + `+De+`));
`+Te+`
if(coordX >= 0 && coordX < `+R+" && coordY >= 0 && coordY < "+I+`) {
outputValue = getImage(coords[0], coordY, coordX, coords[3]);
}
setOutput(outputValue);
}
`}return f}(),Kl={kernelName:i.RotateWithOffset,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.attrs,m=f.backend,g=p.image,I=l,R=I.radians,z=I.fillValue,L=I.center,G=m,Z=new ql(g.shape,R,z,L),be=G.runWebGLProgram(Z,[g],g.dtype);return be}},Xl=pu+`
return sin(x);
`,Cr=Gs(Xl),Yl={kernelName:i.Sin,backendName:"webgl",kernelFunc:Cr},Yu="return x * x;",Ql=Gs(Yu),Br={kernelName:i.Square,backendName:"webgl",kernelFunc:Ql},Jc="return (a - b) * (a - b);",bt=po({opSnippet:Jc,packedOpSnippet:Jc}),Zl={kernelName:i.SquaredDifference,backendName:"webgl",kernelFunc:bt},ui="return a - b;",Jl=po({opSnippet:ui,packedOpSnippet:ui,supportsComplex:!0,cpuKernelImpl:ra}),$c={kernelName:i.Sub,backendName:"webgl",kernelFunc:Jl},$l="return tan(x);",el=Gs($l),eh={kernelName:i.Tan,backendName:"webgl",kernelFunc:el},th={kernelName:i.Transpose,backendName:"webgl",kernelFunc:function(f){for(var p=f.inputs,l=f.attrs,m=f.backend,g=p.x,I=l.perm,R=m,z=g.shape.length,L=new Array(z),G=0;G<L.length;G++)L[G]=g.shape[I[G]];var Z;if(R.shouldExecuteOnCPU([g])){var be=R.texData.get(g.dataId),Ce=be.values,De=Ha(Ce,g.shape,g.dtype,I,L);Z=R.makeTensorInfo(L,g.dtype);var Te=R.texData.get(Z.dataId);Te.values=De}else Z=qs(g,I,R);return Z}};function Qu(f){var p=f.inputs,l=f.attrs,m=f.backend,g=l.axis,I=p.x;ln(I,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");var R=m.readSync(I.dataId),z=ki(R,g,I.shape,I.dtype),L=z.outputValues,G=z.outputShape,Z=z.indices;return[m.makeTensorInfo(G,I.dtype,L),m.makeTensorInfo([Z.length],"int32",Z)]}for(var tl={kernelName:i.Unique,backendName:"webgl",kernelFunc:Qu},rl=[zu,fu,Nc,Tc,un,is,Sc,Bc,Uc,jc,Kc,Il,Yc,kc,Cl,Bu,qu,Fl,Ol,Xu,Ll,sa,Wl,Ul,Hl,jl,Dc,Fc,Wu,Kl,Yl,Br,$c,Zl,eh,th,tl],ci=0,nl=rl;ci<nl.length;ci++){var Ji=nl[ci];i.registerKernel(Ji)}N.GPGPUContext=Oe,N.MathBackendWebGL=Go,N.forceHalfFloat=Hs,N.gpgpu_util=Re,N.setWebGLContext=Ae,N.version_webgl=Ou,N.webgl=bc,N.webgl_util=ni}),to=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=og(),O=sg(),H=cg(),se=gg(),xe=xg(),Q="2.7.0",Ae={"tfjs-core":i.version_core,"tfjs-backend-cpu":se.version_cpu,"tfjs-backend-webgl":xe.version_webgl,"tfjs-data":H.version_data,"tfjs-layers":ke.version_layers,"tfjs-converter":O.version_converter,tfjs:Q};Object.keys(i).forEach(function(P){P!=="default"&&Object.defineProperty(N,P,{enumerable:!0,get:function(){return i[P]}})}),Object.keys(ke).forEach(function(P){P!=="default"&&Object.defineProperty(N,P,{enumerable:!0,get:function(){return ke[P]}})}),Object.keys(O).forEach(function(P){P!=="default"&&Object.defineProperty(N,P,{enumerable:!0,get:function(){return O[P]}})}),N.data=H,N.version=Ae}),_g=Mr(N=>{const i=to(),ke=6;function O(me){const ae={strides:[me/16,me/8],anchors:[2,6]},w=[];for(let ge=0;ge<ae.strides.length;ge++){const ze=ae.strides[ge],W=Math.floor((me+ze-1)/ze),nt=Math.floor((me+ze-1)/ze),tt=ae.anchors[ge];for(let nr=0;nr<W;nr++){const Tt=ze*(nr+.5);for(let Qe=0;Qe<nt;Qe++){const it=ze*(Qe+.5);for(let xt=0;xt<tt;xt++)w.push([it,Tt])}}}return w}const H=me=>{me.startEndTensor.dispose(),me.startPoint.dispose(),me.endPoint.dispose()},se=me=>({startEndTensor:me,startPoint:i.slice(me,[0,0],[-1,2]),endPoint:i.slice(me,[0,2],[-1,2])}),xe=(me,ae)=>{const w=i.mul(me.startPoint,ae),ge=i.mul(me.endPoint,ae),ze=i.concat2d([w,ge],1);return se(ze)};function Q(me,ae,w){const ge=i.slice(me,[0,1],[-1,2]),ze=i.add(ge,ae),W=i.slice(me,[0,3],[-1,2]),nt=i.div(W,w),tt=i.div(ze,w),nr=i.div(nt,2),Tt=i.sub(tt,nr),Qe=i.add(tt,nr),it=i.mul(Tt,w),xt=i.mul(Qe,w),ot=1;return i.concat2d([it,xt],ot)}function Ae(me,ae){return i.tidy(()=>{const w=me.box?me.box:me;return xe(w,ae).startEndTensor.squeeze()})}class P{constructor(me,ae){this.blazeFaceModel=me,this.width=ae.detector.inputSize,this.height=ae.detector.inputSize,this.maxFaces=ae.detector.maxFaces,this.anchorsData=O(ae.detector.inputSize),this.anchors=i.tensor2d(this.anchorsData),this.inputSize=i.tensor1d([this.width,this.height]),this.iouThreshold=ae.detector.iouThreshold,this.scaleFaces=.8,this.scoreThreshold=ae.detector.scoreThreshold}async getBoundingBoxes(me){if(!me||me.isDisposedInternal||me.shape.length!==4||me.shape[1]<1||me.shape[2]<1)return null;const[ae,w,ge]=i.tidy(()=>{const Tt=me.resizeBilinear([this.width,this.height]),Qe=i.mul(i.sub(Tt.div(255),.5),2),it=this.blazeFaceModel.predict(Qe);let xt;if(Array.isArray(it)){const yt=it.sort((Ur,jr)=>Ur.size-jr.size),Zt=i.concat([yt[0],yt[2]],2),ar=i.concat([yt[1],yt[3]],2),qt=i.concat([ar,Zt],1);xt=qt.squeeze(0)}else xt=it.squeeze();const ot=Q(xt,this.anchors,this.inputSize),ht=i.slice(xt,[0,0],[-1,1]),ut=i.sigmoid(ht).squeeze();return[xt,ot,ut]}),ze=await i.image.nonMaxSuppressionAsync(w,ge,this.maxFaces,this.iouThreshold,this.scoreThreshold),W=ze.arraySync();ze.dispose();const nt=W.map(Tt=>i.slice(w,[Tt,0],[1,-1])),tt=nt.map(Tt=>{const Qe=Tt.arraySync();return Tt.dispose(),Qe}),nr=[];for(let Tt=0;Tt<tt.length;Tt++){const Qe=tt[Tt],it=se(Qe),xt=W[Tt],ot=this.anchorsData[xt],ht=i.slice(ae,[xt,ke-1],[1,-1]),ut=ht.squeeze(),yt=ut.reshape([ke,-1]),Zt=i.slice(ge,[xt],[1]),ar={box:it,landmarks:yt,probability:Zt,anchor:ot};nr.push(ar),ht.dispose(),ut.dispose()}return ae.dispose(),w.dispose(),ge.dispose(),ae.dispose(),{boxes:nr,scaleFactor:[me.shape[2]/this.width,me.shape[1]/this.height]}}async estimateFaces(me){const{boxes:ae,scaleFactor:w}=await this.getBoundingBoxes(me),ge=[];for(const ze of ae){const W=ze.landmarks.arraySync(),nt=Ae(ze,w),tt=xe.arraySync(),nr=ze.probability.arraySync(),Tt=ze.anchor,[Qe,it]=w,xt=W.map(ht=>[(ht[0]+Tt[0])*Qe,(ht[1]+Tt[1])*it]),ot={topLeft:tt.slice(0,2),bottomRight:tt.slice(2),landmarks:xt,probability:nr};H(ze.box),ze.landmarks.dispose(),ze.probability.dispose(),nt.dispose(),ge.push(ot)}return ge}}async function he(me){const ae=await i.loadGraphModel(me.detector.modelPath,{fromTFHub:me.detector.modelPath.includes("tfhub.dev")}),w=new P(ae,me);return w}N.load=he,N.BlazeFaceModel=P,N.disposeBox=H}),df=Mr(N=>{N.MESH_ANNOTATIONS={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[61,185,40,39,37,0,267,269,270,409,291],lipsLowerOuter:[146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[78,191,80,81,82,13,312,311,310,415,308],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},N.MESH_TO_IRIS_INDICES_MAP=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}]}),wg=Mr(N=>{const i=to();function ke(Ae,P){const he=[Ae.startPoint[0]*P[0],Ae.startPoint[1]*P[1]],me=[Ae.endPoint[0]*P[0],Ae.endPoint[1]*P[1]];return{startPoint:he,endPoint:me}}N.scaleBoxCoordinates=ke;function O(Ae){return[Math.abs(Ae.endPoint[0]-Ae.startPoint[0]),Math.abs(Ae.endPoint[1]-Ae.startPoint[1])]}N.getBoxSize=O;function H(Ae){return[Ae.startPoint[0]+(Ae.endPoint[0]-Ae.startPoint[0])/2,Ae.startPoint[1]+(Ae.endPoint[1]-Ae.startPoint[1])/2]}N.getBoxCenter=H;function se(Ae,P,he){const me=P.shape[1],ae=P.shape[2],w=[[Ae.startPoint[1]/me,Ae.startPoint[0]/ae,Ae.endPoint[1]/me,Ae.endPoint[0]/ae]];return i.image.cropAndResize(P,w,[0],he)}N.cutBoxFromImageAndResize=se;function xe(Ae,P=1.5){const he=H(Ae),me=O(Ae),ae=[P*me[0]/2,P*me[1]/2],w=[he[0]-ae[0],he[1]-ae[1]],ge=[he[0]+ae[0],he[1]+ae[1]];return{startPoint:w,endPoint:ge,landmarks:Ae.landmarks}}N.enlargeBox=xe;function Q(Ae){const P=H(Ae),he=O(Ae),me=Math.max(...he),ae=me/2,w=[P[0]-ae,P[1]-ae],ge=[P[0]+ae,P[1]+ae];return{startPoint:w,endPoint:ge,landmarks:Ae.landmarks}}N.squarifyBox=Q}),bg=Mr(N=>{N.IDENTITY_MATRIX=[[1,0,0],[0,1,0],[0,0,1]];function i(ae){return ae-2*Math.PI*Math.floor((ae+Math.PI)/(2*Math.PI))}N.normalizeRadians=i;function ke(ae,w){const ge=Math.PI/2-Math.atan2(-(w[1]-ae[1]),w[0]-ae[0]);return i(ge)}N.computeRotation=ke;function O(ae){return ae*180/Math.PI}N.radToDegrees=O;function H(ae,w){return[[1,0,ae],[0,1,w],[0,0,1]]}function se(ae,w){let ge=0;for(let ze=0;ze<ae.length;ze++)ge+=ae[ze]*w[ze];return ge}N.dot=se;function xe(ae,w){const ge=[];for(let ze=0;ze<ae.length;ze++)ge.push(ae[ze][w]);return ge}N.getColumnFrom2DArr=xe;function Q(ae,w){const ge=[],ze=ae.length;for(let W=0;W<ze;W++){ge.push([]);for(let nt=0;nt<ze;nt++)ge[W].push(se(ae[W],xe(w,nt)))}return ge}function Ae(ae,w){const ge=Math.cos(ae),ze=Math.sin(ae),W=[[ge,-ze,0],[ze,ge,0],[0,0,1]],nt=H(w[0],w[1]),tt=Q(nt,W),nr=H(-w[0],-w[1]);return Q(tt,nr)}N.buildRotationMatrix=Ae;function P(ae){const w=[[ae[0][0],ae[1][0]],[ae[0][1],ae[1][1]]],ge=[ae[0][2],ae[1][2]],ze=[-se(w[0],ge),-se(w[1],ge)];return[w[0].concat(ze[0]),w[1].concat(ze[1]),[0,0,1]]}N.invertTransformMatrix=P;function he(ae,w){return[se(ae,w[0]),se(ae,w[1])]}N.rotatePoint=he;function me(ae,w){return Math.sqrt((ae[0]-w[0])**2+(ae[1]-w[1])**2)}N.xyDistanceBetweenPoints=me}),kg=Mr(N=>{const i=to(),ke=wg(),O=df(),H=bg(),se=468,xe=.25,Q=13,Ae=[Q,O.MESH_ANNOTATIONS.midwayBetweenEyes[0]],P=3,he=2,me=[P,he],ae=O.MESH_ANNOTATIONS.leftEyeLower0,w=[ae[0],ae[ae.length-1]],ge=O.MESH_ANNOTATIONS.rightEyeLower0,ze=[ge[0],ge[ge.length-1]],W=3,nt=4,tt=71,nr=76;function Tt(it,xt,ot,ht){for(let ut=0;ut<O.MESH_TO_IRIS_INDICES_MAP.length;ut++){const{key:yt,indices:Zt}=O.MESH_TO_IRIS_INDICES_MAP[ut],ar=O.MESH_ANNOTATIONS[`${ot}${yt}`],qt=ht==null;if(qt||ht.includes(yt))for(let Ur=0;Ur<Zt.length;Ur++){const jr=Zt[Ur];it[ar[Ur]]=[xt[jr][0],xt[jr][1],(xt[jr][2]+it[ar[Ur]][2])/2]}}}class Qe{constructor(it,xt,ot,ht){this.regionsOfInterest=[],this.runsWithoutFaceDetector=0,this.boundingBoxDetector=it,this.meshDetector=xt,this.irisModel=ot,this.meshWidth=ht.mesh.inputSize,this.meshHeight=ht.mesh.inputSize,this.irisSize=ht.iris.inputSize,this.irisEnlarge=ht.iris.enlargeFactor}transformRawCoords(it,xt,ot,ht){const ut=ke.getBoxSize({startPoint:xt.startPoint,endPoint:xt.endPoint}),yt=[ut[0]/this.meshWidth,ut[1]/this.meshHeight],Zt=it.map(tr=>[yt[0]*(tr[0]-this.meshWidth/2),yt[1]*(tr[1]-this.meshHeight/2),tr[2]]),ar=H.buildRotationMatrix(ot,[0,0]),qt=Zt.map(tr=>[...H.rotatePoint(tr,ar),tr[2]]),Ur=H.invertTransformMatrix(ht),jr=[...ke.getBoxCenter({startPoint:xt.startPoint,endPoint:xt.endPoint}),1],_r=[H.dot(jr,Ur[0]),H.dot(jr,Ur[1])];return qt.map(tr=>[tr[0]+_r[0],tr[1]+_r[1],tr[2]])}getLeftToRightEyeDepthDifference(it){const xt=it[w[0]][2],ot=it[ze[0]][2];return xt-ot}getEyeBox(it,xt,ot,ht,ut=!1){const yt=ke.squarifyBox(ke.enlargeBox(this.calculateLandmarksBoundingBox([it[ot],it[ht]]),this.irisEnlarge)),Zt=ke.getBoxSize(yt);let ar=i.image.cropAndResize(xt,[[yt.startPoint[1]/this.meshHeight,yt.startPoint[0]/this.meshWidth,yt.endPoint[1]/this.meshHeight,yt.endPoint[0]/this.meshWidth]],[0],[this.irisSize,this.irisSize]);return ut&&(ar=i.image.flipLeftRight(ar)),{box:yt,boxSize:Zt,crop:ar}}getEyeCoords(it,xt,ot,ht=!1){const ut=[];for(let yt=0;yt<nr;yt++){const Zt=it[yt*3],ar=it[yt*3+1],qt=it[yt*3+2];ut.push([(ht?1-Zt/this.irisSize:Zt/this.irisSize)*ot[0]+xt.startPoint[0],ar/this.irisSize*ot[1]+xt.startPoint[1],qt])}return{rawCoords:ut,iris:ut.slice(tt)}}getAdjustedIrisCoords(it,xt,ot){const ht=it[O.MESH_ANNOTATIONS[`${ot}EyeUpper0`][W]][2],ut=it[O.MESH_ANNOTATIONS[`${ot}EyeLower0`][nt]][2],yt=(ht+ut)/2;return xt.map((Zt,ar)=>{let qt=yt;return ar===2?qt=ht:ar===4&&(qt=ut),[Zt[0],Zt[1],qt]})}async predict(it,xt){if(this.skipFrames=xt.detector.skipFrames,this.maxFaces=xt.detector.maxFaces,this.runsWithoutFaceDetector++,this.shouldUpdateRegionsOfInterest()){const ht=await this.boundingBoxDetector.getBoundingBoxes(it);if(!ht||!ht.boxes||ht.boxes.length===0)return this.regionsOfInterest=[],null;const ut=ht.boxes.map(yt=>{const Zt=yt.box.startPoint.squeeze(),ar=yt.box.endPoint.squeeze(),qt={startPoint:Zt.arraySync(),endPoint:ar.arraySync()};Zt.dispose(),ar.dispose();const Ur=ke.scaleBoxCoordinates(qt,ht.scaleFactor),jr=ke.enlargeBox(Ur),_r=yt.landmarks.arraySync();return yt.box.startPoint.dispose(),yt.box.endPoint.dispose(),yt.landmarks.dispose(),yt.probability.dispose(),{...jr,landmarks:_r}});this.updateRegionsOfInterest(ut),this.runsWithoutFaceDetector=0}const ot=i.tidy(()=>this.regionsOfInterest.map((ht,ut)=>{let yt=0;const Zt=ht.landmarks.length>=se;let[ar,qt]=Ae;Zt===!1&&([ar,qt]=me),yt=H.computeRotation(ht.landmarks[ar],ht.landmarks[qt]);const Ur=ke.getBoxCenter({startPoint:ht.startPoint,endPoint:ht.endPoint}),jr=[Ur[0]/it.shape[2],Ur[1]/it.shape[1]];let _r=it,tr=H.IDENTITY_MATRIX;yt!==0&&(_r=i.image.rotateWithOffset(it,yt,0,jr),tr=H.buildRotationMatrix(-yt,Ur));const Fa={startPoint:ht.startPoint,endPoint:ht.endPoint},Oa=ke.cutBoxFromImageAndResize(Fa,_r,[this.meshHeight,this.meshWidth]).div(255),[,Tn,Wa]=this.meshDetector.predict(Oa),Na=i.reshape(Wa,[-1,3]);let yn=Na.arraySync();if(xt.iris.enabled){const{box:rn,boxSize:Ca,crop:xn}=this.getEyeBox(yn,Oa,w[0],w[1],!0),{box:Hn,boxSize:_i,crop:ha}=this.getEyeBox(yn,Oa,ze[0],ze[1]),Ei=this.irisModel.predict(i.concat([xn,ha])),Gn=Ei.dataSync();Ei.dispose();const jn=Gn.slice(0,nr*3),{rawCoords:Ua,iris:ga}=this.getEyeCoords(jn,rn,Ca,!0),wi=Gn.slice(nr*3),{rawCoords:Ta,iris:on}=this.getEyeCoords(wi,Hn,_i),_n=this.getLeftToRightEyeDepthDifference(yn);Math.abs(_n)<30?(Tt(yn,Ua,"left"),Tt(yn,Ta,"right")):_n<1?Tt(yn,Ua,"left",["EyeUpper0","EyeLower0"]):Tt(yn,Ta,"right",["EyeUpper0","EyeLower0"]);const xa=this.getAdjustedIrisCoords(yn,ga,"left"),Rr=this.getAdjustedIrisCoords(yn,on,"right");yn=yn.concat(xa).concat(Rr)}const Ma=this.transformRawCoords(yn,ht,yt,tr);i.dispose(yn);const li=ke.enlargeBox(this.calculateLandmarksBoundingBox(Ma)),hi=Tn.squeeze();if(i.dispose(Tn),xt.mesh.enabled){const rn=i.tensor2d(Ma);this.regionsOfInterest[ut]={...li,landmarks:rn.arraySync()};const Ca={coords:rn,box:li,confidence:hi,image:Oa};return Ca}const la={coords:null,box:li,confidence:hi,image:Oa};return la}));return ot}updateRegionsOfInterest(it){for(let xt=0;xt<it.length;xt++){const ot=it[xt],ht=this.regionsOfInterest[xt];let ut=0;if(ht&&ht.startPoint){const[yt,Zt]=ot.startPoint,[ar,qt]=ot.endPoint,[Ur,jr]=ht.startPoint,[_r,tr]=ht.endPoint,Fa=Math.max(yt,Ur),Oa=Math.max(Zt,jr),Tn=Math.min(ar,_r),Wa=Math.min(qt,tr),Na=(Tn-Fa)*(Wa-Oa),yn=(ar-yt)*(qt-Zt),Ma=(_r-Ur)*(tr-Zt);ut=Na/(yn+Ma-Na)}ut<xe&&(this.regionsOfInterest[xt]=ot)}this.regionsOfInterest=this.regionsOfInterest.slice(0,it.length)}clearRegionOfInterest(it){this.regionsOfInterest[it]!=null&&(this.regionsOfInterest=[...this.regionsOfInterest.slice(0,it),...this.regionsOfInterest.slice(it+1)])}shouldUpdateRegionsOfInterest(){return this.regionsOfInterest.length===0?!0:this.regionsOfInterest.length!==this.maxFaces&&this.runsWithoutFaceDetector>=this.skipFrames}calculateLandmarksBoundingBox(it){const xt=it.map(yt=>yt[0]),ot=it.map(yt=>yt[1]),ht=[Math.min(...xt),Math.min(...ot)],ut=[Math.max(...xt),Math.max(...ot)];return{startPoint:ht,endPoint:ut,landmarks:it}}}N.Pipeline=Qe}),Sg=Mr(N=>{N.UV_COORDS=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]]}),Ig=Mr(N=>{Kh(N,{default:()=>i});var i=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255]}),Ng=Mr(N=>{const i=to(),ke=_g(),O=df(),H=kg(),se=Sg(),xe=Ig().default;class Q{constructor(P,he,me,ae){this.pipeline=new H.Pipeline(P,he,me,ae),ae&&(this.config=ae)}async estimateFaces(P,he){he&&(this.config=he);const me=await this.pipeline.predict(P,he),ae=[];for(const w of me||[]){if(w.isDisposedInternal)continue;const ge=w.confidence.arraySync();if(ge>=this.config.detector.minConfidence){const ze=w.coords?w.coords.arraySync():null,W={};if(ze&&ze.length>0)for(const nt in O.MESH_ANNOTATIONS)(this.config.iris.enabled||nt.includes("Iris")===!1)&&(W[nt]=O.MESH_ANNOTATIONS[nt].map(tt=>ze[tt]));ae.push({confidence:ge||0,box:w.box?[w.box.startPoint[0],w.box.startPoint[1],w.box.endPoint[0]-w.box.startPoint[0],w.box.endPoint[1]-w.box.startPoint[1]]:0,mesh:ze,annotations:W,image:w.image?i.clone(w.image):null})}w.confidence&&w.confidence.dispose(),w.coords&&w.coords.dispose(),w.image&&w.image.dispose()}return ae}}async function Ae(P){const he=await Promise.all([ke.load(P),i.loadGraphModel(P.mesh.modelPath,{fromTFHub:P.mesh.modelPath.includes("tfhub.dev")}),i.loadGraphModel(P.iris.modelPath,{fromTFHub:P.iris.modelPath.includes("tfhub.dev")})]),me=new Q(he[0],he[1],he[2],P);return me}N.load=Ae,N.MediaPipeFaceMesh=Q,N.uv_coords=se,N.triangulation=xe}),Bp=Mr(N=>{const i={};function ke(O,H){if(!H||!H.kernels)return;const se=5,xe=H.kernels.filter(he=>he.kernelTimeMs>0).reduce((he,me)=>he+=me.kernelTimeMs,0),Q=H.kernels.map((he,me)=>(he.id=me,he)).filter(he=>he.kernelTimeMs>0).sort((he,me)=>me.kernelTimeMs-he.kernelTimeMs),Ae=H.kernels.map((he,me)=>(he.id=me,he)).filter(he=>he.totalBytesSnapshot>0).sort((he,me)=>me.totalBytesSnapshot-he.totalBytesSnapshot);Q.length>se&&(Q.length=se),Ae.length>se&&(Ae.length=se);const P={newBytes:H.newBytes,newTensors:H.newTensors,peakBytes:H.peakBytes,numKernelOps:H.kernels.length,timeKernelOps:xe,slowestKernelOps:Q,largestKernelOps:Ae};i[O]=P}N.run=ke,N.data=i}),Cg=Mr(N=>{const i=to(),ke=Bp(),O={};let H={age:0,gender:""},se=Number.MAX_SAFE_INTEGER;async function xe(P){return O.age||(O.age=await i.loadGraphModel(P.face.age.modelPath)),O.age}async function Q(P){return O.gender||(O.gender=await i.loadGraphModel(P.face.gender.modelPath)),O.gender}async function Ae(P,he){if(se<he.face.age.skipFrames)return se+=1,H;se=0;const me=i.image.resizeBilinear(P,[he.face.age.inputSize,he.face.age.inputSize],!1),ae=i.mul(me,[255]);i.dispose(me);const w=[];let ge,ze;const W={};if(!he.profile||he.async)he.face.age.enabled&&w.push(ge=O.age.predict(ae)),he.face.gender.enabled&&w.push(ze=O.gender.predict(ae)),await Promise.all(w);else{const nt=he.face.age.enabled?await i.profile(()=>O.age.predict(ae)):{};ge=nt.result.clone(),nt.result.dispose(),ke.run("age",nt);const tt=he.face.gender.enabled?await i.profile(()=>O.gender.predict(ae)):{};ze=tt.result.clone(),tt.result.dispose(),ke.run("gender",tt)}if(ge){const nt=ge.dataSync();W.age=Math.trunc(10*nt[0])/10,i.dispose(ge)}if(ze){const nt=ze.dataSync(),tt=Math.trunc(Math.abs(1.9*100*(nt[0]-.5)))/100;tt>he.face.gender.minConfidence&&(W.gender=nt[0]<=.5?"female":"male",W.confidence=tt),i.dispose(ze)}return i.dispose(ae),H=W,W}N.predict=Ae,N.loadAge=xe,N.loadGender=Q}),Tg=Mr(N=>{const i=to(),ke=Bp(),O=["angry","discust","fear","happy","sad","surpise","neutral"],H={};let se=[],xe=Number.MAX_SAFE_INTEGER;const Q=1.5;async function Ae(he){return H.emotion||(H.emotion=await i.loadGraphModel(he.face.emotion.modelPath)),H.emotion}async function P(he,me){if(xe<me.face.emotion.skipFrames)return xe+=1,se;xe=0;const ae=i.image.resizeBilinear(he,[me.face.emotion.inputSize,me.face.emotion.inputSize],!1),[w,ge,ze]=i.split(ae,3,3);ae.dispose();const W=i.mul(w,[.2989]),nt=i.mul(ge,[.587]),tt=i.mul(ze,[.114]);w.dispose(),ge.dispose(),ze.dispose();const nr=i.addN([W,nt,tt]);W.dispose(),nt.dispose(),tt.dispose();const Tt=[];if(me.face.emotion.enabled){let Qe;if(me.profile){const it=await i.profile(()=>H.emotion.predict(nr));Qe=it.result.dataSync(),it.result.dispose(),ke.run("emotion",it)}else{const it=await H.emotion.predict(nr);Qe=it.dataSync(),i.dispose(it)}for(let it=0;it<Qe.length;it++)Q*Qe[it]>me.face.emotion.minConfidence&&Tt.push({score:Math.min(.99,Math.trunc(100*Q*Qe[it])/100),emotion:O[it]});Tt.sort((it,xt)=>xt.score-it.score)}return i.dispose(nr),se=Tt,Tt}N.predict=P,N.load=Ae}),Eg=Mr(N=>{const i=to();class ke{constructor(O,H){this.model=O,this.outputStride=H}predict(O){return i.tidy(()=>{const H=this.preprocessInput(O.toFloat()),se=H.expandDims(0),xe=this.model.predict(se),Q=xe.map(P=>P.squeeze([0])),Ae=this.nameOutputResults(Q);return{heatmapScores:Ae.heatmap.sigmoid(),offsets:Ae.offsets,displacementFwd:Ae.displacementFwd,displacementBwd:Ae.displacementBwd}})}dispose(){this.model.dispose()}}N.BaseModel=ke}),ff=Mr(N=>{const i=to(),ke=Eg();class O extends ke.BaseModel{preprocessInput(H){return i.tidy(()=>i.div(H,127.5).sub(1))}nameOutputResults(H){const[se,xe,Q,Ae]=H;return{offsets:se,heatmap:xe,displacementFwd:Q,displacementBwd:Ae}}}N.MobileNet=O}),Rg=Mr(N=>{function i(O){return Math.floor(O/2)}class ke{constructor(O,H){this.priorityQueue=new Array(O),this.numberOfElements=-1,this.getElementValue=H}enqueue(O){this.priorityQueue[++this.numberOfElements]=O,this.swim(this.numberOfElements)}dequeue(){const O=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,O}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(O){for(;O>0&&this.less(i(O),O);)this.exchange(O,i(O)),O=i(O)}sink(O){for(;2*O<=this.numberOfElements;){let H=2*O;if(H<this.numberOfElements&&this.less(H,H+1)&&H++,!this.less(O,H))break;this.exchange(O,H),O=H}}getValueAt(O){return this.getElementValue(this.priorityQueue[O])}less(O,H){return this.getValueAt(O)<this.getValueAt(H)}exchange(O,H){const se=this.priorityQueue[O];this.priorityQueue[O]=this.priorityQueue[H],this.priorityQueue[H]=se}}N.MaxHeap=ke}),Ag=Mr(N=>{const i=Rg();function ke(H,se,xe,Q,Ae,P){const[he,me]=P.shape;let ae=!0;const w=Math.max(xe-Ae,0),ge=Math.min(xe+Ae+1,he);for(let ze=w;ze<ge;++ze){const W=Math.max(Q-Ae,0),nt=Math.min(Q+Ae+1,me);for(let tt=W;tt<nt;++tt)if(P.get(ze,tt,H)>se){ae=!1;break}if(!ae)break}return ae}function O(H,se,xe){const[Q,Ae,P]=xe.shape,he=new i.MaxHeap(Q*Ae*P,({score:me})=>me);for(let me=0;me<Q;++me)for(let ae=0;ae<Ae;++ae)for(let w=0;w<P;++w){const ge=xe.get(me,ae,w);if(ge<H)continue;ke(w,ge,me,ae,se,xe)&&he.enqueue({score:ge,part:{heatmapY:me,heatmapX:ae,id:w}})}return he}N.buildPartWithScoreQueue=O}),Xh=Mr(N=>{N.partNames=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],N.NUM_KEYPOINTS=N.partNames.length,N.partIds=N.partNames.reduce((ke,O,H)=>(ke[O]=H,ke),{});const i=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]];N.poseChain=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]],N.connectedPartIndices=i.map(([ke,O])=>[N.partIds[ke],N.partIds[O]]),N.partChannels=["left_face","right_face","right_upper_leg_front","right_lower_leg_back","right_upper_leg_back","left_lower_leg_front","left_upper_leg_front","left_upper_leg_back","left_lower_leg_back","right_feet","right_lower_leg_front","left_feet","torso_front","torso_back","right_upper_arm_front","right_upper_arm_back","right_lower_arm_back","left_lower_arm_front","left_upper_arm_front","left_upper_arm_back","left_lower_arm_back","right_hand","right_lower_arm_front","left_hand"]}),mf=Mr(N=>{const i=Xh();function ke(P,he,me,ae){return{y:ae.get(P,he,me),x:ae.get(P,he,me+i.NUM_KEYPOINTS)}}N.getOffsetPoint=ke;function O(P,he,me){const{heatmapY:ae,heatmapX:w,id:ge}=P,{y:ze,x:W}=ke(ae,w,ge,me);return{x:P.heatmapX*he+W,y:P.heatmapY*he+ze}}N.getImageCoords=O;function H(P,he){const me=new Array(he);for(let ae=0;ae<he;ae++)me[ae]=P;return me}N.fillArray=H;function se(P,he,me){return P<he?he:P>me?me:P}N.clamp=se;function xe(P,he,me,ae){const w=me-P,ge=ae-he;return w*w+ge*ge}N.squaredDistance=xe;function Q(P,he){return{x:P.x+he.x,y:P.y+he.y}}N.addVectors=Q;function Ae(P,he,me){return{y:se(P.y,he,me),x:se(P.x,he,me)}}N.clampVector=Ae}),Dg=Mr(N=>{const i=Xh(),ke=mf(),O=i.poseChain.map(([he,me])=>[i.partIds[he],i.partIds[me]]),H=O.map(([,he])=>he),se=O.map(([he])=>he);function xe(he,me,ae){const w=ae.shape[2]/2;return{y:ae.get(me.y,me.x,he),x:ae.get(me.y,me.x,w+he)}}function Q(he,me,ae,w){return{y:ke.clamp(Math.round(he.y/me),0,ae-1),x:ke.clamp(Math.round(he.x/me),0,w-1)}}function Ae(he,me,ae,w,ge,ze,W,nt=2){const[tt,nr]=w.shape,Tt=Q(me.position,ze,tt,nr),Qe=xe(he,Tt,W),it=ke.addVectors(me.position,Qe);let xt=it;for(let ut=0;ut<nt;ut++){const yt=Q(xt,ze,tt,nr),Zt=ke.getOffsetPoint(yt.y,yt.x,ae,ge);xt=ke.addVectors({x:yt.x*ze,y:yt.y*ze},{x:Zt.x,y:Zt.y})}const ot=Q(xt,ze,tt,nr),ht=w.get(ot.y,ot.x,ae);return{position:xt,part:i.partNames[ae],score:ht}}function P(he,me,ae,w,ge,ze){const W=me.shape[2],nt=H.length,tt=new Array(W),{part:nr,score:Tt}=he,Qe=ke.getImageCoords(nr,w,ae);tt[nr.id]={score:Tt,part:i.partNames[nr.id],position:Qe};for(let it=nt-1;it>=0;--it){const xt=H[it],ot=se[it];tt[xt]&&!tt[ot]&&(tt[ot]=Ae(it,tt[xt],ot,me,ae,w,ze))}for(let it=0;it<nt;++it){const xt=se[it],ot=H[it];tt[xt]&&!tt[ot]&&(tt[ot]=Ae(it,tt[xt],ot,me,ae,w,ge))}return tt}N.decodePose=P}),yf=Mr(N=>{const i=Ag(),ke=Dg(),O=mf();function H(Ae,P,{x:he,y:me},ae){return Ae.some(({keypoints:w})=>{const ge=w[ae].position;return O.squaredDistance(me,he,ge.y,ge.x)<=P})}function se(Ae,P,he){const me=he.reduce((ae,{position:w,score:ge},ze)=>(H(Ae,P,w,ze)||(ae+=ge),ae),0);return me/he.length}const xe=1;function Q(Ae,P,he,me,ae,w,ge=.5,ze=20){const W=[],nt=i.buildPartWithScoreQueue(ge,xe,Ae),tt=ze*ze;for(;W.length<w&&!nt.empty();){const nr=nt.dequeue(),Tt=O.getImageCoords(nr.part,ae,P);if(H(W,tt,Tt,nr.part.id))continue;const Qe=ke.decodePose(nr,Ae,P,ae,he,me),it=se(W,tt,Qe);W.push({keypoints:Qe,score:it})}return W}N.decodeMultiplePoses=Q}),vf=Mr(N=>{const i=Xh();function ke(ae,w,ge){return ae<ge||w<ge}function O(ae,w){return i.connectedPartIndices.reduce((ge,[ze,W])=>(ke(ae[ze].score,ae[W].score,w)||ge.push([ae[ze],ae[W]]),ge),[])}N.getAdjacentKeyPoints=O;const{NEGATIVE_INFINITY:H,POSITIVE_INFINITY:se}=Number;function xe(ae){return ae.reduce(({maxX:w,maxY:ge,minX:ze,minY:W},{position:{x:nt,y:tt}})=>({maxX:Math.max(w,nt),maxY:Math.max(ge,tt),minX:Math.min(ze,nt),minY:Math.min(W,tt)}),{maxX:H,maxY:H,minX:se,minY:se})}N.getBoundingBox=xe;function Q(ae){const{minX:w,minY:ge,maxX:ze,maxY:W}=xe(ae);return[{x:w,y:ge},{x:ze,y:ge},{x:ze,y:W},{x:w,y:W}]}N.getBoundingBoxPoints=Q;async function Ae(ae){return Promise.all(ae.map(w=>w.buffer()))}N.toTensorBuffers3D=Ae;function P(ae,w,ge){return{score:ae.score,keypoints:ae.keypoints.map(({score:ze,part:W,position:nt})=>({score:ze,part:W,position:{x:nt.x*ge,y:nt.y*w}}))}}N.scalePose=P;function he(ae,[w,ge]){const ze=ae.squeeze(0),W=ze.resizeBilinear([w,ge]);return ze.dispose(),W}N.resizeTo=he;function me(ae,[w,ge],[ze,W]){const nt=ae.map(tt=>P(tt,w/ze,ge/W));return nt}N.scaleAndFlipPoses=me}),Fg=Mr(N=>{const i=to(),ke=ff(),O=yf(),H=vf();class se{constructor(Ae){this.baseModel=Ae}async estimatePoses(Ae,P){const he=P.outputStride,me=Ae.shape[1],ae=Ae.shape[2],w=H.resizeTo(Ae,[P.inputResolution,P.inputResolution]),{heatmapScores:ge,offsets:ze,displacementFwd:W,displacementBwd:nt}=this.baseModel.predict(w),tt=await H.toTensorBuffers3D([ge,ze,W,nt]),nr=tt[0],Tt=tt[1],Qe=tt[2],it=tt[3],xt=await O.decodeMultiplePoses(nr,Tt,Qe,it,he,P.maxDetections,P.scoreThreshold,P.nmsRadius),ot=H.scaleAndFlipPoses(xt,[me,ae],[P.inputResolution,P.inputResolution]);return ge.dispose(),ze.dispose(),W.dispose(),nt.dispose(),w.dispose(),ot}dispose(){this.baseModel.dispose()}}N.PoseNet=se;async function xe(Ae){const P=await i.loadGraphModel(Ae.modelPath),he=new ke.MobileNet(P,Ae.outputStride);return new se(he)}async function Q(Ae){return xe(Ae)}N.load=Q}),Og=Mr(N=>{const i=ff(),ke=Fg(),O=yf(),H=Xh(),se=vf();N.load=ke.load,N.PoseNet=ke.PoseNet,N.MobileNet=i.MobileNet,N.decodeMultiplePoses=O.decodeMultiplePoses,N.partChannels=H.partChannels,N.partIds=H.partIds,N.partNames=H.partNames,N.poseChain=H.poseChain,N.getAdjacentKeyPoints=se.getAdjacentKeyPoints,N.getBoundingBox=se.getBoundingBox,N.getBoundingBoxPoints=se.getBoundingBoxPoints,N.scaleAndFlipPoses=se.scaleAndFlipPoses,N.scalePose=se.scalePose}),gf=Mr(N=>{Kh(N,{cutBoxFromImageAndResize:()=>H,enlargeBox:()=>xe,getBoxCenter:()=>O,getBoxSize:()=>ke,scaleBoxCoordinates:()=>se,shiftBox:()=>Ae,squarifyBox:()=>Q});const i=to();function ke(P){return[Math.abs(P.endPoint[0]-P.startPoint[0]),Math.abs(P.endPoint[1]-P.startPoint[1])]}function O(P){return[P.startPoint[0]+(P.endPoint[0]-P.startPoint[0])/2,P.startPoint[1]+(P.endPoint[1]-P.startPoint[1])/2]}function H(P,he,me){const ae=he.shape[1],w=he.shape[2],ge=[[P.startPoint[1]/ae,P.startPoint[0]/w,P.endPoint[1]/ae,P.endPoint[0]/w]];return i.image.cropAndResize(he,ge,[0],me)}function se(P,he){const me=[P.startPoint[0]*he[0],P.startPoint[1]*he[1]],ae=[P.endPoint[0]*he[0],P.endPoint[1]*he[1]],w=P.palmLandmarks.map(ge=>{const ze=[ge[0]*he[0],ge[1]*he[1]];return ze});return{startPoint:me,endPoint:ae,palmLandmarks:w}}function xe(P,he=1.5){const me=O(P),ae=ke(P),w=[he*ae[0]/2,he*ae[1]/2],ge=[me[0]-w[0],me[1]-w[1]],ze=[me[0]+w[0],me[1]+w[1]];return{startPoint:ge,endPoint:ze,palmLandmarks:P.palmLandmarks}}function Q(P){const he=O(P),me=ke(P),ae=Math.max(...me),w=ae/2,ge=[he[0]-w,he[1]-w],ze=[he[0]+w,he[1]+w];return{startPoint:ge,endPoint:ze,palmLandmarks:P.palmLandmarks}}function Ae(P,he){const me=[P.endPoint[0]-P.startPoint[0],P.endPoint[1]-P.startPoint[1]],ae=[me[0]*he[0],me[1]*he[1]],w=[P.startPoint[0]+ae[0],P.startPoint[1]+ae[1]],ge=[P.endPoint[0]+ae[0],P.endPoint[1]+ae[1]];return{startPoint:w,endPoint:ge,palmLandmarks:P.palmLandmarks}}}),Mg=Mr(N=>{const i=to(),ke=gf();class O{constructor(H,se,xe){this.model=H,this.width=se,this.height=se,this.anchors=xe.map(Q=>[Q.x_center,Q.y_center]),this.anchorsTensor=i.tensor2d(this.anchors),this.inputSizeTensor=i.tensor1d([se,se]),this.doubleInputSizeTensor=i.tensor1d([se*2,se*2])}normalizeBoxes(H){return i.tidy(()=>{const se=i.slice(H,[0,0],[-1,2]),xe=i.slice(H,[0,2],[-1,2]),Q=i.add(i.div(se,this.inputSizeTensor),this.anchorsTensor),Ae=i.div(xe,this.doubleInputSizeTensor),P=i.mul(i.sub(Q,Ae),this.inputSizeTensor),he=i.mul(i.add(Q,Ae),this.inputSizeTensor);return i.concat2d([P,he],1)})}normalizeLandmarks(H,se){return i.tidy(()=>{const xe=i.add(i.div(H.reshape([-1,7,2]),this.inputSizeTensor),this.anchors[se]);return i.mul(xe,this.inputSizeTensor)})}async getBoundingBoxes(H,se){const xe=i.tidy(()=>i.mul(i.sub(H,.5),2)),Q=this.model.predict(xe),Ae=Q.squeeze(),P=i.tidy(()=>i.sigmoid(i.slice(Ae,[0,0],[-1,1])).squeeze()),he=i.slice(Ae,[0,1],[-1,4]),me=this.normalizeBoxes(he),ae=i.image.nonMaxSuppression(me,P,se.maxHands,se.iouThreshold,se.scoreThreshold),w=ae.arraySync(),ge=[xe,Q,ae,Ae,me,he,P];if(w.length===0)return ge.forEach(W=>W.dispose()),null;const ze=[];for(const W of w){const nt=i.slice(me,[W,0],[1,-1]),tt=i.slice(Ae,[W,5],[1,14]),nr=i.tidy(()=>this.normalizeLandmarks(tt,W).reshape([-1,2]));tt.dispose(),ze.push({boxes:nt,palmLandmarks:nr})}return ge.forEach(W=>W.dispose()),ze}async estimateHandBounds(H,se){const xe=H.shape[1],Q=H.shape[2],Ae=i.tidy(()=>H.resizeBilinear([this.width,this.height]).div(255)),P=await this.getBoundingBoxes(Ae,se);if(!P||P.length===0)return Ae.dispose(),null;const he=[];for(const me of P){const ae=me.boxes.arraySync(),w=ae[0].slice(0,2),ge=ae[0].slice(2,4),ze=me.palmLandmarks.arraySync();Ae.dispose(),me.boxes.dispose(),me.palmLandmarks.dispose(),he.push(ke.scaleBoxCoordinates({startPoint:w,endPoint:ge,palmLandmarks:ze},[Q/this.width,xe/this.height]))}return he}}N.HandDetector=O}),Lg=Mr(N=>{Kh(N,{buildRotationMatrix:()=>Q,computeRotation:()=>ke,dot:()=>H,getColumnFrom2DArr:()=>se,invertTransformMatrix:()=>Ae,normalizeRadians:()=>i,rotatePoint:()=>P});function i(he){return he-2*Math.PI*Math.floor((he+Math.PI)/(2*Math.PI))}function ke(he,me){const ae=Math.PI/2-Math.atan2(-(me[1]-he[1]),me[0]-he[0]);return i(ae)}const O=(he,me)=>[[1,0,he],[0,1,me],[0,0,1]];function H(he,me){let ae=0;for(let w=0;w<he.length;w++)ae+=he[w]*me[w];return ae}function se(he,me){const ae=[];for(let w=0;w<he.length;w++)ae.push(he[w][me]);return ae}function xe(he,me){const ae=[],w=he.length;for(let ge=0;ge<w;ge++){ae.push([]);for(let ze=0;ze<w;ze++)ae[ge].push(H(he[ge],se(me,ze)))}return ae}function Q(he,me){const ae=Math.cos(he),w=Math.sin(he),ge=[[ae,-w,0],[w,ae,0],[0,0,1]],ze=O(me[0],me[1]),W=xe(ze,ge),nt=O(-me[0],-me[1]);return xe(W,nt)}function Ae(he){const me=[[he[0][0],he[1][0]],[he[0][1],he[1][1]]],ae=[he[0][2],he[1][2]],w=[-H(me[0],ae),-H(me[1],ae)];return[me[0].concat(w[0]),me[1].concat(w[1]),[0,0,1]]}function P(he,me){return[H(he,me[0]),H(he,me[1])]}}),zg=Mr(N=>{const i=to(),ke=gf(),O=Lg(),H=.8,se=[0,-.4],xe=3,Q=[0,-.1],Ae=1.65,P=[0,5,9,13,17,1,2],he=0,me=2;class ae{constructor(w,ge,ze){this.boundingBoxDetector=w,this.meshDetector=ge,this.inputSize=ze,this.regionsOfInterest=[],this.runsWithoutHandDetector=0,this.maxHandsNumber=1,this.skipFrames=0}getBoxForPalmLandmarks(w,ge){const ze=w.map(nt=>{const tt=[...nt,1];return O.rotatePoint(tt,ge)}),W=this.calculateLandmarksBoundingBox(ze);return ke.enlargeBox(ke.squarifyBox(ke.shiftBox(W,se)),xe)}getBoxForHandLandmarks(w){const ge=this.calculateLandmarksBoundingBox(w),ze=ke.enlargeBox(ke.squarifyBox(ke.shiftBox(ge,Q)),Ae),W=[];for(let nt=0;nt<P.length;nt++)W.push(w[P[nt]].slice(0,2));return ze.palmLandmarks=W,ze}transformRawCoords(w,ge,ze,W){const nt=ke.getBoxSize(ge),tt=[nt[0]/this.inputSize,nt[1]/this.inputSize],nr=w.map(ht=>[tt[0]*(ht[0]-this.inputSize/2),tt[1]*(ht[1]-this.inputSize/2),ht[2]]),Tt=O.buildRotationMatrix(ze,[0,0]),Qe=nr.map(ht=>{const ut=O.rotatePoint(ht,Tt);return[...ut,ht[2]]}),it=O.invertTransformMatrix(W),xt=[...ke.getBoxCenter(ge),1],ot=[O.dot(xt,it[0]),O.dot(xt,it[1])];return Qe.map(ht=>[ht[0]+ot[0],ht[1]+ot[1],ht[2]])}async estimateHands(w,ge){this.skipFrames=ge.skipFrames;const ze=this.shouldUpdateRegionsOfInterest();if(ze){const nt=await this.boundingBoxDetector.estimateHandBounds(w,ge);if(this.regionsOfInterest=[],!nt||nt.length===0)return w.dispose(),null;for(const tt of nt)this.regionsOfInterest.push(tt);this.runsWithoutHandDetector=0}else this.runsWithoutHandDetector++;const W=[];for(const nt in this.regionsOfInterest){const tt=this.regionsOfInterest[nt];if(!tt)continue;const nr=O.computeRotation(tt.palmLandmarks[he],tt.palmLandmarks[me]),Tt=ke.getBoxCenter(tt),Qe=[Tt[0]/w.shape[2],Tt[1]/w.shape[1]],it=i.image.rotateWithOffset(w,nr,0,Qe),xt=O.buildRotationMatrix(-nr,Tt),ot=ze?this.getBoxForPalmLandmarks(tt.palmLandmarks,xt):tt,ht=ke.cutBoxFromImageAndResize(ot,it,[this.inputSize,this.inputSize]),ut=ht.div(255);ht.dispose(),it.dispose();const yt=this.meshDetector.predict(ut),[Zt,ar]=yt;ut.dispose();const qt=Zt.dataSync()[0];if(Zt.dispose(),qt<ge.minConfidence)return ar.dispose(),this.regionsOfInterest[nt]=null,null;const Ur=i.reshape(ar,[-1,3]),jr=Ur.arraySync();ar.dispose(),Ur.dispose();const _r=this.transformRawCoords(jr,ot,nr,xt),tr=this.getBoxForHandLandmarks(_r);this.updateRegionsOfInterest(tr,nt);const Fa={landmarks:_r,handInViewConfidence:qt,boundingBox:{topLeft:tr.startPoint,bottomRight:tr.endPoint}};W.push(Fa)}return W}calculateLandmarksBoundingBox(w){const ge=w.map(tt=>tt[0]),ze=w.map(tt=>tt[1]),W=[Math.min(...ge),Math.min(...ze)],nt=[Math.max(...ge),Math.max(...ze)];return{startPoint:W,endPoint:nt}}updateRegionsOfInterest(w,ge){const ze=this.regionsOfInterest[ge];let W=0;if(ze!=null&&ze.startPoint!=null){const[nt,tt]=w.startPoint,[nr,Tt]=w.endPoint,[Qe,it]=ze.startPoint,[xt,ot]=ze.endPoint,ht=Math.max(nt,Qe),ut=Math.max(tt,it),yt=Math.min(nr,xt),Zt=Math.min(Tt,ot),ar=(yt-ht)*(Zt-ut),qt=(nr-nt)*(Tt-tt),Ur=(xt-Qe)*(ot-tt);W=ar/(qt+Ur-ar)}this.regionsOfInterest[ge]=W>H?ze:w}shouldUpdateRegionsOfInterest(){return!this.regionsOfInterest||this.regionsOfInterest.length===0||this.runsWithoutHandDetector>=this.skipFrames}}N.HandPipeline=ae}),Pg=Mr(N=>{N.anchors=[{w:1,h:1,x_center:.015625,y_center:.015625},{w:1,h:1,x_center:.015625,y_center:.015625},{w:1,h:1,x_center:.046875,y_center:.015625},{w:1,h:1,x_center:.046875,y_center:.015625},{w:1,h:1,x_center:.078125,y_center:.015625},{w:1,h:1,x_center:.078125,y_center:.015625},{w:1,h:1,x_center:.109375,y_center:.015625},{w:1,h:1,x_center:.109375,y_center:.015625},{w:1,h:1,x_center:.140625,y_center:.015625},{w:1,h:1,x_center:.140625,y_center:.015625},{w:1,h:1,x_center:.171875,y_center:.015625},{w:1,h:1,x_center:.171875,y_center:.015625},{w:1,h:1,x_center:.203125,y_center:.015625},{w:1,h:1,x_center:.203125,y_center:.015625},{w:1,h:1,x_center:.234375,y_center:.015625},{w:1,h:1,x_center:.234375,y_center:.015625},{w:1,h:1,x_center:.265625,y_center:.015625},{w:1,h:1,x_center:.265625,y_center:.015625},{w:1,h:1,x_center:.296875,y_center:.015625},{w:1,h:1,x_center:.296875,y_center:.015625},{w:1,h:1,x_center:.328125,y_center:.015625},{w:1,h:1,x_center:.328125,y_center:.015625},{w:1,h:1,x_center:.359375,y_center:.015625},{w:1,h:1,x_center:.359375,y_center:.015625},{w:1,h:1,x_center:.390625,y_center:.015625},{w:1,h:1,x_center:.390625,y_center:.015625},{w:1,h:1,x_center:.421875,y_center:.015625},{w:1,h:1,x_center:.421875,y_center:.015625},{w:1,h:1,x_center:.453125,y_center:.015625},{w:1,h:1,x_center:.453125,y_center:.015625},{w:1,h:1,x_center:.484375,y_center:.015625},{w:1,h:1,x_center:.484375,y_center:.015625},{w:1,h:1,x_center:.515625,y_center:.015625},{w:1,h:1,x_center:.515625,y_center:.015625},{w:1,h:1,x_center:.546875,y_center:.015625},{w:1,h:1,x_center:.546875,y_center:.015625},{w:1,h:1,x_center:.578125,y_center:.015625},{w:1,h:1,x_center:.578125,y_center:.015625},{w:1,h:1,x_center:.609375,y_center:.015625},{w:1,h:1,x_center:.609375,y_center:.015625},{w:1,h:1,x_center:.640625,y_center:.015625},{w:1,h:1,x_center:.640625,y_center:.015625},{w:1,h:1,x_center:.671875,y_center:.015625},{w:1,h:1,x_center:.671875,y_center:.015625},{w:1,h:1,x_center:.703125,y_center:.015625},{w:1,h:1,x_center:.703125,y_center:.015625},{w:1,h:1,x_center:.734375,y_center:.015625},{w:1,h:1,x_center:.734375,y_center:.015625},{w:1,h:1,x_center:.765625,y_center:.015625},{w:1,h:1,x_center:.765625,y_center:.015625},{w:1,h:1,x_center:.796875,y_center:.015625},{w:1,h:1,x_center:.796875,y_center:.015625},{w:1,h:1,x_center:.828125,y_center:.015625},{w:1,h:1,x_center:.828125,y_center:.015625},{w:1,h:1,x_center:.859375,y_center:.015625},{w:1,h:1,x_center:.859375,y_center:.015625},{w:1,h:1,x_center:.890625,y_center:.015625},{w:1,h:1,x_center:.890625,y_center:.015625},{w:1,h:1,x_center:.921875,y_center:.015625},{w:1,h:1,x_center:.921875,y_center:.015625},{w:1,h:1,x_center:.953125,y_center:.015625},{w:1,h:1,x_center:.953125,y_center:.015625},{w:1,h:1,x_center:.984375,y_center:.015625},{w:1,h:1,x_center:.984375,y_center:.015625},{w:1,h:1,x_center:.015625,y_center:.046875},{w:1,h:1,x_center:.015625,y_center:.046875},{w:1,h:1,x_center:.046875,y_center:.046875},{w:1,h:1,x_center:.046875,y_center:.046875},{w:1,h:1,x_center:.078125,y_center:.046875},{w:1,h:1,x_center:.078125,y_center:.046875},{w:1,h:1,x_center:.109375,y_center:.046875},{w:1,h:1,x_center:.109375,y_center:.046875},{w:1,h:1,x_center:.140625,y_center:.046875},{w:1,h:1,x_center:.140625,y_center:.046875},{w:1,h:1,x_center:.171875,y_center:.046875},{w:1,h:1,x_center:.171875,y_center:.046875},{w:1,h:1,x_center:.203125,y_center:.046875},{w:1,h:1,x_center:.203125,y_center:.046875},{w:1,h:1,x_center:.234375,y_center:.046875},{w:1,h:1,x_center:.234375,y_center:.046875},{w:1,h:1,x_center:.265625,y_center:.046875},{w:1,h:1,x_center:.265625,y_center:.046875},{w:1,h:1,x_center:.296875,y_center:.046875},{w:1,h:1,x_center:.296875,y_center:.046875},{w:1,h:1,x_center:.328125,y_center:.046875},{w:1,h:1,x_center:.328125,y_center:.046875},{w:1,h:1,x_center:.359375,y_center:.046875},{w:1,h:1,x_center:.359375,y_center:.046875},{w:1,h:1,x_center:.390625,y_center:.046875},{w:1,h:1,x_center:.390625,y_center:.046875},{w:1,h:1,x_center:.421875,y_center:.046875},{w:1,h:1,x_center:.421875,y_center:.046875},{w:1,h:1,x_center:.453125,y_center:.046875},{w:1,h:1,x_center:.453125,y_center:.046875},{w:1,h:1,x_center:.484375,y_center:.046875},{w:1,h:1,x_center:.484375,y_center:.046875},{w:1,h:1,x_center:.515625,y_center:.046875},{w:1,h:1,x_center:.515625,y_center:.046875},{w:1,h:1,x_center:.546875,y_center:.046875},{w:1,h:1,x_center:.546875,y_center:.046875},{w:1,h:1,x_center:.578125,y_center:.046875},{w:1,h:1,x_center:.578125,y_center:.046875},{w:1,h:1,x_center:.609375,y_center:.046875},{w:1,h:1,x_center:.609375,y_center:.046875},{w:1,h:1,x_center:.640625,y_center:.046875},{w:1,h:1,x_center:.640625,y_center:.046875},{w:1,h:1,x_center:.671875,y_center:.046875},{w:1,h:1,x_center:.671875,y_center:.046875},{w:1,h:1,x_center:.703125,y_center:.046875},{w:1,h:1,x_center:.703125,y_center:.046875},{w:1,h:1,x_center:.734375,y_center:.046875},{w:1,h:1,x_center:.734375,y_center:.046875},{w:1,h:1,x_center:.765625,y_center:.046875},{w:1,h:1,x_center:.765625,y_center:.046875},{w:1,h:1,x_center:.796875,y_center:.046875},{w:1,h:1,x_center:.796875,y_center:.046875},{w:1,h:1,x_center:.828125,y_center:.046875},{w:1,h:1,x_center:.828125,y_center:.046875},{w:1,h:1,x_center:.859375,y_center:.046875},{w:1,h:1,x_center:.859375,y_center:.046875},{w:1,h:1,x_center:.890625,y_center:.046875},{w:1,h:1,x_center:.890625,y_center:.046875},{w:1,h:1,x_center:.921875,y_center:.046875},{w:1,h:1,x_center:.921875,y_center:.046875},{w:1,h:1,x_center:.953125,y_center:.046875},{w:1,h:1,x_center:.953125,y_center:.046875},{w:1,h:1,x_center:.984375,y_center:.046875},{w:1,h:1,x_center:.984375,y_center:.046875},{w:1,h:1,x_center:.015625,y_center:.078125},{w:1,h:1,x_center:.015625,y_center:.078125},{w:1,h:1,x_center:.046875,y_center:.078125},{w:1,h:1,x_center:.046875,y_center:.078125},{w:1,h:1,x_center:.078125,y_center:.078125},{w:1,h:1,x_center:.078125,y_center:.078125},{w:1,h:1,x_center:.109375,y_center:.078125},{w:1,h:1,x_center:.109375,y_center:.078125},{w:1,h:1,x_center:.140625,y_center:.078125},{w:1,h:1,x_center:.140625,y_center:.078125},{w:1,h:1,x_center:.171875,y_center:.078125},{w:1,h:1,x_center:.171875,y_center:.078125},{w:1,h:1,x_center:.203125,y_center:.078125},{w:1,h:1,x_center:.203125,y_center:.078125},{w:1,h:1,x_center:.234375,y_center:.078125},{w:1,h:1,x_center:.234375,y_center:.078125},{w:1,h:1,x_center:.265625,y_center:.078125},{w:1,h:1,x_center:.265625,y_center:.078125},{w:1,h:1,x_center:.296875,y_center:.078125},{w:1,h:1,x_center:.296875,y_center:.078125},{w:1,h:1,x_center:.328125,y_center:.078125},{w:1,h:1,x_center:.328125,y_center:.078125},{w:1,h:1,x_center:.359375,y_center:.078125},{w:1,h:1,x_center:.359375,y_center:.078125},{w:1,h:1,x_center:.390625,y_center:.078125},{w:1,h:1,x_center:.390625,y_center:.078125},{w:1,h:1,x_center:.421875,y_center:.078125},{w:1,h:1,x_center:.421875,y_center:.078125},{w:1,h:1,x_center:.453125,y_center:.078125},{w:1,h:1,x_center:.453125,y_center:.078125},{w:1,h:1,x_center:.484375,y_center:.078125},{w:1,h:1,x_center:.484375,y_center:.078125},{w:1,h:1,x_center:.515625,y_center:.078125},{w:1,h:1,x_center:.515625,y_center:.078125},{w:1,h:1,x_center:.546875,y_center:.078125},{w:1,h:1,x_center:.546875,y_center:.078125},{w:1,h:1,x_center:.578125,y_center:.078125},{w:1,h:1,x_center:.578125,y_center:.078125},{w:1,h:1,x_center:.609375,y_center:.078125},{w:1,h:1,x_center:.609375,y_center:.078125},{w:1,h:1,x_center:.640625,y_center:.078125},{w:1,h:1,x_center:.640625,y_center:.078125},{w:1,h:1,x_center:.671875,y_center:.078125},{w:1,h:1,x_center:.671875,y_center:.078125},{w:1,h:1,x_center:.703125,y_center:.078125},{w:1,h:1,x_center:.703125,y_center:.078125},{w:1,h:1,x_center:.734375,y_center:.078125},{w:1,h:1,x_center:.734375,y_center:.078125},{w:1,h:1,x_center:.765625,y_center:.078125},{w:1,h:1,x_center:.765625,y_center:.078125},{w:1,h:1,x_center:.796875,y_center:.078125},{w:1,h:1,x_center:.796875,y_center:.078125},{w:1,h:1,x_center:.828125,y_center:.078125},{w:1,h:1,x_center:.828125,y_center:.078125},{w:1,h:1,x_center:.859375,y_center:.078125},{w:1,h:1,x_center:.859375,y_center:.078125},{w:1,h:1,x_center:.890625,y_center:.078125},{w:1,h:1,x_center:.890625,y_center:.078125},{w:1,h:1,x_center:.921875,y_center:.078125},{w:1,h:1,x_center:.921875,y_center:.078125},{w:1,h:1,x_center:.953125,y_center:.078125},{w:1,h:1,x_center:.953125,y_center:.078125},{w:1,h:1,x_center:.984375,y_center:.078125},{w:1,h:1,x_center:.984375,y_center:.078125},{w:1,h:1,x_center:.015625,y_center:.109375},{w:1,h:1,x_center:.015625,y_center:.109375},{w:1,h:1,x_center:.046875,y_center:.109375},{w:1,h:1,x_center:.046875,y_center:.109375},{w:1,h:1,x_center:.078125,y_center:.109375},{w:1,h:1,x_center:.078125,y_center:.109375},{w:1,h:1,x_center:.109375,y_center:.109375},{w:1,h:1,x_center:.109375,y_center:.109375},{w:1,h:1,x_center:.140625,y_center:.109375},{w:1,h:1,x_center:.140625,y_center:.109375},{w:1,h:1,x_center:.171875,y_center:.109375},{w:1,h:1,x_center:.171875,y_center:.109375},{w:1,h:1,x_center:.203125,y_center:.109375},{w:1,h:1,x_center:.203125,y_center:.109375},{w:1,h:1,x_center:.234375,y_center:.109375},{w:1,h:1,x_center:.234375,y_center:.109375},{w:1,h:1,x_center:.265625,y_center:.109375},{w:1,h:1,x_center:.265625,y_center:.109375},{w:1,h:1,x_center:.296875,y_center:.109375},{w:1,h:1,x_center:.296875,y_center:.109375},{w:1,h:1,x_center:.328125,y_center:.109375},{w:1,h:1,x_center:.328125,y_center:.109375},{w:1,h:1,x_center:.359375,y_center:.109375},{w:1,h:1,x_center:.359375,y_center:.109375},{w:1,h:1,x_center:.390625,y_center:.109375},{w:1,h:1,x_center:.390625,y_center:.109375},{w:1,h:1,x_center:.421875,y_center:.109375},{w:1,h:1,x_center:.421875,y_center:.109375},{w:1,h:1,x_center:.453125,y_center:.109375},{w:1,h:1,x_center:.453125,y_center:.109375},{w:1,h:1,x_center:.484375,y_center:.109375},{w:1,h:1,x_center:.484375,y_center:.109375},{w:1,h:1,x_center:.515625,y_center:.109375},{w:1,h:1,x_center:.515625,y_center:.109375},{w:1,h:1,x_center:.546875,y_center:.109375},{w:1,h:1,x_center:.546875,y_center:.109375},{w:1,h:1,x_center:.578125,y_center:.109375},{w:1,h:1,x_center:.578125,y_center:.109375},{w:1,h:1,x_center:.609375,y_center:.109375},{w:1,h:1,x_center:.609375,y_center:.109375},{w:1,h:1,x_center:.640625,y_center:.109375},{w:1,h:1,x_center:.640625,y_center:.109375},{w:1,h:1,x_center:.671875,y_center:.109375},{w:1,h:1,x_center:.671875,y_center:.109375},{w:1,h:1,x_center:.703125,y_center:.109375},{w:1,h:1,x_center:.703125,y_center:.109375},{w:1,h:1,x_center:.734375,y_center:.109375},{w:1,h:1,x_center:.734375,y_center:.109375},{w:1,h:1,x_center:.765625,y_center:.109375},{w:1,h:1,x_center:.765625,y_center:.109375},{w:1,h:1,x_center:.796875,y_center:.109375},{w:1,h:1,x_center:.796875,y_center:.109375},{w:1,h:1,x_center:.828125,y_center:.109375},{w:1,h:1,x_center:.828125,y_center:.109375},{w:1,h:1,x_center:.859375,y_center:.109375},{w:1,h:1,x_center:.859375,y_center:.109375},{w:1,h:1,x_center:.890625,y_center:.109375},{w:1,h:1,x_center:.890625,y_center:.109375},{w:1,h:1,x_center:.921875,y_center:.109375},{w:1,h:1,x_center:.921875,y_center:.109375},{w:1,h:1,x_center:.953125,y_center:.109375},{w:1,h:1,x_center:.953125,y_center:.109375},{w:1,h:1,x_center:.984375,y_center:.109375},{w:1,h:1,x_center:.984375,y_center:.109375},{w:1,h:1,x_center:.015625,y_center:.140625},{w:1,h:1,x_center:.015625,y_center:.140625},{w:1,h:1,x_center:.046875,y_center:.140625},{w:1,h:1,x_center:.046875,y_center:.140625},{w:1,h:1,x_center:.078125,y_center:.140625},{w:1,h:1,x_center:.078125,y_center:.140625},{w:1,h:1,x_center:.109375,y_center:.140625},{w:1,h:1,x_center:.109375,y_center:.140625},{w:1,h:1,x_center:.140625,y_center:.140625},{w:1,h:1,x_center:.140625,y_center:.140625},{w:1,h:1,x_center:.171875,y_center:.140625},{w:1,h:1,x_center:.171875,y_center:.140625},{w:1,h:1,x_center:.203125,y_center:.140625},{w:1,h:1,x_center:.203125,y_center:.140625},{w:1,h:1,x_center:.234375,y_center:.140625},{w:1,h:1,x_center:.234375,y_center:.140625},{w:1,h:1,x_center:.265625,y_center:.140625},{w:1,h:1,x_center:.265625,y_center:.140625},{w:1,h:1,x_center:.296875,y_center:.140625},{w:1,h:1,x_center:.296875,y_center:.140625},{w:1,h:1,x_center:.328125,y_center:.140625},{w:1,h:1,x_center:.328125,y_center:.140625},{w:1,h:1,x_center:.359375,y_center:.140625},{w:1,h:1,x_center:.359375,y_center:.140625},{w:1,h:1,x_center:.390625,y_center:.140625},{w:1,h:1,x_center:.390625,y_center:.140625},{w:1,h:1,x_center:.421875,y_center:.140625},{w:1,h:1,x_center:.421875,y_center:.140625},{w:1,h:1,x_center:.453125,y_center:.140625},{w:1,h:1,x_center:.453125,y_center:.140625},{w:1,h:1,x_center:.484375,y_center:.140625},{w:1,h:1,x_center:.484375,y_center:.140625},{w:1,h:1,x_center:.515625,y_center:.140625},{w:1,h:1,x_center:.515625,y_center:.140625},{w:1,h:1,x_center:.546875,y_center:.140625},{w:1,h:1,x_center:.546875,y_center:.140625},{w:1,h:1,x_center:.578125,y_center:.140625},{w:1,h:1,x_center:.578125,y_center:.140625},{w:1,h:1,x_center:.609375,y_center:.140625},{w:1,h:1,x_center:.609375,y_center:.140625},{w:1,h:1,x_center:.640625,y_center:.140625},{w:1,h:1,x_center:.640625,y_center:.140625},{w:1,h:1,x_center:.671875,y_center:.140625},{w:1,h:1,x_center:.671875,y_center:.140625},{w:1,h:1,x_center:.703125,y_center:.140625},{w:1,h:1,x_center:.703125,y_center:.140625},{w:1,h:1,x_center:.734375,y_center:.140625},{w:1,h:1,x_center:.734375,y_center:.140625},{w:1,h:1,x_center:.765625,y_center:.140625},{w:1,h:1,x_center:.765625,y_center:.140625},{w:1,h:1,x_center:.796875,y_center:.140625},{w:1,h:1,x_center:.796875,y_center:.140625},{w:1,h:1,x_center:.828125,y_center:.140625},{w:1,h:1,x_center:.828125,y_center:.140625},{w:1,h:1,x_center:.859375,y_center:.140625},{w:1,h:1,x_center:.859375,y_center:.140625},{w:1,h:1,x_center:.890625,y_center:.140625},{w:1,h:1,x_center:.890625,y_center:.140625},{w:1,h:1,x_center:.921875,y_center:.140625},{w:1,h:1,x_center:.921875,y_center:.140625},{w:1,h:1,x_center:.953125,y_center:.140625},{w:1,h:1,x_center:.953125,y_center:.140625},{w:1,h:1,x_center:.984375,y_center:.140625},{w:1,h:1,x_center:.984375,y_center:.140625},{w:1,h:1,x_center:.015625,y_center:.171875},{w:1,h:1,x_center:.015625,y_center:.171875},{w:1,h:1,x_center:.046875,y_center:.171875},{w:1,h:1,x_center:.046875,y_center:.171875},{w:1,h:1,x_center:.078125,y_center:.171875},{w:1,h:1,x_center:.078125,y_center:.171875},{w:1,h:1,x_center:.109375,y_center:.171875},{w:1,h:1,x_center:.109375,y_center:.171875},{w:1,h:1,x_center:.140625,y_center:.171875},{w:1,h:1,x_center:.140625,y_center:.171875},{w:1,h:1,x_center:.171875,y_center:.171875},{w:1,h:1,x_center:.171875,y_center:.171875},{w:1,h:1,x_center:.203125,y_center:.171875},{w:1,h:1,x_center:.203125,y_center:.171875},{w:1,h:1,x_center:.234375,y_center:.171875},{w:1,h:1,x_center:.234375,y_center:.171875},{w:1,h:1,x_center:.265625,y_center:.171875},{w:1,h:1,x_center:.265625,y_center:.171875},{w:1,h:1,x_center:.296875,y_center:.171875},{w:1,h:1,x_center:.296875,y_center:.171875},{w:1,h:1,x_center:.328125,y_center:.171875},{w:1,h:1,x_center:.328125,y_center:.171875},{w:1,h:1,x_center:.359375,y_center:.171875},{w:1,h:1,x_center:.359375,y_center:.171875},{w:1,h:1,x_center:.390625,y_center:.171875},{w:1,h:1,x_center:.390625,y_center:.171875},{w:1,h:1,x_center:.421875,y_center:.171875},{w:1,h:1,x_center:.421875,y_center:.171875},{w:1,h:1,x_center:.453125,y_center:.171875},{w:1,h:1,x_center:.453125,y_center:.171875},{w:1,h:1,x_center:.484375,y_center:.171875},{w:1,h:1,x_center:.484375,y_center:.171875},{w:1,h:1,x_center:.515625,y_center:.171875},{w:1,h:1,x_center:.515625,y_center:.171875},{w:1,h:1,x_center:.546875,y_center:.171875},{w:1,h:1,x_center:.546875,y_center:.171875},{w:1,h:1,x_center:.578125,y_center:.171875},{w:1,h:1,x_center:.578125,y_center:.171875},{w:1,h:1,x_center:.609375,y_center:.171875},{w:1,h:1,x_center:.609375,y_center:.171875},{w:1,h:1,x_center:.640625,y_center:.171875},{w:1,h:1,x_center:.640625,y_center:.171875},{w:1,h:1,x_center:.671875,y_center:.171875},{w:1,h:1,x_center:.671875,y_center:.171875},{w:1,h:1,x_center:.703125,y_center:.171875},{w:1,h:1,x_center:.703125,y_center:.171875},{w:1,h:1,x_center:.734375,y_center:.171875},{w:1,h:1,x_center:.734375,y_center:.171875},{w:1,h:1,x_center:.765625,y_center:.171875},{w:1,h:1,x_center:.765625,y_center:.171875},{w:1,h:1,x_center:.796875,y_center:.171875},{w:1,h:1,x_center:.796875,y_center:.171875},{w:1,h:1,x_center:.828125,y_center:.171875},{w:1,h:1,x_center:.828125,y_center:.171875},{w:1,h:1,x_center:.859375,y_center:.171875},{w:1,h:1,x_center:.859375,y_center:.171875},{w:1,h:1,x_center:.890625,y_center:.171875},{w:1,h:1,x_center:.890625,y_center:.171875},{w:1,h:1,x_center:.921875,y_center:.171875},{w:1,h:1,x_center:.921875,y_center:.171875},{w:1,h:1,x_center:.953125,y_center:.171875},{w:1,h:1,x_center:.953125,y_center:.171875},{w:1,h:1,x_center:.984375,y_center:.171875},{w:1,h:1,x_center:.984375,y_center:.171875},{w:1,h:1,x_center:.015625,y_center:.203125},{w:1,h:1,x_center:.015625,y_center:.203125},{w:1,h:1,x_center:.046875,y_center:.203125},{w:1,h:1,x_center:.046875,y_center:.203125},{w:1,h:1,x_center:.078125,y_center:.203125},{w:1,h:1,x_center:.078125,y_center:.203125},{w:1,h:1,x_center:.109375,y_center:.203125},{w:1,h:1,x_center:.109375,y_center:.203125},{w:1,h:1,x_center:.140625,y_center:.203125},{w:1,h:1,x_center:.140625,y_center:.203125},{w:1,h:1,x_center:.171875,y_center:.203125},{w:1,h:1,x_center:.171875,y_center:.203125},{w:1,h:1,x_center:.203125,y_center:.203125},{w:1,h:1,x_center:.203125,y_center:.203125},{w:1,h:1,x_center:.234375,y_center:.203125},{w:1,h:1,x_center:.234375,y_center:.203125},{w:1,h:1,x_center:.265625,y_center:.203125},{w:1,h:1,x_center:.265625,y_center:.203125},{w:1,h:1,x_center:.296875,y_center:.203125},{w:1,h:1,x_center:.296875,y_center:.203125},{w:1,h:1,x_center:.328125,y_center:.203125},{w:1,h:1,x_center:.328125,y_center:.203125},{w:1,h:1,x_center:.359375,y_center:.203125},{w:1,h:1,x_center:.359375,y_center:.203125},{w:1,h:1,x_center:.390625,y_center:.203125},{w:1,h:1,x_center:.390625,y_center:.203125},{w:1,h:1,x_center:.421875,y_center:.203125},{w:1,h:1,x_center:.421875,y_center:.203125},{w:1,h:1,x_center:.453125,y_center:.203125},{w:1,h:1,x_center:.453125,y_center:.203125},{w:1,h:1,x_center:.484375,y_center:.203125},{w:1,h:1,x_center:.484375,y_center:.203125},{w:1,h:1,x_center:.515625,y_center:.203125},{w:1,h:1,x_center:.515625,y_center:.203125},{w:1,h:1,x_center:.546875,y_center:.203125},{w:1,h:1,x_center:.546875,y_center:.203125},{w:1,h:1,x_center:.578125,y_center:.203125},{w:1,h:1,x_center:.578125,y_center:.203125},{w:1,h:1,x_center:.609375,y_center:.203125},{w:1,h:1,x_center:.609375,y_center:.203125},{w:1,h:1,x_center:.640625,y_center:.203125},{w:1,h:1,x_center:.640625,y_center:.203125},{w:1,h:1,x_center:.671875,y_center:.203125},{w:1,h:1,x_center:.671875,y_center:.203125},{w:1,h:1,x_center:.703125,y_center:.203125},{w:1,h:1,x_center:.703125,y_center:.203125},{w:1,h:1,x_center:.734375,y_center:.203125},{w:1,h:1,x_center:.734375,y_center:.203125},{w:1,h:1,x_center:.765625,y_center:.203125},{w:1,h:1,x_center:.765625,y_center:.203125},{w:1,h:1,x_center:.796875,y_center:.203125},{w:1,h:1,x_center:.796875,y_center:.203125},{w:1,h:1,x_center:.828125,y_center:.203125},{w:1,h:1,x_center:.828125,y_center:.203125},{w:1,h:1,x_center:.859375,y_center:.203125},{w:1,h:1,x_center:.859375,y_center:.203125},{w:1,h:1,x_center:.890625,y_center:.203125},{w:1,h:1,x_center:.890625,y_center:.203125},{w:1,h:1,x_center:.921875,y_center:.203125},{w:1,h:1,x_center:.921875,y_center:.203125},{w:1,h:1,x_center:.953125,y_center:.203125},{w:1,h:1,x_center:.953125,y_center:.203125},{w:1,h:1,x_center:.984375,y_center:.203125},{w:1,h:1,x_center:.984375,y_center:.203125},{w:1,h:1,x_center:.015625,y_center:.234375},{w:1,h:1,x_center:.015625,y_center:.234375},{w:1,h:1,x_center:.046875,y_center:.234375},{w:1,h:1,x_center:.046875,y_center:.234375},{w:1,h:1,x_center:.078125,y_center:.234375},{w:1,h:1,x_center:.078125,y_center:.234375},{w:1,h:1,x_center:.109375,y_center:.234375},{w:1,h:1,x_center:.109375,y_center:.234375},{w:1,h:1,x_center:.140625,y_center:.234375},{w:1,h:1,x_center:.140625,y_center:.234375},{w:1,h:1,x_center:.171875,y_center:.234375},{w:1,h:1,x_center:.171875,y_center:.234375},{w:1,h:1,x_center:.203125,y_center:.234375},{w:1,h:1,x_center:.203125,y_center:.234375},{w:1,h:1,x_center:.234375,y_center:.234375},{w:1,h:1,x_center:.234375,y_center:.234375},{w:1,h:1,x_center:.265625,y_center:.234375},{w:1,h:1,x_center:.265625,y_center:.234375},{w:1,h:1,x_center:.296875,y_center:.234375},{w:1,h:1,x_center:.296875,y_center:.234375},{w:1,h:1,x_center:.328125,y_center:.234375},{w:1,h:1,x_center:.328125,y_center:.234375},{w:1,h:1,x_center:.359375,y_center:.234375},{w:1,h:1,x_center:.359375,y_center:.234375},{w:1,h:1,x_center:.390625,y_center:.234375},{w:1,h:1,x_center:.390625,y_center:.234375},{w:1,h:1,x_center:.421875,y_center:.234375},{w:1,h:1,x_center:.421875,y_center:.234375},{w:1,h:1,x_center:.453125,y_center:.234375},{w:1,h:1,x_center:.453125,y_center:.234375},{w:1,h:1,x_center:.484375,y_center:.234375},{w:1,h:1,x_center:.484375,y_center:.234375},{w:1,h:1,x_center:.515625,y_center:.234375},{w:1,h:1,x_center:.515625,y_center:.234375},{w:1,h:1,x_center:.546875,y_center:.234375},{w:1,h:1,x_center:.546875,y_center:.234375},{w:1,h:1,x_center:.578125,y_center:.234375},{w:1,h:1,x_center:.578125,y_center:.234375},{w:1,h:1,x_center:.609375,y_center:.234375},{w:1,h:1,x_center:.609375,y_center:.234375},{w:1,h:1,x_center:.640625,y_center:.234375},{w:1,h:1,x_center:.640625,y_center:.234375},{w:1,h:1,x_center:.671875,y_center:.234375},{w:1,h:1,x_center:.671875,y_center:.234375},{w:1,h:1,x_center:.703125,y_center:.234375},{w:1,h:1,x_center:.703125,y_center:.234375},{w:1,h:1,x_center:.734375,y_center:.234375},{w:1,h:1,x_center:.734375,y_center:.234375},{w:1,h:1,x_center:.765625,y_center:.234375},{w:1,h:1,x_center:.765625,y_center:.234375},{w:1,h:1,x_center:.796875,y_center:.234375},{w:1,h:1,x_center:.796875,y_center:.234375},{w:1,h:1,x_center:.828125,y_center:.234375},{w:1,h:1,x_center:.828125,y_center:.234375},{w:1,h:1,x_center:.859375,y_center:.234375},{w:1,h:1,x_center:.859375,y_center:.234375},{w:1,h:1,x_center:.890625,y_center:.234375},{w:1,h:1,x_center:.890625,y_center:.234375},{w:1,h:1,x_center:.921875,y_center:.234375},{w:1,h:1,x_center:.921875,y_center:.234375},{w:1,h:1,x_center:.953125,y_center:.234375},{w:1,h:1,x_center:.953125,y_center:.234375},{w:1,h:1,x_center:.984375,y_center:.234375},{w:1,h:1,x_center:.984375,y_center:.234375},{w:1,h:1,x_center:.015625,y_center:.265625},{w:1,h:1,x_center:.015625,y_center:.265625},{w:1,h:1,x_center:.046875,y_center:.265625},{w:1,h:1,x_center:.046875,y_center:.265625},{w:1,h:1,x_center:.078125,y_center:.265625},{w:1,h:1,x_center:.078125,y_center:.265625},{w:1,h:1,x_center:.109375,y_center:.265625},{w:1,h:1,x_center:.109375,y_center:.265625},{w:1,h:1,x_center:.140625,y_center:.265625},{w:1,h:1,x_center:.140625,y_center:.265625},{w:1,h:1,x_center:.171875,y_center:.265625},{w:1,h:1,x_center:.171875,y_center:.265625},{w:1,h:1,x_center:.203125,y_center:.265625},{w:1,h:1,x_center:.203125,y_center:.265625},{w:1,h:1,x_center:.234375,y_center:.265625},{w:1,h:1,x_center:.234375,y_center:.265625},{w:1,h:1,x_center:.265625,y_center:.265625},{w:1,h:1,x_center:.265625,y_center:.265625},{w:1,h:1,x_center:.296875,y_center:.265625},{w:1,h:1,x_center:.296875,y_center:.265625},{w:1,h:1,x_center:.328125,y_center:.265625},{w:1,h:1,x_center:.328125,y_center:.265625},{w:1,h:1,x_center:.359375,y_center:.265625},{w:1,h:1,x_center:.359375,y_center:.265625},{w:1,h:1,x_center:.390625,y_center:.265625},{w:1,h:1,x_center:.390625,y_center:.265625},{w:1,h:1,x_center:.421875,y_center:.265625},{w:1,h:1,x_center:.421875,y_center:.265625},{w:1,h:1,x_center:.453125,y_center:.265625},{w:1,h:1,x_center:.453125,y_center:.265625},{w:1,h:1,x_center:.484375,y_center:.265625},{w:1,h:1,x_center:.484375,y_center:.265625},{w:1,h:1,x_center:.515625,y_center:.265625},{w:1,h:1,x_center:.515625,y_center:.265625},{w:1,h:1,x_center:.546875,y_center:.265625},{w:1,h:1,x_center:.546875,y_center:.265625},{w:1,h:1,x_center:.578125,y_center:.265625},{w:1,h:1,x_center:.578125,y_center:.265625},{w:1,h:1,x_center:.609375,y_center:.265625},{w:1,h:1,x_center:.609375,y_center:.265625},{w:1,h:1,x_center:.640625,y_center:.265625},{w:1,h:1,x_center:.640625,y_center:.265625},{w:1,h:1,x_center:.671875,y_center:.265625},{w:1,h:1,x_center:.671875,y_center:.265625},{w:1,h:1,x_center:.703125,y_center:.265625},{w:1,h:1,x_center:.703125,y_center:.265625},{w:1,h:1,x_center:.734375,y_center:.265625},{w:1,h:1,x_center:.734375,y_center:.265625},{w:1,h:1,x_center:.765625,y_center:.265625},{w:1,h:1,x_center:.765625,y_center:.265625},{w:1,h:1,x_center:.796875,y_center:.265625},{w:1,h:1,x_center:.796875,y_center:.265625},{w:1,h:1,x_center:.828125,y_center:.265625},{w:1,h:1,x_center:.828125,y_center:.265625},{w:1,h:1,x_center:.859375,y_center:.265625},{w:1,h:1,x_center:.859375,y_center:.265625},{w:1,h:1,x_center:.890625,y_center:.265625},{w:1,h:1,x_center:.890625,y_center:.265625},{w:1,h:1,x_center:.921875,y_center:.265625},{w:1,h:1,x_center:.921875,y_center:.265625},{w:1,h:1,x_center:.953125,y_center:.265625},{w:1,h:1,x_center:.953125,y_center:.265625},{w:1,h:1,x_center:.984375,y_center:.265625},{w:1,h:1,x_center:.984375,y_center:.265625},{w:1,h:1,x_center:.015625,y_center:.296875},{w:1,h:1,x_center:.015625,y_center:.296875},{w:1,h:1,x_center:.046875,y_center:.296875},{w:1,h:1,x_center:.046875,y_center:.296875},{w:1,h:1,x_center:.078125,y_center:.296875},{w:1,h:1,x_center:.078125,y_center:.296875},{w:1,h:1,x_center:.109375,y_center:.296875},{w:1,h:1,x_center:.109375,y_center:.296875},{w:1,h:1,x_center:.140625,y_center:.296875},{w:1,h:1,x_center:.140625,y_center:.296875},{w:1,h:1,x_center:.171875,y_center:.296875},{w:1,h:1,x_center:.171875,y_center:.296875},{w:1,h:1,x_center:.203125,y_center:.296875},{w:1,h:1,x_center:.203125,y_center:.296875},{w:1,h:1,x_center:.234375,y_center:.296875},{w:1,h:1,x_center:.234375,y_center:.296875},{w:1,h:1,x_center:.265625,y_center:.296875},{w:1,h:1,x_center:.265625,y_center:.296875},{w:1,h:1,x_center:.296875,y_center:.296875},{w:1,h:1,x_center:.296875,y_center:.296875},{w:1,h:1,x_center:.328125,y_center:.296875},{w:1,h:1,x_center:.328125,y_center:.296875},{w:1,h:1,x_center:.359375,y_center:.296875},{w:1,h:1,x_center:.359375,y_center:.296875},{w:1,h:1,x_center:.390625,y_center:.296875},{w:1,h:1,x_center:.390625,y_center:.296875},{w:1,h:1,x_center:.421875,y_center:.296875},{w:1,h:1,x_center:.421875,y_center:.296875},{w:1,h:1,x_center:.453125,y_center:.296875},{w:1,h:1,x_center:.453125,y_center:.296875},{w:1,h:1,x_center:.484375,y_center:.296875},{w:1,h:1,x_center:.484375,y_center:.296875},{w:1,h:1,x_center:.515625,y_center:.296875},{w:1,h:1,x_center:.515625,y_center:.296875},{w:1,h:1,x_center:.546875,y_center:.296875},{w:1,h:1,x_center:.546875,y_center:.296875},{w:1,h:1,x_center:.578125,y_center:.296875},{w:1,h:1,x_center:.578125,y_center:.296875},{w:1,h:1,x_center:.609375,y_center:.296875},{w:1,h:1,x_center:.609375,y_center:.296875},{w:1,h:1,x_center:.640625,y_center:.296875},{w:1,h:1,x_center:.640625,y_center:.296875},{w:1,h:1,x_center:.671875,y_center:.296875},{w:1,h:1,x_center:.671875,y_center:.296875},{w:1,h:1,x_center:.703125,y_center:.296875},{w:1,h:1,x_center:.703125,y_center:.296875},{w:1,h:1,x_center:.734375,y_center:.296875},{w:1,h:1,x_center:.734375,y_center:.296875},{w:1,h:1,x_center:.765625,y_center:.296875},{w:1,h:1,x_center:.765625,y_center:.296875},{w:1,h:1,x_center:.796875,y_center:.296875},{w:1,h:1,x_center:.796875,y_center:.296875},{w:1,h:1,x_center:.828125,y_center:.296875},{w:1,h:1,x_center:.828125,y_center:.296875},{w:1,h:1,x_center:.859375,y_center:.296875},{w:1,h:1,x_center:.859375,y_center:.296875},{w:1,h:1,x_center:.890625,y_center:.296875},{w:1,h:1,x_center:.890625,y_center:.296875},{w:1,h:1,x_center:.921875,y_center:.296875},{w:1,h:1,x_center:.921875,y_center:.296875},{w:1,h:1,x_center:.953125,y_center:.296875},{w:1,h:1,x_center:.953125,y_center:.296875},{w:1,h:1,x_center:.984375,y_center:.296875},{w:1,h:1,x_center:.984375,y_center:.296875},{w:1,h:1,x_center:.015625,y_center:.328125},{w:1,h:1,x_center:.015625,y_center:.328125},{w:1,h:1,x_center:.046875,y_center:.328125},{w:1,h:1,x_center:.046875,y_center:.328125},{w:1,h:1,x_center:.078125,y_center:.328125},{w:1,h:1,x_center:.078125,y_center:.328125},{w:1,h:1,x_center:.109375,y_center:.328125},{w:1,h:1,x_center:.109375,y_center:.328125},{w:1,h:1,x_center:.140625,y_center:.328125},{w:1,h:1,x_center:.140625,y_center:.328125},{w:1,h:1,x_center:.171875,y_center:.328125},{w:1,h:1,x_center:.171875,y_center:.328125},{w:1,h:1,x_center:.203125,y_center:.328125},{w:1,h:1,x_center:.203125,y_center:.328125},{w:1,h:1,x_center:.234375,y_center:.328125},{w:1,h:1,x_center:.234375,y_center:.328125},{w:1,h:1,x_center:.265625,y_center:.328125},{w:1,h:1,x_center:.265625,y_center:.328125},{w:1,h:1,x_center:.296875,y_center:.328125},{w:1,h:1,x_center:.296875,y_center:.328125},{w:1,h:1,x_center:.328125,y_center:.328125},{w:1,h:1,x_center:.328125,y_center:.328125},{w:1,h:1,x_center:.359375,y_center:.328125},{w:1,h:1,x_center:.359375,y_center:.328125},{w:1,h:1,x_center:.390625,y_center:.328125},{w:1,h:1,x_center:.390625,y_center:.328125},{w:1,h:1,x_center:.421875,y_center:.328125},{w:1,h:1,x_center:.421875,y_center:.328125},{w:1,h:1,x_center:.453125,y_center:.328125},{w:1,h:1,x_center:.453125,y_center:.328125},{w:1,h:1,x_center:.484375,y_center:.328125},{w:1,h:1,x_center:.484375,y_center:.328125},{w:1,h:1,x_center:.515625,y_center:.328125},{w:1,h:1,x_center:.515625,y_center:.328125},{w:1,h:1,x_center:.546875,y_center:.328125},{w:1,h:1,x_center:.546875,y_center:.328125},{w:1,h:1,x_center:.578125,y_center:.328125},{w:1,h:1,x_center:.578125,y_center:.328125},{w:1,h:1,x_center:.609375,y_center:.328125},{w:1,h:1,x_center:.609375,y_center:.328125},{w:1,h:1,x_center:.640625,y_center:.328125},{w:1,h:1,x_center:.640625,y_center:.328125},{w:1,h:1,x_center:.671875,y_center:.328125},{w:1,h:1,x_center:.671875,y_center:.328125},{w:1,h:1,x_center:.703125,y_center:.328125},{w:1,h:1,x_center:.703125,y_center:.328125},{w:1,h:1,x_center:.734375,y_center:.328125},{w:1,h:1,x_center:.734375,y_center:.328125},{w:1,h:1,x_center:.765625,y_center:.328125},{w:1,h:1,x_center:.765625,y_center:.328125},{w:1,h:1,x_center:.796875,y_center:.328125},{w:1,h:1,x_center:.796875,y_center:.328125},{w:1,h:1,x_center:.828125,y_center:.328125},{w:1,h:1,x_center:.828125,y_center:.328125},{w:1,h:1,x_center:.859375,y_center:.328125},{w:1,h:1,x_center:.859375,y_center:.328125},{w:1,h:1,x_center:.890625,y_center:.328125},{w:1,h:1,x_center:.890625,y_center:.328125},{w:1,h:1,x_center:.921875,y_center:.328125},{w:1,h:1,x_center:.921875,y_center:.328125},{w:1,h:1,x_center:.953125,y_center:.328125},{w:1,h:1,x_center:.953125,y_center:.328125},{w:1,h:1,x_center:.984375,y_center:.328125},{w:1,h:1,x_center:.984375,y_center:.328125},{w:1,h:1,x_center:.015625,y_center:.359375},{w:1,h:1,x_center:.015625,y_center:.359375},{w:1,h:1,x_center:.046875,y_center:.359375},{w:1,h:1,x_center:.046875,y_center:.359375},{w:1,h:1,x_center:.078125,y_center:.359375},{w:1,h:1,x_center:.078125,y_center:.359375},{w:1,h:1,x_center:.109375,y_center:.359375},{w:1,h:1,x_center:.109375,y_center:.359375},{w:1,h:1,x_center:.140625,y_center:.359375},{w:1,h:1,x_center:.140625,y_center:.359375},{w:1,h:1,x_center:.171875,y_center:.359375},{w:1,h:1,x_center:.171875,y_center:.359375},{w:1,h:1,x_center:.203125,y_center:.359375},{w:1,h:1,x_center:.203125,y_center:.359375},{w:1,h:1,x_center:.234375,y_center:.359375},{w:1,h:1,x_center:.234375,y_center:.359375},{w:1,h:1,x_center:.265625,y_center:.359375},{w:1,h:1,x_center:.265625,y_center:.359375},{w:1,h:1,x_center:.296875,y_center:.359375},{w:1,h:1,x_center:.296875,y_center:.359375},{w:1,h:1,x_center:.328125,y_center:.359375},{w:1,h:1,x_center:.328125,y_center:.359375},{w:1,h:1,x_center:.359375,y_center:.359375},{w:1,h:1,x_center:.359375,y_center:.359375},{w:1,h:1,x_center:.390625,y_center:.359375},{w:1,h:1,x_center:.390625,y_center:.359375},{w:1,h:1,x_center:.421875,y_center:.359375},{w:1,h:1,x_center:.421875,y_center:.359375},{w:1,h:1,x_center:.453125,y_center:.359375},{w:1,h:1,x_center:.453125,y_center:.359375},{w:1,h:1,x_center:.484375,y_center:.359375},{w:1,h:1,x_center:.484375,y_center:.359375},{w:1,h:1,x_center:.515625,y_center:.359375},{w:1,h:1,x_center:.515625,y_center:.359375},{w:1,h:1,x_center:.546875,y_center:.359375},{w:1,h:1,x_center:.546875,y_center:.359375},{w:1,h:1,x_center:.578125,y_center:.359375},{w:1,h:1,x_center:.578125,y_center:.359375},{w:1,h:1,x_center:.609375,y_center:.359375},{w:1,h:1,x_center:.609375,y_center:.359375},{w:1,h:1,x_center:.640625,y_center:.359375},{w:1,h:1,x_center:.640625,y_center:.359375},{w:1,h:1,x_center:.671875,y_center:.359375},{w:1,h:1,x_center:.671875,y_center:.359375},{w:1,h:1,x_center:.703125,y_center:.359375},{w:1,h:1,x_center:.703125,y_center:.359375},{w:1,h:1,x_center:.734375,y_center:.359375},{w:1,h:1,x_center:.734375,y_center:.359375},{w:1,h:1,x_center:.765625,y_center:.359375},{w:1,h:1,x_center:.765625,y_center:.359375},{w:1,h:1,x_center:.796875,y_center:.359375},{w:1,h:1,x_center:.796875,y_center:.359375},{w:1,h:1,x_center:.828125,y_center:.359375},{w:1,h:1,x_center:.828125,y_center:.359375},{w:1,h:1,x_center:.859375,y_center:.359375},{w:1,h:1,x_center:.859375,y_center:.359375},{w:1,h:1,x_center:.890625,y_center:.359375},{w:1,h:1,x_center:.890625,y_center:.359375},{w:1,h:1,x_center:.921875,y_center:.359375},{w:1,h:1,x_center:.921875,y_center:.359375},{w:1,h:1,x_center:.953125,y_center:.359375},{w:1,h:1,x_center:.953125,y_center:.359375},{w:1,h:1,x_center:.984375,y_center:.359375},{w:1,h:1,x_center:.984375,y_center:.359375},{w:1,h:1,x_center:.015625,y_center:.390625},{w:1,h:1,x_center:.015625,y_center:.390625},{w:1,h:1,x_center:.046875,y_center:.390625},{w:1,h:1,x_center:.046875,y_center:.390625},{w:1,h:1,x_center:.078125,y_center:.390625},{w:1,h:1,x_center:.078125,y_center:.390625},{w:1,h:1,x_center:.109375,y_center:.390625},{w:1,h:1,x_center:.109375,y_center:.390625},{w:1,h:1,x_center:.140625,y_center:.390625},{w:1,h:1,x_center:.140625,y_center:.390625},{w:1,h:1,x_center:.171875,y_center:.390625},{w:1,h:1,x_center:.171875,y_center:.390625},{w:1,h:1,x_center:.203125,y_center:.390625},{w:1,h:1,x_center:.203125,y_center:.390625},{w:1,h:1,x_center:.234375,y_center:.390625},{w:1,h:1,x_center:.234375,y_center:.390625},{w:1,h:1,x_center:.265625,y_center:.390625},{w:1,h:1,x_center:.265625,y_center:.390625},{w:1,h:1,x_center:.296875,y_center:.390625},{w:1,h:1,x_center:.296875,y_center:.390625},{w:1,h:1,x_center:.328125,y_center:.390625},{w:1,h:1,x_center:.328125,y_center:.390625},{w:1,h:1,x_center:.359375,y_center:.390625},{w:1,h:1,x_center:.359375,y_center:.390625},{w:1,h:1,x_center:.390625,y_center:.390625},{w:1,h:1,x_center:.390625,y_center:.390625},{w:1,h:1,x_center:.421875,y_center:.390625},{w:1,h:1,x_center:.421875,y_center:.390625},{w:1,h:1,x_center:.453125,y_center:.390625},{w:1,h:1,x_center:.453125,y_center:.390625},{w:1,h:1,x_center:.484375,y_center:.390625},{w:1,h:1,x_center:.484375,y_center:.390625},{w:1,h:1,x_center:.515625,y_center:.390625},{w:1,h:1,x_center:.515625,y_center:.390625},{w:1,h:1,x_center:.546875,y_center:.390625},{w:1,h:1,x_center:.546875,y_center:.390625},{w:1,h:1,x_center:.578125,y_center:.390625},{w:1,h:1,x_center:.578125,y_center:.390625},{w:1,h:1,x_center:.609375,y_center:.390625},{w:1,h:1,x_center:.609375,y_center:.390625},{w:1,h:1,x_center:.640625,y_center:.390625},{w:1,h:1,x_center:.640625,y_center:.390625},{w:1,h:1,x_center:.671875,y_center:.390625},{w:1,h:1,x_center:.671875,y_center:.390625},{w:1,h:1,x_center:.703125,y_center:.390625},{w:1,h:1,x_center:.703125,y_center:.390625},{w:1,h:1,x_center:.734375,y_center:.390625},{w:1,h:1,x_center:.734375,y_center:.390625},{w:1,h:1,x_center:.765625,y_center:.390625},{w:1,h:1,x_center:.765625,y_center:.390625},{w:1,h:1,x_center:.796875,y_center:.390625},{w:1,h:1,x_center:.796875,y_center:.390625},{w:1,h:1,x_center:.828125,y_center:.390625},{w:1,h:1,x_center:.828125,y_center:.390625},{w:1,h:1,x_center:.859375,y_center:.390625},{w:1,h:1,x_center:.859375,y_center:.390625},{w:1,h:1,x_center:.890625,y_center:.390625},{w:1,h:1,x_center:.890625,y_center:.390625},{w:1,h:1,x_center:.921875,y_center:.390625},{w:1,h:1,x_center:.921875,y_center:.390625},{w:1,h:1,x_center:.953125,y_center:.390625},{w:1,h:1,x_center:.953125,y_center:.390625},{w:1,h:1,x_center:.984375,y_center:.390625},{w:1,h:1,x_center:.984375,y_center:.390625},{w:1,h:1,x_center:.015625,y_center:.421875},{w:1,h:1,x_center:.015625,y_center:.421875},{w:1,h:1,x_center:.046875,y_center:.421875},{w:1,h:1,x_center:.046875,y_center:.421875},{w:1,h:1,x_center:.078125,y_center:.421875},{w:1,h:1,x_center:.078125,y_center:.421875},{w:1,h:1,x_center:.109375,y_center:.421875},{w:1,h:1,x_center:.109375,y_center:.421875},{w:1,h:1,x_center:.140625,y_center:.421875},{w:1,h:1,x_center:.140625,y_center:.421875},{w:1,h:1,x_center:.171875,y_center:.421875},{w:1,h:1,x_center:.171875,y_center:.421875},{w:1,h:1,x_center:.203125,y_center:.421875},{w:1,h:1,x_center:.203125,y_center:.421875},{w:1,h:1,x_center:.234375,y_center:.421875},{w:1,h:1,x_center:.234375,y_center:.421875},{w:1,h:1,x_center:.265625,y_center:.421875},{w:1,h:1,x_center:.265625,y_center:.421875},{w:1,h:1,x_center:.296875,y_center:.421875},{w:1,h:1,x_center:.296875,y_center:.421875},{w:1,h:1,x_center:.328125,y_center:.421875},{w:1,h:1,x_center:.328125,y_center:.421875},{w:1,h:1,x_center:.359375,y_center:.421875},{w:1,h:1,x_center:.359375,y_center:.421875},{w:1,h:1,x_center:.390625,y_center:.421875},{w:1,h:1,x_center:.390625,y_center:.421875},{w:1,h:1,x_center:.421875,y_center:.421875},{w:1,h:1,x_center:.421875,y_center:.421875},{w:1,h:1,x_center:.453125,y_center:.421875},{w:1,h:1,x_center:.453125,y_center:.421875},{w:1,h:1,x_center:.484375,y_center:.421875},{w:1,h:1,x_center:.484375,y_center:.421875},{w:1,h:1,x_center:.515625,y_center:.421875},{w:1,h:1,x_center:.515625,y_center:.421875},{w:1,h:1,x_center:.546875,y_center:.421875},{w:1,h:1,x_center:.546875,y_center:.421875},{w:1,h:1,x_center:.578125,y_center:.421875},{w:1,h:1,x_center:.578125,y_center:.421875},{w:1,h:1,x_center:.609375,y_center:.421875},{w:1,h:1,x_center:.609375,y_center:.421875},{w:1,h:1,x_center:.640625,y_center:.421875},{w:1,h:1,x_center:.640625,y_center:.421875},{w:1,h:1,x_center:.671875,y_center:.421875},{w:1,h:1,x_center:.671875,y_center:.421875},{w:1,h:1,x_center:.703125,y_center:.421875},{w:1,h:1,x_center:.703125,y_center:.421875},{w:1,h:1,x_center:.734375,y_center:.421875},{w:1,h:1,x_center:.734375,y_center:.421875},{w:1,h:1,x_center:.765625,y_center:.421875},{w:1,h:1,x_center:.765625,y_center:.421875},{w:1,h:1,x_center:.796875,y_center:.421875},{w:1,h:1,x_center:.796875,y_center:.421875},{w:1,h:1,x_center:.828125,y_center:.421875},{w:1,h:1,x_center:.828125,y_center:.421875},{w:1,h:1,x_center:.859375,y_center:.421875},{w:1,h:1,x_center:.859375,y_center:.421875},{w:1,h:1,x_center:.890625,y_center:.421875},{w:1,h:1,x_center:.890625,y_center:.421875},{w:1,h:1,x_center:.921875,y_center:.421875},{w:1,h:1,x_center:.921875,y_center:.421875},{w:1,h:1,x_center:.953125,y_center:.421875},{w:1,h:1,x_center:.953125,y_center:.421875},{w:1,h:1,x_center:.984375,y_center:.421875},{w:1,h:1,x_center:.984375,y_center:.421875},{w:1,h:1,x_center:.015625,y_center:.453125},{w:1,h:1,x_center:.015625,y_center:.453125},{w:1,h:1,x_center:.046875,y_center:.453125},{w:1,h:1,x_center:.046875,y_center:.453125},{w:1,h:1,x_center:.078125,y_center:.453125},{w:1,h:1,x_center:.078125,y_center:.453125},{w:1,h:1,x_center:.109375,y_center:.453125},{w:1,h:1,x_center:.109375,y_center:.453125},{w:1,h:1,x_center:.140625,y_center:.453125},{w:1,h:1,x_center:.140625,y_center:.453125},{w:1,h:1,x_center:.171875,y_center:.453125},{w:1,h:1,x_center:.171875,y_center:.453125},{w:1,h:1,x_center:.203125,y_center:.453125},{w:1,h:1,x_center:.203125,y_center:.453125},{w:1,h:1,x_center:.234375,y_center:.453125},{w:1,h:1,x_center:.234375,y_center:.453125},{w:1,h:1,x_center:.265625,y_center:.453125},{w:1,h:1,x_center:.265625,y_center:.453125},{w:1,h:1,x_center:.296875,y_center:.453125},{w:1,h:1,x_center:.296875,y_center:.453125},{w:1,h:1,x_center:.328125,y_center:.453125},{w:1,h:1,x_center:.328125,y_center:.453125},{w:1,h:1,x_center:.359375,y_center:.453125},{w:1,h:1,x_center:.359375,y_center:.453125},{w:1,h:1,x_center:.390625,y_center:.453125},{w:1,h:1,x_center:.390625,y_center:.453125},{w:1,h:1,x_center:.421875,y_center:.453125},{w:1,h:1,x_center:.421875,y_center:.453125},{w:1,h:1,x_center:.453125,y_center:.453125},{w:1,h:1,x_center:.453125,y_center:.453125},{w:1,h:1,x_center:.484375,y_center:.453125},{w:1,h:1,x_center:.484375,y_center:.453125},{w:1,h:1,x_center:.515625,y_center:.453125},{w:1,h:1,x_center:.515625,y_center:.453125},{w:1,h:1,x_center:.546875,y_center:.453125},{w:1,h:1,x_center:.546875,y_center:.453125},{w:1,h:1,x_center:.578125,y_center:.453125},{w:1,h:1,x_center:.578125,y_center:.453125},{w:1,h:1,x_center:.609375,y_center:.453125},{w:1,h:1,x_center:.609375,y_center:.453125},{w:1,h:1,x_center:.640625,y_center:.453125},{w:1,h:1,x_center:.640625,y_center:.453125},{w:1,h:1,x_center:.671875,y_center:.453125},{w:1,h:1,x_center:.671875,y_center:.453125},{w:1,h:1,x_center:.703125,y_center:.453125},{w:1,h:1,x_center:.703125,y_center:.453125},{w:1,h:1,x_center:.734375,y_center:.453125},{w:1,h:1,x_center:.734375,y_center:.453125},{w:1,h:1,x_center:.765625,y_center:.453125},{w:1,h:1,x_center:.765625,y_center:.453125},{w:1,h:1,x_center:.796875,y_center:.453125},{w:1,h:1,x_center:.796875,y_center:.453125},{w:1,h:1,x_center:.828125,y_center:.453125},{w:1,h:1,x_center:.828125,y_center:.453125},{w:1,h:1,x_center:.859375,y_center:.453125},{w:1,h:1,x_center:.859375,y_center:.453125},{w:1,h:1,x_center:.890625,y_center:.453125},{w:1,h:1,x_center:.890625,y_center:.453125},{w:1,h:1,x_center:.921875,y_center:.453125},{w:1,h:1,x_center:.921875,y_center:.453125},{w:1,h:1,x_center:.953125,y_center:.453125},{w:1,h:1,x_center:.953125,y_center:.453125},{w:1,h:1,x_center:.984375,y_center:.453125},{w:1,h:1,x_center:.984375,y_center:.453125},{w:1,h:1,x_center:.015625,y_center:.484375},{w:1,h:1,x_center:.015625,y_center:.484375},{w:1,h:1,x_center:.046875,y_center:.484375},{w:1,h:1,x_center:.046875,y_center:.484375},{w:1,h:1,x_center:.078125,y_center:.484375},{w:1,h:1,x_center:.078125,y_center:.484375},{w:1,h:1,x_center:.109375,y_center:.484375},{w:1,h:1,x_center:.109375,y_center:.484375},{w:1,h:1,x_center:.140625,y_center:.484375},{w:1,h:1,x_center:.140625,y_center:.484375},{w:1,h:1,x_center:.171875,y_center:.484375},{w:1,h:1,x_center:.171875,y_center:.484375},{w:1,h:1,x_center:.203125,y_center:.484375},{w:1,h:1,x_center:.203125,y_center:.484375},{w:1,h:1,x_center:.234375,y_center:.484375},{w:1,h:1,x_center:.234375,y_center:.484375},{w:1,h:1,x_center:.265625,y_center:.484375},{w:1,h:1,x_center:.265625,y_center:.484375},{w:1,h:1,x_center:.296875,y_center:.484375},{w:1,h:1,x_center:.296875,y_center:.484375},{w:1,h:1,x_center:.328125,y_center:.484375},{w:1,h:1,x_center:.328125,y_center:.484375},{w:1,h:1,x_center:.359375,y_center:.484375},{w:1,h:1,x_center:.359375,y_center:.484375},{w:1,h:1,x_center:.390625,y_center:.484375},{w:1,h:1,x_center:.390625,y_center:.484375},{w:1,h:1,x_center:.421875,y_center:.484375},{w:1,h:1,x_center:.421875,y_center:.484375},{w:1,h:1,x_center:.453125,y_center:.484375},{w:1,h:1,x_center:.453125,y_center:.484375},{w:1,h:1,x_center:.484375,y_center:.484375},{w:1,h:1,x_center:.484375,y_center:.484375},{w:1,h:1,x_center:.515625,y_center:.484375},{w:1,h:1,x_center:.515625,y_center:.484375},{w:1,h:1,x_center:.546875,y_center:.484375},{w:1,h:1,x_center:.546875,y_center:.484375},{w:1,h:1,x_center:.578125,y_center:.484375},{w:1,h:1,x_center:.578125,y_center:.484375},{w:1,h:1,x_center:.609375,y_center:.484375},{w:1,h:1,x_center:.609375,y_center:.484375},{w:1,h:1,x_center:.640625,y_center:.484375},{w:1,h:1,x_center:.640625,y_center:.484375},{w:1,h:1,x_center:.671875,y_center:.484375},{w:1,h:1,x_center:.671875,y_center:.484375},{w:1,h:1,x_center:.703125,y_center:.484375},{w:1,h:1,x_center:.703125,y_center:.484375},{w:1,h:1,x_center:.734375,y_center:.484375},{w:1,h:1,x_center:.734375,y_center:.484375},{w:1,h:1,x_center:.765625,y_center:.484375},{w:1,h:1,x_center:.765625,y_center:.484375},{w:1,h:1,x_center:.796875,y_center:.484375},{w:1,h:1,x_center:.796875,y_center:.484375},{w:1,h:1,x_center:.828125,y_center:.484375},{w:1,h:1,x_center:.828125,y_center:.484375},{w:1,h:1,x_center:.859375,y_center:.484375},{w:1,h:1,x_center:.859375,y_center:.484375},{w:1,h:1,x_center:.890625,y_center:.484375},{w:1,h:1,x_center:.890625,y_center:.484375},{w:1,h:1,x_center:.921875,y_center:.484375},{w:1,h:1,x_center:.921875,y_center:.484375},{w:1,h:1,x_center:.953125,y_center:.484375},{w:1,h:1,x_center:.953125,y_center:.484375},{w:1,h:1,x_center:.984375,y_center:.484375},{w:1,h:1,x_center:.984375,y_center:.484375},{w:1,h:1,x_center:.015625,y_center:.515625},{w:1,h:1,x_center:.015625,y_center:.515625},{w:1,h:1,x_center:.046875,y_center:.515625},{w:1,h:1,x_center:.046875,y_center:.515625},{w:1,h:1,x_center:.078125,y_center:.515625},{w:1,h:1,x_center:.078125,y_center:.515625},{w:1,h:1,x_center:.109375,y_center:.515625},{w:1,h:1,x_center:.109375,y_center:.515625},{w:1,h:1,x_center:.140625,y_center:.515625},{w:1,h:1,x_center:.140625,y_center:.515625},{w:1,h:1,x_center:.171875,y_center:.515625},{w:1,h:1,x_center:.171875,y_center:.515625},{w:1,h:1,x_center:.203125,y_center:.515625},{w:1,h:1,x_center:.203125,y_center:.515625},{w:1,h:1,x_center:.234375,y_center:.515625},{w:1,h:1,x_center:.234375,y_center:.515625},{w:1,h:1,x_center:.265625,y_center:.515625},{w:1,h:1,x_center:.265625,y_center:.515625},{w:1,h:1,x_center:.296875,y_center:.515625},{w:1,h:1,x_center:.296875,y_center:.515625},{w:1,h:1,x_center:.328125,y_center:.515625},{w:1,h:1,x_center:.328125,y_center:.515625},{w:1,h:1,x_center:.359375,y_center:.515625},{w:1,h:1,x_center:.359375,y_center:.515625},{w:1,h:1,x_center:.390625,y_center:.515625},{w:1,h:1,x_center:.390625,y_center:.515625},{w:1,h:1,x_center:.421875,y_center:.515625},{w:1,h:1,x_center:.421875,y_center:.515625},{w:1,h:1,x_center:.453125,y_center:.515625},{w:1,h:1,x_center:.453125,y_center:.515625},{w:1,h:1,x_center:.484375,y_center:.515625},{w:1,h:1,x_center:.484375,y_center:.515625},{w:1,h:1,x_center:.515625,y_center:.515625},{w:1,h:1,x_center:.515625,y_center:.515625},{w:1,h:1,x_center:.546875,y_center:.515625},{w:1,h:1,x_center:.546875,y_center:.515625},{w:1,h:1,x_center:.578125,y_center:.515625},{w:1,h:1,x_center:.578125,y_center:.515625},{w:1,h:1,x_center:.609375,y_center:.515625},{w:1,h:1,x_center:.609375,y_center:.515625},{w:1,h:1,x_center:.640625,y_center:.515625},{w:1,h:1,x_center:.640625,y_center:.515625},{w:1,h:1,x_center:.671875,y_center:.515625},{w:1,h:1,x_center:.671875,y_center:.515625},{w:1,h:1,x_center:.703125,y_center:.515625},{w:1,h:1,x_center:.703125,y_center:.515625},{w:1,h:1,x_center:.734375,y_center:.515625},{w:1,h:1,x_center:.734375,y_center:.515625},{w:1,h:1,x_center:.765625,y_center:.515625},{w:1,h:1,x_center:.765625,y_center:.515625},{w:1,h:1,x_center:.796875,y_center:.515625},{w:1,h:1,x_center:.796875,y_center:.515625},{w:1,h:1,x_center:.828125,y_center:.515625},{w:1,h:1,x_center:.828125,y_center:.515625},{w:1,h:1,x_center:.859375,y_center:.515625},{w:1,h:1,x_center:.859375,y_center:.515625},{w:1,h:1,x_center:.890625,y_center:.515625},{w:1,h:1,x_center:.890625,y_center:.515625},{w:1,h:1,x_center:.921875,y_center:.515625},{w:1,h:1,x_center:.921875,y_center:.515625},{w:1,h:1,x_center:.953125,y_center:.515625},{w:1,h:1,x_center:.953125,y_center:.515625},{w:1,h:1,x_center:.984375,y_center:.515625},{w:1,h:1,x_center:.984375,y_center:.515625},{w:1,h:1,x_center:.015625,y_center:.546875},{w:1,h:1,x_center:.015625,y_center:.546875},{w:1,h:1,x_center:.046875,y_center:.546875},{w:1,h:1,x_center:.046875,y_center:.546875},{w:1,h:1,x_center:.078125,y_center:.546875},{w:1,h:1,x_center:.078125,y_center:.546875},{w:1,h:1,x_center:.109375,y_center:.546875},{w:1,h:1,x_center:.109375,y_center:.546875},{w:1,h:1,x_center:.140625,y_center:.546875},{w:1,h:1,x_center:.140625,y_center:.546875},{w:1,h:1,x_center:.171875,y_center:.546875},{w:1,h:1,x_center:.171875,y_center:.546875},{w:1,h:1,x_center:.203125,y_center:.546875},{w:1,h:1,x_center:.203125,y_center:.546875},{w:1,h:1,x_center:.234375,y_center:.546875},{w:1,h:1,x_center:.234375,y_center:.546875},{w:1,h:1,x_center:.265625,y_center:.546875},{w:1,h:1,x_center:.265625,y_center:.546875},{w:1,h:1,x_center:.296875,y_center:.546875},{w:1,h:1,x_center:.296875,y_center:.546875},{w:1,h:1,x_center:.328125,y_center:.546875},{w:1,h:1,x_center:.328125,y_center:.546875},{w:1,h:1,x_center:.359375,y_center:.546875},{w:1,h:1,x_center:.359375,y_center:.546875},{w:1,h:1,x_center:.390625,y_center:.546875},{w:1,h:1,x_center:.390625,y_center:.546875},{w:1,h:1,x_center:.421875,y_center:.546875},{w:1,h:1,x_center:.421875,y_center:.546875},{w:1,h:1,x_center:.453125,y_center:.546875},{w:1,h:1,x_center:.453125,y_center:.546875},{w:1,h:1,x_center:.484375,y_center:.546875},{w:1,h:1,x_center:.484375,y_center:.546875},{w:1,h:1,x_center:.515625,y_center:.546875},{w:1,h:1,x_center:.515625,y_center:.546875},{w:1,h:1,x_center:.546875,y_center:.546875},{w:1,h:1,x_center:.546875,y_center:.546875},{w:1,h:1,x_center:.578125,y_center:.546875},{w:1,h:1,x_center:.578125,y_center:.546875},{w:1,h:1,x_center:.609375,y_center:.546875},{w:1,h:1,x_center:.609375,y_center:.546875},{w:1,h:1,x_center:.640625,y_center:.546875},{w:1,h:1,x_center:.640625,y_center:.546875},{w:1,h:1,x_center:.671875,y_center:.546875},{w:1,h:1,x_center:.671875,y_center:.546875},{w:1,h:1,x_center:.703125,y_center:.546875},{w:1,h:1,x_center:.703125,y_center:.546875},{w:1,h:1,x_center:.734375,y_center:.546875},{w:1,h:1,x_center:.734375,y_center:.546875},{w:1,h:1,x_center:.765625,y_center:.546875},{w:1,h:1,x_center:.765625,y_center:.546875},{w:1,h:1,x_center:.796875,y_center:.546875},{w:1,h:1,x_center:.796875,y_center:.546875},{w:1,h:1,x_center:.828125,y_center:.546875},{w:1,h:1,x_center:.828125,y_center:.546875},{w:1,h:1,x_center:.859375,y_center:.546875},{w:1,h:1,x_center:.859375,y_center:.546875},{w:1,h:1,x_center:.890625,y_center:.546875},{w:1,h:1,x_center:.890625,y_center:.546875},{w:1,h:1,x_center:.921875,y_center:.546875},{w:1,h:1,x_center:.921875,y_center:.546875},{w:1,h:1,x_center:.953125,y_center:.546875},{w:1,h:1,x_center:.953125,y_center:.546875},{w:1,h:1,x_center:.984375,y_center:.546875},{w:1,h:1,x_center:.984375,y_center:.546875},{w:1,h:1,x_center:.015625,y_center:.578125},{w:1,h:1,x_center:.015625,y_center:.578125},{w:1,h:1,x_center:.046875,y_center:.578125},{w:1,h:1,x_center:.046875,y_center:.578125},{w:1,h:1,x_center:.078125,y_center:.578125},{w:1,h:1,x_center:.078125,y_center:.578125},{w:1,h:1,x_center:.109375,y_center:.578125},{w:1,h:1,x_center:.109375,y_center:.578125},{w:1,h:1,x_center:.140625,y_center:.578125},{w:1,h:1,x_center:.140625,y_center:.578125},{w:1,h:1,x_center:.171875,y_center:.578125},{w:1,h:1,x_center:.171875,y_center:.578125},{w:1,h:1,x_center:.203125,y_center:.578125},{w:1,h:1,x_center:.203125,y_center:.578125},{w:1,h:1,x_center:.234375,y_center:.578125},{w:1,h:1,x_center:.234375,y_center:.578125},{w:1,h:1,x_center:.265625,y_center:.578125},{w:1,h:1,x_center:.265625,y_center:.578125},{w:1,h:1,x_center:.296875,y_center:.578125},{w:1,h:1,x_center:.296875,y_center:.578125},{w:1,h:1,x_center:.328125,y_center:.578125},{w:1,h:1,x_center:.328125,y_center:.578125},{w:1,h:1,x_center:.359375,y_center:.578125},{w:1,h:1,x_center:.359375,y_center:.578125},{w:1,h:1,x_center:.390625,y_center:.578125},{w:1,h:1,x_center:.390625,y_center:.578125},{w:1,h:1,x_center:.421875,y_center:.578125},{w:1,h:1,x_center:.421875,y_center:.578125},{w:1,h:1,x_center:.453125,y_center:.578125},{w:1,h:1,x_center:.453125,y_center:.578125},{w:1,h:1,x_center:.484375,y_center:.578125},{w:1,h:1,x_center:.484375,y_center:.578125},{w:1,h:1,x_center:.515625,y_center:.578125},{w:1,h:1,x_center:.515625,y_center:.578125},{w:1,h:1,x_center:.546875,y_center:.578125},{w:1,h:1,x_center:.546875,y_center:.578125},{w:1,h:1,x_center:.578125,y_center:.578125},{w:1,h:1,x_center:.578125,y_center:.578125},{w:1,h:1,x_center:.609375,y_center:.578125},{w:1,h:1,x_center:.609375,y_center:.578125},{w:1,h:1,x_center:.640625,y_center:.578125},{w:1,h:1,x_center:.640625,y_center:.578125},{w:1,h:1,x_center:.671875,y_center:.578125},{w:1,h:1,x_center:.671875,y_center:.578125},{w:1,h:1,x_center:.703125,y_center:.578125},{w:1,h:1,x_center:.703125,y_center:.578125},{w:1,h:1,x_center:.734375,y_center:.578125},{w:1,h:1,x_center:.734375,y_center:.578125},{w:1,h:1,x_center:.765625,y_center:.578125},{w:1,h:1,x_center:.765625,y_center:.578125},{w:1,h:1,x_center:.796875,y_center:.578125},{w:1,h:1,x_center:.796875,y_center:.578125},{w:1,h:1,x_center:.828125,y_center:.578125},{w:1,h:1,x_center:.828125,y_center:.578125},{w:1,h:1,x_center:.859375,y_center:.578125},{w:1,h:1,x_center:.859375,y_center:.578125},{w:1,h:1,x_center:.890625,y_center:.578125},{w:1,h:1,x_center:.890625,y_center:.578125},{w:1,h:1,x_center:.921875,y_center:.578125},{w:1,h:1,x_center:.921875,y_center:.578125},{w:1,h:1,x_center:.953125,y_center:.578125},{w:1,h:1,x_center:.953125,y_center:.578125},{w:1,h:1,x_center:.984375,y_center:.578125},{w:1,h:1,x_center:.984375,y_center:.578125},{w:1,h:1,x_center:.015625,y_center:.609375},{w:1,h:1,x_center:.015625,y_center:.609375},{w:1,h:1,x_center:.046875,y_center:.609375},{w:1,h:1,x_center:.046875,y_center:.609375},{w:1,h:1,x_center:.078125,y_center:.609375},{w:1,h:1,x_center:.078125,y_center:.609375},{w:1,h:1,x_center:.109375,y_center:.609375},{w:1,h:1,x_center:.109375,y_center:.609375},{w:1,h:1,x_center:.140625,y_center:.609375},{w:1,h:1,x_center:.140625,y_center:.609375},{w:1,h:1,x_center:.171875,y_center:.609375},{w:1,h:1,x_center:.171875,y_center:.609375},{w:1,h:1,x_center:.203125,y_center:.609375},{w:1,h:1,x_center:.203125,y_center:.609375},{w:1,h:1,x_center:.234375,y_center:.609375},{w:1,h:1,x_center:.234375,y_center:.609375},{w:1,h:1,x_center:.265625,y_center:.609375},{w:1,h:1,x_center:.265625,y_center:.609375},{w:1,h:1,x_center:.296875,y_center:.609375},{w:1,h:1,x_center:.296875,y_center:.609375},{w:1,h:1,x_center:.328125,y_center:.609375},{w:1,h:1,x_center:.328125,y_center:.609375},{w:1,h:1,x_center:.359375,y_center:.609375},{w:1,h:1,x_center:.359375,y_center:.609375},{w:1,h:1,x_center:.390625,y_center:.609375},{w:1,h:1,x_center:.390625,y_center:.609375},{w:1,h:1,x_center:.421875,y_center:.609375},{w:1,h:1,x_center:.421875,y_center:.609375},{w:1,h:1,x_center:.453125,y_center:.609375},{w:1,h:1,x_center:.453125,y_center:.609375},{w:1,h:1,x_center:.484375,y_center:.609375},{w:1,h:1,x_center:.484375,y_center:.609375},{w:1,h:1,x_center:.515625,y_center:.609375},{w:1,h:1,x_center:.515625,y_center:.609375},{w:1,h:1,x_center:.546875,y_center:.609375},{w:1,h:1,x_center:.546875,y_center:.609375},{w:1,h:1,x_center:.578125,y_center:.609375},{w:1,h:1,x_center:.578125,y_center:.609375},{w:1,h:1,x_center:.609375,y_center:.609375},{w:1,h:1,x_center:.609375,y_center:.609375},{w:1,h:1,x_center:.640625,y_center:.609375},{w:1,h:1,x_center:.640625,y_center:.609375},{w:1,h:1,x_center:.671875,y_center:.609375},{w:1,h:1,x_center:.671875,y_center:.609375},{w:1,h:1,x_center:.703125,y_center:.609375},{w:1,h:1,x_center:.703125,y_center:.609375},{w:1,h:1,x_center:.734375,y_center:.609375},{w:1,h:1,x_center:.734375,y_center:.609375},{w:1,h:1,x_center:.765625,y_center:.609375},{w:1,h:1,x_center:.765625,y_center:.609375},{w:1,h:1,x_center:.796875,y_center:.609375},{w:1,h:1,x_center:.796875,y_center:.609375},{w:1,h:1,x_center:.828125,y_center:.609375},{w:1,h:1,x_center:.828125,y_center:.609375},{w:1,h:1,x_center:.859375,y_center:.609375},{w:1,h:1,x_center:.859375,y_center:.609375},{w:1,h:1,x_center:.890625,y_center:.609375},{w:1,h:1,x_center:.890625,y_center:.609375},{w:1,h:1,x_center:.921875,y_center:.609375},{w:1,h:1,x_center:.921875,y_center:.609375},{w:1,h:1,x_center:.953125,y_center:.609375},{w:1,h:1,x_center:.953125,y_center:.609375},{w:1,h:1,x_center:.984375,y_center:.609375},{w:1,h:1,x_center:.984375,y_center:.609375},{w:1,h:1,x_center:.015625,y_center:.640625},{w:1,h:1,x_center:.015625,y_center:.640625},{w:1,h:1,x_center:.046875,y_center:.640625},{w:1,h:1,x_center:.046875,y_center:.640625},{w:1,h:1,x_center:.078125,y_center:.640625},{w:1,h:1,x_center:.078125,y_center:.640625},{w:1,h:1,x_center:.109375,y_center:.640625},{w:1,h:1,x_center:.109375,y_center:.640625},{w:1,h:1,x_center:.140625,y_center:.640625},{w:1,h:1,x_center:.140625,y_center:.640625},{w:1,h:1,x_center:.171875,y_center:.640625},{w:1,h:1,x_center:.171875,y_center:.640625},{w:1,h:1,x_center:.203125,y_center:.640625},{w:1,h:1,x_center:.203125,y_center:.640625},{w:1,h:1,x_center:.234375,y_center:.640625},{w:1,h:1,x_center:.234375,y_center:.640625},{w:1,h:1,x_center:.265625,y_center:.640625},{w:1,h:1,x_center:.265625,y_center:.640625},{w:1,h:1,x_center:.296875,y_center:.640625},{w:1,h:1,x_center:.296875,y_center:.640625},{w:1,h:1,x_center:.328125,y_center:.640625},{w:1,h:1,x_center:.328125,y_center:.640625},{w:1,h:1,x_center:.359375,y_center:.640625},{w:1,h:1,x_center:.359375,y_center:.640625},{w:1,h:1,x_center:.390625,y_center:.640625},{w:1,h:1,x_center:.390625,y_center:.640625},{w:1,h:1,x_center:.421875,y_center:.640625},{w:1,h:1,x_center:.421875,y_center:.640625},{w:1,h:1,x_center:.453125,y_center:.640625},{w:1,h:1,x_center:.453125,y_center:.640625},{w:1,h:1,x_center:.484375,y_center:.640625},{w:1,h:1,x_center:.484375,y_center:.640625},{w:1,h:1,x_center:.515625,y_center:.640625},{w:1,h:1,x_center:.515625,y_center:.640625},{w:1,h:1,x_center:.546875,y_center:.640625},{w:1,h:1,x_center:.546875,y_center:.640625},{w:1,h:1,x_center:.578125,y_center:.640625},{w:1,h:1,x_center:.578125,y_center:.640625},{w:1,h:1,x_center:.609375,y_center:.640625},{w:1,h:1,x_center:.609375,y_center:.640625},{w:1,h:1,x_center:.640625,y_center:.640625},{w:1,h:1,x_center:.640625,y_center:.640625},{w:1,h:1,x_center:.671875,y_center:.640625},{w:1,h:1,x_center:.671875,y_center:.640625},{w:1,h:1,x_center:.703125,y_center:.640625},{w:1,h:1,x_center:.703125,y_center:.640625},{w:1,h:1,x_center:.734375,y_center:.640625},{w:1,h:1,x_center:.734375,y_center:.640625},{w:1,h:1,x_center:.765625,y_center:.640625},{w:1,h:1,x_center:.765625,y_center:.640625},{w:1,h:1,x_center:.796875,y_center:.640625},{w:1,h:1,x_center:.796875,y_center:.640625},{w:1,h:1,x_center:.828125,y_center:.640625},{w:1,h:1,x_center:.828125,y_center:.640625},{w:1,h:1,x_center:.859375,y_center:.640625},{w:1,h:1,x_center:.859375,y_center:.640625},{w:1,h:1,x_center:.890625,y_center:.640625},{w:1,h:1,x_center:.890625,y_center:.640625},{w:1,h:1,x_center:.921875,y_center:.640625},{w:1,h:1,x_center:.921875,y_center:.640625},{w:1,h:1,x_center:.953125,y_center:.640625},{w:1,h:1,x_center:.953125,y_center:.640625},{w:1,h:1,x_center:.984375,y_center:.640625},{w:1,h:1,x_center:.984375,y_center:.640625},{w:1,h:1,x_center:.015625,y_center:.671875},{w:1,h:1,x_center:.015625,y_center:.671875},{w:1,h:1,x_center:.046875,y_center:.671875},{w:1,h:1,x_center:.046875,y_center:.671875},{w:1,h:1,x_center:.078125,y_center:.671875},{w:1,h:1,x_center:.078125,y_center:.671875},{w:1,h:1,x_center:.109375,y_center:.671875},{w:1,h:1,x_center:.109375,y_center:.671875},{w:1,h:1,x_center:.140625,y_center:.671875},{w:1,h:1,x_center:.140625,y_center:.671875},{w:1,h:1,x_center:.171875,y_center:.671875},{w:1,h:1,x_center:.171875,y_center:.671875},{w:1,h:1,x_center:.203125,y_center:.671875},{w:1,h:1,x_center:.203125,y_center:.671875},{w:1,h:1,x_center:.234375,y_center:.671875},{w:1,h:1,x_center:.234375,y_center:.671875},{w:1,h:1,x_center:.265625,y_center:.671875},{w:1,h:1,x_center:.265625,y_center:.671875},{w:1,h:1,x_center:.296875,y_center:.671875},{w:1,h:1,x_center:.296875,y_center:.671875},{w:1,h:1,x_center:.328125,y_center:.671875},{w:1,h:1,x_center:.328125,y_center:.671875},{w:1,h:1,x_center:.359375,y_center:.671875},{w:1,h:1,x_center:.359375,y_center:.671875},{w:1,h:1,x_center:.390625,y_center:.671875},{w:1,h:1,x_center:.390625,y_center:.671875},{w:1,h:1,x_center:.421875,y_center:.671875},{w:1,h:1,x_center:.421875,y_center:.671875},{w:1,h:1,x_center:.453125,y_center:.671875},{w:1,h:1,x_center:.453125,y_center:.671875},{w:1,h:1,x_center:.484375,y_center:.671875},{w:1,h:1,x_center:.484375,y_center:.671875},{w:1,h:1,x_center:.515625,y_center:.671875},{w:1,h:1,x_center:.515625,y_center:.671875},{w:1,h:1,x_center:.546875,y_center:.671875},{w:1,h:1,x_center:.546875,y_center:.671875},{w:1,h:1,x_center:.578125,y_center:.671875},{w:1,h:1,x_center:.578125,y_center:.671875},{w:1,h:1,x_center:.609375,y_center:.671875},{w:1,h:1,x_center:.609375,y_center:.671875},{w:1,h:1,x_center:.640625,y_center:.671875},{w:1,h:1,x_center:.640625,y_center:.671875},{w:1,h:1,x_center:.671875,y_center:.671875},{w:1,h:1,x_center:.671875,y_center:.671875},{w:1,h:1,x_center:.703125,y_center:.671875},{w:1,h:1,x_center:.703125,y_center:.671875},{w:1,h:1,x_center:.734375,y_center:.671875},{w:1,h:1,x_center:.734375,y_center:.671875},{w:1,h:1,x_center:.765625,y_center:.671875},{w:1,h:1,x_center:.765625,y_center:.671875},{w:1,h:1,x_center:.796875,y_center:.671875},{w:1,h:1,x_center:.796875,y_center:.671875},{w:1,h:1,x_center:.828125,y_center:.671875},{w:1,h:1,x_center:.828125,y_center:.671875},{w:1,h:1,x_center:.859375,y_center:.671875},{w:1,h:1,x_center:.859375,y_center:.671875},{w:1,h:1,x_center:.890625,y_center:.671875},{w:1,h:1,x_center:.890625,y_center:.671875},{w:1,h:1,x_center:.921875,y_center:.671875},{w:1,h:1,x_center:.921875,y_center:.671875},{w:1,h:1,x_center:.953125,y_center:.671875},{w:1,h:1,x_center:.953125,y_center:.671875},{w:1,h:1,x_center:.984375,y_center:.671875},{w:1,h:1,x_center:.984375,y_center:.671875},{w:1,h:1,x_center:.015625,y_center:.703125},{w:1,h:1,x_center:.015625,y_center:.703125},{w:1,h:1,x_center:.046875,y_center:.703125},{w:1,h:1,x_center:.046875,y_center:.703125},{w:1,h:1,x_center:.078125,y_center:.703125},{w:1,h:1,x_center:.078125,y_center:.703125},{w:1,h:1,x_center:.109375,y_center:.703125},{w:1,h:1,x_center:.109375,y_center:.703125},{w:1,h:1,x_center:.140625,y_center:.703125},{w:1,h:1,x_center:.140625,y_center:.703125},{w:1,h:1,x_center:.171875,y_center:.703125},{w:1,h:1,x_center:.171875,y_center:.703125},{w:1,h:1,x_center:.203125,y_center:.703125},{w:1,h:1,x_center:.203125,y_center:.703125},{w:1,h:1,x_center:.234375,y_center:.703125},{w:1,h:1,x_center:.234375,y_center:.703125},{w:1,h:1,x_center:.265625,y_center:.703125},{w:1,h:1,x_center:.265625,y_center:.703125},{w:1,h:1,x_center:.296875,y_center:.703125},{w:1,h:1,x_center:.296875,y_center:.703125},{w:1,h:1,x_center:.328125,y_center:.703125},{w:1,h:1,x_center:.328125,y_center:.703125},{w:1,h:1,x_center:.359375,y_center:.703125},{w:1,h:1,x_center:.359375,y_center:.703125},{w:1,h:1,x_center:.390625,y_center:.703125},{w:1,h:1,x_center:.390625,y_center:.703125},{w:1,h:1,x_center:.421875,y_center:.703125},{w:1,h:1,x_center:.421875,y_center:.703125},{w:1,h:1,x_center:.453125,y_center:.703125},{w:1,h:1,x_center:.453125,y_center:.703125},{w:1,h:1,x_center:.484375,y_center:.703125},{w:1,h:1,x_center:.484375,y_center:.703125},{w:1,h:1,x_center:.515625,y_center:.703125},{w:1,h:1,x_center:.515625,y_center:.703125},{w:1,h:1,x_center:.546875,y_center:.703125},{w:1,h:1,x_center:.546875,y_center:.703125},{w:1,h:1,x_center:.578125,y_center:.703125},{w:1,h:1,x_center:.578125,y_center:.703125},{w:1,h:1,x_center:.609375,y_center:.703125},{w:1,h:1,x_center:.609375,y_center:.703125},{w:1,h:1,x_center:.640625,y_center:.703125},{w:1,h:1,x_center:.640625,y_center:.703125},{w:1,h:1,x_center:.671875,y_center:.703125},{w:1,h:1,x_center:.671875,y_center:.703125},{w:1,h:1,x_center:.703125,y_center:.703125},{w:1,h:1,x_center:.703125,y_center:.703125},{w:1,h:1,x_center:.734375,y_center:.703125},{w:1,h:1,x_center:.734375,y_center:.703125},{w:1,h:1,x_center:.765625,y_center:.703125},{w:1,h:1,x_center:.765625,y_center:.703125},{w:1,h:1,x_center:.796875,y_center:.703125},{w:1,h:1,x_center:.796875,y_center:.703125},{w:1,h:1,x_center:.828125,y_center:.703125},{w:1,h:1,x_center:.828125,y_center:.703125},{w:1,h:1,x_center:.859375,y_center:.703125},{w:1,h:1,x_center:.859375,y_center:.703125},{w:1,h:1,x_center:.890625,y_center:.703125},{w:1,h:1,x_center:.890625,y_center:.703125},{w:1,h:1,x_center:.921875,y_center:.703125},{w:1,h:1,x_center:.921875,y_center:.703125},{w:1,h:1,x_center:.953125,y_center:.703125},{w:1,h:1,x_center:.953125,y_center:.703125},{w:1,h:1,x_center:.984375,y_center:.703125},{w:1,h:1,x_center:.984375,y_center:.703125},{w:1,h:1,x_center:.015625,y_center:.734375},{w:1,h:1,x_center:.015625,y_center:.734375},{w:1,h:1,x_center:.046875,y_center:.734375},{w:1,h:1,x_center:.046875,y_center:.734375},{w:1,h:1,x_center:.078125,y_center:.734375},{w:1,h:1,x_center:.078125,y_center:.734375},{w:1,h:1,x_center:.109375,y_center:.734375},{w:1,h:1,x_center:.109375,y_center:.734375},{w:1,h:1,x_center:.140625,y_center:.734375},{w:1,h:1,x_center:.140625,y_center:.734375},{w:1,h:1,x_center:.171875,y_center:.734375},{w:1,h:1,x_center:.171875,y_center:.734375},{w:1,h:1,x_center:.203125,y_center:.734375},{w:1,h:1,x_center:.203125,y_center:.734375},{w:1,h:1,x_center:.234375,y_center:.734375},{w:1,h:1,x_center:.234375,y_center:.734375},{w:1,h:1,x_center:.265625,y_center:.734375},{w:1,h:1,x_center:.265625,y_center:.734375},{w:1,h:1,x_center:.296875,y_center:.734375},{w:1,h:1,x_center:.296875,y_center:.734375},{w:1,h:1,x_center:.328125,y_center:.734375},{w:1,h:1,x_center:.328125,y_center:.734375},{w:1,h:1,x_center:.359375,y_center:.734375},{w:1,h:1,x_center:.359375,y_center:.734375},{w:1,h:1,x_center:.390625,y_center:.734375},{w:1,h:1,x_center:.390625,y_center:.734375},{w:1,h:1,x_center:.421875,y_center:.734375},{w:1,h:1,x_center:.421875,y_center:.734375},{w:1,h:1,x_center:.453125,y_center:.734375},{w:1,h:1,x_center:.453125,y_center:.734375},{w:1,h:1,x_center:.484375,y_center:.734375},{w:1,h:1,x_center:.484375,y_center:.734375},{w:1,h:1,x_center:.515625,y_center:.734375},{w:1,h:1,x_center:.515625,y_center:.734375},{w:1,h:1,x_center:.546875,y_center:.734375},{w:1,h:1,x_center:.546875,y_center:.734375},{w:1,h:1,x_center:.578125,y_center:.734375},{w:1,h:1,x_center:.578125,y_center:.734375},{w:1,h:1,x_center:.609375,y_center:.734375},{w:1,h:1,x_center:.609375,y_center:.734375},{w:1,h:1,x_center:.640625,y_center:.734375},{w:1,h:1,x_center:.640625,y_center:.734375},{w:1,h:1,x_center:.671875,y_center:.734375},{w:1,h:1,x_center:.671875,y_center:.734375},{w:1,h:1,x_center:.703125,y_center:.734375},{w:1,h:1,x_center:.703125,y_center:.734375},{w:1,h:1,x_center:.734375,y_center:.734375},{w:1,h:1,x_center:.734375,y_center:.734375},{w:1,h:1,x_center:.765625,y_center:.734375},{w:1,h:1,x_center:.765625,y_center:.734375},{w:1,h:1,x_center:.796875,y_center:.734375},{w:1,h:1,x_center:.796875,y_center:.734375},{w:1,h:1,x_center:.828125,y_center:.734375},{w:1,h:1,x_center:.828125,y_center:.734375},{w:1,h:1,x_center:.859375,y_center:.734375},{w:1,h:1,x_center:.859375,y_center:.734375},{w:1,h:1,x_center:.890625,y_center:.734375},{w:1,h:1,x_center:.890625,y_center:.734375},{w:1,h:1,x_center:.921875,y_center:.734375},{w:1,h:1,x_center:.921875,y_center:.734375},{w:1,h:1,x_center:.953125,y_center:.734375},{w:1,h:1,x_center:.953125,y_center:.734375},{w:1,h:1,x_center:.984375,y_center:.734375},{w:1,h:1,x_center:.984375,y_center:.734375},{w:1,h:1,x_center:.015625,y_center:.765625},{w:1,h:1,x_center:.015625,y_center:.765625},{w:1,h:1,x_center:.046875,y_center:.765625},{w:1,h:1,x_center:.046875,y_center:.765625},{w:1,h:1,x_center:.078125,y_center:.765625},{w:1,h:1,x_center:.078125,y_center:.765625},{w:1,h:1,x_center:.109375,y_center:.765625},{w:1,h:1,x_center:.109375,y_center:.765625},{w:1,h:1,x_center:.140625,y_center:.765625},{w:1,h:1,x_center:.140625,y_center:.765625},{w:1,h:1,x_center:.171875,y_center:.765625},{w:1,h:1,x_center:.171875,y_center:.765625},{w:1,h:1,x_center:.203125,y_center:.765625},{w:1,h:1,x_center:.203125,y_center:.765625},{w:1,h:1,x_center:.234375,y_center:.765625},{w:1,h:1,x_center:.234375,y_center:.765625},{w:1,h:1,x_center:.265625,y_center:.765625},{w:1,h:1,x_center:.265625,y_center:.765625},{w:1,h:1,x_center:.296875,y_center:.765625},{w:1,h:1,x_center:.296875,y_center:.765625},{w:1,h:1,x_center:.328125,y_center:.765625},{w:1,h:1,x_center:.328125,y_center:.765625},{w:1,h:1,x_center:.359375,y_center:.765625},{w:1,h:1,x_center:.359375,y_center:.765625},{w:1,h:1,x_center:.390625,y_center:.765625},{w:1,h:1,x_center:.390625,y_center:.765625},{w:1,h:1,x_center:.421875,y_center:.765625},{w:1,h:1,x_center:.421875,y_center:.765625},{w:1,h:1,x_center:.453125,y_center:.765625},{w:1,h:1,x_center:.453125,y_center:.765625},{w:1,h:1,x_center:.484375,y_center:.765625},{w:1,h:1,x_center:.484375,y_center:.765625},{w:1,h:1,x_center:.515625,y_center:.765625},{w:1,h:1,x_center:.515625,y_center:.765625},{w:1,h:1,x_center:.546875,y_center:.765625},{w:1,h:1,x_center:.546875,y_center:.765625},{w:1,h:1,x_center:.578125,y_center:.765625},{w:1,h:1,x_center:.578125,y_center:.765625},{w:1,h:1,x_center:.609375,y_center:.765625},{w:1,h:1,x_center:.609375,y_center:.765625},{w:1,h:1,x_center:.640625,y_center:.765625},{w:1,h:1,x_center:.640625,y_center:.765625},{w:1,h:1,x_center:.671875,y_center:.765625},{w:1,h:1,x_center:.671875,y_center:.765625},{w:1,h:1,x_center:.703125,y_center:.765625},{w:1,h:1,x_center:.703125,y_center:.765625},{w:1,h:1,x_center:.734375,y_center:.765625},{w:1,h:1,x_center:.734375,y_center:.765625},{w:1,h:1,x_center:.765625,y_center:.765625},{w:1,h:1,x_center:.765625,y_center:.765625},{w:1,h:1,x_center:.796875,y_center:.765625},{w:1,h:1,x_center:.796875,y_center:.765625},{w:1,h:1,x_center:.828125,y_center:.765625},{w:1,h:1,x_center:.828125,y_center:.765625},{w:1,h:1,x_center:.859375,y_center:.765625},{w:1,h:1,x_center:.859375,y_center:.765625},{w:1,h:1,x_center:.890625,y_center:.765625},{w:1,h:1,x_center:.890625,y_center:.765625},{w:1,h:1,x_center:.921875,y_center:.765625},{w:1,h:1,x_center:.921875,y_center:.765625},{w:1,h:1,x_center:.953125,y_center:.765625},{w:1,h:1,x_center:.953125,y_center:.765625},{w:1,h:1,x_center:.984375,y_center:.765625},{w:1,h:1,x_center:.984375,y_center:.765625},{w:1,h:1,x_center:.015625,y_center:.796875},{w:1,h:1,x_center:.015625,y_center:.796875},{w:1,h:1,x_center:.046875,y_center:.796875},{w:1,h:1,x_center:.046875,y_center:.796875},{w:1,h:1,x_center:.078125,y_center:.796875},{w:1,h:1,x_center:.078125,y_center:.796875},{w:1,h:1,x_center:.109375,y_center:.796875},{w:1,h:1,x_center:.109375,y_center:.796875},{w:1,h:1,x_center:.140625,y_center:.796875},{w:1,h:1,x_center:.140625,y_center:.796875},{w:1,h:1,x_center:.171875,y_center:.796875},{w:1,h:1,x_center:.171875,y_center:.796875},{w:1,h:1,x_center:.203125,y_center:.796875},{w:1,h:1,x_center:.203125,y_center:.796875},{w:1,h:1,x_center:.234375,y_center:.796875},{w:1,h:1,x_center:.234375,y_center:.796875},{w:1,h:1,x_center:.265625,y_center:.796875},{w:1,h:1,x_center:.265625,y_center:.796875},{w:1,h:1,x_center:.296875,y_center:.796875},{w:1,h:1,x_center:.296875,y_center:.796875},{w:1,h:1,x_center:.328125,y_center:.796875},{w:1,h:1,x_center:.328125,y_center:.796875},{w:1,h:1,x_center:.359375,y_center:.796875},{w:1,h:1,x_center:.359375,y_center:.796875},{w:1,h:1,x_center:.390625,y_center:.796875},{w:1,h:1,x_center:.390625,y_center:.796875},{w:1,h:1,x_center:.421875,y_center:.796875},{w:1,h:1,x_center:.421875,y_center:.796875},{w:1,h:1,x_center:.453125,y_center:.796875},{w:1,h:1,x_center:.453125,y_center:.796875},{w:1,h:1,x_center:.484375,y_center:.796875},{w:1,h:1,x_center:.484375,y_center:.796875},{w:1,h:1,x_center:.515625,y_center:.796875},{w:1,h:1,x_center:.515625,y_center:.796875},{w:1,h:1,x_center:.546875,y_center:.796875},{w:1,h:1,x_center:.546875,y_center:.796875},{w:1,h:1,x_center:.578125,y_center:.796875},{w:1,h:1,x_center:.578125,y_center:.796875},{w:1,h:1,x_center:.609375,y_center:.796875},{w:1,h:1,x_center:.609375,y_center:.796875},{w:1,h:1,x_center:.640625,y_center:.796875},{w:1,h:1,x_center:.640625,y_center:.796875},{w:1,h:1,x_center:.671875,y_center:.796875},{w:1,h:1,x_center:.671875,y_center:.796875},{w:1,h:1,x_center:.703125,y_center:.796875},{w:1,h:1,x_center:.703125,y_center:.796875},{w:1,h:1,x_center:.734375,y_center:.796875},{w:1,h:1,x_center:.734375,y_center:.796875},{w:1,h:1,x_center:.765625,y_center:.796875},{w:1,h:1,x_center:.765625,y_center:.796875},{w:1,h:1,x_center:.796875,y_center:.796875},{w:1,h:1,x_center:.796875,y_center:.796875},{w:1,h:1,x_center:.828125,y_center:.796875},{w:1,h:1,x_center:.828125,y_center:.796875},{w:1,h:1,x_center:.859375,y_center:.796875},{w:1,h:1,x_center:.859375,y_center:.796875},{w:1,h:1,x_center:.890625,y_center:.796875},{w:1,h:1,x_center:.890625,y_center:.796875},{w:1,h:1,x_center:.921875,y_center:.796875},{w:1,h:1,x_center:.921875,y_center:.796875},{w:1,h:1,x_center:.953125,y_center:.796875},{w:1,h:1,x_center:.953125,y_center:.796875},{w:1,h:1,x_center:.984375,y_center:.796875},{w:1,h:1,x_center:.984375,y_center:.796875},{w:1,h:1,x_center:.015625,y_center:.828125},{w:1,h:1,x_center:.015625,y_center:.828125},{w:1,h:1,x_center:.046875,y_center:.828125},{w:1,h:1,x_center:.046875,y_center:.828125},{w:1,h:1,x_center:.078125,y_center:.828125},{w:1,h:1,x_center:.078125,y_center:.828125},{w:1,h:1,x_center:.109375,y_center:.828125},{w:1,h:1,x_center:.109375,y_center:.828125},{w:1,h:1,x_center:.140625,y_center:.828125},{w:1,h:1,x_center:.140625,y_center:.828125},{w:1,h:1,x_center:.171875,y_center:.828125},{w:1,h:1,x_center:.171875,y_center:.828125},{w:1,h:1,x_center:.203125,y_center:.828125},{w:1,h:1,x_center:.203125,y_center:.828125},{w:1,h:1,x_center:.234375,y_center:.828125},{w:1,h:1,x_center:.234375,y_center:.828125},{w:1,h:1,x_center:.265625,y_center:.828125},{w:1,h:1,x_center:.265625,y_center:.828125},{w:1,h:1,x_center:.296875,y_center:.828125},{w:1,h:1,x_center:.296875,y_center:.828125},{w:1,h:1,x_center:.328125,y_center:.828125},{w:1,h:1,x_center:.328125,y_center:.828125},{w:1,h:1,x_center:.359375,y_center:.828125},{w:1,h:1,x_center:.359375,y_center:.828125},{w:1,h:1,x_center:.390625,y_center:.828125},{w:1,h:1,x_center:.390625,y_center:.828125},{w:1,h:1,x_center:.421875,y_center:.828125},{w:1,h:1,x_center:.421875,y_center:.828125},{w:1,h:1,x_center:.453125,y_center:.828125},{w:1,h:1,x_center:.453125,y_center:.828125},{w:1,h:1,x_center:.484375,y_center:.828125},{w:1,h:1,x_center:.484375,y_center:.828125},{w:1,h:1,x_center:.515625,y_center:.828125},{w:1,h:1,x_center:.515625,y_center:.828125},{w:1,h:1,x_center:.546875,y_center:.828125},{w:1,h:1,x_center:.546875,y_center:.828125},{w:1,h:1,x_center:.578125,y_center:.828125},{w:1,h:1,x_center:.578125,y_center:.828125},{w:1,h:1,x_center:.609375,y_center:.828125},{w:1,h:1,x_center:.609375,y_center:.828125},{w:1,h:1,x_center:.640625,y_center:.828125},{w:1,h:1,x_center:.640625,y_center:.828125},{w:1,h:1,x_center:.671875,y_center:.828125},{w:1,h:1,x_center:.671875,y_center:.828125},{w:1,h:1,x_center:.703125,y_center:.828125},{w:1,h:1,x_center:.703125,y_center:.828125},{w:1,h:1,x_center:.734375,y_center:.828125},{w:1,h:1,x_center:.734375,y_center:.828125},{w:1,h:1,x_center:.765625,y_center:.828125},{w:1,h:1,x_center:.765625,y_center:.828125},{w:1,h:1,x_center:.796875,y_center:.828125},{w:1,h:1,x_center:.796875,y_center:.828125},{w:1,h:1,x_center:.828125,y_center:.828125},{w:1,h:1,x_center:.828125,y_center:.828125},{w:1,h:1,x_center:.859375,y_center:.828125},{w:1,h:1,x_center:.859375,y_center:.828125},{w:1,h:1,x_center:.890625,y_center:.828125},{w:1,h:1,x_center:.890625,y_center:.828125},{w:1,h:1,x_center:.921875,y_center:.828125},{w:1,h:1,x_center:.921875,y_center:.828125},{w:1,h:1,x_center:.953125,y_center:.828125},{w:1,h:1,x_center:.953125,y_center:.828125},{w:1,h:1,x_center:.984375,y_center:.828125},{w:1,h:1,x_center:.984375,y_center:.828125},{w:1,h:1,x_center:.015625,y_center:.859375},{w:1,h:1,x_center:.015625,y_center:.859375},{w:1,h:1,x_center:.046875,y_center:.859375},{w:1,h:1,x_center:.046875,y_center:.859375},{w:1,h:1,x_center:.078125,y_center:.859375},{w:1,h:1,x_center:.078125,y_center:.859375},{w:1,h:1,x_center:.109375,y_center:.859375},{w:1,h:1,x_center:.109375,y_center:.859375},{w:1,h:1,x_center:.140625,y_center:.859375},{w:1,h:1,x_center:.140625,y_center:.859375},{w:1,h:1,x_center:.171875,y_center:.859375},{w:1,h:1,x_center:.171875,y_center:.859375},{w:1,h:1,x_center:.203125,y_center:.859375},{w:1,h:1,x_center:.203125,y_center:.859375},{w:1,h:1,x_center:.234375,y_center:.859375},{w:1,h:1,x_center:.234375,y_center:.859375},{w:1,h:1,x_center:.265625,y_center:.859375},{w:1,h:1,x_center:.265625,y_center:.859375},{w:1,h:1,x_center:.296875,y_center:.859375},{w:1,h:1,x_center:.296875,y_center:.859375},{w:1,h:1,x_center:.328125,y_center:.859375},{w:1,h:1,x_center:.328125,y_center:.859375},{w:1,h:1,x_center:.359375,y_center:.859375},{w:1,h:1,x_center:.359375,y_center:.859375},{w:1,h:1,x_center:.390625,y_center:.859375},{w:1,h:1,x_center:.390625,y_center:.859375},{w:1,h:1,x_center:.421875,y_center:.859375},{w:1,h:1,x_center:.421875,y_center:.859375},{w:1,h:1,x_center:.453125,y_center:.859375},{w:1,h:1,x_center:.453125,y_center:.859375},{w:1,h:1,x_center:.484375,y_center:.859375},{w:1,h:1,x_center:.484375,y_center:.859375},{w:1,h:1,x_center:.515625,y_center:.859375},{w:1,h:1,x_center:.515625,y_center:.859375},{w:1,h:1,x_center:.546875,y_center:.859375},{w:1,h:1,x_center:.546875,y_center:.859375},{w:1,h:1,x_center:.578125,y_center:.859375},{w:1,h:1,x_center:.578125,y_center:.859375},{w:1,h:1,x_center:.609375,y_center:.859375},{w:1,h:1,x_center:.609375,y_center:.859375},{w:1,h:1,x_center:.640625,y_center:.859375},{w:1,h:1,x_center:.640625,y_center:.859375},{w:1,h:1,x_center:.671875,y_center:.859375},{w:1,h:1,x_center:.671875,y_center:.859375},{w:1,h:1,x_center:.703125,y_center:.859375},{w:1,h:1,x_center:.703125,y_center:.859375},{w:1,h:1,x_center:.734375,y_center:.859375},{w:1,h:1,x_center:.734375,y_center:.859375},{w:1,h:1,x_center:.765625,y_center:.859375},{w:1,h:1,x_center:.765625,y_center:.859375},{w:1,h:1,x_center:.796875,y_center:.859375},{w:1,h:1,x_center:.796875,y_center:.859375},{w:1,h:1,x_center:.828125,y_center:.859375},{w:1,h:1,x_center:.828125,y_center:.859375},{w:1,h:1,x_center:.859375,y_center:.859375},{w:1,h:1,x_center:.859375,y_center:.859375},{w:1,h:1,x_center:.890625,y_center:.859375},{w:1,h:1,x_center:.890625,y_center:.859375},{w:1,h:1,x_center:.921875,y_center:.859375},{w:1,h:1,x_center:.921875,y_center:.859375},{w:1,h:1,x_center:.953125,y_center:.859375},{w:1,h:1,x_center:.953125,y_center:.859375},{w:1,h:1,x_center:.984375,y_center:.859375},{w:1,h:1,x_center:.984375,y_center:.859375},{w:1,h:1,x_center:.015625,y_center:.890625},{w:1,h:1,x_center:.015625,y_center:.890625},{w:1,h:1,x_center:.046875,y_center:.890625},{w:1,h:1,x_center:.046875,y_center:.890625},{w:1,h:1,x_center:.078125,y_center:.890625},{w:1,h:1,x_center:.078125,y_center:.890625},{w:1,h:1,x_center:.109375,y_center:.890625},{w:1,h:1,x_center:.109375,y_center:.890625},{w:1,h:1,x_center:.140625,y_center:.890625},{w:1,h:1,x_center:.140625,y_center:.890625},{w:1,h:1,x_center:.171875,y_center:.890625},{w:1,h:1,x_center:.171875,y_center:.890625},{w:1,h:1,x_center:.203125,y_center:.890625},{w:1,h:1,x_center:.203125,y_center:.890625},{w:1,h:1,x_center:.234375,y_center:.890625},{w:1,h:1,x_center:.234375,y_center:.890625},{w:1,h:1,x_center:.265625,y_center:.890625},{w:1,h:1,x_center:.265625,y_center:.890625},{w:1,h:1,x_center:.296875,y_center:.890625},{w:1,h:1,x_center:.296875,y_center:.890625},{w:1,h:1,x_center:.328125,y_center:.890625},{w:1,h:1,x_center:.328125,y_center:.890625},{w:1,h:1,x_center:.359375,y_center:.890625},{w:1,h:1,x_center:.359375,y_center:.890625},{w:1,h:1,x_center:.390625,y_center:.890625},{w:1,h:1,x_center:.390625,y_center:.890625},{w:1,h:1,x_center:.421875,y_center:.890625},{w:1,h:1,x_center:.421875,y_center:.890625},{w:1,h:1,x_center:.453125,y_center:.890625},{w:1,h:1,x_center:.453125,y_center:.890625},{w:1,h:1,x_center:.484375,y_center:.890625},{w:1,h:1,x_center:.484375,y_center:.890625},{w:1,h:1,x_center:.515625,y_center:.890625},{w:1,h:1,x_center:.515625,y_center:.890625},{w:1,h:1,x_center:.546875,y_center:.890625},{w:1,h:1,x_center:.546875,y_center:.890625},{w:1,h:1,x_center:.578125,y_center:.890625},{w:1,h:1,x_center:.578125,y_center:.890625},{w:1,h:1,x_center:.609375,y_center:.890625},{w:1,h:1,x_center:.609375,y_center:.890625},{w:1,h:1,x_center:.640625,y_center:.890625},{w:1,h:1,x_center:.640625,y_center:.890625},{w:1,h:1,x_center:.671875,y_center:.890625},{w:1,h:1,x_center:.671875,y_center:.890625},{w:1,h:1,x_center:.703125,y_center:.890625},{w:1,h:1,x_center:.703125,y_center:.890625},{w:1,h:1,x_center:.734375,y_center:.890625},{w:1,h:1,x_center:.734375,y_center:.890625},{w:1,h:1,x_center:.765625,y_center:.890625},{w:1,h:1,x_center:.765625,y_center:.890625},{w:1,h:1,x_center:.796875,y_center:.890625},{w:1,h:1,x_center:.796875,y_center:.890625},{w:1,h:1,x_center:.828125,y_center:.890625},{w:1,h:1,x_center:.828125,y_center:.890625},{w:1,h:1,x_center:.859375,y_center:.890625},{w:1,h:1,x_center:.859375,y_center:.890625},{w:1,h:1,x_center:.890625,y_center:.890625},{w:1,h:1,x_center:.890625,y_center:.890625},{w:1,h:1,x_center:.921875,y_center:.890625},{w:1,h:1,x_center:.921875,y_center:.890625},{w:1,h:1,x_center:.953125,y_center:.890625},{w:1,h:1,x_center:.953125,y_center:.890625},{w:1,h:1,x_center:.984375,y_center:.890625},{w:1,h:1,x_center:.984375,y_center:.890625},{w:1,h:1,x_center:.015625,y_center:.921875},{w:1,h:1,x_center:.015625,y_center:.921875},{w:1,h:1,x_center:.046875,y_center:.921875},{w:1,h:1,x_center:.046875,y_center:.921875},{w:1,h:1,x_center:.078125,y_center:.921875},{w:1,h:1,x_center:.078125,y_center:.921875},{w:1,h:1,x_center:.109375,y_center:.921875},{w:1,h:1,x_center:.109375,y_center:.921875},{w:1,h:1,x_center:.140625,y_center:.921875},{w:1,h:1,x_center:.140625,y_center:.921875},{w:1,h:1,x_center:.171875,y_center:.921875},{w:1,h:1,x_center:.171875,y_center:.921875},{w:1,h:1,x_center:.203125,y_center:.921875},{w:1,h:1,x_center:.203125,y_center:.921875},{w:1,h:1,x_center:.234375,y_center:.921875},{w:1,h:1,x_center:.234375,y_center:.921875},{w:1,h:1,x_center:.265625,y_center:.921875},{w:1,h:1,x_center:.265625,y_center:.921875},{w:1,h:1,x_center:.296875,y_center:.921875},{w:1,h:1,x_center:.296875,y_center:.921875},{w:1,h:1,x_center:.328125,y_center:.921875},{w:1,h:1,x_center:.328125,y_center:.921875},{w:1,h:1,x_center:.359375,y_center:.921875},{w:1,h:1,x_center:.359375,y_center:.921875},{w:1,h:1,x_center:.390625,y_center:.921875},{w:1,h:1,x_center:.390625,y_center:.921875},{w:1,h:1,x_center:.421875,y_center:.921875},{w:1,h:1,x_center:.421875,y_center:.921875},{w:1,h:1,x_center:.453125,y_center:.921875},{w:1,h:1,x_center:.453125,y_center:.921875},{w:1,h:1,x_center:.484375,y_center:.921875},{w:1,h:1,x_center:.484375,y_center:.921875},{w:1,h:1,x_center:.515625,y_center:.921875},{w:1,h:1,x_center:.515625,y_center:.921875},{w:1,h:1,x_center:.546875,y_center:.921875},{w:1,h:1,x_center:.546875,y_center:.921875},{w:1,h:1,x_center:.578125,y_center:.921875},{w:1,h:1,x_center:.578125,y_center:.921875},{w:1,h:1,x_center:.609375,y_center:.921875},{w:1,h:1,x_center:.609375,y_center:.921875},{w:1,h:1,x_center:.640625,y_center:.921875},{w:1,h:1,x_center:.640625,y_center:.921875},{w:1,h:1,x_center:.671875,y_center:.921875},{w:1,h:1,x_center:.671875,y_center:.921875},{w:1,h:1,x_center:.703125,y_center:.921875},{w:1,h:1,x_center:.703125,y_center:.921875},{w:1,h:1,x_center:.734375,y_center:.921875},{w:1,h:1,x_center:.734375,y_center:.921875},{w:1,h:1,x_center:.765625,y_center:.921875},{w:1,h:1,x_center:.765625,y_center:.921875},{w:1,h:1,x_center:.796875,y_center:.921875},{w:1,h:1,x_center:.796875,y_center:.921875},{w:1,h:1,x_center:.828125,y_center:.921875},{w:1,h:1,x_center:.828125,y_center:.921875},{w:1,h:1,x_center:.859375,y_center:.921875},{w:1,h:1,x_center:.859375,y_center:.921875},{w:1,h:1,x_center:.890625,y_center:.921875},{w:1,h:1,x_center:.890625,y_center:.921875},{w:1,h:1,x_center:.921875,y_center:.921875},{w:1,h:1,x_center:.921875,y_center:.921875},{w:1,h:1,x_center:.953125,y_center:.921875},{w:1,h:1,x_center:.953125,y_center:.921875},{w:1,h:1,x_center:.984375,y_center:.921875},{w:1,h:1,x_center:.984375,y_center:.921875},{w:1,h:1,x_center:.015625,y_center:.953125},{w:1,h:1,x_center:.015625,y_center:.953125},{w:1,h:1,x_center:.046875,y_center:.953125},{w:1,h:1,x_center:.046875,y_center:.953125},{w:1,h:1,x_center:.078125,y_center:.953125},{w:1,h:1,x_center:.078125,y_center:.953125},{w:1,h:1,x_center:.109375,y_center:.953125},{w:1,h:1,x_center:.109375,y_center:.953125},{w:1,h:1,x_center:.140625,y_center:.953125},{w:1,h:1,x_center:.140625,y_center:.953125},{w:1,h:1,x_center:.171875,y_center:.953125},{w:1,h:1,x_center:.171875,y_center:.953125},{w:1,h:1,x_center:.203125,y_center:.953125},{w:1,h:1,x_center:.203125,y_center:.953125},{w:1,h:1,x_center:.234375,y_center:.953125},{w:1,h:1,x_center:.234375,y_center:.953125},{w:1,h:1,x_center:.265625,y_center:.953125},{w:1,h:1,x_center:.265625,y_center:.953125},{w:1,h:1,x_center:.296875,y_center:.953125},{w:1,h:1,x_center:.296875,y_center:.953125},{w:1,h:1,x_center:.328125,y_center:.953125},{w:1,h:1,x_center:.328125,y_center:.953125},{w:1,h:1,x_center:.359375,y_center:.953125},{w:1,h:1,x_center:.359375,y_center:.953125},{w:1,h:1,x_center:.390625,y_center:.953125},{w:1,h:1,x_center:.390625,y_center:.953125},{w:1,h:1,x_center:.421875,y_center:.953125},{w:1,h:1,x_center:.421875,y_center:.953125},{w:1,h:1,x_center:.453125,y_center:.953125},{w:1,h:1,x_center:.453125,y_center:.953125},{w:1,h:1,x_center:.484375,y_center:.953125},{w:1,h:1,x_center:.484375,y_center:.953125},{w:1,h:1,x_center:.515625,y_center:.953125},{w:1,h:1,x_center:.515625,y_center:.953125},{w:1,h:1,x_center:.546875,y_center:.953125},{w:1,h:1,x_center:.546875,y_center:.953125},{w:1,h:1,x_center:.578125,y_center:.953125},{w:1,h:1,x_center:.578125,y_center:.953125},{w:1,h:1,x_center:.609375,y_center:.953125},{w:1,h:1,x_center:.609375,y_center:.953125},{w:1,h:1,x_center:.640625,y_center:.953125},{w:1,h:1,x_center:.640625,y_center:.953125},{w:1,h:1,x_center:.671875,y_center:.953125},{w:1,h:1,x_center:.671875,y_center:.953125},{w:1,h:1,x_center:.703125,y_center:.953125},{w:1,h:1,x_center:.703125,y_center:.953125},{w:1,h:1,x_center:.734375,y_center:.953125},{w:1,h:1,x_center:.734375,y_center:.953125},{w:1,h:1,x_center:.765625,y_center:.953125},{w:1,h:1,x_center:.765625,y_center:.953125},{w:1,h:1,x_center:.796875,y_center:.953125},{w:1,h:1,x_center:.796875,y_center:.953125},{w:1,h:1,x_center:.828125,y_center:.953125},{w:1,h:1,x_center:.828125,y_center:.953125},{w:1,h:1,x_center:.859375,y_center:.953125},{w:1,h:1,x_center:.859375,y_center:.953125},{w:1,h:1,x_center:.890625,y_center:.953125},{w:1,h:1,x_center:.890625,y_center:.953125},{w:1,h:1,x_center:.921875,y_center:.953125},{w:1,h:1,x_center:.921875,y_center:.953125},{w:1,h:1,x_center:.953125,y_center:.953125},{w:1,h:1,x_center:.953125,y_center:.953125},{w:1,h:1,x_center:.984375,y_center:.953125},{w:1,h:1,x_center:.984375,y_center:.953125},{w:1,h:1,x_center:.015625,y_center:.984375},{w:1,h:1,x_center:.015625,y_center:.984375},{w:1,h:1,x_center:.046875,y_center:.984375},{w:1,h:1,x_center:.046875,y_center:.984375},{w:1,h:1,x_center:.078125,y_center:.984375},{w:1,h:1,x_center:.078125,y_center:.984375},{w:1,h:1,x_center:.109375,y_center:.984375},{w:1,h:1,x_center:.109375,y_center:.984375},{w:1,h:1,x_center:.140625,y_center:.984375},{w:1,h:1,x_center:.140625,y_center:.984375},{w:1,h:1,x_center:.171875,y_center:.984375},{w:1,h:1,x_center:.171875,y_center:.984375},{w:1,h:1,x_center:.203125,y_center:.984375},{w:1,h:1,x_center:.203125,y_center:.984375},{w:1,h:1,x_center:.234375,y_center:.984375},{w:1,h:1,x_center:.234375,y_center:.984375},{w:1,h:1,x_center:.265625,y_center:.984375},{w:1,h:1,x_center:.265625,y_center:.984375},{w:1,h:1,x_center:.296875,y_center:.984375},{w:1,h:1,x_center:.296875,y_center:.984375},{w:1,h:1,x_center:.328125,y_center:.984375},{w:1,h:1,x_center:.328125,y_center:.984375},{w:1,h:1,x_center:.359375,y_center:.984375},{w:1,h:1,x_center:.359375,y_center:.984375},{w:1,h:1,x_center:.390625,y_center:.984375},{w:1,h:1,x_center:.390625,y_center:.984375},{w:1,h:1,x_center:.421875,y_center:.984375},{w:1,h:1,x_center:.421875,y_center:.984375},{w:1,h:1,x_center:.453125,y_center:.984375},{w:1,h:1,x_center:.453125,y_center:.984375},{w:1,h:1,x_center:.484375,y_center:.984375},{w:1,h:1,x_center:.484375,y_center:.984375},{w:1,h:1,x_center:.515625,y_center:.984375},{w:1,h:1,x_center:.515625,y_center:.984375},{w:1,h:1,x_center:.546875,y_center:.984375},{w:1,h:1,x_center:.546875,y_center:.984375},{w:1,h:1,x_center:.578125,y_center:.984375},{w:1,h:1,x_center:.578125,y_center:.984375},{w:1,h:1,x_center:.609375,y_center:.984375},{w:1,h:1,x_center:.609375,y_center:.984375},{w:1,h:1,x_center:.640625,y_center:.984375},{w:1,h:1,x_center:.640625,y_center:.984375},{w:1,h:1,x_center:.671875,y_center:.984375},{w:1,h:1,x_center:.671875,y_center:.984375},{w:1,h:1,x_center:.703125,y_center:.984375},{w:1,h:1,x_center:.703125,y_center:.984375},{w:1,h:1,x_center:.734375,y_center:.984375},{w:1,h:1,x_center:.734375,y_center:.984375},{w:1,h:1,x_center:.765625,y_center:.984375},{w:1,h:1,x_center:.765625,y_center:.984375},{w:1,h:1,x_center:.796875,y_center:.984375},{w:1,h:1,x_center:.796875,y_center:.984375},{w:1,h:1,x_center:.828125,y_center:.984375},{w:1,h:1,x_center:.828125,y_center:.984375},{w:1,h:1,x_center:.859375,y_center:.984375},{w:1,h:1,x_center:.859375,y_center:.984375},{w:1,h:1,x_center:.890625,y_center:.984375},{w:1,h:1,x_center:.890625,y_center:.984375},{w:1,h:1,x_center:.921875,y_center:.984375},{w:1,h:1,x_center:.921875,y_center:.984375},{w:1,h:1,x_center:.953125,y_center:.984375},{w:1,h:1,x_center:.953125,y_center:.984375},{w:1,h:1,x_center:.984375,y_center:.984375},{w:1,h:1,x_center:.984375,y_center:.984375},{w:1,h:1,x_center:.03125,y_center:.03125},{w:1,h:1,x_center:.03125,y_center:.03125},{w:1,h:1,x_center:.09375,y_center:.03125},{w:1,h:1,x_center:.09375,y_center:.03125},{w:1,h:1,x_center:.15625,y_center:.03125},{w:1,h:1,x_center:.15625,y_center:.03125},{w:1,h:1,x_center:.21875,y_center:.03125},{w:1,h:1,x_center:.21875,y_center:.03125},{w:1,h:1,x_center:.28125,y_center:.03125},{w:1,h:1,x_center:.28125,y_center:.03125},{w:1,h:1,x_center:.34375,y_center:.03125},{w:1,h:1,x_center:.34375,y_center:.03125},{w:1,h:1,x_center:.40625,y_center:.03125},{w:1,h:1,x_center:.40625,y_center:.03125},{w:1,h:1,x_center:.46875,y_center:.03125},{w:1,h:1,x_center:.46875,y_center:.03125},{w:1,h:1,x_center:.53125,y_center:.03125},{w:1,h:1,x_center:.53125,y_center:.03125},{w:1,h:1,x_center:.59375,y_center:.03125},{w:1,h:1,x_center:.59375,y_center:.03125},{w:1,h:1,x_center:.65625,y_center:.03125},{w:1,h:1,x_center:.65625,y_center:.03125},{w:1,h:1,x_center:.71875,y_center:.03125},{w:1,h:1,x_center:.71875,y_center:.03125},{w:1,h:1,x_center:.78125,y_center:.03125},{w:1,h:1,x_center:.78125,y_center:.03125},{w:1,h:1,x_center:.84375,y_center:.03125},{w:1,h:1,x_center:.84375,y_center:.03125},{w:1,h:1,x_center:.90625,y_center:.03125},{w:1,h:1,x_center:.90625,y_center:.03125},{w:1,h:1,x_center:.96875,y_center:.03125},{w:1,h:1,x_center:.96875,y_center:.03125},{w:1,h:1,x_center:.03125,y_center:.09375},{w:1,h:1,x_center:.03125,y_center:.09375},{w:1,h:1,x_center:.09375,y_center:.09375},{w:1,h:1,x_center:.09375,y_center:.09375},{w:1,h:1,x_center:.15625,y_center:.09375},{w:1,h:1,x_center:.15625,y_center:.09375},{w:1,h:1,x_center:.21875,y_center:.09375},{w:1,h:1,x_center:.21875,y_center:.09375},{w:1,h:1,x_center:.28125,y_center:.09375},{w:1,h:1,x_center:.28125,y_center:.09375},{w:1,h:1,x_center:.34375,y_center:.09375},{w:1,h:1,x_center:.34375,y_center:.09375},{w:1,h:1,x_center:.40625,y_center:.09375},{w:1,h:1,x_center:.40625,y_center:.09375},{w:1,h:1,x_center:.46875,y_center:.09375},{w:1,h:1,x_center:.46875,y_center:.09375},{w:1,h:1,x_center:.53125,y_center:.09375},{w:1,h:1,x_center:.53125,y_center:.09375},{w:1,h:1,x_center:.59375,y_center:.09375},{w:1,h:1,x_center:.59375,y_center:.09375},{w:1,h:1,x_center:.65625,y_center:.09375},{w:1,h:1,x_center:.65625,y_center:.09375},{w:1,h:1,x_center:.71875,y_center:.09375},{w:1,h:1,x_center:.71875,y_center:.09375},{w:1,h:1,x_center:.78125,y_center:.09375},{w:1,h:1,x_center:.78125,y_center:.09375},{w:1,h:1,x_center:.84375,y_center:.09375},{w:1,h:1,x_center:.84375,y_center:.09375},{w:1,h:1,x_center:.90625,y_center:.09375},{w:1,h:1,x_center:.90625,y_center:.09375},{w:1,h:1,x_center:.96875,y_center:.09375},{w:1,h:1,x_center:.96875,y_center:.09375},{w:1,h:1,x_center:.03125,y_center:.15625},{w:1,h:1,x_center:.03125,y_center:.15625},{w:1,h:1,x_center:.09375,y_center:.15625},{w:1,h:1,x_center:.09375,y_center:.15625},{w:1,h:1,x_center:.15625,y_center:.15625},{w:1,h:1,x_center:.15625,y_center:.15625},{w:1,h:1,x_center:.21875,y_center:.15625},{w:1,h:1,x_center:.21875,y_center:.15625},{w:1,h:1,x_center:.28125,y_center:.15625},{w:1,h:1,x_center:.28125,y_center:.15625},{w:1,h:1,x_center:.34375,y_center:.15625},{w:1,h:1,x_center:.34375,y_center:.15625},{w:1,h:1,x_center:.40625,y_center:.15625},{w:1,h:1,x_center:.40625,y_center:.15625},{w:1,h:1,x_center:.46875,y_center:.15625},{w:1,h:1,x_center:.46875,y_center:.15625},{w:1,h:1,x_center:.53125,y_center:.15625},{w:1,h:1,x_center:.53125,y_center:.15625},{w:1,h:1,x_center:.59375,y_center:.15625},{w:1,h:1,x_center:.59375,y_center:.15625},{w:1,h:1,x_center:.65625,y_center:.15625},{w:1,h:1,x_center:.65625,y_center:.15625},{w:1,h:1,x_center:.71875,y_center:.15625},{w:1,h:1,x_center:.71875,y_center:.15625},{w:1,h:1,x_center:.78125,y_center:.15625},{w:1,h:1,x_center:.78125,y_center:.15625},{w:1,h:1,x_center:.84375,y_center:.15625},{w:1,h:1,x_center:.84375,y_center:.15625},{w:1,h:1,x_center:.90625,y_center:.15625},{w:1,h:1,x_center:.90625,y_center:.15625},{w:1,h:1,x_center:.96875,y_center:.15625},{w:1,h:1,x_center:.96875,y_center:.15625},{w:1,h:1,x_center:.03125,y_center:.21875},{w:1,h:1,x_center:.03125,y_center:.21875},{w:1,h:1,x_center:.09375,y_center:.21875},{w:1,h:1,x_center:.09375,y_center:.21875},{w:1,h:1,x_center:.15625,y_center:.21875},{w:1,h:1,x_center:.15625,y_center:.21875},{w:1,h:1,x_center:.21875,y_center:.21875},{w:1,h:1,x_center:.21875,y_center:.21875},{w:1,h:1,x_center:.28125,y_center:.21875},{w:1,h:1,x_center:.28125,y_center:.21875},{w:1,h:1,x_center:.34375,y_center:.21875},{w:1,h:1,x_center:.34375,y_center:.21875},{w:1,h:1,x_center:.40625,y_center:.21875},{w:1,h:1,x_center:.40625,y_center:.21875},{w:1,h:1,x_center:.46875,y_center:.21875},{w:1,h:1,x_center:.46875,y_center:.21875},{w:1,h:1,x_center:.53125,y_center:.21875},{w:1,h:1,x_center:.53125,y_center:.21875},{w:1,h:1,x_center:.59375,y_center:.21875},{w:1,h:1,x_center:.59375,y_center:.21875},{w:1,h:1,x_center:.65625,y_center:.21875},{w:1,h:1,x_center:.65625,y_center:.21875},{w:1,h:1,x_center:.71875,y_center:.21875},{w:1,h:1,x_center:.71875,y_center:.21875},{w:1,h:1,x_center:.78125,y_center:.21875},{w:1,h:1,x_center:.78125,y_center:.21875},{w:1,h:1,x_center:.84375,y_center:.21875},{w:1,h:1,x_center:.84375,y_center:.21875},{w:1,h:1,x_center:.90625,y_center:.21875},{w:1,h:1,x_center:.90625,y_center:.21875},{w:1,h:1,x_center:.96875,y_center:.21875},{w:1,h:1,x_center:.96875,y_center:.21875},{w:1,h:1,x_center:.03125,y_center:.28125},{w:1,h:1,x_center:.03125,y_center:.28125},{w:1,h:1,x_center:.09375,y_center:.28125},{w:1,h:1,x_center:.09375,y_center:.28125},{w:1,h:1,x_center:.15625,y_center:.28125},{w:1,h:1,x_center:.15625,y_center:.28125},{w:1,h:1,x_center:.21875,y_center:.28125},{w:1,h:1,x_center:.21875,y_center:.28125},{w:1,h:1,x_center:.28125,y_center:.28125},{w:1,h:1,x_center:.28125,y_center:.28125},{w:1,h:1,x_center:.34375,y_center:.28125},{w:1,h:1,x_center:.34375,y_center:.28125},{w:1,h:1,x_center:.40625,y_center:.28125},{w:1,h:1,x_center:.40625,y_center:.28125},{w:1,h:1,x_center:.46875,y_center:.28125},{w:1,h:1,x_center:.46875,y_center:.28125},{w:1,h:1,x_center:.53125,y_center:.28125},{w:1,h:1,x_center:.53125,y_center:.28125},{w:1,h:1,x_center:.59375,y_center:.28125},{w:1,h:1,x_center:.59375,y_center:.28125},{w:1,h:1,x_center:.65625,y_center:.28125},{w:1,h:1,x_center:.65625,y_center:.28125},{w:1,h:1,x_center:.71875,y_center:.28125},{w:1,h:1,x_center:.71875,y_center:.28125},{w:1,h:1,x_center:.78125,y_center:.28125},{w:1,h:1,x_center:.78125,y_center:.28125},{w:1,h:1,x_center:.84375,y_center:.28125},{w:1,h:1,x_center:.84375,y_center:.28125},{w:1,h:1,x_center:.90625,y_center:.28125},{w:1,h:1,x_center:.90625,y_center:.28125},{w:1,h:1,x_center:.96875,y_center:.28125},{w:1,h:1,x_center:.96875,y_center:.28125},{w:1,h:1,x_center:.03125,y_center:.34375},{w:1,h:1,x_center:.03125,y_center:.34375},{w:1,h:1,x_center:.09375,y_center:.34375},{w:1,h:1,x_center:.09375,y_center:.34375},{w:1,h:1,x_center:.15625,y_center:.34375},{w:1,h:1,x_center:.15625,y_center:.34375},{w:1,h:1,x_center:.21875,y_center:.34375},{w:1,h:1,x_center:.21875,y_center:.34375},{w:1,h:1,x_center:.28125,y_center:.34375},{w:1,h:1,x_center:.28125,y_center:.34375},{w:1,h:1,x_center:.34375,y_center:.34375},{w:1,h:1,x_center:.34375,y_center:.34375},{w:1,h:1,x_center:.40625,y_center:.34375},{w:1,h:1,x_center:.40625,y_center:.34375},{w:1,h:1,x_center:.46875,y_center:.34375},{w:1,h:1,x_center:.46875,y_center:.34375},{w:1,h:1,x_center:.53125,y_center:.34375},{w:1,h:1,x_center:.53125,y_center:.34375},{w:1,h:1,x_center:.59375,y_center:.34375},{w:1,h:1,x_center:.59375,y_center:.34375},{w:1,h:1,x_center:.65625,y_center:.34375},{w:1,h:1,x_center:.65625,y_center:.34375},{w:1,h:1,x_center:.71875,y_center:.34375},{w:1,h:1,x_center:.71875,y_center:.34375},{w:1,h:1,x_center:.78125,y_center:.34375},{w:1,h:1,x_center:.78125,y_center:.34375},{w:1,h:1,x_center:.84375,y_center:.34375},{w:1,h:1,x_center:.84375,y_center:.34375},{w:1,h:1,x_center:.90625,y_center:.34375},{w:1,h:1,x_center:.90625,y_center:.34375},{w:1,h:1,x_center:.96875,y_center:.34375},{w:1,h:1,x_center:.96875,y_center:.34375},{w:1,h:1,x_center:.03125,y_center:.40625},{w:1,h:1,x_center:.03125,y_center:.40625},{w:1,h:1,x_center:.09375,y_center:.40625},{w:1,h:1,x_center:.09375,y_center:.40625},{w:1,h:1,x_center:.15625,y_center:.40625},{w:1,h:1,x_center:.15625,y_center:.40625},{w:1,h:1,x_center:.21875,y_center:.40625},{w:1,h:1,x_center:.21875,y_center:.40625},{w:1,h:1,x_center:.28125,y_center:.40625},{w:1,h:1,x_center:.28125,y_center:.40625},{w:1,h:1,x_center:.34375,y_center:.40625},{w:1,h:1,x_center:.34375,y_center:.40625},{w:1,h:1,x_center:.40625,y_center:.40625},{w:1,h:1,x_center:.40625,y_center:.40625},{w:1,h:1,x_center:.46875,y_center:.40625},{w:1,h:1,x_center:.46875,y_center:.40625},{w:1,h:1,x_center:.53125,y_center:.40625},{w:1,h:1,x_center:.53125,y_center:.40625},{w:1,h:1,x_center:.59375,y_center:.40625},{w:1,h:1,x_center:.59375,y_center:.40625},{w:1,h:1,x_center:.65625,y_center:.40625},{w:1,h:1,x_center:.65625,y_center:.40625},{w:1,h:1,x_center:.71875,y_center:.40625},{w:1,h:1,x_center:.71875,y_center:.40625},{w:1,h:1,x_center:.78125,y_center:.40625},{w:1,h:1,x_center:.78125,y_center:.40625},{w:1,h:1,x_center:.84375,y_center:.40625},{w:1,h:1,x_center:.84375,y_center:.40625},{w:1,h:1,x_center:.90625,y_center:.40625},{w:1,h:1,x_center:.90625,y_center:.40625},{w:1,h:1,x_center:.96875,y_center:.40625},{w:1,h:1,x_center:.96875,y_center:.40625},{w:1,h:1,x_center:.03125,y_center:.46875},{w:1,h:1,x_center:.03125,y_center:.46875},{w:1,h:1,x_center:.09375,y_center:.46875},{w:1,h:1,x_center:.09375,y_center:.46875},{w:1,h:1,x_center:.15625,y_center:.46875},{w:1,h:1,x_center:.15625,y_center:.46875},{w:1,h:1,x_center:.21875,y_center:.46875},{w:1,h:1,x_center:.21875,y_center:.46875},{w:1,h:1,x_center:.28125,y_center:.46875},{w:1,h:1,x_center:.28125,y_center:.46875},{w:1,h:1,x_center:.34375,y_center:.46875},{w:1,h:1,x_center:.34375,y_center:.46875},{w:1,h:1,x_center:.40625,y_center:.46875},{w:1,h:1,x_center:.40625,y_center:.46875},{w:1,h:1,x_center:.46875,y_center:.46875},{w:1,h:1,x_center:.46875,y_center:.46875},{w:1,h:1,x_center:.53125,y_center:.46875},{w:1,h:1,x_center:.53125,y_center:.46875},{w:1,h:1,x_center:.59375,y_center:.46875},{w:1,h:1,x_center:.59375,y_center:.46875},{w:1,h:1,x_center:.65625,y_center:.46875},{w:1,h:1,x_center:.65625,y_center:.46875},{w:1,h:1,x_center:.71875,y_center:.46875},{w:1,h:1,x_center:.71875,y_center:.46875},{w:1,h:1,x_center:.78125,y_center:.46875},{w:1,h:1,x_center:.78125,y_center:.46875},{w:1,h:1,x_center:.84375,y_center:.46875},{w:1,h:1,x_center:.84375,y_center:.46875},{w:1,h:1,x_center:.90625,y_center:.46875},{w:1,h:1,x_center:.90625,y_center:.46875},{w:1,h:1,x_center:.96875,y_center:.46875},{w:1,h:1,x_center:.96875,y_center:.46875},{w:1,h:1,x_center:.03125,y_center:.53125},{w:1,h:1,x_center:.03125,y_center:.53125},{w:1,h:1,x_center:.09375,y_center:.53125},{w:1,h:1,x_center:.09375,y_center:.53125},{w:1,h:1,x_center:.15625,y_center:.53125},{w:1,h:1,x_center:.15625,y_center:.53125},{w:1,h:1,x_center:.21875,y_center:.53125},{w:1,h:1,x_center:.21875,y_center:.53125},{w:1,h:1,x_center:.28125,y_center:.53125},{w:1,h:1,x_center:.28125,y_center:.53125},{w:1,h:1,x_center:.34375,y_center:.53125},{w:1,h:1,x_center:.34375,y_center:.53125},{w:1,h:1,x_center:.40625,y_center:.53125},{w:1,h:1,x_center:.40625,y_center:.53125},{w:1,h:1,x_center:.46875,y_center:.53125},{w:1,h:1,x_center:.46875,y_center:.53125},{w:1,h:1,x_center:.53125,y_center:.53125},{w:1,h:1,x_center:.53125,y_center:.53125},{w:1,h:1,x_center:.59375,y_center:.53125},{w:1,h:1,x_center:.59375,y_center:.53125},{w:1,h:1,x_center:.65625,y_center:.53125},{w:1,h:1,x_center:.65625,y_center:.53125},{w:1,h:1,x_center:.71875,y_center:.53125},{w:1,h:1,x_center:.71875,y_center:.53125},{w:1,h:1,x_center:.78125,y_center:.53125},{w:1,h:1,x_center:.78125,y_center:.53125},{w:1,h:1,x_center:.84375,y_center:.53125},{w:1,h:1,x_center:.84375,y_center:.53125},{w:1,h:1,x_center:.90625,y_center:.53125},{w:1,h:1,x_center:.90625,y_center:.53125},{w:1,h:1,x_center:.96875,y_center:.53125},{w:1,h:1,x_center:.96875,y_center:.53125},{w:1,h:1,x_center:.03125,y_center:.59375},{w:1,h:1,x_center:.03125,y_center:.59375},{w:1,h:1,x_center:.09375,y_center:.59375},{w:1,h:1,x_center:.09375,y_center:.59375},{w:1,h:1,x_center:.15625,y_center:.59375},{w:1,h:1,x_center:.15625,y_center:.59375},{w:1,h:1,x_center:.21875,y_center:.59375},{w:1,h:1,x_center:.21875,y_center:.59375},{w:1,h:1,x_center:.28125,y_center:.59375},{w:1,h:1,x_center:.28125,y_center:.59375},{w:1,h:1,x_center:.34375,y_center:.59375},{w:1,h:1,x_center:.34375,y_center:.59375},{w:1,h:1,x_center:.40625,y_center:.59375},{w:1,h:1,x_center:.40625,y_center:.59375},{w:1,h:1,x_center:.46875,y_center:.59375},{w:1,h:1,x_center:.46875,y_center:.59375},{w:1,h:1,x_center:.53125,y_center:.59375},{w:1,h:1,x_center:.53125,y_center:.59375},{w:1,h:1,x_center:.59375,y_center:.59375},{w:1,h:1,x_center:.59375,y_center:.59375},{w:1,h:1,x_center:.65625,y_center:.59375},{w:1,h:1,x_center:.65625,y_center:.59375},{w:1,h:1,x_center:.71875,y_center:.59375},{w:1,h:1,x_center:.71875,y_center:.59375},{w:1,h:1,x_center:.78125,y_center:.59375},{w:1,h:1,x_center:.78125,y_center:.59375},{w:1,h:1,x_center:.84375,y_center:.59375},{w:1,h:1,x_center:.84375,y_center:.59375},{w:1,h:1,x_center:.90625,y_center:.59375},{w:1,h:1,x_center:.90625,y_center:.59375},{w:1,h:1,x_center:.96875,y_center:.59375},{w:1,h:1,x_center:.96875,y_center:.59375},{w:1,h:1,x_center:.03125,y_center:.65625},{w:1,h:1,x_center:.03125,y_center:.65625},{w:1,h:1,x_center:.09375,y_center:.65625},{w:1,h:1,x_center:.09375,y_center:.65625},{w:1,h:1,x_center:.15625,y_center:.65625},{w:1,h:1,x_center:.15625,y_center:.65625},{w:1,h:1,x_center:.21875,y_center:.65625},{w:1,h:1,x_center:.21875,y_center:.65625},{w:1,h:1,x_center:.28125,y_center:.65625},{w:1,h:1,x_center:.28125,y_center:.65625},{w:1,h:1,x_center:.34375,y_center:.65625},{w:1,h:1,x_center:.34375,y_center:.65625},{w:1,h:1,x_center:.40625,y_center:.65625},{w:1,h:1,x_center:.40625,y_center:.65625},{w:1,h:1,x_center:.46875,y_center:.65625},{w:1,h:1,x_center:.46875,y_center:.65625},{w:1,h:1,x_center:.53125,y_center:.65625},{w:1,h:1,x_center:.53125,y_center:.65625},{w:1,h:1,x_center:.59375,y_center:.65625},{w:1,h:1,x_center:.59375,y_center:.65625},{w:1,h:1,x_center:.65625,y_center:.65625},{w:1,h:1,x_center:.65625,y_center:.65625},{w:1,h:1,x_center:.71875,y_center:.65625},{w:1,h:1,x_center:.71875,y_center:.65625},{w:1,h:1,x_center:.78125,y_center:.65625},{w:1,h:1,x_center:.78125,y_center:.65625},{w:1,h:1,x_center:.84375,y_center:.65625},{w:1,h:1,x_center:.84375,y_center:.65625},{w:1,h:1,x_center:.90625,y_center:.65625},{w:1,h:1,x_center:.90625,y_center:.65625},{w:1,h:1,x_center:.96875,y_center:.65625},{w:1,h:1,x_center:.96875,y_center:.65625},{w:1,h:1,x_center:.03125,y_center:.71875},{w:1,h:1,x_center:.03125,y_center:.71875},{w:1,h:1,x_center:.09375,y_center:.71875},{w:1,h:1,x_center:.09375,y_center:.71875},{w:1,h:1,x_center:.15625,y_center:.71875},{w:1,h:1,x_center:.15625,y_center:.71875},{w:1,h:1,x_center:.21875,y_center:.71875},{w:1,h:1,x_center:.21875,y_center:.71875},{w:1,h:1,x_center:.28125,y_center:.71875},{w:1,h:1,x_center:.28125,y_center:.71875},{w:1,h:1,x_center:.34375,y_center:.71875},{w:1,h:1,x_center:.34375,y_center:.71875},{w:1,h:1,x_center:.40625,y_center:.71875},{w:1,h:1,x_center:.40625,y_center:.71875},{w:1,h:1,x_center:.46875,y_center:.71875},{w:1,h:1,x_center:.46875,y_center:.71875},{w:1,h:1,x_center:.53125,y_center:.71875},{w:1,h:1,x_center:.53125,y_center:.71875},{w:1,h:1,x_center:.59375,y_center:.71875},{w:1,h:1,x_center:.59375,y_center:.71875},{w:1,h:1,x_center:.65625,y_center:.71875},{w:1,h:1,x_center:.65625,y_center:.71875},{w:1,h:1,x_center:.71875,y_center:.71875},{w:1,h:1,x_center:.71875,y_center:.71875},{w:1,h:1,x_center:.78125,y_center:.71875},{w:1,h:1,x_center:.78125,y_center:.71875},{w:1,h:1,x_center:.84375,y_center:.71875},{w:1,h:1,x_center:.84375,y_center:.71875},{w:1,h:1,x_center:.90625,y_center:.71875},{w:1,h:1,x_center:.90625,y_center:.71875},{w:1,h:1,x_center:.96875,y_center:.71875},{w:1,h:1,x_center:.96875,y_center:.71875},{w:1,h:1,x_center:.03125,y_center:.78125},{w:1,h:1,x_center:.03125,y_center:.78125},{w:1,h:1,x_center:.09375,y_center:.78125},{w:1,h:1,x_center:.09375,y_center:.78125},{w:1,h:1,x_center:.15625,y_center:.78125},{w:1,h:1,x_center:.15625,y_center:.78125},{w:1,h:1,x_center:.21875,y_center:.78125},{w:1,h:1,x_center:.21875,y_center:.78125},{w:1,h:1,x_center:.28125,y_center:.78125},{w:1,h:1,x_center:.28125,y_center:.78125},{w:1,h:1,x_center:.34375,y_center:.78125},{w:1,h:1,x_center:.34375,y_center:.78125},{w:1,h:1,x_center:.40625,y_center:.78125},{w:1,h:1,x_center:.40625,y_center:.78125},{w:1,h:1,x_center:.46875,y_center:.78125},{w:1,h:1,x_center:.46875,y_center:.78125},{w:1,h:1,x_center:.53125,y_center:.78125},{w:1,h:1,x_center:.53125,y_center:.78125},{w:1,h:1,x_center:.59375,y_center:.78125},{w:1,h:1,x_center:.59375,y_center:.78125},{w:1,h:1,x_center:.65625,y_center:.78125},{w:1,h:1,x_center:.65625,y_center:.78125},{w:1,h:1,x_center:.71875,y_center:.78125},{w:1,h:1,x_center:.71875,y_center:.78125},{w:1,h:1,x_center:.78125,y_center:.78125},{w:1,h:1,x_center:.78125,y_center:.78125},{w:1,h:1,x_center:.84375,y_center:.78125},{w:1,h:1,x_center:.84375,y_center:.78125},{w:1,h:1,x_center:.90625,y_center:.78125},{w:1,h:1,x_center:.90625,y_center:.78125},{w:1,h:1,x_center:.96875,y_center:.78125},{w:1,h:1,x_center:.96875,y_center:.78125},{w:1,h:1,x_center:.03125,y_center:.84375},{w:1,h:1,x_center:.03125,y_center:.84375},{w:1,h:1,x_center:.09375,y_center:.84375},{w:1,h:1,x_center:.09375,y_center:.84375},{w:1,h:1,x_center:.15625,y_center:.84375},{w:1,h:1,x_center:.15625,y_center:.84375},{w:1,h:1,x_center:.21875,y_center:.84375},{w:1,h:1,x_center:.21875,y_center:.84375},{w:1,h:1,x_center:.28125,y_center:.84375},{w:1,h:1,x_center:.28125,y_center:.84375},{w:1,h:1,x_center:.34375,y_center:.84375},{w:1,h:1,x_center:.34375,y_center:.84375},{w:1,h:1,x_center:.40625,y_center:.84375},{w:1,h:1,x_center:.40625,y_center:.84375},{w:1,h:1,x_center:.46875,y_center:.84375},{w:1,h:1,x_center:.46875,y_center:.84375},{w:1,h:1,x_center:.53125,y_center:.84375},{w:1,h:1,x_center:.53125,y_center:.84375},{w:1,h:1,x_center:.59375,y_center:.84375},{w:1,h:1,x_center:.59375,y_center:.84375},{w:1,h:1,x_center:.65625,y_center:.84375},{w:1,h:1,x_center:.65625,y_center:.84375},{w:1,h:1,x_center:.71875,y_center:.84375},{w:1,h:1,x_center:.71875,y_center:.84375},{w:1,h:1,x_center:.78125,y_center:.84375},{w:1,h:1,x_center:.78125,y_center:.84375},{w:1,h:1,x_center:.84375,y_center:.84375},{w:1,h:1,x_center:.84375,y_center:.84375},{w:1,h:1,x_center:.90625,y_center:.84375},{w:1,h:1,x_center:.90625,y_center:.84375},{w:1,h:1,x_center:.96875,y_center:.84375},{w:1,h:1,x_center:.96875,y_center:.84375},{w:1,h:1,x_center:.03125,y_center:.90625},{w:1,h:1,x_center:.03125,y_center:.90625},{w:1,h:1,x_center:.09375,y_center:.90625},{w:1,h:1,x_center:.09375,y_center:.90625},{w:1,h:1,x_center:.15625,y_center:.90625},{w:1,h:1,x_center:.15625,y_center:.90625},{w:1,h:1,x_center:.21875,y_center:.90625},{w:1,h:1,x_center:.21875,y_center:.90625},{w:1,h:1,x_center:.28125,y_center:.90625},{w:1,h:1,x_center:.28125,y_center:.90625},{w:1,h:1,x_center:.34375,y_center:.90625},{w:1,h:1,x_center:.34375,y_center:.90625},{w:1,h:1,x_center:.40625,y_center:.90625},{w:1,h:1,x_center:.40625,y_center:.90625},{w:1,h:1,x_center:.46875,y_center:.90625},{w:1,h:1,x_center:.46875,y_center:.90625},{w:1,h:1,x_center:.53125,y_center:.90625},{w:1,h:1,x_center:.53125,y_center:.90625},{w:1,h:1,x_center:.59375,y_center:.90625},{w:1,h:1,x_center:.59375,y_center:.90625},{w:1,h:1,x_center:.65625,y_center:.90625},{w:1,h:1,x_center:.65625,y_center:.90625},{w:1,h:1,x_center:.71875,y_center:.90625},{w:1,h:1,x_center:.71875,y_center:.90625},{w:1,h:1,x_center:.78125,y_center:.90625},{w:1,h:1,x_center:.78125,y_center:.90625},{w:1,h:1,x_center:.84375,y_center:.90625},{w:1,h:1,x_center:.84375,y_center:.90625},{w:1,h:1,x_center:.90625,y_center:.90625},{w:1,h:1,x_center:.90625,y_center:.90625},{w:1,h:1,x_center:.96875,y_center:.90625},{w:1,h:1,x_center:.96875,y_center:.90625},{w:1,h:1,x_center:.03125,y_center:.96875},{w:1,h:1,x_center:.03125,y_center:.96875},{w:1,h:1,x_center:.09375,y_center:.96875},{w:1,h:1,x_center:.09375,y_center:.96875},{w:1,h:1,x_center:.15625,y_center:.96875},{w:1,h:1,x_center:.15625,y_center:.96875},{w:1,h:1,x_center:.21875,y_center:.96875},{w:1,h:1,x_center:.21875,y_center:.96875},{w:1,h:1,x_center:.28125,y_center:.96875},{w:1,h:1,x_center:.28125,y_center:.96875},{w:1,h:1,x_center:.34375,y_center:.96875},{w:1,h:1,x_center:.34375,y_center:.96875},{w:1,h:1,x_center:.40625,y_center:.96875},{w:1,h:1,x_center:.40625,y_center:.96875},{w:1,h:1,x_center:.46875,y_center:.96875},{w:1,h:1,x_center:.46875,y_center:.96875},{w:1,h:1,x_center:.53125,y_center:.96875},{w:1,h:1,x_center:.53125,y_center:.96875},{w:1,h:1,x_center:.59375,y_center:.96875},{w:1,h:1,x_center:.59375,y_center:.96875},{w:1,h:1,x_center:.65625,y_center:.96875},{w:1,h:1,x_center:.65625,y_center:.96875},{w:1,h:1,x_center:.71875,y_center:.96875},{w:1,h:1,x_center:.71875,y_center:.96875},{w:1,h:1,x_center:.78125,y_center:.96875},{w:1,h:1,x_center:.78125,y_center:.96875},{w:1,h:1,x_center:.84375,y_center:.96875},{w:1,h:1,x_center:.84375,y_center:.96875},{w:1,h:1,x_center:.90625,y_center:.96875},{w:1,h:1,x_center:.90625,y_center:.96875},{w:1,h:1,x_center:.96875,y_center:.96875},{w:1,h:1,x_center:.96875,y_center:.96875},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375}]}),Bg=Mr(N=>{const i=to(),ke=Mg(),O=zg(),H=Pg(),se={thumb:[1,2,3,4],indexFinger:[5,6,7,8],middleFinger:[9,10,11,12],ringFinger:[13,14,15,16],pinky:[17,18,19,20],palmBase:[0]};class xe{constructor(Ae){this.pipeline=Ae}static getAnnotations(){return se}async estimateHands(Ae,P){const he=await this.pipeline.estimateHands(Ae,P);if(!he)return[];const me=[];for(const ae of he){const w={};for(const ge of Object.keys(se))w[ge]=se[ge].map(ze=>ae.landmarks[ze]);me.push({confidence:ae.handInViewConfidence,box:ae.boundingBox?[ae.boundingBox.topLeft[0],ae.boundingBox.topLeft[1],ae.boundingBox.bottomRight[0]-ae.boundingBox.topLeft[0],ae.boundingBox.bottomRight[1]-ae.boundingBox.topLeft[1]]:0,landmarks:ae.landmarks,annotations:w})}return me}}N.HandPose=xe;async function Q(Ae){const[P,he]=await Promise.all([i.loadGraphModel(Ae.detector.modelPath,{fromTFHub:Ae.detector.modelPath.includes("tfhub.dev")}),i.loadGraphModel(Ae.skeleton.modelPath,{fromTFHub:Ae.skeleton.modelPath.includes("tfhub.dev")})]),me=new ke.HandDetector(P,Ae.inputSize,H.anchors),ae=new O.HandPipeline(me,he,Ae.inputSize),w=new xe(ae);return w}N.load=Q}),Wg=Mr(N=>{N.body=i=>{if(!i)return[];const ke=[];for(const O of i){const H=O.keypoints.find(P=>P.part==="leftWrist"),se=O.keypoints.find(P=>P.part==="rightWrist"),xe=O.keypoints.find(P=>P.part==="nose");xe&&H&&se&&H.position.y<xe.position.y&&se.position.y<xe.position.y?ke.push("i give up"):xe&&H&&H.position.y<xe.position.y?ke.push("raise left hand"):xe&&se&&se.position.y<xe.position.y&&ke.push("raise right hand");const Q=O.keypoints.find(P=>P.part==="leftShoulder"),Ae=O.keypoints.find(P=>P.part==="rightShoulder");Q&&Ae&&ke.push(`leaning ${Q.position.y>Ae.position.y?"left":"right"}`)}return ke},N.face=i=>{if(!i)return[];const ke=[];for(const O of i)O.annotations.rightCheek&&O.annotations.leftCheek&&O.annotations.rightCheek.length>0&&O.annotations.leftCheek.length>0&&ke.push(`facing ${O.annotations.rightCheek[0][2]>0||O.annotations.leftCheek[0][2]<0?"right":"left"}`);return ke},N.hand=i=>{if(!i)return[];const ke=[];for(const O of i){const H=[];for(const[Q,Ae]of Object.entries(O.annotations))Q!=="palmBase"&&H.push({name:Q.toLowerCase(),position:Ae[0]});const se=H.reduce((Q,Ae)=>Q.position[2]<Ae.position[2]?Q:Ae),xe=H.reduce((Q,Ae)=>Q.position[1]<Ae.position[1]?Q:Ae);ke.push(`${se.name} forward ${xe.name} up`)}return ke}}),Ug=Mr(N=>{const i=function(O,H,se){const xe=function(he,me,ae){const w=new RegExp("\\b"+me+" \\w+ (\\w+)","ig");he.replace(w,(ge,ze)=>(ae[ze]=0,ge))},Q=function(he,me){const ae=O.createShader(me);if(O.shaderSource(ae,he),O.compileShader(ae),!O.getShaderParameter(ae,O.COMPILE_STATUS))throw new Error("Filter: GL compile failed",O.getShaderInfoLog(ae));return ae};this.uniform={},this.attribute={};const Ae=Q(H,O.VERTEX_SHADER),P=Q(se,O.FRAGMENT_SHADER);if(this.id=O.createProgram(),O.attachShader(this.id,Ae),O.attachShader(this.id,P),O.linkProgram(this.id),!O.getProgramParameter(this.id,O.LINK_STATUS))throw new Error("Filter: GL link failed",O.getProgramInfoLog(this.id));O.useProgram(this.id),xe(H,"attribute",this.attribute);for(const he in this.attribute)this.attribute[he]=O.getAttribLocation(this.id,he);xe(H,"uniform",this.uniform),xe(se,"uniform",this.uniform);for(const he in this.uniform)this.uniform[he]=O.getUniformLocation(this.id,he)},ke=function(O){O||(O={});let H=0,se=null,xe=!1,Q=-1,Ae=[null,null],P=[],he=-1,me=-1,ae=null,w=null;const ge=O.canvas||document.createElement("canvas"),ze={},W=ge.getContext("webgl");if(!W)throw new Error("Filter: getContext() failed");this.addFilter=function(ht){const ut=Array.prototype.slice.call(arguments,1),yt=ot[ht];P.push({func:yt,args:ut})},this.reset=function(){P=[]},this.apply=function(ht){if(nt(ht.width,ht.height),H=0,se||(se=W.createTexture()),W.bindTexture(W.TEXTURE_2D,se),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_S,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_T,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MIN_FILTER,W.NEAREST),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MAG_FILTER,W.NEAREST),W.texImage2D(W.TEXTURE_2D,0,W.RGBA,W.RGBA,W.UNSIGNED_BYTE,ht),P.length===0)return Tt(),ge;for(let ut=0;ut<P.length;ut++){xe=ut===P.length-1;const yt=P[ut];yt.func.apply(this,yt.args||[])}return ge};const nt=function(ht,ut){if(ht===he&&ut===me)return;if(ge.width=ht,he=ht,ge.height=ut,me=ut,!ae){const yt=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);ae=W.createBuffer(),W.bindBuffer(W.ARRAY_BUFFER,ae),W.bufferData(W.ARRAY_BUFFER,yt,W.STATIC_DRAW),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}W.viewport(0,0,he,me),Ae=[null,null]},tt=function(ht){return Ae[ht]=Ae[ht]||nr(he,me),Ae[ht]},nr=function(ht,ut){const yt=W.createFramebuffer();W.bindFramebuffer(W.FRAMEBUFFER,yt);const Zt=W.createRenderbuffer();W.bindRenderbuffer(W.RENDERBUFFER,Zt);const ar=W.createTexture();return W.bindTexture(W.TEXTURE_2D,ar),W.texImage2D(W.TEXTURE_2D,0,W.RGBA,ht,ut,0,W.RGBA,W.UNSIGNED_BYTE,null),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MAG_FILTER,W.LINEAR),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MIN_FILTER,W.LINEAR),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_S,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_T,W.CLAMP_TO_EDGE),W.framebufferTexture2D(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,W.TEXTURE_2D,ar,0),W.bindTexture(W.TEXTURE_2D,null),W.bindFramebuffer(W.FRAMEBUFFER,null),{fbo:yt,texture:ar}},Tt=function(ht){let ut=null,yt=null,Zt=!1;H===0?ut=se:ut=tt(Q).texture,H++,xe&&!(ht&it.INTERMEDIATE)?(yt=null,Zt=H%2===0):(Q=(Q+1)%2,yt=tt(Q).fbo),W.bindTexture(W.TEXTURE_2D,ut),W.bindFramebuffer(W.FRAMEBUFFER,yt),W.uniform1f(w.uniform.flipY,Zt?-1:1),W.drawArrays(W.TRIANGLES,0,6)},Qe=function(ht){if(ze[ht])return w=ze[ht],W.useProgram(w.id),w;w=new i(W,xt.VERTEX_IDENTITY,ht);const ut=Float32Array.BYTES_PER_ELEMENT,yt=4*ut;return W.enableVertexAttribArray(w.attribute.pos),W.vertexAttribPointer(w.attribute.pos,2,W.FLOAT,!1,yt,0*ut),W.enableVertexAttribArray(w.attribute.uv),W.vertexAttribPointer(w.attribute.uv,2,W.FLOAT,!1,yt,2*ut),ze[ht]=w,w};let it={INTERMEDIATE:1},xt={};xt.VERTEX_IDENTITY=["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
`),xt.FRAGMENT_IDENTITY=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","void main(void) {","gl_FragColor = texture2D(texture, vUv);","}"].join(`
`);let ot={};ot.colorMatrix=function(ht){const ut=new Float32Array(ht);ut[4]/=255,ut[9]/=255,ut[14]/=255,ut[19]/=255;const yt=ut[18]===1&&ut[3]===0&&ut[8]===0&&ut[13]===0&&ut[15]===0&&ut[16]===0&&ut[17]===0&&ut[19]===0?ot.colorMatrix.SHADER.WITHOUT_ALPHA:ot.colorMatrix.SHADER.WITH_ALPHA,Zt=Qe(yt);W.uniform1fv(Zt.uniform.m,ut),Tt()},ot.colorMatrix.SHADER={},ot.colorMatrix.SHADER.WITH_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[3] * c.a + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[8] * c.a + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14];","gl_FragColor.a = m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19];","}"].join(`
`),ot.colorMatrix.SHADER.WITHOUT_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[14];","gl_FragColor.a = c.a;","}"].join(`
`),ot.brightness=function(ht){const ut=(ht||0)+1;ot.colorMatrix([ut,0,0,0,0,0,ut,0,0,0,0,0,ut,0,0,0,0,0,1,0])},ot.saturation=function(ht){const ut=(ht||0)*2/3+1,yt=(ut-1)*-.5;ot.colorMatrix([ut,yt,yt,0,0,yt,ut,yt,0,0,yt,yt,ut,0,0,0,0,0,1,0])},ot.desaturate=function(){ot.saturation(-1)},ot.contrast=function(ht){const ut=(ht||0)+1,yt=-128*(ut-1);ot.colorMatrix([ut,0,0,0,yt,0,ut,0,0,yt,0,0,ut,0,yt,0,0,0,1,0])},ot.negative=function(){ot.contrast(-2)},ot.hue=function(ht){ht=(ht||0)/180*Math.PI;const ut=Math.cos(ht),yt=Math.sin(ht),Zt=.213,ar=.715,qt=.072;ot.colorMatrix([Zt+ut*(1-Zt)+yt*-Zt,ar+ut*-ar+yt*-ar,qt+ut*-qt+yt*(1-qt),0,0,Zt+ut*-Zt+yt*.143,ar+ut*(1-ar)+yt*.14,qt+ut*-qt+yt*-.283,0,0,Zt+ut*-Zt+yt*-(1-Zt),ar+ut*-ar+yt*ar,qt+ut*(1-qt)+yt*qt,0,0,0,0,0,1,0])},ot.desaturateLuminance=function(){ot.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},ot.sepia=function(){ot.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},ot.brownie=function(){ot.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},ot.vintagePinhole=function(){ot.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},ot.kodachrome=function(){ot.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},ot.technicolor=function(){ot.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},ot.polaroid=function(){ot.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},ot.shiftToBGR=function(){ot.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},ot.convolution=function(ht){const ut=new Float32Array(ht),yt=1/he,Zt=1/me,ar=Qe(ot.convolution.SHADER);W.uniform1fv(ar.uniform.m,ut),W.uniform2f(ar.uniform.px,yt,Zt),Tt()},ot.convolution.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","uniform float m[9];","void main(void) {","vec4 c11 = texture2D(texture, vUv - px);","vec4 c12 = texture2D(texture, vec2(vUv.x, vUv.y - px.y));","vec4 c13 = texture2D(texture, vec2(vUv.x + px.x, vUv.y - px.y));","vec4 c21 = texture2D(texture, vec2(vUv.x - px.x, vUv.y) );","vec4 c22 = texture2D(texture, vUv);","vec4 c23 = texture2D(texture, vec2(vUv.x + px.x, vUv.y) );","vec4 c31 = texture2D(texture, vec2(vUv.x - px.x, vUv.y + px.y) );","vec4 c32 = texture2D(texture, vec2(vUv.x, vUv.y + px.y) );","vec4 c33 = texture2D(texture, vUv + px );","gl_FragColor = ","c11 * m[0] + c12 * m[1] + c22 * m[2] +","c21 * m[3] + c22 * m[4] + c23 * m[5] +","c31 * m[6] + c32 * m[7] + c33 * m[8];","gl_FragColor.a = c22.a;","}"].join(`
`),ot.detectEdges=function(){ot.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},ot.sobelX=function(){ot.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},ot.sobelY=function(){ot.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},ot.sharpen=function(ht){const ut=ht||1;ot.convolution.call(this,[0,-1*ut,0,-1*ut,1+4*ut,-1*ut,0,-1*ut,0])},ot.emboss=function(ht){const ut=ht||1;ot.convolution.call(this,[-2*ut,-1*ut,0,-1*ut,1,1*ut,0,1*ut,2*ut])},ot.blur=function(ht){const ut=ht/7/he,yt=ht/7/me,Zt=Qe(ot.blur.SHADER);W.uniform2f(Zt.uniform.px,0,yt),Tt(it.INTERMEDIATE),W.uniform2f(Zt.uniform.px,ut,0),Tt()},ot.blur.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","void main(void) {","gl_FragColor = vec4(0.0);","gl_FragColor += texture2D(texture, vUv + vec2(-7.0*px.x, -7.0*px.y))*0.0044299121055113265;","gl_FragColor += texture2D(texture, vUv + vec2(-6.0*px.x, -6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2(-5.0*px.x, -5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2(-4.0*px.x, -4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2(-3.0*px.x, -3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2(-2.0*px.x, -2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2(-1.0*px.x, -1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv )*0.159576912161;","gl_FragColor += texture2D(texture, vUv + vec2( 1.0*px.x, 1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv + vec2( 2.0*px.x, 2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2( 3.0*px.x, 3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2( 4.0*px.x, 4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2( 5.0*px.x, 5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;","}"].join(`
`),ot.pixelate=function(ht){const ut=ht/he,yt=ht/me,Zt=Qe(ot.pixelate.SHADER);W.uniform2f(Zt.uniform.size,ut,yt),Tt()},ot.pixelate.SHADER=["precision highp float;","varying vec2 vUv;","uniform vec2 size;","uniform sampler2D texture;","vec2 pixelate(vec2 coord, vec2 size) {","return floor( coord / size ) * size;","}","void main(void) {","gl_FragColor = vec4(0.0);","vec2 coord = pixelate(vUv, size);","gl_FragColor += texture2D(texture, coord);","}"].join(`
`)};N.Canvas=ke}),Vg=Mr(N=>{const i=to(),ke=Ug();let O=null,H=null;function se(xe,Q){let Ae;if(xe instanceof i.Tensor)Ae=i.clone(xe);else{const P=xe.naturalWidth||xe.videoWidth||xe.width||xe.shape&&xe.shape[1]>0,he=xe.naturalHeight||xe.videoHeight||xe.height||xe.shape&&xe.shape[2]>0;let me=P,ae=he;Q.filter.width>0?me=Q.filter.width:Q.filter.height>0&&(me=P*(Q.filter.height/he)),Q.filter.height>0?ae=Q.filter.height:Q.filter.width>0&&(ae=he*(Q.filter.width/P)),(!O||O.width!==me||O.height!==ae)&&(O=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(me,ae):document.createElement("canvas"),O.width!==me&&(O.width=me),O.height!==ae&&(O.height=ae));const w=O.getContext("2d");xe instanceof ImageData?w.putImageData(xe,0,0):w.drawImage(xe,0,0,P,he,0,0,O.width,O.height),Q.filter.enabled&&((!this.fx||!H||O.width!==H.width||O.height!==H.height)&&(H=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(O.width,O.height):document.createElement("canvas"),H.width!==O.width&&(H.width=O.width),H.height!==O.height&&(H.height=O.height),this.fx=i.ENV.flags.IS_BROWSER&&typeof document!="undefined"?new ke.Canvas({canvas:H}):null),this.fx.reset(),this.fx.addFilter("brightness",Q.filter.brightness),Q.filter.contrast!==0&&this.fx.addFilter("contrast",Q.filter.contrast),Q.filter.sharpness!==0&&this.fx.addFilter("sharpen",Q.filter.sharpness),Q.filter.blur!==0&&this.fx.addFilter("blur",Q.filter.blur),Q.filter.saturation!==0&&this.fx.addFilter("saturation",Q.filter.saturation),Q.filter.hue!==0&&this.fx.addFilter("hue",Q.filter.hue),Q.filter.negative&&this.fx.addFilter("negative"),Q.filter.sepia&&this.fx.addFilter("sepia"),Q.filter.vintage&&this.fx.addFilter("brownie"),Q.filter.sepia&&this.fx.addFilter("sepia"),Q.filter.kodachrome&&this.fx.addFilter("kodachrome"),Q.filter.technicolor&&this.fx.addFilter("technicolor"),Q.filter.polaroid&&this.fx.addFilter("polaroid"),Q.filter.pixelate!==0&&this.fx.addFilter("pixelate",Q.filter.pixelate),this.fx.apply(O)),H||(H=O);let ge;if(Q.backend==="webgl"||H instanceof ImageData)ge=i.browser.fromPixels(H);else{const W=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(me,ae):document.createElement("canvas");W.width=me,W.height=ae;const nt=W.getContext("2d");nt.drawImage(H,0,0);const tt=nt.getImageData(0,0,me,ae);ge=i.browser.fromPixels(tt)}const ze=ge.toFloat();Ae=ze.expandDims(0),ge.dispose(),ze.dispose()}return{tensor:Ae,canvas:Q.filter.return?H:null}}N.process=se}),Hg=Mr(N=>{Kh(N,{default:()=>i});var i={backend:"webgl",console:!0,async:!1,profile:!1,deallocate:!1,scoped:!1,videoOptimized:!0,filter:{enabled:!0,width:0,height:0,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"../models/blazeface-back.json",inputSize:256,maxFaces:10,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.5},mesh:{enabled:!0,modelPath:"../models/facemesh.json",inputSize:192},iris:{enabled:!0,modelPath:"../models/iris.json",enlargeFactor:2.3,inputSize:64},age:{enabled:!0,modelPath:"../models/ssrnet-age-imdb.json",inputSize:64,skipFrames:10},gender:{enabled:!0,minConfidence:.8,modelPath:"../models/ssrnet-gender-imdb.json"},emotion:{enabled:!0,inputSize:64,minConfidence:.5,skipFrames:10,modelPath:"../models/emotion.json"}},body:{enabled:!0,modelPath:"../models/posenet.json",inputResolution:257,outputStride:16,maxDetections:10,scoreThreshold:.5,nmsRadius:20},hand:{enabled:!0,inputSize:256,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.5,enlargeFactor:1.65,maxHands:10,detector:{modelPath:"../models/handdetect.json"},skeleton:{modelPath:"../models/handskeleton.json"}}}}),Gg=Mr((N,i)=>{i.exports={name:"@vladmandic/human",version:"0.6.7",description:"human: 3D Face Detection, Body Pose, Hand & Finger Tracking, Iris Tracking, Age & Gender Prediction, Emotion Prediction & Gesture Recognition",sideEffects:!1,main:"dist/human.node.js",module:"dist/human.esm.js",browser:"dist/human.esm.js",author:"Vladimir Mandic <mandic00@live.com>",bugs:{url:"https://github.com/vladmandic/human/issues"},homepage:"https://github.com/vladmandic/human#readme",license:"MIT",engines:{node:">=14.0.0"},repository:{type:"git",url:"git+https://github.com/vladmandic/human.git"},dependencies:{},peerDependencies:{},devDependencies:{"@tensorflow/tfjs":"^2.7.0","@tensorflow/tfjs-node":"^2.7.0","@vladmandic/pilogger":"^0.2.7",dayjs:"^1.9.4",esbuild:"^0.7.22",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.2","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.2.1",rimraf:"^3.0.2",seedrandom:"^3.0.5","simple-git":"^2.21.0"},scripts:{start:"node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",lint:"eslint src/*.js demo/*.js","build-iife":"esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=iife --external:fs --global-name=Human --metafile=dist/human.json --outfile=dist/human.js src/human.js","build-esm-bundle":"esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=esm --external:fs --metafile=dist/human.esm.json --outfile=dist/human.esm.js src/human.js","build-esm-nobundle":"esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=esm --external:@tensorflow --external:fs --metafile=dist/human.esm-nobundle.json --outfile=dist/human.esm-nobundle.js src/human.js","build-node":"esbuild --bundle --minify --platform=node --sourcemap --target=esnext --format=cjs --metafile=dist/human.node.json --outfile=dist/human.node.js src/human.js","build-node-nobundle":"esbuild --bundle --minify --platform=node --sourcemap --target=esnext --format=cjs --external:@tensorflow --metafile=dist/human.node.json --outfile=dist/human.node-nobundle.js src/human.js","build-demo":"esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=esm --external:fs --metafile=dist/demo-browser-index.json --outfile=dist/demo-browser-index.js demo/browser.js",build:"rimraf dist/* && npm run build-iife && npm run build-esm-bundle && npm run build-esm-nobundle && npm run build-node && npm run build-node-nobundle && npm run build-demo && ls -l dist/",update:"npm update --depth 20 --force && npm dedupe && npm prune && npm audit",changelog:"node changelog.js"},keywords:["tensorflowjs","face-detection","face-geometry","body-tracking","hand-tracking","iris-tracking","age-estimation","emotion-detection","gender-prediction","gesture-recognition"]}});const fo=to(),xf=Ng(),Yh=Cg(),Wp=Tg(),_f=Og(),wf=Bg(),Up=Wg(),jg=Vg(),qg=Bp(),Qh=Hg().default,Kg=Gg(),Xg={face:{detector:{skipFrames:0},age:{skipFrames:0},emotion:{skipFrames:0}},hand:{skipFrames:0}},ei=()=>typeof performance!="undefined"?performance.now():parseInt(Number(process.hrtime.bigint())/1e3/1e3);function Zh(...N){const i=ke=>ke&&typeof ke=="object";return N.reduce((ke,O)=>(Object.keys(O||{}).forEach(H=>{const se=ke[H],xe=O[H];Array.isArray(se)&&Array.isArray(xe)?ke[H]=se.concat(...xe):i(se)&&i(xe)?ke[H]=Zh(se,xe):ke[H]=xe}),ke),{})}class bf{constructor(){this.tf=fo,this.version=Kg.version,this.defaults=Qh,this.config=Qh,this.fx=null,this.state="idle",this.numTensors=0,this.analyzeMemoryLeaks=!1,this.checkSanity=!1,this.firstRun=!0,this.models={facemesh:null,posenet:null,handpose:null,iris:null,age:null,gender:null,emotion:null},this.facemesh=xf,this.ssrnet=Yh,this.emotion=Wp,this.posenet=_f,this.handpose=wf}log(...N){N&&this.config.console&&console.log("Human:",...N)}profile(){return this.config.profile?qg.data:{}}analyze(...N){if(!this.analyzeMemoryLeaks)return;const i=fo.engine().state.numTensors,ke=this.numTensors;this.numTensors=i;const O=i-ke;O!==0&&this.log(...N,O)}sanity(N){if(!this.checkSanity)return null;if(!N)return"input is not defined";if(fo.ENV.flags.IS_NODE&&!(N instanceof fo.Tensor))return"input must be a tensor";try{fo.getBackend()}catch{return"backend not loaded"}return null}async load(N){N&&(this.config=Zh(Qh,N)),this.firstRun&&(this.checkBackend(!0),this.log(`version: ${this.version} TensorFlow/JS version: ${fo.version_core}`),this.log("configuration:",this.config),this.log("flags:",fo.ENV.flags),this.firstRun=!1),this.config.face.enabled&&!this.models.facemesh&&(this.log("load model: face"),this.models.facemesh=await xf.load(this.config.face)),this.config.body.enabled&&!this.models.posenet&&(this.log("load model: body"),this.models.posenet=await _f.load(this.config.body)),this.config.hand.enabled&&!this.models.handpose&&(this.log("load model: hand"),this.models.handpose=await wf.load(this.config.hand)),this.config.face.enabled&&this.config.face.age.enabled&&!this.models.age&&(this.log("load model: age"),this.models.age=await Yh.loadAge(this.config)),this.config.face.enabled&&this.config.face.gender.enabled&&!this.models.gender&&(this.log("load model: gender"),this.models.gender=await Yh.loadGender(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.log("load model: emotion"),this.models.emotion=await Wp.load(this.config))}async checkBackend(N){(N||fo.getBackend()!==this.config.backend)&&(this.state="backend",this.log("setting backend:",this.config.backend),await fo.setBackend(this.config.backend),fo.enableProdMode(),this.config.deallocate&&this.config.backend==="webgl"&&(this.log("Changing WebGL: WEBGL_DELETE_TEXTURE_THRESHOLD:",this.config.deallocate),fo.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",this.config.deallocate?0:-1)),await fo.ready())}async detect(N,i={}){this.state="config";const ke={};let O;this.config=Zh(Qh,i),this.config.videoOptimized||(this.config=Zh(this.config,Xg)),this.state="check";const H=this.sanity(N);return H?(this.log(H,N),{error:H}):new Promise(async se=>{let xe,Q,Ae,P;const he=ei();O=ei(),await this.checkBackend(),ke.backend=Math.trunc(ei()-O),O=ei(),this.state="load",await this.load(),ke.load=Math.trunc(ei()-O),this.config.scoped&&fo.engine().startScope(),this.analyze("Start Detect:"),O=ei();const me=jg.process(N,this.config);ke.image=Math.trunc(ei()-O);const ae=[];if(this.config.face.enabled){this.state="run:face",O=ei(),this.analyze("Start FaceMesh:");const ge=await this.models.facemesh.estimateFaces(me.tensor,this.config.face);ke.face=Math.trunc(ei()-O);for(const ze of ge){if(!ze.image||ze.image.isDisposedInternal){this.log("Face object is disposed:",ze.image);continue}this.state="run:agegender",O=ei(),Ae=this.config.face.age.enabled||this.config.face.gender.enabled?await Yh.predict(ze.image,this.config):{},ke.agegender=Math.trunc(ei()-O),this.state="run:emotion",O=ei(),P=this.config.face.emotion.enabled?await Wp.predict(ze.image,this.config):{},ke.emotion=Math.trunc(ei()-O),ze.image.dispose();const W=ze.annotations.leftEyeIris&&ze.annotations.rightEyeIris?Math.max(ze.annotations.leftEyeIris[3][0]-ze.annotations.leftEyeIris[1][0],ze.annotations.rightEyeIris[3][0]-ze.annotations.rightEyeIris[1][0]):0;ae.push({confidence:ze.confidence,box:ze.box,mesh:ze.mesh,annotations:ze.annotations,age:Ae.age,gender:Ae.gender,agConfidence:Ae.confidence,emotion:P,iris:W!==0?Math.trunc(100*11.7/W)/100:0}),this.analyze("End FaceMesh:")}}this.config.async?xe=this.config.body.enabled?this.models.posenet.estimatePoses(me.tensor,this.config.body):[]:(this.state="run:body",O=ei(),this.analyze("Start PoseNet"),xe=this.config.body.enabled?await this.models.posenet.estimatePoses(me.tensor,this.config.body):[],this.analyze("End PoseNet:"),ke.body=Math.trunc(ei()-O)),this.config.async?Q=this.config.hand.enabled?this.models.handpose.estimateHands(me.tensor,this.config.hand):[]:(this.state="run:hand",O=ei(),this.analyze("Start HandPose:"),Q=this.config.hand.enabled?await this.models.handpose.estimateHands(me.tensor,this.config.hand):[],this.analyze("End HandPose:"),ke.hand=Math.trunc(ei()-O)),this.config.async&&([xe,Q]=await Promise.all([xe,Q])),me.tensor.dispose(),this.state="idle",this.config.scoped&&fo.engine().endScope(),this.analyze("End Scope:");let w=[];this.config.gesture.enabled&&(O=ei(),w={body:Up.body(xe),hand:Up.hand(Q),face:Up.face(ae)},ke.gesture=Math.trunc(ei()-O)),ke.total=Math.trunc(ei()-he),se({face:ae,body:xe,hand:Q,gesture:w,performance:ke,canvas:me.canvas})})}}async function Yg(N,i,ke){if(!N)return;const O=i.getContext("2d");O.font=ke.baseFont,O.fillStyle=ke.baseLabel;let H=1;for(const[se,xe]of Object.entries(N))if(xe.length>0){const Q=`${se}: ${xe.join(", ")}`;O.fillText(Q,6,H*(ke.baseLineHeight+24)),H+=1}}async function Qg(N,i,ke,O){if(!N)return;const H=i.getContext("2d");for(const se of N){H.font=ke.baseFont,H.strokeStyle=ke.baseColor,H.fillStyle=ke.baseColor,H.lineWidth=ke.baseLineWidth,H.beginPath(),ke.drawBoxes&&H.rect(se.box[0],se.box[1],se.box[2],se.box[3]);const xe=[];se.agConfidence&&xe.push(`${Math.trunc(100*se.agConfidence)}% ${se.gender||""}`),se.age&&xe.push(`age: ${se.age||""}`),se.iris&&xe.push(`iris: ${se.iris}`),se.emotion&&se.emotion[0]&&xe.push(`${Math.trunc(100*se.emotion[0].score)}% ${se.emotion[0].emotion}`),H.fillStyle=ke.baseLabel;for(const Q in xe)H.fillText(xe[Q],se.box[0]+8,se.box[1]+24+(Q+1)*ke.baseLineHeight);if(H.stroke(),H.lineWidth=1,se.mesh){if(ke.drawPoints)for(const Q of se.mesh)H.fillStyle=ke.useDepth?`rgba(${127.5+2*Q[2]}, ${127.5-2*Q[2]}, 255, 0.5)`:ke.baseColor,H.beginPath(),H.arc(Q[0],Q[1],2,0,2*Math.PI),H.fill();if(ke.drawPolygons)for(let Q=0;Q<O.length/3;Q++){const Ae=[O[Q*3+0],O[Q*3+1],O[Q*3+2]].map(he=>se.mesh[he]),P=new Path2D;P.moveTo(Ae[0][0],Ae[0][1]);for(const he of Ae)P.lineTo(he[0],he[1]);P.closePath(),H.strokeStyle=ke.useDepth?`rgba(${127.5+2*Ae[0][2]}, ${127.5-2*Ae[0][2]}, 255, 0.3)`:ke.baseColor,H.stroke(P),ke.fillPolygons&&(H.fillStyle=ke.useDepth?`rgba(${127.5+2*Ae[0][2]}, ${127.5-2*Ae[0][2]}, 255, 0.3)`:ke.baseColor,H.fill(P))}}}}async function Zg(N,i,ke){if(!N)return;const O=i.getContext("2d");O.lineJoin="round";for(const H of N){if(O.fillStyle=ke.baseColor,O.strokeStyle=ke.baseColor,O.font=ke.baseFont,O.lineWidth=ke.baseLineWidth,ke.drawPoints)for(const se of H.keypoints)O.beginPath(),O.arc(se.position.x,se.position.y,2,0,2*Math.PI),O.fill();if(ke.drawPolygons){const se=new Path2D;let xe;xe=H.keypoints.find(Q=>Q.part==="leftShoulder"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightShoulder"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightHip"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftHip"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftShoulder"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftHip"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftKnee"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftAnkle"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightHip"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightKnee"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightAnkle"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightShoulder"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftShoulder"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftElbow"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftWrist"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftShoulder"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightShoulder"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightElbow"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightWrist"),se.lineTo(xe.position.x,xe.position.y),O.stroke(se)}}}async function Jg(N,i,ke){if(!N)return;const O=i.getContext("2d");O.lineJoin="round";for(const H of N){if(O.font=ke.baseFont,O.lineWidth=ke.baseLineWidth,ke.drawBoxes&&(O.lineWidth=ke.baseLineWidth,O.beginPath(),O.strokeStyle=ke.baseColor,O.fillStyle=ke.baseColor,O.rect(H.box[0],H.box[1],H.box[2],H.box[3]),O.fillStyle=ke.baseLabel,O.fillText("hand",H.box[0]+2,H.box[1]+22,H.box[2]),O.stroke()),ke.drawPoints)for(const se of H.landmarks)O.fillStyle=ke.useDepth?`rgba(${127.5+2*se[2]}, ${127.5-2*se[2]}, 255, 0.5)`:ke.baseColor,O.beginPath(),O.arc(se[0],se[1],2,0,2*Math.PI),O.fill();if(ke.drawPolygons){const se=xe=>{for(let Q=0;Q<xe.length;Q++)O.lineWidth=ke.baseLineWidth,O.beginPath(),O.strokeStyle=ke.useDepth?`rgba(${127.5+2*xe[Q][2]}, ${127.5-2*xe[Q][2]}, 255, 0.5)`:ke.baseColor,O.moveTo(xe[Q>0?Q-1:0][0],xe[Q>0?Q-1:0][1]),O.lineTo(xe[Q][0],xe[Q][1]),O.stroke()};se(H.annotations.indexFinger),se(H.annotations.middleFinger),se(H.annotations.ringFinger),se(H.annotations.pinky),se(H.annotations.thumb)}}}const $g={face:Qg,body:Zg,hand:Jg,gesture:Yg};var vh=$g;let gh=0,kf=!1,Ia={background:"darkslategray",hover:"lightgray",itemBackground:"black",itemColor:"white",buttonBackground:"lightblue",buttonHover:"lightgreen",checkboxOn:"lightgreen",checkboxOff:"lightcoral",rangeBackground:"lightblue",rangeLabel:"white",chartColor:"lightblue"};function ex(){if(kf)return;const N=`
.menu { position: fixed; top: 0rem; right: 0; width: fit-content; padding: 0 0.8rem 0 0.8rem; line-height: 1.8rem; z-index: 10; max-height: calc(100% - 4rem);
box-shadow: 0 0 8px dimgrey; background: ${Ia.background}; border-radius: 1rem; border-color: black; border-style: solid; border-width: thin; }
.menu:hover { box-shadow: 0 0 8px ${Ia.hover}; }
.menu-container { display: block; max-height: 100vh; }
.menu-container-fadeout { max-height: 0; overflow: hidden; transition: max-height, 0.5s ease; }
.menu-container-fadein { max-height: 100vh; overflow: hidden; transition: max-height, 0.5s ease; }
.menu-item { display: flex; white-space: nowrap; padding: 0.2rem; width: max-content; cursor: default; }
.menu-title { text-align: right; cursor: pointer; }
.menu-hr { margin: 0.2rem; border: 1px solid rgba(0, 0, 0, 0.5) }
.menu-label { padding: 0; }
.menu-list { margin-right: 0.8rem; }
select:focus { outline: none; }
.menu-list-item { background: ${Ia.itemBackground}; color: ${Ia.itemColor}; border: none; padding: 0.2rem; font-family: inherit; font-variant: inherit; border-radius: 1rem; }
.menu-chart-title { padding: 0; font-size: 0.8rem; font-weight: 800; align-items: center}
.menu-chart-canvas { background: transparent; margin: 0.2rem 0 0.2rem 0.6rem; }
.menu-button { border: 0; background: ${Ia.buttonBackground}; width: -webkit-fill-available; padding: 8px; margin: 8px 0 8px 0; cursor: pointer; box-shadow: 4px 4px 4px 0 dimgrey; border-radius: 1rem; justify-content: center; }
.menu-button:hover { background: ${Ia.buttonHover}; box-shadow: 4px 4px 4px 0 black; }
.menu-button:focus { outline: none; }
.menu-checkbox { width: 2.8rem; height: 1rem; background: ${Ia.itemBackground}; margin: 0.5rem 0.8rem 0 0; position: relative; border-radius: 1rem; }
.menu-checkbox:after { content: 'OFF'; color: ${Ia.checkboxOff}; position: absolute; right: 0.2rem; top: -0.4rem; font-weight: 800; font-size: 0.5rem; }
.menu-checkbox:before { content: 'ON'; color: ${Ia.checkboxOn}; position: absolute; left: 0.3rem; top: -0.4rem; font-weight: 800; font-size: 0.5rem; }
.menu-checkbox-label { width: 1.3rem; height: 0.8rem; cursor: pointer; position: absolute; top: 0.1rem; left: 0.1rem; z-index: 1; background: ${Ia.checkboxOff}; border-radius: 1rem; transition: left 0.6s ease; }
input[type=checkbox] { visibility: hidden; }
input[type=checkbox]:checked + label { left: 1.4rem; background: ${Ia.checkboxOn}; }
.menu-range { margin: 0 0.8rem 0 0; width: 5rem; background: transparent; color: ${Ia.rangeBackground}; }
.menu-range:before { content: attr(value); color: ${Ia.rangeLabel}; margin: 0 0.4rem 0 0; font-weight: 800; font-size: 0.6rem; position: relative; top: 0.3rem; }
input[type=range] { -webkit-appearance: none; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 1rem; cursor: pointer; background: ${Ia.itemBackground}; border-radius: 1rem; border: 1px; }
input[type=range]::-webkit-slider-thumb { border: 1px solid #000000; margin-top: 0.05rem; height: 0.9rem; width: 1.5rem; border-radius: 1rem; background: ${Ia.rangeBackground}; cursor: pointer; -webkit-appearance: none; }
`,i=document.createElement("style");i.innerHTML=N,document.getElementsByTagName("head")[0].appendChild(i),kf=!0}class tx{constructor(N,i,ke,O){O&&(Ia={...Ia,...O}),ex(),this.createMenu(N,i,ke),this.id=0,this.instance=gh,gh++,this._maxFPS=0,this.hidden=0}createMenu(N,i="",ke={top:null,left:null,bottom:null,right:null}){if(this.menu=document.createElement("div"),this.menu.id=`menu-${gh}`,this.menu.className="menu",ke&&(ke.top&&(this.menu.style.top=ke.top),ke.bottom&&(this.menu.style.bottom=ke.bottom),ke.left&&(this.menu.style.left=ke.left),ke.right&&(this.menu.style.right=ke.right)),this.container=document.createElement("div"),this.container.id=`menu-container-${gh}`,this.container.className="menu-container menu-container-fadein",i!==""){const O=document.createElement("div");O.className="menu-title",O.id=`menu-title-${gh}`,O.innerHTML=i,this.menu.appendChild(O),O.addEventListener("click",()=>{this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"),this.menu.style.borderStyle=this.container.classList.contains("menu-container-fadeout")?"none":"solid"})}this.menu.appendChild(this.container),typeof N=="object"?N.appendChild(this.menu):document.getElementById(N).appendChild(this.menu)}get newID(){return this.id++,`menu-${this.instance}-${this.id}`}get ID(){return`menu-${this.instance}-${this.id}`}get width(){return this.menu.offsetWidth}get height(){return this.menu.offsetHeight}hide(){this.container.classList.contains("menu-container-fadein")&&(this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"))}visible(){return this.container.classList.contains("menu-container-fadein")}toggle(N){if(this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"),this.container.classList.contains("menu-container-fadein")&&N){const i=N.x||(N.touches&&N.touches[0]?N.touches[0].pageX:null),ke=N.y||(N.touches&&N.touches[0]?N.touches[0].pageY:null);i&&(this.menu.style.left=`${i-105}px`),ke&&(this.menu.style.top="5.5rem"),this.menu.offsetLeft<0&&(this.menu.style.left=0),this.menu.offsetLeft+this.menu.offsetWidth>window.innerWidth&&(this.menu.style.left=null,this.menu.style.right=0),this.menu.style.borderStyle="solid"}else this.menu.style.borderStyle="none"}addTitle(N){const i=document.createElement("div");return i.className="menu-title",i.id=this.newID,i.innerHTML=N,this.menu.appendChild(i),i.addEventListener("click",()=>{this.hidden=!this.hidden;const ke=document.getElementsByClassName("menu");for(const O of ke)O.style.display=this.hidden?"none":"block"}),i}addLabel(N){const i=document.createElement("div");return i.className="menu-item menu-label",i.id=this.newID,i.innerHTML=N,this.container.appendChild(i),i}addBool(N,i,ke,O){const H=document.createElement("div");return H.className="menu-item",H.innerHTML=`<div class="menu-checkbox"><input class="menu-checkbox" type="checkbox" id="${this.newID}" ${i[ke]?"checked":""}/><label class="menu-checkbox-label" for="${this.ID}"></label></div>${N}`,this.container.appendChild(H),H.addEventListener("change",se=>{i[ke]=se.target.checked,O&&O(se.target.checked)}),H}async addList(N,i,ke,O){const H=document.createElement("div");H.className="menu-item";let se="";for(const xe of i){const Q=xe===ke?"selected":"";se+=`<option value="${xe}" ${Q}>${xe}</option>`}return H.innerHTML=`<div class="menu-list"><select name="${this.ID}" class="menu-list-item">${se}</select><label for="${this.ID}"></label></div>${N}`,H.style.fontFamily=document.body.style.fontFamily,H.style.fontSize=document.body.style.fontSize,H.style.fontVariant=document.body.style.fontVariant,this.container.appendChild(H),H.addEventListener("change",xe=>{O&&O(i[xe.target.selectedIndex])}),H}addRange(N,i,ke,O,H,se,xe){const Q=document.createElement("div");return Q.className="menu-item",Q.innerHTML=`<input class="menu-range" type="range" id="${this.newID}" min="${O}" max="${H}" step="${se}" value="${i[ke]}">${N}`,this.container.appendChild(Q),Q.addEventListener("change",Ae=>{i[ke]=Ae.target.value,Ae.target.setAttribute("value",Ae.target.value),xe&&xe(Ae.target.value)}),Q}addHTML(N){const i=document.createElement("div");return i.className="menu-item",i.id=this.newID,N&&(i.innerHTML=N),this.container.appendChild(i),i}addButton(N,i,ke){const O=document.createElement("button");return O.className="menu-item menu-button",O.style.fontFamily=document.body.style.fontFamily,O.style.fontSize=document.body.style.fontSize,O.style.fontVariant=document.body.style.fontVariant,O.type="button",O.id=this.newID,O.innerText=N,this.container.appendChild(O),O.addEventListener("click",()=>{O.innerText===N?O.innerText=i:O.innerText=N,ke&&ke(O.innerText!==N)}),O}addValue(N,i,ke=""){const O=document.createElement("div");return O.className="menu-item",O.id=`menu-val-${N}`,O.innerText=`${N}: ${i}${ke}`,this.container.appendChild(O),O}updateValue(N,i,ke=""){const O=document.getElementById(`menu-val-${N}`);O?O.innerText=`${N}: ${i}${ke}`:this.addValue(N,i)}addChart(N,i,ke=200,O=40,H){H&&(Ia.chartColor=H);const se=document.createElement("div");return se.className="menu-item menu-chart-title",se.id=this.newID,se.innerHTML=`<font color=${Ia.chartColor}>${N}</font><canvas id="menu-canvas-${i}" class="menu-chart-canvas" width="${ke}px" height="${O}px"></canvas>`,this.container.appendChild(se),se}async updateChart(N,i){if(!i||i.length===0)return;const ke=document.getElementById(`menu-canvas-${N}`);if(!ke)return;const O=ke.getContext("2d");O.fillStyle=Ia.background,O.fillRect(0,0,ke.width,ke.height);const H=ke.width/i.length,se=1+Math.max(...i),xe=ke.height/se;for(const Q in i){const Ae=O.createLinearGradient(0,(se-i[Q])*xe,0,0);Ae.addColorStop(.1,Ia.chartColor),Ae.addColorStop(.4,Ia.background),O.fillStyle=Ae,O.fillRect(Q*H,0,H-4,ke.height),O.fillStyle=Ia.background,O.font=`${H/1.5}px "Segoe UI"`,O.fillText(Math.round(i[Q]),Q*H+1,ke.height-1,H-1)}}}var Vp=tx;const Ts=new bf,Cn={baseColor:"rgba(173, 216, 230, 0.3)",baseBackground:"rgba(50, 50, 50, 1)",baseLabel:"rgba(173, 216, 230, 0.9)",baseFontProto:'small-caps {size} "Segoe UI"',baseLineWidth:16,baseLineHeightProto:2,columns:2,busy:!1,facing:!0,useWorker:!1,worker:"worker.js",samples:["../assets/sample6.jpg","../assets/sample1.jpg","../assets/sample4.jpg","../assets/sample5.jpg","../assets/sample3.jpg","../assets/sample2.jpg"],drawBoxes:!0,drawPoints:!1,drawPolygons:!0,fillPolygons:!0,useDepth:!0,console:!0,maxFrames:10,modelsPreload:!0,modelsWarmup:!0},yr={backend:"webgl",profile:!1,deallocate:!1,wasm:{path:"../assets"},filter:{enabled:!0,width:0,height:0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},videoOptimized:!0,face:{enabled:!0,detector:{maxFaces:10,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.5},mesh:{enabled:!0},iris:{enabled:!0},age:{enabled:!0,skipFrames:10},gender:{enabled:!0},emotion:{enabled:!0,minConfidence:.5,useGrayscale:!0}},body:{enabled:!0,maxDetections:10,scoreThreshold:.5,nmsRadius:20},hand:{enabled:!0,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.5},gesture:{enabled:!0}};let Vn,ea,Jh,Hp,xh={};const yl=[];function Sf(...N){if(!Array.isArray(N))return N;let i="";for(const ke of N)typeof ke=="object"?i+=JSON.stringify(ke).replace(/{|}|"|\[|\]/g,"").replace(/,/g,", "):i+=ke;return i}const hs=(...N)=>{Cn.console&&console.log(...N)},Es=N=>{document.getElementById("status").innerText=N};function jp(N,i,ke){yl.push(1e3/(performance.now()-Hp)),yl.length>Cn.maxFrames&&yl.shift(),requestAnimationFrame(()=>Gp(N,ke)),Vn.updateChart("FPS",yl);const O=ke.getContext("2d");O.fillStyle=Cn.baseBackground,O.fillRect(0,0,ke.width,ke.height),i.canvas?(i.canvas.width!==ke.width&&(ke.width=i.canvas.width),i.canvas.height!==ke.height&&(ke.height=i.canvas.height),O.drawImage(i.canvas,0,0,i.canvas.width,i.canvas.height,0,0,i.canvas.width,i.canvas.height)):O.drawImage(N,0,0,N.width,N.height,0,0,ke.width,ke.height),vh.face(i.face,ke,Cn,Ts.facemesh.triangulation),vh.body(i.body,ke,Cn),vh.hand(i.hand,ke,Cn),vh.gesture(i.gesture,ke,Cn);const H=Ts.tf.engine(),se=H.backendInstance?`gpu: ${(H.backendInstance.numBytesInGPU?H.backendInstance.numBytesInGPU:0).toLocaleString()} bytes`:"",xe=`system: ${H.state.numBytes.toLocaleString()} bytes ${se} | tensors: ${H.state.numTensors.toLocaleString()}`,Q=i.canvas?`processing: ${i.canvas.width} x ${i.canvas.height}`:"",Ae=Math.trunc(10*yl.reduce((P,he)=>P+he)/yl.length)/10;document.getElementById("log").innerText=`
video: ${xh.name} | facing: ${xh.facing} | resolution: ${xh.width} x ${xh.height} ${Q}
backend: ${Ts.tf.getBackend()} | ${xe} | object size: ${Sf(i).length.toLocaleString()} bytes
performance: ${Sf(i.performance)} FPS:${Ae}
`}async function qp(){if(Cn.busy)return null;Cn.busy=!0;const N=document.getElementById("video"),i=document.getElementById("canvas"),ke=document.getElementById("log"),O=N.srcObject?N.srcObject.getVideoTracks()[0].readyState==="live"&&N.readyState>2&&!N.paused:!1;let H="";if(Es("starting camera"),!navigator.mediaDevices)return H="camera access not supported",ke.innerText+=`
${H}`,hs(H),Es(H),null;let se;try{se=await navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:Cn.facing?"user":"environment",width:window.innerWidth,height:window.innerHeight,resizeMode:"none",contrast:75}})}catch(Ae){ke.innerText+=`
Camera permission denied`,Es("camera permission denied"),hs(Ae)}if(se)N.srcObject=se;else return null;const xe=se.getVideoTracks()[0],Q=xe.getSettings();return hs("camera settings:",Q),hs("camera track:",xe),xh={name:xe.label,width:Q.width,height:Q.height,facing:Q.facingMode==="user"?"front":"back"},new Promise(Ae=>{N.onloadeddata=async()=>{N.width=N.videoWidth,N.height=N.videoHeight,i.width=N.width,i.height=N.height,O&&N.play(),Cn.busy=!1,Ae(N)}})}function rx(N,i,ke){Jh||(hs("Creating worker thread"),Jh=new Worker(Cn.worker,{type:"module"}),Jh.addEventListener("message",O=>jp(N,O.data,ke))),Jh.postMessage({image:i.data.buffer,width:ke.width,height:ke.height,config:yr},[i.data.buffer])}function Gp(N,i){if(Hp=performance.now(),N.srcObject){const ke=N.srcObject.getVideoTracks()[0].readyState==="live"&&N.readyState>2&&!N.paused;if(!ke){N.paused||(hs(`Video not ready: state: ${N.srcObject.getVideoTracks()[0].readyState} stream state: ${N.readyState}`),setTimeout(()=>Gp(N,i),500));return}if(Cn.useWorker){const O=new OffscreenCanvas(i.width,i.height),H=O.getContext("2d");H.drawImage(N,0,0,N.width,N.height,0,0,i.width,i.height);const se=H.getImageData(0,0,i.width,i.height);rx(N,se,i)}else Ts.detect(N,yr).then(O=>{O.error?hs(O.error):jp(N,O,i),yr.profile&&hs("Profile data:",Ts.profile())})}}async function nx(N){return Hp=performance.now(),new Promise(i=>{const ke=new Image;ke.onload=async()=>{hs("Processing image:",ke.src);const O=document.getElementById("canvas");ke.width=ke.naturalWidth,ke.height=ke.naturalHeight,O.width=yr.filter.width&&yr.filter.width>0?yr.filter.width:ke.naturalWidth,O.height=yr.filter.height&&yr.filter.height>0?yr.filter.height:ke.naturalHeight;const H=await Ts.detect(ke,yr);jp(ke,H,O);const se=document.createElement("canvas");se.className="thumbnail",se.width=window.innerWidth/(Cn.columns+.1),se.height=O.height/(window.innerWidth/se.width);const xe=se.getContext("2d");xe.drawImage(O,0,0,O.width,O.height,0,0,se.width,se.height),document.getElementById("samples-container").appendChild(se),ke.src="",i(!0)},ke.src=N})}async function ax(){yr.videoOptimized=!0,document.getElementById("samples-container").style.display="none",document.getElementById("canvas").style.display="block";const N=document.getElementById("video"),i=document.getElementById("canvas");Cn.baseFont=Cn.baseFontProto.replace(/{size}/,"1.3rem"),Cn.baseLineHeight=Cn.baseLineHeightProto,N.srcObject!==null&&!N.paused?(document.getElementById("play").style.display="block",Es("paused"),N.pause()):(await qp(),document.getElementById("play").style.display="none",Es(""),N.play()),Gp(N,i)}async function ix(){document.getElementById("play").style.display="none",yr.videoOptimized=!1,Cn.baseFont=Cn.baseFontProto.replace(/{size}/,`${1.3*Cn.columns}rem`),Cn.baseLineHeight=Cn.baseLineHeightProto*Cn.columns,document.getElementById("canvas").style.display="none",document.getElementById("samples-container").style.display="block",hs("Running detection of sample images"),Es("processing images"),document.getElementById("samples-container").innerHTML="";for(const N of Cn.samples)await nx(N);Es("")}function ox(){Vn=new Vp(document.body,"...",{top:"1rem",right:"1rem"});const N=Vn.addButton("Start Video","Pause Video",()=>ax());Vn.addButton("Process Images","Process Images",()=>ix()),document.getElementById("play").addEventListener("click",()=>N.click()),Vn.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),Vn.addList("Backend",["cpu","webgl","wasm","webgpu"],yr.backend,i=>yr.backend=i),Vn.addBool("Enable Profiler",yr,"profile"),Vn.addBool("Memory Shield",yr,"deallocate"),Vn.addBool("Use Web Worker",Cn,"useWorker"),Vn.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),Vn.addLabel("Enabled Models"),Vn.addBool("Face Detect",yr.face,"enabled"),Vn.addBool("Face Mesh",yr.face.mesh,"enabled"),Vn.addBool("Face Iris",yr.face.iris,"enabled"),Vn.addBool("Face Age",yr.face.age,"enabled"),Vn.addBool("Face Gender",yr.face.gender,"enabled"),Vn.addBool("Face Emotion",yr.face.emotion,"enabled"),Vn.addBool("Body Pose",yr.body,"enabled"),Vn.addBool("Hand Pose",yr.hand,"enabled"),Vn.addBool("Gesture Analysis",yr.gesture,"enabled"),Vn.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),Vn.addLabel("Model Parameters"),Vn.addRange("Max Objects",yr.face.detector,"maxFaces",0,50,1,i=>{yr.face.detector.maxFaces=parseInt(i),yr.body.maxDetections=parseInt(i),yr.hand.maxHands=parseInt(i)}),Vn.addRange("Skip Frames",yr.face.detector,"skipFrames",0,50,1,i=>{yr.face.detector.skipFrames=parseInt(i),yr.face.emotion.skipFrames=parseInt(i),yr.face.age.skipFrames=parseInt(i),yr.hand.skipFrames=parseInt(i)}),Vn.addRange("Min Confidence",yr.face.detector,"minConfidence",0,1,.05,i=>{yr.face.detector.minConfidence=parseFloat(i),yr.face.emotion.minConfidence=parseFloat(i),yr.hand.minConfidence=parseFloat(i)}),Vn.addRange("Score Threshold",yr.face.detector,"scoreThreshold",.1,1,.05,i=>{yr.face.detector.scoreThreshold=parseFloat(i),yr.hand.scoreThreshold=parseFloat(i),yr.body.scoreThreshold=parseFloat(i)}),Vn.addRange("IOU Threshold",yr.face.detector,"iouThreshold",.1,1,.05,i=>{yr.face.detector.iouThreshold=parseFloat(i),yr.hand.iouThreshold=parseFloat(i)}),Vn.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),Vn.addChart("FPS","FPS"),ea=new Vp(document.body,"...",{top:"1rem",right:"18rem"}),ea.addLabel("UI Options"),ea.addBool("Camera Front/Back",Cn,"facing",()=>qp()),ea.addBool("Use 3D Depth",Cn,"useDepth"),ea.addBool("Draw Boxes",Cn,"drawBoxes"),ea.addBool("Draw Points",Cn,"drawPoints"),ea.addBool("Draw Polygons",Cn,"drawPolygons"),ea.addBool("Fill Polygons",Cn,"fillPolygons"),ea.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),ea.addLabel("Image Processing"),ea.addBool("Enabled",yr.filter,"enabled"),ea.addRange("Image width",yr.filter,"width",0,3840,10,i=>yr.filter.width=parseInt(i)),ea.addRange("Image height",yr.filter,"height",0,2160,10,i=>yr.filter.height=parseInt(i)),ea.addRange("Brightness",yr.filter,"brightness",-1,1,.05,i=>yr.filter.brightness=parseFloat(i)),ea.addRange("Contrast",yr.filter,"contrast",-1,1,.05,i=>yr.filter.contrast=parseFloat(i)),ea.addRange("Sharpness",yr.filter,"sharpness",0,1,.05,i=>yr.filter.sharpness=parseFloat(i)),ea.addRange("Blur",yr.filter,"blur",0,20,1,i=>yr.filter.blur=parseInt(i)),ea.addRange("Saturation",yr.filter,"saturation",-1,1,.05,i=>yr.filter.saturation=parseFloat(i)),ea.addRange("Hue",yr.filter,"hue",0,360,5,i=>yr.filter.hue=parseInt(i)),ea.addRange("Pixelate",yr.filter,"pixelate",0,32,1,i=>yr.filter.pixelate=parseInt(i)),ea.addBool("Negative",yr.filter,"negative"),ea.addBool("Sepia",yr.filter,"sepia"),ea.addBool("Vintage",yr.filter,"vintage"),ea.addBool("Kodachrome",yr.filter,"kodachrome"),ea.addBool("Technicolor",yr.filter,"technicolor"),ea.addBool("Polaroid",yr.filter,"polaroid")}async function sx(){if(hs("Human: demo starting ..."),ox(),document.getElementById("log").innerText=`Human: version ${Ts.version} TensorFlow/JS: version ${Ts.tf.version_core}`,Cn.modelsPreload&&(Es("loading"),await Ts.load()),Cn.modelsWarmup){Es("initializing");const N=new ImageData(50,50);await Ts.detect(N)}Es("human: ready"),document.getElementById("loader").style.display="none",document.getElementById("play").style.display="block"}window.onload=sx;window.onresize=qp;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/**
* @license
* Copyright 2019 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/**
* @license
* Copyright 2020 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/** @license See the LICENSE file. */
//# sourceMappingURL=demo-browser-index.js.map