human/dist/demo-browser-index.js

4212 lines
1.3 MiB

var ff=Object.defineProperty,tg=N=>ff(N,"__esModule",{value:!0}),Or=(N,i)=>()=>(i||(i={exports:{}},N(i.exports,i)),i.exports),Zh=(N,i)=>{tg(N);for(var we in i)ff(N,we,{get:i[we],enumerable:!0})},rg=Or(()=>{}),ng=Or(()=>{}),Bp=Or(()=>{}),ml=Or(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 we(t,e){i(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function M(t,e,n,a){return new(n||(n=Promise))(function(c,d){function y(C){try{_(a.next(C))}catch(F){d(F)}}function v(C){try{_(a.throw(C))}catch(F){d(F)}}function _(C){C.done?c(C.value):new n(function(F){F(C.value)}).then(y,v)}_((a=a.apply(t,e||[])).next())})}function V(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(F){return _([C,F])}}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(F){C=[6,F],c=0}finally{a=d=0}if(C[0]&5)throw C[1];return{value:C[0]?C[1]:void 0,done:!0}}}var oe=1e-7,de=1e-4,X=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}(),Te=function(){function t(){}return t.prototype.time=function(e){return z("time")},t.prototype.read=function(e){return z("read")},t.prototype.readSync=function(e){return z("readSync")},t.prototype.numDataIds=function(){return z("numDataIds")},t.prototype.disposeData=function(e){return z("disposeData")},t.prototype.write=function(e,n,a){return z("write")},t.prototype.move=function(e,n,a,c){return z("move")},t.prototype.memory=function(){return z("memory")},t.prototype.floatPrecision=function(){return z("floatPrecision")},t.prototype.epsilon=function(){return this.floatPrecision()===32?oe:de},t.prototype.batchMatMul=function(e,n,a,c){return z("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 z("fusedBatchMatMul")},t.prototype.slice=function(e,n,a){return z("slice")},t.prototype.stridedSlice=function(e,n,a,c){return z("stridedSlice")},t.prototype.unstack=function(e,n){return z("unstack")},t.prototype.reverse=function(e,n){return z("reverse")},t.prototype.concat=function(e,n){return z("concat")},t.prototype.neg=function(e){return z("neg")},t.prototype.add=function(e,n){return z("add")},t.prototype.addN=function(e){return z("addN")},t.prototype.subtract=function(e,n){return z("subtract")},t.prototype.multiply=function(e,n){return z("multiply")},t.prototype.realDivide=function(e,n){return z("realDivide")},t.prototype.floorDiv=function(e,n){return z("floorDiv")},t.prototype.sum=function(e,n){return z("sum")},t.prototype.prod=function(e,n){return z("prod")},t.prototype.unsortedSegmentSum=function(e,n,a){return z("unsortedSegmentSum")},t.prototype.argMin=function(e,n){return z("argMin")},t.prototype.argMax=function(e,n){return z("argMax")},t.prototype.equal=function(e,n){return z("equal")},t.prototype.notEqual=function(e,n){return z("notEqual")},t.prototype.less=function(e,n){return z("less")},t.prototype.lessEqual=function(e,n){return z("lessEqual")},t.prototype.greater=function(e,n){return z("greater")},t.prototype.greaterEqual=function(e,n){return z("greaterEqual")},t.prototype.logicalNot=function(e){return z("logicalNot")},t.prototype.logicalAnd=function(e,n){return z("logicalAnd")},t.prototype.logicalOr=function(e,n){return z("logicalOr")},t.prototype.where=function(e){return z("where")},t.prototype.select=function(e,n,a){return z("select")},t.prototype.topk=function(e,n,a){return z("topk")},t.prototype.min=function(e,n){return z("min")},t.prototype.minimum=function(e,n){return z("minimum")},t.prototype.mod=function(e,n){return z("mod")},t.prototype.max=function(e,n){return z("max")},t.prototype.maximum=function(e,n){return z("maximum")},t.prototype.all=function(e,n){return z("all")},t.prototype.any=function(e,n){return z("any")},t.prototype.squaredDifference=function(e,n){return z("squaredDifference")},t.prototype.ceil=function(e){return z("ceil")},t.prototype.floor=function(e){return z("floor")},t.prototype.round=function(e){return z("round")},t.prototype.sign=function(e){return z("sign")},t.prototype.isNaN=function(e){return z("isNaN")},t.prototype.isInf=function(e){return z("isInf")},t.prototype.isFinite=function(e){return z("isFinite")},t.prototype.pow=function(e,n){return z("pow")},t.prototype.exp=function(e){return z("exp")},t.prototype.expm1=function(e){return z("expm1")},t.prototype.softmax=function(e,n){return z("softmax")},t.prototype.log=function(e){return z("log")},t.prototype.log1p=function(e){return z("log1p")},t.prototype.sqrt=function(e){return z("sqrt")},t.prototype.rsqrt=function(e){return z("rsqrt")},t.prototype.square=function(e){return z("square")},t.prototype.reciprocal=function(e){return z("reciprocal")},t.prototype.relu=function(e){return z("relu")},t.prototype.relu6=function(e){return z("relu6")},t.prototype.prelu=function(e,n){return z("prelu")},t.prototype.elu=function(e){return z("elu")},t.prototype.eluDer=function(e,n){return z("eluDer")},t.prototype.selu=function(e){return z("selu")},t.prototype.int=function(e){return z("int")},t.prototype.clip=function(e,n,a){return z("clip")},t.prototype.abs=function(e){return z("abs")},t.prototype.complexAbs=function(e){return z("complexAbs")},t.prototype.sigmoid=function(e){return z("sigmoid")},t.prototype.softplus=function(e){return z("softplus")},t.prototype.sin=function(e){return z("sin")},t.prototype.cos=function(e){return z("cos")},t.prototype.tan=function(e){return z("tan")},t.prototype.asin=function(e){return z("asin")},t.prototype.acos=function(e){return z("acos")},t.prototype.atan=function(e){return z("atan")},t.prototype.atan2=function(e,n){return z("atan2")},t.prototype.sinh=function(e){return z("sinh")},t.prototype.cosh=function(e){return z("cosh")},t.prototype.tanh=function(e){return z("tanh")},t.prototype.asinh=function(e){return z("asinh")},t.prototype.acosh=function(e){return z("acosh")},t.prototype.atanh=function(e){return z("atanh")},t.prototype.erf=function(e){return z("erf")},t.prototype.step=function(e,n){return z("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 z("fusedConv2d")},t.prototype.conv2d=function(e,n,a){return z("conv2d")},t.prototype.conv2dDerInput=function(e,n,a){return z("conv2dDerInput")},t.prototype.conv2dDerFilter=function(e,n,a){return z("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 z("fusedDepthwiseConv2D")},t.prototype.depthwiseConv2D=function(e,n,a){return z("depthwiseConv2D")},t.prototype.depthwiseConv2DDerInput=function(e,n,a){return z("depthwiseConv2DDerInput")},t.prototype.depthwiseConv2DDerFilter=function(e,n,a){return z("depthwiseConv2DDerFilter")},t.prototype.conv3d=function(e,n,a){return z("conv3d")},t.prototype.conv3dDerInput=function(e,n,a){return z("conv3dDerInput")},t.prototype.conv3dDerFilter=function(e,n,a){return z("conv3dDerFilter")},t.prototype.maxPool=function(e,n){return z("maxPool")},t.prototype.maxPoolBackprop=function(e,n,a,c){return z("maxPoolBackprop")},t.prototype.avgPool=function(e,n){return z("avgPool")},t.prototype.avgPoolBackprop=function(e,n,a){return z("avgPoolBackprop")},t.prototype.avgPool3d=function(e,n){return z("avgPool3d")},t.prototype.avgPool3dBackprop=function(e,n,a){return z("avgPool3dBackprop")},t.prototype.maxPool3d=function(e,n){return z("maxPool3d")},t.prototype.maxPool3dBackprop=function(e,n,a,c){return z("maxPool3dBackprop")},t.prototype.reshape=function(e,n){return z("reshape")},t.prototype.cast=function(e,n){return z("cast")},t.prototype.tile=function(e,n){return z("tile")},t.prototype.pad=function(e,n,a){return z("pad")},t.prototype.transpose=function(e,n){return z("transpose")},t.prototype.gather=function(e,n,a){return z("gather")},t.prototype.gatherND=function(e,n){return z("gatherND")},t.prototype.scatterND=function(e,n,a){return z("scatterND")},t.prototype.batchToSpaceND=function(e,n,a){return z("batchToSpaceND")},t.prototype.spaceToBatchND=function(e,n,a){return z("spaceToBatchND")},t.prototype.resizeBilinear=function(e,n,a,c){return z("resizeBilinear")},t.prototype.resizeBilinearBackprop=function(e,n,a){return z("resizeBilinearBackprop")},t.prototype.resizeNearestNeighbor=function(e,n,a,c){return z("resizeNearestNeighbor")},t.prototype.resizeNearestNeighborBackprop=function(e,n,a){return z("resizeNearestNeighborBackprop")},t.prototype.batchNorm=function(e,n,a,c,d,y){return z("batchNorm")},t.prototype.localResponseNormalization4D=function(e,n,a,c,d){return z("localResponseNormalization4D")},t.prototype.LRNGrad=function(e,n,a,c,d,y,v){return z("LRNGrad")},t.prototype.multinomial=function(e,n,a,c){return z("multinomial")},t.prototype.oneHot=function(e,n,a,c){return z("oneHot")},t.prototype.cumsum=function(e,n,a,c){return z("cumsum")},t.prototype.nonMaxSuppression=function(e,n,a,c,d){return z("nonMaxSuppression")},t.prototype.fft=function(e){return z("fft")},t.prototype.ifft=function(e){return z("ifft")},t.prototype.complex=function(e,n){return z("complex")},t.prototype.real=function(e){return z("real")},t.prototype.imag=function(e){return z("imag")},t.prototype.cropAndResize=function(e,n,a,c,d,y){return z("cropAndResize")},t.prototype.depthToSpace=function(e,n,a){return z("depthToSpace")},t.prototype.split=function(e,n,a){return z("split")},t.prototype.sparseToDense=function(e,n,a,c){return z("sparseToDense")},t.prototype.diag=function(e){return z("diag")},t.prototype.fill=function(e,n,a){return z("fill")},t.prototype.onesLike=function(e){return z("onesLike")},t.prototype.zerosLike=function(e){return z("zerosLike")},t.prototype.linspace=function(e,n,a){return z("linspace")},t.prototype.dispose=function(){return z("dispose")},t}();function z(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 ye(t,e,n){return Math.max(t,Math.min(e,n))}function ee(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 xe(t,e){var n=Math.random();return e*n+(1-n)*t}function We(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 st(t,e,n){n===void 0&&(n=""),W(mt(t,e),function(){return n+(" Shapes "+t+" and "+e+" must match")})}function ut(t){W(t!=null,function(){return"The input to the tensor constructor must be a non-null value."})}function Kt(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)Kt(t[a],e,n);else e.push(t);return e}function It(t){if(t.length===0)return 1;for(var e=t[0],n=1;n<t.length;n++)e*=t[n];return e}function Ze(t){return t.length===0}function mt(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 yt(t){return t%1===0}function $e(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 ot(t){var e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}function nt(t){for(var e=new Uint32Array(t),n=0;n<t;++n)e[n]=n;return he(e),e}function et(t,e){return e<=t.length?t:t+" ".repeat(e-t.length)}function Qt(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 rr(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 jt(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 yt(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 jr(t,e){for(var n=[],a=[],c=e!=null&&Array.isArray(e)&&e.length===0,d=e==null||c?null:jt(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 Pr(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 ar(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 da(t){return t==="bool"||t==="complex64"||t==="float32"||t==="int32"||t==="string"}function Ha(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 ba(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 ka(t){if(t==null)return 0;var e=0;return t.forEach(function(n){return e+=n.length}),e}function ta(t){return typeof t=="string"||t instanceof String}function Ma(t){return typeof t=="boolean"}function Ti(t){return typeof t=="number"}function Bn(t){return Array.isArray(t)?Bn(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":Ti(t)?"float32":ta(t)?"string":Ma(t)?"bool":"float32"}function ra(t){return!!(t&&t.constructor&&t.call&&t.apply)}function cn(t,e){for(var n=e;n<t;++n)if(t%n===0)return n;return t}function za(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 fn(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(F,B){return F*B}),d=0;d<c;d++)a[d]=fn(t+d*v,y,n);return a}function Gn(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 fn(0,t,e)}function _i(t,e){for(var n=fa(t,e),a=0;a<n.length;a++)n[a]=1;return n}function fa(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 Hi(t,e){var n=t.reduce(function(a,c){return a*c},1);if(e==null||e==="float32")return Gn(t,new Float32Array(n));if(e==="int32")return Gn(t,new Int32Array(n));if(e==="bool")return Gn(t,new Uint8Array(n));throw new Error("Unknown data type "+e)}function Yn(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 Wn(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 Ga(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 Sa(t){return t&&t.then&&typeof t.then=="function"}var hi="tfjsflags",La=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 M(this,void 0,void 0,function(){var n,a;return V(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(Sa(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(hi in n){var a=n[hi].split(",");a.forEach(function(c){var d=c.split(":"),y=d[0],v=d[1];e.urlFlags[y]=Ia(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 xn(e,a[0],a[1]),a.join("=")}),e}function xn(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}function Ia(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 Pa(t){N.ENV=t}var na;function Ei(){if(na==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");na=t}return na}function Gi(){var t=Ei();return t._tfGlobals==null&&(t._tfGlobals=new Map),t._tfGlobals}function Ri(t,e){var n=Gi();if(n.has(t))return n.get(t);var a=e();return n.set(t,a),n.get(t)}var jn="Abs",ni="Acos",pi="Acosh",ma="Add",di="AddN",fi="All",ja="Any",ln="ArgMax",ai="ArgMin",gr="Asin",Ai="Asinh",wi="Atan",no="Atanh",Qn="Atan2",ji="AvgPool",Fi="AvgPoolBackprop",qi="AvgPool3D",Di="AvgPool3DBackprop",ya="BatchMatMul",Oi="BatchToSpaceND",pe="BroadcastTo",Y="Cast",j="Ceil",ne="ClipByValue",re="Complex",Ue="Concat",kt="Conv2D",tt="Conv2DBackpropFilter",ze="Conv2DBackpropInput",Ye="Conv3D",Dt="Conv3DBackpropFilterV2",St="Conv3DBackpropInputV2",Mt="Cos",fr="Cosh",or="Cumsum",aa="CropAndResize",va="DepthToSpace",ia="DepthwiseConv2dNative",qa="DepthwiseConv2dNativeBackpropFilter",bi="DepthwiseConv2dNativeBackpropInput",rn="Diag",hn="Dilation2D",oa="Dilation2DBackpropInput",Jr="Dilation2DBackpropFilter",Vr="Div",Jn="Elu",tn="EluGrad",En="Erf",qn="Equal",sa="Exp",ga="Expm1",Mi="FFT",Aa="Fill",S="FlipLeftRight",x="Floor",k="FloorDiv",K="FusedBatchNorm",Se="GatherV2",be="GatherNd",Je="Greater",Pe="GreaterEqual",gt="Identity",ft="IFFT",Lt="Imag",Wt="IsFinite",Gt="IsInf",Jt="IsNan",wr="Less",Ar="LessEqual",Zt="LinSpace",xr="Log",kn="Log1p",pn="LogicalAnd",zn="LogicalNot",Dr="LogicalOr",Na="LogSoftmax",Sn="LRN",cr="LRNBackprop",$r="Max",Fa="Maximum",mi="MaxPool",Ka="MaxPoolBackprop",Xa="MaxPool3D",ii="MaxPool3DBackprop",zi="MaxPoolWithArgmax",Rn="Mean",Ca="Min",Ki="Minimum",yi="MirrorPad",oi="Mod",qr="Multiply",Io="Negate",nn="NotEqual",Ya="NonMaxSuppressionV3",Ba="NonMaxSuppressionV4",Xi="NonMaxSuppressionV5",si="OnesLike",Li="OneHot",ao="PadV2",mo="Pool",Za="Pow",io="Prelu",Yo="Prod",No="Range",Co="Real",oo="Reciprocal",ua="Relu",Br="Reshape",ca="ResizeNearestNeighbor",Qa="ResizeNearestNeighborGrad",Zn="ResizeBilinear",so="ResizeBilinearGrad",Ta="Relu6",vn="Reverse",Pi="Round",yo="Rsqrt",vo="ScatterNd",Da="SelectV2",go="Selu",To="Slice",Es="Sin",Eo="Sinh",Rs="Sign",As="Sigmoid",Zo="Softplus",Ro="Sqrt",Qo="Sum",Ao="SpaceToBatchND",Jo="SplitV",vi="Softmax",Fs="SquaredDifference",eu="Square",ds="Sub",tu="SparseToDense",Ds="StridedSlice",fs="Tan",Os="Tanh",Ms="Tile",ru="TopK",ms="Transpose",nu="Unique",ys="Unpack",Fo="UnsortedSegmentSum",zs="ZerosLike",$o="Step",xo="FromPixels",vs="RotateWithOffset",Do="_FusedMatMul",Ls="FusedConv2D",es="FusedDepthwiseConv2D",_o=Ri("kernelRegistry",function(){return new Map}),wo=Ri("gradRegistry",function(){return new Map});function Ps(t,e){var n=Mo(t,e);return _o.get(n)}function Bs(t){return wo.get(t)}function gs(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 ts(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 au(t){var e=t.kernelName;wo.has(e)&&Rr().getBool("DEBUG")&&console.warn("Overriding the gradient for '"+e+"'"),wo.set(e,t)}function bu(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 iu(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=gs(t);n.forEach(function(a){var c=Object.assign({},a,{backendName:e});ts(c)})}function Mo(t,e){return e+"_"+t}function xs(t,e){return e==="string"?Yi(t):ki([t],e)}function rs(t,e){return t instanceof Float32Array&&e==="float32"||t instanceof Int32Array&&e==="int32"||t instanceof Uint8Array&&e==="bool"}function ki(t,e){if(e==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=Kt(t)),Rr().getBool("DEBUG")&&ar(t,e),rs(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 zo(){return Rr().platform.now()}function Lo(t,e){return Rr().platform.fetch(t,e)}function Yi(t,e){return e===void 0&&(e="utf-8"),e=e||"utf-8",Rr().platform.encode(t,e)}function ns(t,e){return e===void 0&&(e="utf-8"),e=e||"utf-8",Rr().platform.decode(t,e)}var ae={__proto__:null,createScalarValue:xs,toTypedArray:ki,now:zo,fetch:Lo,encodeString:Yi,decodeString:ns,shuffle:he,clamp:ye,nearestLargerEven:ee,sum:w,randUniform:xe,distSquared:We,assert:W,assertShapesMatch:st,assertNonNull:ut,flatten:Kt,sizeFromShape:It,isScalarShape:Ze,arraysEqual:mt,isInt:yt,tanh:$e,sizeToSquarishShape:ot,createShuffledIndices:nt,rightPad:et,repeatedTry:Qt,inferFromImplicitShape:rr,parseAxisParam:jt,squeezeShape:jr,getTypedArrayFromDType:Pr,getArrayFromDType:_r,checkConversionForErrors:ar,isValidDtype:da,hasEncodingLoss:Ha,isTypedArray:Tn,bytesPerElement:ba,bytesFromStringArray:ka,isString:ta,isBoolean:Ma,isNumber:Ti,inferDtype:Bn,isFunction:ra,nearestDivisor:cn,computeStrides:za,toNestedArray:Gn,makeOnesTypedArray:_i,makeZerosTypedArray:fa,makeZerosNestedTypedArray:Hi,assertNonNegativeIntegerDimensions:Yn,locToIndex:Wn,indexToLoc:Ga,isPromise:Sa},ue=function(){function t(e,n){this.backendTimer=e,this.logger=n,n==null&&(this.logger=new D)}return t.prototype.profileKernel=function(e,n,a){for(var c,d=function(){c=a()},y=this.backendTimer.time(d),v=function(F){var B=c[F];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(F){return F.kernelMs}),extraInfo:y.then(function(F){return F.getExtraProfileInfo!=null?F.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 D=function(){function t(){}return t.prototype.logKernelProfile=function(e,n,a,c,d,y){var v=typeof c=="number"?et(c+"ms",9):c.error,_=et(e,25),C=n.rank,F=n.size,B=et(n.shape.toString(),14),U="";for(var J in d){var me=d[J];if(me!=null){var Le=me.shape||n.shape,Me=Le.length;U+=J+": "+Me+"D "+(Me>0?Le:"")+" "}}console.log("%c"+_+" %c"+v+" %c"+C+"D "+B+" %c"+F+" %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[_],F=!1,B=0;B<e.length;B++)if(a[C.id]){y.outputs.forEach(function(Nt){return a[Nt.id]=!0}),F=!0,c[y.id]=!0;break}if(F)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 me=[],d=0;d<t.length;d++){var y=t[d];if(c[y.id]&&J[y.id]){var Le={};for(var _ in y.inputs){var Me=y.inputs[_];a[Me.id]&&(Le[_]=Me)}var He=Object.assign({},y);He.inputs=Le,He.outputs=y.outputs,me.push(He)}}return me}function H(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(_),F=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 me=v.inputs[U];if(!mt(J.shape,me.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 '"+me.shape+"'"));if(t[me.id]==null)t[me.id]=J;else{var Le=t[me.id];t[me.id]=a(Le,J),Le.dispose()}};for(var B in v.inputs)F(B)},d=e.length-1;d>=0;d--)c(d)}var se=20,te=3,_e=7;function ce(t,e,n,a){var c=za(e),d=fe(t,e,n,c),y=e.length,v=Ae(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 fe(t,e,n,a){var c=It(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 F=C*d,B=0;B<d;B++)y[B]=Math.max(y[B],ve(_[F+B],0,n).length);return y}function ve(t,e,n){var a;return Array.isArray(t)?a=parseFloat(t[0].toFixed(_e))+" + "+(parseFloat(t[1].toFixed(_e))+"j"):ta(t)?a="'"+t+"'":n==="bool"?a=ge(t):a=parseFloat(t.toFixed(_e)).toString(),et(a,e)}function ge(t){return t===0?"false":"true"}function Ae(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[ve(C[0],0,n)]}return n==="bool"?[ge(t[0])]:[t[0].toString()]}if(_===1){if(v>se){var F=te*y,B=Array.from(t.slice(0,F)),U=Array.from(t.slice((v-te)*y,v*y));return n==="complex64"&&(B=Oe(B),U=Oe(U)),["["+B.map(function(nr,yr){return ve(nr,c[yr],n)}).join(", ")+", ..., "+U.map(function(nr,yr){return ve(nr,c[v-te+yr],n)}).join(", ")+"]"]}var J=n==="complex64"?Oe(t):Array.from(t);return["["+J.map(function(nr,yr){return ve(nr,c[yr],n)}).join(", ")+"]"]}var me=e.slice(1),Le=a.slice(1),Me=a[0]*y,He=[];if(v>se){for(var lt=0;lt<te;lt++){var Nt=lt*Me,Ct=Nt+Me;He.push.apply(He,Ae(t.slice(Nt,Ct),me,n,Le,c,!1))}He.push("...");for(var lt=v-te;lt<v;lt++){var Nt=lt*Me,Ct=Nt+Me;He.push.apply(He,Ae(t.slice(Nt,Ct),me,n,Le,c,lt===v-1))}}else for(var lt=0;lt<v;lt++){var Nt=lt*Me,Ct=Nt+Me;He.push.apply(He,Ae(t.slice(Nt,Ct),me,n,Le,c,lt===v-1))}var Bt=_===2?",":"";He[0]="["+He[0]+Bt;for(var lt=1;lt<He.length-1;lt++)He[lt]=" "+He[lt]+Bt;for(var ur=`,
`,lt=2;lt<_;lt++)ur+=`
`;return He[He.length-1]=" "+He[He.length-1]+"]"+(d?"":ur),He}function Oe(t){for(var e=[],n=0;n<t.length;n+=2)e.push([t[n],t[n+1]]);return e}var De=function(){function t(e,n,a){var c=this;if(this.dtype=n,this.shape=e.slice(),this.size=It(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=za(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 at(t){Ve=t}function it(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=It(e),this.strides=za(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 M(this,void 0,void 0,function(){var e;return V(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 M(this,void 0,void 0,function(){var e;return V(this,function(n){switch(n.label){case 0:return[4,this.data()];case 1:return e=n.sent(),[2,Gn(this.shape,e)]}})})},t.prototype.arraySync=function(){return Gn(this.shape,this.dataSync())},t.prototype.data=function(){return M(this,void 0,void 0,function(){var e,n;return V(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 ns(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 ns(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 M(this,void 0,void 0,function(){var e;return V(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 rt=function(t){we(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(!mt(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(rt,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 xt;(function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"})(xt||(xt={}));var ht;(function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"})(ht||(ht={}));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 zt={float32:_t,int32:xt,bool:ht,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 zt[t][e]}function Ut(t){return Pt(t,"int32")}function Tt(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 Xt(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:Tt,assertTypesMatch:Xt,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}(),qt=function(){function t(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Vt}return t.prototype.ready=function(){return M(this,void 0,void 0,function(){var e,n,a,c;return V(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 M(this,void 0,void 0,function(){var n,a,c,d,y;return V(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=gs(this.backendName);n.forEach(function(a){a.setupFunc!=null&&a.setupFunc(e.backendInstance)})},t.prototype.disposeRegisteredKernels=function(e){var n=this,a=gs(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 Te)&&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(F){return F.cast(y,v)},_,null,Y,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,F=[],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 me,Le=Ps(c,this.backendName),Me;if(Le!=null)me=function(){var Nt=_.backend.numDataIds();Me=Le.kernelFunc({inputs:n,attrs:d,backend:_.backend});var Ct=Array.isArray(Me)?Me:[Me];_.shouldCheckForMemLeaks()&&_.checkKernelForMemLeak(c,Nt,Ct);var Bt=Ct.map(function(yr){var Gr=yr.dataId,en=yr.shape,Zr=yr.dtype;return _.makeTensorFromDataId(Gr,en,Zr)});if(B){var ur=_.getTensorsForGradient(c,n,Bt);if(ur==null){v==null&&(v=[]);var nr=Bt.filter(function(yr,Gr){return v[Gr]});ur=(y||[]).slice().concat(nr)}F=_.saveTensorsForBackwardMode(ur)}return Bt};else{var He=function(Nt){if(!B)return;F=Nt.map(function(Ct){return _.keep(_.clone(Ct))})};me=function(){var Nt=_.backend.numDataIds();Me=_.tidy(function(){return e(_.backend,He)});var Ct=Array.isArray(Me)?Me:[Me];return _.shouldCheckForMemLeaks()&&_.checkKernelForMemLeak(c,Nt,Ct),Ct}}var lt;return this.scopedRun(function(){return _.state.kernelDepth++},function(){return _.state.kernelDepth--},function(){!_.ENV.getBool("DEBUG")&&!_.state.profiling?C=me():(lt=_.profiler.profileKernel(c,n,function(){return me()}),_.ENV.getBool("DEBUG")&&_.profiler.logKernelProfile(lt),C=lt.outputs)}),B&&this.addTapeNode(c,n,C,a,F,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(Nt){return n[Nt]!=null?n[Nt].shape:null}),outputShapes:C.map(function(Nt){return Nt.shape}),kernelTimeMs:lt.timeMs,extraInfo:lt.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=Bs(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,F){return y[F]});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"&&ta(e[0])&&(d=e.map(function(F){return Yi(F)}));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=ka(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 rt(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*ba(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 rt||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 M(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C;return V(this,function(F){switch(F.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=F.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,F.label=2;case 2:return d<y.length?(v=y[d],_=v,[4,v.kernelTimeMs]):[3,6];case 3:return _.kernelTimeMs=F.sent(),C=v,[4,v.extraInfo];case 4:C.extraInfo=F.sent(),F.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=Bs(e);C!=null&&(c=C.gradFunc),c!=null&&(_.gradient=function(F){return F=F.map(function(B,U){if(B==null){var J=a[U],me=fa(J.size,J.dtype);return v.makeTensor(me,J.shape,J.dtype)}return B}),c(F.length>1?F:F[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==null?lr(y.shape):a,H(_,v,function(F){return d.tidy(F)},br);var C=n.map(function(F){return _[F.id]});return d.state.gradientDepth===0&&(d.state.activeTape.forEach(function(F){for(var B=0,U=F.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(ra(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(ra(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,_),F=Array.isArray(C)?C:[C];W(F.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(F.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 F.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 M(this,void 0,void 0,function(){var n,a;return V(this,function(c){switch(c.label){case 0:return n=zo(),[4,this.backend.time(e)];case 1:return a=c.sent(),a.wallMs=zo()-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 lr(t){var e=_i(It(t),"float32");return Ie.makeTensor(e,t,"float32")}function ir(){var t=Ei();if(t._tfengine==null){var e=new La(t);t._tfengine=new qt(e)}return Pa(t._tfengine.ENV),at(function(){return t._tfengine}),t._tfengine}var Ie=ir();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,ma)}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 pr(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Fr={__proto__:null,isMobile:Tr,isBrowser:pr},mr=Rr();mr.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.")}),mr.registerFlag("IS_BROWSER",function(){return pr()}),mr.registerFlag("IS_NODE",function(){return typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined"}),mr.registerFlag("IS_CHROME",function(){return typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}),mr.registerFlag("PROD",function(){return!1}),mr.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",function(){return mr.getBool("DEBUG")}),mr.registerFlag("DEPRECATION_WARNINGS_ENABLED",function(){return!0}),mr.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 _n(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 _n(a,t.dtype,e,n),t;var c=Bn(t);if(c!=="string"&&["bool","int32","float32"].indexOf(a)>=0&&(c=a),_n(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"?ki(t,c):Kt(t,[],v);return Ie.makeTensor(_,y,c)}function In(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 wn="__op";function Re(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+wn;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 Sa(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 Un(t,e){var n=ie(t,"real","complex"),a=ie(e,"imag","complex");st(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,re)}var Ln=Re({complex_:Un});function Oa(t,e,n,a){if(a==null&&(a=Bn(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){Yn(e);var c=It(e),d=It(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!==It(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"?ki(t,a):Kt(t,[],!0),Ie.makeTensor(t,e,a)}function An(t,e,n){var a=Er(t,n);return Oa(t,e,a,n)}var Ja={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},Wa=4;function $a(t,e){return M(this,void 0,void 0,function(){var n,a,c,d,y,v,_=this;return V(this,function(C){switch(C.label){case 0:for(n=[],a=[],c=Array.isArray(t)?t.map(function(F){return F.name}):Object.keys(t),d=function(F){var B=c[F],U=Array.isArray(t)?t[F].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 me=new Promise(function(Le){return M(_,void 0,void 0,function(){var Me,He,lt,Nt,Ct,Bt,ur;return V(this,function(nr){switch(nr.label){case 0:return[4,U.bytes()];case 1:for(Me=nr.sent(),He=Me.reduce(function(yr,Gr){return yr+Gr.length},0)+Wa*Me.length,lt=new Uint8Array(He),Nt=0,Ct=0;Ct<Me.length;Ct++)Bt=Me[Ct],ur=new Uint8Array(new Uint32Array([Bt.length]).buffer),lt.set(ur,Nt),Nt+=Wa,lt.set(Bt,Nt),Nt+=Bt.length;return Le(lt),[2]}})})});a.push(me)}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:_a(v),specs:n}]}})})}function xa(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,F=v.shape,B=It(F),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 me=Ja[J.dtype],Le=t.slice(c,c+B*me),Me=J.dtype==="uint8"?new Uint8Array(Le):new Uint16Array(Le);if(C==="float32")if(J.dtype==="uint8"||J.dtype==="uint16"){U=new Float32Array(Me.length);for(var He=0;He<Me.length;He++){var lt=Me[He];U[He]=lt*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 lt=Me[He];U[He]=Math.round(lt*J.scale+J.min)}}else throw new Error("Unsupported dtype in weight '"+_+"': "+C);c+=B*me}else if(C==="string"){var Nt=It(v.shape);U=[];for(var He=0;He<Nt;He++){var Ct=new Uint32Array(t.slice(c,c+Wa))[0];c+=Wa;var Bt=new Uint8Array(t.slice(c,c+Ct));U.push(Bt),c+=Ct}}else{var ur=Ja[C],Le=t.slice(c,c+B*ur);if(C==="float32")U=new Float32Array(Le);else if(C==="int32")U=new Int32Array(Le);else if(C==="bool")U=new Uint8Array(Le);else if(C==="complex64"){U=new Float32Array(Le);for(var nr=new Float32Array(U.length/2),yr=new Float32Array(U.length/2),He=0;He<nr.length;He++)nr[He]=U[He*2],yr[He]=U[He*2+1];var Gr=An(nr,F,"float32"),en=An(yr,F,"float32");n[_]=Ln(Gr,en),Gr.dispose(),en.dispose()}else throw new Error("Unsupported dtype in weight '"+_+"': "+C);c+=B*ur}C!=="complex64"&&(n[_]=An(U,F,C))}return n}function _a(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 Zi=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function Bi(t){return Zi?Buffer.byteLength(t):new Blob([t]).size}function Mr(t){if(Zi)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 ei(t){if(Zi){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 as(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:Bi(JSON.stringify(t.modelTopology)),weightSpecsBytes:t.weightSpecs==null?0:Bi(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 ou(){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=ou();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 ui=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}(),ku=function(t){return ui.registerSaveRouter(t)},Su=function(t){return ui.registerLoadRouter(t)},lc=function(t){return ui.getSaveHandlers(t)},_s=function(t,e){return ui.getLoadHandlers(t,e)},Si="tensorflowjs",ws=1,bo="models_store",uo="model_info_store";function Iu(){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 su(t){var e=t.result;e.createObjectStore(bo,{keyPath:"modelPath"}),e.createObjectStore(uo,{keyPath:"modelPath"})}var bs=function(){function t(e){if(this.indexedDB=Iu(),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 M(this,void 0,void 0,function(){return V(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 M(this,void 0,void 0,function(){return V(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(Si,ws);y.onupgradeneeded=function(){return su(y)},y.onsuccess=function(){var v=y.result;if(n==null){var _=v.transaction(bo,"readonly"),C=_.objectStore(bo),F=C.get(a.modelPath);F.onsuccess=function(){if(F.result==null)return v.close(),d(new Error("Cannot find model with path '"+a.modelPath+"' in IndexedDB."));c(F.result.modelArtifacts)},F.onerror=function(Me){return v.close(),d(F.error)},_.oncomplete=function(){return v.close()}}else{var B=dn(n),U=v.transaction(uo,"readwrite"),J=U.objectStore(uo),me=J.put({modelPath:a.modelPath,modelArtifactsInfo:B}),Le;me.onsuccess=function(){Le=v.transaction(bo,"readwrite");var Me=Le.objectStore(bo),He=Me.put({modelPath:a.modelPath,modelArtifacts:n,modelArtifactsInfo:B});He.onsuccess=function(){return c({modelArtifactsInfo:B})},He.onerror=function(lt){J=U.objectStore(uo);var Nt=J.delete(a.modelPath);Nt.onsuccess=function(){return v.close(),d(He.error)},Nt.onerror=function(Ct){return v.close(),d(He.error)}}},me.onerror=function(Me){return v.close(),d(me.error)},U.oncomplete=function(){Le==null?v.close():Le.oncomplete=function(){return v.close()}}}},y.onerror=function(v){return d(y.error)}})},t.URL_SCHEME="indexeddb://",t}(),Nu=function(t){return Rr().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(bs.URL_SCHEME)?uu(t.slice(bs.URL_SCHEME.length)):null};ui.registerSaveRouter(Nu),ui.registerLoadRouter(Nu);function uu(t){return new bs(t)}function Cu(t){return t.startsWith(bs.URL_SCHEME)?t.slice(bs.URL_SCHEME.length):t}var hc=function(){function t(){this.indexedDB=Iu()}return t.prototype.listModels=function(){return M(this,void 0,void 0,function(){var e=this;return V(this,function(n){return[2,new Promise(function(a,c){var d=e.indexedDB.open(Si,ws);d.onupgradeneeded=function(){return su(d)},d.onsuccess=function(){var y=d.result,v=y.transaction(uo,"readonly"),_=v.objectStore(uo),C=_.getAll();C.onsuccess=function(){for(var F={},B=0,U=C.result;B<U.length;B++){var J=U[B];F[J.modelPath]=J.modelArtifactsInfo}a(F)},C.onerror=function(F){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 M(this,void 0,void 0,function(){var n=this;return V(this,function(a){return e=Cu(e),[2,new Promise(function(c,d){var y=n.indexedDB.open(Si,ws);y.onupgradeneeded=function(){return su(y)},y.onsuccess=function(){var v=y.result,_=v.transaction(uo,"readwrite"),C=_.objectStore(uo),F=C.get(e),B;F.onsuccess=function(){if(F.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 me=B.objectStore(bo),Le=me.delete(e);Le.onsuccess=function(){return c(F.result.modelArtifactsInfo)},Le.onerror=function(Me){return d(F.error)}};U.onsuccess=J,U.onerror=function(me){return J(),v.close(),d(F.error)}},F.onerror=function(U){return v.close(),d(F.error)},_.oncomplete=function(){B==null?v.close():B.oncomplete=function(){return v.close()}}},y.onerror=function(v){return d(y.error)}})]})})},t}(),co="/",ks="tensorflowjs_models",Tu="info",pc="model_topology",dc="weight_specs",fc="weight_data",vl="model_metadata";function Eu(t){return{info:[ks,t,Tu].join(co),topology:[ks,t,pc].join(co),weightSpecs:[ks,t,dc].join(co),weightData:[ks,t,fc].join(co),modelMetadata:[ks,t,vl].join(co)}}function mc(t){var e=t.split(co);if(e.length<3)throw new Error("Invalid key format: "+t);return e.slice(1,e.length-1).join(co)}function yc(t){return t.startsWith(Ii.URL_SCHEME)?t.slice(Ii.URL_SCHEME.length):t}var Ii=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=Eu(this.modelPath)}return t.prototype.save=function(e){return M(this,void 0,void 0,function(){var n,a,c;return V(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,Mr(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 M(this,void 0,void 0,function(){var e,n,a,c,d,y,v;return V(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=ei(v),[2,n]})})},t.URL_SCHEME="localstorage://",t}(),is=function(t){return Rr().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Ii.URL_SCHEME)?Ss(t.slice(Ii.URL_SCHEME.length)):null};ui.registerSaveRouter(is),ui.registerLoadRouter(is);function Ss(t){return new Ii(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 M(this,void 0,void 0,function(){var e,n,a,c,d,y;return V(this,function(v){for(e={},n=ks+co,a=co+Tu,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 M(this,void 0,void 0,function(){var n,a;return V(this,function(c){if(e=yc(e),n=Eu(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="://",lo=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: "+(""+lo.getSchemes().join(",")));return{scheme:t.split(Wo)[0],path:t.split(Wo)[1]}}function cu(t,e,n){return n===void 0&&(n=!1),M(this,void 0,void 0,function(){var a,c,d,y,v,_,C,F,B;return V(this,function(U){switch(U.label){case 0:return W(t!==e,function(){return"Old path and new path are the same: '"+t+"'"}),a=ui.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=ui.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 F=U.sent(),n&&C?[4,lo.getManager(v).removeModel(_)]:[3,3];case 2:U.sent(),U.label=3;case 3:return[4,y.save(F)];case 4:return B=U.sent(),n&&!C?[4,lo.getManager(v).removeModel(_)]:[3,6];case 5:U.sent(),U.label=6;case 6:return[2,B.modelArtifactsInfo]}})})}function os(){return M(this,void 0,void 0,function(){var t,e,n,a,c,d,y,v;return V(this,function(_){switch(_.label){case 0:t=lo.getSchemes(),e={},n=0,a=t,_.label=1;case 1:return n<a.length?(c=a[n],[4,lo.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 M(this,void 0,void 0,function(){var e,n;return V(this,function(a){return e=Uo(t),n=lo.getManager(e.scheme),[2,n.removeModel(e.path)]})})}function gl(t,e){return M(this,void 0,void 0,function(){var n;return V(this,function(a){return n=!1,[2,cu(t,e,n)]})})}function xl(t,e){return M(this,void 0,void 0,function(){var n;return V(this,function(a){return n=!0,[2,cu(t,e,n)]})})}var Ru=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 Ru);try{lo.registerManager(Ii.URL_SCHEME,new vc)}catch(t){}try{lo.registerManager(bs.URL_SCHEME,new hc)}catch(t){}}var gc={importFetch:function(){return rg()}},Ws,xc=function(){function t(){this.util=ng(),this.textEncoder=new this.util.TextEncoder}return t.prototype.fetch=function(e,n){return Rr().global.fetch!=null?Rr().global.fetch(e,n):(Ws==null&&(Ws=gc.importFetch()),Ws(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",Yn(t),new De(t,e,n)}function lu(t,e){var n=ie(t,"x","cast");if(!da(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,Y,c)}var dr=Re({cast_:lu});function Us(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,gt)}var Ho=Re({clone_:Us});function Au(t,e){e===void 0&&(e=!1),console.log(t.toString(e))}ir();var _c={buffer:Qi,cast:dr,clone:Ho,print:Au};it(_c);var Fu="model",Go=".json",wc=".weights.bin";function Du(t){return new Promise(function(e){return setTimeout(e)}).then(t)}var Vs=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 M(this,void 0,void 0,function(){var n,a,c,d,y,v;return V(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,Du(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,Du(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 M(this,void 0,void 0,function(){var e,n,a=this;return V(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),F=C.modelTopology;if(F==null){y(new Error("modelTopology field is missing from file "+e.name));return}n.length===0&&d({modelTopology:F});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=[],me=[],Le=[];B.forEach(function(Me){Me.paths.forEach(function(He){me.push(He),Le.push(null)}),J.push.apply(J,Me.weights)}),B.forEach(function(Me){Me.paths.forEach(function(He){var lt=new FileReader;lt.onload=function(Nt){var Ct=Nt.target.result,Bt=me.indexOf(He);Le[Bt]=Ct,Le.indexOf(null)===-1&&d({modelTopology:F,weightSpecs:J,weightData:as(Le),format:C.format,generatedBy:C.generatedBy,convertedBy:C.convertedBy,userDefinedMetadata:C.userDefinedMetadata})},lt.onerror=function(Nt){return y("Failed to weights data from file of path '"+He+"'.")},lt.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 F=Po(C);if(a.indexOf(F)!==-1)throw new Error("Duplicate file basename found in weights manifest: "+("'"+F+"'"));if(a.push(F),c.indexOf(F)===-1)throw new Error("Weight file with basename '"+F+"' is not provided.");d[C]=n[c.indexOf(F)]})}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}(),ho=function(t){return Rr().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Vs.URL_SCHEME)?kc(t.slice(Vs.URL_SCHEME.length)):null};ui.registerSaveRouter(ho);function kc(t){return t===void 0&&(t="model"),new Vs(t)}function po(t){return new bc(t)}function Sc(t,e,n,a){y(t),n=n==null?0:n,a=a==null?1:a,v(n,a);var c=0,d=function(_){return _.then(function(C){var F=n+ ++c/t.length*(a-n);return e(F),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 hu(t,e){return M(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,F,B,U;return V(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(me){return n(me,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(me){return me.arrayBuffer()}),C=.5,F=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,F)];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=""),M(this,void 0,void 0,function(){var c,d;return V(this,function(y){return c=function(v){return hu(v,{requestInit:a})},d=Ou(c),[2,d(t,e,n)]})})}function Ou(t){var e=this;return function(n,a,c){return a===void 0&&(a=""),M(e,void 0,void 0,function(){var d,y,v,_,C,F,B,U,J,me;return V(this,function(Le){switch(Le.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 lt=0;Me.weights.forEach(function(Nt){var Ct="quantization"in Nt?Nt.quantization.dtype:Nt.dtype,Bt=Ja[Ct]*It(Nt.shape),ur=function(){d[He]=!0,y[He]==null&&(y[He]=[]),y[He].push({manifestEntry:Nt,groupOffset:lt,sizeBytes:Bt})};c!=null?c.forEach(function(nr,yr){nr===Nt.name&&(ur(),v[yr]=!0)}):ur(),_.push(Nt.name),lt+=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 F=d.reduce(function(Me,He,lt){return He&&Me.push(lt),Me},[]),B=[],F.forEach(function(Me){n[Me].paths.forEach(function(He){var lt=a+(a.endsWith("/")?"":"/")+He;B.push(lt)})}),[4,t(B)];case 1:return U=Le.sent(),J={},me=0,F.forEach(function(Me){for(var He=n[Me].paths.length,lt=0,Nt=0;Nt<He;Nt++)lt+=U[me+Nt].byteLength;for(var Ct=new ArrayBuffer(lt),Bt=new Uint8Array(Ct),ur=0,nr=0;nr<He;nr++){var yr=new Uint8Array(U[me+nr]);Bt.set(yr,ur),ur+=yr.byteLength}var Gr=y[Me];Gr.forEach(function(en){var Zr=Ct.slice(en.groupOffset,en.groupOffset+en.sizeBytes),Qr=xa(Zr,[en.manifestEntry]);for(var Kr in Qr)J[Kr]=Qr[Kr]}),me+=He}),[2,J]}})})}}var Hs="application/octet-stream",fo="application/json",Mu=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 M(this,void 0,void 0,function(){var n,a,c,d;return V(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:fo}),"model.json"),e.weightData!=null&&n.body.append("model.weights.bin",new Blob([e.weightData],{type:Hs}),"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 M(this,void 0,void 0,function(){var e,n,a,c,d,y,v,_,C,F,B,U,J,me,Le;return V(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,F=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 me={modelTopology:d,weightSpecs:B,weightData:U,userDefinedMetadata:F,generatedBy:v,convertedBy:_,format:C},Le=n.modelInitializer,Le&&(me.modelInitializer=Le),[2,me]}})})},t.prototype.loadWeights=function(e){return M(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,F,B,U,J,me,Le,Me,He,lt,Nt,Ct,Bt,ur;return V(this,function(nr){switch(nr.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;_++)F=C[_],v.push.apply(v,F.weights);for(B=[],U=[],J=0,me=e;J<me.length;J++)for(Le=me[J],Me=0,He=Le.paths;Me<He.length;Me++)lt=He[Me],this.weightUrlConverter!=null?U.push(this.weightUrlConverter(lt)):B.push(y+lt+d);return this.weightUrlConverter?(Ct=(Nt=B.push).apply,Bt=[B],[4,Promise.all(U)]):[3,2];case 1:Ct.apply(Nt,Bt.concat([nr.sent()])),nr.label=2;case 2:return[4,hu(B,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress})];case 3:return ur=nr.sent(),[2,[v,as(ur)]]}})})},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(Mu.URL_SCHEME_REGEX)!=null}var Lu=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?pu(t,e):null};ui.registerSaveRouter(Lu),ui.registerLoadRouter(Lu);function pu(t,e){return new Mu(t,e)}function wl(t,e){return pu(t,e)}var du=function(){function t(e){this.modelArtifacts=e}return t.prototype.load=function(){return M(this,void 0,void 0,function(){return V(this,function(e){return[2,this.modelArtifacts]})})},t}(),fu=function(){function t(e){this.saveHandler=e}return t.prototype.save=function(e){return M(this,void 0,void 0,function(){return V(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 du(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 du({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 du({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:a})}function Cc(t){return new fu(t)}var Tc={__proto__:null,browserFiles:po,browserHTTPRequest:wl,concatenateArrayBuffers:as,decodeWeights:xa,encodeWeights:$a,fromMemory:Nc,getLoadHandlers:_s,getModelArtifactsInfoForJSON:dn,getSaveHandlers:lc,http:pu,isHTTPScheme:zu,loadWeights:Ic,registerLoadRouter:Su,registerSaveRouter:ku,weightsLoaderFactory:Ou,withSaveHandler:Cc,copyModel:gl,listModels:os,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=rr(e,n.size),W(n.size===It(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,Br,c)}var Ke=Re({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=Tt(d,y),d=c[0],y=c[1];var v=function(F,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],me=n?d.shape[d.rank-1]:d.shape[d.rank-2],Le=a?y.shape[y.rank-2]:y.shape[y.rank-1],Me=d.shape.slice(0,-2),He=y.shape.slice(0,-2),lt=It(Me),Nt=It(He),Ct=lt===Nt||lt===1||Nt===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=lt>Nt?Me:He,ur=Bt.concat([me,Le]),nr=n?Ke(d,[lt,U,me]):Ke(d,[lt,me,U]),yr=a?Ke(y,[Nt,Le,J]):Ke(y,[Nt,J,Le]),Gr=F.batchMatMul(nr,yr,n,a);return Ke(Gr,ur)},_={a:d,b:y},C={transposeA:n,transposeB:a};return Ie.runKernelFunc(v,_,null,ya,C)}var sn=Re({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,F){return F([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,Li,_)}var Is=Re({oneHot_:Ac});function Fc(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,ms,c)}var $n=Re({transpose_:Fc});function Dc(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=Is(dr(a,"int32"),n),y=Is(dr(c,"int32"),n),v=$n(d),_=sn(v,y);return dr(_,"int32")}var Oc=Re({confusionMatrix_:Dc}),Mc={__proto__:null,confusionMatrix:Oc};function Gs(t,e,n){if(ut(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 Oa(t,e,a,n)}var ss;function zc(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 _=Ps(xo,Ie.backendName);if(_!=null){var C={pixels:t},F={numChannels:e};return Ie.runKernel(xo,C,F)}var B=c?[t.videoWidth,t.videoHeight]:[t.width,t.height],U=B[0],J=B[1],me;y?me=t.getContext("2d").getImageData(0,0,U,J).data:a||n?me=t.data:(d||c)&&(ss==null&&(ss=document.createElement("canvas").getContext("2d")),ss.canvas.width=U,ss.canvas.height=J,ss.drawImage(t,0,0,U,J),me=ss.getImageData(0,0,U,J).data);var Le;if(e===4)Le=new Int32Array(me);else{var Me=U*J;Le=new Int32Array(Me*e);for(var He=0;He<Me;He++)for(var lt=0;lt<e;++lt)Le[He*e+lt]=me[He*4+lt]}var Nt=[J,U,e];return Gs(Le,Nt,"int32")}function Lc(t,e){return M(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,F,B,U,J,me,Le,Me,He;return V(this,function(lt){switch(lt.label){case 0:if(n=ie(t,"img","toPixels"),t instanceof $||(a=n,n=dr(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(_=lt.sent(),C=n.dtype==="float32"?255:1,F=new Uint8ClampedArray(y*d*4),B=0;B<d*y;++B){for(U=[0,0,0,255],J=0;J<v;J++){if(me=_[B*v+J],n.dtype==="float32"){if(me<0||me>1)throw new Error("Tensor values for a float32 Tensor must be in the "+("range [0 - 1] but encountered "+me+"."))}else if(n.dtype==="int32"&&(me<0||me>255))throw new Error("Tensor values for a int32 Tensor must be in the "+("range [0 - 255] but encountered "+me+"."));v===1?(U[0]=me*C,U[1]=me*C,U[2]=me*C):U[J]=me*C}Le=B*4,F[Le+0]=Math.round(U[0]),F[Le+1]=Math.round(U[1]),F[Le+2]=Math.round(U[2]),F[Le+3]=Math.round(U[3])}return e!=null&&(e.width=y,e.height=d,Me=e.getContext("2d"),He=new ImageData(F,y,d),Me.putImageData(He,0,0)),n!==t&&n.dispose(),[2,F]}})})}var mu=Re({fromPixels_:zc}),Pc={__proto__:null,toPixels:Lc,fromPixels:mu};function Pu(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=za(t.shape).map(function(F){return F/_}).concat([1]).slice(0,a);return[v,c,_,C]}var bl={__proto__:null,prepareAndValidate:Pu};function Ji(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 Bu(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)}Ji(n,e,t)}function us(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=It(e.shape)/_,F=za(n.slice(0,c)).concat([1]),B=It(n);return{sliceRank:c,numUpdates:C,sliceSize:y,strides:F,outputSize:B}}var kl={__proto__:null,validateUpdateShape:Ji,validateInput:Bu,calculateShapes:us};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 yu(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,F=new Array(C),B=new Array(C),U=new Array(C);if(e.length&&n>0){var J=e[0],me=n+1;F=jc(y,J,me,a,t),B=Wu(v,J,me,c,t),U=Uc(d,J,me,t)}else for(var Le=0;Le<C;Le++)F[Le]=qc(y,a,d,t,Le,_),B[Le]=Kc(v,c,d,t,Le,_),U[Le]=Uu(d,Le,_);return{begin:F,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 Wu(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 F=0;F<d.length;F++){var B=c[F];d[F]<0&&(d[F]+=B),d[F]=ye(0,d[F],c[F])}return d}function Uu(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=ye(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=ye(0,y,_):y=ye(-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 Vu(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:yu,computeOutShape:Wc,stridesWithElidedDims:Uc,getNormalizedAxes:Gc,startIndicesWithElidedDims:jc,stopIndicesWithElidedDims:Wu,stridesForAxis:Uu,startForAxis:qc,stopForAxis:Kc,isSliceContinous:Sl,computeFlatOffset:Il,parseSliceParams:Vu},Yc=function(){function t(){}return t.prototype.getClassName=function(){return this.constructor.className},t.fromConfig=function(e,n){return new e(n)},t}(),cs=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."}),cs.register(t)}var Nl={__proto__:null,Serializable:Yc,SerializationMap:cs,registerClass:jo},Cl=.001,Hu=.1;function Tl(t,e,n){return n==null&&(n=vu()),Gu(t,e,function(a,c){return js(a,c,n)})}function vu(){return Ie.backend.floatPrecision()===32?Cl:Hu}function Gu(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(!mt(y,v))throw new Error("Arrays have different shapes. "+("Actual: ["+y+"]. Expected: ["+v+"]"))}var _=Tn(t)?t:Kt(t),C=Tn(e)?e:Kt(e);if(_.length!==C.length)throw new Error("Arrays have different lengths actual: "+_.length+" vs "+("expected: "+C.length+`.
`)+("Actual: "+_+`.
`)+("Expected: "+C+"."));for(var F=0;F<C.length;++F){var B=_[F],U=C[F];if(!n(B,U))throw new Error("Arrays differ: actual["+F+"] = "+B+", expected["+F+"] = "+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 ta(t)||ta(t[0])||ta(e)||ta(e[0])?Gu(t,n,function(a,c){return a==c}):Gu(t,e,function(a,c){return js(a,c,0)})}function Al(t,e,n){if(n==null&&(n=vu()),!js(t,e,n))throw new Error("Numbers differ: actual === "+t+", expected === "+e)}function js(t,e,n){return!isFinite(t)&&!isFinite(e)?!0:!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n)}function ju(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 Fl(t,e){expect(new Float32Array(t)).toEqual(new Float32Array(e))}var Dl={__proto__:null,TEST_EPSILON_FLOAT16:Hu,expectArraysClose:Tl,testEpsilon:vu,expectPromiseToFail:El,expectArraysEqual:Rl,expectNumbersClose:Al,expectValuesInRange:ju,expectArrayBuffersEqual:Fl},qu="2.7.0";function Ol(){Rr().set("PROD",!0)}function Ml(){Rr().set("DEBUG",!0)}function Ku(){Rr().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Ea(t){Rr().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function zl(){Ie.disposeVariables()}function Ll(){return Ie}function Pl(){return Ie.memory()}function Zc(t){return Ie.profile(t)}function la(t,e){return Ie.tidy(t,e)}function Ua(t){var e=Ot(t);e.forEach(function(n){return n.dispose()})}function gu(t){return Ie.keep(t)}function Qc(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=Tt(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,ma)}var Cr=Re({add_:Xl});function Yl(t,e){var n,a=ie(t,"a","floorDiv"),c=ie(e,"b","floorDiv");n=Tt(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 Xu=Re({floorDiv_:Yl});function Zl(t,e){var n,a=ie(t,"a","div"),c=ie(e,"b","div");if(n=Tt(a,c),a=n[0],c=n[1],a.dtype==="int32"&&c.dtype==="int32")return Xu(a,c);var d=function(_,C){var F=_.realDivide(a,c);return C([a,c]),F},y={a,b:c},v={};return Ie.runKernelFunc(d,y,null,Vr,v)}var Wr=Re({div_:Zl});function Jc(t,e){var n,a=ie(t,"a","mul"),c=ie(e,"b","mul");n=Tt(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=Re({mul_:Jc});function Ql(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,jn)}var ci=Re({abs_:Ql});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,ni)}var $c=Re({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=Re({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(!mt(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=Re({addN_:eh});function Yu(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 li(t,e){var n=e.map(function(a){return 1});return tl(t,n,e)}function nl(t,e,n){W(Yu(e,n),function(){return t+" supports only inner-most axes for now. "+("Got axes "+e+" and rank-"+n+" input.")})}function $i(t,e){if(Yu(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 _=jt(e,a.shape),C=_,F=$i(C,a.rank);F!=null&&(a=$n(a,F),C=p(C.length,a.rank));var B=v.all(a,C);if(n){var U=li(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=Re({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 _=jt(e,a.shape),C=_,F=$i(C,a.rank);F!=null&&(a=$n(a,F),C=p(C.length,a.rank));var B=v.any(a,C);if(n){var U=li(B.shape,_);return Ke(B,U)}return B},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,ja,y)}var I=Re({any_:g});function R(t,e){e===void 0&&(e=0);var n=ie(t,"x","argMax"),a=function(y,v){v([n]);var _=jt(e,n.shape),C=$i(_,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 P=Re({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 _=jt(e,n.shape),C=$i(_,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,ai,d)}var G=Re({argMin_:L});function Q(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 ke=Re({asin_:Q});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,Ai)}var Fe=Re({asinh_:Ce});function Ee(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,wi)}var Ge=Re({atan_:Ee});function Qe(t,e){var n,a=ie(t,"a","atan2"),c=ie(e,"b","atan2");n=Tt(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,Qn)}var s=Re({atan2_:Qe});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,no)}var r=Re({atanh_:u});function o(t,e,n,a,c,d){c===void 0&&(c="NHWC");var y=t[3],v=e.concat([y]),_=Ft(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],F;if(y==="channelsLast")F=[_,C,t[3],t[3]];else if(y==="channelsFirst")F=[_,C,t[1],t[1]];else throw new Error("Unknown dataFormat "+y);return T(t,F,n,a,c,d,!1,y)}function b(t,e,n,a,c,d,y){y===void 0&&(y="NDHWC");var v=Be(e),_=v[0],C=v[1],F=v[2],B,U;if(y==="NDHWC")U="channelsLast",B=[_,C,F,t[4],t[4]];else if(y==="NCDHW")U="channelsFirst",B=[_,C,F,t[1],t[1]];else throw new Error("Unknown dataFormat "+y);return O(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],F=_[1],B=_[2],U=_[3];if(v==="channelsLast")C=t[0],F=t[1],B=t[2],U=t[3];else if(v==="channelsFirst")C=t[0],U=t[1],F=t[2],B=t[3];else throw new Error("Unknown dataFormat "+v);var J=e[0],me=e[1],Le=e[3],Me=Ne(n),He=Me[0],lt=Me[1],Nt=Ne(a),Ct=Nt[0],Bt=Nt[1],ur=je(J,Ct),nr=je(me,Bt),yr=qe(c,F,B,He,lt,ur,nr,d,v),Gr=yr.padInfo,en=yr.outHeight,Zr=yr.outWidth,Qr=y?Le*U:Le,Kr;return v==="channelsFirst"?Kr=[C,Qr,en,Zr]:v==="channelsLast"&&(Kr=[C,en,Zr,Qr]),{batchSize:C,dataFormat:v,inHeight:F,inWidth:B,inChannels:U,outHeight:en,outWidth:Zr,outChannels:Qr,padInfo:Gr,strideHeight:He,strideWidth:lt,filterHeight:J,filterWidth:me,effectiveFilterHeight:ur,effectiveFilterWidth:nr,dilationHeight:Ct,dilationWidth:Bt,inShape:t,outShape:Kr,filterShape:e}}function O(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],F=_[1],B=_[2],U=_[3],J=_[4];if(y==="channelsLast")C=t[0],F=t[1],B=t[2],U=t[3],J=t[4];else if(y==="channelsFirst")C=t[0],J=t[1],F=t[2],B=t[3],U=t[4];else throw new Error("Unknown dataFormat "+y);var me=e[0],Le=e[1],Me=e[2],He=e[4],lt=Be(n),Nt=lt[0],Ct=lt[1],Bt=lt[2],ur=Be(a),nr=ur[0],yr=ur[1],Gr=ur[2],en=je(me,nr),Zr=je(Le,yr),Qr=je(Me,Gr),Kr=vt(c,F,B,U,Nt,Ct,Bt,en,Zr,Qr,v),Hn=Kr.padInfo,yn=Kr.outDepth,Mn=Kr.outHeight,Js=Kr.outWidth,xi=d?He*J:He,Va;return y==="channelsFirst"?Va=[C,xi,yn,Mn,Js]:y==="channelsLast"&&(Va=[C,yn,Mn,Js,xi]),{batchSize:C,dataFormat:y,inDepth:F,inHeight:B,inWidth:U,inChannels:J,outDepth:yn,outHeight:Mn,outWidth:Js,outChannels:xi,padInfo:Hn,strideDepth:Nt,strideHeight:Ct,strideWidth:Bt,filterDepth:me,filterHeight:Le,filterWidth:Me,effectiveFilterDepth:en,effectiveFilterHeight:Zr,effectiveFilterWidth:Qr,dilationDepth:nr,dilationHeight:yr,dilationWidth:Gr,inShape:t,outShape:Va,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(yt(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(yt(_),function(){return"The output # of columns ("+_+") must be an integer. Change the stride and/or zero pad parameters"}),[v,_]}function Z(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(yt(C),function(){return"The output # of depths ("+C+") must be an integer. Change the stride and/or zero pad parameters"});var F=pt((v-e+2*c)/a+1,d);W(yt(F),function(){return"The output # of rows ("+F+") must be an integer. Change the stride and/or zero pad parameters"});var B=pt((_-e+2*c)/a+1,d);return W(yt(B),function(){return"The output # of columns ("+B+") must be an integer. Change the stride and/or zero pad parameters"}),[C,F,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 Be(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,F,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);F=J[0],B=J[1]}else if(t==="same"){F=Math.ceil(e/a),B=Math.ceil(n/c);var me=Math.max(0,(F-1)*a+d-e),Le=Math.max(0,(B-1)*c+y-n),Me=Math.floor(me/2),He=me-Me,lt=Math.floor(Le/2),Nt=Le-lt;C={top:Me,bottom:He,left:lt,right:Nt,type:"SAME"}}else if(t==="valid")C={top:0,bottom:0,left:0,right:0,type:"VALID"},F=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],lt=_==="channelsLast"?t[2][0]:t[3][0],Nt=_==="channelsLast"?t[2][1]:t[3][1],U=Ct===0&&He===0&&lt===0&&Nt===0?"VALID":"EXPLICIT";C={top:Ct,bottom:He,left:lt,right:Nt,type:U},F=pt((e-d+Ct+He)/a+1,v),B=pt((n-y+lt+Nt)/c+1,v)}else throw Error("Unknown padding parameter: "+t);return{padInfo:C,outHeight:F,outWidth:B}}function vt(t,e,n,a,c,d,y,v,_,C,F){var B,U,J,me;if(typeof t=="number"){var Le=t===0?"VALID":"NUMBER";B={top:t,bottom:t,left:t,right:t,front:t,back:t,type:Le};var Me=Z([e,n,a,1],v,1,c,t,F);U=Me[0],J=Me[1],me=Me[2]}else if(t==="same"){U=Math.ceil(e/c),J=Math.ceil(n/d),me=Math.ceil(a/y);var He=(U-1)*c+v-e,lt=(J-1)*d+_-n,Nt=(me-1)*y+C-a,Ct=Math.floor(He/2),Bt=He-Ct,ur=Math.floor(lt/2),nr=lt-ur,yr=Math.floor(Nt/2),Gr=Nt-yr;B={top:ur,bottom:nr,left:yr,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),me=Math.ceil((a-C+1)/y);else throw Error("Unknown padding parameter: "+t);return{padInfo:B,outDepth:U,outHeight:J,outWidth:me}}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 ct(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 ct(t)||ct(e)}function Ft(t){if(t==="NHWC")return"channelsLast";if(t==="NCHW")return"channelsFirst";throw new Error("Unknown dataFormat "+t)}function sr(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(yt(a),function(){return"Error in avgPool: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var C=function(J,me){var Le=h(v.shape,e,n,1,a,c);return me([v]),Le.filterWidth===1&&Le.filterHeight===1&&mt(Le.inShape,Le.outShape)?v.clone():J.avgPool(v,Le)},F={x:v},B={filterSize:e,strides:n,pad:a,dimRoundingMode:c},U=Ie.runKernelFunc(C,F,null,ji,B);return U=dr(U,d.dtype),_?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var Yt=Re({avgPool_:sr});function $t(t,e,n,a,c,d,y){d===void 0&&(d="NDHWC"),y==null?y=[1,1,1]:Ea("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(yt(a),function(){return"Error in avgPool3d: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var F=function(me,Le){y==null&&(y=[1,1,1]);var Me=b(_.shape,e,n,y,a,c,d);return Le([_]),me.avgPool3d(_,Me)},B={x:_},U={filterSize:e,strides:n,pad:a,dimRoundingMode:c,dataFormat:d,dilations:y},J=Ie.runKernelFunc(F,B,null,qi,U);return J=dr(J,_.dtype),C?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var vr=Re({avgPool3d_:$t});function hr(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 zr(t,e){e===void 0&&(e=0),W(t.length>=1,function(){return"Pass at least one tensor to concat"});var n=In(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 _=jt(e,n[0].shape)[0],C=Ir(n.map(function(U){return U.shape}),_);if(It(C)===0)return An([],C);if(n=n.filter(function(U){return U.size>0}),n.length===1)return n[0];var F=n.map(function(U){return U.shape});hr(F,_);var B=y.concat(n,_);return v(n),B},c=n,d={axis:e};return Ie.runKernelFunc(a,c,null,Ue,d)}var kr=Re({concat_:zr});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,As)}var mn=Re({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=Vu(a,e,n),F=C[0],B=C[1];return Bc(a,F,B),_([a]),v.slice(a,F,B)},d={x:a},y={begin:e,size:n};return Ie.runKernelFunc(c,d,null,To,y)}var er=Re({slice_:Xr});function Dn(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,Os)}var Cn=Re({tanh_:Dn});function bn(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"),F=ie(c,"c","basicLSTMCell"),B=ie(d,"h","basicLSTMCell"),U=kr([C,B],1),J=sn(U,v),me=Cr(J,_),Le=me.shape[0],Me=me.shape[1]/4,He=[Le,Me],lt=er(me,[0,0],He),Nt=er(me,[0,Me],He),Ct=er(me,[0,Me*2],He),Bt=er(me,[0,Me*3],He),ur=Cr(bt(mn(lt),Cn(Nt)),bt(F,mn(Cr(y,Ct)))),nr=bt(Cn(ur),mn(Bt));return[ur,nr]}var un=Re({basicLSTMCell_:bn});function On(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,Oi,v)}var Hr=Re({batchToSpaceND_:On});function ha(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 Ni(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 F;a!=null&&(F=ie(a,"offset","batchNorm")),W(v.rank===_.rank,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),W(F==null||v.rank===F.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=ha(y),U=function(Me,He){return He([B,v,_,C]),Me.batchNorm(B,Wi(v),Wi(_),Wi(F),Wi(C),d)},J={x:B,scale:C,offset:F,mean:v,variance:_},me={varianceEpsilon:d},Le=Ie.runKernelFunc(U,J,null,K,me);return Ke(Le,y.shape)}function Wi(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 Kn=Re({batchNorm_:Ni});function eo(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 F;return a!=null&&(F=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+".")}),F!=null&&W(F.rank===2||F.rank===1,function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 "+("but got rank "+F.rank+".")}),Kn(y,v,_,F,C,d)}var Ui=Re({batchNorm2d_:eo});function qs(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 F;return a!=null&&(F=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+".")}),F!=null&&W(F.rank===3||F.rank===1,function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 "+("but got rank "+F.rank+".")}),Kn(y,v,_,F,C,d)}var Zu=Re({batchNorm3d_:qs});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 F;return a!=null&&(F=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+".")}),F!=null&&W(F.rank===4||F.rank===1,function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 "+("but got rank "+F.rank+".")}),Kn(y,v,_,F,C,d)}var kh=Re({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)},F={x:n},B={shape:e,inputShape:d};return Ie.runKernelFunc(C,F,null,pe,B)}var Qu=Re({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=Re({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,ne,d)}var oh=Re({clipByValue_:ih});function sh(t){return kr(t,0)}var Sh=Re({concat1d_:sh});function uh(t,e){return kr(t,e)}var ep=Re({concat2d_:uh});function ch(t,e){return kr(t,e)}var Ih=Re({concat3d_:ch});function tp(t,e){return kr(t,e)}var Vn=Re({concat4d_:tp});function Ns(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,F=!1;v.rank===3&&(F=!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(yt(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 lt=Ft(c),Nt=T(C.shape,_.shape,n,d,a,y,!1,lt),Ct=Me.conv2d(C,_,Nt);return He([C,_]),Ct},J={x:C,filter:_},me={strides:n,pad:a,dataFormat:c,dilations:d,dimRoundingMode:y},Le=Ie.runKernelFunc(U,J,null,kt,me);return F?Ke(Le,[Le.shape[1],Le.shape[2],Le.shape[3]]):Le}var gi=Re({conv2d_:Ns});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,F=!1;v.rank===2&&(F=!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(yt(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],me=[1,d],Le="NHWC",Me=gi(U,B,J,a,Le,me,y);return F?Ke(Me,[Me.shape[2],Me.shape[3]]):Ke(Me,[Me.shape[0],Me.shape[2],Me.shape[3]])}var Cs=Re({conv1d_:qo});function Nh(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 F=d==="NHWC"?v[3]:v[1],B=d==="NHWC"?_.shape[3]:_.shape[1];W(F===n.shape[2],function(){return"Error in conv2dDerInput: depth of input ("+F+") 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(yt(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 lt=1,Nt=Ft(d),Ct=T(v,n.shape,a,lt,c,y,!1,Nt),Bt=Me.conv2dDerInput(_,n,Ct);return He([_,n]),Bt},J={dy:_,filter:n},me={strides:a,pad:c,dataFormat:d,dimRoundingMode:y,inputShape:v},Le=Ie.runKernelFunc(U,J,null,ze,me);return C?Ke(Le,[Le.shape[1],Le.shape[2],Le.shape[3]]):Le}var Ci=Re({conv2DBackpropInput_:Nh});function rp(t,e,n,a,c,d){var y=ie(t,"x","conv2dTranspose"),v=ie(e,"filter","conv2dTranspose");return Ci(n,y,v,a,c,"NHWC",d)}var Ks=Re({conv2dTranspose_:rp});function np(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 F=function(me,Le){var Me=O(_.shape,v.shape,n,d,a),He=me.conv3d(_,v,Me);return Le([_,v]),He},B={x:_,filter:v},U={strides:n,pad:a,dataFormat:c,dilations:d},J=Ie.runKernelFunc(F,B,null,Ye,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var ap=Re({conv3d_:np});function ip(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 F=function(me){var Le=1,Me=O(d,n.shape,a,Le,c);return me.conv3dDerInput(y,n,Me)},B={dy:y,filter:n},U={pad:c,strides:a,inputShape:d},J=Ie.runKernelFunc(F,B,null,St,U);return v?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var Ch=Re({conv3DBackpropInput_:ip});function kf(t,e,n,a,c){var d=ie(t,"x","conv3dTranspose"),y=ie(e,"filter","conv3dTranspose");return Ch(n,d,y,a,c)}var Sf=Re({conv3dTranspose_:kf});function If(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 Th=Re({cos_:If});function Nf(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,fr)}var op=Re({cosh_:Nf});function Cf(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 F=$i([e],c.rank),B=c;F!=null&&(B=$n(c,F));var U=p(1,c.rank)[0],J=_.cumsum(B,U,n,a);if(C([c]),F!=null){var me=f(F);J=$n(J,me)}return J},y={x:c},v={axis:e,exclusive:n,reverse:a};return Ie.runKernelFunc(d,y,null,or,v)}var sp=Re({cumsum_:Cf});function Tf(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(F){return F.depthToSpace(a,e,n)},_={x:a},C={blockSize:e,dataFormat:n};return Ie.runKernelFunc(v,_,null,va,C)}var Yp=Re({depthToSpace_:Tf});function Ef(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,F=!1;v.rank===3&&(F=!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(yt(a),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+a+".")});var B=function(Le,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),lt=Le.depthwiseConv2D(C,_,He);return Me([C,_]),lt},U={x:C,filter:_},J={strides:n,pad:a,dataFormat:c,dilations:d,dimRoundingMode:y},me=Ie.runKernelFunc(B,U,null,ia,J);return F?Ke(me,[me.shape[1],me.shape[2],me.shape[3]]):me}var lh=Re({depthwiseConv2d_:Ef});function Rf(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,rn)}var Af=Re({diag_:Rf});function Ff(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 F={x:_,filter:v},B={strides:n,pad:a,dilations:c},U=Ie.runKernel(hn,F,B);return C?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var Zp=Re({dilation2d_:Ff});function Df(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 ti(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 pa(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 Of(t,e){var n,a=ie(t,"a","equal"),c=ie(e,"b","equal");n=Tt(a,c),a=n[0],c=n[1],pa(a.shape,c.shape);var d=function(v){return v.equal(a,c)},y={a,b:c};return Ie.runKernelFunc(d,y,null,qn)}var hh=Re({equal_:Of});function Mf(t,e,n){var a=ie(e,"a","where"),c=ie(n,"b","where"),d=ie(t,"condition","where","bool"),y=pa(a.shape,c.shape),v=Qu(a,y),_=Qu(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&&st(d.shape,_.shape,"Error in where: ");var C=function(B,U){var J=B.select(d,v,_);return U([d]),J},F={condition:d,t:v,e:_};return Ie.runKernelFunc(C,F,null,Da)}var ls=Re({where_:Mf});function zf(t){var e=ie(t,"x","zerosLike"),n={x:e};return Ie.runKernelFunc(function(a){return a.zerosLike(e)},n,null,zs)}var gn=Re({zerosLike_:zf});function Lf(t,e){var n,a=ie(t,"a","div"),c=ie(e,"b","div");n=Tt(a,c),a=n[0],c=n[1];var d=Wr(a,c),y=gn(d),v=hh(c,y);return ls(v,y,d)}var Qp=Re({divNoNan_:Lf});function Pf(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]),_=sn(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]]),_=sn(y,v);return Ke(_,[_.size])}else if(n.rank===2&&a.rank===1){var v=Ke(a,[-1,1]),_=sn(n,v);return Ke(_,[_.size])}else{var v=Ke(a,[a.shape[0],a.shape[1]]),_=sn(n,v);return _}}var Jp=Re({dot_:Pf});function Bf(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 up=Re({elu_:Bf});function Wf(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=dr(e,"float32"));var n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.erf(e);return c([e]),d},n,null,En)}var $p=Re({erf_:Wf});function Uf(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,sa)}var hs=Re({exp_:Uf});function Vf(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 ps=Re({expandDims_:Vf});function Hf(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,ga)}var ed=Re({expm1_:Hf});function Gf(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 F=_.tile(a,e);return C([a]),F},d=[a],y={x:a},v={reps:e};return Ie.runKernelFunc(c,y,null,Ms,v,d)}var il=Re({tile_:Gf});function jf(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(ps(v,0),[n[0],1,1]);if(n.length===2)return il(ps(ps(v,0),0),[n[0],n[1],1,1]);if(n.length===3)return il(ps(ps(ps(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 td=Re({eye_:jf});function cp(t,e,n){var a={shape:t,value:e,dtype:n};return Ie.runKernelFunc(function(c){return c.fill(t,e,n)},{},null,Aa,a)}function qf(t){var e=ie(t,"x","floor"),n={x:e};return Ie.runKernelFunc(function(a){return a.floor(e)},n,null,x)}var Eh=Re({floor_:qf}),lp=30;function Kf(t){return t<=lp?t:cn(t,Math.floor(Math.sqrt(t)))}function Xf(t,e){var n=!1,a;for(t<=lp?(a=t,n=!0):a=cn(t,Math.floor(Math.sqrt(t)));!n;)a>e||a===t?n=!0:a=cn(t,a+1);return a}function Yf(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 rd(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 Zf={__proto__:null,segOpComputeOptimalWindowSize:Xf,computeOutShape:Yf,collectGatherOpShapeInfo:rd};function Qf(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 F=jt(n,a.shape)[0],B=rd(a,c,F),U=_.gather(a,Ke(c,[c.size]),F);return C([a,c]),Ke(U,B.outputShape)};return Ie.runKernelFunc(v,d,null,Se,y)}var Rh=Re({gather_:Qf});function Jf(t,e){var n,a=ie(t,"a","greater"),c=ie(e,"b","greater");n=Tt(a,c),a=n[0],c=n[1],pa(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 xu=Re({greater_:Jf});function $f(t,e){var n,a=ie(t,"a","greaterEqual"),c=ie(e,"b","greaterEqual");n=Tt(a,c),a=n[0],c=n[1],pa(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,Pe)}var Ju=Re({greaterEqual_:$f});function e1(t){var e=ie(t,"input","imag"),n=function(c){return c.imag(e)},a={input:e};return Ie.runKernelFunc(n,a,null,Lt)}var Ah=Re({imag_:e1});function t1(t){var e=ie(t,"x","isFinite"),n={x:e};return Ie.runKernelFunc(function(a){return a.isFinite(e)},n,null,Wt)}var nd=Re({isFinite_:t1});function r1(t){var e=ie(t,"x","isInf"),n={x:e};return Ie.runKernelFunc(function(a){return a.isInf(e)},n,null,Gt)}var ad=Re({isInf_:r1});function n1(t){var e=ie(t,"x","isNaN"),n={x:e};return Ie.runKernelFunc(function(a){return a.isNaN(e)},n,null,Jt)}var id=Re({isNaN_:n1});function a1(t,e){var n,a=ie(t,"a","maximum"),c=ie(e,"b","maximum");n=Tt(a,c),a=n[0],c=n[1],a.dtype==="bool"&&(a=dr(a,"int32"),c=dr(c,"int32")),pa(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,Fa)}var ol=Re({maximum_:a1});function Ur(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 Oa(t,n,a,e)}function i1(t,e){e===void 0&&(e=.2);var n=ie(t,"x","leakyRelu");return ol(bt(Ur(e),n),n)}var od=Re({leakyRelu_:i1});function o1(t,e){var n,a=ie(t,"a","less"),c=ie(e,"b","less");n=Tt(a,c),a=n[0],c=n[1],pa(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 Fh=Re({less_:o1});function s1(t,e){var n,a=ie(t,"a","lessEqual"),c=ie(e,"b","lessEqual");n=Tt(a,c),a=n[0],c=n[1],pa(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 $u=Re({lessEqual_:s1});function u1(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,Zt,a)}function c1(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(yt(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 me=U.localResponseNormalization4D(y,e,n,a,c);return J([y,me]),me},C={x:y},F={depthRadius:e,bias:n,alpha:a,beta:c},B=Ie.runKernelFunc(_,C,null,Sn,F);return v?Ke(B,[B.shape[1],B.shape[2],B.shape[3]]):B}var sd=Re({localResponseNormalization_:c1});function l1(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 ec=Re({log_:l1});function h1(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,kn)}var hp=Re({log1p_:h1});function p1(t){return W(ra(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&&st(y.shape,c.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Dh(v),v[0]})}}function d1(t){return W(ra(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=In(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&&st(y.shape,c.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Dh(v),v})}}function f1(t){return W(ra(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 Dh(c),{grad:c[0],value:d}}}function m1(t){return W(ra(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&&st(a.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Dh(a.grads),a}}function ud(t,e){W(ra(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 rt}),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 F={};return e.forEach(function(B,U){C[U]!=null&&(F[B.name]=C[U])}),c!=null&&c.forEach(function(B){return F[B.name]=null}),{value:_,grads:F}}function Ts(t){return Ie.customGrad(t)}function Dh(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 y1(t){var e=ie(t,"x","neg"),n={x:e};return Ie.runKernelFunc(function(a){return a.neg(e)},n,null,Io)}var ri=Re({neg_:y1});function v1(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,Zo)}var pp=Re({softplus_:v1});function g1(t){var e=ie(t,"x","logSigmoid"),n=Ts(function(a){var c=ri(pp(ri(a))),d=function(y){var v=bt(y,mn(ri(a)));return v};return{value:c,gradFunc:d}});return n(e)}var cd=Re({logSigmoid_:g1});function x1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","max"),c=function(v,_){var C=jt(e,a.shape),F=C,B=$i(F,a.rank),U=a;B!=null&&(U=$n(a,B),F=p(F.length,U.rank));var J=v.max(U,F);B!=null&&U.dispose();var me=J;if(n){var Le=li(me.shape,jt(e,a.shape));me=Ke(me,Le),J.dispose()}return _([a,me]),me},d={x:a},y={reductionIndices:e,keepDims:n};return Ie.runKernelFunc(c,d,null,$r,y)}var tc=Re({max_:x1});function _1(t,e){var n,a=ie(t,"a","sub"),c=ie(e,"b","sub");n=Tt(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,ds)}var Lr=Re({sub_:_1});function w1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","sum");a.dtype==="bool"&&(a=dr(a,"int32"));var c=function(v,_){_([a]);var C=jt(e,a.shape),F=$i(C,a.rank),B=C,U=a;F!=null&&(U=$n(a,F),B=p(B.length,a.rank));var J=v.sum(U,B);if(n){var me=li(J.shape,C);J=Ke(J,me)}return J},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,Qo,y)}var Yr=Re({sum_:w1});function b1(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=tc(t,e,!0),F=Lr(t,C),B=Lr(dr(F,"float32"),ec(Yr(hs(F),e,_)));return v([B]),B},c={logits:n},d={axis:e};return Ie.runKernelFunc(a,c,null,Na,d)}var ld=Re({logSoftmax_:b1});function k1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","logSumExp"),c=jt(e,a.shape),d=tc(a,c,!0),y=Lr(a,d),v=hs(y),_=Yr(v,c),C=ec(_),F=Cr(Ke(d,C.shape),C);if(n){var B=li(F.shape,c);return Ke(F,B)}return F}var dp=Re({logSumExp_:k1});function S1(t,e){var n=ie(t,"a","logicalAnd","bool"),a=ie(e,"b","logicalAnd","bool");pa(n.shape,a.shape);var c={a:n,b:a};return Ie.runKernelFunc(function(d){return d.logicalAnd(n,a)},c,null,pn)}var rc=Re({logicalAnd_:S1});function I1(t){var e=ie(t,"x","logicalNot","bool"),n={x:e};return Ie.runKernelFunc(function(a){return a.logicalNot(e)},n,null,zn)}var Oh=Re({logicalNot_:I1});function N1(t,e){var n=ie(t,"a","logicalOr","bool"),a=ie(e,"b","logicalOr","bool");pa(n.shape,a.shape);var c={a:n,b:a};return Ie.runKernelFunc(function(d){return d.logicalOr(n,a)},c,null,Dr)}var fp=Re({logicalOr_:N1});function C1(t,e){var n=ie(t,"a","logicalXor","bool"),a=ie(e,"b","logicalXor","bool");return pa(n.shape,a.shape),rc(fp(t,e),Oh(rc(t,e)))}var hd=Re({logicalXor_:C1});function T1(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(yt(a),function(){return"Error in maxPool: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var C=function(J,me){var Le=h(v.shape,e,n,1,a,c),Me;return Le.filterWidth===1&&Le.filterHeight===1&&mt(Le.inShape,Le.outShape)?Me=v.clone():Me=J.maxPool(v,Le),me([v,Me]),Me},F={x:v},B={filterSize:e,strides:n,pad:a,dimRoundingMode:c},U=Ie.runKernelFunc(C,F,null,mi,B);return _?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var mp=Re({maxPool_:T1});function E1(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]:Ea("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(yt(a),function(){return"Error in maxPool3d: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var F=function(me,Le){y==null&&(y=[1,1,1]);var Me=b(_.shape,e,n,y,a,c,d),He=me.maxPool3d(_,Me);return Le([_,He]),He},B={x:_},U={filterSize:e,strides:n,pad:a,dimRoundingMode:c,dataFormat:d,dilations:y},J=Ie.runKernelFunc(F,B,null,Xa,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var R1=Re({maxPool3d_:E1});function A1(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 F1=Re({maxPoolWithArgmax_:A1});function Xs(t,e){if(e===void 0&&(e="float32"),e==="complex64"){var n=Xs(t,"float32"),a=Xs(t,"float32");return Ln(n,a)}var c=fa(It(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=Xs(t,"float32");return Ln(n,a)}var c=_i(It(t),e);return Ie.makeTensor(c,t,e)}function D1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","mean"),c=jt(e,a.shape),d=rl(a.shape,c),y=d[1],v=It(y),_={x:a},C={axis:e,keepDims:n},F=function(){var U=Ur(v),J=U.dtype===a.dtype?a:dr(a,U.dtype),me=Wr(J,U);return Yr(me,e,n)},B=Ts(function(U){var J=Ie.runKernelFunc(F,_,null,Rn,C),me=function(Le){var Me=U.shape.slice();c.forEach(function(Nt){Me[Nt]=1});var He=Ke(Le,Me),lt=Wr(bt(He,sl(U.shape,"float32")),v);return lt};return{value:J,gradFunc:me}});return B(a)}var ph=Re({mean_:D1});function O1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","min"),c=function(v,_){var C=jt(e,a.shape),F=C,B=$i(F,a.rank),U=a;B!=null&&(U=$n(a,B),F=p(F.length,a.rank));var J=v.min(U,F);B!=null&&U.dispose();var me=J;if(n){var Le=li(me.shape,C);me=Ke(J,Le),J.dispose()}return _([a,me]),me},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,Ca,y)}var Mh=Re({min_:O1});function M1(t,e){var n,a=ie(t,"a","minimum"),c=ie(e,"b","minimum");n=Tt(a,c),a=n[0],c=n[1],a.dtype==="bool"&&(a=dr(a,"int32"),c=dr(c,"int32")),pa(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,Ki)}var zh=Re({minimum_:M1});function z1(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 pd=Re({mirrorPad_:z1});function L1(t,e){var n,a=ie(t,"a","mod"),c=ie(e,"b","mod");n=Tt(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,oi)}var yp=Re({mod_:L1});function P1(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 Xn=Re({square_:P1});function B1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1),t=ie(t,"x","moments");var a=jt(e,t.shape),c=ph(t,a,n),d=c.shape;n||(d=li(c.shape,a));var y=Xn(Lr(dr(t,"float32"),Ke(c,d))),v=ph(y,a,n);return{mean:c,variance:v}}var W1=Re({moments_:B1});function U1(t,e,n,a){for(var c=ie(e,"data","multiRNNCell"),d=In(n,"c","multiRNNCell"),y=In(a,"h","multiRNNCell"),v=c,_=[],C=0;C<t.length;C++){var F=t[C](v,d[C],y[C]);_.push(F[0]),_.push(F[1]),v=F[1]}for(var B=[],U=[],C=0;C<_.length;C+=2)B.push(_[C]),U.push(_[C+1]);return[B,U]}var V1=Re({multiRNNCell_:U1});function H1(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 G1=Re({multinomial_:H1});function j1(t,e){var n,a=ie(t,"a","notEqual"),c=ie(e,"b","notEqual");n=Tt(a,c),a=n[0],c=n[1],pa(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 Lh=Re({notEqual_:j1});function q1(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=Re({real_:q1});function K1(t){var e=ie(t,"x","onesLike"),n=function(c,d){if(e.dtype==="complex64"){var y=vp(dh(e)),v=gn(Ah(e));return Ln(y,v)}return c.onesLike(e)},a={x:e};return Ie.runKernelFunc(n,a,null,si)}var vp=Re({onesLike_:K1});function X1(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 sn(c,d)}var Y1=Re({outerProduct_:X1});function Z1(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,ao,d)}var nc=Re({pad_:Z1});function Q1(t,e,n){return n===void 0&&(n=0),W(e.length===2,function(){return"Invalid number of paddings. Must be length of 2."}),nc(t,[e],n)}var J1=Re({pad1d_:Q1});function $1(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."}),nc(t,e,n)}var em=Re({pad2d_:$1});function tm(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."}),nc(t,e,n)}var rm=Re({pad3d_:tm});function nm(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."}),nc(t,e,n)}var am=Re({pad4d_:nm});function im(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 Ph=Re({spaceToBatchND_:im});function om(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),F=[C.dilationHeight,C.dilationWidth],B;a==="same"?B=um([C.filterHeight,C.filterWidth],F):B=[[0,0],[0,0]];var U=F[0]===1&&F[1]===1,J=sm([C.inHeight,C.inWidth],F,B),me=J[0],Le=J[1],Me=U?a:"valid",He=U?v:Ph(v,F,me),lt=n==="avg"?function(){return Yt(He,e,d,Me)}:function(){return mp(He,e,d,Me)},Nt=lt(),Ct=U?Nt:Hr(Nt,F,Le);return _?Ke(Ct,[Ct.shape[1],Ct.shape[2],Ct.shape[3]]):Ct}function sm(t,e,n){var a=n.map(function(F){return F[0]}),c=n.map(function(F){return F[1]}),d=t.concat(a,c),y=e.map(function(F,B){return(F-d[B]%F)%F}),v=c.map(function(F,B){return F+y[B]}),_=e.map(function(F,B){return[a[B],v[B]]}),C=e.map(function(F,B){return[0,y[B]]});return[_,C]}function um(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 dd=Re({pool_:om});function cm(t,e){var n,a=ie(t,"base","pow"),c=ie(e,"exp","pow");n=Tt(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,Za)}var Ys=Re({pow_:cm});function lm(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,io)}var gp=Re({prelu_:lm});function hm(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","prod");a.dtype==="bool"&&(a=dr(a,"int32"));var c=function(v){var _=jt(e,a.shape),C=$i(_,a.rank),F=_,B=a;C!=null&&(B=$n(a,C),F=p(F.length,a.rank));var U=v.prod(B,F);if(n){var J=li(U.shape,_);U=Ke(U,J)}return U},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,Yo,y)}var fd=Re({prod_:hm});function pm(t,e,n){var a=It(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 dm=Re({rand_:pm}),ul=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ac(t,e){return e={exports:{}},t(e,e.exports),e.exports}var fm=ac(function(t){(function(e,n,a){function c(_){var C=this,F=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=F(" "),C.s1=F(" "),C.s2=F(" "),C.s0-=F(_),C.s0<0&&(C.s0+=1),C.s1-=F(_),C.s1<0&&(C.s1+=1),C.s2-=F(_),C.s2<0&&(C.s2+=1),F=null}function d(_,C){return C.c=_.c,C.s0=_.s0,C.s1=_.s1,C.s2=_.s2,C}function y(_,C){var F=new c(_),B=C&&C.state,U=F.next;return U.int32=function(){return F.next()*4294967296|0},U.double=function(){return U()+(U()*2097152|0)*11102230246251565e-32},U.quick=U,B&&(typeof B=="object"&&d(B,F),U.state=function(){return d(F,{})}),U}function v(){var _=4022871197,C=function(F){F=F.toString();for(var B=0;B<F.length;B++){_+=F.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)}),mm=ac(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 F=0;F<C.length+64;F++)_.x^=C.charCodeAt(F)|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),F=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,me=(U+J)/(1<<21);while(me===0);return me},B.int32=C.next,B.quick=B,F&&(typeof F=="object"&&d(F,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)}),ym=ac(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 F=0;F<C.length+64;F++)_.x^=C.charCodeAt(F)|0,F==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),F=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,me=(U+J)/(1<<21);while(me===0);return me},B.int32=C.next,B.quick=B,F&&(typeof F=="object"&&d(F,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)}),vm=ac(function(t){(function(e,n,a){function c(v){var _=this;_.next=function(){var F=_.x,B=_.i,U,J;return U=F[B],U^=U>>>7,J=U^U<<24,U=F[B+1&7],J^=U^U>>>10,U=F[B+3&7],J^=U^U>>>3,U=F[B+4&7],J^=U^U<<7,U=F[B+7&7],U=U^U<<13,J^=U^U<<9,F[B]=J,_.i=B+1&7,J};function C(F,B){var U,J,me=[];if(B===(B|0))J=me[0]=B;else for(B=""+B,U=0;U<B.length;++U)me[U&7]=me[U&7]<<15^B.charCodeAt(U)+me[U+1&7]<<13;for(;me.length<8;)me.push(0);for(U=0;U<8&&me[U]===0;++U);for(U==8?J=me[7]=-1:J=me[U],F.x=me,F.i=0,U=256;U>0;--U)F.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),F=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,me=(U+J)/(1<<21);while(me===0);return me},B.int32=C.next,B.quick=B,F&&(F.x&&d(F,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)}),gm=ac(function(t){(function(e,n,a){function c(v){var _=this;_.next=function(){var F=_.w,B=_.X,U=_.i,J,me;return _.w=F=F+1640531527|0,me=B[U+34&127],J=B[U=U+1&127],me^=me<<13,J^=J<<17,me^=me>>>15,J^=J>>>12,me=B[U]=me^J,_.i=U,me+(F^F>>>16)|0};function C(F,B){var U,J,me,Le,Me,He=[],lt=128;for(B===(B|0)?(J=B,B=null):(B=B+"\0",J=0,lt=Math.max(lt,B.length)),me=0,Le=-32;Le<lt;++Le)B&&(J^=B.charCodeAt((Le+32)%B.length)),Le===0&&(Me=J),J^=J<<10,J^=J>>>15,J^=J<<4,J^=J>>>13,Le>=0&&(Me=Me+1640531527|0,U=He[Le&127]^=J+Me,me=U==0?me+1:0);for(me>=128&&(He[(B&&B.length||0)&127]=-1),me=127,Le=4*128;Le>0;--Le)J=He[me+34&127],U=He[me=me+1&127],J^=J<<13,U^=U<<17,J^=J>>>15,U^=U>>>12,He[me]=J^U;F.w=Me,F.X=He,F.i=me}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),F=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,me=(U+J)/(1<<21);while(me===0);return me},B.int32=C.next,B.quick=B,F&&(F.X&&d(F,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)}),xm=ac(function(t){(function(e,n,a){function c(v){var _=this,C="";_.next=function(){var B=_.b,U=_.c,J=_.d,me=_.a;return B=B<<25^B>>>7^U,U=U-J|0,J=J<<24^J>>>8^me,me=me-B|0,_.b=B=B<<20^B>>>12^U,_.c=U=U-J|0,_.d=J<<16^U>>>16^me,_.a=me-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 F=0;F<C.length+20;F++)_.b^=C.charCodeAt(F)|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),F=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,me=(U+J)/(1<<21);while(me===0);return me},B.int32=C.next,B.quick=B,F&&(typeof F=="object"&&d(F,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)}),ic=ac(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),F=C*2,B=c-1,U;function J(Ct,Bt,ur){var nr=[];Bt=Bt==!0?{entropy:!0}:Bt||{};var yr=He(Me(Bt.entropy?[Ct,Nt(e)]:Ct==null?lt():Ct,3),nr),Gr=new me(nr),en=function(){for(var Zr=Gr.g(d),Qr=_,Kr=0;Zr<C;)Zr=(Zr+Kr)*c,Qr*=c,Kr=Gr.g(1);for(;Zr>=F;)Zr/=2,Qr/=2,Kr>>>=1;return(Zr+Kr)/Qr};return en.int32=function(){return Gr.g(4)|0},en.quick=function(){return Gr.g(4)/4294967296},en.double=en,He(Nt(Gr.S),e),(Bt.pass||ur||function(Zr,Qr,Kr,Hn){return Hn&&(Hn.S&&Le(Hn,Gr),Zr.state=function(){return Le(Gr,{})}),Kr?(n[v]=Zr,Qr):Zr})(en,yr,"global"in Bt?Bt.global:this==n,Bt.state)}n["seed"+v]=J;function me(Ct){var Bt,ur=Ct.length,nr=this,yr=0,Gr=nr.i=nr.j=0,en=nr.S=[];for(ur||(Ct=[ur++]);yr<c;)en[yr]=yr++;for(yr=0;yr<c;yr++)en[yr]=en[Gr=B&Gr+Ct[yr%ur]+(Bt=en[yr])],en[Gr]=Bt;(nr.g=function(Zr){for(var Qr,Kr=0,Hn=nr.i,yn=nr.j,Mn=nr.S;Zr--;)Qr=Mn[Hn=B&Hn+1],Kr=Kr*c+Mn[B&(Mn[Hn]=Mn[yn=B&yn+Qr])+(Mn[yn]=Qr)];return nr.i=Hn,nr.j=yn,Kr})(c)}function Le(Ct,Bt){return Bt.i=Ct.i,Bt.j=Ct.j,Bt.S=Ct.S.slice(),Bt}function Me(Ct,Bt){var ur=[],nr=typeof Ct,yr;if(Bt&&nr=="object")for(yr in Ct)try{ur.push(Me(Ct[yr],Bt-1))}catch(Gr){}return ur.length?ur:nr=="string"?Ct:Ct+"\0"}function He(Ct,Bt){for(var ur=Ct+"",nr,yr=0;yr<ur.length;)Bt[B&yr]=B&(nr^=Bt[B&yr]*19)+ur.charCodeAt(yr++);return Nt(Bt)}function lt(){try{var Ct;return U&&(Ct=U.randomBytes)?Ct=Ct(c):(Ct=new Uint8Array(c),(a.crypto||a.msCrypto).getRandomValues(Ct)),Nt(Ct)}catch(nr){var Bt=a.navigator,ur=Bt&&Bt.plugins;return[+new Date,a,ur,a.screen,Nt(e)]}}function Nt(Ct){return String.fromCharCode.apply(0,Ct)}if(He(n.random(),e),t.exports){t.exports=J;try{U=Bp()}catch(Ct){}}})([],Math)});ic.alea=fm,ic.xor128=mm,ic.xorwow=ym,ic.xorshift7=vm,ic.xor4096=gm,ic.tychei=xm;var _m=ic,xp=_m.alea,_p=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=xp(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}(),wm=function(){function t(e,n,a,c){this.alpha=e,this.beta=1/n,this.dtype=a;var d=c||Math.random();this.randu=xp(d.toString()),this.randn=new _p(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}(),bm=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=xp(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 km(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 wm(e,n,a,c),y=Qi(t,a),v=0;v<y.values.length;v++)y.values[v]=d.nextValue();return y.toTensor()}var Sm=Re({randomGamma_:km});function Im(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 _p(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 Nm=Re({randomNormal_:Im});function Cm(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 bm(e,n,null,c),v=0;v<d.values.length;v++)d.values[v]=y.nextValue();return d.toTensor()}var md=Re({randomUniform_:Cm});function cl(t,e){ut(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 Oa(t,a,n,e)}function wp(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 Xs([0],a);var C=Math.abs(Math.ceil((e-t)/n)),F=fa(C,a);e<t&&n===1&&(n=-1),F[0]=t;for(var B=1;B<F.length;B++)F[B]=F[B-1]+n;return cl(F,a)},d={start:t,stop:e,step:n,dtype:a};return Ie.runKernelFunc(c,{},null,No,d)}function Tm(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,oo)}var yd=Re({reciprocal_:Tm});function Em(t){var e=ie(t,"x","relu"),n=function(c,d){return d([e]),e.dtype==="bool"?dr(e,"int32"):c.relu(e)},a={x:e};return Ie.runKernelFunc(n,a,null,ua)}var fh=Re({relu_:Em});function Rm(t){var e=ie(t,"x","relu6"),n=function(c,d){return d([e]),e.dtype==="bool"?dr(e,"int32"):c.relu6(e)},a={x:e};return Ie.runKernelFunc(n,a,null,Ta)}var bp=Re({relu6_:Rm});function Am(t,e){var n=ie(t,"x","reverse"),a=function(y){var v=jt(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=Re({reverse_:Am});function Fm(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 Dm=Re({reverse1d_:Fm});function Om(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 Mm=Re({reverse2d_:Om});function zm(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 Lm=Re({reverse3d_:zm});function Pm(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 Bm=Re({reverse4d_:Pm});function Wm(t){var e=ie(t,"x","round"),n={x:e};return Ie.runKernelFunc(function(a){return a.round(e)},n,null,Pi)}var vd=Re({round_:Wm});function Um(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 kp=Re({rsqrt_:Um});function Vm(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 gd=Re({selu_:Vm});function Hm(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"),F=v,B=!1;if(v.rank===3&&(B=!0,F=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(F.rank===4,function(){return"Error in separableConv2d: input must be rank 4, but got "+("rank "+F.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 me=lh(F,_,a,c,y,d),Le=1,Me=gi(me,C,Le,"valid",y);return B?Ke(Me,[Me.shape[1],Me.shape[2],Me.shape[3]]):Me}var xd=Re({separableConv2d_:Hm});function Gm(t,e){return M(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,F,_,B;return V(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 De([v],n.dtype),F=new De([v],"int32"),_=0,B=0;_<c.length;_++)y.has(c[_])||(C.values[B]=c[_],F.values[B]=_,B++);return[2,[C.toTensor(),F.toTensor()]]}})})}var jm=Gm;function qm(t){var e=ie(t,"x","sign"),n={x:e};return Ie.runKernelFunc(function(a){return a.sign(e)},n,null,Rs)}var _d=Re({sign_:qm});function Km(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,Es)}var Sp=Re({sin_:Km});function Xm(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 Ip=Re({sinh_:Xm});function Ym(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"}),er(a,[e],[n])}var Zm=Re({slice1d_:Ym});function Qm(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"}),er(a,e,n)}var Jm=Re({slice2d_:Qm});function $m(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"}),er(a,e,n)}var ey=Re({slice3d_:$m});function ty(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"}),er(a,e,n)}var ry=Re({slice4d_:ty});function ny(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 wd=Re({softmax_:ny});function ay(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,Mi)}var Bh=Re({fft_:ay});function iy(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=Re({ifft_:iy});function oy(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(Ah(t),[n,e]),_=Zs(er(y,[0,1],[n,e-2]),1),C=bt(Zs(er(v,[0,1],[n,e-2]),1),Ur(-1)),F=kr([y,_],1),B=kr([v,C],1),c=Ke(Ln(F,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 Np=Re({irfft_:oy});function bd(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 sy(t,e,n){n===void 0&&(n=0);var a=ie(t,"x","split"),c=function(v,_){var C=jt(n,a.shape)[0],F=bd(a,e,C);return v.split(a,F,C)},d={x:a},y={numOrSizeSplits:e,axis:n};return Ie.runKernelFunc(c,d,null,Jo,y)}var ll=Re({split_:sy});function uy(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=er(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,Xs(v)],t.shape.length-1),n=e}else c=t;var _=gn(c),C=Ke(Ln(c,_),[a,n]),F=Bh(C),B=Math.floor(n/2)+1,U=dh(F),J=Ah(F),me=ll(U,[B,n-B],U.shape.length-1),Le=ll(J,[B,n-B],J.shape.length-1),Me=c.shape.slice();return Me[c.shape.length-1]=B,Ke(Ln(me[0],Le[0]),Me)}var Wh=Re({rfft_:uy});function cy(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 to=Re({sqrt_:cy});function ly(t,e){var n,a=ie(t,"a","squaredDifference"),c=ie(e,"b","squaredDifference");n=Tt(a,c),a=n[0],c=n[1],pa(a.shape,c.shape);var d=function(_,C){var F=_.squaredDifference(a,c);return C([a,c]),F},y={a,b:c},v={};return Ie.runKernelFunc(d,y,null,Fs,v)}var Uh=Re({squaredDifference_:ly});function hy(t,e){var n=ie(t,"x","squeeze");return Ke(n,jr(n.shape,e).newShape)}var Vh=Re({squeeze_:hy});function py(t,e){e===void 0&&(e=0);var n=In(t,"tensors","stack");if(W(n.length>=1,function(){return"Pass at least one tensor to tf.stack"}),n.length===1)return ps(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){st(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 ps(v,e)});return kr(y,e)}var oc=Re({stack_:py});function dy(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,$o,c)}var hl=Re({step_:dy});function fy(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"),F=function(J){a==null&&(a=new Array(e.length));var me=yu(y);if(me.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 Le=C.rank-e.length,Me=yu(v),He=C.shape.slice();Me.forEach(function(Zr){e[Zr]=0,n[Zr]=1,He.splice(Zr,0,1)}),C=Ke(C,He);var lt=Gc(C.shape,me,Le,e,n,a,c,d,y),Nt=lt.begin,Ct=lt.end,Bt=lt.strides;e=Nt,n=Ct,a=Bt;var ur=yu(_);ur.forEach(function(Zr){n[Zr]=e[Zr]+1,a[Zr]=1});var nr=Wc(e,n,a),yr=nr.filter(function(Zr,Qr){return ur.indexOf(Qr)===-1}),Gr=a.every(function(Zr){return Zr===1});if(Gr)return Ke(er(C,e,nr),yr);var en=J.stridedSlice(C,e,n,a);return Ke(en,yr)},B={x:C},U={begin:e,end:n,strides:a,beginMask:c,endMask:d,ellipsisMask:y,newAxisMask:v,shrinkAxisMask:_};return Ie.runKernelFunc(F,B,null,Ds,U)}var kd=Re({stridedSlice_:fy});function my(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,fs)}var Sd=Re({tan_:my});function yh(t,e,n){if(ut(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 Oa(t,e,a,n)}function yy(t,e,n){if(ut(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 Oa(t,e,a,n)}function vy(t,e,n){if(ut(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 Oa(t,e,a,n)}function gy(t,e,n){if(ut(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,Oa(t,e,a,n)}function xy(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(F){return F.topk(a,e,n)},d,null,ru,y),_=v[0],C=v[1];return{values:_,indices:C}}var Id=Re({topk_:xy});function _y(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 _p(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 wy=Re({truncatedNormal_:_y});function by(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(nu,a,c),y=d[0],v=d[1];return{values:y,indices:v}}var Nd=Re({unique_:by});function ky(t,e,n){var a=ie(t,"x","unsortedSegmentSum"),c=ie(e,"segmentIds","unsortedSegmentSum","int32");W(yt(n),function(){return"numSegments must be of dtype int"});var d={x:a,segmentIds:c},y={numSegments:n},v=function(_,C){var F=_.unsortedSegmentSum(a,c,n);return C([c]),F};return Ie.runKernelFunc(v,d,null,Fo,y)}var Cp=Re({unsortedSegmentSum_:ky});function Sy(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,ys,c)}var Hh=Re({unstack_:Sy});function Iy(t,e,n,a){return e===void 0&&(e=!0),Ie.makeVariable(t,e,n,a)}function Cd(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 Ny(t){return M(this,void 0,void 0,function(){var e,n,a;return V(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=Cd(e.shape,n),t!==e&&e.dispose(),[2,a]}})})}var Td=Ny;function Cy(t,e,n){return M(this,void 0,void 0,function(){var a,c,d,y,v,_,C,F,B,U,J,me,Le;return V(this,function(Me){switch(Me.label){case 0:for(a=ie(t,"tensor","boolMask"),c=ie(e,"mask","boolMask","bool"),d=n==null?0:n,y=c.rank,v=a.shape,W(y>0,function(){return"mask cannot be scalar"}),st(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 F=v.slice(0,d).concat([_],v.slice(d+y)),B=Ke(a,F),U=Ke(c,[-1]),[4,Td(U)];case 1:return J=Me.sent(),me=Vh(J,[1]),Le=Rh(B,me,d),t!==a&&a.dispose(),e!==c&&c.dispose(),me.dispose(),B.dispose(),U.dispose(),J.dispose(),[2,Le]}})})}var Ty=Cy;function Ey(t,e){Ea("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 st(n.shape,a.shape,"Error in notEqualStrict: "),Lh(n,a)}function Ry(t,e){Ea("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 st(n.shape,a.shape,"Error in lessStrict: "),Fh(n,a)}function Ay(t,e){Ea("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 st(n.shape,a.shape,"Error in equalStrict: "),hh(n,a)}function Fy(t,e){Ea("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 st(n.shape,a.shape,"Error in lessEqualStrict: "),$u(n,a)}function Dy(t,e){Ea("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 st(n.shape,a.shape,"Error in greaterStrict: "),xu(n,a)}function Oy(t,e){Ea("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 st(n.shape,a.shape,"Error in greaterEqualStrict: "),Ju(n,a)}var Ed=Re({equalStrict_:Ay}),Rd=Re({greaterEqualStrict_:Oy}),Ad=Re({greaterStrict_:Dy}),Fd=Re({lessEqualStrict_:Fy}),Dd=Re({lessStrict_:Ry}),Od=Re({notEqualStrict_:Ey});function My(t,e){Ea("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 st(n.shape,a.shape,"Error in addStrict: "),Cr(n,a)}function zy(t,e){Ea("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 st(n.shape,a.shape,"Error in subStrict: "),Lr(n,a)}function Ly(t,e){return Ea("strict variants of ops have been deprecated and will be removed in future"),st(t.shape,e.shape,"Error in powStrict: "),Ys(t,e)}function Py(t,e){Ea("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 st(n.shape,a.shape,"Error in multiplyStrict: "),bt(n,a)}function By(t,e){Ea("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 st(n.shape,a.shape,"Error in divideStrict: "),Wr(n,a)}function Wy(t,e){Ea("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 st(n.shape,a.shape,"Error in modStrict: "),yp(n,a)}function Uy(t,e){Ea("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 st(n.shape,a.shape,"Error in minimumStrict: "),zh(n,a)}function Vy(t,e){Ea("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 st(n.shape,a.shape,"Error in maximumStrict: "),ol(n,a)}function Hy(t,e){Ea("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 st(n.shape,a.shape,"Error in squaredDifferenceStrict: "),Uh(n,a)}var Md=Re({addStrict_:My}),zd=Re({divStrict_:By}),Ld=Re({maximumStrict_:Vy}),Pd=Re({minimumStrict_:Uy}),Bd=Re({modStrict_:Wy}),Wd=Re({mulStrict_:Py}),Ud=Re({powStrict_:Ly}),Vd=Re({squaredDifferenceStrict_:Hy}),Hd=Re({subStrict_:zy});function Gy(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=Gd(t,e,n),d=c.shape;if(a){var y=jt(n,t.shape);d=li(c.shape,y)}return Ke(c,d)}function Gd(t,e,n){if(n===void 0&&(n=null),t.rank===0)return ci(t);if(t.rank!==1&&n===null)return Gd(Ke(t,[-1]),e,n);if(t.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(e===1)return Yr(ci(t),n);if(e===Infinity)return tc(ci(t),n);if(e===-Infinity)return Mh(ci(t),n);if(e==="euclidean"||e===2)return to(Yr(Ys(ci(t),Ur(2,"int32")),n));throw new Error("Error in norm: invalid ord value: "+e)}if(Array.isArray(n)&&n.length===2){if(e===1)return tc(Yr(ci(t),n[0]),n[1]-1);if(e===Infinity)return tc(Yr(ci(t),n[1]),n[0]);if(e===-Infinity)return Mh(Yr(ci(t),n[1]),n[0]);if(e==="fro"||e==="euclidean")return to(Yr(Xn(t),n));throw new Error("Error in norm: invalid ord value: "+e)}throw new Error("Error in norm: invalid axis: "+n)}var Gh=Re({norm_:Gy});function jy(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");Xt(d,y),W(mt(d.shape,y.shape),function(){return"Shape mismatch in v and x"});var _=Ur(1),C=Lr(_,v),F=bt(Lr(y,d),C);if(c){W(a!=null,function(){return"When using zeroDebias: true, step is required."});var B=ie(a,"step","movingAverage");F=Wr(F,Lr(_,Ys(v,B)))}return Cr(d,F)}var qy=Re({movingAverage_:jy});function Ky(t,e,n){var a=ie(t,"indices","scatterND","int32"),c=ie(e,"updates","scatterND");Bu(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 Xy=Re({scatterND_:Ky});function Yy(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 Zy(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);Yy(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,tu,_)}var Qy=Re({sparseToDense_:Zy});function Jy(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,be)}var $y=Re({gatherND_:Jy});function e0(t,e){if(e==null)return t.shape.slice();if(mt(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 t0(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=e0(c,n),y=1-e,v=Wr(Eh(Cr(md(d,0,1,"float32",a),y)),y);return bt(c,v)}var r0=Re({dropout_:t0});function jd(t){return Math.floor(Math.pow(2,Math.ceil(Math.log(t)/Math.log(2))))}function Tp(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 n0(t,e,n){return n===void 0&&(n=1),M(this,void 0,void 0,function(){var a,c,d,y,v,_,C,F,B,U,J,me,Le,Me,Me;return V(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)}),st(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],F=_[1],B=Pr("bool",C),U=0;U<C;U++){for(J=U*F,me=y.subarray(J,J+F),Le=[],Me=0;Me<me.length;Me++)Le.push({value:me[Me],index:Me});for(Le.sort(function(lt,Nt){return Nt.value-lt.value}),B[U]=0,Me=0;Me<n;Me++)if(Le[Me].index===v[U]){B[U]=1;break}}return t!==a&&a.dispose(),e!==c&&c.dispose(),[2,An(B,c.shape,"bool")]}})})}var a0=n0;function i0(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],F=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(F===n[3],function(){return"Error in conv2dDerFilter: depth of dy ("+F+") must "+("match output depth for filter ("+n[3]+").")}),y!=null&&W(yt(c),function(){return"Error in conv2dDerFilter: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+c+".")});var B=function(me){var Le=1,Me=Ft(d),He=T(v.shape,n,a,Le,c,y,!1,Me);return me.conv2dDerFilter(v,_,He)},U={x:v,dy:_},J={strides:a,pad:c,dataFormat:d,dimRoundingMode:y,filterShape:n};return Ie.runKernelFunc(B,U,null,tt,J)}var Ep=Re({conv2DBackpropFilter_:i0});function jh(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 qh(t,e){var n=e,a=ti(t.shape,e.shape);return a.length>0&&(n=Yr(n,a)),Ke(n,t.shape)}function Kh(t,e,n){if(e==="linear")return t;if(e==="relu")return fh(t);if(e==="elu")return up(t);if(e==="relu6")return bp(t);if(e==="prelu")return gp(t,n);throw new Error("Unknown fused activation "+e+".")}var Xh=function(t,e){var n=t>0;return!n||e==="linear"};function o0(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,F=t.bias,B=t.activation,U=B===void 0?"linear":B,J=t.preluActivationWeights;if(U=U||"linear",Xh(Ie.state.gradientDepth,U)===!1){var me=gi(e,n,a,c,y,_,C);return F!=null&&(me=Cr(me,F)),Kh(me,U,J)}var Le=ie(e,"x","conv2d"),Me=ie(n,"filter","conv2d"),He=Le,lt=!1;Le.rank===3&&(lt=!0,He=Ke(Le,[1,Le.shape[0],Le.shape[1],Le.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(yt(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 Nt=T(He.shape,Me.shape,a,_,c,C),Ct;F!=null&&(Ct=ie(F,"bias","fused conv2d"),Ct=Tt(Ct,Le)[0],pa(Nt.outShape,Ct.shape));var Bt;J!=null&&(Bt=ie(J,"prelu weights","fused conv2d"));var ur=function(Qr,Kr){var Hn=Kr,yn=Hn[0],Mn=Hn[1],Js=Hn[2],xi=Hn[3],Va=jh(Qr,Js,U);W(ct(_),function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 "+("are not yet supported in gradients. Got dilations '"+_+"'")});var ko=Ci(Mn.shape,Va,yn,a,c),So=Ep(Mn,Va,yn.shape,a,c),wu=[ko,So];if(xi!=null){var Pp=qh(xi,Va);wu.push(Pp)}return wu},nr=function(Qr){var Kr=Qr.fusedConv2d({input:He,filter:Me,convInfo:Nt,bias:Ct,activation:U,preluActivationWeights:Bt});return Kr},yr={x:He,filter:Me,bias:Ct,preluActivationWeights:Bt},Gr={strides:a,pad:c,dataFormat:y,dilations:_,dimRoundingMode:C,activation:U};if(F==null){var en=Ts(function(Qr,Kr,Hn){var yn=Ie.runKernelFunc(nr,yr,null,Ls,Gr);return Hn([Kr,Qr,yn]),lt&&(yn=Ke(yn,[yn.shape[1],yn.shape[2],yn.shape[3]])),{value:yn,gradFunc:ur}});return en(He,Me)}else{var Zr=Ts(function(Qr,Kr,Hn,yn){var Mn=Ie.runKernelFunc(nr,yr,null,Ls,Gr);return yn([Kr,Qr,Mn,Hn]),lt&&(Mn=Ke(Mn,[Mn.shape[1],Mn.shape[2],Mn.shape[3]])),{value:Mn,gradFunc:ur}});return Zr(He,Me,Ct)}}var s0=Re({fusedConv2d_:o0});function u0(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)},F={x:v,dy:_},B={strides:a,pad:c,dimRoundingMode:y,dilations:d,filterShape:n};return Ie.runKernelFunc(C,F,null,qa,B)}var qd=Re({depthwiseConv2dNativeBackpropFilter_:u0});function c0(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 me=T(t,n.shape,a,d,c,y,!0);return J.depthwiseConv2DDerInput(v,n,me)},F={dy:v,filter:n},B={strides:a,pad:c,dimRoundingMode:y,dilations:d,inputShape:t},U=Ie.runKernelFunc(C,F,null,bi,B);return _?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var Kd=Re({depthwiseConv2dNativeBackpropInput_:c0});function l0(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,F=t.bias,B=t.activation,U=B===void 0?"linear":B,J=t.preluActivationWeights;if(Xh(Ie.state.gradientDepth,U)===!1){var me=lh(e,n,a,c,y,_,C);return F!=null&&(me=Cr(me,F)),Kh(me,U,J)}var Le=ie(e,"x","depthwiseConv2d"),Me=ie(n,"filter","depthwiseConv2d"),He=Le,lt=!1;Le.rank===3&&(lt=!0,He=Ke(Le,[1,Le.shape[0],Le.shape[1],Le.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(yt(c),function(){return"Error in fused depthwiseConv2d: pad must be an integer when "+("using dimRoundingMode "+C+" but got pad "+c+".")});var Nt=T(He.shape,Me.shape,a,_,c,C,!0),Ct;F!=null&&(Ct=ie(F,"bias","fused conv2d"),Ct=Tt(Ct,Le)[0],pa(Nt.outShape,Ct.shape));var Bt;J!=null&&(Bt=ie(J,"prelu weights","fused depthwiseConv2d"));var ur=function(Qr,Kr){W(ct(_),function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations "+("'"+_+"'")});var Hn=Kr[0],yn=Kr[1],Mn=Kr[2],Js=Kr[3],xi=jh(Qr,Mn,U),Va=Kd(yn.shape,xi,Hn,a,c,_,C),ko=qd(yn,xi,Hn.shape,a,c,_,C);if(Js!=null){var So=qh(Ct,xi);return[Va,ko,So]}return[Va,ko]},nr=function(Qr){var Kr=Qr.fusedDepthwiseConv2D({input:He,filter:Me,convInfo:Nt,bias:Ct,activation:U,preluActivationWeights:Bt});return Kr},yr={x:He,filter:Me,bias:Ct,preluActivationWeights:Bt},Gr={strides:a,pad:c,dataFormat:y,dilations:_,dimRoundingMode:C,activation:U};if(F==null){var en=Ts(function(Qr,Kr,Hn){var yn=Ie.runKernelFunc(nr,yr,null,es,Gr);return Hn([Kr,Qr,yn]),lt&&(yn=Ke(yn,[yn.shape[1],yn.shape[2],yn.shape[3]])),{value:yn,gradFunc:ur}});return en(He,Me)}else{var Zr=Ts(function(Qr,Kr,Hn,yn){var Mn=Ie.runKernelFunc(nr,yr,null,es,Gr);return yn([Kr,Qr,Mn,Hn]),lt&&(Mn=Ke(Mn,[Mn.shape[1],Mn.shape[2],Mn.shape[3]])),{value:Mn,gradFunc:ur}});return Zr(He,Me,Ct)}}var h0=Re({fusedDepthwiseConv2d_:l0});function p0(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,F=C===void 0?"linear":C,B=t.preluActivationWeights;if(Xh(Ie.state.gradientDepth,F)===!1){var U=sn(n,a,d,v);return _!=null&&(U=Cr(U,_)),Kh(U,F,B)}var J=ie(n,"a","fused matMul"),me=ie(a,"b","fused matMul");e=Tt(J,me),J=e[0],me=e[1];var Le=d?J.shape[J.rank-2]:J.shape[J.rank-1],Me=v?me.shape[me.rank-1]:me.shape[me.rank-2],He=d?J.shape[J.rank-1]:J.shape[J.rank-2],lt=v?me.shape[me.rank-2]:me.shape[me.rank-1],Nt=J.shape.slice(0,-2),Ct=me.shape.slice(0,-2),Bt=It(Nt),ur=It(Ct);W(J.rank>=2&&me.rank>=2&&J.rank===me.rank,function(){return"Error in fused matMul: inputs must have the same rank of at least "+("2, got ranks "+J.rank+" and "+me.rank+".")}),W(mt(Nt,Ct),function(){return"Error in fused matMul: outer dimensions ("+Nt+") and ("+(Ct+") of Tensors with shapes "+J.shape+" and ")+(me.shape+" must match.")}),W(Le===Me,function(){return"Error in fused matMul: inner shapes ("+Le+") and ("+(Me+") of Tensors with shapes "+J.shape+" and ")+(me.shape+" and transposeA="+d)+(" and transposeB="+v+" must match.")});var nr=J.shape.slice(0,-2).concat([He,lt]),yr=d?Ke(J,[Bt,Le,He]):Ke(J,[Bt,He,Le]),Gr=v?Ke(me,[ur,lt,Me]):Ke(me,[ur,Me,lt]),en;_!=null&&(en=ie(_,"bias","fused matMul"),en=Tt(en,J)[0],pa(nr,en.shape));var Zr;B!=null&&(Zr=ie(B,"prelu weights","fused matMul"));var Qr=function(xi,Va){var ko=Va[0],So=Va[1],wu=Va[2],Pp=Va[3],$s=jh(Ke(xi,wu.shape),wu,F),dl,fl;if(!d&&!v?(dl=sn($s,So,!1,!0),fl=sn(ko,$s,!0,!1)):!d&&v?(dl=sn($s,So,!1,!1),fl=sn($s,ko,!0,!1)):d&&!v?(dl=sn(So,$s,!1,!0),fl=sn(ko,$s,!1,!1)):(dl=sn(So,$s,!0,!0),fl=sn($s,ko,!0,!0)),_!=null){var eg=qh(Pp,$s);return[dl,fl,eg]}else return[dl,fl]},Kr=function(xi){var Va=xi.fusedBatchMatMul({a:yr,b:Gr,transposeA:d,transposeB:v,bias:en,activation:F,preluActivationWeights:Zr});return Va},Hn={a:yr,b:Gr,bias:en,preluActivationWeights:Zr},yn={transposeA:d,transposeB:v,activation:F};if(_==null){var Mn=Ts(function(xi,Va,ko){var So=Ie.runKernelFunc(Kr,Hn,null,Do,yn);return ko([xi,Va,So]),{value:Ke(So,nr),gradFunc:Qr}});return Mn(yr,Gr)}else{var Js=Ts(function(xi,Va,ko,So){var wu=Ie.runKernelFunc(Kr,Hn,null,Do,yn);return So([xi,Va,wu,ko]),{value:Ke(wu,nr),gradFunc:Qr}});return Js(yr,Gr,en)}}var d0=Re({fusedMatMul_:p0}),f0={__proto__:null,conv2d:s0,depthwiseConv2d:h0,matMul:d0};function m0(t){return Tp(t,.54,.46)}var y0=Re({hammingWindow_:m0});function v0(t){return Tp(t,.5,.5)}var Xd=Re({hannWindow_:v0});function g0(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(er(t,d,e)),d+=n;if(a)for(;d<t.size;){var v=d+e-t.size,_=kr([er(t,d,e-v),cp([v],c)]);y.push(_),d+=n}return y.length===0?yh([],[0,e]):Ke(kr(y),[y.length,e])}var Yd=Re({frame_:g0});function x0(t,e,n,a,c){c===void 0&&(c=Xd),a==null&&(a=jd(e));for(var d=Yd(t,e,n),y=bt(d,c(e)),v=[],_=0;_<d.shape[0];_++)v.push(Wh(er(y,[_,0],[1,e]),a));return kr(v)}var _0=Re({stft_:x0});function w0(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 F=function(me){return me.cropAndResize(y,v,_,a,c,d)},B={image:y,boxes:v,boxInd:_},U={method:c,extrapolationValue:d,cropSize:a},J=Ie.runKernelFunc(F,B,null,aa,U);return J}var b0=Re({cropAndResize_:w0});function k0(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 S0=Re({flipLeftRight_:k0});function I0(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(vs,d,y);return v}var N0=Re({rotateWithOffset_:I0});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 C0(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,Ya,_)}var T0=Re({nonMaxSuppression_:C0});function E0(t,e,n){var a=R0(t,e,n),c=a<0?-(a+1):a;t.splice(c,0,e)}function R0(t,e,n){return F0(t,e,n||A0)}function A0(t,e){return t>e?1:t<e?-1:0}function F0(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 Zd(t,e,n,a,c){return Rp(t,e,n,a,c,0).selectedIndices}function Qd(t,e,n,a,c,d){return Rp(t,e,n,a,c,0,!1,d,!0)}function Jd(t,e,n,a,c,d){return Rp(t,e,n,a,c,d,!0)}function Rp(t,e,n,a,c,d,y,v,_){y===void 0&&(y=!1),v===void 0&&(v=!1),_===void 0&&(_=!1);for(var C=[],F=0;F<e.length;F++)e[F]>c&&C.push({score:e[F],boxIndex:F,suppressBeginIndex:0});C.sort($d);for(var B=d>0?-.5/d:0,U=[],J=[];U.length<n&&C.length>0;){var me=C.pop(),Le=me.score,Me=me.boxIndex,He=me.suppressBeginIndex;if(Le<c)break;for(var lt=!1,Nt=U.length-1;Nt>=He;--Nt){var Ct=D0(t,Me,U[Nt]);if(Ct>=a){lt=!0;break}if(me.score=me.score*O0(a,B,Ct),me.score<=c)break}me.suppressBeginIndex=U.length,lt||(me.score===Le?(U.push(Me),J.push(me.score)):me.score>c&&E0(C,me,$d))}var Bt=U.length,ur=n-Bt;v&&ur>0&&(U.push.apply(U,new Array(ur).fill(0)),J.push.apply(J,new Array(ur).fill(0)));var nr={selectedIndices:cl(U,"int32")};return y&&(nr.selectedScores=cl(J,"float32")),_&&(nr.validOutputs=Ur(Bt,"int32")),nr}function D0(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]),F=Math.min(c[1],c[3]),B=Math.max(c[0],c[2]),U=Math.max(c[1],c[3]),J=(v-d)*(_-y),me=(B-C)*(U-F);if(J<=0||me<=0)return 0;var Le=Math.max(d,C),Me=Math.max(y,F),He=Math.min(v,B),lt=Math.min(_,U),Nt=Math.max(He-Le,0)*Math.max(lt-Me,0);return Nt/(J+me-Nt)}function O0(t,e,n){var a=Math.exp(e*n*n);return n<=t?a:0}function $d(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}function M0(t,e,n,a,c){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),M(this,void 0,void 0,function(){var d,y,v,_,C,F,B;return V(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],F=_[1],B=Zd(C,F,n,a,c),d!==t&&d.dispose(),y!==e&&y.dispose(),[2,B]}})})}var z0=M0;function L0(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},F={maxOutputSize:n,iouThreshold:a,scoreThreshold:c,softNmsSigma:d},B=Ie.runKernel(Xi,C,F);return{selectedIndices:B[0],selectedScores:B[1]}}var P0=Re({nonMaxSuppressionWithScore_:L0});function B0(t,e,n,a,c,d){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=0),M(this,void 0,void 0,function(){var y,v,_,C,F,B,U;return V(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(),F=C[0],B=C[1],U=Jd(F,B,n,a,c,d),y!==t&&y.dispose(),v!==e&&v.dispose(),[2,U]}})})}var W0=B0;function U0(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,F=_.iouThreshold,B=_.scoreThreshold,U={boxes:y,scores:v},J={maxOutputSize:C,iouThreshold:F,scoreThreshold:B,padToMaxOutputSize:d},me=Ie.runKernel(Ba,U,J);return{selectedIndices:me[0],validOutputs:me[1]}}var V0=Re({nonMaxSuppressionPadded_:U0});function H0(t,e,n,a,c,d){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=!1),M(this,void 0,void 0,function(){var y,v,_,C,F,B,U,J,me,Le;return V(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,F=_.iouThreshold,B=_.scoreThreshold,[4,Promise.all([y.data(),v.data()])];case 1:return U=Me.sent(),J=U[0],me=U[1],Le=Qd(J,me,C,F,B,d),y!==t&&y.dispose(),v!==e&&v.dispose(),[2,Le]}})})}var G0=H0;function j0(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},F={alignCorners:n,size:e},B=Ie.runKernelFunc(_,C,null,Zn,F);return d?Ke(B,[B.shape[1],B.shape[2],B.shape[3]]):B}var ef=Re({resizeBilinear_:j0});function q0(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},F=function(U,J){return J([c]),U.resizeNearestNeighbor(c,y,v,n)},B=Ie.runKernelFunc(F,_,null,ca,C);return d?Ke(B,[B.shape[1],B.shape[2],B.shape[3]]):B}var tf=Re({resizeNearestNeighbor_:q0});function K0(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(wp(0,y,1,"int32"),[-1,1]),C=wp(0,v,1,"int32"),F=Lr(_,C),B=rc($u(F,Ur(+e,"int32")),Ju(F,Ur(-n,"int32"))),U=Xs([y,v],a.dtype);return Ke(oc(Hh(Ke(a,[-1,y,v])).map(function(J){return ls(B,J,U)})),c)}var X0=Re({bandPart_:K0});function Y0(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 Vh(_,[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 F=y[C];if(C>0)for(var B=0;B<C;++B){var U=bt(Yr(bt(d[B],F)),d[B]);F=Lr(F,U)}return Wr(F,Gh(F,"euclidean"))}))},c=0;c<t.length;++c)v(c);return e?oc(d,0):d}var Z0=Re({gramSchmidt_:Y0});function Q0(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 rf(t,e);var n=t.shape.slice(0,t.shape.length-2).reduce(function(_,C){return _*C}),a=Hh(Ke(t,[n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),c=[],d=[];a.forEach(function(_){var C=rf(_,e),F=C[0],B=C[1];c.push(F),d.push(B)});var y=Ke(oc(c,0),t.shape),v=Ke(oc(d,0),t.shape);return[y,v]}function rf(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=td(n),d=Ho(t),y=yh([[1]],[1,1]),v=Ho(y),_=n>=a?a:n,C=function(B){var U,J=d,me=v,Le=c;U=Ie.tidy(function(){var Me=er(d,[B,B],[n-B,1]),He=Gh(Me),lt=er(d,[B,B],[1,1]),Nt=ls(xu(lt,0),yh([[-1]]),yh([[1]])),Ct=Lr(lt,bt(Nt,He)),Bt=Wr(Me,Ct);Bt.shape[0]===1?v=Ho(y):v=kr([y,er(Bt,[1,0],[Bt.shape[0]-1,Bt.shape[1]])],0);var ur=ri(Wr(sn(Nt,Ct),He)),nr=er(d,[B,0],[n-B,a]),yr=bt(ur,v),Gr=$n(v);if(B===0)d=Lr(nr,sn(yr,sn(Gr,nr)));else{var en=Lr(nr,sn(yr,sn(Gr,nr)));d=kr([er(d,[0,0],[B,a]),en],0)}var Zr=$n(yr),Qr=er(c,[0,B],[n,c.shape[1]-B]);if(B===0)c=Lr(Qr,sn(sn(Qr,v),Zr));else{var Kr=Lr(Qr,sn(sn(Qr,v),Zr));c=kr([er(c,[0,0],[n,B]),Kr],1)}return[v,d,c]}),v=U[0],d=U[1],c=U[2],Ua([J,me,Le])},F=0;F<_;++F)C(F);return!e&&n>a&&(c=er(c,[0,0],[n,a]),d=er(d,[0,0],[a,a])),[c,d]})}var J0=Re({qr_:Q0});(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 $0(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=Wr(Yr(d),Yr(c));return y>1?Wr(v,Ur(y)):v}if(n===N.Reduction.SUM_BY_NONZERO_WEIGHTS){if(c==null)return Wr(Yr(d),Ur(a.size));var _=bt(c,sl(a.shape)),C=dr(Yr(Lh(_,Ur(0))),"float32");return Wr(Yr(d),C)}throw Error("Unknown reduction: "+n)}var Qs=Re({computeWeightedLoss_:$0});function e2(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")),st(c.shape,d.shape,"Error in absoluteDifference: ");var v=ci(Lr(c,d));return Qs(v,y,a)}var t2=Re({absoluteDifference_:e2});function r2(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")),st(d.shape,y.shape,"Error in cosineDistance: ");var _=Ur(1),C=Lr(_,Yr(bt(d,y),n,!0));return Qs(C,v,c)}var n2=Re({cosineDistance_:r2});function a2(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")),st(c.shape,d.shape,"Error in hingeLoss: ");var v=Ur(1);c=Lr(bt(Ur(2),c),v);var _=fh(Lr(v,bt(c,d)));return Qs(_,y,a)}var i2=Re({hingeLoss_:a2});function o2(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")),st(d.shape,y.shape,"Error in huberLoss: ");var _=Ur(a),C=ci(Lr(y,d)),F=zh(C,_),B=Lr(C,F),U=Cr(bt(Ur(.5),Xn(F)),bt(_,B));return Qs(U,v,c)}var s2=Re({huberLoss_:o2});function u2(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")),st(d.shape,y.shape,"Error in logLoss: ");var _=Ur(1),C=Ur(a),F=ri(bt(d,ec(Cr(y,C)))),B=bt(Lr(_,d),ec(Cr(Lr(_,y),C))),U=Lr(F,B);return Qs(U,v,c)}var c2=Re({logLoss_:u2});function l2(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")),st(c.shape,d.shape,"Error in meanSquaredError: ");var v=Uh(c,d);return Qs(v,y,a)}var h2=Re({meanSquaredError_:l2});function p2(t,e){var n=ie(t,"labels","sigmoidCrossEntropyWithLogits"),a=ie(e,"logits","sigmoidCrossEntropyWithLogits");st(n.shape,a.shape,"Error in sigmoidCrossEntropyWithLogits: ");var c=fh(a),d=bt(a,n),y=hp(hs(ri(ci(a))));return Cr(Lr(c,d),y)}function d2(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")),st(d.shape,y.shape,"Error in sigmoidCrossEntropy: "),a>0){var _=Ur(a),C=Ur(1),F=Ur(.5);d=Cr(bt(d,Lr(C,_)),bt(F,_))}var B=p2(d,y);return Qs(B,v,c)}var f2=Re({sigmoidCrossEntropy_:d2});function m2(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=Ts(function(c,d,y){var v=!0,_=dp(d,[n],v),C=Lr(dr(d,"float32"),_);y([c,C]);var F=ri(bt(C,c)),B=Yr(F,[n]),U=function(J,me){var Le=me[0],Me=me[1],He=li(J.shape,[n]);return[bt(Ke(J,He),Lr(dr(Le,"float32"),hs(Me))),bt(Ke(J,He),Lr(hs(Me),dr(Le,"float32")))]};return{value:B,gradFunc:U}});return a(t,e)}function y2(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")),st(d.shape,y.shape,"Error in softmaxCrossEntropy: "),a>0){var _=Ur(a),C=Ur(1),F=Ur(d.shape[1]);d=Cr(bt(d,Lr(C,_)),Wr(_,F))}var B=m2(d,y);return Qs(B,v,c)}var v2=Re({softmaxCrossEntropy_:y2}),g2={fft:Bh,ifft:mh,rfft:Wh,irfft:Np},x2={hammingWindow:y0,hannWindow:Xd,frame:Yd,stft:_0},_2={flipLeftRight:S0,resizeNearestNeighbor:tf,resizeBilinear:ef,rotateWithOffset:N0,cropAndResize:b0,nonMaxSuppression:T0,nonMaxSuppressionAsync:z0,nonMaxSuppressionWithScore:P0,nonMaxSuppressionWithScoreAsync:W0,nonMaxSuppressionPadded:V0,nonMaxSuppressionPaddedAsync:G0},w2={bandPart:X0,gramSchmidt:Z0,qr:J0},b2={absoluteDifference:t2,computeWeightedLoss:Qs,cosineDistance:n2,hingeLoss:i2,huberLoss:s2,logLoss:c2,meanSquaredError:h2,sigmoidCrossEntropy:f2,softmaxCrossEntropy:v2},_u=function(t){we(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 Ua(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 ud(n,a)},e.prototype.dispose=function(){this.iterations_!=null&&Ua(this.iterations_)},e.prototype.saveIterations=function(){return M(this,void 0,void 0,function(){return V(this,function(n){return this.iterations_==null&&(this.iterations_=0),[2,{name:"iter",tensor:Ur(this.iterations_,"int32")}]})})},e.prototype.getWeights=function(){return M(this,void 0,void 0,function(){return V(this,function(n){throw new Error("getWeights() is not implemented for this optimizer yet.")})})},e.prototype.setWeights=function(n){return M(this,void 0,void 0,function(){return V(this,function(a){throw new Error("setWeights() is not implemented for this optimizer class "+(""+this.getClassName()))})})},e.prototype.extractIterations=function(n){return M(this,void 0,void 0,function(){var a;return V(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(_u,Symbol.hasInstance,{value:function(t){return t.minimize!=null&&t.computeGradients!=null&&t.applyGradients!=null}});var Ap=function(t){we(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:la(function(){return gn(v).variable(_)})}),a.accumulatedUpdates[y]==null&&(a.accumulatedUpdates[y]={originalName:d+"/accum_var",variable:la(function(){return gn(v).variable(_)})});var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var F=a.accumulatedGrads[y].variable,B=a.accumulatedUpdates[y].variable;la(function(){var U=Cr(bt(F,a.rho),bt(Xn(C),1-a.rho)),J=bt(Wr(to(Cr(B,a.epsilon)),to(Cr(F,a.epsilon))),C),me=Cr(bt(B,a.rho),bt(Xn(J),1-a.rho));F.assign(U),B.assign(me);var Le=Cr(bt(J,-a.learningRate),v);v.assign(Le)})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedUpdates!=null&&(Ua(this.accumulatedGrads.map(function(n){return n.variable})),Ua(this.accumulatedUpdates.map(function(n){return n.variable})))},e.prototype.getWeights=function(){return M(this,void 0,void 0,function(){var n;return V(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 M(this,void 0,void 0,function(){var a,c;return V(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}(_u);jo(Ap);var Fp=function(t){we(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:la(function(){return cp(v.shape,a.initialAccumulatorValue).variable(_)})}}var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var F=a.accumulatedGrads[y].variable;la(function(){var B=Cr(F,Xn(C));F.assign(B);var U=Cr(bt(Wr(C,to(Cr(B,Ie.backend.epsilon()))),-a.learningRate),v);v.assign(U)})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedGrads!=null&&Ua(this.accumulatedGrads.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return M(this,void 0,void 0,function(){return V(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 M(this,void 0,void 0,function(){var a;return V(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}(_u);jo(Fp);var Dp=function(t){we(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=[],la(function(){y.accBeta1=Ur(a).variable(),y.accBeta2=Ur(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);la(function(){var d=Lr(1,a.accBeta1),y=Lr(1,a.accBeta2);c.forEach(function(v,_){var C=Ie.registeredVariables[v],F=!1;a.accumulatedFirstMoment[_]==null&&(a.accumulatedFirstMoment[_]={originalName:v+"/m",variable:la(function(){return gn(C).variable(F)})}),a.accumulatedSecondMoment[_]==null&&(a.accumulatedSecondMoment[_]={originalName:v+"/v",variable:la(function(){return gn(C).variable(F)})});var B=Array.isArray(n)?n[_].tensor:n[v];if(B==null)return;var U=a.accumulatedFirstMoment[_].variable,J=a.accumulatedSecondMoment[_].variable,me=Cr(bt(U,a.beta1),bt(B,1-a.beta1)),Le=Cr(bt(J,a.beta2),bt(Xn(B),1-a.beta2)),Me=Wr(me,d),He=Wr(Le,y);U.assign(me),J.assign(Le);var lt=Cr(bt(Wr(Me,Cr(to(He),a.epsilon)),-a.learningRate),C);C.assign(lt)}),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&&Ua(this.accumulatedFirstMoment.map(function(n){return n.variable})),this.accumulatedSecondMoment!=null&&Ua(this.accumulatedSecondMoment.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return M(this,void 0,void 0,function(){var n;return V(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 M(this,void 0,void 0,function(){var a,c,d=this;return V(this,function(y){switch(y.label){case 0:return[4,this.extractIterations(n)];case 1:return n=y.sent(),la(function(){d.accBeta1.assign(Ys(d.beta1,d.iterations_+1)),d.accBeta2.assign(Ys(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}(_u);jo(Dp);var Op=function(t){we(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=[],la(function(){v.iteration=Ur(0).variable(),v.accBeta1=Ur(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);la(function(){var d=Lr(1,a.accBeta1),y=Wr(-a.learningRate,Cr(bt(a.iteration,a.decay),1));c.forEach(function(v,_){var C=Ie.registeredVariables[v],F=!1;a.accumulatedFirstMoment[_]==null&&(a.accumulatedFirstMoment[_]={originalName:v+"/m",variable:gn(C).variable(F)}),a.accumulatedWeightedInfNorm[_]==null&&(a.accumulatedWeightedInfNorm[_]={originalName:v+"/v",variable:gn(C).variable(F)});var B=Array.isArray(n)?n[_].tensor:n[v];if(B==null)return;var U=a.accumulatedFirstMoment[_].variable,J=a.accumulatedWeightedInfNorm[_].variable,me=Cr(bt(U,a.beta1),bt(B,1-a.beta1)),Le=bt(J,a.beta2),Me=ci(B),He=ol(Le,Me);U.assign(me),J.assign(He);var lt=Cr(bt(Wr(y,d),Wr(me,Cr(He,a.epsilon))),C);C.assign(lt)}),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&&Ua(this.accumulatedFirstMoment.map(function(n){return n.variable})),this.accumulatedWeightedInfNorm!=null&&Ua(this.accumulatedWeightedInfNorm.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return M(this,void 0,void 0,function(){return V(this,function(n){throw new Error("getWeights() is not implemented for Adamax yet.")})})},e.prototype.setWeights=function(n){return M(this,void 0,void 0,function(){return V(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}(_u);jo(Op);var Yh=function(t){we(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];la(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=gu(Ur(-n))},e.prototype.dispose=function(){this.c.dispose()},e.prototype.getWeights=function(){return M(this,void 0,void 0,function(){return V(this,function(n){switch(n.label){case 0:return[4,this.saveIterations()];case 1:return[2,[n.sent()]]}})})},e.prototype.setWeights=function(n){return M(this,void 0,void 0,function(){return V(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}(_u);jo(Yh);var Mp=function(t){we(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=Ur(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:la(function(){return gn(v).variable(_)})}}var C=a.accumulations[y].variable,F=Array.isArray(n)?n[y].tensor:n[d];if(F==null)return;la(function(){var B,U=Cr(bt(a.m,C),F);a.useNesterov?B=Cr(bt(a.c,Cr(F,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&&Ua(this.accumulations.map(function(n){return n.variable}))},e.prototype.setMomentum=function(n){this.momentum=n},e.prototype.getWeights=function(){return M(this,void 0,void 0,function(){return V(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 M(this,void 0,void 0,function(){var a;return V(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}(Yh);jo(Mp);var zp=function(t){we(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:la(function(){return gn(v).variable(_)})}),a.accumulatedMoments[y]==null&&(a.accumulatedMoments[y]={originalName:d+"/momentum",variable:la(function(){return gn(v).variable(_)})}),a.accumulatedMeanGrads[y]==null&&a.centered&&(a.accumulatedMeanGrads[y]={originalName:d+"/mg",variable:la(function(){return gn(v).variable(_)})});var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var F=a.accumulatedMeanSquares[y].variable,B=a.accumulatedMoments[y].variable;la(function(){var U=Cr(bt(F,a.decay),bt(Xn(C),1-a.decay));if(a.centered){var J=a.accumulatedMeanGrads[y].variable,me=Cr(bt(J,a.decay),bt(C,1-a.decay)),Le=Wr(bt(C,a.learningRate),to(Lr(U,Cr(Xn(me),a.epsilon)))),Me=Cr(bt(B,a.momentum),Le);F.assign(U),J.assign(me),B.assign(Me);var He=Lr(v,Me);v.assign(He)}else{var lt=Cr(bt(F,a.decay),bt(Xn(C),1-a.decay)),Me=Cr(bt(B,a.momentum),Wr(bt(C,a.learningRate),to(Cr(lt,a.epsilon))));F.assign(lt),B.assign(Me);var He=Lr(v,Me);v.assign(He)}})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedMeanSquares!=null&&Ua(this.accumulatedMeanSquares.map(function(n){return n.variable})),this.accumulatedMeanGrads!=null&&this.centered&&Ua(this.accumulatedMeanGrads.map(function(n){return n.variable})),this.accumulatedMoments!=null&&Ua(this.accumulatedMoments.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return M(this,void 0,void 0,function(){var n;return V(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 M(this,void 0,void 0,function(){var a,c;return V(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}(_u);jo(zp);var sc=function(){function t(){}return t.sgd=function(e){return new Yh(e)},t.momentum=function(e,n,a){return a===void 0&&(a=!1),new Mp(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 zp(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 Ap(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 Op(e,n,a,c,d)},t.adagrad=function(e,n){return n===void 0&&(n=.1),new Fp(e,n)},t}(),k2={sgd:sc.sgd,momentum:sc.momentum,adadelta:sc.adadelta,adagrad:sc.adagrad,rmsprop:sc.rmsprop,adamax:sc.adamax,adam:sc.adam},S2=function(){return typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:function(t){return t()}}();function I2(){return new Promise(function(t){return S2(function(){return t()})})}function N2(t,e,n){var a=n*(typeof t=="number"?t:t[0]),c=e*(typeof t=="number"?t:t[1]);return[a,c]}function C2(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 T2(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 E2(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 R2(t,e){for(var n=[0],a=0;a<e;++a)n.push(t[a][0]);return n}function A2(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 nf=1.7580993408473768,af=1.0507009873554805,F2=.3275911,D2=.254829592,O2=-.284496736,M2=1.421413741,z2=-1.453152027,L2=1.061405429;function P2(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Rr().getBool("IS_TEST")||console.warn.apply(console,t)}function B2(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Rr().getBool("IS_TEST")||console.log.apply(console,t)}function W2(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 U2(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 V2(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 H2(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 G2(t,e){var n=t[e*2],a=t[e*2+1];return{real:n,imag:a}}function j2(t,e,n,a){t[a*2]=e,t[a*2+1]=n}function q2(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 K2(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 X2(t,e,n){if(e==="complex64"){if(t.dtype==="complex64")return t.clone();var a=Xs(t.shape),c=dr(t,"float32"),d=n.complex(c,a);return a.dispose(),c.dispose(),d}if(!Ha(t.dtype,e))return Ie.makeTensorFromDataId(t.dataId,t.shape,e);if(t.dtype==="complex64"){var y=n.real(t),d=dr(y,e);return y.dispose(),d}if(e==="int32")return n.int(t);if(e==="bool"){var v=Ur(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 Y2(t,e){return Ie.makeTensorFromDataId(t.dataId,e,t.dtype)}function Z2(t,e,n){var a=(e-t)/(n-1),c=fa(n,"float32");c[0]=t;for(var d=1;d<c.length;d++)c[d]=c[d-1]+a;return cl(c,"float32")}var Q2={__proto__:null,slice_util:Xc,segment_util:Zf,castTensor:X2,reshapeTensor:Y2,linspaceImpl:Z2,upcastType:Pt,axesAreInnerMostDims:Yu,combineLocations:tl,computeOutAndReduceShapes:rl,expandShapeToKeepDim:li,assertAxesAreInnerMostDims:nl,getAxesPermutation:$i,getUndoAxesPermutation:f,getInnerMostAxes:p,getBroadcastDims:Df,getReductionAxes:ti,assertAndGetBroadcastShape:pa,assertParamsConsistent:hr,computeOutShape:Ir,computeDilation2DInfo:o,computePool2DInfo:h,computePool3DInfo:b,computeConv2DInfo:T,computeConv3DInfo:O,computeDefaultPad:le,tupleValuesAreOne:ct,eitherStridesOrDilationsAreOne:dt,convertConv2DDataFormat:Ft,getFusedDyActivation:jh,getFusedBiasGradient:qh,applyActivation:Kh,shouldFuse:Xh,PARALLELIZE_THRESHOLD:lp,computeOptimalWindowSize:Kf,getImageCenter:N2,getReshaped:C2,getPermuted:T2,getReshapedPermuted:E2,getSliceBeginCoords:R2,getSliceSize:A2,prepareAndValidate:Pu,validateUpdateShape:Ji,validateInput:Bu,calculateShapes:us,SELU_SCALEALPHA:nf,SELU_SCALE:af,ERF_P:F2,ERF_A1:D2,ERF_A2:O2,ERF_A3:M2,ERF_A4:z2,ERF_A5:L2,warn:P2,log:B2,mergeRealAndImagArrays:W2,splitRealAndImagArrays:U2,complexWithEvenIndex:V2,complexWithOddIndex:H2,getComplexWithIndex:G2,assignToTypedArray:j2,exponents:q2,exponent:K2,prepareSplitSize:bd};function J2(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=er(t,a,y);return a[n]+=d,v})}function $2(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 ev(t,e,n,a,c){for(var d=e[e.length-1],y=[t.length/d,d],v=y[0],_=y[1],C=Pr(n,v*a),F=Pr("int32",v*a),B=0;B<v;B++){for(var U=B*_,J=t.subarray(U,U+_),me=[],Le=0;Le<J.length;Le++)me.push({value:J[Le],index:Le});me.sort(function(Ct,Bt){return Bt.value-Ct.value});for(var Me=B*a,He=C.subarray(Me,Me+a),lt=F.subarray(Me,Me+a),Le=0;Le<a;Le++)He[Le]=me[Le].value,lt[Le]=me[Le].index}var Nt=e.slice();return Nt[Nt.length-1]=a,[An(C,Nt,n),An(F,Nt,"int32")]}var tv={__proto__:null,nonMaxSuppressionV3Impl:Zd,nonMaxSuppressionV4Impl:Qd,nonMaxSuppressionV5Impl:Jd,split:J2,tile:$2,topkImpl:ev,whereImpl:Cd},rv={kernelName:jn,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,hl(dr(n,"float32"),-1))}}}},nv={kernelName:ni,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=Xn(dr(n,"float32")),c=to(Lr(Ur(1),a));return ri(Wr(t,c))}}}},av={kernelName:pi,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=to(Lr(Xn(dr(n,"float32")),1));return Wr(t,a)}}}},iv={kernelName:ma,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=pa(n.shape,a.shape),d=function(){var v=t,_=ti(n.shape,c);return _.length>0&&(v=Yr(v,_)),Ke(v,n.shape)},y=function(){var v=t,_=ti(a.shape,c);return _.length>0&&(v=Yr(v,_)),Ke(v,a.shape)};return{a:d,b:y}}},ov={kernelName:di,saveAllInputs:!0,gradFunc:function(t,e){var n={};return e.forEach(function(a,c){n[c]=function(){return t.clone()}}),n}},sv={kernelName:ln,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return gn(n)}}}},uv={kernelName:ai,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return gn(n)}}}},cv={kernelName:gr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Wr(t,to(Lr(Ur(1),Xn(dr(n,"float32")))))}}}},lv={kernelName:Ai,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=to(Cr(Ur(1),Xn(dr(n,"float32"))));return Wr(t,a)}}}},hv={kernelName:Qn,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=pa(n.shape,a.shape),d=function(){var v=Cr(Xn(n),Xn(a)),_=bt(t,Wr(a,v)),C=ti(n.shape,c);return C.length>0&&(_=Yr(_,C)),Ke(_,n.shape)},y=function(){var v=Cr(Xn(n),Xn(a)),_=ri(bt(t,Wr(n,v))),C=ti(a.shape,c);return C.length>0&&(_=Yr(_,C)),Ke(_,a.shape)};return{a:d,b:y}}},pv={kernelName:wi,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Wr(t,Cr(Xn(dr(n,"float32")),1))}}}},dv={kernelName:no,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Wr(t,Lr(Ur(1),Xn(dr(n,"float32"))))}}}};function fv(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,F=_,B=!1;_.rank===4&&(B=!0,C=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2],v.shape[3]]),F=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(F.rank===5,function(){return"Error in avgPool3dBackprop: input must be rank 5 but got rank "+(F.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(yt(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(F.shape,n,a,c,d,y);return Me.avgPool3dBackprop(C,F,He)},J={dy:C,input:F},me={filterSize:n,strides:a,dilations:c,pad:d,dimRoundingMode:y},Le=Ie.runKernelFunc(U,J,null,Di,me);return B?Ke(Le,[Le.shape[1],Le.shape[2],Le.shape[3],Le.shape[4]]):Le}var mv=Re({avgPool3dBackprop_:fv}),yv={kernelName:qi,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,F=v==null?[1,1,1]:v;return{x:function(){return mv(t,a,d,y,F,_,C)}}}};function vv(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 F=function(me){var Le=h(v.shape,n,a,1,c);return me.avgPoolBackprop(_,v,Le)},B={dy:_,input:v},U={filterSize:n,strides:a,pad:c},J=Ie.runKernelFunc(F,B,null,Fi,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3]]):J}var gv=Re({avgPoolBackprop_:vv}),xv={kernelName:ji,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 gv(t,a,d,y,v)}}}},_v={kernelName:ya,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 sn(t,c,!1,!0)},b:function(){return sn(a,t,!0,!1)}}:!y&&v?{a:function(){return sn(t,c,!1,!1)},b:function(){return sn(t,a,!0,!1)}}:y&&!v?{a:function(){return sn(c,t,!1,!0)},b:function(){return sn(a,t,!1,!1)}}:{a:function(){return sn(c,t,!0,!0)},b:function(){return sn(t,a,!0,!0)}}}},wv={kernelName:Oi,gradFunc:function(t,e,n){var a=n,c=a.blockShape,d=a.crops;return{x:function(){return Ph(t,c,d)}}}},bv={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)}}}},kv={kernelName:Y,gradFunc:function(t){return{x:function(){return t.clone()}}}},Sv={kernelName:j,gradFunc:function(t){return{x:function(){return gn(t)}}}},Iv={kernelName:ne,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.clipValueMin,y=c.clipValueMax;return{x:function(){return ls(rc(Ju(a,d),$u(a,y)),t,gn(t))}}}},Nv={kernelName:Ue,saveAllInputs:!0,gradFunc:function(t,e,n){var a=e.map(function(_){return _.shape}),c=n.axis,d=jt(c,e[0].shape)[0],y=a.map(function(_){return _[d]}),v=ll(t,y,d);return v.map(function(_){return function(){return _}})}},Cv={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,F=y.dataFormat;return W(ct(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 Ci(c.shape,t,d,_,C,F)},filter:function(){return Ep(c,t,d.shape,_,C,F)}}}},Tv={kernelName:ze,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,F=y.dimRoundingMode;return{dy:function(){return gi(t,d,v,_,C,1,F)},filter:function(){return Ep(t,c,d.shape,v,_,C,F)}}}};function Ev(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(F){var B=1,U=O(d.shape,n,a,B,c);return F.conv3dDerFilter(d,y,U)},_={x:d,dy:y},C={strides:a,pad:c,filterShape:n};return Ie.runKernelFunc(v,_,null,Dt,C)}var Rv=Re({conv3DBackpropFilter_:Ev}),Av={kernelName:Ye,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=n,c=a.dilations,d=a.strides,y=a.pad;W(ct(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 Ch(v.shape,t,_,d,y)},filter:function(){return Rv(v,t,_.shape,d,y)}}}},Fv={kernelName:Mt,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(ri(Sp(dr(n,"float32"))),t)}}}},Dv={kernelName:fr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(Ip(dr(n,"float32")),t)}}}},Ov={kernelName:or,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 _=$i([d],a.rank),C=sp(t,d,y,!v);return _!=null&&(C=$n(C,_)),C}}}},Mv={kernelName:ia,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=n,c=a.dilations,d=a.strides,y=a.pad,v=a.dimRoundingMode,_=c==null?[1,1]:c;W(ct(_),function(){return"Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations "+("'"+_+"'")});var C=e,F=C[0],B=C[1];return W(F.rank===4,function(){return"Error in gradient of depthwiseConv2dNative: input must be "+("rank 4, but got rank "+F.rank+".")}),W(B.rank===4,function(){return"Error in gradient of depthwiseConv2dNative: filter must be "+("rank 4, but got rank "+B.rank+".")}),W(F.shape[3]===B.shape[2],function(){return"Error in gradient of depthwiseConv2d: number of input "+("channels ("+F.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(yt(y),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+v+" but got pad "+y+".")}),{x:function(){return Kd(F.shape,t,B,d,y,c,v)},filter:function(){return qd(F,t,B.shape,d,y,c,v)}}}},zv={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(oa,y,n)},filter:function(){return Ie.runKernel(Jr,v,n)}}}},Lv={kernelName:Vr,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=pa(n.shape,a.shape),d=function(){var v=Wr(t,dr(a,"float32")),_=ti(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,dr(n,"float32")),_=ti(a.shape,c);_.length>0&&(v=Ke(Yr(v,_),a.shape));var C=Xn(a);return ri(Wr(v,dr(C,"float32")))};return{a:d,b:y}}},Pv={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)}}}},Bv={kernelName:En,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0],a=bt(hs(ri(Xn(n))),2/Math.sqrt(Math.PI));return{x:function(){return bt(t,a)}}}},Wv={kernelName:sa,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,n)}}}},Uv={kernelName:ga,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,hs(n))}}}},Vv={kernelName:x,gradFunc:function(t){return{x:function(){return gn(t)}}}},Hv={kernelName:k,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=pa(n.shape,a.shape),d=function(){var v=Wr(t,dr(a,"float32")),_=ti(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,dr(n,"float32")),_=ti(a.shape,c);_.length>0&&(v=Ke(Yr(v,_),a.shape));var C=Xn(a);return ri(Wr(v,dr(C,"float32")))};return{a:d,b:y}}},Gv={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==null?Ur(1):v,C=ti(d.shape,c.shape),F=[];if(d.rank===1){for(var B=0;B<c.shape.length-1;++B)F.push(c.shape[B]);F.push(1)}var U=Lr(c,d),J=bt(t,_),me=kp(Cr(y,Ur(a))),Le=bt(bt(bt(me,me),me),Ur(-.5)),Me=function(){return d.rank===1?Ke(bt(bt(t,il(Ke(me,[1,1,1,d.shape[0]]),F)),_),c.shape):Ke(bt(bt(t,me),_),c.shape)},He=function(){var Bt=bt(bt(me,Ur(-1)),J);return d.rank===1&&(Bt=Yr(Bt,C)),Ke(Bt,d.shape)},lt=function(){var Bt=bt(bt(Le,U),J);return d.rank===1&&(Bt=Yr(Bt,C)),Ke(Bt,d.shape)},Nt=function(){var Bt=bt(U,me),ur=bt(t,Bt);return d.rank===1&&(ur=Yr(ur,C)),Ke(ur,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:lt,scale:Nt,offset:Ct}}},jv={kernelName:Se,inputsToSave:["x","indices"],gradFunc:function(t,e,n){var a=e[0],c=e[1],d=n.axis,y=jt(d,a.shape)[0],v=function(){var _=a.shape,C=c.size,F=_.slice(0,y),B=F.length,U=_.slice(d,_.length).slice(1),J=U.length,me=of(0,B),Le=of(B+1,B+1+J),Me=sf([F,[C],U]),He=Ke(t,Me),lt=Ke(c,[C]),Nt=sf([[B],me,Le]),Ct=$n(He,Nt),Bt=Cp(Ct,lt,a.shape[y]),ur=f(Nt);return Bt=$n(Bt,ur),Bt};return{x:v,indices:function(){return c}}}};function of(t,e){for(var n=[],a=t;a<e;++a)n.push(a);return n}function sf(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 qv={kernelName:Pe,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)}}}},Kv={kernelName:gt,gradFunc:function(t){return{x:function(){return dr(t,"float32")}}}},Xv={kernelName:Wt,gradFunc:function(t){return{x:function(){return gn(t)}}}},Yv={kernelName:Gt,gradFunc:function(t){return{x:function(){return gn(t)}}}},Zv={kernelName:Jt,gradFunc:function(t){return{x:function(){return gn(t)}}}},Qv={kernelName:kn,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Wr(t,Cr(n,1))}}}},Jv={kernelName:xr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Wr(t,dr(n,"float32"))}}}},$v={kernelName:Na,inputsToSave:[],outputsToSave:[!0],gradFunc:function(t,e,n){var a=e[0],c=n.axis;return{logits:function(){var d=!0,y=hs(a);return Lr(t,bt(Yr(t,c,d),y))}}}};function e5(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(F){return F.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,cr,C)}var t5=Re({localResponseNormalizationBackprop_:e5}),r5={kernelName:Sn,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,F=y.beta;return{x:function(){return t5(c,d,t,v,_,C,F)}}}};function uf(t,e,n,a){return e.rank<n.rank&&(e=Ke(e,li(e.shape,a))),t.rank<n.rank&&(t=Ke(t,li(t.shape,a))),{x:function(){var c=bt(t,dr(hh(n,e),t.dtype));return c}}}var cf={kernelName:$r,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var a=n,c=a.reductionIndices,d=e[0],y=e[1],v=jt(c,d.shape),_=uf(t,y,d,v);return{x:function(){return _.x()}}}},n5={kernelName:Fa,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=function(){return bt(t,dr(Ju(n,a),"float32"))},d=function(){return bt(t,dr(Fh(n,a),"float32"))};return{a:c,b:d}}};function a5(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"),F=ie(n,"output","maxPool3dBackprop"),B=_,U=C,J=F,me=!1;C.rank===4&&(me=!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(F,[1,F.shape[0],F.shape[1],F.shape[2],F.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(yt(y),function(){return"Error in maxPool3dBackprop: pad must be an integer when "+("using, dimRoundingMode "+v+" but got pad "+y+".")});var Le=function(Nt){var Ct=b(U.shape,a,c,d,y,v);return Nt.maxPool3dBackprop(B,U,J,Ct)},Me={dy:B,input:U,output:J},He={filterSize:a,strides:c,dilations:d,pad:y,dimRoundingMode:v},lt=Ie.runKernelFunc(Le,Me,null,ii,He);return me?Ke(lt,[lt.shape[1],lt.shape[2],lt.shape[3],lt.shape[4]]):lt}var i5=Re({maxPool3dBackprop_:a5}),o5={kernelName:Xa,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,F=y.pad,B=y.dimRoundingMode,U=C==null?[1,1,1]:C;return{x:function(){return i5(t,c,d,v,_,U,F,B)}}}};function s5(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(yt(d),function(){return"Error in maxPoolBackprop: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+d+".")});var F=function(J){var me=h(_.shape,a,c,1,d,y);return J.maxPoolBackprop(v,_,C,me)},B={dy:v,input:_,output:C},U={filterSize:a,strides:c,pad:d,dimRoundingMode:y};return Ie.runKernelFunc(F,B,null,Ka,U)}var u5=Re({maxPoolBackprop_:s5}),c5={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 u5(t,c,d,v,_,C)}}}},l5={kernelName:Ca,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var a=n,c=a.axis,d=e[0],y=e[1],v=jt(c,d.shape),_=uf(t,y,d,v);return{x:function(){return _.x()}}}},h5={kernelName:Ki,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=function(){return bt(t,dr($u(n,a),"float32"))},d=function(){return bt(t,dr(xu(n,a),"float32"))};return{a:c,b:d}}},p5={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 er(t,d,a.shape)}}}},d5={kernelName:oi,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=pa(n.shape,a.shape),d=function(){var v=ti(n.shape,c);return v.length>0?Ke(Yr(t,v),n.shape):t},y=function(){var v=bt(t,ri(Eh(Wr(n,a)))),_=ti(a.shape,c);return _.length>0?Ke(Yr(v,_),a.shape):v};return{a:d,b:y}}},f5={kernelName:qr,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=pa(n.shape,a.shape),d=function(){var v=bt(t,dr(a,"float32")),_=ti(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,dr(n,"float32")),_=ti(a.shape,c);return _.length>0?Ke(Yr(v,_),a.shape):v};return{a:d,b:y}}},m5={kernelName:Io,gradFunc:function(t){return{x:function(){return ri(t)}}}},y5={kernelName:Li,inputsToSave:["indices"],gradFunc:function(t,e){var n=e[0];return{indices:function(){return Xs(n.shape,"float32")}}}},v5={kernelName:si,gradFunc:function(t){return{x:function(){return gn(t)}}}},lf={kernelName:ao,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 er(t,d,a.shape)}}}},g5={kernelName:Za,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:function(t,e){var n=e[0],a=e[1],c=e[2],d=n,y=a,v=pa(d.shape,y.shape),_=function(){var F=dr(y,"float32"),B=bt(t,bt(F,Ys(d,Lr(F,Ur(1))))),U=ti(d.shape,v);return U.length>0&&(B=Yr(B,U)),Ke(B,d.shape)},C=function(){var F=xu(d,0),B=ls(F,ec(d),gn(d)),U=bt(t,bt(c,B)),J=ti(y.shape,v);return J.length>0&&(U=Yr(U,J)),Ke(U,y.shape)};return{a:_,b:C}}},x5={kernelName:io,inputsToSave:["x","alpha"],gradFunc:function(t,e){var n=e[0],a=e[1],c=xu(n,0);return{x:function(){return ls(c,t,bt(t,a))},alpha:function(){var d=ls(c,gn(t),bt(t,n)),y=ti(a.shape,t.shape);return y.length>0&&(d=Yr(d,y)),Ke(d,a.shape)}}}},_5={kernelName:oo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Wr(t,ri(Xn(n)))}}}},w5={kernelName:Ta,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0],a=bt($u(n,6),hl(n));return{x:function(){return bt(t,dr(a,"float32"))}}}},b5={kernelName:ua,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,dr(hl(n),"float32"))}}}},k5={kernelName:Br,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Ke(t,n.shape)}}}},S5={kernelName:Zn,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,so,n)};return{images:y}}},I5={kernelName:ca,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,Qa,n)};return{images:y}}},N5={kernelName:vn,gradFunc:function(t,e,n){var a=n.dims,c=jt(a,t.shape);return{x:function(){return Zs(t,c)}}}},C5={kernelName:Pi,gradFunc:function(t){return{x:function(){return gn(t)}}}},T5={kernelName:yo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return ri(Wr(t,bt(Ys(n,1.5),2)))}}}},E5={kernelName:Da,inputsToSave:["condition"],gradFunc:function(t,e){var n=e[0];return{condition:function(){return dr(gn(n),"float32")},t:function(){return bt(t,dr(n,t.dtype))},e:function(){return bt(t,dr(Oh(n),t.dtype))}}}},R5={kernelName:go,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=xu(n,Ur(0)),c=Ur(nf),d=Ur(af),y=bt(t,d),v=bt(bt(t,c),hs(dr(n,"float32")));return ls(a,y,v)}}}},A5={kernelName:As,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,bt(n,Lr(Ur(1),n)))}}}},F5={kernelName:Rs,gradFunc:function(t){return{x:function(){return gn(t)}}}},D5={kernelName:Es,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(Th(dr(n,"float32")),t)}}}},O5={kernelName:Eo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(op(dr(n,"float32")),t)}}}},M5={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,_=Vu(a,d,y),C=_[0],F=_[1],B=[],U=0;U<t.rank;U++)B.push([C[U],v[U]-C[U]-F[U]]);return{x:function(){return nc(t,B)}}}},z5={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 Lr(y,bt(Yr(y,[c],d),a))}}}},L5={kernelName:Zo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,mn(n))}}}},hf={kernelName:Ao,gradFunc:function(t,e,n){var a=n,c=a.blockShape,d=a.paddings;return{x:function(){return Hr(t,c,d)}}}},pf={kernelName:Jo,gradFunc:function(t,e,n){var a=n.axis;return{x:function(){return kr(t,a)}}}},P5={kernelName:Ro,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Wr(t,bt(to(dr(n,"float32")),2))}}}},B5={kernelName:eu,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,bt(dr(n,"float32"),2))}}}},W5={kernelName:Fs,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=Ur(2),d=function(){return bt(t,bt(c,Lr(n,a)))},y=function(){return bt(t,bt(c,Lr(a,n)))};return{a:d,b:y}}},U5={kernelName:$o,gradFunc:function(t){return{x:function(){return gn(t)}}}},V5={kernelName:ds,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=pa(n.shape,a.shape),d=function(){var v=t,_=ti(n.shape,c);return _.length>0&&(v=Yr(v,_)),Ke(v,n.shape)},y=function(){var v=t,_=ti(a.shape,c);return _.length>0&&(v=Yr(v,_)),Ke(ri(v),a.shape)};return{a:d,b:y}}},H5={kernelName:Qo,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=a.shape.slice(),d=n.axis,y=jt(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 _}}}},G5={kernelName:fs,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Wr(t,Xn(Th(n)))}}}},j5={kernelName:Os,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(Lr(Ur(1),Xn(n)),t)}}}},q5={kernelName:Ms,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,er(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,er(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,er(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 F=0;F<c[3];++F)y=Cr(y,er(t,[v*a.shape[0],_*a.shape[1],C*a.shape[2],F*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}}},K5={kernelName:ms,gradFunc:function(t,e,n){var a=n,c=a.perm,d=f(c);return{x:function(){return $n(t,d)}}}},X5={kernelName:ys,gradFunc:function(t,e,n){var a=n,c=a.axis;return{value:function(){return oc(t,c)}}}},Y5={kernelName:Fo,inputsToSave:["segmentIds"],gradFunc:function(t,e){var n=e[0],a=function(){return Z5(t,n)};return{x:a}}};function Z5(t,e){for(var n=ol(e,gn(e)),a=Rh(t,n),c=Ju(e,Ur(0,"int32")),d=a.rank-c.rank,y=0;y<d;++y)c=ps(c,y+1);c=rc(c,sl(a.shape,"bool"));var v=gn(a);return ls(c,a,v)}for(var Q5={kernelName:zs,gradFunc:function(t){return{x:function(){return gn(t)}}}},J5=[rv,nv,av,iv,ov,sv,uv,cv,lv,hv,pv,dv,yv,xv,_v,wv,bv,kv,Sv,Iv,Nv,Tv,Cv,Av,Fv,Dv,Ov,Mv,zv,Lv,Pv,Bv,Wv,Uv,Hv,Vv,Gv,jv,qv,Kv,Xv,Yv,Zv,Qv,Jv,$v,r5,cf,cf,n5,o5,c5,l5,h5,p5,d5,f5,m5,y5,v5,lf,lf,g5,x5,_5,w5,b5,k5,S5,I5,N5,C5,T5,E5,R5,A5,F5,D5,O5,M5,z5,L5,hf,hf,pf,pf,P5,W5,B5,U5,V5,H5,G5,j5,q5,K5,X5,Y5,Q5],Lp=0,df=J5;Lp<df.length;Lp++){var $5=df[Lp];au($5)}$.prototype.abs=function(){return this.throwIfDisposed(),ci(this)},$.prototype.acos=function(){return this.throwIfDisposed(),$c(this)},$.prototype.acosh=function(){return this.throwIfDisposed(),el(this)},$.prototype.addStrict=function(t){return this.throwIfDisposed(),Md(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(),P(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(),dr(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(),ke(this)},$.prototype.asinh=function(){return this.throwIfDisposed(),Fe(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(),Yt(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(),Kn(this,t,e,n,a,c)},$.prototype.broadcastTo=function(t){return this.throwIfDisposed(),Qu(this,t)},$.prototype.cast=function(t){return this.throwIfDisposed(),dr(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(),Cs(this,t,e,n,a,c,d)},$.prototype.conv2dTranspose=function(t,e,n,a,c){return this.throwIfDisposed(),Ks(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(),Th(this)},$.prototype.cosh=function(){return this.throwIfDisposed(),op(this)},$.prototype.cumsum=function(t,e,n){return this.throwIfDisposed(),sp(this,t,e,n)},$.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),Yp(this,t,e)},$.prototype.depthwiseConv2D=function(t,e,n,a,c,d){return Ea("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(),Zp(this,t,e,n,a,c)},$.prototype.divNoNan=function(t){return this.throwIfDisposed(),Qp(this,t)},$.prototype.divStrict=function(t){return this.throwIfDisposed(),zd(this,t)},$.prototype.div=function(t){return this.throwIfDisposed(),Wr(this,t)},$.prototype.dot=function(t){return this.throwIfDisposed(),Jp(this,t)},$.prototype.elu=function(){return this.throwIfDisposed(),up(this)},$.prototype.equalStrict=function(t){return this.throwIfDisposed(),Ed(this,t)},$.prototype.equal=function(t){return this.throwIfDisposed(),hh(this,t)},$.prototype.erf=function(){return this.throwIfDisposed(),$p(this)},$.prototype.exp=function(){return this.throwIfDisposed(),hs(this)},$.prototype.expandDims=function(t){return this.throwIfDisposed(),ps(this,t)},$.prototype.expm1=function(){return this.throwIfDisposed(),ed(this)},$.prototype.fft=function(){return this.throwIfDisposed(),Bh(this)},$.prototype.flatten=function(){return this.throwIfDisposed(),Ke(this,[this.size])},$.prototype.floor=function(){return this.throwIfDisposed(),Eh(this)},$.prototype.floorDiv=function(t){return this.throwIfDisposed(),Xu(this,t)},$.prototype.gather=function(t,e){return this.throwIfDisposed(),Rh(this,t,e)},$.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),Rd(this,t)},$.prototype.greaterEqual=function(t){return this.throwIfDisposed(),Ju(this,t)},$.prototype.greaterStrict=function(t){return this.throwIfDisposed(),Ad(this,t)},$.prototype.greater=function(t){return this.throwIfDisposed(),xu(this,t)},$.prototype.ifft=function(){return this.throwIfDisposed(),mh(this)},$.prototype.irfft=function(){return this.throwIfDisposed(),Np(this)},$.prototype.isFinite=function(){return this.throwIfDisposed(),nd(this)},$.prototype.isInf=function(){return this.throwIfDisposed(),ad(this)},$.prototype.isNaN=function(){return this.throwIfDisposed(),id(this)},$.prototype.leakyRelu=function(t){return this.throwIfDisposed(),od(this,t)},$.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),Fd(this,t)},$.prototype.lessEqual=function(t){return this.throwIfDisposed(),$u(this,t)},$.prototype.lessStrict=function(t){return this.throwIfDisposed(),Dd(this,t)},$.prototype.less=function(t){return this.throwIfDisposed(),Fh(this,t)},$.prototype.localResponseNormalization=function(t,e,n,a){return this.throwIfDisposed(),sd(this,t,e,n,a)},$.prototype.logSigmoid=function(){return this.throwIfDisposed(),cd(this)},$.prototype.logSoftmax=function(t){return this.throwIfDisposed(),ld(this,t)},$.prototype.logSumExp=function(t,e){return this.throwIfDisposed(),dp(this,t,e)},$.prototype.log=function(){return this.throwIfDisposed(),ec(this)},$.prototype.log1p=function(){return this.throwIfDisposed(),hp(this)},$.prototype.logicalAnd=function(t){return this.throwIfDisposed(),rc(this,t)},$.prototype.logicalNot=function(){return this.throwIfDisposed(),Oh(this)},$.prototype.logicalOr=function(t){return this.throwIfDisposed(),fp(this,t)},$.prototype.logicalXor=function(t){return this.throwIfDisposed(),hd(this,t)},$.prototype.matMul=function(t,e,n){return this.throwIfDisposed(),sn(this,t,e,n)},$.prototype.maxPool=function(t,e,n,a){return this.throwIfDisposed(),mp(this,t,e,n,a)},$.prototype.max=function(t,e){return this.throwIfDisposed(),tc(this,t,e)},$.prototype.maximumStrict=function(t){return this.throwIfDisposed(),Ld(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(),Mh(this,t,e)},$.prototype.minimumStrict=function(t){return this.throwIfDisposed(),Pd(this,t)},$.prototype.minimum=function(t){return this.throwIfDisposed(),zh(this,t)},$.prototype.mirrorPad=function(t,e){return this.throwIfDisposed(),pd(this,t,e)},$.prototype.modStrict=function(t){return this.throwIfDisposed(),Bd(this,t)},$.prototype.mod=function(t){return this.throwIfDisposed(),yp(this,t)},$.prototype.mulStrict=function(t){return this.throwIfDisposed(),Wd(this,t)},$.prototype.mul=function(t){return this.throwIfDisposed(),bt(this,t)},$.prototype.neg=function(){return this.throwIfDisposed(),ri(this)},$.prototype.norm=function(t,e,n){return this.throwIfDisposed(),Gh(this,t,e,n)},$.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),Od(this,t)},$.prototype.notEqual=function(t){return this.throwIfDisposed(),Lh(this,t)},$.prototype.oneHot=function(t,e,n){return e===void 0&&(e=1),n===void 0&&(n=0),this.throwIfDisposed(),Is(this,t,e,n)},$.prototype.onesLike=function(){return this.throwIfDisposed(),vp(this)},$.prototype.pad=function(t,e){return this.throwIfDisposed(),nc(this,t,e)},$.prototype.pool=function(t,e,n,a,c){return this.throwIfDisposed(),dd(this,t,e,n,a,c)},$.prototype.powStrict=function(t){return this.throwIfDisposed(),Ud(this,t)},$.prototype.pow=function(t){return this.throwIfDisposed(),Ys(this,t)},$.prototype.prelu=function(t){return this.throwIfDisposed(),gp(this,t)},$.prototype.prod=function(t,e){return this.throwIfDisposed(),fd(this,t,e)},$.prototype.reciprocal=function(){return this.throwIfDisposed(),yd(this)},$.prototype.relu=function(){return this.throwIfDisposed(),fh(this)},$.prototype.relu6=function(){return this.throwIfDisposed(),bp(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(),ef(this,t,e)},$.prototype.resizeNearestNeighbor=function(t,e){return this.throwIfDisposed(),tf(this,t,e)},$.prototype.reverse=function(t){return this.throwIfDisposed(),Zs(this,t)},$.prototype.rfft=function(){return this.throwIfDisposed(),Wh(this)},$.prototype.round=function(){return this.throwIfDisposed(),vd(this)},$.prototype.rsqrt=function(){return this.throwIfDisposed(),kp(this)},$.prototype.selu=function(){return this.throwIfDisposed(),gd(this)},$.prototype.separableConv2d=function(t,e,n,a,c,d){return this.throwIfDisposed(),xd(this,t,e,n,a,c,d)},$.prototype.sigmoid=function(){return this.throwIfDisposed(),mn(this)},$.prototype.sign=function(){return this.throwIfDisposed(),_d(this)},$.prototype.sin=function(){return this.throwIfDisposed(),Sp(this)},$.prototype.sinh=function(){return this.throwIfDisposed(),Ip(this)},$.prototype.slice=function(t,e){return this.throwIfDisposed(),er(this,t,e)},$.prototype.softmax=function(t){return this.throwIfDisposed(),wd(this,t)},$.prototype.softplus=function(){return this.throwIfDisposed(),pp(this)},$.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),Ph(this,t,e)},$.prototype.split=function(t,e){return this.throwIfDisposed(),ll(this,t,e)},$.prototype.sqrt=function(){return this.throwIfDisposed(),to(this)},$.prototype.square=function(){return this.throwIfDisposed(),Xn(this)},$.prototype.squaredDifference=function(t){return this.throwIfDisposed(),Uh(this,t)},$.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),Vd(this,t)},$.prototype.squeeze=function(t){return this.throwIfDisposed(),Vh(this,t)},$.prototype.stack=function(t,e){this.throwIfDisposed();var n=t instanceof $?[this,t]:[this].concat(t);return oc(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(),kd(this,t,e,n,a,c,d,y,v)},$.prototype.subStrict=function(t){return this.throwIfDisposed(),Hd(this,t)},$.prototype.sub=function(t){return this.throwIfDisposed(),Lr(this,t)},$.prototype.sum=function(t,e){return this.throwIfDisposed(),Yr(this,t,e)},$.prototype.tan=function(){return this.throwIfDisposed(),Sd(this)},$.prototype.tanh=function(){return this.throwIfDisposed(),Cn(this)},$.prototype.tile=function(t){return this.throwIfDisposed(),il(this,t)},$.prototype.toBool=function(){return this.throwIfDisposed(),dr(this,"bool")},$.prototype.toFloat=function(){return this.throwIfDisposed(),dr(this,"float32")},$.prototype.toInt=function(){return this.throwIfDisposed(),dr(this,"int32")},$.prototype.topk=function(t,e){return this.throwIfDisposed(),Id(this,t,e)},$.prototype.transpose=function(t){return this.throwIfDisposed(),$n(this,t)},$.prototype.unique=function(t){return this.throwIfDisposed(),Nd(this,t)},$.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),Cp(this,t,e)},$.prototype.unstack=function(t){return this.throwIfDisposed(),Hh(this,t)},$.prototype.where=function(t,e){return this.throwIfDisposed(),ls(t,this,e)},$.prototype.zerosLike=function(){return this.throwIfDisposed(),gn(this)},N.Abs=jn,N.Acos=ni,N.Acosh=pi,N.AdadeltaOptimizer=Ap,N.AdagradOptimizer=Fp,N.AdamOptimizer=Dp,N.AdamaxOptimizer=Op,N.Add=ma,N.AddN=di,N.All=fi,N.Any=ja,N.ArgMax=ln,N.ArgMin=ai,N.Asin=gr,N.Asinh=Ai,N.Atan=wi,N.Atan2=Qn,N.Atanh=no,N.AvgPool=ji,N.AvgPool3D=qi,N.AvgPool3DBackprop=Di,N.AvgPoolBackprop=Fi,N.BatchMatMul=ya,N.BatchToSpaceND=Oi,N.BroadcastTo=pe,N.Cast=Y,N.Ceil=j,N.ClipByValue=ne,N.Complex=re,N.Concat=Ue,N.Conv2D=kt,N.Conv2DBackpropFilter=tt,N.Conv2DBackpropInput=ze,N.Conv3D=Ye,N.Conv3DBackpropFilterV2=Dt,N.Conv3DBackpropInputV2=St,N.Cos=Mt,N.Cosh=fr,N.CropAndResize=aa,N.Cumsum=or,N.DataStorage=X,N.DepthToSpace=va,N.DepthwiseConv2dNative=ia,N.DepthwiseConv2dNativeBackpropFilter=qa,N.DepthwiseConv2dNativeBackpropInput=bi,N.Diag=rn,N.Dilation2D=hn,N.Dilation2DBackpropFilter=Jr,N.Dilation2DBackpropInput=oa,N.Div=Vr,N.Elu=Jn,N.EluGrad=tn,N.Environment=La,N.Equal=qn,N.Erf=En,N.Exp=sa,N.Expm1=ga,N.FFT=Mi,N.Fill=Aa,N.FlipLeftRight=S,N.Floor=x,N.FloorDiv=k,N.FromPixels=xo,N.FusedBatchNorm=K,N.FusedConv2D=Ls,N.FusedDepthwiseConv2D=es,N.GatherNd=be,N.GatherV2=Se,N.Greater=Je,N.GreaterEqual=Pe,N.IFFT=ft,N.Identity=gt,N.Imag=Lt,N.IsFinite=Wt,N.IsInf=Gt,N.IsNan=Jt,N.KernelBackend=Te,N.LRN=Sn,N.LRNBackprop=cr,N.Less=wr,N.LessEqual=Ar,N.LinSpace=Zt,N.Log=xr,N.Log1p=kn,N.LogSoftmax=Na,N.LogicalAnd=pn,N.LogicalNot=zn,N.LogicalOr=Dr,N.Max=$r,N.MaxPool=mi,N.MaxPool3D=Xa,N.MaxPool3DBackprop=ii,N.MaxPoolBackprop=Ka,N.MaxPoolWithArgmax=zi,N.Maximum=Fa,N.Mean=Rn,N.Min=Ca,N.Minimum=Ki,N.MirrorPad=yi,N.Mod=oi,N.MomentumOptimizer=Mp,N.Multiply=qr,N.Negate=Io,N.NonMaxSuppressionV3=Ya,N.NonMaxSuppressionV4=Ba,N.NonMaxSuppressionV5=Xi,N.NotEqual=nn,N.OP_SCOPE_SUFFIX=wn,N.OneHot=Li,N.OnesLike=si,N.Optimizer=_u,N.PadV2=ao,N.Pool=mo,N.Pow=Za,N.Prelu=io,N.Prod=Yo,N.RMSPropOptimizer=zp,N.Range=No,N.Real=Co,N.Reciprocal=oo,N.Relu=ua,N.Relu6=Ta,N.Reshape=Br,N.ResizeBilinear=Zn,N.ResizeBilinearGrad=so,N.ResizeNearestNeighbor=ca,N.ResizeNearestNeighborGrad=Qa,N.Reverse=vn,N.RotateWithOffset=vs,N.Round=Pi,N.Rsqrt=yo,N.SGDOptimizer=Yh,N.ScatterNd=vo,N.SelectV2=Da,N.Selu=go,N.Sigmoid=As,N.Sign=Rs,N.Sin=Es,N.Sinh=Eo,N.Slice=To,N.Softmax=vi,N.Softplus=Zo,N.SpaceToBatchND=Ao,N.SparseToDense=tu,N.SplitV=Jo,N.Sqrt=Ro,N.Square=eu,N.SquaredDifference=Fs,N.Step=$o,N.StridedSlice=Ds,N.Sub=ds,N.Sum=Qo,N.Tan=fs,N.Tanh=Os,N.Tensor=$,N.TensorBuffer=De,N.Tile=Ms,N.TopK=ru,N.Transpose=ms,N.Unique=nu,N.Unpack=ys,N.UnsortedSegmentSum=Fo,N.Variable=rt,N.ZerosLike=zs,N._FusedMatMul=Do,N.abs=ci,N.acos=$c,N.acosh=el,N.add=Cr,N.addN=th,N.addStrict=Md,N.all=m,N.any=I,N.argMax=P,N.argMin=G,N.asin=ke,N.asinh=Fe,N.atan=Ge,N.atan2=s,N.atanh=r,N.avgPool=Yt,N.avgPool3d=vr,N.backend=ql,N.backend_util=Q2,N.basicLSTMCell=un,N.batchNorm=Kn,N.batchNorm2d=Ui,N.batchNorm3d=Zu,N.batchNorm4d=kh,N.batchToSpaceND=Hr,N.booleanMaskAsync=Ty,N.broadcastTo=Qu,N.browser=Pc,N.buffer=Qi,N.cast=dr,N.ceil=ah,N.clipByValue=oh,N.clone=Ho,N.complex=Ln,N.concat=kr,N.concat1d=Sh,N.concat2d=ep,N.concat3d=Ih,N.concat4d=Vn,N.conv1d=Cs,N.conv2d=gi,N.conv2dTranspose=Ks,N.conv3d=ap,N.conv3dTranspose=Sf,N.copyRegisteredKernels=Oo,N.cos=Th,N.cosh=op,N.cosineWindow=Tp,N.cumsum=sp,N.customGrad=Ts,N.deprecationWarn=Ea,N.depthToSpace=Yp,N.depthwiseConv2d=lh,N.device_util=Fr,N.diag=Af,N.dilation2d=Zp,N.disableDeprecationWarnings=Ku,N.dispose=Ua,N.disposeVariables=zl,N.div=Wr,N.divNoNan=Qp,N.divStrict=zd,N.dot=Jp,N.dropout=r0,N.elu=up,N.enableDebugMode=Ml,N.enableProdMode=Ol,N.enclosingPowerOfTwo=jd,N.engine=Ll,N.env=Rr,N.equal=hh,N.equalStrict=Ed,N.erf=$p,N.exp=hs,N.expandDims=ps,N.expm1=ed,N.eye=td,N.fft=Bh,N.fill=cp,N.findBackend=Hl,N.findBackendFactory=Gl,N.floor=Eh,N.floorDiv=Xu,N.fused=f0,N.gather=Rh,N.gatherND=$y,N.gather_util=bl,N.getBackend=Ul,N.getGradient=Bs,N.getKernel=Ps,N.getKernelsForBackend=gs,N.grad=p1,N.grads=d1,N.greater=xu,N.greaterEqual=Ju,N.greaterEqualStrict=Rd,N.greaterStrict=Ad,N.ifft=mh,N.imag=Ah,N.image=_2,N.inTopKAsync=a0,N.io=Tc,N.irfft=Np,N.isFinite=nd,N.isInf=ad,N.isNaN=id,N.keep=gu,N.kernel_impls=tv,N.leakyRelu=od,N.less=Fh,N.lessEqual=$u,N.lessEqualStrict=Fd,N.lessStrict=Dd,N.linalg=w2,N.linspace=u1,N.localResponseNormalization=sd,N.log=ec,N.log1p=hp,N.logSigmoid=cd,N.logSoftmax=ld,N.logSumExp=dp,N.logicalAnd=rc,N.logicalNot=Oh,N.logicalOr=fp,N.logicalXor=hd,N.losses=b2,N.matMul=sn,N.math=Mc,N.max=tc,N.maxPool=mp,N.maxPool3d=R1,N.maxPoolWithArgmax=F1,N.maximum=ol,N.maximumStrict=Ld,N.mean=ph,N.memory=Pl,N.min=Mh,N.minimum=zh,N.minimumStrict=Pd,N.mirrorPad=pd,N.mod=yp,N.modStrict=Bd,N.moments=W1,N.movingAverage=qy,N.mul=bt,N.mulStrict=Wd,N.multiRNNCell=V1,N.multinomial=G1,N.neg=ri,N.nextFrame=I2,N.norm=Gh,N.notEqual=Lh,N.notEqualStrict=Od,N.oneHot=Is,N.ones=sl,N.onesLike=vp,N.op=Re,N.outerProduct=Y1,N.pad=nc,N.pad1d=J1,N.pad2d=em,N.pad3d=rm,N.pad4d=am,N.pool=dd,N.pow=Ys,N.powStrict=Ud,N.prelu=gp,N.print=Au,N.prod=fd,N.profile=Zc,N.rand=dm,N.randomGamma=Sm,N.randomNormal=Nm,N.randomUniform=md,N.range=wp,N.ready=Wl,N.real=dh,N.reciprocal=yd,N.registerBackend=jl,N.registerGradient=au,N.registerKernel=ts,N.relu=fh,N.relu6=bp,N.removeBackend=Vl,N.reshape=Ke,N.reverse=Zs,N.reverse1d=Dm,N.reverse2d=Mm,N.reverse3d=Lm,N.reverse4d=Bm,N.rfft=Wh,N.round=vd,N.rsqrt=kp,N.scalar=Ur,N.scatterND=Xy,N.scatter_util=kl,N.selu=gd,N.separableConv2d=xd,N.serialization=Nl,N.setBackend=Bl,N.setPlatform=Kl,N.setdiff1dAsync=jm,N.sigmoid=mn,N.sign=_d,N.signal=x2,N.sin=Sp,N.sinh=Ip,N.slice=er,N.slice1d=Zm,N.slice2d=Jm,N.slice3d=ey,N.slice4d=ry,N.slice_util=Xc,N.softmax=wd,N.softplus=pp,N.spaceToBatchND=Ph,N.sparseToDense=Qy,N.spectral=g2,N.split=ll,N.sqrt=to,N.square=Xn,N.squaredDifference=Uh,N.squaredDifferenceStrict=Vd,N.squeeze=Vh,N.stack=oc,N.step=hl,N.stridedSlice=kd,N.sub=Lr,N.subStrict=Hd,N.sum=Yr,N.sumOutType=Ut,N.tan=Sd,N.tanh=Cn,N.tensor=An,N.tensor1d=cl,N.tensor2d=yh,N.tensor3d=Gs,N.tensor4d=yy,N.tensor5d=vy,N.tensor6d=gy,N.tensor_util=Et,N.test_util=Dl,N.tidy=la,N.tile=il,N.time=Qc,N.topk=Id,N.train=k2,N.transpose=$n,N.truncatedNormal=wy,N.unique=Nd,N.unregisterGradient=iu,N.unregisterKernel=bu,N.unsortedSegmentSum=Cp,N.unstack=Hh,N.upcastType=Pt,N.util=ae,N.valueAndGrad=f1,N.valueAndGrads=m1,N.variable=Iy,N.variableGrads=ud,N.version_core=qu,N.where=ls,N.whereAsync=Td,N.zeros=Xs,N.zerosLike=gn}),ag=Or(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),we=function(s,u){return we=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])},we(s,u)};function M(s,u){we(s,u);function r(){this.constructor=s}s.prototype=u===null?Object.create(u):(r.prototype=u.prototype,new r)}var V=function(){return V=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},V.apply(this,arguments)};function oe(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 de(s,u,r,o){return new(r||(r=Promise))(function(h,b){function T(Z){try{q(o.next(Z))}catch(le){b(le)}}function O(Z){try{q(o.throw(Z))}catch(le){b(le)}}function q(Z){Z.done?h(Z.value):new r(function(le){le(Z.value)}).then(T,O)}q((o=o.apply(s,u||[])).next())})}function X(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:O(0),throw:O(1),return:O(2)},typeof Symbol=="function"&&(T[Symbol.iterator]=function(){return this}),T;function O(Z){return function(le){return q([Z,le])}}function q(Z){if(o)throw new TypeError("Generator is already executing.");for(;r;)try{if(o=1,h&&(b=Z[0]&2?h.return:Z[0]?h.throw||((b=h.return)&&b.call(h),0):h.next)&&!(b=b.call(h,Z[1])).done)return b;(h=0,b)&&(Z=[Z[0]&2,b.value]);switch(Z[0]){case 0:case 1:b=Z;break;case 4:return r.label++,{value:Z[1],done:!1};case 5:r.label++,h=Z[1],Z=[0];continue;case 7:Z=r.ops.pop(),r.trys.pop();continue;default:if(!(b=r.trys,b=b.length>0&&b[b.length-1])&&(Z[0]===6||Z[0]===2)){r=0;continue}if(Z[0]===3&&(!b||Z[1]>b[0]&&Z[1]<b[3])){r.label=Z[1];break}if(Z[0]===6&&r.label<b[1]){r.label=b[1],b=Z;break}if(b&&r.label<b[2]){r.label=b[2],r.ops.push(Z);break}b[2]&&r.ops.pop(),r.trys.pop();continue}Z=u.call(s,r)}catch(le){Z=[6,le],h=0}finally{o=b=0}if(Z[0]&5)throw Z[1];return{value:Z[0]?Z[1]:void 0,done:!0}}}var Te;function z(){return Te==null&&(Te=i.backend().epsilon()),Te}function he(){return"channelsLast"}var ye=function(s){M(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error),ee=function(s){M(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){M(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error),xe=function(s){M(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error),We=function(s){M(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){M(u,s);function u(r){var o=s.call(this,r)||this;return Object.setPrototypeOf(o,u.prototype),o}return u}(Error);function st(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 ut(s,u){if(!s)throw new We(u)}function Kt(s,u){for(var r=0,o=0,h=s;o<h.length;o++){var b=h[o];b===u&&r++}return r}function It(s){return s.length===1?s[0]:s}function Ze(s){return Array.isArray(s)?s:[s]}function mt(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 yt(s){return s.length<=1||s.indexOf("_")===-1?s:s.replace(/[_]+(\w|$)/g,function(u,r){return r.toUpperCase()})}var $e={};function ot(s){if(s==null)return null;var u={};return u.className=s.getClassName(),u.config=s.getConfig(),u}function nt(s){if(s==null||typeof s!="object")return;if(Array.isArray(s))s.forEach(function(T){return nt(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:nt(b))}}function et(s,u,r,o,h){var b,T,O;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,Z=void 0;if(q in r)Z=r[q];else if(q in $e)Z=$e[q];else if(Z=u[q],Z==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 Z}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,Be=void 0,je=void 0;if(Ne in r?(b=r[Ne],Be=b[0],je=b[1]):Ne in $e?(T=$e.className,Be=T[0],je=T[1]):Ne in u&&(O=u[Ne],Be=O[0],je=O[1]),Be==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={},vt=0,pt=Object.keys($e);vt<pt.length;vt++){var ct=pt[vt];qe[ct]=$e[ct]}for(var dt=0,Ft=Object.keys(r);dt<Ft.length;dt++){var ct=Ft[dt];qe[ct]=r[ct]}var sr=le.config;sr.customObjects=qe;for(var Yt=V({},$e),$t=0,vr=Object.keys(r);$t<vr.length;$t++){var ct=vr[$t];$e[ct]=r[ct]}nt(le.config);var hr=je(Be,le.config,r,h);return $e=V({},Yt),hr}else{for(var Yt=V({},$e),Ir=0,zr=Object.keys(r);Ir<zr.length;Ir++){var ct=zr[Ir];$e[ct]=r[ct]}var hr=new Be(le.config);return $e=V({},Yt),hr}}}function Qt(s,u){return s<u?-1:s>u?1:0}function rr(s,u){return-1*Qt(s,u)}function jt(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 jr(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 Pr(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),ut(r>=0),ut(o>=r),Array.isArray(s)&&s.length>=r&&s.length<=o&&s.every(function(h){return typeof h===u})}function ar(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 ar(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 "+(da(s)+".")})}function da(s){return s===null?"null":Array.isArray(s)?"["+s.map(function(u){return da(u)}).join(",")+"]":typeof s=="string"?'"'+s+'"':""+s}function Ha(s,u){var r=i.util.now(),o,h=function(){for(var b=[],T=0;T<arguments.length;T++)b[T]=arguments[T];var O=i.util.now();return O-r<u||(r=O,o=s.apply(void 0,b)),o};return h}function Tn(s){return s==="relu"?"relu":s==="linear"?"linear":s==="elu"?"elu":null}function ba(s,u){return i.tidy(function(){return i.sqrt(i.sum(i.mul(s,s),u,!0))})}var ka=function(s){M(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.getConfig=function(){return{}},u}(i.serialization.Serializable),ta=function(s){M(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=ba(r,o.axis),b=i.clipByValue(h,0,o.maxValue);return i.mul(r,i.div(b,i.add(z(),h)))})},u.prototype.getConfig=function(){return{maxValue:this.maxValue,axis:this.axis}},u.className="MaxNorm",u}(ka);i.serialization.registerClass(ta);var Ma=function(s){M(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(z(),ba(r,o.axis)))})},u.prototype.getConfig=function(){return{axis:this.axis}},u.className="UnitNorm",u}(ka);i.serialization.registerClass(Ma);var Ti=function(s){M(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}(ka);i.serialization.registerClass(Ti);var Bn=function(s){M(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=ba(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(z(),h)))})},u.prototype.getConfig=function(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}},u.className="MinMaxNorm",u}(ka);i.serialization.registerClass(Bn);var ra={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function cn(s){return ot(s)}function za(s,u){return u===void 0&&(u={}),et(s,i.serialization.SerializationMap.getMap().classNameMap,u,"constraint")}function fn(s){if(s==null)return null;if(typeof s=="string"){var u=s in ra?ra[s]:s,r={className:u,config:{}};return za(r)}else return s instanceof ka?s:za(s)}function Gn(s){return new ta(s)}function _i(s){return new Ma(s)}function fa(){return new Ti}function Hi(s){return new Bn(s)}var Yn={__proto__:null,maxNorm:Gn,unitNorm:_i,nonNeg:fa,minMaxNorm:Hi},Wn=["channelsFirst","channelsLast"],Ga=["valid","same","causal"],Sa=["max","avg"],hi=["sum","mul","concat","ave"],La=new Map;function on(s){Pr(Wn,"DataFormat",s)}function xn(s){Pr(Ga,"PaddingMode",s)}function Ia(s){Pr(Sa,"PoolMode",s)}var Rr=[],Pa="/";function na(s,u){Rr.push(s);try{var r=u();return Rr.pop(),r}catch(o){throw Rr.pop(),o}}function Ei(){return Rr.length===0?"":Rr.join(Pa)+Pa}function Gi(s){if(!ni(s))throw new Error("Not a valid tensor name: '"+s+"'");return Ei()+s}function Ri(s){if(!ni(s))throw new Error("Not a valid tensor name: '"+s+"'");La.has(s)||La.set(s,0);var u=La.get(s);if(La.set(s,La.get(s)+1),u>0){var r=s+"_"+u;return La.set(r,1),r}else return s}var jn=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function ni(s){return!!s.match(jn)}function pi(s){return s===parseInt(s.toString(),10)}function ma(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 ja(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 ai(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 Ai(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 ya(r,[1,u,1])})}function wi(s){var u=[ma(s.shape)];return s.reshape(u)}function no(s){if(s.rank<=1)throw new w("batchFlatten requires a minimum rank of 2. Got rank: "+s.rank+".");var u=[s.shape[0],ma(s.shape,1)];return s.reshape(u)}function Qn(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 ji(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 Qn(s,u,r);case 2:return ji(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 Qn(s,u,r);case 2:return i.slice3d(s,[0,u,0],[s.shape[0],r,s.shape[2]]);case 3:return ji(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 Qn(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 ji(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 qi(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 Di(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 ya(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 Oi(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 xe("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 xe("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,O=!1;return i.fused.matMul({a:s,b:u,transposeA:T,transposeB:O,bias:o?ne(s.rank,o,he()):null,activation:r})}else{var q=s.shape.slice(),Z=q.pop();s=s.reshape([-1,Z]);var le=u.shape.slice(),Ne=le.pop(),b=le.pop(),Be=le.concat([Ne]),je=Array.from({length:u.rank},function(dt,Ft){return Ft===0?u.rank-2:Ft<=u.rank-2?Ft-1:Ft});u=u.transpose(je).reshape([b,-1]);var qe=q.concat(Be),T=!1,O=!1;return i.fused.matMul({a:s,b:u,transposeA:T,transposeB:O,bias:o?ne(s.rank,o,he()):null,activation:r}).reshape(qe)}}function Y(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 ne(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 re(s,u,r){return i.tidy(function(){return r==null&&(r=he()),on(r),s.add(ne(s.rank,u,r))})}function Ue(s,u){if(u===void 0&&(u=1),u!==1)throw new xe("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 tt(s,u,r,o){return i.tidy(function(){return i.dropout(s,u,r,o)})}function ze(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 Dt=["fanIn","fanOut","fanAvg"],St=["normal","uniform","truncatedNormal"];function Mt(s){Pr(Dt,"FanMode",s)}function fr(s){Pr(St,"Distribution",s)}var or=function(s){M(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),aa=function(s){M(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}(or);i.serialization.registerClass(aa);var va=function(s){M(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}(or);i.serialization.registerClass(va);var ia=function(s){M(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}(or);i.serialization.registerClass(ia);var qa=function(s){M(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}(or);i.serialization.registerClass(qa);var bi=function(s){M(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 xe("randomNormal does not support dType "+o+".");return Oi(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}(or);i.serialization.registerClass(bi);var rn=function(s){M(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 xe("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}(or);i.serialization.registerClass(rn);var hn=function(s){M(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}(or);i.serialization.registerClass(hn);function oa(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=ma(s,2);r=s[1]*h,o=s[0]*h}else if(u==="channelsLast"){var h=ma(s,0,s.length-2);r=s[s.length-2]*h,o=s[s.length-1]*h}}else{var b=ma(s);r=Math.sqrt(b),o=Math.sqrt(b)}return[r,o]}var Jr=function(s){M(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,fr(o.distribution),o.seed=r.seed,o}return u.prototype.apply=function(r,o){var h=oa(r),b=h[0],T=h[1],O=this.scale;if(this.mode==="fanIn"?O/=Math.max(1,b):this.mode==="fanOut"?O/=Math.max(1,T):O/=Math.max(1,(b+T)/2),this.distribution==="normal"){var q=Math.sqrt(O);if(o=o||"float32",o!=="float32"&&o!=="int32")throw new xe(this.getClassName()+" does not support dType "+o+".");return i.truncatedNormal(r,0,q,o,this.seed)}else{var Z=Math.sqrt(3*O);return i.randomUniform(r,-Z,Z,o)}},u.prototype.getConfig=function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}},u.className="VarianceScaling",u}(or);i.serialization.registerClass(Jr);var Vr=function(s){M(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){M(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){M(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 En=function(s){M(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(En);var qn=function(s){M(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(qn);var sa=function(s){M(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(sa);var ga=function(s){M(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 xe("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 xe("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=Oi(b,0,1,"float32"),O=i.linalg.gramSchmidt(T);return r[0]>r[1]&&(O=O.transpose()),i.mul(h.gain,O)})},u.prototype.getConfig=function(){return{gain:this.gain,seed:this.seed}},u.className="Orthogonal",u}(or);i.serialization.registerClass(ga);var Mi={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 Aa(s,u){return u===void 0&&(u={}),et(s,i.serialization.SerializationMap.getMap().classNameMap,u,"initializer")}function S(s){return ot(s)}function x(s){if(typeof s=="string"){var u=s in Mi?Mi[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 En;if(u==="LeCunNormal")return new qn;if(u==="LeCunUniform")return new sa;var r={};return r.className=u,r.config={},Aa(r)}else return s instanceof or?s:Aa(s)}function k(){return new aa}function K(){return new va}function Se(s){return new ia(s)}function be(s){return new qa(s)}function Je(s){return new bi(s)}function Pe(s){return new rn(s)}function gt(s){return new hn(s)}function ft(s){return new Jr(s)}function Lt(s){return new Vr(s)}function Wt(s){return new Jn(s)}function Gt(s){return new tn(s)}function Jt(s){return new En(s)}function wr(s){return new qn(s)}function Ar(s){return new sa(s)}function Zt(s){return new ga(s)}var xr={__proto__:null,zeros:k,ones:K,constant:Se,randomUniform:be,randomNormal:Je,truncatedNormal:Pe,identity:gt,varianceScaling:ft,glorotUniform:Lt,glorotNormal:Wt,heNormal:Gt,heUniform:Jt,leCunNormal:wr,leCunUniform:Ar,orthogonal:Zt},kn=0;function pn(){return kn++}var zn={};function Dr(s){return s===void 0&&(s=""),s in zn||(zn[s]=0),zn[s]+=1,s+zn[s].toString()}function Na(s){return Array.isArray(s)&&Array.isArray(s[0])}function Sn(s){return s.length===0?[]:Array.isArray(s[0])?s:[s]}function cr(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 Fa(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",Ka=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==null?"float32":r,this.shape=u.shape,this.id=pn(),o=o==null?mi:o,this.originalName=Gi(o),this.name=Ri(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(),Xa(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 Xa(s,u){if(s.shape.toString()!==u.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(s.shape)+" vs. "+JSON.stringify(u.shape))}function ii(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 Rn=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}(),Ca=function(){function s(u,r,o,h,b,T,O){this.dtype=u,this.shape=r,this.sourceLayer=o,this.inputs=h,this.callArgs=b,this.outputTensorIndex=O,this.id=pn(),T!=null&&(this.originalName=Gi(T),this.name=Ri(this.originalName)),this.rank=r.length}return s}(),Ki=0,yi=function(){function s(u,r){this.callArgs=r,this.id=Ki++,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}(),oi=0,qr=function(s){M(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=oi++,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=mt(b)+"_"+Dr(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 O=null;r.batchSize!=null&&(O=r.batchSize),T=[O].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 ee("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 It(this.getNodeAtIndex(r,"input").inputTensors)},u.prototype.getOutputAt=function(r){return It(this.getNodeAtIndex(r,"output").outputTensors)},Object.defineProperty(u.prototype,"input",{get:function(){if(this.inboundNodes.length>1)throw new ye("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 ye("Layer "+this.name+" is not connected, no input to return.");return It(this.getNodeAtIndex(0,"input").inputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"output",{get:function(){if(this.inboundNodes.length===0)throw new ye("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new ye("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return It(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=Ze(r),this.inputSpec==null||this.inputSpec.length===0)return;var o=Ze(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 O=b.rank;if(T.ndim!=null&&O!==T.ndim)throw new w("Input "+h+" is incompatible with layer "+this.name+": "+("expected ndim="+T.ndim+", found ndim="+O));if(T.maxNDim!=null&&O>T.maxNDim)throw new w("Input "+h+" is incompatible with layer "+this.name+(": expected max_ndim="+T.maxNDim+", found ndim="+O));if(T.minNDim!=null&&O<T.minNDim)throw new w("Input "+h+" is incompatible with layer "+this.name+(": expected min_ndim="+T.minNDim+", found ndim="+O+"."));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 Z in T.axes){var le=Number(Z),Ne=T.axes[Z],Be=le>=0?q[le]:q[q.length+le];if(Ne!=null&&[Ne,null].indexOf(Be)===-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],vt=b.shape[je];if(qe!=null&&vt!=null&&qe!==vt)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=Ze(r),T=!0,O=0,q=b;O<q.length;O++){var Z=q[O];if(!(Z instanceof Ca)){T=!1;break}}for(var le=!0,Ne=0,Be=b;Ne<Be.length;Ne++){var Z=Be[Ne];if(Z instanceof Ca){le=!1;break}}if(T===le)throw new w("Arguments to apply() must be all SymbolicTensors or all Tensors");return na(this.name,function(){if(!h.built){h.assertInputCompatibility(r);for(var je=[],qe=0,vt=Ze(r);qe<vt.length;qe++){var pt=vt[qe];je.push(pt.shape)}h.build(It(je)),h.built=!0,h.initialWeights&&h.setWeights(h.initialWeights),h._refCount===null&&le&&(h._refCount=1)}if(h.assertInputCompatibility(r),le){for(var ct=h.call(r,o),dt=Ze(ct),Ft=[],sr=0,Yt=dt;sr<Yt.length;sr++){var $t=Yt[sr];b.indexOf($t)!==-1&&($t=$t.clone()),Ft.push($t)}if(ct=It(Ft),h.activityRegularizer!=null)throw new xe("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return ct}else{var vr=Io(r),hr=h.computeOutputShape(vr),ct=void 0,Ir=nn(r);if(h.warnOnIncompatibleInputShape(Array.isArray(r)?vr[0]:vr),hr!=null&&hr.length>0&&Array.isArray(hr[0])?ct=hr.map(function(kr,Sr){return new Ca(Ir,kr,h,Ze(r),o,h.name,Sr)}):ct=new Ca(Ir,hr,h,Ze(r),o,h.name),h.addInboundNode(r,ct,null,null,vr,hr,o),h._refCount++,h.activityRegularizer!=null)throw new xe("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return ct}})},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 ye("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 O=this.inboundNodes[0].outputShapes;return Array.isArray(O)&&Array.isArray(O[0])&&O.length===1?O[0]:O}else throw new ye("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 ee("You tried to call countParams() on "+this.name+", but the layer is not built yet. Build it first by calling build(batchInputShape).");return Fa(this.weights)},u.prototype.build=function(r){this.built=!0},u.prototype.getWeights=function(r){return r===void 0&&(r=!1),ii(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=ii(h),O=0;O<T.length;++O){var q=T[O],Z=h[O],le=r[O];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([Z,le])}zi(b)})},u.prototype.addWeight=function(r,o,h,b,T,O,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 Z=b.apply(o,h),le=new Ka(Z,h,r,O,q);return Z.dispose(),T!=null&&this.addLoss(function(){return T.apply(le.read())}),O==null&&(O=!0),O?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=Ze(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,O,q){q===void 0&&(q=null);var Z=Ze(r);o=Ze(o),h=Ze(h),b=Ze(b),T=Sn(T),O=Sn(O);for(var le=[],Ne=[],Be=[],je=0,qe=Z;je<qe.length;je++){var vt=qe[je];le.push(vt.sourceLayer),Ne.push(vt.nodeIndex),Be.push(vt.tensorIndex)}new yi({outboundLayer:this,inboundLayers:le,nodeIndices:Ne,tensorIndices:Be,inputTensors:Z,outputTensors:o,inputMasks:h,outputMasks:b,inputShapes:T,outputShapes:O},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=Ze(s);for(var u=[],r=0,o=s;r<o.length;r++){var h=o[r];u.push(h.shape)}return It(u)}function nn(s){return"float32"}function Ya(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],O=o.inboundLayers[b],q=o.nodeIndices[b],Z=Ya(T,O,q),le=0,Ne=Z;le<Ne.length;le++){var Be=Ne[le];h.indexOf(Be)===-1&&h.push(Be)}return h}var Ba=function(s){M(u,s);function u(r){var o=s.call(this,{dtype:r.dtype,name:r.name!=null?r.name:Dr("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 Ca(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(Ba);function Xi(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 Ba({batchInputShape:u,name:s.name,dtype:r,sparse:s.sparse}),h=o.inboundNodes[0].outputTensors;return h[0]}function si(s){return de(this,void 0,void 0,function(){var u,r,o,h,b,T,O,q;return X(this,function(Z){switch(Z.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(O=Z.sent(),q=0;q<O.length;++q)s[r[q]]=O[q][0];i.dispose(o),Z.label=2;case 2:return[2]}})})}function Li(s){if(s==null)return;for(var u in s){var r=s[u];typeof r!="number"&&r.dispose()}}var ao;(function(s){s[s.SILENT=0]="SILENT",s[s.VERBOSE=1]="VERBOSE"})(ao||(ao={}));var mo=125,Za=function(){function s(){this.validationData=null}return s.prototype.setParams=function(u){this.params=u},s.prototype.onEpochBegin=function(u,r){return de(this,void 0,void 0,function(){return X(this,function(o){return[2]})})},s.prototype.onEpochEnd=function(u,r){return de(this,void 0,void 0,function(){return X(this,function(o){return[2]})})},s.prototype.onBatchBegin=function(u,r){return de(this,void 0,void 0,function(){return X(this,function(o){return[2]})})},s.prototype.onBatchEnd=function(u,r){return de(this,void 0,void 0,function(){return X(this,function(o){return[2]})})},s.prototype.onTrainBegin=function(u){return de(this,void 0,void 0,function(){return X(this,function(r){return[2]})})},s.prototype.onTrainEnd=function(u){return de(this,void 0,void 0,function(){return X(this,function(r){return[2]})})},s.prototype.setModel=function(u){},s}(),io=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 de(this,void 0,void 0,function(){var o,h,b;return X(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 de(this,void 0,void 0,function(){var o,h,b;return X(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 de(this,void 0,void 0,function(){var o,h,b;return X(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 de(this,void 0,void 0,function(){var o,h,b;return X(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 de(this,void 0,void 0,function(){var r,o,h;return X(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 de(this,void 0,void 0,function(){var r,o,h;return X(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}(),Yo=function(s){M(u,s);function u(){return s.call(this)||this}return u.prototype.onEpochBegin=function(r){return de(this,void 0,void 0,function(){return X(this,function(o){return this.seen=0,this.totals={},[2]})})},u.prototype.onBatchEnd=function(r,o){return de(this,void 0,void 0,function(){var h,b,T,O,q=this;return X(this,function(Z){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 Be=void 0;le in T.totals?Be=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,Be!=null&&Be.dispose()}},T=this;for(O in o)b(O);return[2]})})},u.prototype.onEpochEnd=function(r,o){return de(this,void 0,void 0,function(){var h,b,T,O,q,Z=this;return X(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 Be=i.mul(i.div(1,Z.seen),Z.totals[Ne]);o[Ne]=Be,Z.totals[Ne].dispose(),i.keep(o[Ne])})},b=this,T=0,O=this.params.metrics;T<O.length;T++)q=O[T],h(q);return[2]})})},u}(Za),No=function(s){M(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.onTrainBegin=function(r){return de(this,void 0,void 0,function(){return X(this,function(o){return this.epoch=[],this.history={},[2]})})},u.prototype.onEpochEnd=function(r,o){return de(this,void 0,void 0,function(){var h;return X(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 de(this,void 0,void 0,function(){var r,o,h,b,T,O,q,Z,le,Ne;return X(this,function(Be){switch(Be.label){case 0:r=[],o=[],h=[];for(b in this.history)for(T=this.history[b],O=0;O<T.length;++O)typeof T[O]!="number"&&(q=T[O],r.push(q.data()),o.push(b),h.push(O));return[4,Promise.all(r)];case 1:for(Z=Be.sent(),le=0;le<Z.length;++le)Ne=this.history[o[le]][h[le]],Ne.dispose(),this.history[o[le]][h[le]]=Z[le][0];return[2]}})})},u}(Za),Co=function(s){M(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=Ha(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 de(this,void 0,void 0,function(){var b;return X(this,function(T){switch(T.label){case 0:return b=[],this.yield!=null?[4,si(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 de(this,void 0,void 0,function(){return X(this,function(h){switch(h.label){case 0:return this.currentEpoch=r,this.epochBegin!=null?[4,si(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 de(this,void 0,void 0,function(){var h;return X(this,function(b){switch(b.label){case 0:return h=[],this.epochEnd!=null?[4,si(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 de(this,void 0,void 0,function(){return X(this,function(h){switch(h.label){case 0:return this.batchBegin!=null?[4,si(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 de(this,void 0,void 0,function(){var h;return X(this,function(b){switch(b.label){case 0:return h=[],this.batchEnd!=null?[4,si(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 de(this,void 0,void 0,function(){return X(this,function(o){switch(o.label){case 0:return this.trainBegin!=null?[4,si(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 de(this,void 0,void 0,function(){return X(this,function(o){switch(o.label){case 0:return this.trainEnd!=null?[4,si(r)]:[3,3];case 1:return o.sent(),[4,this.trainEnd(r)];case 2:o.sent(),o.label=3;case 3:return[2]}})})},u}(Za);function oo(s,u){if(s==null&&(s={}),s instanceof Za)return[s];if(Array.isArray(s)&&s[0]instanceof Za)return s;var r=Ze(s);return r.map(function(o){return new Co(o,u)})}var ua=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 Br(s,u,r,o,h,b,T,O,q){var Z=new No,le=[new Yo].concat(ua.createCallbacks(u));s!=null&&le.push.apply(le,s),le.push(Z);var Ne=new io(le);return Ne.setParams({epochs:r,initialEpoch:o,samples:h,steps:b,batchSize:T,verbose:u,doValidation:O,metrics:q}),{callbackList:Ne,history:Z}}function ca(s,u,r){return u===void 0&&(u={}),r===void 0&&(r=!1),et(s,i.serialization.SerializationMap.getMap().classNameMap,u,"layer",r)}function Qa(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,z()),h=i.sqrt(i.maximum(r,o));return i.div(s,h)})}function Zn(s,u){return i.tidy(function(){return i.mean(j(i.sub(u,s)),-1)})}function so(s,u){return i.tidy(function(){return i.mean(i.abs(i.sub(u,s)),-1)})}function Ta(s,u){return i.tidy(function(){var r=i.sub(s,u),o=i.clipByValue(i.abs(s),z(),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,z(),Number.MAX_VALUE),o=i.log(i.add(1,r)),h=i.clipByValue(s,z(),Number.MAX_VALUE),b=i.log(i.add(1,h));return i.mean(j(i.sub(o,b)),-1)})}function Pi(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 Da(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,z(),1-z()),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(wi(s)).toInt();u=i.clipByValue(u,z(),1-z());var h=u.shape,b=i.oneHot(o,h[h.length-1]).reshape(h);return go(b,u,r)})}function Es(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,z(),1-z()),r=i.log(i.div(r,i.sub(1,r))),i.mean(Es(s,r),-1)})}function Rs(s,u){return i.tidy(function(){var r=i.clipByValue(s,z(),1),o=i.clipByValue(u,z(),1);return i.sum(i.mul(s,i.log(i.div(r,o))),-1)})}function As(s,u){return i.tidy(function(){var r=i.log(i.add(z(),u));return i.mean(i.sub(u,i.mul(s,r)),-1)})}function Zo(s,u){return i.tidy(function(){var r=Qa(s,-1),o=Qa(u,-1),h=i.mul(r,o);return i.neg(i.sum(h,-1))})}var Ro={meanSquaredError:Zn,meanAbsoluteError:so,meanAbsolutePercentageError:Ta,meanSquaredLogarithmicError:vn,squaredHinge:Pi,hinge:yo,categoricalHinge:vo,logcosh:Da,categoricalCrossentropy:go,sparseCategoricalCrossentropy:To,binaryCrossentropy:Eo,kullbackLeiblerDivergence:Rs,poisson:As,cosineProximity:Zo};function Qo(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=ai(i.greater(u,r),s.dtype);return i.mean(i.equal(s,o),-1)})}function Jo(s,u){return i.tidy(function(){return ai(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 eu(s,u){return i.tidy(function(){return i.logicalAnd(s.equal(0),u.equal(1)).sum().cast("float32")})}function ds(s,u){return i.tidy(function(){var r=vi(s,u),o=eu(s,u),h=r.add(o);return i.where(i.greater(h,0),r.div(h),0).cast("float32")})}function tu(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 Ds(s,u){return Eo(s,u)}function fs(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 Os=Zn,Ms=Zn,ru=so,ms=so,nu=Ta,ys=Ta,Fo=go,zs=Zo,$o=To,xo={binaryAccuracy:Ao,categoricalAccuracy:Jo,precision:ds,categoricalCrossentropy:Fo,sparseCategoricalCrossentropy:$o,mse:Os,MSE:Ms,mae:ru,MAE:ms,mape:nu,MAPE:ys,cosine:zs};function vs(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 Do(s){if(ut(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 Ls(s){var u={Adagrad:function(){return i.train.adagrad(.01)},Adadelta:function(){return i.train.adadelta(1,.95,z())},Adam:function(){return i.train.adam(.001,.9,.999,z())},Adamax:function(){return i.train.adamax(.002,.9,.999,z(),0)},RMSProp:function(){return i.train.rmsprop(.001,.9,0,z())},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 es=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>es&&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 <= "+(es+"."))}}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 O=T[b];if(!wo(O))return!1}return!0}else return!1;else{var q=typeof s;return q==="string"||q==="number"||q==="boolean"}}function Ps(s,u,r,o){o===void 0&&(o=console.log);var h=gs(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(Be){return Math.floor(u*Be)}));var T;if(!h){b.push("Receives inputs"),T=[];for(var O in s.nodesByDepth)T.push.apply(T,s.nodesByDepth[O])}o("_".repeat(u)),ts(b,r,o),o("=".repeat(u));for(var q=s.layers,Z=0;Z<q.length;++Z)h?au(q[Z],r,o):bu(q[Z],r,T,o),o((Z===q.length-1?"=":"_").repeat(u));s.checkTrainableWeightsConsistency();var le=Bs(s),Ne=Fa(s.nonTrainableWeights);o("Total params: "+(le+Ne)),o("Trainable params: "+le),o("Non-trainable params: "+Ne),o("_".repeat(u))}function Bs(s){var u;return s.collectedTrainableWeights!=null?u=Fa(s.collectedTrainableWeights):u=Fa(s.trainableWeights),u}function gs(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 O=T[b];if(O.length>1||O.length===1&&O[0].inboundLayers.length>1){u=!1;break}o.push.apply(o,O)}if(u)for(var q=0,Z=s.layers;q<Z.length;q++){for(var le=Z[q],Ne=!1,Be=0,je=le.inboundNodes;Be<je.length;Be++){var qe=je[Be];if(o.indexOf(qe)!==-1)if(Ne){u=!1;break}else Ne=!0}if(!u)break}return u}function ts(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 au(s,u,r){var o;try{o=JSON.stringify(s.outputShape)}catch(O){o="multiple"}var h=s.name,b=s.getClassName(),T=[h+" ("+b+")",o,s.countParams().toString()];ts(T,u,r)}function bu(s,u,r,o){var h;try{h=JSON.stringify(s.outputShape)}catch(ct){h="multiple"}for(var b=[],T=0,O=s.inboundNodes;T<O.length;T++){var q=O[T];if(r!=null&&r.length>0&&r.indexOf(q)===-1)continue;for(var Z=0;Z<q.inboundLayers.length;++Z){var le=q.inboundLayers[Z].name,Ne=q.nodeIndices[Z],Be=q.tensorIndices[Z];b.push(le+"["+Ne+"]["+Be+"]")}}var je=s.name,qe=s.getClassName(),vt=b.length===0?"":b[0],pt=[je+" ("+qe+")",h,s.countParams().toString(),vt];ts(pt,u,o);for(var Z=1;Z<b.length;++Z)ts(["","","",b[Z]],u,o)}function iu(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 yt(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];iu(u,h,b)?r.push(b):r.push(Oo(b,u))}return r}else{for(var T={},O=0,q=Object.keys(s);O<q.length;O++){var Z=q[O],le=s[Z];if(Z==="name"&&typeof le=="string")T[Z]=le;else{var Ne=yt(Z);T[Ne]=Oo(le,Ne)}}return T}}function Mo(s,u){if(s==null)return null;if(typeof s=="string")return mt(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];iu(u,h,b)?r.push(b):r.push(Mo(b,u))}return r}else{for(var T={},O=0,q=Object.keys(s);O<q.length;O++){var Z=q[O],le=s[Z],Ne=mt(Z);(Z==="name"||Z==="className")&&typeof le=="string"?T[Ne]=le:T[Ne]=Mo(le,Z)}return T}}var xs="2.7.0";function rs(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 ki=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]=rs(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 Ca){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 Ca){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}(),zo={},Lo={};function Yi(s,u,r,o){for(var h=r==null?!1:r.training,b=Array.isArray(s),T=b?s:[s],O=T.map(function(Hr){return Hr.name}),q=[],Z=u.names(),le=0,Ne=O;le<Ne.length;le++){var Be=Ne[le];Z.indexOf(Be)!==-1?q.push(u.getValue(Be)):q.push(null)}o!=null&&(o.maxNumTensors=-Infinity,o.minNumTensors=Infinity);var je=O.join(",")+"|"+u.names().join(","),qe,vt;if(zo[je]==null){var pt=ns(T,u);qe=pt.sorted,vt=pt.recipientCounts,zo[je]=qe,Lo[je]=vt}qe=zo[je],vt={},h||Object.assign(vt,Lo[je]);for(var ct=new ki(u),dt=0;dt<qe.length;++dt){if(o!=null){var Ft=i.memory().numTensors;Ft>o.maxNumTensors&&(o.maxNumTensors=Ft),Ft<o.minNumTensors&&(o.minNumTensors=Ft)}var sr=qe[dt],Yt=sr.sourceLayer;if(Yt instanceof Ba)continue;for(var $t=[],vr=[],hr=[],Ir=!1,zr=0,kr=sr.inputs;zr<kr.length;zr++){var Sr=kr[zr],mn=ct.getValue(Sr),Xr=ct.getMask(Sr);$t.push(mn),vr.push(Xr),Xr!=null&&(Ir=!0),h||(vt[Sr.name]--,vt[Sr.name]===0&&!u.hasKey(Sr)&&O.indexOf(Sr.name)===-1&&!mn.isDisposed&&Sr.sourceLayer.stateful!==!0&&hr.push(mn))}Ir&&(r=r||{},r.mask=vr[0]);var er=Ze(Yt.apply($t,r)),Dn=null;Yt.supportsMasking&&(Dn=Yt.computeMask($t,vr));for(var Cn=E(sr),bn=Array.isArray(Cn)?Cn:[Cn],un=0;un<bn.length;++un){ct.hasKey(bn[un])||ct.add(bn[un],er[un],Array.isArray(Dn)?Dn[0]:Dn);var On=O.indexOf(bn[un].name);On!==-1&&(q[On]=er[un])}h||i.dispose(hr)}return ct.disposeMasks(),b?q:q[0]}function ns(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,O=s;T<O.length;T++){for(var q=O[T],Z=ue(q,u),le=Z.sorted,Ne=Z.recipientMap,Be=0,je=le;Be<je.length;Be++){var qe=je[Be];b.has(qe.name)||(r.push(qe),b.add(qe.name))}var vt=function(ct){o[ct]==null&&(o[ct]=new Set),Ne[ct].forEach(function(dt){return o[ct].add(dt)})};for(var pt in Ne)vt(pt)}return{sorted:r,recipientCounts:ae(o)}}function ae(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 O=T[b];r.add(O)}var q=[],Z=[];for(q.push(s);q.length>0;){var le=q[q.length-1];if(r.has(le.name)){q.pop();continue}var Ne=Z[Z.length-1]===q.length-1;if(le.inputs.length===0||Ne)q.pop(),o.push(le),r.add(le.name),Ne&&Z.pop();else{Z.push(q.length-1);for(var Be=0,je=le.inputs;Be<je.length;Be++){var qe=je[Be];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 D=function(s){M(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=Dr(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],jt(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(Vn){return Vn.name})));jt(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(Vn){return Vn.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 O=T[b],q=O.sourceLayer,Z=O.nodeIndex,le=O.tensorIndex;o.outputLayers.push(q),o.outputLayersNodeIndices.push(Z),o.outputLayersTensorIndices.push(le)}for(var Ne=0,Be=o.inputs;Ne<Be.length;Ne++){var O=Be[Ne],q=O.sourceLayer,Z=O.nodeIndex,le=O.tensorIndex;ut(Z===0,"input layer has >1 nodes"),ut(le===0,"input layer has >1 tensors"),o.inputLayers.push(q),o.inputLayersNodeIndices.push(Z),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 Ba))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,vt=o.outputLayers;qe<vt.length;qe++){var q=vt[qe];o.outputNames.push(q.name)}o.internalInputShapes=o.inputs.map(function(Vn){return Vn.shape}),o.internalOutputShapes=o.outputs.map(function(Vn){return Vn.shape});for(var pt={},ct={},dt={},Ft={},sr={},Yt=[],$t=function(Vn,Ns,gi,qo,Cs,Nh){(qo==null||Cs==null||Nh==null)&&(qo=Vn.sourceLayer,Cs=Vn.nodeIndex,Nh=Vn.tensorIndex);var Ci=qo.inboundNodes[Cs];if(gi.indexOf(Ci)!==-1)throw new ee("The tensor "+Vn.name+' at layer "'+qo.name+'" is part of a cycle.');if(Ns.indexOf(Ci)!==-1)return;o.containerNodes.add(u.nodeKey(qo,Cs)),qo.id in sr||(sr[qo.id]=Object.keys(sr).length),gi.indexOf(Ci)===-1&&gi.push(Ci);for(var rp=Ci.inboundLayers.length,Ks=0;Ks<rp;Ks++){var np=Ci.inputTensors[Ks],ap=Ci.inboundLayers[Ks],ip=Ci.nodeIndices[Ks],Ch=Ci.tensorIndices[Ks];$t(np,Ns,gi,ap,ip,Ch)}for(Ns.push(Ci);gi.indexOf(Ci)>=0;)gi.splice(gi.indexOf(Ci),1);Yt.push(Ci)},vr=[],hr=[],Ir=0,zr=o.outputs;Ir<zr.length;Ir++){var O=zr[Ir];$t(O,vr,hr)}for(var kr=Yt.slice().reverse(),Sr=0,mn=kr;Sr<mn.length;Sr++){var Xr=mn[Sr];ct[Xr.id]=Xr,Xr.id in pt||(pt[Xr.id]=0);var er=pt[Xr.id],Dn=dt[Xr.outboundLayer.id]==null?0:dt[Xr.outboundLayer.id];er=Math.max(er,Dn),dt[Xr.outboundLayer.id]=er,Ft[Xr.outboundLayer.id]=Xr.outboundLayer,pt[Xr.id]=er;for(var je=0;je<Xr.inboundLayers.length;je++){var Cn=Xr.inboundLayers[je],Z=Xr.nodeIndices[je],bn=Cn.inboundNodes[Z],un=pt[bn.id]==null?0:pt[bn.id];pt[bn.id]=Math.max(er+1,un),ct[bn.id]=bn}}var On={};for(var Hr in pt){var er=pt[Hr];er in On||(On[er]=[]),On[er].push(ct[Hr])}var ha={};for(var Ni in dt){var er=dt[Ni];er in ha||(ha[er]=[]),ha[er].push(Ft[Ni])}var Wi=Object.keys(ha).map(function(Vn){return parseInt(Vn,10)}).sort(rr);o.layers=[];for(var Kn=0,eo=Wi;Kn<eo.length;Kn++){var er=eo[Kn],Ui=ha[er];Ui.sort(function(Ns,gi){var qo=sr[Ns.id],Cs=sr[gi.id];return qo<Cs?-1:qo>Cs?1:0});for(var qs=0,Zu=Ui;qs<Zu.length;qs++){var q=Zu[qs];q instanceof u&&o.internalContainerRefs.push(q),o.layers.push(q)}}o.layersByDepth=ha,Wi=Object.keys(On).map(function(Vn){return parseInt(Vn,10)}).sort(rr);for(var al=o.inputs.slice(),kh=[],rh=0,Qu=Wi;rh<Qu.length;rh++)for(var er=Qu[rh],nh=0,ah=On[er];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 O=oh[ih];if(al.indexOf(O)===-1)throw new ee("Graph disconnected: cannot obtain value for tensor "+O+(' at layer "'+q.name+'". ')+"The following previous layers were accessed without "+("issue: "+kh))}for(var sh=0,Sh=Xr.outputTensors;sh<Sh.length;sh++){var O=Sh[sh];al.push(O)}kh.push(q.name)}}o.nodesByDepth=On;for(var uh=o.layers.map(function(Vn){return Vn.name}),ep=function(Vn){var Ns=uh.filter(function(gi){return gi===Vn}).length;if(Ns!==1)throw new ee('The name "'+Vn+'" is used '+Ns+" times in the model. All layer names should be unique. Layer names: "+JSON.stringify(uh))},ch=0,Ih=uh;ch<Ih.length;ch++){var tp=Ih[ch];ep(tp)}return o.outboundNodes=[],o.inboundNodes=[],new yi({outboundLayer:o,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:o.inputs,outputTensors:o.outputs,inputMasks:o.inputs.map(function(Vn){return null}),outputMasks:o.outputs.map(function(Vn){return null}),inputShapes:o.inputs.map(function(Vn){return Vn.shape}),outputShapes:o.outputs.map(function(Vn){return Vn.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,O=this.internalContainerRefs;T<O.length;T++){var q=O[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=[],O=0,q=this.layers;O<q.length;O++){var b=q[O];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,O=this.layers;T<O.length;T++)for(var q=O[T],Z=0,le=q.weights;Z<le.length;Z++){var Ne=le[Z];if(h[Ne.originalName]!=null)throw new w("Duplicate weight name: "+Ne.originalName);h[Ne.originalName]=Ne,b++}var Be=[];for(var je in r){var qe=je;if(h[je]==null){var vt=je.split("/"),pt=vt.slice(0,-2).concat([vt[vt.length-1]]);qe=pt.join("/")}if(h[qe]!=null)Be.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 ct=[];for(var dt in h)ct.push(dt);if(ct.length>0)throw new w(ct.length+" of "+b+" weights are not set: "+(""+ct))}zi(Be)},u.prototype.updatedConfig=function(){var r=this.getConfig(),o={};return o.className=this.getClassName(),o.config=r,o.kerasVersion="tfjs-layers "+xs,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=Ze(r);for(var b=new ki,T=0;T<h.inputs.length;++T)b.add(h.inputs[T],r[T]);return Yi(h.outputs,b,o)})},u.prototype.computeMask=function(r,o){var h=this;return i.tidy(function(){r=Ze(r);var b;return o==null?b=st(null,r.length):b=Ze(o),h.runInternalGraph(r,b)[1]})},u.prototype.computeOutputShape=function(r){var o=Sn(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],O=o[b],q=T.name+"_0_0";h[q]=O}var Z=Object.keys(this.nodesByDepth).map(function(mn){return parseInt(mn,10)}).sort(rr);if(Z.length>1)for(var le=0,Ne=Z;le<Ne.length;le++)for(var Be=Ne[le],je=this.nodesByDepth[Be],qe=0,vt=je;qe<vt.length;qe++){var pt=vt[qe],T=pt.outboundLayer;if(this.inputLayers.map(function(Xr){return Xr.id}).indexOf(T.id)!==-1)continue;for(var ct=[],dt=0;dt<pt.inboundLayers.length;dt++){var Ft=pt.inboundLayers[dt],sr=pt.nodeIndices[dt],Yt=pt.tensorIndices[dt],q=Ft.name+"_"+sr+"_"+Yt,$t=h[q];ct.push($t)}for(var vr=T.computeOutputShape(It(ct)),hr=Sn(vr),Ir=T.inboundNodes.indexOf(pt),dt=0;dt<hr.length;dt++){var q=T.name+"_"+Ir+"_"+dt;h[q]=hr[dt]}}for(var zr=[],kr=[],b=0;b<this.outputLayers.length;b++){var T=this.outputLayers[b],Ir=this.outputLayersNodeIndices[b],Yt=this.outputLayersTensorIndices[b],q=T.name+"_"+Ir+"_"+Yt;kr.push(q)}for(var b=0;b<kr.length;b++){var Sr=kr[b];ut(Sr in h),zr.push(h[Sr])}return It(zr)},u.prototype.runInternalGraph=function(r,o){o==null&&(o=st(null,r.length));for(var h={},b=0;b<this.inputs.length;++b){var T=this.inputs[b],O=r[b],q=o[b];h[T.id]=[O,q]}for(var Z=Object.keys(this.nodesByDepth).map(function(ha){return parseInt(ha,10)}).sort(rr),le=0,Ne=Z;le<Ne.length;le++)for(var Be=Ne[le],je=this.nodesByDepth[Be],qe=0,vt=je;qe<vt.length;qe++){for(var pt=vt[qe],ct=pt.outboundLayer,dt=pt.inputTensors,Ft=pt.outputTensors,sr=new Array,Yt=0,$t=dt;Yt<$t.length;Yt++){var T=$t[Yt];T.id in h&&sr.push(h[T.id])}if(sr.length===dt.length){var vr={},hr=void 0,Ir=void 0,zr=void 0,kr=void 0;if(pt.callArgs!=null&&(vr=pt.callArgs),sr.length===1){var Sr=sr[0],mn=Sr[0],Xr=Sr[1];vr.mask==null&&(vr.mask=Xr),zr=Ze(ct.call(mn,vr)),kr=Ze(ct.computeMask(mn,Xr)),hr=[mn],Ir=[Xr]}else hr=sr.map(function(ha){return ha[0]}),Ir=sr.map(function(ha){return ha[1]}),vr.mask==null&&(vr.mask=Ir),zr=Ze(ct.call(hr,vr)),kr=Ze(ct.computeMask(hr,Ir));if(ct.activityRegularizer)throw new xe("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(var b=0;b<Ft.length;++b){var T=Ft[b],O=zr[b],q=kr[b];h[T.id]=[O,q]}}}for(var er=[],Dn=[],Cn=[],bn=0,un=this.outputs;bn<un.length;bn++){var T=un[bn];ut(T.id in h,"Could not compute output "+T.name+" : "+T.id);var On=h[T.id],Hr=On[0],q=On[1];Cn.push(Hr.shape),er.push(Hr),Dn.push(q)}return[er,Dn,Cn]},u.prototype.buildNodeConversionMap=function(r){for(var o={},h,b=0,T=this.layers;b<T.length;b++){var O=T[b];h=O instanceof u?1:0;for(var q=0;q<O.inboundNodes.length;q++){var Z=u.nodeKey(O,q);this.containerNodes.has(Z)&&(o[Z]=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],O=0;O<T.inboundNodes.length;++O){var q=u.nodeKey(T,O);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 O=T[b],q=O.getClassName(),Z=O.getConfig(),le=[],Ne=0;Ne<O.inboundNodes.length;Ne++){var Be=O.inboundNodes[Ne],je=u.nodeKey(O,Ne),qe={};if(this.containerNodes.has(je)){if(Be.callArgs)try{JSON.stringify(Be.callArgs),qe=Be.callArgs}catch(Ir){console.warn("Layer "+O.name+" was passed non-serializable keyword arguments: "+(Be.callArgs+". They will not be included ")+"in the serialized model (and thus will be missing at deserialization time)."),qe={}}if(Be.inboundLayers.length>0){for(var vt=[],pt=0;pt<Be.inboundLayers.length;pt++){var ct=Be.inboundLayers[pt],dt=Be.nodeIndices[pt],Ft=Be.tensorIndices[pt],sr=u.nodeKey(ct,dt),Yt=o[sr];Yt==null&&(Yt=0),vt.push([ct.name,Yt,Ft,qe])}le.push(vt)}}}var $t={};$t.name=O.name,$t.className=q,$t.config=Z,$t.inboundNodes=le,h.push($t)}r.layers=h;for(var vr=[],pt=0;pt<this.inputLayers.length;pt++){var O=this.inputLayers[pt],dt=this.inputLayersNodeIndices[pt],je=u.nodeKey(O,dt);if(!this.containerNodes.has(je))continue;var Yt=o[je];Yt==null&&(Yt=0);var Ft=this.inputLayersTensorIndices[pt];vr.push([O.name,Yt,Ft])}r.inputLayers=vr;for(var hr=[],pt=0;pt<this.outputLayers.length;pt++){var O=this.outputLayers[pt],dt=this.outputLayersNodeIndices[pt],je=u.nodeKey(O,dt);if(!this.containerNodes.has(je))continue;var Yt=o[je];Yt==null&&(Yt=0);var Ft=this.outputLayersTensorIndices[pt];hr.push([O.name,Yt,Ft])}return r.outputLayers=hr,r},u.fromConfig=function(r,o,h,b){b===void 0&&(b=!1);var T={},O={};function q(un,On){un.name in O?O[un.name].push(On):O[un.name]=[On]}function Z(un,On){for(var Hr=[],ha,Ni=0,Wi=On;Ni<Wi.length;Ni++){var Kn=Wi[Ni],eo=Kn[0],Ui=Kn[1],qs=Kn[2];if(ha=Kn[3]==null?{}:Kn[3],!(eo in T)){q(un,On);return}var Zu=T[eo];if(Zu.inboundNodes.length<=Ui){q(un,On);return}var al=Zu.inboundNodes[Ui];Hr.push(al.outputTensors[qs])}Hr.length>0&&un.apply(It(Hr),ha)}function le(un){var On=un.name,Hr=ca(un,o.customObjects!=null?o.customObjects:{});Hr.setFastWeightInitDuringBuild(b),T[On]=Hr;var ha=un.inboundNodes;ha.forEach(function(Ni){if(!(Ni instanceof Array))throw new w("Corrupted configuration, expected array for nodeData: "+Ni);q(Hr,Ni)})}for(var Ne=o.name,Be=o.layers,je=0,qe=Be;je<qe.length;je++){var vt=qe[je];le(vt)}for(;!jr(O);)for(var pt=0,ct=Be;pt<ct.length;pt++){var vt=ct[pt],dt=T[vt.name];if(dt.name in O){var Ft=O[dt.name];delete O[dt.name];for(var sr=0,Yt=Ft;sr<Yt.length;sr++){var $t=Yt[sr];Z(dt,$t)}}}for(var vr=[],hr=[],Ir=o.inputLayers,zr=0,kr=Ir;zr<kr.length;zr++){var vt=kr[zr],Sr=vt[0],mn=vt[1],Xr=vt[2];ut(Sr in T);var dt=T[Sr],er=dt.inboundNodes[mn].outputTensors;vr.push(er[Xr])}for(var Dn=o.outputLayers,Cn=0,bn=Dn;Cn<bn.length;Cn++){var vt=bn[Cn],Sr=vt[0],mn=vt[1],Xr=vt[2];ut(Sr in T);var dt=T[Sr],er=dt.inboundNodes[mn].outputTensors;hr.push(er[Xr])}return new r({inputs:vr,outputs:hr,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 H(s,u){return A(s,u,"classWeight")}function se(s,u,r,o){return de(this,void 0,void 0,function(){var h,b,T,O,q;return X(this,function(Z){switch(Z.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.")}),O=(T=Array).from,[4,h.data()]):[3,2];case 1:return b=O.apply(T,[Z.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 te(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=fe("input",s.inputNames,r),T=fe("output",s.outputNames,o),O=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(Be){i.util.assert(b[Be].shape[0]===O,function(){return"Batch size mismatch: input "+(s.inputNames[Be]+" has "+b[Be].shape[0]+"; ")+("expected "+O+" based on input "+s.inputNames[0]+".")})},Z=0;Z<b.length;Z++)q(Z);for(var le=function(Be){i.util.assert(T[Be].shape[0]===O,function(){return"Batch size mismatch: output "+(s.outputNames[Be]+" has "+T[Be].shape[0]+"; ")+("expected "+O+" based on input "+s.inputNames[0]+".")})},Ne=0;Ne<T.length;Ne++)le(Ne);return{xs:b,ys:T}}function fe(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 ve(s){if(s.length===3)throw new xe("Validation with sample weights is not implemented yet.");return{xs:s[0],ys:s[1]}}function ge(s,u,r){return de(this,void 0,void 0,function(){var o,h,b,T,O,q,Z,le,Ne,Be,je,qe,vt,pt,ct,dt,Ft,sr,Yt,$t,vr,hr,Ir,zr,kr,Sr,mn,Xr,er,Dn,Sr,Cn,bn,un,On,Sr;return X(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)}):(O=ve(r.validationData),b=O.xs,T=O.ys)),q=s.makeTrainFunction(),Z=s.getDedupedMetricsNames(),le=void 0,h?le=Z.slice().concat(Z.map(function(ha){return"val_"+ha})):le=Z.slice(),Ne=oo(r.callbacks,r.yieldEvery),Be=r.verbose==null?1:r.verbose,je=Br(Ne,Be,r.epochs,null,null,Ae(u,r),null,h,le),qe=je.callbackList,vt=je.history,qe.setModel(s),s.history=vt,[4,qe.onTrainBegin()];case 2:return Hr.sent(),s.stopTraining_=!1,pt=r.initialEpoch==null?0:r.initialEpoch,[4,u.iterator()];case 3:ct=Hr.sent(),Hr.label=4;case 4:return pt<r.epochs?(dt={},[4,qe.onEpochBegin(pt)]):[3,23];case 5:return Hr.sent(),Ft=0,sr=0,o?[3,7]:[4,u.iterator()];case 6:ct=Hr.sent(),Hr.label=7;case 7:return(o?Ft<r.batchesPerEpoch:!0)?[4,ct.next()]:[3,21];case 8:return Yt=Hr.sent(),o&&Yt.done?(console.warn("You provided `batchesPerEpoch` as "+(r.batchesPerEpoch+", ")+"but your dataset iterator ran out of data after "+(Ft+" 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]):Yt.value!=null?($t=ce(s,Yt.value),vr=$t.xs,hr=$t.ys,Ir={},Ir.batch=sr,Ir.size=vr[0].shape[0],[4,qe.onBatchBegin(sr,Ir)]):[3,15];case 9:if(Hr.sent(),zr=[],!(r.classWeight!=null))return[3,13];kr=H(r.classWeight,s.outputNames),Sr=0,Hr.label=10;case 10:return Sr<kr.length?(Xr=(mn=zr).push,[4,se(hr[Sr],null,kr[Sr])]):[3,13];case 11:Xr.apply(mn,[Hr.sent()]),Hr.label=12;case 12:return++Sr,[3,10];case 13:for(er=vr.concat(hr).concat(zr),Dn=q(er),i.dispose(er),Sr=0;Sr<Z.length;++Sr)Cn=Z[Sr],bn=Dn[Sr],Ir[Cn]=bn,i.keep(bn);return[4,qe.onBatchEnd(sr,Ir)];case 14:Hr.sent(),Li(Ir),sr++,Ft++,Hr.label=15;case 15:return(o?Ft>=r.batchesPerEpoch:Yt.done)?h?(un=void 0,Oe(r.validationData)?(On=Ze,[4,s.evaluateDataset(r.validationData,{batches:r.validationBatches})]):[3,17]):[3,19]:[3,20];case 16:return un=On.apply(void 0,[Hr.sent()]),[3,18];case 17:un=Ze(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]]=un[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 Ae(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 De(s){return typeof s.next=="function"}function Ve(s,u,r){return de(this,void 0,void 0,function(){var o,h,b,T,O,q,Z,le,Ne,Be,je;return X(this,function(qe){switch(qe.label){case 0:if(r=r||{},o=r.batches!=null,h=s.testFunction,b=[],r.verbose>0)throw new xe("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))}),De(u)?(O=u,[3,3]):[3,1];case 1:return[4,u.iterator()];case 2:O=qe.sent(),qe.label=3;case 3:T=O,q=0,Z=0,le=function(){var vt;return X(this,function(pt){switch(pt.label){case 0:return[4,T.next()];case 1:return vt=pt.sent(),b=i.tidy(function(){if(vt.value){var ct=ce(s,vt.value),dt=ct.xs,Ft=ct.ys,sr=dt.concat(Ft),Yt=i.tidy(function(){return h(sr)});if(i.dispose(sr),Z===0)for(var $t=0;$t<Yt.length;++$t)b.push(i.scalar(0));for(var vr=sr[0].shape[0],hr=function(zr){var kr=Yt[zr],Sr=b[zr];b[zr]=i.tidy(function(){return i.add(b[zr],i.mul(vr,kr))}),Z>0&&i.dispose(Sr)},$t=0;$t<Yt.length;++$t)hr($t);i.dispose(Yt),q+=vr,++Z}return b}),vt.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?Z<r.batches:!0)?[5,le()]:[3,6];case 5:return Ne=qe.sent(),Ne==="break"?[3,6]:[3,4];case 6:for(Be=0;Be<b.length;++Be)je=b[Be],b[Be]=i.div(b[Be],q),i.dispose(je);return[2,It(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 at(s,u,r){return s==null?[null]:Array.isArray(s)?s.map(function(o){return Qn(o,u,r-u)}):Qn(s,u,r-u)}function it(s,u){return i.tidy(function(){return s==null?null:Array.isArray(s)?s.map(function(r){return it(r,u)}):Y(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 rt(s,u,r,o,h,b,T,O,q,Z,le,Ne,Be,je,qe){return de(this,void 0,void 0,function(){var vt,pt,ct,dt,Ft,sr,Yt,$t,vr;return X(this,function(hr){switch(hr.label){case 0:if(h==null&&(h=32),b==null&&(b=1),le==null&&(le=!0),Be==null&&(Be=0),vt=!1,q!=null&&Z!=null&&(vt=!0),qe!=null&&(vt=!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&&(ct=ln(0,pt)),T==null&&(T=1),dt=Br(O,T,b,Be,pt,je,h,vt,Ne),Ft=dt.callbackList,sr=dt.history,Ft.setModel(s),s.history=sr,[4,Ft.onTrainBegin()];case 1:hr.sent(),s.stopTraining_=!1,Yt=function(Ir){var zr,kr,Sr,mn,Xr,er;return X(this,function(Dn){switch(Dn.label){case 0:return[4,Ft.onEpochBegin(Ir)];case 1:if(Dn.sent(),zr={},!(je!=null))return[3,2];throw new xe("stepsPerEpoch mode is not implemented yet.");case 2:if(le==="batch")throw new xe("batch shuffling is not implemneted yet");le&&i.util.shuffle(ct),kr=i.tensor1d(ct),Sr=$(pt,h),mn=function(Cn){var bn;return X(this,function(un){switch(un.label){case 0:return bn={},[4,Ft.onBatchBegin(Cn,bn)];case 1:return un.sent(),i.tidy(function(){var On=Sr[Cn][0],Hr=Sr[Cn][1],ha=Qn(kr,On,Hr-On);bn.batch=Cn,bn.size=Hr-On;for(var Ni=it(r,ha),Wi=u(Ni),Kn=0;Kn<o.length;++Kn){var eo=o[Kn],Ui=Wi[Kn];bn[eo]=Ui,i.keep(Ui)}if(Cn===Sr.length-1&&vt)for(var qs=s.testLoop(q,Z,h),Kn=0;Kn<o.length;++Kn){var eo=o[Kn],Ui=qs[Kn];i.keep(Ui),zr["val_"+eo]=Ui}}),[4,Ft.onBatchEnd(Cn,bn)];case 2:return un.sent(),Li(bn),s.stopTraining_?[2,"break"]:[2]}})},Xr=0,Dn.label=3;case 3:return Xr<Sr.length?[5,mn(Xr)]:[3,6];case 4:if(er=Dn.sent(),er==="break")return[3,6];Dn.label=5;case 5:return++Xr,[3,3];case 6:kr.dispose(),Dn.label=7;case 7:return[4,Ft.onEpochEnd(Ir,zr)];case 8:return Dn.sent(),s.stopTraining_?[2,"break"]:[2]}})},$t=Be,hr.label=2;case 2:return $t<b?[5,Yt($t)]:[3,5];case 3:if(vr=hr.sent(),vr==="break")return[3,5];hr.label=4;case 4:return++$t,[3,2];case 5:return[4,Ft.onTrainEnd()];case 6:return hr.sent(),[4,s.history.syncData()];case 7:return hr.sent(),[2,s.history]}})})}function xt(s,u,r,o){return o===void 0&&(o={}),de(this,void 0,void 0,function(){var h,b,T,O,q,Z,le,Ne,Be,je,qe,vt,pt,ct,dt,Ft,sr,Yt,$t,vr,hr,Ir,zr;return X(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),Be=!1,[4,s.standardizeUserData(u,r,o.sampleWeight,o.classWeight,Be,Ne)];case 2:if(je=kr.sent(),h=je[0],b=je[1],le=je[2],qe=!1,vt=void 0,!(o.validationData!=null&&o.validationData.length>0))return[3,4];if(qe=!0,o.validationData.length===2)T=o.validationData[0],O=o.validationData[1];else throw o.validationData.length===3?new xe("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,O,null,null,pt,Ne)];case 3:return ct=kr.sent(),q=ct[0],Z=ct[1],vt=q.concat(Z),[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)),Ft=h[0].shape[0],q=at(h,dt,Ft),h=at(h,0,dt),Z=at(b,dt,Ft),b=at(b,0,dt),vt=q.concat(Z)):o.validationSteps!=null&&(qe=!0),kr.label=5;case 5:return sr=h.concat(b).concat(le),s.checkTrainableWeightsConsistency(),Yt=s.makeTrainFunction(),$t=s.getDedupedMetricsNames(),vr=void 0,hr=void 0,qe?(s.makeTestFunction(),vr=s.testFunction,hr=$t.slice().concat($t.map(function(Sr){return"val_"+Sr}))):(vr=null,vt=[],hr=$t.slice()),Ir=oo(o.callbacks,o.yieldEvery),[4,rt(s,Yt,sr,$t,Ne,o.epochs,o.verbose,Ir,vr,vt,o.shuffle,hr,o.initialEpoch,null,null)];case 6:return zr=kr.sent(),[2,zr];case 7:return s.isTraining=!1,_t(h,u),_t(b,r),_t(q,T),_t(Z,O),le!=null&&i.dispose(le),[7];case 8:return[2]}})})}function ht(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 O=s[T];r.indexOf(O.id)===-1&&b.push(O)}b.forEach(function(q){q.isDisposed||q.dispose()})}function At(s){return s instanceof i.Tensor}function zt(s){return Array.isArray(s)}function Pt(s){return!At(s)&&!zt(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(zt(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 O;if(Pt(s)){s=s,O=[];for(var q=0,Z=u;q<Z.length;q++){var le=Z[q];if(s[le]==null)throw new w('No data provided for "'+le+'". Need data for each key in: '+(""+u));O.push(s[le])}}else if(zt(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));O=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));O=[s]}if(O=ht(O),r!=null)for(var Ne=0;Ne<u.length;++Ne){if(r[Ne]==null)continue;var Be=O[Ne];if(Be.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 "+Be.shape));for(var je=0;je<r[Ne].length;++je){if(je===0&&!o)continue;var qe=Be.shape[je],vt=r[Ne][je];if(vt!=null&&vt>=0&&qe!==vt)throw new w("Error when checking "+h+": expected "+u[Ne]+" "+("to have shape ["+r[Ne]+"], but got array with shape ")+("["+Be.shape+"]."))}}return O}function Tt(s,u,r){var o=jt(s.map(function(b){return b.shape[0]}));o.sort();var h=jt(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 Xt(s,u,r){for(var o=[Zn,Eo,go],h=0;h<s.length;++h){var b=s[h],T=u[h],O=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),Z=O.slice(1),le=0;le<q.length;++le){var Ne=q[le],Be=Z[le];if(Be!=null&&Ne!==Be)throw new w("A target Tensor with shape "+b.shape+" was passed for an "+("output of shape "+O+", 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 O=b[T];if(O.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(O.shape)));for(var q=0;q<r[T].length;++q){if(q===0&&!o)continue;var Z=O.shape[q],le=r[T][q];if(le!=null&&le!==Z)throw new w("Error when checking "+h+": expected "+(u[T]+" to have shape "+JSON.stringify(r[T])+" but ")+("got array with shape "+JSON.stringify(O.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],O=r.hasOwnProperty(T)?r[T]:[];Array.isArray(O)||(O=[O]),o.push(O)}return o}var Rt="layers-model",wt=function(s){M(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).");Ps(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_=Ls(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,O=this.outputNames;T<O.length;T++){var q=O[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(Qo(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 Z=r.loss;h=Z.map(function(ct){return Qo(ct)})}else{var le=Qo(r.loss);this.outputs.forEach(function(ct){h.push(le)})}this.lossFunctions=h,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(var Ne=0;Ne<this.outputs.length;++Ne){var Be=this.internalOutputShapes[Ne],je=this.outputNames[Ne];this.feedOutputNames.push(je),this.feedOutputShapes.push(Be),this.feedLossFns.push(this.lossFunctions[Ne])}var qe=[];this.metrics=r.metrics,this.metricsNames=["loss"],this.metricsTensors=[],na("loss",function(){for(var ct=0;ct<o.outputs.length;++ct){if(qe.indexOf(ct)!==-1)continue;var dt=o.lossFunctions[ct];o.outputs.length>1&&(o.metricsTensors.push([dt,ct]),o.metricsNames.push(o.outputNames[ct]+"_loss"))}});var vt=Ot(r.metrics,this.outputNames),pt=function(ct,dt,Ft){o.outputNames.length>1&&(dt=o.outputNames[ct]+"_"+dt),o.metricsNames.push(dt),o.metricsTensors.push([Ft,ct])};na("metric",function(){for(var ct=function(Ft){if(qe.indexOf(Ft)!==-1)return"continue";var sr=vt[Ft],Yt=function($t){for(var vr="",hr,Ir,zr,kr=function(er){if(typeof er=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(er)!==-1){var Dn=o.internalOutputShapes[Ft];Dn[Dn.length-1]===1||o.lossFunctions[Ft]===Eo?["accuracy","acc"].indexOf(er)!==-1?Ir=Ao:["crossentropy","ce"].indexOf(er)!==-1&&(Ir=Ds):o.lossFunctions[Ft]===To?["accuracy","acc"].indexOf(er)!==-1?Ir=fs:["crossentropy","ce"].indexOf(er)!==-1&&(Ir=$o):["accuracy","acc"].indexOf(er)!==-1?Ir=Jo:["crossentropy","ce"].indexOf(er)!==-1&&(Ir=Fo);var Cn=void 0;["accuracy","acc"].indexOf(er)!==-1?Cn="acc":["crossentropy","ce"].indexOf(er)!==-1&&(Cn="ce"),zr=Ir,hr=vr+Cn}else{var bn=vs(er);zr=bn,hr=vr+Do(er)}var un;na(hr,function(){un=zr}),pt(Ft,hr,un)},Sr=0,mn=$t;Sr<mn.length;Sr++){var Xr=mn[Sr];kr(Xr)}};Yt(sr)},dt=0;dt<o.outputs.length;++dt)ct(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,O=this.standardizeUserDataXY(r,o,T,b);try{var q=O[0].concat(O[1]);this.makeTestFunction();var Z=this.testFunction,le=this.testLoop(Z,q,b,h.verbose,h.steps);return It(le)}finally{_t(O[0],r),_t(O[1],o)}},u.prototype.evaluateDataset=function(r,o){return de(this,void 0,void 0,function(){return X(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),O=new ki;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)O.add(this.inputs[q],r[q])}else for(var Z=0,le=this.inputs;Z<le.length;Z++){var Ne=le[Z],Be=r[Ne.name];if(Be==null)throw new w("No value is provided for the model's input "+Ne.name);O.add(Ne,Be)}var je=Yi(T,O);return h?je:je[0]},u.prototype.retrieveSymbolicTensors=function(r){for(var o=st(null,r.length),h=r.length,b=0,T=this.layers;b<T.length;b++){for(var O=T[b],q=Array.isArray(O.output)?O.output:[O.output],Z=q.map(function(je){return je.name}),le=0;le<r.length;++le){var Ne=Z.indexOf(r[le]);if(Ne!==-1&&(o[le]=q[Ne],h--),h===0)break}if(h===0)break}if(h>0){var Be=[];throw o.forEach(function(je,qe){je==null&&Be.push(r[qe])}),new w("Cannot find SymbolicTensors for output name(s): "+(""+JSON.stringify(Be)))}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 xe("Verbose predictLoop() is not implemented yet.");for(var O=$(T,o),q=b.outputs.map(function(Ne){return[]}),Z=function(Ne){var Be=i.tidy(function(){var je=O[Ne][0],qe=O[Ne][1],vt=at(r,je,qe),pt=[];if(Array.isArray(vt))for(var ct=0;ct<vt.length;++ct)pt.push({key:b.inputs[ct],value:vt[ct]});else pt.push({key:b.inputs[0],value:vt});var dt=new ki(pt);return Yi(b.outputs,dt)});Be.forEach(function(je,qe){return q[qe].push(je)})},le=0;le<O.length;++le)Z(le);return It(q.map(function(Ne){return i.concat(Ne,0)}))})},u.prototype.predict=function(r,o){o===void 0&&(o={});var h=ht(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 ee("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");for(var T=[],O=0;O<this.feedOutputShapes.length;++O){var q=this.feedOutputShapes[O],Z=this.feedLossFns[O];Z===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"),Tt(r,o),Xt(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,O){return T===void 0&&(T=!0),de(this,void 0,void 0,function(){var q,Z,le,Ne,Be,je,qe,vt;return X(this,function(pt){switch(pt.label){case 0:if(q=this.standardizeUserDataXY(r,o,T,O),Z=q[0],le=q[1],h!=null)throw new Error("sample weight is not supported yet.");if(Ne=null,!(b!=null))return[3,4];Be=H(b,this.outputNames),Ne=[],je=0,pt.label=1;case 1:return je<Be.length?(vt=(qe=Ne).push,[4,se(le[je],null,Be[je])]):[3,4];case 2:vt.apply(qe,[pt.sent()]),pt.label=3;case 3:return++je,[3,1];case 4:return[2,[Z,le,Ne]]}})})},u.prototype.testLoop=function(r,o,h,b,T){var O=this;return b===void 0&&(b=0),i.tidy(function(){var q=O.checkNumSamples(o,h,T,"steps"),Z=[];if(b>0)throw new xe("Verbose mode is not implemented yet.");if(T!=null)throw new xe("steps mode in testLoop() is not implemented yet");for(var le=$(q,h),Ne=i.tensor1d(ln(0,q)),Be=0;Be<le.length;++Be){var je=le[Be][0],qe=le[Be][1],vt=Qn(Ne,je,qe-je),pt=it(o,vt),ct=r(pt);if(Be===0)for(var dt=0;dt<ct.length;++dt)Z.push(i.scalar(0));for(var dt=0;dt<ct.length;++dt){var Ft=ct[dt];Z[dt]=i.add(Z[dt],i.mul(qe-je,Ft))}}for(var dt=0;dt<Z.length;++dt)Z[dt]=i.div(Z[dt],q);return Z})},u.prototype.getDedupedMetricsNames=function(){for(var r=this.metricsNames,o=[],h=0;h<r.length;++h){var b=r[h],T=b;if(Kt(r,b)>1){var O=Kt(r.slice(0,h),b);T+="_"+O}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),O=o.slice(r.inputs.length+r.outputs.length,r.inputs.length+r.outputs.length*2),q=[],Z=function(){for(var je=[],qe=0;qe<r.inputs.length;++qe)je.push({key:r.inputs[qe],value:b[qe]});for(var vt=new ki(je),pt=Yi(r.outputs,vt,{training:!0}),ct,qe=0;qe<r.lossFunctions.length;++qe){var dt=r.lossFunctions[qe],Ft=dt(T[qe],pt[qe]);O[qe]!=null&&(Ft=te(Ft,O[qe]));var sr=i.mean(Ft);h.push(sr),qe===0?ct=Ft:ct=i.add(ct,Ft)}for(var qe=0;qe<r.metricsTensors.length;++qe){var Yt=void 0;if(r.outputs.length>1&&qe<r.outputs.length)Yt=h[qe];else{var $t=r.metricsTensors[qe][0],vr=r.metricsTensors[qe][1];Yt=i.mean($t(T[vr],pt[vr]))}i.keep(Yt),q.push(Yt)}return ct=i.mean(ct),r.calculateLosses().forEach(function(hr){ct=i.add(ct,hr)}),ct},le=r.collectedTrainableWeights.map(function(je){return je.read()}),Ne=!0,Be=r.optimizer_.minimize(Z,Ne,le);return[Be].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),O=o.slice(r.inputs.length,r.inputs.length+r.outputs.length),q=[],Z=0;Z<r.inputs.length;++Z)q.push({key:r.inputs[Z],value:T[Z]});for(var le=new ki(q),Ne=Yi(r.outputs,le),Z=0;Z<r.lossFunctions.length;++Z){var Be=r.lossFunctions[Z],je=i.mean(Be(O[Z],Ne[Z]));Z===0?b=je:b=i.add(b,je),h.push(b)}for(var Z=0;Z<r.metricsTensors.length;++Z){var qe=r.metricsTensors[Z][0],vt=r.metricsTensors[Z][1],pt=i.mean(qe(O[vt],Ne[vt]));h.push(pt)}return h})}},u.prototype.fit=function(r,o,h){return h===void 0&&(h={}),de(this,void 0,void 0,function(){return X(this,function(b){return[2,xt(this,r,o,h)]})})},u.prototype.fitDataset=function(r,o){return de(this,void 0,void 0,function(){return X(this,function(h){return[2,ge(this,r,o)]})})},u.prototype.trainOnBatch=function(r,o){return de(this,void 0,void 0,function(){var h,b,T,O,q,Z,le,Ne,Be,je;return X(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],O=this.makeTrainFunction(),q=O(b.concat(T)),Z=[],le=0,Ne=q,qe.label=2;case 2:return le<Ne.length?(Be=Ne[le],[4,Be.data()]):[3,5];case 3:je=qe.sent(),Z.push(je[0]),qe.label=4;case 4:return le++,[3,2];case 5:return i.dispose(q),[2,It(Z)]}})})},u.prototype.getNamedWeights=function(r){for(var o=[],h=r!=null&&r.trainableOnly,b=h?this.trainableWeights:this.weights,T=this.getWeights(h),O=0;O<b.length;++O){if(h&&!b[O].trainable)continue;o.push({name:b[O].originalName,tensor:T[O]})}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=mt(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 mt(Ne)})}else{var T=Object.keys(this.loss);r={};for(var O=this.loss,q=0,Z=T;q<Z.length;q++){var le=Z[q];if(typeof O[le]=="string")r[le]=mt(O[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[mt(Do(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(function(h){return mt(Do(h))});var r={};for(var o in this.metrics)r[o]=mt(Do(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=ca(o),b;if(typeof r.loss=="string")b=yt(r.loss);else if(Array.isArray(r.loss))b=r.loss.map(function(q){return yt(q)});else if(r.loss!=null){b={};for(var T in r.loss)b[T]=yt(r.loss[T])}var O;if(Array.isArray(r.metrics))O=r.metrics.map(function(q){return yt(q)});else if(r.metrics!=null){O={};for(var T in r.metrics)O[T]=yt(r.metrics[T])}this.compile({loss:b,metrics:O,optimizer:h})},u.prototype.save=function(r,o){return de(this,void 0,void 0,function(){var h,b,T,O,q,Z,le,Ne,Be,je,qe,vt,pt,ct,dt;return X(this,function(Ft){switch(Ft.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=Ft.sent(),T=!1,O=null,q=this.toJSON(O,T),Z={modelTopology:q,format:Rt,generatedBy:"TensorFlow.js tfjs-layers v"+xs,convertedBy:null},le=o==null?!1:o.includeOptimizer,le&&this.optimizer!=null?(Z.trainingConfig=this.getTrainingConfig(),Ne="optimizer",pt=(vt=i.io).encodeWeights,[4,this.optimizer.getWeights()]):[3,4];case 2:return[4,pt.apply(vt,[Ft.sent(),Ne])];case 3:Be=Ft.sent(),je=Be.data,qe=Be.specs,(dt=b.specs).push.apply(dt,qe),b.data=i.io.concatenateArrayBuffers([b.data,je]),Ft.label=4;case 4:return this.userDefinedMetadata!=null&&(ct=!0,_o(this.userDefinedMetadata,this.name,ct),Z.userDefinedMetadata=this.userDefinedMetadata),Z.weightData=b.data,Z.weightSpecs=b.specs,[2,r.save(Z)]}})})},u.prototype.setUserDefinedMetadata=function(r){_o(r,this.name),this.userDefinedMetadata=r},u.prototype.getUserDefinedMetadata=function(){return this.userDefinedMetadata},u.className="Model",u}(D);i.serialization.registerClass(wt);var Et=function(s){M(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 de(this,void 0,void 0,function(){var r,o,h,b,T,O,q,Z;return X(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=ca(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={},O=0,q=h.weights;O<q.length;O++)Z=q[O],T[Z.originalName]=b[Z.originalName];h.loadWeights(T),i.dispose(b),le.label=2;case 2:return[2,h]}})})}function qt(s,u){return de(this,void 0,void 0,function(){var r;return X(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,lr(s,void 0,u)]})})}function lr(s,u,r){return de(this,void 0,void 0,function(){var o,h,b,T,O,q,Z,le,Ne;return X(this,function(Be){switch(Be.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=Be.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,O=ca(Oo(h),u,T),q=o.trainingConfig,q!=null&&O.loadTrainingConfig(q),o.userDefinedMetadata!=null&&O.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 Z=ir(o.weightData,o.weightSpecs),le=Z.modelWeights,Ne=Z.optimizerWeights,O.loadWeights(le,b),O.optimizer!=null&&Ne.length>0?[4,O.optimizer.setWeights(Ne)]:[3,3];case 2:Be.sent(),Be.label=3;case 3:i.dispose(le),i.dispose(Ne.map(function(je){return je.tensor})),Be.label=4;case 4:return[2,O]}})})}function ir(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){M(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:Dr("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=Xi({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=Ya(this.outputs[0])}this.inboundNodes=[],new yi({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:st(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(function(O){return O.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 ee("The model needs to be compiled before being used.");return this.model.evaluate(r,o,h)},u.prototype.evaluateDataset=function(r,o){return de(this,void 0,void 0,function(){return X(this,function(h){if(!this.built)throw new ee("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={}),de(this,void 0,void 0,function(){return X(this,function(b){if(!this.built)throw new ee("The model needs to be compiled before being used.");return[2,this.model.fit(r,o,h)]})})},u.prototype.fitDataset=function(r,o){return de(this,void 0,void 0,function(){return X(this,function(h){if(!this.built)throw new ee("The model needs to be compiled before being used.");return[2,this.model.fitDataset(r,o)]})})},u.prototype.trainOnBatch=function(r,o){return de(this,void 0,void 0,function(){return X(this,function(h){return[2,this.model.trainOnBatch(r,o)]})})},u.fromConfig=function(r,o,h,b){b===void 0&&(b=!1);var T,O={};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,O=o;var q=new r(O);if(!(q instanceof u))throw new xe("Sequential.fromConfig called on non-Sequential input: "+q);for(var Z=0,le=T;Z<le.length;Z++){var Ne=le[Z],Be=void 0,je=ca(Ne,Be,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={}),qt(s,u)}function pr(s){return Xi(s)}function Fr(s,u){ua.registerCallbackConstructor(s,u)}var mr=function(s){M(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){M(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}(mr);i.serialization.registerClass(Er);var an=function(s){M(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}(mr);i.serialization.registerClass(an);var _n=function(s){M(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}(mr);i.serialization.registerClass(_n);var ie=function(s){M(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}(mr);i.serialization.registerClass(ie);var In=function(s){M(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return r},u.className="linear",u}(mr);i.serialization.registerClass(In);var wn=function(s){M(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}(mr);i.serialization.registerClass(wn);var Re=function(s){M(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r){return ze(r)},u.className="hardSigmoid",u}(mr);i.serialization.registerClass(Re);var Un=function(s){M(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}(mr);i.serialization.registerClass(Un);var Ln=function(s){M(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}(mr);i.serialization.registerClass(Ln);var Oa=function(s){M(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}(mr);i.serialization.registerClass(Oa);var An=function(s){M(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}(mr);i.serialization.registerClass(An);var Ja=function(s){M(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}(mr);i.serialization.registerClass(Ja);var Wa=function(s){M(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}(mr);i.serialization.registerClass(Wa);function $a(s){return s.getClassName()}function xa(s,u){return u===void 0&&(u={}),et(s,i.serialization.SerializationMap.getMap().classNameMap,u,"activation")}function _a(s){if(s==null){var u={};return u.className="linear",u.config={},xa(u)}if(typeof s=="string"){var u={};return u.className=s,u.config={},xa(u)}else return s instanceof mr?s:xa(s)}function Zi(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 Bi=function(s){M(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u}(i.serialization.Serializable),Mr=function(s){M(u,s);function u(r){var o=s.call(this)||this;return Zi(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}(Bi);i.serialization.registerClass(Mr);function ei(s){return Zi(s),new Mr({l1:s!=null?s.l1:null,l2:0})}function as(s){return Zi(s),new Mr({l2:s!=null?s.l2:null,l1:0})}var Po={l1l2:"L1L2"};function dn(s){return ot(s)}function Bo(s,u){return u===void 0&&(u={}),et(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 Bi?s:Bo(s)}var ou=function(s){M(u,s);function u(r){var o=s.call(this,r==null?{}:r)||this;return o.supportsMasking=!0,r!=null&&(o.maxValue=r.maxValue),o}return u.prototype.call=function(r,o){r=cr(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(ou);var cc=function(s){M(u,s);function u(r){var o=s.call(this,r==null?{}: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=cr(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 ui=function(s){M(u,s);function u(r){var o=s.call(this,r==null?{}: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=fn(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 O={};if(this.sharedAxes!=null)for(var T=1;T<r.length;++T)O[T]=r[T];this.inputSpec=[new Rn({ndim:r.length,axes:O})],this.built=!0},u.prototype.call=function(r,o){return r=cr(r),i.prelu(r,this.alpha.read())},u.prototype.getConfig=function(){var r={alphaInitializer:S(this.alphaInitializer),alphaRegularizer:dn(this.alphaRegularizer),alphaConstraint:cn(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(ui);var ku=function(s){M(u,s);function u(r){var o=s.call(this,r==null?{}:r)||this;if(o.DEFAULT_ALPHA=1,r==null&&(r={}),r.alpha!=null&&r.alpha!==o.DEFAULT_ALPHA)throw new xe("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=cr(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(ku);var Su=function(s){M(u,s);function u(r){var o=s.call(this,r==null?{}: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=cr(r);return h.mul(ai(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(Su);var lc=function(s){M(u,s);function u(r){var o=s.call(this,r==null?{}:r)||this;return o.DEFAULT_AXIS=1,r==null&&(r={}),o.softmax=new An().apply,o.axis=r.axis==null?o.DEFAULT_AXIS:r.axis,o}return u.prototype.call=function(r,o){var h=cr(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 _s(s,u,r){if(typeof s=="number")return st(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 Si(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 ws(s,u,r,o){if(s==null)return null;if(o==="valid")s=s*u+ja([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 uo(s,u){return i.tidy(function(){return on(u),u==="channelsFirst"?i.transpose(s,[0,2,3,4,1]):s})}function Iu(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 xe("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");var O=i.conv1d(s,u,o,h==="same"?"same":"valid","NWC",T);return r!=null&&(O=re(O,r)),O})}function su(s,u,r,o,h,b,T,O){return o===void 0&&(o=[1,1]),h===void 0&&(h="valid"),O===void 0&&(O=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 xe("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:O}),b==="channelsFirst"&&(q=i.transpose(q,[0,3,1,2])),q})}function bs(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 O=uo(s,b);if(h==="causal")throw new xe("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return O=i.conv3d(O,u,o,h==="same"?"same":"valid","NDHWC",T),r!=null&&(O=re(O,r)),b==="channelsFirst"&&(O=i.transpose(O,[0,4,1,2,3])),O})}var Nu=function(s){M(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,ar(h.rank,"rank"),h.rank!==1&&h.rank!==2&&h.rank!==3)throw new xe("Convolution layer for rank other than 1, 2, or 3 ("+h.rank+") is not implemented yet.");if(h.kernelSize=_s(o.kernelSize,r,"kernelSize"),h.strides=_s(o.strides==null?1:o.strides,r,"strides"),h.padding=o.padding==null?"valid":o.padding,xn(h.padding),h.dataFormat=o.dataFormat==null?"channelsLast":o.dataFormat,on(h.dataFormat),h.activation=_a(o.activation),h.useBias=o.useBias==null?!0:o.useBias,h.biasInitializer=x(o.biasInitializer||h.DEFAULT_BIAS_INITIALIZER),h.biasConstraint=fn(o.biasConstraint),h.biasRegularizer=Fn(o.biasRegularizer),h.activityRegularizer=Fn(o.activityRegularizer),h.dilationRate=_s(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(ut("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:$a(this.activation),useBias:this.useBias,biasInitializer:S(this.biasInitializer),biasRegularizer:dn(this.biasRegularizer),activityRegularizer:dn(this.activityRegularizer),biasConstraint:cn(this.biasConstraint)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),uu=function(s){M(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,ar(h.filters,"filters"),h.kernelInitializer=x(o.kernelInitializer||h.DEFAULT_KERNEL_INITIALIZER),h.kernelConstraint=fn(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=cr(r);var b,T=h.bias==null?null:h.bias.read(),O=Tn(h.activation.getClassName());if(O!=null&&h.rank===2)b=su(r,h.kernel.read(),T,h.strides,h.padding,h.dataFormat,h.dilationRate,O);else{if(h.rank===1)b=Iu(r,h.kernel.read(),T,h.strides[0],h.padding,h.dataFormat,h.dilationRate[0]);else if(h.rank===2)b=su(r,h.kernel.read(),T,h.strides,h.padding,h.dataFormat,h.dilationRate);else if(h.rank===3)b=bs(r,h.kernel.read(),T,h.strides,h.padding,h.dataFormat,h.dilationRate);else throw new xe("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=Si(h[b],this.kernelSize[b],this.padding,this.strides[b],typeof this.dilationRate=="number"?this.dilationRate:this.dilationRate[b]);o.push(T)}var O=[r[0]];return this.dataFormat==="channelsLast"?(O=O.concat(o),O.push(this.filters)):(O.push(this.filters),O=O.concat(o)),O},u.prototype.getConfig=function(){var r={filters:this.filters,kernelInitializer:S(this.kernelInitializer),kernelRegularizer:dn(this.kernelRegularizer),kernelConstraint:cn(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}(Nu),Cu=function(s){M(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}(uu);i.serialization.registerClass(Cu);var hc=function(s){M(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}(uu);i.serialization.registerClass(hc);var co=function(s){M(u,s);function u(r){var o=s.call(this,r)||this;if(o.inputSpec=[new Rn({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 Rn({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=cr(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,O=T[0],q,Z;h.dataFormat==="channelsFirst"?(q=2,Z=3):(q=1,Z=2);var le=T[q],Ne=T[Z],Be=h.kernelSize[0],je=h.kernelSize[1],qe=h.strides[0],vt=h.strides[1],pt=ws(le,qe,Be,h.padding),ct=ws(Ne,vt,je,h.padding),dt=[O,pt,ct,h.filters];h.dataFormat!=="channelsLast"&&(b=i.transpose(b,[0,2,3,1]));var Ft=i.conv2dTranspose(b,h.kernel.read(),dt,h.strides,h.padding);return h.dataFormat!=="channelsLast"&&(Ft=i.transpose(Ft,[0,3,1,2])),h.bias!=null&&(Ft=re(Ft,h.bias.read(),h.dataFormat)),h.activation!=null&&(Ft=h.activation.apply(Ft)),Ft})},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 O=this.kernelSize[0],q=this.kernelSize[1],Z=this.strides[0],le=this.strides[1];return o[h]=this.filters,o[b]=ws(o[b],Z,O,this.padding),o[T]=ws(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}(Cu);i.serialization.registerClass(co);var ks=function(s){M(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=fn(o.depthwiseConstraint),h.pointwiseInitializer=x(o.depthwiseInitializer||h.DEFAULT_POINTWISE_INITIALIZER),h.pointwiseRegularizer=Fn(o.pointwiseRegularizer),h.pointwiseConstraint=fn(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]),O=[],q=0;q<this.rank;++q)O.push(1);O.push(b*this.depthMultiplier,this.filters);var Z=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",T,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,Z,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",O,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,Z,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,Z,this.biasConstraint):this.bias=null,this.inputSpec=[new Rn({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=cr(r);var b;if(h.rank===1)throw new xe("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=re(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=cn(this.depthwiseConstraint),r.pointwiseConstraint=cn(this.pointwiseConstraint),r},u.className="SeparableConv",u}(uu),Tu=function(s){M(u,s);function u(r){return s.call(this,2,r)||this}return u.className="SeparableConv2D",u}(ks);i.serialization.registerClass(Tu);var pc=function(s){M(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}(uu);i.serialization.registerClass(pc);var dc=function(s){M(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=cr(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){M(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=cr(r),T=b.shape;if(h.dataFormat==="channelsFirst"){b=i.transpose(b,[0,2,3,1]);var O=h.size[0]*T[2],q=h.size[1]*T[3],Z=b.resizeNearestNeighbor([O,q]);return i.transpose(Z,[0,3,1,2])}else{var O=h.size[0]*T[1],q=h.size[1]*T[2];return b.resizeNearestNeighbor([O,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 Eu=function(s){M(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=fn(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=cr(r);var b=vl(r,h.depthwiseKernel.read(),h.strides,h.padding,h.dataFormat,null);return h.useBias&&(b=re(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=Si(o,this.kernelSize[0],this.padding,this.strides[0]),O=Si(h,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[r[0],b,T,O]:[r[0],T,O,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=cn(this.depthwiseRegularizer),r},u.className="DepthwiseConv2D",u}(Nu);i.serialization.registerClass(Eu);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,O){return o===void 0&&(o=!1),T===void 0&&(T=!1),O===void 0&&(O=!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 Z=[1,0].concat(ln(2,q));if(u=i.transpose(u,Z),b!=null)throw new xe("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,Z)),o&&(u=i.reverse(u,0),h!=null&&(h=i.reverse(h,0)));var le=[],Ne,Be=r,je=u.shape[0],qe=i.unstack(u),vt;h!=null&&(vt=i.unstack(h));for(var pt=function(sr){var Yt=qe[sr],$t=i.tidy(function(){return s(Yt,Be)});if(h==null)Ne=$t[0],Be=$t[1];else{var vr=i.tidy(function(){var hr=vt[sr],Ir=i.onesLike(hr).sub(hr),zr=$t[0].mul(hr).add(Be[0].mul(Ir)),kr=Be.map(function(Sr,mn){return $t[1][mn].mul(hr).add(Sr.mul(Ir))});return{output:zr,newStates:kr}});Ne=vr.output,Be=vr.newStates}O&&le.push(Ne)},ct=0;ct<je;++ct)pt(ct);var dt;if(O){var Ft=1;dt=i.stack(le,Ft)}return[Ne,dt,Be]})}var Ii=function(s){M(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 os({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 Rn({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){Na(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=[],O=0,q=o;O<q.length;O++){var Z=q[O];T.push([r[0],Z])}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(O){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 xe("Constants support is not implemented in RNN yet.");Na(r)&&(r=r[0]),r=r;var o=this.stateful?r[0]:null,h=r.slice(2);this.inputSpec[0]=new Rn({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(O){return O.shape[O.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(O){return new Rn({shape:[null,O]})});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 ye("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 O=r[T],q=Array.isArray(h.cell.stateSize)?h.cell.stateSize[T]:h.cell.stateSize,Z=[b,q];if(!i.util.arraysEqual(O.shape,Z))throw new w("State "+T+" is incompatible with layer "+h.name+": "+("expected shape="+Z+", received shape="+O.shape));h.states_[T]=O}}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 O=[],q=[];if(h!=null){o.initialState=h,O=O.concat(h),this.stateSpec=[];for(var Z=0,le=h;Z<le.length;Z++){var Ne=le[Z];this.stateSpec.push(new Rn({shape:Ne.shape}))}q=q.concat(this.stateSpec)}b!=null&&(o.constants=b,O=O.concat(b),this.numConstants=b.length);var Be=O[0]instanceof Ca;if(Be){var je=[r].concat(O),qe=this.inputSpec.concat(q),vt=this.inputSpec;this.inputSpec=qe;var pt=s.prototype.apply.call(this,je,o);return this.inputSpec=vt,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,O=o==null?null:o.initialState;r=cr(r),O==null&&(h.stateful?O=h.states_:O=h.getInitialState(r));var q=Array.isArray(h.cell.stateSize)?h.cell.stateSize.length:1;if(O.length!==q)throw new w("RNN Layer has "+q+" state(s) but was passed "+(O.length+" initial state(s)."));h.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");var Z={training:T},le=function(pt,ct){var dt=h.cell.call([pt].concat(ct),Z);return[dt[0],dt.slice(1)]},Ne=yc(le,r,O,h.goBackwards,b,null,h.unroll,h.returnSequences),Be=Ne[0],je=Ne[1],qe=Ne[2];h.stateful&&h.resetStates(qe,T);var vt=h.returnSequences?je:Be;return h.returnState?[vt].concat(qe):vt})},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?ya(h,[1,b]):h}):o.cell.stateSize>1?[ya(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}),V({},h,r,o)},u.fromConfig=function(r,o,h){h===void 0&&(h={});var b=o.cell,T=ca(b,h);return new r(Object.assign(o,{cell:T}))},u.className="RNN",u}(qr);i.serialization.registerClass(Ii);var is=function(s){M(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u}(qr),Ss=function(s){M(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,ar(o.units,"units"),o.activation=_a(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=fn(r.kernelConstraint),o.recurrentConstraint=fn(r.recurrentConstraint),o.biasConstraint=fn(r.biasConstraint),o.dropout=fi([1,ja([0,r.dropout==null?0:r.dropout])]),o.recurrentDropout=fi([1,ja([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 O,q=h.dropoutMask,Z=h.recurrentDropoutMask;q!=null?O=pe(i.mul(r,q),h.kernel.read()):O=pe(r,h.kernel.read()),h.bias!=null&&(O=re(O,h.bias.read())),Z!=null&&(b=i.mul(b,Z));var le=i.add(O,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:$a(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:cn(this.kernelConstraint),recurrentConstraint:cn(this.recurrentConstraint),biasConstraint:cn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return V({},r,o)},u.className="SimpleRNNCell",u}(is);i.serialization.registerClass(Ss);var vc=function(s){M(u,s);function u(r){var o=this;return r.cell=new Ss(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,O=o==null?null:o.initialState;return s.prototype.call.call(h,r,{mask:b,training:T,initialState:O})})},u.fromConfig=function(r,o){return new r(o)},u.className="SimpleRNN",u}(Ii);i.serialization.registerClass(vc);var Wo=function(s){M(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,ar(o.units,"units"),o.activation=_a(r.activation===void 0?o.DEFAULT_ACTIVATION:r.activation),o.recurrentActivation=_a(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=fn(r.kernelConstraint),o.recurrentConstraint=fn(r.recurrentConstraint),o.biasConstraint=fn(r.biasConstraint),o.dropout=fi([1,ja([0,r.dropout==null?0:r.dropout])]),o.recurrentDropout=fi([1,ja([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 O=h.dropoutMask,q=h.recurrentDropoutMask,Z,le,Ne;0<h.dropout&&h.dropout<1&&(r=i.mul(r,O[0]));var Be=pe(r,h.kernel.read());h.useBias&&(Be=re(Be,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),vt=qe[0],pt=qe[1],ct=pe(T,vt),dt=i.split(Be,3,Be.rank-1),Ft=dt[0],sr=dt[1],Yt=dt[2],$t=i.split(ct,2,ct.rank-1),vr=$t[0],hr=$t[1];Z=h.recurrentActivation.apply(i.add(Ft,vr)),le=h.recurrentActivation.apply(i.add(sr,hr));var Ir=pe(i.mul(le,T),pt);Ne=h.activation.apply(i.add(Yt,Ir));var zr=i.add(i.mul(Z,T),i.mul(i.add(1,i.neg(Z)),Ne));return[zr,zr]})},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={units:this.units,activation:$a(this.activation),recurrentActivation:$a(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:cn(this.kernelConstraint),recurrentConstraint:cn(this.recurrentConstraint),biasConstraint:cn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return V({},r,o)},u.className="GRUCell",u}(is);i.serialization.registerClass(Wo);var lo=function(s){M(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,O=o==null?null:o.initialState;return s.prototype.call.call(h,r,{mask:b,training:T,initialState:O})})},u.fromConfig=function(r,o){return o.implmentation===0&&(o.implementation=1),new r(o)},u.className="GRU",u}(Ii);i.serialization.registerClass(lo);var Uo=function(s){M(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,ar(o.units,"units"),o.activation=_a(r.activation===void 0?o.DEFAULT_ACTIVATION:r.activation),o.recurrentActivation=_a(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=fn(r.kernelConstraint),o.recurrentConstraint=fn(r.recurrentConstraint),o.biasConstraint=fn(r.biasConstraint),o.dropout=fi([1,ja([0,r.dropout==null?0:r.dropout])]),o.recurrentDropout=fi([1,ja([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,O=this.units;b=new(o=function(q){M(Z,q);function Z(){return q!==null&&q.apply(this,arguments)||this}return Z.prototype.apply=function(le,Ne){var Be=T.apply([O]),je=new va().apply([O]),qe=T.apply([O*2]);return Di(Di(Be,je),qe)},Z}(or),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],O=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,Z=h.recurrentDropoutMask,le,Ne,Be,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,Z[0])),qe=i.add(qe,pe(T,h.recurrentKernel.read())),h.useBias&&(qe=re(qe,h.bias.read()));var vt=i.split(qe,4,qe.rank-1),pt=vt[0],ct=vt[1],dt=vt[2],Ft=vt[3];le=h.recurrentActivation.apply(pt),Ne=h.recurrentActivation.apply(ct),Be=i.add(i.mul(Ne,O),i.mul(le,h.activation.apply(dt))),je=h.recurrentActivation.apply(Ft);var sr=i.mul(je,h.activation.apply(Be));return[sr,sr,Be]})},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={units:this.units,activation:$a(this.activation),recurrentActivation:$a(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:cn(this.kernelConstraint),recurrentConstraint:cn(this.recurrentConstraint),biasConstraint:cn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return V({},r,o)},u.className="LSTMCell",u}(is);i.serialization.registerClass(Uo);var cu=function(s){M(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,O=o==null?null:o.initialState;return s.prototype.call.call(h,r,{mask:b,training:T,initialState:O})})},u.fromConfig=function(r,o){return o.implmentation===0&&(o.implementation=1),new r(o)},u.className="LSTM",u}(Ii);i.serialization.registerClass(cu);var os=function(s){M(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=[],O=0,q=h.cells.slice().reverse();O<q.length;O++){var Z=q[O];Array.isArray(Z.stateSize)?T.push(b.splice(0,Z.stateSize.length)):T.push(b.splice(0,1))}T.reverse();for(var le=[],Ne,Be=0;Be<h.cells.length;++Be){var Z=h.cells[Be];b=T[Be],Be===0?Ne=[r[0]].concat(b):Ne=[Ne[0]].concat(b),Ne=Z.call(Ne,o),le.push(Ne.slice(1))}b=[];for(var je=0,qe=le.slice().reverse();je<qe.length;je++){var vt=qe[je];b.push.apply(b,vt)}return[Ne[0]].concat(b)})},u.prototype.build=function(r){Na(r)&&(r=r[0]),r=r;var o;this.cells.forEach(function(h,b){na("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 V({},r,b)},u.fromConfig=function(r,o,h){h===void 0&&(h={});for(var b=[],T=0,O=o.cells;T<O.length;T++){var q=O[T];b.push(ca(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=[],O=0,q=this.cells;O<q.length;O++){var b=q[O];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 ii(r)},u.prototype.setWeights=function(r){for(var o=[],h=0,b=this.cells;h<b.length;h++)for(var T=b[h],O=T.weights.length,q=r.splice(O),Z=0;Z<T.weights.length;++Z)o.push([T.weights[Z],q[Z]]);zi(o)},u.className="StackedRNNCells",u}(is);i.serialization.registerClass(os);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,O=function(){return tt(u(),r)},q=function(){return Ye(O,u,h)};if(!T||T<=1)return i.keep(q().clone());var Z=Array(T).fill(void 0).map(q);return Z.map(function(le){return i.keep(le.clone())})}var gl=function(s){M(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u}(is),xl=function(s){M(u,s);function u(r){var o=this;if(r.unroll)throw new xe("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(r.cell))throw new xe("It is not possible at the moment to stack convolutional cells.");return o=s.call(this,r)||this,o.inputSpec=[new Rn({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,O=o==null?null:o.initialState;return s.prototype.call.call(h,r,{mask:b,training:T,initialState:O})})},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),O=[T[0]].concat(T.slice(2)),q=i.zeros(O);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 ye("Cannot call resetStates() on an RNN Layer that is not stateful.");var b=h.inputSpec[0].shape,T=h.computeSingleOutputShape(b),O=[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(O)}):h.states_=[i.zeros(O)];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(O)}):h.states_[0]=i.zeros(O);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 Z=0;Z<h.states_.length;++Z){var le=r[Z],Ne=O;if(!i.util.arraysEqual(le.shape,Ne))throw new w("State "+Z+" is incompatible with layer "+h.name+": "+("expected shape="+Ne+", received shape="+le.shape));h.states_[Z]=le}}h.states_=h.states_.map(function(Be){return i.keep(Be.clone())})})},u.prototype.computeSingleOutputShape=function(r){var o=this.cell,h=o.dataFormat,b=o.filters,T=o.kernelSize,O=o.padding,q=o.strides,Z=o.dilationRate,le=h==="channelsFirst",Ne=r[le?3:2],Be=r[le?4:3],je=Si(Ne,T[0],O,q[0],Z[0]),qe=Si(Be,T[1],O,q[1],Z[1]),vt=r.slice(0,2).concat(le?[b,je,qe]:[je,qe,b]);return vt},u.className="ConvRNN2D",u}(Ii),Ru=function(s){M(u,s);function u(r){var o=this,h=r.filters,b=r.kernelSize,T=r.strides,O=r.padding,q=r.dataFormat,Z=r.dilationRate;return o=s.call(this,V({},r,{units:h}))||this,o.filters=h,ar(o.filters,"filters"),o.kernelSize=_s(b,2,"kernelSize"),o.kernelSize.forEach(function(le){return ar(le,"kernelSize")}),o.strides=_s(T||1,2,"strides"),o.strides.forEach(function(le){return ar(le,"strides")}),o.padding=O||"valid",xn(o.padding),o.dataFormat=q||"channelsLast",on(o.dataFormat),o.dilationRate=_s(Z||1,2,"dilationRate"),o.dilationRate.forEach(function(le){return ar(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,O=this.kernelSize.concat([b,this.filters*T]);this.kernel=this.addWeight("kernel",O,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 Z=void 0;if(this.unitForgetBias){var le=this.biasInitializer,Ne=this.filters;Z=new(o=function(Be){M(je,Be);function je(){return Be!==null&&Be.apply(this,arguments)||this}return je.prototype.apply=function(qe,vt){var pt=le.apply([Ne]),ct=i.ones([Ne]),dt=le.apply([Ne*2]);return qi([pt,ct,dt])},je}(or),o.className="CustomInit",o)}else Z=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*T],null,Z,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],O=r[1],q=r[2],Z=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:Z}));var le=h.dropoutMask,Ne=function(Kn,eo,Ui){return!eo||!eo[Ui]?Kn:i.mul(eo[Ui],Kn)},Be=Ne(T,le,0),je=Ne(T,le,1),qe=Ne(T,le,2),vt=Ne(T,le,3);0<h.recurrentDropout&&h.recurrentDropout<1&&h.recurrentDropoutMask==null&&(h.recurrentDropoutMask=Vo({ones:function(){return i.onesLike(O)},rate:h.recurrentDropout,training:b,count:Z}));var pt=h.recurrentDropoutMask,ct=Ne(O,pt,0),dt=Ne(O,pt,1),Ft=Ne(O,pt,2),sr=Ne(O,pt,3),Yt=3,$t=i.split(h.kernel.read(),Z,Yt),vr=$t[0],hr=$t[1],Ir=$t[2],zr=$t[3],kr=h.useBias?i.split(h.bias.read(),Z):[null,null,null,null],Sr=kr[0],mn=kr[1],Xr=kr[2],er=kr[3];Be=h.inputConv(Be,vr,Sr,h.padding),je=h.inputConv(je,hr,mn,h.padding),qe=h.inputConv(qe,Ir,Xr,h.padding),vt=h.inputConv(vt,zr,er,h.padding);var Dn=i.split(h.recurrentKernel.read(),Z,Yt),Cn=Dn[0],bn=Dn[1],un=Dn[2],On=Dn[3];ct=h.recurrentConv(ct,Cn),dt=h.recurrentConv(dt,bn),Ft=h.recurrentConv(Ft,un),sr=h.recurrentConv(sr,On);var Hr=h.recurrentActivation.apply(i.add(Be,ct)),ha=h.recurrentActivation.apply(i.add(je,dt)),Ni=i.add(i.mul(ha,q),i.mul(Hr,h.activation.apply(i.add(qe,Ft)))),Wi=i.mul(h.recurrentActivation.apply(i.add(vt,sr)),h.activation.apply(Ni));return[Wi,Wi,Ni]})},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o=r.units,h=oe(r,["units"]),b={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return V({},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?re(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(Ru);var gc=function(s){M(u,s);function u(r){var o=this,h=new Ru(r);return o=s.call(this,V({},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 Ws=function(s){M(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=cr(r);if(0<h.rate&&h.rate<1){var T=o.training==null?!1:o.training,O=h.getNoiseShape(b),q=Ye(function(){return tt(b,h.rate,O,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(Ws);var xc=function(s){M(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}(Ws);i.serialization.registerClass(xc);var Qi=function(s){M(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,ar(o.units,"units"),o.activation=_a(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=fn(r.kernelConstraint),o.biasConstraint=fn(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=cr(r),T=Tn(h.activation.getClassName()),O;return T!=null?O=pe(b,h.kernel.read(),T,h.bias?h.bias.read():null):(O=pe(b,h.kernel.read()),h.bias!=null&&(O=re(O,h.bias.read())),h.activation!=null&&(O=h.activation.apply(O))),O})},u.prototype.getConfig=function(){var r={units:this.units,activation:$a(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:cn(this.kernelConstraint),biasConstraint:cn(this.biasConstraint)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Dense",u}(qr);i.serialization.registerClass(Qi);var lu=function(s){M(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],ma(r,1)]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=cr(r);if(h.dataFormat==="channelsFirst"&&b.rank>1){for(var T=[0],O=2;O<b.rank;++O)T.push(O);T.push(1),b=b.transpose(T)}return no(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(lu);var dr=function(s){M(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o.activation=_a(r.activation),o}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=cr(r);return h.activation.apply(b)})},u.prototype.getConfig=function(){var r={activation:$a(this.activation)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Activation",u}(qr);i.serialization.registerClass(dr);var Us=function(s){M(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=cr(r),Ai(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(Us);var Ho=function(s){M(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,O=null,q=0;q<b.length;++q){var Z=b[q];if(this.isUnknown(Z))if(O===null)O=q;else throw new w("Can only specifiy one unknown dimension.");else T*=Z}var le=ma(r);if(O!==null){if(T===0||le%T!==0)throw new w(h);b[O]=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=cr(r),T=b.shape,O=T.slice(0,1).concat(h.fixUnknownDimension(T.slice(1),h.targetShape));return b.reshape(O)})},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 Au=function(s){M(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 Rn({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(cr(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(Au);var _c=function(s){M(u,s);function u(r){var o=s.call(this,r==null?{}: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=cr(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=cr(r),T=-1,O=!0,q=i.any(i.notEqual(b,h.maskValue),T,O),Z=b.mul(q.asType(b.dtype));return Z})},u.className="Masking",u}(qr);i.serialization.registerClass(_c);var Fu=function(s){M(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(Ze(r.inputLength))}return o.inputDim=r.inputDim,ar(o.inputDim,"inputDim"),o.outputDim=r.outputDim,ar(o.outputDim,"outputDim"),o.embeddingsInitializer=x(r.embeddingsInitializer||o.DEFAULT_EMBEDDINGS_INITIALIZER),o.embeddingsRegularizer=Fn(r.embeddingsRegularizer),o.activityRegularizer=Fn(r.activityRegularizer),o.embeddingsConstraint=fn(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=cr(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=Ze(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],O=r[b+1];if(T!=null&&O!=null&&T!==O)throw new w('"inputLength" is '+this.inputLength+", but received "+("input shape has shape "+r));T==null&&(o[h]=O),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=cr(r);b.dtype!=="int32"&&(b=ai(b,"int32"));var T=Y(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:cn(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){M(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 xe},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],O=o[b];if(T==null||O==null||T<0||O<0)h.push(null);else if(T===1)h.push(O);else if(O===1)h.push(T);else{if(T!==O)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=jt(o),o.length>1)throw new w("Can not merge tensors with different batch sizes. "+("Got tensors with shapes: "+JSON.stringify(r)+"."));for(var O=r[0]==null?null:r[0].slice(1),q=1;q<r.length;++q){var T=r[q]==null?null:r[q].slice(1);O=this.computeElementwiseOpOutputShape(O,T)}var Z=r.map(function(le){return le.length});r.indexOf(null)===-1&&jt(Z).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 O=ja(T),q=0,Z=r;q<Z.length;q++){for(var le=Z[q],Ne=le.rank,Be=0;Be<O-Ne;++Be)le=gr(le,1);b.push(le)}return h.mergeFunction(b)}else{for(var je=!1,qe=0,vt=r;qe<vt.length;qe++){var le=vt[qe],Ne=le.rank;if(Ne==null){var pt=le.shape,ct=pt[0],dt=pt.slice(1).concat([ct]),Ft=le.reshape([ct].concat(ma(pt.slice(1))));Ft=i.transpose(Ft,[1,0]),Ft=Ft.reshape(dt),b.push(Ft),je=!0}else if(Ne>1){var sr=ln(1,Ne).concat([0]);b.push(i.transpose(le,sr)),je=!0}else b.push(le)}var Yt=h.mergeFunction(b),$t=Yt.rank;if(je){if($t==null){var vr=Yt.shape,hr=vr.length,ct=vr[hr-1],dt=[ct].concat(vr.slice(0,vr.length-1));Yt=i.transpose(Yt.reshape([-1,ct]),[1,0]).reshape(dt)}else if($t>1){var sr=[$t-1].concat(ln(0,$t-1));Yt=i.transpose(Yt,sr)}}return Yt}}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=[],O=0,q=r;O<q.length;O++){var b=q[O];b!=null&&b[0]!==null&&T.push(b[0])}return T=jt(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){M(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 Du=function(s){M(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(Du);var Vs=function(s){M(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(Vs);var bc=function(s){M(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 ho=function(s){M(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(ho);var kc=function(s){M(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 O=[],q=0;q<r.length;++q){var Z=r[q].slice();Z.splice(this.axis,1);for(var le=!1,Ne=0,Be=O;Ne<Be.length;Ne++){var T=Be[Ne];if(i.util.arraysEqual(T,Z)){le=!0;break}}le||O.push(Z)}if(O.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 qi(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,O=o.slice(1);T<O.length;T++){var q=O[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(Z){if(Z!=null){b=!1;return}}),b)return null;for(var T=[],O=0;O<r.length;++O)o[O]==null?T.push(i.onesLike(r[O]).asType("bool")):o[O].rank<r[O].rank?T.push(i.expandDims(o[O],-1)):T.push(o[O]);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 po(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 xe("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 xe("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 O=[],q=0;q<T;++q)O.push(1);u=u.reshape(u.shape.concat(O))}else if(h>o){T=h-o;for(var O=[],q=0;q<T;++q)O.push(1);s=s.reshape(s.shape.concat(O))}else T=0;var Z;if(s.shape.length===2&&u.shape.length===2)b[0]===b[1]?Z=s.mul(u).sum(b[0]):Z=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;Z=s.matMul(u,le,Ne)}if(T>0){var Be=void 0;o>h?Be=o+h-3:Be=o-1;for(var je=[],q=Be;q<Be+T;++q)je.push(q);Z=Z.squeeze(je)}return Z.shape.length===1&&(Z=Z.expandDims(1)),Z})}var hu=function(s){M(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 xe("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,O){return po(T,r[O].shape.length)}):b=[po(this.axes,o.shape.length),po(this.axes,h.shape.length)],this.normalize&&(o=Qa(o,b[0]),h=Qa(h,b[1])),Sc(o,h,b)},u.prototype.interpretAxes=function(r,o){var h;return Array.isArray(this.axes)?h=this.axes:h=[po(this.axes,r.length),po(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 xe("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(hu);var Ic=function(s){M(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=cr(r),T=function(){return Oi(b.shape,0,h.stddev).add(b)},O=Ye(T,function(){return b},o.training||!1);return O})},u.className="GaussianNoise",u}(qr);i.serialization.registerClass(Ic);var Ou=function(s){M(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=cr(r);if(h.rate>0&&h.rate<1){var T=function(){var O=Math.sqrt(h.rate/(1-h.rate));return b.mul(Oi(b.shape,1,O))};return Ye(T,function(){return b},o.training||!1)}return b})},u.className="GaussianDropout",u}(qr);i.serialization.registerClass(Ou);var Hs=function(s){M(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||cr(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 O=cr(r),q=1.6732632423543772,Z=1.0507009873554805,le=-q*Z,Ne=i.greaterEqual(i.randomUniform(b),h.rate);Ne=ai(Ne,"float32");var Be=Math.pow((1-h.rate)*(1+h.rate*Math.pow(le,2)),-.5),je=-Be*le*h.rate,qe=O.mul(Ne).add(Ne.add(-1).mul(le));return qe.mul(Be).add(je)};return Ye(T,function(){return cr(r)},o.training||!1)}return r})},u.className="AlphaDropout",u}(qr);i.serialization.registerClass(Hs);function fo(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 xe("batchNormalization is not implemented for array of rank "+s.rank+" yet");return T}function Mu(s,u,r,o,h){return h===void 0&&(h=.001),i.tidy(function(){var b=i.moments(s,o),T=b.mean,O=b.variance,q=fo(s,T,O,r,u,h);return[q,T,O]})}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,O=b.variance,q=[],Z=0,le=ln(0,s.rank);Z<le.length;Z++){var Ne=le[Z];o.indexOf(Ne)!==-1?q.push(1):q.push(s.shape[Ne])}var Be=T.reshape(q),je=O.reshape(q),qe=u==null?null:u.reshape(q),vt=r==null?null:r.reshape(q),pt=fo(s,Be,je,vt,qe,h);return[pt,T,O]})}function zu(s,u,r,o,h){return h===void 0&&(h=.001),i.util.arraysEqual(o.slice().sort(),ln(0,s.rank-1))?Mu(s,u,r,o,h):_l(s,u,r,o,h)}var Lu=function(s){M(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=fn(r.betaConstraint),o.gammaConstraint=fn(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 Rn({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=cr(r),O=T.shape,q=O.length,Z=ln(0,q),le=h.axis>=0?h.axis:h.axis+q;Z.splice(le,1);var Ne=st(1,q);Ne[le]=O[le];var Be=Z.slice();Be.sort();var je=!i.util.arraysEqual(Be,ln(0,q).slice(0,q-1)),qe=function(){if(je){var Yt=h.movingMean.read().reshape(Ne),$t=h.movingVariance.read().reshape(Ne),vr=h.center?h.beta.read().reshape(Ne):null,hr=h.scale?h.gamma.read().reshape(Ne):null;return fo(T,Yt,$t,vr,hr,h.epsilon)}else return fo(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 vt=zu(T,h.gamma.read(),h.beta.read(),Z,h.epsilon),pt=vt[0],ct=vt[1],dt=vt[2],Ft=function(Yt,$t,vr){i.tidy(function(){var hr=1-vr,Ir=Yt.read(),zr=Ir.sub($t).mul(hr);Yt.write(Ir.sub(zr))})},sr=function(){Ft(h.movingMean,ct,h.momentum),Ft(h.movingVariance,dt,h.momentum)};return sr(),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:cn(this.betaConstraint),gammaConstraint:cn(this.gammaConstraint)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="BatchNormalization",u}(qr);i.serialization.registerClass(Lu);var pu=function(s){M(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 O=T[b];if(O<0||O>=o)throw new Error("Invalid axis: "+O)}if(this.axis.length!==jt(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);var q=this.axis.map(function(le){return r[le]}),Z=!0;this.scale?this.gamma=this.addWeight("gamma",q,"float32",this.gammaInitializer,this.gammaRegularizer,Z):this.gamma=null,this.center?this.beta=this.addWeight("beta",q,"float32",this.betaInitializer,this.betaRegularizer,Z):this.beta=null,this.built=!0},u.prototype.call=function(r,o){var h=this,b=cr(r),T=b.shape,O=T.length;return i.tidy(function(){for(var q=!0,Z=i.moments(b,h.axis,q),le=Z.mean,Ne=Z.variance,Be=st(1,O),je=0,qe=h.axis;je<qe.length;je++){var vt=qe[je];Be[vt]=T[vt]}for(var pt=function($t){return $t!=null&&$t.shape.length!==O&&h.axis!==[O-1]?$t.reshape(Be):$t},ct=pt(h.gamma.read()),dt=pt(h.beta.read()),Ft=[],sr=[],Yt=0;Yt<O;++Yt)h.axis.indexOf(Yt)!==-1?(Ft.push(T[Yt]),sr.push(1)):(Ft.push(1),sr.push(T[Yt]));return le=le.tile(Ft),Ne=Ne.tile(Ft),ct=ct.tile(sr),dt=dt.tile(sr),fo(b,le,Ne,dt,ct,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(pu);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 du=function(s){M(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 Rn({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(cr(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(du);function fu(s,u,r,o,h,b){return i.tidy(function(){on(h),Ia(b),xn(o),r==null&&(r=[1,1]),o==null&&(o="valid"),h==null&&(h=he()),b==null&&(b="max"),s=bo(s,h);var T,O=o==="same"?"same":"valid";return b==="max"?T=i.maxPool(s,u,r,O):T=i.avgPool(s,u,r,O),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),Ia(b),xn(o),r==null&&(r=[1,1,1]),o==null&&(o="valid"),h==null&&(h=he()),b==null&&(b="max"),s=uo(s,h);var T,O=o==="same"?"same":"valid";return b==="max"?T=i.maxPool3d(s,u,r,O):T=i.avgPool3d(s,u,r,O),h==="channelsFirst"&&(T=i.transpose(T,[0,4,1,2,3])),T})}var Cc=function(s){M(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(ar(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 ar(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,xn(o.padding),o.inputSpec=[new Rn({ndim:3})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o=Si(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(cr(r),2);var b=h.poolingFunction(cr(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){M(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),xn(b),fu(r,o,h,b,T,"max")},u.className="MaxPooling1D",u}(Cc);i.serialization.registerClass(Tc);var Ec=function(s){M(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),xn(b),fu(r,o,h,b,T,"avg")},u.className="AveragePooling1D",u}(Cc);i.serialization.registerClass(Ec);var Ke=function(s){M(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 ar(o.poolSize,"poolSize"),ar(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,on(o.dataFormat),xn(o.padding),o.inputSpec=[new Rn({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=Si(o,this.poolSize[0],this.padding,this.strides[0]),h=Si(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(cr(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){M(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),xn(b),fu(r,o,h,b,T,"max")},u.className="MaxPooling2D",u}(Ke);i.serialization.registerClass(Rc);var sn=function(s){M(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),xn(b),fu(r,o,h,b,T,"avg")},u.className="AveragePooling2D",u}(Ke);i.serialization.registerClass(sn);var Ac=function(s){M(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 ar(o.poolSize,"poolSize"),ar(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,on(o.dataFormat),xn(o.padding),o.inputSpec=[new Rn({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=Si(o,this.poolSize[0],this.padding,this.strides[0]),h=Si(h,this.poolSize[1],this.padding,this.strides[1]),b=Si(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(cr(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),Is=function(s){M(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),xn(b),Nc(r,o,h,b,T,"max")},u.className="MaxPooling3D",u}(Ac);i.serialization.registerClass(Is);var Fc=function(s){M(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),xn(b),Nc(r,o,h,b,T,"avg")},u.className="AveragePooling3D",u}(Ac);i.serialization.registerClass(Fc);var $n=function(s){M(u,s);function u(r){var o=s.call(this,r)||this;return o.inputSpec=[new Rn({ndim:3})],o}return u.prototype.computeOutputShape=function(r){return[r[0],r[2]]},u.prototype.call=function(r,o){throw new xe},u}(qr),Dc=function(s){M(u,s);function u(r){return s.call(this,r||{})||this}return u.prototype.call=function(r,o){return i.tidy(function(){var h=cr(r);return i.mean(h,1)})},u.className="GlobalAveragePooling1D",u}($n);i.serialization.registerClass(Dc);var Oc=function(s){M(u,s);function u(r){return s.call(this,r||{})||this}return u.prototype.call=function(r,o){return i.tidy(function(){var h=cr(r);return i.max(h,1)})},u.className="GlobalMaxPooling1D",u}($n);i.serialization.registerClass(Oc);var Mc=function(s){M(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 Rn({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 xe},u.prototype.getConfig=function(){var r={dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),Gs=function(s){M(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=cr(r);return h.dataFormat==="channelsLast"?i.mean(b,[1,2]):i.mean(b,[2,3])})},u.className="GlobalAveragePooling2D",u}(Mc);i.serialization.registerClass(Gs);var ss=function(s){M(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=cr(r);return h.dataFormat==="channelsLast"?i.max(b,[1,2]):i.max(b,[2,3])})},u.className="GlobalMaxPooling2D",u}(Mc);i.serialization.registerClass(ss);var zc=function(s){M(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=ca(b,h);delete o.layer;var O={layer:T};return Object.assign(O,o),new r(O)},u}(qr),Lc=function(s){M(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=cr(r);var b=function(q,Z){var le=cr(h.layer.call(q,o));return[le,[]]},T=yc(b,r,[],!1,null,null,!1,!0),O=T[1];return O})},u.className="TimeDistributed",u}(zc);i.serialization.registerClass(Lc);function mu(s){Pr(hi,"BidirectionalMergeMode",s)}var Pc="concat",Pu=function(s){M(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=ca(b),h.goBackwards=!(h.goBackwards===!0);var T={};if(T.className=r.layer.getClassName(),T.config=h,o.backwardLayer=ca(T),o.forwardLayer.name="forward_"+o.forwardLayer.name,o.backwardLayer.name="backward_"+o.backwardLayer.name,o.mergeMode=r.mergeMode===void 0?Pc:r.mergeMode,mu(o.mergeMode),r.weights)throw new xe("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()):It(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 O=[],q=[];if(h!=null){var Z=h.length;if(Z%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,O.push.apply(O,h);var le=h.map(function(Ft){return new Rn({shape:Ft.shape})});this.forwardLayer.stateSpec=le.slice(0,Z/2),this.backwardLayer.stateSpec=le.slice(Z/2),q.push.apply(q,le)}if(b!=null)throw new xe("Support for constants in Bidirectional layers is not implemented yet.");for(var Ne=O[0]instanceof Ca,Be=0,je=O;Be<je.length;Be++){var qe=je[Be];if(qe instanceof Ca!==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 vt=[r].concat(O),pt=this.inputSpec.concat(q),ct=this.inputSpec;this.inputSpec=pt;var dt=s.prototype.apply.call(this,vt,o);return this.inputSpec=ct,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,O;if(b==null)T=h.forwardLayer.call(r,o),O=h.backwardLayer.call(r,o);else{var q=b.slice(0,b.length/2),Z=b.slice(b.length/2);T=h.forwardLayer.call(r,Object.assign(o,{initialState:q})),O=h.backwardLayer.call(r,Object.assign(o,{initialState:Z}))}var le;h.returnState&&(Array.isArray(T)&&(le=T.slice(1).concat(O.slice(1))),T=T[0],O=O[0]),h.returnSequences&&(O=i.reverse(O,1));var Ne;return h.mergeMode==="concat"?Ne=qi([T,O]):h.mergeMode==="sum"?Ne=i.add(T,O):h.mergeMode==="ave"?Ne=i.mul(.5,i.add(T,O)):h.mergeMode==="mul"?Ne=i.mul(T,O):h.mergeMode==null&&(Ne=[T,O]),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;na(this.forwardLayer.name,function(){o.forwardLayer.build(r)}),na(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(O){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=ca(o.layer);if(delete o.layer,o.numConstants!=null)throw new xe("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}(zc);i.serialization.registerClass(Pu);function bl(s){return new Ba(s)}function Ji(s){return new ku(s)}function Bu(s){return new ou(s)}function us(s){return new cc(s)}function kl(s){return new ui(s)}function Bc(s){return new lc(s)}function yu(s){return new Su(s)}function Wc(s){return new pc(s)}function Uc(s){return new Cu(s)}function Vc(s){return new co(s)}function Hc(s){return new hc(s)}function Gc(s){return new Tu(s)}function jc(s){return new dc(s)}function Wu(s){return new fc(s)}function Uu(s){return new Eu(s)}function qc(s){return new dr(s)}function Kc(s){return new Qi(s)}function Sl(s){return new Ws(s)}function Il(s){return new xc(s)}function Vu(s){return new lu(s)}function Xc(s){return new Us(s)}function Yc(s){return new Ho(s)}function cs(s){return new Au(s)}function jo(s){return new Fu(s)}function Nl(s){return new wc(s)}function Cl(s){return new Vs(s)}function Hu(s){return new kc(s)}function Tl(s){return new bc(s)}function vu(s){return new ho(s)}function Gu(s){return new Du(s)}function El(s){return new hu(s)}function Rl(s){return new Lu(s)}function Al(s){return new pu(s)}function js(s){return new du(s)}function ju(s){return new Ec(s)}function Fl(s){return ju(s)}function Dl(s){return ju(s)}function qu(s){return new sn(s)}function Ol(s){return qu(s)}function Ml(s){return qu(s)}function Ku(s){return new Fc(s)}function Ea(s){return Ku(s)}function zl(s){return Ku(s)}function Ll(s){return new Dc(s)}function Pl(s){return new Gs(s)}function Zc(s){return new Oc(s)}function la(s){return new ss(s)}function Ua(s){return new Tc(s)}function gu(s){return new Rc(s)}function Qc(s){return new Is(s)}function Bl(s){return new lo(s)}function Wl(s){return new Wo(s)}function Ul(s){return new cu(s)}function Vl(s){return new Uo(s)}function Hl(s){return new vc(s)}function Gl(s){return new Ss(s)}function jl(s){return new gc(s)}function ql(s){return new Ru(s)}function Kl(s){return new Ii(s)}function Xl(s){return new os(s)}function Cr(s){return new Pu(s)}function Yl(s){return new Lc(s)}var Xu=Zc,Zl=la,Wr=Ua,Jc=gu;function bt(s){return new Ic(s)}function Ql(s){return new Ou(s)}function ci(s){return new Hs(s)}function Jl(s){return new _c(s)}var $c={__proto__:null,inputLayer:bl,elu:Ji,reLU:Bu,leakyReLU:us,prelu:kl,softmax:Bc,thresholdedReLU:yu,conv1d:Wc,conv2d:Uc,conv2dTranspose:Vc,conv3d:Hc,separableConv2d:Gc,cropping2D:jc,upSampling2d:Wu,depthwiseConv2d:Uu,activation:qc,dense:Kc,dropout:Sl,spatialDropout1d:Il,flatten:Vu,repeatVector:Xc,reshape:Yc,permute:cs,embedding:jo,add:Nl,average:Cl,concatenate:Hu,maximum:Tl,minimum:vu,multiply:Gu,dot:El,batchNormalization:Rl,layerNormalization:Al,zeroPadding2d:js,averagePooling1d:ju,avgPool1d:Fl,avgPooling1d:Dl,averagePooling2d:qu,avgPool2d:Ol,avgPooling2d:Ml,averagePooling3d:Ku,avgPool3d:Ea,avgPooling3d:zl,globalAveragePooling1d:Ll,globalAveragePooling2d:Pl,globalMaxPooling1d:Zc,globalMaxPooling2d:la,maxPooling1d:Ua,maxPooling2d:gu,maxPooling3d:Qc,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:Xu,globalMaxPool2d:Zl,maxPool1d:Wr,maxPool2d:Jc,Layer:qr,RNN:Ii,RNNCell:is,input:pr,gaussianNoise:bt,gaussianDropout:Ql,alphaDropout:ci,masking:Jl};function $l(s,u){return Ao(s,u)}function el(s,u){return Ds(s,u)}function eh(s,u){return fs(s,u)}function th(s,u){return Jo(s,u)}function Yu(s,u){return Fo(s,u)}function tl(s,u){return ds(s,u)}function rl(s,u){return tu(s,u)}function li(s,u){return Zo(s,u)}function nl(s,u){return so(s,u)}function $i(s,u){return Ta(s,u)}function f(s,u){return Ta(s,u)}function p(s,u){return Ta(s,u)}function l(s,u){return Zn(s,u)}function m(s,u){return Zn(s,u)}function g(s,u){return Zn(s,u)}var I={__proto__:null,binaryAccuracy:$l,binaryCrossentropy:el,sparseCategoricalAccuracy:eh,categoricalAccuracy:th,categoricalCrossentropy:Yu,precision:tl,recall:rl,cosineProximity:li,meanAbsoluteError:nl,meanAbsolutePercentageError:$i,MAPE:f,mape:p,meanSquaredError:l,MSE:m,mse:g},R={__proto__:null,modelFromJSON:Vt};function P(s){return new Mr(s)}function L(s){return ei(s)}function G(s){return as(s)}var Q={__proto__:null,l1l2:P,l1:L,l2:G},ke=function(s){M(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}(Za);function Ce(s,u){return s<u}function Fe(s,u){return s>u}var Ee=function(s){M(u,s);function u(r){var o=s.call(this)||this;if(r==null&&(r={}),r.restoreBestWeights)throw new xe("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=Fe:o.monitorFunc=Ce,o.monitorFunc===Ce&&(o.minDelta*=-1),o}return u.prototype.onTrainBegin=function(r){return de(this,void 0,void 0,function(){return X(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 de(this,void 0,void 0,function(){var h;return X(this,function(b){switch(b.label){case 0:return[4,si(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 de(this,void 0,void 0,function(){return X(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}(ke);function Ge(s){return new Ee(s)}var Qe={earlyStopping:Ge};N.Callback=ke,N.CallbackList=io,N.CustomCallback=Co,N.EarlyStopping=Ee,N.History=No,N.InputSpec=Rn,N.LayerVariable=Ka,N.LayersModel=wt,N.RNN=Ii,N.Sequential=Ie,N.SymbolicTensor=Ca,N.callbacks=Qe,N.constraints=Yn,N.initializers=xr,N.input=pr,N.layers=$c,N.loadLayersModel=Tr,N.metrics=I,N.model=br,N.models=R,N.registerCallbackConstructor=Fr,N.regularizers=Q,N.sequential=Nr,N.version_layers=xs}),ig=Or(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),we=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 M(S,x,k,K){return new(k||(k=Promise))(function(Se,be){function Je(ft){try{gt(K.next(ft))}catch(Lt){be(Lt)}}function Pe(ft){try{gt(K.throw(ft))}catch(Lt){be(Lt)}}function gt(ft){ft.done?Se(ft.value):new k(function(Lt){Lt(ft.value)}).then(Je,Pe)}gt((K=K.apply(S,x||[])).next())})}function V(S,x){var k={label:0,sent:function(){if(be[0]&1)throw be[1];return be[1]},trys:[],ops:[]},K,Se,be,Je;return Je={next:Pe(0),throw:Pe(1),return:Pe(2)},typeof Symbol=="function"&&(Je[Symbol.iterator]=function(){return this}),Je;function Pe(ft){return function(Lt){return gt([ft,Lt])}}function gt(ft){if(K)throw new TypeError("Generator is already executing.");for(;k;)try{if(K=1,Se&&(be=Se[ft[0]&2?"return":ft[0]?"throw":"next"])&&!(be=be.call(Se,ft[1])).done)return be;(Se=0,be)&&(ft=[0,be.value]);switch(ft[0]){case 0:case 1:be=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(!(be=k.trys,be=be.length>0&&be[be.length-1])&&(ft[0]===6||ft[0]===2)){k=0;continue}if(ft[0]===3&&(!be||ft[1]>be[0]&&ft[1]<be[3])){k.label=ft[1];break}if(ft[0]===6&&k.label<be[1]){k.label=be[1],be=ft;break}if(be&&k.label<be[2]){k.label=be[2],k.ops.push(ft);break}be[2]&&k.ops.pop(),k.trys.pop();continue}ft=x.call(S,k)}catch(Lt){ft=[6,Lt],Se=0}finally{K=be=0}if(ft[0]&5)throw ft[1];return{value:ft[0]?ft[1]:void 0,done:!0}}}function oe(S,x){var k=typeof Symbol=="function"&&S[Symbol.iterator];if(!k)return S;var K=k.call(S),Se,be=[],Je;try{for(;(x===void 0||x-- >0)&&!(Se=K.next()).done;)be.push(Se.value)}catch(Pe){Je={error:Pe}}finally{try{Se&&!Se.done&&(k=K.return)&&k.call(K)}finally{if(Je)throw Je.error}}return be}function de(){for(var S=[],x=0;x<arguments.length;x++)S=S.concat(oe(arguments[x]));return S}var X;(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"})(X||(X={}));var Te;(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={}))})(Te||(Te={}));var z={};function he(S,x){var k={tfOpName:S,category:"custom",inputs:[],attrs:[],customExecutor:x};z[S]=k}function ye(S){return z[S]}function ee(S){delete z[S]}function w(S,x,k,K,Se){var be=x.inputParams[S];if(be&&be.inputIndexStart!==void 0){var Je=be.inputIndexStart,Pe=be.inputIndexEnd===0?void 0:be.inputIndexEnd===void 0?Je+1:be.inputIndexEnd;if(be.type==="tensor")return xe(x.inputNames[be.inputIndexStart],k,K,Se);if(be.type==="tensors"){var gt=x.inputNames.slice(Je,Pe);return gt.map(function(Gt){return xe(Gt,k,K,Se)})}var ft=xe(x.inputNames.slice(Je)[0],k,K,Se),Lt=ft.dataSync();return be.type==="number"?Lt[0]:i.util.toNestedArray(ft.shape,Lt)}var Wt=x.attrParams[S];return Wt&&Wt.value}function xe(S,x,k,K){var Se=oe(ut(S),2),be=Se[0],Je=Se[1];if(K!=null){var Pe=K.getHashTableHandleByName(be);if(Pe!=null)return Pe}var gt=k.currentContextIds.find(function(ft){return!!x[st(be,ft)]});return gt!==void 0?x[st(be,gt)][Je]:void 0}function We(S,x,k){return x[st(S,k.currentContextId)]}function W(S,x){var k=oe(ut(S),2),K=k[0],Se=k[1];return[st(K,x&&x.currentContextId),Se]}function st(S,x){return x?S+"-"+x:S}function ut(S){var x=S.split(":");if(x.length===1)return[S,0];var k=x[0];return[k,Number(x[x.length-1])]}function Kt(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]],be=0;be<4;be++)Se[be][0]=K[be*2],Se[be][1]=K[be*2+1];return Se}return K}function It(S){return S.kept?S:i.clone(S)}var Ze=[{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}]}],mt={__proto__:null,json:Ze},yt=[{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}]}],$e={__proto__:null,json:yt},ot=[{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"}]}],nt={__proto__:null,json:ot},et=[{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"}]}],Qt={__proto__:null,json:et},rr=[{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"}]}],jt={__proto__:null,json:rr},jr=[{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}]}],Pr={__proto__:null,json:jr},_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"}]}],ar={__proto__:null,json:_r},da=[{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"}]}],Ha={__proto__:null,json:da},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}]}],ba={__proto__:null,json:Tn},ka=[{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"}]}],ta={__proto__:null,json:ka},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}]}],Ti={__proto__:null,json:Ma},Bn=[{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}]}],ra={__proto__:null,json:Bn},cn=[{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}]}],za={__proto__:null,json:cn},fn=[{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"}]}],Gn={__proto__:null,json:fn},_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}]}],fa={__proto__:null,json:_i},Hi=[{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}]}],Yn={__proto__:null,json:Hi},Wn=[{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:[]}],Ga={__proto__:null,json:Wn},Sa=function(){function S(){var x=[mt,$e,nt,Qt,jt,Pr,ar,Ti,ta,Ha,ra,za,Gn,fa,Yn,Ga,ba],k=[].concat.apply([],de(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,be=[],Je=[],Pe=[],gt=Se.reduce(function(Zt,xr){return Zt[xr.name]=K.mapNode(xr),xr.op.startsWith("Placeholder")?be.push(Zt[xr.name]):xr.op==="Const"?Je.push(Zt[xr.name]):(xr.input==null||xr.input.length===0)&&Pe.push(Zt[xr.name]),Zt},{}),ft=[],Lt=[],Wt={},Gt={};k!=null&&(Wt=this.mapSignatureEntries(k.inputs),Gt=this.mapSignatureEntries(k.outputs));var Jt=Object.keys(gt);Jt.forEach(function(Zt){var xr=gt[Zt];xr.inputNames.forEach(function(kn){var pn=oe(W(kn),1),zn=pn[0];xr.inputs.push(gt[zn]),gt[zn].children.push(xr)})}),Object.keys(Gt).length===0?Jt.forEach(function(Zt){var xr=gt[Zt];xr.children.length===0&&Lt.push(xr)}):Object.keys(Gt).forEach(function(Zt){var xr=oe(W(Zt),1),kn=xr[0],pn=gt[kn];pn!=null&&(pn.signatureKey=Gt[Zt],Lt.push(pn))}),Object.keys(Wt).length>0?Object.keys(Wt).forEach(function(Zt){var xr=oe(W(Zt),1),kn=xr[0],pn=gt[kn];pn&&(pn.signatureKey=Wt[Zt],ft.push(pn))}):ft=be;var wr={};x.library!=null&&x.library.function!=null&&(wr=x.library.function.reduce(function(Zt,xr){return Zt[xr.signature.name]=K.mapFunction(xr),Zt},{}));var Ar={nodes:gt,inputs:ft,outputs:Lt,weights:Je,placeholders:be,signature:k,functions:wr};return Pe.length>0&&(Ar.initNodes=Pe),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=ye(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,be){return Se[be.name]={type:be.type,inputIndexStart:be.start,inputIndexEnd:be.end},Se},{})),k.attrs!=null&&(K.attrParams=k.attrs.reduce(function(Se,be){var Je=be.type,Pe=void 0;switch(be.type){case"string":Pe=on(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=on(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"string[]":Pe=ni(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=ni(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"number":Pe=Ia(x.attr,be.tfName,be.defaultValue||0),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=Ia(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"number[]":Pe=jn(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=jn(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"bool":Pe=xn(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=xn(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"bool[]":Pe=ma(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=ma(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"shape":Pe=Ri(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=Ri(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"shape[]":Pe=pi(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=pi(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"dtype":Pe=na(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=na(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"dtype[]":Pe=Ei(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=Ei(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"func":Pe=Pa(x.attr,be.tfName,be.defaultValue),Pe===void 0&&!!be.tfDeprecatedName&&(Pe=Pa(x.attr,be.tfDeprecatedName,be.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: "+be.type+" for op: "+x.op)}return Se[be.name]={value:Pe,type:Je},Se},{})),K},S.prototype.mapFunction=function(x){var k=this,K=x.nodeDef,Se=[],be=[],Je={};K!=null&&(Je=K.reduce(function(Gt,Jt){return Gt[Jt.name]=k.mapNode(Jt),Jt.op==="Const"&&be.push(Gt[Jt.name]),Gt},{}));var Pe=[],gt=[];x.signature.inputArg.forEach(function(Gt){var Jt=oe(W(Gt.name),1),wr=Jt[0],Ar={name:wr,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:Rr(Gt.type),type:"dtype"}},children:[]};Ar.signatureKey=Gt.name,Pe.push(Ar),Je[wr]=Ar});var ft=Object.keys(Je);ft.forEach(function(Gt){var Jt=Je[Gt];Jt.inputNames.forEach(function(wr){var Ar=oe(W(wr),1),Zt=Ar[0];Jt.inputs.push(Je[Zt]),Je[Zt].children.push(Jt)})});var Lt=x.ret;x.signature.outputArg.forEach(function(Gt){var Jt=oe(W(Lt[Gt.name]),2),wr=Jt[0],Ar=Jt[1],Zt=Je[wr];Zt!=null&&(Zt.defaultOutput=Ar,gt.push(Zt))});var Wt=this.mapArgsToSignature(x);return{nodes:Je,inputs:Pe,outputs:gt,weights:be,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 hi(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 La(S,x){var k=Array.isArray(S)?String.fromCharCode.apply(null,S):hi(S);return x?k:k.toLowerCase()}function on(S,x,k,K){K===void 0&&(K=!1);var Se=S[x];return Se!=null?La(Se.s,K):k}function xn(S,x,k){var K=S[x];return K?K.b:k}function Ia(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=X[S]);switch(S){case X.DT_FLOAT:return"float32";case X.DT_INT32:case X.DT_INT64:case X.DT_INT8:case X.DT_UINT8:return"int32";case X.DT_BOOL:return"bool";case X.DT_DOUBLE:return"float32";case X.DT_STRING:return"string";default:return null}}function Pa(S,x,k){var K=S[x];return K&&K.func?K.func.name:k}function na(S,x,k){var K=S[x];return K&&K.type?Rr(K.type):k}function Ei(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 Gi(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 Ri(S,x,k){var K=S[x];return K&&K.shape?Gi(K.shape):k}function jn(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 ni(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(be){return La(be,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 Gi(Se)}):k}function ma(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(be){return Se.getInput(be)}),x.rawAttrs!=null&&(this.attrs=Object.keys(x.rawAttrs).reduce(function(be,Je){return be[Je]=Se.getAttr(Je),be},{}))}return S.prototype.getInput=function(x){return xe(x,this.tensorMap,this.context)},S.prototype.getAttr=function(x,k){var K=this.node.rawAttrs[x];if(K.tensor!=null)return xe(x,this.tensorMap,this.context);if(K.i!=null||K.f!=null)return Ia(this.node.rawAttrs,x,k);if(K.s!=null)return on(this.node.rawAttrs,x,k);if(K.b!=null)return xn(this.node.rawAttrs,x,k);if(K.shape!=null)return Ri(this.node.rawAttrs,x,k);if(K.type!=null)return na(this.node.rawAttrs,x,k);if(K.list!=null){if(K.list.i!=null||K.list.f!=null)return jn(this.node.rawAttrs,x,k);if(K.list.s!=null)return ni(this.node.rawAttrs,x,k);if(K.list.shape!=null)return pi(this.node.rawAttrs,x,k);if(K.list.b!=null)return ma(this.node.rawAttrs,x,k);if(K.list.type!=null)return Ei(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")}},ja=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(xe(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(ai(S,x),function(){return k+(" Shapes "+S+" and "+x+" must match")})}function ai(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,be,Je,Pe){this.name=x,this.dtype=k,this.maxSize=K,this.elementShape=Se,this.identicalElementShapes=be,this.dynamicSize=Je,this.clearAfterRead=Pe,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,be){return K.write(Se,k[be])})},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,de(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,be=x.map(function(Lt){return Se+=Lt,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,Pe=[];i.tidy(function(){k=i.reshape(k,[1,Se,Je]);for(var Lt=0;Lt<x.length;++Lt){var Wt=Lt===0?0:be[Lt-1],Gt=[0,Wt,0],Jt=[1,x[Lt],Je];Pe[Lt]=i.reshape(i.slice(k,Gt,Jt),K.elementShape)}return Pe});for(var gt=[],ft=0;ft<x.length;ft++)gt[ft]=ft;this.writeMany(gt,Pe)},S}(),Ai=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(be){if(K!==be.dtype)throw new Error("Invalid data types; op elements "+K+", but list elements "+be.dtype);ln(k,be.shape,"TensorList shape mismatch: "),i.keep(be)}),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(de(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 be=Se.tensors.map(function(Je){return i.reshape(Je,x)});return i.stack(be,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 be=x.map(function(Je){return i.reshape(Se.tensors[Je],K)});return i.stack(be,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(be){return i.reshape(be,k)});return i.concat(Se,0)})},S}();function wi(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 be=i.unstack(S);return new Ai(be,x,K)}function no(S,x,k){return new Ai([],S,x,k)}function Qn(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,de(x));if(K!=null&&K!==-1&&Se>=K)throw new Error("Max index must be < array size ("+Se+" vs. "+K+")");var be=new Ai([],k,S.dtype,K),Je=i.unstack(S,0);return x.forEach(function(Pe,gt){be.setItem(Pe,Je[gt])}),be}function ji(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 be=K===0?0:S.size/K,Je=i.tidy(function(){var ft=[];S=i.reshape(S,[1,K,be]);for(var Lt=0;Lt<x.length;++Lt){var Wt=Lt===0?0:Se[Lt-1],Gt=[0,Wt,0],Jt=[1,x[Lt],be];ft[Lt]=i.reshape(i.slice(S,Gt,Jt),k)}return S.dispose(),ft}),Pe=new Ai([],k,S.dtype,x.length),gt=0;gt<Je.length;gt++)Pe.setItem(gt,Je[gt]);return Pe}var Fi=void 0,qi=function(S,x,k){return M(Fi,void 0,void 0,function(){var K,Se,be,Je,Pe,gt,ft,Lt,Pe,Wt,Gt,gt,Jt,wr,Ar,Ar,Zt,xr,Zt,kn,Zt,Zt,Zt,pn,zn,Dr,Na,Sn,cr,$r,Fa,mi,Ka,Xa,ii,zi,Rn,Ca,Ki,yi,oi,qr,Io,nn,Ya,Ba,Xi,si,Li,ao,mo,Za,io,Yo,No,Co,oo,ua,Ka,Xa,Br,ua,Rn,Dr,ca,Br,nn,Ya,Dr,Qa,Br,Dr,Zn,Qa,Br,Ki,yi,Dr,Zn,Br,ua,Dr,Zn,Qa,Br,so,Dr,Zn,Br,Xi,Br,Li,Dr,ua,Xa,Br,ua,Dr,ca,Br,mo,Dr,Za,Br;return V(this,function(Ta){switch(Ta.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),be=w("elseBranch",S,x,k),Je=w("cond",S,x,k),Pe=w("args",S,x,k),[4,Je.data()];case 2:return gt=Ta.sent(),gt[0]?[2,k.functionMap[Se].executeFunctionAsync(Pe,k.tensorArrayMap,k.tensorListMap)]:[2,k.functionMap[be].executeFunctionAsync(Pe,k.tensorArrayMap,k.tensorListMap)];case 3:return ft=w("body",S,x,k),Lt=w("cond",S,x,k),Pe=w("args",S,x,k),[4,k.functionMap[Lt].executeFunctionAsync(Pe,k.tensorArrayMap,k.tensorListMap)];case 4:return Wt=Ta.sent(),Gt=Pe.map(function(vn){return vn.id}),[4,Wt[0].data()];case 5:gt=Ta.sent(),Wt.forEach(function(vn){!vn.kept&&Gt.indexOf(vn.id)===-1&&vn.dispose()}),Jt=Pe,wr=function(){var vn,Pi,yo;return V(this,function(vo){switch(vo.label){case 0:return vn=Jt,[4,k.functionMap[ft].executeFunctionAsync(Jt,k.tensorArrayMap,k.tensorListMap)];case 1:return Jt=vo.sent(),Pi=Jt.map(function(Da){return Da.id}),vn.forEach(function(Da){!Da.kept&&Gt.indexOf(Da.id)===-1&&Pi.indexOf(Da.id)===-1&&Da.dispose()}),[4,k.functionMap[Lt].executeFunctionAsync(Jt,k.tensorArrayMap,k.tensorListMap)];case 2:return yo=vo.sent(),[4,yo[0].data()];case 3:return gt=vo.sent(),yo.forEach(function(Da){!Da.kept&&Gt.indexOf(Da.id)===-1&&Pi.indexOf(Da.id)===-1&&Da.dispose()}),[2]}})},Ta.label=6;case 6:return gt[0]?[5,wr()]:[3,8];case 7:return Ta.sent(),[3,6];case 8:return[2,Jt];case 9:return Ar=w("pred",S,x,k),[2,[It(Ar)]];case 10:return Ar=w("pred",S,x,k),Zt=w("data",S,x,k),Zt.kept||(Zt=It(Zt)),[4,Ar.data()];case 11:return[2,Ta.sent()[0]?[void 0,Zt]:[Zt,void 0]];case 12:return xr=S.inputNames.find(function(vn){return xe(vn,x,k)!==void 0}),xr?(Zt=xe(xr,x,k),[2,[It(Zt)]]):[2,void 0];case 13:return kn=w("frameName",S,x,k),Zt=w("tensor",S,x,k),k.enterFrame(kn),[2,[It(Zt)]];case 14:return Zt=w("tensor",S,x,k),k.exitFrame(),[2,[It(Zt)]];case 15:return Zt=w("tensor",S,x,k),k.nextIteration(),[2,[It(Zt)]];case 16:return pn=w("size",S,x,k),zn=w("dtype",S,x,k),Dr=w("elementShape",S,x,k),Na=w("dynamicSize",S,x,k),Sn=w("clearAfterRead",S,x,k),cr=w("identicalElementShapes",S,x,k),$r=w("name",S,x,k),Fa=new gr($r,zn,pn,Dr,cr,Na,Sn),k.addTensorArray(Fa),[2,[Fa.idTensor,i.scalar(1)]];case 17:return mi=w("tensorArrayId",S,x,k),Ka=w("index",S,x,k),Xa=w("tensor",S,x,k),ii=k.getTensorArray(mi.id),ii.write(Ka,Xa),[2,[ii.idTensor]];case 18:return zi=w("tensorArrayId",S,x,k),Rn=w("index",S,x,k),Ca=k.getTensorArray(zi.id),[2,[Ca.read(Rn)]];case 19:return Ki=w("tensorArrayId",S,x,k),yi=w("indices",S,x,k),oi=w("dtype",S,x,k),qr=k.getTensorArray(Ki.id),[2,[qr.gather(yi,oi)]];case 20:return Io=w("tensorArrayId",S,x,k),nn=w("indices",S,x,k),Ya=w("tensor",S,x,k),Ba=k.getTensorArray(Io.id),Ba.scatter(nn,Ya),[2,[Ba.idTensor]];case 21:return Xi=w("tensorArrayId",S,x,k),si=k.getTensorArray(Xi.id),Li=w("dtype",S,x,k),[2,[si.concat(Li)]];case 22:return ao=w("tensorArrayId",S,x,k),mo=w("tensor",S,x,k),Za=w("lengths",S,x,k),io=k.getTensorArray(ao.id),io.split(Za,mo),[2,[io.idTensor]];case 23:return Yo=w("tensorArrayId",S,x,k),No=k.getTensorArray(Yo.id),[2,[i.scalar(No.size(),"int32")]];case 24:return Co=w("tensorArrayId",S,x,k),oo=k.getTensorArray(Co.id),oo.clearAndClose(),[2,[oo.idTensor]];case 25:return ua=w("tensorListId",S,x,k),Ka=w("index",S,x,k),Xa=w("tensor",S,x,k),Br=k.getTensorList(ua.id),Br.setItem(Ka,Xa),[2,[Br.idTensor]];case 26:return ua=w("tensorListId",S,x,k),Rn=w("index",S,x,k),Dr=w("elementShape",S,x,k),ca=w("elementDType",S,x,k),Br=k.getTensorList(ua.id),[2,[Br.getItem(Rn,Dr,ca)]];case 27:return nn=w("indices",S,x,k),Ya=w("tensor",S,x,k),Dr=w("elementShape",S,x,k),Qa=w("numElements",S,x,k),Br=Qn(Ya,nn,Dr,Qa),k.addTensorList(Br),[2,[Br.idTensor]];case 28:return Dr=w("elementShape",S,x,k),Zn=w("elementDType",S,x,k),Qa=w("numElements",S,x,k),Br=no(Dr,Zn,Qa),k.addTensorList(Br),[2,[Br.idTensor]];case 29:return Ki=w("tensorListId",S,x,k),yi=w("indices",S,x,k),Dr=w("elementShape",S,x,k),Zn=w("elementDType",S,x,k),Br=k.getTensorList(Ki.id),[2,[Br.gather(yi,Zn,Dr)]];case 30:return ua=w("tensorListId",S,x,k),Dr=w("elementShape",S,x,k),Zn=w("elementDType",S,x,k),Qa=w("numElements",S,x,k),Br=k.getTensorList(ua.id),[2,[Br.stack(Dr,Zn,Qa)]];case 31:return so=w("tensor",S,x,k),Dr=w("elementShape",S,x,k),Zn=w("elementDType",S,x,k),Br=wi(so,Dr,Zn),k.addTensorList(Br),[2,[Br.idTensor]];case 32:return Xi=w("tensorListId",S,x,k),Br=k.getTensorList(Xi.id),Li=w("dtype",S,x,k),Dr=w("elementShape",S,x,k),[2,[Br.concat(Li,Dr)]];case 33:return ua=w("tensorListId",S,x,k),Xa=w("tensor",S,x,k),Br=k.getTensorList(ua.id),Br.pushBack(Xa),[2,[Br.idTensor]];case 34:return ua=w("tensorListId",S,x,k),Dr=w("elementShape",S,x,k),ca=w("elementDType",S,x,k),Br=k.getTensorList(ua.id),[2,[Br.popBack(Dr,ca)]];case 35:return mo=w("tensor",S,x,k),Dr=w("elementShape",S,x,k),Za=w("lengths",S,x,k),Br=ji(mo,Za,Dr),k.addTensorList(Br),[2,[Br.idTensor]];case 36:throw TypeError("Node type "+S.op+" is not implemented")}})})};function Di(S,x,k){var K=oe(w("fusedOps",S,x,k),2),Se=K[0],be=K[1],Je=Se==="biasadd",Pe=be==="prelu",gt=Se==="fusedbatchnorm",ft=w("numArgs",S,x,k);if(Je){if(Pe&&ft!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!Pe&&ft!==1)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(gt)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.");var Lt=w("strides",S,x,k),Wt=Kt(S,x,k),Gt=w("dataFormat",S,x,k).toUpperCase(),Jt=w("dilations",S,x,k),wr=oe(w("args",S,x,k),2),Ar=wr[0],Zt=wr[1];return{stride:Lt,pad:Wt,dataFormat:Gt,dilations:Jt,biasArg:Ar,preluArg:Zt,activationFunc:be}}var ya=function(S,x,k){switch(S.op){case"Conv1D":{var K=w("stride",S,x,k),Se=w("pad",S,x,k),be=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,be,Je)]}case"Conv2D":{var K=w("strides",S,x,k),Se=Kt(S,x,k),be=w("dataFormat",S,x,k).toUpperCase(),Pe=w("dilations",S,x,k);return[i.conv2d(w("x",S,x,k),w("filter",S,x,k),[K[1],K[2]],Se,be,[Pe[1],Pe[2]])]}case"_FusedConv2D":{var gt=Di(S,x,k),K=gt.stride,Se=gt.pad,be=gt.dataFormat,Pe=gt.dilations,ft=gt.biasArg,Lt=gt.preluArg,Wt=gt.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:be,dilations:[Pe[1],Pe[2]],bias:ft,activation:Wt,preluActivationWeights:Lt})]}case"FusedDepthwiseConv2dNative":{var Gt=Di(S,x,k),K=Gt.stride,Se=Gt.pad,be=Gt.dataFormat,Pe=Gt.dilations,ft=Gt.biasArg,Lt=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:be,dilations:[Pe[1],Pe[2]],bias:ft,activation:Wt,preluActivationWeights:Lt})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{var Jt=w("outputShape",S,x,k),K=w("strides",S,x,k),Se=Kt(S,x,k);return[i.conv2dTranspose(w("x",S,x,k),w("filter",S,x,k),Jt,[K[1],K[2]],Se)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{var K=w("strides",S,x,k),Se=Kt(S,x,k),Pe=w("dilations",S,x,k),be=w("dataFormat",S,x,k).toUpperCase();return[i.depthwiseConv2d(w("input",S,x,k),w("filter",S,x,k),[K[1],K[2]],Se,be,[Pe[1],Pe[2]])]}case"Conv3D":{var K=w("strides",S,x,k),Se=w("pad",S,x,k),be=w("dataFormat",S,x,k).toUpperCase(),Pe=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,be,[Pe[1],Pe[2],Pe[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),Zt=i.maxPoolWithArgmax(w("x",S,x,k),[wr[1],wr[2]],[K[1],K[2]],Se,Ar),xr=Zt.result,kn=Zt.indexes;return[xr,kn]}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),Pe=w("dilations",S,x,k),zn=pn[1],Dr=pn[2],Na=Pe[1],Sn=Pe[2];return[i.dilation2d(w("x",S,x,k),w("filter",S,x,k),[zn,Dr],Se,[Na,Sn],"NHWC")]}default:throw TypeError("Node type "+S.op+" is not implemented")}},Oi=function(S,x,k){switch(S.op){case"Fill":{var K=w("shape",S,x,k),Se=w("dtype",S,x,k),be=w("value",S,x,k);return[i.fill(K,be,Se)]}case"LinSpace":{var Je=w("start",S,x,k),Pe=w("stop",S,x,k),gt=w("num",S,x,k);return[i.linspace(Je,Pe,gt)]}case"Multinomial":{var ft=w("logits",S,x,k),Lt=w("numSamples",S,x,k),Wt=w("seed",S,x,k);return[i.multinomial(ft,Lt,Wt)]}case"OneHot":{var Gt=w("indices",S,x,k),Jt=w("depth",S,x,k),wr=w("onValue",S,x,k),Ar=w("offValue",S,x,k);return[i.oneHot(Gt,Jt,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),Zt=w("stop",S,x,k),xr=w("step",S,x,k);return[i.range(Je,Zt,xr,w("dtype",S,x,k))]}case"TruncatedNormal":{var K=w("shape",S,x,k),kn=w("mean",S,x,k),pn=w("stdDev",S,x,k),Wt=w("seed",S,x,k);return[i.truncatedNormal(K,kn,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 Y(S,x,k){var K=w("boxes",S,x,k),Se=w("scores",S,x,k),be=w("maxOutputSize",S,x,k),Je=w("iouThreshold",S,x,k),Pe=w("scoreThreshold",S,x,k),gt=w("softNmsSigma",S,x,k);return{boxes:K,scores:Se,maxOutputSize:be,iouThreshold:Je,scoreThreshold:Pe,softNmsSigma:gt}}var j=function(S,x,k){return M(pe,void 0,void 0,function(){var K,Se,be,Je,Pe,gt,ft,Lt,Wt,Gt,be,Je,Pe,gt,ft,Jt,Wt,wr,be,Je,Pe,gt,ft,Ar,Wt;return V(this,function(Zt){switch(Zt.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=Y(S,x,k),be=Se.boxes,Je=Se.scores,Pe=Se.maxOutputSize,gt=Se.iouThreshold,ft=Se.scoreThreshold,Lt=Se.softNmsSigma,[4,i.image.nonMaxSuppressionWithScoreAsync(be,Je,Pe,gt,ft,Lt)];case 2:return Wt=Zt.sent(),[2,[Wt.selectedIndices,Wt.selectedScores]];case 3:return Gt=Y(S,x,k),be=Gt.boxes,Je=Gt.scores,Pe=Gt.maxOutputSize,gt=Gt.iouThreshold,ft=Gt.scoreThreshold,Jt=w("padToMaxOutputSize",S,x,k),[4,i.image.nonMaxSuppressionPaddedAsync(be,Je,Pe,gt,ft,Jt)];case 4:return Wt=Zt.sent(),[2,[Wt.selectedIndices,Wt.validOutputs]];case 5:return wr=Y(S,x,k),be=wr.boxes,Je=wr.scores,Pe=wr.maxOutputSize,gt=wr.iouThreshold,ft=wr.scoreThreshold,[4,i.image.nonMaxSuppressionAsync(be,Je,Pe,gt,ft)];case 6:return[2,[Zt.sent()]];case 7:return Ar=i.cast(w("condition",S,x,k),"bool"),[4,i.whereAsync(Ar)];case 8:return Wt=[Zt.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")}})})},ne=function(S,x,k){switch(S.op){case"TopKV2":{var K=w("x",S,x,k),Se=w("k",S,x,k),be=w("sorted",S,x,k),Je=i.topk(K,Se,be);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),Pe=w("axis",S,x,k),Je=i.unique(K,Pe);return[Je.values,Je.indices]}default:throw TypeError("Node type "+S.op+" is not implemented")}},re=function(S,x,k){switch(S.op){case"Const":return x[S.name];case"PlaceholderWithDefault":var K=w("default",S,x,k);return[xe(S.name,x,k)||K];case"Placeholder":return[xe(S.name,x,k)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{var Se=w("x",S,x,k);return[It(Se)]}case"IdentityN":return w("x",S,x,k).map(function(Wt){return It(Wt)});case"Snapshot":var be=w("x",S,x,k);return[It(be)];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),Pe=w("data",S,x,k),gt=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(gt);for(var Lt=0;Lt<Pe.length;Lt++)console.log(Array.prototype.slice.call(Pe[Lt].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 M(this,void 0,void 0,function(){var K,Se=this;return V(this,function(be){switch(be.label){case 0:return this.checkKeyAndValueTensor(x,k),[4,x.data()];case 1:return K=be.sent(),this.tensorMap.forEach(function(Je){return Je.dispose()}),this.tensorMap.clear(),[2,i.tidy(function(){var Je=i.unstack(k),Pe=K.length,gt=Je.length;i.util.assert(Pe===gt,function(){return"The number of elements doesn't match, keys has "+(Pe+" elements, the values has "+gt+" ")+"elements."});for(var ft=0;ft<Pe;ft++){var Lt=K[ft],Wt=Je[ft];i.keep(Wt),Se.tensorMap.set(Lt,Wt)}return Se.handle})]}})})},S.prototype.find=function(x,k){return M(this,void 0,void 0,function(){var K,Se=this;return V(this,function(be){switch(be.label){case 0:return this.checkKeyAndValueTensor(x,k),[4,x.data()];case 1:return K=be.sent(),[2,i.tidy(function(){for(var Je=[],Pe=0;Pe<K.length;Pe++){var gt=K[Pe],ft=Se.findWithDefault(gt,k);Je.push(ft)}return i.stack(Je)})]}})})},S.prototype.findWithDefault=function(x,k){var K=this.tensorMap.get(x);return K!=null?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,tt=function(S,x,k,K){return M(kt,void 0,void 0,function(){var Se,be,Je,Pe,gt,ft,Lt,Pe,gt,ft,Wt,Pe;return V(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 be=w("keyDType",S,x,k),Je=w("valueDType",S,x,k),Pe=new Ue(be,Je),K.addHashTable(S.name,Pe),[2,[Pe.handle]];case 2:return gt=w("tableHandle",S,x,k,K),ft=w("keys",S,x,k),Lt=w("values",S,x,k),Pe=K.getHashTableById(gt.id),[4,Pe.import(ft,Lt)];case 3:return[2,[Gt.sent()]];case 4:return gt=w("tableHandle",S,x,k,K),ft=w("keys",S,x,k),Wt=w("defaultValue",S,x,k),Pe=K.getHashTableById(gt.id),[4,Pe.find(ft,Wt)];case 5:return[2,[Gt.sent()]];case 6:throw TypeError("Node type "+S.op+" is not implemented")}})})},ze=function(S,x,k){switch(S.op){case"ResizeBilinear":{var K=w("images",S,x,k),Se=w("size",S,x,k),be=w("alignCorners",S,x,k);return[i.image.resizeBilinear(K,[Se[0],Se[1]],be)]}case"ResizeNearestNeighbor":{var K=w("images",S,x,k),Se=w("size",S,x,k),be=w("alignCorners",S,x,k);return[i.image.resizeNearestNeighbor(K,[Se[0],Se[1]],be)]}case"CropAndResize":{var Je=w("image",S,x,k),Pe=w("boxes",S,x,k),gt=w("boxInd",S,x,k),ft=w("cropSize",S,x,k),Lt=w("method",S,x,k),Wt=w("extrapolationValue",S,x,k);return[i.image.cropAndResize(Je,Pe,gt,ft,Lt,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")}},Dt=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=oe(w("fusedOps",S,x,k),2),Se=K[0],be=K[1],Je=Se==="biasadd",Pe=be==="prelu",gt=w("numArgs",S,x,k);if(Je){if(Pe&&gt!==2)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!Pe&&gt!==1)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}var ft=oe(w("args",S,x,k),2),Lt=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:Lt,activation:be,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),be=w("exclusive",S,x,k),Je=w("reverse",S,x,k);return[i.cumsum(w("x",S,x,k),K,be,Je)]}default:throw TypeError("Node type "+S.op+" is not implemented")}},fr=function(S,x,k){switch(S.op){case"ConcatV2":case"Concat":{var K=w("n",S,x,k),Se=w("axis",S,x,k),be=w("tensors",S,x,k);return be=be.slice(0,K),[i.concat(be,Se)]}case"GatherV2":case"Gather":{var Se=w("axis",S,x,k),Je=w("x",S,x,k),Pe=w("indices",S,x,k);return[i.gather(Je,i.cast(Pe,"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 gt=w("begin",S,x,k),ft=w("size",S,x,k);return[i.slice(w("x",S,x,k),gt,ft)]}case"StridedSlice":{var gt=w("begin",S,x,k),Lt=w("end",S,x,k),Wt=w("strides",S,x,k),Gt=w("beginMask",S,x,k),Jt=w("endMask",S,x,k),wr=w("ellipsisMask",S,x,k),Ar=w("newAxisMask",S,x,k),Zt=w("shrinkAxisMask",S,x,k),xr=w("x",S,x,k);return[i.stridedSlice(xr,gt,Lt,Wt,Gt,Jt,wr,Ar,Zt)]}case"Pack":return i.tidy(function(){var $r=w("axis",S,x,k),Fa=w("tensors",S,x,k),mi=Fa[0].shape,Ka=i.squeeze(Fa[0]).shape,Xa=Fa.map(function(ii){var zi=i.util.arraysEqual(ii.shape,mi);if(!zi&&!i.util.arraysEqual(i.squeeze(ii).shape,Ka))throw new Error("the input tensors shape does not match");return zi?ii:i.reshape(ii,mi)});return[i.stack(Xa,$r)]});case"Unpack":{var Se=w("axis",S,x,k),xr=w("tensor",S,x,k);return i.unstack(xr,Se)}case"Tile":{var kn=w("reps",S,x,k);return[i.tile(w("x",S,x,k),kn)]}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 Pe=w("indices",S,x,k),zn=w("values",S,x,k),Dr=w("shape",S,x,k);return[i.scatterND(Pe,zn,Dr)]}case"GatherNd":{var Na=w("x",S,x,k),Pe=w("indices",S,x,k);return[i.gatherND(Na,Pe)]}case"SparseToDense":{var Pe=w("sparseIndices",S,x,k),Dr=w("outputShape",S,x,k),Sn=w("sparseValues",S,x,k),cr=w("defaultValue",S,x,k);return[i.sparseToDense(Pe,Sn,Dr,Sn.dtype===cr.dtype?cr:i.cast(cr,Sn.dtype))]}default:throw TypeError("Node type "+S.op+" is not implemented")}},or=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")}},aa=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),be=w("paddings",S,x,k);return[i.spaceToBatchND(w("x",S,x,k),Se,be)]}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 Pe=w("blockSize",S,x,k),gt=w("dataFormat",S,x,k).toUpperCase();return[i.depthToSpace(w("x",S,x,k),Pe,gt)]}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 va(S,x,k,K){var Se=function(be,Je,Pe){switch(be.category){case"arithmetic":return i.tidy(function(){return fi(be,Je,Pe)});case"basic_math":return i.tidy(function(){return ja(be,Je,Pe)});case"control":return qi(be,Je,Pe);case"convolution":return i.tidy(function(){return ya(be,Je,Pe)});case"creation":return i.tidy(function(){return Oi(be,Je,Pe)});case"dynamic":return j(be,Je,Pe);case"evaluation":return i.tidy(function(){return ne(be,Je,Pe)});case"image":return i.tidy(function(){return ze(be,Je,Pe)});case"graph":return i.tidy(function(){return re(be,Je,Pe)});case"logical":return i.tidy(function(){return Ye(be,Je,Pe)});case"matrices":return i.tidy(function(){return Dt(be,Je,Pe)});case"normalization":return i.tidy(function(){return St(be,Je,Pe)});case"reduction":return i.tidy(function(){return Mt(be,Je,Pe)});case"slice_join":return i.tidy(function(){return fr(be,Je,Pe)});case"spectral":return i.tidy(function(){return or(be,Je,Pe)});case"transformation":return i.tidy(function(){return aa(be,Je,Pe)});case"hash_table":return tt(be,Je,Pe,K);case"custom":var gt=ye(be.op);if(gt&&gt.customExecutor)return gt.customExecutor(new di(be,Je,Pe));throw TypeError("Custom op "+be.op+" is not registered.");default:throw TypeError("Unknown op '"+be.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(be){return[].concat(be)}):[].concat(Se)}var ia=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 qa(S,x,k,K){var Se=new Set,be=[],Je=null,Pe=null,gt=new Set,ft=Object.keys(S).map(function(Jt){return ut(Jt)[0]}),Lt=[];K!=null&&(Lt=K.map(function(Jt){return ut(Jt.name)[0]}));for(var Wt=de(x);Wt.length>0;){var Gt=Wt.pop();if((Jr(Gt)||Vr(Gt)||Jn(Gt))&&Je==null&&(Je=Gt,Pe=Je.children.map(function(Jt){return Jt.name}).filter(function(Jt){return Se.has(Jt)})),Se.add(Gt.name),k[Gt.name]!=null)continue;if(ft.indexOf(Gt.name)!==-1)continue;if(Lt.indexOf(Gt.name)!==-1)continue;if(Gt.inputs.length===0){be.push(Gt.name);continue}Gt.inputs.forEach(function(Jt){if(gt.has(Jt.name))return;gt.add(Jt.name),Wt.push(Jt)})}return{inputs:S,outputs:x,usedNodes:Se,missingInputs:be,dynamicNode:Je,syncInputs:Pe}}function bi(S,x,k){var K=k.usedNodes,Se=k.inputs,be=[],Je=Object.keys(Se).map(function(Wt){return ut(Wt)[0]}).map(function(Wt){return S.nodes[Wt]}),Pe=S.initNodes;Je.forEach(function(Wt){K.has(Wt.name)&&be.push(Wt)}),S.weights.forEach(function(Wt){K.has(Wt.name)&&be.push(Wt)}),Pe!=null&&Pe.forEach(function(Wt){K.has(Wt.name)&&be.push(Wt)});for(var gt=new Set,ft=[];be.length>0;){var Lt=be.pop();gt.add(Lt.name),x[Lt.name]||ft.push(Lt),Lt.children.forEach(function(Wt){!gt.has(Wt.name)&&K.has(Wt.name)&&Wt.inputs.every(function(Gt){return gt.has(Gt.name)})&&be.push(Wt)})}return ft}var rn=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],hn=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],oa=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2"];function Jr(S){return rn.indexOf(S.op)>=0}function Vr(S){return hn.indexOf(S.op)>=0}function Jn(S){return oa.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([],de(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(be){return be.name}).sort(),Se=k.map(function(be){return be.name}).sort();return K.join(this.SEPERATOR)+"--"+Se.join(this.SEPERATOR)},S.prototype.compile=function(x,k){var K=qa(x,k,this.weightMap,this._initNodes),Se=K.missingInputs,be=K.dynamicNode,Je=K.syncInputs;if(be!=null)throw new Error("This execution contains the node '"+be.name+"', which has "+("the dynamic op '"+be.op+"'. Please use ")+"model.executeAsync() instead. Alternatively, to avoid the "+("dynamic ops, specify the inputs ["+Je+"]"));if(Se.length>0){var Pe=k.map(function(ft){return ft.name}),gt=Object.keys(x);throw new Error("Cannot compute the outputs ["+Pe+"] from the provided inputs "+("["+gt+"]. Missing the following inputs: ["+Se+"]"))}return bi(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 be=Se.map(function(Gt){return K.graph.nodes[ut(Gt)[0]]}),Je=k.map(function(Gt){return ut(Gt)[0]}),Pe=Je.map(function(Gt){return K.graph.nodes[Gt]});Pe.length===0&&(Pe=this._outputs);var gt=this.getCompilationKey(be,Pe),ft=this.compiledMap.get(gt);ft==null&&(ft=this.compile(x,Pe),this.compiledMap.set(gt,ft));var Lt={},Wt={};return i.tidy(function(){var Gt=new ia(K.weightMap,Lt,Wt,K.functionExecutorMap),Jt=we({},K.weightMap);Object.keys(x).forEach(function(pn){var zn=oe(ut(pn),2),Dr=zn[0],Na=zn[1],Sn=[];Sn[Na]=x[pn],Jt[Dr]=Sn});for(var wr=K.getFrozenTensorIds(Jt),Ar={},Zt=0;Zt<ft.length;Zt++){var xr=ft[Zt];if(!Jt[xr.name]){var kn=va(xr,Jt,Gt,K._resourceManager);if(i.util.isPromise(kn))throw new Error("The execution of the op '"+xr.op+"' returned a promise. Please use model.executeAsync() instead.");Jt[xr.name]=kn,K.checkTensorForDisposal(xr.name,xr,Jt,Gt,wr,Je,Ar)}}return K.parent==null&&Gt.dispose(wr),k.map(function(pn){return xe(pn,Jt,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,be,Je,Pe){if(k.category==="control"||Je.indexOf(x)!==-1)return;K[x].forEach(function(gt){gt!=null&&(Pe[gt.id]=(Pe[gt.id]||0)+k.children.length)}),k.inputs.forEach(function(gt){if(gt.category!=="control"){var ft=We(gt.name,K,Se);ft!=null&&ft.forEach(function(Lt){if(Lt&&!be.has(Lt.id)){var Wt=Pe[Lt.id];Wt===1?(Lt.dispose(),delete Pe[Lt.id]):Wt!=null&&Pe[Lt.id]--}})}})},S.prototype.executeAsync=function(x,k){return M(this,void 0,void 0,function(){return V(this,function(K){return[2,this._executeAsync(x,k)]})})},S.prototype._executeAsync=function(x,k,K,Se,be){return K===void 0&&(K=!1),Se===void 0&&(Se={}),be===void 0&&(be={}),M(this,void 0,void 0,function(){var Je,Pe,gt,ft,Lt,Wt;return V(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 ia(this.weightMap,Se,be,this.functionExecutorMap),[4,this.executeWithControlFlow(x,Je,k,K)];case 1:return Pe=Gt.sent(),gt=k.map(function(Jt){return xe(Jt,Pe,Je)}),ft=gt.map(function(Jt){return Jt.id}),Lt=Object.keys(x).map(function(Jt){return x[Jt].id}),Wt=new Set(de(ft,Lt,this.weightIds)),Object.keys(Pe).forEach(function(Jt){var wr=Pe[Jt];wr.forEach(function(Ar){Ar&&!Ar.isDisposed&&!Wt.has(Ar.id)&&Ar.dispose()})}),this.parent==null&&Je.dispose(Wt),[2,gt]}})})},S.prototype.executeFunctionAsync=function(x,k,K){return M(this,void 0,void 0,function(){var Se,be=this;return V(this,function(Je){return Se=x.reduce(function(Pe,gt,ft){return Pe[be.inputs[ft].name]=gt,Pe},{}),[2,this._executeAsync(Se,this.outputNodes,!0,k,K)]})})},S.prototype.executeWithControlFlow=function(x,k,K,Se){return M(this,void 0,void 0,function(){var be,Je,Pe,gt,ft,Lt,Wt,Gt,Jt,wr,Ar,Zt,xr,kn,pn,zn,Dr,Na=this;return V(this,function(Sn){switch(Sn.label){case 0:be=Object.keys(x),Je=be.map(function(cr){return Na.graph.nodes[ut(cr)[0]]}),Pe=K.map(function(cr){return ut(cr)[0]}),gt=Pe.map(function(cr){return Na.graph.nodes[cr]}),gt.length===0&&(gt=this._outputs),ft=qa(x,gt,this.weightMap,this._initNodes),Lt=ft.usedNodes,Wt=ft.missingInputs,Gt=ft.dynamicNode,Jt=ft.syncInputs,wr=de(Je,this.graph.weights,this._initNodes||[]).map(function(cr){return{node:cr,contexts:k.currentContext}}),Ar=we({},this.weightMap),Object.keys(x).forEach(function(cr){var $r=oe(ut(cr),2),Fa=$r[0],mi=$r[1],Ka=[];Ka[mi]=x[cr],Ar[Fa]=Ka}),Zt={},xr=this.getFrozenTensorIds(Ar),kn={},Sn.label=1;case 1:return wr.length>0?(pn=this.processStack(Je,wr,k,Ar,kn,xr,Pe,Zt,Lt),[4,Promise.all(pn)]):[3,3];case 2:return Sn.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=gt.filter(function(cr){return!Jr(cr)&&!xe(cr.name,Ar,k)}).map(function(cr){return cr.name}),zn.length>0)throw Dr="",Gt!=null&&(Dr="Alternatively, to avoid the dynamic ops, use model.execute() "+("and specify the inputs ["+Jt+"]")),new Error("Cannot compute the outputs ["+zn+"] from the provided "+("inputs ["+be+"]. Consider providing the following inputs: ")+("["+Wt+"]. "+Dr));return[2,Ar]}})})},S.prototype.processStack=function(x,k,K,Se,be,Je,Pe,gt,ft){for(var Lt=this,Wt=[],Gt=function(){var wr,Ar,Zt=k.pop();K.currentContext=Zt.contexts;var xr="";if(Zt.node.op==="Enter"&&w("isConstant",Zt.node,Se,K)&&(wr=oe(W(Zt.node.name,K),1),xr=wr[0]),Se[Zt.node.name]==null){var kn=va(Zt.node,Se,K,Jt._resourceManager);xr||(Ar=oe(W(Zt.node.name,K),1),xr=Ar[0]);var pn=K.currentContext;i.util.isPromise(kn)?Wt.push(kn.then(function(zn){return Se[xr]=zn,K.currentContext=pn,Lt.checkTensorForDisposal(xr,Zt.node,Se,K,Je,Pe,gt),Lt.processChildNodes(Zt.node,k,K,Se,be,ft),zn})):(Se[xr]=kn,Jt.checkTensorForDisposal(xr,Zt.node,Se,K,Je,Pe,gt),Jt.processChildNodes(Zt.node,k,K,Se,be,ft))}else Jt.processChildNodes(Zt.node,k,K,Se,be,ft)},Jt=this;k.length>0;)Gt();return Wt},S.prototype.processChildNodes=function(x,k,K,Se,be,Je){x.children.forEach(function(Pe){var gt=oe(W(Pe.name,K),1),ft=gt[0];if(be[ft]||!Je.has(Pe.name))return;Pe.op==="Merge"?Pe.inputNames.some(function(Lt){return!!xe(Lt,Se,K)})&&(be[ft]=!0,k.push({contexts:K.currentContext,node:Pe})):Pe.inputNames.every(function(Lt){return!!xe(Lt,Se,K)})&&(be[ft]=!0,k.push({contexts:K.currentContext,node:Pe}))})},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],be=oe(ut(K),1),Je=be[0],Pe=k.graph.nodes[Je];if(Pe.attrParams.shape&&Pe.attrParams.shape.value){var gt=Pe.attrParams.shape.value,ft=gt.length===Se.shape.length&&Se.shape.every(function(Lt,Wt){return gt[Wt]===-1||gt[Wt]===Lt});i.util.assert(ft,function(){return"The shape of dict['"+Pe.name+"'] provided in "+("model.execute(dict) must be ["+gt+"], but was ")+("["+Se.shape+"]")})}Pe.attrParams.dtype&&Pe.attrParams.dtype.value&&i.util.assert(Se.dtype===Pe.attrParams.dtype.value,function(){return"The dtype of dict['"+Pe.name+"'] provided in model.execute(dict) must be "+(Pe.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 be=oe(ut(Se),1),Je=be[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=oe(ut(K),1),be=Se[0];if(!k.graph.nodes[be])throw new Error("The output '"+K+"' is not found in the graph")})},S}(),En=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}(),qn="?tfjs-format=file",sa="model.json",ga=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 En}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 M(this,void 0,void 0,function(){var x;return V(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(Sa.Instance.transformGraph(k,K)),this.executor.weightMap=this.convertTensorMapToTensorsMap(Se),this.executor.resourceManager=this.resourceManager,x.modelInitializer!=null){var be=Sa.Instance.transformGraph(x.modelInitializer);this.initializer=new tn(be),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0},S.prototype.save=function(x,k){return M(this,void 0,void 0,function(){var K;return V(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 M(this,void 0,void 0,function(){var K;return V(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 Mi(S,x){return x===void 0&&(x={}),M(this,void 0,void 0,function(){var k;return V(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+sa+qn),k=new ga(S,x),[4,k.load()];case 1:return K.sent(),[2,k]}})})}var Aa="2.7.0";N.GraphModel=ga,N.deregisterOp=ee,N.loadGraphModel=Mi,N.registerOp=he,N.version_converter=Aa}),og=Or(()=>{}),sg=Or(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),we=function(pe,Y){return we=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,ne){j.__proto__=ne}||function(j,ne){for(var re in ne)ne.hasOwnProperty(re)&&(j[re]=ne[re])},we(pe,Y)};function M(pe,Y){we(pe,Y);function j(){this.constructor=pe}pe.prototype=Y===null?Object.create(Y):(j.prototype=Y.prototype,new j)}function V(pe,Y,j,ne){return new(j||(j=Promise))(function(re,Ue){function kt(Ye){try{ze(ne.next(Ye))}catch(Dt){Ue(Dt)}}function tt(Ye){try{ze(ne.throw(Ye))}catch(Dt){Ue(Dt)}}function ze(Ye){Ye.done?re(Ye.value):new j(function(Dt){Dt(Ye.value)}).then(kt,tt)}ze((ne=ne.apply(pe,Y||[])).next())})}function oe(pe,Y){var j={label:0,sent:function(){if(Ue[0]&1)throw Ue[1];return Ue[1]},trys:[],ops:[]},ne,re,Ue,kt;return kt={next:tt(0),throw:tt(1),return:tt(2)},typeof Symbol=="function"&&(kt[Symbol.iterator]=function(){return this}),kt;function tt(Ye){return function(Dt){return ze([Ye,Dt])}}function ze(Ye){if(ne)throw new TypeError("Generator is already executing.");for(;j;)try{if(ne=1,re&&(Ue=Ye[0]&2?re.return:Ye[0]?re.throw||((Ue=re.return)&&Ue.call(re),0):re.next)&&!(Ue=Ue.call(re,Ye[1])).done)return Ue;(re=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++,re=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=Y.call(pe,j)}catch(Dt){Ye=[6,Dt],re=0}finally{ne=Ue=0}if(Ye[0]&5)throw Ye[1];return{value:Ye[0]?Ye[1]:void 0,done:!0}}}var de=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function X(pe,Y){return Y={exports:{}},pe(Y,Y.exports),Y.exports}var Te=X(function(pe){(function(Y,j,ne){function re(ze){var Ye=this,Dt=tt();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=Dt(" "),Ye.s1=Dt(" "),Ye.s2=Dt(" "),Ye.s0-=Dt(ze),Ye.s0<0&&(Ye.s0+=1),Ye.s1-=Dt(ze),Ye.s1<0&&(Ye.s1+=1),Ye.s2-=Dt(ze),Ye.s2<0&&(Ye.s2+=1),Dt=null}function Ue(ze,Ye){return Ye.c=ze.c,Ye.s0=ze.s0,Ye.s1=ze.s1,Ye.s2=ze.s2,Ye}function kt(ze,Ye){var Dt=new re(ze),St=Ye&&Ye.state,Mt=Dt.next;return Mt.int32=function(){return Dt.next()*4294967296|0},Mt.double=function(){return Mt()+(Mt()*2097152|0)*11102230246251565e-32},Mt.quick=Mt,St&&(typeof St=="object"&&Ue(St,Dt),Mt.state=function(){return Ue(Dt,{})}),Mt}function tt(){var ze=4022871197,Ye=function(Dt){Dt=Dt.toString();for(var St=0;St<Dt.length;St++){ze+=Dt.charCodeAt(St);var Mt=.02519603282416938*ze;ze=Mt>>>0,Mt-=ze,Mt*=ze,ze=Mt>>>0,Mt-=ze,ze+=Mt*4294967296}return(ze>>>0)*23283064365386963e-26};return Ye}j&&j.exports?j.exports=kt:ne&&ne.amd?ne(function(){return kt}):this.alea=kt})(de,pe,!1)}),z=X(function(pe){(function(Y,j,ne){function re(tt){var ze=this,Ye="";ze.x=0,ze.y=0,ze.z=0,ze.w=0,ze.next=function(){var St=ze.x^ze.x<<11;return ze.x=ze.y,ze.y=ze.z,ze.z=ze.w,ze.w^=ze.w>>>19^St^St>>>8},tt===(tt|0)?ze.x=tt:Ye+=tt;for(var Dt=0;Dt<Ye.length+64;Dt++)ze.x^=Ye.charCodeAt(Dt)|0,ze.next()}function Ue(tt,ze){return ze.x=tt.x,ze.y=tt.y,ze.z=tt.z,ze.w=tt.w,ze}function kt(tt,ze){var Ye=new re(tt),Dt=ze&&ze.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,fr=(Ye.next()>>>0)/4294967296,or=(Mt+fr)/(1<<21);while(or===0);return or},St.int32=Ye.next,St.quick=St,Dt&&(typeof Dt=="object"&&Ue(Dt,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:ne&&ne.amd?ne(function(){return kt}):this.xor128=kt})(de,pe,!1)}),he=X(function(pe){(function(Y,j,ne){function re(tt){var ze=this,Ye="";ze.next=function(){var St=ze.x^ze.x>>>2;return ze.x=ze.y,ze.y=ze.z,ze.z=ze.w,ze.w=ze.v,(ze.d=ze.d+362437|0)+(ze.v=ze.v^ze.v<<4^(St^St<<1))|0},ze.x=0,ze.y=0,ze.z=0,ze.w=0,ze.v=0,tt===(tt|0)?ze.x=tt:Ye+=tt;for(var Dt=0;Dt<Ye.length+64;Dt++)ze.x^=Ye.charCodeAt(Dt)|0,Dt==Ye.length&&(ze.d=ze.x<<10^ze.x>>>4),ze.next()}function Ue(tt,ze){return ze.x=tt.x,ze.y=tt.y,ze.z=tt.z,ze.w=tt.w,ze.v=tt.v,ze.d=tt.d,ze}function kt(tt,ze){var Ye=new re(tt),Dt=ze&&ze.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,fr=(Ye.next()>>>0)/4294967296,or=(Mt+fr)/(1<<21);while(or===0);return or},St.int32=Ye.next,St.quick=St,Dt&&(typeof Dt=="object"&&Ue(Dt,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:ne&&ne.amd?ne(function(){return kt}):this.xorwow=kt})(de,pe,!1)}),ye=X(function(pe){(function(Y,j,ne){function re(tt){var ze=this;ze.next=function(){var Dt=ze.x,St=ze.i,Mt,fr;return Mt=Dt[St],Mt^=Mt>>>7,fr=Mt^Mt<<24,Mt=Dt[St+1&7],fr^=Mt^Mt>>>10,Mt=Dt[St+3&7],fr^=Mt^Mt>>>3,Mt=Dt[St+4&7],fr^=Mt^Mt<<7,Mt=Dt[St+7&7],Mt=Mt^Mt<<13,fr^=Mt^Mt<<9,Dt[St]=fr,ze.i=St+1&7,fr};function Ye(Dt,St){var Mt,fr,or=[];if(St===(St|0))fr=or[0]=St;else for(St=""+St,Mt=0;Mt<St.length;++Mt)or[Mt&7]=or[Mt&7]<<15^St.charCodeAt(Mt)+or[Mt+1&7]<<13;for(;or.length<8;)or.push(0);for(Mt=0;Mt<8&&or[Mt]===0;++Mt);for(Mt==8?fr=or[7]=-1:fr=or[Mt],Dt.x=or,Dt.i=0,Mt=256;Mt>0;--Mt)Dt.next()}Ye(ze,tt)}function Ue(tt,ze){return ze.x=tt.x.slice(),ze.i=tt.i,ze}function kt(tt,ze){tt==null&&(tt=+new Date);var Ye=new re(tt),Dt=ze&&ze.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,fr=(Ye.next()>>>0)/4294967296,or=(Mt+fr)/(1<<21);while(or===0);return or},St.int32=Ye.next,St.quick=St,Dt&&(Dt.x&&Ue(Dt,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:ne&&ne.amd?ne(function(){return kt}):this.xorshift7=kt})(de,pe,!1)}),ee=X(function(pe){(function(Y,j,ne){function re(tt){var ze=this;ze.next=function(){var Dt=ze.w,St=ze.X,Mt=ze.i,fr,or;return ze.w=Dt=Dt+1640531527|0,or=St[Mt+34&127],fr=St[Mt=Mt+1&127],or^=or<<13,fr^=fr<<17,or^=or>>>15,fr^=fr>>>12,or=St[Mt]=or^fr,ze.i=Mt,or+(Dt^Dt>>>16)|0};function Ye(Dt,St){var Mt,fr,or,aa,va,ia=[],qa=128;for(St===(St|0)?(fr=St,St=null):(St=St+"\0",fr=0,qa=Math.max(qa,St.length)),or=0,aa=-32;aa<qa;++aa)St&&(fr^=St.charCodeAt((aa+32)%St.length)),aa===0&&(va=fr),fr^=fr<<10,fr^=fr>>>15,fr^=fr<<4,fr^=fr>>>13,aa>=0&&(va=va+1640531527|0,Mt=ia[aa&127]^=fr+va,or=Mt==0?or+1:0);for(or>=128&&(ia[(St&&St.length||0)&127]=-1),or=127,aa=4*128;aa>0;--aa)fr=ia[or+34&127],Mt=ia[or=or+1&127],fr^=fr<<13,Mt^=Mt<<17,fr^=fr>>>15,Mt^=Mt>>>12,ia[or]=fr^Mt;Dt.w=va,Dt.X=ia,Dt.i=or}Ye(ze,tt)}function Ue(tt,ze){return ze.i=tt.i,ze.w=tt.w,ze.X=tt.X.slice(),ze}function kt(tt,ze){tt==null&&(tt=+new Date);var Ye=new re(tt),Dt=ze&&ze.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,fr=(Ye.next()>>>0)/4294967296,or=(Mt+fr)/(1<<21);while(or===0);return or},St.int32=Ye.next,St.quick=St,Dt&&(Dt.X&&Ue(Dt,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:ne&&ne.amd?ne(function(){return kt}):this.xor4096=kt})(de,pe,!1)}),w=X(function(pe){(function(Y,j,ne){function re(tt){var ze=this,Ye="";ze.next=function(){var St=ze.b,Mt=ze.c,fr=ze.d,or=ze.a;return St=St<<25^St>>>7^Mt,Mt=Mt-fr|0,fr=fr<<24^fr>>>8^or,or=or-St|0,ze.b=St=St<<20^St>>>12^Mt,ze.c=Mt=Mt-fr|0,ze.d=fr<<16^Mt>>>16^or,ze.a=or-St|0},ze.a=0,ze.b=0,ze.c=2654435769|0,ze.d=1367130551,tt===Math.floor(tt)?(ze.a=tt/4294967296|0,ze.b=tt|0):Ye+=tt;for(var Dt=0;Dt<Ye.length+20;Dt++)ze.b^=Ye.charCodeAt(Dt)|0,ze.next()}function Ue(tt,ze){return ze.a=tt.a,ze.b=tt.b,ze.c=tt.c,ze.d=tt.d,ze}function kt(tt,ze){var Ye=new re(tt),Dt=ze&&ze.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,fr=(Ye.next()>>>0)/4294967296,or=(Mt+fr)/(1<<21);while(or===0);return or},St.int32=Ye.next,St.quick=St,Dt&&(typeof Dt=="object"&&Ue(Dt,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:ne&&ne.amd?ne(function(){return kt}):this.tychei=kt})(de,pe,!1)}),xe=X(function(pe){(function(Y,j){var ne=this,re=256,Ue=6,kt=52,tt="random",ze=j.pow(re,Ue),Ye=j.pow(2,kt),Dt=Ye*2,St=re-1,Mt;function fr(rn,hn,oa){var Jr=[];hn=hn==!0?{entropy:!0}:hn||{};var Vr=ia(va(hn.entropy?[rn,bi(Y)]:rn==null?qa():rn,3),Jr),Jn=new or(Jr),tn=function(){for(var En=Jn.g(Ue),qn=ze,sa=0;En<Ye;)En=(En+sa)*re,qn*=re,sa=Jn.g(1);for(;En>=Dt;)En/=2,qn/=2,sa>>>=1;return(En+sa)/qn};return tn.int32=function(){return Jn.g(4)|0},tn.quick=function(){return Jn.g(4)/4294967296},tn.double=tn,ia(bi(Jn.S),Y),(hn.pass||oa||function(En,qn,sa,ga){return ga&&(ga.S&&aa(ga,Jn),En.state=function(){return aa(Jn,{})}),sa?(j[tt]=En,qn):En})(tn,Vr,"global"in hn?hn.global:this==j,hn.state)}j["seed"+tt]=fr;function or(rn){var hn,oa=rn.length,Jr=this,Vr=0,Jn=Jr.i=Jr.j=0,tn=Jr.S=[];for(oa||(rn=[oa++]);Vr<re;)tn[Vr]=Vr++;for(Vr=0;Vr<re;Vr++)tn[Vr]=tn[Jn=St&Jn+rn[Vr%oa]+(hn=tn[Vr])],tn[Jn]=hn;(Jr.g=function(En){for(var qn,sa=0,ga=Jr.i,Mi=Jr.j,Aa=Jr.S;En--;)qn=Aa[ga=St&ga+1],sa=sa*re+Aa[St&(Aa[ga]=Aa[Mi=St&Mi+qn])+(Aa[Mi]=qn)];return Jr.i=ga,Jr.j=Mi,sa})(re)}function aa(rn,hn){return hn.i=rn.i,hn.j=rn.j,hn.S=rn.S.slice(),hn}function va(rn,hn){var oa=[],Jr=typeof rn,Vr;if(hn&&Jr=="object")for(Vr in rn)try{oa.push(va(rn[Vr],hn-1))}catch(Jn){}return oa.length?oa:Jr=="string"?rn:rn+"\0"}function ia(rn,hn){for(var oa=rn+"",Jr,Vr=0;Vr<oa.length;)hn[St&Vr]=St&(Jr^=hn[St&Vr]*19)+oa.charCodeAt(Vr++);return bi(hn)}function qa(){try{var rn;return Mt&&(rn=Mt.randomBytes)?rn=rn(re):(rn=new Uint8Array(re),(ne.crypto||ne.msCrypto).getRandomValues(rn)),bi(rn)}catch(Jr){var hn=ne.navigator,oa=hn&&hn.plugins;return[+new Date,ne,oa,ne.screen,bi(Y)]}}function bi(rn){return String.fromCharCode.apply(0,rn)}if(ia(j.random(),Y),pe.exports){pe.exports=fr;try{Mt=Bp()}catch(rn){}}})([],Math)});xe.alea=Te,xe.xor128=z,xe.xorwow=he,xe.xorshift7=ye,xe.xor4096=ee,xe.tychei=w;var We=xe,W=We.alea;function st(pe,Y){return ut(pe,Y)}function ut(pe,Y,j,ne){if(j===void 0&&(j=new Map),ne===void 0&&(ne=new Set),pe==null)return null;if(ne.has(pe))throw new Error("Circular references are not supported.");if(j.has(pe))return j.get(pe);var re=Y(pe);if(re.recurse&&re.value!==null)throw new Error("A deep map function may not return both a value and recurse=true.");if(re.recurse)if(yt(pe)){var Ue=Array.isArray(pe)?[]:{};ne.add(pe);for(var kt in pe){var tt=pe[kt],ze=ut(tt,Y,j,ne);Ue[kt]=ze}return ne.delete(pe),Ue}else throw new Error("Can't recurse into non-iterable type: "+pe);else return j.set(pe,re.value),re.value}function Kt(pe,Y){return Y===void 0&&(Y=Ze),It(pe,Y)}function It(pe,Y,j){j===void 0&&(j=new Set);var ne=pe[0];if(j.has(ne))throw new Error("Circular references are not supported.");var re=Y(pe);if(re.recurse&&re.value!==null)throw new Error("A deep zip function may not return both a value and recurse=true.");if(re.recurse)if(yt(ne)){var Ue=Array.isArray(ne)?[]:{};j.add(ne);var kt=function(ze){var Ye=pe.map(function(St){return St[ze]}),Dt=It(Ye,Y,j);Ue[ze]=Dt};for(var tt in ne)kt(tt);return j.delete(ne),Ue}else throw new Error("Can't recurse into non-iterable type: "+ne);else return re.value}function Ze(pe){return pe===null?null:yt(pe[0])?{value:null,recurse:!0}:{value:pe,recurse:!1}}function mt(pe,Y){return V(this,void 0,void 0,function(){var j,ne,re,Ue,kt,tt,ze;return oe(this,function(Ye){switch(Ye.label){case 0:j=new Map,ut(pe,Y,j),ne=0,re=Array.from(j.keys()),Ye.label=1;case 1:return ne<re.length?(Ue=re[ne],kt=j.get(Ue),i.util.isPromise(kt)?[4,kt]:[3,3]):[3,4];case 2:tt=Ye.sent(),j.set(Ue,tt),Ye.label=3;case 3:return ne++,[3,1];case 4:return ze=ut(pe,Y,j),[2,ze]}})})}function yt(pe){return pe!=null&&!ArrayBuffer.isView(pe)&&(Array.isArray(pe)||typeof pe=="object"&&!(pe instanceof i.Tensor))}function $e(pe){return pe==null||ot(pe)||Array.isArray(pe)||typeof pe=="object"&&pe instanceof i.Tensor||i.util.isTypedArray(pe)}function ot(pe){return pe===null||typeof pe!="object"&&typeof pe!="function"}function nt(pe){return st(pe,et)}function et(pe){return pe instanceof i.Tensor?{value:pe.clone(),recurse:!1}:yt(pe)?{value:null,recurse:!0}:{value:pe,recurse:!1}}var Qt=function(){function pe(Y){if(this.capacity=Y,this.begin=0,this.end=0,Y==null)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(Y<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(Y),this.doubledCapacity=2*Y}return pe.prototype.wrap=function(Y){for(;Y<0;)Y+=this.doubledCapacity;return Y%this.doubledCapacity},pe.prototype.get=function(Y){if(Y<0)throw new RangeError("Can't get item at a negative index.");return this.data[Y%this.capacity]},pe.prototype.set=function(Y,j){if(Y<0)throw new RangeError("Can't set item at a negative index.");this.data[Y%this.capacity]=j},pe.prototype.length=function(){var Y=this.end-this.begin;return Y<0&&(Y=this.doubledCapacity+Y),Y},pe.prototype.isFull=function(){return this.length()===this.capacity},pe.prototype.isEmpty=function(){return this.length()===0},pe.prototype.push=function(Y){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,Y),this.end=this.wrap(this.end+1)},pe.prototype.pushAll=function(Y){for(var j=0,ne=Y;j<ne.length;j++){var re=ne[j];this.push(re)}},pe.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var Y=this.get(this.end);return this.set(this.end,void 0),Y},pe.prototype.unshift=function(Y){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,Y)},pe.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var Y=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),Y},pe.prototype.shuffleExcise=function(Y){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var j=this.wrap(this.begin+Y),ne=this.get(j);return this.set(j,this.pop()),ne},pe}(),rr=function(pe){M(Y,pe);function Y(){return pe.call(this,Y.INITIAL_CAPACITY)||this}return Y.prototype.isFull=function(){return!1},Y.prototype.push=function(j){pe.prototype.isFull.call(this)&&this.expand(),pe.prototype.push.call(this,j)},Y.prototype.unshift=function(j){pe.prototype.isFull.call(this)&&this.expand(),pe.prototype.unshift.call(this,j)},Y.prototype.expand=function(){for(var j=this.capacity*2,ne=new Array(j),re=this.length(),Ue=0;Ue<re;Ue++)ne[Ue]=this.get(this.wrap(this.begin+Ue));this.data=ne,this.capacity=j,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=re},Y.INITIAL_CAPACITY=32,Y}(Qt);function jt(pe){return new da(pe)}function jr(pe){return new Ha(pe)}function Pr(pe,Y){return new fn(pe,Y)}function _r(pe,Y){return Y===void 0&&(Y=Gn.FAIL),new _i(pe,Y)}var ar=function(){function pe(){}return pe.prototype.toArray=function(){return V(this,void 0,void 0,function(){var Y,j;return oe(this,function(ne){switch(ne.label){case 0:return Y=[],[4,this.next()];case 1:j=ne.sent(),ne.label=2;case 2:return j.done?[3,4]:(Y.push(j.value),[4,this.next()]);case 3:return j=ne.sent(),[3,2];case 4:return[2,Y]}})})},pe.prototype.toArrayForTest=function(){return V(this,void 0,void 0,function(){var Y,j,ne;return oe(this,function(re){switch(re.label){case 0:return Y=this.prefetch(100),j=[],[4,Y.next()];case 1:ne=re.sent(),re.label=2;case 2:return ne.done?[3,4]:(j.push(ne.value),[4,Y.next()]);case 3:return ne=re.sent(),[3,2];case 4:return[2,j]}})})},pe.prototype.resolveFully=function(){return V(this,void 0,void 0,function(){var Y;return oe(this,function(j){switch(j.label){case 0:return[4,this.next()];case 1:Y=j.sent(),j.label=2;case 2:return Y.done?[3,4]:[4,this.next()];case 3:return Y=j.sent(),[3,2];case 4:return[2]}})})},pe.prototype.resolveWhile=function(Y){return V(this,void 0,void 0,function(){var j,ne;return oe(this,function(re){switch(re.label){case 0:return[4,this.next()];case 1:j=re.sent(),ne=Y(j.value),re.label=2;case 2:return!j.done&&ne?[4,this.next()]:[3,4];case 3:return j=re.sent(),ne=Y(j.value),[3,2];case 4:return[2]}})})},pe.prototype.handleErrors=function(Y){return new Bn(this,Y)},pe.prototype.filter=function(Y){return new Ma(this,Y)},pe.prototype.map=function(Y){return new Ti(this,Y)},pe.prototype.mapAsync=function(Y){return new ra(this,Y)},pe.prototype.serialMapAsync=function(Y){return new ra(this,Y).serial()},pe.prototype.flatmap=function(Y){return new za(this,Y)},pe.prototype.forEachAsync=function(Y){return V(this,void 0,void 0,function(){return oe(this,function(j){return[2,this.map(Y).resolveFully()]})})},pe.prototype.serialForEach=function(Y){return V(this,void 0,void 0,function(){return oe(this,function(j){return[2,this.serialMapAsync(Y).resolveWhile(function(ne){return ne===!0})]})})},pe.prototype.rowMajorBatch=function(Y,j){return j===void 0&&(j=!0),new ta(this,Y,j)},pe.prototype.columnMajorBatch=function(Y,j,ne){j===void 0&&(j=!0),ne===void 0&&(ne=Ze);var re=this.rowMajorBatch(Y,j);return re.map(function(Ue){return Kt(Ue,ne)})},pe.prototype.concatenate=function(Y,j){return new fn(jt([this,Y]),j)},pe.prototype.take=function(Y){return Y<0||Y==null?this:new ka(this,Y)},pe.prototype.skip=function(Y){return Y<0||Y==null?this:new ba(this,Y)},pe.prototype.prefetch=function(Y){return new fa(this,Y)},pe.prototype.shuffle=function(Y,j){return new Hi(this,Y,j)},pe.prototype.serial=function(){return new Tn(this)},pe}(),da=function(pe){M(Y,pe);function Y(j){var ne=pe.call(this)||this;return ne.items=j,ne.trav=0,ne}return Y.prototype.summary=function(){return"Array of "+this.items.length+" items"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j;return oe(this,function(ne){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(j=this.items[this.trav],this.trav++,[2,{value:nt(j),done:!1}])})})},Y}(ar),Ha=function(pe){M(Y,pe);function Y(j){var ne=pe.call(this)||this;return ne.nextFn=j,ne}return Y.prototype.summary=function(){return"Function call"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){try{return[2,this.nextFn()]}catch(ne){throw ne.message="Error thrown while iterating through a dataset: "+ne.message,ne}return[2]})})},Y}(ar),Tn=function(pe){M(Y,pe);function Y(j){var ne=pe.call(this)||this;return ne.upstream=j,ne.lastRead=Promise.resolve({value:null,done:!1}),ne}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j=this;return oe(this,function(ne){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},Y.prototype.serialNext=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){return[2,this.upstream.next()]})})},Y}(ar),ba=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.maxCount=ne,re.count=0,re.lastRead=Promise.resolve({value:null,done:!1}),re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j=this;return oe(this,function(ne){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},Y.prototype.serialNext=function(){return V(this,void 0,void 0,function(){var j;return oe(this,function(ne){switch(ne.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return j=ne.sent(),j.done?[2,j]:(i.dispose(j.value),[3,0]);case 2:return[2,this.upstream.next()]}})})},Y}(ar),ka=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.maxCount=ne,re.count=0,re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Take"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},Y}(ar),ta=function(pe){M(Y,pe);function Y(j,ne,re){re===void 0&&(re=!0);var Ue=pe.call(this)||this;return Ue.upstream=j,Ue.batchSize=ne,Ue.enableSmallLastBatch=re,Ue.lastRead=Promise.resolve({value:null,done:!1}),Ue}return Y.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j=this;return oe(this,function(ne){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},Y.prototype.serialNext=function(){return V(this,void 0,void 0,function(){var j,ne;return oe(this,function(re){switch(re.label){case 0:j=[],re.label=1;case 1:return j.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return ne=re.sent(),ne.done?this.enableSmallLastBatch&&j.length>0?[2,{value:j,done:!1}]:[2,{value:null,done:!0}]:(j.push(ne.value),[3,1]);case 3:return[2,{value:j,done:!1}]}})})},Y}(ar),Ma=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.predicate=ne,re.lastRead=Promise.resolve({value:null,done:!1}),re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j=this;return oe(this,function(ne){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},Y.prototype.serialNext=function(){return V(this,void 0,void 0,function(){var j;return oe(this,function(ne){switch(ne.label){case 0:return[4,this.upstream.next()];case 1:return j=ne.sent(),j.done||this.predicate(j.value)?[2,j]:(i.dispose(j.value),[3,0]);case 2:return[2]}})})},Y}(ar),Ti=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.transform=ne,re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Map"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue,kt,tt,ze;return oe(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(ne=i.tensor_util.getTensorsInContainer(j.value),re=this.transform(j.value),Ue=i.tensor_util.getTensorsInContainer(re),kt=0,tt=ne;kt<tt.length;kt++)ze=tt[kt],i.tensor_util.isTensorInList(ze,Ue)||ze.dispose();return[2,{value:re,done:!1}]}})})},Y}(ar),Bn=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.handler=ne,re.count=0,re.lastRead=Promise.resolve({value:null,done:!1}),re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j=this;return oe(this,function(ne){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},Y.prototype.serialNext=function(){return V(this,void 0,void 0,function(){var j;return oe(this,function(ne){switch(ne.label){case 0:ne.label=1;case 1:return ne.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,ne.sent()];case 3:return j=ne.sent(),this.handler(j)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},Y}(ar),ra=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.transform=ne,re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue,kt,tt,ze;return oe(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}]:(ne=i.tensor_util.getTensorsInContainer(j.value),[4,this.transform(j.value)]);case 2:for(re=Ye.sent(),Ue=i.tensor_util.getTensorsInContainer(re),kt=0,tt=ne;kt<tt.length;kt++)ze=tt[kt],i.tensor_util.isTensorInList(ze,Ue)||ze.dispose();return[2,{value:re,done:!1}]}})})},Y}(ar),cn=function(pe){M(Y,pe);function Y(){var j=pe.call(this)||this;return j.outputQueue=new rr,j.lastRead=Promise.resolve({value:null,done:!1}),j}return Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j=this;return oe(this,function(ne){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},Y.prototype.serialNext=function(){return V(this,void 0,void 0,function(){return oe(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}]}})})},Y}(ar),za=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.transform=ne,re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},Y.prototype.pump=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue,kt,tt,ze;return oe(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(ne=i.tensor_util.getTensorsInContainer(j.value),re=this.transform(j.value),Ue=i.tensor_util.getTensorsInContainer(re),this.outputQueue.pushAll(re),kt=0,tt=ne;kt<tt.length;kt++)ze=tt[kt],i.tensor_util.isTensorInList(ze,Ue)||ze.dispose();return[2,!0]}})})},Y}(cn),fn=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.baseErrorHandler=ne,re.lastRead=null,re.iterator=null,re.moreIterators=j,re}return Y.prototype.summary=function(){var j="TODO: fill in upstream of chained summaries";return j+" -> Chained"},Y.prototype.next=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},Y.prototype.readFromChain=function(j){return V(this,void 0,void 0,function(){var ne,re;return oe(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(ne=Ue.sent(),ne.done)return[2,{value:null,done:!0}];this.iterator=ne.value,this.baseErrorHandler!=null&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),Ue.label=3;case 3:return[4,this.iterator.next()];case 4:return re=Ue.sent(),re.done?(this.iterator=null,[2,this.readFromChain(j)]):[2,re]}})})},Y}(ar),Gn;(function(pe){pe[pe.FAIL=0]="FAIL",pe[pe.SHORTEST=1]="SHORTEST",pe[pe.LONGEST=2]="LONGEST"})(Gn||(Gn={}));var _i=function(pe){M(Y,pe);function Y(j,ne){ne===void 0&&(ne=Gn.FAIL);var re=pe.call(this)||this;return re.iterators=j,re.mismatchMode=ne,re.count=0,re.currentPromise=null,re}return Y.prototype.summary=function(){var j="TODO: fill in upstream of zip summaries";return"{"+j+"} -> Zip"},Y.prototype.nextState=function(j){return V(this,void 0,void 0,function(){function ne(tt){if(tt instanceof ar){var ze=tt.next();return{value:ze.then(function(Ye){return re++,Ye.done&&Ue++,Ye.value}),recurse:!1}}else return{value:null,recurse:!0}}var re,Ue,kt;return oe(this,function(tt){switch(tt.label){case 0:return[4,j];case 1:return tt.sent(),re=0,Ue=0,[4,mt(this.iterators,ne)];case 2:if(kt=tt.sent(),re===Ue)return[2,{value:null,done:!0}];if(Ue>0)switch(this.mismatchMode){case Gn.FAIL:throw new Error("Zipped streams should have the same length. "+("Mismatched at element "+this.count+"."));case Gn.SHORTEST:return[2,{value:null,done:!0}];case Gn.LONGEST:}return this.count++,[2,{value:kt,done:!1}]}})})},Y.prototype.next=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]})})},Y}(ar),fa=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.bufferSize=ne,re.buffer=new Qt(ne),re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},Y.prototype.refill=function(){for(;!this.buffer.isFull();){var j=this.upstream.next();this.buffer.push(j)}},Y.prototype.next=function(){return this.refill(),this.buffer.shift()},Y}(ar),Hi=function(pe){M(Y,pe);function Y(j,ne,re){var Ue=pe.call(this,j,ne)||this;return Ue.upstream=j,Ue.windowSize=ne,Ue.upstreamExhausted=!1,Ue.random=W(re||i.util.now().toString()),Ue.lastRead=Promise.resolve({value:null,done:!1}),Ue}return Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j=this;return oe(this,function(ne){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},Y.prototype.randomInt=function(j){return Math.floor(this.random()*j)},Y.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},Y.prototype.serialNext=function(){return V(this,void 0,void 0,function(){var j,ne;return oe(this,function(re){switch(re.label){case 0:this.upstreamExhausted||this.refill(),re.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(j=this.chooseIndex(),[4,this.buffer.shuffleExcise(j)]);case 2:if(ne=re.sent(),ne.done)this.upstreamExhausted=!0;else return this.refill(),[2,ne];return[3,1];case 3:return[2,{value:null,done:!0}]}})})},Y}(fa),Yn=function(){function pe(){this.size=null}return pe.prototype.batch=function(Y,j){var ne=this;j===void 0&&(j=!0);var re=this;i.util.assert(Y>0,function(){return`batchSize needs to be positive, but it is
`+Y});var Ue;return this.size===Infinity||this.size==null?Ue=this.size:j?Ue=Math.ceil(this.size/Y):Ue=Math.floor(this.size/Y),Wn(function(){return V(ne,void 0,void 0,function(){return oe(this,function(kt){switch(kt.label){case 0:return[4,re.iterator()];case 1:return[2,kt.sent().columnMajorBatch(Y,j,hi)]}})})},Ue)},pe.prototype.concatenate=function(Y){var j=this,ne=this,re;return this.size===Infinity||Y.size===Infinity?re=Infinity:this.size!=null&&Y.size!=null?re=this.size+Y.size:re=null,Wn(function(){return V(j,void 0,void 0,function(){var Ue,kt;return oe(this,function(tt){switch(tt.label){case 0:return[4,ne.iterator()];case 1:return kt=(Ue=tt.sent()).concatenate,[4,Y.iterator()];case 2:return[2,kt.apply(Ue,[tt.sent()])]}})})},re)},pe.prototype.filter=function(Y){var j=this,ne=this,re;return this.size===Infinity?re=Infinity:re=null,Wn(function(){return V(j,void 0,void 0,function(){return oe(this,function(Ue){switch(Ue.label){case 0:return[4,ne.iterator()];case 1:return[2,Ue.sent().filter(function(kt){return i.tidy(function(){return Y(kt)})})]}})})},re)},pe.prototype.forEachAsync=function(Y){return V(this,void 0,void 0,function(){return oe(this,function(j){switch(j.label){case 0:return[4,this.iterator()];case 1:return[2,j.sent().forEachAsync(Y)]}})})},pe.prototype.map=function(Y){var j=this,ne=this;return Wn(function(){return V(j,void 0,void 0,function(){return oe(this,function(re){switch(re.label){case 0:return[4,ne.iterator()];case 1:return[2,re.sent().map(function(Ue){return i.tidy(function(){return Y(Ue)})})]}})})},this.size)},pe.prototype.mapAsync=function(Y){var j=this,ne=this;return Wn(function(){return V(j,void 0,void 0,function(){return oe(this,function(re){switch(re.label){case 0:return[4,ne.iterator()];case 1:return[2,re.sent().mapAsync(Y)]}})})},this.size)},pe.prototype.prefetch=function(Y){var j=this;if(Y==null)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var ne=this;return Wn(function(){return V(j,void 0,void 0,function(){return oe(this,function(re){switch(re.label){case 0:return[4,ne.iterator()];case 1:return[2,re.sent().prefetch(Y)]}})})},this.size)},pe.prototype.repeat=function(Y){var j=this,ne=this,re;return this.size!=null&&Y>0?re=this.size*Y:Y===0?re=0:this.size!=null&&(Y===void 0||Y<0)?re=Infinity:re=null,Wn(function(){return V(j,void 0,void 0,function(){var Ue,kt=this;return oe(this,function(tt){return Ue=jr(function(){return V(kt,void 0,void 0,function(){var ze;return oe(this,function(Ye){switch(Ye.label){case 0:return ze={},[4,ne.iterator()];case 1:return[2,(ze.value=Ye.sent(),ze.done=!1,ze)]}})})}),[2,Pr(Ue.take(Y))]})})},re)},pe.prototype.skip=function(Y){var j=this,ne=this,re;return this.size!=null&&Y>=0&&this.size>=Y?re=this.size-Y:this.size!=null&&(this.size<Y||Y===void 0||Y<0)?re=0:re=null,Wn(function(){return V(j,void 0,void 0,function(){return oe(this,function(Ue){switch(Ue.label){case 0:return[4,ne.iterator()];case 1:return[2,Ue.sent().skip(Y)]}})})},re)},pe.prototype.shuffle=function(Y,j,ne){var re=this;if(ne===void 0&&(ne=!0),Y==null||Y<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 Wn(function(){return V(re,void 0,void 0,function(){var tt;return oe(this,function(ze){switch(ze.label){case 0:return tt=kt.int32(),ne&&(tt+=kt.int32()),[4,Ue.iterator()];case 1:return[2,ze.sent().shuffle(Y,tt.toString())]}})})},this.size)},pe.prototype.take=function(Y){var j=this,ne=this,re;return this.size!=null&&this.size>Y?re=Y:this.size!=null&&this.size<=Y?re=this.size:re=null,Wn(function(){return V(j,void 0,void 0,function(){return oe(this,function(Ue){switch(Ue.label){case 0:return[4,ne.iterator()];case 1:return[2,Ue.sent().take(Y)]}})})},re)},pe.prototype.toArray=function(){return V(this,void 0,void 0,function(){return oe(this,function(Y){switch(Y.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,Y.sent().toArray()]}})})},pe.prototype.toArrayForTest=function(){return V(this,void 0,void 0,function(){return oe(this,function(Y){switch(Y.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,Y.sent().toArrayForTest()]}})})},pe.MAX_BUFFER_SIZE=1e4,pe}();function Wn(pe,Y){return Y===void 0&&(Y=null),new(function(j){M(ne,j);function ne(){var re=j!==null&&j.apply(this,arguments)||this;return re.size=Y,re}return ne.prototype.iterator=function(){return V(this,void 0,void 0,function(){return oe(this,function(re){return[2,pe()]})})},ne}(Yn))}function Ga(pe){var Y=this;return Wn(function(){return V(Y,void 0,void 0,function(){return oe(this,function(j){return[2,jt(pe)]})})},pe.length)}function Sa(pe){var Y=this;if(!yt(pe))throw new Error("The argument to zip() must be an object or array.");var j;if(Array.isArray(pe))for(var ne=0;ne<pe.length;ne++)j=j==null?pe[ne].size:Math.min(j,pe[ne].size);else if(pe instanceof Object)for(var re in pe)j=j==null?pe[re].size:Math.min(j,pe[re].size);return Wn(function(){return V(Y,void 0,void 0,function(){var Ue;return oe(this,function(kt){switch(kt.label){case 0:return[4,mt(pe,function(tt){if(tt instanceof Yn)return{value:tt.iterator(),recurse:!1};if(yt(tt))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,Gn.SHORTEST)]}})})},j)}function hi(pe){if(pe===null)return null;var Y=pe[0];if($e(Y)){var j=La(pe);return{value:j,recurse:!1}}return{value:null,recurse:!0}}function La(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){M(Y,pe);function Y(j){var ne=pe.call(this)||this;return ne.input=j,ne}return Y.prototype.iterator=function(){return V(this,void 0,void 0,function(){var j,ne,re;return oe(this,function(Ue){switch(Ue.label){case 0:return[4,this.input.iterator()];case 1:return j=Ue.sent(),ne=j.decodeUTF8(),re=ne.split(`
`).map(function(kt){return kt.endsWith("\r")&&(kt=kt.slice(0,-1)),kt}),[2,re]}})})},Y}(Yn),xn='"',Ia=Symbol("out"),Rr=Symbol("field"),Pa=Symbol("quote"),na=Symbol("quoteafterquote"),Ei=Symbol("quoteinquote"),Gi=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.input=j,re.hasHeader=!0,re.fullColumnNames=null,re.columnNamesValidated=!1,re.columnConfigs=null,re.configuredColumnsOnly=!1,re.delimiter=",",re.delimWhitespace=!1,re.base=new on(j),ne||(ne={}),re.hasHeader=!(ne.hasHeader===!1),re.fullColumnNames=ne.columnNames,re.columnConfigs=ne.columnConfigs,re.configuredColumnsOnly=ne.configuredColumnsOnly,ne.delimWhitespace?(i.util.assert(ne.delimiter==null,function(){return"Delimiter should not be provided when delimWhitespace is true."}),re.delimWhitespace=!0,re.delimiter=" "):re.delimiter=ne.delimiter?ne.delimiter:",",re}return Y.prototype.columnNames=function(){return V(this,void 0,void 0,function(){return oe(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]}})})},Y.prototype.setColumnNames=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue,kt,tt,ze,Ye=this;return oe(this,function(Dt){switch(Dt.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(j=Dt.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),ne=this.fullColumnNames.reduce(function(St,Mt){return St[Mt]=St[Mt]+1||1,St},{}),re=Object.keys(ne).filter(function(St){return ne[St]>1}),i.util.assert(re.length===0,function(){return"Duplicate column names found: "+re.toString()}),this.columnConfigs){for(Ue=0,kt=Object.keys(this.columnConfigs);Ue<kt.length;Ue++)if(tt=kt[Ue],ze=this.fullColumnNames.indexOf(tt),ze===-1)throw new Error('The key "'+tt+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}return this.columnNamesValidated=!0,[2]}})})},Y.prototype.maybeReadHeaderLine=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue;return oe(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(ne=kt.sent(),ne.done)throw new Error("No data was found for CSV parsing.");return re=ne.value,Ue=this.parseRow(re,!1),[2,Ue];case 3:return[2,null]}})})},Y.prototype.iterator=function(){return V(this,void 0,void 0,function(){var j,ne=this;return oe(this,function(re){switch(re.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:re.sent(),re.label=2;case 2:return[4,this.base.iterator()];case 3:return j=re.sent(),this.hasHeader&&(j=j.skip(1)),[2,j.map(function(Ue){return ne.makeDataElement(Ue)})]}})})},Y.prototype.makeDataElement=function(j){for(var ne=this.parseRow(j),re={},Ue={},kt=0;kt<this.fullColumnNames.length;kt++){var tt=this.fullColumnNames[kt],ze=this.columnConfigs?this.columnConfigs[tt]:null;if(this.configuredColumnsOnly&&!ze)continue;var Ye=ne[kt],Dt=null;if(Ye==="")if(ze&&ze.default!==void 0)Dt=ze.default;else{if(ze&&(ze.required||ze.isLabel))throw new Error("Required column "+tt+" is empty in this line: "+j);Dt=void 0}else{var St=Number(Ye);if(isNaN(St))ze&&ze.dtype==="bool"?Dt=this.getBoolean(Ye):Dt=Ye;else if(!ze||!ze.dtype)Dt=St;else switch(ze.dtype){case"float32":Dt=St;break;case"int32":Dt=Math.floor(St);break;case"bool":Dt=this.getBoolean(Ye);break;default:Dt=St}}ze&&ze.isLabel?Ue[tt]=Dt:re[tt]=Dt}return Object.keys(Ue).length===0?re:{xs:re,ys:Ue}},Y.prototype.getBoolean=function(j){return j==="1"||j.toLowerCase()==="true"?1:0},Y.prototype.parseRow=function(j,ne){ne===void 0&&(ne=!0);for(var re=[],Ue=0,kt=j.length,tt=Ia,ze=0;ze<kt;ze++)switch(tt){case Ia:switch(j.charAt(ze)){case xn:Ue=ze+1,tt=Pa;break;case this.delimiter:if(Ue=ze+1,this.delimiter===" "&&this.delimWhitespace)break;re.push(""),tt=Ia;break;default:tt=Rr,Ue=ze;break}break;case Rr:switch(j.charAt(ze)){case this.delimiter:re.push(j.substring(Ue,ze)),tt=Ia,Ue=ze+1;break}break;case Pa:switch(j.charAt(ze)){case xn:tt=na;break}break;case na:switch(j.charAt(ze)){case this.delimiter:re.push(j.substring(Ue,ze-1)),tt=Ia,Ue=ze+1;break;case xn:tt=Pa;break;default:tt=Ei;break}break;case Ei:switch(j.charAt(ze)){case xn:tt=Pa;break}break}if(tt===na?re.push(j.substring(Ue,kt-1)):re.push(j.substring(Ue)),ne&&re.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+re);return re},Y}(Yn),Ri=function(pe){M(Y,pe);function Y(j){var ne=pe.call(this)||this;ne.microphoneConfig=j,ne.isClosed=!1,ne.fftSize=j.fftSize||1024;var re=Math.log2(ne.fftSize);if(ne.fftSize<0||re<4||re>14||!Number.isInteger(re))throw new Error("Invalid fftSize: it must be a power of 2 between "+("2 to 4 and 2 to 14, but got "+ne.fftSize));if(ne.numFrames=j.numFramesPerSpectrogram||43,ne.sampleRateHz=j.sampleRateHz,ne.columnTruncateLength=j.columnTruncateLength||ne.fftSize,ne.audioTrackConstraints=j.audioTrackConstraints,ne.smoothingTimeConstant=j.smoothingTimeConstant||0,ne.includeSpectrogram=!(j.includeSpectrogram===!1),ne.includeWaveform=j.includeWaveform===!0,!ne.includeSpectrogram&&!ne.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return ne}return Y.prototype.summary=function(){return"microphone"},Y.create=function(j){return j===void 0&&(j={}),V(this,void 0,void 0,function(){var ne;return oe(this,function(re){switch(re.label){case 0:if(i.env().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return ne=new Y(j),[4,ne.start()];case 1:return re.sent(),[2,ne]}})})},Y.prototype.start=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue;return oe(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 ne=kt.sent(),new Error("Error thrown while initializing video stream: "+ne.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(re=window.AudioContext||window.webkitAudioContext,this.audioContext=new re,!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]}})})},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue,kt;return oe(this,function(tt){switch(tt.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return re=tt.sent(),this.includeSpectrogram&&(Ue=this.flattenQueue(re.freqDataQueue),j=this.getTensorFromAudioDataArray(Ue,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(kt=this.flattenQueue(re.timeDataQueue),ne=this.getTensorFromAudioDataArray(kt,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:j,waveform:ne},done:!1}]}})})},Y.prototype.capture=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){switch(j.label){case 0:return[4,this.next()];case 1:return[2,j.sent().value]}})})},Y.prototype.getAudioData=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue=this;return oe(this,function(kt){return j=[],ne=[],re=0,[2,new Promise(function(tt){var ze=setInterval(function(){Ue.includeSpectrogram&&(Ue.analyser.getFloatFrequencyData(Ue.freqData),Ue.freqData[0]===-Infinity&&tt({freqDataQueue:j,timeDataQueue:ne}),j.push(Ue.freqData.slice(0,Ue.columnTruncateLength))),Ue.includeWaveform&&(Ue.analyser.getFloatTimeDomainData(Ue.timeData),ne.push(Ue.timeData.slice())),++re===Ue.numFrames&&(clearInterval(ze),tt({freqDataQueue:j,timeDataQueue:ne}))},Ue.fftSize/Ue.sampleRateHz*1e3)})]})})},Y.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())},Y.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},Y.prototype.getSampleRate=function(){return this.sampleRateHz},Y.prototype.flattenQueue=function(j){var ne=j[0].length,re=new Float32Array(j.length*ne);return j.forEach(function(Ue,kt){return re.set(Ue,kt*ne)}),re},Y.prototype.getTensorFromAudioDataArray=function(j,ne){var re=new Float32Array(i.util.sizeFromShape(ne));return re.set(j,re.length-j.length),i.tensor(re,ne)},Y}(ar),jn=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;if(re.webcamVideoElement=j,re.webcamConfig=ne,re.isClosed=!0,re.resize=!1,re.needToResize())if(re.resize=!0,re.cropSize=[re.webcamConfig.resizeHeight,re.webcamConfig.resizeWidth],re.cropBoxInd=i.tensor1d([0],"int32"),re.webcamConfig.centerCrop){var Ue=re.webcamConfig.resizeWidth*1/re.webcamVideoElement.width,kt=re.webcamConfig.resizeHeight*1/re.webcamVideoElement.height,tt=(1-Ue)/2,ze=(1-kt)/2,Ye=tt+Ue,Dt=kt+ze;re.cropBox=i.tensor2d([ze,tt,Dt,Ye],[1,4])}else re.cropBox=i.tensor2d([0,0,1,1],[1,4]);return re}return Y.prototype.summary=function(){return"webcam"},Y.create=function(j,ne){return ne===void 0&&(ne={}),V(this,void 0,void 0,function(){var re;return oe(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"),!ne.resizeWidth||!ne.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");j.width=ne.resizeWidth,j.height=ne.resizeHeight}return re=new Y(j,ne),[4,re.start()];case 1:return Ue.sent(),[2,re]}})})},Y.prototype.start=function(){return V(this,void 0,void 0,function(){var j,ne,re=this;return oe(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: "+re.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 ne=Ue.sent(),ne.message="Error thrown while initializing video stream: "+ne.message,ne;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){re.webcamVideoElement.onloadedmetadata=function(){kt()}})]}})})},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j;return oe(this,function(ne){if(this.isClosed)return[2,{value:null,done:!0}];try{j=i.browser.fromPixels(this.webcamVideoElement)}catch(re){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(re))}if(this.resize)try{return[2,{value:this.cropAndResizeFrame(j),done:!1}]}catch(re){throw new Error("Error thrown cropping the video: "+re.message)}finally{j.dispose()}else return[2,{value:j,done:!1}];return[2]})})},Y.prototype.needToResize=function(){return!!(this.webcamConfig.resizeWidth&&this.webcamConfig.resizeHeight&&(this.webcamVideoElement.width!==this.webcamConfig.resizeWidth||this.webcamVideoElement.height!==this.webcamConfig.resizeHeight))},Y.prototype.cropAndResizeFrame=function(j){var ne=this;return i.tidy(function(){var re=j.toFloat().expandDims(0),Ue;Ue=i.image.cropAndResize(re,ne.cropBox,ne.cropBoxInd,ne.cropSize,"bilinear");var kt=Ue.shape;return Ue.reshape(kt.slice(1))})},Y.prototype.capture=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){switch(j.label){case 0:return[4,this.next()];case 1:return[2,j.sent().value]}})})},Y.prototype.stop=function(){var j=this.stream.getTracks();j.forEach(function(ne){return ne.stop()});try{this.webcamVideoElement.srcObject=null}catch(ne){console.log(ne),this.webcamVideoElement.src=null}this.isClosed=!0},Y.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},Y}(ar),ni=function(){function pe(){}return pe}(),pi=function(pe){M(Y,pe);function Y(){return pe!==null&&pe.apply(this,arguments)||this}return Y.prototype.split=function(j){return new ma(this,j)},Y}(ar),ma=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.impl=new di(j,ne),re}return Y.prototype.summary=function(){return this.impl.summary()},Y.prototype.next=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){return[2,this.impl.next()]})})},Y}(pi),di=function(pe){M(Y,pe);function Y(j,ne){var re=pe.call(this)||this;return re.upstream=j,re.separator=ne,re.carryover="",re}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},Y.prototype.pump=function(){return V(this,void 0,void 0,function(){var j,ne,re,Ue,kt;return oe(this,function(tt){switch(tt.label){case 0:return[4,this.upstream.next()];case 1:if(j=tt.sent(),j.done)return this.carryover===""?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for(ne=j.value.split(this.separator),ne[0]=this.carryover+ne[0],re=0,Ue=ne.slice(0,-1);re<Ue.length;re++)kt=Ue[re],this.outputQueue.push(kt);return this.carryover=ne[ne.length-1],[2,!0]}})})},Y}(cn),fi=function(pe){M(Y,pe);function Y(){return pe!==null&&pe.apply(this,arguments)||this}return Y.prototype.decodeUTF8=function(){return new ja(this)},Y}(ar),ja=function(pe){M(Y,pe);function Y(j){var ne=pe.call(this)||this;return ne.upstream=j,ne.impl=new ln(j),ne}return Y.prototype.summary=function(){return this.impl.summary()},Y.prototype.next=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){return[2,this.impl.next()]})})},Y}(pi),ln=function(pe){M(Y,pe);function Y(j){var ne=pe.call(this)||this;if(ne.upstream=j,i.env().get("IS_BROWSER"))ne.decoder=new TextDecoder("utf-8");else{var re=og().StringDecoder;ne.decoder=new re("utf8")}return ne}return Y.prototype.summary=function(){return this.upstream.summary()+" -> Utf8"},Y.prototype.pump=function(){return V(this,void 0,void 0,function(){var j,ne,re;return oe(this,function(Ue){switch(Ue.label){case 0:return[4,this.upstream.next()];case 1:return j=Ue.sent(),j.done?[2,!1]:(ne=j.value,i.env().get("IS_BROWSER")?re=this.decoder.decode(ne,{stream:!0}):re=this.decoder.write(Buffer.from(ne.buffer)),this.outputQueue.push(re),[2,!0])}})})},Y}(cn),ai=function(pe){M(Y,pe);function Y(j,ne){ne===void 0&&(ne={});var re=pe.call(this)||this;return re.file=j,re.options=ne,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."}),re.offset=ne.offset||0,re.chunkSize=ne.chunkSize||1024*1024,re}return Y.prototype.summary=function(){return"FileChunks "+this.file},Y.prototype.next=function(){return V(this,void 0,void 0,function(){var j,ne,re=this;return oe(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,tt){var ze=re.offset+re.chunkSize;if(re.file instanceof Uint8Array)kt(new Uint8Array(re.file.slice(re.offset,ze)));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 tt(new TypeError("FileReader returned unknown type."));kt(Mt)},Ye.onabort=function(St){return tt(new Error("Aborted"))},Ye.onerror=function(St){return tt(new Error(St.type))};var Dt=re.file.slice(re.offset,ze);Ye.readAsArrayBuffer(Dt)}re.offset=ze}),ne={},[4,j]);case 1:return[2,(ne.value=Ue.sent(),ne.done=!1,ne)]}})})},Y}(fi);function gr(pe,Y){return Y===void 0&&(Y={}),V(this,void 0,void 0,function(){var j,ne,re,Ue,kt;return oe(this,function(tt){switch(tt.label){case 0:return typeof pe=="string"?j=pe:(j=pe.url,ne=Ai(pe)),[4,i.util.fetch(j,ne)];case 1:return re=tt.sent(),re.ok?(kt=Uint8Array.bind,[4,re.arrayBuffer()]):[3,3];case 2:return Ue=new(kt.apply(Uint8Array,[void 0,tt.sent()])),[2,new ai(Ue,Y)];case 3:throw new Error(re.statusText)}})})}var Ai=function(pe){var Y={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 Y};function wi(pe){return typeof pe=="string"&&pe.substr(0,7)==="file://"}var no=function(pe){M(Y,pe);function Y(j,ne){ne===void 0&&(ne={});var re=pe.call(this)||this;return re.input=j,re.options=ne,re}return Y.prototype.iterator=function(){return V(this,void 0,void 0,function(){var j;return oe(this,function(ne){return wi(this.input)&&i.env().get("IS_NODE")&&(j=require("fs"),this.input=j.readFileSync(this.input.substr(7))),[2,new ai(this.input,this.options)]})})},Y}(ni),Qn=function(pe){M(Y,pe);function Y(j,ne){ne===void 0&&(ne={});var re=pe.call(this)||this;return re.url=j,re.fileOptions=ne,re}return Y.prototype.iterator=function(){return V(this,void 0,void 0,function(){return oe(this,function(j){return wi(this.url)?[2,new no(this.url,this.fileOptions).iterator()]:[2,gr(this.url,this.fileOptions)]})})},Y}(ni);function ji(pe,Y){return Y===void 0&&(Y={}),new Gi(new Qn(pe),Y)}function Fi(pe){var Y=this,j=jr(pe);return Wn(function(){return V(Y,void 0,void 0,function(){return oe(this,function(ne){return[2,j]})})})}function qi(pe){var Y=this;return Wn(function(){return V(Y,void 0,void 0,function(){var j;return oe(this,function(ne){switch(ne.label){case 0:return[4,pe()];case 1:return j=ne.sent(),[2,jr(function(){return j.next()})]}})})})}function Di(pe,Y){return V(this,void 0,void 0,function(){return oe(this,function(j){return[2,jn.create(pe,Y)]})})}function ya(pe){return V(this,void 0,void 0,function(){return oe(this,function(Y){return[2,Ri.create(pe)]})})}var Oi="2.7.0";N.CSVDataset=Gi,N.Dataset=Yn,N.FileDataSource=no,N.TextLineDataset=on,N.URLDataSource=Qn,N.array=Ga,N.csv=ji,N.func=Fi,N.generator=qi,N.microphone=ya,N.version_data=Oi,N.webcam=Di,N.zip=Sa}),ug=Or((N,i)=>{(function(we,M,V){function oe(z){var he=this,ye=Te();he.next=function(){var ee=2091639*he.s0+he.c*23283064365386963e-26;return he.s0=he.s1,he.s1=he.s2,he.s2=ee-(he.c=ee|0)},he.c=1,he.s0=ye(" "),he.s1=ye(" "),he.s2=ye(" "),he.s0-=ye(z),he.s0<0&&(he.s0+=1),he.s1-=ye(z),he.s1<0&&(he.s1+=1),he.s2-=ye(z),he.s2<0&&(he.s2+=1),ye=null}function de(z,he){return he.c=z.c,he.s0=z.s0,he.s1=z.s1,he.s2=z.s2,he}function X(z,he){var ye=new oe(z),ee=he&&he.state,w=ye.next;return w.int32=function(){return ye.next()*4294967296|0},w.double=function(){return w()+(w()*2097152|0)*11102230246251565e-32},w.quick=w,ee&&(typeof ee=="object"&&de(ee,ye),w.state=function(){return de(ye,{})}),w}function Te(){var z=4022871197,he=function(ye){ye=ye.toString();for(var ee=0;ee<ye.length;ee++){z+=ye.charCodeAt(ee);var w=.02519603282416938*z;z=w>>>0,w-=z,w*=z,z=w>>>0,w-=z,z+=w*4294967296}return(z>>>0)*23283064365386963e-26};return he}M&&M.exports?M.exports=X:V&&V.amd?V(function(){return X}):this.alea=X})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),cg=Or((N,i)=>{(function(we,M,V){function oe(Te){var z=this,he="";z.x=0,z.y=0,z.z=0,z.w=0,z.next=function(){var ee=z.x^z.x<<11;return z.x=z.y,z.y=z.z,z.z=z.w,z.w^=z.w>>>19^ee^ee>>>8},Te===(Te|0)?z.x=Te:he+=Te;for(var ye=0;ye<he.length+64;ye++)z.x^=he.charCodeAt(ye)|0,z.next()}function de(Te,z){return z.x=Te.x,z.y=Te.y,z.z=Te.z,z.w=Te.w,z}function X(Te,z){var he=new oe(Te),ye=z&&z.state,ee=function(){return(he.next()>>>0)/4294967296};return ee.double=function(){do var w=he.next()>>>11,xe=(he.next()>>>0)/4294967296,We=(w+xe)/(1<<21);while(We===0);return We},ee.int32=he.next,ee.quick=ee,ye&&(typeof ye=="object"&&de(ye,he),ee.state=function(){return de(he,{})}),ee}M&&M.exports?M.exports=X:V&&V.amd?V(function(){return X}):this.xor128=X})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),lg=Or((N,i)=>{(function(we,M,V){function oe(Te){var z=this,he="";z.next=function(){var ee=z.x^z.x>>>2;return z.x=z.y,z.y=z.z,z.z=z.w,z.w=z.v,(z.d=z.d+362437|0)+(z.v=z.v^z.v<<4^(ee^ee<<1))|0},z.x=0,z.y=0,z.z=0,z.w=0,z.v=0,Te===(Te|0)?z.x=Te:he+=Te;for(var ye=0;ye<he.length+64;ye++)z.x^=he.charCodeAt(ye)|0,ye==he.length&&(z.d=z.x<<10^z.x>>>4),z.next()}function de(Te,z){return z.x=Te.x,z.y=Te.y,z.z=Te.z,z.w=Te.w,z.v=Te.v,z.d=Te.d,z}function X(Te,z){var he=new oe(Te),ye=z&&z.state,ee=function(){return(he.next()>>>0)/4294967296};return ee.double=function(){do var w=he.next()>>>11,xe=(he.next()>>>0)/4294967296,We=(w+xe)/(1<<21);while(We===0);return We},ee.int32=he.next,ee.quick=ee,ye&&(typeof ye=="object"&&de(ye,he),ee.state=function(){return de(he,{})}),ee}M&&M.exports?M.exports=X:V&&V.amd?V(function(){return X}):this.xorwow=X})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),hg=Or((N,i)=>{(function(we,M,V){function oe(Te){var z=this;z.next=function(){var ye=z.x,ee=z.i,w,xe,We;return w=ye[ee],w^=w>>>7,xe=w^w<<24,w=ye[ee+1&7],xe^=w^w>>>10,w=ye[ee+3&7],xe^=w^w>>>3,w=ye[ee+4&7],xe^=w^w<<7,w=ye[ee+7&7],w=w^w<<13,xe^=w^w<<9,ye[ee]=xe,z.i=ee+1&7,xe};function he(ye,ee){var w,xe,We=[];if(ee===(ee|0))xe=We[0]=ee;else for(ee=""+ee,w=0;w<ee.length;++w)We[w&7]=We[w&7]<<15^ee.charCodeAt(w)+We[w+1&7]<<13;for(;We.length<8;)We.push(0);for(w=0;w<8&&We[w]===0;++w);for(w==8?xe=We[7]=-1:xe=We[w],ye.x=We,ye.i=0,w=256;w>0;--w)ye.next()}he(z,Te)}function de(Te,z){return z.x=Te.x.slice(),z.i=Te.i,z}function X(Te,z){Te==null&&(Te=+new Date);var he=new oe(Te),ye=z&&z.state,ee=function(){return(he.next()>>>0)/4294967296};return ee.double=function(){do var w=he.next()>>>11,xe=(he.next()>>>0)/4294967296,We=(w+xe)/(1<<21);while(We===0);return We},ee.int32=he.next,ee.quick=ee,ye&&(ye.x&&de(ye,he),ee.state=function(){return de(he,{})}),ee}M&&M.exports?M.exports=X:V&&V.amd?V(function(){return X}):this.xorshift7=X})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),pg=Or((N,i)=>{(function(we,M,V){function oe(Te){var z=this;z.next=function(){var ye=z.w,ee=z.X,w=z.i,xe,We;return z.w=ye=ye+1640531527|0,We=ee[w+34&127],xe=ee[w=w+1&127],We^=We<<13,xe^=xe<<17,We^=We>>>15,xe^=xe>>>12,We=ee[w]=We^xe,z.i=w,We+(ye^ye>>>16)|0};function he(ye,ee){var w,xe,We,W,st,ut=[],Kt=128;for(ee===(ee|0)?(xe=ee,ee=null):(ee=ee+"\0",xe=0,Kt=Math.max(Kt,ee.length)),We=0,W=-32;W<Kt;++W)ee&&(xe^=ee.charCodeAt((W+32)%ee.length)),W===0&&(st=xe),xe^=xe<<10,xe^=xe>>>15,xe^=xe<<4,xe^=xe>>>13,W>=0&&(st=st+1640531527|0,w=ut[W&127]^=xe+st,We=w==0?We+1:0);for(We>=128&&(ut[(ee&&ee.length||0)&127]=-1),We=127,W=4*128;W>0;--W)xe=ut[We+34&127],w=ut[We=We+1&127],xe^=xe<<13,w^=w<<17,xe^=xe>>>15,w^=w>>>12,ut[We]=xe^w;ye.w=st,ye.X=ut,ye.i=We}he(z,Te)}function de(Te,z){return z.i=Te.i,z.w=Te.w,z.X=Te.X.slice(),z}function X(Te,z){Te==null&&(Te=+new Date);var he=new oe(Te),ye=z&&z.state,ee=function(){return(he.next()>>>0)/4294967296};return ee.double=function(){do var w=he.next()>>>11,xe=(he.next()>>>0)/4294967296,We=(w+xe)/(1<<21);while(We===0);return We},ee.int32=he.next,ee.quick=ee,ye&&(ye.X&&de(ye,he),ee.state=function(){return de(he,{})}),ee}M&&M.exports?M.exports=X:V&&V.amd?V(function(){return X}):this.xor4096=X})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),dg=Or((N,i)=>{(function(we,M,V){function oe(Te){var z=this,he="";z.next=function(){var ee=z.b,w=z.c,xe=z.d,We=z.a;return ee=ee<<25^ee>>>7^w,w=w-xe|0,xe=xe<<24^xe>>>8^We,We=We-ee|0,z.b=ee=ee<<20^ee>>>12^w,z.c=w=w-xe|0,z.d=xe<<16^w>>>16^We,z.a=We-ee|0},z.a=0,z.b=0,z.c=2654435769|0,z.d=1367130551,Te===Math.floor(Te)?(z.a=Te/4294967296|0,z.b=Te|0):he+=Te;for(var ye=0;ye<he.length+20;ye++)z.b^=he.charCodeAt(ye)|0,z.next()}function de(Te,z){return z.a=Te.a,z.b=Te.b,z.c=Te.c,z.d=Te.d,z}function X(Te,z){var he=new oe(Te),ye=z&&z.state,ee=function(){return(he.next()>>>0)/4294967296};return ee.double=function(){do var w=he.next()>>>11,xe=(he.next()>>>0)/4294967296,We=(w+xe)/(1<<21);while(We===0);return We},ee.int32=he.next,ee.quick=ee,ye&&(typeof ye=="object"&&de(ye,he),ee.state=function(){return de(he,{})}),ee}M&&M.exports?M.exports=X:V&&V.amd?V(function(){return X}):this.tychei=X})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),fg=Or((N,i)=>{(function(we,M){var V=this,oe=256,de=6,X=52,Te="random",z=M.pow(oe,de),he=M.pow(2,X),ye=he*2,ee=oe-1,w;function xe(Ze,mt,yt){var $e=[];mt=mt==!0?{entropy:!0}:mt||{};var ot=ut(st(mt.entropy?[Ze,It(we)]:Ze==null?Kt():Ze,3),$e),nt=new We($e),et=function(){for(var Qt=nt.g(de),rr=z,jt=0;Qt<he;)Qt=(Qt+jt)*oe,rr*=oe,jt=nt.g(1);for(;Qt>=ye;)Qt/=2,rr/=2,jt>>>=1;return(Qt+jt)/rr};return et.int32=function(){return nt.g(4)|0},et.quick=function(){return nt.g(4)/4294967296},et.double=et,ut(It(nt.S),we),(mt.pass||yt||function(Qt,rr,jt,jr){return jr&&(jr.S&&W(jr,nt),Qt.state=function(){return W(nt,{})}),jt?(M[Te]=Qt,rr):Qt})(et,ot,"global"in mt?mt.global:this==M,mt.state)}M["seed"+Te]=xe;function We(Ze){var mt,yt=Ze.length,$e=this,ot=0,nt=$e.i=$e.j=0,et=$e.S=[];for(yt||(Ze=[yt++]);ot<oe;)et[ot]=ot++;for(ot=0;ot<oe;ot++)et[ot]=et[nt=ee&nt+Ze[ot%yt]+(mt=et[ot])],et[nt]=mt;($e.g=function(Qt){for(var rr,jt=0,jr=$e.i,Pr=$e.j,_r=$e.S;Qt--;)rr=_r[jr=ee&jr+1],jt=jt*oe+_r[ee&(_r[jr]=_r[Pr=ee&Pr+rr])+(_r[Pr]=rr)];return $e.i=jr,$e.j=Pr,jt})(oe)}function W(Ze,mt){return mt.i=Ze.i,mt.j=Ze.j,mt.S=Ze.S.slice(),mt}function st(Ze,mt){var yt=[],$e=typeof Ze,ot;if(mt&&$e=="object")for(ot in Ze)try{yt.push(st(Ze[ot],mt-1))}catch(nt){}return yt.length?yt:$e=="string"?Ze:Ze+"\0"}function ut(Ze,mt){for(var yt=Ze+"",$e,ot=0;ot<yt.length;)mt[ee&ot]=ee&($e^=mt[ee&ot]*19)+yt.charCodeAt(ot++);return It(mt)}function Kt(){try{var Ze;return w&&(Ze=w.randomBytes)?Ze=Ze(oe):(Ze=new Uint8Array(oe),(V.crypto||V.msCrypto).getRandomValues(Ze)),It(Ze)}catch($e){var mt=V.navigator,yt=mt&&mt.plugins;return[+new Date,V,yt,V.screen,It(we)]}}function It(Ze){return String.fromCharCode.apply(0,Ze)}if(ut(M.random(),we),typeof i=="object"&&i.exports){i.exports=xe;try{w=Bp()}catch(Ze){}}else typeof define=="function"&&define.amd&&define(function(){return xe})})([],Math)}),mg=Or((N,i)=>{var we=ug(),M=cg(),V=lg(),oe=hg(),de=pg(),X=dg(),Te=fg();Te.alea=we,Te.xor128=M,Te.xorwow=V,Te.xorshift7=oe,Te.xor4096=de,Te.tychei=X,i.exports=Te}),yg=Or(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),we=mg(),M=function(ae,ue){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,D){E.__proto__=D}||function(E,D){for(var A in D)D.hasOwnProperty(A)&&(E[A]=D[A])},M(ae,ue)};function V(ae,ue){M(ae,ue);function E(){this.constructor=ae}ae.prototype=ue===null?Object.create(ue):(E.prototype=ue.prototype,new E)}function oe(ae,ue,E,D){function A(H){return H instanceof E?H:new E(function(se){se(H)})}return new(E||(E=Promise))(function(H,se){function te(fe){try{ce(D.next(fe))}catch(ve){se(ve)}}function _e(fe){try{ce(D.throw(fe))}catch(ve){se(ve)}}function ce(fe){fe.done?H(fe.value):A(fe.value).then(te,_e)}ce((D=D.apply(ae,ue||[])).next())})}function de(ae,ue){var E={label:0,sent:function(){if(H[0]&1)throw H[1];return H[1]},trys:[],ops:[]},D,A,H,se;return se={next:te(0),throw:te(1),return:te(2)},typeof Symbol=="function"&&(se[Symbol.iterator]=function(){return this}),se;function te(ce){return function(fe){return _e([ce,fe])}}function _e(ce){if(D)throw new TypeError("Generator is already executing.");for(;E;)try{if(D=1,A&&(H=ce[0]&2?A.return:ce[0]?A.throw||((H=A.return)&&H.call(A),0):A.next)&&!(H=H.call(A,ce[1])).done)return H;(A=0,H)&&(ce=[ce[0]&2,H.value]);switch(ce[0]){case 0:case 1:H=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(!(H=E.trys,H=H.length>0&&H[H.length-1])&&(ce[0]===6||ce[0]===2)){E=0;continue}if(ce[0]===3&&(!H||ce[1]>H[0]&&ce[1]<H[3])){E.label=ce[1];break}if(ce[0]===6&&E.label<H[1]){E.label=H[1],H=ce;break}if(H&&E.label<H[2]){E.label=H[2],E.ops.push(ce);break}H[2]&&E.ops.pop(),E.trys.pop();continue}ce=ue.call(ae,E)}catch(fe){ce=[6,fe],A=0}finally{D=H=0}if(ce[0]&5)throw ce[1];return{value:ce[0]?ce[1]:void 0,done:!0}}}function X(ae,ue){Array.isArray(ae)||(ae=[ae]),ae.forEach(function(E){E!=null&&i.util.assert(E.dtype!=="complex64",function(){return ue+" does not support complex64 tensors in the CPU backend."})})}var Te=i.kernel_impls.nonMaxSuppressionV3Impl,z=i.kernel_impls.split,he=i.kernel_impls.tile,ye=i.kernel_impls.topkImpl,ee=i.kernel_impls.whereImpl,w=function(ae){V(ue,ae);function ue(){var E=ae.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,D,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 H={};return this.data.set(H,{values:E,dtype:A,refCount:1}),H},ue.prototype.makeTensorInfo=function(E,D,A){var H;if(D==="string"&&A!=null&&A.length>0&&i.util.isString(A[0])){var se=A.map(function(te){return i.util.encodeString(te)});H=this.write(se,E,D)}else H=this.write(A,E,D);return{dataId:H,shape:E,dtype:D}},ue.prototype.incRef=function(E){var D=this.data.get(E);D.refCount++},ue.prototype.decRef=function(E){if(this.data.has(E)){var D=this.data.get(E);D.refCount--}},ue.prototype.move=function(E,D,A,H){this.data.set(E,{values:D,dtype:H,refCount:1})},ue.prototype.numDataIds=function(){return this.data.numDataIds()},ue.prototype.read=function(E){return oe(this,void 0,void 0,function(){return de(this,function(D){return[2,this.readSync(E)]})})},ue.prototype.readSync=function(E){var D=this.data.get(E),A=D.dtype,H=D.complexTensorInfos;if(A==="complex64"){var se=this.readSync(H.real.dataId),te=this.readSync(H.imag.dataId);return i.backend_util.mergeRealAndImagArrays(se,te)}return this.data.get(E).values},ue.prototype.bufferSync=function(E){var D=this.readSync(E.dataId),A=D;if(E.dtype==="string")try{A=D.map(function(H){return i.util.decodeString(H)})}catch(H){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,D,A){var H=this.write(E,D,A);return i.engine().makeTensorFromDataId(H,D,A,this)},ue.prototype.disposeData=function(E){if(this.data.has(E)){var D=this.data.get(E).complexTensorInfos;D!=null&&(this.disposeData(D.real.dataId),this.disposeData(D.imag.dataId)),this.data.delete(E)}},ue.prototype.disposeIntermediateTensorInfo=function(E){var D=E.dataId;if(this.data.has(D)){var A=this.data.get(D);A.refCount--,A.refCount<1&&this.disposeData(D)}},ue.prototype.time=function(E){return oe(this,void 0,void 0,function(){var D,A;return de(this,function(H){return D=i.util.now(),E(),A=i.util.now()-D,[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,D,A,H){X(E,"stridedSlice");var se=i.slice_util.computeOutShape(D,A,H);if(se.some(function(Ae){return Ae===0}))return i.tensor([],se);for(var te=i.buffer(se,E.dtype),_e=this.bufferSync(E),ce=0;ce<te.size;ce++){for(var fe=te.indexToLoc(ce),ve=new Array(fe.length),ge=0;ge<ve.length;ge++)ve[ge]=fe[ge]*H[ge]+D[ge];te.set.apply(te,[_e.get.apply(_e,ve)].concat(fe))}return te.toTensor()},ue.prototype.diag=function(E){for(var D=this.readSync(E.dataId),A=i.buffer([E.size,E.size],E.dtype),H=A.values,se=0;se<D.length;se++)H[se*E.size+se]=D[se];return A.toTensor()},ue.prototype.unstack=function(E,D){for(var A=E.shape[D],H=new Array(E.rank-1),se=0,te=0;te<E.rank;te++)te!==D&&(H[se++]=E.shape[te]);var _e=new Array(E.rank).fill(0),ce=E.shape.slice();ce[D]=1;for(var fe=new Array(A),te=0;te<fe.length;te++)_e[D]=te,fe[te]=i.slice(E,_e,ce).reshape(H);return fe},ue.prototype.reverse=function(E,D){X(E,"reverse");for(var A=i.buffer(E.shape,E.dtype),H=this.bufferSync(E),se=function(_e){var ce=A.indexToLoc(_e),fe=ce.slice();D.forEach(function(ve){return fe[ve]=E.shape[ve]-1-fe[ve]}),A.set.apply(A,[H.get.apply(H,fe)].concat(ce))},te=0;te<A.size;te++)se(te);return A.toTensor()},ue.prototype.neg=function(E){return X(E,"neg"),i.mul(i.scalar(-1),E)},ue.prototype.addN=function(E){var D=this;X(E,"addN");for(var A=E.map(function(fe){return D.readSync(fe.dataId)}),H=i.buffer(E[0].shape,E[0].dtype),se=H.values,te=0;te<E.length;te++)for(var _e=A[te],ce=0;ce<se.length;ce++)se[ce]+=_e[ce];return H.toTensor()},ue.prototype.softmax=function(E,D){var A=i.util.parseAxisParam([D],E.shape),H=i.max(E,A),se=i.backend_util.expandShapeToKeepDim(H.shape,A),te=i.sub(E,H.reshape(se)),_e=i.exp(te),ce=this.sum(_e,A).reshape(se);return i.div(_e,ce)},ue.prototype.pow=function(E,D){return X([E,D],"pow"),this.broadcastedBinaryOp(E,D,E.dtype,function(A,H){return Math.pow(A,H)})},ue.prototype.floorDiv=function(E,D){X([E,D],"floorDiv");var A=function(se,te){return Math.floor(se/te)},H="int32";return this.broadcastedBinaryOp(E,D,H,A)},ue.prototype.sum=function(E,D){X(E,"sum"),i.backend_util.assertAxesAreInnerMostDims("sum",D,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,D),H=A[0],se=A[1],te=i.upcastType(E.dtype,"int32"),_e=i.zeros(H,te),ce=i.util.sizeFromShape(se),fe=this.readSync(_e.dataId),ve=this.readSync(E.dataId),ge=0;ge<fe.length;++ge){for(var Ae=ge*ce,Oe=0,De=0;De<ce;++De)Oe+=ve[Ae+De];fe[ge]=Oe}return _e},ue.prototype.prod=function(E,D){X(E,"sum");for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,D),H=A[0],se=A[1],te=i.upcastType(E.dtype,"int32"),_e=i.zeros(H,te),ce=i.util.sizeFromShape(se),fe=this.readSync(_e.dataId),ve=this.readSync(E.dataId),ge=0;ge<fe.length;++ge){for(var Ae=ge*ce,Oe=1,De=0;De<ce;++De)Oe*=ve[Ae+De];fe[ge]=Oe}return _e},ue.prototype.unsortedSegmentSum=function(E,D,A){X(E,"unsortedSegmentSum");for(var H=[],se=E.rank-D.rank,te=0;te<se;++te)D=D.expandDims(te+1);for(var te=0;te<A;++te){var _e=i.scalar(te,"int32"),ce=i.equal(_e,D).asType("float32"),fe=ce.mul(E).sum(0);H.push(fe)}return i.stack(H)},ue.prototype.argMin=function(E,D){X(E,"argMin");var A=[D];i.backend_util.assertAxesAreInnerMostDims("argMin",A,E.rank);for(var H=i.backend_util.computeOutAndReduceShapes(E.shape,A),se=H[0],te=H[1],_e=i.zeros(se,"int32"),ce=i.util.sizeFromShape(te),fe=this.readSync(_e.dataId),ve=this.readSync(E.dataId),ge=0;ge<fe.length;++ge){for(var Ae=ge*ce,Oe=ve[Ae],De=0,Ve=0;Ve<ce;++Ve){var Xe=ve[Ae+Ve];Xe<Oe&&(Oe=Xe,De=Ve)}fe[ge]=De}return _e},ue.prototype.argMax=function(E,D){X(E,"argMax");var A=[D];i.backend_util.assertAxesAreInnerMostDims("argMax",A,E.rank);for(var H=i.backend_util.computeOutAndReduceShapes(E.shape,A),se=H[0],te=H[1],_e=i.zeros(se,"int32"),ce=i.util.sizeFromShape(te),fe=this.readSync(_e.dataId),ve=this.readSync(E.dataId),ge=0;ge<fe.length;++ge){for(var Ae=ge*ce,Oe=ve[Ae],De=0,Ve=0;Ve<ce;++Ve){var Xe=ve[Ae+Ve];Xe>Oe&&(Oe=Xe,De=Ve)}fe[ge]=De}return _e},ue.prototype.cumsum=function(E,D,A,H){if(X(E,"cumsum"),D!==E.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(E.rank-1)+" "+("but got axis="+D));for(var se=i.upcastType(E.dtype,"int32"),te=i.zeros(E.shape,se),_e=this.readSync(te.dataId),ce=this.readSync(E.dataId),fe=E.shape[E.rank-1],ve=H?function(Ve,Xe){return Ve+fe-Xe-1}:function(Ve,Xe){return Ve+Xe},ge=0;ge<ce.length;ge+=fe)for(var Ae=0;Ae<fe;Ae++){var Oe=ve(ge,Ae);if(Ae===0)_e[Oe]=A?0:ce[Oe];else{var De=ve(ge,Ae-1);_e[Oe]=A?ce[De]+_e[De]:ce[Oe]+_e[De]}}return te},ue.prototype.equal=function(E,D){return X([E,D],"equal"),this.broadcastedBinaryOp(E,D,"bool",function(A,H){return A===H?1:0})},ue.prototype.notEqual=function(E,D){return X([E,D],"notEqual"),this.broadcastedBinaryOp(E,D,"bool",function(A,H){return A!==H?1:0})},ue.prototype.less=function(E,D){return X([E,D],"less"),this.broadcastedBinaryOp(E,D,"bool",function(A,H){return A<H?1:0})},ue.prototype.lessEqual=function(E,D){return X([E,D],"lessEqual"),this.broadcastedBinaryOp(E,D,"bool",function(A,H){return A<=H?1:0})},ue.prototype.greater=function(E,D){return X([E,D],"greater"),this.broadcastedBinaryOp(E,D,"bool",function(A,H){return A>H?1:0})},ue.prototype.greaterEqual=function(E,D){return X([E,D],"greaterEqual"),this.broadcastedBinaryOp(E,D,"bool",function(A,H){return A>=H?1:0})},ue.prototype.logicalAnd=function(E,D){return X([E,D],"logicalAnd"),this.broadcastedBinaryOp(E,D,"bool",function(A,H){return A&&H})},ue.prototype.logicalOr=function(E,D){return X([E,D],"logicalOr"),this.broadcastedBinaryOp(E,D,"bool",function(A,H){return A||H})},ue.prototype.select=function(E,D,A){X([E,D,A],"select");for(var H=this.readSync(E.dataId),se=this.readSync(D.dataId),te=this.readSync(A.dataId),_e=i.zeros(D.shape,i.upcastType(D.dtype,A.dtype)),ce=this.readSync(_e.dataId),fe=0,ve=E.rank===0||E.rank>1||D.rank===1?1:i.util.sizeFromShape(D.shape.slice(1)),ge=0;ge<H.length;ge++)for(var Ae=0;Ae<ve;Ae++)H[ge]===1?ce[fe++]=se[ge]:ce[fe++]=te[ge];return _e},ue.prototype.where=function(E){X([E],"where");var D=this.readSync(E.dataId);return ee(E.shape,D)},ue.prototype.topk=function(E,D,A){X(E,"topk");var H=this.readSync(E.dataId);return ye(H,E.shape,E.dtype,D,A)},ue.prototype.min=function(E,D){X(E,"min"),i.backend_util.assertAxesAreInnerMostDims("min",D,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,D),H=A[0],se=A[1],te=i.zeros(H,E.dtype),_e=i.util.sizeFromShape(se),ce=this.readSync(te.dataId),fe=this.readSync(E.dataId),ve=0;ve<ce.length;++ve){for(var ge=ve*_e,Ae=fe[ge],Oe=0;Oe<_e;++Oe){var De=fe[ge+Oe];De<Ae&&(Ae=De)}ce[ve]=Ae}return te},ue.prototype.minimum=function(E,D){return X([E,D],"minimum"),this.broadcastedBinaryOp(E,D,E.dtype,function(A,H){return Math.min(A,H)})},ue.prototype.mod=function(E,D){return X([E,D],"mod"),this.broadcastedBinaryOp(E,D,E.dtype,function(A,H){var se=A%H;return A<0&&H<0||A>=0&&H>=0?se:(se+H)%H})},ue.prototype.maximum=function(E,D){return X([E,D],"maximum"),this.broadcastedBinaryOp(E,D,E.dtype,function(A,H){return Math.max(A,H)})},ue.prototype.all=function(E,D){X(E,"all"),i.backend_util.assertAxesAreInnerMostDims("all",D,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,D),H=A[0],se=A[1],te=i.zeros(H,E.dtype),_e=i.util.sizeFromShape(se),ce=this.readSync(te.dataId),fe=this.readSync(E.dataId),ve=0;ve<ce.length;++ve){for(var ge=ve*_e,Ae=fe[ge],Oe=0;Oe<_e;++Oe){var De=fe[ge+Oe];Ae=Ae&&De}ce[ve]=Ae}return te},ue.prototype.any=function(E,D){X(E,"any"),i.backend_util.assertAxesAreInnerMostDims("any",D,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,D),H=A[0],se=A[1],te=i.zeros(H,E.dtype),_e=i.util.sizeFromShape(se),ce=this.readSync(te.dataId),fe=this.readSync(E.dataId),ve=0;ve<ce.length;++ve){for(var ge=ve*_e,Ae=fe[ge],Oe=0;Oe<_e;++Oe){var De=fe[ge+Oe];Ae=Ae||De}ce[ve]=Ae}return te},ue.prototype.squaredDifference=function(E,D){return X([E,D],"squaredDifference"),this.broadcastedBinaryOp(E,D,E.dtype,function(A,H){var se=A-H;return se*se})},ue.prototype.eluDer=function(E,D){X([E,D],"eluDer");for(var A=new Float32Array(D.size),H=this.readSync(D.dataId),se=this.readSync(E.dataId),te=0;te<H.length;++te){var _e=H[te];_e>=1?A[te]=se[te]:A[te]=se[te]*(_e+1)}return this.makeOutput(A,D.shape,"float32")},ue.prototype.atan2=function(E,D){return X([E,D],"atan2"),this.broadcastedBinaryOp(E,D,E.dtype,function(A,H){return Math.atan2(A,H)})},ue.prototype.tile=function(E,D){return X(E,"tile"),he(this.bufferSync(E),D)},ue.prototype.gather=function(E,D,A){X([E,D],"gather");var H=E.shape.slice(),se=this.readSync(D.dataId);H[A]=se.length;for(var te=i.buffer(H,E.dtype),_e=this.bufferSync(E),ce=0;ce<te.size;++ce){var fe=te.indexToLoc(ce),ve=fe.slice();ve[A]=se[fe[A]];var ge=_e.locToIndex(ve);te.values[ce]=_e.values[ge]}return te.toTensor()},ue.prototype.batchToSpaceND=function(E,D,A){X([E],"batchToSpaceND");var H=D.reduce(function(ve,ge){return ve*ge}),se=i.backend_util.getReshaped(E.shape,D,H),te=i.backend_util.getPermuted(se.length,D.length),_e=i.backend_util.getReshapedPermuted(E.shape,D,H),ce=i.backend_util.getSliceBeginCoords(A,D.length),fe=i.backend_util.getSliceSize(_e,A,D.length);return i.transpose(E.reshape(se),te).reshape(_e).slice(ce,fe)},ue.prototype.pool3d=function(E,D,A){X(E,"pool3d");for(var H=D.strideDepth,se=D.strideHeight,te=D.strideWidth,_e=D.dilationDepth,ce=D.dilationHeight,fe=D.dilationWidth,ve=D.effectiveFilterDepth,ge=D.effectiveFilterHeight,Ae=D.effectiveFilterWidth,Oe=D.padInfo.front,De=D.padInfo.top,Ve=D.padInfo.left,Xe=A==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,at=this.readSync(E.dataId),it=i.buffer(D.outShape,E.dtype),$=it.values,rt=D.outShape[1]*D.outShape[2]*D.outShape[3]*D.outShape[4],xt=D.outShape[2]*D.outShape[3]*D.outShape[4],ht=D.outShape[3]*D.outShape[4],_t=D.outShape[4],At=0;At<D.batchSize;++At)for(var zt=At*rt,Pt=At*E.strides[0],Ut=0;Ut<D.inChannels;++Ut)for(var Tt=0;Tt<D.outDepth;++Tt){for(var Xt=Tt*H-Oe,Ht=Xt;Ht<0;)Ht+=_e;for(var Ot=Math.min(D.inDepth,ve+Xt),Rt=zt+Tt*xt,wt=0;wt<D.outHeight;++wt){for(var Et=wt*se-De,Vt=Et;Vt<0;)Vt+=ce;for(var qt=Math.min(D.inHeight,ge+Et),lr=Rt+wt*ht,ir=0;ir<D.outWidth;++ir){for(var Ie=ir*te-Ve,br=Ie;br<0;)br+=fe;for(var Nr=Math.min(D.inWidth,Ae+Ie),Tr=lr+ir*_t,pr=Xe,Fr=0,mr=0,Er=Ht;Er<Ot;Er+=_e){for(var an=Pt+Er*E.strides[1],_n=Vt;_n<qt;_n+=ce){for(var ie=an+_n*E.strides[2],In=br;In<Nr;In+=fe){var wn=ie+In*E.strides[3],Re=at[wn+Ut];if(A==="max"&&Re>pr?pr=Re:A==="avg"&&(Fr+=Re,mr++),isNaN(pr))break}if(isNaN(pr))break}if(isNaN(pr))break}var Un=Tr+Ut;$[Un]=A==="avg"?Fr/mr:pr}}}return it.toTensor()},ue.prototype.avgPool3d=function(E,D){return X(E,"avgPool3d"),this.pool3d(E,D,"avg").toFloat()},ue.prototype.avgPool3dBackprop=function(E,D,A){X([E,D],"avgPool3dBackprop");for(var H=A.strideDepth,se=A.strideHeight,te=A.strideWidth,_e=A.filterDepth,ce=A.filterHeight,fe=A.filterWidth,ve=A.dilationDepth,ge=A.dilationHeight,Ae=A.dilationWidth,Oe=A.effectiveFilterDepth,De=A.effectiveFilterHeight,Ve=A.effectiveFilterWidth,Xe=Oe-1-A.padInfo.front,at=Ve-1-A.padInfo.left,it=De-1-A.padInfo.top,$=i.buffer(D.shape,"float32"),rt=1/(_e*ce*fe),xt=this.bufferSync(E),ht=0;ht<A.batchSize;++ht)for(var _t=0;_t<A.inChannels;++_t)for(var At=0;At<A.inDepth;++At)for(var zt=0;zt<A.inHeight;++zt)for(var Pt=0;Pt<A.inWidth;++Pt){for(var Ut=At-Xe,Tt=zt-it,Xt=Pt-at,Ht=0,Ot=0;Ot<Oe;Ot+=ve){var Rt=(Ut+Ot)/H;if(Rt<0||Rt>=A.outDepth||Math.floor(Rt)!==Rt)continue;for(var wt=0;wt<De;wt+=ge){var Et=(Tt+wt)/se;if(Et<0||Et>=A.outHeight||Math.floor(Et)!==Et)continue;for(var Vt=0;Vt<Ve;Vt+=Ae){var qt=(Xt+Vt)/te;if(qt<0||qt>=A.outWidth||Math.floor(qt)!==qt)continue;var lr=xt.get(ht,Rt,Et,qt,_t);Ht+=lr}}}$.set(Ht*rt,ht,At,zt,Pt,_t)}return $.toTensor()},ue.prototype.maxPool3d=function(E,D){return X(E,"maxPool3d"),this.pool3d(E,D,"max").toFloat()},ue.prototype.maxPool3dPositions=function(E,D){for(var A=i.buffer(D.outShape,"int32"),H=D.strideDepth,se=D.strideHeight,te=D.strideWidth,_e=D.dilationDepth,ce=D.dilationHeight,fe=D.dilationWidth,ve=D.effectiveFilterDepth,ge=D.effectiveFilterHeight,Ae=D.effectiveFilterWidth,Oe=D.padInfo.front,De=D.padInfo.top,Ve=D.padInfo.left,Xe=this.bufferSync(E),at=0;at<D.batchSize;++at)for(var it=0;it<D.inChannels;++it)for(var $=0;$<D.outDepth;++$){for(var rt=$*H-Oe,xt=rt;xt<0;)xt+=_e;for(var ht=Math.min(D.inDepth,ve+rt),_t=0;_t<D.outHeight;++_t){for(var At=_t*se-De,zt=At;zt<0;)zt+=ce;for(var Pt=Math.min(D.inHeight,ge+At),Ut=0;Ut<D.outWidth;++Ut){for(var Tt=Ut*te-Ve,Xt=Tt;Xt<0;)Xt+=fe;for(var Ht=Math.min(D.inWidth,Ae+Tt),Ot=Number.NEGATIVE_INFINITY,Rt=-1,wt=xt;wt<ht;wt+=_e)for(var Et=wt-rt,Vt=zt;Vt<Pt;Vt+=ce)for(var qt=Vt-At,lr=Xt;lr<Ht;lr+=fe){var ir=lr-Tt,Ie=Xe.get(at,wt,Vt,lr,it);Ie>=Ot&&(Ot=Ie,Rt=Et*ge*Ae+qt*ge+ir)}A.set(Rt,at,$,_t,Ut,it)}}}return A.toTensor()},ue.prototype.maxPool3dBackprop=function(E,D,A,H){X([D,A],"maxPool3dBackprop");for(var se=this.maxPool3dPositions(D,H),te=H.strideDepth,_e=H.strideHeight,ce=H.strideWidth,fe=H.dilationDepth,ve=H.dilationHeight,ge=H.dilationWidth,Ae=H.effectiveFilterDepth,Oe=H.effectiveFilterHeight,De=H.effectiveFilterWidth,Ve=Ae-1-H.padInfo.front,Xe=De-1-H.padInfo.left,at=Oe-1-H.padInfo.top,it=i.buffer(D.shape,"float32"),$=this.bufferSync(se),rt=this.bufferSync(E),xt=0;xt<H.batchSize;++xt)for(var ht=0;ht<H.inChannels;++ht)for(var _t=0;_t<H.inDepth;++_t)for(var At=0;At<H.inHeight;++At)for(var zt=0;zt<H.inWidth;++zt){for(var Pt=_t-Ve,Ut=At-at,Tt=zt-Xe,Xt=0,Ht=0;Ht<Ae;Ht+=fe){var Ot=(Pt+Ht)/te;if(Ot<0||Ot>=H.outDepth||Math.floor(Ot)!==Ot)continue;for(var Rt=0;Rt<Oe;Rt+=ve){var wt=(Ut+Rt)/_e;if(wt<0||wt>=H.outHeight||Math.floor(wt)!==wt)continue;for(var Et=0;Et<De;Et+=ge){var Vt=(Tt+Et)/ce;if(Vt<0||Vt>=H.outWidth||Math.floor(Vt)!==Vt)continue;var qt=Ae*Oe*De-1-$.get(xt,Ot,wt,Vt,ht),lr=Ht*Oe*De+Rt*De+Et,ir=qt===lr?1:0;if(ir===0)continue;var Ie=rt.get(xt,Ot,wt,Vt,ht);Xt+=Ie*ir}}}it.set(Xt,xt,_t,At,zt,ht)}return it.toTensor()},ue.prototype.resizeBilinear=function(E,D,A,H){X(E,"resizeBilinear");for(var se=E.shape,te=se[0],_e=se[1],ce=se[2],fe=se[3],ve=this.readSync(E.dataId),ge=new Float32Array(i.util.sizeFromShape([te,D,A,fe])),Ae=[H&&D>1?_e-1:_e,H&&A>1?ce-1:ce],Oe=[H&&D>1?D-1:D,H&&A>1?A-1:A],De=0,Ve=Ae[0]/Oe[0],Xe=Ae[1]/Oe[1],at=0;at<te;at++)for(var it=0;it<D;it++)for(var $=Ve*it,rt=Math.floor($),xt=$-rt,ht=Math.min(_e-1,Math.ceil($)),_t=at*E.strides[0]+rt*E.strides[1],At=at*E.strides[0]+ht*E.strides[1],zt=0;zt<A;zt++)for(var Pt=Xe*zt,Ut=Math.floor(Pt),Tt=Pt-Ut,Xt=Math.min(ce-1,Math.ceil(Pt)),Ht=_t+Ut*E.strides[2],Ot=At+Ut*E.strides[2],Rt=_t+Xt*E.strides[2],wt=At+Xt*E.strides[2],Et=0;Et<fe;Et++){var Vt=ve[Ht+Et],qt=ve[Ot+Et],lr=ve[Rt+Et],ir=ve[wt+Et],Ie=Vt+(lr-Vt)*Tt,br=qt+(ir-qt)*Tt,Nr=Ie+(br-Ie)*xt;ge[De++]=Nr}return i.tensor(ge,[te,D,A,fe])},ue.prototype.resizeBilinearBackprop=function(E,D,A){X([E,D],"resizeBilinearBackprop");for(var H=D.shape,se=H[0],te=H[1],_e=H[2],ce=H[3],fe=E.shape,ve=fe[1],ge=fe[2],Ae=new Float32Array(se*te*_e*ce),Oe=[A&&ve>1?te-1:te,A&&ge>1?_e-1:_e],De=[A&&ve>1?ve-1:ve,A&&ge>1?ge-1:ge],Ve=Oe[0]/De[0],Xe=Oe[1]/De[1],at=this.readSync(E.dataId),it=0,$=0;$<se;$++)for(var rt=$*D.strides[0],xt=0;xt<ve;xt++)for(var ht=xt*Ve,_t=Math.floor(ht),At=Math.min(Math.ceil(ht),te-1),zt=rt+_t*D.strides[1],Pt=rt+At*D.strides[1],Ut=ht-_t,Tt=1-Ut,Xt=0;Xt<ge;Xt++)for(var Ht=Xt*Xe,Ot=Math.floor(Ht),Rt=Math.min(Math.ceil(Ht),_e-1),wt=Ht-Ot,Et=1-wt,Vt=zt+Ot*D.strides[2],qt=zt+Rt*D.strides[2],lr=Pt+Ot*D.strides[2],ir=Pt+Rt*D.strides[2],Ie=Tt*Et,br=Tt*wt,Nr=Ut*Et,Tr=Ut*wt,pr=0;pr<ce;pr++){var Fr=at[it++];Ae[Vt+pr]+=Fr*Ie,Ae[qt+pr]+=Fr*br,Ae[lr+pr]+=Fr*Nr,Ae[ir+pr]+=Fr*Tr}return i.tensor4d(Ae,[se,_e,te,ce],D.dtype)},ue.prototype.resizeNearestNeighbor=function(E,D,A,H){X(E,"resizeNearestNeighbor");for(var se=E.shape,te=se[0],_e=se[1],ce=se[2],fe=se[3],ve=this.readSync(E.dataId),ge=new Float32Array(te*D*A*fe),Ae=[H&&D>1?_e-1:_e,H&&A>1?ce-1:ce],Oe=[H&&D>1?D-1:D,H&&A>1?A-1:A],De=Ae[0]/Oe[0],Ve=Ae[1]/Oe[1],Xe=0,at=0;at<te;at++)for(var it=at*E.strides[0],$=0;$<D;$++)for(var rt=De*$,xt=Math.min(_e-1,H?Math.round(rt):Math.floor(rt)),ht=it+xt*E.strides[1],_t=0;_t<A;_t++)for(var At=Ve*_t,zt=Math.min(ce-1,H?Math.round(At):Math.floor(At)),Pt=ht+zt*E.strides[2],Ut=0;Ut<fe;Ut++){var Tt=ve[Pt+Ut];ge[Xe++]=Tt}return i.tensor(ge,[te,D,A,fe],E.dtype)},ue.prototype.resizeNearestNeighborBackprop=function(E,D,A){X([E,D],"resizeNearestNeighborBackprop");for(var H=D.shape,se=H[0],te=H[1],_e=H[2],ce=H[3],fe=E.shape,ve=fe[1],ge=fe[2],Ae=new Float32Array(se*te*_e*ce),Oe=this.readSync(E.dataId),De=[A&&ve>1?te-1:te,A&&ge>1?_e-1:_e],Ve=[A&&ve>1?ve-1:ve,A&&ge>1?ge-1:ge],Xe=De[0]/Ve[0],at=De[1]/Ve[1],it=1/Xe,$=1/at,rt=Math.ceil(it)*2+2,xt=Math.ceil($)*2+2,ht=0;ht<se;ht++)for(var _t=ht*D.strides[0],At=0;At<te;At++)for(var zt=_t+At*D.strides[1],Pt=Math.floor(At*it),Ut=Math.floor(Pt-rt/2),Tt=0;Tt<_e;Tt++)for(var Xt=zt+Tt*D.strides[2],Ht=Math.floor(Tt*$),Ot=Math.floor(Ht-xt/2),Rt=0;Rt<ce;Rt++){for(var wt=0,Et=0;Et<rt;Et++){var Vt=Et+Ut;if(Vt<0||Vt>=ve)continue;var qt=_t+Vt*E.strides[1],lr=Vt*Xe,ir=Math.min(te-1,A?Math.round(lr):Math.floor(lr));if(At!==ir)continue;for(var Ie=0;Ie<xt;Ie++){var br=Ie+Ot;if(br<0||br>=ge)continue;var Nr=qt+br*E.strides[2],Tr=br*at,pr=Math.min(_e-1,A?Math.round(Tr):Math.floor(Tr));Tt===pr&&(wt+=Oe[Nr+Rt])}}Ae[Xt+Rt]=wt}return i.tensor4d(Ae,D.shape,D.dtype)},ue.prototype.localResponseNormalization4D=function(E,D,A,H,se){X(E,"localResponseNormalization4D");var te=E.shape[3],_e=te-1,ce=this.readSync(E.dataId),fe=E.size,ve=new Float32Array(fe);function ge(Ve){for(var Xe=Ve%te,at=Ve-Xe+Math.max(0,Xe-D),it=Ve-Xe+Math.min(Xe+D,_e),$=0;at<=it;at++){var rt=ce[at];$+=rt*rt}return $}for(var Ae=0;Ae<fe;Ae++){var Oe=ge(Ae),De=ce[Ae]*Math.pow(A+H*Oe,-se);ve[Ae]=De}return i.tensor4d(ve,E.shape)},ue.prototype.LRNGrad=function(E,D,A,H,se,te,_e){X(E,"LRNGrad");for(var ce=E.shape[3],fe=this.readSync(E.dataId),ve=this.readSync(D.dataId),ge=this.readSync(A.dataId),Ae=new Float32Array(E.size),Oe=E.size,De=0;De<Oe;De++){for(var Ve=De%ce,Xe=De-Ve+Math.max(0,Ve-H),at=De-Ve+Math.min(ce,Ve+H+1),it=0,$=Xe;$<at;$++)it+=Math.pow(ve[$],2);it=te*it+se;for(var $=Xe;$<at;$++){var rt=-2*te*_e*ve[$]*ge[De]/it;De===$&&(rt+=Math.pow(it,-_e)),rt*=fe[De],Ae[$]+=rt}}return i.tensor4d(Ae,E.shape)},ue.prototype.multinomial=function(E,D,A,H){X(E,"multinomial");for(var se=D?E:i.softmax(E),te=se.shape[0],_e=se.shape[1],ce=i.zeros([te,A],"int32"),fe=this.readSync(ce.dataId),ve=this.readSync(se.dataId),ge=0;ge<te;++ge){var Ae=ge*_e,Oe=new Float32Array(_e-1);Oe[0]=ve[Ae];for(var De=1;De<Oe.length;++De)Oe[De]=Oe[De-1]+ve[Ae+De];for(var Ve=we.alea(H.toString()),Xe=ge*A,at=0;at<A;++at){var it=Ve();fe[Xe+at]=Oe.length;for(var $=0;$<Oe.length;$++)if(it<Oe[$]){fe[Xe+at]=$;break}}}return ce},ue.prototype.oneHot=function(E,D,A,H){X(E,"oneHot");var se=new Float32Array(E.size*D);se.fill(H);for(var te=this.readSync(E.dataId),_e=0;_e<E.size;++_e)te[_e]>=0&&te[_e]<D&&(se[_e*D+te[_e]]=A);return i.tensor2d(se,[E.size,D],"int32")},ue.prototype.nonMaxSuppression=function(E,D,A,H,se){X(E,"nonMaxSuppression");var te=this.readSync(E.dataId),_e=this.readSync(D.dataId);return Te(te,_e,A,H,se)},ue.prototype.depthToSpace=function(E,D,A){i.util.assert(A==="NHWC",function(){return"Only NHWC dataFormat supported on CPU for depthToSpace. Got "+A}),i.util.assert(D>1,function(){return"blockSize should be > 1 for depthToSpace, but was: "+D});for(var H=E.shape[0],se=E.shape[1],te=E.shape[2],_e=E.shape[3],ce=se*D,fe=te*D,ve=_e/(D*D),ge=this.readSync(E.dataId),Ae=new Float32Array(H*ce*fe*ve),Oe=0,De=0;De<H;++De)for(var Ve=0;Ve<ce;++Ve)for(var Xe=Math.floor(Ve/D),at=Ve%D,it=0;it<fe;++it)for(var $=Math.floor(it/D),rt=it%D,xt=(at*D+rt)*ve,ht=0;ht<ve;++ht){var _t=ht+xt,At=_t+_e*($+te*(Xe+se*De));Ae[Oe++]=ge[At]}return i.tensor4d(Ae,[H,ce,fe,ve])},ue.prototype.broadcastedBinaryOp=function(E,D,A,H){var se=i.backend_util.assertAndGetBroadcastShape(E.shape,D.shape),te=i.buffer(se,A),_e=this.readSync(E.dataId),ce=this.readSync(D.dataId),fe=i.backend_util.getBroadcastDims(E.shape,se),ve=i.backend_util.getBroadcastDims(D.shape,se),ge=te.values;if(fe.length+ve.length===0)for(var Ae=0;Ae<ge.length;++Ae)ge[Ae]=H(_e[Ae%_e.length],ce[Ae%ce.length]);else for(var Oe=this.bufferSync(E),De=this.bufferSync(D),Ve=function(at){var it=te.indexToLoc(at),$=it.slice(-E.rank);fe.forEach(function(_t){return $[_t]=0});var rt=Oe.locToIndex($),xt=it.slice(-D.rank);ve.forEach(function(_t){return xt[_t]=0});var ht=De.locToIndex(xt);ge[at]=H(_e[rt],ce[ht])},Ae=0;Ae<ge.length;++Ae)Ve(Ae);return te.toTensor()},ue.prototype.split=function(E,D,A){return z(E,D,A)},ue.prototype.dispose=function(){},ue.prototype.floatPrecision=function(){return 32},ue.prototype.epsilon=function(){return ae.prototype.epsilon.call(this)},ue.prototype.cropAndResize=function(E,D,A,H,se,te){for(var _e=E.shape,ce=_e[0],fe=_e[1],ve=_e[2],ge=_e[3],Ae=D.shape[0],Oe=H[0],De=H[1],Ve=i.buffer([Ae,Oe,De,ge],"float32"),Xe=this.readSync(D.dataId),at=this.readSync(A.dataId),it=this.readSync(E.dataId),$=E.strides,rt=Ve.strides,xt=0;xt<Ae;xt++){var ht=xt*4,_t=Xe[ht],At=Xe[ht+1],zt=Xe[ht+2],Pt=Xe[ht+3],Ut=at[xt];if(Ut>=ce)continue;for(var Tt=Oe>1?(zt-_t)*(fe-1)/(Oe-1):0,Xt=De>1?(Pt-At)*(ve-1)/(De-1):0,Ht=0;Ht<Oe;Ht++){var Ot=Oe>1?_t*(fe-1)+Ht*Tt:.5*(_t+zt)*(fe-1);if(Ot<0||Ot>fe-1){for(var Rt=0;Rt<De;Rt++)for(var wt=0;wt<ge;wt++){var Et=wt+Rt*rt[2]+Ht*rt[1]+xt*rt[0];Ve.values[Et]=te}continue}if(se==="bilinear")for(var Vt=Math.floor(Ot),qt=Math.ceil(Ot),lr=Ot-Vt,Rt=0;Rt<De;Rt++){var ir=De>1?At*(ve-1)+Rt*Xt:.5*(At+Pt)*(ve-1);if(ir<0||ir>ve-1){for(var wt=0;wt<ge;wt++){var Et=wt+Rt*rt[2]+Ht*rt[1]+xt*rt[0];Ve.values[Et]=te}continue}for(var Ie=Math.floor(ir),br=Math.ceil(ir),Nr=ir-Ie,wt=0;wt<ge;wt++){var Et=wt+Ie*$[2]+Vt*$[1]+Ut*$[0],Tr=it[Et];Et=wt+br*$[2]+Vt*$[1]+Ut*$[0];var pr=it[Et];Et=wt+Ie*$[2]+qt*$[1]+Ut*$[0];var Fr=it[Et];Et=wt+br*$[2]+qt*$[1]+Ut*$[0];var mr=it[Et],Er=Tr+(pr-Tr)*Nr,an=Fr+(mr-Fr)*Nr;Et=wt+Rt*rt[2]+Ht*rt[1]+xt*rt[0],Ve.values[Et]=Er+(an-Er)*lr}}else for(var Rt=0;Rt<De;++Rt){var ir=De>1?At*(ve-1)+Rt*Xt:.5*(At+Pt)*(ve-1);if(ir<0||ir>ve-1){for(var wt=0;wt<ge;wt++){var Et=wt+Rt*rt[2]+Ht*rt[1]+xt*rt[0];Ve.values[Et]=te}continue}for(var _n=Math.round(ir),ie=Math.round(Ot),wt=0;wt<ge;wt++){var In=wt+_n*$[2]+ie*$[1]+Ut*$[0],wn=wt+Rt*rt[2]+Ht*rt[1]+xt*rt[0];Ve.values[wn]=it[In]}}}}return Ve.toTensor()},ue.prototype.sparseToDense=function(E,D,A,H){var se=i.backend_util.calculateShapes(D,E,A),te=se.sliceRank,_e=se.numUpdates,ce=se.sliceSize,fe=se.strides,ve=se.outputSize,ge=!1;return this.scatter(E,D,A,ve,ce,_e,te,fe,H,ge)},ue.prototype.gatherND=function(E,D){var A=D.shape,H=A[A.length-1],se=i.backend_util.prepareAndValidate(E,D),te=se[0],_e=se[1],ce=se[2],fe=se[3];if(_e===0)return i.tensor([],te,E.dtype);for(var ve=new i.TensorBuffer([_e,ce],E.dtype),ge=this.readSync(D.dataId),Ae=this.readSync(E.dataId),Oe=0;Oe<_e;Oe++){for(var De=[],Ve=0,Xe=0;Xe<H;Xe++){var at=ge[Oe*H+Xe];Ve+=at*fe[Xe],De.push(at)}if(Ve<0||Ve>=E.size/ce)throw new Error("Invalid indices: "+De+" does not index into "+E.shape);for(var it=0;it<ce;it++)ve.values[Oe*ce+it]=Ae[Ve*ce+it]}return ve.toTensor().reshape(te)},ue.prototype.scatterND=function(E,D,A){var H=i.backend_util.calculateShapes(D,E,A),se=H.sliceRank,te=H.numUpdates,_e=H.sliceSize,ce=H.strides,fe=H.outputSize,ve=i.scalar(0),ge=!0;return this.scatter(E,D,A,fe,_e,te,se,ce,ve,ge)},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 D=i.util.getArrayFromDType(E.dtype,i.util.sizeFromShape(E.shape));return this.makeOutput(D,E.shape,E.dtype)},ue.prototype.linspace=function(E,D,A){return i.backend_util.linspaceImpl(E,D,A)},ue.prototype.scatter=function(E,D,A,H,se,te,_e,ce,fe,ve){var ge=[H/se,se],Ae=this.readSync(E.dataId),Oe=this.readSync(D.dataId);if(H===0)return i.tensor([],A,D.dtype);var De=new i.TensorBuffer(ge,D.dtype);De.values.fill(this.readSync(fe.dataId)[0]);for(var Ve=0;Ve<te;Ve++){for(var Xe=[],at=0,it=0;it<_e;it++){var $=Ae[Ve*_e+it];Xe.push($),at+=$*ce[it]}if(at<0||at>=H/se)throw new Error("Invalid indices: "+Xe+" does not index into "+A);for(var rt=0;rt<se;rt++)ve?De.values[at*se+rt]+=Oe[Ve*se+rt]:De.values[at*se+rt]=D.rank===0?Oe[0]:Oe[Ve*se+rt]}return De.toTensor().reshape(A)},ue}(i.KernelBackend);function xe(ae){for(var ue=new Float32Array(ae.length),E=0;E<ae.length;++E)ue[E]=Math.abs(ae[E]);return ue}var We=function(ae){var ue=ae.inputs.x,E=ae.backend,D=new Float32Array(i.util.sizeFromShape(ue.shape));if(ue.dtype!=="complex64"){var A=E.data.get(ue.dataId).values;D=xe(A)}else for(var H=E.data.get(ue.dataId),se=H.complexTensorInfos.real,te=H.complexTensorInfos.imag,_e=E.data.get(se.dataId).values,ce=E.data.get(te.dataId).values,fe=0;fe<_e.length;fe++){var ve=_e[fe],ge=ce[fe];D[fe]=Math.hypot(ve,ge)}return E.makeOutput(D,ue.shape,"float32")},W={kernelName:i.Abs,backendName:"cpu",kernelFunc:We};function st(ae){return function(ue,E,D,A,H){var se=i.backend_util.assertAndGetBroadcastShape(ue,E),te=se.length,_e=i.util.computeStrides(se),ce=i.util.sizeFromShape(se),fe=i.util.getTypedArrayFromDType(H,ce),ve=ue.length,ge=E.length,Ae=i.util.computeStrides(ue),Oe=i.util.computeStrides(E),De=i.backend_util.getBroadcastDims(ue,se),Ve=i.backend_util.getBroadcastDims(E,se);if(De.length+Ve.length===0)for(var Xe=0;Xe<fe.length;++Xe)fe[Xe]=ae(D[Xe%D.length],A[Xe%A.length]);else for(var at=function($){var rt=i.util.indexToLoc($,te,_e),xt=rt.slice(-ve);De.forEach(function(zt){return xt[zt]=0});var ht=i.util.locToIndex(xt,ve,Ae),_t=rt.slice(-ge);Ve.forEach(function(zt){return _t[zt]=0});var At=i.util.locToIndex(_t,ge,Oe);fe[$]=ae(D[ht],A[At])},Xe=0;Xe<fe.length;++Xe)at(Xe);return[fe,se]}}function ut(ae){var ue=ae.inputs,E=ae.backend,D=ue.real,A=ue.imag,H=E.data.get(D.dataId).values,se=E.data.get(A.dataId).values,te=E.makeTensorInfo(D.shape,"complex64"),_e=E.data.get(te.dataId);return _e.complexTensorInfos={real:E.makeTensorInfo(D.shape,"float32",H),imag:E.makeTensorInfo(A.shape,"float32",se)},te}var Kt={kernelName:i.Complex,backendName:"cpu",kernelFunc:ut};function It(ae){var ue=ae.inputs,E=ae.backend,D=ue.x;return E.incRef(D.dataId),{dataId:D.dataId,shape:D.shape,dtype:D.dtype}}var Ze={kernelName:i.Identity,backendName:"cpu",kernelFunc:It};function mt(ae){var ue=ae.inputs,E=ae.backend,D=ue.input,A=E.data.get(D.dataId).complexTensorInfos.real,H=E.data.get(A.dataId).values;return E.makeTensorInfo(A.shape,A.dtype,H)}var yt={kernelName:i.Real,backendName:"cpu",kernelFunc:mt};function $e(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=D.dtype;if(H==="complex64"){if(A.dtype==="complex64")return It({inputs:{x:A},backend:E});var se=i.zeros(A.shape),te=$e({inputs:{x:A},backend:E,attrs:{dtype:"float32"}}),_e=ut({inputs:{real:te,imag:se},backend:E});return se.dispose(),E.disposeIntermediateTensorInfo(te),_e}if(A.dtype==="complex64"){var ce=mt({inputs:{input:A},backend:E}),_e=$e({inputs:{x:ce},backend:E,attrs:{dtype:H}});return E.disposeIntermediateTensorInfo(ce),_e}if(!i.util.hasEncodingLoss(A.dtype,H)){var _e=It({inputs:{x:A},backend:E});return{dataId:_e.dataId,shape:_e.shape,dtype:H}}if(H==="int32"){var fe=E.data.get(A.dataId).values,ve=Int32Array.from(fe);return E.makeTensorInfo(A.shape,"int32",ve)}if(H==="bool"){var ge=E.data.get(A.dataId).values,Ae=i.util.toTypedArray([0],A.dtype),Oe=st(function(Xe,at){return Xe!==at?1:0})(A.shape,[],ge,Ae,"bool"),De=Oe[0],Ve=Oe[1];return E.makeTensorInfo(Ve,"bool",De)}throw new Error("Error in Cast: failed to cast "+A.dtype+" to "+H)}var ot={kernelName:i.Cast,backendName:"cpu",kernelFunc:$e};function nt(ae,ue,E,D){return E==null?function(A){var H=A.inputs,se=A.backend,te=H,_e=te.a,ce=te.b,fe=se;X([_e,ce],ae);var ve=fe.data.get(_e.dataId).values,ge=fe.data.get(ce.dataId).values,Ae=D||_e.dtype,Oe=ue(_e.shape,ce.shape,ve,ge,Ae),De=Oe[0],Ve=Oe[1];return fe.makeTensorInfo(Ve,Ae,De)}:function(A){var H=A.inputs,se=A.backend,te=H,_e=te.a,ce=te.b,fe=se;if(_e.dtype==="complex64"||ce.dtype==="complex64"){var ve=$e({inputs:{x:_e},backend:fe,attrs:{dtype:"complex64"}}),ge=fe.data.get(ve.dataId),Ae=ge.complexTensorInfos.real,Oe=ge.complexTensorInfos.imag,De=fe.data.get(Ae.dataId).values,Ve=fe.data.get(Oe.dataId).values,Xe=$e({inputs:{x:ce},backend:fe,attrs:{dtype:"complex64"}}),at=fe.data.get(Xe.dataId),it=at.complexTensorInfos.real,$=at.complexTensorInfos.imag,rt=fe.data.get(it.dataId).values,xt=fe.data.get($.dataId).values,ht=E(_e.shape,ce.shape,De,Ve,rt,xt),_t=ht[0],At=ht[1],zt=ht[2],Pt=fe.makeTensorInfo(zt,"float32",_t),Ut=fe.makeTensorInfo(zt,"float32",At),Tt=ut({inputs:{real:Pt,imag:Ut},backend:fe});return fe.disposeIntermediateTensorInfo(ve),fe.disposeIntermediateTensorInfo(Xe),fe.disposeIntermediateTensorInfo(Pt),fe.disposeIntermediateTensorInfo(Ut),Tt}else{var Xt=fe.data.get(_e.dataId).values,Ht=fe.data.get(ce.dataId).values,Ot=D||_e.dtype,Rt=ue(_e.shape,ce.shape,Xt,Ht,Ot),wt=Rt[0],zt=Rt[1];return fe.makeTensorInfo(zt,Ot,wt)}}}function et(ae){return function(ue,E,D,A,H,se){var te=i.backend_util.assertAndGetBroadcastShape(ue,E),_e=i.util.sizeFromShape(te),ce=te.length,fe=i.util.computeStrides(te),ve=i.util.getTypedArrayFromDType("float32",_e),ge=i.util.getTypedArrayFromDType("float32",_e),Ae=i.backend_util.getBroadcastDims(ue,te),Oe=i.backend_util.getBroadcastDims(E,te),De=i.backend_util.mergeRealAndImagArrays(D,A),Ve=i.backend_util.mergeRealAndImagArrays(H,se),Xe=ue.length,at=i.util.computeStrides(ue),it=E.length,$=i.util.computeStrides(E);if(Ae.length+Oe.length===0)for(var rt=0;rt<ve.length;rt++){var xt=rt%De.length,ht=rt%Ve.length,_t=ae(De[xt*2],De[xt*2+1],Ve[ht*2],Ve[ht*2+1]);ve[rt]=_t.real,ge[rt]=_t.imag}else for(var At=function(Pt){var Ut=i.util.indexToLoc(Pt,ce,fe),Tt=Ut.slice(-Xe);Ae.forEach(function(wt){return Tt[wt]=0});var Xt=i.util.locToIndex(Tt,Xe,at),Ht=Ut.slice(-it);Oe.forEach(function(wt){return Ht[wt]=0});var Ot=i.util.locToIndex(Ht,it,$),Rt=ae(De[Xt*2],De[Xt*2+1],Ve[Ot*2],Ve[Ot*2+1]);ve[Pt]=Rt.real,ge[Pt]=Rt.imag},rt=0;rt<ve.length;rt++)At(rt);return[ve,ge,te]}}var Qt=st(function(ae,ue){return ae+ue}),rr=et(function(ae,ue,E,D){return{real:ae+E,imag:ue+D}}),jt=nt(i.Add,Qt,rr),jr={kernelName:i.Add,backendName:"cpu",kernelFunc:jt};function Pr(ae){return function(ue,E,D){for(var A=i.util.getTypedArrayFromDType(E,ue.length),H=0;H<ue.length;++H)A[H]=ae(ue[H],D);return A}}function _r(ae,ue,E){return function(D){var A=D.inputs,H=D.attrs,se=D.backend,te=A.x;if(X(te,ae),te.dtype==="string"||E==="string")throw new Error("unaryKernelFunc does not support string input/output");for(var _e=se,ce=_e.data.get(te.dataId).values,fe=i.util.sizeFromShape(te.shape),ve=E||te.dtype,ge=i.util.getArrayFromDType(ve,fe),Ae=0;Ae<fe;++Ae)ge[Ae]=ue(ce[Ae],H);return _e.makeTensorInfo(te.shape,ve,ge)}}function ar(ae,ue,E){return function(D){var A=D.inputs,H=D.attrs,se=D.backend,te=A.x;if(X(te,ae),te.dtype==="string"||E==="string")throw new Error("unaryKernelFunc does not support string input/output");var _e=se,ce=_e.data.get(te.dataId).values,fe=E||te.dtype,ve=ue(ce,fe,H);return _e.makeTensorInfo(te.shape,fe,ve)}}var da=Pr(function(ae){return Math.ceil(ae)}),Ha=ar(i.Ceil,da),Tn={kernelName:i.Ceil,backendName:"cpu",kernelFunc:Ha},ba=Pr(function(ae){return Math.exp(ae)}),ka=ar(i.Exp,ba),ta={kernelName:i.Exp,backendName:"cpu",kernelFunc:ka},Ma=Pr(function(ae){return Math.expm1(ae)}),Ti=ar(i.Expm1,Ma),Bn={kernelName:i.Expm1,backendName:"cpu",kernelFunc:Ti},ra=Pr(function(ae){return Math.floor(ae)}),cn=ar(i.Floor,ra),za={kernelName:i.Floor,backendName:"cpu",kernelFunc:cn},fn=Pr(function(ae){return Math.log(ae)}),Gn=ar(i.Log,fn),_i={kernelName:i.Log,backendName:"cpu",kernelFunc:Gn};function fa(ae,ue,E,D){for(var A=i.util.getTypedArrayFromDType(D,i.util.sizeFromShape(E)),H=0;H<A.length;++H){for(var se=H*ue,te=ae[se],_e=0;_e<ue;++_e){var ce=ae[se+_e];ce>te&&(te=ce)}A[H]=te}return A}var Hi=st(function(ae,ue){return ae*ue}),Yn=et(function(ae,ue,E,D){return{real:ae*E-ue*D,imag:ae*D+ue*E}}),Wn=nt(i.Multiply,Hi,Yn),Ga={kernelName:i.Multiply,backendName:"cpu",kernelFunc:Wn},Sa=st(function(ae,ue){return ae!==ue?1:0}),hi=nt(i.NotEqual,Sa,null,"bool"),La={kernelName:i.NotEqual,backendName:"cpu",kernelFunc:hi},on=Pr(function(ae){return 1/Math.sqrt(ae)}),xn=ar(i.Rsqrt,on),Ia={kernelName:i.Rsqrt,backendName:"cpu",kernelFunc:xn};function Rr(ae,ue,E,D,A){var H=i.slice_util.isSliceContinous(D,ue,E),se=i.util.sizeFromShape(E),te=i.util.computeStrides(D);if(H){var _e=i.slice_util.computeFlatOffset(ue,te);return ae.subarray(_e,_e+se)}for(var ce=i.util.getTypedArrayFromDType(A,se),fe=0;fe<se;++fe){var ve=E.length,ge=i.util.computeStrides(E),Ae=i.util.indexToLoc(fe,ve,ge),Oe=Ae.map(function(Ve,Xe){return Ve+ue[Xe]}),De=i.util.locToIndex(Oe,D.length,te);ce[fe]=ae[De]}return ce}function Pa(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=D.begin,se=D.size;X(A,"slice");var te=i.slice_util.parseSliceParams(A,H,se),_e=te[0],ce=te[1];i.slice_util.assertParamsValid(A,_e,ce);var fe=E.data.get(A.dataId).values,ve=Rr(fe,_e,ce,A.shape,A.dtype);return E.makeTensorInfo(ce,A.dtype,ve)}var na={kernelName:i.Slice,backendName:"cpu",kernelFunc:Pa},Ei=st(function(ae,ue){var E=ae-ue;return E*E}),Gi=nt(i.SquaredDifference,Ei),Ri={kernelName:i.SquaredDifference,backendName:"cpu",kernelFunc:Gi},jn=st(function(ae,ue){return ae-ue}),ni=et(function(ae,ue,E,D){return{real:ae-E,imag:ue-D}}),pi=nt(i.Sub,jn,ni),ma={kernelName:i.Sub,backendName:"cpu",kernelFunc:pi};function di(ae,ue,E,D,A){for(var H=ue.length,se=i.util.sizeFromShape(ue),te=i.util.computeStrides(ue),_e=i.util.computeStrides(A),ce=i.util.getTypedArrayFromDType(E,i.util.sizeFromShape(A)),fe=0;fe<se;++fe){for(var ve=i.util.indexToLoc(fe,H,te),ge=new Array(ve.length),Ae=0;Ae<ge.length;Ae++)ge[Ae]=ve[D[Ae]];var Oe=i.util.locToIndex(ge,H,_e);ce[Oe]=ae[fe]}return ce}function fi(ae,ue,E,D){for(var A=i.util.parseAxisParam(ue,E)[0],H=[1,E[0],1],se=0;se<A;se++)H[0]*=E[se];H[1]=E[A];for(var se=A+1;se<E.length;se++)H[2]*=E[se];for(var te={},_e=new Int32Array(E[A]),ce=new i.TensorBuffer(H,D,ae),fe=[],ve=H[0]===1&&H[2]===1,se=0;se<E[A];se++){var ge=void 0;if(ve)ge=ae[se].toString();else{for(var Ae=[],Oe=0;Oe<H[0];Oe++)for(var De=0;De<H[2];De++)Ae.push(ce.get(Oe,se,De));ge=Ae.join(",")}if(te[ge]!==void 0)_e[se]=te[ge];else{var Ve=Object.keys(te).length;te[ge]=Ve,_e[se]=Ve,fe.push(se)}}var Xe=H.slice();Xe[1]=Object.keys(te).length;var at=new i.TensorBuffer(Xe,D);fe.forEach(function($,rt){for(var xt=0;xt<H[0];xt++)for(var ht=0;ht<H[2];ht++)at.set(ce.get(xt,$,ht),xt,rt,ht)});var it=E.slice();return it[A]=Xe[1],{outputValues:at.values,outputShape:it,indices:_e}}var ja={__proto__:null,simpleAbsImpl:xe,addImpl:Qt,ceilImpl:da,expImpl:ba,expm1Impl:Ma,floorImpl:ra,logImpl:fn,maxImpl:fa,multiplyImpl:Hi,notEqualImpl:Sa,rsqrtImpl:on,sliceImpl:Rr,squaredDifferenceImpl:Ei,subImpl:jn,transposeImpl:di,uniqueImpl:fi},ln="2.7.0";i.registerBackend("cpu",function(){return new w},1);var ai=_r(i.Elu,function(ae){return ae>=0?ae:Math.exp(ae)-1}),gr={kernelName:i.Elu,backendName:"cpu",kernelFunc:ai},Ai=st(function(ae,ue){return ae<0?ue*ae:ae});function wi(ae){var ue=ae.inputs,E=ae.backend,D=ue.x,A=ue.alpha;X([D,A],"prelu");var H=E.data.get(D.dataId).values,se=E.data.get(A.dataId).values,te=Ai(D.shape,A.shape,H,se,D.dtype),_e=te[0],ce=te[1];return E.makeTensorInfo(ce,D.dtype,_e)}var no={kernelName:i.Prelu,backendName:"cpu",kernelFunc:wi},Qn=_r(i.Relu,function(ae){return Math.max(0,ae)}),ji={kernelName:i.Relu,backendName:"cpu",kernelFunc:Qn},Fi=_r(i.Relu6,function(ae){return Math.min(Math.max(0,ae),6)}),qi={kernelName:i.Relu6,backendName:"cpu",kernelFunc:Fi};function Di(ae,ue,E,D){if(E==="linear")return It({inputs:{x:ue},backend:ae});if(E==="relu")return Qn({inputs:{x:ue},backend:ae});if(E==="elu")return ai({inputs:{x:ue},backend:ae});if(E==="relu6")return Fi({inputs:{x:ue},backend:ae});if(E==="prelu")return wi({inputs:{x:ue,alpha:D},backend:ae});throw new Error("Activation "+E+" has not been implemented for the CPU backend.")}function ya(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=D.shape,se=i.util.sizeFromShape(A.shape),te=i.util.inferFromImplicitShape(H,se),_e=i.util.sizeFromShape(te);i.util.assert(se===_e,function(){return"The new shape ("+te+") has "+_e+" elements and the old "+("shape ("+A.shape+") has "+se+" 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 fe=ce.complexTensorInfos.real,ve=ce.complexTensorInfos.imag;fe.shape=te,ve.shape=te}return{dataId:A.dataId,shape:te,dtype:A.dtype}}var Oi={kernelName:i.Reshape,backendName:"cpu",kernelFunc:ya};function pe(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.a,H=ue.b,se=D.transposeA,te=D.transposeB;X([A,H],"matMul");var _e=A.shape.length,ce=H.shape.length,fe=se?A.shape[_e-2]:A.shape[_e-1],ve=te?H.shape[ce-1]:H.shape[ce-2],ge=se?A.shape[_e-1]:A.shape[_e-2],Ae=te?H.shape[ce-2]:H.shape[ce-1],Oe=A.shape.slice(0,-2),De=H.shape.slice(0,-2),Ve=i.util.sizeFromShape(Oe),Xe=i.util.sizeFromShape(De),at=Ve===Xe||Ve===1||Xe===1;i.util.assert(_e>=2&&ce>=2&&at,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 ("+De+").")});var it=Ve>Xe?A.shape.slice(0,-2):H.shape.slice(0,-2),$=it.concat([ge,Ae]);i.util.assert(fe===ve,function(){return"Error in matMul: inner shapes ("+fe+") and ("+(ve+") of Tensors with shapes "+A.shape+" and ")+(H.shape+" and transposeA="+se)+(" and transposeB="+te+" must match.")});for(var rt=se?[Ve,fe,ge]:[Ve,ge,fe],xt=te?[Xe,Ae,ve]:[Xe,ve,Ae],ht=ya({inputs:{x:A},backend:E,attrs:{shape:rt}}),_t=ya({inputs:{x:H},backend:E,attrs:{shape:xt}}),At=se?ht.shape[1]:ht.shape[2],zt=se?ht.shape[2]:ht.shape[1],Pt=te?_t.shape[1]:_t.shape[2],Ut=Math.max(Ve,Xe),Tt=E.data.get(ht.dataId).values,Xt=E.data.get(_t.dataId).values,Ht=i.util.computeStrides(ht.shape),Ot=i.util.computeStrides(_t.shape),Rt=se?[Ht[0],1,Ht[1]]:[Ht[0],Ht[1],1],wt=Rt[0],Et=Rt[1],Vt=Rt[2],qt=te?[1,Ot[1],Ot[0]]:[Ot[1],1,Ot[0]],lr=qt[0],ir=qt[1],Ie=qt[2],br=zt*Pt,Nr=i.buffer([Ut,zt,Pt],ht.dtype),Tr=Nr.values,pr=E.blockSize,Fr=0;Fr<Ut;Fr++)for(var mr=0;mr<zt;mr+=pr)for(var Er=0;Er<Pt;Er+=pr)for(var an=0;an<At;an+=pr)for(var _n=Math.min(mr+pr,zt),ie=Math.min(Er+pr,Pt),In=Math.min(an+pr,At),wn=mr;wn<_n;wn++)for(var Re=Er;Re<ie;Re++){for(var Un=0,Ln=an;Ln<In;Ln++){var Oa=Math.min(Fr,Ve-1)*wt,An=Math.min(Fr,Xe-1)*Ie,Ja=Tt[Oa+wn*Et+Ln*Vt],Wa=Xt[Ln*lr+Re*ir+An];Un+=Ja*Wa}Tr[Fr*br+(wn*Pt+Re)]+=Un}return E.disposeIntermediateTensorInfo(ht),E.disposeIntermediateTensorInfo(_t),E.makeTensorInfo($,Nr.dtype,Nr.values)}var Y={kernelName:i.BatchMatMul,backendName:"cpu",kernelFunc:pe};function j(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.a,H=ue.b,se=ue.bias,te=ue.preluActivationWeights,_e=D.transposeA,ce=D.transposeB,fe=D.activation,ve,ge,Ae,Oe=[],De=pe({inputs:{a:A,b:H},attrs:{transposeA:_e,transposeB:ce},backend:E});ve=De,se&&(ge=jt({inputs:{a:ve,b:se},backend:E}),Oe.push(ve),ve=ge),fe&&(Ae=Di(E,ve,fe,te),Oe.push(ve),ve=Ae);for(var Ve=0,Xe=Oe;Ve<Xe.length;Ve++){var at=Xe[Ve];E.disposeIntermediateTensorInfo(at)}return ve}var ne={kernelName:i._FusedMatMul,backendName:"cpu",kernelFunc:j},re=_r(i.Acos,function(ae){return Math.acos(ae)}),Ue={kernelName:i.Acos,backendName:"cpu",kernelFunc:re},kt=_r(i.Acosh,function(ae){return Math.acosh(ae)}),tt={kernelName:i.Acosh,backendName:"cpu",kernelFunc:kt},ze=_r(i.Asin,function(ae){return Math.asin(ae)}),Ye={kernelName:i.Asin,backendName:"cpu",kernelFunc:ze},Dt=_r(i.Asinh,function(ae){return Math.asinh(ae)}),St={kernelName:i.Asinh,backendName:"cpu",kernelFunc:Dt},Mt=_r(i.Atan,function(ae){return Math.atan(ae)}),fr={kernelName:i.Atan,backendName:"cpu",kernelFunc:Mt},or=_r(i.Atanh,function(ae){return Math.atanh(ae)}),aa={kernelName:i.Atanh,backendName:"cpu",kernelFunc:or};function va(ae,ue,E,D,A,H){for(var se=A.strideHeight,te=A.strideWidth,_e=A.dilationHeight,ce=A.dilationWidth,fe=A.effectiveFilterHeight,ve=A.effectiveFilterWidth,ge=A.padInfo.top,Ae=A.padInfo.left,Oe=H==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,De=i.buffer(A.outShape,E),Ve=De.values,Xe=A.outShape[1]*A.outShape[2]*A.outShape[3],at=A.outShape[2]*A.outShape[3],it=A.outShape[3],$=0;$<A.batchSize;++$)for(var rt=$*Xe,xt=$*D[0],ht=0;ht<A.inChannels;++ht)for(var _t=0;_t<A.outHeight;++_t)for(var At=_t*se-ge,zt=Math.max(0,At),Pt=Math.min(A.inHeight,fe+At),Ut=rt+_t*at,Tt=0;Tt<A.outWidth;++Tt){for(var Xt=Tt*te-Ae,Ht=Math.max(0,Xt),Ot=Math.min(A.inWidth,ve+Xt),Rt=Oe,wt=0,Et=0,Vt=zt;Vt<Pt;Vt+=_e){for(var qt=xt+Vt*D[1],lr=Ht;lr<Ot;lr+=ce){var ir=qt+lr*D[2],Ie=ae[ir+ht];H==="max"&&Ie>Rt?Rt=Ie:H==="avg"&&(wt+=Ie,Et++)}if(isNaN(Rt))break}var br=Ut+Tt*it+ht;Ve[br]=H==="avg"?wt/Et:Rt}return De}function ia(ae,ue,E,D,A,H){A===void 0&&(A=!1),H===void 0&&(H=!1);for(var se=i.buffer(D.outShape,"int32"),te=D.strideHeight,_e=D.strideWidth,ce=D.dilationHeight,fe=D.dilationWidth,ve=D.effectiveFilterHeight,ge=D.effectiveFilterWidth,Ae=D.padInfo.top,Oe=D.padInfo.left,De=i.buffer(ue,E,ae),Ve=0;Ve<D.batchSize;++Ve)for(var Xe=0;Xe<D.inChannels;++Xe)for(var at=0;at<D.outHeight;++at){for(var it=at*te-Ae,$=it;$<0;)$+=ce;for(var rt=Math.min(D.inHeight,ve+it),xt=0;xt<D.outWidth;++xt){for(var ht=xt*_e-Oe,_t=ht;_t<0;)_t+=fe;for(var At=Math.min(D.inWidth,ge+ht),zt=Number.NEGATIVE_INFINITY,Pt=-1,Ut=$;Ut<rt;Ut+=ce)for(var Tt=Ut-it,Xt=_t;Xt<At;Xt+=fe){var Ht=Xt-ht,Ot=De.get(Ve,Ut,Xt,Xe);Ot>zt&&(zt=Ot,A?Pt=H?((Ve*D.inHeight+Ut)*D.inWidth+Xt)*D.inChannels+Xe:(Ut*D.inWidth+Xt)*D.inChannels+Xe:Pt=Tt*ge+Ht)}se.set(Pt,Ve,at,xt,Xe)}}return se}function qa(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x;X(A,"avgPool");var H=D.filterSize,se=D.strides,te=D.pad,_e=D.dimRoundingMode,ce=1;i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(se,ce),function(){return"Error in avgPool: Either strides or dilations must be 1. "+("Got strides "+se+" and dilations '"+ce+"'")});var fe=i.backend_util.computePool2DInfo(A.shape,H,se,ce,te,_e),ve;if(fe.filterWidth===1&&fe.filterHeight===1&&i.util.arraysEqual(fe.inShape,fe.outShape))ve=It({inputs:{x:A},backend:E});else{var ge=E.data.get(A.dataId).values,Ae=i.util.computeStrides(A.shape),Oe=va(ge,A.shape,A.dtype,Ae,fe,"avg");ve=E.makeTensorInfo(fe.outShape,A.dtype,Oe.values)}return ve}var bi={kernelName:i.AvgPool,backendName:"cpu",kernelFunc:qa};function rn(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.dy,H=ue.input,se=H;X([A,H],"avgPoolBackprop");for(var te=D.filterSize,_e=D.strides,ce=D.pad,fe=i.backend_util.computePool2DInfo(se.shape,te,_e,1,ce),ve=fe.strideHeight,ge=fe.strideWidth,Ae=fe.filterHeight,Oe=fe.filterWidth,De=fe.dilationHeight,Ve=fe.dilationWidth,Xe=fe.effectiveFilterHeight,at=fe.effectiveFilterWidth,it=at-1-fe.padInfo.left,$=Xe-1-fe.padInfo.top,rt=i.buffer(se.shape,"float32"),xt=1/(Ae*Oe),ht=E.data.get(A.dataId).values,_t=i.buffer(A.shape,"float32",ht),At=0;At<fe.batchSize;++At)for(var zt=0;zt<fe.inChannels;++zt)for(var Pt=0;Pt<fe.inHeight;++Pt)for(var Ut=0;Ut<fe.inWidth;++Ut){for(var Tt=Pt-$,Xt=Ut-it,Ht=0,Ot=0;Ot<Xe;Ot+=De){var Rt=(Tt+Ot)/ve;if(Rt<0||Rt>=fe.outHeight||Math.floor(Rt)!==Rt)continue;for(var wt=0;wt<at;wt+=Ve){var Et=(Xt+wt)/ge;if(Et<0||Et>=fe.outWidth||Math.floor(Et)!==Et)continue;var Vt=_t.get(At,Rt,Et,zt);Ht+=Vt}}rt.set(Ht*xt,At,Pt,Ut,zt)}return E.makeTensorInfo(rt.shape,rt.dtype,rt.values)}var hn={kernelName:i.AvgPoolBackprop,backendName:"cpu",kernelFunc:rn};function oa(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.scale,se=ue.offset,te=ue.mean,_e=ue.variance;i.util.assert(te.shape.length===_e.shape.length,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),i.util.assert(se==null||te.shape.length===se.shape.length,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),i.util.assert(H==null||te.shape.length===H.shape.length,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}),X([A,te,_e,H,se],"batchNorm");var ce=D.varianceEpsilon;ce==null&&(ce=.001);for(var fe=E.data.get(A.dataId).values,ve=E.data.get(te.dataId).values,ge=E.data.get(_e.dataId).values,Ae=H?E.data.get(H.dataId).values:new Float32Array([1]),Oe=se?E.data.get(se.dataId).values:new Float32Array([0]),De=new Float32Array(fe.length),Ve=Oe.length,Xe=Ae.length,at=ge.length,it=ve.length,$=0,rt=0,xt=0,ht=0,_t=0;_t<fe.length;++_t)De[_t]=Oe[$++]+(fe[_t]-ve[rt++])*Ae[xt++]/Math.sqrt(ge[ht++]+ce),$>=Ve&&($=0),rt>=it&&(rt=0),xt>=Xe&&(xt=0),ht>=at&&(ht=0);return E.makeTensorInfo(A.shape,A.dtype,De)}var Jr={kernelName:i.FusedBatchNorm,backendName:"cpu",kernelFunc:oa},Vr=_r(i.ClipByValue,function(ae,ue){var E=ue;return ae>E.clipValueMax?E.clipValueMax:ae<E.clipValueMin?E.clipValueMin:ae}),Jn={kernelName:i.ClipByValue,backendName:"cpu",kernelFunc:Vr};function tn(ae){var ue=ae.inputs,E=ae.backend,D=ue.input,A=E.data.get(D.dataId).complexTensorInfos.imag,H=E.data.get(A.dataId).values;return E.makeTensorInfo(A.shape,A.dtype,H)}var En={kernelName:i.Imag,backendName:"cpu",kernelFunc:tn};function qn(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=D.axis,H=i.util.parseAxisParam(A,ue[0].shape)[0],se=i.backend_util.computeOutShape(ue.map(function($){return $.shape}),H);if(i.util.sizeFromShape(se)===0)return E.makeTensorInfo(se,ue[0].dtype,[]);var te=ue.filter(function($){return i.util.sizeFromShape($.shape)>0});if(te.length===1)return te[0];var _e=te.map(function($){return $.shape});if(i.backend_util.assertParamsConsistent(_e,H),te[0].dtype==="complex64"){var ce=te.map(function($){return mt({inputs:{input:$},backend:E})}),fe=te.map(function($){return tn({inputs:{input:$},backend:E})}),ve=qn({inputs:ce,backend:E,attrs:{axis:H}}),ge=qn({inputs:fe,backend:E,attrs:{axis:H}}),Ae=ut({inputs:{real:ve,imag:ge},backend:E});return ce.forEach(function($){return E.disposeIntermediateTensorInfo($)}),fe.forEach(function($){return E.disposeIntermediateTensorInfo($)}),E.disposeIntermediateTensorInfo(ve),E.disposeIntermediateTensorInfo(ge),Ae}var Oe=te.map(function($){var rt=i.util.sizeFromShape($.shape.slice(H)),xt=[-1,rt];return ya({inputs:{x:$},backend:E,attrs:{shape:xt}})});se=i.backend_util.computeOutShape(Oe.map(function($){return $.shape}),1);var De=i.util.getTypedArrayFromDType(te[0].dtype,i.util.sizeFromShape(se));if(Oe[0].shape[0]===1){var Ve=0;Oe.forEach(function($){var rt=E.data.get($.dataId).values,xt=i.util.sizeFromShape($.shape);De.set(rt,Ve),Ve+=xt})}else{var Xe=0;Oe.forEach(function($){for(var rt=E.data.get($.dataId).values,xt=0,ht=0;ht<$.shape[0];++ht)for(var _t=ht*se[1]+Xe,At=0;At<$.shape[1];++At)De[_t+At]=rt[xt++];Xe+=$.shape[1]})}var at=i.backend_util.computeOutShape(te.map(function($){return $.shape}),H),it=E.makeTensorInfo(at,ue[0].dtype,De);return Oe.forEach(function($){return E.disposeIntermediateTensorInfo($)}),it}var sa={kernelName:i.Concat,backendName:"cpu",kernelFunc:qn};function ga(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.filter,se=D.strides,te=D.pad,_e=D.dataFormat,ce=D.dilations,fe=D.dimRoundingMode;X([A,H],"conv2d");for(var ve=i.backend_util.convertConv2DDataFormat(_e),ge=i.backend_util.computeConv2DInfo(A.shape,H.shape,se,ce,te,fe,!1,ve),Ae=ge.filterHeight,Oe=ge.filterWidth,De=ge.dilationHeight,Ve=ge.dilationWidth,Xe=ge.padInfo.left,at=ge.padInfo.top,it=ge.dataFormat==="channelsLast",$=new i.TensorBuffer(ge.outShape,A.dtype),rt=i.util.computeStrides(A.shape),xt=i.util.computeStrides(H.shape),ht=rt[0],_t=it?rt[1]:rt[2],At=it?rt[2]:1,zt=it?1:rt[1],Pt=$.strides[0],Ut=it?$.strides[1]:$.strides[2],Tt=it?$.strides[2]:1,Xt=it?1:$.strides[1],Ht=E.data.get(A.dataId).values,Ot=E.data.get(H.dataId).values,Rt=$.values,wt=0;wt<ge.batchSize;++wt)for(var Et=wt*ht,Vt=wt*Pt,qt=0;qt<ge.outHeight;++qt)for(var lr=Vt+qt*Ut,ir=qt*ge.strideHeight-at,Ie=0;Ie<Ae;++Ie){var br=ir+Ie*De;if(br<0||br>=ge.inHeight)continue;for(var Nr=Ie*xt[0],Tr=Et+br*_t,pr=0;pr<ge.outWidth;++pr)for(var Fr=lr+pr*Tt,mr=pr*ge.strideWidth-Xe,Er=0;Er<Oe;++Er){var an=mr+Er*Ve;if(an<0||an>=ge.inWidth)continue;for(var _n=Nr+Er*xt[1],ie=Tr+an*At,In=_n,wn=0;wn<ge.inChannels;++wn){for(var Re=Ht[ie+wn*zt],Un=0;Un<ge.outChannels;++Un)Rt[Fr+Un*Xt]+=Re*Ot[In+Un];In+=ge.outChannels}}}return E.makeTensorInfo($.shape,$.dtype,Rt)}var Mi={kernelName:i.Conv2D,backendName:"cpu",kernelFunc:ga};function Aa(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.dy,se=D.strides,te=D.pad,_e=D.dataFormat,ce=D.dimRoundingMode,fe=D.filterShape;X([A,H],"conv2dBackpropFilter");for(var ve=i.backend_util.convertConv2DDataFormat(_e),ge=i.backend_util.computeConv2DInfo(A.shape,fe,se,1,te,ce,!1,ve),Ae=ge.strideHeight,Oe=ge.strideWidth,De=ge.filterHeight,Ve=ge.filterWidth,Xe=ge.dataFormat==="channelsLast",at=new i.TensorBuffer(ge.filterShape,"float32"),it=ge.padInfo.left,$=ge.padInfo.top,rt=E.data.get(A.dataId).values,xt=E.data.get(H.dataId).values,ht=new i.TensorBuffer(A.shape,A.dtype,rt),_t=new i.TensorBuffer(H.shape,H.dtype,xt),At=0;At<De;++At)for(var zt=Math.max(0,Math.ceil(($-At)/Ae)),Pt=Math.min(ge.outHeight,(ge.inHeight+$-At)/Ae),Ut=0;Ut<Ve;++Ut)for(var Tt=Math.max(0,Math.ceil((it-Ut)/Oe)),Xt=Math.min(ge.outWidth,(ge.inWidth+it-Ut)/Oe),Ht=0;Ht<ge.inChannels;++Ht)for(var Ot=0;Ot<ge.outChannels;++Ot){for(var Rt=0,wt=0;wt<ge.batchSize;++wt)for(var Et=zt;Et<Pt;++Et)for(var Vt=At+Et*Ae-$,qt=Tt;qt<Xt;++qt){var lr=Ut+qt*Oe-it;Xe?Rt+=ht.get(wt,Vt,lr,Ht)*_t.get(wt,Et,qt,Ot):Rt+=ht.get(wt,Ht,Vt,lr)*_t.get(wt,Ot,Et,qt)}at.set(Rt,At,Ut,Ht,Ot)}return E.makeTensorInfo(at.shape,at.dtype,at.values)}var S={kernelName:i.Conv2DBackpropFilter,backendName:"cpu",kernelFunc:Aa};function x(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.dy,H=ue.filter,se=D.inputShape,te=D.strides,_e=D.pad,ce=D.dataFormat,fe=D.dimRoundingMode;X([A,H],"conv2dBackpropInput");var ve=i.util.computeStrides(H.shape),ge=i.util.computeStrides(A.shape),Ae=i.backend_util.convertConv2DDataFormat(ce),Oe=i.backend_util.computeConv2DInfo(se,H.shape,te,1,_e,fe,!1,Ae),De=new i.TensorBuffer(Oe.inShape,"float32"),Ve=De.values,Xe=E.data.get(A.dataId).values,at=E.data.get(H.dataId).values,it=ve[0],$=ve[1],rt=ve[2],xt=Oe.batchSize,ht=Oe.filterHeight,_t=Oe.filterWidth,At=Oe.inChannels,zt=Oe.inHeight,Pt=Oe.inWidth,Ut=Oe.outChannels,Tt=Oe.outHeight,Xt=Oe.outWidth,Ht=Oe.strideHeight,Ot=Oe.strideWidth;Ae=Oe.dataFormat;for(var Rt=ht-1-Oe.padInfo.top,wt=_t-1-Oe.padInfo.left,Et=Ae==="channelsLast",Vt=De.strides[0],qt=Et?De.strides[1]:De.strides[2],lr=Et?De.strides[2]:1,ir=Et?1:De.strides[1],Ie=ge[0],br=Et?ge[1]:ge[2],Nr=Et?ge[2]:1,Tr=Et?1:ge[1],pr=0;pr<xt;++pr)for(var Fr=0;Fr<At;++Fr)for(var mr=0;mr<zt;++mr)for(var Er=mr-Rt,an=Math.max(0,Math.ceil(Er/Ht)),_n=Math.min(Tt,(ht+Er)/Ht),ie=0;ie<Pt;++ie){for(var In=ie-wt,wn=Math.max(0,Math.ceil(In/Ot)),Re=Math.min(Xt,(_t+In)/Ot),Un=0,Ln=an;Ln<_n;++Ln)for(var Oa=Ln*Ht-Er,An=wn;An<Re;++An)for(var Ja=An*Ot-In,Wa=Ie*pr+br*Ln+Nr*An,$a=it*(ht-1-Oa)+$*(_t-1-Ja)+rt*Fr,xa=0;xa<Ut;++xa){var _a=Xe[Wa+Tr*xa],Zi=at[$a+xa];Un+=_a*Zi}var Bi=Vt*pr+qt*mr+lr*ie+ir*Fr;Ve[Bi]=Un}return E.makeTensorInfo(De.shape,De.dtype,De.values)}var k={kernelName:i.Conv2DBackpropInput,backendName:"cpu",kernelFunc:x};function K(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.filter,se=D.strides,te=D.pad,_e=D.dilations;X([A,H],"conv3d");for(var ce=i.backend_util.computeConv3DInfo(A.shape,H.shape,se,_e,te),fe=ce.filterDepth,ve=ce.filterHeight,ge=ce.filterWidth,Ae=ce.dilationDepth,Oe=ce.dilationHeight,De=ce.dilationWidth,Ve=ce.padInfo,Xe=Ve.front,at=Ve.left,it=Ve.top,$=new i.TensorBuffer(ce.outShape,A.dtype),rt=E.data.get(A.dataId).values,xt=E.data.get(H.dataId).values,ht=$.values,_t=i.util.computeStrides(A.shape),At=i.util.computeStrides(H.shape),zt=0;zt<ce.batchSize;++zt)for(var Pt=zt*_t[0],Ut=zt*$.strides[0],Tt=0;Tt<ce.outDepth;++Tt)for(var Xt=Ut+Tt*$.strides[1],Ht=Tt*ce.strideDepth-Xe,Ot=0;Ot<fe;++Ot){var Rt=Ht+Ot*Ae;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 qt=Xt+Vt*$.strides[2],lr=Vt*ce.strideHeight-it,ir=0;ir<ve;++ir){var Ie=lr+ir*Oe;if(Ie<0||Ie>=ce.inHeight)continue;for(var br=wt+ir*At[1],Nr=Et+Ie*_t[2],Tr=0;Tr<ce.outWidth;++Tr)for(var pr=qt+Tr*ce.outChannels,Fr=Tr*ce.strideWidth-at,mr=0;mr<ge;++mr){var Er=Fr+mr*De;if(Er<0||Er>=ce.inWidth)continue;for(var an=br+mr*At[2],_n=Nr+Er*ce.inChannels,ie=an,In=0;In<ce.inChannels;++In){for(var wn=rt[_n+In],Re=0;Re<ce.outChannels;++Re)ht[pr+Re]+=wn*xt[ie+Re];ie+=ce.outChannels}}}}return E.makeTensorInfo($.shape,$.dtype,$.values)}var Se={kernelName:i.Conv3D,backendName:"cpu",kernelFunc:K};function be(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.dy,se=D.strides,te=D.pad,_e=D.filterShape;X([A,H],"conv3dBackpropFilterV2");for(var ce=i.util.computeStrides(A.shape),fe=i.util.computeStrides(H.shape),ve=i.backend_util.computeConv3DInfo(A.shape,_e,se,1,te),ge=ve.strideDepth,Ae=ve.strideHeight,Oe=ve.strideWidth,De=ve.filterDepth,Ve=ve.filterHeight,Xe=ve.filterWidth,at=new i.TensorBuffer(ve.filterShape,"float32"),it=at.values,$=at.strides,rt=$[0],xt=$[1],ht=$[2],_t=$[3],At=E.data.get(H.dataId).values,zt=fe[0],Pt=fe[1],Ut=fe[2],Tt=fe[3],Xt=E.data.get(A.dataId).values,Ht=ce[0],Ot=ce[1],Rt=ce[2],wt=ce[3],Et=ve.padInfo.front,Vt=ve.padInfo.left,qt=ve.padInfo.top,lr=0;lr<De;++lr)for(var ir=Math.max(0,Math.ceil((Et-lr)/ge)),Ie=Math.min(ve.outDepth,(ve.inDepth+Et-lr)/ge),br=lr*rt,Nr=0;Nr<Ve;++Nr)for(var Tr=Math.max(0,Math.ceil((qt-Nr)/Ae)),pr=Math.min(ve.outHeight,(ve.inHeight+qt-Nr)/Ae),Fr=Nr*xt+br,mr=0;mr<Xe;++mr)for(var Er=Math.max(0,Math.ceil((Vt-mr)/Oe)),an=Math.min(ve.outWidth,(ve.inWidth+Vt-mr)/Oe),_n=mr*ht+Fr,ie=0;ie<ve.inChannels;++ie)for(var In=ie*_t+_n,wn=0;wn<ve.outChannels;++wn){for(var Re=0,Un=0;Un<ve.batchSize;++Un)for(var Ln=Un*Ht,Oa=Un*zt,An=ir;An<Ie;++An)for(var Ja=lr+An*ge-Et,Wa=Ja*Ot+Ln,$a=An*Pt+Oa,xa=Tr;xa<pr;++xa)for(var _a=Nr+xa*Ae-qt,Zi=_a*Rt+Wa,Bi=xa*Ut+$a,Mr=Er;Mr<an;++Mr){var ei=mr+Mr*Oe-Vt,as=ei*wt+Zi,Po=Mr*Tt+Bi;Re+=Xt[as+ie]*At[Po+wn]}it[In+wn]=Re}return E.makeTensorInfo(at.shape,at.dtype,at.values)}var Je={kernelName:i.Conv3DBackpropFilterV2,backendName:"cpu",kernelFunc:be};function Pe(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.dy,H=ue.filter,se=D.pad,te=D.strides,_e=D.inputShape;X([A],"conv3dBackpropInputV2");for(var ce=i.util.computeStrides(A.shape),fe=i.util.computeStrides(H.shape),ve=i.backend_util.computeConv3DInfo(_e,H.shape,te,1,se),ge=new i.TensorBuffer(ve.inShape,"float32"),Ae=ge.values,Oe=ge.strides,De=Oe[0],Ve=Oe[1],Xe=Oe[2],at=Oe[3],it=E.data.get(A.dataId).values,$=ce[0],rt=ce[1],xt=ce[2],ht=ce[3],_t=E.data.get(H.dataId).values,At=fe[0],zt=fe[1],Pt=fe[2],Ut=fe[3],Tt=ve.batchSize,Xt=ve.filterDepth,Ht=ve.filterHeight,Ot=ve.filterWidth,Rt=ve.inChannels,wt=ve.inDepth,Et=ve.inHeight,Vt=ve.inWidth,qt=ve.outChannels,lr=ve.outDepth,ir=ve.outHeight,Ie=ve.outWidth,br=ve.strideDepth,Nr=ve.strideHeight,Tr=ve.strideWidth,pr=Xt-1-ve.padInfo.front,Fr=Ht-1-ve.padInfo.top,mr=Ot-1-ve.padInfo.left,Er=0;Er<Tt;++Er)for(var an=0;an<Rt;++an)for(var _n=0;_n<wt;++_n)for(var ie=_n-pr,In=Math.max(0,Math.ceil(ie/br)),wn=Math.min(lr,(Xt+ie)/br),Re=0;Re<Et;++Re)for(var Un=Re-Fr,Ln=Math.max(0,Math.ceil(Un/Nr)),Oa=Math.min(ir,(Ht+Un)/Nr),An=0;An<Vt;++An){for(var Ja=An-mr,Wa=Math.max(0,Math.ceil(Ja/Tr)),$a=Math.min(Ie,(Ot+Ja)/Tr),xa=0,_a=In;_a<wn;++_a)for(var Zi=_a*br-ie,Bi=Ln;Bi<Oa;++Bi)for(var Mr=Bi*Nr-Un,ei=Wa;ei<$a;++ei)for(var as=ei*Tr-Ja,Po=$*Er+rt*_a+xt*Bi+ht*ei,dn=At*(Xt-1-Zi)+zt*(Ht-1-Mr)+Pt*(Ot-1-as)+Ut*an,Bo=0;Bo<qt;++Bo){var Fn=it[Po+Bo],ou=_t[dn+Bo];xa+=Fn*ou}Ae[De*Er+Ve*_n+Xe*Re+at*An+an]=xa}return E.makeTensorInfo(ge.shape,ge.dtype,ge.values)}var gt={kernelName:i.Conv3DBackpropInputV2,backendName:"cpu",kernelFunc:Pe},ft=_r(i.Cos,function(ae){return Math.cos(ae)}),Lt={kernelName:i.Cos,backendName:"cpu",kernelFunc:ft},Wt=_r(i.Cosh,function(ae){return Math.cosh(ae)}),Gt={kernelName:i.Cosh,backendName:"cpu",kernelFunc:Wt};function Jt(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.filter,se=D.strides,te=D.pad,_e=D.dilations,ce=D.dimRoundingMode;X([A,H],"depthwiseConv2DNative");var fe=i.util.computeStrides(A.shape),ve=i.util.computeStrides(H.shape),ge=_e;ge==null&&(ge=[1,1]),i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(se,ge),function(){return"Error in depthwiseConv2d: Either strides or dilations must be "+("1. Got strides "+se+" and dilations '"+ge+"'")});for(var Ae=i.backend_util.computeConv2DInfo(A.shape,H.shape,se,ge,te,ce,!0),Oe=Ae.filterHeight,De=Ae.filterWidth,Ve=Ae.dilationHeight,Xe=Ae.dilationWidth,at=Ae.padInfo,it=at.left,$=at.top,rt=Ae.outChannels/Ae.inChannels,xt=new i.TensorBuffer(Ae.outShape,A.dtype),ht=E.data.get(A.dataId).values,_t=E.data.get(H.dataId).values,At=xt.values,zt=0;zt<Ae.batchSize;++zt)for(var Pt=zt*fe[0],Ut=zt*xt.strides[0],Tt=0;Tt<Ae.outHeight;++Tt)for(var Xt=Ut+Tt*xt.strides[1],Ht=Tt*Ae.strideHeight-it,Ot=0;Ot<Oe;++Ot){var Rt=Ht+Ot*Ve;if(Rt<0||Rt>=Ae.inHeight)continue;for(var wt=Ot*ve[0],Et=Pt+Rt*fe[1],Vt=0;Vt<Ae.outWidth;++Vt)for(var qt=Xt+Vt*xt.strides[2],lr=Vt*Ae.strideWidth-$,ir=0;ir<De;++ir){var Ie=lr+ir*Xe;if(Ie<0||Ie>=Ae.inWidth)continue;for(var br=wt+ir*ve[1],Nr=Et+Ie*Ae.inChannels,Tr=qt,pr=br,Fr=0;Fr<Ae.inChannels;++Fr){for(var mr=ht[Nr+Fr],Er=0;Er<rt;++Er)At[Tr+Er]+=mr*_t[pr+Er];Tr+=rt,pr+=rt}}}return E.makeTensorInfo(xt.shape,xt.dtype,xt.values)}var wr={kernelName:i.DepthwiseConv2dNative,backendName:"cpu",kernelFunc:Jt};function Ar(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.dy,se=D.strides,te=D.dilations,_e=D.pad,ce=D.dimRoundingMode,fe=D.filterShape;X([A,H],"depthwiseConv2dNativeBackpropFilter");for(var ve=i.backend_util.computeConv2DInfo(A.shape,fe,se,te,_e,ce,!0),ge=ve.strideHeight,Ae=ve.strideWidth,Oe=ve.filterHeight,De=ve.filterWidth,Ve=new i.TensorBuffer(ve.filterShape,"float32"),Xe=ve.padInfo.left,at=ve.padInfo.top,it=ve.outChannels/ve.inChannels,$=E.data.get(A.dataId).values,rt=new i.TensorBuffer(A.shape,A.dtype,$),xt=E.data.get(H.dataId).values,ht=new i.TensorBuffer(H.shape,H.dtype,xt),_t=0;_t<Oe;++_t)for(var At=Math.max(0,Math.ceil((at-_t)/ge)),zt=Math.min(ve.outHeight,(ve.inHeight+at-_t)/ge),Pt=0;Pt<De;++Pt)for(var Ut=Math.max(0,Math.ceil((Xe-Pt)/Ae)),Tt=Math.min(ve.outWidth,(ve.inWidth+Xe-Pt)/Ae),Xt=0;Xt<ve.outChannels;++Xt){for(var Ht=Math.trunc(Xt/it),Ot=Xt%it,Rt=0,wt=0;wt<ve.batchSize;++wt)for(var Et=At;Et<zt;++Et)for(var Vt=_t+Et*ge-at,qt=Ut;qt<Tt;++qt){var lr=Pt+qt*Ae-Xe;Rt+=rt.get(wt,Vt,lr,Ht)*ht.get(wt,Et,qt,Xt)}Ve.set(Rt,_t,Pt,Ht,Ot)}return E.makeTensorInfo(Ve.shape,Ve.dtype,Ve.values)}var Zt={kernelName:i.DepthwiseConv2dNativeBackpropFilter,backendName:"cpu",kernelFunc:Ar};function xr(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.dy,H=ue.filter,se=D.strides,te=D.dilations,_e=D.pad,ce=D.dimRoundingMode,fe=D.inputShape;X([A,H],"depthwiseConv2DNativeBackpropInput");for(var ve=i.util.computeStrides(A.shape),ge=i.util.computeStrides(H.shape),Ae=i.backend_util.computeConv2DInfo(fe,H.shape,se,te,_e,ce,!0),Oe=new i.TensorBuffer(Ae.inShape,"float32"),De=Oe.values,Ve=Oe.strides,Xe=Ve[0],at=Ve[1],it=Ve[2],$=E.data.get(A.dataId).values,rt=ve[0],xt=ve[1],ht=ve[2],_t=E.data.get(H.dataId).values,At=ge[0],zt=ge[1],Pt=ge[2],Ut=Ae.batchSize,Tt=Ae.filterHeight,Xt=Ae.filterWidth,Ht=Ae.inChannels,Ot=Ae.inHeight,Rt=Ae.inWidth,wt=Ae.outChannels,Et=Ae.outHeight,Vt=Ae.outWidth,qt=Ae.strideHeight,lr=Ae.strideWidth,ir=Tt-1-Ae.padInfo.top,Ie=Xt-1-Ae.padInfo.left,br=wt/Ht,Nr=0;Nr<Ut;++Nr)for(var Tr=0;Tr<Ht;++Tr)for(var pr=0;pr<Ot;++pr)for(var Fr=pr-ir,mr=Math.max(0,Math.ceil(Fr/qt)),Er=Math.min(Et,(Tt+Fr)/qt),an=0;an<Rt;++an){for(var _n=an-Ie,ie=Math.max(0,Math.ceil(_n/lr)),In=Math.min(Vt,(Xt+_n)/lr),wn=0,Re=mr;Re<Er;++Re)for(var Un=Re*qt-Fr,Ln=ie;Ln<In;++Ln)for(var Oa=Ln*lr-_n,An=rt*Nr+xt*Re+ht*Ln,Ja=At*(Tt-1-Un)+zt*(Xt-1-Oa)+Pt*Tr,Wa=0;Wa<br;++Wa){var $a=Tr*br+Wa,xa=$[An+$a],_a=_t[Ja+Wa];wn+=xa*_a}De[Xe*Nr+at*pr+it*an+Tr]=wn}return E.makeTensorInfo(Oe.shape,Oe.dtype,Oe.values)}var kn={kernelName:i.DepthwiseConv2dNativeBackpropInput,backendName:"cpu",kernelFunc:xr},pn={kernelName:i.Dilation2D,backendName:"cpu",kernelFunc:function(ae){for(var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue,H=A.x,se=A.filter,te=D,_e=te.strides,ce=te.pad,fe=te.dilations,ve=E,ge=ve.data.get(H.dataId).values,Ae=H.shape.length,Oe=ve.data.get(se.dataId).values,De=se.shape.length,Ve=i.backend_util.computeDilation2DInfo(H.shape,se.shape,_e,ce,"NHWC",fe),Xe=Ve.batchSize,at=Ve.inHeight,it=Ve.inWidth,$=Ve.inChannels,rt=Ve.outHeight,xt=Ve.outWidth,ht=Ve.padInfo,_t=Ve.strideHeight,At=Ve.strideWidth,zt=Ve.filterHeight,Pt=Ve.filterWidth,Ut=Ve.dilationHeight,Tt=Ve.dilationWidth,Xt=Ve.outShape,Ht=i.util.sizeFromShape(Xt),Ot=Xt.length,Rt=i.util.getArrayFromDType(H.dtype,Ht),wt=0;wt<Xe;++wt)for(var Et=0;Et<rt;++Et)for(var Vt=Et*_t-ht.top,qt=0;qt<xt;++qt)for(var lr=qt*At-ht.left,ir=0;ir<$;++ir){for(var Ie=Number.MIN_SAFE_INTEGER,br=0;br<zt;++br){var Nr=Vt+br*Ut;if(Nr>=0&&Nr<at)for(var Tr=0;Tr<Pt;++Tr){var pr=lr+Tr*Tt;if(pr>=0&&pr<it){var Fr=i.util.locToIndex([wt,Nr,pr,ir],Ae,i.util.computeStrides(H.shape)),mr=i.util.locToIndex([br,Tr,ir],De,i.util.computeStrides(se.shape)),Er=ge[Fr]+Oe[mr];Er>Ie&&(Ie=Er)}}}var an=i.util.locToIndex([wt,Et,qt,ir],Ot,i.util.computeStrides(Xt));Rt[an]=Ie}var _n=ve.write(i.util.toTypedArray(Rt,H.dtype),Xt,H.dtype);return{dataId:_n,shape:Xt,dtype:H.dtype}}},zn={kernelName:i.Dilation2DBackpropFilter,backendName:"cpu",kernelFunc:function(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue,H=A.x,se=A.filter,te=A.dy,_e=D,ce=_e.strides,fe=_e.pad,ve=_e.dilations,ge=E,Ae=i.util.toNestedArray(H.shape,ge.data.get(H.dataId).values),Oe=i.util.toNestedArray(se.shape,ge.data.get(se.dataId).values),De=i.backend_util.computeDilation2DInfo(H.shape,se.shape,ce,fe,"NHWC",ve),Ve=De.batchSize,Xe=De.inHeight,at=De.inWidth,it=De.inChannels,$=De.outHeight,rt=De.outWidth,xt=De.padInfo,ht=De.strideHeight,_t=De.strideWidth,At=De.filterHeight,zt=De.filterWidth,Pt=De.dilationHeight,Ut=De.dilationWidth,Tt=De.outShape;i.util.assert(te.rank===Tt.length,function(){return"Error in "+i.Dilation2DBackpropFilter+", dy "+("must have the same rank as output "+Tt.length+", but got ")+(""+te.rank)});for(var Xt=i.util.toNestedArray(Tt,ge.data.get(te.dataId).values),Ht=i.util.makeZerosNestedTypedArray(se.shape,se.dtype),Ot=0;Ot<Ve;++Ot)for(var Rt=0;Rt<$;++Rt)for(var wt=Rt*ht-xt.top,Et=0;Et<rt;++Et)for(var Vt=Et*_t-xt.left,qt=0;qt<it;++qt){for(var lr=Number.MIN_SAFE_INTEGER,ir=0,Ie=0,br=0;br<At;++br){var Nr=wt+br*Pt;if(Nr>=0&&Nr<Xe)for(var Tr=0;Tr<zt;++Tr){var pr=Vt+Tr*Ut;if(pr>=0&&pr<at){var Fr=Ae[Ot][Nr][pr][qt]+Oe[br][Tr][qt];Fr>lr&&(lr=Fr,ir=br,Ie=Tr)}}}Ht[ir][Ie][qt]+=Xt[Ot][Rt][Et][qt]}var mr=ge.write(i.util.toTypedArray(Ht,H.dtype),se.shape,se.dtype);return{dataId:mr,shape:se.shape,dtype:se.dtype}}},Dr={kernelName:i.Dilation2DBackpropInput,backendName:"cpu",kernelFunc:function(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue,H=A.x,se=A.filter,te=A.dy,_e=D,ce=_e.strides,fe=_e.pad,ve=_e.dilations,ge=E,Ae=i.util.toNestedArray(H.shape,ge.data.get(H.dataId).values),Oe=i.util.toNestedArray(se.shape,ge.data.get(se.dataId).values),De=i.backend_util.computeDilation2DInfo(H.shape,se.shape,ce,fe,"NHWC",ve),Ve=De.batchSize,Xe=De.inHeight,at=De.inWidth,it=De.inChannels,$=De.outHeight,rt=De.outWidth,xt=De.padInfo,ht=De.strideHeight,_t=De.strideWidth,At=De.filterHeight,zt=De.filterWidth,Pt=De.dilationHeight,Ut=De.dilationWidth,Tt=De.outShape;i.util.assert(te.rank===Tt.length,function(){return"Error in "+i.Dilation2DBackpropInput+", dy "+("must have the same rank as output "+Tt.length+", but got ")+(""+te.rank)});for(var Xt=i.util.toNestedArray(Tt,ge.data.get(te.dataId).values),Ht=i.util.makeZerosNestedTypedArray(H.shape,H.dtype),Ot=0;Ot<Ve;++Ot)for(var Rt=0;Rt<$;++Rt)for(var wt=Rt*ht-xt.top,Et=0;Et<rt;++Et)for(var Vt=Et*_t-xt.left,qt=0;qt<it;++qt){for(var lr=Number.MIN_SAFE_INTEGER,ir=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<zt;++Tr){var pr=Vt+Tr*Ut;if(pr>=0&&pr<at){var Fr=Ae[Ot][Nr][pr][qt]+Oe[br][Tr][qt];Fr>lr&&(lr=Fr,ir=Nr,Ie=pr)}}}Ht[Ot][ir][Ie][qt]+=Xt[Ot][Rt][Et][qt]}var mr=ge.write(i.util.toTypedArray(Ht,H.dtype),H.shape,H.dtype);return{dataId:mr,shape:H.shape,dtype:H.dtype}}},Na=st(function(ae,ue){return ae/ue}),Sn=nt(i.Div,Na),cr={kernelName:i.Div,backendName:"cpu",kernelFunc:Sn},$r=i.backend_util.ERF_P,Fa=i.backend_util.ERF_A1,mi=i.backend_util.ERF_A2,Ka=i.backend_util.ERF_A3,Xa=i.backend_util.ERF_A4,ii=i.backend_util.ERF_A5,zi=_r(i.Erf,function(ae){var ue=Math.sign(ae),E=Math.abs(ae),D=1/(1+$r*E);return ue*(1-((((ii*D+Xa)*D+Ka)*D+mi)*D+Fa)*D*Math.exp(-E*E))}),Rn={kernelName:i.Erf,backendName:"cpu",kernelFunc:zi};function Ca(ae,ue,E){for(var D=ae.shape,A=D[0],H=D[1],se=E.data.get(ae.dataId),te=se.complexTensorInfos.real,_e=se.complexTensorInfos.imag,ce=[A,H],fe=i.util.sizeFromShape(ce),ve=i.util.getTypedArrayFromDType("float32",fe),ge=i.util.getTypedArrayFromDType("float32",fe),Ae=0;Ae<A;Ae++){for(var Oe=Pa({inputs:{x:te},backend:E,attrs:{begin:[Ae,0],size:[1,H]}}),De=Pa({inputs:{x:_e},backend:E,attrs:{begin:[Ae,0],size:[1,H]}}),Ve=ut({inputs:{real:Oe,imag:De},backend:E}),Xe=Ki(Ve,ue,E),at=Xe.real,it=Xe.imag,$=i.backend_util.mergeRealAndImagArrays(at,it),rt=0;rt<H;rt++){var xt=i.backend_util.getComplexWithIndex($,rt);ve[Ae*H+rt]=xt.real,ge[Ae*H+rt]=xt.imag}E.disposeIntermediateTensorInfo(Oe),E.disposeIntermediateTensorInfo(De),E.disposeIntermediateTensorInfo(Ve)}var ht=E.makeTensorInfo(ce,"float32",ve),_t=E.makeTensorInfo(ce,"float32",ge),At=ut({inputs:{real:ht,imag:_t},backend:E});return E.disposeIntermediateTensorInfo(ht),E.disposeIntermediateTensorInfo(_t),At}function Ki(ae,ue,E){var D=i.util.sizeFromShape(ae.shape),A=E.data.get(ae.dataId),H=E.data.get(A.complexTensorInfos.real.dataId).values,se=E.data.get(A.complexTensorInfos.imag.dataId).values;if(yi(D)){var te=oi(H,se,D,ue,E),_e=[ae.shape[0],ae.shape[1]];if(ue){var ce=E.makeTensorInfo(_e,"float32",te.real),fe=E.makeTensorInfo(_e,"float32",te.imag),ve=E.makeTensorInfo([],"float32",i.util.createScalarValue(D,"float32")),ge=It({inputs:{x:ve},backend:E}),Ae=cr.kernelFunc({inputs:{a:ce,b:ve},backend:E}),Oe=cr.kernelFunc({inputs:{a:fe,b:ge},backend:E}),De=E.data.get(Ae.dataId).values,Ve=E.data.get(Oe.dataId).values;return E.disposeIntermediateTensorInfo(ce),E.disposeIntermediateTensorInfo(fe),E.disposeIntermediateTensorInfo(ve),E.disposeIntermediateTensorInfo(ge),E.disposeIntermediateTensorInfo(Ae),E.disposeIntermediateTensorInfo(Oe),{real:De,imag:Ve}}return te}else{var Xe=i.backend_util.mergeRealAndImagArrays(H,se),at=qr(Xe,D,ue);return i.backend_util.splitRealAndImagArrays(at)}}function yi(ae){return(ae&ae-1)===0}function oi(ae,ue,E,D,A){if(E===1)return{real:ae,imag:ue};var H=i.backend_util.mergeRealAndImagArrays(ae,ue),se=E/2,te=i.backend_util.complexWithEvenIndex(H),_e=te.real,ce=te.imag,fe=[_e.length],ve=A.makeTensorInfo(fe,"float32",_e),ge=A.makeTensorInfo(fe,"float32",ce),Ae=ut({inputs:{real:ve,imag:ge},backend:A}),Oe=i.backend_util.complexWithOddIndex(H),De=Oe.real,Ve=Oe.imag,Xe=[De.length],at=A.makeTensorInfo(Xe,"float32",De),it=A.makeTensorInfo(Xe,"float32",Ve),$=ut({inputs:{real:at,imag:it},backend:A}),rt=oi(_e,ce,se,D,A),xt=rt.real,ht=rt.imag,_t=[xt.length],At=A.makeTensorInfo(_t,"float32",xt),zt=A.makeTensorInfo(_t,"float32",ht),Pt=ut({inputs:{real:At,imag:zt},backend:A}),Ut=oi(De,Ve,se,D,A),Tt=Ut.real,Xt=Ut.imag,Ht=[Tt.length],Ot=A.makeTensorInfo(Ht,"float32",Tt),Rt=A.makeTensorInfo(Ht,"float32",Xt),wt=ut({inputs:{real:Ot,imag:Rt},backend:A}),Et=i.backend_util.exponents(E,D),Vt=[Et.real.length],qt=A.makeTensorInfo(Vt,"float32",Et.real),lr=A.makeTensorInfo(Vt,"float32",Et.imag),ir=ut({inputs:{real:qt,imag:lr},backend:A}),Ie=Wn({inputs:{a:ir,b:wt},backend:A}),br=jt({inputs:{a:Pt,b:Ie},backend:A}),Nr=pi({inputs:{a:Pt,b:Ie},backend:A}),Tr=mt({inputs:{input:br},backend:A}),pr=mt({inputs:{input:Nr},backend:A}),Fr=tn({inputs:{input:br},backend:A}),mr=tn({inputs:{input:Nr},backend:A}),Er=qn({inputs:[Tr,pr],backend:A,attrs:{axis:0}}),an=qn({inputs:[Fr,mr],backend:A,attrs:{axis:0}}),_n=A.data.get(Er.dataId).values,ie=A.data.get(an.dataId).values;return A.disposeIntermediateTensorInfo(ve),A.disposeIntermediateTensorInfo(ge),A.disposeIntermediateTensorInfo(Ae),A.disposeIntermediateTensorInfo(at),A.disposeIntermediateTensorInfo(it),A.disposeIntermediateTensorInfo($),A.disposeIntermediateTensorInfo(At),A.disposeIntermediateTensorInfo(zt),A.disposeIntermediateTensorInfo(Pt),A.disposeIntermediateTensorInfo(Ot),A.disposeIntermediateTensorInfo(Rt),A.disposeIntermediateTensorInfo(wt),A.disposeIntermediateTensorInfo(qt),A.disposeIntermediateTensorInfo(lr),A.disposeIntermediateTensorInfo(ir),A.disposeIntermediateTensorInfo(Ie),A.disposeIntermediateTensorInfo(br),A.disposeIntermediateTensorInfo(Nr),A.disposeIntermediateTensorInfo(Tr),A.disposeIntermediateTensorInfo(Fr),A.disposeIntermediateTensorInfo(pr),A.disposeIntermediateTensorInfo(mr),A.disposeIntermediateTensorInfo(Er),A.disposeIntermediateTensorInfo(an),{real:_n,imag:ie}}function qr(ae,ue,E){for(var D=new Float32Array(ue*2),A=0;A<ue;A++){for(var H=0,se=0,te=0;te<ue;te++){var _e=i.backend_util.exponent(A*te,ue,E),ce=i.backend_util.getComplexWithIndex(ae,te);H+=ce.real*_e.real-ce.imag*_e.imag,se+=ce.real*_e.imag+ce.imag*_e.real}E&&(H/=ue,se/=ue),i.backend_util.assignToTypedArray(D,H,se,A)}return D}function Io(ae){var ue=ae.inputs,E=ae.backend,D=ue.input,A=i.util.sizeFromShape(D.shape),H=D.shape[D.shape.length-1],se=A/H,te=ya({inputs:{x:D},backend:E,attrs:{shape:[se,H]}}),_e=Ca(te,!1,E),ce=ya({inputs:{x:_e},backend:E,attrs:{shape:D.shape}});return E.disposeIntermediateTensorInfo(te),E.disposeIntermediateTensorInfo(_e),ce}var nn={kernelName:i.FFT,backendName:"cpu",kernelFunc:Io};function Ya(ae){var ue=ae.backend,E=ae.attrs,D=E.shape,A=E.value,H=E.dtype,se=H||i.util.inferDtype(A),te=i.util.getArrayFromDType(se,i.util.sizeFromShape(D));return Xi(te,A,se),ue.makeTensorInfo(D,se,te)}var Ba={kernelName:i.Fill,backendName:"cpu",kernelFunc:Ya};function Xi(ae,ue,E){E==="string",ae.fill(ue)}var si={kernelName:i.FlipLeftRight,backendName:"cpu",kernelFunc:function(ae){for(var ue=ae.inputs,E=ae.attrs,D=ae.backend,A=ue.image,H=D,se=i.util.getTypedArrayFromDType(A.dtype,i.util.sizeFromShape(A.shape)),te=A.shape,_e=te[0],ce=te[1],fe=te[2],ve=te[3],ge=H.data.get(A.dataId).values,Ae=0;Ae<_e;Ae++)for(var Oe=Ae*fe*ce*ve,De=0;De<ce;De++)for(var Ve=De*(fe*ve),Xe=0;Xe<fe;Xe++)for(var at=Xe*ve,it=0;it<ve;it++){var $=[_e,De,Xe,it],rt=$[2],xt=Math.round(fe-rt),ht=Oe+Ve+at+it,_t=ge[ht];if(xt>=0&&xt<fe){var At=xt*ve,zt=Oe+Ve+At+it;_t=ge[zt]}se[ht]=_t}var Pt=H.write(se,A.shape,A.dtype);return{dataId:Pt,shape:A.shape,dtype:A.dtype}}};function Li(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.filter,se=ue.bias,te=ue.preluActivationWeights,_e=D.strides,ce=D.pad,fe=D.dataFormat,ve=D.dilations,ge=D.dimRoundingMode,Ae=D.activation,Oe=ga({inputs:{x:A,filter:H},backend:E,attrs:{strides:_e,pad:ce,dataFormat:fe,dilations:ve,dimRoundingMode:ge}});if(se){var De=Oe;Oe=jt({inputs:{a:Oe,b:se},backend:E}),E.disposeIntermediateTensorInfo(De)}if(Ae){var De=Oe;Oe=Di(E,Oe,Ae,te),E.disposeIntermediateTensorInfo(De)}return Oe}var ao={kernelName:i.FusedConv2D,backendName:"cpu",kernelFunc:Li};function mo(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=ue.filter,se=ue.bias,te=ue.preluActivationWeights,_e=D.strides,ce=D.pad,fe=D.dataFormat,ve=D.dilations,ge=D.dimRoundingMode,Ae=D.activation,Oe=Jt({inputs:{x:A,filter:H},backend:E,attrs:{strides:_e,pad:ce,dataFormat:fe,dilations:ve,dimRoundingMode:ge}});if(se){var De=Oe;Oe=jt({inputs:{a:Oe,b:se},backend:E}),E.disposeIntermediateTensorInfo(De)}if(Ae){var De=Oe;Oe=Di(E,Oe,Ae,te),E.disposeIntermediateTensorInfo(De)}return Oe}var Za={kernelName:i.FusedDepthwiseConv2D,backendName:"cpu",kernelFunc:mo};function io(ae){var ue=ae.inputs,E=ae.backend,D=ue.input,A=i.util.sizeFromShape(D.shape),H=D.shape[D.shape.length-1],se=A/H,te=ya({inputs:{x:D},backend:E,attrs:{shape:[se,H]}}),_e=Ca(te,!0,E),ce=ya({inputs:{x:_e},backend:E,attrs:{shape:D.shape}});return E.disposeIntermediateTensorInfo(te),E.disposeIntermediateTensorInfo(_e),ce}var Yo={kernelName:i.IFFT,backendName:"cpu",kernelFunc:io},No=_r(i.IsFinite,function(ae){return Number.isFinite(ae)?1:0},"bool"),Co={kernelName:i.IsFinite,backendName:"cpu",kernelFunc:No},oo=_r(i.IsInf,function(ae){return Math.abs(ae)===Infinity?1:0},"bool"),ua={kernelName:i.IsInf,backendName:"cpu",kernelFunc:oo},Br=_r(i.IsNan,function(ae){return Number.isNaN(ae)?1:0},"bool"),ca={kernelName:i.IsNan,backendName:"cpu",kernelFunc:Br},Qa=_r(i.Log1p,function(ae){return Math.log1p(ae)}),Zn={kernelName:i.Log1p,backendName:"cpu",kernelFunc:Qa},so=_r(i.LogicalNot,function(ae){return ae?0:1},"bool"),Ta={kernelName:i.LogicalNot,backendName:"cpu",kernelFunc:so},vn={kernelName:i.Max,backendName:"cpu",kernelFunc:function(ae){var ue=ae.inputs,E=ae.attrs,D=ae.backend,A=ue.x,H=E,se=H.reductionIndices,te=H.keepDims,_e=D,ce=A.shape,fe=ce.length,ve=i.util.parseAxisParam(se,ce),ge=ve,Ae=i.backend_util.getAxesPermutation(ge,fe),Oe=_e.data.get(A.dataId).values;if(Ae!=null){for(var De=new Array(fe),Ve=0;Ve<De.length;Ve++)De[Ve]=ce[Ae[Ve]];Oe=di(Oe,ce,A.dtype,Ae,De),ge=i.backend_util.getInnerMostAxes(ge.length,fe),ce=De}X(A,"max"),i.backend_util.assertAxesAreInnerMostDims("max",ge,fe);var Xe=i.backend_util.computeOutAndReduceShapes(ce,ge),at=Xe[0],it=Xe[1],$=i.util.sizeFromShape(it),rt=fa(Oe,$,at,A.dtype),xt=_e.write(rt,at,A.dtype),ht=at;if(te){var De=i.backend_util.expandShapeToKeepDim(at,ve);ht=De}return{dataId:xt,shape:ht,dtype:A.dtype}}};function Pi(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x;X(A,"maxPool");var H=D.filterSize,se=D.strides,te=D.pad,_e=D.dimRoundingMode,ce=1;i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(se,ce),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+se+" and dilations '"+ce+"'")});var fe=i.backend_util.computePool2DInfo(A.shape,H,se,ce,te,_e),ve;if(fe.filterWidth===1&&fe.filterHeight===1&&i.util.arraysEqual(fe.inShape,fe.outShape))ve=It({inputs:{x:A},backend:E});else{var ge=E.data.get(A.dataId).values,Ae=i.util.computeStrides(A.shape),Oe=va(ge,A.shape,A.dtype,Ae,fe,"max");ve=E.makeTensorInfo(fe.outShape,A.dtype,Oe.values)}return ve}var yo={kernelName:i.MaxPool,backendName:"cpu",kernelFunc:Pi};function vo(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.dy,H=ue.input,se=ue.output,te=H;X([H,se],"maxPoolBackprop");for(var _e=D.filterSize,ce=D.strides,fe=D.pad,ve=D.dimRoundingMode,ge=i.backend_util.computePool2DInfo(te.shape,_e,ce,1,fe,ve),Ae=E.data.get(te.dataId).values,Oe=i.buffer(ge.outShape,te.dtype,ia(Ae,te.shape,te.dtype,ge).values),De=ge.strideHeight,Ve=ge.strideWidth,Xe=ge.dilationHeight,at=ge.dilationWidth,it=ge.effectiveFilterHeight,$=ge.effectiveFilterWidth,rt=$-1-ge.padInfo.left,xt=it-1-ge.padInfo.top,ht=i.buffer(te.shape,"float32"),_t=E.data.get(A.dataId).values,At=i.buffer(A.shape,"float32",_t),zt=0;zt<ge.batchSize;++zt)for(var Pt=0;Pt<ge.inChannels;++Pt)for(var Ut=0;Ut<ge.inHeight;++Ut)for(var Tt=0;Tt<ge.inWidth;++Tt){for(var Xt=Ut-xt,Ht=Tt-rt,Ot=0,Rt=0;Rt<it;Rt+=Xe){var wt=(Xt+Rt)/De;if(wt<0||wt>=ge.outHeight||Math.floor(wt)!==wt)continue;for(var Et=0;Et<$;Et+=at){var Vt=(Ht+Et)/Ve;if(Vt<0||Vt>=ge.outWidth||Math.floor(Vt)!==Vt)continue;var qt=it*$-1-Oe.get(zt,wt,Vt,Pt),lr=Rt*$+Et,ir=qt===lr?1:0;if(ir===0)continue;var Ie=At.get(zt,wt,Vt,Pt);Ot+=Ie*ir}}ht.set(Ot,zt,Ut,Tt,Pt)}return E.makeTensorInfo(ht.shape,ht.dtype,ht.values)}var Da={kernelName:i.MaxPoolBackprop,backendName:"cpu",kernelFunc:vo};function go(ae,ue,E,D,A){var H=i.util.computeStrides(ue),se=va(ae,ue,E,H,A,"max"),te=ia(ae,ue,E,A,!0,D);return[se.values,te.values]}var To={kernelName:i.MaxPoolWithArgmax,backendName:"cpu",kernelFunc:function(ae){var ue=ae.inputs,E=ae.attrs,D=ae.backend,A=ue.x,H=E,se=H.filterSize,te=H.strides,_e=H.pad,ce=H.includeBatchInIndex,fe=D;X(A,"MaxPoolWithArgmax");var ve=fe.data.get(A.dataId).values,ge=i.backend_util.computePool2DInfo(A.shape,se,te,[1,1],_e),Ae=go(ve,A.shape,A.dtype,ce,ge),Oe=Ae[0],De=Ae[1],Ve=fe.write(Oe,ge.outShape,A.dtype),Xe=fe.write(De,ge.outShape,A.dtype);return[{dataId:Ve,shape:ge.outShape,dtype:A.dtype},{dataId:Xe,shape:ge.outShape,dtype:"int32"}]}};function Es(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=D.paddings,se=D.mode;X(A,"mirrorPad");for(var te=H.map(function(ht,_t){return ht[0]+A.shape[_t]+ht[1]}),_e=H.map(function(ht){return ht[0]}),ce=H.map(function(ht,_t){return ht[0]+A.shape[_t]}),fe=se==="reflect"?0:1,ve=E.data.get(A.dataId).values,ge=A.shape.length,Ae=i.util.computeStrides(A.shape),Oe=i.util.sizeFromShape(te),De=te.length,Ve=i.util.computeStrides(te),Xe=i.util.getTypedArrayFromDType(A.dtype,Oe),at=0;at<Oe;at++){for(var it=i.util.indexToLoc(at,De,Ve),$=0;$<De;$++)it[$]<_e[$]?it[$]=_e[$]*2-it[$]-fe:it[$]>=ce[$]&&(it[$]=(ce[$]-1)*2-it[$]+fe);it=it.map(function(ht,_t){return ht-_e[_t]});var rt=i.util.locToIndex(it,ge,Ae);Xe[at]=ve[rt]}var xt=E.write(Xe,te,A.dtype);return{dataId:xt,shape:te,dtype:A.dtype}}var Eo={kernelName:i.MirrorPad,backendName:"cpu",kernelFunc:Es},Rs=i.kernel_impls.nonMaxSuppressionV4Impl,As={kernelName:i.NonMaxSuppressionV4,backendName:"cpu",kernelFunc:function(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue,H=A.boxes,se=A.scores,te=D,_e=te.maxOutputSize,ce=te.iouThreshold,fe=te.scoreThreshold,ve=te.padToMaxOutputSize,ge=E;X(H,"NonMaxSuppressionPadded");var Ae=ge.data.get(H.dataId).values,Oe=ge.data.get(se.dataId).values,De=Rs(Ae,Oe,_e,ce,fe,ve),Ve=De.selectedIndices,Xe=De.validOutputs;return[Ve,Xe]}},Zo=i.kernel_impls.nonMaxSuppressionV5Impl,Ro={kernelName:i.NonMaxSuppressionV5,backendName:"cpu",kernelFunc:function(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue,H=A.boxes,se=A.scores,te=D,_e=te.maxOutputSize,ce=te.iouThreshold,fe=te.scoreThreshold,ve=te.softNmsSigma,ge=E;X(H,"NonMaxSuppressionWithScore");var Ae=ge.data.get(H.dataId).values,Oe=ge.data.get(se.dataId).values,De=_e,Ve=ce,Xe=fe,at=ve,it=Zo(Ae,Oe,De,Ve,Xe,at),$=it.selectedIndices,rt=it.selectedScores;return[$,rt]}};function Qo(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=D.paddings,se=D.constantValue;X(A,"pad");var te=H.map(function(xt,ht){return xt[0]+A.shape[ht]+xt[1]}),_e=H.map(function(xt){return xt[0]}),ce=E.data.get(A.dataId).values,fe=i.util.sizeFromShape(A.shape),ve=A.shape.length,ge=i.util.computeStrides(A.shape),Ae=i.util.sizeFromShape(te),Oe=te.length,De=i.util.computeStrides(te),Ve=i.util.getTypedArrayFromDType(A.dtype,Ae);se!==0&&Ve.fill(se);for(var Xe=0;Xe<fe;Xe++){var at=i.util.indexToLoc(Xe,ve,ge),it=at.map(function(xt,ht){return xt+_e[ht]}),$=i.util.locToIndex(it,Oe,De);Ve[$]=ce[Xe]}var rt=E.write(Ve,te,A.dtype);return{dataId:rt,shape:te,dtype:A.dtype}}var Ao={kernelName:i.PadV2,backendName:"cpu",kernelFunc:Qo},Jo=_r(i.Reciprocal,function(ae){return 1/ae}),vi={kernelName:i.Reciprocal,backendName:"cpu",kernelFunc:Jo},Fs={kernelName:i.RotateWithOffset,backendName:"cpu",kernelFunc:function(ae){for(var ue=ae.inputs,E=ae.attrs,D=ae.backend,A=ue.image,H=E,se=H.radians,te=H.fillValue,_e=H.center,ce=D,fe=i.util.getTypedArrayFromDType(A.dtype,i.util.sizeFromShape(A.shape)),ve=A.shape,ge=ve[0],Ae=ve[1],Oe=ve[2],De=ve[3],Ve=i.backend_util.getImageCenter(_e,Ae,Oe),Xe=Ve[0],at=Ve[1],it=255,$=Math.sin(se),rt=Math.cos(se),xt=ce.data.get(A.dataId).values,ht=0;ht<ge;ht++)for(var _t=ht*Oe*Ae*De,At=0;At<Ae;At++)for(var zt=At*(Oe*De),Pt=0;Pt<Oe;Pt++)for(var Ut=Pt*De,Tt=0;Tt<De;Tt++){var Xt=[ge,At,Pt,Tt],Ht=Xt[2],Ot=Xt[1],Rt=(Ht-Xe)*rt-(Ot-at)*$,wt=(Ht-Xe)*$+(Ot-at)*rt;Rt=Math.round(Rt+Xe),wt=Math.round(wt+at);var Et=te;if(typeof te!="number"&&(Tt===3?Et=it:Et=te[Tt]),Rt>=0&&Rt<Oe&&wt>=0&&wt<Ae){var Vt=wt*(Oe*De),qt=Rt*De,lr=_t+Vt+qt+Tt;Et=xt[lr]}var ir=_t+zt+Ut+Tt;fe[ir]=Et}var Ie=ce.write(fe,A.shape,A.dtype);return{dataId:Ie,shape:A.shape,dtype:A.dtype}}},eu=_r(i.Round,function(ae){var ue=Math.floor(ae);return ae-ue<.5?Math.floor(ae):ae-ue>.5?Math.ceil(ae):ue%2===0?ue:ue+1}),ds={kernelName:i.Round,backendName:"cpu",kernelFunc:eu},tu=i.backend_util.SELU_SCALEALPHA,Ds=i.backend_util.SELU_SCALE,fs=_r(i.Selu,function(ae){return ae>=0?Ds*ae:tu*(Math.exp(ae)-1)}),Os={kernelName:i.Selu,backendName:"cpu",kernelFunc:fs},Ms=_r(i.Sigmoid,function(ae){return 1/(1+Math.exp(-ae))}),ru={kernelName:i.Sigmoid,backendName:"cpu",kernelFunc:Ms},ms=_r(i.Sign,function(ae){return ae<0?-1:ae>0?1:0}),nu={kernelName:i.Sign,backendName:"cpu",kernelFunc:ms},ys=_r(i.Sin,function(ae){return Math.sin(ae)}),Fo={kernelName:i.Sin,backendName:"cpu",kernelFunc:ys},zs=_r(i.Sinh,function(ae){return Math.sinh(ae)}),$o={kernelName:i.Sinh,backendName:"cpu",kernelFunc:zs},xo=11920928955078125e-23,vs=Math.log(xo)+2,Do=_r(i.Softplus,function(ae){var ue=ae>-vs,E=ae<vs,D=Math.exp(ae),A;return E?A=D:ue?A=ae:A=Math.log(1+D),A}),Ls={kernelName:i.Softplus,backendName:"cpu",kernelFunc:Do};function es(ae){var ue=ae.inputs,E=ae.attrs,D=ae.backend,A=ue.x,H=E.perm;X(A,"transpose");for(var se=A.shape.length,te=new Array(se),_e=0;_e<te.length;_e++)te[_e]=A.shape[H[_e]];var ce=D.data.get(A.dataId).values,fe=di(ce,A.shape,A.dtype,H,te),ve=D.write(fe,te,A.dtype);return{dataId:ve,shape:te,dtype:A.dtype}}var _o={kernelName:i.Transpose,backendName:"cpu",kernelFunc:es};function wo(ae){var ue=ae.inputs,E=ae.backend,D=ae.attrs,A=ue.x,H=D.blockShape,se=D.paddings;X([A],"spaceToBatchND");var te=i.util.sizeFromShape(H),_e=[[0,0]];_e.push.apply(_e,se);for(var ce=1+H.length;ce<A.shape.length;++ce)_e.push([0,0]);var fe=Ao.kernelFunc({inputs:{x:A},backend:E,attrs:{paddings:_e,constantValue:0}}),ve=i.backend_util.getReshaped(fe.shape,H,te,!1),ge=i.backend_util.getPermuted(ve.length,H.length,!1),Ae=i.backend_util.getReshapedPermuted(fe.shape,H,te,!1),Oe={x:fe},De={shape:ve},Ve=ya({inputs:Oe,backend:E,attrs:De}),Xe={x:Ve},at={perm:ge},it=es({inputs:Xe,backend:E,attrs:at}),$={x:it},rt={shape:Ae},xt=ya({inputs:$,backend:E,attrs:rt});return E.disposeIntermediateTensorInfo(fe),E.disposeIntermediateTensorInfo(Ve),E.disposeIntermediateTensorInfo(it),xt}var Ps={kernelName:i.SpaceToBatchND,backendName:"cpu",kernelFunc:wo},Bs=_r(i.Sqrt,function(ae){return Math.sqrt(ae)}),gs={kernelName:i.Sqrt,backendName:"cpu",kernelFunc:Bs},ts={kernelName:i.Square,backendName:"cpu",kernelFunc:function(ae){var ue=ae.inputs,E=ae.backend,D=ue.x,A=E;X(D,"square");for(var H=A.data.get(D.dataId).values,se=new Float32Array(H.length),te=0;te<H.length;++te){var _e=H[te];se[te]=_e*_e}var ce=A.write(se,D.shape,D.dtype);return{dataId:ce,shape:D.shape,dtype:D.dtype}}},au=_r(i.Step,function(ae,ue){var E=ue;return isNaN(ae)?NaN:ae>0?1:E.alpha}),bu={kernelName:i.Step,backendName:"cpu",kernelFunc:au},iu=_r(i.Tan,function(ae){return Math.tan(ae)}),Oo={kernelName:i.Tan,backendName:"cpu",kernelFunc:iu},Mo=_r(i.Tanh,function(ae){return Math.tanh(ae)}),xs={kernelName:i.Tanh,backendName:"cpu",kernelFunc:Mo};function rs(ae){var ue=ae.inputs,E=ae.attrs,D=ae.backend,A=E.axis,H=ue.x;X(H,"unique");var se=D.data.get(H.dataId).values,te=fi(se,A,H.shape,H.dtype),_e=te.outputValues,ce=te.outputShape,fe=te.indices;return[D.makeTensorInfo(ce,H.dtype,_e),D.makeTensorInfo([fe.length],"int32",fe)]}for(var ki={kernelName:i.Unique,backendName:"cpu",kernelFunc:rs},zo=[ne,W,Ue,tt,jr,Ye,St,fr,aa,bi,hn,Y,Jr,ot,Tn,Jn,Kt,sa,S,k,Mi,Je,gt,Se,Lt,Gt,wr,Zt,kn,pn,Dr,zn,cr,gr,Rn,ta,Bn,nn,Ba,si,za,ao,Za,Ze,Yo,En,Co,ua,ca,_i,Zn,Ta,yo,Da,To,vn,Eo,Ga,As,Ro,La,Ao,no,yt,vi,ji,qi,Oi,Fs,ds,Ia,Os,ru,nu,Fo,$o,na,Ls,Ps,gs,ts,Ri,bu,ma,Oo,xs,_o,ki],Lo=0,Yi=zo;Lo<Yi.length;Lo++){var ns=Yi[Lo];i.registerKernel(ns)}N.MathBackendCPU=w,N.shared=ja,N.version_cpu=ln}),vg=Or(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),we=function(f,p){return we=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])},we(f,p)};function M(f,p){we(f,p);function l(){this.constructor=f}f.prototype=p===null?Object.create(p):(l.prototype=p.prototype,new l)}function V(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 P(Q){try{G(m.next(Q))}catch(ke){R(ke)}}function L(Q){try{G(m.throw(Q))}catch(ke){R(ke)}}function G(Q){Q.done?I(Q.value):g(Q.value).then(P,L)}G((m=m.apply(f,p||[])).next())})}function oe(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:P(0),throw:P(1),return:P(2)},typeof Symbol=="function"&&(R[Symbol.iterator]=function(){return this}),R;function P(G){return function(Q){return L([G,Q])}}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(Q){G=[6,Q],g=0}finally{m=I=0}if(G[0]&5)throw G[1];return{value:G[0]?G[1]:void 0,done:!0}}}var de={},X={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Te(f,p){de[f]=p}function z(f){if(!(f in de)){var p=ye(f);if(p!==null)de[f]=p;else return console.log("Could not get context for WebGL version",f),null}var l=de[f];return l.isContextLost()?(delete de[f],z(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),de[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 ye(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 de[f]},!1),f===1?p.getContext("webgl",X)||p.getContext("experimental-webgl",X):p.getContext("webgl2",X)}var ee;(function(f){f[f.DENSE=0]="DENSE",f[f.SHARED_BATCH=1]="SHARED_BATCH"})(ee||(ee={}));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 xe;(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"})(xe||(xe={}));function We(f,p){return[p,f]}function W(f,p){return f*p}function st(f){var p=i.util.sizeFromShape(f),l=Math.ceil(p/4);return i.util.sizeToSquarishShape(l)}function ut(f,p){return[Math.max(1,Math.ceil(p/2)),Math.max(1,Math.ceil(f/2))]}function Kt(f,p){var l=ut(f,p),m=l[0],g=l[1];return m*g*4}function It(f,p){var l=f,m,g,I,R,P,L,G,Q,ke,Ce;return i.env().getNumber("WEBGL_VERSION")===2?(m=l.R32F,g=l.R16F,I=l.RGBA16F,R=l.RGBA32F,P=l.RED,G=4,Q=1,ke=l.HALF_FLOAT,Ce=l.FLOAT):(m=f.RGBA,g=f.RGBA,I=f.RGBA,R=l.RGBA,P=f.RGBA,G=4,Q=4,ke=p!=null?p.HALF_FLOAT_OES:null,Ce=f.FLOAT),L=f.RGBA,{internalFormatFloat:m,internalFormatHalfFloat:g,internalFormatPackedHalfFloat:I,internalFormatPackedFloat:R,textureFormatFloat:P,downloadTextureFormat:L,downloadUnpackNumChannels:G,defaultNumChannels:Q,textureTypeHalfFloat:ke,textureTypeFloat:Ce}}function Ze(f,p){var l=p();return i.env().getBool("DEBUG")&&mt(f),l}function mt(f){var p=f.getError();if(p!==f.NO_ERROR)throw new Error("WebGL Error: "+nt(f,p))}var yt=596e-10,$e=65504;function ot(f){return!!(i.env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||f===0||yt<Math.abs(f)&&Math.abs(f)<$e)}function nt(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 et(f,p){return Yn(f,function(){return f.getExtension(p)},'Extension "'+p+'" not supported on this browser.')}function Qt(f,p){var l=Yn(f,function(){return f.createShader(f.VERTEX_SHADER)},"Unable to create vertex WebGLShader.");if(Ze(f,function(){return f.shaderSource(l,p)}),Ze(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 rr(f,p){var l=Yn(f,function(){return f.createShader(f.FRAGMENT_SHADER)},"Unable to create fragment WebGLShader.");if(Ze(f,function(){return f.shaderSource(l,p)}),Ze(f,function(){return f.compileShader(l)}),f.getShaderParameter(l,f.COMPILE_STATUS)===!1)throw jr(p,f.getShaderInfoLog(l)),new Error("Failed to compile fragment shader.");return l}var jt=/ERROR: [0-9]+:([0-9]+):/g;function jr(f,p){var l=jt.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,Fe){return i.util.rightPad((Fe+1).toString(),I)+Ce}),P=0,L=0;L<R.length;L++)P=Math.max(R[L].length,P);var G=R.slice(0,m-1),Q=R.slice(m-1,m),ke=R.slice(m);console.log(G.join(`
`)),console.log(p.split(`
`)[0]),console.log("%c "+i.util.rightPad(Q[0],P),"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(ke.join(`
`))}function Pr(f){return Yn(f,function(){return f.createProgram()},"Unable to create WebGLProgram.")}function _r(f,p){if(Ze(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 ar(f,p){if(Ze(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 da(f,p){var l=Yn(f,function(){return f.createBuffer()},"Unable to create WebGLBuffer");return Ze(f,function(){return f.bindBuffer(f.ARRAY_BUFFER,l)}),Ze(f,function(){return f.bufferData(f.ARRAY_BUFFER,p,f.STATIC_DRAW)}),l}function Ha(f,p){var l=Yn(f,function(){return f.createBuffer()},"Unable to create WebGLBuffer");return Ze(f,function(){return f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,l)}),Ze(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 ba(f){return Yn(f,function(){return f.createTexture()},"Unable to create WebGLTexture.")}function ka(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 ta(f){return Yn(f,function(){return f.createFramebuffer()},"Unable to create WebGLFramebuffer.")}function Ma(f,p,l,m,g,I,R){var P=f.getAttribLocation(p,l);return P===-1?!1:(Ze(f,function(){return f.bindBuffer(f.ARRAY_BUFFER,m)}),Ze(f,function(){return f.vertexAttribPointer(P,g,f.FLOAT,!1,I,R)}),Ze(f,function(){return f.enableVertexAttribArray(P)}),!0)}function Ti(f,p,l){Wn(f,l),Ze(f,function(){return f.activeTexture(f.TEXTURE0+l)}),Ze(f,function(){return f.bindTexture(f.TEXTURE_2D,p)})}function Bn(f,p){Wn(f,p),Ze(f,function(){return f.activeTexture(f.TEXTURE0+p)}),Ze(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function ra(f,p,l){return Yn(f,function(){return f.getUniformLocation(p,l)},'uniform "'+l+'" not present in program.')}function cn(f,p,l){return f.getUniformLocation(p,l)}function za(f,p,l,m){Ze(f,function(){return Ti(f,p,m)}),Ze(f,function(){return f.uniform1i(l,m)})}function fn(f){Ze(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,null)}),Ze(f,function(){return f.viewport(0,0,f.canvas.width,f.canvas.height)}),Ze(f,function(){return f.scissor(0,0,f.canvas.width,f.canvas.height)})}function Gn(f,p,l){Ze(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,l)}),Ze(f,function(){return f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,p,0)})}function _i(f,p){Ze(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,p)}),Ze(f,function(){return f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,null,0)})}function fa(f){var p=f.checkFramebufferStatus(f.FRAMEBUFFER);if(p!==f.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+Hi(f,p))}function Hi(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 Yn(f,p,l){var m=Ze(f,function(){return p()});if(m==null)throw new Error(l);return m}function Wn(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 Ga(f,p){return p===void 0&&(p=2),i.util.sizeFromShape(f.slice(0,f.length-p))}function Sa(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 hi(f){var p=[1,1,1],l=f.length===0||f.length===1&&f[0]===1;return l||(p=[Ga(f)].concat(Sa(f))),p}function La(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,Q){return Q>=f.length-2?i.util.nearestLargerEven(f[Q]):f[Q]}),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=Ga(f),P=2,L=2;return f.length&&(l=Sa(f),P=l[0],L=l[1]),I=R*(P/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 xn(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 Ia,Rr;function Pa(f){if(Ia==null){var p=z(f);Ia=p.getParameter(p.MAX_TEXTURE_SIZE)}return Ia}function na(){Ia=null}function Ei(){Rr=null}function Gi(f){if(Rr==null){var p=z(f);Rr=p.getParameter(p.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Rr)}function Ri(f){if(f===0)return 0;var p,l=z(f);return jn(l,"EXT_disjoint_timer_query_webgl2")&&f===2?p=2:jn(l,"EXT_disjoint_timer_query")?p=1:p=0,p}function jn(f,p){var l=f.getExtension(p);return l!=null}function ni(f){try{var p=z(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=z(f);if(f===1){if(!jn(p,"OES_texture_float"))return!1}else if(!jn(p,"EXT_color_buffer_float"))return!1;var l=di(p);return l}function ma(f){if(f===0)return!1;var p=z(f);if(f===1){if(!jn(p,"OES_texture_float"))return!1;if(!jn(p,"WEBGL_color_buffer_float"))return!1}else{if(jn(p,"EXT_color_buffer_float"))return di(p);var l="EXT_color_buffer_half_float";if(jn(p,l)){var m=p.getExtension(l);return fi(p,m)}return!1}var g=di(p);return g}function di(f){var p=It(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=It(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 P=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),P}function ja(f){if(f!==2)return!1;var p=z(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 ai={__proto__:null,callAndCheck:Ze,canBeRepresented:ot,getWebGLErrorMessage:nt,getExtensionOrThrow:et,createVertexShader:Qt,createFragmentShader:rr,createProgram:Pr,linkProgram:_r,validateProgram:ar,createStaticVertexBuffer:da,createStaticIndexBuffer:Ha,getNumChannels:Tn,createTexture:ba,validateTextureSize:ka,createFramebuffer:ta,bindVertexBufferToProgramAttribute:Ma,bindTextureUnit:Ti,unbindTextureUnit:Bn,getProgramUniformLocationOrThrow:ra,getProgramUniformLocation:cn,bindTextureToProgramUniformSampler:za,bindCanvasToFramebuffer:fn,bindColorTextureToFramebuffer:Gn,unbindColorTextureFromFramebuffer:_i,validateFramebuffer:fa,getFramebufferErrorMessage:Hi,getBatchDim:Ga,getRowsCols:Sa,getShapeAs3D:hi,getTextureShapeFromLogicalShape:La,isReshapeFree:xn,getWebGLMaxTextureSize:Pa,resetMaxTextureSize:na,resetMaxTexturesInShader:Ei,getMaxTexturesInShader:Gi,getWebGLDisjointQueryTimerVersion:Ri,hasExtension:jn,isWebGLVersionEnabled:ni,isCapableOfRenderingToFloatTexture:pi,isDownloadFloatTextureEnabled:ma,isWebGLFenceEnabled:ja,assertNotComplex:ln},gr=i.env();gr.registerFlag("HAS_WEBGL",function(){return gr.getNumber("WEBGL_VERSION")>0}),gr.registerFlag("WEBGL_VERSION",function(){return ni(2)?2:ni(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 Pa(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",function(){return Gi(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",function(){var f=gr.getNumber("WEBGL_VERSION");return f===0?0:Ri(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 ma(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_FENCE_API_ENABLED",function(){return ja(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 Ai(f){const p=new Float32Array(f.length);for(let l=0;l<f.length;++l)p[l]=Math.abs(f[l]);return p}function wi(f){return(p,l,m,g,I)=>{const R=i.backend_util.assertAndGetBroadcastShape(p,l),P=R.length,L=i.util.computeStrides(R),G=i.util.sizeFromShape(R),Q=i.util.getTypedArrayFromDType(I,G),ke=p.length,Ce=l.length,Fe=i.util.computeStrides(p),Ee=i.util.computeStrides(l),Ge=i.backend_util.getBroadcastDims(p,R),Qe=i.backend_util.getBroadcastDims(l,R);if(Ge.length+Qe.length===0)for(let s=0;s<Q.length;++s)Q[s]=f(m[s%m.length],g[s%g.length]);else for(let s=0;s<Q.length;++s){const u=i.util.indexToLoc(s,P,L),r=u.slice(-ke);Ge.forEach(T=>r[T]=0);const o=i.util.locToIndex(r,ke,Fe),h=u.slice(-Ce);Qe.forEach(T=>h[T]=0);const b=i.util.locToIndex(h,Ce,Ee);Q[s]=f(m[o],g[b])}return[Q,R]}}const no=wi((f,p)=>f+p);function Qn(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 ji=Qn(f=>Math.ceil(f)),Fi=Qn(f=>Math.exp(f)),qi=Qn(f=>Math.expm1(f)),Di=Qn(f=>Math.floor(f)),ya=Qn(f=>Math.log(f));function Oi(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 P=f[R];for(let L=0;L<p;++L){const G=f[R+L];G>P&&(P=G)}g[I]=P}return g}const pe=wi((f,p)=>f*p),Y=Qn(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),P=i.util.computeStrides(m);if(I){const G=i.slice_util.computeFlatOffset(p,P);return f.subarray(G,G+R)}const L=i.util.getTypedArrayFromDType(g,R);for(let G=0;G<R;++G){const Q=l.length,ke=i.util.computeStrides(l),Ce=i.util.indexToLoc(G,Q,ke),Fe=Ce.map((Ge,Qe)=>Ge+p[Qe]),Ee=i.util.locToIndex(Fe,m.length,P);L[G]=f[Ee]}return L}const ne=wi((f,p)=>f-p);function re(f,p,l,m,g){const I=p.length,R=i.util.sizeFromShape(p),P=i.util.computeStrides(p),L=i.util.computeStrides(g),G=i.util.getTypedArrayFromDType(l,i.util.sizeFromShape(g));for(let Q=0;Q<R;++Q){const ke=i.util.indexToLoc(Q,I,P),Ce=new Array(ke.length);for(let Ee=0;Ee<Ce.length;Ee++)Ce[Ee]=ke[m[Ee]];const Fe=i.util.locToIndex(Ce,I,L);G[Fe]=f[Q]}return G}function Ue(f,p,l,m){const g=i.util.parseAxisParam(p,l)[0],I=[1,l[0],1];for(let Ee=0;Ee<g;Ee++)I[0]*=l[Ee];I[1]=l[g];for(let Ee=g+1;Ee<l.length;Ee++)I[2]*=l[Ee];const R={},P=new Int32Array(l[g]),L=new i.TensorBuffer(I,m,f),G=[],Q=I[0]===1&&I[2]===1;for(let Ee=0;Ee<l[g];Ee++){let Ge;if(Q)Ge=f[Ee].toString();else{const Qe=[];for(let s=0;s<I[0];s++)for(let u=0;u<I[2];u++)Qe.push(L.get(s,Ee,u));Ge=Qe.join(",")}if(R[Ge]!==void 0)P[Ee]=R[Ge];else{const Qe=Object.keys(R).length;R[Ge]=Qe,P[Ee]=Qe,G.push(Ee)}}const ke=I.slice();ke[1]=Object.keys(R).length;const Ce=new i.TensorBuffer(ke,m);G.forEach((Ee,Ge)=>{for(let Qe=0;Qe<I[0];Qe++)for(let s=0;s<I[2];s++)Ce.set(L.get(Qe,Ee,s),Qe,Ge,s)});const Fe=l.slice();return Fe[g]=ke[1],{outputValues:Ce.values,outputShape:Fe,indices:P}}var kt=Ai,tt=no,ze=ji,Ye=Fi,Dt=qi,St=Di,Mt=ya,fr=Oi,or=pe,aa=Y,va=j,ia=ne,qa=re,bi=Ue,rn=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}(),oa=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 P=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 `+P+` 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,P,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;",P=`
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="",P=`
#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:P,defineSpecialInf:L,defineRound:G}}function En(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,P=I===m.length-1?"int "+f[I+1]+" = "+l+" - "+f[I]+" * "+g:"index -= "+f[I]+" * "+g;return R+"; "+P+";"}).join("")}function qn(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 sa=`
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;
}
`,ga=i.backend_util.getBroadcastDims;function Mi(f,p,l,m){var g=[];f.forEach(function(Ee){var Ge=i.util.sizeFromShape(Ee.shapeInfo.logicalShape);Ee.shapeInfo.isUniform?g.push("uniform float "+Ee.name+(Ge>1?"["+Ge+"]":"")+";"):(g.push("uniform sampler2D "+Ee.name+";"),g.push("uniform int offset"+Ee.name+";"))});var I=g.join(`
`),R=f.map(function(Ee){return x(Ee,p,m)}).join(`
`),P=p.texShape,L=tn(),G=Se(L),Q,ke,Ce=Pe(L);p.isPacked?(Q=k(p.logicalShape,P),ke=Je(L)):(Q=K(p.logicalShape,P),ke=be(L)),m&&(Ce+=Wt);var Fe=[Ce,G,ke,I,Q,R,l].join(`
`);return Fe}function Aa(f){var p=f.shapeInfo.logicalShape;switch(p.length){case 0:return $r(f);case 1:return mi(f);case 2:return Xa(f);case 3:return zi(f);case 4:return Ca(f);case 5:return Ki(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 cr(f);case 1:return Fa(f);case 2:return Ka(f);case 3:return ii(f);default:return Rn(f)}}function x(f,p,l){l===void 0&&(l=!1);var m="";l?m+=S(f):m+=Aa(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 Jt(f,p);case 2:return Dr(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 Na(f,p);case 3:return Zt(f,p);case 4:return kn(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 be(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 Pe(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);
}
`+gt+`
`+ft+`
`+Lt+`
`;return p}var gt=`
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);
}
`,Lt=`
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 Jt(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 Zt(f,p){var l=En(["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="",P="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,P="b"+L+", "+P;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+"("+P+`);
}
`}function kn(f,p){var l=En(["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=En(["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=En(["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 Dr(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 Na(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 Sn(f){return"offset"+f}function cr(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,P=R[0],L=R[1],G=Sn(p);return`
float `+l+`() {
vec2 uv = uvFromFlat(`+P+", "+L+", "+G+`);
return sampleTexture(`+p+`, uv);
}
`}function Fa(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) {
`+oi(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=Sn(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 Ka(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],P=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 `+P.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 `+P.texture2D+"("+l+`, uv);
}
`}function Xa(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 P=i.util.squeezeShape(p),L=P.newShape,G=P.keptDims,Q=L;if(Q.length<p.length){var ke=Ya(f,Q),Ce=["row","col"];return`
`+Aa(ke)+`
float `+m+`(int row, int col) {
return `+m+"("+Ba(Ce,G)+`);
}
`}if(f.shapeInfo.isUniform)return`
float `+m+`(int row, int col) {
int index = round(dot(vec2(row, col), vec2(`+p[1]+`, 1)));
`+oi(f)+`
}
`;var Fe=g[0],Ee=g[1],Ge=Sn(l);return Ee===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) / `+Fe+`.0);
return sampleTexture(`+l+`, uv);
}
`:Fe===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) / `+Ee+`.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(`+Fe+", "+Ee+`, index);
return sampleTexture(`+l+`, uv);
}
`}function ii(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),P=[1,2],L=Ya(f,R),G=["b","row","col"];return`
`+S(L)+`
vec4 `+m+`(int b, int row, int col) {
return `+m+"("+Ba(G,P)+`);
}
`}var Q=I[0],ke=I[1],Ce=Math.ceil(p[2]/2),Fe=Ce*Math.ceil(p[1]/2),Ee=tn();return`
vec4 `+m+`(int b, int row, int col) {
vec2 uv = packedUVfrom3D(
`+Q+", "+ke+", "+Fe+", "+Ce+`, b, row, col);
return `+Ee.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),P=R.newShape,L=R.keptDims,G=P;if(G.length<p.length){var Q=Ya(f,G),ke=["row","col","depth"];return`
`+Aa(Q)+`
float `+m+`(int row, int col, int depth) {
return `+m+"("+Ba(ke,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)));
`+oi(f)+`
}
`;var Ce=f.shapeInfo.texShape,Fe=Ce[0],Ee=Ce[1],Ge=f.shapeInfo.flatOffset;if(Ee===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(`+Ee+".0, "+Fe+`.0);
return sampleTexture(`+l+`, uv);
}
`;if(Ee===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(`+Ee+".0, "+Fe+`.0);
return sampleTexture(`+l+`, uv);
}
`;var Qe=Sn(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 + "+Qe+`;
vec2 uv = uvFromFlat(`+Fe+", "+Ee+`, index);
return sampleTexture(`+l+`, uv);
}
`}function Rn(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)],P=R[0],L=R[1],G=Math.ceil(p[l-1]/2),Q=G*Math.ceil(p[l-2]/2),ke="int b, int row, int col",Ce="b * "+Q+" + (row / 2) * "+G+" + (col / 2)",Fe=2;Fe<l-1;Fe++)ke="int b"+Fe+", "+ke,Q*=p[l-Fe-1],Ce="b"+Fe+" * "+Q+" + "+Ce;var Ee=tn();return`
vec4 `+g+"("+ke+`) {
int index = `+Ce+`;
int texR = index / `+L+`;
int texC = index - texR * `+L+`;
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(`+L+", "+P+`);
return `+Ee.texture2D+"("+m+`, uv);
}
`}function Ca(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,P=i.util.squeezeShape(p),L=P.newShape,G=P.keptDims;if(L.length<p.length){var Q=Ya(f,L),ke=["row","col","depth","depth2"];return`
`+Aa(Q)+`
float `+m+`(int row, int col, int depth, int depth2) {
return `+m+"("+Ba(ke,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)));
`+oi(f)+`
}
`;var Ce=f.shapeInfo.flatOffset,Fe=f.shapeInfo.texShape,Ee=Fe[0],Ge=Fe[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, "+Ee+`.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, "+Ee+`.0);
return sampleTexture(`+l+`, uv);
}
`;var Qe=Sn(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(`+Ee+", "+Ge+", index + "+Qe+`);
return sampleTexture(`+l+`, uv);
}
`}function Ki(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,P=p[1]*R,L=i.util.squeezeShape(p),G=L.newShape,Q=L.keptDims;if(G.length<p.length){var ke=Ya(f,G),Ce=["row","col","depth","depth2","depth3"];return`
`+Aa(ke)+`
float `+m+`(int row, int col, int depth, int depth2, int depth3) {
return `+m+"("+Ba(Ce,Q)+`);
}
`}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(`+P+", "+R+", "+I+", "+g+`)) +
depth3;
`+oi(f)+`
}
`;var Fe=f.shapeInfo.flatOffset,Ee=f.shapeInfo.texShape,Ge=Ee[0],Qe=Ee[1];if(Qe===P&&Fe==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(`+Qe+".0, "+Ge+`.0);
return sampleTexture(`+l+`, uv);
}
`;if(Qe===g&&Fe==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(`+Qe+".0, "+Ge+`.0);
return sampleTexture(`+l+`, uv);
}
`;var s=Sn(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 * `+P+" + col * "+R+" + depth * "+I+` +
depth2 * `+g+" + depth3 + "+s+`;
vec2 uv = uvFromFlat(`+Ge+", "+Qe+`, 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 P=Ya(f,I),L=["row","col","depth","depth2","depth3","depth4"];return`
`+Aa(P)+`
float `+m+`(int row, int col, int depth,
int depth2, int depth3, int depth4) {
return `+m+"("+Ba(L,R)+`);
}
`}var G=p[5],Q=p[4]*G,ke=p[3]*Q,Ce=p[2]*ke,Fe=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(`+Fe+", "+Ce+", "+ke+", "+Q+`)) +
dot(
vec2(depth3, depth4),
vec2(`+G+`, 1)));
`+oi(f)+`
}
`;var Ee=f.shapeInfo.flatOffset,Ge=f.shapeInfo.texShape,Qe=Ge[0],s=Ge[1];if(s===Fe&&Ee==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+", "+ke+", "+Q+", "+G+`)) +
float(depth4);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(`+s+".0, "+Qe+`.0);
return sampleTexture(`+l+`, uv);
}
`;if(s===G&&Ee==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, "+Qe+`.0);
return sampleTexture(`+l+`, uv);
}
`;var u=Sn(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 * `+Fe+" + col * "+Ce+" + depth * "+ke+` +
depth2 * `+Q+" + depth3 * "+G+" + depth4 + "+u+`;
vec2 uv = uvFromFlat(`+Qe+", "+s+`, index);
return sampleTexture(`+l+`, uv);
}
`}function oi(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,P=ga(f.shapeInfo.logicalShape,p.logicalShape),L=nn(R),G=R-I,Q,ke=["x","y","z","w","u","v"];I===0?Q="":R<2&&P.length>=1?Q="coords = 0;":Q=P.map(function(o){return"coords."+ke[o+G]+" = 0;"}).join(`
`);var Ce="";R<2&&I>0?Ce="coords":Ce=f.shapeInfo.logicalShape.map(function(o,h){return"coords."+ke[h+G]}).join(", ");var Fe="return outputValue;",Ee=i.util.sizeFromShape(f.shapeInfo.logicalShape),Ge=Ee===1,Qe=i.util.sizeFromShape(p.logicalShape),s=Qe===1;if(I===1&&!Ge&&!s)Fe=`
return vec4(outputValue.xy, outputValue.xy);
`;else if(Ge&&!s)R===1?Fe=`
return vec4(outputValue.x, outputValue.x, 0., 0.);
`:Fe=`
return vec4(outputValue.x);
`;else if(P.length){var u=I-2,r=I-1;P.indexOf(u)>-1&&P.indexOf(r)>-1?Fe="return vec4(outputValue.x);":P.indexOf(u)>-1?Fe="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":P.indexOf(r)>-1&&(Fe="return vec4(outputValue.xx, outputValue.zz);")}return`
vec4 `+g+`() {
`+L+` coords = getOutputCoords();
`+Q+`
vec4 outputValue = get`+m+"("+Ce+`);
`+Fe+`
}
`}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,P=f.shapeInfo.logicalShape.length,L=p.logicalShape.length;if(!f.shapeInfo.isUniform&&P===L&&f.shapeInfo.flatOffset==null&&i.util.arraysEqual(R,I))return`
float `+g+`() {
return sampleTexture(`+l+`, resultUV);
}
`;var G=nn(L),Q=ga(f.shapeInfo.logicalShape,p.logicalShape),ke=L-P,Ce,Fe=["x","y","z","w","u","v"];P===0?Ce="":L<2&&Q.length>=1?Ce="coords = 0;":Ce=Q.map(function(Ge){return"coords."+Fe[Ge+ke]+" = 0;"}).join(`
`);var Ee="";return L<2&&P>0?Ee="coords":Ee=f.shapeInfo.logicalShape.map(function(Ge,Qe){return"coords."+Fe[Qe+ke]}).join(", "),`
float `+g+`() {
`+G+` coords = getOutputCoords();
`+Ce+`
return get`+m+"("+Ee+`);
}
`}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 Ya(f,p){var l=JSON.parse(JSON.stringify(f));return l.shapeInfo.logicalShape=p,l}function Ba(f,p){return p.map(function(l){return f[l]}).join(", ")}var Xi=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 P=this.outputShape,L=P.length,G=nn(L),Q=Vr("coords",L),ke,Ce;if(R===1){Ce=L+1;var Fe=nn(Ce);ke=`
`+Fe+" sourceLocR = "+Fe+"("+Q.join()+`, 0);
++`+Q[L-1]+`;
`+Fe+" sourceLocG = "+Fe+"("+Q.join()+`, 0);
++`+Q[L-2]+`;
`+Fe+" sourceLocA = "+Fe+"("+Q.join()+`, 0);
--`+Q[L-1]+`;
`+Fe+" sourceLocB = "+Fe+"("+Q.join()+`, 0);
--`+Q[L-2]+";"}else Ce=L,ke=`
`+G+` sourceLocR = coords;
++`+Q[L-1]+`;
`+G+` sourceLocG = coords;
++`+Q[L-2]+`;
`+G+` sourceLocA = coords;
--`+Q[L-1]+`;
`+G+` sourceLocB = coords;
--`+Q[L-2]+";";var Ee=["x","y","z","w","u","v"].slice(0,Ce),Ge="."+Ee[Ce-1],Qe=Ee.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.)",O=g?"":`
float getBestIndicesAChannel(`+Qe.join()+`) {
return getChannel(getBestIndicesA(`+Ee.join()+`),
vec2(`+Ee.slice(-2).join()+`));
}`;this.userCode=`
float getAChannel(`+Qe.join()+`) {
return getChannel(getA(`+Ee.join()+`),
vec2(`+Ee.slice(-2).join()+`));
}
`+O+`
void main() {
`+G+` coords = getOutputCoords();
bool hasNextCol = `+Q[L-1]+" < "+(P[L-1]-1)+`;
bool hasNextRow = `+Q[L-2]+" < "+(P[L-2]-1)+`;
`+ke+`
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}(),si=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,P=p.dilationWidth,L=p.effectiveFilterHeight,G=p.effectiveFilterWidth,Q=L-1-p.padInfo.top,ke=G-1-p.padInfo.left,Ce=1/(l*m);this.userCode=`
const ivec2 pads = ivec2(`+Q+", "+ke+`);
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+= `+P+`) {
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}(),Li=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,P=p.strideWidth,L=p.dilationDepth,G=p.dilationHeight,Q=p.dilationWidth,ke=p.effectiveFilterDepth,Ce=p.effectiveFilterHeight,Fe=p.effectiveFilterWidth,Ee=ke-1-p.padInfo.front,Ge=Ce-1-p.padInfo.top,Qe=Fe-1-p.padInfo.left,s=1/(l*m*g);this.userCode=`
const ivec3 pads = ivec3(`+Ee+", "+Ge+", "+Qe+`);
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 < `+ke+`;
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 < `+Fe+`;
wC += `+Q+`) {
float dyC = float(dyCCorner + wC) / `+P+`.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}(),ao=`
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;
}
`,Za=`
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);
`,io="return float(a == b);",Yo="return float(a < b);",No="return float(a <= b);",Co="return float(a > b);",oo="return float(a >= b);",ua="return float(a >= 1.0 && b >= 1.0);",Br="return float(a >= 1.0 || b >= 1.0);",ca=ao+`
return max(a, b);
`,Qa=ao+`
return min(a, b);
`,Zn=`if (b == 0.0) return NAN;
return mod(a, b);`,so="return (b >= 1.0) ? a : a * (b + 1.0);",Ta="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}(),Pi=`
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));
`+Pi+`
return result;
`,Da=`
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));
`,Es=`
return vec4(lessThan(a, b));
`,Eo=`
return vec4(lessThanEqual(a, b));
`,Rs=`
return vec4(greaterThan(a, b));
`,As=`
return vec4(greaterThanEqual(a, b));
`,Zo=`
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));
`,Qo=`
vec4 result = vec4(max(a, b));
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
`+Pi+`
return result;
`,Ao=`
vec4 result = vec4(min(a, b));
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
`+Pi+`
return result;
`,Jo=`
vec4 result = mod(a, b);
vec4 isNaN = vec4(equal(b, vec4(0.0)));
`+Pi+`
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 P=nn(I);if(R=`
`+P+` 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}(),eu=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}(),ds=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}(),tu=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}(),Ds=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",P=l-1-p.padInfo.top,L=m-1-p.padInfo.left,G=R?1:2,Q=R?2:3,ke=R?3:1;this.userCode=`
const ivec2 pads = ivec2(`+P+", "+L+`);
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d1 = coords[`+ke+`];
ivec2 dyCorner = ivec2(coords[`+G+"], coords["+Q+`]) - 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}(),fs=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,P=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+" - "+P+`;
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}(),Os=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,P=p.strideWidth,L=l-1-p.padInfo.front,G=m-1-p.padInfo.top,Q=g-1-p.padInfo.left;this.userCode=`
const ivec3 pads = ivec3(`+L+", "+G+", "+Q+`);
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) / `+P+`.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}(),Ms=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}(),ru=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,P=m-1-p.padInfo.left,L=p.outChannels/p.inChannels;this.userCode=`
const ivec2 pads = ivec2(`+R+", "+P+`);
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}(),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.padInfo.top,R=p.padInfo.left,P=p.strideHeight,L=p.strideWidth,G=p.dilationHeight,Q=p.dilationWidth,ke=p.filterHeight,Ce=p.filterWidth,Fe=Math.floor(p.inChannels/4)*4,Ee=p.inChannels%4,Ge=p.dataFormat==="channelsLast",Qe=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(`+P+", "+L+`);
const ivec2 pads = ivec2(`+I+", "+R+`);
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d2 = coords[`+u+`];
ivec2 xRCCorner =
ivec2(coords[`+Qe+"], 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 < `+ke+`; wR++) {
int xR = xRCorner + wR * `+G+`;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+Ce+`; wC++) {
int xC = xCCorner + wC * `+Q+`;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
for (int d1 = 0; d1 < `+Fe+`; 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 (`+(Ee===1)+`) {
if (`+Ge+`) {
dotProd +=
getX(batch, xR, xC, `+Fe+`) *
getW(wR, wC, `+Fe+`, d2);
} else {
dotProd +=
getX(batch, `+Fe+`, xR, xC) *
getW(wR, wC, `+Fe+`, d2);
}
} else if (`+(Ee===2)+`) {
vec2 wValues = vec2(
getW(wR, wC, `+Fe+`, d2),
getW(wR, wC, `+Fe+` + 1, d2)
);
if (`+Ge+`) {
vec2 xValues = vec2(
getX(batch, xR, xC, `+Fe+`),
getX(batch, xR, xC, `+Fe+` + 1)
);
dotProd += dot(xValues, wValues);
} else {
vec2 xValues = vec2(
getX(batch, `+Fe+`, xR, xC),
getX(batch, `+Fe+` + 1, xR, xC)
);
dotProd += dot(xValues, wValues);
}
} else if (`+(Ee===3)+`) {
vec3 wValues = vec3(
getW(wR, wC, `+Fe+`, d2),
getW(wR, wC, `+Fe+` + 1, d2),
getW(wR, wC, `+Fe+` + 2, d2)
);
if (`+Ge+`) {
vec3 xValues = vec3(
getX(batch, xR, xC, `+Fe+`),
getX(batch, xR, xC, `+Fe+` + 1),
getX(batch, xR, xC, `+Fe+` + 2)
);
dotProd += dot(xValues, wValues);
} else {
vec3 xValues = vec3(
getX(batch, `+Fe+`, xR, xC),
getX(batch, `+Fe+` + 1, xR, xC),
getX(batch, `+Fe+` + 2, xR, xC)
);
dotProd += dot(xValues, wValues);
}
}
}
}
float result = dotProd;
`+h+`
`+o+`
setOutput(result);
}
`}return f}(),nu=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,P=p.strideWidth,L=p.dilationDepth,G=p.dilationHeight,Q=p.dilationWidth,ke=p.filterDepth,Ce=p.filterHeight,Fe=p.filterWidth,Ee=Math.floor(p.inChannels/4)*4,Ge=p.inChannels%4;this.userCode=`
const ivec3 strides = ivec3(`+I+", "+R+", "+P+`);
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 < `+ke+`; 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 < `+Fe+`; wC++) {
int xC = xCCorner + wC * `+Q+`;
if (xC < 0 || xC >= `+p.inWidth+`) {
continue;
}
for (int d1 = 0; d1 < `+Ee+`; 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, `+Ee+`) *
getW(wF, wR, wC, `+Ee+`, d2);
} else if (`+(Ge===2)+`) {
vec2 xValues = vec2(
getX(batch, xF, xR, xC, `+Ee+`),
getX(batch, xF, xR, xC, `+Ee+` + 1)
);
vec2 wValues = vec2(
getW(wF, wR, wC, `+Ee+`, d2),
getW(wF, wR, wC, `+Ee+` + 1, d2)
);
dotProd += dot(xValues, wValues);
} else if (`+(Ge===3)+`) {
vec3 xValues = vec3(
getX(batch, xF, xR, xC, `+Ee+`),
getX(batch, xF, xR, xC, `+Ee+` + 1),
getX(batch, xF, xR, xC, `+Ee+` + 2)
);
vec3 wValues = vec3(
getW(wF, wR, wC, `+Ee+`, d2),
getW(wF, wR, wC, `+Ee+` + 1, d2),
getW(wF, wR, wC, `+Ee+` + 2, d2)
);
dotProd += dot(xValues, wValues);
}
}
}
}
setOutput(dotProd);
}
`}return f}(),ys=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,P=p.padInfo.top,L=p.padInfo.left,G=p.strideHeight,Q=p.strideWidth,ke=p.dilationHeight,Ce=p.dilationWidth,Fe=p.filterHeight,Ee=p.filterWidth,Ge=p.outChannels/p.inChannels,Qe="",s="";m&&(g?Qe=`float activation(float a) {
float b = getPreluActivationWeightsAtOutCoords();
`+m+`
}`:Qe=`
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=`
`+Qe+`
const ivec2 strides = ivec2(`+G+", "+Q+`);
const ivec2 pads = ivec2(`+P+", "+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 < `+Fe+`; wR++) {
int xR = xRCorner + wR * `+ke+`;
if (xR < 0 || xR >= `+I+`) {
continue;
}
for (int wC = 0; wC < `+Ee+`; 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}(),Fo=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,P=p.padInfo.top,L=p.padInfo.left,G=p.strideHeight,Q=p.strideWidth,ke=p.dilationHeight,Ce=p.dilationWidth,Fe=p.filterHeight,Ee=p.filterWidth,Ge=Ee,Qe="int xR; int xC; int xCOffset;",s=0;s<Fe;s++)for(var u=0;u<Ee;u++)Qe+=`
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<Fe;s++)for(var r=0;r<Ge;r++){var u=r*2;if(Qe+=`
xR = xRCorner + `+s*ke+`;
xC = xCCorner + `+u*Ce+`;
`,Q===1){if(u<Ee&&(L%2===1?Qe+=`
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);
}
`:Qe+=`
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<Ee)){var o=L%2===0?i.util.nearestLargerEven(Ce):Ce;Ce%2===0&&L%2===1||Ce%2!==0&&L%2!==1?(Qe+=`
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&&(Qe+=`
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.);
}
`),Qe+=`
xR`+s+"C"+(u+1)+` = vec4(
xTexelR`+s+"C"+u+".zw, xTexelR"+s+"C"+(u+2)+`.xy);
`):Qe+=`
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<Ee&&(Qe+=`
if(xR >= 0 && xR < `+I+`) {
`,L%2===1?(Qe+=`
xCOffset = xC + 1 - `+Q+`;
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<Ee&&(Qe+=`
vec4 final = vec4(0.);
xCOffset = xC + 1 + `+Q+`;
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);
`)):(Qe+=`
if(xC >= 0 && xC < `+R+`) {
xTexelR`+s+"C"+u+` = getX(batch, xR, xC, d1);
} else {
xTexelR`+s+"C"+u+` = vec4(0.);
}
xCOffset = xC + `+Q+`;
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<Ee&&(Qe+=`
xR`+s+"C"+(u+1)+` = vec4(
xTexelR`+s+"C"+u+".zw, xTexelR"+s+"C"+(u+2)+`.zw);
`)),Qe+="}");u<Ee&&(Qe+=`
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<Ee&&(Qe+=`
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<Fe;s++)for(var u=0;u<Ee;u++)Qe+="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+", "+Q+`);
const ivec2 pads = ivec2(`+P+", "+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.);
`+Qe+`
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],P=p[1],L=p[2],G=p[3],Q=l[0],ke=m[0],Ce=m[1];this.outputShape=[Q,ke,Ce,G];var Fe=g==="bilinear"?1:0,Ee=[P-1+".0",L-1+".0"],Ge=Ee[0],Qe=Ee[1],s=ke>1?[""+(P-1)/(ke-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*"+Qe+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+Qe],b=h[0],T=h[1],O=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 = `+O+`;
if( in_x < 0.0 || in_x > `+Qe+` ) {
setOutput(float(`+I+`));
return;
}
vec2 sourceFracIndexCR = vec2(in_x,in_y);
if(`+Fe+` == 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}(),$o=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],P="",L="";l?(P=m?"end != "+(R-1):"end != 0",L=m?"end + 1":"end - 1"):(P=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 = `+vs(g,"coords")+`;
float val = `+I+`;
int pow2 = int(pow(2.0, index));
if (`+P+`) {
int idx = `+L+`;
`+vs(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 vs(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 Do=function(){function f(p){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=ee.DENSE;var l=st(p),m=tn();this.outputShape=p,this.userCode=`
ivec3 outCoordsFromFlatIndex(int index) {
`+En(["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}(),Ls=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=ee.DENSE;var l=st(p),m=tn();this.outputShape=p,this.userCode=`
ivec3 outCoordsFromFlatIndex(int index) {
`+En(["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}(),es=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=`
`+sa+`
void main() {
float x = getAAtOutCoords();
`+l.output+` = encode_float(x);
}
`}return f}(),Ps=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=`
`+sa+`
void main() {
ivec3 coords = getOutputCoords();
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
`+l.output+` = encode_float(x);
}
`}return f}(),Bs=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 P="result";m&&(P="floor(result * 255. + 0.5)"),this.userCode=`
`+qn(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("+P+`, 0., 0., 0.);
}
`}return f}(),gs=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 P="",L="result";m&&(L="floor(result * 255. + 0.5)");for(var G=0;G<=1;G++)for(var Q=0;Q<=1;Q++){var ke=G*2+Q;P+=`
localCoords = coords;
if(localCoords[2] + `+Q+" < "+p[2]+`) {
localCoords[2] += `+Q+`;
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[`+ke+`] = values[0];
} else if(offset == 1) {
result[`+ke+`] = values[1];
} else if(offset == 2) {
result[`+ke+`] = values[2];
} else {
result[`+ke+`] = values[3];
}
}
}
`}this.userCode=`
`+qn(p)+`
void main() {
ivec3 coords = getOutputCoords();
vec4 result = vec4(0.);
int flatIndex, r, c, offset;
ivec3 localCoords;
vec2 uv;
vec4 values;
`+P+`
`+g.output+" = "+L+`;
}
`}return f}(),ts=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}(),au=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=bu(p,m);this.userCode=`
void main() {
`+I+` resRC = getOutputCoords();
setOutput(getA(`+R+`));
}
`}return f}();function bu(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 iu=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 Qt(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 da(f,p)}function xs(f){var p=new Uint16Array([0,1,2,2,1,3]);return Ha(f,p)}function rs(f,p,l,m,g,I){ka(p,l);var R=ba(f),P=f.TEXTURE_2D;return Ze(f,function(){return f.bindTexture(P,R)}),Ze(f,function(){return f.texParameteri(P,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE)}),Ze(f,function(){return f.texParameteri(P,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE)}),Ze(f,function(){return f.texParameteri(P,f.TEXTURE_MIN_FILTER,f.NEAREST)}),Ze(f,function(){return f.texParameteri(P,f.TEXTURE_MAG_FILTER,f.NEAREST)}),Ze(f,function(){return f.texImage2D(P,0,m,p,l,0,g,I,null)}),Ze(f,function(){return f.bindTexture(f.TEXTURE_2D,null)}),R}function ki(f){return f.internalFormatFloat}function zo(f,p,l,m){var g=We(p,l),I=g[0],R=g[1];return rs(f,I,R,ki(m),m.textureFormatFloat,f.FLOAT)}function Lo(f){return f.internalFormatHalfFloat}function Yi(f,p,l,m){var g=We(p,l),I=g[0],R=g[1];return rs(f,I,R,Lo(m),m.textureFormatFloat,m.textureTypeHalfFloat)}function ns(f){return f.downloadTextureFormat}function ae(f,p,l,m){var g=We(p,l),I=g[0],R=g[1];return rs(f,I,R,ns(m),f.RGBA,f.UNSIGNED_BYTE)}function ue(f){return f.internalFormatPackedFloat}function E(f,p,l,m){var g=ut(p,l),I=g[0],R=g[1];return rs(f,I,R,ue(m),f.RGBA,f.FLOAT)}function D(f){return f.internalFormatPackedHalfFloat}function A(f,p,l,m){var g=ut(p,l),I=g[0],R=g[1];return rs(f,I,R,D(m),f.RGBA,m.textureTypeHalfFloat)}function H(f,p,l){var m=0,g=3*4,I=3*4+2*4;Ze(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 se(f,p,l,m,g,I){Ze(f,function(){return f.bindTexture(f.TEXTURE_2D,p)});var R,P,L;g instanceof Uint8Array?(R=new Uint8Array(l*m*4),P=f.UNSIGNED_BYTE,L=f.RGBA):(R=new Float32Array(l*m*4),P=f.FLOAT,L=I.internalFormatPackedFloat),R.set(g),Ze(f,function(){return f.texImage2D(f.TEXTURE_2D,0,L,l,m,0,f.RGBA,P,R)}),Ze(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function te(f,p,l){Ze(f,function(){return f.bindTexture(f.TEXTURE_2D,p)}),l.data instanceof Uint8Array?Ze(f,function(){return f.texImage2D(f.TEXTURE_2D,0,f.RGBA,l.width,l.height,0,f.RGBA,f.UNSIGNED_BYTE,l.data)}):Ze(f,function(){return f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,l)}),Ze(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function _e(f,p,l,m){var g=f.createBuffer();Ze(f,function(){return f.bindBuffer(f.PIXEL_PACK_BUFFER,g)});var I=4,R=4,P=I*R*p*l;return Ze(f,function(){return f.bufferData(f.PIXEL_PACK_BUFFER,P,f.STREAM_READ)}),Ze(f,function(){return f.readPixels(0,0,l,p,f.RGBA,f.FLOAT,0)}),Ze(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 fe(f,p,l,m){var g=We(p,l),I=g[0],R=g[1],P=4,L=new Uint8Array(W(p*l,P));return Ze(f,function(){return f.readPixels(0,0,I,R,m.downloadTextureFormat,f.UNSIGNED_BYTE,L)}),new Float32Array(L.buffer)}function ve(f,p,l,m,g,I,R,P){var L=f,G=new Float32Array(Kt(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 ge(f,p,l){var m=new Float32Array(p*l*4);return Ze(f,function(){return f.readPixels(0,0,l,p,f.RGBA,f.FLOAT,m)}),m}var Ae={__proto__:null,createVertexShader:Oo,createVertexBuffer:Mo,createIndexBuffer:xs,getInternalFormatForFloat32MatrixTexture:ki,createFloat32MatrixTexture:zo,getInternalFormatForFloat16MatrixTexture:Lo,createFloat16MatrixTexture:Yi,getInternalFormatForUnsignedBytesMatrixTexture:ns,createUnsignedBytesMatrixTexture:ae,getInternalFormatForPackedMatrixTexture:ue,createPackedMatrixTexture:E,getInternalFormatForFloat16PackedMatrixTexture:D,createFloat16PackedMatrixTexture:A,bindVertexProgramAttributeStreams:H,uploadDenseMatrixToTexture:se,uploadPixelDataToTexture:te,createBufferFromOutputTexture:_e,downloadFloat32MatrixFromBuffer:ce,downloadByteEncodedFloatMatrixFromOutputTexture:fe,downloadPackedMatrixFromBuffer:ve,downloadMatrixFromPackedOutputTexture:ge},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,Te(l,p)):this.gl=z(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=et(this.gl,I),jn(this.gl,R))this.textureHalfFloatExtension=et(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),jn(this.gl,g))this.colorBufferHalfFloatExtension=et(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",jn(this.gl,m))this.colorBufferFloatExtension=this.gl.getExtension(m);else if(jn(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=xs(this.gl),this.framebuffer=ta(this.gl),this.textureConfig=It(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;Ze(l,function(){return l.finish()}),Ze(l,function(){return l.bindFramebuffer(l.FRAMEBUFFER,null)}),Ze(l,function(){return l.deleteFramebuffer(p.framebuffer)}),Ze(l,function(){return l.bindBuffer(l.ARRAY_BUFFER,null)}),Ze(l,function(){return l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)}),Ze(l,function(){return l.deleteBuffer(p.indexBuffer)}),this.disposed=!0},f.prototype.createFloat32MatrixTexture=function(p,l){return this.throwIfDisposed(),zo(this.gl,p,l,this.textureConfig)},f.prototype.createFloat16MatrixTexture=function(p,l){return this.throwIfDisposed(),Yi(this.gl,p,l,this.textureConfig)},f.prototype.createUnsignedBytesMatrixTexture=function(p,l){return this.throwIfDisposed(),ae(this.gl,p,l,this.textureConfig)},f.prototype.uploadPixelDataToTexture=function(p,l){this.throwIfDisposed(),te(this.gl,p,l)},f.prototype.uploadDenseMatrixToTexture=function(p,l,m,g){this.throwIfDisposed(),se(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),Ze(this.gl,function(){return l.gl.deleteTexture(p)})},f.prototype.downloadByteEncodedFloatMatrixFromOutputTexture=function(p,l,m){var g=this;return this.downloadMatrixDriver(p,function(){return fe(g.gl,l,m,g.textureConfig)})},f.prototype.downloadPackedMatrixFromBuffer=function(p,l,m,g,I,R){return ve(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 P=I.clientWaitSync(R,0,0);return P===I.ALREADY_SIGNALED||P===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 ge(g.gl,l,m)})},f.prototype.createProgram=function(p){this.throwIfDisposed();var l=this.gl,m=rr(l,p),g=Oo(l),I=Pr(l);return Ze(l,function(){return l.attachShader(I,g)}),Ze(l,function(){return l.attachShader(I,m)}),_r(l,I),this.debug&&ar(l,I),this.vertexAttrsAreBound||(this.setProgram(I),this.vertexAttrsAreBound=H(l,this.program,this.vertexBuffer)),I},f.prototype.deleteProgram=function(p){var l=this;this.throwIfDisposed(),p===this.program&&(this.program=null),p!=null&&Ze(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&&ar(this.gl,this.program),Ze(this.gl,function(){return l.gl.useProgram(p)})},f.prototype.getUniformLocation=function(p,l,m){return m===void 0&&(m=!0),this.throwIfDisposed(),m?ra(this.gl,p,l):cn(this.gl,p,l)},f.prototype.getAttributeLocation=function(p,l){var m=this;return this.throwIfDisposed(),Ze(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(),za(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=ut(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&&ar(this.gl,this.program),fa(this.gl)},f.prototype.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var p=this.gl;this.debug&&this.debugValidate(),Ze(p,function(){return p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0)})},f.prototype.blockUntilAllProgramsCompleted=function(){var p=this;this.throwIfDisposed(),Ze(this.gl,function(){return p.gl.finish()})},f.prototype.getQueryTimerExtension=function(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=et(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 V(this,void 0,void 0,function(){var l=this;return oe(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=De(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(),Gn(this.gl,p,this.framebuffer),this.debug&&fa(this.gl)},f.prototype.unbindTextureToFrameBuffer=function(){this.outputTexture!=null?(Gn(this.gl,this.outputTexture,this.framebuffer),this.debug&&fa(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;Gn(g,p,this.framebuffer),this.debug&&fa(g),this.outputTexture=p,Ze(g,function(){return g.viewport(0,0,l,m)}),Ze(g,function(){return g.scissor(0,0,l,m)})},f.prototype.setOutputMatrixWriteRegionDriver=function(p,l,m,g){var I=this;this.throwIfDisposed(),Ze(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 De(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(Qe,s){var u={logicalShape:Qe.shape,texShape:Qe.isUniform?null:Qe.texData.texShape,isUniform:Qe.isUniform,isPacked:Qe.isUniform?!1:Qe.texData.isPacked,flatOffset:null};return Qe.texData!=null&&Qe.texData.slice!=null&&Qe.texData.slice.flatOffset>0&&(u.flatOffset=Qe.texData.slice.flatOffset),{name:p.variableNames[s],shapeInfo:u}}),R=I.map(function(Qe){return Qe.shapeInfo}),P={logicalShape:m.shape,texShape:m.texData.texShape,isUniform:!1,isPacked:m.texData.isPacked,flatOffset:null},L=Mi(I,P,g,p.packedInputs),G=f.createProgram(L),Q=null,ke=f.getUniformLocation(G,"NAN",!1);i.env().getNumber("WEBGL_VERSION")===1&&(Q=f.getUniformLocation(G,"INFINITY",!1));for(var Ce={},Fe=0;Fe<p.variableNames.length;Fe++){var Ee=p.variableNames[Fe],Ge=!1;Ce[Ee]=f.getUniformLocation(G,Ee,Ge),Ce["offset"+Ee]=f.getUniformLocation(G,"offset"+Ee,Ge)}return{program:p,source:L,webGLProgram:G,uniformLocations:Ce,inShapeInfos:R,outShapeInfo:P,infLoc:Q,nanLoc:ke}}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 P=l.texShape,L=I.isUniform?null:I.texData.texShape;if(!i.util.arraysEqual(P,L))throw Error("Binary was compiled with different texture shapes than the"+(" current args. Shape "+P+" and "+L+" must match"))})}function at(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(P,L){var G=p.program.variableNames[L],Q=p.uniformLocations[G],ke=p.uniformLocations["offset"+G];if(Q==null)return;if(P.isUniform){if(i.util.sizeFromShape(P.shape)<2)f.gl.uniform1f(Q,P.uniformValues[0]);else{var Ce=P.uniformValues;Ce instanceof Float32Array||(Ce=new Float32Array(Ce)),f.gl.uniform1fv(Q,Ce)}return}P.texData.slice!=null&&ke!=null&&f.gl.uniform1i(ke,P.texData.slice.flatOffset),f.setInputMatrixTexture(P.texData.texture,Q,L)}),g!=null&&g(f,p.webGLProgram),f.executeProgram()}function it(f,p,l){var m="";p.concat(l).forEach(function(R){var P=R.texData!=null&&R.texData.slice!=null&&R.texData.slice.flatOffset>0,L=R.isUniform?"uniform":R.texData.texShape;m+=R.shape+"_"+L+"_"+P});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,P=m.strideHeight,L=m.padInfo,G=m.outWidth,Q=m.dilationWidth,ke=m.dilationHeight,Ce=m.dataFormat,Fe=L.left,Ee=L.top,Ge=I*g,Qe=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+")) * "+P+" - "+Ee+`;
d0 = offsetY + `+ke+" * (pos / "+Ge+`);
if(d0 < `+l[u]+` && d0 >= 0) {
offsetX = int(mod(float(blockIndex), `+G+".) * "+R+". - "+Fe+`.);
d1 = offsetX + `+Q+" * (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+`
`+Qe.output+` = result;
}
`}return f}(),rt=function(){function f(p,l,m,g,I){this.variableNames=["x"],this.outputShape=[];var R=l,P=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 <= `+P+`) {
float z = getX(b, r, c, idx);
sum += z * z;
}
}
float val = x * `+L+`;
setOutput(val);
}
`}return f}(),xt=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}(),ht=function(){function f(p,l,m,g,I){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var R=l,P=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(`+P+`));
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,P=I-1-p.padInfo.top,L=R-1-p.padInfo.left,G=I*R-1;this.userCode=`
const ivec2 pads = ivec2(`+P+", "+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,P=p.dilationWidth,L=p.effectiveFilterDepth,G=p.effectiveFilterHeight,Q=p.effectiveFilterWidth,ke=L-1-p.padInfo.front,Ce=G-1-p.padInfo.top,Fe=Q-1-p.padInfo.left,Ee=L*G*Q-1;this.userCode=`
const ivec3 pads = ivec3(`+ke+", "+Ce+", "+Fe+`);
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 < `+Q+`;
wC += `+P+`) {
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 = `+Ee+` -
int(getMaxPos(batch, idyD, idyR, idyC, ch));
// Get the current value, check it against the value from the
// position matrix.
int curPosValue =
wD * `+G+" * "+Q+` +
wR * `+Q+` + wC;
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
dotProd += dyValue * mask;
}
}
}
setOutput(dotProd);
}
`}return f}(),zt=function(){function f(p,l,m,g,I,R,P,L){g===void 0&&(g=!1),I===void 0&&(I=!1),R===void 0&&(R=!1),P===void 0&&(P=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],Q=Math.ceil(G/2),ke=g?"i * 2, rc.y":"rc.y, i * 2",Ce=I?"rc.z, i * 2":"i * 2, rc.z",Fe=g?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],Ee=I?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],Ge="",Qe="";P&&(L?Ge=`vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
`+P+`
}`:Ge=`vec4 activation(vec4 x) {
`+P+`
}`,Qe="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 = `+Q+`.0;
vec4 dot2x2ARowBCol(ivec3 rc) {
vec4 result = vec4(0);
for (int i = 0; i < `+Q+`; i++) {
int batchA = `+u+`;
int batchB = `+r+`;
vec4 a = getMatrixA(batchA, `+ke+`);
vec4 b = getMatrixB(batchB, `+Ce+`);
// These swizzled products need to be separately added.
// See: https://github.com/tensorflow/tfjs/issues/1735
result += (`+Fe[0]+" * "+Ee[0]+`);
result += (`+Fe[1]+" * "+Ee[1]+`);
}
return result;
}
void main() {
ivec3 rc = getOutputCoords();
vec4 result = dot2x2ARowBCol(rc);
`+s+`
`+Qe+`
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}(),Tt=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),P=Rt(p,m);this.userCode=`
void main() {
`+g+` rc = getOutputCoords();
if(`+I+`) {
setOutput(vec4(0));
} else {
`+R+`
setOutput(vec4(`+P+`));
}
}
`}}return f}();function Xt(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=Xt(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,Q){return G[0]+p[Q]+G[1]});var g=p.length,I=nn(g),R=l.map(function(G){return G[0]}).join(","),P=l.map(function(G,Q){return G[0]+p[Q]}).join(","),L=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,g);if(g===1){this.userCode=`
int start = `+R+`;
int end = `+P+`;
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+"("+P+`);
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(","),P=l.map(function(s,u){return s[0]+p[u]}).join(","),L=Vr("rc",g),G=Vr("source",g),Q=L[g-1]+" < "+this.outputShape[g-1],ke=g===1?"source":"vec2("+G.slice(-2).join()+")",Ce=[I+" rc = outputLoc;",L[g-1]+` += 1;
if(`+Q+`) {
`,g===1?"":`}
rc = outputLoc;
`+L[g-2]+` += 1;
if(`+L[g-2]+" < "+this.outputShape[g-2]+") {",g===1?"":" "+L[g-1]+` += 1;
if(`+Q+") {"],Fe=g===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",Ee="",Ge=0,Qe=g===1?2:4;Ge<Qe;Ge++)Ee+=`
`+Ce[Ge]+`
if (`+Fe+`) {
result[`+Ge+"] = float("+m+`);
} else {
`+I+` source = rc - start;
result[`+Ge+"] = getChannel(getX("+G.join()+"), "+ke+`);
}
`;Ee+=g===1?"} ":"}}",this.userCode=`
const `+I+" start = "+I+"("+R+`);
const `+I+" end = "+I+"("+P+`);
void main() {
`+I+` outputLoc = getOutputCoords();
vec4 result = vec4(0.);
`+Ee+`
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,P=p.strideHeight,L=p.strideWidth,G=p.dilationHeight,Q=p.dilationWidth,ke=p.effectiveFilterHeight,Ce=p.effectiveFilterWidth,Fe=p.padInfo.top,Ee=p.padInfo.left;this.outputShape=p.outShape;var Ge=l==="avg",Qe="((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(`+P+", "+L+`);
const ivec2 pads = ivec2(`+Fe+", "+Ee+`);
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 < `+ke+`;
wR += `+G+`) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+Ce+`;
wC += `+Q+`) {
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?Qe: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,O=`
if (`+Ge+`) {
avgValue += dot(values, ones);
} else {
minMaxValue = `+o+`(values, minMaxValue);
}
`;this.userCode=`
const ivec2 strides = ivec2(`+P+", "+L+`);
const ivec2 pads = ivec2(`+Fe+", "+Ee+`);
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 < `+ke+`;
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 * `+Q+`;
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + `+Q+`, d),
getValue(batch, xR, xC + 2 * `+Q+`, d),
getValue(batch, xR, xC + 3 * `+Q+`, d)
);
`+O+`
}
int xC = xCCorner + `+b+`;
if (`+(T===1)+`) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
initializationValue,
initializationValue,
initializationValue
);
`+O+`
} else if (`+(T===2)+`) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + `+Q+`, d),
initializationValue,
initializationValue
);
`+O+`
} else if (`+(T===3)+`) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + `+Q+`, d),
getValue(batch, xR, xC + 2 * `+Q+`, d),
initializationValue
);
`+O+`
}
}
setOutput(`+h+`);
}
`}return f}(),qt=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,P=p.strideDepth,L=p.strideHeight,G=p.strideWidth,Q=p.dilationDepth,ke=p.dilationHeight,Ce=p.dilationWidth,Fe=p.effectiveFilterDepth,Ee=p.effectiveFilterHeight,Ge=p.effectiveFilterWidth,Qe=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(`+P+", "+L+", "+G+`);
const ivec3 pads = ivec3(`+Qe+", "+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 < `+Fe+`;
wD += `+Q+`) {
int xD = xDCorner + wD;
if (xD < 0 || xD >= `+p.inDepth+`) {
continue;
}
for (int wR = 0; wR < `+Ee+`;
wR += `+ke+`) {
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 * "+Ee+" * "+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 O=Math.floor(R/4)*4,q=R%4,Z=`
if (`+r+`) {
avgValue += dot(values, ones);
} else {
minMaxValue = `+b+`(values, minMaxValue);
}
`;this.userCode=`
const ivec3 strides =
ivec3(`+P+", "+L+", "+G+`);
const ivec3 pads = ivec3(`+Qe+", "+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 < `+Fe+`;
wD += `+Q+`) {
int xD = xDCorner + wD;
if (xD < 0 || xD >= `+p.inDepth+`) {
continue;
}
for (int wR = 0; wR < `+Ee+`;
wR += `+ke+`) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= `+p.inHeight+`) {
continue;
}
for (int wC = 0; wC < `+O+`; 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)
);
`+Z+`
}
int xC = xCCorner + `+O+`;
if (`+(q===1)+`) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
initializationValue,
initializationValue,
initializationValue
);
`+Z+`
} else if (`+(q===2)+`) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + `+Ce+`, ch),
initializationValue,
initializationValue
);
`+Z+`
} 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
);
`+Z+`
}
}
setOutput(`+T+`);
}
}
`}return f}(),lr=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 P="0.0",L="";l==="prod"?P="1.0":l==="min"?(P="1.0 / 1e-20",L="min"):l==="max"&&(P="-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 Q=Math.floor(m/4)*4,ke=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);
}
`,Fe="vec4";l==="all"?(P="1.0",Ce=`
bool reducedAllValue = all(values);
float floatedReducedAllValue = float(reducedAllValue);
allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
`,Fe="bvec4"):l==="any"&&(P="0.0",Ce=`
bool reducedAnyValue = any(values);
float floatedReducedAnyValue = float(reducedAnyValue);
anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
`,Fe="bvec4");var Ee="";I%m>0&&(Ee=`
if (inIdx < 0 || inIdx >= `+I+`) {
return initializationValue;
}
`),this.userCode=`
const float initializationValue = `+P+`;
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float getValue(int batch, int inIdx) {
`+Ee+`
return getX(batch, inIdx);
}
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * `+m+`;
vec4 minMaxValue = vec4(`+P+`);
float prodValue = 1.0;
float sumValue = 0.0;
float allValue = 1.0;
float anyValue = 0.0;
for (int i = 0; i < `+Q+`; i += 4) {
int inIdx = inOffset + i;
`+Fe+" values = "+Fe+`(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
`+Ce+`
}
int inIdx = inOffset + `+Q+`;
if (`+(ke===1)+`) {
`+Fe+" values = "+Fe+`(
getValue(batch, inIdx),
initializationValue,
initializationValue,
initializationValue
);
`+Ce+`
} else if (`+(ke===2)+`) {
`+Fe+" values = "+Fe+`(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
initializationValue,
initializationValue
);
`+Ce+`
} else if (`+(ke===3)+`) {
`+Fe+" values = "+Fe+`(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
initializationValue
);
`+Ce+`
}
setOutput(`+G+`);
}
`}return f}(),ir=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)+`
`+qn(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=En(["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],P=p.shape,L=P[1],G=P[2],Q=[m&&L>1?I-1:I,m&&G>1?R-1:R],ke=[m&&L>1?L-1:L,m&&G>1?G-1:G],Ce=Q[0]/ke[0],Fe=Q[1]/ke[1],Ee=1/Ce,Ge=1/Fe,Qe=Math.ceil(Ee)*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(`+Fe+`);
const float invHeightScale = float(`+Ee+`);
const float invWidthScale = float(`+Ge+`);
const int winHeight = int(`+Qe+`);
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],P=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?P-1:P],Q=[g&&l>1?l-1:l,g&&m>1?m-1:m];this.userCode=`
const vec2 effectiveInputOverOutputRatioRC = vec2(
`+G[0]/Q[0]+`,
`+G[1]/Q[1]+`);
const vec2 inputShapeRC = vec2(`+R+".0, "+P+`.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],P=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?P-1:P],Q=[g&&l>1?l-1:l,g&&m>1?m-1:m];this.userCode=`
const vec3 effectiveInputOverOutputRatioRC = vec3(
`+G[0]/Q[0]+`,
`+G[1]/Q[1]+`,
`+G[1]/Q[1]+`);
const vec3 inputShapeRC = vec3(`+R+".0, "+P+`.0,
`+P+`.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}(),pr=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],P=p.shape,L=P[1],G=P[2],Q=[m&&L>1?I-1:I,m&&G>1?R-1:R],ke=[m&&L>1?L-1:L,m&&G>1?G-1:G],Ce=Q[0]/ke[0],Fe=Q[1]/ke[1],Ee=1/Ce,Ge=1/Fe,Qe=Math.ceil(Ee)*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(`+Fe+`);
const float invHeightScale = float(`+Ee+`);
const float invWidthScale = float(`+Ge+`);
const int winHeight = int(`+Qe+`);
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(`+Q[0]+`) *
(float(dyR) / float(`+ke[0]+`));
float sourceFracCol =
float(`+Q[1]+`) *
(float(dyC) / float(`+ke[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}(),Fr=function(){function f(p,l,m,g){this.variableNames=["A"],this.outputShape=[];var I=p[0],R=p[1],P=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?P-1:P],Q=[g&&l>1?l-1:l,g&&m>1?m-1:m],ke=g?"0.5":"0.0";this.userCode=`
const vec2 effectiveInputOverOutputRatioRC = vec2(
`+G[0]/Q[0]+`,
`+G[1]/Q[1]+`);
const vec2 inputShapeRC = vec2(`+R+".0, "+P+`.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 + `+ke+`)));
float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);
setOutput(newValue);
}
`}return f}(),mr=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(P){return l.indexOf(P)!==-1&&p[P]!==1?p[P]+" - coords["+P+"] - 1":"coords["+P+"]"},I=p.map(function(P,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],P=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() {
`+P+` rc = getOutputCoords();
vec4 result = vec4(0.);
result.r = `+L(g.slice())+`;
if(`+I+`){
result.g = `+G(g.slice())+`;
}
if(`+R+`) {
result.b = `+Q(g.slice())+`;
if(`+I+`) {
result.a = `+ke(g.slice())+`;
}
}
setOutput(result);
}
`;function L(Ee){return Ce(Ee)}function G(Ee){return Ee[m-1]="("+Ee[m-1]+" + 1)",Ce(Ee)}function Q(Ee){return Ee[m-2]="("+Ee[m-2]+" + 1)",Ce(Ee)}function ke(Ee){return Ee[m-1]="("+Ee[m-1]+" + 1)",Ee[m-2]="("+Ee[m-2]+" + 1)",Ce(Ee)}function Ce(Ee){var Ge=p.map(function(u,r){return Fe(r,Ee)}),Qe=Ge.join(","),s=Ge.slice(-2).join(",");return"getChannel(getX("+Qe+"), vec2("+s+"))"}function Fe(Ee,Ge){return l.indexOf(Ee)!==-1&&p[Ee]!==1?p[Ee]+" - "+Ge[Ee]+" - 1":""+Ge[Ee]}}return f}(),an=function(){function f(p,l,m,g,I,R,P){this.variableNames=["updates","indices","defaultValue"],this.outputShape=R;var L=nn(I.length),G=nn(R.length),Q="";m===1?Q="i":m===2&&(Q="i, j");var ke="getIndices("+Q+")",Ce="";g===1?Ce="i":g===2&&(Ce="i, coords[1]");var Fe="getUpdates("+Ce+")",Ee=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(`+ke+`);
flattenedIndex += index * `+Ee+`;
}
if (flattenedIndex == coords[0]) {
sum += `+Fe+`;
found = true;
}
}
setOutput(mix(getDefaultValue(), sum, float(found)));
}
`}return f}(),_n=function(){function f(p,l){this.variableNames=["x","segmentIds"];var m=p.windowSize,g=p.batchSize,I=p.inSize,R=p.numSegments,P=R*Math.ceil(I/m);this.outputShape=[g,P];var L="0.0",G="sumValue",Q=Math.floor(m/4)*4,ke=m%4,Ce=`
sumValue += dot(values, segFilter);
`,Fe="";I%m>0&&(Fe=`
if (inIdx < 0 || inIdx >= `+I+`) {
return initializationValue;
}
`);var Ee="";I%m>0&&(Ee=`
if (inIdx < 0 || inIdx >= `+I+`) {
return -1.0;
}
`),this.userCode=`
const float initializationValue = `+L+`;
float getValue(int batch, int inIdx) {
`+Fe+`
return getX(batch, inIdx);
}
float getSegmentIdAtIndex(int inIdx) {
`+Ee+`
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 < `+Q+`; 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 + `+Q+`;
if (`+(ke===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 (`+(ke===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 (`+(ke===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"],P=[],L=[],G=0;G<l.length;G++)L.push(""+R[G]),G<p&&P.push(""+R[G]);g=P.join(),I=L.join()}var Q=nn(m);this.userCode=`
void main() {
`+Q+` resRC = getOutputCoords();
float cVal = getC(`+g+`);
if (cVal >= 1.0) {
setOutput(getA(`+I+`));
} else {
setOutput(getB(`+I+`));
}
}
`}return f}(),In=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=Re(this.rank),I,R=p.map(function(P,L){return"sourceLoc."+wn[L]+" = start["+L+"] + coords."+wn[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}(),wn=["x","y","z","w","u","v"];function Re(f){if(f===1)return"sourceLoc";if(f<=6)return wn.slice(0,f).map(function(p){return"sourceLoc."+p}).join(",");throw Error("Slicing for rank "+f+" is not yet supported")}var Un=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+")",P=`
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(Q,ke){return"start["+ke+"]"}).join()+");":p.map(function(Q,ke){return g[ke]+" = "+m[ke]+" + start["+ke+"];"}).join(`
`);this.userCode=`
uniform int start[`+this.rank+`];
void main() {
`+l+` coords = getOutputCoords();
`+l+` sourceLoc;
`+G+`
vec4 result = vec4(0.);
`+P+`
`+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}(),Ln=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=m;var g=m.length,I=nn(m.length),R=nn(m.length),P="";if(g===1)P="coords * strides + begin";else{var L=0;P=m.map(function(G,Q){return L++,m.length===1?"coords * strides["+Q+"] + begin["+Q+"]":"coords["+(L-1)+"] * strides["+Q+"] + begin["+Q+"]"}).join(",")}this.userCode=`
`+I+" begin = "+I+"("+p+`);
`+I+" strides = "+I+"("+l+`);
void main() {
`+R+` coords = getOutputCoords();
setOutput(getX(`+P+`));
}
`}return f}(),Oa=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=xa(l,m),I=_a(p,g,m);I in this.freeTextures||(this.freeTextures[I]=[]),I in this.usedTextures||(this.usedTextures[I]=[]);var R=Ja(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 P=this.freeTextures[I].shift();return this.usedTextures[I].push(P),P}var L;return g===xe.PACKED_2X2_FLOAT32?L=this.gpgpu.createPackedMatrixTexture(p[0],p[1]):g===xe.PACKED_2X2_FLOAT16?L=this.gpgpu.createFloat16PackedMatrixTexture(p[0],p[1]):g===xe.UNPACKED_FLOAT32?L=this.gpgpu.createFloat32MatrixTexture(p[0],p[1]):g===xe.UNPACKED_FLOAT16?L=this.gpgpu.createFloat16MatrixTexture(p[0],p[1]):g===xe.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=xa(m,g),R=_a(l,I,g);R in this.freeTextures||(this.freeTextures[R]=[]);var P=Ja(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-=P):(this.freeTextures[R].push(p),this.numFreeTextures++,this._numBytesFree+=P),this.numUsedTextures--;var G=this.usedTextures[R],Q=G.indexOf(p);if(Q<0)throw new Error("Cannot release a texture that was never provided by this texture manager");G.splice(Q,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 An(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 Ja(f,p,l,m,g){var I=Wa(p,m),R;if(g){var P=ut(f[0],f[1]),L=P[0],G=P[1];R=L*G}else{var Q=We(f[0],f[1]),ke=Q[0],Ce=Q[1];R=ke*Ce}var Fe=An(l,I);return R*Fe}function Wa(f,p){switch(f){case xe.PACKED_2X2_FLOAT32:return ue(p);case xe.PACKED_2X2_FLOAT16:return D(p);case xe.UNPACKED_FLOAT32:return ki(p);case xe.UNPACKED_FLOAT16:return Lo(p);case xe.PACKED_4X1_UNSIGNED_BYTE:return ns(p);default:throw new Error("Unknown physical texture type "+f)}}function $a(f){return i.env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?f?xe.PACKED_2X2_FLOAT32:xe.UNPACKED_FLOAT32:f?xe.PACKED_2X2_FLOAT16:xe.UNPACKED_FLOAT16}function xa(f,p){if(f===w.UPLOAD)return xe.PACKED_2X2_FLOAT32;if(f===w.RENDER||f==null)return $a(p);if(f===w.DOWNLOAD||f===w.PIXELS)return xe.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+f)}function _a(f,p,l){return f[0]+"_"+f[1]+"_"+p+"_"+l}var Zi=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=Bi(p);this.userCode=`
void main() {
`+I+` resRC = getOutputCoords();
setOutput(getA(`+R+`));
}
`}return f}();function Bi(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 Mr=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}(),ei="if (isnan(x)) return x;",as="return x;",Po="return abs(x);",dn=ei+`
return (x < 0.0) ? 0.0 : x;
`,Bo=ei+`
return (x < 0.0) ? 0.0 : min(6.0, x);
`,Fn="return (x >= 0.0) ? x : (exp(x) - 1.0);",ou=`
// 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),ei+(`
return x > 0.0 ? 1.0 : float(`+f+`);
`)}var ui="return -x;",ku="return ceil(x);",Su="return floor(x);",lc=`
if (isnan(x)) { return 0.0; }
return sign(x);
`,_s="return float(isnan(x));",Si="return float(isinf(x));",ws="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;
}
}
`,uo="return exp(x);",Iu="return exp(x) - 1.0;",su=`if (x < 0.0) return NAN;
return log(x);`,bs="return log(1.0 + x);",Nu="return sqrt(x);",uu="return inversesqrt(x);",Cu="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;
`,co=ei+`
if (abs(x) > 1.) {
return NAN;
}
return asin(x);
`,ks=ei+`
if (abs(x) > 1.) {
return NAN;
}
return acos(x);
`,Tu=ei+`
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=ei+"return log(x + sqrt(x * x + 1.0));",Eu=ei+`
if (x < 1.0) return NAN;
return log(x + sqrt(x * x - 1.0));`,mc=ei+`
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));
`,Ii="return 1.0 / x;",is="return float(!(x >= 1.0));",Ss="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;
`,lo=`
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;
`,cu=`
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;
`,os=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),P=l<=1?"rc":"vec2("+R.join(",")+")";this.userCode=`
void main() {
`+g+` rc = getOutputCoords();
vec4 packedInput = getA(`+I+`);
setOutput(getChannel(packedInput, `+P+`));
}
`}return f}(),gl=i.backend_util.segment_util,xl=i.kernel_impls.split,Ru=i.kernel_impls.tile,gc=i.kernel_impls.topkImpl,Ws=i.kernel_impls.whereImpl,xc=1e-7,Qi=1e-4,lu={};function dr(f){return f in lu||(lu[f]={}),lu[f]}function Us(f,p){if(p===void 0&&(p=!1),f==="linear")return p?vc:as;if(f==="relu")return p?lo:dn;if(f==="elu")return p?cu:Fn;if(f==="relu6")return p?Uo:Bo;if(f==="prelu")return p?Da:Ta;throw new Error("Activation "+f+" has not been implemented for the WebGL backend.")}var Ho=128,Au=600;function _c(){return i.env().global.screen==null?1024:i.env().global.screen.height*i.env().global.screen.width*window.devicePixelRatio*Au/1024/1024}var Fu=1e3,Go=function(f){M(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=z(i.env().getNumber("WEBGL_VERSION"));m.binaryCache=dr(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 Oa(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,P=m.slice,L=m.shape,G=m.isPacked;if(P!=null){var Q=void 0;G?Q=new os(L,Ss):Q=new Mr(L,Ss);var ke=this.runWebGLProgram(Q,[{dataId:l,shape:L,dtype:I}],I),Ce=this.readSync(ke.dataId);return this.disposeIntermediateTensorInfo(ke),Ce}if(g!=null)return this.convertAndCacheOnCPU(l);if(I==="string")return g;var Fe=this.activeTimers!=null,Ee;Fe&&(Ee=i.util.now());var Ge;if(I==="complex64"){var Qe=this.readSync(R.real.dataId),s=this.readSync(R.imag.dataId);Ge=i.backend_util.mergeRealAndImagArrays(Qe,s)}else Ge=this.getValuesFromTexture(l);return Fe&&(this.downloadWaitMs+=i.util.now()-Ee),this.convertAndCacheOnCPU(l,Ge)},p.prototype.read=function(l){return V(this,void 0,void 0,function(){var m,g,I,R,P,L,G,Q,ke,Ce,Fe,Ee,Ge,Qe,s,u,r,o,h,b,T,O;return oe(this,function(q){switch(q.label){case 0:if(this.pendingRead.has(l))return m=this.pendingRead.get(l),[2,new Promise(function(Z){return m.push(Z)})];if(g=this.texData.get(l),I=g.values,R=g.shape,P=g.slice,L=g.dtype,G=g.complexTensorInfos,Q=g.isPacked,P!=null)return ke=void 0,Q?ke=new os(R,Ss):ke=new Mr(R,Ss),Ce=this.runWebGLProgram(ke,[{dataId:l,shape:R,dtype:L}],L),Fe=this.read(Ce.dataId),this.disposeIntermediateTensorInfo(Ce),[2,Fe];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 Ee=null,L!=="complex64"&&i.env().get("WEBGL_BUFFER_SUPPORTED")&&(Ge=this.decode(l),Qe=this.texData.get(Ge.dataId),Ee=(O=this.gpgpu).createBufferFromTexture.apply(O,[Qe.texture].concat(st(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:Ee==null?s=this.getValuesFromTexture(l):(h=i.util.sizeFromShape(R),s=this.gpgpu.downloadFloat32MatrixFromBuffer(Ee,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(Z){return Z(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(!ot(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,P=g.isPacked,L=i.util.sizeFromShape(I);if(i.env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var G=this.decode(l),Q=this.texData.get(G.dataId),ke=(m=this.gpgpu).downloadMatrixFromPackedTexture.apply(m,[Q.texture].concat(st(I))).subarray(0,L);return this.disposeIntermediateTensorInfo(G),ke}var Ce=i.env().getBool("WEBGL_PACK")&&P===!0,Fe=Ce?hi(I):I,Ee=Ce?new Ps(Fe):new wo(Fe),Ge=this.runWebGLProgram(Ee,[{shape:Fe,dtype:R,dataId:l}],"float32"),Qe=this.texData.get(Ge.dataId),s=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(Qe.texture,Qe.texShape[0],Qe.texShape[1]).subarray(0,L);return this.disposeIntermediateTensorInfo(Ge),s},p.prototype.time=function(l){return V(this,void 0,void 0,function(){var m,g,I,R,P,L,G;return oe(this,function(Q){switch(Q.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(ke){return ke.query})).filter(function(ke){return ke!=null}),P=i.util.flatten(this.activeTimers.map(function(ke){return ke.name})).filter(function(ke){return ke!=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=Q.sent(),L.kernelMs=i.util.sum(G),L.getExtraProfileInfo=function(){return G.map(function(ke,Ce){return{name:P[Ce],ms:ke}}).map(function(ke){return ke.name+": "+ke.ms}).join(", ")},[3,3];case 2:L.kernelMs={error:"WebGL query timers are not supported in this environment."},Q.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 V(this,void 0,void 0,function(){var m;return oe(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,P=m.usage,L=m.isPacked,G=m.slice,Q=G&&G.origDataId||l,ke=this.dataRefCount.get(Q);ke>1?this.dataRefCount.set(Q,ke-1):(this.dataRefCount.delete(Q),g!=null&&(this.numBytesInGPU-=this.computeBytes(R,I),this.textureManager.releaseTexture(g,R,P,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=va(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,P=i.slice_util.isSliceContinous(l.shape,m,g);if(R||!P){var L=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Un(g):new In(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),P=this.texData.get(R.dataId);Object.assign(P,I),P.shape=g,P.dtype=l.dtype;var L=i.slice_util.computeFlatOffset(m,l.strides);I.slice&&(L+=I.slice.flatOffset),P.slice={flatOffset:L,origDataId:I.slice&&I.slice.origDataId||l.dataId};var G=this.dataRefCount.get(P.slice.origDataId)||1;return this.dataRefCount.set(P.slice.origDataId,G+1),R},p.prototype.stridedSlice=function(l,m,g,I){var R=this,P=this.tryRunOnCpuOrThrow([l],function(){return R.cpuBackend.stridedSlice(l,m,g,I)});if(P)return P;var L=i.slice_util.computeOutShape(m,g,I);if(L.some(function(Q){return Q===0}))return i.tensor([],L);var G=new Ln(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 mr(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,ui,l.dtype);var I=new Mr(l.shape,ui);return this.compileAndRun(I,[l])},p.prototype.batchMatMul=function(l,m,g,I){var R=g?l.shape[2]:l.shape[1],P=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||P===1)&&L>Fu){g&&(l=i.transpose(l,[0,2,1])),I&&(m=i.transpose(m,[0,2,1]));var Q=P===1?l:l.as3D(G,L,1),ke=P===1?2:1,Ce=P===1?m.as3D(G,1,L):m,Fe=i.mul(Q,Ce);return Fe.sum(ke,!0)}var Ee=i.upcastType(l.dtype,m.dtype),Ge=new zt(l.shape,m.shape,[G,R,P],g,I);return this.compileAndRun(Ge,[l,m],Ee)},p.prototype.fusedBatchMatMul=function(l){var m=l.a,g=l.b,I=l.transposeA,R=l.transposeB,P=l.bias,L=l.activation,G=l.preluActivationWeights,Q=I?m.shape[2]:m.shape[1],ke=R?g.shape[1]:g.shape[2],Ce=Math.max(m.shape[0],g.shape[0]),Fe=i.upcastType(m.dtype,g.dtype),Ee=P!=null,Ge=G!=null,Qe=L?Us(L,!0):null,s=new zt(m.shape,g.shape,[Ce,Q,ke],I,R,Ee,Qe,Ge),u=[m,g];return P&&u.push(P),G&&u.push(G),this.compileAndRun(s,u,Fe)},p.prototype.localResponseNormalization4D=function(l,m,g,I,R){var P=i.env().getBool("WEBGL_PACK_NORMALIZATION")?new ht(l.shape,m,g,I,R):new rt(l.shape,m,g,I,R);return this.compileAndRun(P,[l])},p.prototype.LRNGrad=function(l,m,g,I,R,P,L){var G=new xt(m.shape,I,R,P,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 Ru(R,m)}var P=new Zi(l.shape,m);return this.compileAndRun(P,[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 P=new au(l.shape,m.size,g);return this.compileAndRun(P,[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(ke,Ce){return ke*Ce}),R=i.backend_util.getReshaped(l.shape,m,I),P=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),Q=i.backend_util.getSliceSize(L,g,m.length);return i.transpose(l.reshape(R),P).reshape(L).slice(G,Q)},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(Fe,Ee){return Fe*Ee}),R=[[0,0]];R.push.apply(R,g);for(var P=1+m.length;P<l.shape.length;++P)R.push([0,0]);var L=l.pad(R),G=i.backend_util.getReshaped(L.shape,m,I,!1),Q=i.backend_util.getPermuted(G.length,m.length,!1),ke=i.backend_util.getReshapedPermuted(L.shape,m,I,!1),Ce=i.transpose(L.reshape(G),Q);return i.reshape(Ce,ke)},p.prototype.reduce=function(l,m,g){var I=l.shape[0],R=l.shape[1],P=i.backend_util.computeOptimalWindowSize(R),L=Math.ceil(R/P),G={windowSize:P,inSize:R,batchSize:I,outSize:L},Q=new lr(G,m),ke=this.compileAndRun(Q,[l],g);return ke.shape[1]===1?ke:this.reduce(ke,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 P=i.backend_util.computeOptimalWindowSize(R),L={windowSize:P,inSize:R,batchSize:I,outSize:Math.ceil(R/P)},G=new oa(L,m,g==null),Q=[l];g!=null&&Q.push(g);var ke=this.compileAndRun(G,Q,"int32");return ke.shape[1]===1?ke:this.argReduce(l,m,ke)},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],P=i.backend_util.computeOptimalWindowSize(R),L=new Xi(I,P,m,g==null),G=g==null?[l]:[l,g],Q=this.compileAndRun(L,G,"int32");return Q.rank===l.rank?this.argReducePacked(l,m,Q):Q},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],P=i.util.sizeFromShape(R),L=l.as2D(-1,P),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),P=R[0],L=R[1],G=i.util.sizeFromShape(L),Q=l.as2D(-1,G),ke=i.sumOutType(l.dtype);return this.reduce(Q,"prod",ke).reshape(P)},p.prototype.unsortedSegmentSum=function(l,m,g){var I=0,R=i.backend_util.getAxesPermutation([I],l.rank),P=l;R!=null&&(P=i.transpose(l,R),I=i.backend_util.getInnerMostAxes(1,l.rank)[0]);var L=gl.computeOutShape(P.shape,I,g),G=i.util.sizeFromShape([P.shape[I]]),Q=P.as2D(-1,G),ke=i.sumOutType(l.dtype),Ce=this.segOpCompute(Q,"unsortedSegmentSum",m,ke,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 P=l.shape[0],L=l.shape[1],G=gl.segOpComputeOptimalWindowSize(L,R),Q={windowSize:G,inSize:L,batchSize:P,numSegments:R},ke=new _n(Q,m),Ce=this.compileAndRun(ke,[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),P=R[0],L=R[1],G=i.util.sizeFromShape(L),Q=l.as2D(-1,G);return this.argReduce(Q,g).reshape(P)}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],P=l,L=0;L<=Math.ceil(Math.log2(R))-1;L++){var G=new $o(l.shape,!1,I),Q=G.getCustomSetupFunc(L),ke=P;P=this.compileAndRun(G,[P],P.dtype,Q),ke.dispose()}if(g){var G=new $o(l.shape,g,I),ke=P;P=this.compileAndRun(G,[P]),ke.dispose()}return P},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(io,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,Es,"bool");var R=new vn(Yo,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,Rs,"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,As,"bool");var g=new vn(oo,l.shape,m.shape);return this.compileAndRun(g,[l,m],"bool")},p.prototype.logicalNot=function(l){var m=new Mr(l.shape,is);return this.compileAndRun(m,[l])},p.prototype.logicalAnd=function(l,m){if(i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(l,m,Zo,"bool");var g=new vn(ua,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(Br,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 Ws(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],P=i.util.sizeFromShape(R),L=l.as2D(-1,P);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(Qa,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(Jo,l.shape,m.shape):new vn(Zn,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(Qo,l.shape,m.shape):new vn(ca,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],P=i.util.sizeFromShape(R),L=l.as2D(-1,P);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],P=i.util.sizeFromShape(R),L=l.as2D(-1,P);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 os(l.shape,m);return this.compileAndRun(I,[l],g)},p.prototype.packedBinaryOp=function(l,m,g,I,R){R===void 0&&(R=!1);var P=new vi(g,l.shape,m.shape,R);return this.compileAndRun(P,[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(Q){return Q.dtype}).reduce(function(Q,ke){return i.upcastType(Q,ke)}),P=l.map(function(Q){return Q.shape}),L=i.env().getBool("WEBGL_PACK"),G=L?new hn(l[0].shape,P):new rn(l[0].shape,P);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(Za,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=ze(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,ku,l.dtype);var g=new Mr(l.shape,ku);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,Su,l.dtype);var g=new Mr(l.shape,Su);return this.compileAndRun(g,[l])},p.prototype.sign=function(l){var m=new Mr(l.shape,lc);return this.compileAndRun(m,[l])},p.prototype.isNaN=function(l){var m=new Mr(l.shape,_s);return this.compileAndRun(m,[l],"bool")},p.prototype.isInf=function(l){var m=new Mr(l.shape,Si);return this.compileAndRun(m,[l],"bool")},p.prototype.isFinite=function(l){var m=new Mr(l.shape,ws);return this.compileAndRun(m,[l],"bool")},p.prototype.round=function(l){var m=new Mr(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,uo,l.dtype);var g=new Mr(l.shape,uo);return this.compileAndRun(g,[l])},p.prototype.expm1=function(l){if(this.shouldExecuteOnCPU([l])){var m=Dt(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 Mr(l.shape,Iu);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),P=i.sub(l,I.reshape(R)),L=this.exp(P),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 Mr(l.shape,su);return this.compileAndRun(g,[l])},p.prototype.log1p=function(l){var m=new Mr(l.shape,bs);return this.compileAndRun(m,[l])},p.prototype.sqrt=function(l){var m=new Mr(l.shape,Nu);return this.compileAndRun(m,[l])},p.prototype.rsqrt=function(l){if(this.shouldExecuteOnCPU([l])){var m=aa(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}var g=new Mr(l.shape,uu);return this.compileAndRun(g,[l])},p.prototype.reciprocal=function(l){var m=new Mr(l.shape,Ii);return this.compileAndRun(m,[l])},p.prototype.relu=function(l){var m;return i.env().getBool("WEBGL_PACK")?m=new os(l.shape,lo):m=new Mr(l.shape,dn),this.compileAndRun(m,[l])},p.prototype.relu6=function(l){var m;return i.env().getBool("WEBGL_PACK")?m=new os(l.shape,Uo):m=new Mr(l.shape,Bo),this.compileAndRun(m,[l])},p.prototype.prelu=function(l,m){var g=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vi(Da,l.shape,m.shape):new vn(Ta,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,cu,l.dtype);var m=new Mr(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(so,l.shape,m.shape);return this.compileAndRun(g,[l,m])},p.prototype.selu=function(l){var m=new Mr(l.shape,ou);return this.compileAndRun(m,[l])},p.prototype.clip=function(l,m,g){var I;i.env().getBool("WEBGL_PACK_CLIP")?I=new eu(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 Mr(l.shape,Po);return this.compileAndRun(g,[l])},p.prototype.complexAbs=function(l){var m=this.texData.get(l.dataId),g=new ds(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 Mr(l.shape,Cu);return this.compileAndRun(m,[l])},p.prototype.softplus=function(l){var m=new Mr(l.shape,hc);return this.compileAndRun(m,[l])},p.prototype.asin=function(l){var m=new Mr(l.shape,co);return this.compileAndRun(m,[l])},p.prototype.acos=function(l){var m=new Mr(l.shape,ks);return this.compileAndRun(m,[l])},p.prototype.atan=function(l){var m=new Mr(l.shape,Tu);return this.compileAndRun(m,[l])},p.prototype.sinh=function(l){var m=new Mr(l.shape,pc);return this.compileAndRun(m,[l])},p.prototype.cosh=function(l){var m=new Mr(l.shape,dc);return this.compileAndRun(m,[l])},p.prototype.tanh=function(l){var m=new Mr(l.shape,fc);return this.compileAndRun(m,[l])},p.prototype.asinh=function(l){var m=new Mr(l.shape,vl);return this.compileAndRun(m,[l])},p.prototype.acosh=function(l){var m=new Mr(l.shape,Eu);return this.compileAndRun(m,[l])},p.prototype.atanh=function(l){var m=new Mr(l.shape,mc);return this.compileAndRun(m,[l])},p.prototype.erf=function(l){var m=new Mr(l.shape,yc);return this.compileAndRun(m,[l])},p.prototype.step=function(l,m){var g=new Mr(l.shape,cc(m));return this.compileAndRun(g,[l])},p.prototype.conv2dByMatMul=function(l,m,g,I,R,P){var L=l.shape,G=this.texData.get(l.dataId),Q=g.inChannels,ke=L[0]*L[1]*L[2],Ce=g.outChannels,Fe=g.dataFormat==="channelsLast",Ee=!1,Ge=!1,Qe=(ke===1||Ce===1)&&Q>Fu,s=L[2]%2!==0&&!!G.isPacked;if(Qe||!i.env().getBool("WEBGL_LAZILY_UNPACK")||!i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!s){var u=Fe?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:Ee,transposeB:Ge,bias:I,activation:R,preluActivationWeights:P});return i.reshape(h,g.outShape)}var b=Fe?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},O=G.shape;G.shape=G.shape.slice(),G.shape[G.shape.length-2]++,i.util.assert(xn(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]),Z=this.fusedBatchMatMul({a:T,b:q,transposeA:Ee,transposeB:Ge,bias:I,activation:R,preluActivationWeights:P}),le=this.texData.get(Z.dataId);return i.util.assert(le.isPacked,function(){return"batchMatMul result is expected to be packed"}),G.shape=O,le.shape=g.outShape,i.engine().makeTensorFromDataId(Z.dataId,g.outShape,Z.dtype)},p.prototype.conv2dWithIm2Row=function(l,m,g,I,R,P){var L=g.filterWidth,G=g.filterHeight,Q=g.inChannels,ke=g.outWidth,Ce=g.outHeight,Fe=g.dataFormat,Ee=Fe==="channelsLast",Ge=L*G*Q,Qe=Ce*ke,s=[Ge,Qe],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]]),O=I!=null,q=P!=null,Z=R?Us(R,!0):null,le=new zt(T.shape,h.shape,[1,Qe,g.outChannels],u,r,O,Z,q),Ne=[T,h];I&&Ne.push(I),q&&Ne.push(P);var Be=this.compileAndRun(le,Ne);return Ee?Be.reshape([1,Ce,ke,g.outChannels]):Be.reshape([1,g.outChannels,Ce,ke])},p.prototype.fusedConv2d=function(l){var m=l.input,g=l.filter,I=l.convInfo,R=l.bias,P=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,P,L);if(i.env().getBool("WEBGL_CONV_IM2COL")&&m.shape[0]===1)return this.conv2dWithIm2Row(m,g,I,R,P,L);var G=R!=null,Q=L!=null,ke=P?Us(P,!1):null,Ce=new ms(I,G,ke,Q),Fe=[m,g];return R&&Fe.push(R),L&&Fe.push(L),this.compileAndRun(Ce,Fe)},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 ms(g);return this.compileAndRun(I,[l,m])},p.prototype.conv2dDerInput=function(l,m,g){var I=new Ds(g);return this.compileAndRun(I,[l,m])},p.prototype.conv2dDerFilter=function(l,m,g){var I=new tu(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,P=l.activation,L=l.preluActivationWeights,G=i.env().getBool("WEBGL_PACK_DEPTHWISECONV")&&I.strideWidth<=2&&I.outChannels/I.inChannels===1,Q=P?Us(P,G):null,ke=[m,g],Ce=R!=null,Fe=L!=null;Ce&&ke.push(R),Fe&&ke.push(L);var Ee;return G?(Ee=new Fo(I,Ce,Q,Fe),this.compileAndRun(Ee,ke)):(Ee=new ys(I,Ce,Q,Fe),this.compileAndRun(Ee,ke))},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 Fo(g),this.compileAndRun(I,[l,m])):(I=new ys(g),this.compileAndRun(I,[l,m]))},p.prototype.depthwiseConv2DDerInput=function(l,m,g){var I=new ru(g);return this.compileAndRun(I,[l,m])},p.prototype.depthwiseConv2DDerFilter=function(l,m,g){var I=new Ms(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3d=function(l,m,g){var I=new nu(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3dDerInput=function(l,m,g){var I=new Os(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3dDerFilter=function(l,m,g){var I=new fs(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,P=0;P<l.rank;P++)P!==m&&(I[R++]=l.shape[P]);var L=new Array(l.rank).fill(0),G=l.shape.slice();G[m]=1;for(var Q=new Array(g),P=0;P<Q.length;P++)L[m]=P,Q[P]=this.slice(l,L,G).reshape(I);return Q},p.prototype.avgPool3d=function(l,m){var g=new qt(m,"avg",!1);return this.compileAndRun(g,[l],"float32")},p.prototype.avgPool3dBackprop=function(l,m,g){var I=new Li(g);return this.compileAndRun(I,[l],m.dtype)},p.prototype.maxPool3d=function(l,m){var g=new qt(m,"max",!1);return this.compileAndRun(g,[l],"float32")},p.prototype.maxPool3dBackprop=function(l,m,g,I){var R=!0,P=new qt(I,"max",R),L=this.compileAndRun(P,[m]),G=new At(I),Q=this.compileAndRun(G,[l,L],m.dtype);return L.dispose(),Q},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 Fr(l.shape,m,g,I);return this.compileAndRun(R,[l])},p.prototype.resizeNearestNeighborBackprop=function(l,m,g){var I=new pr(l,m,g);return this.compileAndRun(I,[l])},p.prototype.multinomial=function(l,m,g,I){var R=m?l:i.softmax(l),P=R.shape[0],L=R.shape[1],G=new Pt(P,L,g),Q=G.getCustomSetupFunc(I);return this.compileAndRun(G,[R],"int32",Q)},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,P){var L=new zs(l.shape,m.shape,I,R,P);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],P=g==="NHWC"?l.shape[2]:l.shape[3],L=g==="NHWC"?l.shape[3]:l.shape[1],G=R*m,Q=P*m,ke=L/(m*m),Ce=g==="NHWC"?[I,G,Q,ke]:[I,ke,G,Q],Fe=new es(Ce,m,g);return this.compileAndRun(Fe,[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,P=I.numUpdates,L=I.sliceSize,G=I.strides,Q=I.outputSize,ke=[Q/L,L],Ce=l.reshape([P,R]),Fe=m.reshape([P,L]);if(Q===0)return i.backend_util.reshapeTensor(i.tensor([]),g);var Ee=i.scalar(0),Ge=new an(P,R,Ce.rank,Fe.rank,G,ke),Qe=this.compileAndRun(Ge,[Fe,Ce,Ee]);return Qe.reshape(g)},p.prototype.sparseToDense=function(l,m,g,I){var R=i.backend_util.calculateShapes(m,l,g),P=R.sliceRank,L=R.numUpdates,G=R.strides,Q=R.outputSize,ke=!1,Ce=new an(L,P,l.rank,m.rank,G,[Q,1],ke),Fe=this.compileAndRun(Ce,[m,l,I]);return Fe.reshape(g)},p.prototype.gatherND=function(l,m){var g=m.shape,I=g[g.length-1],R=i.backend_util.prepareAndValidate(l,m),P=R[0],L=R[1],G=R[2],Q=R[3],ke=m.reshape([L,I]),Ce=l.reshape([l.size/G,G]),Fe=new iu(I,Q,[L,G]),Ee=this.compileAndRun(Fe,[Ce,ke]);return Ee.reshape(P)},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 ts(l,m),P=R.getCustomSetupFunc(m);return this.compileAndRun(R,[],g,P)}},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 Tt(l.shape),g=!0;return this.runWebGLProgram(m,[l],l.dtype,null,g)},p.prototype.packedReshape=function(l,m){var g=[Ga(l.shape)].concat(Sa(l.shape)),I={dtype:l.dtype,shape:g,dataId:l.dataId},R=[Ga(m)].concat(Sa(m)),P=new ir(R,g),L=!0,G=this.runWebGLProgram(P,[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,P=hi(I),L;g?L=new Ls(P):L=new Do(P);var G=!0,Q=this.runWebGLProgram(L,[{shape:P,dtype:R,dataId:l}],R,null,G);return{dtype:R,shape:I,dataId:Q.dataId}},p.prototype.runWebGLProgram=function(l,m,g,I,R){var P=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===ee.DENSE){var Q=st(l.outputShape);G.texShape=Q.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 ke=[],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=P.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?P.unpackTensor(r):P.packTensor(r),ke.push(r),o=P.texData.get(r.dataId);else if(o.isPacked&&!xn(o.shape,r.shape)){var h=r,b=r.shape;r.shape=o.shape,r=P.packedReshape(r,b),ke.push(r),o=P.texData.get(r.dataId),h.shape=b}return P.uploadToGPU(r.dataId),{shape:r.shape,texData:o,isUniform:!1}});this.uploadToGPU(L.dataId);var Fe={shape:L.shape,texData:G,isUniform:!1},Ee=it(l,Ce,Fe),Ge=this.getAndSaveBinary(Ee,function(){return Ve(P.gpgpu,l,Ce,Fe)}),Qe=this.activeTimers!=null,s;if(Qe&&(s=this.startTimer()),at(this.gpgpu,Ge,Ce,Fe,I),ke.forEach(function(r){return P.disposeIntermediateTensorInfo(r)}),Qe&&(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 P=this.runWebGLProgram(l,m,g,I,R);return i.engine().makeTensorFromDataId(P.dataId,P.shape,P.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,P=g.values,L=g.texture,G=g.usage,Q=g.isPacked;if(L!=null)return;var ke=this.activeTimers!=null,Ce;ke&&(Ce=i.util.now());var Fe=g.texShape;if(Fe==null&&(Fe=La(I,Q),g.texShape=Fe),P!=null){var Ee=hi(I),Ge=void 0,Qe=Fe[1],s=Fe[0],u=P instanceof Uint8Array;Q?(m=ut(Fe[0],Fe[1]),Qe=m[0],s=m[1],Ge=new gs(Ee,[s,Qe],u)):Ge=new Bs(Ee,[s,Qe],u);var r=this.makeTensorInfo([s,Qe],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),Qe,s,P);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,ke&&(this.uploadWaitMs+=i.util.now()-Ce)}else{var T=this.acquireTexture(Fe,G,R,Q);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 Du="2.7.0";function Vs(){i.env().set("WEBGL_FORCE_F16_TEXTURES",!0)}i.device_util.isBrowser()&&i.registerBackend("webgl",function(){return new Go},2);var bc={forceHalfFloat:Vs};function ho(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:ho};function po(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),P=ho({inputs:{x:m},backend:l}),L=l.texData.get(P.dataId);L.complexParentRefCount++;var G=ho({inputs:{x:g},backend:l}),Q=l.texData.get(G.dataId);return Q.complexParentRefCount++,R.complexTensorInfos={real:P,imag:G},I}var Sc={kernelName:i.Complex,backendName:"webgl",kernelFunc:po},hu="if (isnan(x)) return x;",Ic=`
if (isnan(a)) return a;
if (isnan(b)) return b;
`,Ou=`
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 Hs(f){return function(p){var l=p.inputs,m=p.backend,g=l.x,I=m,R=new Mr(g.shape,f);return I.runWebGLProgram(R,[g],g.dtype)}}function fo(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,P=f.cpuKernelImpl,L=f.dtype;return function(G){var Q=G.inputs,ke=G.backend,Ce=Q,Fe=Ce.a,Ee=Ce.b,Ge=ke;if(R&&Fe.dtype==="complex64"){var Qe=Ge.texData.get(Fe.dataId),s=Ge.texData.get(Ee.dataId),u=[[Qe.complexTensorInfos.real,s.complexTensorInfos.real],[Qe.complexTensorInfos.imag,s.complexTensorInfos.imag]].map(function(je){var qe=je[0],vt=je[1],pt={dataId:qe.dataId,dtype:qe.dtype,shape:Fe.shape},ct={dataId:vt.dataId,dtype:vt.dtype,shape:Ee.shape},dt=new vn(p,Fe.shape,Ee.shape);return Ge.runWebGLProgram(dt,[pt,ct],i.upcastType(qe.dtype,vt.dtype))}),r=u[0],o=u[1],h=po({inputs:{real:r,imag:o},backend:Ge});return Ge.disposeIntermediateTensorInfo(r),Ge.disposeIntermediateTensorInfo(o),h}var b=L||i.upcastType(Fe.dtype,Ee.dtype);if(Ge.shouldExecuteOnCPU([Fe,Ee])&&P!=null){var Qe=Ge.texData.get(Fe.dataId),s=Ge.texData.get(Ee.dataId),T=P(Fe.shape,Ee.shape,Qe.values,s.values,b),O=T[0],q=T[1],Z=Ge.makeTensorInfo(q,b),le=Ge.texData.get(Z.dataId);return le.values=O,Z}var Ne=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&l!=null,Be;return Ne?Be=new vi(l,Fe.shape,Ee.shape,g):Be=new vn(p,Fe.shape,Ee.shape),Ge.runWebGLProgram(Be,[Fe,Ee],b)}}var Mu="return a + b;",_l=fo({opSnippet:Mu,packedOpSnippet:Mu,supportsComplex:!0,cpuKernelImpl:tt}),zu={kernelName:i.Add,backendName:"webgl",kernelFunc:_l},Lu=Ic+`
return atan(a, b);
`,pu=`
vec4 result = atan(a, b);
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
`+Ou+`
return result;
`,wl=fo({opSnippet:Lu,packedOpSnippet:pu}),du={kernelName:i.Atan2,backendName:"webgl",kernelFunc:wl};function fu(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x;ln(g,"avgPool");var I=m.filterSize,R=m.strides,P=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 Q=i.backend_util.computePool2DInfo(g.shape,I,R,G,P,L);if(Q.filterWidth===1&&Q.filterHeight===1&&i.util.arraysEqual(Q.inShape,Q.outShape))return ho({inputs:{x:g},backend:l});var ke=new Vt(Q,"avg",!1);return l.runWebGLProgram(ke,[g],"float32")}var Nc={kernelName:i.AvgPool,backendName:"webgl",kernelFunc:fu};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 P=m.filterSize,L=m.strides,G=m.pad,Q=i.backend_util.computePool2DInfo(R.shape,P,L,1,G),ke=new si(Q);return l.runWebGLProgram(ke,[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 P="0.0";g!=null&&(i.backend_util.assertAndGetBroadcastShape(p,g),this.variableNames.push("offset"),P="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 = `+P+`;
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 P="vec4(0.0)";g!=null&&(i.backend_util.assertAndGetBroadcastShape(p,g),this.variableNames.push("offset"),P="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 = `+P+`;
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,P=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(P==null||I.shape.length===P.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 Q=[g,I,R],ke=null;P!=null&&(ke=P.shape,Q.push(P));var Ce=null;L!=null&&(Ce=L.shape,Q.push(L));var Fe=i.env().getBool("WEBGL_PACK_NORMALIZATION")?new Ke(g.shape,I.shape,R.shape,ke,Ce,G):new Ec(g.shape,I.shape,R.shape,ke,Ce,G),Ee=l.runWebGLProgram(Fe,Q,Q[0].dtype);return Ee},sn={kernelName:i.FusedBatchNorm,backendName:"webgl",kernelFunc:Rc},Ac="return float(a != b);",Is=fo({opSnippet:Ac,dtype:"bool"}),Fc={kernelName:i.NotEqual,backendName:"webgl",kernelFunc:Is};function $n(f){var p=f.inputs,l=f.backend,m=p.input,g=l.texData.get(m.dataId);return ho({inputs:{x:g.complexTensorInfos.real},backend:l})}var Dc={kernelName:i.Real,backendName:"webgl",kernelFunc:$n},Oc="return float(int(x));";function Mc(f,p){var l=new Mr(f.shape,Oc),m=p.runWebGLProgram(l,[f],"int32");return{dataId:m.dataId,shape:m.shape,dtype:m.dtype}}function Gs(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 ho({inputs:{x:g},backend:l});var R=i.zeros(g.shape),P=Gs({inputs:{x:g},backend:l,attrs:{dtype:"float32"}}),L=po({inputs:{real:P,imag:R},backend:l});return R.dispose(),l.disposeIntermediateTensorInfo(P),L}if(g.dtype==="complex64"){var G=$n({inputs:{input:g},backend:l}),L=Gs({inputs:{x:G},backend:l,attrs:{dtype:I}});return l.disposeIntermediateTensorInfo(G),L}if(!i.util.hasEncodingLoss(g.dtype,I)){var L=ho({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 Q=l.makeTensorInfo([],"bool",i.util.getTypedArrayFromDType("bool",1)),ke={a:g,b:Q},L=Is({inputs:ke,backend:l});return l.disposeIntermediateTensorInfo(Q),L}throw new Error("Error in Cast: failed to cast "+g.dtype+" to "+I)}var ss={kernelName:i.Cast,backendName:"webgl",kernelFunc:Gs},zc=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,P=l[l.length-1];g.push("else setOutput(getT"+R+"(yR, yC-"+P+"));"),this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int yR = coords.x;
int yC = coords.y;
`+g.join(`
`)+`
}
`}return f}(),Lc=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),P=["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 Q=P[l],ke=P.slice(-2),Ce=P.join(),Fe="if ("+Q+" < "+L[0]+`) {
return getChannel(
getT0(`+Ce+"), vec2("+ke.join()+`));
}`,G=1;G<L.length;G++){var Ee=L[G-1];Fe+=`
if (`+Q+" < "+L[G]+" && "+Q+" >= "+L[G-1]+`) {
return getChannel(
getT`+G+"("+mu(P,Q,Ee)+`),
vec2(`+mu(ke,Q,Ee)+`));
}`}var Ge=L.length,Qe=L[L.length-1];Fe+=`
return getChannel(
getT`+Ge+"("+mu(P,Q,Qe)+`),
vec2(`+mu(ke,Q,Qe)+"));",this.userCode=`
float getValue(`+P.map(function(s){return"int "+s})+`) {
`+Fe+`
}
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 mu(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 ho({inputs:{x:g.complexTensorInfos.imag},backend:l})}var Pu={kernelName:i.Imag,backendName:"webgl",kernelFunc:Pc};function bl(f,p,l){var m=[Ga(f.shape)].concat(Sa(f.shape)),g={dtype:f.dtype,shape:m,dataId:f.dataId},I=[Ga(p)].concat(Sa(p)),R=new ir(I,m),P=!0,L=l.runWebGLProgram(R,[g],f.dtype,null,P);return{dataId:L.dataId,shape:p,dtype:L.dtype}}function Ji(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=m.shape,R=l,P=i.util.sizeFromShape(g.shape),L=i.util.inferFromImplicitShape(I,P),G=i.util.sizeFromShape(L);i.util.assert(P===G,function(){return"The new shape ("+L+") has "+G+" elements and the old "+("shape ("+g.shape+") has "+P+" elements. The new shape and old ")+"shape must have the same number of elements."});var Q=R.texData.get(g.dataId);return Q.isPacked&&!xn(g.shape,L)&&!(Q.texture!==null&&xn(Q.shape,L))?bl(g,L,R):(R.incRef(g.dataId),{dataId:g.dataId,shape:L,dtype:g.dtype})}var Bu={kernelName:i.Reshape,backendName:"webgl",kernelFunc:Ji};function us(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=us(g,p,l),P=us(I,p,l),L=po({inputs:{real:R,imag:P},backend:l});return g.forEach(function(r){return l.disposeIntermediateTensorInfo(r)}),I.forEach(function(r){return l.disposeIntermediateTensorInfo(r)}),l.disposeIntermediateTensorInfo(R),l.disposeIntermediateTensorInfo(P),L}if(f.length>i.env().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var G=Math.floor(f.length/2),Q=us(f.slice(0,G),p,l),ke=us(f.slice(G),p,l),Ce=us([Q,ke],p,l);return l.disposeIntermediateTensorInfo(Q),l.disposeIntermediateTensorInfo(ke),Ce}if(i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&f[0].shape.length>1){var Fe=new Lc(f.map(function(r){return r.shape}),p);return l.runWebGLProgram(Fe,f,m)}var Ee=i.backend_util.computeOutShape(f.map(function(r){return r.shape}),p),Ge=f.map(function(r){return Ji({inputs:{x:r},attrs:{shape:[-1,i.util.sizeFromShape(r.shape.slice(p))]},backend:l})}),Qe=new zc(Ge.map(function(r){return r.shape})),s=l.runWebGLProgram(Qe,Ge,m);Ge.forEach(function(r){return l.disposeIntermediateTensorInfo(r)});var u=Ji({inputs:{x:s},attrs:{shape:Ee},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 P=p.filter(function(G){return i.util.sizeFromShape(G.shape)>0});if(P.length===1)return P[0];var L=P.map(function(G){return G.shape});return i.backend_util.assertParamsConsistent(L,I),us(P,I,l)}var Bc={kernelName:i.Concat,backendName:"webgl",kernelFunc:kl},yu=hu+`
return cos(x);
`,Wc=Hs(yu),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=fo({opSnippet:Vc,packedOpSnippet:Hc,checkOutOfBounds:!0}),jc={kernelName:i.Div,backendName:"webgl",kernelFunc:Gc},Wu=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",P;if(p==="real")P="return real * expR - imag * expI;";else if(p==="imag")P="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) {
`+P+`
}
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 Uu(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,P=Ji({inputs:{x:f},backend:l,attrs:{shape:[R,I]}}),L=P.shape,G=new Wu("real",L,p),Q=new Wu("imag",L,p),ke=[{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,ke,"float32"),Fe=l.runWebGLProgram(Q,ke,"float32"),Ee=po({inputs:{real:Ce,imag:Fe},backend:l});l.disposeIntermediateTensorInfo(Ce),l.disposeIntermediateTensorInfo(Fe);var Ge=Ji({inputs:{x:Ee},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 Uu(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}},Vu=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},cs;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,P=typeof HTMLImageElement!="undefined"&&g instanceof HTMLImageElement,L=R?[g.videoWidth,g.videoHeight]:[g.width,g.height],G=L[0],Q=L[1],ke=[Q,G],Ce=[Q,G,I];(P||R)&&(cs==null&&(cs=document.createElement("canvas").getContext("2d")),cs.canvas.width=G,cs.canvas.height=Q,cs.drawImage(g,0,0,G,Q),g=cs.canvas);var Fe=l.makeTensorInfo(ke,"int32");l.texData.get(Fe.dataId).usage=w.PIXELS,l.gpgpu.uploadPixelDataToTexture(l.getTexture(Fe.dataId),g);var Ee=i.env().getBool("WEBGL_PACK")?new Xc(Ce):new Vu(Ce),Ge=l.runWebGLProgram(Ee,[Fe],"int32");return l.disposeData(Fe.dataId),Ge}function Nl(f){var p=f.inputs,l=f.backend,m=p.input;return Uu(m,!0,l)}var Cl={kernelName:i.IFFT,backendName:"webgl",kernelFunc:Nl},Hu=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 P=Math.floor(m/4)*4,L=m%4,G="sumValue += dot(values, ones);";if(l!=null){var Q=1/l;G="sumValue += dot(values * "+(i.util.isInt(Q)?Q.toPrecision(2):Q)+", ones);"}var ke="";I%m>0&&(ke=`
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) {
`+ke+`
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 < `+P+`; 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 + `+P+`;
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 vu(f,p,l,m){for(var g=Tl(f.shape),I=f,R=0;R<g.length;R++){var P=g[R],L=P.inSize,G=P.windowSize,Q=P.outSize,ke=void 0,Ce=void 0;l==="mean"?ke=R===0?new Hu({windowSize:G,inSize:L,batchSize:f.shape[0],outSize:Q},L):new Hu({windowSize:G,inSize:L,batchSize:f.shape[0],outSize:Q}):ke=new lr({windowSize:G,inSize:L,batchSize:f.shape[0],outSize:Q},l),Ce=I,I=m.runWebGLProgram(ke,[I],p),Ce.dataId!==f.dataId&&m.disposeIntermediateTensorInfo(Ce)}return I}function Gu(f,p,l,m){var g=i.util.sizeFromShape(p),I=i.util.sizeFromShape(f.shape),R=I/g,P=Ji({inputs:{x:f},attrs:{shape:[R,g]},backend:m}),L=vu(P,f.dtype,"max",m),G=Ji({inputs:{x:L},attrs:{shape:l},backend:m});return m.disposeIntermediateTensorInfo(P),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),P=new Array(this.rank),g=0;g<l.length;g++)P[l[g]]=R[g];var L="vec2("+P.slice(-2).join()+")",G="++"+R[this.rank-1]+" < "+m[this.rank-1],Q="getChannel(getA("+P.join()+"), "+L+")";this.userCode=`
void main() {
`+I+` rc = getOutputCoords();
vec4 result = vec4(0.);
result[0] = `+Q+`;
if(`+G+`) {
result[1] = `+Q+`;
}
--`+R[this.rank-1]+`;
if(++`+R[this.rank-2]+" < "+m[this.rank-2]+`) {
result[2] = `+Q+`;
if(`+G+`) {
result[3] = `+Q+`;
}
}
setOutput(result);
}
`}return f}();function js(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 ju={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,P=I.keepDims,L=m,G=g.shape.length,Q=i.util.parseAxisParam(R,g.shape),ke=Q,Ce=i.backend_util.getAxesPermutation(ke,G),Fe=Ce!=null,Ee=L.shouldExecuteOnCPU([g]),Ge=g;if(Fe){if(Ee){for(var Qe=L.texData.get(Ge.dataId),s=Qe.values,u=new Array(G),r=0;r<u.length;r++)u[r]=g.shape[Ce[r]];var o=qa(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=js(g,Ce,L);ke=i.backend_util.getInnerMostAxes(ke.length,G)}i.backend_util.assertAxesAreInnerMostDims("max",ke,G);var b=i.backend_util.computeOutAndReduceShapes(Ge.shape,ke),T=b[0],O=b[1],q=T;P&&(q=i.backend_util.expandShapeToKeepDim(T,Q));var Z;if(Ee){var Qe=L.texData.get(Ge.dataId),s=Qe.values,le=fr(s,i.util.sizeFromShape(O),q,g.dtype);Z=L.makeTensorInfo(q,g.dtype);var Ne=L.texData.get(Z.dataId);Ne.values=le}else Z=Gu(Ge,O,q,L);return Fe&&L.disposeIntermediateTensorInfo(Ge),Z}};function Fl(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x;ln(g,"maxPool");var I=m.filterSize,R=m.strides,P=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 Q=i.backend_util.computePool2DInfo(g.shape,I,R,G,P,L);if(Q.filterWidth===1&&Q.filterHeight===1&&i.util.arraysEqual(Q.inShape,Q.outShape))return ho({inputs:{x:g},backend:l});var ke=new Vt(Q,"max",!1);return l.runWebGLProgram(ke,[g],g.dtype)}var Dl={kernelName:i.MaxPool,backendName:"webgl",kernelFunc:Fl};function qu(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.dy,I=p.input,R=p.output,P=I;ln([I,R],"maxPoolBackprop");var L=m.filterSize,G=m.strides,Q=m.pad,ke=m.dimRoundingMode,Ce=i.backend_util.computePool2DInfo(P.shape,L,G,1,Q,ke),Fe=!0,Ee=new Vt(Ce,"max",Fe),Ge=l.runWebGLProgram(Ee,[P],P.dtype),Qe=new _t(Ce),s=l.runWebGLProgram(Qe,[g,Ge],P.dtype);return l.disposeIntermediateTensorInfo(Ge),s}var Ol={kernelName:i.MaxPoolBackprop,backendName:"webgl",kernelFunc:qu};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 Ku={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,P=I.strides,L=I.pad,G=I.includeBatchInIndex,Q=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 ke=[1,1];i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(P,ke),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+P+" and dilations '"+ke+"'")});var Ce=i.backend_util.computePool2DInfo(g.shape,R,P,ke,L),Fe=Ml(g,G,Ce,Q),Ee=Fe[0],Ge=Fe[1];return[Ee,Ge]}};function Ea(f,p,l,m){var g=i.util.sizeFromShape(p),I=i.util.sizeFromShape(f.shape),R=I/g,P=Ji({inputs:{x:f},attrs:{shape:[R,g]},backend:m}),L=vu(P,"float32","mean",m),G=Ji({inputs:{x:L},attrs:{shape:l},backend:m});return m.disposeIntermediateTensorInfo(P),m.disposeIntermediateTensorInfo(L),G}var zl={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,P=I.axis,L=m,G=g.shape.length,Q=i.util.parseAxisParam(P,g.shape),ke=Q,Ce=i.backend_util.getAxesPermutation(ke,G),Fe=Ce!=null,Ee=L.shouldExecuteOnCPU([g]),Ge=[],Qe=g;if(Fe){if(Ee){for(var s=L.texData.get(Qe.dataId),u=s.values,r=new Array(G),o=0;o<r.length;o++)r[o]=g.shape[Ce[o]];var h=qa(u,g.shape,g.dtype,Ce,r);Qe=L.makeTensorInfo(r,g.dtype);var b=L.texData.get(Qe.dataId);b.values=h}else Qe=js(g,Ce,L);Ge.push(Qe),ke=i.backend_util.getInnerMostAxes(ke.length,G)}i.backend_util.assertAxesAreInnerMostDims("sum",ke,G);var T=i.backend_util.computeOutAndReduceShapes(Qe.shape,ke),O=T[0],q=T[1],Z=O;R&&(Z=i.backend_util.expandShapeToKeepDim(O,Q));for(var le=Ea(Qe,q,Z,L),Ne=0,Be=Ge;Ne<Be.length;Ne++){var o=Be[Ne];L.disposeIntermediateTensorInfo(o)}return le}},Ll=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=l.map(function(Q,ke){return Q[0]+p[ke]+Q[1]});var g=p.length,I=nn(g),R=l.map(function(Q){return Q[0]}).join(","),P=l.map(function(Q,ke){return Q[0]+p[ke]}).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 = `+P+`;
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+"("+P+`);
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,Qe){return Ge[0]+p[Qe]+Ge[1]});var g=p.length,I=nn(g),R=l.map(function(Ge){return Ge[0]}).join(","),P=l.map(function(Ge,Qe){return Ge[0]+p[Qe]}).join(","),L=Vr("rc",g),G=Vr("source",g),Q=L[g-1]+" < "+this.outputShape[g-1],ke=g===1?"source":"vec2("+G.slice(-2).join()+")",Ce=m==="reflect"?0:1,Fe="";if(g===1){var Ee=`
`+I+` source = rc;
if (source < start) {
source = start * 2 - source - `+Ce+`;
} else if (source >= end) {
source = (end - 1) * 2 - source + `+Ce+`;
}
source -= start;
`;Fe=`
`+I+` rc = outputLoc;
`+Ee+`
result[0] = getChannel(getX(`+G.join()+"), "+ke+`);
`+L[g-1]+` += 1;
if(`+Q+`) {
`+Ee+`
result[1] = getChannel(getX(`+G.join()+"), "+ke+`);
}
`}else{var Ee=`
`+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;
`;Fe=`
`+I+` rc = outputLoc;
`+Ee+`
result[0] = getChannel(getX(`+G.join()+"), "+ke+`);
`+L[g-1]+` += 1;
if(`+Q+`) {
`+Ee+`
result[1] = getChannel(getX(`+G.join()+"), "+ke+`);
}
rc = outputLoc;
`+L[g-2]+` += 1;
if(`+L[g-2]+" < "+this.outputShape[g-2]+`) {
`+Ee+`
result[2] = getChannel(getX(`+G.join()+"), "+ke+`);
`+L[g-1]+` += 1;
if(`+Q+`) {
`+Ee+`
result[3] = getChannel(getX(`+G.join()+"), "+ke+`);
}
}
`}this.userCode=`
const `+I+" start = "+I+"("+R+`);
const `+I+" end = "+I+"("+P+`);
void main() {
`+I+` outputLoc = getOutputCoords();
vec4 result = vec4(0.);
`+Fe+`
setOutput(result);
}
`}return f}(),Zc=function(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=m.paddings,R=m.mode,P=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Pl(g.shape,I,R):new Ll(g.shape,I,R),L=l.runWebGLProgram(P,[g],g.dtype);return L},la={kernelName:i.MirrorPad,backendName:"webgl",kernelFunc:Zc},Ua={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},gu=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}(),Qc="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),P=l.texData.get(g.dataId),L=new gu(Ua.REAL,m.shape,g.shape),G=new gu(Ua.IMAG,m.shape,g.shape),Q=[{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:P.complexTensorInfos.real.dataId,dtype:P.complexTensorInfos.real.dtype,shape:g.shape},{dataId:P.complexTensorInfos.imag.dataId,dtype:P.complexTensorInfos.imag.dtype,shape:g.shape}],ke=l.runWebGLProgram(L,Q,"float32"),Ce=l.runWebGLProgram(G,Q,"float32"),Fe=po({inputs:{real:ke,imag:Ce},backend:l});return l.disposeIntermediateTensorInfo(ke),l.disposeIntermediateTensorInfo(Ce),Fe}if(l.shouldExecuteOnCPU([m,g])){var R=l.texData.get(m.dataId),P=l.texData.get(g.dataId),Ee=or(m.shape,g.shape,R.values,P.values,I),Ge=Ee[0],Qe=Ee[1],s=l.makeTensorInfo(Qe,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(Qc,m.shape,g.shape):r=new vn(Qc,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,P=m,L=P.maxOutputSize,G=P.iouThreshold,Q=P.scoreThreshold,ke=l,Ce=ke.readSync(I.dataId),Fe=ke.readSync(R.dataId),Ee=L,Ge=G,Qe=Q;return i.kernel_impls.nonMaxSuppressionV3Impl(Ce,Fe,Ee,Ge,Qe)}},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,P=m,L=P.maxOutputSize,G=P.iouThreshold,Q=P.scoreThreshold,ke=P.padToMaxOutputSize,Ce=l,Fe=Ce.readSync(I.dataId),Ee=Ce.readSync(R.dataId),Ge=Vl(Fe,Ee,L,G,Q,ke),Qe=Ge.selectedIndices,s=Ge.validOutputs;return[Qe,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,P=m,L=P.maxOutputSize,G=P.iouThreshold,Q=P.scoreThreshold,ke=P.softNmsSigma,Ce=l,Fe=Ce.readSync(I.dataId),Ee=Ce.readSync(R.dataId),Ge=L,Qe=G,s=Q,u=ke,r=Gl(Fe,Ee,Ge,Qe,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],P=Math.sin(l).toFixed(3),L=Math.cos(l).toFixed(3);this.outputShape=p;var G=i.backend_util.getImageCenter(g,I,R),Q=G[0],ke=G[1],Ce=Q.toFixed(3),Fe=ke.toFixed(3),Ee="";typeof m=="number"?Ee="float outputValue = "+m.toFixed(2)+";":Ee=`
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) - "+Fe+") * "+P+`;
float coordYFloat = (float(x) - `+Ce+") * "+P+" + (float(y) - "+Fe+") * "+L+`;
int coordX = int(round(coordXFloat + `+Ce+`));
int coordY = int(round(coordYFloat + `+Fe+`));
`+Ee+`
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,P=I.fillValue,L=I.center,G=m,Q=new ql(g.shape,R,P,L),ke=G.runWebGLProgram(Q,[g],g.dtype);return ke}},Xl=hu+`
return sin(x);
`,Cr=Hs(Xl),Yl={kernelName:i.Sin,backendName:"webgl",kernelFunc:Cr},Xu="return x * x;",Zl=Hs(Xu),Wr={kernelName:i.Square,backendName:"webgl",kernelFunc:Zl},Jc="return (a - b) * (a - b);",bt=fo({opSnippet:Jc,packedOpSnippet:Jc}),Ql={kernelName:i.SquaredDifference,backendName:"webgl",kernelFunc:bt},ci="return a - b;",Jl=fo({opSnippet:ci,packedOpSnippet:ci,supportsComplex:!0,cpuKernelImpl:ia}),$c={kernelName:i.Sub,backendName:"webgl",kernelFunc:Jl},$l="return tan(x);",el=Hs($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,P=g.shape.length,L=new Array(P),G=0;G<L.length;G++)L[G]=g.shape[I[G]];var Q;if(R.shouldExecuteOnCPU([g])){var ke=R.texData.get(g.dataId),Ce=ke.values,Fe=qa(Ce,g.shape,g.dtype,I,L);Q=R.makeTensorInfo(L,g.dtype);var Ee=R.texData.get(Q.dataId);Ee.values=Fe}else Q=js(g,I,R);return Q}};function Yu(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),P=bi(R,g,I.shape,I.dtype),L=P.outputValues,G=P.outputShape,Q=P.indices;return[m.makeTensorInfo(G,I.dtype,L),m.makeTensorInfo([Q.length],"int32",Q)]}for(var tl={kernelName:i.Unique,backendName:"webgl",kernelFunc:Yu},rl=[zu,du,Nc,Tc,sn,ss,Sc,Bc,Uc,jc,Kc,Il,Yc,kc,Cl,Pu,ju,Dl,Ol,Ku,zl,la,Wl,Ul,Hl,jl,Fc,Dc,Bu,Kl,Yl,Wr,$c,Ql,eh,th,tl],li=0,nl=rl;li<nl.length;li++){var $i=nl[li];i.registerKernel($i)}N.GPGPUContext=Oe,N.MathBackendWebGL=Go,N.forceHalfFloat=Vs,N.gpgpu_util=Ae,N.setWebGLContext=Te,N.version_webgl=Du,N.webgl=bc,N.webgl_util=ai}),Vi=Or(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),we=ag(),M=ig(),V=sg(),oe=yg(),de=vg(),X="2.7.0",Te={"tfjs-core":i.version_core,"tfjs-backend-cpu":oe.version_cpu,"tfjs-backend-webgl":de.version_webgl,"tfjs-data":V.version_data,"tfjs-layers":we.version_layers,"tfjs-converter":M.version_converter,tfjs:X};Object.keys(i).forEach(function(z){z!=="default"&&Object.defineProperty(N,z,{enumerable:!0,get:function(){return i[z]}})}),Object.keys(we).forEach(function(z){z!=="default"&&Object.defineProperty(N,z,{enumerable:!0,get:function(){return we[z]}})}),Object.keys(M).forEach(function(z){z!=="default"&&Object.defineProperty(N,z,{enumerable:!0,get:function(){return M[z]}})}),N.data=V,N.version=Te}),gg=Or(N=>{const i=Vi(),we=6;function M(ye){const ee={strides:[ye/16,ye/8],anchors:[2,6]},w=[];for(let xe=0;xe<ee.strides.length;xe++){const We=ee.strides[xe],W=Math.floor((ye+We-1)/We),st=Math.floor((ye+We-1)/We),ut=ee.anchors[xe];for(let Kt=0;Kt<W;Kt++){const It=We*(Kt+.5);for(let Ze=0;Ze<st;Ze++){const mt=We*(Ze+.5);for(let yt=0;yt<ut;yt++)w.push([mt,It])}}}return w}const V=ye=>{ye.startEndTensor.dispose(),ye.startPoint.dispose(),ye.endPoint.dispose()},oe=ye=>({startEndTensor:ye,startPoint:i.slice(ye,[0,0],[-1,2]),endPoint:i.slice(ye,[0,2],[-1,2])}),de=(ye,ee)=>{const w=i.mul(ye.startPoint,ee),xe=i.mul(ye.endPoint,ee),We=i.concat2d([w,xe],1);return oe(We)};function X(ye,ee,w){const xe=i.slice(ye,[0,1],[-1,2]),We=i.add(xe,ee),W=i.slice(ye,[0,3],[-1,2]),st=i.div(W,w),ut=i.div(We,w),Kt=i.div(st,2),It=i.sub(ut,Kt),Ze=i.add(ut,Kt),mt=i.mul(It,w),yt=i.mul(Ze,w),$e=1;return i.concat2d([mt,yt],$e)}function Te(ye,ee){return i.tidy(()=>{const w=ye.box?ye.box:ye;return de(w,ee).startEndTensor.squeeze()})}class z{constructor(ye,ee){this.blazeFaceModel=ye,this.width=ee.detector.inputSize,this.height=ee.detector.inputSize,this.anchorsData=M(ee.detector.inputSize),this.anchors=i.tensor2d(this.anchorsData),this.inputSize=i.tensor1d([this.width,this.height]),this.config=ee,this.scaleFaces=.8}async getBoundingBoxes(ye){if(!ye||ye.isDisposedInternal||ye.shape.length!==4||ye.shape[1]<1||ye.shape[2]<1)return null;const[ee,w,xe]=i.tidy(()=>{const It=ye.resizeBilinear([this.width,this.height]),Ze=i.sub(It.div(127.5),1),mt=this.blazeFaceModel.predict(Ze);let yt;if(Array.isArray(mt)){const et=mt.sort((jr,Pr)=>jr.size-Pr.size),Qt=i.concat([et[0],et[2]],2),rr=i.concat([et[1],et[3]],2),jt=i.concat([rr,Qt],1);yt=jt.squeeze(0)}else yt=mt.squeeze();const $e=X(yt,this.anchors,this.inputSize),ot=i.slice(yt,[0,0],[-1,1]),nt=ot.squeeze();return[yt,$e,nt]}),We=await i.image.nonMaxSuppressionAsync(w,xe,this.config.detector.maxFaces,this.config.detector.iouThreshold,this.config.detector.scoreThreshold),W=We.arraySync();We.dispose();const st=W.map(It=>i.slice(w,[It,0],[1,-1])),ut=st.map(It=>{const Ze=It.arraySync();return It.dispose(),Ze}),Kt=[];for(let It=0;It<ut.length;It++){const Ze=ut[It],mt=oe(Ze),yt=W[It],$e=this.anchorsData[yt],ot=i.slice(ee,[yt,we-1],[1,-1]),nt=ot.squeeze(),et=nt.reshape([we,-1]),Qt=i.slice(xe,[yt],[1]),rr={box:mt,landmarks:et,probability:Qt,anchor:$e};Kt.push(rr),ot.dispose(),nt.dispose()}return ee.dispose(),w.dispose(),xe.dispose(),ee.dispose(),{boxes:Kt,scaleFactor:[ye.shape[2]/this.width,ye.shape[1]/this.height]}}async estimateFaces(ye){const{boxes:ee,scaleFactor:w}=await this.getBoundingBoxes(ye),xe=[];for(const We of ee){const W=We.landmarks.arraySync(),st=Te(We,w),ut=de.arraySync(),Kt=We.probability.arraySync(),It=We.anchor,[Ze,mt]=w,yt=W.map(ot=>[(ot[0]+It[0])*Ze,(ot[1]+It[1])*mt]),$e={topLeft:ut.slice(0,2),bottomRight:ut.slice(2),landmarks:yt,probability:Kt};V(We.box),We.landmarks.dispose(),We.probability.dispose(),st.dispose(),xe.push($e)}return xe}}async function he(ye){const ee=await i.loadGraphModel(ye.detector.modelPath,{fromTFHub:ye.detector.modelPath.includes("tfhub.dev")}),w=new z(ee,ye);return console.log(`Human: load model: ${ye.detector.modelPath.match(/\/(.*)\./)[1]}`),w}N.load=he,N.BlazeFaceModel=z,N.disposeBox=V}),mf=Or(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]}]}),xg=Or(N=>{const i=Vi();function we(Te,z){const he=[Te.startPoint[0]*z[0],Te.startPoint[1]*z[1]],ye=[Te.endPoint[0]*z[0],Te.endPoint[1]*z[1]];return{startPoint:he,endPoint:ye}}N.scaleBoxCoordinates=we;function M(Te){return[Math.abs(Te.endPoint[0]-Te.startPoint[0]),Math.abs(Te.endPoint[1]-Te.startPoint[1])]}N.getBoxSize=M;function V(Te){return[Te.startPoint[0]+(Te.endPoint[0]-Te.startPoint[0])/2,Te.startPoint[1]+(Te.endPoint[1]-Te.startPoint[1])/2]}N.getBoxCenter=V;function oe(Te,z,he){const ye=z.shape[1],ee=z.shape[2],w=[[Te.startPoint[1]/ye,Te.startPoint[0]/ee,Te.endPoint[1]/ye,Te.endPoint[0]/ee]];return i.image.cropAndResize(z,w,[0],he)}N.cutBoxFromImageAndResize=oe;function de(Te,z=1.5){const he=V(Te),ye=M(Te),ee=[z*ye[0]/2,z*ye[1]/2],w=[he[0]-ee[0],he[1]-ee[1]],xe=[he[0]+ee[0],he[1]+ee[1]];return{startPoint:w,endPoint:xe,landmarks:Te.landmarks}}N.enlargeBox=de;function X(Te){const z=V(Te),he=M(Te),ye=Math.max(...he),ee=ye/2,w=[z[0]-ee,z[1]-ee],xe=[z[0]+ee,z[1]+ee];return{startPoint:w,endPoint:xe,landmarks:Te.landmarks}}N.squarifyBox=X}),_g=Or(N=>{N.IDENTITY_MATRIX=[[1,0,0],[0,1,0],[0,0,1]];function i(ee){return ee-2*Math.PI*Math.floor((ee+Math.PI)/(2*Math.PI))}N.normalizeRadians=i;function we(ee,w){const xe=Math.PI/2-Math.atan2(-(w[1]-ee[1]),w[0]-ee[0]);return i(xe)}N.computeRotation=we;function M(ee){return ee*180/Math.PI}N.radToDegrees=M;function V(ee,w){return[[1,0,ee],[0,1,w],[0,0,1]]}function oe(ee,w){let xe=0;for(let We=0;We<ee.length;We++)xe+=ee[We]*w[We];return xe}N.dot=oe;function de(ee,w){const xe=[];for(let We=0;We<ee.length;We++)xe.push(ee[We][w]);return xe}N.getColumnFrom2DArr=de;function X(ee,w){const xe=[],We=ee.length;for(let W=0;W<We;W++){xe.push([]);for(let st=0;st<We;st++)xe[W].push(oe(ee[W],de(w,st)))}return xe}function Te(ee,w){const xe=Math.cos(ee),We=Math.sin(ee),W=[[xe,-We,0],[We,xe,0],[0,0,1]],st=V(w[0],w[1]),ut=X(st,W),Kt=V(-w[0],-w[1]);return X(ut,Kt)}N.buildRotationMatrix=Te;function z(ee){const w=[[ee[0][0],ee[1][0]],[ee[0][1],ee[1][1]]],xe=[ee[0][2],ee[1][2]],We=[-oe(w[0],xe),-oe(w[1],xe)];return[w[0].concat(We[0]),w[1].concat(We[1]),[0,0,1]]}N.invertTransformMatrix=z;function he(ee,w){return[oe(ee,w[0]),oe(ee,w[1])]}N.rotatePoint=he;function ye(ee,w){return Math.sqrt((ee[0]-w[0])**2+(ee[1]-w[1])**2)}N.xyDistanceBetweenPoints=ye}),wg=Or(N=>{const i=Vi(),we=xg(),M=mf(),V=_g(),oe=468,de=.25,X=13,Te=[X,M.MESH_ANNOTATIONS.midwayBetweenEyes[0]],z=3,he=2,ye=[z,he],ee=M.MESH_ANNOTATIONS.leftEyeLower0,w=[ee[0],ee[ee.length-1]],xe=M.MESH_ANNOTATIONS.rightEyeLower0,We=[xe[0],xe[xe.length-1]],W=3,st=4,ut=71,Kt=76;function It(mt,yt,$e,ot){for(let nt=0;nt<M.MESH_TO_IRIS_INDICES_MAP.length;nt++){const{key:et,indices:Qt}=M.MESH_TO_IRIS_INDICES_MAP[nt],rr=M.MESH_ANNOTATIONS[`${$e}${et}`],jt=ot==null;if(jt||ot.includes(et))for(let jr=0;jr<Qt.length;jr++){const Pr=Qt[jr];mt[rr[jr]]=[yt[Pr][0],yt[Pr][1],(yt[Pr][2]+mt[rr[jr]][2])/2]}}}class Ze{constructor(mt,yt,$e,ot){this.regionsOfInterest=[],this.runsWithoutFaceDetector=0,this.boundingBoxDetector=mt,this.meshDetector=yt,this.irisModel=$e,this.meshWidth=ot.mesh.inputSize,this.meshHeight=ot.mesh.inputSize,this.irisSize=ot.iris.inputSize,this.irisEnlarge=ot.iris.enlargeFactor}transformRawCoords(mt,yt,$e,ot){const nt=we.getBoxSize({startPoint:yt.startPoint,endPoint:yt.endPoint}),et=[nt[0]/this.meshWidth,nt[1]/this.meshHeight],Qt=mt.map(ar=>[et[0]*(ar[0]-this.meshWidth/2),et[1]*(ar[1]-this.meshHeight/2),ar[2]]),rr=V.buildRotationMatrix($e,[0,0]),jt=Qt.map(ar=>[...V.rotatePoint(ar,rr),ar[2]]),jr=V.invertTransformMatrix(ot),Pr=[...we.getBoxCenter({startPoint:yt.startPoint,endPoint:yt.endPoint}),1],_r=[V.dot(Pr,jr[0]),V.dot(Pr,jr[1])];return jt.map(ar=>[ar[0]+_r[0],ar[1]+_r[1],ar[2]])}getLeftToRightEyeDepthDifference(mt){const yt=mt[w[0]][2],$e=mt[We[0]][2];return yt-$e}getEyeBox(mt,yt,$e,ot,nt=!1){const et=we.squarifyBox(we.enlargeBox(this.calculateLandmarksBoundingBox([mt[$e],mt[ot]]),this.irisEnlarge)),Qt=we.getBoxSize(et);let rr=i.image.cropAndResize(yt,[[et.startPoint[1]/this.meshHeight,et.startPoint[0]/this.meshWidth,et.endPoint[1]/this.meshHeight,et.endPoint[0]/this.meshWidth]],[0],[this.irisSize,this.irisSize]);return nt&&(rr=i.image.flipLeftRight(rr)),{box:et,boxSize:Qt,crop:rr}}getEyeCoords(mt,yt,$e,ot=!1){const nt=[];for(let et=0;et<Kt;et++){const Qt=mt[et*3],rr=mt[et*3+1],jt=mt[et*3+2];nt.push([(ot?1-Qt/this.irisSize:Qt/this.irisSize)*$e[0]+yt.startPoint[0],rr/this.irisSize*$e[1]+yt.startPoint[1],jt])}return{rawCoords:nt,iris:nt.slice(ut)}}getAdjustedIrisCoords(mt,yt,$e){const ot=mt[M.MESH_ANNOTATIONS[`${$e}EyeUpper0`][W]][2],nt=mt[M.MESH_ANNOTATIONS[`${$e}EyeLower0`][st]][2],et=(ot+nt)/2;return yt.map((Qt,rr)=>{let jt=et;return rr===2?jt=ot:rr===4&&(jt=nt),[Qt[0],Qt[1],jt]})}async predict(mt,yt){this.runsWithoutFaceDetector+=1;let $e=this.detectedFaces===0||this.detectedFaces!==this.regionsOfInterest.length,ot;if(($e||this.runsWithoutFaceDetector>yt.detector.skipFrames)&&(ot=await this.boundingBoxDetector.getBoundingBoxes(mt)),yt.detector.maxFaces>1&&ot&&ot.boxes&&ot.boxes.length>0&&ot.boxes.length!==this.detectedFaces&&($e=!0),$e){if(!ot||!ot.boxes||ot.boxes.length===0)return this.regionsOfInterest=[],this.detectedFaces=0,null;const et=ot.boxes.map(Qt=>{const rr=Qt.box.startPoint.squeeze(),jt=Qt.box.endPoint.squeeze(),jr={startPoint:rr.arraySync(),endPoint:jt.arraySync()};rr.dispose(),jt.dispose();const Pr=we.scaleBoxCoordinates(jr,ot.scaleFactor),_r=we.enlargeBox(Pr),ar=Qt.landmarks.arraySync();return{..._r,landmarks:ar}});this.updateRegionsOfInterest(et),this.runsWithoutFaceDetector=0}ot&&ot.boxes&&ot.boxes.forEach(et=>{et.box.startPoint.dispose(),et.box.endPoint.dispose(),et.landmarks.dispose(),et.probability.dispose()});let nt=i.tidy(()=>this.regionsOfInterest.map((et,Qt)=>{let rr=0;const jt=et.landmarks.length>=oe;let[jr,Pr]=Te;jt===!1&&([jr,Pr]=ye),rr=V.computeRotation(et.landmarks[jr],et.landmarks[Pr]);const _r=we.getBoxCenter({startPoint:et.startPoint,endPoint:et.endPoint}),ar=[_r[0]/mt.shape[2],_r[1]/mt.shape[1]];let da=mt,Ha=V.IDENTITY_MATRIX;rr!==0&&(da=i.image.rotateWithOffset(mt,rr,0,ar),Ha=V.buildRotationMatrix(-rr,_r));const Tn={startPoint:et.startPoint,endPoint:et.endPoint},ba=we.cutBoxFromImageAndResize(Tn,da,[this.meshHeight,this.meshWidth]).div(255),[,ka,ta]=this.meshDetector.predict(ba),Ma=ka.dataSync()[0];if(ka.dispose(),Ma<yt.detector.minConfidence)return ta.dispose(),null;const Ti=i.reshape(ta,[-1,3]);let Bn=Ti.arraySync();if(yt.iris.enabled){const{box:fn,boxSize:Gn,crop:_i}=this.getEyeBox(Bn,ba,w[0],w[1],!0),{box:fa,boxSize:Hi,crop:Yn}=this.getEyeBox(Bn,ba,We[0],We[1]),Wn=this.irisModel.predict(i.concat([_i,Yn])),Ga=Wn.dataSync();Wn.dispose();const Sa=Ga.slice(0,Kt*3),{rawCoords:hi,iris:La}=this.getEyeCoords(Sa,fn,Gn,!0),on=Ga.slice(Kt*3),{rawCoords:xn,iris:Ia}=this.getEyeCoords(on,fa,Hi),Rr=this.getLeftToRightEyeDepthDifference(Bn);Math.abs(Rr)<30?(It(Bn,hi,"left"),It(Bn,xn,"right")):Rr<1?It(Bn,hi,"left",["EyeUpper0","EyeLower0"]):It(Bn,xn,"right",["EyeUpper0","EyeLower0"]);const Pa=this.getAdjustedIrisCoords(Bn,La,"left"),na=this.getAdjustedIrisCoords(Bn,Ia,"right");Bn=Bn.concat(Pa).concat(na)}const ra=this.transformRawCoords(Bn,et,rr,Ha);i.dispose(Bn);const cn=we.enlargeBox(this.calculateLandmarksBoundingBox(ra)),za={coords:null,box:cn,confidence:Ma,image:ba};if(yt.mesh.enabled){const fn=i.tensor2d(ra);this.regionsOfInterest[Qt]={...cn,landmarks:fn.arraySync()},za.coords=fn}return za}));return nt=nt.filter(et=>et!==null),this.detectedFaces=nt.length,nt}updateRegionsOfInterest(mt){for(let yt=0;yt<mt.length;yt++){const $e=mt[yt],ot=this.regionsOfInterest[yt];let nt=0;if(ot&&ot.startPoint){const[et,Qt]=$e.startPoint,[rr,jt]=$e.endPoint,[jr,Pr]=ot.startPoint,[_r,ar]=ot.endPoint,da=Math.max(et,jr),Ha=Math.max(Qt,Pr),Tn=Math.min(rr,_r),ba=Math.min(jt,ar),ka=(Tn-da)*(ba-Ha),ta=(rr-et)*(jt-Qt),Ma=(_r-jr)*(ar-Qt);nt=ka/(ta+Ma-ka)}nt<de&&(this.regionsOfInterest[yt]=$e)}this.regionsOfInterest=this.regionsOfInterest.slice(0,mt.length)}clearRegionOfInterest(mt){this.regionsOfInterest[mt]!=null&&(this.regionsOfInterest=[...this.regionsOfInterest.slice(0,mt),...this.regionsOfInterest.slice(mt+1)])}calculateLandmarksBoundingBox(mt){const yt=mt.map(et=>et[0]),$e=mt.map(et=>et[1]),ot=[Math.min(...yt),Math.min(...$e)],nt=[Math.max(...yt),Math.max(...$e)];return{startPoint:ot,endPoint:nt,landmarks:mt}}}N.Pipeline=Ze}),bg=Or(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]]}),kg=Or(N=>{Zh(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]}),Sg=Or(N=>{const i=Vi(),we=gg(),M=mf(),V=wg(),oe=bg(),de=kg().default;class X{constructor(z,he,ye,ee){this.pipeline=new V.Pipeline(z,he,ye,ee),ee&&(this.config=ee)}async estimateFaces(z,he){he&&(this.config=he);const ye=await this.pipeline.predict(z,he),ee=[];for(const w of ye||[]){if(w.isDisposedInternal)continue;const xe=w.coords?w.coords.arraySync():null,We={};if(xe&&xe.length>0)for(const W in M.MESH_ANNOTATIONS)(this.config.iris.enabled||W.includes("Iris")===!1)&&(We[W]=M.MESH_ANNOTATIONS[W].map(st=>xe[st]));ee.push({confidence:w.confidence||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:xe,annotations:We,image:w.image?i.clone(w.image):null}),w.coords&&w.coords.dispose(),w.image&&w.image.dispose()}return ee}}async function Te(z){const he=await Promise.all([we.load(z),i.loadGraphModel(z.mesh.modelPath,{fromTFHub:z.mesh.modelPath.includes("tfhub.dev")}),i.loadGraphModel(z.iris.modelPath,{fromTFHub:z.iris.modelPath.includes("tfhub.dev")})]),ye=new X(he[0],he[1],he[2],z);return console.log(`Human: load model: ${z.mesh.modelPath.match(/\/(.*)\./)[1]}`),console.log(`Human: load model: ${z.iris.modelPath.match(/\/(.*)\./)[1]}`),ye}N.load=Te,N.MediaPipeFaceMesh=X,N.uv_coords=oe,N.triangulation=de}),Qh=Or(N=>{const i={};function we(M,V){if(!V||!V.kernels)return;const oe=5,de=V.kernels.filter(he=>he.kernelTimeMs>0).reduce((he,ye)=>he+=ye.kernelTimeMs,0),X=V.kernels.map((he,ye)=>(he.id=ye,he)).filter(he=>he.kernelTimeMs>0).sort((he,ye)=>ye.kernelTimeMs-he.kernelTimeMs),Te=V.kernels.map((he,ye)=>(he.id=ye,he)).filter(he=>he.totalBytesSnapshot>0).sort((he,ye)=>ye.totalBytesSnapshot-he.totalBytesSnapshot);X.length>oe&&(X.length=oe),Te.length>oe&&(Te.length=oe);const z={newBytes:V.newBytes,newTensors:V.newTensors,peakBytes:V.peakBytes,numKernelOps:V.kernels.length,timeKernelOps:de,slowestKernelOps:X,largestKernelOps:Te};i[M]=z}N.run=we,N.data=i}),Ig=Or(N=>{const i=Vi(),we=Qh(),M={};let V={age:0},oe=Number.MAX_SAFE_INTEGER;const de=[0,0];async function X(z){return M.age||(M.age=await i.loadGraphModel(z.face.age.modelPath),console.log(`Human: load model: ${z.face.age.modelPath.match(/\/(.*)\./)[1]}`)),M.age}async function Te(z,he){return oe<he.face.age.skipFrames&&V.age&&V.age>0?(oe+=1,V):(oe=0,new Promise(async ye=>{const ee=[[z.shape[1]*de[0]/z.shape[1],z.shape[2]*de[1]/z.shape[2],(z.shape[1]-z.shape[1]*de[0])/z.shape[1],(z.shape[2]-z.shape[2]*de[1])/z.shape[2]]],w=i.image.cropAndResize(z,ee,[0],[he.face.age.inputSize,he.face.age.inputSize]),xe=i.mul(w,[255]);i.dispose(w);let We;const W={};if(!he.profile)he.face.age.enabled&&(We=await M.age.predict(xe));else{const st=he.face.age.enabled?await i.profile(()=>M.age.predict(xe)):{};We=st.result.clone(),st.result.dispose(),we.run("age",st)}if(xe.dispose(),We){const st=We.dataSync();W.age=Math.trunc(10*st[0])/10}We.dispose(),V=W,ye(W)}))}N.predict=Te,N.load=X}),Ng=Or(N=>{const i=Vi(),we=Qh(),M={};let V={gender:""},oe=Number.MAX_SAFE_INTEGER,de=!1;const X=[0,0],Te=[.2989,.587,.114];async function z(ye){return M.gender||(M.gender=await i.loadGraphModel(ye.face.gender.modelPath),de=M.gender.inputs[0].shape[3]===1,console.log(`Human: load model: ${ye.face.gender.modelPath.match(/\/(.*)\./)[1]}`)),M.gender}async function he(ye,ee){return oe<ee.face.gender.skipFrames&&V.gender!==""?(oe+=1,V):(oe=0,new Promise(async w=>{const xe=[[ye.shape[1]*X[0]/ye.shape[1],ye.shape[2]*X[1]/ye.shape[2],(ye.shape[1]-ye.shape[1]*X[0])/ye.shape[1],(ye.shape[2]-ye.shape[2]*X[1])/ye.shape[2]]],We=i.image.cropAndResize(ye,xe,[0],[ee.face.gender.inputSize,ee.face.gender.inputSize]);let W;de?W=i.tidy(()=>{const[Kt,It,Ze]=i.split(We,3,3),mt=i.mul(Kt,Te[0]),yt=i.mul(It,Te[1]),$e=i.mul(Ze,Te[2]),ot=i.addN([mt,yt,$e]);return ot.sub(.5).mul(2)}):W=i.mul(We,[255]),i.dispose(We);let st;const ut={};if(!ee.profile)ee.face.gender.enabled&&(st=await M.gender.predict(W));else{const Kt=ee.face.gender.enabled?await i.profile(()=>M.gender.predict(W)):{};st=Kt.result.clone(),Kt.result.dispose(),we.run("gender",Kt)}if(W.dispose(),st){const Kt=st.dataSync();if(de){const It=Math.trunc(100*Math.abs(Kt[0]-Kt[1]))/100;It>ee.face.gender.minConfidence&&(ut.gender=Kt[0]>Kt[1]?"female":"male",ut.confidence=It)}else{const It=Math.trunc(200*Math.abs(Kt[0]-.5))/100;It>ee.face.gender.minConfidence&&(ut.gender=Kt[0]<=.5?"female":"male",ut.confidence=It)}}st.dispose(),V=ut,w(ut)}))}N.predict=he,N.load=z}),Cg=Or(N=>{const i=Vi(),we=Qh(),M=["angry","disgust","fear","happy","sad","surpise","neutral"],V={};let oe=[],de=Number.MAX_SAFE_INTEGER;const X=[0,0],Te=[.2989,.587,.114],z=1;async function he(ee){return V.emotion||(V.emotion=await i.loadGraphModel(ee.face.emotion.modelPath),console.log(`Human: load model: ${ee.face.emotion.modelPath.match(/\/(.*)\./)[1]}`)),V.emotion}async function ye(ee,w){return de<w.face.emotion.skipFrames&&oe.length>0?(de+=1,oe):(de=0,new Promise(async xe=>{const We=[[ee.shape[1]*X[0]/ee.shape[1],ee.shape[2]*X[1]/ee.shape[2],(ee.shape[1]-ee.shape[1]*X[0])/ee.shape[1],(ee.shape[2]-ee.shape[2]*X[1])/ee.shape[2]]],W=i.image.cropAndResize(ee,We,[0],[w.face.emotion.inputSize,w.face.emotion.inputSize]),[st,ut,Kt]=i.split(W,3,3);W.dispose();const It=i.mul(st,Te[0]),Ze=i.mul(ut,Te[1]),mt=i.mul(Kt,Te[2]);st.dispose(),ut.dispose(),Kt.dispose();const yt=i.addN([It,Ze,mt]);It.dispose(),Ze.dispose(),mt.dispose();const $e=i.tidy(()=>yt.sub(.5).mul(2));yt.dispose();const ot=[];if(w.face.emotion.enabled){let nt;if(w.profile){const et=await i.profile(()=>V.emotion.predict(yt));nt=et.result.dataSync(),et.result.dispose(),we.run("emotion",et)}else{const et=await V.emotion.predict($e);nt=et.dataSync(),i.dispose(et)}for(let et=0;et<nt.length;et++)z*nt[et]>w.face.emotion.minConfidence&&ot.push({score:Math.min(.99,Math.trunc(100*z*nt[et])/100),emotion:M[et]});ot.sort((et,Qt)=>Qt.score-et.score)}$e.dispose(),oe=ot,xe(ot)}))}N.predict=ye,N.load=he}),Tg=Or(N=>{const i=Vi();class we{constructor(M,V){this.model=M,this.outputStride=V}predict(M){return i.tidy(()=>{const V=this.preprocessInput(M.toFloat()),oe=V.expandDims(0),de=this.model.predict(oe),X=de.map(z=>z.squeeze([0])),Te=this.nameOutputResults(X);return{heatmapScores:Te.heatmap.sigmoid(),offsets:Te.offsets,displacementFwd:Te.displacementFwd,displacementBwd:Te.displacementBwd}})}dispose(){this.model.dispose()}}N.BaseModel=we}),yf=Or(N=>{const i=Vi(),we=Tg();class M extends we.BaseModel{preprocessInput(V){return i.tidy(()=>i.div(V,127.5).sub(1))}nameOutputResults(V){const[oe,de,X,Te]=V;return{offsets:oe,heatmap:de,displacementFwd:X,displacementBwd:Te}}}N.MobileNet=M}),Eg=Or(N=>{function i(M){return Math.floor(M/2)}class we{constructor(M,V){this.priorityQueue=new Array(M),this.numberOfElements=-1,this.getElementValue=V}enqueue(M){this.priorityQueue[++this.numberOfElements]=M,this.swim(this.numberOfElements)}dequeue(){const M=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,M}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(M){for(;M>0&&this.less(i(M),M);)this.exchange(M,i(M)),M=i(M)}sink(M){for(;2*M<=this.numberOfElements;){let V=2*M;if(V<this.numberOfElements&&this.less(V,V+1)&&V++,!this.less(M,V))break;this.exchange(M,V),M=V}}getValueAt(M){return this.getElementValue(this.priorityQueue[M])}less(M,V){return this.getValueAt(M)<this.getValueAt(V)}exchange(M,V){const oe=this.priorityQueue[M];this.priorityQueue[M]=this.priorityQueue[V],this.priorityQueue[V]=oe}}N.MaxHeap=we}),Rg=Or(N=>{const i=Eg();function we(V,oe,de,X,Te,z){const[he,ye]=z.shape;let ee=!0;const w=Math.max(de-Te,0),xe=Math.min(de+Te+1,he);for(let We=w;We<xe;++We){const W=Math.max(X-Te,0),st=Math.min(X+Te+1,ye);for(let ut=W;ut<st;++ut)if(z.get(We,ut,V)>oe){ee=!1;break}if(!ee)break}return ee}function M(V,oe,de){const[X,Te,z]=de.shape,he=new i.MaxHeap(X*Te*z,({score:ye})=>ye);for(let ye=0;ye<X;++ye)for(let ee=0;ee<Te;++ee)for(let w=0;w<z;++w){const xe=de.get(ye,ee,w);if(xe<V)continue;we(w,xe,ye,ee,oe,de)&&he.enqueue({score:xe,part:{heatmapY:ye,heatmapX:ee,id:w}})}return he}N.buildPartWithScoreQueue=M}),Jh=Or(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((we,M,V)=>(we[M]=V,we),{});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(([we,M])=>[N.partIds[we],N.partIds[M]]),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"]}),vf=Or(N=>{const i=Jh();function we(z,he,ye,ee){return{y:ee.get(z,he,ye),x:ee.get(z,he,ye+i.NUM_KEYPOINTS)}}N.getOffsetPoint=we;function M(z,he,ye){const{heatmapY:ee,heatmapX:w,id:xe}=z,{y:We,x:W}=we(ee,w,xe,ye);return{x:z.heatmapX*he+W,y:z.heatmapY*he+We}}N.getImageCoords=M;function V(z,he){const ye=new Array(he);for(let ee=0;ee<he;ee++)ye[ee]=z;return ye}N.fillArray=V;function oe(z,he,ye){return z<he?he:z>ye?ye:z}N.clamp=oe;function de(z,he,ye,ee){const w=ye-z,xe=ee-he;return w*w+xe*xe}N.squaredDistance=de;function X(z,he){return{x:z.x+he.x,y:z.y+he.y}}N.addVectors=X;function Te(z,he,ye){return{y:oe(z.y,he,ye),x:oe(z.x,he,ye)}}N.clampVector=Te}),Ag=Or(N=>{const i=Jh(),we=vf(),M=i.poseChain.map(([he,ye])=>[i.partIds[he],i.partIds[ye]]),V=M.map(([,he])=>he),oe=M.map(([he])=>he);function de(he,ye,ee){const w=ee.shape[2]/2;return{y:ee.get(ye.y,ye.x,he),x:ee.get(ye.y,ye.x,w+he)}}function X(he,ye,ee,w){return{y:we.clamp(Math.round(he.y/ye),0,ee-1),x:we.clamp(Math.round(he.x/ye),0,w-1)}}function Te(he,ye,ee,w,xe,We,W,st=2){const[ut,Kt]=w.shape,It=X(ye.position,We,ut,Kt),Ze=de(he,It,W),mt=we.addVectors(ye.position,Ze);let yt=mt;for(let nt=0;nt<st;nt++){const et=X(yt,We,ut,Kt),Qt=we.getOffsetPoint(et.y,et.x,ee,xe);yt=we.addVectors({x:et.x*We,y:et.y*We},{x:Qt.x,y:Qt.y})}const $e=X(yt,We,ut,Kt),ot=w.get($e.y,$e.x,ee);return{position:yt,part:i.partNames[ee],score:ot}}function z(he,ye,ee,w,xe,We){const W=ye.shape[2],st=V.length,ut=new Array(W),{part:Kt,score:It}=he,Ze=we.getImageCoords(Kt,w,ee);ut[Kt.id]={score:It,part:i.partNames[Kt.id],position:Ze};for(let mt=st-1;mt>=0;--mt){const yt=V[mt],$e=oe[mt];ut[yt]&&!ut[$e]&&(ut[$e]=Te(mt,ut[yt],$e,ye,ee,w,We))}for(let mt=0;mt<st;++mt){const yt=oe[mt],$e=V[mt];ut[yt]&&!ut[$e]&&(ut[$e]=Te(mt,ut[yt],$e,ye,ee,w,xe))}return ut}N.decodePose=z}),gf=Or(N=>{const i=Rg(),we=Ag(),M=vf();function V(Te,z,{x:he,y:ye},ee){return Te.some(({keypoints:w})=>{const xe=w[ee].position;return M.squaredDistance(ye,he,xe.y,xe.x)<=z})}function oe(Te,z,he){const ye=he.reduce((ee,{position:w,score:xe},We)=>(V(Te,z,w,We)||(ee+=xe),ee),0);return ye/he.length}const de=1;function X(Te,z,he,ye,ee,w,xe=.5,We=20){const W=[],st=i.buildPartWithScoreQueue(xe,de,Te),ut=We*We;for(;W.length<w&&!st.empty();){const Kt=st.dequeue(),It=M.getImageCoords(Kt.part,ee,z);if(V(W,ut,It,Kt.part.id))continue;const Ze=we.decodePose(Kt,Te,z,ee,he,ye),mt=oe(W,ut,Ze);W.push({keypoints:Ze,score:mt})}return W}N.decodeMultiplePoses=X}),xf=Or(N=>{const i=Jh();function we(ee,w,xe){return ee<xe||w<xe}function M(ee,w){return i.connectedPartIndices.reduce((xe,[We,W])=>(we(ee[We].score,ee[W].score,w)||xe.push([ee[We],ee[W]]),xe),[])}N.getAdjacentKeyPoints=M;const{NEGATIVE_INFINITY:V,POSITIVE_INFINITY:oe}=Number;function de(ee){return ee.reduce(({maxX:w,maxY:xe,minX:We,minY:W},{position:{x:st,y:ut}})=>({maxX:Math.max(w,st),maxY:Math.max(xe,ut),minX:Math.min(We,st),minY:Math.min(W,ut)}),{maxX:V,maxY:V,minX:oe,minY:oe})}N.getBoundingBox=de;function X(ee){const{minX:w,minY:xe,maxX:We,maxY:W}=de(ee);return[{x:w,y:xe},{x:We,y:xe},{x:We,y:W},{x:w,y:W}]}N.getBoundingBoxPoints=X;async function Te(ee){return Promise.all(ee.map(w=>w.buffer()))}N.toTensorBuffers3D=Te;function z(ee,w,xe){return{score:ee.score,keypoints:ee.keypoints.map(({score:We,part:W,position:st})=>({score:We,part:W,position:{x:st.x*xe,y:st.y*w}}))}}N.scalePose=z;function he(ee,[w,xe]){const We=ee.squeeze(0),W=We.resizeBilinear([w,xe]);return We.dispose(),W}N.resizeTo=he;function ye(ee,[w,xe],[We,W]){const st=ee.map(ut=>z(ut,w/We,xe/W));return st}N.scaleAndFlipPoses=ye}),Fg=Or(N=>{const i=Vi(),we=yf(),M=gf(),V=xf();class oe{constructor(Te){this.baseModel=Te}async estimatePoses(Te,z){return new Promise(async he=>{const ye=z.outputStride,ee=Te.shape[1],w=Te.shape[2],xe=V.resizeTo(Te,[z.inputResolution,z.inputResolution]),{heatmapScores:We,offsets:W,displacementFwd:st,displacementBwd:ut}=this.baseModel.predict(xe),Kt=await V.toTensorBuffers3D([We,W,st,ut]),It=Kt[0],Ze=Kt[1],mt=Kt[2],yt=Kt[3],$e=await M.decodeMultiplePoses(It,Ze,mt,yt,ye,z.maxDetections,z.scoreThreshold,z.nmsRadius),ot=V.scaleAndFlipPoses($e,[ee,w],[z.inputResolution,z.inputResolution]);We.dispose(),W.dispose(),st.dispose(),ut.dispose(),xe.dispose(),he(ot)})}dispose(){this.baseModel.dispose()}}N.PoseNet=oe;async function de(Te){const z=await i.loadGraphModel(Te.modelPath),he=new we.MobileNet(z,Te.outputStride);return console.log(`Human: load model: ${Te.modelPath.match(/\/(.*)\./)[1]}`),new oe(he)}async function X(Te){return de(Te)}N.load=X}),Dg=Or(N=>{const i=yf(),we=Fg(),M=gf(),V=Jh(),oe=xf();N.load=we.load,N.PoseNet=we.PoseNet,N.MobileNet=i.MobileNet,N.decodeMultiplePoses=M.decodeMultiplePoses,N.partChannels=V.partChannels,N.partIds=V.partIds,N.partNames=V.partNames,N.poseChain=V.poseChain,N.getAdjacentKeyPoints=oe.getAdjacentKeyPoints,N.getBoundingBox=oe.getBoundingBox,N.getBoundingBoxPoints=oe.getBoundingBoxPoints,N.scaleAndFlipPoses=oe.scaleAndFlipPoses,N.scalePose=oe.scalePose}),_f=Or(N=>{Zh(N,{cutBoxFromImageAndResize:()=>V,enlargeBox:()=>de,getBoxCenter:()=>M,getBoxSize:()=>we,scaleBoxCoordinates:()=>oe,shiftBox:()=>Te,squarifyBox:()=>X});const i=Vi();function we(z){return[Math.abs(z.endPoint[0]-z.startPoint[0]),Math.abs(z.endPoint[1]-z.startPoint[1])]}function M(z){return[z.startPoint[0]+(z.endPoint[0]-z.startPoint[0])/2,z.startPoint[1]+(z.endPoint[1]-z.startPoint[1])/2]}function V(z,he,ye){const ee=he.shape[1],w=he.shape[2],xe=[[z.startPoint[1]/ee,z.startPoint[0]/w,z.endPoint[1]/ee,z.endPoint[0]/w]];return i.image.cropAndResize(he,xe,[0],ye)}function oe(z,he){const ye=[z.startPoint[0]*he[0],z.startPoint[1]*he[1]],ee=[z.endPoint[0]*he[0],z.endPoint[1]*he[1]],w=z.palmLandmarks.map(xe=>{const We=[xe[0]*he[0],xe[1]*he[1]];return We});return{startPoint:ye,endPoint:ee,palmLandmarks:w}}function de(z,he=1.5){const ye=M(z),ee=we(z),w=[he*ee[0]/2,he*ee[1]/2],xe=[ye[0]-w[0],ye[1]-w[1]],We=[ye[0]+w[0],ye[1]+w[1]];return{startPoint:xe,endPoint:We,palmLandmarks:z.palmLandmarks}}function X(z){const he=M(z),ye=we(z),ee=Math.max(...ye),w=ee/2,xe=[he[0]-w,he[1]-w],We=[he[0]+w,he[1]+w];return{startPoint:xe,endPoint:We,palmLandmarks:z.palmLandmarks}}function Te(z,he){const ye=[z.endPoint[0]-z.startPoint[0],z.endPoint[1]-z.startPoint[1]],ee=[ye[0]*he[0],ye[1]*he[1]],w=[z.startPoint[0]+ee[0],z.startPoint[1]+ee[1]],xe=[z.endPoint[0]+ee[0],z.endPoint[1]+ee[1]];return{startPoint:w,endPoint:xe,palmLandmarks:z.palmLandmarks}}}),Og=Or(N=>{const i=Vi(),we=_f();class M{constructor(V,oe,de){this.model=V,this.anchors=de.map(X=>[X.x_center,X.y_center]),this.anchorsTensor=i.tensor2d(this.anchors),this.inputSizeTensor=i.tensor1d([oe,oe]),this.doubleInputSizeTensor=i.tensor1d([oe*2,oe*2])}normalizeBoxes(V){return i.tidy(()=>{const oe=i.slice(V,[0,0],[-1,2]),de=i.slice(V,[0,2],[-1,2]),X=i.add(i.div(oe,this.inputSizeTensor),this.anchorsTensor),Te=i.div(de,this.doubleInputSizeTensor),z=i.mul(i.sub(X,Te),this.inputSizeTensor),he=i.mul(i.add(X,Te),this.inputSizeTensor);return i.concat2d([z,he],1)})}normalizeLandmarks(V,oe){return i.tidy(()=>{const de=i.add(i.div(V.reshape([-1,7,2]),this.inputSizeTensor),this.anchors[oe]);return i.mul(de,this.inputSizeTensor)})}async getBoundingBoxes(V,oe){const de=this.model.predict(V),X=de.squeeze(),Te=i.tidy(()=>i.sigmoid(i.slice(X,[0,0],[-1,1])).squeeze()),z=i.slice(X,[0,1],[-1,4]),he=this.normalizeBoxes(z),ye=await i.image.nonMaxSuppressionAsync(he,Te,oe.maxHands,oe.iouThreshold,oe.scoreThreshold),ee=ye.arraySync(),w=[de,ye,X,he,z,Te];if(ee.length===0)return w.forEach(We=>We.dispose()),null;const xe=[];for(const We of ee){const W=i.slice(he,[We,0],[1,-1]),st=i.slice(X,[We,5],[1,14]),ut=i.tidy(()=>this.normalizeLandmarks(st,We).reshape([-1,2]));st.dispose(),xe.push({boxes:W,palmLandmarks:ut})}return w.forEach(We=>We.dispose()),xe}async estimateHandBounds(V,oe){const de=V.shape[1],X=V.shape[2],Te=i.tidy(()=>V.resizeBilinear([oe.inputSize,oe.inputSize]).div(127.5).sub(1)),z=await this.getBoundingBoxes(Te,oe);if(Te.dispose(),!z||z.length===0)return null;const he=[];for(const ye of z){const ee=ye.boxes.dataSync(),w=ee.slice(0,2),xe=ee.slice(2,4),We=ye.palmLandmarks.arraySync();ye.boxes.dispose(),ye.palmLandmarks.dispose(),he.push(we.scaleBoxCoordinates({startPoint:w,endPoint:xe,palmLandmarks:We},[X/oe.inputSize,de/oe.inputSize]))}return he}}N.HandDetector=M}),Mg=Or(N=>{Zh(N,{buildRotationMatrix:()=>X,computeRotation:()=>we,dot:()=>V,getColumnFrom2DArr:()=>oe,invertTransformMatrix:()=>Te,normalizeRadians:()=>i,rotatePoint:()=>z});function i(he){return he-2*Math.PI*Math.floor((he+Math.PI)/(2*Math.PI))}function we(he,ye){const ee=Math.PI/2-Math.atan2(-(ye[1]-he[1]),ye[0]-he[0]);return i(ee)}const M=(he,ye)=>[[1,0,he],[0,1,ye],[0,0,1]];function V(he,ye){let ee=0;for(let w=0;w<he.length;w++)ee+=he[w]*ye[w];return ee}function oe(he,ye){const ee=[];for(let w=0;w<he.length;w++)ee.push(he[w][ye]);return ee}function de(he,ye){const ee=[],w=he.length;for(let xe=0;xe<w;xe++){ee.push([]);for(let We=0;We<w;We++)ee[xe].push(V(he[xe],oe(ye,We)))}return ee}function X(he,ye){const ee=Math.cos(he),w=Math.sin(he),xe=[[ee,-w,0],[w,ee,0],[0,0,1]],We=M(ye[0],ye[1]),W=de(We,xe),st=M(-ye[0],-ye[1]);return de(W,st)}function Te(he){const ye=[[he[0][0],he[1][0]],[he[0][1],he[1][1]]],ee=[he[0][2],he[1][2]],w=[-V(ye[0],ee),-V(ye[1],ee)];return[ye[0].concat(w[0]),ye[1].concat(w[1]),[0,0,1]]}function z(he,ye){return[V(he,ye[0]),V(he,ye[1])]}}),zg=Or(N=>{const i=Vi(),we=_f(),M=Mg(),V=.8,oe=[0,-.4],de=3,X=[0,-.1],Te=1.65,z=[0,5,9,13,17,1,2],he=0,ye=2;class ee{constructor(w,xe,We){this.boundingBoxDetector=w,this.meshDetector=xe,this.inputSize=We,this.regionsOfInterest=[],this.runsWithoutHandDetector=0,this.skipFrames=0,this.detectedHands=0}getBoxForPalmLandmarks(w,xe){const We=w.map(st=>{const ut=[...st,1];return M.rotatePoint(ut,xe)}),W=this.calculateLandmarksBoundingBox(We);return we.enlargeBox(we.squarifyBox(we.shiftBox(W,oe)),de)}getBoxForHandLandmarks(w){const xe=this.calculateLandmarksBoundingBox(w),We=we.enlargeBox(we.squarifyBox(we.shiftBox(xe,X)),Te),W=[];for(let st=0;st<z.length;st++)W.push(w[z[st]].slice(0,2));return We.palmLandmarks=W,We}transformRawCoords(w,xe,We,W){const st=we.getBoxSize(xe),ut=[st[0]/this.inputSize,st[1]/this.inputSize],Kt=w.map(ot=>[ut[0]*(ot[0]-this.inputSize/2),ut[1]*(ot[1]-this.inputSize/2),ot[2]]),It=M.buildRotationMatrix(We,[0,0]),Ze=Kt.map(ot=>{const nt=M.rotatePoint(ot,It);return[...nt,ot[2]]}),mt=M.invertTransformMatrix(W),yt=[...we.getBoxCenter(xe),1],$e=[M.dot(yt,mt[0]),M.dot(yt,mt[1])];return Ze.map(ot=>[ot[0]+$e[0],ot[1]+$e[1],ot[2]])}async estimateHands(w,xe){this.skipFrames=xe.skipFrames;let We=this.runsWithoutHandDetector>this.skipFrames||this.detectedHands!==this.regionsOfInterest.length,W;if(We&&(W=await this.boundingBoxDetector.estimateHandBounds(w,xe)),xe.maxHands>1&&W&&W.length>0&&W.length!==this.detectedHands&&(We=!0),We){if(this.regionsOfInterest=[],!W||W.length===0)return this.detectedHands=0,null;for(const ut of W)this.regionsOfInterest.push(ut);this.runsWithoutHandDetector=0}else this.runsWithoutHandDetector++;const st=[];for(const ut in this.regionsOfInterest){const Kt=this.regionsOfInterest[ut];if(!Kt)continue;const It=M.computeRotation(Kt.palmLandmarks[he],Kt.palmLandmarks[ye]),Ze=we.getBoxCenter(Kt),mt=[Ze[0]/w.shape[2],Ze[1]/w.shape[1]],yt=i.image.rotateWithOffset(w,It,0,mt),$e=M.buildRotationMatrix(-It,Ze),ot=We?this.getBoxForPalmLandmarks(Kt.palmLandmarks,$e):Kt,nt=we.cutBoxFromImageAndResize(ot,yt,[this.inputSize,this.inputSize]),et=nt.div(255);nt.dispose(),yt.dispose();const Qt=this.meshDetector.predict(et),[rr,jt]=Qt;et.dispose();const jr=rr.dataSync()[0];if(rr.dispose(),jr>=xe.minConfidence){const Pr=i.reshape(jt,[-1,3]),_r=Pr.arraySync();jt.dispose(),Pr.dispose();const ar=this.transformRawCoords(_r,ot,It,$e),da=this.getBoxForHandLandmarks(ar);this.updateRegionsOfInterest(da,ut);const Ha={landmarks:ar,handInViewConfidence:jr,boundingBox:{topLeft:da.startPoint,bottomRight:da.endPoint}};st.push(Ha)}else this.updateRegionsOfInterest(null,ut);jt.dispose()}return this.regionsOfInterest=this.regionsOfInterest.filter(ut=>ut!==null),this.detectedHands=st.length,st}calculateLandmarksBoundingBox(w){const xe=w.map(ut=>ut[0]),We=w.map(ut=>ut[1]),W=[Math.min(...xe),Math.min(...We)],st=[Math.max(...xe),Math.max(...We)];return{startPoint:W,endPoint:st}}updateRegionsOfInterest(w,xe){const We=this.regionsOfInterest[xe];let W=0;if(w&&We&&We.startPoint){const[st,ut]=w.startPoint,[Kt,It]=w.endPoint,[Ze,mt]=We.startPoint,[yt,$e]=We.endPoint,ot=Math.max(st,Ze),nt=Math.max(ut,mt),et=Math.min(Kt,yt),Qt=Math.min(It,$e),rr=(et-ot)*(Qt-nt),jt=(Kt-st)*(It-ut),jr=(yt-Ze)*($e-ut);W=rr/(jt+jr-rr)}this.regionsOfInterest[xe]=W>V?We:w}}N.HandPipeline=ee}),Lg=Or(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}]}),Pg=Or(N=>{const i=Vi(),we=Og(),M=zg(),V=Lg(),oe={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 de{constructor(Te){this.pipeline=Te}static getAnnotations(){return oe}async estimateHands(Te,z){const he=await this.pipeline.estimateHands(Te,z);if(!he)return[];const ye=[];for(const ee of he){const w={};if(ee.landmarks)for(const xe of Object.keys(oe))w[xe]=oe[xe].map(We=>ee.landmarks[We]);ye.push({confidence:ee.handInViewConfidence,box:ee.boundingBox?[ee.boundingBox.topLeft[0],ee.boundingBox.topLeft[1],ee.boundingBox.bottomRight[0]-ee.boundingBox.topLeft[0],ee.boundingBox.bottomRight[1]-ee.boundingBox.topLeft[1]]:0,landmarks:ee.landmarks,annotations:w})}return ye}}N.HandPose=de;async function X(Te){const[z,he]=await Promise.all([i.loadGraphModel(Te.detector.modelPath,{fromTFHub:Te.detector.modelPath.includes("tfhub.dev")}),i.loadGraphModel(Te.skeleton.modelPath,{fromTFHub:Te.skeleton.modelPath.includes("tfhub.dev")})]),ye=new we.HandDetector(z,Te.inputSize,V.anchors),ee=new M.HandPipeline(ye,he,Te.inputSize),w=new de(ee);return console.log(`Human: load model: ${Te.detector.modelPath.match(/\/(.*)\./)[1]}`),console.log(`Human: load model: ${Te.skeleton.modelPath.match(/\/(.*)\./)[1]}`),w}N.load=X}),Bg=Or(N=>{N.body=i=>{if(!i)return[];const we=[];for(const M of i){const V=M.keypoints.find(z=>z.part==="leftWrist"),oe=M.keypoints.find(z=>z.part==="rightWrist"),de=M.keypoints.find(z=>z.part==="nose");de&&V&&oe&&V.position.y<de.position.y&&oe.position.y<de.position.y?we.push("i give up"):de&&V&&V.position.y<de.position.y?we.push("raise left hand"):de&&oe&&oe.position.y<de.position.y&&we.push("raise right hand");const X=M.keypoints.find(z=>z.part==="leftShoulder"),Te=M.keypoints.find(z=>z.part==="rightShoulder");X&&Te&&we.push(`leaning ${X.position.y>Te.position.y?"left":"right"}`)}return we},N.face=i=>{if(!i)return[];const we=[];for(const M of i)M.annotations.rightCheek&&M.annotations.leftCheek&&M.annotations.rightCheek.length>0&&M.annotations.leftCheek.length>0&&we.push(`facing ${M.annotations.rightCheek[0][2]>0||M.annotations.leftCheek[0][2]<0?"right":"left"}`);return we},N.hand=i=>{if(!i)return[];const we=[];for(const M of i){const V=[];for(const[oe,de]of Object.entries(M.annotations))oe!=="palmBase"&&V.push({name:oe.toLowerCase(),position:de[0]});if(V&&V.length>0){const oe=V.reduce((X,Te)=>X.position[2]<Te.position[2]?X:Te),de=V.reduce((X,Te)=>X.position[1]<Te.position[1]?X:Te);we.push(`${oe.name} forward ${de.name} up`)}}return we}}),Wg=Or(N=>{const i=function(M,V,oe){const de=function(he,ye,ee){const w=new RegExp("\\b"+ye+" \\w+ (\\w+)","ig");he.replace(w,(xe,We)=>(ee[We]=0,xe))},X=function(he,ye){const ee=M.createShader(ye);if(M.shaderSource(ee,he),M.compileShader(ee),!M.getShaderParameter(ee,M.COMPILE_STATUS))throw new Error("Filter: GL compile failed",M.getShaderInfoLog(ee));return ee};this.uniform={},this.attribute={};const Te=X(V,M.VERTEX_SHADER),z=X(oe,M.FRAGMENT_SHADER);if(this.id=M.createProgram(),M.attachShader(this.id,Te),M.attachShader(this.id,z),M.linkProgram(this.id),!M.getProgramParameter(this.id,M.LINK_STATUS))throw new Error("Filter: GL link failed",M.getProgramInfoLog(this.id));M.useProgram(this.id),de(V,"attribute",this.attribute);for(const he in this.attribute)this.attribute[he]=M.getAttribLocation(this.id,he);de(V,"uniform",this.uniform),de(oe,"uniform",this.uniform);for(const he in this.uniform)this.uniform[he]=M.getUniformLocation(this.id,he)},we=function(M){M||(M={});let V=0,oe=null,de=!1,X=-1,Te=[null,null],z=[],he=-1,ye=-1,ee=null,w=null;const xe=M.canvas||document.createElement("canvas"),We={},W=xe.getContext("webgl");if(!W)throw new Error("Filter: getContext() failed");this.addFilter=function(ot){const nt=Array.prototype.slice.call(arguments,1),et=$e[ot];z.push({func:et,args:nt})},this.reset=function(){z=[]},this.apply=function(ot){if(st(ot.width,ot.height),V=0,oe||(oe=W.createTexture()),W.bindTexture(W.TEXTURE_2D,oe),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,ot),z.length===0)return It(),xe;for(let nt=0;nt<z.length;nt++){de=nt===z.length-1;const et=z[nt];et.func.apply(this,et.args||[])}return xe};const st=function(ot,nt){if(ot===he&&nt===ye)return;if(xe.width=ot,he=ot,xe.height=nt,ye=nt,!ee){const et=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]);ee=W.createBuffer(),W.bindBuffer(W.ARRAY_BUFFER,ee),W.bufferData(W.ARRAY_BUFFER,et,W.STATIC_DRAW),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}W.viewport(0,0,he,ye),Te=[null,null]},ut=function(ot){return Te[ot]=Te[ot]||Kt(he,ye),Te[ot]},Kt=function(ot,nt){const et=W.createFramebuffer();W.bindFramebuffer(W.FRAMEBUFFER,et);const Qt=W.createRenderbuffer();W.bindRenderbuffer(W.RENDERBUFFER,Qt);const rr=W.createTexture();return W.bindTexture(W.TEXTURE_2D,rr),W.texImage2D(W.TEXTURE_2D,0,W.RGBA,ot,nt,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,rr,0),W.bindTexture(W.TEXTURE_2D,null),W.bindFramebuffer(W.FRAMEBUFFER,null),{fbo:et,texture:rr}},It=function(ot){let nt=null,et=null,Qt=!1;V===0?nt=oe:nt=ut(X).texture,V++,de&&!(ot&mt.INTERMEDIATE)?(et=null,Qt=V%2===0):(X=(X+1)%2,et=ut(X).fbo),W.bindTexture(W.TEXTURE_2D,nt),W.bindFramebuffer(W.FRAMEBUFFER,et),W.uniform1f(w.uniform.flipY,Qt?-1:1),W.drawArrays(W.TRIANGLES,0,6)},Ze=function(ot){if(We[ot])return w=We[ot],W.useProgram(w.id),w;w=new i(W,yt.VERTEX_IDENTITY,ot);const nt=Float32Array.BYTES_PER_ELEMENT,et=4*nt;return W.enableVertexAttribArray(w.attribute.pos),W.vertexAttribPointer(w.attribute.pos,2,W.FLOAT,!1,et,0*nt),W.enableVertexAttribArray(w.attribute.uv),W.vertexAttribPointer(w.attribute.uv,2,W.FLOAT,!1,et,2*nt),We[ot]=w,w};let mt={INTERMEDIATE:1},yt={};yt.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(`
`),yt.FRAGMENT_IDENTITY=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","void main(void) {","gl_FragColor = texture2D(texture, vUv);","}"].join(`
`);let $e={};$e.colorMatrix=function(ot){const nt=new Float32Array(ot);nt[4]/=255,nt[9]/=255,nt[14]/=255,nt[19]/=255;const et=nt[18]===1&&nt[3]===0&&nt[8]===0&&nt[13]===0&&nt[15]===0&&nt[16]===0&&nt[17]===0&&nt[19]===0?$e.colorMatrix.SHADER.WITHOUT_ALPHA:$e.colorMatrix.SHADER.WITH_ALPHA,Qt=Ze(et);W.uniform1fv(Qt.uniform.m,nt),It()},$e.colorMatrix.SHADER={},$e.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(`
`),$e.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(`
`),$e.brightness=function(ot){const nt=(ot||0)+1;$e.colorMatrix([nt,0,0,0,0,0,nt,0,0,0,0,0,nt,0,0,0,0,0,1,0])},$e.saturation=function(ot){const nt=(ot||0)*2/3+1,et=(nt-1)*-.5;$e.colorMatrix([nt,et,et,0,0,et,nt,et,0,0,et,et,nt,0,0,0,0,0,1,0])},$e.desaturate=function(){$e.saturation(-1)},$e.contrast=function(ot){const nt=(ot||0)+1,et=-128*(nt-1);$e.colorMatrix([nt,0,0,0,et,0,nt,0,0,et,0,0,nt,0,et,0,0,0,1,0])},$e.negative=function(){$e.contrast(-2)},$e.hue=function(ot){ot=(ot||0)/180*Math.PI;const nt=Math.cos(ot),et=Math.sin(ot),Qt=.213,rr=.715,jt=.072;$e.colorMatrix([Qt+nt*(1-Qt)+et*-Qt,rr+nt*-rr+et*-rr,jt+nt*-jt+et*(1-jt),0,0,Qt+nt*-Qt+et*.143,rr+nt*(1-rr)+et*.14,jt+nt*-jt+et*-.283,0,0,Qt+nt*-Qt+et*-(1-Qt),rr+nt*-rr+et*rr,jt+nt*(1-jt)+et*jt,0,0,0,0,0,1,0])},$e.desaturateLuminance=function(){$e.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},$e.sepia=function(){$e.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},$e.brownie=function(){$e.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},$e.vintagePinhole=function(){$e.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},$e.kodachrome=function(){$e.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])},$e.technicolor=function(){$e.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])},$e.polaroid=function(){$e.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},$e.shiftToBGR=function(){$e.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},$e.convolution=function(ot){const nt=new Float32Array(ot),et=1/he,Qt=1/ye,rr=Ze($e.convolution.SHADER);W.uniform1fv(rr.uniform.m,nt),W.uniform2f(rr.uniform.px,et,Qt),It()},$e.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(`
`),$e.detectEdges=function(){$e.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},$e.sobelX=function(){$e.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},$e.sobelY=function(){$e.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},$e.sharpen=function(ot){const nt=ot||1;$e.convolution.call(this,[0,-1*nt,0,-1*nt,1+4*nt,-1*nt,0,-1*nt,0])},$e.emboss=function(ot){const nt=ot||1;$e.convolution.call(this,[-2*nt,-1*nt,0,-1*nt,1,1*nt,0,1*nt,2*nt])},$e.blur=function(ot){const nt=ot/7/he,et=ot/7/ye,Qt=Ze($e.blur.SHADER);W.uniform2f(Qt.uniform.px,0,et),It(mt.INTERMEDIATE),W.uniform2f(Qt.uniform.px,nt,0),It()},$e.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(`
`),$e.pixelate=function(ot){const nt=ot/he,et=ot/ye,Qt=Ze($e.pixelate.SHADER);W.uniform2f(Qt.uniform.size,nt,et),It()},$e.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=we}),Ug=Or(N=>{const i=Vi(),we=Wg();let M=null,V=null;function oe(de,X){let Te;if(de instanceof i.Tensor)Te=i.clone(de);else{const z=de.naturalWidth||de.videoWidth||de.width||de.shape&&de.shape[1]>0,he=de.naturalHeight||de.videoHeight||de.height||de.shape&&de.shape[2]>0;let ye=z,ee=he;X.filter.width>0?ye=X.filter.width:X.filter.height>0&&(ye=z*(X.filter.height/he)),X.filter.height>0?ee=X.filter.height:X.filter.width>0&&(ee=he*(X.filter.width/z)),(!M||M.width!==ye||M.height!==ee)&&(M=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(ye,ee):document.createElement("canvas"),M.width!==ye&&(M.width=ye),M.height!==ee&&(M.height=ee));const w=M.getContext("2d");de instanceof ImageData?w.putImageData(de,0,0):w.drawImage(de,0,0,z,he,0,0,M.width,M.height),X.filter.enabled&&((!this.fx||!V||M.width!==V.width||M.height!==V.height)&&(V=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(M.width,M.height):document.createElement("canvas"),V.width!==M.width&&(V.width=M.width),V.height!==M.height&&(V.height=M.height),this.fx=i.ENV.flags.IS_BROWSER?new we.Canvas({canvas:V}):null),this.fx.reset(),this.fx.addFilter("brightness",X.filter.brightness),X.filter.contrast!==0&&this.fx.addFilter("contrast",X.filter.contrast),X.filter.sharpness!==0&&this.fx.addFilter("sharpen",X.filter.sharpness),X.filter.blur!==0&&this.fx.addFilter("blur",X.filter.blur),X.filter.saturation!==0&&this.fx.addFilter("saturation",X.filter.saturation),X.filter.hue!==0&&this.fx.addFilter("hue",X.filter.hue),X.filter.negative&&this.fx.addFilter("negative"),X.filter.sepia&&this.fx.addFilter("sepia"),X.filter.vintage&&this.fx.addFilter("brownie"),X.filter.sepia&&this.fx.addFilter("sepia"),X.filter.kodachrome&&this.fx.addFilter("kodachrome"),X.filter.technicolor&&this.fx.addFilter("technicolor"),X.filter.polaroid&&this.fx.addFilter("polaroid"),X.filter.pixelate!==0&&this.fx.addFilter("pixelate",X.filter.pixelate),this.fx.apply(M)),V||(V=M);let xe;if(X.backend==="webgl"||V instanceof ImageData)xe=i.browser.fromPixels(V);else{const W=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(ye,ee):document.createElement("canvas");W.width=ye,W.height=ee;const st=W.getContext("2d");st.drawImage(V,0,0);const ut=st.getImageData(0,0,ye,ee);xe=i.browser.fromPixels(ut)}const We=xe.toFloat();Te=We.expandDims(0),xe.dispose(),We.dispose()}return{tensor:Te,canvas:X.filter.return?V:null}}N.process=oe}),Vg=Or(N=>{Zh(N,{default:()=>i});var i={backend:"webgl",console:!0,async:!0,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:15,minConfidence:.1,iouThreshold:.1,scoreThreshold:.2},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/age-ssrnet-imdb.json",inputSize:64,skipFrames:15},gender:{enabled:!0,minConfidence:.1,modelPath:"../models/gender-ssrnet-imdb.json",inputSize:64,skipFrames:15},emotion:{enabled:!0,inputSize:64,minConfidence:.2,skipFrames:15,modelPath:"../models/emotion-large.json"}},body:{enabled:!0,modelPath:"../models/posenet.json",inputResolution:257,outputStride:16,maxDetections:10,scoreThreshold:.8,nmsRadius:20},hand:{enabled:!0,inputSize:256,skipFrames:15,minConfidence:.5,iouThreshold:.2,scoreThreshold:.5,enlargeFactor:1.65,maxHands:10,detector:{modelPath:"../models/handdetect.json"},skeleton:{modelPath:"../models/handskeleton.json"}}}}),Hg=Or((N,i)=>{i.exports={name:"@vladmandic/human",version:"0.7.6",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",chokidar:"^3.4.3",dayjs:"^1.9.5",esbuild:"^0.7.22",eslint:"^7.13.0","eslint-config-airbnb-base":"^14.2.1","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",dev:"npm install && node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation dev-server.js","build-iife":"esbuild --bundle --minify --platform=browser --sourcemap --target=es2018 --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=es2018 --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=es2018 --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=es2018 --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=es2018 --format=cjs --external:@tensorflow --metafile=dist/human.node.json --outfile=dist/human.node-nobundle.js src/human.js","build-demo":"esbuild --bundle --log-level=error --platform=browser --sourcemap --target=es2018 --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 ro=Vi(),Wp=Sg(),vh=Ig(),gh=Ng(),xh=Cg(),Up=Dg(),Vp=Pg(),Hp=Bg(),Gg=Ug(),jg=Qh(),qg=Vg().default,Kg=Hg(),Xg={face:{detector:{skipFrames:0},age:{skipFrames:0},gender:{skipFrames:0},emotion:{skipFrames:0}},hand:{skipFrames:0}},wa=()=>typeof performance!="undefined"?performance.now():parseInt(Number(process.hrtime.bigint())/1e3/1e3);function $h(...N){const i=we=>we&&typeof we=="object";return N.reduce((we,M)=>(Object.keys(M||{}).forEach(V=>{const oe=we[V],de=M[V];Array.isArray(oe)&&Array.isArray(de)?we[V]=oe.concat(...de):i(oe)&&i(de)?we[V]=$h(oe,de):we[V]=de}),we),{})}class wf{constructor(){this.tf=ro,this.version=Kg.version,this.config=qg,this.fx=null,this.state="idle",this.numTensors=0,this.analyzeMemoryLeaks=!1,this.checkSanity=!1,this.firstRun=!0,this.perf={},this.models={facemesh:null,posenet:null,handpose:null,iris:null,age:null,gender:null,emotion:null},this.facemesh=Wp,this.age=vh,this.gender=gh,this.emotion=xh,this.body=Up,this.hand=Vp}log(...N){N&&this.config.console&&console.log("Human:",...N)}profile(){return this.config.profile?jg.data:{}}analyze(...N){if(!this.analyzeMemoryLeaks)return;const i=ro.engine().state.numTensors,we=this.numTensors;this.numTensors=i;const M=i-we;M!==0&&this.log(...N,M)}sanity(N){if(!this.checkSanity)return null;if(!N)return"input is not defined";if(ro.ENV.flags.IS_NODE&&!(N instanceof ro.Tensor))return"input must be a tensor";try{ro.getBackend()}catch(i){return"backend not loaded"}return null}async load(N){this.state="load";const i=wa();N&&(this.config=$h(this.config,N)),this.firstRun&&(this.checkBackend(!0),this.log(`version: ${this.version} TensorFlow/JS version: ${ro.version_core}`),this.log("configuration:",this.config),this.log("flags:",ro.ENV.flags),this.firstRun=!1),this.config.async?[this.models.age,this.models.gender,this.models.emotion,this.models.facemesh,this.models.posenet,this.models.handpose]=await Promise.all([this.models.age||vh.load(this.config),this.models.gender||gh.load(this.config),this.models.emotion||xh.load(this.config),this.models.facemesh||Wp.load(this.config.face),this.models.posenet||Up.load(this.config.body),this.models.handpose||Vp.load(this.config.hand)]):(this.config.face.enabled&&!this.models.facemesh&&(this.models.facemesh=await Wp.load(this.config.face)),this.config.body.enabled&&!this.models.posenet&&(this.models.posenet=await Up.load(this.config.body)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await Vp.load(this.config.hand)),this.config.face.enabled&&this.config.face.age.enabled&&!this.models.age&&(this.models.age=await vh.load(this.config)),this.config.face.enabled&&this.config.face.gender.enabled&&!this.models.gender&&(this.models.gender=await gh.load(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await xh.load(this.config)));const we=Math.trunc(wa()-i);we>(this.perf.load||0)&&(this.perf.load=we)}async checkBackend(N){const i=wa();(N||ro.getBackend()!==this.config.backend)&&(this.state="backend",this.log("setting backend:",this.config.backend),await ro.setBackend(this.config.backend),ro.enableProdMode(),this.config.deallocate&&this.config.backend==="webgl"&&(this.log("Changing WebGL: WEBGL_DELETE_TEXTURE_THRESHOLD:",this.config.deallocate),ro.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",this.config.deallocate?0:-1)),ro.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0),await ro.ready());const we=Math.trunc(wa()-i);we>(this.perf.backend||0)&&(this.perf.backend=we)}async detectFace(N){let i,we,M,V;const oe=[];this.state="run:face",i=wa();const de=await this.models.facemesh.estimateFaces(N,this.config.face);this.perf.face=Math.trunc(wa()-i);for(const X of de){if(this.analyze("Get Face"),!X.image||X.image.isDisposedInternal){this.log("Face object is disposed:",X.image);continue}this.analyze("Start Age:"),this.config.async?we=this.config.face.age.enabled?vh.predict(X.image,this.config):{}:(this.state="run:age",i=wa(),we=this.config.face.age.enabled?await vh.predict(X.image,this.config):{},this.perf.age=Math.trunc(wa()-i)),this.analyze("Start Gender:"),this.config.async?M=this.config.face.gender.enabled?gh.predict(X.image,this.config):{}:(this.state="run:gender",i=wa(),M=this.config.face.gender.enabled?await gh.predict(X.image,this.config):{},this.perf.gender=Math.trunc(wa()-i)),this.analyze("Start Emotion:"),this.config.async?V=this.config.face.emotion.enabled?xh.predict(X.image,this.config):{}:(this.state="run:emotion",i=wa(),V=this.config.face.emotion.enabled?await xh.predict(X.image,this.config):{},this.perf.emotion=Math.trunc(wa()-i)),this.analyze("End Emotion:"),this.config.async&&([we,M,V]=await Promise.all([we,M,V])),this.analyze("Finish Face:"),X.image.dispose();const Te=X.annotations.leftEyeIris&&X.annotations.rightEyeIris?Math.max(X.annotations.leftEyeIris[3][0]-X.annotations.leftEyeIris[1][0],X.annotations.rightEyeIris[3][0]-X.annotations.rightEyeIris[1][0]):0;oe.push({confidence:X.confidence,box:X.box,mesh:X.mesh,annotations:X.annotations,age:we.age,gender:M.gender,genderConfidence:M.confidence,emotion:V,iris:Te!==0?Math.trunc(100*11.7/Te)/100:0}),this.analyze("End Face")}return this.analyze("End FaceMesh:"),this.config.async&&(this.perf.face&&delete this.perf.face,this.perf.age&&delete this.perf.age,this.perf.gender&&delete this.perf.gender,this.perf.emotion&&delete this.perf.emotion),oe}async detect(N,i={}){this.state="config";let we;this.config=$h(this.config,i),this.config.videoOptimized||(this.config=$h(this.config,Xg)),this.state="check";const M=this.sanity(N);return M?(this.log(M,N),{error:M}):new Promise(async V=>{let oe,de,X;const Te=wa();await this.checkBackend(),await this.load(),this.config.scoped&&ro.engine().startScope(),this.analyze("Start Scope:"),we=wa();const z=Gg.process(N,this.config);this.perf.image=Math.trunc(wa()-we),this.analyze("Get Image:"),this.config.async?(X=this.config.face.enabled?this.detectFace(z.tensor):[],this.perf.face&&delete this.perf.face):(this.state="run:face",we=wa(),X=this.config.face.enabled?await this.detectFace(z.tensor):[],this.perf.face=Math.trunc(wa()-we)),this.analyze("Start Body:"),this.config.async?(oe=this.config.body.enabled?this.models.posenet.estimatePoses(z.tensor,this.config.body):[],this.perf.body&&delete this.perf.body):(this.state="run:body",we=wa(),oe=this.config.body.enabled?await this.models.posenet.estimatePoses(z.tensor,this.config.body):[],this.perf.body=Math.trunc(wa()-we)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(de=this.config.hand.enabled?this.models.handpose.estimateHands(z.tensor,this.config.hand):[],this.perf.hand&&delete this.perf.hand):(this.state="run:hand",we=wa(),de=this.config.hand.enabled?await this.models.handpose.estimateHands(z.tensor,this.config.hand):[],this.perf.hand=Math.trunc(wa()-we)),this.config.async&&([X,oe,de]=await Promise.all([X,oe,de])),z.tensor.dispose(),this.config.scoped&&ro.engine().endScope(),this.analyze("End Scope:");let he=[];this.config.gesture.enabled&&(we=wa(),he={body:Hp.body(oe),hand:Hp.hand(de),face:Hp.face(X)},this.config.async?this.perf.gesture&&delete this.perf.gesture:this.perf.gesture=Math.trunc(wa()-we)),this.perf.total=Math.trunc(wa()-Te),this.state="idle",V({face:X,body:oe,hand:de,gesture:he,performance:this.perf,canvas:z.canvas})})}}async function Yg(N,i,we){if(!N)return;const M=i.getContext("2d");M.font=we.baseFont,M.fillStyle=we.baseLabel;let V=1;for(const[oe,de]of Object.entries(N))if(de.length>0){const X=`${oe}: ${de.join(", ")}`;M.fillText(X,6,V*(we.baseLineHeight+24)),V+=1}}async function Zg(N,i,we,M){if(!N)return;const V=i.getContext("2d");for(const oe of N){V.font=we.baseFont,V.strokeStyle=we.baseColor,V.fillStyle=we.baseColor,V.lineWidth=we.baseLineWidth,V.beginPath(),we.drawBoxes&&V.rect(oe.box[0],oe.box[1],oe.box[2],oe.box[3]);const de=[];if(oe.genderConfidence&&de.push(`${Math.trunc(100*oe.genderConfidence)}% ${oe.gender||""}`),oe.age&&de.push(`age: ${oe.age||""}`),oe.iris&&de.push(`iris: ${oe.iris}`),oe.emotion&&oe.emotion.length>0){const X=oe.emotion.map(Te=>`${Math.trunc(100*Te.score)}% ${Te.emotion}`);de.push(X.join(" "))}V.fillStyle=we.baseLabel;for(const X in de)V.fillText(de[X],oe.box[0]+8,oe.box[1]+24+(X+1)*we.baseLineHeight);if(V.stroke(),V.lineWidth=1,oe.mesh){if(we.drawPoints)for(const X of oe.mesh)V.fillStyle=we.useDepth?`rgba(${127.5+2*X[2]}, ${127.5-2*X[2]}, 255, 0.5)`:we.baseColor,V.beginPath(),V.arc(X[0],X[1],2,0,2*Math.PI),V.fill();if(we.drawPolygons)for(let X=0;X<M.length/3;X++){const Te=[M[X*3+0],M[X*3+1],M[X*3+2]].map(he=>oe.mesh[he]),z=new Path2D;z.moveTo(Te[0][0],Te[0][1]);for(const he of Te)z.lineTo(he[0],he[1]);z.closePath(),V.strokeStyle=we.useDepth?`rgba(${127.5+2*Te[0][2]}, ${127.5-2*Te[0][2]}, 255, 0.3)`:we.baseColor,V.stroke(z),we.fillPolygons&&(V.fillStyle=we.useDepth?`rgba(${127.5+2*Te[0][2]}, ${127.5-2*Te[0][2]}, 255, 0.3)`:we.baseColor,V.fill(z))}}}}async function Qg(N,i,we){if(!N)return;const M=i.getContext("2d");M.lineJoin="round";for(const V of N){if(M.fillStyle=we.baseColor,M.strokeStyle=we.baseColor,M.font=we.baseFont,M.lineWidth=we.baseLineWidth,we.drawPoints)for(const oe of V.keypoints)M.beginPath(),M.arc(oe.position.x,oe.position.y,2,0,2*Math.PI),M.fill();if(we.drawPolygons){const oe=new Path2D;let de;de=V.keypoints.find(X=>X.part==="leftShoulder"),oe.moveTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightShoulder"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightHip"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftHip"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftShoulder"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftHip"),oe.moveTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftKnee"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftAnkle"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightHip"),oe.moveTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightKnee"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightAnkle"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightShoulder"),oe.moveTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftShoulder"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftElbow"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftWrist"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="leftShoulder"),oe.moveTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightShoulder"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightElbow"),oe.lineTo(de.position.x,de.position.y),de=V.keypoints.find(X=>X.part==="rightWrist"),oe.lineTo(de.position.x,de.position.y),M.stroke(oe)}}}async function Jg(N,i,we){if(!N)return;const M=i.getContext("2d");M.lineJoin="round";for(const V of N){if(M.font=we.baseFont,M.lineWidth=we.baseLineWidth,we.drawBoxes&&(M.lineWidth=we.baseLineWidth,M.beginPath(),M.strokeStyle=we.baseColor,M.fillStyle=we.baseColor,M.rect(V.box[0],V.box[1],V.box[2],V.box[3]),M.fillStyle=we.baseLabel,M.fillText("hand",V.box[0]+2,V.box[1]+22,V.box[2]),M.stroke()),we.drawPoints&&(V.landmarks&&V.landmarks.length>0))for(const oe of V.landmarks)M.fillStyle=we.useDepth?`rgba(${127.5+2*oe[2]}, ${127.5-2*oe[2]}, 255, 0.5)`:we.baseColor,M.beginPath(),M.arc(oe[0],oe[1],2,0,2*Math.PI),M.fill();if(we.drawPolygons){const oe=de=>{if(!de)return;for(let X=0;X<de.length;X++)M.lineWidth=we.baseLineWidth,M.beginPath(),M.strokeStyle=we.useDepth?`rgba(${127.5+2*de[X][2]}, ${127.5-2*de[X][2]}, 255, 0.5)`:we.baseColor,M.moveTo(de[X>0?X-1:0][0],de[X>0?X-1:0][1]),M.lineTo(de[X][0],de[X][1]),M.stroke()};oe(V.annotations.indexFinger),oe(V.annotations.middleFinger),oe(V.annotations.ringFinger),oe(V.annotations.pinky),oe(V.annotations.thumb)}}}const $g={face:Zg,body:Qg,hand:Jg,gesture:Yg};var _h=$g;let wh=0,bf=!1,Ra={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(bf)return;const N=`
:root { --rounded: 0.2rem; }
.menu { position: absolute; 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: ${Ra.background}; border-radius: var(--rounded); border-color: black; border-style: solid; border-width: thin; }
.menu:hover { box-shadow: 0 0 8px ${Ra.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: ${Ra.itemBackground}; color: ${Ra.itemColor}; border: none; padding: 0.2rem; font-family: inherit; font-variant: inherit; border-radius: var(--rounded); font-weight: 800; }
.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: ${Ra.buttonBackground}; width: -webkit-fill-available; padding: 8px; margin: 8px 0 8px 0; cursor: pointer; box-shadow: 4px 4px 4px 0 dimgrey;
border-radius: var(--rounded); justify-content: center; font-family: inherit; font-variant: inherit; font-size: 1rem; font-weight: 800; }
.menu-button:hover { background: ${Ra.buttonHover}; box-shadow: 4px 4px 4px 0 black; }
.menu-button:focus { outline: none; }
.menu-checkbox { width: 2.8rem; height: 1rem; background: ${Ra.itemBackground}; margin: 0.5rem 0.8rem 0 0; position: relative; border-radius: var(--rounded); }
.menu-checkbox:after { content: 'OFF'; color: ${Ra.checkboxOff}; position: absolute; right: 0.2rem; top: -0.4rem; font-weight: 800; font-size: 0.5rem; }
.menu-checkbox:before { content: 'ON'; color: ${Ra.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: ${Ra.checkboxOff}; border-radius: var(--rounded); transition: left 0.6s ease; }
input[type=checkbox] { visibility: hidden; }
input[type=checkbox]:checked + label { left: 1.4rem; background: ${Ra.checkboxOn}; }
.menu-range { margin: 0 0.8rem 0 0; width: 5rem; background: transparent; color: ${Ra.rangeBackground}; }
.menu-range:before { content: attr(value); color: ${Ra.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: ${Ra.itemBackground}; border-radius: var(--rounded); border: 1px; }
input[type=range]::-webkit-slider-thumb { border: 1px solid #000000; margin-top: 0.05rem; height: 0.9rem; width: 1.5rem; border-radius: var(--rounded); background: ${Ra.rangeBackground}; cursor: pointer; -webkit-appearance: none; }
`,i=document.createElement("style");i.innerHTML=N,document.getElementsByTagName("head")[0].appendChild(i),bf=!0}class tx{constructor(N,i,we,M){M&&(Ra={...Ra,...M}),ex(),this.createMenu(N,i,we),this.id=0,this.instance=wh,wh++,this._maxFPS=0,this.hidden=0}createMenu(N,i="",we={top:null,left:null,bottom:null,right:null}){if(this.menu=document.createElement("div"),this.menu.id=`menu-${wh}`,this.menu.className="menu",we&&(we.top&&(this.menu.style.top=we.top),we.bottom&&(this.menu.style.bottom=we.bottom),we.left&&(this.menu.style.left=we.left),we.right&&(this.menu.style.right=we.right)),this.container=document.createElement("div"),this.container.id=`menu-container-${wh}`,this.container.className="menu-container menu-container-fadein",i!==""){const M=document.createElement("div");M.className="menu-title",M.id=`menu-title-${wh}`,M.innerHTML=i,this.menu.appendChild(M),M.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),we=N.y||(N.touches&&N.touches[0]?N.touches[0].pageY:null);i&&(this.menu.style.left=`${i-105}px`),we&&(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 we=document.getElementsByClassName("menu");for(const M of we)M.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,we,M){const V=document.createElement("div");return V.className="menu-item",V.innerHTML=`<div class="menu-checkbox"><input class="menu-checkbox" type="checkbox" id="${this.newID}" ${i[we]?"checked":""}/><label class="menu-checkbox-label" for="${this.ID}"></label></div>${N}`,this.container.appendChild(V),V.addEventListener("change",oe=>{i[we]=oe.target.checked,M&&M(oe.target.checked)}),V}async addList(N,i,we,M){const V=document.createElement("div");V.className="menu-item";let oe="";for(const de of i){const X=de===we?"selected":"";oe+=`<option value="${de}" ${X}>${de}</option>`}return V.innerHTML=`<div class="menu-list"><select name="${this.ID}" class="menu-list-item">${oe}</select><label for="${this.ID}"></label></div>${N}`,V.style.fontFamily=document.body.style.fontFamily,V.style.fontSize=document.body.style.fontSize,V.style.fontVariant=document.body.style.fontVariant,this.container.appendChild(V),V.addEventListener("change",de=>{M&&M(i[de.target.selectedIndex])}),V}addRange(N,i,we,M,V,oe,de){const X=document.createElement("div");return X.className="menu-item",X.innerHTML=`<input class="menu-range" type="range" id="${this.newID}" min="${M}" max="${V}" step="${oe}" value="${i[we]}">${N}`,this.container.appendChild(X),X.addEventListener("change",Te=>{i[we]=parseInt(Te.target.value)===parseFloat(Te.target.value)?parseInt(Te.target.value):parseFloat(Te.target.value),Te.target.setAttribute("value",Te.target.value),de&&de(Te.target.value)}),X}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,we){const M=document.createElement("button");return M.className="menu-item menu-button",M.style.fontFamily=document.body.style.fontFamily,M.style.fontSize=document.body.style.fontSize,M.style.fontVariant=document.body.style.fontVariant,M.type="button",M.id=this.newID,M.innerText=N,this.container.appendChild(M),M.addEventListener("click",()=>{M.innerText===N?M.innerText=i:M.innerText=N,we&&we(M.innerText!==N)}),M}addValue(N,i,we=""){const M=document.createElement("div");return M.className="menu-item",M.id=`menu-val-${N}`,M.innerText=`${N}: ${i}${we}`,this.container.appendChild(M),M}updateValue(N,i,we=""){const M=document.getElementById(`menu-val-${N}`);M?M.innerText=`${N}: ${i}${we}`:this.addValue(N,i)}addChart(N,i,we=200,M=40,V){V&&(Ra.chartColor=V);const oe=document.createElement("div");return oe.className="menu-item menu-chart-title",oe.id=this.newID,oe.innerHTML=`<font color=${Ra.chartColor}>${N}</font><canvas id="menu-canvas-${i}" class="menu-chart-canvas" width="${we}px" height="${M}px"></canvas>`,this.container.appendChild(oe),oe}async updateChart(N,i){if(!i||i.length===0)return;const we=document.getElementById(`menu-canvas-${N}`);if(!we)return;const M=we.getContext("2d");M.fillStyle=Ra.background,M.fillRect(0,0,we.width,we.height);const V=we.width/i.length,oe=1+Math.max(...i),de=we.height/oe;for(const X in i){const Te=M.createLinearGradient(0,(oe-i[X])*de,0,0);Te.addColorStop(.1,Ra.chartColor),Te.addColorStop(.4,Ra.background),M.fillStyle=Te,M.fillRect(X*V,0,V-4,we.height),M.fillStyle=Ra.background,M.font=`${V/1.5}px "Segoe UI"`,M.fillText(Math.round(i[X]),X*V+1,we.height-1,V-1)}}}var Gp=tx;const tr=new wf,Nn={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:12,baseLineHeightProto:2,columns:2,busy:!1,facing:!0,useWorker:!1,worker:"demo/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};let Pn,ea,uc,jp,bh={};const yl=[];function rx(...N){if(!Array.isArray(N))return N;let i="";for(const we of N)typeof we=="object"?i+=JSON.stringify(we).replace(/{|}|"|\[|\]/g,"").replace(/,/g,", "):i+=we;return i}const Ko=(...N)=>{Nn.console&&console.log(...N)},Xo=N=>{document.getElementById("status").innerText=N};function Kp(N,i,we){yl.push(1e3/(performance.now()-jp)),yl.length>Nn.maxFrames&&yl.shift(),N.srcObject&&requestAnimationFrame(()=>qp(N,we)),Pn.updateChart("FPS",yl);const M=we.getContext("2d");M.fillStyle=Nn.baseBackground,M.fillRect(0,0,we.width,we.height),i.canvas?(i.canvas.width!==we.width&&(we.width=i.canvas.width),i.canvas.height!==we.height&&(we.height=i.canvas.height),M.drawImage(i.canvas,0,0,i.canvas.width,i.canvas.height,0,0,i.canvas.width,i.canvas.height)):M.drawImage(N,0,0,N.width,N.height,0,0,we.width,we.height),_h.face(i.face,we,Nn,tr.facemesh.triangulation),_h.body(i.body,we,Nn),_h.hand(i.hand,we,Nn),_h.gesture(i.gesture,we,Nn);const V=tr.tf.engine(),oe=V.backendInstance?`gpu: ${(V.backendInstance.numBytesInGPU?V.backendInstance.numBytesInGPU:0).toLocaleString()} bytes`:"",de=`system: ${V.state.numBytes.toLocaleString()} bytes ${oe} | tensors: ${V.state.numTensors.toLocaleString()}`,X=i.canvas?`processing: ${i.canvas.width} x ${i.canvas.height}`:"",Te=Math.trunc(10*yl.reduce((z,he)=>z+he)/yl.length)/10;document.getElementById("log").innerText=`
video: ${bh.name} | facing: ${bh.facing} | resolution: ${bh.width} x ${bh.height} ${X}
backend: ${tr.tf.getBackend()} | ${de}
performance: ${rx(i.performance)} FPS:${Te}
`}async function Xp(){if(Nn.busy)return null;Nn.busy=!0;const N=document.getElementById("video"),i=document.getElementById("canvas"),we=document.getElementById("log"),M=N.srcObject?N.srcObject.getVideoTracks()[0].readyState==="live"&&N.readyState>2&&!N.paused:!1;let V="";if(Xo("setting up camera"),!navigator.mediaDevices)return V="camera access not supported",we.innerText+=`
${V}`,Ko(V),Xo(V),null;let oe;const de={audio:!1,video:{facingMode:Nn.facing?"user":"environment",resizeMode:"none",width:{ideal:window.innerWidth},height:{ideal:window.innerHeight}}};try{oe=await navigator.mediaDevices.getUserMedia(de)}catch(z){z.name==="PermissionDeniedError"?V="camera permission denied":z.name==="SourceUnavailableError"?V="camera not available":V="camera error",we.innerText+=`
${V}`,Xo(V),Ko(z)}if(oe)N.srcObject=oe;else return null;const X=oe.getVideoTracks()[0],Te=X.getSettings();return Ko("camera constraints:",de,"window:",{width:window.innerWidth,height:window.innerHeight},"settings:",Te,"track:",X),bh={name:X.label,width:Te.width,height:Te.height,facing:Te.facingMode==="user"?"front":"back"},new Promise(z=>{N.onloadeddata=async()=>{N.width=N.videoWidth,N.height=N.videoHeight,i.width=N.width,i.height=N.height,i.style.width=i.width>i.height?"100vw":"",i.style.height=i.width>i.height?"":"100vh";const he=14+6*i.width/window.innerWidth;Nn.baseFont=Nn.baseFontProto.replace(/{size}/,`${he}px`),M&&N.play(),Nn.busy=!1,Xo(""),z(N)}})}function nx(N,i,we){uc||(Ko("creating worker thread"),uc=new Worker(Nn.worker,{type:"module"}),uc.warned=!1,uc.addEventListener("message",M=>{uc.warned||(Ko("warning: cannot transfer canvas from worked thread"),Ko("warning: image will not show filter effects"),uc.warned=!0),Kp(N,M.data.result,we)})),uc.postMessage({image:i.data.buffer,width:we.width,height:we.height},[i.data.buffer])}function qp(N,i){var M;jp=performance.now();const we=N.srcObject&&N.srcObject.getVideoTracks()[0].readyState==="live"&&N.readyState>2&&!N.paused;if(!we&&N.srcObject){N.srcObject.getVideoTracks()[0].readyState==="live"&&N.readyState<=2?setTimeout(()=>qp(N,i),500):Ko(`camera not ready: track state: ${(M=N.srcObject)==null?void 0:M.getVideoTracks()[0].readyState} stream state: ${N.readyState}`);return}if(Xo(""),Nn.useWorker){const V=new OffscreenCanvas(i.width,i.height),oe=V.getContext("2d");oe.drawImage(N,0,0,N.width,N.height,0,0,i.width,i.height);const de=oe.getImageData(0,0,i.width,i.height);nx(N,de,i)}else tr.detect(N).then(V=>{V.error?Ko(V.error):Kp(N,V,i),tr.config.profile&&Ko("profile data:",tr.profile())})}async function ax(N){return jp=performance.now(),new Promise(i=>{const we=new Image;we.onload=async()=>{Ko("Processing image:",we.src);const M=document.getElementById("canvas");we.width=we.naturalWidth,we.height=we.naturalHeight,M.width=tr.config.filter.width&&tr.config.filter.width>0?tr.config.filter.width:we.naturalWidth,M.height=tr.config.filter.height&&tr.config.filter.height>0?tr.config.filter.height:we.naturalHeight;const V=await tr.detect(we);Kp(we,V,M);const oe=document.createElement("canvas");oe.className="thumbnail",oe.width=window.innerWidth/(Nn.columns+.1),oe.height=M.height/(window.innerWidth/oe.width);const de=oe.getContext("2d");de.drawImage(M,0,0,M.width,M.height,0,0,oe.width,oe.height),document.getElementById("samples-container").appendChild(oe),we.src="",i(!0)},we.src=N})}async function ix(){tr.config.videoOptimized=!0,document.getElementById("samples-container").style.display="none",document.getElementById("canvas").style.display="block";const N=document.getElementById("video"),i=document.getElementById("canvas");Nn.baseLineHeight=Nn.baseLineHeightProto,N.srcObject!==null&&!N.paused?(document.getElementById("play").style.display="block",Xo("paused"),N.pause()):(await Xp(),document.getElementById("play").style.display="none",Xo(""),N.play()),qp(N,i)}async function ox(){document.getElementById("play").style.display="none",tr.config.videoOptimized=!1;const N=12+Math.trunc(12*Nn.columns*window.innerWidth/document.body.clientWidth);Nn.baseFont=Nn.baseFontProto.replace(/{size}/,`${N}px`),Nn.baseLineHeight=Nn.baseLineHeightProto*Nn.columns,document.getElementById("canvas").style.display="none",document.getElementById("samples-container").style.display="block",Ko("Running detection of sample images"),Xo("processing images"),document.getElementById("samples-container").innerHTML="";for(const i of Nn.samples)await ax(i);Xo("")}function sx(){Pn=new Gp(document.body,"...",{top:"1rem",right:"1rem"});const N=Pn.addButton("start video","pause video",()=>ix());Pn.addButton("process images","process images",()=>ox()),document.getElementById("play").addEventListener("click",()=>N.click()),Pn.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),Pn.addList("Backend",["cpu","webgl","wasm","webgpu"],tr.config.backend,i=>tr.config.backend=i),Pn.addBool("Async Operations",tr.config,"async",i=>tr.config.async=i),Pn.addBool("Enable Profiler",tr.config,"profile",i=>tr.config.profile=i),Pn.addBool("Memory Shield",tr.config,"deallocate",i=>tr.config.deallocate=i),Pn.addBool("Use Web Worker",Nn,"useWorker"),Pn.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),Pn.addLabel("Enabled Models"),Pn.addBool("Face Detect",tr.config.face,"enabled"),Pn.addBool("Face Mesh",tr.config.face.mesh,"enabled"),Pn.addBool("Face Iris",tr.config.face.iris,"enabled"),Pn.addBool("Face Age",tr.config.face.age,"enabled"),Pn.addBool("Face Gender",tr.config.face.gender,"enabled"),Pn.addBool("Face Emotion",tr.config.face.emotion,"enabled"),Pn.addBool("Body Pose",tr.config.body,"enabled"),Pn.addBool("Hand Pose",tr.config.hand,"enabled"),Pn.addBool("Gesture Analysis",tr.config.gesture,"enabled"),Pn.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),Pn.addLabel("Model Parameters"),Pn.addRange("Max Objects",tr.config.face.detector,"maxFaces",1,50,1,i=>{tr.config.face.detector.maxFaces=parseInt(i),tr.config.body.maxDetections=parseInt(i),tr.config.hand.maxHands=parseInt(i)}),Pn.addRange("Skip Frames",tr.config.face.detector,"skipFrames",0,50,1,i=>{tr.config.face.detector.skipFrames=parseInt(i),tr.config.face.emotion.skipFrames=parseInt(i),tr.config.face.age.skipFrames=parseInt(i),tr.config.hand.skipFrames=parseInt(i)}),Pn.addRange("Min Confidence",tr.config.face.detector,"minConfidence",0,1,.05,i=>{tr.config.face.detector.minConfidence=parseFloat(i),tr.config.face.gender.minConfidence=parseFloat(i),tr.config.face.emotion.minConfidence=parseFloat(i),tr.config.hand.minConfidence=parseFloat(i)}),Pn.addRange("Score Threshold",tr.config.face.detector,"scoreThreshold",.1,1,.05,i=>{tr.config.face.detector.scoreThreshold=parseFloat(i),tr.config.hand.scoreThreshold=parseFloat(i),tr.config.body.scoreThreshold=parseFloat(i)}),Pn.addRange("IOU Threshold",tr.config.face.detector,"iouThreshold",.1,1,.05,i=>{tr.config.face.detector.iouThreshold=parseFloat(i),tr.config.hand.iouThreshold=parseFloat(i)}),Pn.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),Pn.addChart("FPS","FPS"),ea=new Gp(document.body,"...",{top:"1rem",right:"18rem"}),ea.addLabel("UI Options"),ea.addBool("Camera Front/Back",Nn,"facing",()=>Xp()),ea.addBool("Use 3D Depth",Nn,"useDepth"),ea.addBool("Draw Boxes",Nn,"drawBoxes"),ea.addBool("Draw Points",Nn,"drawPoints"),ea.addBool("Draw Polygons",Nn,"drawPolygons"),ea.addBool("Fill Polygons",Nn,"fillPolygons"),ea.addHTML('<hr style="min-width: 200px; border-style: inset; border-color: dimgray">'),ea.addLabel("Image Processing"),ea.addBool("Enabled",tr.config.filter,"enabled"),ea.addRange("Image width",tr.config.filter,"width",0,3840,10,i=>tr.config.filter.width=parseInt(i)),ea.addRange("Image height",tr.config.filter,"height",0,2160,10,i=>tr.config.filter.height=parseInt(i)),ea.addRange("Brightness",tr.config.filter,"brightness",-1,1,.05,i=>tr.config.filter.brightness=parseFloat(i)),ea.addRange("Contrast",tr.config.filter,"contrast",-1,1,.05,i=>tr.config.filter.contrast=parseFloat(i)),ea.addRange("Sharpness",tr.config.filter,"sharpness",0,1,.05,i=>tr.config.filter.sharpness=parseFloat(i)),ea.addRange("Blur",tr.config.filter,"blur",0,20,1,i=>tr.config.filter.blur=parseInt(i)),ea.addRange("Saturation",tr.config.filter,"saturation",-1,1,.05,i=>tr.config.filter.saturation=parseFloat(i)),ea.addRange("Hue",tr.config.filter,"hue",0,360,5,i=>tr.config.filter.hue=parseInt(i)),ea.addRange("Pixelate",tr.config.filter,"pixelate",0,32,1,i=>tr.config.filter.pixelate=parseInt(i)),ea.addBool("Negative",tr.config.filter,"negative"),ea.addBool("Sepia",tr.config.filter,"sepia"),ea.addBool("Vintage",tr.config.filter,"vintage"),ea.addBool("Kodachrome",tr.config.filter,"kodachrome"),ea.addBool("Technicolor",tr.config.filter,"technicolor"),ea.addBool("Polaroid",tr.config.filter,"polaroid")}async function ux(){if(Ko("Human: demo starting ..."),sx(),document.getElementById("log").innerText=`Human: version ${tr.version} TensorFlow/JS: version ${tr.tf.version_core}`,Nn.modelsPreload&&(Xo("loading"),await tr.load()),Nn.modelsWarmup){Xo("initializing");const N=new ImageData(50,50);await tr.detect(N)}Xo("human: ready"),document.getElementById("loader").style.display="none",document.getElementById("play").style.display="block"}window.onload=ux;window.onresize=Xp;
/*! *****************************************************************************
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