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]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=n){c();return}setTimeout(y,v)};y()})}function rr(t,e){for(var n=1,a=-1,c=0;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&&av)&&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=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=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;c0?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=0;d--)for(var y=t[d],v=y.inputs,B=0;B=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;Cse){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=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;C0)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 d0&&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;d0,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;B0,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=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>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;B0,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 n0,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;Nt0,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;_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&&d0&&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 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;He4||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;B1)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;d1?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.rank1?e.shape[a-1]:1,d=n.length,y=1,v=c;v0;)t&1&&e.push(n),t/=2,n++;return e}function Wc(t,e,n){for(var a=[],c=0;c0){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-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-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;F0?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<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;c1){a=c;break}for(var c=a+1;c0||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=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;Fn)}function ju(t,e,n){for(var a=0;an)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=0&&e=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.lengthn.rank){for(var c=n.shape.slice();c.length=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;c1&&y===1&&a.unshift(d)}return a}function ti(t,e){for(var n=[],a=0;a1)&&n.unshift(d)}return n}function pa(t,e){for(var n=[],a=Math.max(t.length,e.length),c=0;ce||a===t?n=!0:a=cn(t,a+1);return a}function Yf(t,e,n){for(var a=[],c=t.length,d=0;d0,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;y2)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>>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>>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>>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;U0;--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>>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>>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=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=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(),d1;if(y||v||_)return Xs([0],a);var C=Math.abs(Math.ceil((e-t)/n)),F=fa(C,a);e0?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&&en){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;v0,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&&e0,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;C2)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=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;d1,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;U0&&(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=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>>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;Fc&&C.push({score:e[F],boxIndex:F,suppressBeginIndex:0});C.sort($d);for(var B=d>0?-.5/d:0,U=[],J=[];U.length0;){var me=C.pop(),Le=me.score,Me=me.boxIndex,He=me.suppressBeginIndex;if(Le=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;c0)for(var B=0;B=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=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;d0&&(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;v1&&_.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;B0?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;U0&&(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{"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;r0&&b[b.length-1])&&(Z[0]===6||Z[0]===2)){r=0;continue}if(Z[0]===3&&(!b||Z[1]>b[0]&&Z[1]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=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;T0){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= 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;r1)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=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;je0&&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;o0)&&(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;b0?[4,Promise.all(u)]:[3,2];case 1:for(O=Z.sent(),q=0;q=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);res&&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;r1||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;q0&&(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;T0&&r.indexOf(q)===-1)continue;for(var Z=0;Zo.maxNumTensors&&(o.maxNumTensors=Ft),Ft0,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;T0;){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;Be1 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=0;)gi.splice(gi.indexOf(Ci),1);Yt.push(Ci)},vr=[],hr=[],Ir=0,zr=o.outputs;IrCs?1:0});for(var qs=0,Zu=Ui;qs0)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;o0)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;T1)for(var le=0,Ne=Z;le0){for(var vt=[],pt=0;pt0&&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;je0&&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;Z0&&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.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;Sr0)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;$t0&&i.dispose(Sr)},$t=0;$t0&&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=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;Kn0))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;r0)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;q1)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=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;h1)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;T1&&(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;Sr0){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;ct0&&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 je0)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;Be1){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;qe1&&qe1)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;O1)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 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.length1&&(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;ct1?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;01){for(var T=[0],O=2;O1)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;q1){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;h1)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);T3||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;qo){T=h-o;for(var O=[],q=0;q0){var Be=void 0;o>h?Be=o+h-3:Be=o-1;for(var je=[],q=Be;q3||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=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=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=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;Beu}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;k0&&be[be.length-1])&&(ft[0]===6||ft[0]===2)){k=0;continue}if(ft[0]===3&&(!be||ft[1]>be[0]&&ft[1]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;x0?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=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.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;Ltthis.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;Lt1)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;Zt0?(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]>>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>>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>>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;Mt0;--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>>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>>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=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=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++ 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.length0?[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 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 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 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.sizeY?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;ne1}),i.util.assert(re.length===0,function(){return"Duplicate column names found: "+re.toString()}),this.columnConfigs){for(Ue=0,kt=Object.keys(this.columnConfigs);Ue14||!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 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>>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>>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>>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;w0;--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>>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>>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=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{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]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;ceOe&&(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;geH?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=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=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;cepr?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.outDepth||Math.floor(Rt)!==Rt)continue;for(var wt=0;wt=A.outHeight||Math.floor(Et)!==Et)continue;for(var Vt=0;Vt=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=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.outDepth||Math.floor(Ot)!==Ot)continue;for(var Rt=0;Rt=H.outHeight||Math.floor(wt)!==wt)continue;for(var Et=0;Et=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;at1?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;$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;at1?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=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=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=0&&te[_e]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=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;Ht1?_t*(fe-1)+Ht*Tt:.5*(_t+zt)*(fe-1);if(Ot<0||Ot>fe-1){for(var Rt=0;Rt1?At*(ve-1)+Rt*Xt:.5*(At+Pt)*(ve-1);if(ir<0||ir>ve-1){for(var wt=0;wt1?At*(ve-1)+Rt*Xt:.5*(At+Pt)*(ve-1);if(ir<0||ir>ve-1){for(var wt=0;wt=E.size/ce)throw new Error("Invalid indices: "+De+" does not index into "+E.shape);for(var it=0;it=H/se)throw new Error("Invalid indices: "+Xe+" does not index into "+A);for(var rt=0;rtte&&(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=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;FrRt?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;Vezt&&(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.outHeight||Math.floor(Rt)!==Rt)continue;for(var wt=0;wt=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=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:ae0});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.inHeight)continue;for(var Nr=Ie*xt[0],Tr=Et+br*_t,pr=0;pr=ge.inWidth)continue;for(var _n=Nr+Er*xt[1],ie=Tr+an*At,In=_n,wn=0;wn=ce.inDepth)continue;for(var wt=Ot*At[0],Et=Pt+Rt*_t[1],Vt=0;Vt=ce.inHeight)continue;for(var br=wt+ir*At[1],Nr=Et+Ie*_t[2],Tr=0;Tr=ce.inWidth)continue;for(var an=br+mr*At[2],_n=Nr+Er*ce.inChannels,ie=an,In=0;In=Ae.inHeight)continue;for(var wt=Ot*ve[0],Et=Pt+Rt*fe[1],Vt=0;Vt=Ae.inWidth)continue;for(var br=wt+ir*ve[1],Nr=Et+Ie*Ae.inChannels,Tr=qt,pr=br,Fr=0;Fr=0&&Nr=0&&prIe&&(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=0&&Nr=0&&prlr&&(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=0&&Nr=0&&prlr&&(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=0&&xt=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=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=0&&Rt=0&&wt.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=ae0?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{"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]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(ml){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{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;sr[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;IMath.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;IP&&(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;GGe+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{for(let Qe=0;Qe":"<",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 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=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= 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= 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= 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= 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+11?[""+(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;I1?"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;p0&&(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;Fe0,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] "+p[0];for(var m="",g=f-2;g= "+p[g],g= `+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= `+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= 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;g5)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= 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;m0?[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)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;Pi.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;P1,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 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[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;R6)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;g6)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= 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{"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{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[(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{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[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{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(),Maet!==null),this.detectedFaces=nt.length,nt}updateRegionsOfInterest(mt){for(let yt=0;ytet[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 oe0?(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{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 de0?(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;etw.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{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;Weoe){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{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;eeye?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=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{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{const i=Jh();function we(ee,w,xe){return ee(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{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[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;console.log(this.runsWithoutHandDetector,this.skipFrames,this.detectedHands,this.regionsOfInterest.length);let 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.yz.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]X.position[1]{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{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 ",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;Xoe.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;X0?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=` .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: 1rem; 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: 1rem; 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: 1rem; 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: 1rem; } .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: 1rem; 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: 1rem; border: 1px; } input[type=range]::-webkit-slider-thumb { border: 1px solid #000000; margin-top: 0.05rem; height: 0.9rem; width: 1.5rem; border-radius: 1rem; background: ${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=`${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+=``}return V.innerHTML=`${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=`${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=`${N}`,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('
'),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('
'),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('
'),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('
'),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('
'),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