var pf=Object.defineProperty,ng=N=>pf(N,"__esModule",{value:!0}),Mr=(N,i)=>()=>(i||(i={exports:{}},N(i.exports,i)),i.exports),Kh=(N,i)=>{ng(N);for(var ke in i)pf(N,ke,{get:i[ke],enumerable:!0})},ag=Mr(()=>{}),ig=Mr(()=>{}),Pp=Mr(()=>{}),ml=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,a){n.__proto__=a}||function(n,a){for(var c in a)a.hasOwnProperty(c)&&(n[c]=a[c])},i(t,e)};function ke(t,e){i(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function O(t,e,n,a){return new(n||(n=Promise))(function(c,d){function y(C){try{_(a.next(C))}catch(D){d(D)}}function v(C){try{_(a.throw(C))}catch(D){d(D)}}function _(C){C.done?c(C.value):new n(function(D){D(C.value)}).then(y,v)}_((a=a.apply(t,e||[])).next())})}function H(t,e){var n={label:0,sent:function(){if(d[0]&1)throw d[1];return d[1]},trys:[],ops:[]},a,c,d,y;return y={next:v(0),throw:v(1),return:v(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function v(C){return function(D){return _([C,D])}}function _(C){if(a)throw new TypeError("Generator is already executing.");for(;n;)try{if(a=1,c&&(d=C[0]&2?c.return:C[0]?c.throw||((d=c.return)&&d.call(c),0):c.next)&&!(d=d.call(c,C[1])).done)return d;(c=0,d)&&(C=[C[0]&2,d.value]);switch(C[0]){case 0:case 1:d=C;break;case 4:return n.label++,{value:C[1],done:!1};case 5:n.label++,c=C[1],C=[0];continue;case 7:C=n.ops.pop(),n.trys.pop();continue;default:if(!(d=n.trys,d=d.length>0&&d[d.length-1])&&(C[0]===6||C[0]===2)){n=0;continue}if(C[0]===3&&(!d||C[1]>d[0]&&C[1]0;)a=Math.random()*e|0,e--,n=t[e],t[e]=t[a],t[a]=n}function me(t,e,n){return Math.max(t,Math.min(e,n))}function ae(t){return t%2===0?t:t+1}function w(t){for(var e=0,n=0;n=n){c();return}setTimeout(y,v)};y()})}function ar(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 qt(t,e){var n=e.length;return t=t==null?e.map(function(a,c){return c}):[].concat(t),W(t.every(function(a){return a>=-n&&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 jr(t,e){var n=null;if(t==null||t==="float32")n=new Float32Array(e);else if(t==="int32")n=new Int32Array(e);else if(t==="bool")n=new Uint8Array(e);else throw new Error("Unknown data type "+t);return n}function _r(t,e){var n=null;if(t==null||t==="float32")n=new Float32Array(e);else if(t==="int32")n=new Int32Array(e);else if(t==="bool")n=new Uint8Array(e);else if(t==="string")n=new Array(e);else throw new Error("Unknown data type "+t);return n}function tr(t,e){for(var n=0;n=0;--a)n[a]=n[a+1]*t[a+1];return n}function xn(t,e,n){var a=new Array;if(e.length===1)for(var c=e[0],d=0;d=0,function(){return"Tensor must have a shape comprised of positive integers but got "+("shape ["+t+"].")})})}function jn(t,e,n){if(e===0)return 0;if(e===1)return t[0];for(var a=t[t.length-1],c=0;c0?Pe:"")+" "}}console.log("%c"+_+" %c"+v+" %c"+C+"D "+B+" %c"+D+" %c"+U+" %c"+y,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")},t}();function A(t,e,n){for(var a={},c={},d=0;d=0;d--)for(var y=t[d],v=y.inputs,B=0;B=0;d--)c(d)}var oe=20,ee=3,_e=7;function ce(t,e,n,a){var c=Ca(e),d=de(t,e,n,c),y=e.length,v=Re(t,e,n,c,d),_=["Tensor"];return a&&(_.push(" dtype: "+n),_.push(" rank: "+y),_.push(" shape: ["+e+"]"),_.push(" values:")),_.push(v.map(function(C){return" "+C}).join(` `)),_.join(` `)}function de(t,e,n,a){var c=Tt(e),d=a[a.length-1],y=new Array(d).fill(0),v=e.length,_=n==="complex64"?Oe(t):t;if(v>1)for(var C=0;Coe){var D=ee*y,B=Array.from(t.slice(0,D)),U=Array.from(t.slice((v-ee)*y,v*y));return n==="complex64"&&(B=Oe(B),U=Oe(U)),["["+B.map(function(er,mr){return ye(er,c[mr],n)}).join(", ")+", ..., "+U.map(function(er,mr){return ye(er,c[v-ee+mr],n)}).join(", ")+"]"]}var J=n==="complex64"?Oe(t):Array.from(t);return["["+J.map(function(er,mr){return ye(er,c[mr],n)}).join(", ")+"]"]}var fe=e.slice(1),Pe=a.slice(1),Me=a[0]*y,He=[];if(v>oe){for(var ct=0;ct=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,D=[],B=this.isTapeOn();c==null&&(c=this.state.activeScope!=null?this.state.activeScope.name:"");var U=this.state.numBytes,J=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var fe,Pe=Bs(c,this.backendName),Me;if(Pe!=null)fe=function(){var It=_.backend.numDataIds();Me=Pe.kernelFunc({inputs:n,attrs:d,backend:_.backend});var Ct=Array.isArray(Me)?Me:[Me];_.shouldCheckForMemLeaks()&&_.checkKernelForMemLeak(c,It,Ct);var Bt=Ct.map(function(mr){var Gr=mr.dataId,en=mr.shape,Qr=mr.dtype;return _.makeTensorFromDataId(Gr,en,Qr)});if(B){var sr=_.getTensorsForGradient(c,n,Bt);if(sr==null){v==null&&(v=[]);var er=Bt.filter(function(mr,Gr){return v[Gr]});sr=(y||[]).slice().concat(er)}D=_.saveTensorsForBackwardMode(sr)}return Bt};else{var He=function(It){if(!B)return;D=It.map(function(Ct){return _.keep(_.clone(Ct))})};fe=function(){var It=_.backend.numDataIds();Me=_.tidy(function(){return e(_.backend,He)});var Ct=Array.isArray(Me)?Me:[Me];return _.shouldCheckForMemLeaks()&&_.checkKernelForMemLeak(c,It,Ct),Ct}}var ct;return this.scopedRun(function(){return _.state.kernelDepth++},function(){return _.state.kernelDepth--},function(){!_.ENV.getBool("DEBUG")&&!_.state.profiling?C=fe():(ct=_.profiler.profileKernel(c,n,function(){return fe()}),_.ENV.getBool("DEBUG")&&_.profiler.logKernelProfile(ct),C=ct.outputs)}),B&&this.addTapeNode(c,n,C,a,D,d),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-U,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-J,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(n).map(function(It){return n[It]!=null?n[It].shape:null}),outputShapes:C.map(function(It){return It.shape}),kernelTimeMs:ct.timeMs,extraInfo:ct.extraInfo}),Array.isArray(Me)?C:C[0]},t.prototype.saveTensorsForBackwardMode=function(e){var n=this,a=e.map(function(c){return n.keep(n.clone(c))});return a},t.prototype.getTensorsForGradient=function(e,n,a){var c=Ws(e);if(c!=null){var d=c.inputsToSave||[],y=c.outputsToSave||[],v=void 0;c.saveAllInputs?(W(Array.isArray(n),function(){return"saveAllInputs is true, expected inputs to be an array."}),v=Object.keys(n).map(function(C){return n[C]})):v=d.map(function(C){return n[C]});var _=a.filter(function(C,D){return y[D]});return v.concat(_)}return null},t.prototype.makeTensor=function(e,n,a,c){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");a=a||"float32",c=c||this.backend;var d=e;a==="string"&&yn(e[0])&&(d=e.map(function(D){return Xi(D)}));var y=c.write(d,n,a),v=new $(n,a,y,this.nextTensorId());if(this.incRef(v,c),a==="string"){var _=this.state.tensorInfo.get(y),C=Na(d);this.state.numBytes+=C-_.bytes,_.bytes=C}return v},t.prototype.makeTensorFromDataId=function(e,n,a,c){a=a||"float32";var d=new $(n,a,e,this.nextTensorId());return this.incRef(d,c),d},t.prototype.makeVariable=function(e,n,a,c){n===void 0&&(n=!0),a=a||this.nextVariableId().toString(),c!=null&&c!==e.dtype&&(e=e.cast(c));var d=new et(e,n,a,this.nextTensorId());if(this.state.registeredVariables[d.name]!=null)throw new Error("Variable with name "+d.name+" was already registered");return this.state.registeredVariables[d.name]=d,this.incRef(d,this.backend),d},t.prototype.incRef=function(e,n){var a=this.state.tensorInfo.has(e.dataId)?this.state.tensorInfo.get(e.dataId).refCount:0;if(this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++,a===0){this.state.numDataBuffers++;var c=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(c=e.size*Wa(e.dtype)),this.state.tensorInfo.set(e.dataId,{backend:n||this.backend,dtype:e.dtype,shape:e.shape,bytes:c,refCount:0}),this.state.numBytes+=c}this.state.tensorInfo.get(e.dataId).refCount++,e instanceof et||this.track(e)},t.prototype.disposeTensor=function(e){if(!this.state.tensorInfo.has(e.dataId))return;this.state.numTensors--,e.dtype==="string"&&this.state.numStringTensors--;var n=this.state.tensorInfo.get(e.dataId),a=n.refCount;a<=1?(e.dtype!=="complex64"&&(this.state.numBytes-=n.bytes),this.state.numDataBuffers--,n.backend.disposeData(e.dataId),this.state.tensorInfo.delete(e.dataId)):this.state.tensorInfo.get(e.dataId).refCount--},t.prototype.disposeVariables=function(){for(var e in this.state.registeredVariables){var n=this.state.registeredVariables[e];this.disposeVariable(n)}},t.prototype.disposeVariable=function(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&delete this.state.registeredVariables[e.name]},t.prototype.memory=function(){var e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,e.reasons==null&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e},t.prototype.profile=function(e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C;return H(this,function(D){switch(D.label){case 0:return this.state.profiling=!0,n=this.state.numBytes,a=this.state.numTensors,this.state.activeProfile.kernels=[],c=this.state.activeProfile,[4,e()];case 1:c.result=D.sent(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map(function(B){return B.totalBytesSnapshot})),this.state.activeProfile.newBytes=this.state.numBytes-n,this.state.activeProfile.newTensors=this.state.numTensors-a,d=0,y=this.state.activeProfile.kernels,D.label=2;case 2:return 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=Ws(e);C!=null&&(c=C.gradFunc),c!=null&&(_.gradient=function(D){return D=D.map(function(B,U){if(B==null){var J=a[U],fe=ha(J.size,J.dtype);return v.makeTensor(fe,J.shape,J.dtype)}return B}),c(D.length>1?D:D[0],d,y)}),this.state.activeTape.push(_)},t.prototype.keep=function(e){return e.kept=!0,e},t.prototype.startTape=function(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++},t.prototype.endTape=function(){this.state.gradientDepth--},t.prototype.startScope=function(e){var n={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(n.name=e),this.state.scopeStack.push(n),this.state.activeScope=n},t.prototype.endScope=function(e){for(var n=this,a=Ot(e),c=new Set(a.map(function(_){return _.id})),d=0;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??cr(y.shape),V(_,v,function(D){return d.tidy(D)},br);var C=n.map(function(D){return _[D.id]});return d.state.gradientDepth===0&&(d.state.activeTape.forEach(function(D){for(var B=0,U=D.saved;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),wn(a,c,e,n),t==null||!Tn(t)&&!Array.isArray(t)&&typeof t!="number"&&typeof t!="boolean"&&typeof t!="string"){var d=t==null?"null":t.constructor.name;throw new Error("Argument '"+e+"' passed to '"+n+"' must be a "+("Tensor or TensorLike, but got '"+d+"'"))}var y=Er(t,c);!Tn(t)&&!Array.isArray(t)&&(t=[t]);var v=!0,_=c!=="string"?Si(t,c):nr(t,[],v);return Ie.makeTensor(_,y,c)}function Nn(t,e,n,a){if(a===void 0&&(a="numeric"),!Array.isArray(t))throw new Error("Argument "+e+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");var c=t;return c.map(function(d,y){return ie(d,e+"["+y+"]",n)},a)}var bn="__op";function Ee(t){var e=Object.keys(t);if(e.length!==1)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+(e.length+" keys."));var n=e[0],a=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+bn;var c=function(){for(var d=[],y=0;y>10]+(v&1023)]+e[v>>10];d[y]=_}return new Float32Array(c)}}var si=function(){function t(){this.saveRouters=[],this.loadRouters=[]}return t.getInstance=function(){return t.instance==null&&(t.instance=new t),t.instance},t.registerSaveRouter=function(e){t.getInstance().saveRouters.push(e)},t.registerLoadRouter=function(e){t.getInstance().loadRouters.push(e)},t.getSaveHandlers=function(e){return t.getHandlers(e,"save")},t.getLoadHandlers=function(e,n){return t.getHandlers(e,"load",n)},t.getHandlers=function(e,n,a){var c=[],d=n==="load"?t.getInstance().loadRouters:t.getInstance().saveRouters;return d.forEach(function(y){var v=y(e,a);v!==null&&c.push(v)}),c},t}(),Su=function(t){return si.registerSaveRouter(t)},Iu=function(t){return si.registerLoadRouter(t)},lc=function(t){return si.getSaveHandlers(t)},xs=function(t,e){return si.getLoadHandlers(t,e)},Ii="tensorflowjs",_s=1,bo="models_store",so="model_info_store";function Nu(){if(!Rr().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var t=typeof window=="undefined"?self:window,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(e==null)throw new Error("The current browser does not appear to support IndexedDB.");return e}function uu(t){var e=t.result;e.createObjectStore(bo,{keyPath:"modelPath"}),e.createObjectStore(so,{keyPath:"modelPath"})}var ws=function(){function t(e){if(this.indexedDB=Nu(),e==null||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}return t.prototype.save=function(e){return O(this,void 0,void 0,function(){return H(this,function(n){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return[2,this.databaseAction(this.modelPath,e)]})})},t.prototype.load=function(){return O(this,void 0,void 0,function(){return H(this,function(e){return[2,this.databaseAction(this.modelPath)]})})},t.prototype.databaseAction=function(e,n){var a=this;return new Promise(function(c,d){var y=a.indexedDB.open(Ii,_s);y.onupgradeneeded=function(){return uu(y)},y.onsuccess=function(){var v=y.result;if(n==null){var _=v.transaction(bo,"readonly"),C=_.objectStore(bo),D=C.get(a.modelPath);D.onsuccess=function(){if(D.result==null)return v.close(),d(new Error("Cannot find model with path '"+a.modelPath+"' in IndexedDB."));c(D.result.modelArtifacts)},D.onerror=function(Me){return v.close(),d(D.error)},_.oncomplete=function(){return v.close()}}else{var B=dn(n),U=v.transaction(so,"readwrite"),J=U.objectStore(so),fe=J.put({modelPath:a.modelPath,modelArtifactsInfo:B}),Pe;fe.onsuccess=function(){Pe=v.transaction(bo,"readwrite");var Me=Pe.objectStore(bo),He=Me.put({modelPath:a.modelPath,modelArtifacts:n,modelArtifactsInfo:B});He.onsuccess=function(){return c({modelArtifactsInfo:B})},He.onerror=function(ct){J=U.objectStore(so);var It=J.delete(a.modelPath);It.onsuccess=function(){return v.close(),d(He.error)},It.onerror=function(Ct){return v.close(),d(He.error)}}},fe.onerror=function(Me){return v.close(),d(fe.error)},U.oncomplete=function(){Pe==null?v.close():Pe.oncomplete=function(){return v.close()}}}},y.onerror=function(v){return d(y.error)}})},t.URL_SCHEME="indexeddb://",t}(),Cu=function(t){return Rr().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(ws.URL_SCHEME)?cu(t.slice(ws.URL_SCHEME.length)):null};si.registerSaveRouter(Cu),si.registerLoadRouter(Cu);function cu(t){return new ws(t)}function Tu(t){return t.startsWith(ws.URL_SCHEME)?t.slice(ws.URL_SCHEME.length):t}var hc=function(){function t(){this.indexedDB=Nu()}return t.prototype.listModels=function(){return O(this,void 0,void 0,function(){var e=this;return H(this,function(n){return[2,new Promise(function(a,c){var d=e.indexedDB.open(Ii,_s);d.onupgradeneeded=function(){return uu(d)},d.onsuccess=function(){var y=d.result,v=y.transaction(so,"readonly"),_=v.objectStore(so),C=_.getAll();C.onsuccess=function(){for(var D={},B=0,U=C.result;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: "+(""+co.getSchemes().join(",")));return{scheme:t.split(Wo)[0],path:t.split(Wo)[1]}}function lu(t,e,n){return n===void 0&&(n=!1),O(this,void 0,void 0,function(){var a,c,d,y,v,_,C,D,B;return H(this,function(U){switch(U.label){case 0:return W(t!==e,function(){return"Old path and new path are the same: '"+t+"'"}),a=si.getLoadHandlers(t),W(a.length>0,function(){return"Copying failed because no load handler is found for source URL "+t+"."}),W(a.length<2,function(){return"Copying failed because more than one ("+a.length+") "+("load handlers for source URL "+t+".")}),c=a[0],d=si.getSaveHandlers(e),W(d.length>0,function(){return"Copying failed because no save handler is found for destination "+("URL "+e+".")}),W(d.length<2,function(){return"Copying failed because more than one ("+a.length+") "+("save handlers for destination URL "+e+".")}),y=d[0],v=Uo(t).scheme,_=Uo(t).path,C=v===Uo(t).scheme,[4,c.load()];case 1:return D=U.sent(),n&&C?[4,co.getManager(v).removeModel(_)]:[3,3];case 2:U.sent(),U.label=3;case 3:return[4,y.save(D)];case 4:return B=U.sent(),n&&!C?[4,co.getManager(v).removeModel(_)]:[3,6];case 5:U.sent(),U.label=6;case 6:return[2,B.modelArtifactsInfo]}})})}function as(){return O(this,void 0,void 0,function(){var t,e,n,a,c,d,y,v;return H(this,function(_){switch(_.label){case 0:t=co.getSchemes(),e={},n=0,a=t,_.label=1;case 1:return 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 pu(t,e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,D,B,U;return H(this,function(J){switch(J.label){case 0:return e==null&&(e={}),n=e.fetchFunc==null?Rr().platform.fetch:e.fetchFunc,a=t.map(function(fe){return n(fe,e.requestInit,{isBinary:!0})}),c=0,d=.5,e.onProgress==null?[4,Promise.all(a)]:[3,2];case 1:return v=J.sent(),[3,4];case 2:return[4,Sc(a,e.onProgress,c,d)];case 3:v=J.sent(),J.label=4;case 4:return y=v,_=y.map(function(fe){return fe.arrayBuffer()}),C=.5,D=1,e.onProgress==null?[4,Promise.all(_)]:[3,6];case 5:return U=J.sent(),[3,8];case 6:return[4,Sc(_,e.onProgress,C,D)];case 7:U=J.sent(),J.label=8;case 8:return B=U,[2,B]}})})}function Ic(t,e,n,a){return e===void 0&&(e=""),O(this,void 0,void 0,function(){var c,d;return H(this,function(y){return c=function(v){return pu(v,{requestInit:a})},d=Mu(c),[2,d(t,e,n)]})})}function Mu(t){var e=this;return function(n,a,c){return a===void 0&&(a=""),O(e,void 0,void 0,function(){var d,y,v,_,C,D,B,U,J,fe;return H(this,function(Pe){switch(Pe.label){case 0:if(d=n.map(function(){return!1}),y={},v=c!=null?c.map(function(){return!1}):[],_=[],n.forEach(function(Me,He){var ct=0;Me.weights.forEach(function(It){var Ct="quantization"in It?It.quantization.dtype:It.dtype,Bt=Ya[Ct]*Tt(It.shape),sr=function(){d[He]=!0,y[He]==null&&(y[He]=[]),y[He].push({manifestEntry:It,groupOffset:ct,sizeBytes:Bt})};c!=null?c.forEach(function(er,mr){er===It.name&&(sr(),v[mr]=!0)}):sr(),_.push(It.name),ct+=Bt})}),!v.every(function(Me){return Me}))throw C=c.filter(function(Me,He){return!v[He]}),new Error("Could not find weights in manifest with names: "+(C.join(", ")+`. `)+"Manifest JSON has weights with names: "+(_.join(", ")+"."));return D=d.reduce(function(Me,He,ct){return He&&Me.push(ct),Me},[]),B=[],D.forEach(function(Me){n[Me].paths.forEach(function(He){var ct=a+(a.endsWith("/")?"":"/")+He;B.push(ct)})}),[4,t(B)];case 1:return U=Pe.sent(),J={},fe=0,D.forEach(function(Me){for(var He=n[Me].paths.length,ct=0,It=0;It0,function(){return"URL path for http must not be null, undefined or empty."}),Array.isArray(e)&&W(e.length===2,function(){return"URL paths for http must have a length of 2, "+("(actual length is "+e.length+").")}),this.path=e,n.requestInit!=null&&n.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=n.requestInit||{}}return t.prototype.save=function(e){return O(this,void 0,void 0,function(){var n,a,c,d;return H(this,function(y){switch(y.label){case 0:if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return n=Object.assign({method:this.DEFAULT_METHOD},this.requestInit),n.body=new FormData,a=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],c={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,userDefinedMetadata:e.userDefinedMetadata,weightsManifest:a},n.body.append("model.json",new Blob([JSON.stringify(c)],{type:po}),"model.json"),e.weightData!=null&&n.body.append("model.weights.bin",new Blob([e.weightData],{type:Gs}),"model.weights.bin"),[4,this.fetch(this.path,n)];case 1:if(d=y.sent(),d.ok)return[2,{modelArtifactsInfo:dn(e),responses:[d]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+(d.status+"."))}})})},t.prototype.load=function(){return O(this,void 0,void 0,function(){var e,n,a,c,d,y,v,_,C,D,B,U,J,fe,Pe;return H(this,function(Me){switch(Me.label){case 0:return[4,this.fetch(this.path,this.requestInit)];case 1:if(e=Me.sent(),!e.ok)throw new Error("Request to "+this.path+" failed with status code "+(e.status+". Please verify this URL points to ")+"the model JSON of the model to load.");Me.label=2;case 2:return Me.trys.push([2,4,,5]),[4,e.json()];case 3:return n=Me.sent(),[3,5];case 4:throw a=Me.sent(),c="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?c+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":c+=" Please make sure the server is serving valid JSON for this request.",new Error(c);case 5:if(d=n.modelTopology,y=n.weightsManifest,v=n.generatedBy,_=n.convertedBy,C=n.format,D=n.userDefinedMetadata,d==null&&y==null)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return y!=null?[4,this.loadWeights(y)]:[3,7];case 6:J=Me.sent(),B=J[0],U=J[1],Me.label=7;case 7:return fe={modelTopology:d,weightSpecs:B,weightData:U,userDefinedMetadata:D,generatedBy:v,convertedBy:_,format:C},Pe=n.modelInitializer,Pe&&(fe.modelInitializer=Pe),[2,fe]}})})},t.prototype.loadWeights=function(e){return O(this,void 0,void 0,function(){var n,a,c,d,y,v,_,C,D,B,U,J,fe,Pe,Me,He,ct,It,Ct,Bt,sr;return H(this,function(er){switch(er.label){case 0:for(n=Array.isArray(this.path)?this.path[1]:this.path,a=_l(n),c=a[0],d=a[1],y=this.weightPathPrefix||c,v=[],_=0,C=e;_e?t.substring(n):"";return[a+"/",c]}function zu(t){return t.match(Lu.URL_SCHEME_REGEX)!=null}var Pu=function(t,e){if(typeof fetch=="undefined"&&(e==null||e.fetchFunc==null))return null;var n=!0;return Array.isArray(t)?n=t.every(function(a){return zu(a)}):n=zu(t),n?du(t,e):null};si.registerSaveRouter(Pu),si.registerLoadRouter(Pu);function du(t,e){return new Lu(t,e)}function wl(t,e){return du(t,e)}var fu=function(){function t(e){this.modelArtifacts=e}return t.prototype.load=function(){return O(this,void 0,void 0,function(){return H(this,function(e){return[2,this.modelArtifacts]})})},t}(),mu=function(){function t(e){this.saveHandler=e}return t.prototype.save=function(e){return O(this,void 0,void 0,function(){return H(this,function(n){return[2,this.saveHandler(e)]})})},t}();function Nc(t,e,n,a){if(arguments.length===1){var c=t.modelTopology!=null||t.weightSpecs!=null;return c?new fu(t):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new fu({modelTopology:t}))}else return console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new fu({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:a})}function Cc(t){return new mu(t)}var Tc={__proto__:null,browserFiles:ho,browserHTTPRequest:wl,concatenateArrayBuffers:rs,decodeWeights:ya,encodeWeights:Qa,fromMemory:Nc,getLoadHandlers:xs,getModelArtifactsInfoForJSON:dn,getSaveHandlers:lc,http:du,isHTTPScheme:zu,loadWeights:Ic,registerLoadRouter:Iu,registerSaveRouter:Su,weightsLoaderFactory:Mu,withSaveHandler:Cc,copyModel:gl,listModels:as,moveModel:xl,removeModel:Vo};function Ec(t,e){var n=ie(t,"x","reshape",null),a={x:n},c={shape:e},d=function(y,v){return e=ar(e,n.size),W(n.size===Tt(e),function(){return"new shape and old shape must have the same number of elements."}),v([n]),y.reshape(n,e)};return Ie.runKernelFunc(d,a,null,Pr,c)}var Ke=Ee({reshape_:Ec});function Rc(t,e,n,a){var c;n===void 0&&(n=!1),a===void 0&&(a=!1);var d=ie(t,"a","matMul"),y=ie(e,"b","matMul");c=Nt(d,y),d=c[0],y=c[1];var v=function(D,B){B([d,y]);var U=n?d.shape[d.rank-2]:d.shape[d.rank-1],J=a?y.shape[y.rank-1]:y.shape[y.rank-2],fe=n?d.shape[d.rank-1]:d.shape[d.rank-2],Pe=a?y.shape[y.rank-2]:y.shape[y.rank-1],Me=d.shape.slice(0,-2),He=y.shape.slice(0,-2),ct=Tt(Me),It=Tt(He),Ct=ct===It||ct===1||It===1;W(d.rank>=2&&y.rank>=2&&Ct,function(){return"Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input "+("batch dimensions of ("+Me+") and ("+He+").")}),W(U===J,function(){return"Error in matMul: inner shapes ("+U+") and ("+(J+") of Tensors with shapes "+d.shape+" and ")+(y.shape+" and transposeA="+n)+(" and transposeB="+a+" must match.")});var Bt=ct>It?Me:He,sr=Bt.concat([fe,Pe]),er=n?Ke(d,[ct,U,fe]):Ke(d,[ct,fe,U]),mr=a?Ke(y,[It,Pe,J]):Ke(y,[It,J,Pe]),Gr=D.batchMatMul(er,mr,n,a);return Ke(Gr,sr)},_={a:d,b:y},C={transposeA:n,transposeB:a};return Ie.runKernelFunc(v,_,null,da,C)}var un=Ee({matMul_:Rc});function Ac(t,e,n,a){if(n===void 0&&(n=1),a===void 0&&(a=0),e<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+e);var c=ie(t,"indices","oneHot","int32"),d=c.shape.concat([e]),y=function(C,D){return D([c]),Ke(C.oneHot(Ke(c,[c.size]),e,n,a),d)},v={indices:c},_={depth:e,onValue:n,offValue:a};return Ie.runKernelFunc(y,v,null,Pi,_)}var Ss=Ee({oneHot_:Ac});function Dc(t,e){var n=ie(t,"x","transpose");if(e==null&&(e=n.shape.map(function(d,y){return y}).reverse()),W(n.rank===e.length,function(){return"Error in transpose: rank of input "+n.rank+" "+("must match length of perm "+e+".")}),e.forEach(function(d){W(d>=0&&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=Ss(pr(a,"int32"),n),y=Ss(pr(c,"int32"),n),v=$n(d),_=un(v,y);return pr(_,"int32")}var Oc=Ee({confusionMatrix_:Fc}),Mc={__proto__:null,confusionMatrix:Oc};function js(t,e,n){if(tt(t),e!=null&&e.length!==3)throw new Error("tensor3d() requires shape to have three numbers");var a=Er(t,n);if(a.length!==3&&a.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Da(t,e,a,n)}var is;function Lc(t,e){if(e===void 0&&(e=3),e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(t==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,a=!1,c=!1,d=!1,y=!1;if(t.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&t instanceof ImageData)a=!0;else if(typeof HTMLVideoElement!="undefined"&&t instanceof HTMLVideoElement)c=!0;else if(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement)d=!0;else if(t.getContext!=null)y=!0;else throw new Error("pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, "+("but was "+t.constructor.name));if(c){var v=2;if(c&&t.readyState element.")}var _=Bs(xo,Ie.backendName);if(_!=null){var C={pixels:t},D={numChannels:e};return Ie.runKernel(xo,C,D)}var B=c?[t.videoWidth,t.videoHeight]:[t.width,t.height],U=B[0],J=B[1],fe;y?fe=t.getContext("2d").getImageData(0,0,U,J).data:a||n?fe=t.data:(d||c)&&(is==null&&(is=document.createElement("canvas").getContext("2d")),is.canvas.width=U,is.canvas.height=J,is.drawImage(t,0,0,U,J),fe=is.getImageData(0,0,U,J).data);var Pe;if(e===4)Pe=new Int32Array(fe);else{var Me=U*J;Pe=new Int32Array(Me*e);for(var He=0;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(_=ct.sent(),C=n.dtype==="float32"?255:1,D=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 "+fe+"."))}else if(n.dtype==="int32"&&(fe<0||fe>255))throw new Error("Tensor values for a int32 Tensor must be in the "+("range [0 - 255] but encountered "+fe+"."));v===1?(U[0]=fe*C,U[1]=fe*C,U[2]=fe*C):U[J]=fe*C}Pe=B*4,D[Pe+0]=Math.round(U[0]),D[Pe+1]=Math.round(U[1]),D[Pe+2]=Math.round(U[2]),D[Pe+3]=Math.round(U[3])}return e!=null&&(e.width=y,e.height=d,Me=e.getContext("2d"),He=new ImageData(D,y,d),Me.putImageData(He,0,0)),n!==t&&n.dispose(),[2,D]}})})}var yu=Ee({fromPixels_:Lc}),Pc={__proto__:null,toPixels:zc,fromPixels:yu};function Bu(t,e){if(t.rank<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher,"+(" but the rank was "+t.rank+"."));if(e.rank<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher,"+(" but the rank was "+e.rank+"."));if(e.dtype!=="int32")throw new Error("tf.gatherND() expects the indices to be int32 type,"+(" but the dtype was "+e.dtype+"."));if(e.shape[e.rank-1]>t.rank)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+(e.shape[e.rank-1]+" vs. "+t.rank));if(t.size===0)throw new Error("Requested more than 0 entries, but input is empty."+(" Input shape: "+t.shape+"."));for(var n=e.shape,a=n[n.length-1],c=1,d=0;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],fe=n+1;D=jc(y,J,fe,a,t),B=Uu(v,J,fe,c,t),U=Uc(d,J,fe,t)}else for(var Pe=0;Pe-1)d[v]=0;else{var _=Vc(e,n,v),C=a[_];t&1<<_&&(C=0),d[v]=C}return d}function Uu(t,e,n,a,c){for(var d=c.slice(),y=Hc(n,e),v=0;v-1)d[v]=Number.MAX_SAFE_INTEGER;else{var _=Vc(e,n,v),C=a[_];t&1<<_&&(C=Number.MAX_SAFE_INTEGER),d[v]=C}for(var D=0;D0?y=Number.MIN_SAFE_INTEGER:y=Number.MAX_SAFE_INTEGER);var _=a[c];return y<0&&(y+=_),y=me(0,y,_-1),y}function Kc(t,e,n,a,c,d){var y=e[c],v=n[c]||1;(t&1<0?y=Number.MAX_SAFE_INTEGER:y=Number.MIN_SAFE_INTEGER);var _=a[c];return y<0&&(y+=_),v>0?y=me(0,y,_):y=me(-1,y,_-1),y}function Sl(t,e,n){for(var a=n.length,c=0;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:vu,computeOutShape:Wc,stridesWithElidedDims:Uc,getNormalizedAxes:Gc,startIndicesWithElidedDims:jc,stopIndicesWithElidedDims:Uu,stridesForAxis:Vu,startForAxis:qc,stopForAxis:Kc,isSliceContinous:Sl,computeFlatOffset:Il,parseSliceParams:Hu},Yc=function(){function t(){}return t.prototype.getClassName=function(){return this.constructor.className},t.fromConfig=function(e,n){return new e(n)},t}(),ss=function(){function t(){this.classNameMap={}}return t.getMap=function(){return t.instance==null&&(t.instance=new t),t.instance},t.register=function(e){t.getMap().classNameMap[e.className]=[e,e.fromConfig]},t}();function jo(t){W(t.className!=null,function(){return"Class being registered does not have the static className property defined."}),W(typeof t.className=="string",function(){return"className is required to be a string, but got type "+typeof t.className}),W(t.className.length>0,function(){return"Class being registered has an empty-string as its className, which is disallowed."}),ss.register(t)}var Nl={__proto__:null,Serializable:Yc,SerializationMap:ss,registerClass:jo},Cl=.001,Gu=.1;function Tl(t,e,n){return n==null&&(n=gu()),ju(t,e,function(a,c){return qs(a,c,n)})}function gu(){return Ie.backend.floatPrecision()===32?Cl:Gu}function ju(t,e,n){var a=!0;if((Tn(t)||Tn(e))&&(a=!1),Tn(t)&&Tn(e)&&(a=!0),a){var c=t.constructor.name,d=e.constructor.name;if(c!==d)throw new Error("Arrays are of different type. Actual: "+c+". "+("Expected: "+d))}if(Array.isArray(t)&&Array.isArray(e)){var y=Er(t),v=Er(e);if(!it(y,v))throw new Error("Arrays have different shapes. "+("Actual: ["+y+"]. Expected: ["+v+"]"))}var _=Tn(t)?t:nr(t),C=Tn(e)?e:nr(e);if(_.length!==C.length)throw new Error("Arrays have different lengths actual: "+_.length+" vs "+("expected: "+C.length+`. `)+("Actual: "+_+`. `)+("Expected: "+C+"."));for(var D=0;Dn)}function qu(t,e,n){for(var a=0;an)throw new Error("Value out of range:"+t[a]+" low: "+e+", high: "+n)}function Dl(t,e){expect(new Float32Array(t)).toEqual(new Float32Array(e))}var Fl={__proto__:null,TEST_EPSILON_FLOAT16:Gu,expectArraysClose:Tl,testEpsilon:gu,expectPromiseToFail:El,expectArraysEqual:Rl,expectNumbersClose:Al,expectValuesInRange:qu,expectArrayBuffersEqual:Dl},Ku="2.7.0";function Ol(){Rr().set("PROD",!0)}function Ml(){Rr().set("DEBUG",!0)}function Xu(){Rr().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Sa(t){Rr().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function Ll(){Ie.disposeVariables()}function zl(){return Ie}function Pl(){return Ie.memory()}function Qc(t){return Ie.profile(t)}function sa(t,e){return Ie.tidy(t,e)}function Pa(t){var e=Ot(t);e.forEach(function(n){return n.dispose()})}function xu(t){return Ie.keep(t)}function Zc(t){return Ie.time(t)}function Bl(t){return Ie.setBackend(t)}function Wl(){return Ie.ready()}function Ul(){return Ie.backendName}function Vl(t){Ie.removeBackend(t)}function Hl(t){return Ie.findBackend(t)}function Gl(t){return Ie.findBackendFactory(t)}function jl(t,e,n){return n===void 0&&(n=1),Ie.registerBackend(t,e,n)}function ql(){return Ie.backend}function Kl(t,e){Rr().setPlatform(t,e)}function Xl(t,e){var n,a=ie(t,"a","add"),c=ie(e,"b","add");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.add(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,pa)}var Cr=Ee({add_:Xl});function Yl(t,e){var n,a=ie(t,"a","floorDiv"),c=ie(e,"b","floorDiv");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.floorDiv(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,k)}var Yu=Ee({floorDiv_:Yl});function Ql(t,e){var n,a=ie(t,"a","div"),c=ie(e,"b","div");if(n=Nt(a,c),a=n[0],c=n[1],a.dtype==="int32"&&c.dtype==="int32")return Yu(a,c);var d=function(_,C){var D=_.realDivide(a,c);return C([a,c]),D},y={a,b:c},v={};return Ie.runKernelFunc(d,y,null,Vr,v)}var Br=Ee({div_:Ql});function Jc(t,e){var n,a=ie(t,"a","mul"),c=ie(e,"b","mul");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.multiply(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,qr)}var bt=Ee({mul_:Jc});function Zl(t){var e=ie(t,"x","abs"),n={x:e};return Ie.runKernelFunc(function(a,c){return c([e]),e.dtype==="complex64"?a.complexAbs(e):a.abs(e)},n,null,qn)}var ui=Ee({abs_:Zl});function Jl(t){var e=ie(t,"x","acos"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.acos(e);return c([e]),d},n,null,ri)}var $c=Ee({acos_:Jl});function $l(t){var e=ie(t,"x","acosh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.acosh(e);return c([e]),d},n,null,pi)}var el=Ee({acosh_:$l});function eh(t){W(Array.isArray(t),function(){return"The argument passed to tf.addN() must be a list of tensors"}),W(t.length>=1,function(){return"Must pass at least one tensor to tf.addN(), but got "+(""+t.length)});var e=t.map(function(d,y){return ie(d,"tensors"+y,"addN")}),n=e[0];e.forEach(function(d){if(d.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),e.forEach(function(d){if(!it(d.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});var a=function(d,y){var v=d.addN(e);return y(e),v},c=e;return Ie.runKernelFunc(a,c,null,di)}var th=Ee({addN_:eh});function Qu(t,e){for(var n=0;n=0&&e=1,function(){return"Pass at least one tensor to concat"});var n=Nn(t,"tensors","concat");n[0].dtype==="complex64"&&n.forEach(function(y){if(y.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor with dtype `+y.dtype+". ")});var a=function(y,v){var _=qt(e,n[0].shape)[0],C=Ir(n.map(function(U){return U.shape}),_);if(Tt(C)===0)return Dn([],C);if(n=n.filter(function(U){return U.size>0}),n.length===1)return n[0];var D=n.map(function(U){return U.shape});lr(D,_);var B=y.concat(n,_);return v(n),B},c=n,d={axis:e};return Ie.runKernelFunc(a,c,null,Ue,d)}var kr=Ee({concat_:Lr});function Sr(t){var e=ie(t,"x","sigmoid"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.sigmoid(e);return c([d]),d},n,null,Ds)}var fn=Ee({sigmoid_:Sr});function Xr(t,e,n){var a=ie(t,"x","slice");if(a.rank===0)throw new Error("Slicing scalar is not possible");var c=function(v,_){var C=Hu(a,e,n),D=C[0],B=C[1];return Bc(a,D,B),_([a]),v.slice(a,D,B)},d={x:a},y={begin:e,size:n};return Ie.runKernelFunc(c,d,null,To,y)}var $t=Ee({slice_:Xr});function On(t){var e=ie(t,"x","tanh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.tanh(e);return c([d]),d},n,null,Ms)}var En=Ee({tanh_:On});function kn(t,e,n,a,c,d){var y=ie(t,"forgetBias","basicLSTMCell"),v=ie(e,"lstmKernel","basicLSTMCell"),_=ie(n,"lstmBias","basicLSTMCell"),C=ie(a,"data","basicLSTMCell"),D=ie(c,"c","basicLSTMCell"),B=ie(d,"h","basicLSTMCell"),U=kr([C,B],1),J=un(U,v),fe=Cr(J,_),Pe=fe.shape[0],Me=fe.shape[1]/4,He=[Pe,Me],ct=$t(fe,[0,0],He),It=$t(fe,[0,Me],He),Ct=$t(fe,[0,Me*2],He),Bt=$t(fe,[0,Me*3],He),sr=Cr(bt(fn(ct),En(It)),bt(D,fn(Cr(y,Ct)))),er=bt(En(sr),fn(Bt));return[sr,er]}var cn=Ee({basicLSTMCell_:kn});function Mn(t,e,n){var a=ie(t,"x","batchToSpaceND"),c=e.reduce(function(_,C){return _*C});W(a.rank>=1+e.length,function(){return"input rank is "+a.rank+" but should be > than blockShape.length "+e.length}),W(n.length===e.length,function(){return"crops.length is "+n.length+" but should be equal to blockShape.length "+e.length}),W(a.shape[0]%c===0,function(){return"input tensor batch is "+a.shape[0]+" but is not divisible by the product of "+("the elements of blockShape "+e.join(" * ")+" === "+c)});var d=function(_){return _.batchToSpaceND(a,e,n)},y={x:a},v={blockShape:e,crops:n};return Ie.runKernelFunc(d,y,null,Mi,v)}var Hr=Ee({batchToSpaceND_:Mn});function ua(t){var e;return t.rank===0||t.rank===1?e=Ke(t,[1,1,1,t.size]):t.rank===2?e=Ke(t,[1,1,t.shape[0],t.shape[1]]):t.rank===3?e=Ke(t,[1,t.shape[0],t.shape[1],t.shape[2]]):e=t,e}function Ci(t,e,n,a,c,d){d==null&&(d=.001);var y=ie(t,"x","batchNorm"),v=ie(e,"mean","batchNorm"),_=ie(n,"variance","batchNorm"),C;c!=null&&(C=ie(c,"scale","batchNorm"));var D;a!=null&&(D=ie(a,"offset","batchNorm")),W(v.rank===_.rank,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),W(D==null||v.rank===D.rank,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),W(C==null||v.rank===C.rank,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var B=ua(y),U=function(Me,He){return He([B,v,_,C]),Me.batchNorm(B,Ui(v),Ui(_),Ui(D),Ui(C),d)},J={x:B,scale:C,offset:D,mean:v,variance:_},fe={varianceEpsilon:d},Pe=Ie.runKernelFunc(U,J,null,K,fe);return Ke(Pe,y.shape)}function Ui(t){return t==null?null:t.rank===0?Ke(t,[t.size]):t.rank===1?t:t.rank===2?Ke(t,[1,1,t.shape[0],t.shape[1]]):t.rank===3?Ke(t,[1,t.shape[0],t.shape[1],t.shape[2]]):t}var Xn=Ee({batchNorm_:Ci});function $i(t,e,n,a,c,d){var y=ie(t,"x","batchNorm"),v=ie(e,"mean","batchNorm"),_=ie(n,"variance","batchNorm"),C;c!=null&&(C=ie(c,"scale","batchNorm"));var D;return a!=null&&(D=ie(a,"offset","batchNorm")),W(y.rank===2,function(){return"Error in batchNorm2D: x must be rank 2 but got rank "+(y.rank+".")}),W(v.rank===2||v.rank===1,function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but "+("got rank "+v.rank+".")}),W(_.rank===2||_.rank===1,function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 "+("but got rank "+_.rank+".")}),C!=null&&W(C.rank===2||C.rank===1,function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 "+("but got rank "+C.rank+".")}),D!=null&&W(D.rank===2||D.rank===1,function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 "+("but got rank "+D.rank+".")}),Xn(y,v,_,D,C,d)}var Vi=Ee({batchNorm2d_:$i});function Ks(t,e,n,a,c,d){var y=ie(t,"x","batchNorm"),v=ie(e,"mean","batchNorm"),_=ie(n,"variance","batchNorm"),C;c!=null&&(C=ie(c,"scale","batchNorm"));var D;return a!=null&&(D=ie(a,"offset","batchNorm")),W(y.rank===3,function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+(y.rank+".")}),W(v.rank===3||v.rank===1,function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but "+("got rank "+v.rank+".")}),W(_.rank===3||_.rank===1,function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 "+("but got rank "+_.rank+".")}),C!=null&&W(C.rank===3||C.rank===1,function(){return"Error in batchNorm3D: scale must be rank 3 or rank 1 "+("but got rank "+C.rank+".")}),D!=null&&W(D.rank===3||D.rank===1,function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 "+("but got rank "+D.rank+".")}),Xn(y,v,_,D,C,d)}var Zu=Ee({batchNorm3d_:Ks});function al(t,e,n,a,c,d){var y=ie(t,"x","batchNorm"),v=ie(e,"mean","batchNorm"),_=ie(n,"variance","batchNorm"),C;c!=null&&(C=ie(c,"scale","batchNorm"));var D;return a!=null&&(D=ie(a,"offset","batchNorm")),W(y.rank===4,function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+(y.rank+".")}),W(v.rank===4||v.rank===1,function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but "+("got rank "+v.rank+".")}),W(_.rank===4||_.rank===1,function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 "+("but got rank "+_.rank+".")}),C!=null&&W(C.rank===4||C.rank===1,function(){return"Error in batchNorm4D: scale must be rank 4 or rank 1 "+("but got rank "+C.rank+".")}),D!=null&&W(D.rank===4||D.rank===1,function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 "+("but got rank "+D.rank+".")}),Xn(y,v,_,D,C,d)}var _h=Ee({batchNorm4d_:al});function rh(t,e){var n=ie(t,"broadcastTo","x"),a=n.shape;if(e.some(function(U){return!(U>0)||U%1!==0}))throw new Error("broadcastTo(): Invalid broadcast shape ["+e+"].");if(e.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)},D={x:n},B={shape:e,inputShape:d};return Ie.runKernelFunc(C,D,null,pe,B)}var Ju=Ee({broadcastTo_:rh});function nh(t){var e=ie(t,"x","ceil"),n={x:e};return Ie.runKernelFunc(function(a){return a.ceil(e)},n,null,j)}var ah=Ee({ceil_:nh});function ih(t,e,n){var a=ie(t,"x","clipByValue");W(e<=n,function(){return"Error in clip: min ("+e+") must be "+("less than or equal to max ("+n+").")});var c={x:a},d={clipValueMin:e,clipValueMax:n};return Ie.runKernelFunc(function(y,v){var _=y.clip(a,e,n);return v([a]),_},c,null,re,d)}var oh=Ee({clipByValue_:ih});function sh(t){return kr(t,0)}var wh=Ee({concat1d_:sh});function uh(t,e){return kr(t,e)}var $h=Ee({concat2d_:uh});function ch(t,e){return kr(t,e)}var bh=Ee({concat3d_:ch});function ep(t,e){return kr(t,e)}var Wn=Ee({concat4d_:ep});function Is(t,e,n,a,c,d,y){c===void 0&&(c="NHWC"),d===void 0&&(d=[1,1]);var v=ie(t,"x","conv2d"),_=ie(e,"filter","conv2d"),C=v,D=!1;v.rank===3&&(D=!0,C=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2]])),W(C.rank===4,function(){return"Error in conv2d: input must be rank 4, but got rank "+C.rank+"."}),W(_.rank===4,function(){return"Error in conv2d: filter must be rank 4, but got rank "+(_.rank+".")}),y!=null&&W(xt(a),function(){return"Error in conv2d: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+a+".")});var B=c==="NHWC"?C.shape[3]:C.shape[1];W(B===_.shape[2],function(){return"Error in conv2d: depth of input ("+B+") must match "+("input depth for filter "+_.shape[2]+".")}),W(dt(n,d),function(){return"Error in conv2D: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+d+"'")});var U=function(Me,He){var ct=Dt(c),It=T(C.shape,_.shape,n,d,a,y,!1,ct),Ct=Me.conv2d(C,_,It);return He([C,_]),Ct},J={x:C,filter:_},fe={strides:n,pad:a,dataFormat:c,dilations:d,dimRoundingMode:y},Pe=Ie.runKernelFunc(U,J,null,kt,fe);return D?Ke(Pe,[Pe.shape[1],Pe.shape[2],Pe.shape[3]]):Pe}var gi=Ee({conv2d_:Is});function qo(t,e,n,a,c,d,y){c===void 0&&(c="NWC"),d===void 0&&(d=1);var v=ie(t,"x","conv1d"),_=ie(e,"filter","conv1d"),C=v,D=!1;v.rank===2&&(D=!0,C=Ke(v,[1,v.shape[0],v.shape[1]])),W(C.rank===3,function(){return"Error in conv1d: input must be rank 3, but got rank "+C.rank+"."}),W(_.rank===3,function(){return"Error in conv1d: filter must be rank 3, but got rank "+(_.rank+".")}),y!=null&&W(xt(a),function(){return"Error in conv1d: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+a+".")}),W(C.shape[2]===_.shape[1],function(){return"Error in conv1d: depth of input ("+C.shape[2]+") must match "+("input depth for filter "+_.shape[1]+".")}),W(dt(n,d),function(){return"Error in conv1D: Either stride or dilation must be 1. "+("Got stride "+n+" and dilation '"+d+"'")}),W(c==="NWC",function(){return"Error in conv1d: got dataFormat of "+c+" but only NWC is currently supported."});var B=Ke(_,[1,_.shape[0],_.shape[1],_.shape[2]]),U=Ke(C,[C.shape[0],1,C.shape[1],C.shape[2]]),J=[1,n],fe=[1,d],Pe="NHWC",Me=gi(U,B,J,a,Pe,fe,y);return D?Ke(Me,[Me.shape[2],Me.shape[3]]):Ke(Me,[Me.shape[0],Me.shape[2],Me.shape[3]])}var Ns=Ee({conv1d_:qo});function kh(t,e,n,a,c,d,y){d===void 0&&(d="NHWC"),W(t.length===e.rank,function(){return"Length of inShape "+("("+t.length+") and rank of dy ("+e.rank+") must match")});var v=t,_=e,C=!1;e.rank===3&&(C=!0,_=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2]]),v=[1,t[0],t[1],t[2]]),W(v.length===4,function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+(v.length+".")}),W(_.rank===4,function(){return"Error in conv2dDerInput: dy must be rank 4, but got "+("rank "+_.rank)}),W(n.rank===4,function(){return"Error in conv2dDerInput: filter must be rank 4, but got "+("rank "+n.rank)});var D=d==="NHWC"?v[3]:v[1],B=d==="NHWC"?_.shape[3]:_.shape[1];W(D===n.shape[2],function(){return"Error in conv2dDerInput: depth of input ("+D+") must "+("match input depth for filter "+n.shape[2]+".")}),W(B===n.shape[3],function(){return"Error in conv2dDerInput: depth of output ("+B+") must "+("match output depth for filter "+n.shape[3]+".")}),y!=null&&W(xt(c),function(){return"Error in conv2dDerInput: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+c+".")});var U=function(Me,He){var ct=1,It=Dt(d),Ct=T(v,n.shape,a,ct,c,y,!1,It),Bt=Me.conv2dDerInput(_,n,Ct);return He([_,n]),Bt},J={dy:_,filter:n},fe={strides:a,pad:c,dataFormat:d,dimRoundingMode:y,inputShape:v},Pe=Ie.runKernelFunc(U,J,null,Le,fe);return C?Ke(Pe,[Pe.shape[1],Pe.shape[2],Pe.shape[3]]):Pe}var Ti=Ee({conv2DBackpropInput_:kh});function tp(t,e,n,a,c,d){var y=ie(t,"x","conv2dTranspose"),v=ie(e,"filter","conv2dTranspose");return Ti(n,y,v,a,c,"NHWC",d)}var Xs=Ee({conv2dTranspose_:tp});function rp(t,e,n,a,c,d){c===void 0&&(c="NDHWC"),d===void 0&&(d=[1,1,1]);var y=ie(t,"x","conv3d"),v=ie(e,"filter","conv3d"),_=y,C=!1;y.rank===4&&(C=!0,_=Ke(y,[1,y.shape[0],y.shape[1],y.shape[2],y.shape[3]])),W(_.rank===5,function(){return"Error in conv3d: input must be rank 5, but got rank "+_.rank+"."}),W(v.rank===5,function(){return"Error in conv3d: filter must be rank 5, but got rank "+(v.rank+".")}),W(_.shape[4]===v.shape[3],function(){return"Error in conv3d: depth of input ("+_.shape[4]+") must match "+("input depth for filter "+v.shape[3]+".")}),W(dt(n,d),function(){return"Error in conv3D: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+d+"'")}),W(c==="NDHWC",function(){return"Error in conv3d: got dataFormat of "+c+" but only NDHWC is currently supported."});var D=function(fe,Pe){var Me=M(_.shape,v.shape,n,d,a),He=fe.conv3d(_,v,Me);return Pe([_,v]),He},B={x:_,filter:v},U={strides:n,pad:a,dataFormat:c,dilations:d},J=Ie.runKernelFunc(D,B,null,Ye,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var np=Ee({conv3d_:rp});function ap(t,e,n,a,c){W(t.length===e.rank,function(){return"Length of inShape "+("("+t.length+") and rank of dy ("+e.rank+") must match")});var d=t,y=e,v=!1;e.rank===4&&(v=!0,y=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),d=[1,t[0],t[1],t[2],t[3]]);var _=d[4],C=y.shape[4];W(d.length===5,function(){return"Error in conv3dDerInput: inShape must be length 5, but got length "+(d.length+".")}),W(y.rank===5,function(){return"Error in conv3dDerInput: dy must be rank 5, but got "+("rank "+y.rank)}),W(n.rank===5,function(){return"Error in conv3dDerInput: filter must be rank 5, but got "+("rank "+n.rank)}),W(_===n.shape[3],function(){return"Error in conv3dDerInput: depth of input ("+_+") must "+("match input depth for filter "+n.shape[3]+".")}),W(C===n.shape[4],function(){return"Error in conv3dDerInput: depth of output ("+C+") must "+("match output depth for filter "+n.shape[4]+".")});var D=function(fe){var Pe=1,Me=M(d,n.shape,a,Pe,c);return fe.conv3dDerInput(y,n,Me)},B={dy:y,filter:n},U={pad:c,strides:a,inputShape:d},J=Ie.runKernelFunc(D,B,null,St,U);return v?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var Sh=Ee({conv3DBackpropInput_:ap});function If(t,e,n,a,c){var d=ie(t,"x","conv3dTranspose"),y=ie(e,"filter","conv3dTranspose");return Sh(n,d,y,a,c)}var Nf=Ee({conv3dTranspose_:If});function Cf(t){var e=ie(t,"x","cos"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.cos(e);return c([e]),d},n,null,Mt)}var Ih=Ee({cos_:Cf});function Tf(t){var e=ie(t,"x","cosh"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.cosh(e);return c([e]),d},n,null,dr)}var ip=Ee({cosh_:Tf});function Ef(t,e,n,a){e===void 0&&(e=0),n===void 0&&(n=!1),a===void 0&&(a=!1);var c=ie(t,"x","cumsum"),d=function(_,C){var D=Ji([e],c.rank),B=c;D!=null&&(B=$n(c,D));var U=p(1,c.rank)[0],J=_.cumsum(B,U,n,a);if(C([c]),D!=null){var fe=f(D);J=$n(J,fe)}return J},y={x:c},v={axis:e,exclusive:n,reverse:a};return Ie.runKernelFunc(d,y,null,ir,v)}var op=Ee({cumsum_:Ef});function Rf(t,e,n){n===void 0&&(n="NHWC");var a=ie(t,"x","depthToSpace"),c=n==="NHWC"?a.shape[1]:a.shape[2],d=n==="NHWC"?a.shape[2]:a.shape[3],y=n==="NHWC"?a.shape[3]:a.shape[1];W(c*e>=0,function(){return`Negative dimension size caused by overflow when multiplying `+c+" and "+e+` for depthToSpace with input shape `+a.shape}),W(d*e>=0,function(){return`Negative dimension size caused by overflow when multiplying `+d+" and "+e+` for depthToSpace with input shape `+a.shape}),W(y%(e*e)===0,function(){return"Dimension size must be evenly divisible by "+e*e+" but is "+y+" for depthToSpace with input shape "+a.shape});var v=function(D){return D.depthToSpace(a,e,n)},_={x:a},C={blockSize:e,dataFormat:n};return Ie.runKernelFunc(v,_,null,fa,C)}var Kp=Ee({depthToSpace_:Rf});function Af(t,e,n,a,c,d,y){c===void 0&&(c="NHWC"),d===void 0&&(d=[1,1]);var v=ie(t,"x","depthwiseConv2d"),_=ie(e,"filter","depthwiseConv2d"),C=v,D=!1;v.rank===3&&(D=!0,C=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2]])),W(C.rank===4,function(){return"Error in depthwiseConv2d: input must be rank 4, but got "+("rank "+C.rank+".")}),W(_.rank===4,function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+(_.rank+".")}),W(C.shape[3]===_.shape[2],function(){return"Error in depthwiseConv2d: number of input channels "+("("+C.shape[3]+") must match the inChannels dimension in ")+("filter "+_.shape[2]+".")}),y!=null&&W(xt(a),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+y+" but got pad "+a+".")});var B=function(Pe,Me){d==null&&(d=[1,1]),W(dt(n,d),function(){return"Error in depthwiseConv2d: Either strides or dilations must be "+("1. Got strides "+n+" and dilations '"+d+"'")});var He=T(C.shape,_.shape,n,d,a,y,!0),ct=Pe.depthwiseConv2D(C,_,He);return Me([C,_]),ct},U={x:C,filter:_},J={strides:n,pad:a,dataFormat:c,dilations:d,dimRoundingMode:y},fe=Ie.runKernelFunc(B,U,null,ra,J);return D?Ke(fe,[fe.shape[1],fe.shape[2],fe.shape[3]]):fe}var lh=Ee({depthwiseConv2d_:Af});function Df(t){var e=ie(t,"x","diag"),n=function(c){var d=Ke(e,[e.size]),y=c.diag(d),v=t.shape.concat(t.shape);return Ke(y,v)},a={x:e};return Ie.runKernelFunc(n,a,null,sn)}var Ff=Ee({diag_:Df});function Of(t,e,n,a,c,d){c===void 0&&(c=[1,1]),d===void 0&&(d="NHWC");var y=ie(t,"x","dilation2d"),v=ie(e,"filter","dilation2d");W(y.rank===3||y.rank===4,function(){return"Error in dilation2d: input must be rank 3 or 4, but got rank "+(y.rank+".")}),W(v.rank===3,function(){return"Error in dilation2d: filter must be rank 3, but got rank "+(v.rank+".")}),W(d==="NHWC",function(){return"Error in dilation2d: Only NHWC is currently supported, "+("but got dataFormat of "+d)});var _=y,C=!1;y.rank===3&&(_=Ke(y,[1,y.shape[0],y.shape[1],y.shape[2]]),C=!0);var D={x:_,filter:v},B={strides:n,pad:a,dilations:c},U=Ie.runKernel(hn,D,B);return C?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var Xp=Ee({dilation2d_:Of});function Mf(t,e){for(var n=t.length,a=[],c=0;c1&&y===1&&a.unshift(d)}return a}function Ja(t,e){for(var n=[],a=0;a1)&&n.unshift(d)}return n}function ca(t,e){for(var n=[],a=Math.max(t.length,e.length),c=0;ce||a===t?n=!0:a=rn(t,a+1);return a}function Zf(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 D={};return e.forEach(function(B,U){C[U]!=null&&(D[B.name]=C[U])}),c!=null&&c.forEach(function(B){return D[B.name]=null}),{value:_,grads:D}}function Cs(t){return Ie.customGrad(t)}function Rh(t){var e=t.filter(function(n){return n==null}).length;if(e>0)throw new Error(`Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.`)}function g1(t){var e=ie(t,"x","neg"),n={x:e};return Ie.runKernelFunc(function(a){return a.neg(e)},n,null,Io)}var $a=Ee({neg_:g1});function x1(t){var e=ie(t,"x","softplus"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.softplus(e);return c([e]),d},n,null,Xo)}var hp=Ee({softplus_:x1});function _1(t){var e=ie(t,"x","logSigmoid"),n=Cs(function(a){var c=$a(hp($a(a))),d=function(y){var v=bt(y,fn($a(a)));return v};return{value:c,gradFunc:d}});return n(e)}var sd=Ee({logSigmoid_:_1});function w1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","max"),c=function(v,_){var C=qt(e,a.shape),D=C,B=Ji(D,a.rank),U=a;B!=null&&(U=$n(a,B),D=p(D.length,U.rank));var J=v.max(U,D);B!=null&&U.dispose();var fe=J;if(n){var Pe=ci(fe.shape,qt(e,a.shape));fe=Ke(fe,Pe),J.dispose()}return _([a,fe]),fe},d={x:a},y={reductionIndices:e,keepDims:n};return Ie.runKernelFunc(c,d,null,$r,y)}var rc=Ee({max_:w1});function b1(t,e){var n,a=ie(t,"a","sub"),c=ie(e,"b","sub");n=Nt(a,c),a=n[0],c=n[1];var d=function(v,_){var C=v.subtract(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,ps)}var zr=Ee({sub_:b1});function k1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","sum");a.dtype==="bool"&&(a=pr(a,"int32"));var c=function(v,_){_([a]);var C=qt(e,a.shape),D=Ji(C,a.rank),B=C,U=a;D!=null&&(U=$n(a,D),B=p(B.length,a.rank));var J=v.sum(U,B);if(n){var fe=ci(J.shape,C);J=Ke(J,fe)}return J},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,Yo,y)}var Yr=Ee({sum_:k1});function S1(t,e){e===void 0&&(e=-1);var n=ie(t,"logits","logSoftmax");if(e===-1&&(e=n.rank-1),e!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. "+("Logits was rank "+n.rank+" and axis was "+e));var a=function(y,v){var _=!0,C=rc(t,e,!0),D=zr(t,C),B=zr(pr(D,"float32"),tc(Yr(cs(D),e,_)));return v([B]),B},c={logits:n},d={axis:e};return Ie.runKernelFunc(a,c,null,wa,d)}var ud=Ee({logSoftmax_:S1});function I1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","logSumExp"),c=qt(e,a.shape),d=rc(a,c,!0),y=zr(a,d),v=cs(y),_=Yr(v,c),C=tc(_),D=Cr(Ke(d,C.shape),C);if(n){var B=ci(D.shape,c);return Ke(D,B)}return D}var pp=Ee({logSumExp_:I1});function N1(t,e){var n=ie(t,"a","logicalAnd","bool"),a=ie(e,"b","logicalAnd","bool");ca(n.shape,a.shape);var c={a:n,b:a};return Ie.runKernelFunc(function(d){return d.logicalAnd(n,a)},c,null,pn)}var nc=Ee({logicalAnd_:N1});function C1(t){var e=ie(t,"x","logicalNot","bool"),n={x:e};return Ie.runKernelFunc(function(a){return a.logicalNot(e)},n,null,zn)}var Ah=Ee({logicalNot_:C1});function T1(t,e){var n=ie(t,"a","logicalOr","bool"),a=ie(e,"b","logicalOr","bool");ca(n.shape,a.shape);var c={a:n,b:a};return Ie.runKernelFunc(function(d){return d.logicalOr(n,a)},c,null,Fr)}var dp=Ee({logicalOr_:T1});function E1(t,e){var n=ie(t,"a","logicalXor","bool"),a=ie(e,"b","logicalXor","bool");return ca(n.shape,a.shape),nc(dp(t,e),Ah(nc(t,e)))}var cd=Ee({logicalXor_:E1});function R1(t,e,n,a,c){var d=ie(t,"x","maxPool"),y=1,v=d,_=!1;d.rank===3&&(_=!0,v=Ke(d,[1,d.shape[0],d.shape[1],d.shape[2]])),W(v.rank===4,function(){return"Error in maxPool: input must be rank 4 but got rank "+v.rank+"."}),W(dt(n,y),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+y+"'")}),c!=null&&W(xt(a),function(){return"Error in maxPool: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var C=function(J,fe){var Pe=h(v.shape,e,n,1,a,c),Me;return Pe.filterWidth===1&&Pe.filterHeight===1&&it(Pe.inShape,Pe.outShape)?Me=v.clone():Me=J.maxPool(v,Pe),fe([v,Me]),Me},D={x:v},B={filterSize:e,strides:n,pad:a,dimRoundingMode:c},U=Ie.runKernelFunc(C,D,null,mi,B);return _?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var fp=Ee({maxPool_:R1});function A1(t,e,n,a,c,d,y){e===void 0&&(e=[1,1,1]),d===void 0&&(d="NDHWC"),y==null?y=[1,1,1]:Sa("dilations is deprecated, this field will be gone in v3.0.0.");var v=ie(t,"x","maxPool3d"),_=v,C=!1;v.rank===4&&(C=!0,_=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2],v.shape[3]])),W(_.rank===5,function(){return"Error in maxPool3d: x must be rank 5 but got rank "+_.rank+"."}),W(d==="NDHWC",function(){return"Error in maxPool3d: Only NDHWC is currently supported, "+("but got dataFormat of "+d)}),W(dt(n,y),function(){return"Error in maxPool3d: Either strides or dilations must be 1. "+("Got strides "+n+" and dilations '"+y+"'")}),c!=null&&W(xt(a),function(){return"Error in maxPool3d: pad must be an integer when using, "+("dimRoundingMode "+c+" but got pad "+a+".")});var D=function(fe,Pe){y==null&&(y=[1,1,1]);var Me=b(_.shape,e,n,y,a,c,d),He=fe.maxPool3d(_,Me);return Pe([_,He]),He},B={x:_},U={filterSize:e,strides:n,pad:a,dimRoundingMode:c,dataFormat:d,dilations:y},J=Ie.runKernelFunc(D,B,null,ja,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3],J.shape[4]]):J}var D1=Ee({maxPool3d_:A1});function F1(t,e,n,a,c){c===void 0&&(c=!1);var d=ie(t,"x","maxPoolWithArgmax"),y={x:d},v={filterSize:e,strides:n,pad:a,includeBatchInIndex:c},_=Ie.runKernel(zi,y,v);return{result:_[0],indexes:_[1]}}var O1=Ee({maxPoolWithArgmax_:F1});function Ys(t,e){if(e===void 0&&(e="float32"),e==="complex64"){var n=Ys(t,"float32"),a=Ys(t,"float32");return Pn(n,a)}var c=ha(Tt(t),e);return Ie.makeTensor(c,t,e)}function sl(t,e){if(e===void 0&&(e="float32"),e==="complex64"){var n=sl(t,"float32"),a=Ys(t,"float32");return Pn(n,a)}var c=_i(Tt(t),e);return Ie.makeTensor(c,t,e)}function M1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","mean"),c=qt(e,a.shape),d=rl(a.shape,c),y=d[1],v=Tt(y),_={x:a},C={axis:e,keepDims:n},D=function(){var U=Wr(v),J=U.dtype===a.dtype?a:pr(a,U.dtype),fe=Br(J,U);return Yr(fe,e,n)},B=Cs(function(U){var J=Ie.runKernelFunc(D,_,null,An,C),fe=function(Pe){var Me=U.shape.slice();c.forEach(function(It){Me[It]=1});var He=Ke(Pe,Me),ct=Br(bt(He,sl(U.shape,"float32")),v);return ct};return{value:J,gradFunc:fe}});return B(a)}var ph=Ee({mean_:M1});function L1(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","min"),c=function(v,_){var C=qt(e,a.shape),D=C,B=Ji(D,a.rank),U=a;B!=null&&(U=$n(a,B),D=p(D.length,a.rank));var J=v.min(U,D);B!=null&&U.dispose();var fe=J;if(n){var Pe=ci(fe.shape,C);fe=Ke(J,Pe),J.dispose()}return _([a,fe]),fe},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,ba,y)}var Dh=Ee({min_:L1});function z1(t,e){var n,a=ie(t,"a","minimum"),c=ie(e,"b","minimum");n=Nt(a,c),a=n[0],c=n[1],a.dtype==="bool"&&(a=pr(a,"int32"),c=pr(c,"int32")),ca(a.shape,c.shape);var d=function(v,_){var C=v.minimum(a,c);return _([a,c]),C},y={a,b:c};return Ie.runKernelFunc(d,y,null,qi)}var Fh=Ee({minimum_:z1});function P1(t,e,n){W(n==="reflect"||n==="symmetric",function(){return"Invalid mode. Mode must be either reflect or symmetric. "+("Got "+n+".")});var a=ie(t,"x","mirrorPad");if(a.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");W(e.length===a.rank,function(){return"Padding doesn't match input. Must be "+a.rank+". "+("Got "+e.length+".")});for(var c=n==="reflect"?1:0,d=function(C){W(e[C].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),W(e[C][0]>=0&&e[C][0]<=a.shape[C]-c&&e[C][1]>=0&&e[C][1]<=a.shape[C]-c,function(){return"Padding in dimension "+C+" cannot be greater than or equal "+("to "+(a.shape[C]-c)+" or less than 0 for input of ")+("shape "+a.shape)})},y=0;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 q1=Ee({multinomial_:j1});function K1(t,e){var n,a=ie(t,"a","notEqual"),c=ie(e,"b","notEqual");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(v){return v.notEqual(a,c)},y={a,b:c};return Ie.runKernelFunc(d,y,null,nn)}var Oh=Ee({notEqual_:K1});function X1(t){var e=ie(t,"input","real"),n=function(c){return c.real(e)},a={input:e};return Ie.runKernelFunc(n,a,null,Co)}var dh=Ee({real_:X1});function Y1(t){var e=ie(t,"x","onesLike"),n=function(c,d){if(e.dtype==="complex64"){var y=yp(dh(e)),v=gn(Th(e));return Pn(y,v)}return c.onesLike(e)},a={x:e};return Ie.runKernelFunc(n,a,null,oi)}var yp=Ee({onesLike_:Y1});function Q1(t,e){var n=ie(t,"v1","outerProduct"),a=ie(e,"v2","outerProduct");W(n.rank===1&&a.rank===1,function(){return"Error in outerProduct: inputs must be rank 1, but got ranks "+(n.rank+" and "+a.rank+".")});var c=Ke(n,[-1,1]),d=Ke(a,[1,-1]);return un(c,d)}var Z1=Ee({outerProduct_:Q1});function J1(t,e,n){n===void 0&&(n=0);var a=ie(t,"x","pad");if(a.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var c=function(v,_){return _([a]),v.pad(a,e,n)},d={paddings:e,constantValue:n},y={x:a};return Ie.runKernelFunc(c,y,null,no,d)}var ac=Ee({pad_:J1});function $1(t,e,n){return n===void 0&&(n=0),W(e.length===2,function(){return"Invalid number of paddings. Must be length of 2."}),ac(t,[e],n)}var em=Ee({pad1d_:$1});function tm(t,e,n){return n===void 0&&(n=0),W(e.length===2&&e[0].length===2&&e[1].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),ac(t,e,n)}var rm=Ee({pad2d_:tm});function nm(t,e,n){return n===void 0&&(n=0),W(e.length===3&&e[0].length===2&&e[1].length===2&&e[2].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),ac(t,e,n)}var am=Ee({pad3d_:nm});function im(t,e,n){return n===void 0&&(n=0),W(e.length===4&&e[0].length===2&&e[1].length===2&&e[2].length===2&&e[3].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),ac(t,e,n)}var om=Ee({pad4d_:im});function sm(t,e,n){var a=ie(t,"x","spaceToBatchND");W(a.rank>=1+e.length,function(){return"input rank "+a.rank+" should be > than [blockShape] "+e.length}),W(n.length===e.length,function(){return"paddings.shape[0] "+n.length+" must be equal to [blockShape] "+e.length}),W(a.shape.reduce(function(v,_,C){return C>0&&C<=e.length?v&&(_+n[C-1][0]+n[C-1][1])%e[C-1]===0:v},!0),function(){return"input spatial dimensions "+a.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+e.toString()});var c=function(v){return v.spaceToBatchND(a,e,n)},d={x:a},y={blockShape:e,paddings:n};return Ie.runKernelFunc(c,d,null,Ao,y)}var Mh=Ee({spaceToBatchND_:sm});function um(t,e,n,a,c,d){c==null&&(c=[1,1]),d==null&&(d=1),a===0&&(a="valid");var y=ie(t,"x","maxPool"),v=y,_=!1;y.rank===3&&(_=!0,v=Ke(y,[1,y.shape[0],y.shape[1],y.shape[2]])),W(dt(d,c),function(){return"Error in pool: Either strides or dilations must be 1. "+("Got strides "+d+" and dilations '"+c+"'")});var C=h(v.shape,e,d,c,a),D=[C.dilationHeight,C.dilationWidth],B;a==="same"?B=lm([C.filterHeight,C.filterWidth],D):B=[[0,0],[0,0]];var U=D[0]===1&&D[1]===1,J=cm([C.inHeight,C.inWidth],D,B),fe=J[0],Pe=J[1],Me=U?a:"valid",He=U?v:Mh(v,D,fe),ct=n==="avg"?function(){return Xt(He,e,d,Me)}:function(){return fp(He,e,d,Me)},It=ct(),Ct=U?It:Hr(It,D,Pe);return _?Ke(Ct,[Ct.shape[1],Ct.shape[2],Ct.shape[3]]):Ct}function cm(t,e,n){var a=n.map(function(D){return D[0]}),c=n.map(function(D){return D[1]}),d=t.concat(a,c),y=e.map(function(D,B){return(D-d[B]%D)%D}),v=c.map(function(D,B){return D+y[B]}),_=e.map(function(D,B){return[a[B],v[B]]}),C=e.map(function(D,B){return[0,y[B]]});return[_,C]}function lm(t,e){var n=t.map(function(y,v){return y+(y-1)*(e[v]-1)}),a=n.map(function(y){return y-1}),c=a.map(function(y){return Math.floor(y/2)}),d=a.map(function(y,v){return y-c[v]});return a.map(function(y,v){return[c[v],d[v]]})}var hd=Ee({pool_:um});function hm(t,e){var n,a=ie(t,"base","pow"),c=ie(e,"exp","pow");n=Nt(a,c),a=n[0],c=n[1];var d={a,b:c},y=function(v,_){var C=v.pow(a,c);return _([a,c,C]),C};return Ie.runKernelFunc(y,d,null,Ka)}var Qs=Ee({pow_:hm});function pm(t,e){var n=ie(t,"x","prelu"),a=ie(e,"alpha","prelu"),c=function(y,v){var _=y.prelu(n,a);return v([n,a]),_},d={x:n,alpha:a};return Ie.runKernelFunc(c,d,null,ao)}var vp=Ee({prelu_:pm});function dm(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!1);var a=ie(t,"x","prod");a.dtype==="bool"&&(a=pr(a,"int32"));var c=function(v){var _=qt(e,a.shape),C=Ji(_,a.rank),D=_,B=a;C!=null&&(B=$n(a,C),D=p(D.length,a.rank));var U=v.prod(B,D);if(n){var J=ci(U.shape,_);U=Ke(U,J)}return U},d={x:a},y={axis:e,keepDims:n};return Ie.runKernelFunc(c,d,null,Ko,y)}var pd=Ee({prod_:dm});function fm(t,e,n){var a=Tt(t),c=null;if(n==null||n==="float32")c=new Float32Array(a);else if(n==="int32")c=new Int32Array(a);else if(n==="bool")c=new Uint8Array(a);else throw new Error("Unknown data type "+n);for(var d=0;d>>0,U-=_,U*=_,_=U>>>0,U-=_,_+=U*4294967296}return(_>>>0)*23283064365386963e-26};return C}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.alea=y})(ul,t,!1)}),vm=ic(function(t){(function(e,n,a){function c(v){var _=this,C="";_.x=0,_.y=0,_.z=0,_.w=0,_.next=function(){var B=_.x^_.x<<11;return _.x=_.y,_.y=_.z,_.z=_.w,_.w^=_.w>>>19^B^B>>>8},v===(v|0)?_.x=v:C+=v;for(var D=0;D>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(typeof D=="object"&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.xor128=y})(ul,t,!1)}),gm=ic(function(t){(function(e,n,a){function c(v){var _=this,C="";_.next=function(){var B=_.x^_.x>>>2;return _.x=_.y,_.y=_.z,_.z=_.w,_.w=_.v,(_.d=_.d+362437|0)+(_.v=_.v^_.v<<4^(B^B<<1))|0},_.x=0,_.y=0,_.z=0,_.w=0,_.v=0,v===(v|0)?_.x=v:C+=v;for(var D=0;D>>4),_.next()}function d(v,_){return _.x=v.x,_.y=v.y,_.z=v.z,_.w=v.w,_.v=v.v,_.d=v.d,_}function y(v,_){var C=new c(v),D=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(typeof D=="object"&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.xorwow=y})(ul,t,!1)}),xm=ic(function(t){(function(e,n,a){function c(v){var _=this;_.next=function(){var D=_.x,B=_.i,U,J;return U=D[B],U^=U>>>7,J=U^U<<24,U=D[B+1&7],J^=U^U>>>10,U=D[B+3&7],J^=U^U>>>3,U=D[B+4&7],J^=U^U<<7,U=D[B+7&7],U=U^U<<13,J^=U^U<<9,D[B]=J,_.i=B+1&7,J};function C(D,B){var U,J,fe=[];if(B===(B|0))J=fe[0]=B;else for(B=""+B,U=0;U0;--U)D.next()}C(_,v)}function d(v,_){return _.x=v.x.slice(),_.i=v.i,_}function y(v,_){v==null&&(v=+new Date);var C=new c(v),D=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(D.x&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.xorshift7=y})(ul,t,!1)}),_m=ic(function(t){(function(e,n,a){function c(v){var _=this;_.next=function(){var D=_.w,B=_.X,U=_.i,J,fe;return _.w=D=D+1640531527|0,fe=B[U+34&127],J=B[U=U+1&127],fe^=fe<<13,J^=J<<17,fe^=fe>>>15,J^=J>>>12,fe=B[U]=fe^J,_.i=U,fe+(D^D>>>16)|0};function C(D,B){var U,J,fe,Pe,Me,He=[],ct=128;for(B===(B|0)?(J=B,B=null):(B=B+"\0",J=0,ct=Math.max(ct,B.length)),fe=0,Pe=-32;Pe>>15,J^=J<<4,J^=J>>>13,Pe>=0&&(Me=Me+1640531527|0,U=He[Pe&127]^=J+Me,fe=U==0?fe+1:0);for(fe>=128&&(He[(B&&B.length||0)&127]=-1),fe=127,Pe=4*128;Pe>0;--Pe)J=He[fe+34&127],U=He[fe=fe+1&127],J^=J<<13,U^=U<<17,J^=J>>>15,U^=U>>>12,He[fe]=J^U;D.w=Me,D.X=He,D.i=fe}C(_,v)}function d(v,_){return _.i=v.i,_.w=v.w,_.X=v.X.slice(),_}function y(v,_){v==null&&(v=+new Date);var C=new c(v),D=_&&_.state,B=function(){return(C.next()>>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(D.X&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.xor4096=y})(ul,t,!1)}),wm=ic(function(t){(function(e,n,a){function c(v){var _=this,C="";_.next=function(){var B=_.b,U=_.c,J=_.d,fe=_.a;return B=B<<25^B>>>7^U,U=U-J|0,J=J<<24^J>>>8^fe,fe=fe-B|0,_.b=B=B<<20^B>>>12^U,_.c=U=U-J|0,_.d=J<<16^U>>>16^fe,_.a=fe-B|0},_.a=0,_.b=0,_.c=2654435769|0,_.d=1367130551,v===Math.floor(v)?(_.a=v/4294967296|0,_.b=v|0):C+=v;for(var D=0;D>>0)/4294967296};return B.double=function(){do var U=C.next()>>>11,J=(C.next()>>>0)/4294967296,fe=(U+J)/(1<<21);while(fe===0);return fe},B.int32=C.next,B.quick=B,D&&(typeof D=="object"&&d(D,C),B.state=function(){return d(C,{})}),B}n&&n.exports?n.exports=y:a&&a.amd?a(function(){return y}):this.tychei=y})(ul,t,!1)}),oc=ic(function(t){(function(e,n){var a=this,c=256,d=6,y=52,v="random",_=n.pow(c,d),C=n.pow(2,y),D=C*2,B=c-1,U;function J(Ct,Bt,sr){var er=[];Bt=Bt==!0?{entropy:!0}:Bt||{};var mr=He(Me(Bt.entropy?[Ct,It(e)]:Ct??ct(),3),er),Gr=new fe(er),en=function(){for(var Qr=Gr.g(d),Zr=_,Kr=0;Qr=D;)Qr/=2,Zr/=2,Kr>>>=1;return(Qr+Kr)/Zr};return en.int32=function(){return Gr.g(4)|0},en.quick=function(){return Gr.g(4)/4294967296},en.double=en,He(It(Gr.S),e),(Bt.pass||sr||function(Qr,Zr,Kr,Un){return Un&&(Un.S&&Pe(Un,Gr),Qr.state=function(){return Pe(Gr,{})}),Kr?(n[v]=Qr,Zr):Qr})(en,mr,"global"in Bt?Bt.global:this==n,Bt.state)}n["seed"+v]=J;function fe(Ct){var Bt,sr=Ct.length,er=this,mr=0,Gr=er.i=er.j=0,en=er.S=[];for(sr||(Ct=[sr++]);mr=1||v===0);var _=Math.sqrt(-2*Math.log(v)/v);n=this.mean+this.stdDev*d*_,a=this.mean+this.stdDev*y*_,(!this.truncated||this.isValidTruncated(n))&&(c=!0)}return(!this.truncated||this.isValidTruncated(a))&&(this.nextVal=this.convertValue(a)),this.convertValue(n)},t.prototype.convertValue=function(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)},t.prototype.isValidTruncated=function(e){return e<=this.upper&&e>=this.lower},t}(),km=function(){function t(e,n,a,c){this.alpha=e,this.beta=1/n,this.dtype=a;var d=c||Math.random();this.randu=gp(d.toString()),this.randn=new xp(0,1,a,!1,this.randu()),e<1?this.d=e+2/3:this.d=e-1/3,this.c=1/Math.sqrt(9*this.d)}return t.prototype.nextValue=function(){for(var e,n,a,c,d,y;;){do c=this.randn.nextValue(),y=1+this.c*c;while(y<=0);if(y*=y*y,e=c*c,n=1-.331*e*e,a=.5*e+this.d*(1-y+Math.log(y)),d=this.randu(),d1;if(y||v||_)return Ys([0],a);var C=Math.abs(Math.ceil((e-t)/n)),D=ha(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 cy(t,e,n){n===void 0&&(n=0);var a=ie(t,"x","split"),c=function(v,_){var C=qt(n,a.shape)[0],D=_d(a,e,C);return v.split(a,D,C)},d={x:a},y={numOrSizeSplits:e,axis:n};return Ie.runKernelFunc(c,d,null,Qo,y)}var ll=Ee({split_:cy});function ly(t,e){W(t.dtype==="float32",function(){return"The dtype for rfft() must be real value but got "+t.dtype});var n=t.shape[t.shape.length-1],a=t.size/n,c;if(e!=null&&en){var v=t.shape.map(function(He){return He});v[t.shape.length-1]=e-n,c=kr([t,Ys(v)],t.shape.length-1),n=e}else c=t;var _=gn(c),C=Ke(Pn(c,_),[a,n]),D=Lh(C),B=Math.floor(n/2)+1,U=dh(D),J=Th(D),fe=ll(U,[B,n-B],U.shape.length-1),Pe=ll(J,[B,n-B],J.shape.length-1),Me=c.shape.slice();return Me[c.shape.length-1]=B,Ke(Pn(fe[0],Pe[0]),Me)}var zh=Ee({rfft_:ly});function hy(t){var e=ie(t,"x","sqrt"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.sqrt(e);return c([e]),d},n,null,Ro)}var eo=Ee({sqrt_:hy});function py(t,e){var n,a=ie(t,"a","squaredDifference"),c=ie(e,"b","squaredDifference");n=Nt(a,c),a=n[0],c=n[1],ca(a.shape,c.shape);var d=function(_,C){var D=_.squaredDifference(a,c);return C([a,c]),D},y={a,b:c},v={};return Ie.runKernelFunc(d,y,null,Fs,v)}var Ph=Ee({squaredDifference_:py});function dy(t,e){var n=ie(t,"x","squeeze");return Ke(n,Ur(n.shape,e).newShape)}var Bh=Ee({squeeze_:dy});function fy(t,e){e===void 0&&(e=0);var n=Nn(t,"tensors","stack");if(W(n.length>=1,function(){return"Pass at least one tensor to tf.stack"}),n.length===1)return ls(n[0],e);var a=n[0].rank,c=n[0].shape,d=n[0].dtype;W(e<=a,function(){return"Axis must be <= rank of the tensor"}),n.forEach(function(v){nt(c,v.shape,"All tensors passed to stack must have matching shapes"),W(d===v.dtype,function(){return"All tensors passed to stack must have matching dtypes"})});var y=n.map(function(v){return ls(v,e)});return kr(y,e)}var sc=Ee({stack_:fy});function my(t,e){e===void 0&&(e=0);var n=ie(t,"x","step"),a={x:n},c={alpha:e};return Ie.runKernelFunc(function(d){return d.step(n,e)},a,null,Zo,c)}var hl=Ee({step_:my});function yy(t,e,n,a,c,d,y,v,_){c===void 0&&(c=0),d===void 0&&(d=0),y===void 0&&(y=0),v===void 0&&(v=0),_===void 0&&(_=0);var C=ie(t,"x","stridedSlice"),D=function(J){a==null&&(a=new Array(e.length));var fe=vu(y);if(fe.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(y!==0&&v!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(y!==0&&_!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");var Pe=C.rank-e.length,Me=vu(v),He=C.shape.slice();Me.forEach(function(Qr){e[Qr]=0,n[Qr]=1,He.splice(Qr,0,1)}),C=Ke(C,He);var ct=Gc(C.shape,fe,Pe,e,n,a,c,d,y),It=ct.begin,Ct=ct.end,Bt=ct.strides;e=It,n=Ct,a=Bt;var sr=vu(_);sr.forEach(function(Qr){n[Qr]=e[Qr]+1,a[Qr]=1});var er=Wc(e,n,a),mr=er.filter(function(Qr,Zr){return sr.indexOf(Zr)===-1}),Gr=a.every(function(Qr){return Qr===1});if(Gr)return Ke($t(C,e,er),mr);var en=J.stridedSlice(C,e,n,a);return Ke(en,mr)},B={x:C},U={begin:e,end:n,strides:a,beginMask:c,endMask:d,ellipsisMask:y,newAxisMask:v,shrinkAxisMask:_};return Ie.runKernelFunc(D,B,null,Os,U)}var wd=Ee({stridedSlice_:yy});function vy(t){var e=ie(t,"x","tan"),n={x:e};return Ie.runKernelFunc(function(a,c){var d=a.tan(e);return c([e]),d},n,null,ds)}var bd=Ee({tan_:vy});function yh(t,e,n){if(tt(t),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");var a=Er(t,n);if(a.length!==2&&a.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Da(t,e,a,n)}function gy(t,e,n){if(tt(t),e!=null&&e.length!==4)throw new Error("tensor4d() requires shape to have four numbers");var a=Er(t,n);if(a.length!==4&&a.length!==1)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Da(t,e,a,n)}function xy(t,e,n){if(tt(t),e!=null&&e.length!==5)throw new Error("tensor5d() requires shape to have five numbers");var a=Er(t,n);if(a.length!==5&&a.length!==1)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Da(t,e,a,n)}function _y(t,e,n){if(tt(t),e!=null&&e.length!==6)throw new Error("tensor6d() requires shape to have six numbers");var a=Er(t,n);if(a.length!==6&&a.length!==1)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(a.length===1&&e==null)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return e=e||a,Da(t,e,a,n)}function wy(t,e,n){e===void 0&&(e=1),n===void 0&&(n=!0);var a=ie(t,"x","topk");if(a.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");var c=a.shape[a.shape.length-1];if(e>c)throw new Error("'k' passed to topk() must be <= the last dimension ("+c+") "+("but got "+e));var d={x:a},y={k:e,sorted:n},v=Ie.runKernelFunc(function(D){return D.topk(a,e,n)},d,null,nu,y),_=v[0],C=v[1];return{values:_,indices:C}}var kd=Ee({topk_:wy});function by(t,e,n,a,c){if(e===void 0&&(e=0),n===void 0&&(n=1),a!=null&&a==="bool")throw new Error("Unsupported data type $ { dtype }");for(var d=new xp(e,n,a,!0,c),y=Qi(t,a),v=0;v0,function(){return"The input tensor must be at least 1D"});var a={x:n},c={axis:e},d=Ie.runKernel(au,a,c),y=d[0],v=d[1];return{values:y,indices:v}}var Sd=Ee({unique_:Sy});function Iy(t,e,n){var a=ie(t,"x","unsortedSegmentSum"),c=ie(e,"segmentIds","unsortedSegmentSum","int32");W(xt(n),function(){return"numSegments must be of dtype int"});var d={x:a,segmentIds:c},y={numSegments:n},v=function(_,C){var D=_.unsortedSegmentSum(a,c,n);return C([c]),D};return Ie.runKernelFunc(v,d,null,Do,y)}var Np=Ee({unsortedSegmentSum_:Iy});function Ny(t,e){e===void 0&&(e=0);var n=ie(t,"x","unstack");W(e>=-n.shape.length&&e0,function(){return"mask cannot be scalar"}),nt(v.slice(d,d+y),c.shape,"mask's shape must match the first K dimensions of tensor's shape,"),_=1,C=d;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 Jy(t,e,n,a){a===void 0&&(a=0);var c=ie(t,"sparseIndices","sparseToDense","int32"),d=ie(e,"sparseValues","sparseToDense"),y=ie(a,"defaultValue","sparseToDense",d.dtype);Zy(c,d,n,y);var v={sparseIndices:c,sparseValues:d,defaultValue:y},_={outputShape:n};return Ie.runKernelFunc(function(C){return C.sparseToDense(c,d,n,y)},v,null,ru,_)}var $y=Ee({sparseToDense_:Jy});function e0(t,e){var n=ie(e,"indices","gatherND","int32"),a=ie(t,"x","gatherND"),c=function(y){return y.gatherND(a,n)},d={params:a,indices:n};return Ie.runKernelFunc(c,d,null,we)}var t0=Ee({gatherND_:e0});function r0(t,e){if(e==null)return t.shape.slice();if(it(t.shape,e))return e;if(t.shape.length===e.length){for(var n=[],a=0;a=0&&e<1,function(){return"rate must be a float in the range [0, 1), but got "+e+"."}),e===0)return t instanceof $?c.clone():c;var d=r0(c,n),y=1-e,v=Br(Nh(Cr(dd(d,0,1,"float32",a),y)),y);return bt(c,v)}var a0=Ee({dropout_:n0});function Hd(t){return Math.floor(Math.pow(2,Math.ceil(Math.log(t)/Math.log(2))))}function Cp(t,e,n){for(var a=1-t%2,c=new Float32Array(t),d=0;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)}),nt(a.shape.slice(0,a.shape.length-1),c.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),d=a.shape[a.shape.length-1],W(n>0&&n<=d,function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last "+("dimension ("+d+"), but got "+n)}),[4,a.data()];case 1:return y=He.sent(),[4,c.data()];case 2:for(v=He.sent(),_=[y.length/d,d],C=_[0],D=_[1],B=jr("bool",C),U=0;U0&&(n=Yr(n,a)),Ke(n,t.shape)}function Gh(t,e,n){if(e==="linear")return t;if(e==="relu")return fh(t);if(e==="elu")return sp(t);if(e==="relu6")return wp(t);if(e==="prelu")return vp(t,n);throw new Error("Unknown fused activation "+e+".")}var jh=function(t,e){var n=t>0;return!n||e==="linear"};function u0(t){var e=t.x,n=t.filter,a=t.strides,c=t.pad,d=t.dataFormat,y=d===void 0?"NHWC":d,v=t.dilations,_=v===void 0?[1,1]:v,C=t.dimRoundingMode,D=t.bias,B=t.activation,U=B===void 0?"linear":B,J=t.preluActivationWeights;if(U=U||"linear",jh(Ie.state.gradientDepth,U)===!1){var fe=gi(e,n,a,c,y,_,C);return D!=null&&(fe=Cr(fe,D)),Gh(fe,U,J)}var Pe=ie(e,"x","conv2d"),Me=ie(n,"filter","conv2d"),He=Pe,ct=!1;Pe.rank===3&&(ct=!0,He=Ke(Pe,[1,Pe.shape[0],Pe.shape[1],Pe.shape[2]])),W(He.rank===4,function(){return"Error in fused conv2d: input must be rank 4, but got rank "+(He.rank+".")}),W(Me.rank===4,function(){return"Error in fused conv2d: filter must be rank 4, but got rank "+(Me.rank+".")}),C!=null&&W(xt(c),function(){return"Error in fused conv2d: pad must be an integer when using, "+("dimRoundingMode "+C+" but got pad "+c+".")}),W(He.shape[3]===Me.shape[2],function(){return"Error in conv2d: depth of input ("+He.shape[3]+") must match "+("input depth for filter "+Me.shape[2]+".")}),W(dt(a,_),function(){return"Error in conv2D: Either strides or dilations must be 1. "+("Got strides "+a+" and dilations '"+_+"'")}),W(y==="NHWC",function(){return"Error in conv2d: got dataFormat of "+y+" but only NHWC is currently supported."});var It=T(He.shape,Me.shape,a,_,c,C),Ct;D!=null&&(Ct=ie(D,"bias","fused conv2d"),Ct=Nt(Ct,Pe)[0],ca(It.outShape,Ct.shape));var Bt;J!=null&&(Bt=ie(J,"prelu weights","fused conv2d"));var sr=function(Zr,Kr){var Un=Kr,mn=Un[0],Ln=Un[1],$s=Un[2],xi=Un[3],Ba=Vh(Zr,$s,U);W(st(_),function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 "+("are not yet supported in gradients. Got dilations '"+_+"'")});var ko=Ti(Ln.shape,Ba,mn,a,c),So=Tp(Ln,Ba,mn.shape,a,c),bu=[ko,So];if(xi!=null){var zp=Hh(xi,Ba);bu.push(zp)}return bu},er=function(Zr){var Kr=Zr.fusedConv2d({input:He,filter:Me,convInfo:It,bias:Ct,activation:U,preluActivationWeights:Bt});return Kr},mr={x:He,filter:Me,bias:Ct,preluActivationWeights:Bt},Gr={strides:a,pad:c,dataFormat:y,dilations:_,dimRoundingMode:C,activation:U};if(D==null){var en=Cs(function(Zr,Kr,Un){var mn=Ie.runKernelFunc(er,mr,null,Ps,Gr);return Un([Kr,Zr,mn]),ct&&(mn=Ke(mn,[mn.shape[1],mn.shape[2],mn.shape[3]])),{value:mn,gradFunc:sr}});return en(He,Me)}else{var Qr=Cs(function(Zr,Kr,Un,mn){var Ln=Ie.runKernelFunc(er,mr,null,Ps,Gr);return mn([Kr,Zr,Ln,Un]),ct&&(Ln=Ke(Ln,[Ln.shape[1],Ln.shape[2],Ln.shape[3]])),{value:Ln,gradFunc:sr}});return Qr(He,Me,Ct)}}var c0=Ee({fusedConv2d_:u0});function l0(t,e,n,a,c,d,y){d===void 0&&(d=[1,1]);var v=t;t.rank===3&&(v=Ke(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var _=e;_.rank===3&&(_=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var C=function(U){var J=T(t.shape,n,a,d,c,y,!0);return U.depthwiseConv2DDerFilter(v,_,J)},D={x:v,dy:_},B={strides:a,pad:c,dimRoundingMode:y,dilations:d,filterShape:n};return Ie.runKernelFunc(C,D,null,Ha,B)}var Gd=Ee({depthwiseConv2dNativeBackpropFilter_:l0});function h0(t,e,n,a,c,d,y){d===void 0&&(d=[1,1]);var v=e,_=!1;e.rank===3&&(_=!0,v=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var C=function(J){var fe=T(t,n.shape,a,d,c,y,!0);return J.depthwiseConv2DDerInput(v,n,fe)},D={dy:v,filter:n},B={strides:a,pad:c,dimRoundingMode:y,dilations:d,inputShape:t},U=Ie.runKernelFunc(C,D,null,ki,B);return _?Ke(U,[U.shape[1],U.shape[2],U.shape[3]]):U}var jd=Ee({depthwiseConv2dNativeBackpropInput_:h0});function p0(t){var e=t.x,n=t.filter,a=t.strides,c=t.pad,d=t.dataFormat,y=d===void 0?"NHWC":d,v=t.dilations,_=v===void 0?[1,1]:v,C=t.dimRoundingMode,D=t.bias,B=t.activation,U=B===void 0?"linear":B,J=t.preluActivationWeights;if(jh(Ie.state.gradientDepth,U)===!1){var fe=lh(e,n,a,c,y,_,C);return D!=null&&(fe=Cr(fe,D)),Gh(fe,U,J)}var Pe=ie(e,"x","depthwiseConv2d"),Me=ie(n,"filter","depthwiseConv2d"),He=Pe,ct=!1;Pe.rank===3&&(ct=!0,He=Ke(Pe,[1,Pe.shape[0],Pe.shape[1],Pe.shape[2]])),W(He.rank===4,function(){return"Error in fused depthwiseConv2d: input must be rank 4, but got "+("rank "+He.rank+".")}),W(Me.rank===4,function(){return"Error in fused depthwiseConv2d: filter must be rank 4, "+("but got rank "+Me.rank+".")}),W(He.shape[3]===Me.shape[2],function(){return"Error in fused depthwiseConv2d: number of input channels "+("("+He.shape[3]+") must match the inChannels dimension in ")+("filter "+Me.shape[2]+".")}),_==null&&(_=[1,1]),W(dt(a,_),function(){return"Error in fused depthwiseConv2d: Either strides or dilations must "+("be 1. Got strides "+a+" and dilations '"+_+"'")}),C!=null&&W(xt(c),function(){return"Error in fused depthwiseConv2d: pad must be an integer when "+("using dimRoundingMode "+C+" but got pad "+c+".")});var It=T(He.shape,Me.shape,a,_,c,C,!0),Ct;D!=null&&(Ct=ie(D,"bias","fused conv2d"),Ct=Nt(Ct,Pe)[0],ca(It.outShape,Ct.shape));var Bt;J!=null&&(Bt=ie(J,"prelu weights","fused depthwiseConv2d"));var sr=function(Zr,Kr){W(st(_),function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations "+("'"+_+"'")});var Un=Kr[0],mn=Kr[1],Ln=Kr[2],$s=Kr[3],xi=Vh(Zr,Ln,U),Ba=jd(mn.shape,xi,Un,a,c,_,C),ko=Gd(mn,xi,Un.shape,a,c,_,C);if($s!=null){var So=Hh(Ct,xi);return[Ba,ko,So]}return[Ba,ko]},er=function(Zr){var Kr=Zr.fusedDepthwiseConv2D({input:He,filter:Me,convInfo:It,bias:Ct,activation:U,preluActivationWeights:Bt});return Kr},mr={x:He,filter:Me,bias:Ct,preluActivationWeights:Bt},Gr={strides:a,pad:c,dataFormat:y,dilations:_,dimRoundingMode:C,activation:U};if(D==null){var en=Cs(function(Zr,Kr,Un){var mn=Ie.runKernelFunc(er,mr,null,Jo,Gr);return Un([Kr,Zr,mn]),ct&&(mn=Ke(mn,[mn.shape[1],mn.shape[2],mn.shape[3]])),{value:mn,gradFunc:sr}});return en(He,Me)}else{var Qr=Cs(function(Zr,Kr,Un,mn){var Ln=Ie.runKernelFunc(er,mr,null,Jo,Gr);return mn([Kr,Zr,Ln,Un]),ct&&(Ln=Ke(Ln,[Ln.shape[1],Ln.shape[2],Ln.shape[3]])),{value:Ln,gradFunc:sr}});return Qr(He,Me,Ct)}}var d0=Ee({fusedDepthwiseConv2d_:p0});function f0(t){var e,n=t.a,a=t.b,c=t.transposeA,d=c===void 0?!1:c,y=t.transposeB,v=y===void 0?!1:y,_=t.bias,C=t.activation,D=C===void 0?"linear":C,B=t.preluActivationWeights;if(jh(Ie.state.gradientDepth,D)===!1){var U=un(n,a,d,v);return _!=null&&(U=Cr(U,_)),Gh(U,D,B)}var J=ie(n,"a","fused matMul"),fe=ie(a,"b","fused matMul");e=Nt(J,fe),J=e[0],fe=e[1];var Pe=d?J.shape[J.rank-2]:J.shape[J.rank-1],Me=v?fe.shape[fe.rank-1]:fe.shape[fe.rank-2],He=d?J.shape[J.rank-1]:J.shape[J.rank-2],ct=v?fe.shape[fe.rank-2]:fe.shape[fe.rank-1],It=J.shape.slice(0,-2),Ct=fe.shape.slice(0,-2),Bt=Tt(It),sr=Tt(Ct);W(J.rank>=2&&fe.rank>=2&&J.rank===fe.rank,function(){return"Error in fused matMul: inputs must have the same rank of at least "+("2, got ranks "+J.rank+" and "+fe.rank+".")}),W(it(It,Ct),function(){return"Error in fused matMul: outer dimensions ("+It+") and ("+(Ct+") of Tensors with shapes "+J.shape+" and ")+(fe.shape+" must match.")}),W(Pe===Me,function(){return"Error in fused matMul: inner shapes ("+Pe+") and ("+(Me+") of Tensors with shapes "+J.shape+" and ")+(fe.shape+" and transposeA="+d)+(" and transposeB="+v+" must match.")});var er=J.shape.slice(0,-2).concat([He,ct]),mr=d?Ke(J,[Bt,Pe,He]):Ke(J,[Bt,He,Pe]),Gr=v?Ke(fe,[sr,ct,Me]):Ke(fe,[sr,Me,ct]),en;_!=null&&(en=ie(_,"bias","fused matMul"),en=Nt(en,J)[0],ca(er,en.shape));var Qr;B!=null&&(Qr=ie(B,"prelu weights","fused matMul"));var Zr=function(xi,Ba){var ko=Ba[0],So=Ba[1],bu=Ba[2],zp=Ba[3],eu=Vh(Ke(xi,bu.shape),bu,D),dl,fl;if(!d&&!v?(dl=un(eu,So,!1,!0),fl=un(ko,eu,!0,!1)):!d&&v?(dl=un(eu,So,!1,!1),fl=un(eu,ko,!0,!1)):d&&!v?(dl=un(So,eu,!1,!0),fl=un(ko,eu,!1,!1)):(dl=un(So,eu,!0,!0),fl=un(eu,ko,!0,!0)),_!=null){var rg=Hh(zp,eu);return[dl,fl,rg]}else return[dl,fl]},Kr=function(xi){var Ba=xi.fusedBatchMatMul({a:mr,b:Gr,transposeA:d,transposeB:v,bias:en,activation:D,preluActivationWeights:Qr});return Ba},Un={a:mr,b:Gr,bias:en,preluActivationWeights:Qr},mn={transposeA:d,transposeB:v,activation:D};if(_==null){var Ln=Cs(function(xi,Ba,ko){var So=Ie.runKernelFunc(Kr,Un,null,Fo,mn);return ko([xi,Ba,So]),{value:Ke(So,er),gradFunc:Zr}});return Ln(mr,Gr)}else{var $s=Cs(function(xi,Ba,ko,So){var bu=Ie.runKernelFunc(Kr,Un,null,Fo,mn);return So([xi,Ba,bu,ko]),{value:Ke(bu,er),gradFunc:Zr}});return $s(mr,Gr,en)}}var m0=Ee({fusedMatMul_:f0}),y0={__proto__:null,conv2d:c0,depthwiseConv2d:d0,matMul:m0};function v0(t){return Cp(t,.54,.46)}var g0=Ee({hammingWindow_:v0});function x0(t){return Cp(t,.5,.5)}var qd=Ee({hannWindow_:x0});function _0(t,e,n,a,c){a===void 0&&(a=!1),c===void 0&&(c=0);for(var d=0,y=[];d+e<=t.size;)y.push($t(t,d,e)),d+=n;if(a)for(;d=1&&a[1]>=1,function(){return"cropSize must be atleast [1,1], but was "+a}),W(c==="bilinear"||c==="nearest",function(){return"method must be bilinear or nearest, but was "+c});var D=function(fe){return fe.cropAndResize(y,v,_,a,c,d)},B={image:y,boxes:v,boxInd:_},U={method:c,extrapolationValue:d,cropSize:a},J=Ie.runKernelFunc(D,B,null,ta,U);return J}var S0=Ee({cropAndResize_:k0});function I0(t){var e=ie(t,"image","flipLeftRight","float32");W(e.rank===4,function(){return"Error in flipLeftRight: image must be rank 4,"+("but got rank "+e.rank+".")});var n={image:e},a=Ie.runKernel(S,n,{});return a}var N0=Ee({flipLeftRight_:I0});function C0(t,e,n,a){n===void 0&&(n=0),a===void 0&&(a=.5);var c=ie(t,"image","rotateWithOffset","float32");W(c.rank===4,function(){return"Error in rotateWithOffset: image must be rank 4,"+("but got rank "+c.rank+".")});var d={image:c},y={radians:e,fillValue:n,center:a},v=Ie.runKernel(ys,d,y);return v}var T0=Ee({rotateWithOffset_:C0});function pl(t,e,n,a,c,d){a==null&&(a=.5),c==null&&(c=Number.NEGATIVE_INFINITY),d==null&&(d=0);var y=t.shape[0];return n=Math.min(n,y),W(0<=a&&a<=1,function(){return"iouThreshold must be in [0, 1], but was '"+a+"'"}),W(t.rank===2,function(){return"boxes must be a 2D tensor, but was of rank '"+t.rank+"'"}),W(t.shape[1]===4,function(){return"boxes must have 4 columns, but 2nd dimension was "+t.shape[1]}),W(e.rank===1,function(){return"scores must be a 1D tensor"}),W(e.shape[0]===y,function(){return"scores has incompatible shape with boxes. Expected "+y+", "+("but was "+e.shape[0])}),W(0<=d&&d<=1,function(){return"softNmsSigma must be in [0, 1], but was '"+d+"'"}),{maxOutputSize:n,iouThreshold:a,scoreThreshold:c,softNmsSigma:d}}function E0(t,e,n,a,c){a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY);var d=ie(t,"boxes","nonMaxSuppression"),y=ie(e,"scores","nonMaxSuppression"),v=pl(d,y,n,a,c);n=v.maxOutputSize,a=v.iouThreshold,c=v.scoreThreshold;var _={maxOutputSize:n,iouThreshold:a,scoreThreshold:c};return Ie.runKernelFunc(function(C){return C.nonMaxSuppression(d,y,n,a,c)},{boxes:d,scores:y},null,qa,_)}var R0=Ee({nonMaxSuppression_:E0});function A0(t,e,n){var a=D0(t,e,n),c=a<0?-(a+1):a;t.splice(c,0,e)}function D0(t,e,n){return O0(t,e,n||F0)}function F0(t,e){return t>e?1:t>>1);var v=n(e,t[d]);v>0?a=d+1:(c=d,y=!v)}return y?a:-a-1}function Xd(t,e,n,a,c){return Ep(t,e,n,a,c,0).selectedIndices}function Yd(t,e,n,a,c,d){return Ep(t,e,n,a,c,0,!1,d,!0)}function Qd(t,e,n,a,c,d){return Ep(t,e,n,a,c,d,!0)}function Ep(t,e,n,a,c,d,y,v,_){y===void 0&&(y=!1),v===void 0&&(v=!1),_===void 0&&(_=!1);for(var C=[],D=0;Dc&&C.push({score:e[D],boxIndex:D,suppressBeginIndex:0});C.sort(Zd);for(var B=d>0?-.5/d:0,U=[],J=[];U.length0;){var fe=C.pop(),Pe=fe.score,Me=fe.boxIndex,He=fe.suppressBeginIndex;if(Pe=He;--It){var Ct=M0(t,Me,U[It]);if(Ct>=a){ct=!0;break}if(fe.score=fe.score*L0(a,B,Ct),fe.score<=c)break}fe.suppressBeginIndex=U.length,ct||(fe.score===Pe?(U.push(Me),J.push(fe.score)):fe.score>c&&A0(C,fe,Zd))}var Bt=U.length,sr=n-Bt;v&&sr>0&&(U.push.apply(U,new Array(sr).fill(0)),J.push.apply(J,new Array(sr).fill(0)));var er={selectedIndices:cl(U,"int32")};return y&&(er.selectedScores=cl(J,"float32")),_&&(er.validOutputs=Wr(Bt,"int32")),er}function M0(t,e,n){var a=t.subarray(e*4,e*4+4),c=t.subarray(n*4,n*4+4),d=Math.min(a[0],a[2]),y=Math.min(a[1],a[3]),v=Math.max(a[0],a[2]),_=Math.max(a[1],a[3]),C=Math.min(c[0],c[2]),D=Math.min(c[1],c[3]),B=Math.max(c[0],c[2]),U=Math.max(c[1],c[3]),J=(v-d)*(_-y),fe=(B-C)*(U-D);if(J<=0||fe<=0)return 0;var Pe=Math.max(d,C),Me=Math.max(y,D),He=Math.min(v,B),ct=Math.min(_,U),It=Math.max(He-Pe,0)*Math.max(ct-Me,0);return It/(J+fe-It)}function L0(t,e,n){var a=Math.exp(e*n*n);return n<=t?a:0}function Zd(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}function z0(t,e,n,a,c){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),O(this,void 0,void 0,function(){var d,y,v,_,C,D,B;return H(this,function(U){switch(U.label){case 0:return d=ie(t,"boxes","nonMaxSuppressionAsync"),y=ie(e,"scores","nonMaxSuppressionAsync"),v=pl(d,y,n,a,c),n=v.maxOutputSize,a=v.iouThreshold,c=v.scoreThreshold,[4,Promise.all([d.data(),y.data()])];case 1:return _=U.sent(),C=_[0],D=_[1],B=Xd(C,D,n,a,c),d!==t&&d.dispose(),y!==e&&y.dispose(),[2,B]}})})}var P0=z0;function B0(t,e,n,a,c,d){a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=0);var y=ie(t,"boxes","nonMaxSuppression"),v=ie(e,"scores","nonMaxSuppression"),_=pl(y,v,n,a,c,d);n=_.maxOutputSize,a=_.iouThreshold,c=_.scoreThreshold,d=_.softNmsSigma;var C={boxes:y,scores:v},D={maxOutputSize:n,iouThreshold:a,scoreThreshold:c,softNmsSigma:d},B=Ie.runKernel(Ki,C,D);return{selectedIndices:B[0],selectedScores:B[1]}}var W0=Ee({nonMaxSuppressionWithScore_:B0});function U0(t,e,n,a,c,d){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=0),O(this,void 0,void 0,function(){var y,v,_,C,D,B,U;return H(this,function(J){switch(J.label){case 0:return y=ie(t,"boxes","nonMaxSuppressionAsync"),v=ie(e,"scores","nonMaxSuppressionAsync"),_=pl(y,v,n,a,c,d),n=_.maxOutputSize,a=_.iouThreshold,c=_.scoreThreshold,d=_.softNmsSigma,[4,Promise.all([y.data(),v.data()])];case 1:return C=J.sent(),D=C[0],B=C[1],U=Qd(D,B,n,a,c,d),y!==t&&y.dispose(),v!==e&&v.dispose(),[2,U]}})})}var V0=U0;function H0(t,e,n,a,c,d){a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=!1);var y=ie(t,"boxes","nonMaxSuppression"),v=ie(e,"scores","nonMaxSuppression"),_=pl(y,v,n,a,c,null),C=_.maxOutputSize,D=_.iouThreshold,B=_.scoreThreshold,U={boxes:y,scores:v},J={maxOutputSize:C,iouThreshold:D,scoreThreshold:B,padToMaxOutputSize:d},fe=Ie.runKernel(La,U,J);return{selectedIndices:fe[0],validOutputs:fe[1]}}var G0=Ee({nonMaxSuppressionPadded_:H0});function j0(t,e,n,a,c,d){return a===void 0&&(a=.5),c===void 0&&(c=Number.NEGATIVE_INFINITY),d===void 0&&(d=!1),O(this,void 0,void 0,function(){var y,v,_,C,D,B,U,J,fe,Pe;return H(this,function(Me){switch(Me.label){case 0:return y=ie(t,"boxes","nonMaxSuppressionAsync"),v=ie(e,"scores","nonMaxSuppressionAsync"),_=pl(y,v,n,a,c,null),C=_.maxOutputSize,D=_.iouThreshold,B=_.scoreThreshold,[4,Promise.all([y.data(),v.data()])];case 1:return U=Me.sent(),J=U[0],fe=U[1],Pe=Yd(J,fe,C,D,B,d),y!==t&&y.dispose(),v!==e&&v.dispose(),[2,Pe]}})})}var q0=j0;function K0(t,e,n){n===void 0&&(n=!1);var a=ie(t,"images","resizeBilinear");W(a.rank===3||a.rank===4,function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got "+("rank "+a.rank+".")}),W(e.length===2,function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+(e+".")});var c=a,d=!1;a.rank===3&&(d=!0,c=Ke(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var y=e[0],v=e[1],_=function(U,J){return J([c]),U.resizeBilinear(c,y,v,n)},C={images:c},D={alignCorners:n,size:e},B=Ie.runKernelFunc(_,C,null,Qn,D);return d?Ke(B,[B.shape[1],B.shape[2],B.shape[3]]):B}var Jd=Ee({resizeBilinear_:K0});function X0(t,e,n){n===void 0&&(n=!1);var a=ie(t,"images","resizeNearestNeighbor");W(a.rank===3||a.rank===4,function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got "+("rank "+a.rank+".")}),W(e.length===2,function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+(e+".")}),W(a.dtype==="float32"||a.dtype==="int32",function(){return"`images` must have `int32` or `float32` as dtype"});var c=a,d=!1;a.rank===3&&(d=!0,c=Ke(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var y=e[0],v=e[1],_={images:c},C={alignCorners:n,size:e},D=function(U,J){return J([c]),U.resizeNearestNeighbor(c,y,v,n)},B=Ie.runKernelFunc(D,_,null,oa,C);return d?Ke(B,[B.shape[1],B.shape[2],B.shape[3]]):B}var $d=Ee({resizeNearestNeighbor_:X0});function Y0(t,e,n){W(e%1===0,function(){return"bandPart(): numLower must be an integer, got "+e+"."}),W(n%1===0,function(){return"bandPart(): numUpper must be an integer, got "+n+"."});var a=ie(t,"a","bandPart");W(a.rank>=2,function(){return"bandPart(): Rank must be at least 2, got "+a.rank+"."});var c=a.shape,d=a.shape.slice(-2),y=d[0],v=d[1];if(!(e<=y))throw new Error("bandPart(): numLower ("+e+")"+(" must not be greater than the number of rows ("+y+")."));if(!(n<=v))throw new Error("bandPart(): numUpper ("+n+")"+(" must not be greater than the number of columns ("+v+")."));e<0&&(e=y),n<0&&(n=v);var _=Ke(_p(0,y,1,"int32"),[-1,1]),C=_p(0,v,1,"int32"),D=zr(_,C),B=nc(ec(D,Wr(+e,"int32")),$u(D,Wr(-n,"int32"))),U=Ys([y,v],a.dtype);return Ke(sc(Wh(Ke(a,[-1,y,v])).map(function(J){return us(B,J,U)})),c)}var Q0=Ee({bandPart_:Y0});function Z0(t){var e;if(Array.isArray(t)){e=!1,W(t!=null&&t.length>0,function(){return"Gram-Schmidt process: input must not be null, undefined, or empty"});for(var n=t[0].shape[0],a=function(_){W(t[_].shape[0]===n,function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: "+("("+t[_].shape[0]+" vs. "+n+")")})},c=1;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 ef(t,e);var n=t.shape.slice(0,t.shape.length-2).reduce(function(_,C){return _*C}),a=Wh(Ke(t,[n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),c=[],d=[];a.forEach(function(_){var C=ef(_,e),D=C[0],B=C[1];c.push(D),d.push(B)});var y=Ke(sc(c,0),t.shape),v=Ke(sc(d,0),t.shape);return[y,v]}function ef(t,e){return e===void 0&&(e=!1),Ie.tidy(function(){W(t.shape.length===2,function(){return"qr2d() requires a 2D Tensor, but got a "+t.shape.length+"D Tensor."});for(var n=t.shape[0],a=t.shape[1],c=$p(n),d=Ho(t),y=yh([[1]],[1,1]),v=Ho(y),_=n>=a?a:n,C=function(B){var U,J=d,fe=v,Pe=c;U=Ie.tidy(function(){var Me=$t(d,[B,B],[n-B,1]),He=Uh(Me),ct=$t(d,[B,B],[1,1]),It=us(_u(ct,0),yh([[-1]]),yh([[1]])),Ct=zr(ct,bt(It,He)),Bt=Br(Me,Ct);Bt.shape[0]===1?v=Ho(y):v=kr([y,$t(Bt,[1,0],[Bt.shape[0]-1,Bt.shape[1]])],0);var sr=$a(Br(un(It,Ct),He)),er=$t(d,[B,0],[n-B,a]),mr=bt(sr,v),Gr=$n(v);if(B===0)d=zr(er,un(mr,un(Gr,er)));else{var en=zr(er,un(mr,un(Gr,er)));d=kr([$t(d,[0,0],[B,a]),en],0)}var Qr=$n(mr),Zr=$t(c,[0,B],[n,c.shape[1]-B]);if(B===0)c=zr(Zr,un(un(Zr,v),Qr));else{var Kr=zr(Zr,un(un(Zr,v),Qr));c=kr([$t(c,[0,0],[n,B]),Kr],1)}return[v,d,c]}),v=U[0],d=U[1],c=U[2],Pa([J,fe,Pe])},D=0;D<_;++D)C(D);return!e&&n>a&&(c=$t(c,[0,0],[n,a]),d=$t(d,[0,0],[a,a])),[c,d]})}var e2=Ee({qr_:$0});(function(t){t[t.NONE=0]="NONE",t[t.MEAN=1]="MEAN",t[t.SUM=2]="SUM",t[t.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"})(N.Reduction||(N.Reduction={}));function t2(t,e,n){n===void 0&&(n=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=ie(t,"losses","computeWeightedLoss"),c=null;e!=null&&(c=ie(e,"weights","computeWeightedLoss"));var d=c==null?a:bt(a,c);if(n===N.Reduction.NONE)return d;if(n===N.Reduction.SUM)return Yr(d);if(n===N.Reduction.MEAN){if(c==null)return ph(d);var y=a.size/c.size,v=Br(Yr(d),Yr(c));return y>1?Br(v,Wr(y)):v}if(n===N.Reduction.SUM_BY_NONZERO_WEIGHTS){if(c==null)return Br(Yr(d),Wr(a.size));var _=bt(c,sl(a.shape)),C=pr(Yr(Oh(_,Wr(0))),"float32");return Br(Yr(d),C)}throw Error("Unknown reduction: "+n)}var Js=Ee({computeWeightedLoss_:t2});function r2(t,e,n,a){a===void 0&&(a=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var c=ie(t,"labels","absoluteDifference"),d=ie(e,"predictions","absoluteDifference"),y=null;n!=null&&(y=ie(n,"weights","absoluteDifference")),nt(c.shape,d.shape,"Error in absoluteDifference: ");var v=ui(zr(c,d));return Js(v,y,a)}var n2=Ee({absoluteDifference_:r2});function a2(t,e,n,a,c){c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"labels","cosineDistance"),y=ie(e,"predictions","cosineDistance"),v=null;a!=null&&(v=ie(a,"weights","cosineDistance")),nt(d.shape,y.shape,"Error in cosineDistance: ");var _=Wr(1),C=zr(_,Yr(bt(d,y),n,!0));return Js(C,v,c)}var i2=Ee({cosineDistance_:a2});function o2(t,e,n,a){a===void 0&&(a=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var c=ie(t,"labels","hingeLoss"),d=ie(e,"predictions","hingeLoss"),y=null;n!=null&&(y=ie(n,"weights","hingeLoss")),nt(c.shape,d.shape,"Error in hingeLoss: ");var v=Wr(1);c=zr(bt(Wr(2),c),v);var _=fh(zr(v,bt(c,d)));return Js(_,y,a)}var s2=Ee({hingeLoss_:o2});function u2(t,e,n,a,c){a===void 0&&(a=1),c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"labels","huberLoss"),y=ie(e,"predictions","huberLoss"),v=null;n!=null&&(v=ie(n,"weights","huberLoss")),nt(d.shape,y.shape,"Error in huberLoss: ");var _=Wr(a),C=ui(zr(y,d)),D=Fh(C,_),B=zr(C,D),U=Cr(bt(Wr(.5),Yn(D)),bt(_,B));return Js(U,v,c)}var c2=Ee({huberLoss_:u2});function l2(t,e,n,a,c){a===void 0&&(a=1e-7),c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"labels","logLoss"),y=ie(e,"predictions","logLoss"),v=null;n!=null&&(v=ie(n,"weights","logLoss")),nt(d.shape,y.shape,"Error in logLoss: ");var _=Wr(1),C=Wr(a),D=$a(bt(d,tc(Cr(y,C)))),B=bt(zr(_,d),tc(Cr(zr(_,y),C))),U=zr(D,B);return Js(U,v,c)}var h2=Ee({logLoss_:l2});function p2(t,e,n,a){a===void 0&&(a=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var c=ie(t,"labels","meanSquaredError"),d=ie(e,"predictions","meanSquaredError"),y=null;n!=null&&(y=ie(n,"weights","meanSquaredError")),nt(c.shape,d.shape,"Error in meanSquaredError: ");var v=Ph(c,d);return Js(v,y,a)}var d2=Ee({meanSquaredError_:p2});function f2(t,e){var n=ie(t,"labels","sigmoidCrossEntropyWithLogits"),a=ie(e,"logits","sigmoidCrossEntropyWithLogits");nt(n.shape,a.shape,"Error in sigmoidCrossEntropyWithLogits: ");var c=fh(a),d=bt(a,n),y=lp(cs($a(ui(a))));return Cr(zr(c,d),y)}function m2(t,e,n,a,c){a===void 0&&(a=0),c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"multiClassLabels","sigmoidCrossEntropy"),y=ie(e,"logits","sigmoidCrossEntropy"),v=null;if(n!=null&&(v=ie(n,"weights","sigmoidCrossEntropy")),nt(d.shape,y.shape,"Error in sigmoidCrossEntropy: "),a>0){var _=Wr(a),C=Wr(1),D=Wr(.5);d=Cr(bt(d,zr(C,_)),bt(D,_))}var B=f2(d,y);return Js(B,v,c)}var y2=Ee({sigmoidCrossEntropy_:m2});function v2(t,e,n){if(n===void 0&&(n=-1),n===-1&&(n=e.rank-1),n!==e.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet "+("supported. Labels / logits was rank "+e.rank+" ")+("and dim was "+n));var a=Cs(function(c,d,y){var v=!0,_=pp(d,[n],v),C=zr(pr(d,"float32"),_);y([c,C]);var D=$a(bt(C,c)),B=Yr(D,[n]),U=function(J,fe){var Pe=fe[0],Me=fe[1],He=ci(J.shape,[n]);return[bt(Ke(J,He),zr(pr(Pe,"float32"),cs(Me))),bt(Ke(J,He),zr(cs(Me),pr(Pe,"float32")))]};return{value:B,gradFunc:U}});return a(t,e)}function g2(t,e,n,a,c){a===void 0&&(a=0),c===void 0&&(c=N.Reduction.SUM_BY_NONZERO_WEIGHTS);var d=ie(t,"onehotLabels","softmaxCrossEntropy"),y=ie(e,"logits","softmaxCrossEntropy"),v=null;if(n!=null&&(v=ie(n,"weights","softmaxCrossEntropy")),nt(d.shape,y.shape,"Error in softmaxCrossEntropy: "),a>0){var _=Wr(a),C=Wr(1),D=Wr(d.shape[1]);d=Cr(bt(d,zr(C,_)),Br(_,D))}var B=v2(d,y);return Js(B,v,c)}var x2=Ee({softmaxCrossEntropy_:g2}),_2={fft:Lh,ifft:mh,rfft:zh,irfft:Ip},w2={hammingWindow:g0,hannWindow:qd,frame:Kd,stft:b0},b2={flipLeftRight:N0,resizeNearestNeighbor:$d,resizeBilinear:Jd,rotateWithOffset:T0,cropAndResize:S0,nonMaxSuppression:R0,nonMaxSuppressionAsync:P0,nonMaxSuppressionWithScore:W0,nonMaxSuppressionWithScoreAsync:V0,nonMaxSuppressionPadded:G0,nonMaxSuppressionPaddedAsync:q0},k2={bandPart:Q0,gramSchmidt:J0,qr:e2},S2={absoluteDifference:n2,computeWeightedLoss:Js,cosineDistance:i2,hingeLoss:s2,huberLoss:c2,logLoss:h2,meanSquaredError:d2,sigmoidCrossEntropy:y2,softmaxCrossEntropy:x2},wu=function(t){ke(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.minimize=function(n,a,c){a===void 0&&(a=!1);var d=this.computeGradients(n,c),y=d.value,v=d.grads;if(c!=null){var _=c.map(function(C){return{name:C.name,tensor:v[C.name]}});this.applyGradients(_)}else this.applyGradients(v);return Pa(v),a?y:(y.dispose(),null)},Object.defineProperty(e.prototype,"iterations",{get:function(){return this.iterations_==null&&(this.iterations_=0),this.iterations_},enumerable:!0,configurable:!0}),e.prototype.incrementIterations=function(){this.iterations_=this.iterations+1},e.prototype.computeGradients=function(n,a){return od(n,a)},e.prototype.dispose=function(){this.iterations_!=null&&Pa(this.iterations_)},e.prototype.saveIterations=function(){return O(this,void 0,void 0,function(){return H(this,function(n){return this.iterations_==null&&(this.iterations_=0),[2,{name:"iter",tensor:Wr(this.iterations_,"int32")}]})})},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){throw new Error("getWeights() is not implemented for this optimizer yet.")})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){return H(this,function(a){throw new Error("setWeights() is not implemented for this optimizer class "+(""+this.getClassName()))})})},e.prototype.extractIterations=function(n){return O(this,void 0,void 0,function(){var a;return H(this,function(c){switch(c.label){case 0:return a=this,[4,n[0].tensor.data()];case 1:return a.iterations_=c.sent()[0],[2,n.slice(1)]}})})},e}(Yc);Object.defineProperty(wu,Symbol.hasInstance,{value:function(t){return t.minimize!=null&&t.computeGradients!=null&&t.applyGradients!=null}});var Rp=function(t){ke(e,t);function e(n,a,c){c===void 0&&(c=null);var d=t.call(this)||this;return d.learningRate=n,d.rho=a,d.epsilon=c,d.accumulatedGrads=[],d.accumulatedUpdates=[],c==null&&(d.epsilon=Ie.backend.epsilon()),d}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Ie.registeredVariables[d],_=!1;a.accumulatedGrads[y]==null&&(a.accumulatedGrads[y]={originalName:d+"/accum_grad",variable:sa(function(){return gn(v).variable(_)})}),a.accumulatedUpdates[y]==null&&(a.accumulatedUpdates[y]={originalName:d+"/accum_var",variable:sa(function(){return gn(v).variable(_)})});var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var D=a.accumulatedGrads[y].variable,B=a.accumulatedUpdates[y].variable;sa(function(){var U=Cr(bt(D,a.rho),bt(Yn(C),1-a.rho)),J=bt(Br(eo(Cr(B,a.epsilon)),eo(Cr(D,a.epsilon))),C),fe=Cr(bt(B,a.rho),bt(Yn(J),1-a.rho));D.assign(U),B.assign(fe);var Pe=Cr(bt(J,-a.learningRate),v);v.assign(Pe)})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedUpdates!=null&&(Pa(this.accumulatedGrads.map(function(n){return n.variable})),Pa(this.accumulatedUpdates.map(function(n){return n.variable})))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){var n;return H(this,function(a){switch(a.label){case 0:return n=this.accumulatedGrads.concat(this.accumulatedUpdates),[4,this.saveIterations()];case 1:return[2,[a.sent()].concat(n.map(function(c){return{name:c.originalName,tensor:c.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a,c;return H(this,function(d){switch(d.label){case 0:return[4,this.extractIterations(n)];case 1:return n=d.sent(),a=n.length/2,c=!1,this.accumulatedGrads=n.slice(0,a).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}}),this.accumulatedUpdates=n.slice(a,a*2).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}}),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}},e.fromConfig=function(n,a){return new n(a.learningRate,a.rho,a.epsilon)},e.className="Adadelta",e}(wu);jo(Rp);var Ap=function(t){ke(e,t);function e(n,a){a===void 0&&(a=.1);var c=t.call(this)||this;return c.learningRate=n,c.initialAccumulatorValue=a,c.accumulatedGrads=[],c}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Ie.registeredVariables[d];if(a.accumulatedGrads[y]==null){var _=!1;a.accumulatedGrads[y]={originalName:d+"/accumulator",variable:sa(function(){return up(v.shape,a.initialAccumulatorValue).variable(_)})}}var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var D=a.accumulatedGrads[y].variable;sa(function(){var B=Cr(D,Yn(C));D.assign(B);var U=Cr(bt(Br(C,eo(Cr(B,Ie.backend.epsilon()))),-a.learningRate),v);v.assign(U)})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedGrads!=null&&Pa(this.accumulatedGrads.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){switch(n.label){case 0:return[4,this.saveIterations()];case 1:return[2,[n.sent()].concat(this.accumulatedGrads.map(function(a){return{name:a.originalName,tensor:a.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a;return H(this,function(c){switch(c.label){case 0:return[4,this.extractIterations(n)];case 1:return n=c.sent(),a=!1,this.accumulatedGrads=n.map(function(d){return{originalName:d.name,variable:d.tensor.variable(a)}}),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}},e.fromConfig=function(n,a){return new n(a.learningRate,a.initialAccumulatorValue)},e.className="Adagrad",e}(wu);jo(Ap);var Dp=function(t){ke(e,t);function e(n,a,c,d){d===void 0&&(d=null);var y=t.call(this)||this;return y.learningRate=n,y.beta1=a,y.beta2=c,y.epsilon=d,y.accumulatedFirstMoment=[],y.accumulatedSecondMoment=[],sa(function(){y.accBeta1=Wr(a).variable(),y.accBeta2=Wr(c).variable()}),d==null&&(y.epsilon=Ie.backend.epsilon()),y}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);sa(function(){var d=zr(1,a.accBeta1),y=zr(1,a.accBeta2);c.forEach(function(v,_){var C=Ie.registeredVariables[v],D=!1;a.accumulatedFirstMoment[_]==null&&(a.accumulatedFirstMoment[_]={originalName:v+"/m",variable:sa(function(){return gn(C).variable(D)})}),a.accumulatedSecondMoment[_]==null&&(a.accumulatedSecondMoment[_]={originalName:v+"/v",variable:sa(function(){return gn(C).variable(D)})});var B=Array.isArray(n)?n[_].tensor:n[v];if(B==null)return;var U=a.accumulatedFirstMoment[_].variable,J=a.accumulatedSecondMoment[_].variable,fe=Cr(bt(U,a.beta1),bt(B,1-a.beta1)),Pe=Cr(bt(J,a.beta2),bt(Yn(B),1-a.beta2)),Me=Br(fe,d),He=Br(Pe,y);U.assign(fe),J.assign(Pe);var ct=Cr(bt(Br(Me,Cr(eo(He),a.epsilon)),-a.learningRate),C);C.assign(ct)}),a.accBeta1.assign(bt(a.accBeta1,a.beta1)),a.accBeta2.assign(bt(a.accBeta2,a.beta2))}),this.incrementIterations()},e.prototype.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&Pa(this.accumulatedFirstMoment.map(function(n){return n.variable})),this.accumulatedSecondMoment!=null&&Pa(this.accumulatedSecondMoment.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){var n;return H(this,function(a){switch(a.label){case 0:return n=this.accumulatedFirstMoment.concat(this.accumulatedSecondMoment),[4,this.saveIterations()];case 1:return[2,[a.sent()].concat(n.map(function(c){return{name:c.originalName,tensor:c.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a,c,d=this;return H(this,function(y){switch(y.label){case 0:return[4,this.extractIterations(n)];case 1:return n=y.sent(),sa(function(){d.accBeta1.assign(Qs(d.beta1,d.iterations_+1)),d.accBeta2.assign(Qs(d.beta2,d.iterations_+1))}),a=n.length/2,c=!1,this.accumulatedFirstMoment=n.slice(0,a).map(function(v){return{originalName:v.name,variable:v.tensor.variable(c)}}),this.accumulatedSecondMoment=n.slice(a,a*2).map(function(v){return{originalName:v.name,variable:v.tensor.variable(c)}}),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}},e.fromConfig=function(n,a){return new n(a.learningRate,a.beta1,a.beta2,a.epsilon)},e.className="Adam",e}(wu);jo(Dp);var Fp=function(t){ke(e,t);function e(n,a,c,d,y){d===void 0&&(d=null),y===void 0&&(y=0);var v=t.call(this)||this;return v.learningRate=n,v.beta1=a,v.beta2=c,v.epsilon=d,v.decay=y,v.accumulatedFirstMoment=[],v.accumulatedWeightedInfNorm=[],sa(function(){v.iteration=Wr(0).variable(),v.accBeta1=Wr(a).variable()}),d==null&&(v.epsilon=Ie.backend.epsilon()),v}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);sa(function(){var d=zr(1,a.accBeta1),y=Br(-a.learningRate,Cr(bt(a.iteration,a.decay),1));c.forEach(function(v,_){var C=Ie.registeredVariables[v],D=!1;a.accumulatedFirstMoment[_]==null&&(a.accumulatedFirstMoment[_]={originalName:v+"/m",variable:gn(C).variable(D)}),a.accumulatedWeightedInfNorm[_]==null&&(a.accumulatedWeightedInfNorm[_]={originalName:v+"/v",variable:gn(C).variable(D)});var B=Array.isArray(n)?n[_].tensor:n[v];if(B==null)return;var U=a.accumulatedFirstMoment[_].variable,J=a.accumulatedWeightedInfNorm[_].variable,fe=Cr(bt(U,a.beta1),bt(B,1-a.beta1)),Pe=bt(J,a.beta2),Me=ui(B),He=ol(Pe,Me);U.assign(fe),J.assign(He);var ct=Cr(bt(Br(y,d),Br(fe,Cr(He,a.epsilon))),C);C.assign(ct)}),a.iteration.assign(Cr(a.iteration,1)),a.accBeta1.assign(bt(a.accBeta1,a.beta1))}),this.incrementIterations()},e.prototype.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&Pa(this.accumulatedFirstMoment.map(function(n){return n.variable})),this.accumulatedWeightedInfNorm!=null&&Pa(this.accumulatedWeightedInfNorm.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){throw new Error("getWeights() is not implemented for Adamax yet.")})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){return H(this,function(a){throw new Error("setWeights() is not implemented for Adamax yet.")})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}},e.fromConfig=function(n,a){return new n(a.learningRate,a.beta1,a.beta2,a.epsilon,a.decay)},e.className="Adamax",e}(wu);jo(Fp);var qh=function(t){ke(e,t);function e(n){var a=t.call(this)||this;return a.learningRate=n,a.setLearningRate(n),a}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Array.isArray(n)?n[y].tensor:n[d];if(v==null)return;var _=Ie.registeredVariables[d];sa(function(){var C=Cr(bt(a.c,v),_);_.assign(C)})}),this.incrementIterations()},e.prototype.setLearningRate=function(n){this.learningRate=n,this.c!=null&&this.c.dispose(),this.c=xu(Wr(-n))},e.prototype.dispose=function(){this.c.dispose()},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){switch(n.label){case 0:return[4,this.saveIterations()];case 1:return[2,[n.sent()]]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){return H(this,function(a){switch(a.label){case 0:return[4,this.extractIterations(n)];case 1:if(n=a.sent(),n.length!==0)throw new Error("SGD optimizer does not have settable weights.");return[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate}},e.fromConfig=function(n,a){return new n(a.learningRate)},e.className="SGD",e}(wu);jo(qh);var Op=function(t){ke(e,t);function e(n,a,c){c===void 0&&(c=!1);var d=t.call(this,n)||this;return d.learningRate=n,d.momentum=a,d.useNesterov=c,d.accumulations=[],d.m=Wr(d.momentum),d}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Ie.registeredVariables[d];if(a.accumulations[y]==null){var _=!1;a.accumulations[y]={originalName:d+"/momentum",variable:sa(function(){return gn(v).variable(_)})}}var C=a.accumulations[y].variable,D=Array.isArray(n)?n[y].tensor:n[d];if(D==null)return;sa(function(){var B,U=Cr(bt(a.m,C),D);a.useNesterov?B=Cr(bt(a.c,Cr(D,bt(U,a.m))),v):B=Cr(bt(a.c,U),v),C.assign(U),v.assign(B)})}),this.incrementIterations()},e.prototype.dispose=function(){this.m.dispose(),this.accumulations!=null&&Pa(this.accumulations.map(function(n){return n.variable}))},e.prototype.setMomentum=function(n){this.momentum=n},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){return H(this,function(n){switch(n.label){case 0:return[4,this.saveIterations()];case 1:return[2,[n.sent()].concat(this.accumulations.map(function(a){return{name:a.originalName,tensor:a.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a;return H(this,function(c){switch(c.label){case 0:return[4,this.extractIterations(n)];case 1:return n=c.sent(),a=!1,this.accumulations=n.map(function(d){return{originalName:d.name,variable:d.tensor.variable(a)}}),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}},e.fromConfig=function(n,a){return new n(a.learningRate,a.momentum,a.useNesterov)},e.className="Momentum",e}(qh);jo(Op);var Mp=function(t){ke(e,t);function e(n,a,c,d,y){a===void 0&&(a=.9),c===void 0&&(c=0),d===void 0&&(d=null),y===void 0&&(y=!1);var v=t.call(this)||this;if(v.learningRate=n,v.decay=a,v.momentum=c,v.epsilon=d,v.accumulatedMeanSquares=[],v.accumulatedMoments=[],v.accumulatedMeanGrads=[],v.centered=y,d==null&&(v.epsilon=Ie.backend.epsilon()),n==null)throw new Error("learningRate for RMSPropOptimizer must be defined.");return v}return e.prototype.applyGradients=function(n){var a=this,c=Array.isArray(n)?n.map(function(d){return d.name}):Object.keys(n);c.forEach(function(d,y){var v=Ie.registeredVariables[d],_=!1;a.accumulatedMeanSquares[y]==null&&(a.accumulatedMeanSquares[y]={originalName:d+"/rms",variable:sa(function(){return gn(v).variable(_)})}),a.accumulatedMoments[y]==null&&(a.accumulatedMoments[y]={originalName:d+"/momentum",variable:sa(function(){return gn(v).variable(_)})}),a.accumulatedMeanGrads[y]==null&&a.centered&&(a.accumulatedMeanGrads[y]={originalName:d+"/mg",variable:sa(function(){return gn(v).variable(_)})});var C=Array.isArray(n)?n[y].tensor:n[d];if(C==null)return;var D=a.accumulatedMeanSquares[y].variable,B=a.accumulatedMoments[y].variable;sa(function(){var U=Cr(bt(D,a.decay),bt(Yn(C),1-a.decay));if(a.centered){var J=a.accumulatedMeanGrads[y].variable,fe=Cr(bt(J,a.decay),bt(C,1-a.decay)),Pe=Br(bt(C,a.learningRate),eo(zr(U,Cr(Yn(fe),a.epsilon)))),Me=Cr(bt(B,a.momentum),Pe);D.assign(U),J.assign(fe),B.assign(Me);var He=zr(v,Me);v.assign(He)}else{var ct=Cr(bt(D,a.decay),bt(Yn(C),1-a.decay)),Me=Cr(bt(B,a.momentum),Br(bt(C,a.learningRate),eo(Cr(ct,a.epsilon))));D.assign(ct),B.assign(Me);var He=zr(v,Me);v.assign(He)}})}),this.incrementIterations()},e.prototype.dispose=function(){this.accumulatedMeanSquares!=null&&Pa(this.accumulatedMeanSquares.map(function(n){return n.variable})),this.accumulatedMeanGrads!=null&&this.centered&&Pa(this.accumulatedMeanGrads.map(function(n){return n.variable})),this.accumulatedMoments!=null&&Pa(this.accumulatedMoments.map(function(n){return n.variable}))},e.prototype.getWeights=function(){return O(this,void 0,void 0,function(){var n;return H(this,function(a){switch(a.label){case 0:return n=this.accumulatedMeanSquares.concat(this.accumulatedMoments),this.centered&&n.push.apply(n,this.accumulatedMeanGrads),[4,this.saveIterations()];case 1:return[2,[a.sent()].concat(n.map(function(c){return{name:c.originalName,tensor:c.variable}}))]}})})},e.prototype.setWeights=function(n){return O(this,void 0,void 0,function(){var a,c;return H(this,function(d){switch(d.label){case 0:return[4,this.extractIterations(n)];case 1:return n=d.sent(),a=this.centered?n.length/3:n.length/2,c=!1,this.accumulatedMeanSquares=n.slice(0,a).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}}),this.accumulatedMoments=n.slice(a,a*2).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}}),this.centered&&(this.accumulatedMeanGrads=n.slice(a*2,a*3).map(function(y){return{originalName:y.name,variable:y.tensor.variable(c)}})),[2]}})})},e.prototype.getConfig=function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}},e.fromConfig=function(n,a){return new n(a.learningRate,a.decay,a.momentum,a.epsilon,a.centered)},e.className="RMSProp",e}(wu);jo(Mp);var uc=function(){function t(){}return t.sgd=function(e){return new qh(e)},t.momentum=function(e,n,a){return a===void 0&&(a=!1),new Op(e,n,a)},t.rmsprop=function(e,n,a,c,d){return n===void 0&&(n=.9),a===void 0&&(a=0),c===void 0&&(c=null),d===void 0&&(d=!1),new Mp(e,n,a,c,d)},t.adam=function(e,n,a,c){return e===void 0&&(e=.001),n===void 0&&(n=.9),a===void 0&&(a=.999),c===void 0&&(c=null),new Dp(e,n,a,c)},t.adadelta=function(e,n,a){return e===void 0&&(e=.001),n===void 0&&(n=.95),a===void 0&&(a=null),new Rp(e,n,a)},t.adamax=function(e,n,a,c,d){return e===void 0&&(e=.002),n===void 0&&(n=.9),a===void 0&&(a=.999),c===void 0&&(c=null),d===void 0&&(d=0),new Fp(e,n,a,c,d)},t.adagrad=function(e,n){return n===void 0&&(n=.1),new Ap(e,n)},t}(),I2={sgd:uc.sgd,momentum:uc.momentum,adadelta:uc.adadelta,adagrad:uc.adagrad,rmsprop:uc.rmsprop,adamax:uc.adamax,adam:uc.adam},N2=function(){return typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:function(t){return t()}}();function C2(){return new Promise(function(t){return N2(function(){return t()})})}function T2(t,e,n){var a=n*(typeof t=="number"?t:t[0]),c=e*(typeof t=="number"?t:t[1]);return[a,c]}function E2(t,e,n,a){a===void 0&&(a=!0);var c=[];if(a)c=c.concat(e.slice(0)),c.push(t[0]/n),c=c.concat(t.slice(1));else{c=c.concat(t[0]);for(var d=e.length,y=0;y=e*2+1||c%2===1?y.push(c):d.push(c);a.push.apply(a,d),a.push(0),a.push.apply(a,y)}return a}function A2(t,e,n,a){a===void 0&&(a=!0);var c=[];a?c.push(t[0]/n):c.push(t[0]*n);for(var d=1;d0&&(v=Yr(v,_)),Ke(v,n.shape)},y=function(){var v=t,_=Ja(a.shape,c);return _.length>0&&(v=Yr(v,_)),Ke(v,a.shape)};return{a:d,b:y}}},uv={kernelName:di,saveAllInputs:!0,gradFunc:function(t,e){var n={};return e.forEach(function(a,c){n[c]=function(){return t.clone()}}),n}},cv={kernelName:ln,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return gn(n)}}}},lv={kernelName:ni,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return gn(n)}}}},hv={kernelName:gr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,eo(zr(Wr(1),Yn(pr(n,"float32")))))}}}},pv={kernelName:Di,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=eo(Cr(Wr(1),Yn(pr(n,"float32"))));return Br(t,a)}}}},dv={kernelName:Zn,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=Cr(Yn(n),Yn(a)),_=bt(t,Br(a,v)),C=Ja(n.shape,c);return C.length>0&&(_=Yr(_,C)),Ke(_,n.shape)},y=function(){var v=Cr(Yn(n),Yn(a)),_=$a(bt(t,Br(n,v))),C=Ja(a.shape,c);return C.length>0&&(_=Yr(_,C)),Ke(_,a.shape)};return{a:d,b:y}}},fv={kernelName:bi,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,Cr(Yn(pr(n,"float32")),1))}}}},mv={kernelName:ro,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,zr(Wr(1),Yn(pr(n,"float32"))))}}}};function yv(t,e,n,a,c,d,y){c===void 0&&(c=[1,1,1]);var v=ie(t,"dy","avgPool3dBackprop"),_=ie(e,"input","avgPool3dBackprop"),C=v,D=_,B=!1;_.rank===4&&(B=!0,C=Ke(v,[1,v.shape[0],v.shape[1],v.shape[2],v.shape[3]]),D=Ke(_,[1,_.shape[0],_.shape[1],_.shape[2],_.shape[3]])),W(C.rank===5,function(){return"Error in avgPool3dBackprop: dy must be rank 5 but got rank "+(C.rank+".")}),W(D.rank===5,function(){return"Error in avgPool3dBackprop: input must be rank 5 but got rank "+(D.rank+".")}),W(dt(a,c),function(){return"Error in avgPool3dBackprop: Either strides or dilations "+("must be 1. Got strides "+a+" and dilations '"+c+"'")}),y!=null&&W(xt(d),function(){return"Error in maxPool3dBackprop: pad must be an integer when "+("using, dimRoundingMode "+y+" but got pad "+d+".")});var U=function(Me){var He=b(D.shape,n,a,c,d,y);return Me.avgPool3dBackprop(C,D,He)},J={dy:C,input:D},fe={filterSize:n,strides:a,dilations:c,pad:d,dimRoundingMode:y},Pe=Ie.runKernelFunc(U,J,null,Oi,fe);return B?Ke(Pe,[Pe.shape[1],Pe.shape[2],Pe.shape[3],Pe.shape[4]]):Pe}var vv=Ee({avgPool3dBackprop_:yv}),gv={kernelName:ji,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.filterSize,y=c.strides,v=c.dilations,_=c.pad,C=c.dimRoundingMode,D=v??[1,1,1];return{x:function(){return vv(t,a,d,y,D,_,C)}}}};function xv(t,e,n,a,c){var d=ie(t,"dy","avgPoolBackprop"),y=ie(e,"input","avgPoolBackprop");W(y.rank===d.rank,function(){return"Rank of input ("+y.rank+") does not match rank of dy ("+d.rank+")"});var v=y,_=d,C=!1;y.rank===3&&(C=!0,v=Ke(y,[1,y.shape[0],y.shape[1],y.shape[2]]),_=Ke(d,[1,d.shape[0],d.shape[1],d.shape[2]])),W(_.rank===4,function(){return"Error in avgPoolBackprop: dy must be rank 4 but got rank "+(_.rank+".")}),W(v.rank===4,function(){return"Error in avgPoolBackprop: input must be rank 4 but got rank "+(v.rank+".")});var D=function(fe){var Pe=h(v.shape,n,a,1,c);return fe.avgPoolBackprop(_,v,Pe)},B={dy:_,input:v},U={filterSize:n,strides:a,pad:c},J=Ie.runKernelFunc(D,B,null,Fi,U);return C?Ke(J,[J.shape[1],J.shape[2],J.shape[3]]):J}var _v=Ee({avgPoolBackprop_:xv}),wv={kernelName:Gi,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.filterSize,y=c.strides,v=c.pad;return{x:function(){return _v(t,a,d,y,v)}}}},bv={kernelName:da,inputsToSave:["a","b"],gradFunc:function(t,e,n){var a=e[0],c=e[1],d=n,y=d.transposeA,v=d.transposeB;return!y&&!v?{a:function(){return un(t,c,!1,!0)},b:function(){return un(a,t,!0,!1)}}:!y&&v?{a:function(){return un(t,c,!1,!1)},b:function(){return un(t,a,!0,!1)}}:y&&!v?{a:function(){return un(c,t,!1,!0)},b:function(){return un(a,t,!1,!1)}}:{a:function(){return un(c,t,!0,!0)},b:function(){return un(t,a,!0,!0)}}}},kv={kernelName:Mi,gradFunc:function(t,e,n){var a=n,c=a.blockShape,d=a.crops;return{x:function(){return Mh(t,c,d)}}}},Sv={kernelName:pe,gradFunc:function(t,e,n){for(var a=n,c=a.inputShape,d=a.shape,y=Array.from(d),v=c.length-1;v>=0;v--)if(c[v]===d[v])y[v]=1;else if(c[v]!==1)throw new Error("broadcastTo(): ["+c+"] cannot be broadcast to ["+d+"].");for(var _=[],v=0;v1&&_.push(v);return{x:function(){return Yr(t,_,!0)}}}},Iv={kernelName:X,gradFunc:function(t){return{x:function(){return t.clone()}}}},Nv={kernelName:j,gradFunc:function(t){return{x:function(){return gn(t)}}}},Cv={kernelName:re,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.clipValueMin,y=c.clipValueMax;return{x:function(){return us(nc($u(a,d),ec(a,y)),t,gn(t))}}}},Tv={kernelName:Ue,saveAllInputs:!0,gradFunc:function(t,e,n){var a=e.map(function(_){return _.shape}),c=n.axis,d=qt(c,e[0].shape)[0],y=a.map(function(_){return _[d]}),v=ll(t,y,d);return v.map(function(_){return function(){return _}})}},Ev={kernelName:kt,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y=n,v=y.dilations,_=y.strides,C=y.pad,D=y.dataFormat;return W(st(v),function(){return"Error in gradient of conv2D: dilation rates greater than 1 "+("are not yet supported in gradients. Got dilations '"+v+"'")}),{x:function(){return Ti(c.shape,t,d,_,C,D)},filter:function(){return Tp(c,t,d.shape,_,C,D)}}}},Rv={kernelName:Le,inputsToSave:["dy","filter"],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y=n,v=y.strides,_=y.pad,C=y.dataFormat,D=y.dimRoundingMode;return{dy:function(){return gi(t,d,v,_,C,1,D)},filter:function(){return Tp(t,c,d.shape,v,_,C,D)}}}};function Av(t,e,n,a,c){var d=t;t.rank===4&&(d=Ke(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]));var y=e;y.rank===4&&(y=Ke(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),W(d.rank===5,function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+(d.shape+".")}),W(y.rank===5,function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+(y.shape+".")}),W(n.length===5,function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+(n+".")}),W(d.shape[4]===n[3],function(){return"Error in conv3dDerFilter: depth of input "+d.shape[4]+") must "+("match input depth in filter ("+n[3]+".")}),W(y.shape[4]===n[4],function(){return"Error in conv3dDerFilter: depth of dy ("+y.shape[4]+") must "+("match output depth for filter ("+n[4]+").")});var v=function(D){var B=1,U=M(d.shape,n,a,B,c);return D.conv3dDerFilter(d,y,U)},_={x:d,dy:y},C={strides:a,pad:c,filterShape:n};return Ie.runKernelFunc(v,_,null,Ft,C)}var Dv=Ee({conv3DBackpropFilter_:Av}),Fv={kernelName:Ye,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=n,c=a.dilations,d=a.strides,y=a.pad;W(st(c),function(){return"Error in gradient of conv3D: dilation rates greater than 1 are "+("not yet supported in gradients. Got dilations '"+c+"'")});var v=e[0],_=e[1];return{x:function(){return Sh(v.shape,t,_,d,y)},filter:function(){return Dv(v,t,_.shape,d,y)}}}},Ov={kernelName:Mt,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt($a(kp(pr(n,"float32"))),t)}}}},Mv={kernelName:dr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(Sp(pr(n,"float32")),t)}}}},Lv={kernelName:ir,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n,d=c.axis,y=c.exclusive,v=c.reverse;return{x:function(){var _=Ji([d],a.rank),C=op(t,d,y,!v);return _!=null&&(C=$n(C,_)),C}}}},zv={kernelName:ra,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=n,c=a.dilations,d=a.strides,y=a.pad,v=a.dimRoundingMode,_=c??[1,1];W(st(_),function(){return"Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations "+("'"+_+"'")});var C=e,D=C[0],B=C[1];return W(D.rank===4,function(){return"Error in gradient of depthwiseConv2dNative: input must be "+("rank 4, but got rank "+D.rank+".")}),W(B.rank===4,function(){return"Error in gradient of depthwiseConv2dNative: filter must be "+("rank 4, but got rank "+B.rank+".")}),W(D.shape[3]===B.shape[2],function(){return"Error in gradient of depthwiseConv2d: number of input "+("channels ("+D.shape[3]+") must match the inChannels dimension ")+("in filter "+B.shape[2]+".")}),W(dt(d,_),function(){return"Error in gradient of depthwiseConv2d: Either strides or "+("dilations must be 1. Got strides "+d+" and dilations ")+("'"+_+"'.")}),v!=null&&W(xt(y),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+v+" but got pad "+y+".")}),{x:function(){return jd(D.shape,t,B,d,y,c,v)},filter:function(){return Gd(D,t,B.shape,d,y,c,v)}}}},Pv={kernelName:hn,inputsToSave:["x","filter"],gradFunc:function(t,e,n){var a=e,c=a[0],d=a[1],y={x:c,filter:d,dy:t},v={x:c,filter:d,dy:t};return{x:function(){return Ie.runKernel(na,y,n)},filter:function(){return Ie.runKernel(Jr,v,n)}}}},Bv={kernelName:Vr,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=Br(t,pr(a,"float32")),_=Ja(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,pr(n,"float32")),_=Ja(a.shape,c);_.length>0&&(v=Ke(Yr(v,_),a.shape));var C=Yn(a);return $a(Br(v,pr(C,"float32")))};return{a:d,b:y}}},Wv={kernelName:Jn,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0],a=function(d){return d.eluDer(t,n)},c={dy:t,y:n};return{x:function(){return Ie.runKernelFunc(a,c,null,tn)}}}},Uv={kernelName:Rn,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0],a=bt(cs($a(Yn(n))),2/Math.sqrt(Math.PI));return{x:function(){return bt(t,a)}}}},Vv={kernelName:aa,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,n)}}}},Hv={kernelName:ma,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,cs(n))}}}},Gv={kernelName:x,gradFunc:function(t){return{x:function(){return gn(t)}}}},jv={kernelName:k,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=Br(t,pr(a,"float32")),_=Ja(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,pr(n,"float32")),_=Ja(a.shape,c);_.length>0&&(v=Ke(Yr(v,_),a.shape));var C=Yn(a);return $a(Br(v,pr(C,"float32")))};return{a:d,b:y}}},qv={kernelName:K,inputsToSave:["x","mean","variance","scale"],gradFunc:function(t,e,n){var a=n.varianceEpsilon,c=e[0],d=e[1],y=e[2],v=e[3],_=v??Wr(1),C=Ja(d.shape,c.shape),D=[];if(d.rank===1){for(var B=0;B0?Ke(Yr(t,v),n.shape):t},y=function(){var v=bt(t,$a(Nh(Br(n,a)))),_=Ja(a.shape,c);return _.length>0?Ke(Yr(v,_),a.shape):v};return{a:d,b:y}}},y5={kernelName:qr,inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],a=e[1],c=ca(n.shape,a.shape),d=function(){var v=bt(t,pr(a,"float32")),_=Ja(n.shape,c);return _.length>0?Ke(Yr(v,_),n.shape):v},y=function(){var v=bt(t,pr(n,"float32")),_=Ja(a.shape,c);return _.length>0?Ke(Yr(v,_),a.shape):v};return{a:d,b:y}}},v5={kernelName:Io,gradFunc:function(t){return{x:function(){return $a(t)}}}},g5={kernelName:Pi,inputsToSave:["indices"],gradFunc:function(t,e){var n=e[0];return{indices:function(){return Ys(n.shape,"float32")}}}},x5={kernelName:oi,gradFunc:function(t){return{x:function(){return gn(t)}}}},uf={kernelName:no,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n.paddings,d=c.map(function(y){return y[0]});return{x:function(){return $t(t,d,a.shape)}}}},_5={kernelName:Ka,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:function(t,e){var n=e[0],a=e[1],c=e[2],d=n,y=a,v=ca(d.shape,y.shape),_=function(){var D=pr(y,"float32"),B=bt(t,bt(D,Qs(d,zr(D,Wr(1))))),U=Ja(d.shape,v);return U.length>0&&(B=Yr(B,U)),Ke(B,d.shape)},C=function(){var D=_u(d,0),B=us(D,tc(d),gn(d)),U=bt(t,bt(c,B)),J=Ja(y.shape,v);return J.length>0&&(U=Yr(U,J)),Ke(U,y.shape)};return{a:_,b:C}}},w5={kernelName:ao,inputsToSave:["x","alpha"],gradFunc:function(t,e){var n=e[0],a=e[1],c=_u(n,0);return{x:function(){return us(c,t,bt(t,a))},alpha:function(){var d=us(c,gn(t),bt(t,n)),y=Ja(a.shape,t.shape);return y.length>0&&(d=Yr(d,y)),Ke(d,a.shape)}}}},b5={kernelName:io,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,$a(Yn(n)))}}}},k5={kernelName:ka,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0],a=bt(ec(n,6),hl(n));return{x:function(){return bt(t,pr(a,"float32"))}}}},S5={kernelName:ia,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,pr(hl(n),"float32"))}}}},I5={kernelName:Pr,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Ke(t,n.shape)}}}},N5={kernelName:Qn,inputsToSave:["images"],gradFunc:function(t,e,n){var a=e[0],c=function(v){var _=n.alignCorners;return v.resizeBilinearBackprop(t,a,_)},d={images:a},y=function(){return Ie.runKernelFunc(c,d,null,oo,n)};return{images:y}}},C5={kernelName:oa,inputsToSave:["images"],gradFunc:function(t,e,n){var a=e[0],c=function(v){var _=n.alignCorners;return v.resizeNearestNeighborBackprop(t,a,_)},d={images:a},y=function(){return Ie.runKernelFunc(c,d,null,Xa,n)};return{images:y}}},T5={kernelName:vn,gradFunc:function(t,e,n){var a=n.dims,c=qt(a,t.shape);return{x:function(){return Zs(t,c)}}}},E5={kernelName:Bi,gradFunc:function(t){return{x:function(){return gn(t)}}}},R5={kernelName:yo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return $a(Br(t,bt(Qs(n,1.5),2)))}}}},A5={kernelName:Aa,inputsToSave:["condition"],gradFunc:function(t,e){var n=e[0];return{condition:function(){return pr(gn(n),"float32")},t:function(){return bt(t,pr(n,t.dtype))},e:function(){return bt(t,pr(Ah(n),t.dtype))}}}},D5={kernelName:go,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){var a=_u(n,Wr(0)),c=Wr(tf),d=Wr(rf),y=bt(t,d),v=bt(bt(t,c),cs(pr(n,"float32")));return us(a,y,v)}}}},F5={kernelName:Ds,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(t,bt(n,zr(Wr(1),n)))}}}},O5={kernelName:As,gradFunc:function(t){return{x:function(){return gn(t)}}}},M5={kernelName:Rs,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(Ih(pr(n,"float32")),t)}}}},L5={kernelName:Eo,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(ip(pr(n,"float32")),t)}}}},z5={kernelName:To,inputsToSave:["x"],gradFunc:function(t,e,n){for(var a=e[0],c=n,d=c.begin,y=c.size,v=a.shape,_=Hu(a,d,y),C=_[0],D=_[1],B=[],U=0;U0&&(v=Yr(v,_)),Ke(v,n.shape)},y=function(){var v=t,_=Ja(a.shape,c);return _.length>0&&(v=Yr(v,_)),Ke($a(v),a.shape)};return{a:d,b:y}}},j5={kernelName:Yo,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=a.shape.slice(),d=n.axis,y=qt(d,a.shape);y.forEach(function(C){c[C]=1});var v=Ke(t,c),_=bt(v,sl(a.shape,"float32"));return{x:function(){return _}}}},q5={kernelName:ds,inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return Br(t,Yn(Ih(n)))}}}},K5={kernelName:Ms,outputsToSave:[!0],gradFunc:function(t,e){var n=e[0];return{x:function(){return bt(zr(Wr(1),Yn(n)),t)}}}},X5={kernelName:Ls,inputsToSave:["x"],gradFunc:function(t,e,n){var a=e[0],c=n.reps,d=function(){var y=gn(a);if(a.rank===1)for(var v=0;v{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=function(s,u){return ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var h in o)o.hasOwnProperty(h)&&(r[h]=o[h])},ke(s,u)};function O(s,u){ke(s,u);function r(){this.constructor=s}s.prototype=u===null?Object.create(u):(r.prototype=u.prototype,new r)}var H=function(){return H=Object.assign||function(s){for(var u,r=1,o=arguments.length;r0&&b[b.length-1])&&(Y[0]===6||Y[0]===2)){r=0;continue}if(Y[0]===3&&(!b||Y[1]>b[0]&&Y[1]u?1:0}function ar(s,u){return-1*Zt(s,u)}function qt(s){if(s==null)return s;for(var u=[],r=0,o=s;r=0),tt(o>=r),Array.isArray(s)&&s.length>=r&&s.length<=o&&s.every(function(h){return typeof h===u})}function tr(s,u){Array.isArray(s)?(i.util.assert(s.length>0,function(){return u+" is unexpectedly an empty array."}),s.forEach(function(r,o){return tr(r,"element "+(o+1)+" of "+u)})):i.util.assert(Number.isInteger(s)&&s>0,function(){return"Expected "+u+" to be a positive integer, but got "+(Fa(s)+".")})}function Fa(s){return s===null?"null":Array.isArray(s)?"["+s.map(function(u){return Fa(u)}).join(",")+"]":typeof s=="string"?'"'+s+'"':""+s}function Oa(s,u){var r=i.util.now(),o,h=function(){for(var b=[],T=0;T0){var r=s+"_"+u;return Ta.set(r,1),r}else return s}var qn=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function ri(s){return!!s.match(qn)}function pi(s){return s===parseInt(s.toString(),10)}function pa(s,u,r){u==null&&(u=0),r==null&&(r=s.length);for(var o=1,h=u;h= 2"+(" but got x shape = "+s.shape+" and y shape = "+u.shape));if(u.rank>=3){var h=s.shape.slice(-1)[0],b=u.shape.slice(-2)[0];if(h!==b)throw new ge("If rank y >= 3, then the second last dim"+(" of y must equal the last dim of x but got x shape = "+s.shape+" and ")+(" y shape = "+u.shape))}if(s.rank===2&&u.rank===2){var T=!1,M=!1;return i.fused.matMul({a:s,b:u,transposeA:T,transposeB:M,bias:o?re(s.rank,o,he()):null,activation:r})}else{var q=s.shape.slice(),Y=q.pop();s=s.reshape([-1,Y]);var le=u.shape.slice(),Ne=le.pop(),b=le.pop(),We=le.concat([Ne]),je=Array.from({length:u.rank},function(dt,Dt){return Dt===0?u.rank-2:Dt<=u.rank-2?Dt-1:Dt});u=u.transpose(je).reshape([b,-1]);var qe=q.concat(We),T=!1,M=!1;return i.fused.matMul({a:s,b:u,transposeA:T,transposeB:M,bias:o?re(s.rank,o,he()):null,activation:r}).reshape(qe)}}function X(s,u,r){return i.tidy(function(){return Array.isArray(u)?u=i.tensor1d(u,"int32"):u=u.toInt(),i.gather(s,u,r)})}function j(s){return i.mul(s,s)}function re(s,u,r){var o=u.shape;if(u.rank!==1&&u.rank!==s)throw new w("Unexpected bias dimensions: "+u.rank+("; expected it to be 1 or "+s));if(s===5){if(r==="channelsFirst")return o.length===1?u.reshape([1,o[0],1,1,1]):u.reshape([1,o[3],o[0],o[1],o[2]]);if(r==="channelsLast")return o.length===1?u.reshape([1,1,1,1,o[0]]):u.reshape([1].concat(o))}else if(s===4){if(r==="channelsFirst")return o.length===1?u.reshape([1,o[0],1,1]):u.reshape([1,o[2],o[0],o[1]]);if(r==="channelsLast")return o.length===1?u.reshape([1,1,1,o[0]]):u.reshape([1].concat(o))}else if(s===3){if(r==="channelsFirst")return o.length===1?u.reshape([1,o[0],1]):u.reshape([1,o[1],o[0]]);if(r==="channelsLast")return o.length===1?u.reshape([1,1,o[0]]):u.reshape([1].concat(o))}else if(s<3)return u;throw new w("Unsupported input rank by biasAdd: "+u.rank)}function te(s,u,r){return i.tidy(function(){return r==null&&(r=he()),on(r),s.add(re(s.rank,u,r))})}function Ue(s,u){if(u===void 0&&(u=1),u!==1)throw new ge("Support for alpha values other than 1 ("+u+") is not implemented yet.");return i.elu(s)}function kt(s){return i.tidy(function(){return i.div(s,i.abs(s).add(1))})}function $e(s,u,r,o){return i.tidy(function(){return i.dropout(s,u,r,o)})}function Le(s){return i.tidy(function(){var u=i.add(.5,i.mul(.2,s));return i.clipByValue(u,0,1)})}function Ye(s,u,r){return r===void 0&&(r=!1),r?s():u()}var Ft=["fanIn","fanOut","fanAvg"],St=["normal","uniform","truncatedNormal"];function Mt(s){jr(Ft,"FanMode",s)}function dr(s){jr(St,"Distribution",s)}var ir=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.fromConfigUsesCustomObjects=function(){return!1},u.prototype.getConfig=function(){return{}},u}(i.serialization.Serializable),ta=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r,o){return i.zeros(r,o)},u.className="Zeros",u}(ir);i.serialization.registerClass(ta);var fa=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.apply=function(r,o){return i.ones(r,o)},u.className="Ones",u}(ir);i.serialization.registerClass(fa);var ra=function(s){O(u,s);function u(r){var o=s.call(this)||this;if(typeof r!="object")throw new w("Expected argument of type ConstantConfig but got "+r);if(r.value===void 0)throw new w("config must have value set but got "+r);return o.value=r.value,o}return u.prototype.apply=function(r,o){var h=this;return i.tidy(function(){return i.mul(i.scalar(h.value),i.ones(r,o))})},u.prototype.getConfig=function(){return{value:this.value}},u.className="Constant",u}(ir);i.serialization.registerClass(ra);var Ha=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.DEFAULT_MINVAL=-.05,o.DEFAULT_MAXVAL=.05,o.minval=r.minval||o.DEFAULT_MINVAL,o.maxval=r.maxval||o.DEFAULT_MAXVAL,o.seed=r.seed,o}return u.prototype.apply=function(r,o){return i.randomUniform(r,this.minval,this.maxval,o)},u.prototype.getConfig=function(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}},u.className="RandomUniform",u}(ir);i.serialization.registerClass(Ha);var ki=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.DEFAULT_MEAN=0,o.DEFAULT_STDDEV=.05,o.mean=r.mean||o.DEFAULT_MEAN,o.stddev=r.stddev||o.DEFAULT_STDDEV,o.seed=r.seed,o}return u.prototype.apply=function(r,o){if(o=o||"float32",o!=="float32"&&o!=="int32")throw new ge("randomNormal does not support dType "+o+".");return Mi(r,this.mean,this.stddev,o,this.seed)},u.prototype.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},u.className="RandomNormal",u}(ir);i.serialization.registerClass(ki);var sn=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.DEFAULT_MEAN=0,o.DEFAULT_STDDEV=.05,o.mean=r.mean||o.DEFAULT_MEAN,o.stddev=r.stddev||o.DEFAULT_STDDEV,o.seed=r.seed,o}return u.prototype.apply=function(r,o){if(o=o||"float32",o!=="float32"&&o!=="int32")throw new ge("truncatedNormal does not support dType "+o+".");return i.truncatedNormal(r,this.mean,this.stddev,o,this.seed)},u.prototype.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},u.className="TruncatedNormal",u}(ir);i.serialization.registerClass(sn);var hn=function(s){O(u,s);function u(r){var o=s.call(this)||this;return o.gain=r.gain!=null?r.gain:1,o}return u.prototype.apply=function(r,o){var h=this;return i.tidy(function(){if(r.length!==2||r[0]!==r[1])throw new w("Identity matrix initializer can only be used for 2D square matrices.");return i.mul(h.gain,i.eye(r[0]))})},u.prototype.getConfig=function(){return{gain:this.gain}},u.className="Identity",u}(ir);i.serialization.registerClass(hn);function na(s,u){u===void 0&&(u="channelsLast");var r,o;if(on(u),s.length===2)r=s[0],o=s[1];else if([3,4,5].indexOf(s.length)!==-1){if(u==="channelsFirst"){var h=pa(s,2);r=s[1]*h,o=s[0]*h}else if(u==="channelsLast"){var h=pa(s,0,s.length-2);r=s[s.length-2]*h,o=s[s.length-1]*h}}else{var b=pa(s);r=Math.sqrt(b),o=Math.sqrt(b)}return[r,o]}var Jr=function(s){O(u,s);function u(r){var o=s.call(this)||this;if(r.scale<0)throw new w("scale must be a positive float. Got: "+r.scale);return o.scale=r.scale==null?1:r.scale,o.mode=r.mode==null?"fanIn":r.mode,Mt(o.mode),o.distribution=r.distribution==null?"normal":r.distribution,dr(o.distribution),o.seed=r.seed,o}return u.prototype.apply=function(r,o){var h=na(r),b=h[0],T=h[1],M=this.scale;if(this.mode==="fanIn"?M/=Math.max(1,b):this.mode==="fanOut"?M/=Math.max(1,T):M/=Math.max(1,(b+T)/2),this.distribution==="normal"){var q=Math.sqrt(M);if(o=o||"float32",o!=="float32"&&o!=="int32")throw new ge(this.getClassName()+" does not support dType "+o+".");return i.truncatedNormal(r,0,q,o,this.seed)}else{var Y=Math.sqrt(3*M);return i.randomUniform(r,-Y,Y,o)}},u.prototype.getConfig=function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}},u.className="VarianceScaling",u}(ir);i.serialization.registerClass(Jr);var Vr=function(s){O(u,s);function u(r){return s.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="GlorotUniform",u}(Jr);i.serialization.registerClass(Vr);var Jn=function(s){O(u,s);function u(r){return s.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="GlorotNormal",u}(Jr);i.serialization.registerClass(Jn);var tn=function(s){O(u,s);function u(r){return s.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="HeNormal",u}(Jr);i.serialization.registerClass(tn);var Rn=function(s){O(u,s);function u(r){return s.call(this,{scale:2,mode:"fanIn",distribution:"uniform",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="HeUniform",u}(Jr);i.serialization.registerClass(Rn);var Kn=function(s){O(u,s);function u(r){return s.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="LeCunNormal",u}(Jr);i.serialization.registerClass(Kn);var aa=function(s){O(u,s);function u(r){return s.call(this,{scale:1,mode:"fanIn",distribution:"uniform",seed:r==null?null:r.seed})||this}return u.prototype.getClassName=function(){return Jr.className},u.className="LeCunNormal",u}(Jr);i.serialization.registerClass(aa);var ma=function(s){O(u,s);function u(r){var o=s.call(this)||this;if(o.DEFAULT_GAIN=1,o.gain=r.gain==null?o.DEFAULT_GAIN:r.gain,o.seed=r.seed,o.seed!=null)throw new ge("Random seed is not implemented for Orthogonal Initializer yet.");return o}return u.prototype.apply=function(r,o){var h=this;return i.tidy(function(){if(r.length<2)throw new ge("Shape must be at least 2D.");r[0]*r[1]>2e3&&console.warn("Orthogonal initializer is being called on a matrix with more "+("than 2000 ("+r[0]*r[1]+") elements: ")+"Slowness may result.");var b=r[0]>r[1]?[r[1],r[0]]:r,T=Mi(b,0,1,"float32"),M=i.linalg.gramSchmidt(T);return r[0]>r[1]&&(M=M.transpose()),i.mul(h.gain,M)})},u.prototype.getConfig=function(){return{gain:this.gain,seed:this.seed}},u.className="Orthogonal",u}(ir);i.serialization.registerClass(ma);var Li={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Ea(s,u){return u===void 0&&(u={}),yt(s,i.serialization.SerializationMap.getMap().classNameMap,u,"initializer")}function S(s){return ht(s)}function x(s){if(typeof s=="string"){var u=s in Li?Li[s]:s;if(u==="GlorotNormal")return new Jn;if(u==="GlorotUniform")return new Vr;if(u==="HeNormal")return new tn;if(u==="HeUniform")return new Rn;if(u==="LeCunNormal")return new Kn;if(u==="LeCunUniform")return new aa;var r={};return r.className=u,r.config={},Ea(r)}else return s instanceof ir?s:Ea(s)}function k(){return new ta}function K(){return new fa}function Se(s){return new ra(s)}function we(s){return new Ha(s)}function Je(s){return new ki(s)}function Be(s){return new sn(s)}function vt(s){return new hn(s)}function ft(s){return new Jr(s)}function zt(s){return new Vr(s)}function Wt(s){return new Jn(s)}function Gt(s){return new tn(s)}function Qt(s){return new Rn(s)}function wr(s){return new Kn(s)}function Ar(s){return new aa(s)}function Yt(s){return new ma(s)}var xr={__proto__:null,zeros:k,ones:K,constant:Se,randomUniform:we,randomNormal:Je,truncatedNormal:Be,identity:vt,varianceScaling:ft,glorotUniform:zt,glorotNormal:Wt,heNormal:Gt,heUniform:Qt,leCunNormal:wr,leCunUniform:Ar,orthogonal:Yt},Sn=0;function pn(){return Sn++}var zn={};function Fr(s){return s===void 0&&(s=""),s in zn||(zn[s]=0),zn[s]+=1,s+zn[s].toString()}function wa(s){return Array.isArray(s)&&Array.isArray(s[0])}function In(s){return s.length===0?[]:Array.isArray(s[0])?s:[s]}function ur(s){var u;if(Array.isArray(s)){if(s.length!==1)throw new w("Expected Tensor length to be 1; got "+s.length);u=s[0]}else u=s;return u}function $r(s){if(Array.isArray(s)&&Array.isArray(s[0])){if(s.length===1)return s=s,s[0];throw new w("Expected exactly 1 Shape; got "+s.length)}else return s}function Ra(s){for(var u=0,r=0,o=s;r1)throw new me("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use `getInputAt(nodeIndex)` instead.');if(this.inboundNodes.length===0)throw new me("Layer "+this.name+" is not connected, no input to return.");return Tt(this.getNodeAtIndex(0,"input").inputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"output",{get:function(){if(this.inboundNodes.length===0)throw new me("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new me("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return Tt(this.getNodeAtIndex(0,"output").outputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"losses",{get:function(){return this._losses},enumerable:!0,configurable:!0}),u.prototype.calculateLosses=function(){return this.losses.map(function(r){return r()})},Object.defineProperty(u.prototype,"updates",{get:function(){return this._updates},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"built",{get:function(){return this._built},set:function(r){this._built=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"trainable",{get:function(){return this.trainable_},set:function(r){this._trainableWeights.forEach(function(o){return o.trainable=r}),this.trainable_=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"trainableWeights",{get:function(){return this.trainable_?this._trainableWeights.filter(function(r){return r.trainable}):[]},set:function(r){this._trainableWeights=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){return this.trainable?this._trainableWeights.filter(function(r){return!r.trainable}).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)},set:function(r){this._nonTrainableWeights=r},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"weights",{get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"stateful",{get:function(){return this._stateful},enumerable:!0,configurable:!0}),u.prototype.resetStates=function(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")},u.prototype.assertInputCompatibility=function(r){if(r=Qe(r),this.inputSpec==null||this.inputSpec.length===0)return;var o=Qe(this.inputSpec);if(r.length!==o.length)throw new w("Layer "+this.name+" expects "+o.length+" inputs, "+("but it received "+r.length+" input tensors. ")+("Input received: "+r));for(var h=0;h=0?q[le]:q[q.length+le];if(Ne!=null&&[Ne,null].indexOf(We)===-1)throw new w("Input "+h+" is incompatible with layer "+(this.name+": expected axis "+le+" of input shape to ")+("have value "+Ne+" but got shape "+q+"."))}}if(T.shape!=null)for(var je=0;je0&&Array.isArray(lr[0])?st=lr.map(function(kr,Sr){return new ba(Ir,kr,h,Qe(r),o,h.name,Sr)}):st=new ba(Ir,lr,h,Qe(r),o,h.name),h.addInboundNode(r,st,null,null,vr,lr,o),h._refCount++,h.activityRegularizer!=null)throw new ge("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return st}})},u.prototype.warnOnIncompatibleInputShape=function(r){if(this.batchInputShape==null)return;if(r.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+(JSON.stringify(r)+") does not match that of the ")+("batchInputShape ("+JSON.stringify(this.batchInputShape)+") ")+("of the layer "+this.name));else{var o=!1;this.batchInputShape.forEach(function(h,b){h!=null&&r[b]!=null&&r[b]!==h&&(o=!0)}),o&&console.warn("The shape of the input tensor "+("("+JSON.stringify(r)+") does not ")+("match the expectation of layer "+this.name+": ")+(""+JSON.stringify(this.batchInputShape)))}},Object.defineProperty(u.prototype,"outputShape",{get:function(){if(this.inboundNodes==null||this.inboundNodes.length===0)throw new me("The layer "+this.name+" has never been called and thus has no defined output shape.");for(var r=[],o=0,h=this.inboundNodes;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(M=Y.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 Pr(s,u,r,o,h,b,T,M,q){var Y=new No,le=[new Ko].concat(ia.createCallbacks(u));s!=null&&le.push.apply(le,s),le.push(Y);var Ne=new ao(le);return Ne.setParams({epochs:r,initialEpoch:o,samples:h,steps:b,batchSize:T,verbose:u,doValidation:M,metrics:q}),{callbackList:Ne,history:Y}}function oa(s,u,r){return u===void 0&&(u={}),r===void 0&&(r=!1),yt(s,i.serialization.SerializationMap.getMap().classNameMap,u,"layer",r)}function Xa(s,u){return i.tidy(function(){s.dtype!=="float32"&&(s=s.asType("float32"));var r=i.sum(j(s),u,!0),o=i.fill(r.shape,P()),h=i.sqrt(i.maximum(r,o));return i.div(s,h)})}function Qn(s,u){return i.tidy(function(){return i.mean(j(i.sub(u,s)),-1)})}function oo(s,u){return i.tidy(function(){return i.mean(i.abs(i.sub(u,s)),-1)})}function ka(s,u){return i.tidy(function(){var r=i.sub(s,u),o=i.clipByValue(i.abs(s),P(),Number.MAX_VALUE),h=i.abs(i.div(r,o));return i.mul(100,i.mean(h,-1))})}function vn(s,u){return i.tidy(function(){var r=i.clipByValue(u,P(),Number.MAX_VALUE),o=i.log(i.add(1,r)),h=i.clipByValue(s,P(),Number.MAX_VALUE),b=i.log(i.add(1,h));return i.mean(j(i.sub(o,b)),-1)})}function Bi(s,u){return i.tidy(function(){var r=i.maximum(0,i.sub(1,i.mul(s,u)));return i.mean(j(r),-1)})}function yo(s,u){return i.tidy(function(){var r=i.maximum(0,i.sub(1,i.mul(s,u)));return i.mean(r,-1)})}function vo(s,u){return i.tidy(function(){var r=i.sum(i.mul(s,u),-1),o=i.max(i.mul(i.sub(1,s),u),-1);return i.maximum(0,i.add(1,i.sub(o,r)))})}function Aa(s,u){return i.tidy(function(){var r=Math.log(2),o=i.sub(u,s),h=i.sub(i.add(o,i.softplus(i.mul(-2,o))),r);return i.mean(h,-1)})}function go(s,u,r){return r===void 0&&(r=!1),i.tidy(function(){if(r)u=i.softmax(u);else{var o=i.sum(u,u.shape.length-1,!0);u=i.div(u,o)}return u=i.clipByValue(u,P(),1-P()),i.neg(i.sum(i.mul(s.toFloat(),i.log(u)),u.shape.length-1))})}function To(s,u,r){return r===void 0&&(r=!1),i.tidy(function(){var o=i.floor(bi(s)).toInt();u=i.clipByValue(u,P(),1-P());var h=u.shape,b=i.oneHot(o,h[h.length-1]).reshape(h);return go(b,u,r)})}function Rs(s,u){if(!i.util.arraysEqual(s.shape,u.shape))throw new w("logits and labels must have the same shape, but got shapes "+(JSON.stringify(s.shape)+" and "+JSON.stringify(u.shape)));return i.tidy(function(){var r=u.relu(),o=u.abs().neg();return r.sub(u.mul(s)).add(o.exp().log1p())})}function Eo(s,u){return i.tidy(function(){var r;return r=i.clipByValue(u,P(),1-P()),r=i.log(i.div(r,i.sub(1,r))),i.mean(Rs(s,r),-1)})}function As(s,u){return i.tidy(function(){var r=i.clipByValue(s,P(),1),o=i.clipByValue(u,P(),1);return i.sum(i.mul(s,i.log(i.div(r,o))),-1)})}function Ds(s,u){return i.tidy(function(){var r=i.log(i.add(P(),u));return i.mean(i.sub(u,i.mul(s,r)),-1)})}function Xo(s,u){return i.tidy(function(){var r=Xa(s,-1),o=Xa(u,-1),h=i.mul(r,o);return i.neg(i.sum(h,-1))})}var Ro={meanSquaredError:Qn,meanAbsoluteError:oo,meanAbsolutePercentageError:ka,meanSquaredLogarithmicError:vn,squaredHinge:Bi,hinge:yo,categoricalHinge:vo,logcosh:Aa,categoricalCrossentropy:go,sparseCategoricalCrossentropy:To,binaryCrossentropy:Eo,kullbackLeiblerDivergence:As,poisson:Ds,cosineProximity:Xo};function Yo(s){if(typeof s=="string"){if(s in Ro)return Ro[s];var u="Unknown loss "+s;throw s.toLowerCase().includes("softmaxcrossentropy")&&(u="Unknown loss "+s+'. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'),new w(u)}else return s}function Ao(s,u){return i.tidy(function(){var r=i.mul(.5,i.onesLike(u)),o=ni(i.greater(u,r),s.dtype);return i.mean(i.equal(s,o),-1)})}function Qo(s,u){return i.tidy(function(){return ni(i.equal(i.argMax(s,-1),i.argMax(u,-1)),"float32")})}function vi(s,u){return i.tidy(function(){return i.logicalAnd(s.equal(1),u.equal(1)).sum().cast("float32")})}function Fs(s,u){return i.tidy(function(){return i.logicalAnd(s.equal(1),u.equal(0)).sum().cast("float32")})}function tu(s,u){return i.tidy(function(){return i.logicalAnd(s.equal(0),u.equal(1)).sum().cast("float32")})}function ps(s,u){return i.tidy(function(){var r=vi(s,u),o=tu(s,u),h=r.add(o);return i.where(i.greater(h,0),r.div(h),0).cast("float32")})}function ru(s,u){return i.tidy(function(){var r=vi(s,u),o=Fs(s,u),h=r.add(o);return i.where(i.greater(h,0),r.div(h),0).cast("float32")})}function Os(s,u){return Eo(s,u)}function ds(s,u){return s.rank===u.rank&&(s=s.squeeze([s.rank-1])),u=u.argMax(-1),u.dtype!==s.dtype&&(u=u.asType(s.dtype)),i.equal(s,u).asType("float32")}var Ms=Qn,Ls=Qn,nu=oo,fs=oo,au=ka,ms=ka,Do=go,zs=Xo,Zo=To,xo={binaryAccuracy:Ao,categoricalAccuracy:Qo,precision:ps,categoricalCrossentropy:Do,sparseCategoricalCrossentropy:Zo,mse:Ms,MSE:Ls,mae:nu,MAE:fs,mape:au,MAPE:ms,cosine:zs};function ys(s){if(typeof s=="string"&&s in xo)return xo[s];if(typeof s!="string"&&s!=null)return s;throw new w("Unknown metric "+s)}function Fo(s){if(tt(s!==null,"Unknown LossOrMetricFn "+s),typeof s=="string")return s;for(var u=void 0,r=0,o=Object.keys(Ro);rJo&&console.warn('User-defined metadata of model "'+u+'" is too large in '+("size (length="+o.length+" when serialized). It is not ")+"recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= "+(Jo+"."))}}function wo(s){if(s===null)return!0;if(typeof s=="object")if(Object.getPrototypeOf(s)===Object.prototype){for(var u=Object.keys(s),r=0,o=u;r1||M.length===1&&M[0].inboundLayers.length>1){u=!1;break}o.push.apply(o,M)}if(u)for(var q=0,Y=s.layers;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 iu(s,u,r){var o;try{o=JSON.stringify(s.outputShape)}catch(M){o="multiple"}var h=s.name,b=s.getClassName(),T=[h+" ("+b+")",o,s.countParams().toString()];$o(T,u,r)}function ku(s,u,r,o){var h;try{h=JSON.stringify(s.outputShape)}catch(st){h="multiple"}for(var b=[],T=0,M=s.inboundNodes;T0&&r.indexOf(q)===-1)continue;for(var Y=0;Yo.maxNumTensors&&(o.maxNumTensors=Dt),Dt0,function(){return"Expected at least one fetch, got none"});var r=[],o={};if(s.length===1){var h=ue(s[0],u);r=h.sorted,o=h.recipientMap}else for(var b=new Set,T=0,M=s;T0;){var le=q[q.length-1];if(r.has(le.name)){q.pop();continue}var Ne=Y[Y.length-1]===q.length-1;if(le.inputs.length===0||Ne)q.pop(),o.push(le),r.add(le.name),Ne&&Y.pop();else{Y.push(q.length-1);for(var We=0,je=le.inputs;We1 nodes"),tt(le===0,"input layer has >1 tensors"),o.inputLayers.push(q),o.inputLayersNodeIndices.push(Y),o.inputLayersTensorIndices.push(le)}o.inputNames=[],o.outputNames=[],o.feedInputShapes=[],o.feedInputNames=[],o.feedOutputNames=[];for(var je=0;je=0;)gi.splice(gi.indexOf(Ti),1);Xt.push(Ti)},vr=[],lr=[],Ir=0,Lr=o.outputs;IrNs?1:0});for(var Ks=0,Zu=Vi;Ks0)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(st.length+" of "+b+" weights are not set: "+(""+st))}zi(We)},u.prototype.updatedConfig=function(){var r=this.getConfig(),o={};return o.className=this.getClassName(),o.config=r,o.kerasVersion="tfjs-layers "+gs,o.backend="TensorFlow.js",o},u.prototype.toJSON=function(r,o){o===void 0&&(o=!0);var h=Mo(this.updatedConfig());return o?JSON.stringify(h):h},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){r=Qe(r);for(var b=new Si,T=0;T1)for(var le=0,Ne=Y;le0){for(var mt=[],pt=0;pt0&&cn.apply(Tt(Hr),ua)}function le(cn){var Mn=cn.name,Hr=oa(cn,o.customObjects!=null?o.customObjects:{});Hr.setFastWeightInitDuringBuild(b),T[Mn]=Hr;var ua=cn.inboundNodes;ua.forEach(function(Ci){if(!(Ci instanceof Array))throw new w("Corrupted configuration, expected array for nodeData: "+Ci);q(Hr,Ci)})}for(var Ne=o.name,We=o.layers,je=0,qe=We;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 V(s,u){return A(s,u,"classWeight")}function oe(s,u,r,o){return xe(this,void 0,void 0,function(){var h,b,T,M,q;return Q(this,function(Y){switch(Y.label){case 0:if(u!=null||o!=null)throw new Error("Support sampleWeight is not implemented yet");return r!=null?(h=i.tidy(function(){if(s.shape.length===1)return s.clone();if(s.shape.length===2)if(s.shape[1]>1){var le=1;return s.argMax(le)}else{if(s.shape[1]===1)return s.reshape([s.shape[0]]);throw new Error("Encountered unexpected last-dimension size ("+s.shape[1]+") during handling of class weights. The size is expected to be >= 1.")}else throw new Error("Unexpected rank of target (y) tensor ("+s.rank+") during handling of class weights. The rank is expected to be 1 or 2.")}),M=(T=Array).from,[4,h.data()]):[3,2];case 1:return b=M.apply(T,[Y.sent()]),i.dispose(h),q=[],b.forEach(function(le){if(r[le]==null)throw new Error("classWeight must contain all classes in the training data. "+("The class "+le+" exists in the data but not in ")+"classWeight");q.push(r[le])}),[2,i.tensor1d(q,"float32")];case 2:return[2,null]}})})}function ee(s,u){return i.mul(s,u)}var _e=32;function ce(s,u){var r,o,h=u;r=h.xs,o=h.ys,i.util.assert(r!=null&&o!=null,function(){return"A Dataset iterator for fitDataset() is expected to generate objects of the form `{xs: xVal, ys: yVal}`, where the two values may be `tf.Tensor`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates "+(""+u)});var b=de("input",s.inputNames,r),T=de("output",s.outputNames,o),M=b[0].shape[0];i.util.assert(b.length===s.inputs.length,function(){return"LayersModel has "+s.inputs.length+" inputs, but the dataset "+("provides "+b.length+" inputs. (Expected input keys: ")+(JSON.stringify(s.inputNames)+")")}),i.util.assert(T.length===s.outputs.length,function(){return"LayersModel has "+s.outputs.length+" outputs, but the dataset "+("provides "+T.length+" outputs. (Expected output keys: ")+(JSON.stringify(s.outputNames)+")")});for(var q=function(We){i.util.assert(b[We].shape[0]===M,function(){return"Batch size mismatch: input "+(s.inputNames[We]+" has "+b[We].shape[0]+"; ")+("expected "+M+" based on input "+s.inputNames[0]+".")})},Y=0;Y0&&Number.isInteger(r.epochs),function(){return"For fitDataset(), config.epochs is expected to be a positive "+("integer, but got "+r.epochs)}),i.util.assert(!o||r.batchesPerEpoch>0&&Number.isInteger(r.batchesPerEpoch),function(){return"For fitDataset(), config.batchesPerEpoch is expected to be a "+("positive integer if specified, but got "+r.batchesPerEpoch)}),i.util.assert(r.validationSplit==null,function(){return"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."}),s.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");s.isTraining=!0,Hr.label=1;case 1:return Hr.trys.push([1,,26,27]),h=r.validationData!=null,b=void 0,T=void 0,h&&(Oe(r.validationData)?i.util.assert(r.validationBatches==null||r.validationBatches>0&&Number.isInteger(r.validationBatches),function(){return"For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, "+("but got "+r.validationBatches)}):(M=ye(r.validationData),b=M.xs,T=M.ys)),q=s.makeTrainFunction(),Y=s.getDedupedMetricsNames(),le=void 0,h?le=Y.slice().concat(Y.map(function(ua){return"val_"+ua})):le=Y.slice(),Ne=io(r.callbacks,r.yieldEvery),We=r.verbose==null?1:r.verbose,je=Pr(Ne,We,r.epochs,null,null,Re(u,r),null,h,le),qe=je.callbackList,mt=je.history,qe.setModel(s),s.history=mt,[4,qe.onTrainBegin()];case 2:return Hr.sent(),s.stopTraining_=!1,pt=r.initialEpoch==null?0:r.initialEpoch,[4,u.iterator()];case 3:st=Hr.sent(),Hr.label=4;case 4:return pt=r.batchesPerEpoch:Xt.done)?h?(cn=void 0,Oe(r.validationData)?(Mn=Qe,[4,s.evaluateDataset(r.validationData,{batches:r.validationBatches})]):[3,17]):[3,19]:[3,20];case 16:return cn=Mn.apply(void 0,[Hr.sent()]),[3,18];case 17:cn=Qe(s.evaluate(b,T,{batchSize:r.validationBatchSize==null?_e:r.validationBatchSize,verbose:0})),Hr.label=18;case 18:for(Sr=0;Sr0)throw new ge("Verbose mode is not implemented yet.");return i.util.assert(!o||r.batches>0&&Number.isInteger(r.batches),function(){return"Test loop expects `batches` to be a positive integer, but "+("received "+JSON.stringify(r.batches))}),Fe(u)?(M=u,[3,3]):[3,1];case 1:return[4,u.iterator()];case 2:M=qe.sent(),qe.label=3;case 3:T=M,q=0,Y=0,le=function(){var mt;return Q(this,function(pt){switch(pt.label){case 0:return[4,T.next()];case 1:return mt=pt.sent(),b=i.tidy(function(){if(mt.value){var st=ce(s,mt.value),dt=st.xs,Dt=st.ys,or=dt.concat(Dt),Xt=i.tidy(function(){return h(or)});if(i.dispose(or),Y===0)for(var Jt=0;Jt0&&i.dispose(Sr)},Jt=0;Jt0&&Number.isInteger(s),function(){return"batchSize is required to be a positive integer, but got "+s})}function rt(s,u,r){return s==null?[null]:Array.isArray(s)?s.map(function(o){return Zn(o,u,r-u)}):Zn(s,u,r-u)}function at(s,u){return i.tidy(function(){return s==null?null:Array.isArray(s)?s.map(function(r){return at(r,u)}):X(s,u.dtype==="int32"?u:u.toInt())})}function $(s,u){for(var r=[],o=0,h=null;o=s&&(h=s),r.push([o,h]),o=h;return r}function et(s,u,r,o,h,b,T,M,q,Y,le,Ne,We,je,qe){return xe(this,void 0,void 0,function(){var mt,pt,st,dt,Dt,or,Xt,Jt,vr;return Q(this,function(lr){switch(lr.label){case 0:if(h==null&&(h=32),b==null&&(b=1),le==null&&(le=!0),We==null&&(We=0),mt=!1,q!=null&&Y!=null&&(mt=!0),qe!=null&&(mt=!0,je==null))throw new w("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");return pt=s.checkNumSamples(r,h,je,"steps_per_epoch"),pt!=null&&(st=ln(0,pt)),T==null&&(T=1),dt=Pr(M,T,b,We,pt,je,h,mt,Ne),Dt=dt.callbackList,or=dt.history,Dt.setModel(s),s.history=or,[4,Dt.onTrainBegin()];case 1:lr.sent(),s.stopTraining_=!1,Xt=function(Ir){var Lr,kr,Sr,fn,Xr,$t;return Q(this,function(On){switch(On.label){case 0:return[4,Dt.onEpochBegin(Ir)];case 1:if(On.sent(),Lr={},!(je!=null))return[3,2];throw new ge("stepsPerEpoch mode is not implemented yet.");case 2:if(le==="batch")throw new ge("batch shuffling is not implemneted yet");le&&i.util.shuffle(st),kr=i.tensor1d(st),Sr=$(pt,h),fn=function(En){var kn;return Q(this,function(cn){switch(cn.label){case 0:return kn={},[4,Dt.onBatchBegin(En,kn)];case 1:return cn.sent(),i.tidy(function(){var Mn=Sr[En][0],Hr=Sr[En][1],ua=Zn(kr,Mn,Hr-Mn);kn.batch=En,kn.size=Hr-Mn;for(var Ci=at(r,ua),Ui=u(Ci),Xn=0;Xn0))return[3,4];if(qe=!0,o.validationData.length===2)T=o.validationData[0],M=o.validationData[1];else throw o.validationData.length===3?new ge("validationData including sample weights is not supported yet."):new w("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+(o.validationData+" is invalid."));return pt=!0,[4,s.standardizeUserData(T,M,null,null,pt,Ne)];case 3:return st=kr.sent(),q=st[0],Y=st[1],mt=q.concat(Y),[3,5];case 4:o.validationSplit!=null&&o.validationSplit>0&&o.validationSplit<1?(qe=!0,dt=Math.floor(h[0].shape[0]*(1-o.validationSplit)),Dt=h[0].shape[0],q=rt(h,dt,Dt),h=rt(h,0,dt),Y=rt(b,dt,Dt),b=rt(b,0,dt),mt=q.concat(Y)):o.validationSteps!=null&&(qe=!0),kr.label=5;case 5:return or=h.concat(b).concat(le),s.checkTrainableWeightsConsistency(),Xt=s.makeTrainFunction(),Jt=s.getDedupedMetricsNames(),vr=void 0,lr=void 0,qe?(s.makeTestFunction(),vr=s.testFunction,lr=Jt.slice().concat(Jt.map(function(Sr){return"val_"+Sr}))):(vr=null,mt=[],lr=Jt.slice()),Ir=io(o.callbacks,o.yieldEvery),[4,et(s,Xt,or,Jt,Ne,o.epochs,o.verbose,Ir,vr,mt,o.shuffle,lr,o.initialEpoch,null,null)];case 6:return Lr=kr.sent(),[2,Lr];case 7:return s.isTraining=!1,_t(h,u),_t(b,r),_t(q,T),_t(Y,M),le!=null&&i.dispose(le),[7];case 8:return[2]}})})}function lt(s){var u=[];s instanceof i.Tensor&&(s=[s]);for(var r=0;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 M;if(Pt(s)){s=s,M=[];for(var q=0,Y=u;q1)throw new w("The model "+h+" expects "+u.length+" Tensor(s), "+("but only received one Tensor. Found: Tensor with shape "+s.shape));M=[s]}if(M=lt(M),r!=null)for(var Ne=0;Ne=0&&qe!==mt)throw new w("Error when checking "+h+": expected "+u[Ne]+" "+("to have shape ["+r[Ne]+"], but got array with shape ")+("["+We.shape+"]."))}}return M}function Nt(s,u,r){var o=qt(s.map(function(b){return b.shape[0]}));o.sort();var h=qt(u.map(function(b){return b.shape[0]}));if(h.sort(),o.length>1)throw new w("All input Tensors (x) should have the same number of samples. Got array shapes: "+(""+JSON.stringify(s.map(function(b){return b.shape}))));if(h.length>1)throw new w("All target Tensors (y) should have the same number of samples. Got array shapes: "+(""+JSON.stringify(u.map(function(b){return b.shape}))));if(o.length>0&&h.length>0&&!i.util.arraysEqual(o,h))throw new w("Input Tensors should have the same number of samples as target "+("Tensors. Found "+o[0]+" input sample(s) and "+h[0]+" target ")+"sample(s).")}function Kt(s,u,r){for(var o=[Qn,Eo,go],h=0;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,st]),o.metricsNames.push(o.outputNames[st]+"_loss"))}});var mt=Ot(r.metrics,this.outputNames),pt=function(st,dt,Dt){o.outputNames.length>1&&(dt=o.outputNames[st]+"_"+dt),o.metricsNames.push(dt),o.metricsTensors.push([Dt,st])};_a("metric",function(){for(var st=function(Dt){if(qe.indexOf(Dt)!==-1)return"continue";var or=mt[Dt],Xt=function(Jt){for(var vr="",lr,Ir,Lr,kr=function($t){if(typeof $t=="string"&&["accuracy","acc","crossentropy","ce"].indexOf($t)!==-1){var On=o.internalOutputShapes[Dt];On[On.length-1]===1||o.lossFunctions[Dt]===Eo?["accuracy","acc"].indexOf($t)!==-1?Ir=Ao:["crossentropy","ce"].indexOf($t)!==-1&&(Ir=Os):o.lossFunctions[Dt]===To?["accuracy","acc"].indexOf($t)!==-1?Ir=ds:["crossentropy","ce"].indexOf($t)!==-1&&(Ir=Zo):["accuracy","acc"].indexOf($t)!==-1?Ir=Qo:["crossentropy","ce"].indexOf($t)!==-1&&(Ir=Do);var En=void 0;["accuracy","acc"].indexOf($t)!==-1?En="acc":["crossentropy","ce"].indexOf($t)!==-1&&(En="ce"),Lr=Ir,lr=vr+En}else{var kn=ys($t);Lr=kn,lr=vr+Fo($t)}var cn;_a(lr,function(){cn=Lr}),pt(Dt,lr,cn)},Sr=0,fn=Jt;Sr0){var We=[];throw o.forEach(function(je,qe){je==null&&We.push(r[qe])}),new w("Cannot find SymbolicTensors for output name(s): "+(""+JSON.stringify(We)))}return o},u.prototype.predictLoop=function(r,o,h){var b=this;return o===void 0&&(o=32),h===void 0&&(h=!1),i.tidy(function(){var T=b.checkNumSamples(r);if(h)throw new ge("Verbose predictLoop() is not implemented yet.");for(var M=$(T,o),q=b.outputs.map(function(Ne){return[]}),Y=function(Ne){var We=i.tidy(function(){var je=M[Ne][0],qe=M[Ne][1],mt=rt(r,je,qe),pt=[];if(Array.isArray(mt))for(var st=0;st0&&r[0].shape[0]%b!==0)throw new w("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+(b+". Found: "+r[0].shape[0]+" sample(s)."));return[r,o]},u.prototype.standardizeUserData=function(r,o,h,b,T,M){return T===void 0&&(T=!0),xe(this,void 0,void 0,function(){var q,Y,le,Ne,We,je,qe,mt;return Q(this,function(pt){switch(pt.label){case 0:if(q=this.standardizeUserDataXY(r,o,T,M),Y=q[0],le=q[1],h!=null)throw new Error("sample weight is not supported yet.");if(Ne=null,!(b!=null))return[3,4];We=V(b,this.outputNames),Ne=[],je=0,pt.label=1;case 1:return je0)throw new ge("Verbose mode is not implemented yet.");if(T!=null)throw new ge("steps mode in testLoop() is not implemented yet");for(var le=$(q,h),Ne=i.tensor1d(ln(0,q)),We=0;We1){var M=nr(r.slice(0,h),b);T+="_"+M}o.push(T)}return o},u.prototype.makeTrainFunction=function(){var r=this;return function(o){var h=[],b=o.slice(0,r.inputs.length),T=o.slice(r.inputs.length,r.inputs.length+r.outputs.length),M=o.slice(r.inputs.length+r.outputs.length,r.inputs.length+r.outputs.length*2),q=[],Y=function(){for(var je=[],qe=0;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=Dt.sent(),T=!1,M=null,q=this.toJSON(M,T),Y={modelTopology:q,format:Rt,generatedBy:"TensorFlow.js tfjs-layers v"+gs,convertedBy:null},le=o==null?!1:o.includeOptimizer,le&&this.optimizer!=null?(Y.trainingConfig=this.getTrainingConfig(),Ne="optimizer",pt=(mt=i.io).encodeWeights,[4,this.optimizer.getWeights()]):[3,4];case 2:return[4,pt.apply(mt,[Dt.sent(),Ne])];case 3:We=Dt.sent(),je=We.data,qe=We.specs,(dt=b.specs).push.apply(dt,qe),b.data=i.io.concatenateArrayBuffers([b.data,je]),Dt.label=4;case 4:return this.userDefinedMetadata!=null&&(st=!0,_o(this.userDefinedMetadata,this.name,st),Y.userDefinedMetadata=this.userDefinedMetadata),Y.weightData=b.data,Y.weightSpecs=b.specs,[2,r.save(Y)]}})})},u.prototype.setUserDefinedMetadata=function(r){_o(r,this.name),this.userDefinedMetadata=r},u.prototype.getUserDefinedMetadata=function(){return this.userDefinedMetadata},u.className="Model",u}(F);i.serialization.registerClass(wt);var Et=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.className="Functional",u}(wt);i.serialization.registerClass(Et);function Vt(s,u){return xe(this,void 0,void 0,function(){var r,o,h,b,T,M,q,Y;return Q(this,function(le){switch(le.label){case 0:return"modelTopology"in s||(s={modelTopology:s}),s=s,r=s.modelTopology,r.model_config!=null&&(r=r.model_config),o=Oo(r),h=oa(o,u),s.weightsManifest!=null?[4,i.io.loadWeights(s.weightsManifest,s.pathPrefix,h.weights.map(function(Ne){return Ne.originalName}))]:[3,2];case 1:for(b=le.sent(),T={},M=0,q=h.weights;M1)throw new w("Found more than one ("+r.length+") load handlers for "+("URL '"+s+"'"));s=r[0]}return[2,cr(s,void 0,u)]})})}function cr(s,u,r){return xe(this,void 0,void 0,function(){var o,h,b,T,M,q,Y,le,Ne;return Q(this,function(We){switch(We.label){case 0:if(r==null&&(r={}),s.load==null)throw new w("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");return[4,s.load()];case 1:if(o=We.sent(),h=o.modelTopology,h.model_config!=null&&(h=h.model_config),b=r.strict==null?!0:r.strict,T=o.weightData!=null&&o.weightSpecs!=null&&b,M=oa(Oo(h),u,T),q=o.trainingConfig,q!=null&&M.loadTrainingConfig(q),o.userDefinedMetadata!=null&&M.setUserDefinedMetadata(o.userDefinedMetadata),!(o.weightData!=null))return[3,4];if(o.weightSpecs==null)throw new w("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");return Y=rr(o.weightData,o.weightSpecs),le=Y.modelWeights,Ne=Y.optimizerWeights,M.loadWeights(le,b),M.optimizer!=null&&Ne.length>0?[4,M.optimizer.setWeights(Ne)]:[3,3];case 2:We.sent(),We.label=3;case 3:i.dispose(le),i.dispose(Ne.map(function(je){return je.tensor})),We.label=4;case 4:return[2,M]}})})}function rr(s,u){var r=i.io.decodeWeights(s,u),o={},h=[];return u.forEach(function(b){b.group==="optimizer"?h.push({name:b.name,tensor:r[b.name]}):o[b.name]=r[b.name]}),{modelWeights:o,optimizerWeights:h}}var Ie=function(s){O(u,s);function u(r){var o=s.call(this,{inputs:[],outputs:[]})||this;if(r=r||{},o.trainable=!0,o.built=!1,o.name=r.name!=null?r.name:Fr("sequential_"),r.layers!=null)for(var h=0,b=r.layers;h 0 "+("but got "+JSON.stringify(r.filters)))},u}(Cu),Tu=function(s){O(u,s);function u(r){var o=s.call(this,2,r)||this;return u.verifyArgs(r),o}return u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return delete r.rank,r},u.verifyArgs=function(r){if(typeof r.kernelSize!="number"&&!_r(r.kernelSize,"number",1,2))throw new w("Conv2D expects config.kernelSize to be number or number[] with "+("length 1 or 2, but received "+JSON.stringify(r.kernelSize)+"."))},u.className="Conv2D",u}(cu);i.serialization.registerClass(Tu);var hc=function(s){O(u,s);function u(r){var o=s.call(this,3,r)||this;return u.verifyArgs(r),o}return u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return delete r.rank,r},u.verifyArgs=function(r){if(typeof r.kernelSize!="number"&&!(Array.isArray(r.kernelSize)&&(r.kernelSize.length===1||r.kernelSize.length===3)))throw new w("Conv3D expects config.kernelSize to be number or"+(" [number, number, number], but received "+JSON.stringify(r.kernelSize)+"."))},u.className="Conv3D",u}(cu);i.serialization.registerClass(hc);var uo=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;if(o.inputSpec=[new An({ndim:4})],o.padding!=="same"&&o.padding!=="valid")throw new w("Conv2DTranspose currently supports only padding modes 'same' "+("and 'valid', but received padding mode "+o.padding));return o}return u.prototype.build=function(r){var o;if(r=$r(r),r.length!==4)throw new w("Input should have rank 4; Received input shape: "+JSON.stringify(r));var h=this.dataFormat==="channelsFirst"?1:r.length-1;if(r[h]==null)throw new w("The channel dimension of the inputs should be defined. Found `None`.");var b=r[h],T=this.kernelSize.concat([this.filters,b]);this.kernel=this.addWeight("kernel",T,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new An({ndim:4,axes:(o={},o[h]=b,o)})],this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=ur(r);if(b.shape.length!==4)throw new w("Conv2DTranspose.call() expects input tensor to be rank-4, but "+("received a tensor of rank-"+b.shape.length));var T=b.shape,M=T[0],q,Y;h.dataFormat==="channelsFirst"?(q=2,Y=3):(q=1,Y=2);var le=T[q],Ne=T[Y],We=h.kernelSize[0],je=h.kernelSize[1],qe=h.strides[0],mt=h.strides[1],pt=_s(le,qe,We,h.padding),st=_s(Ne,mt,je,h.padding),dt=[M,pt,st,h.filters];h.dataFormat!=="channelsLast"&&(b=i.transpose(b,[0,2,3,1]));var Dt=i.conv2dTranspose(b,h.kernel.read(),dt,h.strides,h.padding);return h.dataFormat!=="channelsLast"&&(Dt=i.transpose(Dt,[0,3,1,2])),h.bias!=null&&(Dt=te(Dt,h.bias.read(),h.dataFormat)),h.activation!=null&&(Dt=h.activation.apply(Dt)),Dt})},u.prototype.computeOutputShape=function(r){r=$r(r);var o=r.slice(),h,b,T;this.dataFormat==="channelsFirst"?(h=1,b=2,T=3):(h=3,b=1,T=2);var M=this.kernelSize[0],q=this.kernelSize[1],Y=this.strides[0],le=this.strides[1];return o[h]=this.filters,o[b]=_s(o[b],Y,M,this.padding),o[T]=_s(o[T],le,q,this.padding),o},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this);return delete r.dilationRate,r},u.className="Conv2DTranspose",u}(Tu);i.serialization.registerClass(uo);var bs=function(s){O(u,s);function u(r,o){var h=s.call(this,r,o)||this;if(h.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",h.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",h.depthwiseKernel=null,h.pointwiseKernel=null,o.filters==null)throw new w("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(o.kernelInitializer!=null||o.kernelRegularizer!=null||o.kernelConstraint!=null)throw new w("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(o.padding!=null&&o.padding!=="same"&&o.padding!=="valid")throw new w("SeparableConv"+h.rank+"D supports only padding modes: "+("'same' and 'valid', but received "+JSON.stringify(o.padding)));return h.depthMultiplier=o.depthMultiplier==null?1:o.depthMultiplier,h.depthwiseInitializer=x(o.depthwiseInitializer||h.DEFAULT_DEPTHWISE_INITIALIZER),h.depthwiseRegularizer=Fn(o.depthwiseRegularizer),h.depthwiseConstraint=xn(o.depthwiseConstraint),h.pointwiseInitializer=x(o.depthwiseInitializer||h.DEFAULT_POINTWISE_INITIALIZER),h.pointwiseRegularizer=Fn(o.pointwiseRegularizer),h.pointwiseConstraint=xn(o.pointwiseConstraint),h}return u.prototype.build=function(r){var o;if(r=$r(r),r.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,M){return o===void 0&&(o=!1),T===void 0&&(T=!1),M===void 0&&(M=!1),i.tidy(function(){var q=u.shape.length;if(q<3)throw new w("Input should be at least 3D, but is "+q+"D.");var Y=[1,0].concat(ln(2,q));if(u=i.transpose(u,Y),b!=null)throw new ge("The rnn() functoin of the deeplearn.js backend does not support constants yet.");T&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),h!=null&&(h=h.asType("bool").asType("float32"),h.rank===q-1&&(h=i.expandDims(h,-1)),h=i.transpose(h,Y)),o&&(u=i.reverse(u,0),h!=null&&(h=i.reverse(h,0)));var le=[],Ne,We=r,je=u.shape[0],qe=i.unstack(u),mt;h!=null&&(mt=i.unstack(h));for(var pt=function(or){var Xt=qe[or],Jt=i.tidy(function(){return s(Xt,We)});if(h==null)Ne=Jt[0],We=Jt[1];else{var vr=i.tidy(function(){var lr=mt[or],Ir=i.onesLike(lr).sub(lr),Lr=Jt[0].mul(lr).add(We[0].mul(Ir)),kr=We.map(function(Sr,fn){return Jt[1][fn].mul(lr).add(Sr.mul(Ir))});return{output:Lr,newStates:kr}});Ne=vr.output,We=vr.newStates}M&&le.push(Ne)},st=0;st1?da(h,[1,b]):h}):o.cell.stateSize>1?[da(h,[1,o.cell.stateSize])]:[h]})},Object.defineProperty(u.prototype,"trainableWeights",{get:function(){return this.trainable?this.cell.trainableWeights:[]},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights},enumerable:!0,configurable:!0}),u.prototype.setFastWeightInitDuringBuild=function(r){s.prototype.setFastWeightInitDuringBuild.call(this,r),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(r)},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(o.numConstants=this.numConstants);var h=this.cell.getConfig();return this.getClassName()===u.className&&(o.cell={className:this.cell.getClassName(),config:h}),H({},h,r,o)},u.fromConfig=function(r,o,h){h===void 0&&(h={});var b=o.cell,T=oa(b,h);return new r(Object.assign(o,{cell:T}))},u.className="RNN",u}(qr);i.serialization.registerClass(Ni);var ns=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u}(qr),ks=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.DEFAULT_ACTIVATION="tanh",o.DEFAULT_KERNEL_INITIALIZER="glorotNormal",o.DEFAULT_RECURRENT_INITIALIZER="orthogonal",o.DEFAULT_BIAS_INITIALIZER="zeros",o.units=r.units,tr(o.units,"units"),o.activation=va(r.activation==null?o.DEFAULT_ACTIVATION:r.activation),o.useBias=r.useBias==null?!0:r.useBias,o.kernelInitializer=x(r.kernelInitializer||o.DEFAULT_KERNEL_INITIALIZER),o.recurrentInitializer=x(r.recurrentInitializer||o.DEFAULT_RECURRENT_INITIALIZER),o.biasInitializer=x(r.biasInitializer||o.DEFAULT_BIAS_INITIALIZER),o.kernelRegularizer=Fn(r.kernelRegularizer),o.recurrentRegularizer=Fn(r.recurrentRegularizer),o.biasRegularizer=Fn(r.biasRegularizer),o.kernelConstraint=xn(r.kernelConstraint),o.recurrentConstraint=xn(r.recurrentConstraint),o.biasConstraint=xn(r.biasConstraint),o.dropout=fi([1,Va([0,r.dropout==null?0:r.dropout])]),o.recurrentDropout=fi([1,Va([0,r.recurrentDropout==null?0:r.recurrentDropout])]),o.stateSize=o.units,o.dropoutMask=null,o.recurrentDropoutMask=null,o}return u.prototype.build=function(r){r=$r(r),this.kernel=this.addWeight("kernel",[r[r.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(r=r,r.length!==2)throw new w("SimpleRNNCell expects 2 input Tensors, got "+r.length+".");var b=r[1];r=r[0];var T=o.training==null?!1:o.training;01){for(var T=[0],M=2;M1)throw new w("Can not merge tensors with different batch sizes. "+("Got tensors with shapes: "+JSON.stringify(r)+"."));for(var M=r[0]==null?null:r[0].slice(1),q=1;q1){var or=ln(1,Ne).concat([0]);b.push(i.transpose(le,or)),je=!0}else b.push(le)}var Xt=h.mergeFunction(b),Jt=Xt.rank;if(je){if(Jt==null){var vr=Xt.shape,lr=vr.length,st=vr[lr-1],dt=[st].concat(vr.slice(0,vr.length-1));Xt=i.transpose(Xt.reshape([-1,st]),[1,0]).reshape(dt)}else if(Jt>1){var or=[Jt-1].concat(ln(0,Jt-1));Xt=i.transpose(Xt,or)}}return Xt}}else return h.mergeFunction(r)})},u.prototype.computeOutputShape=function(r){r=r;var o;r[0]==null?o=null:o=r[0].slice(1);for(var h=1;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 ji(r,o.axis)})},u.prototype.computeOutputShape=function(r){if(!(Array.isArray(r)&&Array.isArray(r[0])))throw new w("A `Concatenate` layer should be called on a list of inputs.");for(var o=r,h=o[0].slice(),b=this.axis<0?h.length+this.axis:this.axis,T=0,M=o.slice(1);T3||u.shape.length>3)throw new ge("batchDot is not implemented for tensors of 4D or higher rank yet");if(i.util.assert(s.shape.length>=2,function(){return"batchDot requires the rank of x to be >= 2, "+("but got "+s.shape.length)}),i.util.assert(s.shape.length>=2,function(){return"batchDot requires the rank of y to be >= 2, "+("but got "+u.shape.length)}),typeof r=="number"&&(r=[r,r]),s.dtype==="complex64"||u.dtype==="complex64")throw new ge("batchDot is not implemented for complex64-type Tensors yet.");var o=s.shape.length,h=u.shape.length;r==null&&(r=[o-1,h-2]);var b=r;return i.tidy(function(){var T;if(o>h){T=o-h;for(var M=[],q=0;qo){T=h-o;for(var M=[],q=0;q0){var We=void 0;o>h?We=o+h-3:We=o-1;for(var je=[],q=We;q3||h.length>3)throw new ge("Dot layer does not support tensors of 4D or higher rank yet.");var b=this.interpretAxes(o,h);if(o[b[0]]!==h[b[1]])throw new w("Dimension incompatibility: "+(o[b[0]]+" !== "+h[b[1]]))},u.prototype.mergeFunction=function(r){if(r.length!==2)throw new w("A `Dot` layer must be called on exactly 2 inputs, "+("but received "+r.length+" input(s)."));var o=r[0],h=r[1],b;return Array.isArray(this.axes)?b=this.axes.map(function(T,M){return ho(T,r[M].shape.length)}):b=[ho(this.axes,o.shape.length),ho(this.axes,h.shape.length)],this.normalize&&(o=Xa(o,b[0]),h=Xa(h,b[1])),Sc(o,h,b)},u.prototype.interpretAxes=function(r,o){var h;return Array.isArray(this.axes)?h=this.axes:h=[ho(this.axes,r.length),ho(this.axes,o.length)],h},u.prototype.computeOutputShape=function(r){i.util.assert(Array.isArray(r)&&r.length===2&&Array.isArray(r[0])&&Array.isArray(r[1]),function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."});var o=r[0].slice(),h=r[1].slice();if(o.length>3||h.length>3)throw new ge("Dot layer does not support tensors of 4D or higher rank yet.");var b=this.interpretAxes(o,h);o.splice(b[0],1),h.splice(b[1],1),h.splice(0,1);var T=o.concat(h);return T.length===1&&T.push(1),T},u.prototype.computeMask=function(r,o){return null},u.prototype.getConfig=function(){var r={axes:this.axes,normalize:this.normalize},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="Dot",u}(Go);i.serialization.registerClass(pu);var Ic=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o.stddev=r.stddev,o}return u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={stddev:this.stddev};return Object.assign(o,r),o},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r),T=function(){return Mi(b.shape,0,h.stddev).add(b)},M=Ye(T,function(){return b},o.training||!1);return M})},u.className="GaussianNoise",u}(qr);i.serialization.registerClass(Ic);var Mu=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o.rate=r.rate,o}return u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={rate:this.rate};return Object.assign(o,r),o},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o);var b=ur(r);if(h.rate>0&&h.rate<1){var T=function(){var M=Math.sqrt(h.rate/(1-h.rate));return b.mul(Mi(b.shape,1,M))};return Ye(T,function(){return b},o.training||!1)}return b})},u.className="GaussianDropout",u}(qr);i.serialization.registerClass(Mu);var Gs=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o.rate=r.rate,o.noiseShape=r.noiseShape,o}return u.prototype._getNoiseShape=function(r){return this.noiseShape||ur(r).shape},u.prototype.computeOutputShape=function(r){return r},u.prototype.getConfig=function(){var r=s.prototype.getConfig.call(this),o={rate:this.rate};return Object.assign(o,r),o},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){if(h.rate<1&&h.rate>0){var b=h._getNoiseShape(r),T=function(){var M=ur(r),q=1.6732632423543772,Y=1.0507009873554805,le=-q*Y,Ne=i.greaterEqual(i.randomUniform(b),h.rate);Ne=ni(Ne,"float32");var We=Math.pow((1-h.rate)*(1+h.rate*Math.pow(le,2)),-.5),je=-We*le*h.rate,qe=M.mul(Ne).add(Ne.add(-1).mul(le));return qe.mul(We).add(je)};return Ye(T,function(){return ur(r)},o.training||!1)}return r})},u.className="AlphaDropout",u}(qr);i.serialization.registerClass(Gs);function po(s,u,r,o,h,b){b===void 0&&(b=.001);var T;if(s.rank===2)T=i.batchNorm2d(s,u,r,o,h,b);else if(s.rank===3)T=i.batchNorm3d(s,u,r,o,h,b);else if(s.rank===4)T=i.batchNorm4d(s,u,r,o,h,b);else throw new ge("batchNormalization is not implemented for array of rank "+s.rank+" yet");return T}function Lu(s,u,r,o,h){return h===void 0&&(h=.001),i.tidy(function(){var b=i.moments(s,o),T=b.mean,M=b.variance,q=po(s,T,M,r,u,h);return[q,T,M]})}function _l(s,u,r,o,h){return h===void 0&&(h=.001),i.tidy(function(){for(var b=i.moments(s,o),T=b.mean,M=b.variance,q=[],Y=0,le=ln(0,s.rank);Y=0?this.axis:this.axis+r.length,b=r[h];if(b==null)throw new w("Axis "+h+" of input tensor should have a defined dimension but the layer received an input with shape "+(JSON.stringify(r)+"."));this.inputSpec=[new An({ndim:r.length,axes:(o={},o[h]=b,o)})];var T=[b];this.scale&&(this.gamma=this.addWeight("gamma",T,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",T,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",T,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",T,null,this.movingVarianceInitializer,null,!1),this.built=!0},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=o.training==null?!1:o.training,T=ur(r),M=T.shape,q=M.length,Y=ln(0,q),le=h.axis>=0?h.axis:h.axis+q;Y.splice(le,1);var Ne=nt(1,q);Ne[le]=M[le];var We=Y.slice();We.sort();var je=!i.util.arraysEqual(We,ln(0,q).slice(0,q-1)),qe=function(){if(je){var Xt=h.movingMean.read().reshape(Ne),Jt=h.movingVariance.read().reshape(Ne),vr=h.center?h.beta.read().reshape(Ne):null,lr=h.scale?h.gamma.read().reshape(Ne):null;return po(T,Xt,Jt,vr,lr,h.epsilon)}else return po(T,h.movingMean.read(),h.movingVariance.read(),h.beta==null?null:h.beta.read(),h.gamma==null?null:h.gamma.read(),h.epsilon)};if(!b)return qe();var mt=zu(T,h.gamma.read(),h.beta.read(),Y,h.epsilon),pt=mt[0],st=mt[1],dt=mt[2],Dt=function(Xt,Jt,vr){i.tidy(function(){var lr=1-vr,Ir=Xt.read(),Lr=Ir.sub(Jt).mul(lr);Xt.write(Ir.sub(Lr))})},or=function(){Dt(h.movingMean,st,h.momentum),Dt(h.movingVariance,dt,h.momentum)};return or(),pt})},u.prototype.getConfig=function(){var r={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:S(this.betaInitializer),gammaInitializer:S(this.gammaInitializer),movingMeanInitializer:S(this.movingMeanInitializer),movingVarianceInitializer:S(this.movingVarianceInitializer),betaRegularizer:dn(this.betaRegularizer),gammaRegularizer:dn(this.gammaRegularizer),betaConstraint:rn(this.betaConstraint),gammaConstraint:rn(this.gammaConstraint)},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="BatchNormalization",u}(qr);i.serialization.registerClass(Pu);var du=function(s){O(u,s);function u(r){var o=this;if(r==null&&(r={}),o=s.call(this,r)||this,o.axis=r.axis==null?-1:r.axis,typeof o.axis=="number"){if(!Number.isInteger(o.axis))throw new Error("Expected axis to be an integer, but received "+o.axis)}else if(Array.isArray(o.axis))for(var h=0,b=o.axis;h=o)throw new Error("Invalid axis: "+M)}if(this.axis.length!==qt(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);var q=this.axis.map(function(le){return r[le]}),Y=!0;this.scale?this.gamma=this.addWeight("gamma",q,"float32",this.gammaInitializer,this.gammaRegularizer,Y):this.gamma=null,this.center?this.beta=this.addWeight("beta",q,"float32",this.betaInitializer,this.betaRegularizer,Y):this.beta=null,this.built=!0},u.prototype.call=function(r,o){var h=this,b=ur(r),T=b.shape,M=T.length;return i.tidy(function(){for(var q=!0,Y=i.moments(b,h.axis,q),le=Y.mean,Ne=Y.variance,We=nt(1,M),je=0,qe=h.axis;je=0?o=r[2]+this.padding[0][0]+this.padding[0][1]:o=null,r[3]!=null&&r[3]>=0?h=r[3]+this.padding[1][0]+this.padding[1][1]:h=null,[r[0],r[1],o,h]):(r[1]!=null&&r[1]>=0?o=r[1]+this.padding[0][0]+this.padding[0][1]:o=null,r[2]!=null&&r[2]>=0?h=r[2]+this.padding[1][0]+this.padding[1][1]:h=null,[r[0],o,h,r[3]])},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){return wl(ur(r),h.padding,h.dataFormat)})},u.prototype.getConfig=function(){var r={padding:this.padding,dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.className="ZeroPadding2D",u}(qr);i.serialization.registerClass(fu);function mu(s,u,r,o,h,b){return i.tidy(function(){on(h),xa(b),_n(o),r==null&&(r=[1,1]),o==null&&(o="valid"),h==null&&(h=he()),b==null&&(b="max"),s=bo(s,h);var T,M=o==="same"?"same":"valid";return b==="max"?T=i.maxPool(s,u,r,M):T=i.avgPool(s,u,r,M),h==="channelsFirst"&&(T=i.transpose(T,[0,3,1,2])),T})}function Nc(s,u,r,o,h,b){return i.tidy(function(){on(h),xa(b),_n(o),r==null&&(r=[1,1,1]),o==null&&(o="valid"),h==null&&(h=he()),b==null&&(b="max"),s=so(s,h);var T,M=o==="same"?"same":"valid";return b==="max"?T=i.maxPool3d(s,u,r,M):T=i.avgPool3d(s,u,r,M),h==="channelsFirst"&&(T=i.transpose(T,[0,4,1,2,3])),T})}var Cc=function(s){O(u,s);function u(r){var o=this;if(r.poolSize==null&&(r.poolSize=2),o=s.call(this,r)||this,typeof r.poolSize=="number")o.poolSize=[r.poolSize];else if(Array.isArray(r.poolSize)&&r.poolSize.length===1&&typeof r.poolSize[0]=="number")o.poolSize=r.poolSize;else throw new w("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+(""+JSON.stringify(r.poolSize)));if(tr(o.poolSize,"poolSize"),r.strides==null)o.strides=o.poolSize;else if(typeof r.strides=="number")o.strides=[r.strides];else if(Array.isArray(r.strides)&&r.strides.length===1&&typeof r.strides[0]=="number")o.strides=r.strides;else throw new w("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+(""+JSON.stringify(r.strides)));return tr(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,_n(o.padding),o.inputSpec=[new An({ndim:3})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o=Ii(r[1],this.poolSize[0],this.padding,this.strides[0]);return[r[0],o,r[2]]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){h.invokeCallHook(r,o),r=gr(ur(r),2);var b=h.poolingFunction(ur(r),[h.poolSize[0],1],[h.strides[0],1],h.padding,"channelsLast");return i.squeeze(b,[2])})},u.prototype.getConfig=function(){var r={poolSize:this.poolSize,padding:this.padding,strides:this.strides},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),Tc=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),mu(r,o,h,b,T,"max")},u.className="MaxPooling1D",u}(Cc);i.serialization.registerClass(Tc);var Ec=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),mu(r,o,h,b,T,"avg")},u.className="AveragePooling1D",u}(Cc);i.serialization.registerClass(Ec);var Ke=function(s){O(u,s);function u(r){var o=this;if(r.poolSize==null&&(r.poolSize=[2,2]),o=s.call(this,r)||this,o.poolSize=Array.isArray(r.poolSize)?r.poolSize:[r.poolSize,r.poolSize],r.strides==null)o.strides=o.poolSize;else if(Array.isArray(r.strides)){if(r.strides.length!==2)throw new w("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length "+(r.strides.length+"."));o.strides=r.strides}else o.strides=[r.strides,r.strides];return tr(o.poolSize,"poolSize"),tr(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,on(o.dataFormat),_n(o.padding),o.inputSpec=[new An({ndim:4})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o=this.dataFormat==="channelsFirst"?r[2]:r[1],h=this.dataFormat==="channelsFirst"?r[3]:r[2];return o=Ii(o,this.poolSize[0],this.padding,this.strides[0]),h=Ii(h,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[r[0],r[1],o,h]:[r[0],o,h,r[3]]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){return h.invokeCallHook(r,o),h.poolingFunction(ur(r),h.poolSize,h.strides,h.padding,h.dataFormat)})},u.prototype.getConfig=function(){var r={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),Rc=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),mu(r,o,h,b,T,"max")},u.className="MaxPooling2D",u}(Ke);i.serialization.registerClass(Rc);var un=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),mu(r,o,h,b,T,"avg")},u.className="AveragePooling2D",u}(Ke);i.serialization.registerClass(un);var Ac=function(s){O(u,s);function u(r){var o=this;if(r.poolSize==null&&(r.poolSize=[2,2,2]),o=s.call(this,r)||this,o.poolSize=Array.isArray(r.poolSize)?r.poolSize:[r.poolSize,r.poolSize,r.poolSize],r.strides==null)o.strides=o.poolSize;else if(Array.isArray(r.strides)){if(r.strides.length!==3)throw new w("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length "+(r.strides.length+"."));o.strides=r.strides}else o.strides=[r.strides,r.strides,r.strides];return tr(o.poolSize,"poolSize"),tr(o.strides,"strides"),o.padding=r.padding==null?"valid":r.padding,o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,on(o.dataFormat),_n(o.padding),o.inputSpec=[new An({ndim:5})],o}return u.prototype.computeOutputShape=function(r){r=$r(r);var o=this.dataFormat==="channelsFirst"?r[2]:r[1],h=this.dataFormat==="channelsFirst"?r[3]:r[2],b=this.dataFormat==="channelsFirst"?r[4]:r[3];return o=Ii(o,this.poolSize[0],this.padding,this.strides[0]),h=Ii(h,this.poolSize[1],this.padding,this.strides[1]),b=Ii(b,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[r[0],r[1],o,h,b]:[r[0],o,h,b,r[4]]},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){return h.invokeCallHook(r,o),h.poolingFunction(ur(r),h.poolSize,h.strides,h.padding,h.dataFormat)})},u.prototype.getConfig=function(){var r={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),Ss=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),Nc(r,o,h,b,T,"max")},u.className="MaxPooling3D",u}(Ac);i.serialization.registerClass(Ss);var Dc=function(s){O(u,s);function u(r){return s.call(this,r)||this}return u.prototype.poolingFunction=function(r,o,h,b,T){return on(T),_n(b),Nc(r,o,h,b,T,"avg")},u.className="AveragePooling3D",u}(Ac);i.serialization.registerClass(Dc);var $n=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.inputSpec=[new An({ndim:3})],o}return u.prototype.computeOutputShape=function(r){return[r[0],r[2]]},u.prototype.call=function(r,o){throw new ge},u}(qr),Fc=function(s){O(u,s);function u(r){return s.call(this,r||{})||this}return u.prototype.call=function(r,o){return i.tidy(function(){var h=ur(r);return i.mean(h,1)})},u.className="GlobalAveragePooling1D",u}($n);i.serialization.registerClass(Fc);var Oc=function(s){O(u,s);function u(r){return s.call(this,r||{})||this}return u.prototype.call=function(r,o){return i.tidy(function(){var h=ur(r);return i.max(h,1)})},u.className="GlobalMaxPooling1D",u}($n);i.serialization.registerClass(Oc);var Mc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.dataFormat=r.dataFormat==null?"channelsLast":r.dataFormat,on(o.dataFormat),o.inputSpec=[new An({ndim:4})],o}return u.prototype.computeOutputShape=function(r){return r=r,this.dataFormat==="channelsLast"?[r[0],r[3]]:[r[0],r[1]]},u.prototype.call=function(r,o){throw new ge},u.prototype.getConfig=function(){var r={dataFormat:this.dataFormat},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u}(qr),js=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=ur(r);return h.dataFormat==="channelsLast"?i.mean(b,[1,2]):i.mean(b,[2,3])})},u.className="GlobalAveragePooling2D",u}(Mc);i.serialization.registerClass(js);var is=function(s){O(u,s);function u(){return s!==null&&s.apply(this,arguments)||this}return u.prototype.call=function(r,o){var h=this;return i.tidy(function(){var b=ur(r);return h.dataFormat==="channelsLast"?i.max(b,[1,2]):i.max(b,[2,3])})},u.className="GlobalMaxPooling2D",u}(Mc);i.serialization.registerClass(is);var Lc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.layer=r.layer,o}return u.prototype.build=function(r){this.built=!0},Object.defineProperty(u.prototype,"trainable",{get:function(){return this.layer!=null?this.layer.trainable:!1},set:function(r){this.layer!=null&&(this.layer.trainable=r)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"trainableWeights",{get:function(){return this.layer.trainableWeights},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nonTrainableWeights",{get:function(){return this.layer.nonTrainableWeights},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"updates",{get:function(){return this.layer._updates},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"losses",{get:function(){return this.layer.losses},enumerable:!0,configurable:!0}),u.prototype.getWeights=function(){return this.layer.getWeights()},u.prototype.setWeights=function(r){this.layer.setWeights(r)},u.prototype.getConfig=function(){var r={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},o=s.prototype.getConfig.call(this);return Object.assign(r,o),r},u.prototype.setFastWeightInitDuringBuild=function(r){s.prototype.setFastWeightInitDuringBuild.call(this,r),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(r)},u.fromConfig=function(r,o,h){h===void 0&&(h={});var b=o.layer,T=oa(b,h);delete o.layer;var M={layer:T};return Object.assign(M,o),new r(M)},u}(qr),zc=function(s){O(u,s);function u(r){var o=s.call(this,r)||this;return o.supportsMasking=!0,o}return u.prototype.build=function(r){if(r=$r(r),r.length<3)throw new w("TimeDistributed layer expects an input shape >= 3D, but received "+("input shape "+JSON.stringify(r)));this.inputSpec=[{shape:r}];var o=[r[0]].concat(r.slice(2));this.layer.built||(this.layer.build(o),this.layer.built=!0),s.prototype.build.call(this,r)},u.prototype.computeOutputShape=function(r){r=$r(r);var o=[r[0]].concat(r.slice(2)),h=this.layer.computeOutputShape(o),b=r[1];return[h[0],b].concat(h.slice(1))},u.prototype.call=function(r,o){var h=this;return i.tidy(function(){r=ur(r);var b=function(q,Y){var le=ur(h.layer.call(q,o));return[le,[]]},T=yc(b,r,[],!1,null,null,!1,!0),M=T[1];return M})},u.className="TimeDistributed",u}(Lc);i.serialization.registerClass(zc);function yu(s){jr(wi,"BidirectionalMergeMode",s)}var Pc="concat",Bu=function(s){O(u,s);function u(r){var o=s.call(this,r)||this,h=r.layer.getConfig(),b={};b.className=r.layer.getClassName(),b.config=h,o.forwardLayer=oa(b),h.goBackwards=!(h.goBackwards===!0);var T={};if(T.className=r.layer.getClassName(),T.config=h,o.backwardLayer=oa(T),o.forwardLayer.name="forward_"+o.forwardLayer.name,o.backwardLayer.name="backward_"+o.backwardLayer.name,o.mergeMode=r.mergeMode===void 0?Pc:r.mergeMode,yu(o.mergeMode),r.weights)throw new ge("weights support is not implemented for Bidirectional layer yet.");return o._stateful=r.layer.stateful,o.returnSequences=r.layer.returnSequences,o.returnState=r.layer.returnState,o.supportsMasking=!0,o._trainable=!0,o.inputSpec=r.layer.inputSpec,o.numConstants=null,o}return Object.defineProperty(u.prototype,"trainable",{get:function(){return this._trainable},set:function(r){this._trainable=r,this.forwardLayer!=null&&(this.forwardLayer.trainable=r),this.backwardLayer!=null&&(this.backwardLayer.trainable=r)},enumerable:!0,configurable:!0}),u.prototype.getWeights=function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())},u.prototype.setWeights=function(r){var o=r.length,h=Math.floor(o/2);this.forwardLayer.setWeights(r.slice(0,h)),this.backwardLayer.setWeights(r.slice(h))},u.prototype.computeOutputShape=function(r){var o=this.forwardLayer.computeOutputShape(r);Array.isArray(o)&&Array.isArray(o[0])||(o=[o]),o=o;var h,b,T;return this.returnState&&(T=o.slice(1)),h=o[0],h=h,this.mergeMode==="concat"?(h[h.length-1]*=2,b=[h]):this.mergeMode==null?b=[h,h.slice()]:b=[h],this.returnState?this.mergeMode==null?b.concat(T).concat(T.slice()):[h].concat(T).concat(T.slice()):Tt(b)},u.prototype.apply=function(r,o){var h=o==null?null:o.initialState,b=o==null?null:o.constants;o==null&&(o={});var T=mc(r,h,b,this.numConstants);if(r=T.inputs,h=T.initialState,b=T.constants,Array.isArray(r)&&(h=r.slice(1),r=r[0]),(h==null||h.length===0)&&b==null)return s.prototype.apply.call(this,r,o);var M=[],q=[];if(h!=null){var Y=h.length;if(Y%2>0)throw new w("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");o.initialState=h,M.push.apply(M,h);var le=h.map(function(Dt){return new An({shape:Dt.shape})});this.forwardLayer.stateSpec=le.slice(0,Y/2),this.backwardLayer.stateSpec=le.slice(Y/2),q.push.apply(q,le)}if(b!=null)throw new ge("Support for constants in Bidirectional layers is not implemented yet.");for(var Ne=M[0]instanceof ba,We=0,je=M;Weu}var Te=function(s){O(u,s);function u(r){var o=s.call(this)||this;if(r==null&&(r={}),r.restoreBestWeights)throw new ge("restoreBestWeights = True is not implemented in EarlyStopping yet.");return o.monitor=r.monitor||"val_loss",o.minDelta=Math.abs(r.minDelta||0),o.patience=r.patience||0,o.verbose=r.verbose||0,o.mode=r.mode||"auto",o.baseline=r.baseline,["auto","min","max"].indexOf(o.mode)===-1&&(console.warn("EarlyStopping mode '"+o.mode+"' is invalid. Falling back to mode 'auto'."),o.mode="auto"),o.mode==="min"?o.monitorFunc=Ce:o.mode==="max"||o.monitor.indexOf("acc")!==-1?o.monitorFunc=De:o.monitorFunc=Ce,o.monitorFunc===Ce&&(o.minDelta*=-1),o}return u.prototype.onTrainBegin=function(r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return this.wait=0,this.stoppedEpoch=0,this.baseline!=null?this.best=this.baseline:this.best=this.monitorFunc===Ce?Infinity:-Infinity,[2]})})},u.prototype.onEpochEnd=function(r,o){return xe(this,void 0,void 0,function(){var h;return Q(this,function(b){switch(b.label){case 0:return[4,oi(o)];case 1:return b.sent(),h=this.getMonitorValue(o),h==null?[2]:(this.monitorFunc(h-this.minDelta,this.best)?(this.best=h,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=r,this.model.stopTraining=!0)),[2])}})})},u.prototype.onTrainEnd=function(r){return xe(this,void 0,void 0,function(){return Q(this,function(o){return this.stoppedEpoch>0&&this.verbose&&console.log("Epoch "+this.stoppedEpoch+": early stopping."),[2]})})},u.prototype.getMonitorValue=function(r){r==null&&(r={});var o=r[this.monitor];return o==null&&console.warn("Metric for EarlyStopping "+this.monitor+" is not available. "+("Available metrics are: "+Object.keys(r))),o},u}(be);function Ge(s){return new Te(s)}var Ze={earlyStopping:Ge};N.Callback=be,N.CallbackList=ao,N.CustomCallback=Co,N.EarlyStopping=Te,N.History=No,N.InputSpec=An,N.LayerVariable=Ga,N.LayersModel=wt,N.RNN=Ni,N.Sequential=Ie,N.SymbolicTensor=ba,N.callbacks=Ze,N.constraints=Gn,N.initializers=xr,N.input=hr,N.layers=$c,N.loadLayersModel=Tr,N.metrics=I,N.model=br,N.models=R,N.registerCallbackConstructor=Dr,N.regularizers=Z,N.sequential=Nr,N.version_layers=gs}),sg=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=Object.assign||function(S){for(var x,k=1,K=arguments.length;k0&&we[we.length-1])&&(ft[0]===6||ft[0]===2)){k=0;continue}if(ft[0]===3&&(!we||ft[1]>we[0]&&ft[1]0)&&!(Se=K.next()).done;)we.push(Se.value)}catch(Be){Je={error:Be}}finally{try{Se&&!Se.done&&(k=K.return)&&k.call(K)}finally{if(Je)throw Je.error}}return we}function xe(){for(var S=[],x=0;x0?Object.keys(Wt).forEach(function(Yt){var xr=se(W(Yt),1),Sn=xr[0],pn=vt[Sn];pn&&(pn.signatureKey=Wt[Yt],ft.push(pn))}):ft=we;var wr={};x.library!=null&&x.library.function!=null&&(wr=x.library.function.reduce(function(Yt,xr){return Yt[xr.signature.name]=K.mapFunction(xr),Yt},{}));var Ar={nodes:vt,inputs:ft,outputs:zt,weights:Je,placeholders:we,signature:k,functions:wr};return Be.length>0&&(Ar.initNodes=Be),Ar},S.prototype.mapSignatureEntries=function(x){return Object.keys(x||{}).reduce(function(k,K){return k[x[K].name]=K,k},{})},S.prototype.mapNode=function(x){var k=me(x.op)||this.opMappers[x.op]||{};x.attr==null&&(x.attr={});var K={name:x.name,op:x.op,category:k.category,inputNames:(x.input||[]).map(function(Se){return Se.startsWith("^")?Se.substr(1):Se}),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:x.attr};return k.inputs!=null&&(K.inputParams=k.inputs.reduce(function(Se,we){return Se[we.name]={type:we.type,inputIndexStart:we.start,inputIndexEnd:we.end},Se},{})),k.attrs!=null&&(K.attrParams=k.attrs.reduce(function(Se,we){var Je=we.type,Be=void 0;switch(we.type){case"string":Be=on(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=on(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"string[]":Be=ri(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=ri(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"number":Be=xa(x.attr,we.tfName,we.defaultValue||0),Be===void 0&&!!we.tfDeprecatedName&&(Be=xa(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"number[]":Be=qn(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=qn(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"bool":Be=_n(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=_n(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"bool[]":Be=pa(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=pa(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"shape":Be=Ai(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=Ai(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"shape[]":Be=pi(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=pi(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"dtype":Be=_a(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=_a(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"dtype[]":Be=Ri(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=Ri(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"func":Be=ti(x.attr,we.tfName,we.defaultValue),Be===void 0&&!!we.tfDeprecatedName&&(Be=ti(x.attr,we.tfDeprecatedName,we.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: "+we.type+" for op: "+x.op)}return Se[we.name]={value:Be,type:Je},Se},{})),K},S.prototype.mapFunction=function(x){var k=this,K=x.nodeDef,Se=[],we=[],Je={};K!=null&&(Je=K.reduce(function(Gt,Qt){return Gt[Qt.name]=k.mapNode(Qt),Qt.op==="Const"&&we.push(Gt[Qt.name]),Gt},{}));var Be=[],vt=[];x.signature.inputArg.forEach(function(Gt){var Qt=se(W(Gt.name),1),wr=Qt[0],Ar={name:wr,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:Rr(Gt.type),type:"dtype"}},children:[]};Ar.signatureKey=Gt.name,Be.push(Ar),Je[wr]=Ar});var ft=Object.keys(Je);ft.forEach(function(Gt){var Qt=Je[Gt];Qt.inputNames.forEach(function(wr){var Ar=se(W(wr),1),Yt=Ar[0];Qt.inputs.push(Je[Yt]),Je[Yt].children.push(Qt)})});var zt=x.ret;x.signature.outputArg.forEach(function(Gt){var Qt=se(W(zt[Gt.name]),2),wr=Qt[0],Ar=Qt[1],Yt=Je[wr];Yt!=null&&(Yt.defaultOutput=Ar,vt.push(Yt))});var Wt=this.mapArgsToSignature(x);return{nodes:Je,inputs:Be,outputs:vt,weights:we,placeholders:Se,signature:Wt}},S.prototype.mapArgsToSignature=function(x){var k=this;return{methodName:x.signature.name,inputs:x.signature.inputArg.reduce(function(K,Se){return K[Se.name]=k.mapArgToTensorInfo(Se),K},{}),outputs:x.signature.outputArg.reduce(function(K,Se){return K[Se.name]=k.mapArgToTensorInfo(Se,x.ret),K},{})}},S.prototype.mapArgToTensorInfo=function(x,k){var K=x.name;return k!=null&&(K=k[K]),{name:K,dtype:x.type}},S}();function wi(S){var x=i.env().global;if(typeof x.atob!="undefined")return x.atob(S);if(typeof Buffer!="undefined")return new Buffer(S,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}function Ta(S,x){var k=Array.isArray(S)?String.fromCharCode.apply(null,S):wi(S);return x?k:k.toLowerCase()}function on(S,x,k,K){K===void 0&&(K=!1);var Se=S[x];return Se!=null?Ta(Se.s,K):k}function _n(S,x,k){var K=S[x];return K?K.b:k}function xa(S,x,k){var K=S[x]||{},Se=K.i!=null?K.i:K.f!=null?K.f:k;return typeof Se=="number"?Se:parseInt(Se,10)}function Rr(S){typeof S=="string"&&(S=Q[S]);switch(S){case Q.DT_FLOAT:return"float32";case Q.DT_INT32:case Q.DT_INT64:case Q.DT_INT8:case Q.DT_UINT8:return"int32";case Q.DT_BOOL:return"bool";case Q.DT_DOUBLE:return"float32";case Q.DT_STRING:return"string";default:return null}}function ti(S,x,k){var K=S[x];return K&&K.func?K.func.name:k}function _a(S,x,k){var K=S[x];return K&&K.type?Rr(K.type):k}function Ri(S,x,k){var K=S[x];return K&&K.list&&K.list.type?K.list.type.map(function(Se){return Rr(Se)}):k}function Hi(S){return S.unknownRank?void 0:S.dim!=null?S.dim.map(function(x){return typeof x.size=="number"?x.size:parseInt(x.size,10)}):[]}function Ai(S,x,k){var K=S[x];return K&&K.shape?Hi(K.shape):k}function qn(S,x,k){var K=S[x];return K?((K.list.f&&K.list.f.length?K.list.f:K.list.i)||[]).map(function(Se){return typeof Se=="number"?Se:parseInt(Se,10)}):k}function ri(S,x,k,K){K===void 0&&(K=!1);var Se=S[x];return Se&&Se.list&&Se.list.s?Se.list.s.map(function(we){return Ta(we,K)}):k}function pi(S,x,k){var K=S[x];return K&&K.list&&K.list.shape?K.list.shape.map(function(Se){return Hi(Se)}):k}function pa(S,x,k){var K=S[x];return K&&K.list&&K.list.b?K.list.b:k}var di=function(){function S(x,k,K){var Se=this;this.node=x,this.tensorMap=k,this.context=K,this.inputs=[],this.attrs={},this.inputs=x.inputNames.map(function(we){return Se.getInput(we)}),x.rawAttrs!=null&&(this.attrs=Object.keys(x.rawAttrs).reduce(function(we,Je){return we[Je]=Se.getAttr(Je),we},{}))}return S.prototype.getInput=function(x){return ge(x,this.tensorMap,this.context)},S.prototype.getAttr=function(x,k){var K=this.node.rawAttrs[x];if(K.tensor!=null)return ge(x,this.tensorMap,this.context);if(K.i!=null||K.f!=null)return xa(this.node.rawAttrs,x,k);if(K.s!=null)return on(this.node.rawAttrs,x,k);if(K.b!=null)return _n(this.node.rawAttrs,x,k);if(K.shape!=null)return Ai(this.node.rawAttrs,x,k);if(K.type!=null)return _a(this.node.rawAttrs,x,k);if(K.list!=null){if(K.list.i!=null||K.list.f!=null)return qn(this.node.rawAttrs,x,k);if(K.list.s!=null)return ri(this.node.rawAttrs,x,k);if(K.list.shape!=null)return pi(this.node.rawAttrs,x,k);if(K.list.b!=null)return pa(this.node.rawAttrs,x,k);if(K.list.type!=null)return Ri(this.node.rawAttrs,x,k)}return k},S}(),fi=function(S,x,k){switch(S.op){case"BiasAdd":case"AddV2":case"Add":return[i.add(w("a",S,x,k),w("b",S,x,k))];case"AddN":return[i.addN(w("tensors",S,x,k))];case"FloorMod":case"Mod":return[i.mod(w("a",S,x,k),w("b",S,x,k))];case"Mul":return[i.mul(w("a",S,x,k),w("b",S,x,k))];case"RealDiv":case"Div":return[i.div(w("a",S,x,k),w("b",S,x,k))];case"DivNoNan":return[i.divNoNan(w("a",S,x,k),w("b",S,x,k))];case"FloorDiv":return[i.floorDiv(w("a",S,x,k),w("b",S,x,k))];case"Sub":return[i.sub(w("a",S,x,k),w("b",S,x,k))];case"Minimum":return[i.minimum(w("a",S,x,k),w("b",S,x,k))];case"Maximum":return[i.maximum(w("a",S,x,k),w("b",S,x,k))];case"Pow":return[i.pow(w("a",S,x,k),w("b",S,x,k))];case"SquaredDifference":return[i.squaredDifference(w("a",S,x,k),w("b",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}},Va=function(S,x,k){switch(S.op){case"Abs":case"ComplexAbs":return[i.abs(w("x",S,x,k))];case"Acos":return[i.acos(w("x",S,x,k))];case"Acosh":return[i.acosh(w("x",S,x,k))];case"Asin":return[i.asin(w("x",S,x,k))];case"Asinh":return[i.asinh(w("x",S,x,k))];case"Atan":return[i.atan(w("x",S,x,k))];case"Atan2":return[i.atan2(w("x",S,x,k),w("y",S,x,k))];case"Atanh":return[i.atanh(w("x",S,x,k))];case"Ceil":return[i.ceil(w("x",S,x,k))];case"Complex":return[i.complex(w("real",S,x,k),w("imag",S,x,k))];case"Cos":return[i.cos(w("x",S,x,k))];case"Cosh":return[i.cosh(w("x",S,x,k))];case"Elu":return[i.elu(w("x",S,x,k))];case"Erf":return[i.erf(w("x",S,x,k))];case"Exp":return[i.exp(w("x",S,x,k))];case"Expm1":return[i.expm1(w("x",S,x,k))];case"Floor":return[i.floor(w("x",S,x,k))];case"Log":return[i.log(w("x",S,x,k))];case"Log1p":return[i.log1p(w("x",S,x,k))];case"Imag":return[i.imag(w("x",S,x,k))];case"Neg":return[i.neg(w("x",S,x,k))];case"Reciprocal":return[i.reciprocal(w("x",S,x,k))];case"Real":return[i.real(w("x",S,x,k))];case"Relu":return[i.relu(w("x",S,x,k))];case"Round":return[i.round(w("x",S,x,k))];case"Selu":return[i.selu(w("x",S,x,k))];case"Sigmoid":return[i.sigmoid(w("x",S,x,k))];case"Sin":return[i.sin(w("x",S,x,k))];case"Sign":return[i.sign(w("x",S,x,k))];case"Sinh":return[i.sinh(w("x",S,x,k))];case"Softplus":return[i.softplus(w("x",S,x,k))];case"Sqrt":return[i.sqrt(w("x",S,x,k))];case"Square":return[i.square(w("x",S,x,k))];case"Tanh":return[i.tanh(w("x",S,x,k))];case"Tan":return[i.tan(w("x",S,x,k))];case"Relu6":case"ClipByValue":return[i.clipByValue(w("x",S,x,k),w("clipValueMin",S,x,k),w("clipValueMax",S,x,k))];case"Rsqrt":return[i.rsqrt(ge(S.inputNames[0],x,k))];case"Prod":return[i.prod(w("x",S,x,k),w("axes",S,x,k))];case"LeakyRelu":return[i.leakyRelu(w("x",S,x,k),w("alpha",S,x,k))];case"Prelu":return[i.prelu(w("x",S,x,k),w("alpha",S,x,k))];default:throw TypeError("Node type "+S.op+" is not implemented")}};function ln(S,x,k){k===void 0&&(k=""),i.util.assert(ni(S,x),function(){return k+(" Shapes "+S+" and "+x+" must match")})}function ni(S,x){if(S.length!==x.length)return!1;for(var k=0;k=this.size())throw new Error("Tried to read from index "+x+", but array size is: "+this.size());var k=this.tensors[x];if(k.cleared)throw new Error("TensorArray "+this.name+": Could not read index "+x+" twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).");return this.clearAfterRead&&(k.cleared=!0),k.read=!0,k.tensor},S.prototype.readMany=function(x){var k=this;return x.map(function(K){return k.read(K)})},S.prototype.write=function(x,k){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(x<0||!this.dynamicSize&&x>=this.maxSize)throw new Error("Tried to write to index "+x+", but array is not resizeable and size is: "+this.maxSize);var K=this.tensors[x]||{};if(k.dtype!==this.dtype)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+x+`, because the value dtype is `+k.dtype+", but TensorArray dtype is "+this.dtype+".");if(this.size()===0&&(this.elementShape==null||this.elementShape.length===0)&&(this.elementShape=k.shape),ln(this.elementShape,k.shape,"TensorArray "+this.name+": Could not write to TensorArray index "+x+"."),K.read)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+x+", because it has already been read.");if(K.written)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+x+", because it has already been written.");K.tensor=k,i.keep(k),K.written=!0,this.tensors[x]=K},S.prototype.writeMany=function(x,k){var K=this;if(x.length!==k.length)throw new Error("TensorArray "+this.name+": could not write multiple tensors,"+("because the index size: "+x.length+" is not the same as tensors size: "+k.length+"."));x.forEach(function(Se,we){return K.write(Se,k[we])})},S.prototype.gather=function(x,k){if(!!k&&k!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but gather requested dtype "+k);if(x)x=x.slice(0,this.size());else{x=[];for(var K=0;K=this.maxSize)throw new Error("Max index must be < array size ("+K+" vs. "+this.maxSize+")");this.writeMany(x,i.unstack(k,0))},S.prototype.split=function(x,k){var K=this;if(k.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+k.dtype);var Se=0,we=x.map(function(zt){return Se+=zt,Se});if(Se!==k.shape[0])throw new Error(`Expected sum of lengths to be equal to tensor.shape[0], but sum of lengths is `+Se+", and tensor's shape is: "+k.shape);if(!this.dynamicSize&&x.length!==this.maxSize)throw new Error("TensorArray's size is not equal to the size of lengths ("+this.maxSize+" vs. "+x.length+"), and the TensorArray is not marked as dynamically resizeable");var Je=Se===0?0:k.size/Se,Be=[];i.tidy(function(){k=i.reshape(k,[1,Se,Je]);for(var zt=0;ztthis.maxNumElements)throw new Error("TensorListResize input size "+x+" is greater maxNumElement "+this.maxNumElements+".");this.tensors.length=x},S.prototype.getItem=function(x,k,K){if(K!==this.elementDtype)throw new Error("Invalid data types; op elements "+K+", but list elements "+this.elementDtype);if(x<0||x>this.tensors.length)throw new Error("Trying to access element "+x+" in a list with "+this.tensors.length+" elements.");if(this.tensors[x]==null)throw new Error("element at index "+x+" is null.");return ln(this.tensors[x].shape,k,"TensorList shape mismatch: "),this.tensors[x]},S.prototype.setItem=function(x,k){if(k.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+k.dtype+", but list elements "+this.elementDtype);if(x<0||this.maxNumElements!==-1&&x>=this.maxNumElements)throw new Error("Trying to set element "+x+" in a list with max "+this.maxNumElements+" elements.");ln(this.elementShape,k.shape,"TensorList shape mismatch: "),i.keep(k),this.tensors[x]=k},S.prototype.gather=function(x,k,K){var Se=this;if(k!==this.elementDtype)throw new Error("Invalid data types; op elements "+k+", but list elements "+this.elementDtype);return ln(this.elementShape,K,"TensorList shape mismatch: "),x=x.slice(0,this.size()),x.length===0?i.tensor([],[0].concat(this.elementShape)):i.tidy(function(){var we=x.map(function(Je){return i.reshape(Se.tensors[Je],K)});return i.stack(we,0)})},S.prototype.concat=function(x,k){var K=this;if(!!x&&x!==this.elementDtype)throw new Error("TensorList dtype is "+this.elementDtype+" but concat requested dtype "+x);return ln(this.elementShape,k,"TensorList shape mismatch: "),this.size()===0?i.tensor([],[0].concat(this.elementShape)):i.tidy(function(){var Se=K.tensors.map(function(we){return i.reshape(we,k)});return i.concat(Se,0)})},S}();function bi(S,x,k){var K=S.dtype;if(S.shape.length<1)throw new Error("Tensor must be at least a vector, but saw shape: "+S.shape);if(S.dtype!==k)throw new Error("Invalid data types; op elements "+S.dtype+", but list elements "+k);var Se=S.shape.slice(1);ln(Se,x,"TensorList shape mismatch: ");var we=i.unstack(S);return new Di(we,x,K)}function ro(S,x,k){return new Di([],S,x,k)}function Zn(S,x,k,K){if(x.length!==S.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+x.length+" vs. "+S.shape[0]);var Se=Math.max.apply(Math,xe(x));if(K!=null&&K!==-1&&Se>=K)throw new Error("Max index must be < array size ("+Se+" vs. "+K+")");var we=new Di([],k,S.dtype,K),Je=i.unstack(S,0);return x.forEach(function(Be,vt){we.setItem(Be,Je[vt])}),we}function Gi(S,x,k){var K=0,Se=x.map(function(ft){return K+=ft,K});if(K!==S.shape[0])throw new Error(`Expected sum of lengths to be equal to tensor.shape[0], but sum of lengths is `+K+", and tensor's shape is: "+S.shape);for(var we=K===0?0:S.size/K,Je=i.tidy(function(){var ft=[];S=i.reshape(S,[1,K,we]);for(var zt=0;zt1)this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift();else throw new Error("Cannot exit frame, the context is empty")},S.prototype.nextIteration=function(){if(this.contexts&&this.contexts.length>0){this.contexts=this.contexts.slice(),this.lastId++;var x=Object.assign({},this.contexts[this.contexts.length-1]);x.iterationId+=1,x.id=this.lastId,this.contexts.splice(-1,1,x),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}else throw new Error("Cannot increase frame iteration, the context is empty")},S.prototype.getWeight=function(x){return this.weightMap[x]},S.prototype.addTensorArray=function(x){this.tensorArrayMap[x.id]=x},S.prototype.getTensorArray=function(x){return this.tensorArrayMap[x]},S.prototype.addTensorList=function(x){this.tensorListMap[x.id]=x},S.prototype.getTensorList=function(x){return this.tensorListMap[x]},S.prototype.dispose=function(x){for(var k in this.tensorArrayMap)this.tensorArrayMap[k].clearAndClose(x);for(var k in this.tensorListMap)this.tensorListMap[k].clearAndClose(x)},S}();function Ha(S,x,k,K){var Se=new Set,we=[],Je=null,Be=null,vt=new Set,ft=Object.keys(S).map(function(Qt){return tt(Qt)[0]}),zt=[];K!=null&&(zt=K.map(function(Qt){return tt(Qt.name)[0]}));for(var Wt=xe(x);Wt.length>0;){var Gt=Wt.pop();if((Jr(Gt)||Vr(Gt)||Jn(Gt))&&Je==null&&(Je=Gt,Be=Je.children.map(function(Qt){return Qt.name}).filter(function(Qt){return Se.has(Qt)})),Se.add(Gt.name),k[Gt.name]!=null)continue;if(ft.indexOf(Gt.name)!==-1)continue;if(zt.indexOf(Gt.name)!==-1)continue;if(Gt.inputs.length===0){we.push(Gt.name);continue}Gt.inputs.forEach(function(Qt){if(vt.has(Qt.name))return;vt.add(Qt.name),Wt.push(Qt)})}return{inputs:S,outputs:x,usedNodes:Se,missingInputs:we,dynamicNode:Je,syncInputs:Be}}function ki(S,x,k){var K=k.usedNodes,Se=k.inputs,we=[],Je=Object.keys(Se).map(function(Wt){return tt(Wt)[0]}).map(function(Wt){return S.nodes[Wt]}),Be=S.initNodes;Je.forEach(function(Wt){K.has(Wt.name)&&we.push(Wt)}),S.weights.forEach(function(Wt){K.has(Wt.name)&&we.push(Wt)}),Be!=null&&Be.forEach(function(Wt){K.has(Wt.name)&&we.push(Wt)});for(var vt=new Set,ft=[];we.length>0;){var zt=we.pop();vt.add(zt.name),x[zt.name]||ft.push(zt),zt.children.forEach(function(Wt){!vt.has(Wt.name)&&K.has(Wt.name)&&Wt.inputs.every(function(Gt){return vt.has(Gt.name)})&&we.push(Wt)})}return ft}var sn=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],hn=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],na=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2"];function Jr(S){return sn.indexOf(S.op)>=0}function Vr(S){return hn.indexOf(S.op)>=0}function Jn(S){return na.indexOf(S.op)>=0}var tn=function(){function S(x,k){var K=this;this.graph=x,this.parent=k,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this._outputs=x.outputs,this._inputs=x.inputs,this._initNodes=x.initNodes,this._signature=x.signature,this._functions=x.functions,x.functions!=null&&Object.keys(x.functions).forEach(function(Se){K._functionExecutorMap[Se]=new S(x.functions[Se],K)})}return Object.defineProperty(S.prototype,"weightIds",{get:function(){return this.parent?this.parent.weightIds:this._weightIds},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"functionExecutorMap",{get:function(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"weightMap",{get:function(){return this.parent?this.parent.weightMap:this._weightMap},set:function(x){var k=Object.keys(x).map(function(K){return x[K].map(function(Se){return Se.id})});this._weightIds=[].concat.apply([],xe(k)),this._weightMap=x},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"resourceManager",{set:function(x){this._resourceManager=x},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"inputs",{get:function(){return this._inputs.map(function(x){return{name:x.name,shape:x.attrParams.shape?x.attrParams.shape.value:void 0,dtype:x.attrParams.dtype?x.attrParams.dtype.value:void 0}})},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"outputs",{get:function(){return this._outputs.map(function(x){return{name:x.name,shape:x.attrParams.shape?x.attrParams.shape.value:void 0,dtype:x.attrParams.dtype?x.attrParams.dtype.value:void 0}})},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"inputNodes",{get:function(){return this._inputs.map(function(x){return x.signatureKey||x.name})},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"outputNodes",{get:function(){return this._outputs.map(function(x){var k=x.signatureKey||x.name;return x.defaultOutput?k+":"+x.defaultOutput:k})},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"functions",{get:function(){var x=this;return Object.keys(this._functions).reduce(function(k,K){return k[K]=x._functions[K].signature,k},{})},enumerable:!0,configurable:!0}),S.prototype.getCompilationKey=function(x,k){var K=x.map(function(we){return we.name}).sort(),Se=k.map(function(we){return we.name}).sort();return K.join(this.SEPERATOR)+"--"+Se.join(this.SEPERATOR)},S.prototype.compile=function(x,k){var K=Ha(x,k,this.weightMap,this._initNodes),Se=K.missingInputs,we=K.dynamicNode,Je=K.syncInputs;if(we!=null)throw new Error("This execution contains the node '"+we.name+"', which has "+("the dynamic op '"+we.op+"'. Please use ")+"model.executeAsync() instead. Alternatively, to avoid the "+("dynamic ops, specify the inputs ["+Je+"]"));if(Se.length>0){var Be=k.map(function(ft){return ft.name}),vt=Object.keys(x);throw new Error("Cannot compute the outputs ["+Be+"] from the provided inputs "+("["+vt+"]. Missing the following inputs: ["+Se+"]"))}return ki(this.graph,this.weightMap,K)},S.prototype.execute=function(x,k){var K=this;x=this.mapInputs(x);var Se=Object.keys(x).sort();this.checkInputs(x),this.checkInputShapeAndType(x),k=this.mapOutputs(k),this.checkOutputs(k);var we=Se.map(function(Gt){return K.graph.nodes[tt(Gt)[0]]}),Je=k.map(function(Gt){return tt(Gt)[0]}),Be=Je.map(function(Gt){return K.graph.nodes[Gt]});Be.length===0&&(Be=this._outputs);var vt=this.getCompilationKey(we,Be),ft=this.compiledMap.get(vt);ft==null&&(ft=this.compile(x,Be),this.compiledMap.set(vt,ft));var zt={},Wt={};return i.tidy(function(){var Gt=new ra(K.weightMap,zt,Wt,K.functionExecutorMap),Qt=ke({},K.weightMap);Object.keys(x).forEach(function(pn){var zn=se(tt(pn),2),Fr=zn[0],wa=zn[1],In=[];In[wa]=x[pn],Qt[Fr]=In});for(var wr=K.getFrozenTensorIds(Qt),Ar={},Yt=0;Yt0?(pn=this.processStack(Je,wr,k,Ar,Sn,xr,Be,Yt,zt),[4,Promise.all(pn)]):[3,3];case 2:return In.sent(),[3,1];case 3:if(Gt==null&&!Se&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."),zn=vt.filter(function(ur){return!Jr(ur)&&!ge(ur.name,Ar,k)}).map(function(ur){return ur.name}),zn.length>0)throw Fr="",Gt!=null&&(Fr="Alternatively, to avoid the dynamic ops, use model.execute() "+("and specify the inputs ["+Qt+"]")),new Error("Cannot compute the outputs ["+zn+"] from the provided "+("inputs ["+we+"]. Consider providing the following inputs: ")+("["+Wt+"]. "+Fr));return[2,Ar]}})})},S.prototype.processStack=function(x,k,K,Se,we,Je,Be,vt,ft){for(var zt=this,Wt=[],Gt=function(){var wr,Ar,Yt=k.pop();K.currentContext=Yt.contexts;var xr="";if(Yt.node.op==="Enter"&&w("isConstant",Yt.node,Se,K)&&(wr=se(W(Yt.node.name,K),1),xr=wr[0]),Se[Yt.node.name]==null){var Sn=fa(Yt.node,Se,K,Qt._resourceManager);xr||(Ar=se(W(Yt.node.name,K),1),xr=Ar[0]);var pn=K.currentContext;i.util.isPromise(Sn)?Wt.push(Sn.then(function(zn){return Se[xr]=zn,K.currentContext=pn,zt.checkTensorForDisposal(xr,Yt.node,Se,K,Je,Be,vt),zt.processChildNodes(Yt.node,k,K,Se,we,ft),zn})):(Se[xr]=Sn,Qt.checkTensorForDisposal(xr,Yt.node,Se,K,Je,Be,vt),Qt.processChildNodes(Yt.node,k,K,Se,we,ft))}else Qt.processChildNodes(Yt.node,k,K,Se,we,ft)},Qt=this;k.length>0;)Gt();return Wt},S.prototype.processChildNodes=function(x,k,K,Se,we,Je){x.children.forEach(function(Be){var vt=se(W(Be.name,K),1),ft=vt[0];if(we[ft]||!Je.has(Be.name))return;Be.op==="Merge"?Be.inputNames.some(function(zt){return!!ge(zt,Se,K)})&&(we[ft]=!0,k.push({contexts:K.currentContext,node:Be})):Be.inputNames.every(function(zt){return!!ge(zt,Se,K)})&&(we[ft]=!0,k.push({contexts:K.currentContext,node:Be}))})},S.prototype.dispose=function(){var x=this;Object.keys(this.weightMap).forEach(function(k){return x.weightMap[k].forEach(function(K){return K.dispose()})})},S.prototype.checkInputShapeAndType=function(x){var k=this;Object.keys(x).forEach(function(K){var Se=x[K],we=se(tt(K),1),Je=we[0],Be=k.graph.nodes[Je];if(Be.attrParams.shape&&Be.attrParams.shape.value){var vt=Be.attrParams.shape.value,ft=vt.length===Se.shape.length&&Se.shape.every(function(zt,Wt){return vt[Wt]===-1||vt[Wt]===zt});i.util.assert(ft,function(){return"The shape of dict['"+Be.name+"'] provided in "+("model.execute(dict) must be ["+vt+"], but was ")+("["+Se.shape+"]")})}Be.attrParams.dtype&&Be.attrParams.dtype.value&&i.util.assert(Se.dtype===Be.attrParams.dtype.value,function(){return"The dtype of dict['"+Be.name+"'] provided in model.execute(dict) must be "+(Be.attrParams.dtype.value+", but was "+Se.dtype)})})},S.prototype.mapInputs=function(x){var k={};for(var K in x)if(this._signature!=null&&this._signature.inputs!=null&&this._signature.inputs[K]!=null){var Se=this._signature.inputs[K];k[Se.name]=x[K]}else k[K]=x[K];return k},S.prototype.checkInputs=function(x){var k=this,K=Object.keys(x).filter(function(Se){var we=se(tt(Se),1),Je=we[0];return k.graph.nodes[Je]==null});if(K.length>0)throw new Error("The dict provided in model.execute(dict) has "+("keys: ["+K+"] that are not part of graph"))},S.prototype.mapOutputs=function(x){var k=this;return x.map(function(K){if(k._signature!=null&&k._signature.outputs!=null&&k._signature.outputs[K]!=null){var Se=k._signature.outputs[K];return Se.name}return K},{})},S.prototype.checkOutputs=function(x){var k=this;x.forEach(function(K){var Se=se(tt(K),1),we=Se[0];if(!k.graph.nodes[we])throw new Error("The output '"+K+"' is not found in the graph")})},S}(),Rn=function(){function S(x,k){x===void 0&&(x={}),k===void 0&&(k={}),this.hashTableNameToHandle=x,this.hashTableMap=k}return S.prototype.addHashTable=function(x,k){this.hashTableNameToHandle[x]=k.handle,this.hashTableMap[k.id]=k},S.prototype.getHashTableHandleByName=function(x){return this.hashTableNameToHandle[x]},S.prototype.getHashTableById=function(x){return this.hashTableMap[x]},S.prototype.dispose=function(){for(var x in this.hashTableMap)this.hashTableMap[x].clearAndClose(),delete this.hashTableMap[x];for(var k in this.hashTableNameToHandle)this.hashTableNameToHandle[k].dispose(),delete this.hashTableNameToHandle[k]},S}(),Kn="?tfjs-format=file",aa="model.json",ma=function(){function S(x,k){k===void 0&&(k={}),this.modelUrl=x,this.loadOptions=k,this.version="n/a",k==null&&(this.loadOptions={}),this.resourceManager=new Rn}return Object.defineProperty(S.prototype,"modelVersion",{get:function(){return this.version},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"inputNodes",{get:function(){return this.executor.inputNodes},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"outputNodes",{get:function(){return this.executor.outputNodes},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"inputs",{get:function(){return this.executor.inputs},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"outputs",{get:function(){return this.executor.outputs},enumerable:!0,configurable:!0}),Object.defineProperty(S.prototype,"weights",{get:function(){return this.executor.weightMap},enumerable:!0,configurable:!0}),S.prototype.findIOHandler=function(){var x=this.modelUrl;if(x.load!=null)this.handler=x;else if(this.loadOptions.requestInit!=null)this.handler=i.io.browserHTTPRequest(x,this.loadOptions);else{var k=i.io.getLoadHandlers(x,this.loadOptions);if(k.length===0)k.push(i.io.browserHTTPRequest(x,this.loadOptions));else if(k.length>1)throw new Error("Found more than one ("+k.length+") load handlers for "+("URL '"+[x]+"'"));this.handler=k[0]}},S.prototype.load=function(){return O(this,void 0,void 0,function(){var x;return H(this,function(k){switch(k.label){case 0:if(this.findIOHandler(),this.handler.load==null)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");return[4,this.handler.load()];case 1:return x=k.sent(),[2,this.loadSync(x)]}})})},S.prototype.loadSync=function(x){this.artifacts=x;var k=this.artifacts.modelTopology,K={};this.artifacts.userDefinedMetadata!=null&&(K=this.artifacts.userDefinedMetadata.signature),this.version=k.versions.producer+"."+k.versions.minConsumer;var Se=i.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new tn(ga.Instance.transformGraph(k,K)),this.executor.weightMap=this.convertTensorMapToTensorsMap(Se),this.executor.resourceManager=this.resourceManager,x.modelInitializer!=null){var we=ga.Instance.transformGraph(x.modelInitializer);this.initializer=new tn(we),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0},S.prototype.save=function(x,k){return O(this,void 0,void 0,function(){var K;return H(this,function(Se){if(typeof x=="string"){if(K=i.io.getSaveHandlers(x),K.length===0)throw new Error("Cannot find any save handlers for URL '"+x+"'");if(K.length>1)throw new Error("Found more than one ("+K.length+") save handlers for "+("URL '"+x+"'"));x=K[0]}if(x.save==null)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return[2,x.save(this.artifacts)]})})},S.prototype.predict=function(x,k){return this.execute(x,this.outputNodes)},S.prototype.normalizeInputs=function(x){if(!(x instanceof i.Tensor)&&!Array.isArray(x))return x;if(x=Array.isArray(x)?x:[x],x.length!==this.inputNodes.length)throw new Error("Input tensor count mismatch,"+("the graph model has "+this.inputNodes.length+" placeholders, ")+("while there are "+x.length+" input tensors."));return this.inputNodes.reduce(function(k,K,Se){return k[K]=x[Se],k},{})},S.prototype.normalizeOutputs=function(x){return x=x||this.outputNodes,Array.isArray(x)?x:[x]},S.prototype.execute=function(x,k){x=this.normalizeInputs(x),k=this.normalizeOutputs(k);var K=this.executor.execute(x,k);return K.length>1?K:K[0]},S.prototype.executeAsync=function(x,k){return O(this,void 0,void 0,function(){var K;return H(this,function(Se){switch(Se.label){case 0:return x=this.normalizeInputs(x),k=this.normalizeOutputs(k),[4,this.executor.executeAsync(x,k)];case 1:return K=Se.sent(),[2,K.length>1?K:K[0]]}})})},S.prototype.convertTensorMapToTensorsMap=function(x){return Object.keys(x).reduce(function(k,K){return k[K]=[x[K]],k},{})},S.prototype.dispose=function(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()},S}();function Li(S,x){return x===void 0&&(x={}),O(this,void 0,void 0,function(){var k;return H(this,function(K){switch(K.label){case 0:if(S==null)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");return x==null&&(x={}),x.fromTFHub&&S.load==null&&(S.endsWith("/")||(S=S+"/"),S=""+S+aa+Kn),k=new ma(S,x),[4,k.load()];case 1:return K.sent(),[2,k]}})})}var Ea="2.7.0";N.GraphModel=ma,N.deregisterOp=ae,N.loadGraphModel=Li,N.registerOp=he,N.version_converter=Ea}),ug=Mr(()=>{}),cg=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=function(pe,X){return ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,re){j.__proto__=re}||function(j,re){for(var te in re)re.hasOwnProperty(te)&&(j[te]=re[te])},ke(pe,X)};function O(pe,X){ke(pe,X);function j(){this.constructor=pe}pe.prototype=X===null?Object.create(X):(j.prototype=X.prototype,new j)}function H(pe,X,j,re){return new(j||(j=Promise))(function(te,Ue){function kt(Ye){try{Le(re.next(Ye))}catch(Ft){Ue(Ft)}}function $e(Ye){try{Le(re.throw(Ye))}catch(Ft){Ue(Ft)}}function Le(Ye){Ye.done?te(Ye.value):new j(function(Ft){Ft(Ye.value)}).then(kt,$e)}Le((re=re.apply(pe,X||[])).next())})}function se(pe,X){var j={label:0,sent:function(){if(Ue[0]&1)throw Ue[1];return Ue[1]},trys:[],ops:[]},re,te,Ue,kt;return kt={next:$e(0),throw:$e(1),return:$e(2)},typeof Symbol=="function"&&(kt[Symbol.iterator]=function(){return this}),kt;function $e(Ye){return function(Ft){return Le([Ye,Ft])}}function Le(Ye){if(re)throw new TypeError("Generator is already executing.");for(;j;)try{if(re=1,te&&(Ue=Ye[0]&2?te.return:Ye[0]?te.throw||((Ue=te.return)&&Ue.call(te),0):te.next)&&!(Ue=Ue.call(te,Ye[1])).done)return Ue;(te=0,Ue)&&(Ye=[Ye[0]&2,Ue.value]);switch(Ye[0]){case 0:case 1:Ue=Ye;break;case 4:return j.label++,{value:Ye[1],done:!1};case 5:j.label++,te=Ye[1],Ye=[0];continue;case 7:Ye=j.ops.pop(),j.trys.pop();continue;default:if(!(Ue=j.trys,Ue=Ue.length>0&&Ue[Ue.length-1])&&(Ye[0]===6||Ye[0]===2)){j=0;continue}if(Ye[0]===3&&(!Ue||Ye[1]>Ue[0]&&Ye[1]>>0,Mt-=Le,Mt*=Le,Le=Mt>>>0,Mt-=Le,Le+=Mt*4294967296}return(Le>>>0)*23283064365386963e-26};return Ye}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.alea=kt})(xe,pe,!1)}),P=Q(function(pe){(function(X,j,re){function te($e){var Le=this,Ye="";Le.x=0,Le.y=0,Le.z=0,Le.w=0,Le.next=function(){var St=Le.x^Le.x<<11;return Le.x=Le.y,Le.y=Le.z,Le.z=Le.w,Le.w^=Le.w>>>19^St^St>>>8},$e===($e|0)?Le.x=$e:Ye+=$e;for(var Ft=0;Ft>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(typeof Ft=="object"&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.xor128=kt})(xe,pe,!1)}),he=Q(function(pe){(function(X,j,re){function te($e){var Le=this,Ye="";Le.next=function(){var St=Le.x^Le.x>>>2;return Le.x=Le.y,Le.y=Le.z,Le.z=Le.w,Le.w=Le.v,(Le.d=Le.d+362437|0)+(Le.v=Le.v^Le.v<<4^(St^St<<1))|0},Le.x=0,Le.y=0,Le.z=0,Le.w=0,Le.v=0,$e===($e|0)?Le.x=$e:Ye+=$e;for(var Ft=0;Ft>>4),Le.next()}function Ue($e,Le){return Le.x=$e.x,Le.y=$e.y,Le.z=$e.z,Le.w=$e.w,Le.v=$e.v,Le.d=$e.d,Le}function kt($e,Le){var Ye=new te($e),Ft=Le&&Le.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(typeof Ft=="object"&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.xorwow=kt})(xe,pe,!1)}),me=Q(function(pe){(function(X,j,re){function te($e){var Le=this;Le.next=function(){var Ft=Le.x,St=Le.i,Mt,dr;return Mt=Ft[St],Mt^=Mt>>>7,dr=Mt^Mt<<24,Mt=Ft[St+1&7],dr^=Mt^Mt>>>10,Mt=Ft[St+3&7],dr^=Mt^Mt>>>3,Mt=Ft[St+4&7],dr^=Mt^Mt<<7,Mt=Ft[St+7&7],Mt=Mt^Mt<<13,dr^=Mt^Mt<<9,Ft[St]=dr,Le.i=St+1&7,dr};function Ye(Ft,St){var Mt,dr,ir=[];if(St===(St|0))dr=ir[0]=St;else for(St=""+St,Mt=0;Mt0;--Mt)Ft.next()}Ye(Le,$e)}function Ue($e,Le){return Le.x=$e.x.slice(),Le.i=$e.i,Le}function kt($e,Le){$e==null&&($e=+new Date);var Ye=new te($e),Ft=Le&&Le.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(Ft.x&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.xorshift7=kt})(xe,pe,!1)}),ae=Q(function(pe){(function(X,j,re){function te($e){var Le=this;Le.next=function(){var Ft=Le.w,St=Le.X,Mt=Le.i,dr,ir;return Le.w=Ft=Ft+1640531527|0,ir=St[Mt+34&127],dr=St[Mt=Mt+1&127],ir^=ir<<13,dr^=dr<<17,ir^=ir>>>15,dr^=dr>>>12,ir=St[Mt]=ir^dr,Le.i=Mt,ir+(Ft^Ft>>>16)|0};function Ye(Ft,St){var Mt,dr,ir,ta,fa,ra=[],Ha=128;for(St===(St|0)?(dr=St,St=null):(St=St+"\0",dr=0,Ha=Math.max(Ha,St.length)),ir=0,ta=-32;ta>>15,dr^=dr<<4,dr^=dr>>>13,ta>=0&&(fa=fa+1640531527|0,Mt=ra[ta&127]^=dr+fa,ir=Mt==0?ir+1:0);for(ir>=128&&(ra[(St&&St.length||0)&127]=-1),ir=127,ta=4*128;ta>0;--ta)dr=ra[ir+34&127],Mt=ra[ir=ir+1&127],dr^=dr<<13,Mt^=Mt<<17,dr^=dr>>>15,Mt^=Mt>>>12,ra[ir]=dr^Mt;Ft.w=fa,Ft.X=ra,Ft.i=ir}Ye(Le,$e)}function Ue($e,Le){return Le.i=$e.i,Le.w=$e.w,Le.X=$e.X.slice(),Le}function kt($e,Le){$e==null&&($e=+new Date);var Ye=new te($e),Ft=Le&&Le.state,St=function(){return(Ye.next()>>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(Ft.X&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.xor4096=kt})(xe,pe,!1)}),w=Q(function(pe){(function(X,j,re){function te($e){var Le=this,Ye="";Le.next=function(){var St=Le.b,Mt=Le.c,dr=Le.d,ir=Le.a;return St=St<<25^St>>>7^Mt,Mt=Mt-dr|0,dr=dr<<24^dr>>>8^ir,ir=ir-St|0,Le.b=St=St<<20^St>>>12^Mt,Le.c=Mt=Mt-dr|0,Le.d=dr<<16^Mt>>>16^ir,Le.a=ir-St|0},Le.a=0,Le.b=0,Le.c=2654435769|0,Le.d=1367130551,$e===Math.floor($e)?(Le.a=$e/4294967296|0,Le.b=$e|0):Ye+=$e;for(var Ft=0;Ft>>0)/4294967296};return St.double=function(){do var Mt=Ye.next()>>>11,dr=(Ye.next()>>>0)/4294967296,ir=(Mt+dr)/(1<<21);while(ir===0);return ir},St.int32=Ye.next,St.quick=St,Ft&&(typeof Ft=="object"&&Ue(Ft,Ye),St.state=function(){return Ue(Ye,{})}),St}j&&j.exports?j.exports=kt:re&&re.amd?re(function(){return kt}):this.tychei=kt})(xe,pe,!1)}),ge=Q(function(pe){(function(X,j){var re=this,te=256,Ue=6,kt=52,$e="random",Le=j.pow(te,Ue),Ye=j.pow(2,kt),Ft=Ye*2,St=te-1,Mt;function dr(sn,hn,na){var Jr=[];hn=hn==!0?{entropy:!0}:hn||{};var Vr=ra(fa(hn.entropy?[sn,ki(X)]:sn??Ha(),3),Jr),Jn=new ir(Jr),tn=function(){for(var Rn=Jn.g(Ue),Kn=Le,aa=0;Rn=Ft;)Rn/=2,Kn/=2,aa>>>=1;return(Rn+aa)/Kn};return tn.int32=function(){return Jn.g(4)|0},tn.quick=function(){return Jn.g(4)/4294967296},tn.double=tn,ra(ki(Jn.S),X),(hn.pass||na||function(Rn,Kn,aa,ma){return ma&&(ma.S&&ta(ma,Jn),Rn.state=function(){return ta(Jn,{})}),aa?(j[$e]=Rn,Kn):Rn})(tn,Vr,"global"in hn?hn.global:this==j,hn.state)}j["seed"+$e]=dr;function ir(sn){var hn,na=sn.length,Jr=this,Vr=0,Jn=Jr.i=Jr.j=0,tn=Jr.S=[];for(na||(sn=[na++]);Vr=this.items.length?[2,{value:null,done:!0}]:(j=this.items[this.trav],this.trav++,[2,{value:ut(j),done:!1}])})})},X}(tr),Oa=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;return re.nextFn=j,re}return X.prototype.summary=function(){return"Function call"},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){try{return[2,this.nextFn()]}catch(re){throw re.message="Error thrown while iterating through a dataset: "+re.message,re}return[2]})})},X}(tr),Tn=function(pe){O(X,pe);function X(j){var re=pe.call(this)||this;return re.upstream=j,re.lastRead=Promise.resolve({value:null,done:!1}),re}return X.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,this.upstream.next()]})})},X}(tr),Wa=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.maxCount=re,te.count=0,te.lastRead=Promise.resolve({value:null,done:!1}),te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){switch(re.label){case 0:return this.count++ Take"},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},X}(tr),yn=function(pe){O(X,pe);function X(j,re,te){te===void 0&&(te=!0);var Ue=pe.call(this)||this;return Ue.upstream=j,Ue.batchSize=re,Ue.enableSmallLastBatch=te,Ue.lastRead=Promise.resolve({value:null,done:!1}),Ue}return X.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j,re;return se(this,function(te){switch(te.label){case 0:j=[],te.label=1;case 1:return j.length0?[2,{value:j,done:!1}]:[2,{value:null,done:!0}]:(j.push(re.value),[3,1]);case 3:return[2,{value:j,done:!1}]}})})},X}(tr),Ma=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.predicate=re,te.lastRead=Promise.resolve({value:null,done:!1}),te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){switch(re.label){case 0:return[4,this.upstream.next()];case 1:return j=re.sent(),j.done||this.predicate(j.value)?[2,j]:(i.dispose(j.value),[3,0]);case 2:return[2]}})})},X}(tr),li=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.transform=re,te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Map"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt,$e,Le;return se(this,function(Ye){switch(Ye.label){case 0:return[4,this.upstream.next()];case 1:if(j=Ye.sent(),j.done)return[2,{value:null,done:!0}];for(re=i.tensor_util.getTensorsInContainer(j.value),te=this.transform(j.value),Ue=i.tensor_util.getTensorsInContainer(te),kt=0,$e=re;kt<$e.length;kt++)Le=$e[kt],i.tensor_util.isTensorInList(Le,Ue)||Le.dispose();return[2,{value:te,done:!1}]}})})},X}(tr),hi=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.handler=re,te.count=0,te.lastRead=Promise.resolve({value:null,done:!1}),te}return X.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){switch(re.label){case 0:re.label=1;case 1:return re.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,re.sent()];case 3:return j=re.sent(),this.handler(j)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},X}(tr),la=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.transform=re,te}return X.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt,$e,Le;return se(this,function(Ye){switch(Ye.label){case 0:return[4,this.upstream.next()];case 1:return j=Ye.sent(),j.done?[2,{value:null,done:!0}]:(re=i.tensor_util.getTensorsInContainer(j.value),[4,this.transform(j.value)]);case 2:for(te=Ye.sent(),Ue=i.tensor_util.getTensorsInContainer(te),kt=0,$e=re;kt<$e.length;kt++)Le=$e[kt],i.tensor_util.isTensorInList(Le,Ue)||Le.dispose();return[2,{value:te,done:!1}]}})})},X}(tr),rn=function(pe){O(X,pe);function X(){var j=pe.call(this)||this;return j.outputQueue=new ar,j.lastRead=Promise.resolve({value:null,done:!1}),j}return X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return this.outputQueue.length()===0?[4,this.pump()]:[3,2];case 1:return j.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}})})},X}(tr),Ca=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.transform=re,te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap"},X.prototype.pump=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt,$e,Le;return se(this,function(Ye){switch(Ye.label){case 0:return[4,this.upstream.next()];case 1:if(j=Ye.sent(),j.done)return[2,!1];for(re=i.tensor_util.getTensorsInContainer(j.value),te=this.transform(j.value),Ue=i.tensor_util.getTensorsInContainer(te),this.outputQueue.pushAll(te),kt=0,$e=re;kt<$e.length;kt++)Le=$e[kt],i.tensor_util.isTensorInList(Le,Ue)||Le.dispose();return[2,!0]}})})},X}(rn),xn=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.baseErrorHandler=re,te.lastRead=null,te.iterator=null,te.moreIterators=j,te}return X.prototype.summary=function(){var j="TODO: fill in upstream of chained summaries";return j+" -> Chained"},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},X.prototype.readFromChain=function(j){return H(this,void 0,void 0,function(){var re,te;return se(this,function(Ue){switch(Ue.label){case 0:return[4,j];case 1:return Ue.sent(),this.iterator==null?[4,this.moreIterators.next()]:[3,3];case 2:if(re=Ue.sent(),re.done)return[2,{value:null,done:!0}];this.iterator=re.value,this.baseErrorHandler!=null&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),Ue.label=3;case 3:return[4,this.iterator.next()];case 4:return te=Ue.sent(),te.done?(this.iterator=null,[2,this.readFromChain(j)]):[2,te]}})})},X}(tr),Hn;(function(pe){pe[pe.FAIL=0]="FAIL",pe[pe.SHORTEST=1]="SHORTEST",pe[pe.LONGEST=2]="LONGEST"})(Hn||(Hn={}));var _i=function(pe){O(X,pe);function X(j,re){re===void 0&&(re=Hn.FAIL);var te=pe.call(this)||this;return te.iterators=j,te.mismatchMode=re,te.count=0,te.currentPromise=null,te}return X.prototype.summary=function(){var j="TODO: fill in upstream of zip summaries";return"{"+j+"} -> Zip"},X.prototype.nextState=function(j){return H(this,void 0,void 0,function(){function re($e){if($e instanceof tr){var Le=$e.next();return{value:Le.then(function(Ye){return te++,Ye.done&&Ue++,Ye.value}),recurse:!1}}else return{value:null,recurse:!0}}var te,Ue,kt;return se(this,function($e){switch($e.label){case 0:return[4,j];case 1:return $e.sent(),te=0,Ue=0,[4,it(this.iterators,re)];case 2:if(kt=$e.sent(),te===Ue)return[2,{value:null,done:!0}];if(Ue>0)switch(this.mismatchMode){case Hn.FAIL:throw new Error("Zipped streams should have the same length. "+("Mismatched at element "+this.count+"."));case Hn.SHORTEST:return[2,{value:null,done:!0}];case Hn.LONGEST:}return this.count++,[2,{value:kt,done:!1}]}})})},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]})})},X}(tr),ha=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.bufferSize=re,te.buffer=new Zt(re),te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},X.prototype.refill=function(){for(;!this.buffer.isFull();){var j=this.upstream.next();this.buffer.push(j)}},X.prototype.next=function(){return this.refill(),this.buffer.shift()},X}(tr),Ei=function(pe){O(X,pe);function X(j,re,te){var Ue=pe.call(this,j,re)||this;return Ue.upstream=j,Ue.windowSize=re,Ue.upstreamExhausted=!1,Ue.random=W(te||i.util.now().toString()),Ue.lastRead=Promise.resolve({value:null,done:!1}),Ue}return X.prototype.next=function(){return H(this,void 0,void 0,function(){var j=this;return se(this,function(re){return this.lastRead=this.lastRead.then(function(){return j.serialNext()}),[2,this.lastRead]})})},X.prototype.randomInt=function(j){return Math.floor(this.random()*j)},X.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},X.prototype.serialNext=function(){return H(this,void 0,void 0,function(){var j,re;return se(this,function(te){switch(te.label){case 0:this.upstreamExhausted||this.refill(),te.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(j=this.chooseIndex(),[4,this.buffer.shuffleExcise(j)]);case 2:if(re=te.sent(),re.done)this.upstreamExhausted=!0;else return this.refill(),[2,re];return[3,1];case 3:return[2,{value:null,done:!0}]}})})},X}(ha),Gn=function(){function pe(){this.size=null}return pe.prototype.batch=function(X,j){var re=this;j===void 0&&(j=!0);var te=this;i.util.assert(X>0,function(){return`batchSize needs to be positive, but it is `+X});var Ue;return this.size===Infinity||this.size==null?Ue=this.size:j?Ue=Math.ceil(this.size/X):Ue=Math.floor(this.size/X),jn(function(){return H(re,void 0,void 0,function(){return se(this,function(kt){switch(kt.label){case 0:return[4,te.iterator()];case 1:return[2,kt.sent().columnMajorBatch(X,j,wi)]}})})},Ue)},pe.prototype.concatenate=function(X){var j=this,re=this,te;return this.size===Infinity||X.size===Infinity?te=Infinity:this.size!=null&&X.size!=null?te=this.size+X.size:te=null,jn(function(){return H(j,void 0,void 0,function(){var Ue,kt;return se(this,function($e){switch($e.label){case 0:return[4,re.iterator()];case 1:return kt=(Ue=$e.sent()).concatenate,[4,X.iterator()];case 2:return[2,kt.apply(Ue,[$e.sent()])]}})})},te)},pe.prototype.filter=function(X){var j=this,re=this,te;return this.size===Infinity?te=Infinity:te=null,jn(function(){return H(j,void 0,void 0,function(){return se(this,function(Ue){switch(Ue.label){case 0:return[4,re.iterator()];case 1:return[2,Ue.sent().filter(function(kt){return i.tidy(function(){return X(kt)})})]}})})},te)},pe.prototype.forEachAsync=function(X){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return[4,this.iterator()];case 1:return[2,j.sent().forEachAsync(X)]}})})},pe.prototype.map=function(X){var j=this,re=this;return jn(function(){return H(j,void 0,void 0,function(){return se(this,function(te){switch(te.label){case 0:return[4,re.iterator()];case 1:return[2,te.sent().map(function(Ue){return i.tidy(function(){return X(Ue)})})]}})})},this.size)},pe.prototype.mapAsync=function(X){var j=this,re=this;return jn(function(){return H(j,void 0,void 0,function(){return se(this,function(te){switch(te.label){case 0:return[4,re.iterator()];case 1:return[2,te.sent().mapAsync(X)]}})})},this.size)},pe.prototype.prefetch=function(X){var j=this;if(X==null)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var re=this;return jn(function(){return H(j,void 0,void 0,function(){return se(this,function(te){switch(te.label){case 0:return[4,re.iterator()];case 1:return[2,te.sent().prefetch(X)]}})})},this.size)},pe.prototype.repeat=function(X){var j=this,re=this,te;return this.size!=null&&X>0?te=this.size*X:X===0?te=0:this.size!=null&&(X===void 0||X<0)?te=Infinity:te=null,jn(function(){return H(j,void 0,void 0,function(){var Ue,kt=this;return se(this,function($e){return Ue=Ur(function(){return H(kt,void 0,void 0,function(){var Le;return se(this,function(Ye){switch(Ye.label){case 0:return Le={},[4,re.iterator()];case 1:return[2,(Le.value=Ye.sent(),Le.done=!1,Le)]}})})}),[2,jr(Ue.take(X))]})})},te)},pe.prototype.skip=function(X){var j=this,re=this,te;return this.size!=null&&X>=0&&this.size>=X?te=this.size-X:this.size!=null&&(this.sizeX?te=X:this.size!=null&&this.size<=X?te=this.size:te=null,jn(function(){return H(j,void 0,void 0,function(){return se(this,function(Ue){switch(Ue.label){case 0:return[4,re.iterator()];case 1:return[2,Ue.sent().take(X)]}})})},te)},pe.prototype.toArray=function(){return H(this,void 0,void 0,function(){return se(this,function(X){switch(X.label){case 0:if(this.size===Infinity)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,X.sent().toArray()]}})})},pe.prototype.toArrayForTest=function(){return H(this,void 0,void 0,function(){return se(this,function(X){switch(X.label){case 0:if(this.size===Infinity)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,X.sent().toArrayForTest()]}})})},pe.MAX_BUFFER_SIZE=1e4,pe}();function jn(pe,X){return X===void 0&&(X=null),new(function(j){O(re,j);function re(){var te=j!==null&&j.apply(this,arguments)||this;return te.size=X,te}return re.prototype.iterator=function(){return H(this,void 0,void 0,function(){return se(this,function(te){return[2,pe()]})})},re}(Gn))}function Ua(pe){var X=this;return jn(function(){return H(X,void 0,void 0,function(){return se(this,function(j){return[2,qt(pe)]})})},pe.length)}function ga(pe){var X=this;if(!xt(pe))throw new Error("The argument to zip() must be an object or array.");var j;if(Array.isArray(pe))for(var re=0;re1}),i.util.assert(te.length===0,function(){return"Duplicate column names found: "+te.toString()}),this.columnConfigs){for(Ue=0,kt=Object.keys(this.columnConfigs);Ue14||!Number.isInteger(te))throw new Error("Invalid fftSize: it must be a power of 2 between "+("2 to 4 and 2 to 14, but got "+re.fftSize));if(re.numFrames=j.numFramesPerSpectrogram||43,re.sampleRateHz=j.sampleRateHz,re.columnTruncateLength=j.columnTruncateLength||re.fftSize,re.audioTrackConstraints=j.audioTrackConstraints,re.smoothingTimeConstant=j.smoothingTimeConstant||0,re.includeSpectrogram=!(j.includeSpectrogram===!1),re.includeWaveform=j.includeWaveform===!0,!re.includeSpectrogram&&!re.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return re}return X.prototype.summary=function(){return"microphone"},X.create=function(j){return j===void 0&&(j={}),H(this,void 0,void 0,function(){var re;return se(this,function(te){switch(te.label){case 0:if(i.env().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return re=new X(j),[4,re.start()];case 1:return te.sent(),[2,re]}})})},X.prototype.start=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue;return se(this,function(kt){switch(kt.label){case 0:return kt.trys.push([0,2,,3]),j=this,[4,navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints==null?!0:this.audioTrackConstraints,video:!1})];case 1:return j.stream=kt.sent(),[3,3];case 2:throw re=kt.sent(),new Error("Error thrown while initializing video stream: "+re.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(te=window.AudioContext||window.webkitAudioContext,this.audioContext=new te,!this.sampleRateHz)this.sampleRateHz=this.audioContext.sampleRate;else if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error("Mismatch in sampling rate: "+("Expected: "+this.sampleRateHz+"; ")+("Actual: "+this.audioContext.sampleRate));return Ue=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=this.fftSize*2,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,Ue.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt;return se(this,function($e){switch($e.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return te=$e.sent(),this.includeSpectrogram&&(Ue=this.flattenQueue(te.freqDataQueue),j=this.getTensorFromAudioDataArray(Ue,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(kt=this.flattenQueue(te.timeDataQueue),re=this.getTensorFromAudioDataArray(kt,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:j,waveform:re},done:!1}]}})})},X.prototype.capture=function(){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return[4,this.next()];case 1:return[2,j.sent().value]}})})},X.prototype.getAudioData=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue=this;return se(this,function(kt){return j=[],re=[],te=0,[2,new Promise(function($e){var Le=setInterval(function(){Ue.includeSpectrogram&&(Ue.analyser.getFloatFrequencyData(Ue.freqData),Ue.freqData[0]===-Infinity&&$e({freqDataQueue:j,timeDataQueue:re}),j.push(Ue.freqData.slice(0,Ue.columnTruncateLength))),Ue.includeWaveform&&(Ue.analyser.getFloatTimeDomainData(Ue.timeData),re.push(Ue.timeData.slice())),++te===Ue.numFrames&&(clearInterval(Le),$e({freqDataQueue:j,timeDataQueue:re}))},Ue.fftSize/Ue.sampleRateHz*1e3)})]})})},X.prototype.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),this.stream!=null&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())},X.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},X.prototype.getSampleRate=function(){return this.sampleRateHz},X.prototype.flattenQueue=function(j){var re=j[0].length,te=new Float32Array(j.length*re);return j.forEach(function(Ue,kt){return te.set(Ue,kt*re)}),te},X.prototype.getTensorFromAudioDataArray=function(j,re){var te=new Float32Array(i.util.sizeFromShape(re));return te.set(j,te.length-j.length),i.tensor(te,re)},X}(tr),qn=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;if(te.webcamVideoElement=j,te.webcamConfig=re,te.isClosed=!0,te.resize=!1,te.needToResize())if(te.resize=!0,te.cropSize=[te.webcamConfig.resizeHeight,te.webcamConfig.resizeWidth],te.cropBoxInd=i.tensor1d([0],"int32"),te.webcamConfig.centerCrop){var Ue=te.webcamConfig.resizeWidth*1/te.webcamVideoElement.width,kt=te.webcamConfig.resizeHeight*1/te.webcamVideoElement.height,$e=(1-Ue)/2,Le=(1-kt)/2,Ye=$e+Ue,Ft=kt+Le;te.cropBox=i.tensor2d([Le,$e,Ft,Ye],[1,4])}else te.cropBox=i.tensor2d([0,0,1,1],[1,4]);return te}return X.prototype.summary=function(){return"webcam"},X.create=function(j,re){return re===void 0&&(re={}),H(this,void 0,void 0,function(){var te;return se(this,function(Ue){switch(Ue.label){case 0:if(i.env().get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!j){if(j=document.createElement("video"),!re.resizeWidth||!re.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");j.width=re.resizeWidth,j.height=re.resizeHeight}return te=new X(j,re),[4,te.start()];case 1:return Ue.sent(),[2,te]}})})},X.prototype.start=function(){return H(this,void 0,void 0,function(){var j,re,te=this;return se(this,function(Ue){switch(Ue.label){case 0:this.webcamConfig.facingMode&&i.util.assert(this.webcamConfig.facingMode==="user"||this.webcamConfig.facingMode==="environment",function(){return"Invalid webcam facing mode: "+te.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),Ue.label=1;case 1:return Ue.trys.push([1,3,,4]),j=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return j.stream=Ue.sent(),[3,4];case 3:throw re=Ue.sent(),re.message="Error thrown while initializing video stream: "+re.message,re;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(kt){console.log(kt),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(kt){te.webcamVideoElement.onloadedmetadata=function(){kt()}})]}})})},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){if(this.isClosed)return[2,{value:null,done:!0}];try{j=i.browser.fromPixels(this.webcamVideoElement)}catch(te){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(te))}if(this.resize)try{return[2,{value:this.cropAndResizeFrame(j),done:!1}]}catch(te){throw new Error("Error thrown cropping the video: "+te.message)}finally{j.dispose()}else return[2,{value:j,done:!1}];return[2]})})},X.prototype.needToResize=function(){return!!(this.webcamConfig.resizeWidth&&this.webcamConfig.resizeHeight&&(this.webcamVideoElement.width!==this.webcamConfig.resizeWidth||this.webcamVideoElement.height!==this.webcamConfig.resizeHeight))},X.prototype.cropAndResizeFrame=function(j){var re=this;return i.tidy(function(){var te=j.toFloat().expandDims(0),Ue;Ue=i.image.cropAndResize(te,re.cropBox,re.cropBoxInd,re.cropSize,"bilinear");var kt=Ue.shape;return Ue.reshape(kt.slice(1))})},X.prototype.capture=function(){return H(this,void 0,void 0,function(){return se(this,function(j){switch(j.label){case 0:return[4,this.next()];case 1:return[2,j.sent().value]}})})},X.prototype.stop=function(){var j=this.stream.getTracks();j.forEach(function(re){return re.stop()});try{this.webcamVideoElement.srcObject=null}catch(re){console.log(re),this.webcamVideoElement.src=null}this.isClosed=!0},X.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},X}(tr),ri=function(){function pe(){}return pe}(),pi=function(pe){O(X,pe);function X(){return pe!==null&&pe.apply(this,arguments)||this}return X.prototype.split=function(j){return new pa(this,j)},X}(tr),pa=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.impl=new di(j,re),te}return X.prototype.summary=function(){return this.impl.summary()},X.prototype.next=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,this.impl.next()]})})},X}(pi),di=function(pe){O(X,pe);function X(j,re){var te=pe.call(this)||this;return te.upstream=j,te.separator=re,te.carryover="",te}return X.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},X.prototype.pump=function(){return H(this,void 0,void 0,function(){var j,re,te,Ue,kt;return se(this,function($e){switch($e.label){case 0:return[4,this.upstream.next()];case 1:if(j=$e.sent(),j.done)return this.carryover===""?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for(re=j.value.split(this.separator),re[0]=this.carryover+re[0],te=0,Ue=re.slice(0,-1);te Utf8"},X.prototype.pump=function(){return H(this,void 0,void 0,function(){var j,re,te;return se(this,function(Ue){switch(Ue.label){case 0:return[4,this.upstream.next()];case 1:return j=Ue.sent(),j.done?[2,!1]:(re=j.value,i.env().get("IS_BROWSER")?te=this.decoder.decode(re,{stream:!0}):te=this.decoder.write(Buffer.from(re.buffer)),this.outputQueue.push(te),[2,!0])}})})},X}(rn),ni=function(pe){O(X,pe);function X(j,re){re===void 0&&(re={});var te=pe.call(this)||this;return te.file=j,te.options=re,i.util.assert(j instanceof Uint8Array||(i.env().get("IS_BROWSER")?j instanceof File||j instanceof Blob:!1),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),te.offset=re.offset||0,te.chunkSize=re.chunkSize||1024*1024,te}return X.prototype.summary=function(){return"FileChunks "+this.file},X.prototype.next=function(){return H(this,void 0,void 0,function(){var j,re,te=this;return se(this,function(Ue){switch(Ue.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(j=new Promise(function(kt,$e){var Le=te.offset+te.chunkSize;if(te.file instanceof Uint8Array)kt(new Uint8Array(te.file.slice(te.offset,Le)));else{var Ye=new FileReader;Ye.onload=function(St){var Mt=Ye.result;if(Mt instanceof ArrayBuffer&&(Mt=new Uint8Array(Mt)),!(Mt instanceof Uint8Array))return $e(new TypeError("FileReader returned unknown type."));kt(Mt)},Ye.onabort=function(St){return $e(new Error("Aborted"))},Ye.onerror=function(St){return $e(new Error(St.type))};var Ft=te.file.slice(te.offset,Le);Ye.readAsArrayBuffer(Ft)}te.offset=Le}),re={},[4,j]);case 1:return[2,(re.value=Ue.sent(),re.done=!1,re)]}})})},X}(fi);function gr(pe,X){return X===void 0&&(X={}),H(this,void 0,void 0,function(){var j,re,te,Ue,kt;return se(this,function($e){switch($e.label){case 0:return typeof pe=="string"?j=pe:(j=pe.url,re=Di(pe)),[4,i.util.fetch(j,re)];case 1:return te=$e.sent(),te.ok?(kt=Uint8Array.bind,[4,te.arrayBuffer()]):[3,3];case 2:return Ue=new(kt.apply(Uint8Array,[void 0,$e.sent()])),[2,new ni(Ue,X)];case 3:throw new Error(te.statusText)}})})}var Di=function(pe){var X={method:pe.method,headers:pe.headers,body:pe.body,mode:pe.mode,credentials:pe.credentials,cache:pe.cache,redirect:pe.redirect,referrer:pe.referrer,integrity:pe.integrity};return X};function bi(pe){return typeof pe=="string"&&pe.substr(0,7)==="file://"}var ro=function(pe){O(X,pe);function X(j,re){re===void 0&&(re={});var te=pe.call(this)||this;return te.input=j,te.options=re,te}return X.prototype.iterator=function(){return H(this,void 0,void 0,function(){var j;return se(this,function(re){return bi(this.input)&&i.env().get("IS_NODE")&&(j=require("fs"),this.input=j.readFileSync(this.input.substr(7))),[2,new ni(this.input,this.options)]})})},X}(ri),Zn=function(pe){O(X,pe);function X(j,re){re===void 0&&(re={});var te=pe.call(this)||this;return te.url=j,te.fileOptions=re,te}return X.prototype.iterator=function(){return H(this,void 0,void 0,function(){return se(this,function(j){return bi(this.url)?[2,new ro(this.url,this.fileOptions).iterator()]:[2,gr(this.url,this.fileOptions)]})})},X}(ri);function Gi(pe,X){return X===void 0&&(X={}),new Hi(new Zn(pe),X)}function Fi(pe){var X=this,j=Ur(pe);return jn(function(){return H(X,void 0,void 0,function(){return se(this,function(re){return[2,j]})})})}function ji(pe){var X=this;return jn(function(){return H(X,void 0,void 0,function(){var j;return se(this,function(re){switch(re.label){case 0:return[4,pe()];case 1:return j=re.sent(),[2,Ur(function(){return j.next()})]}})})})}function Oi(pe,X){return H(this,void 0,void 0,function(){return se(this,function(j){return[2,qn.create(pe,X)]})})}function da(pe){return H(this,void 0,void 0,function(){return se(this,function(X){return[2,Ai.create(pe)]})})}var Mi="2.7.0";N.CSVDataset=Hi,N.Dataset=Gn,N.FileDataSource=ro,N.TextLineDataset=on,N.URLDataSource=Zn,N.array=Ua,N.csv=Gi,N.func=Fi,N.generator=ji,N.microphone=da,N.version_data=Mi,N.webcam=Oi,N.zip=ga}),lg=Mr((N,i)=>{(function(ke,O,H){function se(P){var he=this,me=Ae();he.next=function(){var ae=2091639*he.s0+he.c*23283064365386963e-26;return he.s0=he.s1,he.s1=he.s2,he.s2=ae-(he.c=ae|0)},he.c=1,he.s0=me(" "),he.s1=me(" "),he.s2=me(" "),he.s0-=me(P),he.s0<0&&(he.s0+=1),he.s1-=me(P),he.s1<0&&(he.s1+=1),he.s2-=me(P),he.s2<0&&(he.s2+=1),me=null}function xe(P,he){return he.c=P.c,he.s0=P.s0,he.s1=P.s1,he.s2=P.s2,he}function Q(P,he){var me=new se(P),ae=he&&he.state,w=me.next;return w.int32=function(){return me.next()*4294967296|0},w.double=function(){return w()+(w()*2097152|0)*11102230246251565e-32},w.quick=w,ae&&(typeof ae=="object"&&xe(ae,me),w.state=function(){return xe(me,{})}),w}function Ae(){var P=4022871197,he=function(me){me=me.toString();for(var ae=0;ae>>0,w-=P,w*=P,P=w>>>0,w-=P,P+=w*4294967296}return(P>>>0)*23283064365386963e-26};return he}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.alea=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),hg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this,he="";P.x=0,P.y=0,P.z=0,P.w=0,P.next=function(){var ae=P.x^P.x<<11;return P.x=P.y,P.y=P.z,P.z=P.w,P.w^=P.w>>>19^ae^ae>>>8},Ae===(Ae|0)?P.x=Ae:he+=Ae;for(var me=0;me>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(typeof me=="object"&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.xor128=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),pg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this,he="";P.next=function(){var ae=P.x^P.x>>>2;return P.x=P.y,P.y=P.z,P.z=P.w,P.w=P.v,(P.d=P.d+362437|0)+(P.v=P.v^P.v<<4^(ae^ae<<1))|0},P.x=0,P.y=0,P.z=0,P.w=0,P.v=0,Ae===(Ae|0)?P.x=Ae:he+=Ae;for(var me=0;me>>4),P.next()}function xe(Ae,P){return P.x=Ae.x,P.y=Ae.y,P.z=Ae.z,P.w=Ae.w,P.v=Ae.v,P.d=Ae.d,P}function Q(Ae,P){var he=new se(Ae),me=P&&P.state,ae=function(){return(he.next()>>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(typeof me=="object"&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.xorwow=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),dg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this;P.next=function(){var me=P.x,ae=P.i,w,ge,ze;return w=me[ae],w^=w>>>7,ge=w^w<<24,w=me[ae+1&7],ge^=w^w>>>10,w=me[ae+3&7],ge^=w^w>>>3,w=me[ae+4&7],ge^=w^w<<7,w=me[ae+7&7],w=w^w<<13,ge^=w^w<<9,me[ae]=ge,P.i=ae+1&7,ge};function he(me,ae){var w,ge,ze=[];if(ae===(ae|0))ge=ze[0]=ae;else for(ae=""+ae,w=0;w0;--w)me.next()}he(P,Ae)}function xe(Ae,P){return P.x=Ae.x.slice(),P.i=Ae.i,P}function Q(Ae,P){Ae==null&&(Ae=+new Date);var he=new se(Ae),me=P&&P.state,ae=function(){return(he.next()>>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(me.x&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.xorshift7=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),fg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this;P.next=function(){var me=P.w,ae=P.X,w=P.i,ge,ze;return P.w=me=me+1640531527|0,ze=ae[w+34&127],ge=ae[w=w+1&127],ze^=ze<<13,ge^=ge<<17,ze^=ze>>>15,ge^=ge>>>12,ze=ae[w]=ze^ge,P.i=w,ze+(me^me>>>16)|0};function he(me,ae){var w,ge,ze,W,nt,tt=[],nr=128;for(ae===(ae|0)?(ge=ae,ae=null):(ae=ae+"\0",ge=0,nr=Math.max(nr,ae.length)),ze=0,W=-32;W>>15,ge^=ge<<4,ge^=ge>>>13,W>=0&&(nt=nt+1640531527|0,w=tt[W&127]^=ge+nt,ze=w==0?ze+1:0);for(ze>=128&&(tt[(ae&&ae.length||0)&127]=-1),ze=127,W=4*128;W>0;--W)ge=tt[ze+34&127],w=tt[ze=ze+1&127],ge^=ge<<13,w^=w<<17,ge^=ge>>>15,w^=w>>>12,tt[ze]=ge^w;me.w=nt,me.X=tt,me.i=ze}he(P,Ae)}function xe(Ae,P){return P.i=Ae.i,P.w=Ae.w,P.X=Ae.X.slice(),P}function Q(Ae,P){Ae==null&&(Ae=+new Date);var he=new se(Ae),me=P&&P.state,ae=function(){return(he.next()>>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(me.X&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.xor4096=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),mg=Mr((N,i)=>{(function(ke,O,H){function se(Ae){var P=this,he="";P.next=function(){var ae=P.b,w=P.c,ge=P.d,ze=P.a;return ae=ae<<25^ae>>>7^w,w=w-ge|0,ge=ge<<24^ge>>>8^ze,ze=ze-ae|0,P.b=ae=ae<<20^ae>>>12^w,P.c=w=w-ge|0,P.d=ge<<16^w>>>16^ze,P.a=ze-ae|0},P.a=0,P.b=0,P.c=2654435769|0,P.d=1367130551,Ae===Math.floor(Ae)?(P.a=Ae/4294967296|0,P.b=Ae|0):he+=Ae;for(var me=0;me>>0)/4294967296};return ae.double=function(){do var w=he.next()>>>11,ge=(he.next()>>>0)/4294967296,ze=(w+ge)/(1<<21);while(ze===0);return ze},ae.int32=he.next,ae.quick=ae,me&&(typeof me=="object"&&xe(me,he),ae.state=function(){return xe(he,{})}),ae}O&&O.exports?O.exports=Q:H&&H.amd?H(function(){return Q}):this.tychei=Q})(N,typeof i=="object"&&i,typeof define=="function"&&define)}),yg=Mr((N,i)=>{(function(ke,O){var H=this,se=256,xe=6,Q=52,Ae="random",P=O.pow(se,xe),he=O.pow(2,Q),me=he*2,ae=se-1,w;function ge(Qe,it,xt){var ot=[];it=it==!0?{entropy:!0}:it||{};var ht=tt(nt(it.entropy?[Qe,Tt(ke)]:Qe??nr(),3),ot),ut=new ze(ot),yt=function(){for(var Zt=ut.g(xe),ar=P,qt=0;Zt=me;)Zt/=2,ar/=2,qt>>>=1;return(Zt+qt)/ar};return yt.int32=function(){return ut.g(4)|0},yt.quick=function(){return ut.g(4)/4294967296},yt.double=yt,tt(Tt(ut.S),ke),(it.pass||xt||function(Zt,ar,qt,Ur){return Ur&&(Ur.S&&W(Ur,ut),Zt.state=function(){return W(ut,{})}),qt?(O[Ae]=Zt,ar):Zt})(yt,ht,"global"in it?it.global:this==O,it.state)}O["seed"+Ae]=ge;function ze(Qe){var it,xt=Qe.length,ot=this,ht=0,ut=ot.i=ot.j=0,yt=ot.S=[];for(xt||(Qe=[xt++]);ht{var ke=lg(),O=hg(),H=pg(),se=dg(),xe=fg(),Q=mg(),Ae=yg();Ae.alea=ke,Ae.xor128=O,Ae.xorwow=H,Ae.xorshift7=se,Ae.xor4096=xe,Ae.tychei=Q,i.exports=Ae}),gg=Mr(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=vg(),O=function(ne,ue){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,F){E.__proto__=F}||function(E,F){for(var A in F)F.hasOwnProperty(A)&&(E[A]=F[A])},O(ne,ue)};function H(ne,ue){O(ne,ue);function E(){this.constructor=ne}ne.prototype=ue===null?Object.create(ue):(E.prototype=ue.prototype,new E)}function se(ne,ue,E,F){function A(V){return V instanceof E?V:new E(function(oe){oe(V)})}return new(E||(E=Promise))(function(V,oe){function ee(de){try{ce(F.next(de))}catch(ye){oe(ye)}}function _e(de){try{ce(F.throw(de))}catch(ye){oe(ye)}}function ce(de){de.done?V(de.value):A(de.value).then(ee,_e)}ce((F=F.apply(ne,ue||[])).next())})}function xe(ne,ue){var E={label:0,sent:function(){if(V[0]&1)throw V[1];return V[1]},trys:[],ops:[]},F,A,V,oe;return oe={next:ee(0),throw:ee(1),return:ee(2)},typeof Symbol=="function"&&(oe[Symbol.iterator]=function(){return this}),oe;function ee(ce){return function(de){return _e([ce,de])}}function _e(ce){if(F)throw new TypeError("Generator is already executing.");for(;E;)try{if(F=1,A&&(V=ce[0]&2?A.return:ce[0]?A.throw||((V=A.return)&&V.call(A),0):A.next)&&!(V=V.call(A,ce[1])).done)return V;(A=0,V)&&(ce=[ce[0]&2,V.value]);switch(ce[0]){case 0:case 1:V=ce;break;case 4:return E.label++,{value:ce[1],done:!1};case 5:E.label++,A=ce[1],ce=[0];continue;case 7:ce=E.ops.pop(),E.trys.pop();continue;default:if(!(V=E.trys,V=V.length>0&&V[V.length-1])&&(ce[0]===6||ce[0]===2)){E=0;continue}if(ce[0]===3&&(!V||ce[1]>V[0]&&ce[1]0&&i.util.isString(A[0])){var oe=A.map(function(ee){return i.util.encodeString(ee)});V=this.write(oe,E,F)}else V=this.write(A,E,F);return{dataId:V,shape:E,dtype:F}},ue.prototype.incRef=function(E){var F=this.data.get(E);F.refCount++},ue.prototype.decRef=function(E){if(this.data.has(E)){var F=this.data.get(E);F.refCount--}},ue.prototype.move=function(E,F,A,V){this.data.set(E,{values:F,dtype:V,refCount:1})},ue.prototype.numDataIds=function(){return this.data.numDataIds()},ue.prototype.read=function(E){return se(this,void 0,void 0,function(){return xe(this,function(F){return[2,this.readSync(E)]})})},ue.prototype.readSync=function(E){var F=this.data.get(E),A=F.dtype,V=F.complexTensorInfos;if(A==="complex64"){var oe=this.readSync(V.real.dataId),ee=this.readSync(V.imag.dataId);return i.backend_util.mergeRealAndImagArrays(oe,ee)}return this.data.get(E).values},ue.prototype.bufferSync=function(E){var F=this.readSync(E.dataId),A=F;if(E.dtype==="string")try{A=F.map(function(V){return i.util.decodeString(V)})}catch(V){throw new Error("Failed to decode encoded string bytes into utf-8")}return i.buffer(E.shape,E.dtype,A)},ue.prototype.makeOutput=function(E,F,A){var V=this.write(E,F,A);return i.engine().makeTensorFromDataId(V,F,A,this)},ue.prototype.disposeData=function(E){if(this.data.has(E)){var F=this.data.get(E).complexTensorInfos;F!=null&&(this.disposeData(F.real.dataId),this.disposeData(F.imag.dataId)),this.data.delete(E)}},ue.prototype.disposeIntermediateTensorInfo=function(E){var F=E.dataId;if(this.data.has(F)){var A=this.data.get(F);A.refCount--,A.refCount<1&&this.disposeData(F)}},ue.prototype.time=function(E){return se(this,void 0,void 0,function(){var F,A;return xe(this,function(V){return F=i.util.now(),E(),A=i.util.now()-F,[2,{kernelMs:A}]})})},ue.prototype.memory=function(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}},ue.prototype.stridedSlice=function(E,F,A,V){Q(E,"stridedSlice");var oe=i.slice_util.computeOutShape(F,A,V);if(oe.some(function(Re){return Re===0}))return i.tensor([],oe);for(var ee=i.buffer(oe,E.dtype),_e=this.bufferSync(E),ce=0;ceOe&&(Oe=Xe,Fe=Ve)}de[ve]=Fe}return _e},ue.prototype.cumsum=function(E,F,A,V){if(Q(E,"cumsum"),F!==E.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(E.rank-1)+" "+("but got axis="+F));for(var oe=i.upcastType(E.dtype,"int32"),ee=i.zeros(E.shape,oe),_e=this.readSync(ee.dataId),ce=this.readSync(E.dataId),de=E.shape[E.rank-1],ye=V?function(Ve,Xe){return Ve+de-Xe-1}:function(Ve,Xe){return Ve+Xe},ve=0;veV?1:0})},ue.prototype.greaterEqual=function(E,F){return Q([E,F],"greaterEqual"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A>=V?1:0})},ue.prototype.logicalAnd=function(E,F){return Q([E,F],"logicalAnd"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A&&V})},ue.prototype.logicalOr=function(E,F){return Q([E,F],"logicalOr"),this.broadcastedBinaryOp(E,F,"bool",function(A,V){return A||V})},ue.prototype.select=function(E,F,A){Q([E,F,A],"select");for(var V=this.readSync(E.dataId),oe=this.readSync(F.dataId),ee=this.readSync(A.dataId),_e=i.zeros(F.shape,i.upcastType(F.dtype,A.dtype)),ce=this.readSync(_e.dataId),de=0,ye=E.rank===0||E.rank>1||F.rank===1?1:i.util.sizeFromShape(F.shape.slice(1)),ve=0;ve=0&&V>=0?oe:(oe+V)%V})},ue.prototype.maximum=function(E,F){return Q([E,F],"maximum"),this.broadcastedBinaryOp(E,F,E.dtype,function(A,V){return Math.max(A,V)})},ue.prototype.all=function(E,F){Q(E,"all"),i.backend_util.assertAxesAreInnerMostDims("all",F,E.rank);for(var A=i.backend_util.computeOutAndReduceShapes(E.shape,F),V=A[0],oe=A[1],ee=i.zeros(V,E.dtype),_e=i.util.sizeFromShape(oe),ce=this.readSync(ee.dataId),de=this.readSync(E.dataId),ye=0;ye=1?A[ee]=oe[ee]:A[ee]=oe[ee]*(_e+1)}return this.makeOutput(A,F.shape,"float32")},ue.prototype.atan2=function(E,F){return Q([E,F],"atan2"),this.broadcastedBinaryOp(E,F,E.dtype,function(A,V){return Math.atan2(A,V)})},ue.prototype.tile=function(E,F){return Q(E,"tile"),he(this.bufferSync(E),F)},ue.prototype.gather=function(E,F,A){Q([E,F],"gather");var V=E.shape.slice(),oe=this.readSync(F.dataId);V[A]=oe.length;for(var ee=i.buffer(V,E.dtype),_e=this.bufferSync(E),ce=0;cehr?hr=Ee:A==="avg"&&(Dr+=Ee,fr++),isNaN(hr))break}if(isNaN(hr))break}if(isNaN(hr))break}var Bn=Tr+Ut;$[Bn]=A==="avg"?Dr/fr:hr}}}return at.toTensor()},ue.prototype.avgPool3d=function(E,F){return Q(E,"avgPool3d"),this.pool3d(E,F,"avg").toFloat()},ue.prototype.avgPool3dBackprop=function(E,F,A){Q([E,F],"avgPool3dBackprop");for(var V=A.strideDepth,oe=A.strideHeight,ee=A.strideWidth,_e=A.filterDepth,ce=A.filterHeight,de=A.filterWidth,ye=A.dilationDepth,ve=A.dilationHeight,Re=A.dilationWidth,Oe=A.effectiveFilterDepth,Fe=A.effectiveFilterHeight,Ve=A.effectiveFilterWidth,Xe=Oe-1-A.padInfo.front,rt=Ve-1-A.padInfo.left,at=Fe-1-A.padInfo.top,$=i.buffer(F.shape,"float32"),et=1/(_e*ce*de),gt=this.bufferSync(E),lt=0;lt=A.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(jt)!==jt)continue;var cr=gt.get(lt,Rt,Et,jt,_t);Ht+=cr}}}$.set(Ht*et,lt,At,Lt,Pt,_t)}return $.toTensor()},ue.prototype.maxPool3d=function(E,F){return Q(E,"maxPool3d"),this.pool3d(E,F,"max").toFloat()},ue.prototype.maxPool3dPositions=function(E,F){for(var A=i.buffer(F.outShape,"int32"),V=F.strideDepth,oe=F.strideHeight,ee=F.strideWidth,_e=F.dilationDepth,ce=F.dilationHeight,de=F.dilationWidth,ye=F.effectiveFilterDepth,ve=F.effectiveFilterHeight,Re=F.effectiveFilterWidth,Oe=F.padInfo.front,Fe=F.padInfo.top,Ve=F.padInfo.left,Xe=this.bufferSync(E),rt=0;rt=Ot&&(Ot=Ie,Rt=Et*ve*Re+jt*ve+rr)}A.set(Rt,rt,$,_t,Ut,at)}}}return A.toTensor()},ue.prototype.maxPool3dBackprop=function(E,F,A,V){Q([F,A],"maxPool3dBackprop");for(var oe=this.maxPool3dPositions(F,V),ee=V.strideDepth,_e=V.strideHeight,ce=V.strideWidth,de=V.dilationDepth,ye=V.dilationHeight,ve=V.dilationWidth,Re=V.effectiveFilterDepth,Oe=V.effectiveFilterHeight,Fe=V.effectiveFilterWidth,Ve=Re-1-V.padInfo.front,Xe=Fe-1-V.padInfo.left,rt=Oe-1-V.padInfo.top,at=i.buffer(F.shape,"float32"),$=this.bufferSync(oe),et=this.bufferSync(E),gt=0;gt=V.outDepth||Math.floor(Ot)!==Ot)continue;for(var Rt=0;Rt=V.outHeight||Math.floor(wt)!==wt)continue;for(var Et=0;Et=V.outWidth||Math.floor(Vt)!==Vt)continue;var jt=Re*Oe*Fe-1-$.get(gt,Ot,wt,Vt,lt),cr=Ht*Oe*Fe+Rt*Fe+Et,rr=jt===cr?1:0;if(rr===0)continue;var Ie=et.get(gt,Ot,wt,Vt,lt);Kt+=Ie*rr}}}at.set(Kt,gt,_t,At,Lt,lt)}return at.toTensor()},ue.prototype.resizeBilinear=function(E,F,A,V){Q(E,"resizeBilinear");for(var oe=E.shape,ee=oe[0],_e=oe[1],ce=oe[2],de=oe[3],ye=this.readSync(E.dataId),ve=new Float32Array(i.util.sizeFromShape([ee,F,A,de])),Re=[V&&F>1?_e-1:_e,V&&A>1?ce-1:ce],Oe=[V&&F>1?F-1:F,V&&A>1?A-1:A],Fe=0,Ve=Re[0]/Oe[0],Xe=Re[1]/Oe[1],rt=0;rt1?ee-1:ee,A&&ve>1?_e-1:_e],Fe=[A&&ye>1?ye-1:ye,A&&ve>1?ve-1:ve],Ve=Oe[0]/Fe[0],Xe=Oe[1]/Fe[1],rt=this.readSync(E.dataId),at=0,$=0;$1?_e-1:_e,V&&A>1?ce-1:ce],Oe=[V&&F>1?F-1:F,V&&A>1?A-1:A],Fe=Re[0]/Oe[0],Ve=Re[1]/Oe[1],Xe=0,rt=0;rt1?ee-1:ee,A&&ve>1?_e-1:_e],Ve=[A&&ye>1?ye-1:ye,A&&ve>1?ve-1:ve],Xe=Fe[0]/Ve[0],rt=Fe[1]/Ve[1],at=1/Xe,$=1/rt,et=Math.ceil(at)*2+2,gt=Math.ceil($)*2+2,lt=0;lt=ye)continue;var jt=_t+Vt*E.strides[1],cr=Vt*Xe,rr=Math.min(ee-1,A?Math.round(cr):Math.floor(cr));if(At!==rr)continue;for(var Ie=0;Ie=ve)continue;var Nr=jt+br*E.strides[2],Tr=br*rt,hr=Math.min(_e-1,A?Math.round(Tr):Math.floor(Tr));Nt===hr&&(wt+=Oe[Nr+Rt])}}Re[Kt+Rt]=wt}return i.tensor4d(Re,F.shape,F.dtype)},ue.prototype.localResponseNormalization4D=function(E,F,A,V,oe){Q(E,"localResponseNormalization4D");var ee=E.shape[3],_e=ee-1,ce=this.readSync(E.dataId),de=E.size,ye=new Float32Array(de);function ve(Ve){for(var Xe=Ve%ee,rt=Ve-Xe+Math.max(0,Xe-F),at=Ve-Xe+Math.min(Xe+F,_e),$=0;rt<=at;rt++){var et=ce[rt];$+=et*et}return $}for(var Re=0;Re=0&&ee[_e]1,function(){return"blockSize should be > 1 for depthToSpace, but was: "+F});for(var V=E.shape[0],oe=E.shape[1],ee=E.shape[2],_e=E.shape[3],ce=oe*F,de=ee*F,ye=_e/(F*F),ve=this.readSync(E.dataId),Re=new Float32Array(V*ce*de*ye),Oe=0,Fe=0;Fe=ce)continue;for(var Nt=Oe>1?(Lt-_t)*(de-1)/(Oe-1):0,Kt=Fe>1?(Pt-At)*(ye-1)/(Fe-1):0,Ht=0;Ht1?_t*(de-1)+Ht*Nt:.5*(_t+Lt)*(de-1);if(Ot<0||Ot>de-1){for(var Rt=0;Rt1?At*(ye-1)+Rt*Kt:.5*(At+Pt)*(ye-1);if(rr<0||rr>ye-1){for(var wt=0;wt1?At*(ye-1)+Rt*Kt:.5*(At+Pt)*(ye-1);if(rr<0||rr>ye-1){for(var wt=0;wt=E.size/ce)throw new Error("Invalid indices: "+Fe+" does not index into "+E.shape);for(var at=0;at=V/oe)throw new Error("Invalid indices: "+Xe+" does not index into "+A);for(var et=0;etee&&(ee=ce)}A[V]=ee}return A}var Ei=nt(function(ne,ue){return ne*ue}),Gn=yt(function(ne,ue,E,F){return{real:ne*E-ue*F,imag:ne*F+ue*E}}),jn=ut(i.Multiply,Ei,Gn),Ua={kernelName:i.Multiply,backendName:"cpu",kernelFunc:jn},ga=nt(function(ne,ue){return ne!==ue?1:0}),wi=ut(i.NotEqual,ga,null,"bool"),Ta={kernelName:i.NotEqual,backendName:"cpu",kernelFunc:wi},on=jr(function(ne){return 1/Math.sqrt(ne)}),_n=tr(i.Rsqrt,on),xa={kernelName:i.Rsqrt,backendName:"cpu",kernelFunc:_n};function Rr(ne,ue,E,F,A){var V=i.slice_util.isSliceContinous(F,ue,E),oe=i.util.sizeFromShape(E),ee=i.util.computeStrides(F);if(V){var _e=i.slice_util.computeFlatOffset(ue,ee);return ne.subarray(_e,_e+oe)}for(var ce=i.util.getTypedArrayFromDType(A,oe),de=0;de=0?ne:Math.exp(ne)-1}),gr={kernelName:i.Elu,backendName:"cpu",kernelFunc:ni},Di=nt(function(ne,ue){return ne<0?ue*ne:ne});function bi(ne){var ue=ne.inputs,E=ne.backend,F=ue.x,A=ue.alpha;Q([F,A],"prelu");var V=E.data.get(F.dataId).values,oe=E.data.get(A.dataId).values,ee=Di(F.shape,A.shape,V,oe,F.dtype),_e=ee[0],ce=ee[1];return E.makeTensorInfo(ce,F.dtype,_e)}var ro={kernelName:i.Prelu,backendName:"cpu",kernelFunc:bi},Zn=_r(i.Relu,function(ne){return Math.max(0,ne)}),Gi={kernelName:i.Relu,backendName:"cpu",kernelFunc:Zn},Fi=_r(i.Relu6,function(ne){return Math.min(Math.max(0,ne),6)}),ji={kernelName:i.Relu6,backendName:"cpu",kernelFunc:Fi};function Oi(ne,ue,E,F){if(E==="linear")return Tt({inputs:{x:ue},backend:ne});if(E==="relu")return Zn({inputs:{x:ue},backend:ne});if(E==="elu")return ni({inputs:{x:ue},backend:ne});if(E==="relu6")return Fi({inputs:{x:ue},backend:ne});if(E==="prelu")return bi({inputs:{x:ue,alpha:F},backend:ne});throw new Error("Activation "+E+" has not been implemented for the CPU backend.")}function da(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.shape,oe=i.util.sizeFromShape(A.shape),ee=i.util.inferFromImplicitShape(V,oe),_e=i.util.sizeFromShape(ee);i.util.assert(oe===_e,function(){return"The new shape ("+ee+") has "+_e+" elements and the old "+("shape ("+A.shape+") has "+oe+" elements. The new shape and old ")+"shape must have the same number of elements."}),E.incRef(A.dataId);var ce=E.data.get(A.dataId);if(ce.complexTensorInfos!=null){var de=ce.complexTensorInfos.real,ye=ce.complexTensorInfos.imag;de.shape=ee,ye.shape=ee}return{dataId:A.dataId,shape:ee,dtype:A.dtype}}var Mi={kernelName:i.Reshape,backendName:"cpu",kernelFunc:da};function pe(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.a,V=ue.b,oe=F.transposeA,ee=F.transposeB;Q([A,V],"matMul");var _e=A.shape.length,ce=V.shape.length,de=oe?A.shape[_e-2]:A.shape[_e-1],ye=ee?V.shape[ce-1]:V.shape[ce-2],ve=oe?A.shape[_e-1]:A.shape[_e-2],Re=ee?V.shape[ce-2]:V.shape[ce-1],Oe=A.shape.slice(0,-2),Fe=V.shape.slice(0,-2),Ve=i.util.sizeFromShape(Oe),Xe=i.util.sizeFromShape(Fe),rt=Ve===Xe||Ve===1||Xe===1;i.util.assert(_e>=2&&ce>=2&&rt,function(){return"Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input "+("batch dimensions of ("+Oe+") and ("+Fe+").")});var at=Ve>Xe?A.shape.slice(0,-2):V.shape.slice(0,-2),$=at.concat([ve,Re]);i.util.assert(de===ye,function(){return"Error in matMul: inner shapes ("+de+") and ("+(ye+") of Tensors with shapes "+A.shape+" and ")+(V.shape+" and transposeA="+oe)+(" and transposeB="+ee+" must match.")});for(var et=oe?[Ve,de,ve]:[Ve,ve,de],gt=ee?[Xe,Re,ye]:[Xe,ye,Re],lt=da({inputs:{x:A},backend:E,attrs:{shape:et}}),_t=da({inputs:{x:V},backend:E,attrs:{shape:gt}}),At=oe?lt.shape[1]:lt.shape[2],Lt=oe?lt.shape[2]:lt.shape[1],Pt=ee?_t.shape[1]:_t.shape[2],Ut=Math.max(Ve,Xe),Nt=E.data.get(lt.dataId).values,Kt=E.data.get(_t.dataId).values,Ht=i.util.computeStrides(lt.shape),Ot=i.util.computeStrides(_t.shape),Rt=oe?[Ht[0],1,Ht[1]]:[Ht[0],Ht[1],1],wt=Rt[0],Et=Rt[1],Vt=Rt[2],jt=ee?[1,Ot[1],Ot[0]]:[Ot[1],1,Ot[0]],cr=jt[0],rr=jt[1],Ie=jt[2],br=Lt*Pt,Nr=i.buffer([Ut,Lt,Pt],lt.dtype),Tr=Nr.values,hr=E.blockSize,Dr=0;DrRt?Rt=Ie:V==="avg"&&(wt+=Ie,Et++)}if(isNaN(Rt))break}var br=Ut+Nt*at+lt;Ve[br]=V==="avg"?wt/Et:Rt}return Fe}function ra(ne,ue,E,F,A,V){A===void 0&&(A=!1),V===void 0&&(V=!1);for(var oe=i.buffer(F.outShape,"int32"),ee=F.strideHeight,_e=F.strideWidth,ce=F.dilationHeight,de=F.dilationWidth,ye=F.effectiveFilterHeight,ve=F.effectiveFilterWidth,Re=F.padInfo.top,Oe=F.padInfo.left,Fe=i.buffer(ue,E,ne),Ve=0;VeLt&&(Lt=Ot,A?Pt=V?((Ve*F.inHeight+Ut)*F.inWidth+Kt)*F.inChannels+Xe:(Ut*F.inWidth+Kt)*F.inChannels+Xe:Pt=Nt*ve+Ht)}oe.set(Pt,Ve,rt,gt,Xe)}}return oe}function Ha(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x;Q(A,"avgPool");var V=F.filterSize,oe=F.strides,ee=F.pad,_e=F.dimRoundingMode,ce=1;i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(oe,ce),function(){return"Error in avgPool: Either strides or dilations must be 1. "+("Got strides "+oe+" and dilations '"+ce+"'")});var de=i.backend_util.computePool2DInfo(A.shape,V,oe,ce,ee,_e),ye;if(de.filterWidth===1&&de.filterHeight===1&&i.util.arraysEqual(de.inShape,de.outShape))ye=Tt({inputs:{x:A},backend:E});else{var ve=E.data.get(A.dataId).values,Re=i.util.computeStrides(A.shape),Oe=fa(ve,A.shape,A.dtype,Re,de,"avg");ye=E.makeTensorInfo(de.outShape,A.dtype,Oe.values)}return ye}var ki={kernelName:i.AvgPool,backendName:"cpu",kernelFunc:Ha};function sn(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.dy,V=ue.input,oe=V;Q([A,V],"avgPoolBackprop");for(var ee=F.filterSize,_e=F.strides,ce=F.pad,de=i.backend_util.computePool2DInfo(oe.shape,ee,_e,1,ce),ye=de.strideHeight,ve=de.strideWidth,Re=de.filterHeight,Oe=de.filterWidth,Fe=de.dilationHeight,Ve=de.dilationWidth,Xe=de.effectiveFilterHeight,rt=de.effectiveFilterWidth,at=rt-1-de.padInfo.left,$=Xe-1-de.padInfo.top,et=i.buffer(oe.shape,"float32"),gt=1/(Re*Oe),lt=E.data.get(A.dataId).values,_t=i.buffer(A.shape,"float32",lt),At=0;At=de.outHeight||Math.floor(Rt)!==Rt)continue;for(var wt=0;wt=de.outWidth||Math.floor(Et)!==Et)continue;var Vt=_t.get(At,Rt,Et,Lt);Ht+=Vt}}et.set(Ht*gt,At,Pt,Ut,Lt)}return E.makeTensorInfo(et.shape,et.dtype,et.values)}var hn={kernelName:i.AvgPoolBackprop,backendName:"cpu",kernelFunc:sn};function na(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.scale,oe=ue.offset,ee=ue.mean,_e=ue.variance;i.util.assert(ee.shape.length===_e.shape.length,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),i.util.assert(oe==null||ee.shape.length===oe.shape.length,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),i.util.assert(V==null||ee.shape.length===V.shape.length,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}),Q([A,ee,_e,V,oe],"batchNorm");var ce=F.varianceEpsilon;ce==null&&(ce=.001);for(var de=E.data.get(A.dataId).values,ye=E.data.get(ee.dataId).values,ve=E.data.get(_e.dataId).values,Re=V?E.data.get(V.dataId).values:new Float32Array([1]),Oe=oe?E.data.get(oe.dataId).values:new Float32Array([0]),Fe=new Float32Array(de.length),Ve=Oe.length,Xe=Re.length,rt=ve.length,at=ye.length,$=0,et=0,gt=0,lt=0,_t=0;_t=Ve&&($=0),et>=at&&(et=0),gt>=Xe&&(gt=0),lt>=rt&&(lt=0);return E.makeTensorInfo(A.shape,A.dtype,Fe)}var Jr={kernelName:i.FusedBatchNorm,backendName:"cpu",kernelFunc:na},Vr=_r(i.ClipByValue,function(ne,ue){var E=ue;return ne>E.clipValueMax?E.clipValueMax:ne0});if(ee.length===1)return ee[0];var _e=ee.map(function($){return $.shape});if(i.backend_util.assertParamsConsistent(_e,V),ee[0].dtype==="complex64"){var ce=ee.map(function($){return it({inputs:{input:$},backend:E})}),de=ee.map(function($){return tn({inputs:{input:$},backend:E})}),ye=Kn({inputs:ce,backend:E,attrs:{axis:V}}),ve=Kn({inputs:de,backend:E,attrs:{axis:V}}),Re=tt({inputs:{real:ye,imag:ve},backend:E});return ce.forEach(function($){return E.disposeIntermediateTensorInfo($)}),de.forEach(function($){return E.disposeIntermediateTensorInfo($)}),E.disposeIntermediateTensorInfo(ye),E.disposeIntermediateTensorInfo(ve),Re}var Oe=ee.map(function($){var et=i.util.sizeFromShape($.shape.slice(V)),gt=[-1,et];return da({inputs:{x:$},backend:E,attrs:{shape:gt}})});oe=i.backend_util.computeOutShape(Oe.map(function($){return $.shape}),1);var Fe=i.util.getTypedArrayFromDType(ee[0].dtype,i.util.sizeFromShape(oe));if(Oe[0].shape[0]===1){var Ve=0;Oe.forEach(function($){var et=E.data.get($.dataId).values,gt=i.util.sizeFromShape($.shape);Fe.set(et,Ve),Ve+=gt})}else{var Xe=0;Oe.forEach(function($){for(var et=E.data.get($.dataId).values,gt=0,lt=0;lt<$.shape[0];++lt)for(var _t=lt*oe[1]+Xe,At=0;At<$.shape[1];++At)Fe[_t+At]=et[gt++];Xe+=$.shape[1]})}var rt=i.backend_util.computeOutShape(ee.map(function($){return $.shape}),V),at=E.makeTensorInfo(rt,ue[0].dtype,Fe);return Oe.forEach(function($){return E.disposeIntermediateTensorInfo($)}),at}var aa={kernelName:i.Concat,backendName:"cpu",kernelFunc:Kn};function ma(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=ue.filter,oe=F.strides,ee=F.pad,_e=F.dataFormat,ce=F.dilations,de=F.dimRoundingMode;Q([A,V],"conv2d");for(var ye=i.backend_util.convertConv2DDataFormat(_e),ve=i.backend_util.computeConv2DInfo(A.shape,V.shape,oe,ce,ee,de,!1,ye),Re=ve.filterHeight,Oe=ve.filterWidth,Fe=ve.dilationHeight,Ve=ve.dilationWidth,Xe=ve.padInfo.left,rt=ve.padInfo.top,at=ve.dataFormat==="channelsLast",$=new i.TensorBuffer(ve.outShape,A.dtype),et=i.util.computeStrides(A.shape),gt=i.util.computeStrides(V.shape),lt=et[0],_t=at?et[1]:et[2],At=at?et[2]:1,Lt=at?1:et[1],Pt=$.strides[0],Ut=at?$.strides[1]:$.strides[2],Nt=at?$.strides[2]:1,Kt=at?1:$.strides[1],Ht=E.data.get(A.dataId).values,Ot=E.data.get(V.dataId).values,Rt=$.values,wt=0;wt=ve.inHeight)continue;for(var Nr=Ie*gt[0],Tr=Et+br*_t,hr=0;hr=ve.inWidth)continue;for(var wn=Nr+Er*gt[1],ie=Tr+an*At,Nn=wn,bn=0;bn=ce.inDepth)continue;for(var wt=Ot*At[0],Et=Pt+Rt*_t[1],Vt=0;Vt=ce.inHeight)continue;for(var br=wt+rr*At[1],Nr=Et+Ie*_t[2],Tr=0;Tr=ce.inWidth)continue;for(var an=br+fr*At[2],wn=Nr+Er*ce.inChannels,ie=an,Nn=0;Nn=Re.inHeight)continue;for(var wt=Ot*ye[0],Et=Pt+Rt*de[1],Vt=0;Vt=Re.inWidth)continue;for(var br=wt+rr*ye[1],Nr=Et+Ie*Re.inChannels,Tr=jt,hr=br,Dr=0;Dr=0&&Nr=0&&hrIe&&(Ie=Er)}}}var an=i.util.locToIndex([wt,Et,jt,rr],Ot,i.util.computeStrides(Kt));Rt[an]=Ie}var wn=ye.write(i.util.toTypedArray(Rt,V.dtype),Kt,V.dtype);return{dataId:wn,shape:Kt,dtype:V.dtype}}},zn={kernelName:i.Dilation2DBackpropFilter,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.x,oe=A.filter,ee=A.dy,_e=F,ce=_e.strides,de=_e.pad,ye=_e.dilations,ve=E,Re=i.util.toNestedArray(V.shape,ve.data.get(V.dataId).values),Oe=i.util.toNestedArray(oe.shape,ve.data.get(oe.dataId).values),Fe=i.backend_util.computeDilation2DInfo(V.shape,oe.shape,ce,de,"NHWC",ye),Ve=Fe.batchSize,Xe=Fe.inHeight,rt=Fe.inWidth,at=Fe.inChannels,$=Fe.outHeight,et=Fe.outWidth,gt=Fe.padInfo,lt=Fe.strideHeight,_t=Fe.strideWidth,At=Fe.filterHeight,Lt=Fe.filterWidth,Pt=Fe.dilationHeight,Ut=Fe.dilationWidth,Nt=Fe.outShape;i.util.assert(ee.rank===Nt.length,function(){return"Error in "+i.Dilation2DBackpropFilter+", dy "+("must have the same rank as output "+Nt.length+", but got ")+(""+ee.rank)});for(var Kt=i.util.toNestedArray(Nt,ve.data.get(ee.dataId).values),Ht=i.util.makeZerosNestedTypedArray(oe.shape,oe.dtype),Ot=0;Ot=0&&Nr=0&&hrcr&&(cr=Dr,rr=br,Ie=Tr)}}}Ht[rr][Ie][jt]+=Kt[Ot][Rt][Et][jt]}var fr=ve.write(i.util.toTypedArray(Ht,V.dtype),oe.shape,oe.dtype);return{dataId:fr,shape:oe.shape,dtype:oe.dtype}}},Fr={kernelName:i.Dilation2DBackpropInput,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.x,oe=A.filter,ee=A.dy,_e=F,ce=_e.strides,de=_e.pad,ye=_e.dilations,ve=E,Re=i.util.toNestedArray(V.shape,ve.data.get(V.dataId).values),Oe=i.util.toNestedArray(oe.shape,ve.data.get(oe.dataId).values),Fe=i.backend_util.computeDilation2DInfo(V.shape,oe.shape,ce,de,"NHWC",ye),Ve=Fe.batchSize,Xe=Fe.inHeight,rt=Fe.inWidth,at=Fe.inChannels,$=Fe.outHeight,et=Fe.outWidth,gt=Fe.padInfo,lt=Fe.strideHeight,_t=Fe.strideWidth,At=Fe.filterHeight,Lt=Fe.filterWidth,Pt=Fe.dilationHeight,Ut=Fe.dilationWidth,Nt=Fe.outShape;i.util.assert(ee.rank===Nt.length,function(){return"Error in "+i.Dilation2DBackpropInput+", dy "+("must have the same rank as output "+Nt.length+", but got ")+(""+ee.rank)});for(var Kt=i.util.toNestedArray(Nt,ve.data.get(ee.dataId).values),Ht=i.util.makeZerosNestedTypedArray(V.shape,V.dtype),Ot=0;Ot=0&&Nr=0&&hrcr&&(cr=Dr,rr=Nr,Ie=hr)}}}Ht[Ot][rr][Ie][jt]+=Kt[Ot][Rt][Et][jt]}var fr=ve.write(i.util.toTypedArray(Ht,V.dtype),V.shape,V.dtype);return{dataId:fr,shape:V.shape,dtype:V.dtype}}},wa=nt(function(ne,ue){return ne/ue}),In=ut(i.Div,wa),ur={kernelName:i.Div,backendName:"cpu",kernelFunc:In},$r=i.backend_util.ERF_P,Ra=i.backend_util.ERF_A1,mi=i.backend_util.ERF_A2,Ga=i.backend_util.ERF_A3,ja=i.backend_util.ERF_A4,ai=i.backend_util.ERF_A5,zi=_r(i.Erf,function(ne){var ue=Math.sign(ne),E=Math.abs(ne),F=1/(1+$r*E);return ue*(1-((((ai*F+ja)*F+Ga)*F+mi)*F+Ra)*F*Math.exp(-E*E))}),An={kernelName:i.Erf,backendName:"cpu",kernelFunc:zi};function ba(ne,ue,E){for(var F=ne.shape,A=F[0],V=F[1],oe=E.data.get(ne.dataId),ee=oe.complexTensorInfos.real,_e=oe.complexTensorInfos.imag,ce=[A,V],de=i.util.sizeFromShape(ce),ye=i.util.getTypedArrayFromDType("float32",de),ve=i.util.getTypedArrayFromDType("float32",de),Re=0;Re=0&>=ve.outHeight||Math.floor(wt)!==wt)continue;for(var Et=0;Et<$;Et+=rt){var Vt=(Ht+Et)/Ve;if(Vt<0||Vt>=ve.outWidth||Math.floor(Vt)!==Vt)continue;var jt=at*$-1-Oe.get(Lt,wt,Vt,Pt),cr=Rt*$+Et,rr=jt===cr?1:0;if(rr===0)continue;var Ie=At.get(Lt,wt,Vt,Pt);Ot+=Ie*rr}}lt.set(Ot,Lt,Ut,Nt,Pt)}return E.makeTensorInfo(lt.shape,lt.dtype,lt.values)}var Aa={kernelName:i.MaxPoolBackprop,backendName:"cpu",kernelFunc:vo};function go(ne,ue,E,F,A){var V=i.util.computeStrides(ue),oe=fa(ne,ue,E,V,A,"max"),ee=ra(ne,ue,E,A,!0,F);return[oe.values,ee.values]}var To={kernelName:i.MaxPoolWithArgmax,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.attrs,F=ne.backend,A=ue.x,V=E,oe=V.filterSize,ee=V.strides,_e=V.pad,ce=V.includeBatchInIndex,de=F;Q(A,"MaxPoolWithArgmax");var ye=de.data.get(A.dataId).values,ve=i.backend_util.computePool2DInfo(A.shape,oe,ee,[1,1],_e),Re=go(ye,A.shape,A.dtype,ce,ve),Oe=Re[0],Fe=Re[1],Ve=de.write(Oe,ve.outShape,A.dtype),Xe=de.write(Fe,ve.outShape,A.dtype);return[{dataId:Ve,shape:ve.outShape,dtype:A.dtype},{dataId:Xe,shape:ve.outShape,dtype:"int32"}]}};function Rs(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.paddings,oe=F.mode;Q(A,"mirrorPad");for(var ee=V.map(function(lt,_t){return lt[0]+A.shape[_t]+lt[1]}),_e=V.map(function(lt){return lt[0]}),ce=V.map(function(lt,_t){return lt[0]+A.shape[_t]}),de=oe==="reflect"?0:1,ye=E.data.get(A.dataId).values,ve=A.shape.length,Re=i.util.computeStrides(A.shape),Oe=i.util.sizeFromShape(ee),Fe=ee.length,Ve=i.util.computeStrides(ee),Xe=i.util.getTypedArrayFromDType(A.dtype,Oe),rt=0;rt=ce[$]&&(at[$]=(ce[$]-1)*2-at[$]+de);at=at.map(function(lt,_t){return lt-_e[_t]});var et=i.util.locToIndex(at,ve,Re);Xe[rt]=ye[et]}var gt=E.write(Xe,ee,A.dtype);return{dataId:gt,shape:ee,dtype:A.dtype}}var Eo={kernelName:i.MirrorPad,backendName:"cpu",kernelFunc:Rs},As=i.kernel_impls.nonMaxSuppressionV4Impl,Ds={kernelName:i.NonMaxSuppressionV4,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.boxes,oe=A.scores,ee=F,_e=ee.maxOutputSize,ce=ee.iouThreshold,de=ee.scoreThreshold,ye=ee.padToMaxOutputSize,ve=E;Q(V,"NonMaxSuppressionPadded");var Re=ve.data.get(V.dataId).values,Oe=ve.data.get(oe.dataId).values,Fe=As(Re,Oe,_e,ce,de,ye),Ve=Fe.selectedIndices,Xe=Fe.validOutputs;return[Ve,Xe]}},Xo=i.kernel_impls.nonMaxSuppressionV5Impl,Ro={kernelName:i.NonMaxSuppressionV5,backendName:"cpu",kernelFunc:function(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue,V=A.boxes,oe=A.scores,ee=F,_e=ee.maxOutputSize,ce=ee.iouThreshold,de=ee.scoreThreshold,ye=ee.softNmsSigma,ve=E;Q(V,"NonMaxSuppressionWithScore");var Re=ve.data.get(V.dataId).values,Oe=ve.data.get(oe.dataId).values,Fe=_e,Ve=ce,Xe=de,rt=ye,at=Xo(Re,Oe,Fe,Ve,Xe,rt),$=at.selectedIndices,et=at.selectedScores;return[$,et]}};function Yo(ne){var ue=ne.inputs,E=ne.backend,F=ne.attrs,A=ue.x,V=F.paddings,oe=F.constantValue;Q(A,"pad");var ee=V.map(function(gt,lt){return gt[0]+A.shape[lt]+gt[1]}),_e=V.map(function(gt){return gt[0]}),ce=E.data.get(A.dataId).values,de=i.util.sizeFromShape(A.shape),ye=A.shape.length,ve=i.util.computeStrides(A.shape),Re=i.util.sizeFromShape(ee),Oe=ee.length,Fe=i.util.computeStrides(ee),Ve=i.util.getTypedArrayFromDType(A.dtype,Re);oe!==0&&Ve.fill(oe);for(var Xe=0;Xe=0&&Rt=0&&wt.5?Math.ceil(ne):ue%2===0?ue:ue+1}),ps={kernelName:i.Round,backendName:"cpu",kernelFunc:tu},ru=i.backend_util.SELU_SCALEALPHA,Os=i.backend_util.SELU_SCALE,ds=_r(i.Selu,function(ne){return ne>=0?Os*ne:ru*(Math.exp(ne)-1)}),Ms={kernelName:i.Selu,backendName:"cpu",kernelFunc:ds},Ls=_r(i.Sigmoid,function(ne){return 1/(1+Math.exp(-ne))}),nu={kernelName:i.Sigmoid,backendName:"cpu",kernelFunc:Ls},fs=_r(i.Sign,function(ne){return ne<0?-1:ne>0?1:0}),au={kernelName:i.Sign,backendName:"cpu",kernelFunc:fs},ms=_r(i.Sin,function(ne){return Math.sin(ne)}),Do={kernelName:i.Sin,backendName:"cpu",kernelFunc:ms},zs=_r(i.Sinh,function(ne){return Math.sinh(ne)}),Zo={kernelName:i.Sinh,backendName:"cpu",kernelFunc:zs},xo=11920928955078125e-23,ys=Math.log(xo)+2,Fo=_r(i.Softplus,function(ne){var ue=ne>-ys,E=ne0?1:E.alpha}),ku={kernelName:i.Step,backendName:"cpu",kernelFunc:iu},ou=_r(i.Tan,function(ne){return Math.tan(ne)}),Oo={kernelName:i.Tan,backendName:"cpu",kernelFunc:ou},Mo=_r(i.Tanh,function(ne){return Math.tanh(ne)}),gs={kernelName:i.Tanh,backendName:"cpu",kernelFunc:Mo};function es(ne){var ue=ne.inputs,E=ne.attrs,F=ne.backend,A=E.axis,V=ue.x;Q(V,"unique");var oe=F.data.get(V.dataId).values,ee=fi(oe,A,V.shape,V.dtype),_e=ee.outputValues,ce=ee.outputShape,de=ee.indices;return[F.makeTensorInfo(ce,V.dtype,_e),F.makeTensorInfo([de.length],"int32",de)]}for(var Si={kernelName:i.Unique,backendName:"cpu",kernelFunc:es},Lo=[re,W,Ue,$e,Ur,Ye,St,dr,ta,ki,hn,X,Jr,ht,Tn,Jn,nr,aa,S,k,Li,Je,vt,Se,zt,Gt,wr,Yt,Sn,pn,Fr,zn,ur,gr,An,yn,hi,nn,La,oi,Ca,no,Ka,Qe,Ko,Rn,Co,ia,oa,_i,Qn,ka,yo,Aa,To,vn,Eo,Ua,Ds,Ro,Ta,Ao,ro,xt,vi,Gi,ji,Mi,Fs,ps,xa,Ms,nu,au,Do,Zo,_a,Ps,Bs,vs,$o,Ai,ku,pa,Oo,gs,_o,Si],zo=0,Xi=Lo;zo{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=function(f,p){return ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,m){l.__proto__=m}||function(l,m){for(var g in m)m.hasOwnProperty(g)&&(l[g]=m[g])},ke(f,p)};function O(f,p){ke(f,p);function l(){this.constructor=f}f.prototype=p===null?Object.create(p):(l.prototype=p.prototype,new l)}function H(f,p,l,m){function g(I){return I instanceof l?I:new l(function(R){R(I)})}return new(l||(l=Promise))(function(I,R){function z(Z){try{G(m.next(Z))}catch(be){R(be)}}function L(Z){try{G(m.throw(Z))}catch(be){R(be)}}function G(Z){Z.done?I(Z.value):g(Z.value).then(z,L)}G((m=m.apply(f,p||[])).next())})}function se(f,p){var l={label:0,sent:function(){if(I[0]&1)throw I[1];return I[1]},trys:[],ops:[]},m,g,I,R;return R={next:z(0),throw:z(1),return:z(2)},typeof Symbol=="function"&&(R[Symbol.iterator]=function(){return this}),R;function z(G){return function(Z){return L([G,Z])}}function L(G){if(m)throw new TypeError("Generator is already executing.");for(;l;)try{if(m=1,g&&(I=G[0]&2?g.return:G[0]?g.throw||((I=g.return)&&I.call(g),0):g.next)&&!(I=I.call(g,G[1])).done)return I;(g=0,I)&&(G=[G[0]&2,I.value]);switch(G[0]){case 0:case 1:I=G;break;case 4:return l.label++,{value:G[1],done:!1};case 5:l.label++,g=G[1],G=[0];continue;case 7:G=l.ops.pop(),l.trys.pop();continue;default:if(!(I=l.trys,I=I.length>0&&I[I.length-1])&&(G[0]===6||G[0]===2)){l=0;continue}if(G[0]===3&&(!I||G[1]>I[0]&&G[1]l||p>l){var m="["+f+"x"+p+"]",g="["+l+"x"+l+"]";throw new Error("Requested texture size "+m+" greater than WebGL maximum on this browser / GPU "+g+".")}}function yn(f){return Gn(f,function(){return f.createFramebuffer()},"Unable to create WebGLFramebuffer.")}function Ma(f,p,l,m,g,I,R){var z=f.getAttribLocation(p,l);return z===-1?!1:(Qe(f,function(){return f.bindBuffer(f.ARRAY_BUFFER,m)}),Qe(f,function(){return f.vertexAttribPointer(z,g,f.FLOAT,!1,I,R)}),Qe(f,function(){return f.enableVertexAttribArray(z)}),!0)}function li(f,p,l){jn(f,l),Qe(f,function(){return f.activeTexture(f.TEXTURE0+l)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,p)})}function hi(f,p){jn(f,p),Qe(f,function(){return f.activeTexture(f.TEXTURE0+p)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function la(f,p,l){return Gn(f,function(){return f.getUniformLocation(p,l)},'uniform "'+l+'" not present in program.')}function rn(f,p,l){return f.getUniformLocation(p,l)}function Ca(f,p,l,m){Qe(f,function(){return li(f,p,m)}),Qe(f,function(){return f.uniform1i(l,m)})}function xn(f){Qe(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,null)}),Qe(f,function(){return f.viewport(0,0,f.canvas.width,f.canvas.height)}),Qe(f,function(){return f.scissor(0,0,f.canvas.width,f.canvas.height)})}function Hn(f,p,l){Qe(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,l)}),Qe(f,function(){return f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,p,0)})}function _i(f,p){Qe(f,function(){return f.bindFramebuffer(f.FRAMEBUFFER,p)}),Qe(f,function(){return f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,null,0)})}function ha(f){var p=f.checkFramebufferStatus(f.FRAMEBUFFER);if(p!==f.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+Ei(f,p))}function Ei(f,p){switch(p){case f.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case f.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case f.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case f.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+p}}function Gn(f,p,l){var m=Qe(f,function(){return p()});if(m==null)throw new Error(l);return m}function jn(f,p){var l=f.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,m=p+f.TEXTURE0;if(ml){var g="[gl.TEXTURE0, gl.TEXTURE"+l+"]";throw new Error("textureUnit must be in "+g+".")}}function Ua(f,p){return p===void 0&&(p=2),i.util.sizeFromShape(f.slice(0,f.length-p))}function ga(f){if(f.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[f.length>1?f[f.length-2]:1,f[f.length-1]]}function wi(f){var p=[1,1,1],l=f.length===0||f.length===1&&f[0]===1;return l||(p=[Ua(f)].concat(ga(f))),p}function Ta(f,p){var l;p===void 0&&(p=!1);var m=i.env().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(p&&(m=m*2,f=f.map(function(G,Z){return Z>=f.length-2?i.util.nearestLargerEven(f[Z]):f[Z]}),f.length===1&&(f=[2,f[0]])),f.length!==2){var g=i.util.squeezeShape(f);f=g.newShape}var I=i.util.sizeFromShape(f);if(f.length<=1&&I<=m)return[1,I];if(f.length===2&&f[0]<=m&&f[1]<=m)return f;if(f.length===3&&f[0]*f[1]<=m&&f[2]<=m)return[f[0]*f[1],f[2]];if(f.length===3&&f[0]<=m&&f[1]*f[2]<=m)return[f[0],f[1]*f[2]];if(f.length===4&&f[0]*f[1]*f[2]<=m&&f[3]<=m)return[f[0]*f[1]*f[2],f[3]];if(f.length===4&&f[0]<=m&&f[1]*f[2]*f[3]<=m)return[f[0],f[1]*f[2]*f[3]];if(p){var R=Ua(f),z=2,L=2;return f.length&&(l=ga(f),z=l[0],L=l[1]),I=R*(z/2)*(L/2),i.util.sizeToSquarishShape(I).map(function(G){return G*2})}return i.util.sizeToSquarishShape(I)}function on(f){return f%2===0}function _n(f,p){if(f=f.slice(-2),p=p.slice(-2),i.util.arraysEqual(f,p))return!0;if(!f.length||!p.length)return!0;if(f[0]===0||f[1]===0||p[0]===0||p[1]===0)return!0;if(f.length!==p.length){var l=f.slice(-1)[0],m=p.slice(-1)[0];if(l===m)return!0;if(on(l)&&on(m)&&(f[0]===1||p[0]===1))return!0}return f[1]===p[1]&&on(f[0])&&on(p[0])}var xa,Rr;function ti(f){if(xa==null){var p=P(f);xa=p.getParameter(p.MAX_TEXTURE_SIZE)}return xa}function _a(){xa=null}function Ri(){Rr=null}function Hi(f){if(Rr==null){var p=P(f);Rr=p.getParameter(p.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Rr)}function Ai(f){if(f===0)return 0;var p,l=P(f);return qn(l,"EXT_disjoint_timer_query_webgl2")&&f===2?p=2:qn(l,"EXT_disjoint_timer_query")?p=1:p=0,p}function qn(f,p){var l=f.getExtension(p);return l!=null}function ri(f){try{var p=P(f);if(p!=null)return!0}catch(l){return console.log("Error when getting WebGL context: ",l),!1}return!1}function pi(f){if(f===0)return!1;var p=P(f);if(f===1){if(!qn(p,"OES_texture_float"))return!1}else if(!qn(p,"EXT_color_buffer_float"))return!1;var l=di(p);return l}function pa(f){if(f===0)return!1;var p=P(f);if(f===1){if(!qn(p,"OES_texture_float"))return!1;if(!qn(p,"WEBGL_color_buffer_float"))return!1}else{if(qn(p,"EXT_color_buffer_float"))return di(p);var l="EXT_color_buffer_half_float";if(qn(p,l)){var m=p.getExtension(l);return fi(p,m)}return!1}var g=di(p);return g}function di(f){var p=Tt(f),l=f.createTexture();f.bindTexture(f.TEXTURE_2D,l);var m=1,g=1;f.texImage2D(f.TEXTURE_2D,0,p.internalFormatFloat,m,g,0,p.textureFormatFloat,p.textureTypeFloat,null);var I=f.createFramebuffer();f.bindFramebuffer(f.FRAMEBUFFER,I),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l,0);var R=f.checkFramebufferStatus(f.FRAMEBUFFER)===f.FRAMEBUFFER_COMPLETE;return f.bindTexture(f.TEXTURE_2D,null),f.bindFramebuffer(f.FRAMEBUFFER,null),f.deleteTexture(l),f.deleteFramebuffer(I),R}function fi(f,p){var l=Tt(f,p),m=f.createTexture();f.bindTexture(f.TEXTURE_2D,m);var g=1,I=1;f.texImage2D(f.TEXTURE_2D,0,l.internalFormatHalfFloat,g,I,0,l.textureFormatFloat,l.textureTypeHalfFloat,null);var R=f.createFramebuffer();f.bindFramebuffer(f.FRAMEBUFFER,R),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,m,0);var z=f.checkFramebufferStatus(f.FRAMEBUFFER)===f.FRAMEBUFFER_COMPLETE;return f.bindTexture(f.TEXTURE_2D,null),f.bindFramebuffer(f.FRAMEBUFFER,null),f.deleteTexture(m),f.deleteFramebuffer(R),z}function Va(f){if(f!==2)return!1;var p=P(f),l=p.fenceSync!=null;return l}function ln(f,p){Array.isArray(f)||(f=[f]),f.forEach(function(l){l!=null&&i.util.assert(l.dtype!=="complex64",function(){return p+" does not support complex64 tensors in the WebGL backend."})})}var ni={__proto__:null,callAndCheck:Qe,canBeRepresented:ht,getWebGLErrorMessage:ut,getExtensionOrThrow:yt,createVertexShader:Zt,createFragmentShader:ar,createProgram:jr,linkProgram:_r,validateProgram:tr,createStaticVertexBuffer:Fa,createStaticIndexBuffer:Oa,getNumChannels:Tn,createTexture:Wa,validateTextureSize:Na,createFramebuffer:yn,bindVertexBufferToProgramAttribute:Ma,bindTextureUnit:li,unbindTextureUnit:hi,getProgramUniformLocationOrThrow:la,getProgramUniformLocation:rn,bindTextureToProgramUniformSampler:Ca,bindCanvasToFramebuffer:xn,bindColorTextureToFramebuffer:Hn,unbindColorTextureFromFramebuffer:_i,validateFramebuffer:ha,getFramebufferErrorMessage:Ei,getBatchDim:Ua,getRowsCols:ga,getShapeAs3D:wi,getTextureShapeFromLogicalShape:Ta,isReshapeFree:_n,getWebGLMaxTextureSize:ti,resetMaxTextureSize:_a,resetMaxTexturesInShader:Ri,getMaxTexturesInShader:Hi,getWebGLDisjointQueryTimerVersion:Ai,hasExtension:qn,isWebGLVersionEnabled:ri,isCapableOfRenderingToFloatTexture:pi,isDownloadFloatTextureEnabled:pa,isWebGLFenceEnabled:Va,assertNotComplex:ln},gr=i.env();gr.registerFlag("HAS_WEBGL",function(){return gr.getNumber("WEBGL_VERSION")>0}),gr.registerFlag("WEBGL_VERSION",function(){return ri(2)?2:ri(1)?1:0}),gr.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",function(){return!1}),gr.registerFlag("WEBGL_BUFFER_SUPPORTED",function(){return gr.get("WEBGL_VERSION")===2}),gr.registerFlag("WEBGL_CPU_FORWARD",function(){return!0}),gr.registerFlag("WEBGL_FORCE_F16_TEXTURES",function(){return!1}),gr.registerFlag("WEBGL_PACK",function(){return gr.getBool("HAS_WEBGL")}),gr.registerFlag("WEBGL_PACK_NORMALIZATION",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_CLIP",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_DEPTHWISECONV",function(){return!1}),gr.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_PACK_REDUCE",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_LAZILY_UNPACK",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_CONV_IM2COL",function(){return gr.getBool("WEBGL_PACK")}),gr.registerFlag("WEBGL_MAX_TEXTURE_SIZE",function(){return ti(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",function(){return Hi(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",function(){var f=gr.getNumber("WEBGL_VERSION");return f===0?0:Ai(f)}),gr.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",function(){return gr.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!i.device_util.isMobile()}),gr.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",function(){return pi(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",function(){return gr.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:gr.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")}),gr.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",function(){return pa(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_FENCE_API_ENABLED",function(){return Va(gr.getNumber("WEBGL_VERSION"))}),gr.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",function(){var f=gr.getBool("WEBGL_RENDER_FLOAT32_ENABLED");return f?4:0}),gr.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",function(){return-1},function(f){if(f<0&&f!==-1)throw new Error("WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never "+("delete) or at least 0, but got "+f+"."))});function Di(f){const p=new Float32Array(f.length);for(let l=0;l{const R=i.backend_util.assertAndGetBroadcastShape(p,l),z=R.length,L=i.util.computeStrides(R),G=i.util.sizeFromShape(R),Z=i.util.getTypedArrayFromDType(I,G),be=p.length,Ce=l.length,De=i.util.computeStrides(p),Te=i.util.computeStrides(l),Ge=i.backend_util.getBroadcastDims(p,R),Ze=i.backend_util.getBroadcastDims(l,R);if(Ge.length+Ze.length===0)for(let s=0;sr[T]=0);const o=i.util.locToIndex(r,be,De),h=u.slice(-Ce);Ze.forEach(T=>h[T]=0);const b=i.util.locToIndex(h,Ce,Te);Z[s]=f(m[o],g[b])}return[Z,R]}}const ro=bi((f,p)=>f+p);function Zn(f){return(p,l,m)=>{const g=i.util.getTypedArrayFromDType(l,p.length);for(let I=0;IMath.ceil(f)),Fi=Zn(f=>Math.exp(f)),ji=Zn(f=>Math.expm1(f)),Oi=Zn(f=>Math.floor(f)),da=Zn(f=>Math.log(f));function Mi(f,p,l,m){const g=i.util.getTypedArrayFromDType(m,i.util.sizeFromShape(l));for(let I=0;Iz&&(z=G)}g[I]=z}return g}const pe=bi((f,p)=>f*p),X=Zn(f=>1/Math.sqrt(f));function j(f,p,l,m,g){const I=i.slice_util.isSliceContinous(m,p,l),R=i.util.sizeFromShape(l),z=i.util.computeStrides(m);if(I){const G=i.slice_util.computeFlatOffset(p,z);return f.subarray(G,G+R)}const L=i.util.getTypedArrayFromDType(g,R);for(let G=0;GGe+p[Ze]),Te=i.util.locToIndex(De,m.length,z);L[G]=f[Te]}return L}const re=bi((f,p)=>f-p);function te(f,p,l,m,g){const I=p.length,R=i.util.sizeFromShape(p),z=i.util.computeStrides(p),L=i.util.computeStrides(g),G=i.util.getTypedArrayFromDType(l,i.util.sizeFromShape(g));for(let Z=0;Z{for(let Ze=0;Ze":"<",L=m?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=` void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; int outIdx = coords[1]; int inOffset = outIdx * `+g+`; int bestIndex = inOffset; float bestValue = getA(batch, bestIndex); for (int i = 0; i < `+g+`; i++) { int inIdx = `+L+`; float candidate = getA(batch, inIdx); if (candidate `+z+` bestValue) { bestValue = candidate; bestIndex = inIdx; } } setOutput(float(bestIndex)); } `}return f}();function Jr(f,p){return["x","y","z","w","u","v"].slice(0,p).map(function(l){return f+"."+l})}function Vr(f,p){return p===1?[f]:Jr(f,p)}function Jn(f,p){if(f===1)return"rc";for(var l="",m=0;m 0.0 || val < 0.0) ? false : val != 0.0; } bvec4 isnan_custom(vec4 val) { return bvec4(isnan_custom(val.x), isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w)); } #define isnan(value) isnan_custom(value) `,L="",G=` #define round(value) newRound(value) int newRound(float value) { return int(floor(value + 0.5)); } ivec4 newRound(vec4 value) { return ivec4(floor(value + vec4(0.5))); } `):(f="",p="attribute",l="varying",m="varying",g="texture2D",I="gl_FragColor",R="",z=` #define isnan(value) isnan_custom(value) bool isnan_custom(float val) { return (val > 0. || val < 1. || val == 0.) ? false : true; } bvec4 isnan_custom(vec4 val) { return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w)); } `,L=` uniform float INFINITY; bool isinf(float val) { return abs(val) == INFINITY; } bvec4 isinf(vec4 val) { return equal(abs(val), vec4(INFINITY)); } `,G=` int round(float value) { return int(floor(value + 0.5)); } ivec4 round(vec4 value) { return ivec4(floor(value + vec4(0.5))); } `),{version:f,attribute:p,varyingVs:l,varyingFs:m,texture2D:g,output:I,defineOutput:R,defineSpecialNaN:z,defineSpecialInf:L,defineRound:G}}function Rn(f,p,l){l===void 0&&(l="index");var m=i.util.computeStrides(p);return m.map(function(g,I){var R="int "+f[I]+" = "+l+" / "+g,z=I===m.length-1?"int "+f[I+1]+" = "+l+" - "+f[I]+" * "+g:"index -= "+f[I]+" * "+g;return R+"; "+z+";"}).join("")}function Kn(f){var p=i.util.computeStrides(f).map(function(l){return l.toString()});return` int getFlatIndex(ivec3 coords) { return coords.x * `+p[0]+" + coords.y * "+p[1]+` + coords.z; } `}var aa=` const float FLOAT_MAX = 1.70141184e38; const float FLOAT_MIN = 1.17549435e-38; lowp vec4 encode_float(highp float v) { if (isnan(v)) { return vec4(255, 255, 255, 255); } highp float av = abs(v); if(av < FLOAT_MIN) { return vec4(0.0, 0.0, 0.0, 0.0); } else if(v > FLOAT_MAX) { return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; } else if(v < -FLOAT_MAX) { return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; } highp vec4 c = vec4(0,0,0,0); highp float e = floor(log2(av)); highp float m = exp2(fract(log2(av))) - 1.0; c[2] = floor(128.0 * m); m -= c[2] / 128.0; c[1] = floor(32768.0 * m); m -= c[1] / 32768.0; c[0] = floor(8388608.0 * m); highp float ebias = e + 127.0; c[3] = floor(ebias / 2.0); ebias -= c[3] * 2.0; c[2] += floor(ebias) * 128.0; c[3] += 128.0 * step(0.0, -v); return c / 255.0; } `,ma=i.backend_util.getBroadcastDims;function Li(f,p,l,m){var g=[];f.forEach(function(Te){var Ge=i.util.sizeFromShape(Te.shapeInfo.logicalShape);Te.shapeInfo.isUniform?g.push("uniform float "+Te.name+(Ge>1?"["+Ge+"]":"")+";"):(g.push("uniform sampler2D "+Te.name+";"),g.push("uniform int offset"+Te.name+";"))});var I=g.join(` `),R=f.map(function(Te){return x(Te,p,m)}).join(` `),z=p.texShape,L=tn(),G=Se(L),Z,be,Ce=Be(L);p.isPacked?(Z=k(p.logicalShape,z),be=Je(L)):(Z=K(p.logicalShape,z),be=we(L)),m&&(Ce+=Wt);var De=[Ce,G,be,I,Z,R,l].join(` `);return De}function Ea(f){var p=f.shapeInfo.logicalShape;switch(p.length){case 0:return $r(f);case 1:return mi(f);case 2:return ja(f);case 3:return zi(f);case 4:return ba(f);case 5:return qi(f);case 6:return yi(f);default:throw new Error(p.length+"-D input sampling is not yet supported")}}function S(f){var p=f.shapeInfo.logicalShape;switch(p.length){case 0:return ur(f);case 1:return Ra(f);case 2:return Ga(f);case 3:return ai(f);default:return An(f)}}function x(f,p,l){l===void 0&&(l=!1);var m="";l?m+=S(f):m+=Ea(f);var g=f.shapeInfo.logicalShape,I=p.logicalShape;return g.length<=I.length&&(l?m+=qr(f,p):m+=Io(f,p)),m}function k(f,p){switch(f.length){case 0:return Gt();case 1:return Qt(f,p);case 2:return Fr(f,p);case 3:return Ar(f,p);default:return xr(f,p)}}function K(f,p){switch(f.length){case 0:return Gt();case 1:return wr(f,p);case 2:return wa(f,p);case 3:return Yt(f,p);case 4:return Sn(f,p);case 5:return pn(f,p);case 6:return zn(f,p);default:throw new Error(f.length+"-D output sampling is not yet supported")}}function Se(f){return` float sampleTexture(sampler2D textureSampler, vec2 uv) { return `+f.texture2D+`(textureSampler, uv).r; } `}function we(f){return` void setOutput(float val) { `+f.output+` = vec4(val, 0, 0, 0); } `}function Je(f){return` void setOutput(vec4 val) { `+f.output+` = val; } `}function Be(f){var p=f.version+` precision highp float; precision highp int; precision highp sampler2D; `+f.varyingFs+` vec2 resultUV; `+f.defineOutput+` const vec2 halfCR = vec2(0.5, 0.5); struct ivec5 { int x; int y; int z; int w; int u; }; struct ivec6 { int x; int y; int z; int w; int u; int v; }; uniform float NAN; `+f.defineSpecialNaN+` `+f.defineSpecialInf+` `+f.defineRound+` int imod(int x, int y) { return x - y * (x / y); } int idiv(int a, int b, float sign) { int res = a / b; int mod = imod(a, b); if (sign < 0. && mod != 0) { res -= 1; } return res; } //Based on the work of Dave Hoskins //https://www.shadertoy.com/view/4djSRW #define HASHSCALE1 443.8975 float random(float seed){ vec2 p = resultUV * seed; vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1); p3 += dot(p3, p3.yzx + 19.19); return fract((p3.x + p3.y) * p3.z); } `+vt+` `+ft+` `+zt+` `;return p}var vt=` vec2 uvFromFlat(int texNumR, int texNumC, int index) { int texR = index / texNumC; int texC = index - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { int texelIndex = index / 2; int texR = texelIndex / texNumC; int texC = texelIndex - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } `,ft=` vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR, int texNumC, int row, int col) { int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); int texR = texelIndex / texNumC; int texC = texelIndex - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } `,zt=` vec2 packedUVfrom3D(int texNumR, int texNumC, int texelsInBatch, int texelsInLogicalRow, int b, int row, int col) { int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); int texR = index / texNumC; int texC = index - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } `,Wt=` float getChannel(vec4 frag, vec2 innerDims) { vec2 modCoord = mod(innerDims, 2.); return modCoord.x == 0. ? (modCoord.y == 0. ? frag.r : frag.g) : (modCoord.y == 0. ? frag.b : frag.a); } float getChannel(vec4 frag, int dim) { float modCoord = mod(float(dim), 2.); return modCoord == 0. ? frag.r : frag.g; } `;function Gt(){return` int getOutputCoords() { return 0; } `}function Qt(f,p){var l=[Math.ceil(p[0]/2),Math.ceil(p[1]/2)];return l[0]===1?` int getOutputCoords() { return 2 * int(resultUV.x * `+l[1]+`.0); } `:l[1]===1?` int getOutputCoords() { return 2 * int(resultUV.y * `+l[0]+`.0); } `:` int getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+l[0]+", "+l[1]+`)); return 2 * (resTexRC.x * `+l[1]+` + resTexRC.y); } `}function wr(f,p){return p[0]===1?` int getOutputCoords() { return int(resultUV.x * `+p[1]+`.0); } `:p[1]===1?` int getOutputCoords() { return int(resultUV.y * `+p[0]+`.0); } `:` int getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+p[0]+", "+p[1]+`)); return resTexRC.x * `+p[1]+` + resTexRC.y; } `}function Ar(f,p){var l=[Math.ceil(p[0]/2),Math.ceil(p[1]/2)],m=Math.ceil(f[2]/2),g=m*Math.ceil(f[1]/2);return` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+l[0]+", "+l[1]+`)); int index = resTexRC.x * `+l[1]+` + resTexRC.y; int b = index / `+g+`; index -= b * `+g+`; int r = 2 * (index / `+m+`); int c = imod(index, `+m+`) * 2; return ivec3(b, r, c); } `}function Yt(f,p){var l=Rn(["r","c","d"],f);return` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+p[0]+", "+p[1]+`)); int index = resTexRC.x * `+p[1]+` + resTexRC.y; `+l+` return ivec3(r, c, d); } `}function xr(f,p){for(var l=[Math.ceil(p[0]/2),Math.ceil(p[1]/2)],m=Math.ceil(f[f.length-1]/2),g=m*Math.ceil(f[f.length-2]/2),I=g,R="",z="b, r, c",L=2;L=1?Z="coords = 0;":Z=z.map(function(o){return"coords."+be[o+G]+" = 0;"}).join(` `);var Ce="";R<2&&I>0?Ce="coords":Ce=f.shapeInfo.logicalShape.map(function(o,h){return"coords."+be[h+G]}).join(", ");var De="return outputValue;",Te=i.util.sizeFromShape(f.shapeInfo.logicalShape),Ge=Te===1,Ze=i.util.sizeFromShape(p.logicalShape),s=Ze===1;if(I===1&&!Ge&&!s)De=` return vec4(outputValue.xy, outputValue.xy); `;else if(Ge&&!s)R===1?De=` return vec4(outputValue.x, outputValue.x, 0., 0.); `:De=` return vec4(outputValue.x); `;else if(z.length){var u=I-2,r=I-1;z.indexOf(u)>-1&&z.indexOf(r)>-1?De="return vec4(outputValue.x);":z.indexOf(u)>-1?De="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":z.indexOf(r)>-1&&(De="return vec4(outputValue.xx, outputValue.zz);")}return` vec4 `+g+`() { `+L+` coords = getOutputCoords(); `+Z+` vec4 outputValue = get`+m+"("+Ce+`); `+De+` } `}function Io(f,p){var l=f.name,m=l.charAt(0).toUpperCase()+l.slice(1),g="get"+m+"AtOutCoords",I=p.texShape,R=f.shapeInfo.texShape,z=f.shapeInfo.logicalShape.length,L=p.logicalShape.length;if(!f.shapeInfo.isUniform&&z===L&&f.shapeInfo.flatOffset==null&&i.util.arraysEqual(R,I))return` float `+g+`() { return sampleTexture(`+l+`, resultUV); } `;var G=nn(L),Z=ma(f.shapeInfo.logicalShape,p.logicalShape),be=L-z,Ce,De=["x","y","z","w","u","v"];z===0?Ce="":L<2&&Z.length>=1?Ce="coords = 0;":Ce=Z.map(function(Ge){return"coords."+De[Ge+be]+" = 0;"}).join(` `);var Te="";return L<2&&z>0?Te="coords":Te=f.shapeInfo.logicalShape.map(function(Ge,Ze){return"coords."+De[Ze+be]}).join(", "),` float `+g+`() { `+G+` coords = getOutputCoords(); `+Ce+` return get`+m+"("+Te+`); } `}function nn(f){if(f<=1)return"int";if(f===2)return"ivec2";if(f===3)return"ivec3";if(f===4)return"ivec4";if(f===5)return"ivec5";if(f===6)return"ivec6";throw Error("GPU for rank "+f+" is not yet supported")}function qa(f,p){var l=JSON.parse(JSON.stringify(f));return l.shapeInfo.logicalShape=p,l}function La(f,p){return p.map(function(l){return f[l]}).join(", ")}var Ki=function(){function f(p,l,m,g){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,i.util.assert(p.length>2,function(){return"Packed arg"+(m.charAt(0).toUpperCase()+m.slice(1))+" supports only inputs with rank above 2."});var I=p[p.length-1],R=Math.ceil(I/l);this.outputShape=p.slice(0,-1),R>1&&this.outputShape.push(R),g||this.variableNames.push("bestIndicesA");var z=this.outputShape,L=z.length,G=nn(L),Z=Vr("coords",L),be,Ce;if(R===1){Ce=L+1;var De=nn(Ce);be=` `+De+" sourceLocR = "+De+"("+Z.join()+`, 0); ++`+Z[L-1]+`; `+De+" sourceLocG = "+De+"("+Z.join()+`, 0); ++`+Z[L-2]+`; `+De+" sourceLocA = "+De+"("+Z.join()+`, 0); --`+Z[L-1]+`; `+De+" sourceLocB = "+De+"("+Z.join()+`, 0); --`+Z[L-2]+";"}else Ce=L,be=` `+G+` sourceLocR = coords; ++`+Z[L-1]+`; `+G+` sourceLocG = coords; ++`+Z[L-2]+`; `+G+` sourceLocA = coords; --`+Z[L-1]+`; `+G+` sourceLocB = coords; --`+Z[L-2]+";";var Te=["x","y","z","w","u","v"].slice(0,Ce),Ge="."+Te[Ce-1],Ze=Te.map(function(q){return"int "+q}),s=Vr("sourceLocR",Ce-1).concat("inIdx.r"),u=Vr("sourceLocG",Ce-1).concat("inIdx.g"),r=Vr("sourceLocB",Ce-1).concat("inIdx.b"),o=Vr("sourceLocA",Ce-1).concat("inIdx.a"),h=m==="max"?"greaterThan":"lessThan",b=g?"":` inIdx = round(vec4(getBestIndicesAChannel(`+s.join()+`), getBestIndicesAChannel(`+u.join()+`), getBestIndicesAChannel(`+r.join()+`), getBestIndicesAChannel(`+o.join()+")));",T=`vec4( getAChannel(`+s.join()+`), hasNextCol ? getAChannel(`+u.join()+`) : 0., hasNextRow ? getAChannel(`+r.join()+`) : 0., hasNextRow && hasNextCol ? getAChannel(`+o.join()+") : 0.)",M=g?"":` float getBestIndicesAChannel(`+Ze.join()+`) { return getChannel(getBestIndicesA(`+Te.join()+`), vec2(`+Te.slice(-2).join()+`)); }`;this.userCode=` float getAChannel(`+Ze.join()+`) { return getChannel(getA(`+Te.join()+`), vec2(`+Te.slice(-2).join()+`)); } `+M+` void main() { `+G+` coords = getOutputCoords(); bool hasNextCol = `+Z[L-1]+" < "+(z[L-1]-1)+`; bool hasNextRow = `+Z[L-2]+" < "+(z[L-2]-1)+`; `+be+` ivec4 srcIdx = ivec4(sourceLocR`+Ge+", sourceLocG"+Ge+`, sourceLocB`+Ge+", sourceLocA"+Ge+") * "+l+`; ivec4 inIdx = srcIdx; vec4 bestIndex = vec4(inIdx); vec4 bestValue = `+T+`; for (int i = 0; i < `+l+`; i++) { inIdx = srcIdx; `+b+` vec4 candidate = `+T+`; bvec4 nan = isnan(candidate); bvec4 replace = bvec4( vec4(`+h+`(candidate, bestValue)) * (vec4(1.0) - vec4(nan))); bestValue = vec4(replace.x ? candidate.x : bestValue.x, replace.y ? candidate.y : bestValue.y, replace.z ? candidate.z : bestValue.z, replace.w ? candidate.w : bestValue.w); bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace)); srcIdx++; } setOutput(bestIndex); } `}return f}(),oi=function(){function f(p){this.variableNames=["dy"],this.outputShape=p.inShape;var l=p.filterHeight,m=p.filterWidth,g=p.strideHeight,I=p.strideWidth,R=p.dilationHeight,z=p.dilationWidth,L=p.effectiveFilterHeight,G=p.effectiveFilterWidth,Z=L-1-p.padInfo.top,be=G-1-p.padInfo.left,Ce=1/(l*m);this.userCode=` const ivec2 pads = ivec2(`+Z+", "+be+`); const float avgMultiplier = float(`+Ce+`); void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int d = coords[3]; ivec2 dyRCCorner = coords.yz - pads; int dyRCorner = dyRCCorner.x; int dyCCorner = dyRCCorner.y; // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). // ? = to be determined. : = across all values in that axis. float dotProd = 0.0; for (int wR = 0; wR < `+L+`; wR += `+R+`) { float dyR = float(dyRCorner + wR) / `+g+`.0; if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); for (int wC = 0; wC < `+G+`; wC+= `+z+`) { float dyC = float(dyCCorner + wC) / `+I+`.0; if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); float dyValue = getDy(b, idyR, idyC, d); dotProd += dyValue * avgMultiplier; } } setOutput(dotProd); } `}return f}(),Pi=function(){function f(p){this.variableNames=["dy"],this.outputShape=p.inShape;var l=p.filterDepth,m=p.filterHeight,g=p.filterWidth,I=p.strideDepth,R=p.strideHeight,z=p.strideWidth,L=p.dilationDepth,G=p.dilationHeight,Z=p.dilationWidth,be=p.effectiveFilterDepth,Ce=p.effectiveFilterHeight,De=p.effectiveFilterWidth,Te=be-1-p.padInfo.front,Ge=Ce-1-p.padInfo.top,Ze=De-1-p.padInfo.left,s=1/(l*m*g);this.userCode=` const ivec3 pads = ivec3(`+Te+", "+Ge+", "+Ze+`); const float avgMultiplier = float(`+s+`); void main() { ivec5 coords = getOutputCoords(); int batch = coords.x; int ch = coords.u; ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; int dyDCorner = dyCorner.x; int dyRCorner = dyCorner.y; int dyCCorner = dyCorner.z; // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get // dx(xD, xR, xC, ch). // ? = to be determined. : = across all values in that axis. float dotProd = 0.0; for (int wD = 0; wD < `+be+`; wD += `+L+`) { float dyD = float(dyDCorner + wD) / `+I+`.0; if (dyD < 0.0 || dyD >= `+p.outDepth+`.0 || fract(dyD) > 0.0) { continue; } int idyD = int(dyD); for (int wR = 0; wR < `+Ce+`; wR += `+G+`) { float dyR = float(dyRCorner + wR) / `+R+`.0; if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); for (int wC = 0; wC < `+De+`; wC += `+Z+`) { float dyC = float(dyCCorner + wC) / `+z+`.0; if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); float dyValue = getDy(batch, idyD, idyR, idyC, ch); dotProd += dyValue * avgMultiplier; } } } setOutput(dotProd); } `}return f}(),no=` if (isnan(a)) return a; if (isnan(b)) return b; `,mo=` float s = sign(a) * sign(b); int ia = round(a); int ib = round(b); if (ib != 0) { // Windows (D3D) wants guaranteed non-zero int division at compile-time. return float(idiv(ia, ib, s)); } else { return NAN; } `,Ka=` if(a < 0.0 && floor(b) < b){ return NAN; } if (b == 0.0) { return 1.0; } return (round(mod(b, 2.0)) != 1) ? pow(abs(a), b) : sign(a) * pow(abs(a), b); `,ao="return float(a == b);",Ko="return float(a < b);",No="return float(a <= b);",Co="return float(a > b);",io="return float(a >= b);",ia="return float(a >= 1.0 && b >= 1.0);",Pr="return float(a >= 1.0 || b >= 1.0);",oa=no+` return max(a, b); `,Xa=no+` return min(a, b); `,Qn=`if (b == 0.0) return NAN; return mod(a, b);`,oo="return (b >= 1.0) ? a : a * (b + 1.0);",ka="return (a < 0.) ? b * a : a;",vn=function(){function f(p,l,m){this.variableNames=["A","B"],this.outputShape=i.backend_util.assertAndGetBroadcastShape(l,m),this.userCode=` float binaryOperation(float a, float b) { `+p+` } void main() { float a = getAAtOutCoords(); float b = getBAtOutCoords(); setOutput(binaryOperation(a, b)); } `}return f}(),Bi=` result.r = isNaN.r > 0. ? NAN : result.r; result.g = isNaN.g > 0. ? NAN : result.g; result.b = isNaN.b > 0. ? NAN : result.b; result.a = isNaN.a > 0. ? NAN : result.a; `,yo=` ivec4 ia = round(a); ivec4 ib = round(b); bvec4 cond = notEqual(ib, ivec4(0)); ivec4 result = ivec4(0); vec4 s = sign(a) * sign(b); // Windows (D3D) wants guaranteed non-zero int division at compile-time. if (cond[0]) { result[0] = idiv(ia[0], ib[0], s[0]); } if (cond[1]) { result[1] = idiv(ia[1], ib[1], s[1]); } if (cond[2]) { result[2] = idiv(ia[2], ib[2], s[2]); } if (cond[3]) { result[3] = idiv(ia[3], ib[3], s[3]); } return vec4(result); `,vo=` // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise. vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1))); vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); vec4 result = multiplier * pow(abs(a), b); // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS bvec4 isExpZero = equal(b, vec4(0.0)); result.r = isExpZero.r ? 1.0 : result.r; result.g = isExpZero.g ? 1.0 : result.g; result.b = isExpZero.b ? 1.0 : result.b; result.a = isExpZero.a ? 1.0 : result.a; vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b)); `+Bi+` return result; `,Aa=` vec4 aLessThanZero = vec4(lessThan(a, vec4(0.))); return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); `,go=` vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.))); return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); `,To=` return vec4(equal(a, b)); `,Rs=` return vec4(lessThan(a, b)); `,Eo=` return vec4(lessThanEqual(a, b)); `,As=` return vec4(greaterThan(a, b)); `,Ds=` return vec4(greaterThanEqual(a, b)); `,Xo=` return vec4( vec4(greaterThanEqual(a, vec4(1.0))) * vec4(greaterThanEqual(b, vec4(1.0)))); `,Ro=` return min( vec4(greaterThanEqual(a, vec4(1.0))) + vec4(greaterThanEqual(b, vec4(1.0))), vec4(1.0)); `,Yo=` vec4 result = vec4(max(a, b)); vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0)); `+Bi+` return result; `,Ao=` vec4 result = vec4(min(a, b)); vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0)); `+Bi+` return result; `,Qo=` vec4 result = mod(a, b); vec4 isNaN = vec4(equal(b, vec4(0.0))); `+Bi+` return result; `,vi=function(){function f(p,l,m,g){g===void 0&&(g=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i.backend_util.assertAndGetBroadcastShape(l,m);var I=this.outputShape.length,R="";if(g)if(I===0||i.util.sizeFromShape(this.outputShape)===1)R=` result.y = 0.; result.z = 0.; result.w = 0.; `;else{var z=nn(I);if(R=` `+z+` coords = getOutputCoords(); `,I===1)R+=` result.y = (coords + 1) >= `+this.outputShape[0]+` ? 0. : result.y; result.z = 0.; result.w = 0.; `;else{var L=Vr("coords",I);R+=` bool nextRowOutOfBounds = (`+L[I-2]+" + 1) >= "+this.outputShape[I-2]+`; bool nextColOutOfBounds = (`+L[I-1]+" + 1) >= "+this.outputShape[I-1]+`; result.y = nextColOutOfBounds ? 0. : result.y; result.z = nextRowOutOfBounds ? 0. : result.z; result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; `}}this.userCode=` vec4 binaryOperation(vec4 a, vec4 b) { `+p+` } void main() { vec4 a = getAAtOutCoords(); vec4 b = getBAtOutCoords(); vec4 result = binaryOperation(a, b); `+R+` setOutput(result); } `}return f}(),Fs=function(){function f(p){this.variableNames=["A"],this.outputShape=p,this.userCode=` uniform float minVal; uniform float maxVal; void main() { float value = getAAtOutCoords(); if (isnan(value)) { setOutput(value); return; } setOutput(clamp(value, minVal, maxVal)); } `}return f.prototype.getCustomSetupFunc=function(p,l){var m=this;return function(g,I){m.minLoc==null&&(m.minLoc=g.getUniformLocationNoThrow(I,"minVal"),m.maxLoc=g.getUniformLocationNoThrow(I,"maxVal")),g.gl.uniform1f(m.minLoc,p),g.gl.uniform1f(m.maxLoc,l)}},f}(),tu=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p,this.userCode=` uniform float minVal; uniform float maxVal; void main() { vec4 value = getAAtOutCoords(); if (any(isnan(value))) { setOutput(value); return; } setOutput(clamp(value, vec4(minVal), vec4(maxVal))); } `}return f.prototype.getCustomSetupFunc=function(p,l){var m=this;return function(g,I){m.minLoc==null&&(m.minLoc=g.getUniformLocationNoThrow(I,"minVal"),m.maxLoc=g.getUniformLocationNoThrow(I,"maxVal")),g.gl.uniform1f(m.minLoc,p),g.gl.uniform1f(m.maxLoc,l)}},f}(),ps=function(){function f(p){this.variableNames=["real","imag"],this.outputShape=p,this.userCode=` void main() { float re = abs(getRealAtOutCoords()); float im = abs(getImagAtOutCoords()); float mx = max(re, im); // sadly the length function in glsl is not underflow-safe // (at least not on Intel GPUs). So the safe solution is // to ensure underflow-safety in all cases. setOutput( mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx)) ); } `}return f}(),ru=function(){function f(p){this.variableNames=["x","dy"],this.outputShape=p.filterShape;var l=p.strideHeight,m=p.strideWidth,g=p.padInfo.top,I=p.padInfo.left,R=p.dataFormat==="channelsLast";this.userCode=` void main() { ivec4 coords = getOutputCoords(); int wR = coords.x; int wC = coords.y; int d1 = coords.z; int d2 = coords.w; // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2). // ? = to be determined. : = across all values in that axis. float dotProd = 0.0; for (int b = 0; b < `+p.batchSize+`; b++) { for (int yR = 0; yR < `+p.outHeight+`; yR++) { int xR = wR + yR * `+l+" - "+g+`; if (xR < 0 || xR >= `+p.inHeight+`) { continue; } for (int yC = 0; yC < `+p.outWidth+`; yC++) { int xC = wC + yC * `+m+" - "+I+`; if (xC < 0 || xC >= `+p.inWidth+`) { continue; } if (`+R+`) { float dyValue = getDy(b, yR, yC, d2); float xValue = getX(b, xR, xC, d1); dotProd += (xValue * dyValue); } else { float dyValue = getDy(b, d2, yR, yC); float xValue = getX(b, d1, xR, xC); dotProd += (xValue * dyValue); } } } } setOutput(dotProd); } `}return f}(),Os=function(){function f(p){this.variableNames=["dy","W"],this.outputShape=p.inShape;var l=p.filterHeight,m=p.filterWidth,g=p.strideHeight,I=p.strideWidth,R=p.dataFormat==="channelsLast",z=l-1-p.padInfo.top,L=m-1-p.padInfo.left,G=R?1:2,Z=R?2:3,be=R?3:1;this.userCode=` const ivec2 pads = ivec2(`+z+", "+L+`); void main() { ivec4 coords = getOutputCoords(); int batch = coords[0]; int d1 = coords[`+be+`]; ivec2 dyCorner = ivec2(coords[`+G+"], coords["+Z+`]) - pads; int dyRCorner = dyCorner.x; int dyCCorner = dyCorner.y; // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1). // ? = to be determined. : = across all values in that axis. float dotProd = 0.0; for (int wR = 0; wR < `+l+`; wR++) { float dyR = float(dyRCorner + wR) / `+g+`.0; if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); int wRPerm = `+l+` - 1 - wR; for (int wC = 0; wC < `+m+`; wC++) { float dyC = float(dyCCorner + wC) / `+I+`.0; if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); int wCPerm = `+m+` - 1 - wC; for (int d2 = 0; d2 < `+p.outChannels+`; d2++) { if (`+R+`) { float xValue = getDy(batch, idyR, idyC, d2); float wValue = getW(wRPerm, wCPerm, d1, d2); dotProd += xValue * wValue; } else { float xValue = getDy(batch, d2, idyR, idyC); float wValue = getW(wRPerm, wCPerm, d1, d2); dotProd += xValue * wValue; } } } } setOutput(dotProd); } `}return f}(),ds=function(){function f(p){this.variableNames=["x","dy"],this.outputShape=p.filterShape;var l=p.strideDepth,m=p.strideHeight,g=p.strideWidth,I=p.padInfo.front,R=p.padInfo.top,z=p.padInfo.left;this.userCode=` void main() { ivec5 coords = getOutputCoords(); int wF = coords.x; int wR = coords.y; int wC = coords.z; int d1 = coords.w; int d2 = coords.u; float dotProd = 0.0; for (int b = 0; b < `+p.batchSize+`; b++) { for (int yF = 0; yF < `+p.outDepth+`; yF++) { int xF = wF + yF * `+l+" - "+I+`; if (xF < 0 || xF >= `+p.inDepth+`) { continue; } for (int yR = 0; yR < `+p.outHeight+`; yR++) { int xR = wR + yR * `+m+" - "+R+`; if (xR < 0 || xR >= `+p.inHeight+`) { continue; } for (int yC = 0; yC < `+p.outWidth+`; yC++) { int xC = wC + yC * `+g+" - "+z+`; if (xC < 0 || xC >= `+p.inWidth+`) { continue; } float dyValue = getDy(b, yF, yR, yC, d2); float xValue = getX(b, xF, xR, xC, d1); dotProd += (xValue * dyValue); } } } } setOutput(dotProd); } `}return f}(),Ms=function(){function f(p){this.variableNames=["dy","W"],this.outputShape=p.inShape;var l=p.filterDepth,m=p.filterHeight,g=p.filterWidth,I=p.strideDepth,R=p.strideHeight,z=p.strideWidth,L=l-1-p.padInfo.front,G=m-1-p.padInfo.top,Z=g-1-p.padInfo.left;this.userCode=` const ivec3 pads = ivec3(`+L+", "+G+", "+Z+`); void main() { ivec5 coords = getOutputCoords(); int batch = coords.x; int d1 = coords.u; ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; int dyFCorner = dyCorner.x; int dyRCorner = dyCorner.y; int dyCCorner = dyCorner.z; float dotProd = 0.0; for (int wF = 0; wF < `+l+`; wF++) { float dyF = float(dyFCorner + wF) / `+I+`.0; if (dyF < 0.0 || dyF >= `+p.outDepth+`.0 || fract(dyF) > 0.0) { continue; } int idyF = int(dyF); int wFPerm = `+l+` - 1 - wF; for (int wR = 0; wR < `+m+`; wR++) { float dyR = float(dyRCorner + wR) / `+R+`.0; if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); int wRPerm = `+m+` - 1 - wR; for (int wC = 0; wC < `+g+`; wC++) { float dyC = float(dyCCorner + wC) / `+z+`.0; if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); int wCPerm = `+g+` - 1 - wC; for (int d2 = 0; d2 < `+p.outChannels+`; d2++) { float xValue = getDy(batch, idyF, idyR, idyC, d2); float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2); dotProd += xValue * wValue; } } } } setOutput(dotProd); } `}return f}(),Ls=function(){function f(p){this.variableNames=["x","dy"],this.outputShape=p.filterShape;var l=p.strideHeight,m=p.strideWidth,g=p.padInfo.top,I=p.padInfo.left,R=p.outChannels/p.inChannels;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int wR = coords.x; int wC = coords.y; int d1 = coords.z; int dm = coords.w; int d2 = d1 * `+R+` + dm; float dotProd = 0.0; // TO DO: Vec4 over the batch size for (int b = 0; b < `+p.batchSize+`; b++) { for (int yR = 0; yR < `+p.outHeight+`; yR++) { int xR = wR + yR * `+l+" - "+g+`; if (xR < 0 || xR >= `+p.inHeight+`) { continue; } for (int yC = 0; yC < `+p.outWidth+`; yC++) { int xC = wC + yC * `+m+" - "+I+`; if (xC < 0 || xC >= `+p.inWidth+`) { continue; } float dyValue = getDy(b, yR, yC, d2); float xValue = getX(b, xR, xC, d1); dotProd += (xValue * dyValue); } } } setOutput(dotProd); } `}return f}(),nu=function(){function f(p){this.variableNames=["dy","W"],this.outputShape=p.inShape;var l=p.filterHeight,m=p.filterWidth,g=p.strideHeight,I=p.strideWidth,R=l-1-p.padInfo.top,z=m-1-p.padInfo.left,L=p.outChannels/p.inChannels;this.userCode=` const ivec2 pads = ivec2(`+R+", "+z+`); void main() { ivec4 coords = getOutputCoords(); int batch = coords[0]; int d1 = coords[3]; ivec2 dyCorner = coords.yz - pads; int dyRCorner = dyCorner.x; int dyCCorner = dyCorner.y; float dotProd = 0.0; for (int wR = 0; wR < `+l+`; wR++) { float dyR = float(dyRCorner + wR) / `+g+`.0; if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); int wRPerm = `+l+` - 1 - wR; for (int wC = 0; wC < `+m+`; wC++) { float dyC = float(dyCCorner + wC) / `+I+`.0; if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); int wCPerm = `+m+` - 1 - wC; // TO DO: Vec4 over the channelMul for (int dm = 0; dm < `+L+`; dm++) { int d2 = d1 * `+L+` + dm; float xValue = getDy(batch, idyR, idyC, d2); float wValue = getW(wRPerm, wCPerm, d1, dm); dotProd += xValue * wValue; } } } setOutput(dotProd); } `}return f}(),fs=function(){function f(p,l,m,g){l===void 0&&(l=!1),m===void 0&&(m=null),g===void 0&&(g=!1),this.variableNames=["x","W"],this.outputShape=p.outShape;var I=p.padInfo.top,R=p.padInfo.left,z=p.strideHeight,L=p.strideWidth,G=p.dilationHeight,Z=p.dilationWidth,be=p.filterHeight,Ce=p.filterWidth,De=Math.floor(p.inChannels/4)*4,Te=p.inChannels%4,Ge=p.dataFormat==="channelsLast",Ze=Ge?1:2,s=Ge?2:3,u=Ge?3:1,r="",o="";m&&(g?r=`float activation(float a) { float b = getPreluActivationWeightsAtOutCoords(); `+m+` }`:r=` float activation(float x) { `+m+` } `,o="result = activation(result);");var h=l?"result += getBiasAtOutCoords();":"";l&&this.variableNames.push("bias"),g&&this.variableNames.push("preluActivationWeights"),this.userCode=` `+r+` const ivec2 strides = ivec2(`+z+", "+L+`); const ivec2 pads = ivec2(`+I+", "+R+`); void main() { ivec4 coords = getOutputCoords(); int batch = coords[0]; int d2 = coords[`+u+`]; ivec2 xRCCorner = ivec2(coords[`+Ze+"], coords["+s+`]) * strides - pads; int xRCorner = xRCCorner.x; int xCCorner = xRCCorner.y; // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2). // ? = to be determined. : = across all values in that axis. float dotProd = 0.0; for (int wR = 0; wR < `+be+`; wR++) { int xR = xRCorner + wR * `+G+`; if (xR < 0 || xR >= `+p.inHeight+`) { continue; } for (int wC = 0; wC < `+Ce+`; wC++) { int xC = xCCorner + wC * `+Z+`; if (xC < 0 || xC >= `+p.inWidth+`) { continue; } for (int d1 = 0; d1 < `+De+`; d1 += 4) { vec4 wValues = vec4( getW(wR, wC, d1, d2), getW(wR, wC, d1 + 1, d2), getW(wR, wC, d1 + 2, d2), getW(wR, wC, d1 + 3, d2) ); if (`+Ge+`) { vec4 xValues = vec4( getX(batch, xR, xC, d1), getX(batch, xR, xC, d1 + 1), getX(batch, xR, xC, d1 + 2), getX(batch, xR, xC, d1 + 3) ); dotProd += dot(xValues, wValues); } else { vec4 xValues = vec4( getX(batch, d1, xR, xC), getX(batch, d1 + 1, xR, xC), getX(batch, d1 + 2, xR, xC), getX(batch, d1 + 3, xR, xC) ); dotProd += dot(xValues, wValues); } } if (`+(Te===1)+`) { if (`+Ge+`) { dotProd += getX(batch, xR, xC, `+De+`) * getW(wR, wC, `+De+`, d2); } else { dotProd += getX(batch, `+De+`, xR, xC) * getW(wR, wC, `+De+`, d2); } } else if (`+(Te===2)+`) { vec2 wValues = vec2( getW(wR, wC, `+De+`, d2), getW(wR, wC, `+De+` + 1, d2) ); if (`+Ge+`) { vec2 xValues = vec2( getX(batch, xR, xC, `+De+`), getX(batch, xR, xC, `+De+` + 1) ); dotProd += dot(xValues, wValues); } else { vec2 xValues = vec2( getX(batch, `+De+`, xR, xC), getX(batch, `+De+` + 1, xR, xC) ); dotProd += dot(xValues, wValues); } } else if (`+(Te===3)+`) { vec3 wValues = vec3( getW(wR, wC, `+De+`, d2), getW(wR, wC, `+De+` + 1, d2), getW(wR, wC, `+De+` + 2, d2) ); if (`+Ge+`) { vec3 xValues = vec3( getX(batch, xR, xC, `+De+`), getX(batch, xR, xC, `+De+` + 1), getX(batch, xR, xC, `+De+` + 2) ); dotProd += dot(xValues, wValues); } else { vec3 xValues = vec3( getX(batch, `+De+`, xR, xC), getX(batch, `+De+` + 1, xR, xC), getX(batch, `+De+` + 2, xR, xC) ); dotProd += dot(xValues, wValues); } } } } float result = dotProd; `+h+` `+o+` setOutput(result); } `}return f}(),au=function(){function f(p){this.variableNames=["x","W"],this.outputShape=p.outShape;var l=p.padInfo.front,m=p.padInfo.top,g=p.padInfo.left,I=p.strideDepth,R=p.strideHeight,z=p.strideWidth,L=p.dilationDepth,G=p.dilationHeight,Z=p.dilationWidth,be=p.filterDepth,Ce=p.filterHeight,De=p.filterWidth,Te=Math.floor(p.inChannels/4)*4,Ge=p.inChannels%4;this.userCode=` const ivec3 strides = ivec3(`+I+", "+R+", "+z+`); const ivec3 pads = ivec3(`+l+", "+m+", "+g+`); void main() { ivec5 coords = getOutputCoords(); int batch = coords.x; int d2 = coords.u; ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; int xFCorner = xFRCCorner.x; int xRCorner = xFRCCorner.y; int xCCorner = xFRCCorner.z; // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get // y(yF, yR, yC, d2). ? = to be determined. : = across all // values in that axis. float dotProd = 0.0; for (int wF = 0; wF < `+be+`; wF++) { int xF = xFCorner + wF * `+L+`; if (xF < 0 || xF >= `+p.inDepth+`) { continue; } for (int wR = 0; wR < `+Ce+`; wR++) { int xR = xRCorner + wR * `+G+`; if (xR < 0 || xR >= `+p.inHeight+`) { continue; } for (int wC = 0; wC < `+De+`; wC++) { int xC = xCCorner + wC * `+Z+`; if (xC < 0 || xC >= `+p.inWidth+`) { continue; } for (int d1 = 0; d1 < `+Te+`; d1 += 4) { vec4 xValues = vec4( getX(batch, xF, xR, xC, d1), getX(batch, xF, xR, xC, d1 + 1), getX(batch, xF, xR, xC, d1 + 2), getX(batch, xF, xR, xC, d1 + 3) ); vec4 wValues = vec4( getW(wF, wR, wC, d1, d2), getW(wF, wR, wC, d1 + 1, d2), getW(wF, wR, wC, d1 + 2, d2), getW(wF, wR, wC, d1 + 3, d2) ); dotProd += dot(xValues, wValues); } if (`+(Ge===1)+`) { dotProd += getX(batch, xF, xR, xC, `+Te+`) * getW(wF, wR, wC, `+Te+`, d2); } else if (`+(Ge===2)+`) { vec2 xValues = vec2( getX(batch, xF, xR, xC, `+Te+`), getX(batch, xF, xR, xC, `+Te+` + 1) ); vec2 wValues = vec2( getW(wF, wR, wC, `+Te+`, d2), getW(wF, wR, wC, `+Te+` + 1, d2) ); dotProd += dot(xValues, wValues); } else if (`+(Ge===3)+`) { vec3 xValues = vec3( getX(batch, xF, xR, xC, `+Te+`), getX(batch, xF, xR, xC, `+Te+` + 1), getX(batch, xF, xR, xC, `+Te+` + 2) ); vec3 wValues = vec3( getW(wF, wR, wC, `+Te+`, d2), getW(wF, wR, wC, `+Te+` + 1, d2), getW(wF, wR, wC, `+Te+` + 2, d2) ); dotProd += dot(xValues, wValues); } } } } setOutput(dotProd); } `}return f}(),ms=function(){function f(p,l,m,g){l===void 0&&(l=!1),m===void 0&&(m=null),g===void 0&&(g=!1),this.variableNames=["x","W"],this.outputShape=p.outShape;var I=p.inHeight,R=p.inWidth,z=p.padInfo.top,L=p.padInfo.left,G=p.strideHeight,Z=p.strideWidth,be=p.dilationHeight,Ce=p.dilationWidth,De=p.filterHeight,Te=p.filterWidth,Ge=p.outChannels/p.inChannels,Ze="",s="";m&&(g?Ze=`float activation(float a) { float b = getPreluActivationWeightsAtOutCoords(); `+m+` }`:Ze=` float activation(float x) { `+m+` } `,s="result = activation(result);");var u=l?"result += getBiasAtOutCoords();":"";l&&this.variableNames.push("bias"),g&&this.variableNames.push("preluActivationWeights"),this.userCode=` `+Ze+` const ivec2 strides = ivec2(`+G+", "+Z+`); const ivec2 pads = ivec2(`+z+", "+L+`); void main() { ivec4 coords = getOutputCoords(); int batch = coords.x; ivec2 xRCCorner = coords.yz * strides - pads; int d2 = coords.w; int d1 = d2 / `+Ge+`; int q = d2 - d1 * `+Ge+`; int xRCorner = xRCCorner.x; int xCCorner = xRCCorner.y; // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2). // ? = to be determined. : = across all values in that axis. float dotProd = 0.0; // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations. for (int wR = 0; wR < `+De+`; wR++) { int xR = xRCorner + wR * `+be+`; if (xR < 0 || xR >= `+I+`) { continue; } for (int wC = 0; wC < `+Te+`; wC++) { int xC = xCCorner + wC * `+Ce+`; if (xC < 0 || xC >= `+R+`) { continue; } float xVal = getX(batch, xR, xC, d1); float wVal = getW(wR, wC, d1, q); dotProd += xVal * wVal; } } float result = dotProd; `+u+` `+s+` setOutput(result); } `}return f}(),Do=function(){function f(p,l,m,g){l===void 0&&(l=!1),m===void 0&&(m=null),g===void 0&&(g=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p.outShape;for(var I=p.inHeight,R=p.inWidth,z=p.padInfo.top,L=p.padInfo.left,G=p.strideHeight,Z=p.strideWidth,be=p.dilationHeight,Ce=p.dilationWidth,De=p.filterHeight,Te=p.filterWidth,Ge=Te,Ze="int xR; int xC; int xCOffset;",s=0;s= 0 && xR < `+I+" && xCOffset >= 0 && xCOffset < "+R+`) { xTexelR`+s+"C"+u+` = getX(batch, xR, xCOffset, d1); // Need to manually clear unused channels in case // we're reading from recycled texture. if(xCOffset + 1 >= `+R+`) { xTexelR`+s+"C"+u+`.zw = vec2(0.); } } else { xTexelR`+s+"C"+u+` = vec4(0.); } xCOffset = xC + 1 - 2; if(xR >= 0 && xR < `+I+" && xCOffset >= 0 && xCOffset < "+R+`) { vec4 previous = getX(batch, xR, xCOffset, d1); // Need to manually clear unused channels in case // we're reading from recycled texture. if(xCOffset + 1 >= `+R+`) { previous.zw = vec2(0.); } xR`+s+"C"+u+" = vec4(previous.zw, xTexelR"+s+"C"+u+`.xy); } else { xR`+s+"C"+u+" = vec4(0, 0, xTexelR"+s+"C"+u+`.xy); } `:Ze+=` if(xR >= 0 && xR < `+I+" && xC >= 0 && xC < "+R+`) { xTexelR`+s+"C"+u+` = getX(batch, xR, xC, d1); } else { xTexelR`+s+"C"+u+` = vec4(0.); } xR`+s+"C"+u+" = xTexelR"+s+"C"+u+`; `,u+1= 0 && xR < `+I+` && xCOffset >= 0 && xCOffset < `+R+`) { xTexelR`+s+"C"+(u+2)+` = getX(batch, xR, xCOffset, d1); } `,Ce>1&&(Ze+=` xCOffset -= 2; if(xR >= 0 && xR < `+I+` && xCOffset >= 0 && xCOffset < `+R+`) { xTexelR`+s+"C"+u+` = getX(batch, xR, xCOffset, d1); } else { xTexelR`+s+"C"+u+` = vec4(0.); } `),Ze+=` xR`+s+"C"+(u+1)+` = vec4( xTexelR`+s+"C"+u+".zw, xTexelR"+s+"C"+(u+2)+`.xy); `):Ze+=` xCOffset = xC + `+o+`; if(xR >= 0 && xR < `+I+` && xCOffset >= 0 && xCOffset < `+R+`) { xTexelR`+s+"C"+(u+2)+` = getX(batch, xR, xCOffset, d1); } xR`+s+"C"+(u+1)+" = xTexelR"+s+"C"+(u+2)+`; `}}else u= 0 && xR < `+I+`) { `,L%2===1?(Ze+=` xCOffset = xC + 1 - `+Z+`; if(xCOffset >= 0 && xCOffset < `+R+`) { xTexelR`+s+"C"+u+` = getX(batch, xR, xCOffset, d1); } else { xTexelR`+s+"C"+u+` = vec4(0.); } if(xC + 1 >= 0 && xC + 1 < `+R+`) { xTexelR`+s+"C"+(u+2)+` = getX(batch, xR, xC + 1, d1); } else { xTexelR`+s+"C"+(u+2)+` = vec4(0.); } xR`+s+"C"+u+` = vec4( xTexelR`+s+"C"+u+".zw, xTexelR"+s+"C"+(u+2)+`.zw); `,u+1= 0 && xCOffset < `+R+`) { final = getX(batch, xR, xCOffset, d1); } xR`+s+"C"+(u+1)+" = vec4(xTexelR"+s+"C"+(u+2)+`.xy, final.xy); `)):(Ze+=` if(xC >= 0 && xC < `+R+`) { xTexelR`+s+"C"+u+` = getX(batch, xR, xC, d1); } else { xTexelR`+s+"C"+u+` = vec4(0.); } xCOffset = xC + `+Z+`; if(xCOffset >= 0 && xCOffset < `+R+`) { xTexelR`+s+"C"+(u+2)+` = getX(batch, xR, xCOffset, d1); } else { xTexelR`+s+"C"+(u+2)+` = vec4(0.); } xR`+s+"C"+u+` = vec4( xTexelR`+s+"C"+u+".xy, xTexelR"+s+"C"+(u+2)+`.xy); `,u+11?[""+(z-1)/(be-1),"(y2-y1) * height_ratio","y1*"+Ge+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+Ge],u=s[0],r=s[1],o=s[2],h=Ce>1?[""+(L-1)/(Ce-1),"(x2-x1) * width_ratio","x1*"+Ze+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+Ze],b=h[0],T=h[1],M=h[2];this.userCode=` const float height_ratio = float(`+u+`); const float width_ratio = float(`+b+`); void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int y = coords[1]; int x = coords[2]; int d = coords[3]; // get box vals float y1 = getBoxes(b,0); float x1 = getBoxes(b,1); float y2 = getBoxes(b,2); float x2 = getBoxes(b,3); // get image in batch index int bInd = round(getBoxInd(b)); if(bInd < 0 || bInd >= `+R+`) { return; } float height_scale = `+r+`; float width_scale = `+T+`; float in_y = `+o+`; if( in_y < 0.0 || in_y > `+Ge+` ) { setOutput(float(`+I+`)); return; } float in_x = `+M+`; if( in_x < 0.0 || in_x > `+Ze+` ) { setOutput(float(`+I+`)); return; } vec2 sourceFracIndexCR = vec2(in_x,in_y); if(`+De+` == 1) { // Compute the four integer indices. ivec2 sourceFloorCR = ivec2(sourceFracIndexCR); ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR)); float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d); float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d); float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d); float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d); vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR); float top = topLeft + (topRight - topLeft) * fracCR.x; float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x; float newValue = top + (bottom - top) * fracCR.y; setOutput(newValue); } else { // Compute the coordinators of nearest neighbor point. ivec2 sourceNearestCR = ivec2(floor( sourceFracIndexCR + vec2(0.5,0.5))); float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d); setOutput(newValue); } } `}return f}(),Zo=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=p;var g=p.length,I=l?"0.0":"getX("+xo(g,"coords")+")",R=p[p.length-1],z="",L="";l?(z=m?"end != "+(R-1):"end != 0",L=m?"end + 1":"end - 1"):(z=m?"end + pow2 < "+R:"end >= pow2",L=m?"end + pow2":"end - pow2"),this.userCode=` uniform float index; void main() { `+nn(g)+` coords = getOutputCoords(); int end = `+ys(g,"coords")+`; float val = `+I+`; int pow2 = int(pow(2.0, index)); if (`+z+`) { int idx = `+L+`; `+ys(g,"coords")+` = idx; val += getX(`+xo(g,"coords")+`); } setOutput(val); } `}return f.prototype.getCustomSetupFunc=function(p){var l=this;return function(m,g){l.index==null&&(l.index=m.getUniformLocation(g,"index")),m.gl.uniform1f(l.index,p)}},f}();function xo(f,p){if(f===1)return""+p;if(f===2)return p+".x, "+p+".y";if(f===3)return p+".x, "+p+".y, "+p+".z";if(f===4)return p+".x, "+p+".y, "+p+".z, "+p+".w";throw Error("Cumulative sum for rank "+f+" is not yet supported")}function ys(f,p){if(f===1)return""+p;if(f===2)return p+".y";if(f===3)return p+".z";if(f===4)return p+".w";throw Error("Cumulative sum for rank "+f+" is not yet supported")}var Fo=function(){function f(p){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=ae.DENSE;var l=nt(p),m=tn();this.outputShape=p,this.userCode=` ivec3 outCoordsFromFlatIndex(int index) { `+Rn(["r","c","d"],p)+` return ivec3(r, c, d); } void main() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+l[0]+", "+l[1]+`)); int index = 4 * (resTexRC.x * `+l[1]+` + resTexRC.y); vec4 result = vec4(0.); for (int i=0; i<4; i++) { int flatIndex = index + i; ivec3 rc = outCoordsFromFlatIndex(flatIndex); result[i] = getA(rc.x, rc.y, rc.z); } `+m.output+` = result; } `}return f}(),Ps=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=ae.DENSE;var l=nt(p),m=tn();this.outputShape=p,this.userCode=` ivec3 outCoordsFromFlatIndex(int index) { `+Rn(["r","c","d"],p)+` return ivec3(r, c, d); } void main() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+l[0]+", "+l[1]+`)); int index = 4 * (resTexRC.x * `+l[1]+` + resTexRC.y); vec4 result = vec4(0.); for (int i=0; i<4; i++) { int flatIndex = index + i; ivec3 rc = outCoordsFromFlatIndex(flatIndex); result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z)); } `+m.output+` = result; } `}return f}(),Jo=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=[],this.outputShape=p,this.blockSize=l,this.dataFormat=m,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int h = `+this.getHeightCoordString()+`; int w = `+this.getWidthCoordString()+`; int d = `+this.getDepthCoordString()+`; int in_h = h / `+l+`; int offset_h = imod(h, `+l+`); int in_w = w / `+l+`; int offset_w = imod(w, `+l+`); int offset_d = (offset_h * `+l+` + offset_w) * `+this.getOutputDepthSize()+`; int in_d = d + offset_d; float result = `+this.getInputSamplingString()+`; setOutput(result); } `}return f.prototype.getHeightCoordString=function(){return this.dataFormat==="NHWC"?"coords[1]":"coords[2]"},f.prototype.getWidthCoordString=function(){return this.dataFormat==="NHWC"?"coords[2]":"coords[3]"},f.prototype.getDepthCoordString=function(){return this.dataFormat==="NHWC"?"coords[3]":"coords[1]"},f.prototype.getOutputDepthSize=function(){return this.dataFormat==="NHWC"?this.outputShape[3]:this.outputShape[1]},f.prototype.getInputSamplingString=function(){return this.dataFormat==="NHWC"?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"},f}(),_o=function(){function f(p){this.variableNames=["X"],this.outputShape=[p,p],this.userCode=` void main() { ivec2 coords = getOutputCoords(); float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; setOutput(val); } `}return f}(),wo=function(){function f(p){this.variableNames=["A"],this.outTexUsage=w.DOWNLOAD;var l=tn();this.outputShape=p,this.userCode=` `+aa+` void main() { float x = getAAtOutCoords(); `+l.output+` = encode_float(x); } `}return f}(),Bs=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=w.DOWNLOAD;var l=tn();this.outputShape=p,this.userCode=` `+aa+` void main() { ivec3 coords = getOutputCoords(); float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z)); `+l.output+` = encode_float(x); } `}return f}(),Ws=function(){function f(p,l,m){m===void 0&&(m=!1),this.variableNames=["A"];var g=tn(),I=l[0],R=l[1];this.outputShape=p;var z="result";m&&(z="floor(result * 255. + 0.5)"),this.userCode=` `+Kn(p)+` void main() { ivec3 coords = getOutputCoords(); int flatIndex = getFlatIndex(coords); int offset = imod(flatIndex, 4); flatIndex = idiv(flatIndex, 4, 1.); int r = flatIndex / `+R+`; int c = imod(flatIndex, `+R+`); vec2 uv = (vec2(c, r) + halfCR) / vec2(`+R+".0, "+I+`.0); vec4 values = `+g.texture2D+`(A, uv); float result; if(offset == 0) { result = values[0]; } else if(offset == 1) { result = values[1]; } else if(offset == 2) { result = values[2]; } else { result = values[3]; } `+g.output+" = vec4("+z+`, 0., 0., 0.); } `}return f}(),vs=function(){function f(p,l,m){m===void 0&&(m=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var g=tn(),I=l[0],R=l[1];this.outputShape=p;var z="",L="result";m&&(L="floor(result * 255. + 0.5)");for(var G=0;G<=1;G++)for(var Z=0;Z<=1;Z++){var be=G*2+Z;z+=` localCoords = coords; if(localCoords[2] + `+Z+" < "+p[2]+`) { localCoords[2] += `+Z+`; if(localCoords[1] + `+G+" < "+p[1]+`) { localCoords[1] += `+G+`; flatIndex = getFlatIndex(localCoords); offset = imod(flatIndex, 4); flatIndex = idiv(flatIndex, 4, 1.); r = flatIndex / `+R+`; c = imod(flatIndex, `+R+`); uv = (vec2(c, r) + halfCR) / vec2(`+R+".0, "+I+`.0); values = `+g.texture2D+`(A, uv); if(offset == 0) { result[`+be+`] = values[0]; } else if(offset == 1) { result[`+be+`] = values[1]; } else if(offset == 2) { result[`+be+`] = values[2]; } else { result[`+be+`] = values[3]; } } } `}this.userCode=` `+Kn(p)+` void main() { ivec3 coords = getOutputCoords(); vec4 result = vec4(0.); int flatIndex, r, c, offset; ivec3 localCoords; vec2 uv; vec4 values; `+z+` `+g.output+" = "+L+`; } `}return f}(),$o=function(){function f(p,l){this.outputShape=[],this.variableNames=["x"],this.outputShape=p,this.userCode=` uniform float value; void main() { // Input can be obtained from uniform value. setOutput(value); } `}return f.prototype.getCustomSetupFunc=function(p){var l=this;return function(m,g){l.valueLoc==null&&(l.valueLoc=m.getUniformLocationNoThrow(g,"value")),m.gl.uniform1f(l.valueLoc,p)}},f}(),iu=function(){function f(p,l,m){this.variableNames=["A","indices"];var g=p.slice();g[m]=l,this.outputShape=g,this.rank=g.length;var I=nn(this.rank),R=ku(p,m);this.userCode=` void main() { `+I+` resRC = getOutputCoords(); setOutput(getA(`+R+`)); } `}return f}();function ku(f,p){var l=f.length;if(l>4)throw Error("Gather for rank "+l+" is not yet supported");if(l===1)return"int(getIndices(resRC))";for(var m=["resRC.x","resRC.y","resRC.z","resRC.w"],g=[],I=0;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 Zt(f,l)}function Mo(f){var p=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return Fa(f,p)}function gs(f){var p=new Uint16Array([0,1,2,2,1,3]);return Oa(f,p)}function es(f,p,l,m,g,I){Na(p,l);var R=Wa(f),z=f.TEXTURE_2D;return Qe(f,function(){return f.bindTexture(z,R)}),Qe(f,function(){return f.texParameteri(z,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE)}),Qe(f,function(){return f.texParameteri(z,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE)}),Qe(f,function(){return f.texParameteri(z,f.TEXTURE_MIN_FILTER,f.NEAREST)}),Qe(f,function(){return f.texParameteri(z,f.TEXTURE_MAG_FILTER,f.NEAREST)}),Qe(f,function(){return f.texImage2D(z,0,m,p,l,0,g,I,null)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,null)}),R}function Si(f){return f.internalFormatFloat}function Lo(f,p,l,m){var g=ze(p,l),I=g[0],R=g[1];return es(f,I,R,Si(m),m.textureFormatFloat,f.FLOAT)}function zo(f){return f.internalFormatHalfFloat}function Xi(f,p,l,m){var g=ze(p,l),I=g[0],R=g[1];return es(f,I,R,zo(m),m.textureFormatFloat,m.textureTypeHalfFloat)}function ts(f){return f.downloadTextureFormat}function ne(f,p,l,m){var g=ze(p,l),I=g[0],R=g[1];return es(f,I,R,ts(m),f.RGBA,f.UNSIGNED_BYTE)}function ue(f){return f.internalFormatPackedFloat}function E(f,p,l,m){var g=tt(p,l),I=g[0],R=g[1];return es(f,I,R,ue(m),f.RGBA,f.FLOAT)}function F(f){return f.internalFormatPackedHalfFloat}function A(f,p,l,m){var g=tt(p,l),I=g[0],R=g[1];return es(f,I,R,F(m),f.RGBA,m.textureTypeHalfFloat)}function V(f,p,l){var m=0,g=3*4,I=3*4+2*4;Qe(f,function(){return f.bindBuffer(f.ARRAY_BUFFER,l)});var R=Ma(f,p,"clipSpacePos",l,3,I,m);return R&&Ma(f,p,"uv",l,2,I,g)}function oe(f,p,l,m,g,I){Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,p)});var R,z,L;g instanceof Uint8Array?(R=new Uint8Array(l*m*4),z=f.UNSIGNED_BYTE,L=f.RGBA):(R=new Float32Array(l*m*4),z=f.FLOAT,L=I.internalFormatPackedFloat),R.set(g),Qe(f,function(){return f.texImage2D(f.TEXTURE_2D,0,L,l,m,0,f.RGBA,z,R)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function ee(f,p,l){Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,p)}),l.data instanceof Uint8Array?Qe(f,function(){return f.texImage2D(f.TEXTURE_2D,0,f.RGBA,l.width,l.height,0,f.RGBA,f.UNSIGNED_BYTE,l.data)}):Qe(f,function(){return f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,l)}),Qe(f,function(){return f.bindTexture(f.TEXTURE_2D,null)})}function _e(f,p,l,m){var g=f.createBuffer();Qe(f,function(){return f.bindBuffer(f.PIXEL_PACK_BUFFER,g)});var I=4,R=4,z=I*R*p*l;return Qe(f,function(){return f.bufferData(f.PIXEL_PACK_BUFFER,z,f.STREAM_READ)}),Qe(f,function(){return f.readPixels(0,0,l,p,f.RGBA,f.FLOAT,0)}),Qe(f,function(){return f.bindBuffer(f.PIXEL_PACK_BUFFER,null)}),g}function ce(f,p,l){var m=f,g=new Float32Array(l);return m.bindBuffer(m.PIXEL_PACK_BUFFER,p),m.getBufferSubData(m.PIXEL_PACK_BUFFER,0,g),m.bindBuffer(m.PIXEL_PACK_BUFFER,null),g}function de(f,p,l,m){var g=ze(p,l),I=g[0],R=g[1],z=4,L=new Uint8Array(W(p*l,z));return Qe(f,function(){return f.readPixels(0,0,I,R,m.downloadTextureFormat,f.UNSIGNED_BYTE,L)}),new Float32Array(L.buffer)}function ye(f,p,l,m,g,I,R,z){var L=f,G=new Float32Array(nr(I,R));return L.bindBuffer(L.PIXEL_PACK_BUFFER,p),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,G),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),G}function ve(f,p,l){var m=new Float32Array(p*l*4);return Qe(f,function(){return f.readPixels(0,0,l,p,f.RGBA,f.FLOAT,m)}),m}var Re={__proto__:null,createVertexShader:Oo,createVertexBuffer:Mo,createIndexBuffer:gs,getInternalFormatForFloat32MatrixTexture:Si,createFloat32MatrixTexture:Lo,getInternalFormatForFloat16MatrixTexture:zo,createFloat16MatrixTexture:Xi,getInternalFormatForUnsignedBytesMatrixTexture:ts,createUnsignedBytesMatrixTexture:ne,getInternalFormatForPackedMatrixTexture:ue,createPackedMatrixTexture:E,getInternalFormatForFloat16PackedMatrixTexture:F,createFloat16PackedMatrixTexture:A,bindVertexProgramAttributeStreams:V,uploadDenseMatrixToTexture:oe,uploadPixelDataToTexture:ee,createBufferFromOutputTexture:_e,downloadFloat32MatrixFromBuffer:ce,downloadByteEncodedFloatMatrixFromOutputTexture:de,downloadPackedMatrixFromBuffer:ye,downloadMatrixFromPackedOutputTexture:ve},Oe=function(){function f(p){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var l=i.env().getNumber("WEBGL_VERSION");p!=null?(this.gl=p,Ae(l,p)):this.gl=P(l);var m="WEBGL_color_buffer_float",g="EXT_color_buffer_half_float";if(i.env().getNumber("WEBGL_VERSION")===1){var I="OES_texture_float",R="OES_texture_half_float";if(this.textureFloatExtension=yt(this.gl,I),qn(this.gl,R))this.textureHalfFloatExtension=yt(this.gl,R);else if(i.env().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(m),qn(this.gl,g))this.colorBufferHalfFloatExtension=yt(this.gl,g);else if(i.env().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(m="EXT_color_buffer_float",qn(this.gl,m))this.colorBufferFloatExtension=this.gl.getExtension(m);else if(qn(this.gl,g))this.colorBufferHalfFloatExtension=this.gl.getExtension(g);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=Mo(this.gl),this.indexBuffer=gs(this.gl),this.framebuffer=yn(this.gl),this.textureConfig=Tt(this.gl,this.textureHalfFloatExtension)}return Object.defineProperty(f.prototype,"debug",{get:function(){return i.env().getBool("DEBUG")},enumerable:!0,configurable:!0}),f.prototype.dispose=function(){var p=this;if(this.disposed)return;this.program!=null&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),this.outputTexture!=null&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");var l=this.gl;Qe(l,function(){return l.finish()}),Qe(l,function(){return l.bindFramebuffer(l.FRAMEBUFFER,null)}),Qe(l,function(){return l.deleteFramebuffer(p.framebuffer)}),Qe(l,function(){return l.bindBuffer(l.ARRAY_BUFFER,null)}),Qe(l,function(){return l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)}),Qe(l,function(){return l.deleteBuffer(p.indexBuffer)}),this.disposed=!0},f.prototype.createFloat32MatrixTexture=function(p,l){return this.throwIfDisposed(),Lo(this.gl,p,l,this.textureConfig)},f.prototype.createFloat16MatrixTexture=function(p,l){return this.throwIfDisposed(),Xi(this.gl,p,l,this.textureConfig)},f.prototype.createUnsignedBytesMatrixTexture=function(p,l){return this.throwIfDisposed(),ne(this.gl,p,l,this.textureConfig)},f.prototype.uploadPixelDataToTexture=function(p,l){this.throwIfDisposed(),ee(this.gl,p,l)},f.prototype.uploadDenseMatrixToTexture=function(p,l,m,g){this.throwIfDisposed(),oe(this.gl,p,l,m,g,this.textureConfig)},f.prototype.createFloat16PackedMatrixTexture=function(p,l){return this.throwIfDisposed(),A(this.gl,p,l,this.textureConfig)},f.prototype.createPackedMatrixTexture=function(p,l){return this.throwIfDisposed(),E(this.gl,p,l,this.textureConfig)},f.prototype.deleteMatrixTexture=function(p){var l=this;this.throwIfDisposed(),this.outputTexture===p&&(_i(this.gl,this.framebuffer),this.outputTexture=null),Qe(this.gl,function(){return l.gl.deleteTexture(p)})},f.prototype.downloadByteEncodedFloatMatrixFromOutputTexture=function(p,l,m){var g=this;return this.downloadMatrixDriver(p,function(){return de(g.gl,l,m,g.textureConfig)})},f.prototype.downloadPackedMatrixFromBuffer=function(p,l,m,g,I,R){return ye(this.gl,p,l,m,g,I,R,this.textureConfig)},f.prototype.downloadFloat32MatrixFromBuffer=function(p,l){return ce(this.gl,p,l)},f.prototype.createBufferFromTexture=function(p,l,m){this.bindTextureToFrameBuffer(p);var g=_e(this.gl,l,m,this.textureConfig);return this.unbindTextureToFrameBuffer(),g},f.prototype.createAndWaitForFence=function(){var p=this.createFence(this.gl);return this.pollFence(p)},f.prototype.createFence=function(p){var l=this,m,g;if(i.env().getBool("WEBGL_FENCE_API_ENABLED")){var I=p,R=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);p.flush(),g=function(){var z=I.clientWaitSync(R,0,0);return z===I.ALREADY_SIGNALED||z===I.CONDITION_SATISFIED},m=R}else i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(m=this.beginQuery(),this.endQuery(),g=function(){return l.isQueryAvailable(m,i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):g=function(){return!0};return{query:m,isFencePassed:g}},f.prototype.downloadMatrixFromPackedTexture=function(p,l,m){var g=this;return this.downloadMatrixDriver(p,function(){return ve(g.gl,l,m)})},f.prototype.createProgram=function(p){this.throwIfDisposed();var l=this.gl,m=ar(l,p),g=Oo(l),I=jr(l);return Qe(l,function(){return l.attachShader(I,g)}),Qe(l,function(){return l.attachShader(I,m)}),_r(l,I),this.debug&&tr(l,I),this.vertexAttrsAreBound||(this.setProgram(I),this.vertexAttrsAreBound=V(l,this.program,this.vertexBuffer)),I},f.prototype.deleteProgram=function(p){var l=this;this.throwIfDisposed(),p===this.program&&(this.program=null),p!=null&&Qe(this.gl,function(){return l.gl.deleteProgram(p)})},f.prototype.setProgram=function(p){var l=this;this.throwIfDisposed(),this.program=p,this.program!=null&&this.debug&&tr(this.gl,this.program),Qe(this.gl,function(){return l.gl.useProgram(p)})},f.prototype.getUniformLocation=function(p,l,m){return m===void 0&&(m=!0),this.throwIfDisposed(),m?la(this.gl,p,l):rn(this.gl,p,l)},f.prototype.getAttributeLocation=function(p,l){var m=this;return this.throwIfDisposed(),Qe(this.gl,function(){return m.gl.getAttribLocation(p,l)})},f.prototype.getUniformLocationNoThrow=function(p,l){return this.throwIfDisposed(),this.gl.getUniformLocation(p,l)},f.prototype.setInputMatrixTexture=function(p,l,m){this.throwIfDisposed(),this.throwIfNoProgram(),Ca(this.gl,p,l,m)},f.prototype.setOutputMatrixTexture=function(p,l,m){this.setOutputMatrixTextureDriver(p,m,l)},f.prototype.setOutputPackedMatrixTexture=function(p,l,m){this.throwIfDisposed();var g=tt(l,m),I=g[0],R=g[1];this.setOutputMatrixTextureDriver(p,I,R)},f.prototype.setOutputMatrixWriteRegion=function(p,l,m,g){this.setOutputMatrixWriteRegionDriver(m,p,g,l)},f.prototype.setOutputPackedMatrixWriteRegion=function(p,l,m,g){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")},f.prototype.debugValidate=function(){this.program!=null&&tr(this.gl,this.program),ha(this.gl)},f.prototype.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var p=this.gl;this.debug&&this.debugValidate(),Qe(p,function(){return p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0)})},f.prototype.blockUntilAllProgramsCompleted=function(){var p=this;this.throwIfDisposed(),Qe(this.gl,function(){return p.gl.finish()})},f.prototype.getQueryTimerExtension=function(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=yt(this.gl,i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension},f.prototype.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension()},f.prototype.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension()},f.prototype.beginQuery=function(){if(i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){var p=this.gl,l=this.getQueryTimerExtensionWebGL2(),m=p.createQuery();return p.beginQuery(l.TIME_ELAPSED_EXT,m),m}var g=this.getQueryTimerExtensionWebGL1(),I=g.createQueryEXT();return g.beginQueryEXT(g.TIME_ELAPSED_EXT,I),I},f.prototype.endQuery=function(){if(i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){var p=this.gl,l=this.getQueryTimerExtensionWebGL2();p.endQuery(l.TIME_ELAPSED_EXT);return}var m=this.getQueryTimerExtensionWebGL1();m.endQueryEXT(m.TIME_ELAPSED_EXT)},f.prototype.waitForQueryAndGetTime=function(p){return H(this,void 0,void 0,function(){var l=this;return se(this,function(m){switch(m.label){case 0:return[4,i.util.repeatedTry(function(){return l.disposed||l.isQueryAvailable(p,i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))})];case 1:return m.sent(),[2,this.getQueryTime(p,i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))]}})})},f.prototype.getQueryTime=function(p,l){if(l===0)return null;if(l===2){var m=this.gl,g=m.getQueryParameter(p,m.QUERY_RESULT);return g/1e6}else{var I=this.getQueryTimerExtensionWebGL1(),g=I.getQueryObjectEXT(p,I.QUERY_RESULT_EXT);return g/1e6}},f.prototype.isQueryAvailable=function(p,l){if(l===0)return!0;if(l===2){var m=this.gl,g=this.getQueryTimerExtensionWebGL2(),I=m.getQueryParameter(p,m.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(g.GPU_DISJOINT_EXT)),I&&!this.disjoint}else{var g=this.getQueryTimerExtensionWebGL1(),I=g.getQueryObjectEXT(p,g.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(g.GPU_DISJOINT_EXT)),I&&!this.disjoint}},f.prototype.pollFence=function(p){var l=this;return new Promise(function(m){l.addItemToPoll(function(){return p.isFencePassed()},function(){return m()})})},f.prototype.pollItems=function(){for(var p=Fe(this.itemsToPoll.map(function(g){return g.isDoneFn})),l=0;l<=p;++l){var m=this.itemsToPoll[l].resolveFn;m()}this.itemsToPoll=this.itemsToPoll.slice(p+1)},f.prototype.addItemToPoll=function(p,l){var m=this;if(this.itemsToPoll.push({isDoneFn:p,resolveFn:l}),this.itemsToPoll.length>1)return;i.util.repeatedTry(function(){return m.pollItems(),m.itemsToPoll.length===0})},f.prototype.bindTextureToFrameBuffer=function(p){this.throwIfDisposed(),Hn(this.gl,p,this.framebuffer),this.debug&&ha(this.gl)},f.prototype.unbindTextureToFrameBuffer=function(){this.outputTexture!=null?(Hn(this.gl,this.outputTexture,this.framebuffer),this.debug&&ha(this.gl)):_i(this.gl,this.framebuffer)},f.prototype.downloadMatrixDriver=function(p,l){this.bindTextureToFrameBuffer(p);var m=l();return this.unbindTextureToFrameBuffer(),m},f.prototype.setOutputMatrixTextureDriver=function(p,l,m){this.throwIfDisposed();var g=this.gl;Hn(g,p,this.framebuffer),this.debug&&ha(g),this.outputTexture=p,Qe(g,function(){return g.viewport(0,0,l,m)}),Qe(g,function(){return g.scissor(0,0,l,m)})},f.prototype.setOutputMatrixWriteRegionDriver=function(p,l,m,g){var I=this;this.throwIfDisposed(),Qe(this.gl,function(){return I.gl.scissor(p,l,m,g)})},f.prototype.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")},f.prototype.throwIfNoProgram=function(){if(this.program==null)throw new Error("No GPU program is currently set.")},f}();function Fe(f){for(var p=0;p0&&(u.flatOffset=Ze.texData.slice.flatOffset),{name:p.variableNames[s],shapeInfo:u}}),R=I.map(function(Ze){return Ze.shapeInfo}),z={logicalShape:m.shape,texShape:m.texData.texShape,isUniform:!1,isPacked:m.texData.isPacked,flatOffset:null},L=Li(I,z,g,p.packedInputs),G=f.createProgram(L),Z=null,be=f.getUniformLocation(G,"NAN",!1);i.env().getNumber("WEBGL_VERSION")===1&&(Z=f.getUniformLocation(G,"INFINITY",!1));for(var Ce={},De=0;De0,L=R.isUniform?"uniform":R.texData.texShape;m+=R.shape+"_"+L+"_"+z});var g=f.userCode,I=f.constructor.name;return I+="_"+m+"_"+g,I}var $=function(){function f(p,l,m){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p;for(var g=m.filterWidth,I=m.inChannels,R=m.strideWidth,z=m.strideHeight,L=m.padInfo,G=m.outWidth,Z=m.dilationWidth,be=m.dilationHeight,Ce=m.dataFormat,De=L.left,Te=L.top,Ge=I*g,Ze=tn(),s=Ce==="channelsLast",u=s?0:1,r=s?1:2,o="",h=0;h<=1;h++)for(var b=0;b<=1;b++)o+=` blockIndex = rc.y + `+b+`; pos = rc.x + `+h+`; if(blockIndex < `+p[1]+" && pos < "+p[0]+`) { offsetY = int(blockIndex / (`+G+")) * "+z+" - "+Te+`; d0 = offsetY + `+be+" * (pos / "+Ge+`); if(d0 < `+l[u]+` && d0 >= 0) { offsetX = int(mod(float(blockIndex), `+G+".) * "+R+". - "+De+`.); d1 = offsetX + `+Z+" * (int(mod(float(pos), "+Ge+".) / "+I+`.)); if(d1 < `+l[r]+` && d1 >= 0) { ch = int(mod(float(pos), `+I+`.)); if (`+s+`) { innerDims = vec2(d1, ch); result[`+(h*2+b)+`] = getChannel( getA(d0, int(innerDims.x), int(innerDims.y)), innerDims); } else { innerDims = vec2(d0, d1); result[`+(h*2+b)+`] = getChannel( getA(ch, int(innerDims.x), int(innerDims.y)), innerDims); } } } } `;this.userCode=` void main() { ivec2 rc = getOutputCoords(); vec4 result = vec4(0); int blockIndex, pos, offsetY, d0, offsetX, d1, ch; vec2 innerDims; `+o+` `+Ze.output+` = result; } `}return f}(),et=function(){function f(p,l,m,g,I){this.variableNames=["x"],this.outputShape=[];var R=l,z=p[3]-1;this.outputShape=p;var L,G="float("+m+") + float("+g+") * sum";I===.5?L="inversesqrt("+G+")":I===1?L="1.0/("+G+")":L="exp(log("+G+") * float(-"+I+"));",this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int r = coords[1]; int c = coords[2]; int d = coords[3]; float x = getX(b, r, c, d); float sum = 0.0; for (int j = -`+R+"; j <= "+R+`; j++) { int idx = d + j; if (idx >= 0 && idx <= `+z+`) { float z = getX(b, r, c, idx); sum += z * z; } } float val = x * `+L+`; setOutput(val); } `}return f}(),gt=function(){function f(p,l,m,g,I){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=p,this.depth=p[3],this.depthRadius=l,this.bias=m,this.alpha=g,this.beta=I,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int r = coords[1]; int c = coords[2]; float result = 0.0; for (int d = 0; d < `+this.depth+`; ++d) { int depthBegin = int(max(0.0, float(d - `+l+`))); int depthEnd = int(min(float(`+this.depth+`), float(d + `+l+` + 1))); const int MIN_DEPTH_BEGIN = 0; const int MAX_DEPTH_END = `+this.depth+`; float norm = 0.0; for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) { if (k < depthBegin){ continue; } else if (k >= depthBegin && k < depthEnd) { norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k); } else { break; } } norm = float(`+g+") * norm + float("+m+`); for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){ if (k < depthBegin){ continue; } else if (k >= depthBegin && k < depthEnd){ float dyi = -2.0 * float(`+g+`) * float(`+I+`) * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d) / norm; if (k == d) { dyi += pow(norm, -1.0 * `+I+`); } if (k == coords[3]) { dyi *= getDy(b, r, c, d); result += dyi; } } else { break; } } } setOutput(result); } `}return f}(),lt=function(){function f(p,l,m,g,I){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var R=l,z=p[3]-1;this.outputShape=p;var L,G="float("+m+") + float("+g+") * sum";I===.5?L="inversesqrt("+G+")":I===1?L="1.0/("+G+")":L="exp(log("+G+") * float(-"+I+"));",this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords.x; int r = coords.y; int c = coords.z; int d = coords.w; bool hasNextCol = d < `+this.outputShape[3]+`; bool hasNextRow = c < `+this.outputShape[2]+`; vec4 sum = vec4(0.); vec4 xFragAtOutputCoords = getX(b, r, c, d); vec4 xAtOutputCoords = vec4( getChannel(xFragAtOutputCoords, vec2(c, d)), hasNextCol ? getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0, hasNextRow ? getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0, (hasNextRow && hasNextCol) ? getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0 ); int firstChannel = d - `+R+`; vec2 cache = vec2(0.); if(firstChannel >= 0){ vec4 firstChannelFrag = getX(b, r, c, firstChannel); cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel)); if(hasNextRow){ cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel)); } } ivec2 depth = ivec2(d, d + 1); for (int j = - `+R+"; j <= "+R+`; j++) { ivec2 idx = depth + j; bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0)); bvec2 belowUpperBound = lessThanEqual(idx, ivec2(`+z+`)); bool depthInRange = aboveLowerBound.x && belowUpperBound.x; bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y; if(depthInRange || depthPlusOneInRange){ vec4 z = vec4(0.); vec4 xFragAtCurrentDepth; z.xz = cache.xy; if(depthPlusOneInRange && hasNextCol){ xFragAtCurrentDepth = idx.y != d ? getX(b, r, c, idx.y) : xFragAtOutputCoords; z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y)); if(hasNextRow){ z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y)); } } cache.xy = z.yw; sum += z * z; } } vec4 result = xAtOutputCoords * `+L+`; setOutput(result); } `}return f}(),_t=function(){function f(p){this.variableNames=["dy","maxPos"],this.outputShape=p.inShape;var l=p.strideHeight,m=p.strideWidth,g=p.dilationHeight,I=p.effectiveFilterHeight,R=p.effectiveFilterWidth,z=I-1-p.padInfo.top,L=R-1-p.padInfo.left,G=I*R-1;this.userCode=` const ivec2 pads = ivec2(`+z+", "+L+`); void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int d = coords[3]; ivec2 dyRCCorner = coords.yz - pads; int dyRCorner = dyRCCorner.x; int dyCCorner = dyRCCorner.y; // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). // ? = to be determined. : = across all values in that axis. float dotProd = 0.0; for (int wR = 0; wR < `+I+`; wR += `+g+`) { float dyR = float(dyRCorner + wR) / `+l+`.0; if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); for (int wC = 0; wC < `+R+`; wC++) { float dyC = float(dyCCorner + wC) / `+m+`.0; if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); float dyValue = getDy(b, idyR, idyC, d); int maxPosValue = `+G+` - int(getMaxPos(b, idyR, idyC, d)); // Get the current value, check it against the value from the // position matrix. int curPosValue = wR * `+R+` + wC; float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); dotProd += dyValue * mask; } } setOutput(dotProd); } `}return f}(),At=function(){function f(p){this.variableNames=["dy","maxPos"],this.outputShape=p.inShape;var l=p.strideDepth,m=p.strideHeight,g=p.strideWidth,I=p.dilationDepth,R=p.dilationHeight,z=p.dilationWidth,L=p.effectiveFilterDepth,G=p.effectiveFilterHeight,Z=p.effectiveFilterWidth,be=L-1-p.padInfo.front,Ce=G-1-p.padInfo.top,De=Z-1-p.padInfo.left,Te=L*G*Z-1;this.userCode=` const ivec3 pads = ivec3(`+be+", "+Ce+", "+De+`); void main() { ivec5 coords = getOutputCoords(); int batch = coords.x; int ch = coords.u; ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; int dyDCorner = dyCorner.x; int dyRCorner = dyCorner.y; int dyCCorner = dyCorner.z; // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get // dx(xD, xR, xC, ch). // ? = to be determined. : = across all values in that axis. float dotProd = 0.0; for (int wD = 0; wD < `+L+`; wD += `+I+`) { float dyD = float(dyDCorner + wD) / `+l+`.0; if (dyD < 0.0 || dyD >= `+p.outDepth+`.0 || fract(dyD) > 0.0) { continue; } int idyD = int(dyD); for (int wR = 0; wR < `+G+`; wR += `+R+`) { float dyR = float(dyRCorner + wR) / `+m+`.0; if (dyR < 0.0 || dyR >= `+p.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); for (int wC = 0; wC < `+Z+`; wC += `+z+`) { float dyC = float(dyCCorner + wC) / `+g+`.0; if (dyC < 0.0 || dyC >= `+p.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); float dyValue = getDy(batch, idyD, idyR, idyC, ch); int maxPosValue = `+Te+` - int(getMaxPos(batch, idyD, idyR, idyC, ch)); // Get the current value, check it against the value from the // position matrix. int curPosValue = wD * `+G+" * "+Z+` + wR * `+Z+` + wC; float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); dotProd += dyValue * mask; } } } setOutput(dotProd); } `}return f}(),Lt=function(){function f(p,l,m,g,I,R,z,L){g===void 0&&(g=!1),I===void 0&&(I=!1),R===void 0&&(R=!1),z===void 0&&(z=null),L===void 0&&(L=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=m;var G=g?p[1]:p[2],Z=Math.ceil(G/2),be=g?"i * 2, rc.y":"rc.y, i * 2",Ce=I?"rc.z, i * 2":"i * 2, rc.z",De=g?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],Te=I?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],Ge="",Ze="";z&&(L?Ge=`vec4 activation(vec4 a) { vec4 b = getPreluActivationWeightsAtOutCoords(); `+z+` }`:Ge=`vec4 activation(vec4 x) { `+z+` }`,Ze="result = activation(result);");var s=R?"result += getBiasAtOutCoords();":"";R&&this.variableNames.push("bias"),L&&this.variableNames.push("preluActivationWeights");var u="rc.x",r="rc.x";p[0] "+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=Kt(l,p);return l===1?`getA(rc), rc + 1 >= `+f[0]+` ? 0. : getA(rc + 1), 0, 0`:"getA("+m[0]+`), cEdge ? 0. : getA(`+m[1]+`), rEdge ? 0. : getA(`+m[2]+`), rEdge || cEdge ? 0. : getA(`+m[3]+")"}var wt=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=l.map(function(G,Z){return G[0]+p[Z]+G[1]});var g=p.length,I=nn(g),R=l.map(function(G){return G[0]}).join(","),z=l.map(function(G,Z){return G[0]+p[Z]}).join(","),L=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,g);if(g===1){this.userCode=` int start = `+R+`; int end = `+z+`; void main() { int outC = getOutputCoords(); if (outC < start || outC >= end) { setOutput(float(`+m+`)); } else { setOutput(getX(outC - start)); } } `;return}this.userCode=` `+I+" start = "+I+"("+R+`); `+I+" end = "+I+"("+z+`); void main() { `+I+` outC = getOutputCoords(); if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) { setOutput(float(`+m+`)); } else { `+I+` coords = outC - start; setOutput(getX(`+L+`)); } } `}return f}(),Et=function(){function f(p,l,m){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=l.map(function(s,u){return s[0]+p[u]+s[1]});for(var g=p.length,I=nn(g),R=l.map(function(s){return s[0]}).join(","),z=l.map(function(s,u){return s[0]+p[u]}).join(","),L=Vr("rc",g),G=Vr("source",g),Z=L[g-1]+" < "+this.outputShape[g-1],be=g===1?"source":"vec2("+G.slice(-2).join()+")",Ce=[I+" rc = outputLoc;",L[g-1]+` += 1; if(`+Z+`) { `,g===1?"":`} rc = outputLoc; `+L[g-2]+` += 1; if(`+L[g-2]+" < "+this.outputShape[g-2]+") {",g===1?"":" "+L[g-1]+` += 1; if(`+Z+") {"],De=g===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",Te="",Ge=0,Ze=g===1?2:4;Ge= `+p.inHeight+`) { continue; } for (int wC = 0; wC < `+Ce+`; wC += `+Z+`) { int xC = xCCorner + wC; if (xC < 0 || xC >= `+p.inWidth+`) { continue; } float value = getX(batch, xR, xC, d); // If a min / max value has already been found, use it. If not, // use the current value. float currMinMaxValue = mix( value, minMaxValue, minMaxValueFound); if (value `+r+` currMinMaxValue) { minMaxValue = value; minMaxValueFound = 1.0; minMaxPosition = `+(g?I?Ze:s:"wR * "+Ce+" + wC")+`; } } } setOutput(float(minMaxPosition)); } `;return}var o="max",h=l+"("+l+"("+l+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";l==="avg"&&(h="avgValue / count");var b=Math.floor(R/4)*4,T=R%4,M=` if (`+Ge+`) { avgValue += dot(values, ones); } else { minMaxValue = `+o+`(values, minMaxValue); } `;this.userCode=` const ivec2 strides = ivec2(`+z+", "+L+`); const ivec2 pads = ivec2(`+De+", "+Te+`); const float initializationValue = `+u+`; const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); float count = 0.0; float getValue(int batch, int xR, int xC, int d) { if (xC < 0 || xC >= `+p.inWidth+`) { return initializationValue; } count += 1.0; return getX(batch, xR, xC, d); } void main() { ivec4 coords = getOutputCoords(); int batch = coords[0]; int d = coords[3]; ivec2 xRCCorner = coords.yz * strides - pads; int xRCorner = xRCCorner.x; int xCCorner = xRCCorner.y; // max/min x(?, ?, d) to get y(yR, yC, d). // ? = to be determined vec4 minMaxValue = vec4(`+u+`); float avgValue = 0.0; count = 0.0; for (int wR = 0; wR < `+be+`; wR += `+G+`) { int xR = xRCorner + wR; if (xR < 0 || xR >= `+p.inHeight+`) { continue; } for (int wC = 0; wC < `+b+`; wC += 4) { int xC = xCCorner + wC * `+Z+`; vec4 values = vec4( getValue(batch, xR, xC, d), getValue(batch, xR, xC + `+Z+`, d), getValue(batch, xR, xC + 2 * `+Z+`, d), getValue(batch, xR, xC + 3 * `+Z+`, d) ); `+M+` } int xC = xCCorner + `+b+`; if (`+(T===1)+`) { vec4 values = vec4( getValue(batch, xR, xC, d), initializationValue, initializationValue, initializationValue ); `+M+` } else if (`+(T===2)+`) { vec4 values = vec4( getValue(batch, xR, xC, d), getValue(batch, xR, xC + `+Z+`, d), initializationValue, initializationValue ); `+M+` } else if (`+(T===3)+`) { vec4 values = vec4( getValue(batch, xR, xC, d), getValue(batch, xR, xC + `+Z+`, d), getValue(batch, xR, xC + 2 * `+Z+`, d), initializationValue ); `+M+` } } setOutput(`+h+`); } `}return f}(),jt=function(){function f(p,l,m,g,I){if(g===void 0&&(g=!1),I===void 0&&(I=!1),this.variableNames=["x"],l==="avg"&&m)throw new Error("Cannot compute positions for average pool.");var R=p.filterWidth,z=p.strideDepth,L=p.strideHeight,G=p.strideWidth,Z=p.dilationDepth,be=p.dilationHeight,Ce=p.dilationWidth,De=p.effectiveFilterDepth,Te=p.effectiveFilterHeight,Ge=p.effectiveFilterWidth,Ze=p.padInfo.front,s=p.padInfo.top,u=p.padInfo.left;this.outputShape=p.outShape;var r=l==="avg",o="0.0";if(r||(o="-1.0 / 1e-20"),m){var h=">=";this.userCode=` const ivec3 strides = ivec3(`+z+", "+L+", "+G+`); const ivec3 pads = ivec3(`+Ze+", "+s+", "+u+`); void main() { ivec5 coords = getOutputCoords(); int batch = coords.x; int ch = coords.u; ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; int xDCorner = xCorner.x; int xRCorner = xCorner.y; int xCCorner = xCorner.z; // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch). // ? = to be determined float minMaxValue = 0.0; float minMaxValueFound = 0.0; int minMaxPosition = 0; for (int wD = 0; wD < `+De+`; wD += `+Z+`) { int xD = xDCorner + wD; if (xD < 0 || xD >= `+p.inDepth+`) { continue; } for (int wR = 0; wR < `+Te+`; wR += `+be+`) { int xR = xRCorner + wR; if (xR < 0 || xR >= `+p.inHeight+`) { continue; } for (int wC = 0; wC < `+Ge+`; wC += `+Ce+`) { int xC = xCCorner + wC; if (xC < 0 || xC >= `+p.inWidth+`) { continue; } float value = getX(batch, xD, xR, xC, ch); // If a min / max value has already been found, use it. If not, // use the current value. float currMinMaxValue = mix( value, minMaxValue, minMaxValueFound); if (value `+h+` currMinMaxValue) { minMaxValue = value; minMaxValueFound = 1.0; minMaxPosition = `+(g?I?"(((batch * "+p.inDepth+" + xD) * "+p.inHeight+" + xR) * "+p.inWidth+" + xC) * "+p.inChannels+" + ch":"((xD * "+p.inHeight+" + xR) * "+p.inWidth+" + xC) * "+p.inChannels+" + ch":"wD * "+Te+" * "+Ge+` + wR * `+Ge+" + wC")+`; } } } } setOutput(float(minMaxPosition)); } `;return}var b="max",T=l+"("+l+"("+l+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";l==="avg"&&(T="avgValue / count");var M=Math.floor(R/4)*4,q=R%4,Y=` if (`+r+`) { avgValue += dot(values, ones); } else { minMaxValue = `+b+`(values, minMaxValue); } `;this.userCode=` const ivec3 strides = ivec3(`+z+", "+L+", "+G+`); const ivec3 pads = ivec3(`+Ze+", "+s+", "+u+`); const float initializationValue = `+o+`; const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); float count = 0.0; float getValue(int batch, int xD, int xR, int xC, int ch) { if (xC < 0 || xC >= `+p.inWidth+`) { return initializationValue; } count += 1.0; return getX(batch, xD, xR, xC, ch); } void main() { ivec5 coords = getOutputCoords(); int batch = coords.x; int ch = coords.u; ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; int xDCorner = xCorner.x; int xRCorner = xCorner.y; int xCCorner = xCorner.z; // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch). // ? = to be determined vec4 minMaxValue = vec4(`+o+`); float avgValue = 0.0; count = 0.0; for (int wD = 0; wD < `+De+`; wD += `+Z+`) { int xD = xDCorner + wD; if (xD < 0 || xD >= `+p.inDepth+`) { continue; } for (int wR = 0; wR < `+Te+`; wR += `+be+`) { int xR = xRCorner + wR; if (xR < 0 || xR >= `+p.inHeight+`) { continue; } for (int wC = 0; wC < `+M+`; wC += 4) { int xC = xCCorner + wC * `+Ce+`; vec4 values = vec4( getValue(batch, xD, xR, xC, ch), getValue(batch, xD, xR, xC + `+Ce+`, ch), getValue(batch, xD, xR, xC + 2 * `+Ce+`, ch), getValue(batch, xD, xR, xC + 3 * `+Ce+`, ch) ); `+Y+` } int xC = xCCorner + `+M+`; if (`+(q===1)+`) { vec4 values = vec4( getValue(batch, xD, xR, xC, ch), initializationValue, initializationValue, initializationValue ); `+Y+` } else if (`+(q===2)+`) { vec4 values = vec4( getValue(batch, xD, xR, xC, ch), getValue(batch, xD, xR, xC + `+Ce+`, ch), initializationValue, initializationValue ); `+Y+` } else if (`+(q===3)+`) { vec4 values = vec4( getValue(batch, xD, xR, xC, ch), getValue(batch, xD, xR, xC + `+Ce+`, ch), getValue(batch, xD, xR, xC + 2 * `+Ce+`, ch), initializationValue ); `+Y+` } } setOutput(`+T+`); } } `}return f}(),cr=function(){function f(p,l){this.variableNames=["x"];var m=p.windowSize,g=p.batchSize,I=p.inSize,R=p.outSize;this.outputShape=[g,R];var z="0.0",L="";l==="prod"?z="1.0":l==="min"?(z="1.0 / 1e-20",L="min"):l==="max"&&(z="-1.0 / 1e-20",L="max");var G=l+"("+l+"("+l+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";l==="sum"?G="sumValue":l==="prod"?G="prodValue":l==="all"?G="allValue":l==="any"&&(G="anyValue");var Z=Math.floor(m/4)*4,be=m%4,Ce=` if (`+(l==="sum")+`) { sumValue += dot(values, ones); } else if (`+(l==="prod")+`) { vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]); prodValue *= tmp[0] * tmp[1]; } else { minMaxValue = `+L+`(values, minMaxValue); } `,De="vec4";l==="all"?(z="1.0",Ce=` bool reducedAllValue = all(values); float floatedReducedAllValue = float(reducedAllValue); allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0); `,De="bvec4"):l==="any"&&(z="0.0",Ce=` bool reducedAnyValue = any(values); float floatedReducedAnyValue = float(reducedAnyValue); anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0); `,De="bvec4");var Te="";I%m>0&&(Te=` if (inIdx < 0 || inIdx >= `+I+`) { return initializationValue; } `),this.userCode=` const float initializationValue = `+z+`; const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); float getValue(int batch, int inIdx) { `+Te+` return getX(batch, inIdx); } void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; int outIdx = coords[1]; int inOffset = outIdx * `+m+`; vec4 minMaxValue = vec4(`+z+`); float prodValue = 1.0; float sumValue = 0.0; float allValue = 1.0; float anyValue = 0.0; for (int i = 0; i < `+Z+`; i += 4) { int inIdx = inOffset + i; `+De+" values = "+De+`( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), getValue(batch, inIdx + 3) ); `+Ce+` } int inIdx = inOffset + `+Z+`; if (`+(be===1)+`) { `+De+" values = "+De+`( getValue(batch, inIdx), initializationValue, initializationValue, initializationValue ); `+Ce+` } else if (`+(be===2)+`) { `+De+" values = "+De+`( getValue(batch, inIdx), getValue(batch, inIdx + 1), initializationValue, initializationValue ); `+Ce+` } else if (`+(be===3)+`) { `+De+" values = "+De+`( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), initializationValue ); `+Ce+` } setOutput(`+G+`); } `}return f}(),rr=function(){function f(p,l){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p;for(var m="",g=0;g<4;g++){var I="thisRC = rc;";g%2===1&&(I+="thisRC.z += 1;"),g>1&&(I+="thisRC.y += 1;"),m+=` `+I+` `+(g>0?"if(thisRC.y < rows && thisRC.z < cols){":"")+` int flatIndex = getFlatIndex(thisRC); ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex); vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z)); result[`+g+`] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims); `+(g>0?"}":"")+` `}this.userCode=` `+Ie(l)+` `+Kn(p)+` void main() { ivec3 rc = getOutputCoords(); vec4 result = vec4(0.); ivec3 thisRC; int rows = `+p[1]+`; int cols = `+p[2]+`; `+m+` setOutput(result); } `}return f}();function Ie(f){var p=Rn(["r","c","d"],f);return` ivec3 inputCoordsFromReshapedOutCoords(int index) { `+p+` return ivec3(r, c, d); } `}var br=function(){function f(p,l,m){this.variableNames=["dy"],this.outputShape=[],this.outputShape=l.shape;var g=l.shape,I=g[1],R=g[2],z=p.shape,L=z[1],G=z[2],Z=[m&&L>1?I-1:I,m&&G>1?R-1:R],be=[m&&L>1?L-1:L,m&&G>1?G-1:G],Ce=Z[0]/be[0],De=Z[1]/be[1],Te=1/Ce,Ge=1/De,Ze=Math.ceil(Te)*2+2,s=Math.ceil(Ge)*2+2;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int d = coords[3]; int r = coords[1]; int c = coords[2]; float accumulator = 0.0; const float heightScale = float(`+Ce+`); const float widthScale = float(`+De+`); const float invHeightScale = float(`+Te+`); const float invWidthScale = float(`+Ge+`); const int winHeight = int(`+Ze+`); const int winWidth = int(`+s+`); // Compute bounds for where in dy we will look float startRLerp = floor(float(r) * invHeightScale); int startDyR = int(startRLerp - float(winHeight / 2)); float startCLerp = floor(float(c) * invWidthScale); int startDyC = int(startCLerp - float(winWidth / 2)); // Loop over dy for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { int dyR = dyROffset + startDyR; // Guard against the window exceeding the bounds of dy if (dyR < 0 || dyR >= `+L+`) { continue; } for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { int dyC = dyCOffset + startDyC; // Guard against the window exceeding the bounds of dy if (dyC < 0 || dyC >= `+G+`) { continue; } float dxR = float(dyR) * heightScale; int topDxRIndex = int(floor(dxR)); int bottomDxRIndex = int(min(ceil(dxR), `+(I-1)+`.0)); float dxRLerp = dxR - float(topDxRIndex); float inverseDxRLerp = 1.0 - dxRLerp; float dxC = float(dyC) * widthScale; int leftDxCIndex = int(floor(dxC)); int rightDxCIndex = int(min(ceil(dxC), `+(R-1)+`.0)); float dxCLerp = dxC - float(leftDxCIndex); float inverseDxCLerp = 1.0 - dxCLerp; if (r == topDxRIndex && c == leftDxCIndex) { // topLeft accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp; } if (r == topDxRIndex && c == rightDxCIndex) { // topRight accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp; } if (r == bottomDxRIndex && c == leftDxCIndex) { // bottomLeft accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp; } if (r == bottomDxRIndex && c == rightDxCIndex) { // bottomRight accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp; } } } // End loop over dy setOutput(accumulator); } `}return f}(),Nr=function(){function f(p,l,m,g){this.variableNames=["A"],this.outputShape=[];var I=p[0],R=p[1],z=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?z-1:z],Z=[g&&l>1?l-1:l,g&&m>1?m-1:m];this.userCode=` const vec2 effectiveInputOverOutputRatioRC = vec2( `+G[0]/Z[0]+`, `+G[1]/Z[1]+`); const vec2 inputShapeRC = vec2(`+R+".0, "+z+`.0); void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int d = coords[3]; ivec2 yRC = coords.yz; // Fractional source index. vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC; // Compute the four integer indices. ivec2 sourceFloorRC = ivec2(sourceFracIndexRC); ivec2 sourceCeilRC = ivec2( min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d); float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d); float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d); float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d); vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC); float top = topLeft + (topRight - topLeft) * fracRC.y; float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y; float newValue = top + (bottom - top) * fracRC.x; setOutput(newValue); } `}return f}(),Tr=function(){function f(p,l,m,g){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var I=p[0],R=p[1],z=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?z-1:z],Z=[g&&l>1?l-1:l,g&&m>1?m-1:m];this.userCode=` const vec3 effectiveInputOverOutputRatioRC = vec3( `+G[0]/Z[0]+`, `+G[1]/Z[1]+`, `+G[1]/Z[1]+`); const vec3 inputShapeRC = vec3(`+R+".0, "+z+`.0, `+z+`.0); float getAValue(int b, int r, int c, int d) { return getChannel(getA(b, r, c, d), vec2(c, d)); } void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int d = coords[3]; // Calculate values for next column in yRC.z. ivec3 yRC = coords.yzz + ivec3(0, 0, 1); // Fractional source index. vec3 sourceFracIndexRC = vec3(yRC) * effectiveInputOverOutputRatioRC; // Compute the four integer indices. ivec3 sourceFloorRC = ivec3(sourceFracIndexRC); ivec3 sourceCeilRC = ivec3( min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); // Should we calculate next column and row elements in 2x2 packed cell. bool hasNextCol = d < `+(L-1)+`; bool hasNextRow = coords.z < `+(m-1)+`; // In parallel, construct four corners for all four components in // packed 2x2 cell. vec4 topLeft = vec4( getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d), hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1) : 0.0, hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d) : 0.0, (hasNextRow && hasNextCol) ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0); vec4 bottomLeft = vec4( getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d), hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1) : 0.0, hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d) : 0.0, (hasNextRow && hasNextCol) ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0); vec4 topRight = vec4( getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d), hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1) : 0.0, hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d) : 0.0, (hasNextRow && hasNextCol) ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0); vec4 bottomRight = vec4( getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d), hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1) : 0.0, hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d) : 0.0, (hasNextRow && hasNextCol) ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0); vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC); vec4 top = mix(topLeft, topRight, fracRC.yyzz); vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz); vec4 newValue = mix(top, bottom, fracRC.x); setOutput(newValue); } `}return f}(),hr=function(){function f(p,l,m){this.variableNames=["dy"],this.outputShape=[],this.outputShape=l.shape;var g=l.shape,I=g[1],R=g[2],z=p.shape,L=z[1],G=z[2],Z=[m&&L>1?I-1:I,m&&G>1?R-1:R],be=[m&&L>1?L-1:L,m&&G>1?G-1:G],Ce=Z[0]/be[0],De=Z[1]/be[1],Te=1/Ce,Ge=1/De,Ze=Math.ceil(Te)*2+2,s=Math.ceil(Ge)*2+2;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int d = coords[3]; int r = coords[1]; int c = coords[2]; float accumulator = 0.0; const float heightScale = float(`+Ce+`); const float widthScale = float(`+De+`); const float invHeightScale = float(`+Te+`); const float invWidthScale = float(`+Ge+`); const int winHeight = int(`+Ze+`); const int winWidth = int(`+s+`); // Compute bounds for where in dy we will look float startRLerp = floor(float(r) * invHeightScale); int startDyR = int(floor(startRLerp - float(winHeight / 2))); float startCLerp = floor(float(c) * invWidthScale); int startDyC = int(floor(startCLerp - float(winWidth / 2))); // Loop over dy for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { int dyR = dyROffset + startDyR; // Guard against the window exceeding the bounds of dy if (dyR < 0 || dyR >= `+L+`) { continue; } for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { int dyC = dyCOffset + startDyC; // Guard against the window exceeding the bounds of dy if (dyC < 0 || dyC >= `+G+`) { continue; } float sourceFracRow = float(`+Z[0]+`) * (float(dyR) / float(`+be[0]+`)); float sourceFracCol = float(`+Z[1]+`) * (float(dyC) / float(`+be[1]+`)); int sourceNearestRow = int(min( float(int(`+I+`) - 1), `+m+` ? float(round(sourceFracRow)) : float(floor(sourceFracRow)))); int sourceNearestCol = int(min( float(int(`+R+`) - 1), `+m+` ? float(round(sourceFracCol)) : float(floor(sourceFracCol)))); if (r == sourceNearestRow && c == sourceNearestCol) { accumulator += getDy(b, dyR, dyC, d); } } } // End loop over dy setOutput(accumulator); } `}return f}(),Dr=function(){function f(p,l,m,g){this.variableNames=["A"],this.outputShape=[];var I=p[0],R=p[1],z=p[2],L=p[3];this.outputShape=[I,l,m,L];var G=[g&&l>1?R-1:R,g&&m>1?z-1:z],Z=[g&&l>1?l-1:l,g&&m>1?m-1:m],be=g?"0.5":"0.0";this.userCode=` const vec2 effectiveInputOverOutputRatioRC = vec2( `+G[0]/Z[0]+`, `+G[1]/Z[1]+`); const vec2 inputShapeRC = vec2(`+R+".0, "+z+`.0); void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; int d = coords[3]; ivec2 yRC = coords.yz; // Fractional source index. vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC; // Compute the coordinators of nearest neighbor point. ivec2 sourceNearestRC = ivec2( min(inputShapeRC - 1.0, floor(sourceFracIndexRC + `+be+`))); float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d); setOutput(newValue); } `}return f}(),fr=function(){function f(p,l){this.variableNames=["x"];var m=p.length;if(m>4)throw new Error("WebGL backend: Reverse of rank-"+m+" tensor is not yet supported");if(this.outputShape=p,m===1){this.userCode=` void main() { int coord = getOutputCoords(); setOutput(getX(`+p[0]+` - coord - 1)); } `;return}var g=function(z){return l.indexOf(z)!==-1&&p[z]!==1?p[z]+" - coords["+z+"] - 1":"coords["+z+"]"},I=p.map(function(z,L){return g(L)}).join(","),R=nn(m);this.userCode=` void main() { `+R+` coords = getOutputCoords(); setOutput(getX(`+I+`)); } `}return f}(),Er=function(){function f(p,l){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var m=p.length;if(m>4)throw new Error("WebGL backend: Reverse of rank-"+m+" tensor is not yet supported");this.outputShape=p;var g=Vr("rc",m),I=g[m-1]+" + 1 < "+this.outputShape[m-1],R=g[m-2]+" + 1 < "+this.outputShape[m-2],z=nn(m);m===1?this.userCode=` void main(){ int rc = getOutputCoords(); vec4 result = vec4(0.); result.r = getChannel(getX(`+p[0]+` - rc - 1), `+p[0]+` - rc - 1); if(`+I+`){ result.g = getChannel(getX(`+p[0]+` - (rc + 1) - 1), `+p[0]+` - (rc + 1) - 1); } setOutput(result); } `:this.userCode=` void main() { `+z+` rc = getOutputCoords(); vec4 result = vec4(0.); result.r = `+L(g.slice())+`; if(`+I+`){ result.g = `+G(g.slice())+`; } if(`+R+`) { result.b = `+Z(g.slice())+`; if(`+I+`) { result.a = `+be(g.slice())+`; } } setOutput(result); } `;function L(Te){return Ce(Te)}function G(Te){return Te[m-1]="("+Te[m-1]+" + 1)",Ce(Te)}function Z(Te){return Te[m-2]="("+Te[m-2]+" + 1)",Ce(Te)}function be(Te){return Te[m-1]="("+Te[m-1]+" + 1)",Te[m-2]="("+Te[m-2]+" + 1)",Ce(Te)}function Ce(Te){var Ge=p.map(function(u,r){return De(r,Te)}),Ze=Ge.join(","),s=Ge.slice(-2).join(",");return"getChannel(getX("+Ze+"), vec2("+s+"))"}function De(Te,Ge){return l.indexOf(Te)!==-1&&p[Te]!==1?p[Te]+" - "+Ge[Te]+" - 1":""+Ge[Te]}}return f}(),an=function(){function f(p,l,m,g,I,R,z){this.variableNames=["updates","indices","defaultValue"],this.outputShape=R;var L=nn(I.length),G=nn(R.length),Z="";m===1?Z="i":m===2&&(Z="i, j");var be="getIndices("+Z+")",Ce="";g===1?Ce="i":g===2&&(Ce="i, coords[1]");var De="getUpdates("+Ce+")",Te=l>1?"strides[j]":"strides";this.userCode=` `+L+" strides = "+L+"("+I+`); void main() { `+G+` coords = getOutputCoords(); float sum = 0.0; bool found = false; for (int i = 0; i < `+p+`; i++) { int flattenedIndex = 0; for (int j = 0; j < `+l+`; j++) { int index = round(`+be+`); flattenedIndex += index * `+Te+`; } if (flattenedIndex == coords[0]) { sum += `+De+`; found = true; } } setOutput(mix(getDefaultValue(), sum, float(found))); } `}return f}(),wn=function(){function f(p,l){this.variableNames=["x","segmentIds"];var m=p.windowSize,g=p.batchSize,I=p.inSize,R=p.numSegments,z=R*Math.ceil(I/m);this.outputShape=[g,z];var L="0.0",G="sumValue",Z=Math.floor(m/4)*4,be=m%4,Ce=` sumValue += dot(values, segFilter); `,De="";I%m>0&&(De=` if (inIdx < 0 || inIdx >= `+I+`) { return initializationValue; } `);var Te="";I%m>0&&(Te=` if (inIdx < 0 || inIdx >= `+I+`) { return -1.0; } `),this.userCode=` const float initializationValue = `+L+`; float getValue(int batch, int inIdx) { `+De+` return getX(batch, inIdx); } float getSegmentIdAtIndex(int inIdx) { `+Te+` return getSegmentIds(inIdx); } void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; int outIdx = coords[1]; int inOffset = int(floor(float(outIdx) / float( `+R+")) * float("+m+`)); int currentSeg = int(mod(float(outIdx), float(`+R+`))); float sumValue = 0.0; for (int i = 0; i < `+Z+`; i += 4) { int inIdx = inOffset + i; vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), getValue(batch, inIdx + 3) ); vec4 segFilter = vec4( int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0 ); `+Ce+` } int inIdx = inOffset + `+Z+`; if (`+(be===1)+`) { vec4 values = vec4( getValue(batch, inIdx), initializationValue, initializationValue, initializationValue ); int inIdxSeg = int(getSegmentIdAtIndex(inIdx)); vec4 segFilter = vec4( int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 0, 0, 0 ); `+Ce+` } else if (`+(be===2)+`) { vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), initializationValue, initializationValue ); vec4 segFilter = vec4( int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 0, 0 ); `+Ce+` } else if (`+(be===3)+`) { vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), initializationValue ); vec4 segFilter = vec4( int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 0 ); `+Ce+` } setOutput(`+G+`); } `}return f}(),ie=function(){function f(p,l,m){this.variableNames=["c","a","b"],this.outputShape=l;var g,I;if(m>4)throw Error("Where for rank "+m+" is not yet supported");if(m===1)I="resRC",g="resRC";else{for(var R=["resRC.x","resRC.y","resRC.z","resRC.w"],z=[],L=[],G=0;G= 1.0) { setOutput(getA(`+I+`)); } else { setOutput(getB(`+I+`)); } } `}return f}(),Nn=function(){function f(p){this.variableNames=["source"],this.outputShape=p,this.rank=p.length;var l=nn(this.rank),m="uniform int start["+this.rank+"];",g=Ee(this.rank),I,R=p.map(function(z,L){return"sourceLoc."+bn[L]+" = start["+L+"] + coords."+bn[L]+";"});I=` `+l+` sourceLoc; `+l+` coords = getOutputCoords(); `+R.join(` `)+` `,this.userCode=` `+m+` void main() { `+I+` setOutput(getSource(`+g+`)); } `}return f.prototype.getCustomSetupFunc=function(p){var l=this;if(p.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the "+("length of start ("+p.length+")"));return function(m,g){if(l.startLoc==null&&(l.startLoc=m.getUniformLocationNoThrow(g,"start"),l.startLoc==null))return;m.gl.uniform1iv(l.startLoc,p)}},f}(),bn=["x","y","z","w","u","v"];function Ee(f){if(f===1)return"sourceLoc";if(f<=6)return bn.slice(0,f).map(function(p){return"sourceLoc."+p}).join(",");throw Error("Slicing for rank "+f+" is not yet supported")}var Bn=function(){function f(p){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p,this.rank=p.length;var l=nn(this.rank),m=Vr("coords",this.rank),g=Vr("sourceLoc",this.rank),I=this.rank===1?"sourceLoc":"vec2("+g.slice(-2).join()+")",R="getChannel(getSource("+g.join()+"), "+I+")",z=` result.x = `+R+`; if (++`+m[this.rank-1]+" < "+p[this.rank-1]+`) { ++`+g[this.rank-1]+`; result.y = `+R+`; --`+g[this.rank-1]+`; } `,L=this.rank===1?"":` --`+m[this.rank-1]+`; if (++`+m[this.rank-2]+" < "+p[this.rank-2]+`) { ++`+g[this.rank-2]+`; result.z = `+R+`; if (++`+m[this.rank-1]+" < "+p[this.rank-1]+`) { ++`+g[this.rank-1]+`; result.w = `+R+`; } } `,G=this.rank<=4?`sourceLoc = coords + `+l+"("+p.map(function(Z,be){return"start["+be+"]"}).join()+");":p.map(function(Z,be){return g[be]+" = "+m[be]+" + start["+be+"];"}).join(` `);this.userCode=` uniform int start[`+this.rank+`]; void main() { `+l+` coords = getOutputCoords(); `+l+` sourceLoc; `+G+` vec4 result = vec4(0.); `+z+` `+L+` setOutput(result); } `}return f.prototype.getCustomSetupFunc=function(p){var l=this;if(p.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the "+("length of start ("+p.length+")"));return function(m,g){if(l.startLoc==null&&(l.startLoc=m.getUniformLocationNoThrow(g,"start"),l.startLoc==null))return;m.gl.uniform1iv(l.startLoc,p)}},f}(),Pn=function(){function f(p,l,m){this.variableNames=["x"],this.outputShape=m;var g=m.length,I=nn(m.length),R=nn(m.length),z="";if(g===1)z="coords * strides + begin";else{var L=0;z=m.map(function(G,Z){return L++,m.length===1?"coords * strides["+Z+"] + begin["+Z+"]":"coords["+(L-1)+"] * strides["+Z+"] + begin["+Z+"]"}).join(",")}this.userCode=` `+I+" begin = "+I+"("+p+`); `+I+" strides = "+I+"("+l+`); void main() { `+R+` coords = getOutputCoords(); setOutput(getX(`+z+`)); } `}return f}(),Da=function(){function f(p){this.gpgpu=p,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}return f.prototype.acquireTexture=function(p,l,m){var g=ya(l,m),I=va(p,g,m);I in this.freeTextures||(this.freeTextures[I]=[]),I in this.usedTextures||(this.usedTextures[I]=[]);var R=Ya(p,g,this.gpgpu.gl,this.gpgpu.textureConfig,m);if(this.freeTextures[I].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=R,this.log();var z=this.freeTextures[I].shift();return this.usedTextures[I].push(z),z}var L;return g===ge.PACKED_2X2_FLOAT32?L=this.gpgpu.createPackedMatrixTexture(p[0],p[1]):g===ge.PACKED_2X2_FLOAT16?L=this.gpgpu.createFloat16PackedMatrixTexture(p[0],p[1]):g===ge.UNPACKED_FLOAT32?L=this.gpgpu.createFloat32MatrixTexture(p[0],p[1]):g===ge.UNPACKED_FLOAT16?L=this.gpgpu.createFloat16MatrixTexture(p[0],p[1]):g===ge.PACKED_4X1_UNSIGNED_BYTE&&(L=this.gpgpu.createUnsignedBytesMatrixTexture(p[0],p[1])),this.usedTextures[I].push(L),this.numUsedTextures++,this._numBytesAllocated+=R,this.log(),L},f.prototype.releaseTexture=function(p,l,m,g){if(this.freeTextures==null)return;var I=ya(m,g),R=va(l,I,g);R in this.freeTextures||(this.freeTextures[R]=[]);var z=Ya(l,I,this.gpgpu.gl,this.gpgpu.textureConfig,g),L=i.env().get("WEBGL_DELETE_TEXTURE_THRESHOLD");L!==-1&&this._numBytesAllocated>L?(this.gpgpu.deleteMatrixTexture(p),this._numBytesAllocated-=z):(this.freeTextures[R].push(p),this.numFreeTextures++,this._numBytesFree+=z),this.numUsedTextures--;var G=this.usedTextures[R],Z=G.indexOf(p);if(Z<0)throw new Error("Cannot release a texture that was never provided by this texture manager");G.splice(Z,1),this.log()},f.prototype.log=function(){if(!this.logEnabled)return;var p=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+p+")");var l=this._numBytesFree/this._numBytesAllocated;console.log("Bytes allocated: "+this._numBytesAllocated),console.log("Bytes unused: "+this._numBytesFree+" ("+Math.round(100*l)+"%)")},Object.defineProperty(f.prototype,"numBytesAllocated",{get:function(){return this._numBytesAllocated},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"numBytesFree",{get:function(){return this._numBytesFree},enumerable:!0,configurable:!0}),f.prototype.getNumUsedTextures=function(){return this.numUsedTextures},f.prototype.getNumFreeTextures=function(){return this.numFreeTextures},f.prototype.dispose=function(){var p=this;if(this.freeTextures==null)return;for(var l in this.freeTextures)this.freeTextures[l].forEach(function(m){p.gpgpu.deleteMatrixTexture(m)});for(var l in this.usedTextures)this.usedTextures[l].forEach(function(g){p.gpgpu.deleteMatrixTexture(g)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0},f}();function Dn(f,p){var l=f;if(p===l.R32F)return 4;if(p===l.R16F)return 2;if(p===l.RGBA32F)return 16;if(p===f.RGBA)return 16;if(p===l.RGBA16F)return 8;throw new Error("Unknown internal format "+p)}function Ya(f,p,l,m,g){var I=za(p,m),R;if(g){var z=tt(f[0],f[1]),L=z[0],G=z[1];R=L*G}else{var Z=ze(f[0],f[1]),be=Z[0],Ce=Z[1];R=be*Ce}var De=Dn(l,I);return R*De}function za(f,p){switch(f){case ge.PACKED_2X2_FLOAT32:return ue(p);case ge.PACKED_2X2_FLOAT16:return F(p);case ge.UNPACKED_FLOAT32:return Si(p);case ge.UNPACKED_FLOAT16:return zo(p);case ge.PACKED_4X1_UNSIGNED_BYTE:return ts(p);default:throw new Error("Unknown physical texture type "+f)}}function Qa(f){return i.env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?f?ge.PACKED_2X2_FLOAT32:ge.UNPACKED_FLOAT32:f?ge.PACKED_2X2_FLOAT16:ge.UNPACKED_FLOAT16}function ya(f,p){if(f===w.UPLOAD)return ge.PACKED_2X2_FLOAT32;if(f===w.RENDER||f==null)return Qa(p);if(f===w.DOWNLOAD||f===w.PIXELS)return ge.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+f)}function va(f,p,l){return f[0]+"_"+f[1]+"_"+p+"_"+l}var Yi=function(){function f(p,l){this.variableNames=["A"];for(var m=new Array(p.length),g=0;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),Za+(` return x > 0.0 ? 1.0 : float(`+f+`); `)}var si="return -x;",Su="return ceil(x);",Iu="return floor(x);",lc=` if (isnan(x)) { return 0.0; } return sign(x); `,xs="return float(isnan(x));",Ii="return float(isinf(x));",_s="return float(!isnan(x) && !isinf(x));",bo=` // OpenGL ES does not support round function. // The algorithm is based on banker's rounding. float base = floor(x); if ((x - base) < 0.5) { return floor(x); } else if ((x - base) > 0.5) { return ceil(x); } else { if (mod(base, 2.0) == 0.0) { return base; } else { return base + 1.0; } } `,so="return exp(x);",Nu="return exp(x) - 1.0;",uu=`if (x < 0.0) return NAN; return log(x);`,ws="return log(1.0 + x);",Cu="return sqrt(x);",cu="return inversesqrt(x);",Tu="return 1.0 / (1.0 + exp(-1.0 * x));",hc=` float epsilon = 1.1920928955078125e-7; float threshold = log(epsilon) + 2.0; bool too_large = x > -threshold; bool too_small = x < threshold; float result; float exp_x = exp(x); if (too_large){ result = x; } else if (too_small){ result = exp_x; } else{ result = log(exp_x + 1.0); } return result; `,uo=Za+` if (abs(x) > 1.) { return NAN; } return asin(x); `,bs=Za+` if (abs(x) > 1.) { return NAN; } return acos(x); `,Eu=Za+` return atan(x); `,pc=` float e2x = exp(x); return (e2x - 1.0 / e2x) / 2.0; `,dc=` float e2x = exp(-x); return (e2x + 1.0 / e2x) / 2.0; `,fc=` float e2x = exp(-2.0 * abs(x)); return sign(x) * (1.0 - e2x) / (1.0 + e2x); `,vl=Za+"return log(x + sqrt(x * x + 1.0));",Ru=Za+` if (x < 1.0) return NAN; return log(x + sqrt(x * x - 1.0));`,mc=Za+` if ((x < -1.0) || (x > 1.0)) return NAN; return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,yc=` // Error function is calculated approximately with elementary function. // See "Handbook of Mathematical Functions with Formulas, // Graphs, and Mathematical Tables", Abramowitz and Stegun. float p = `+i.backend_util.ERF_P+`; float a1 = `+i.backend_util.ERF_A1+`; float a2 = `+i.backend_util.ERF_A2+`; float a3 = `+i.backend_util.ERF_A3+`; float a4 = `+i.backend_util.ERF_A4+`; float a5 = `+i.backend_util.ERF_A5+`; float sign = sign(x); x = abs(x); float t = 1.0 / (1.0 + p * x); return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); `,Ni="return 1.0 / x;",ns="return float(!(x >= 1.0));",ks="return x;",vc="return x;",Wo=` vec4 result = log(x); vec4 isNaN = vec4(lessThan(x, vec4(0.0))); result.r = isNaN.r == 1.0 ? NAN : result.r; result.g = isNaN.g == 1.0 ? NAN : result.g; result.b = isNaN.b == 1.0 ? NAN : result.b; result.a = isNaN.a == 1.0 ? NAN : result.a; return result; `,co=` vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); result.r = isNaN.r ? x.r : result.r; result.g = isNaN.g ? x.g : result.g; result.b = isNaN.b ? x.b : result.b; result.a = isNaN.a ? x.a : result.a; return result; `,Uo=` vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); result.r = isNaN.r ? x.r : result.r; result.g = isNaN.g ? x.g : result.g; result.b = isNaN.b ? x.b : result.b; result.a = isNaN.a ? x.a : result.a; return result; `,lu=` vec4 result; result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); return result; `,as=function(){function f(p,l){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=p,this.userCode=` vec4 unaryOperation(vec4 x) { `+l+` } void main() { vec4 x = getAAtOutCoords(); vec4 y = unaryOperation(x); setOutput(y); } `}return f}(),Vo=function(){function f(p){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=p;var l=p.length,m=Vr("rc",l),g=nn(l),I=Jn(l,m),R=m.slice(-2),z=l<=1?"rc":"vec2("+R.join(",")+")";this.userCode=` void main() { `+g+` rc = getOutputCoords(); vec4 packedInput = getA(`+I+`); setOutput(getChannel(packedInput, `+z+`)); } `}return f}(),gl=i.backend_util.segment_util,xl=i.kernel_impls.split,Au=i.kernel_impls.tile,gc=i.kernel_impls.topkImpl,Us=i.kernel_impls.whereImpl,xc=1e-7,Qi=1e-4,hu={};function pr(f){return f in hu||(hu[f]={}),hu[f]}function Vs(f,p){if(p===void 0&&(p=!1),f==="linear")return p?vc:rs;if(f==="relu")return p?co:dn;if(f==="elu")return p?lu:Fn;if(f==="relu6")return p?Uo:Bo;if(f==="prelu")return p?Aa:ka;throw new Error("Activation "+f+" has not been implemented for the WebGL backend.")}var Ho=128,Du=600;function _c(){return i.env().global.screen==null?1024:i.env().global.screen.height*i.env().global.screen.width*window.devicePixelRatio*Du/1024/1024}var Fu=1e3,Go=function(f){O(p,f);function p(l){var m=f.call(this)||this;if(m.pendingRead=new WeakMap,m.pendingDisposal=new WeakSet,m.dataRefCount=new WeakMap,m.numBytesInGPU=0,m.uploadWaitMs=0,m.downloadWaitMs=0,m.warnedAboutMemory=!1,m.warnedAboutCPUBackend=!1,m.pendingDeletes=0,m.disposed=!1,!i.env().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(l==null){var g=P(i.env().getNumber("WEBGL_VERSION"));m.binaryCache=pr(i.env().getNumber("WEBGL_VERSION")),m.gpgpu=new Oe(g),m.canvas=g.canvas,m.gpgpuCreatedLocally=!0}else m.gpgpu=l,m.binaryCache={},m.gpgpuCreatedLocally=!1,m.canvas=l.gl.canvas;return m.textureManager=new Da(m.gpgpu),m.numMBBeforeWarning=_c(),m.texData=new i.DataStorage(m,i.engine()),m}return p.prototype.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes},p.prototype.write=function(l,m,g){if((i.env().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||i.env().getBool("DEBUG"))&&this.checkNumericalProblems(l),g==="complex64"&&l!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var I={};return this.texData.set(I,{shape:m,dtype:g,values:l,usage:w.UPLOAD,refCount:1,complexParentRefCount:0}),I},p.prototype.incRef=function(l){var m=this.texData.get(l);m.refCount++},p.prototype.decRef=function(l){if(this.texData.has(l)){var m=this.texData.get(l);m.refCount--}},p.prototype.move=function(l,m,g,I){if(i.env().getBool("DEBUG")&&this.checkNumericalProblems(m),I==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(l,{shape:g,dtype:I,values:m,usage:w.UPLOAD,refCount:1,complexParentRefCount:0})},p.prototype.disposeIntermediateTensorInfo=function(l){var m=l.dataId;if(this.texData.has(m)){var g=this.texData.get(m);g.refCount--,g.refCount<1&&this.disposeData(m)}},p.prototype.readSync=function(l){var m=this.texData.get(l),g=m.values,I=m.dtype,R=m.complexTensorInfos,z=m.slice,L=m.shape,G=m.isPacked;if(z!=null){var Z=void 0;G?Z=new as(L,ks):Z=new Or(L,ks);var be=this.runWebGLProgram(Z,[{dataId:l,shape:L,dtype:I}],I),Ce=this.readSync(be.dataId);return this.disposeIntermediateTensorInfo(be),Ce}if(g!=null)return this.convertAndCacheOnCPU(l);if(I==="string")return g;var De=this.activeTimers!=null,Te;De&&(Te=i.util.now());var Ge;if(I==="complex64"){var Ze=this.readSync(R.real.dataId),s=this.readSync(R.imag.dataId);Ge=i.backend_util.mergeRealAndImagArrays(Ze,s)}else Ge=this.getValuesFromTexture(l);return De&&(this.downloadWaitMs+=i.util.now()-Te),this.convertAndCacheOnCPU(l,Ge)},p.prototype.read=function(l){return H(this,void 0,void 0,function(){var m,g,I,R,z,L,G,Z,be,Ce,De,Te,Ge,Ze,s,u,r,o,h,b,T,M;return se(this,function(q){switch(q.label){case 0:if(this.pendingRead.has(l))return m=this.pendingRead.get(l),[2,new Promise(function(Y){return m.push(Y)})];if(g=this.texData.get(l),I=g.values,R=g.shape,z=g.slice,L=g.dtype,G=g.complexTensorInfos,Z=g.isPacked,z!=null)return be=void 0,Z?be=new as(R,ks):be=new Or(R,ks),Ce=this.runWebGLProgram(be,[{dataId:l,shape:R,dtype:L}],L),De=this.read(Ce.dataId),this.disposeIntermediateTensorInfo(Ce),[2,De];if(I!=null)return[2,this.convertAndCacheOnCPU(l)];if(!i.env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&i.env().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");return Te=null,L!=="complex64"&&i.env().get("WEBGL_BUFFER_SUPPORTED")&&(Ge=this.decode(l),Ze=this.texData.get(Ge.dataId),Te=(M=this.gpgpu).createBufferFromTexture.apply(M,[Ze.texture].concat(nt(R)))),this.pendingRead.set(l,[]),L!=="complex64"?[4,this.gpgpu.createAndWaitForFence()]:[3,2];case 1:q.sent(),q.label=2;case 2:return L==="complex64"?[4,Promise.all([this.read(G.real.dataId),this.read(G.imag.dataId)])]:[3,4];case 3:return u=q.sent(),r=u[0],o=u[1],s=i.backend_util.mergeRealAndImagArrays(r,o),[3,5];case 4:Te==null?s=this.getValuesFromTexture(l):(h=i.util.sizeFromShape(R),s=this.gpgpu.downloadFloat32MatrixFromBuffer(Te,h)),q.label=5;case 5:return Ge!=null&&this.disposeIntermediateTensorInfo(Ge),b=this.convertAndCacheOnCPU(l,s),T=this.pendingRead.get(l),this.pendingRead.delete(l),T.forEach(function(Y){return Y(b)}),this.pendingDisposal.has(l)&&(this.pendingDisposal.delete(l),this.disposeData(l),this.pendingDeletes--),[2,b]}})})},p.prototype.checkNumericalProblems=function(l){if(l==null)return;for(var m=0;m0?[4,Promise.all(R)]:[3,2];case 1:return G=Z.sent(),L.kernelMs=i.util.sum(G),L.getExtraProfileInfo=function(){return G.map(function(be,Ce){return{name:z[Ce],ms:be}}).map(function(be){return be.name+": "+be.ms}).join(", ")},[3,3];case 2:L.kernelMs={error:"WebGL query timers are not supported in this environment."},Z.label=3;case 3:return this.uploadWaitMs=0,this.downloadWaitMs=0,[2,L]}})})},p.prototype.memory=function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}},p.prototype.startTimer=function(){return i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:i.util.now(),endMs:null}},p.prototype.endTimer=function(l){return i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),l):(l.endMs=i.util.now(),l)},p.prototype.getQueryTime=function(l){return H(this,void 0,void 0,function(){var m;return se(this,function(g){return i.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?[2,this.gpgpu.waitForQueryAndGetTime(l)]:(m=l,[2,m.endMs-m.startMs])})})},p.prototype.disposeData=function(l){if(this.pendingDisposal.has(l))return;if(this.pendingRead.has(l)){this.pendingDisposal.add(l),this.pendingDeletes++;return}if(!this.texData.has(l))return;if(this.texData.get(l).complexParentRefCount>0){this.texData.get(l).refCount--;return}this.releaseGPUData(l);var m=this.texData.get(l).complexTensorInfos;m!=null&&(this.texData.get(m.real.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(m.real),this.texData.get(m.imag.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(m.imag)),this.texData.delete(l)},p.prototype.releaseGPUData=function(l){var m=this.texData.get(l),g=m.texture,I=m.dtype,R=m.texShape,z=m.usage,L=m.isPacked,G=m.slice,Z=G&&G.origDataId||l,be=this.dataRefCount.get(Z);be>1?this.dataRefCount.set(Z,be-1):(this.dataRefCount.delete(Z),g!=null&&(this.numBytesInGPU-=this.computeBytes(R,I),this.textureManager.releaseTexture(g,R,z,L)));var Ce=this.texData.get(l);Ce.texture=null,Ce.texShape=null,Ce.isPacked=!1,Ce.slice=null},p.prototype.getTexture=function(l){return this.uploadToGPU(l),this.texData.get(l).texture},p.prototype.getDataInfo=function(l){return this.texData.get(l)},p.prototype.getCPUBackend=function(){return i.env().getBool("WEBGL_CPU_FORWARD")?(this.cpuBackend==null&&(this.cpuBackend=i.engine().findBackend("cpu")),this.cpuBackend):null},p.prototype.shouldExecuteOnCPU=function(l,m){var g=this;m===void 0&&(m=Ho);var I=this.getCPUBackend();return!this.warnedAboutCPUBackend&&I==null&&(console.warn("Your application contains ops that are small enough to be executed on the CPU backend, however the CPU backend cannot be found. Consider importing the CPU backend (@tensorflow/tfjs-backend-cpu) for better performance."),this.warnedAboutCPUBackend=!0),I!=null&&l.every(function(R){return g.texData.get(R.dataId).texture==null&&i.util.sizeFromShape(R.shape)Fu){g&&(l=i.transpose(l,[0,2,1])),I&&(m=i.transpose(m,[0,2,1]));var Z=z===1?l:l.as3D(G,L,1),be=z===1?2:1,Ce=z===1?m.as3D(G,1,L):m,De=i.mul(Z,Ce);return De.sum(be,!0)}var Te=i.upcastType(l.dtype,m.dtype),Ge=new Lt(l.shape,m.shape,[G,R,z],g,I);return this.compileAndRun(Ge,[l,m],Te)},p.prototype.fusedBatchMatMul=function(l){var m=l.a,g=l.b,I=l.transposeA,R=l.transposeB,z=l.bias,L=l.activation,G=l.preluActivationWeights,Z=I?m.shape[2]:m.shape[1],be=R?g.shape[1]:g.shape[2],Ce=Math.max(m.shape[0],g.shape[0]),De=i.upcastType(m.dtype,g.dtype),Te=z!=null,Ge=G!=null,Ze=L?Vs(L,!0):null,s=new Lt(m.shape,g.shape,[Ce,Z,be],I,R,Te,Ze,Ge),u=[m,g];return z&&u.push(z),G&&u.push(G),this.compileAndRun(s,u,De)},p.prototype.localResponseNormalization4D=function(l,m,g,I,R){var z=i.env().getBool("WEBGL_PACK_NORMALIZATION")?new lt(l.shape,m,g,I,R):new et(l.shape,m,g,I,R);return this.compileAndRun(z,[l])},p.prototype.LRNGrad=function(l,m,g,I,R,z,L){var G=new gt(m.shape,I,R,z,L);return this.compileAndRun(G,[m,g,l])},p.prototype.tile=function(l,m){if(l.dtype==="string"){var g=this.readSync(l.dataId),I=g.map(function(L){return i.util.decodeString(L)}),R=i.buffer(l.shape,l.dtype,I);return Au(R,m)}var z=new Yi(l.shape,m);return this.compileAndRun(z,[l])},p.prototype.pad=function(l,m,g){var I=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Et(l.shape,m,g):new wt(l.shape,m,g);return this.compileAndRun(I,[l])},p.prototype.gather=function(l,m,g){var I=this,R=this.tryRunOnCpuOrThrow([l,m],function(){return I.cpuBackend.gather(l,m,g)});if(R)return R;var z=new iu(l.shape,m.size,g);return this.compileAndRun(z,[l,m])},p.prototype.batchToSpaceND=function(l,m,g){i.util.assert(l.rank<=4,function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"});var I=m.reduce(function(be,Ce){return be*Ce}),R=i.backend_util.getReshaped(l.shape,m,I),z=i.backend_util.getPermuted(R.length,m.length),L=i.backend_util.getReshapedPermuted(l.shape,m,I),G=i.backend_util.getSliceBeginCoords(g,m.length),Z=i.backend_util.getSliceSize(L,g,m.length);return i.transpose(l.reshape(R),z).reshape(L).slice(G,Z)},p.prototype.spaceToBatchND=function(l,m,g){i.util.assert(l.rank<=4,function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"});var I=m.reduce(function(De,Te){return De*Te}),R=[[0,0]];R.push.apply(R,g);for(var z=1+m.length;zi.env().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var m=Math.floor(l.length/2),g=this.addN(l.slice(0,m)),I=this.addN(l.slice(m));return this.addN([g,I])}var R=l.map(function(Z){return Z.dtype}).reduce(function(Z,be){return i.upcastType(Z,be)}),z=l.map(function(Z){return Z.shape}),L=i.env().getBool("WEBGL_PACK"),G=L?new hn(l[0].shape,z):new sn(l[0].shape,z);return this.compileAndRun(G,l,R)},p.prototype.pow=function(l,m){var g=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"),I=g?new vi(vo,l.shape,m.shape):new vn(Ka,l.shape,m.shape),R=i.upcastType(l.dtype,m.dtype);return this.compileAndRun(I,[l,m],R)},p.prototype.ceil=function(l){if(this.shouldExecuteOnCPU([l])){var m=Le(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Su,l.dtype);var g=new Or(l.shape,Su);return this.compileAndRun(g,[l])},p.prototype.floor=function(l){if(this.shouldExecuteOnCPU([l])){var m=St(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Iu,l.dtype);var g=new Or(l.shape,Iu);return this.compileAndRun(g,[l])},p.prototype.sign=function(l){var m=new Or(l.shape,lc);return this.compileAndRun(m,[l])},p.prototype.isNaN=function(l){var m=new Or(l.shape,xs);return this.compileAndRun(m,[l],"bool")},p.prototype.isInf=function(l){var m=new Or(l.shape,Ii);return this.compileAndRun(m,[l],"bool")},p.prototype.isFinite=function(l){var m=new Or(l.shape,_s);return this.compileAndRun(m,[l],"bool")},p.prototype.round=function(l){var m=new Or(l.shape,bo);return this.compileAndRun(m,[l])},p.prototype.exp=function(l){if(this.shouldExecuteOnCPU([l])){var m=Ye(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,so,l.dtype);var g=new Or(l.shape,so);return this.compileAndRun(g,[l])},p.prototype.expm1=function(l){if(this.shouldExecuteOnCPU([l])){var m=Ft(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Nu,l.dtype);var g=new Or(l.shape,Nu);return this.compileAndRun(g,[l])},p.prototype.softmax=function(l,m){var g=i.util.parseAxisParam([m],l.shape),I=i.max(l,g),R=i.backend_util.expandShapeToKeepDim(I.shape,g),z=i.sub(l,I.reshape(R)),L=this.exp(z),G=this.sum(L,g).reshape(R);return i.div(L,G)},p.prototype.log=function(l){if(this.shouldExecuteOnCPU([l])){var m=Mt(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Wo,l.dtype);var g=new Or(l.shape,uu);return this.compileAndRun(g,[l])},p.prototype.log1p=function(l){var m=new Or(l.shape,ws);return this.compileAndRun(m,[l])},p.prototype.sqrt=function(l){var m=new Or(l.shape,Cu);return this.compileAndRun(m,[l])},p.prototype.rsqrt=function(l){if(this.shouldExecuteOnCPU([l])){var m=ta(this.texData.get(l.dataId).values,l.dtype);return this.makeOutput(l.shape,l.dtype,m)}var g=new Or(l.shape,cu);return this.compileAndRun(g,[l])},p.prototype.reciprocal=function(l){var m=new Or(l.shape,Ni);return this.compileAndRun(m,[l])},p.prototype.relu=function(l){var m;return i.env().getBool("WEBGL_PACK")?m=new as(l.shape,co):m=new Or(l.shape,dn),this.compileAndRun(m,[l])},p.prototype.relu6=function(l){var m;return i.env().getBool("WEBGL_PACK")?m=new as(l.shape,Uo):m=new Or(l.shape,Bo),this.compileAndRun(m,[l])},p.prototype.prelu=function(l,m){var g=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vi(Aa,l.shape,m.shape):new vn(ka,l.shape,m.shape);return this.compileAndRun(g,[l,m])},p.prototype.elu=function(l){if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,lu,l.dtype);var m=new Or(l.shape,Fn);return this.compileAndRun(m,[l])},p.prototype.eluDer=function(l,m){var g=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vi(go,l.shape,m.shape):new vn(oo,l.shape,m.shape);return this.compileAndRun(g,[l,m])},p.prototype.selu=function(l){var m=new Or(l.shape,su);return this.compileAndRun(m,[l])},p.prototype.clip=function(l,m,g){var I;i.env().getBool("WEBGL_PACK_CLIP")?I=new tu(l.shape):I=new Fs(l.shape);var R=I.getCustomSetupFunc(m,g);return this.compileAndRun(I,[l],null,R)},p.prototype.abs=function(l){if(this.shouldExecuteOnCPU([l])&&l.dtype!=="complex64"){var m=kt(this.texData.get(l.dataId).values);return this.makeOutput(l.shape,l.dtype,m)}if(i.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(l,Po,l.dtype);var g=new Or(l.shape,Po);return this.compileAndRun(g,[l])},p.prototype.complexAbs=function(l){var m=this.texData.get(l.dataId),g=new ps(l.shape),I=[this.makeComplexComponentTensorInfo(l,m.complexTensorInfos.real),this.makeComplexComponentTensorInfo(l,m.complexTensorInfos.imag)];return this.compileAndRun(g,I)},p.prototype.sigmoid=function(l){var m=new Or(l.shape,Tu);return this.compileAndRun(m,[l])},p.prototype.softplus=function(l){var m=new Or(l.shape,hc);return this.compileAndRun(m,[l])},p.prototype.asin=function(l){var m=new Or(l.shape,uo);return this.compileAndRun(m,[l])},p.prototype.acos=function(l){var m=new Or(l.shape,bs);return this.compileAndRun(m,[l])},p.prototype.atan=function(l){var m=new Or(l.shape,Eu);return this.compileAndRun(m,[l])},p.prototype.sinh=function(l){var m=new Or(l.shape,pc);return this.compileAndRun(m,[l])},p.prototype.cosh=function(l){var m=new Or(l.shape,dc);return this.compileAndRun(m,[l])},p.prototype.tanh=function(l){var m=new Or(l.shape,fc);return this.compileAndRun(m,[l])},p.prototype.asinh=function(l){var m=new Or(l.shape,vl);return this.compileAndRun(m,[l])},p.prototype.acosh=function(l){var m=new Or(l.shape,Ru);return this.compileAndRun(m,[l])},p.prototype.atanh=function(l){var m=new Or(l.shape,mc);return this.compileAndRun(m,[l])},p.prototype.erf=function(l){var m=new Or(l.shape,yc);return this.compileAndRun(m,[l])},p.prototype.step=function(l,m){var g=new Or(l.shape,cc(m));return this.compileAndRun(g,[l])},p.prototype.conv2dByMatMul=function(l,m,g,I,R,z){var L=l.shape,G=this.texData.get(l.dataId),Z=g.inChannels,be=L[0]*L[1]*L[2],Ce=g.outChannels,De=g.dataFormat==="channelsLast",Te=!1,Ge=!1,Ze=(be===1||Ce===1)&&Z>Fu,s=L[2]%2!==0&&!!G.isPacked;if(Ze||!i.env().getBool("WEBGL_LAZILY_UNPACK")||!i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!s){var u=De?L[0]*L[1]*L[2]:L[0]*L[2]*L[3],r=i.reshape(l,[1,u,g.inChannels]),o=i.reshape(m,[1,g.inChannels,g.outChannels]),h=this.fusedBatchMatMul({a:r,b:o,transposeA:Te,transposeB:Ge,bias:I,activation:R,preluActivationWeights:z});return i.reshape(h,g.outShape)}var b=De?L[0]*L[1]*(L[2]+1):L[0]*L[2]*(L[3]+1),T={dataId:l.dataId,shape:[1,b,g.inChannels],dtype:l.dtype},M=G.shape;G.shape=G.shape.slice(),G.shape[G.shape.length-2]++,i.util.assert(_n(G.shape,T.shape),function(){return"packed reshape "+G.shape+" to "+T.shape+" isn't free"});var q=i.reshape(m,[1,g.inChannels,g.outChannels]),Y=this.fusedBatchMatMul({a:T,b:q,transposeA:Te,transposeB:Ge,bias:I,activation:R,preluActivationWeights:z}),le=this.texData.get(Y.dataId);return i.util.assert(le.isPacked,function(){return"batchMatMul result is expected to be packed"}),G.shape=M,le.shape=g.outShape,i.engine().makeTensorFromDataId(Y.dataId,g.outShape,Y.dtype)},p.prototype.conv2dWithIm2Row=function(l,m,g,I,R,z){var L=g.filterWidth,G=g.filterHeight,Z=g.inChannels,be=g.outWidth,Ce=g.outHeight,De=g.dataFormat,Te=De==="channelsLast",Ge=L*G*Z,Ze=Ce*be,s=[Ge,Ze],u=!0,r=!1,o=l.squeeze([0]),h=m.reshape([1,Ge,-1]),b=new $(s,o.shape,g),T=this.compileAndRun(b,[o]).reshape([1,s[0],s[1]]),M=I!=null,q=z!=null,Y=R?Vs(R,!0):null,le=new Lt(T.shape,h.shape,[1,Ze,g.outChannels],u,r,M,Y,q),Ne=[T,h];I&&Ne.push(I),q&&Ne.push(z);var We=this.compileAndRun(le,Ne);return Te?We.reshape([1,Ce,be,g.outChannels]):We.reshape([1,g.outChannels,Ce,be])},p.prototype.fusedConv2d=function(l){var m=l.input,g=l.filter,I=l.convInfo,R=l.bias,z=l.activation,L=l.preluActivationWeights;if(I.filterHeight===1&&I.filterWidth===1&&I.dilationHeight===1&&I.dilationWidth===1&&I.strideHeight===1&&I.strideWidth===1&&(I.padInfo.type==="SAME"||I.padInfo.type==="VALID"))return this.conv2dByMatMul(m,g,I,R,z,L);if(i.env().getBool("WEBGL_CONV_IM2COL")&&m.shape[0]===1)return this.conv2dWithIm2Row(m,g,I,R,z,L);var G=R!=null,Z=L!=null,be=z?Vs(z,!1):null,Ce=new fs(I,G,be,Z),De=[m,g];return R&&De.push(R),L&&De.push(L),this.compileAndRun(Ce,De)},p.prototype.conv2d=function(l,m,g){if(g.filterHeight===1&&g.filterWidth===1&&g.dilationHeight===1&&g.dilationWidth===1&&g.strideHeight===1&&g.strideWidth===1&&(g.padInfo.type==="SAME"||g.padInfo.type==="VALID"))return this.conv2dByMatMul(l,m,g);if(i.env().getBool("WEBGL_CONV_IM2COL")&&l.shape[0]===1)return this.conv2dWithIm2Row(l,m,g);var I=new fs(g);return this.compileAndRun(I,[l,m])},p.prototype.conv2dDerInput=function(l,m,g){var I=new Os(g);return this.compileAndRun(I,[l,m])},p.prototype.conv2dDerFilter=function(l,m,g){var I=new ru(g);return this.compileAndRun(I,[l,m])},p.prototype.fusedDepthwiseConv2D=function(l){var m=l.input,g=l.filter,I=l.convInfo,R=l.bias,z=l.activation,L=l.preluActivationWeights,G=i.env().getBool("WEBGL_PACK_DEPTHWISECONV")&&I.strideWidth<=2&&I.outChannels/I.inChannels===1,Z=z?Vs(z,G):null,be=[m,g],Ce=R!=null,De=L!=null;Ce&&be.push(R),De&&be.push(L);var Te;return G?(Te=new Do(I,Ce,Z,De),this.compileAndRun(Te,be)):(Te=new ms(I,Ce,Z,De),this.compileAndRun(Te,be))},p.prototype.depthwiseConv2D=function(l,m,g){var I;return i.env().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels===1?(I=new Do(g),this.compileAndRun(I,[l,m])):(I=new ms(g),this.compileAndRun(I,[l,m]))},p.prototype.depthwiseConv2DDerInput=function(l,m,g){var I=new nu(g);return this.compileAndRun(I,[l,m])},p.prototype.depthwiseConv2DDerFilter=function(l,m,g){var I=new Ls(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3d=function(l,m,g){var I=new au(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3dDerInput=function(l,m,g){var I=new Ms(g);return this.compileAndRun(I,[l,m])},p.prototype.conv3dDerFilter=function(l,m,g){var I=new ds(g);return this.compileAndRun(I,[l,m])},p.prototype.unstack=function(l,m){for(var g=l.shape[m],I=new Array(l.rank-1),R=0,z=0;z1,function(){return"blockSize should be > 1 for depthToSpace, but was: "+m});var I=l.shape[0],R=g==="NHWC"?l.shape[1]:l.shape[2],z=g==="NHWC"?l.shape[2]:l.shape[3],L=g==="NHWC"?l.shape[3]:l.shape[1],G=R*m,Z=z*m,be=L/(m*m),Ce=g==="NHWC"?[I,G,Z,be]:[I,be,G,Z],De=new Jo(Ce,m,g);return this.compileAndRun(De,[l])},p.prototype.split=function(l,m,g){return xl(l,m,g)},p.prototype.scatterND=function(l,m,g){var I=i.backend_util.calculateShapes(m,l,g),R=I.sliceRank,z=I.numUpdates,L=I.sliceSize,G=I.strides,Z=I.outputSize,be=[Z/L,L],Ce=l.reshape([z,R]),De=m.reshape([z,L]);if(Z===0)return i.backend_util.reshapeTensor(i.tensor([]),g);var Te=i.scalar(0),Ge=new an(z,R,Ce.rank,De.rank,G,be),Ze=this.compileAndRun(Ge,[De,Ce,Te]);return Ze.reshape(g)},p.prototype.sparseToDense=function(l,m,g,I){var R=i.backend_util.calculateShapes(m,l,g),z=R.sliceRank,L=R.numUpdates,G=R.strides,Z=R.outputSize,be=!1,Ce=new an(L,z,l.rank,m.rank,G,[Z,1],be),De=this.compileAndRun(Ce,[m,l,I]);return De.reshape(g)},p.prototype.gatherND=function(l,m){var g=m.shape,I=g[g.length-1],R=i.backend_util.prepareAndValidate(l,m),z=R[0],L=R[1],G=R[2],Z=R[3],be=m.reshape([L,I]),Ce=l.reshape([l.size/G,G]),De=new ou(I,Z,[L,G]),Te=this.compileAndRun(De,[Ce,be]);return Te.reshape(z)},p.prototype.fill=function(l,m,g){if(g=g||i.util.inferDtype(m),g==="string"){var I=i.util.getArrayFromDType(g,i.util.sizeFromShape(l));return I.fill(m),i.engine().makeTensor(I,l,g,this)}else{var R=new $o(l,m),z=R.getCustomSetupFunc(m);return this.compileAndRun(R,[],g,z)}},p.prototype.onesLike=function(l){if(l.dtype==="string")throw new Error("onesLike is not supported under string dtype");return this.fill(l.shape,1,l.dtype)},p.prototype.zerosLike=function(l){return this.fill(l.shape,l.dtype==="string"?"":0,l.dtype)},p.prototype.linspace=function(l,m,g){return i.backend_util.linspaceImpl(l,m,g)},p.prototype.makeTensorInfo=function(l,m,g){var I=this.write(g,l,m);return this.texData.get(I).usage=null,{dataId:I,shape:l,dtype:m}},p.prototype.makeOutput=function(l,m,g){var I=this.makeTensorInfo(l,m,g).dataId;return i.engine().makeTensorFromDataId(I,l,m,this)},p.prototype.unpackTensor=function(l){var m=new Vo(l.shape);return this.runWebGLProgram(m,[l],l.dtype)},p.prototype.packTensor=function(l){var m=new Nt(l.shape),g=!0;return this.runWebGLProgram(m,[l],l.dtype,null,g)},p.prototype.packedReshape=function(l,m){var g=[Ua(l.shape)].concat(ga(l.shape)),I={dtype:l.dtype,shape:g,dataId:l.dataId},R=[Ua(m)].concat(ga(m)),z=new rr(R,g),L=!0,G=this.runWebGLProgram(z,[I],l.dtype,null,L);return{dataId:G.dataId,shape:m,dtype:G.dtype}},p.prototype.decode=function(l){var m=this.texData.get(l),g=m.isPacked,I=m.shape,R=m.dtype,z=wi(I),L;g?L=new Ps(z):L=new Fo(z);var G=!0,Z=this.runWebGLProgram(L,[{shape:z,dtype:R,dataId:l}],R,null,G);return{dtype:R,shape:I,dataId:Z.dataId}},p.prototype.runWebGLProgram=function(l,m,g,I,R){var z=this;R===void 0&&(R=!1);var L=this.makeTensorInfo(l.outputShape,g),G=this.texData.get(L.dataId);if(l.packedOutput&&(G.isPacked=!0),l.outPackingScheme===ae.DENSE){var Z=nt(l.outputShape);G.texShape=Z.map(function(r){return r*2})}if(l.outTexUsage!=null&&(G.usage=l.outTexUsage),i.util.sizeFromShape(L.shape)===0)return G.values=i.util.getTypedArrayFromDType(L.dtype,0),L;var be=[],Ce=m.map(function(r){if(r.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var o=z.texData.get(r.dataId);if(o.texture==null){if(!l.packedInputs&&i.util.sizeFromShape(r.shape)<=i.env().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:r.shape,texData:null,isUniform:!0,uniformValues:o.values};l.packedInputs&&(o.isPacked=!0,o.shape=r.shape)}else if(!!o.isPacked!==!!l.packedInputs)r=o.isPacked?z.unpackTensor(r):z.packTensor(r),be.push(r),o=z.texData.get(r.dataId);else if(o.isPacked&&!_n(o.shape,r.shape)){var h=r,b=r.shape;r.shape=o.shape,r=z.packedReshape(r,b),be.push(r),o=z.texData.get(r.dataId),h.shape=b}return z.uploadToGPU(r.dataId),{shape:r.shape,texData:o,isUniform:!1}});this.uploadToGPU(L.dataId);var De={shape:L.shape,texData:G,isUniform:!1},Te=at(l,Ce,De),Ge=this.getAndSaveBinary(Te,function(){return Ve(z.gpgpu,l,Ce,De)}),Ze=this.activeTimers!=null,s;if(Ze&&(s=this.startTimer()),rt(this.gpgpu,Ge,Ce,De,I),be.forEach(function(r){return z.disposeIntermediateTensorInfo(r)}),Ze&&(s=this.endTimer(s),this.activeTimers.push({name:l.constructor.name,query:this.getQueryTime(s)})),!i.env().getBool("WEBGL_LAZILY_UNPACK")&&G.isPacked&&R===!1){var u=this.unpackTensor(L);return this.disposeIntermediateTensorInfo(L),u}return L},p.prototype.compileAndRun=function(l,m,g,I,R){R===void 0&&(R=!1),g=g||m[0].dtype;var z=this.runWebGLProgram(l,m,g,I,R);return i.engine().makeTensorFromDataId(z.dataId,z.shape,z.dtype)},p.prototype.getAndSaveBinary=function(l,m){return l in this.binaryCache||(this.binaryCache[l]=m()),this.binaryCache[l]},p.prototype.getTextureManager=function(){return this.textureManager},p.prototype.dispose=function(){var l=this;if(this.disposed)return;if(!i.env().getBool("IS_TEST")){var m=Object.keys(this.binaryCache);m.forEach(function(g){l.gpgpu.deleteProgram(l.binaryCache[g].webGLProgram),delete l.binaryCache[g]})}this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement!="undefined"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0},p.prototype.floatPrecision=function(){var l=this;return this.floatPrecisionValue==null&&(this.floatPrecisionValue=i.tidy(function(){if(!i.env().get("WEBGL_RENDER_FLOAT32_ENABLED")){var m=i.env().getBool("DEBUG");i.env().set("DEBUG",!1);var g=l.abs(i.scalar(1e-8)).dataSync()[0];if(i.env().set("DEBUG",m),g>0)return 32}return 16})),this.floatPrecisionValue},p.prototype.epsilon=function(){return this.floatPrecision()===32?xc:Qi},p.prototype.uploadToGPU=function(l){var m,g=this.texData.get(l),I=g.shape,R=g.dtype,z=g.values,L=g.texture,G=g.usage,Z=g.isPacked;if(L!=null)return;var be=this.activeTimers!=null,Ce;be&&(Ce=i.util.now());var De=g.texShape;if(De==null&&(De=Ta(I,Z),g.texShape=De),z!=null){var Te=wi(I),Ge=void 0,Ze=De[1],s=De[0],u=z instanceof Uint8Array;Z?(m=tt(De[0],De[1]),Ze=m[0],s=m[1],Ge=new vs(Te,[s,Ze],u)):Ge=new Ws(Te,[s,Ze],u);var r=this.makeTensorInfo([s,Ze],R);u?this.texData.get(r.dataId).usage=w.PIXELS:this.texData.get(r.dataId).usage=w.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(r.dataId),Ze,s,z);var o=!0,h=this.runWebGLProgram(Ge,[r],R,null,o),b=this.texData.get(h.dataId);g.texture=b.texture,g.texShape=b.texShape,g.isPacked=b.isPacked,g.usage=b.usage,this.disposeIntermediateTensorInfo(r),this.texData.delete(h.dataId),g.values=null,be&&(this.uploadWaitMs+=i.util.now()-Ce)}else{var T=this.acquireTexture(De,G,R,Z);g.texture=T}},p.prototype.convertAndCacheOnCPU=function(l,m){var g=this.texData.get(l),I=g.dtype;return this.releaseGPUData(l),m!=null&&(g.values=wc(m,I)),g.values},p.prototype.acquireTexture=function(l,m,g,I){if(this.numBytesInGPU+=this.computeBytes(l,g),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){var R=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: "+R+" MB, most likely due to a memory leak")}return this.textureManager.acquireTexture(l,m,I)},p.prototype.computeBytes=function(l,m){return l[0]*l[1]*i.util.bytesPerElement(m)},p.prototype.tryRunOnCpuOrThrow=function(l,m){if(this.shouldExecuteOnCPU(l))try{return m()}catch(g){if(i.env().getBool("IS_TEST"))throw new Error("CPU forwarding failed")}return null},p}(i.KernelBackend);function wc(f,p){if(p==="float32"||p==="complex64")return f;if(p==="int32"||p==="bool"){for(var l=p==="int32"?new Int32Array(f.length):new Uint8Array(f.length),m=0;m 0. ? NAN : result.r; result.g = isNaN.g > 0. ? NAN : result.g; result.b = isNaN.b > 0. ? NAN : result.b; result.a = isNaN.a > 0. ? NAN : result.a; `;function Gs(f){return function(p){var l=p.inputs,m=p.backend,g=l.x,I=m,R=new Or(g.shape,f);return I.runWebGLProgram(R,[g],g.dtype)}}function po(f){var p=f.opSnippet,l=f.packedOpSnippet,m=f.checkOutOfBounds,g=m===void 0?!1:m,I=f.supportsComplex,R=I===void 0?!1:I,z=f.cpuKernelImpl,L=f.dtype;return function(G){var Z=G.inputs,be=G.backend,Ce=Z,De=Ce.a,Te=Ce.b,Ge=be;if(R&&De.dtype==="complex64"){var Ze=Ge.texData.get(De.dataId),s=Ge.texData.get(Te.dataId),u=[[Ze.complexTensorInfos.real,s.complexTensorInfos.real],[Ze.complexTensorInfos.imag,s.complexTensorInfos.imag]].map(function(je){var qe=je[0],mt=je[1],pt={dataId:qe.dataId,dtype:qe.dtype,shape:De.shape},st={dataId:mt.dataId,dtype:mt.dtype,shape:Te.shape},dt=new vn(p,De.shape,Te.shape);return Ge.runWebGLProgram(dt,[pt,st],i.upcastType(qe.dtype,mt.dtype))}),r=u[0],o=u[1],h=ho({inputs:{real:r,imag:o},backend:Ge});return Ge.disposeIntermediateTensorInfo(r),Ge.disposeIntermediateTensorInfo(o),h}var b=L||i.upcastType(De.dtype,Te.dtype);if(Ge.shouldExecuteOnCPU([De,Te])&&z!=null){var Ze=Ge.texData.get(De.dataId),s=Ge.texData.get(Te.dataId),T=z(De.shape,Te.shape,Ze.values,s.values,b),M=T[0],q=T[1],Y=Ge.makeTensorInfo(q,b),le=Ge.texData.get(Y.dataId);return le.values=M,Y}var Ne=i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&l!=null,We;return Ne?We=new vi(l,De.shape,Te.shape,g):We=new vn(p,De.shape,Te.shape),Ge.runWebGLProgram(We,[De,Te],b)}}var Lu="return a + b;",_l=po({opSnippet:Lu,packedOpSnippet:Lu,supportsComplex:!0,cpuKernelImpl:$e}),zu={kernelName:i.Add,backendName:"webgl",kernelFunc:_l},Pu=Ic+` return atan(a, b); `,du=` vec4 result = atan(a, b); vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0)); `+Mu+` return result; `,wl=po({opSnippet:Pu,packedOpSnippet:du}),fu={kernelName:i.Atan2,backendName:"webgl",kernelFunc:wl};function mu(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x;ln(g,"avgPool");var I=m.filterSize,R=m.strides,z=m.pad,L=m.dimRoundingMode,G=1;i.util.assert(i.backend_util.eitherStridesOrDilationsAreOne(R,G),function(){return"Error in avgPool: Either strides or dilations must be 1. "+("Got strides "+R+" and dilations '"+G+"'")});var Z=i.backend_util.computePool2DInfo(g.shape,I,R,G,z,L);if(Z.filterWidth===1&&Z.filterHeight===1&&i.util.arraysEqual(Z.inShape,Z.outShape))return lo({inputs:{x:g},backend:l});var be=new Vt(Z,"avg",!1);return l.runWebGLProgram(be,[g],"float32")}var Nc={kernelName:i.AvgPool,backendName:"webgl",kernelFunc:mu};function Cc(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.dy,I=p.input,R=I;ln([g,I],"avgPoolBackprop");var z=m.filterSize,L=m.strides,G=m.pad,Z=i.backend_util.computePool2DInfo(R.shape,z,L,1,G),be=new oi(Z);return l.runWebGLProgram(be,[g],R.dtype)}var Tc={kernelName:i.AvgPoolBackprop,backendName:"webgl",kernelFunc:Cc},Ec=function(){function f(p,l,m,g,I,R){this.outputShape=[],this.variableNames=["x","mean","variance"],i.backend_util.assertAndGetBroadcastShape(p,l),i.backend_util.assertAndGetBroadcastShape(p,m);var z="0.0";g!=null&&(i.backend_util.assertAndGetBroadcastShape(p,g),this.variableNames.push("offset"),z="getOffsetAtOutCoords()");var L="1.0";I!=null&&(i.backend_util.assertAndGetBroadcastShape(p,I),this.variableNames.push("scale"),L="getScaleAtOutCoords()"),this.outputShape=p,this.userCode=` void main() { float x = getXAtOutCoords(); float mean = getMeanAtOutCoords(); float variance = getVarianceAtOutCoords(); float offset = `+z+`; float scale = `+L+`; float inv = scale * inversesqrt(variance + float(`+R+`)); setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1))); } `}return f}(),Ke=function(){function f(p,l,m,g,I,R){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],i.backend_util.assertAndGetBroadcastShape(p,l),i.backend_util.assertAndGetBroadcastShape(p,m);var z="vec4(0.0)";g!=null&&(i.backend_util.assertAndGetBroadcastShape(p,g),this.variableNames.push("offset"),z="getOffsetAtOutCoords()");var L="vec4(1.0)";I!=null&&(i.backend_util.assertAndGetBroadcastShape(p,I),this.variableNames.push("scale"),L="getScaleAtOutCoords()"),this.outputShape=p,this.userCode=` void main() { vec4 offset = `+z+`; vec4 scale = `+L+`; vec4 x = getXAtOutCoords(); vec4 mean = getMeanAtOutCoords(); vec4 variance = getVarianceAtOutCoords(); vec4 inv = scale * inversesqrt(variance + vec4(`+R+`)); setOutput((x - mean) * inv + offset); } `}return f}(),Rc=function(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=p.mean,R=p.variance,z=p.offset,L=p.scale;i.util.assert(I.shape.length===R.shape.length,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),i.util.assert(z==null||I.shape.length===z.shape.length,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),i.util.assert(L==null||I.shape.length===L.shape.length,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var G=m.varianceEpsilon;G==null&&(G=.001);var Z=[g,I,R],be=null;z!=null&&(be=z.shape,Z.push(z));var Ce=null;L!=null&&(Ce=L.shape,Z.push(L));var De=i.env().getBool("WEBGL_PACK_NORMALIZATION")?new Ke(g.shape,I.shape,R.shape,be,Ce,G):new Ec(g.shape,I.shape,R.shape,be,Ce,G),Te=l.runWebGLProgram(De,Z,Z[0].dtype);return Te},un={kernelName:i.FusedBatchNorm,backendName:"webgl",kernelFunc:Rc},Ac="return float(a != b);",Ss=po({opSnippet:Ac,dtype:"bool"}),Dc={kernelName:i.NotEqual,backendName:"webgl",kernelFunc:Ss};function $n(f){var p=f.inputs,l=f.backend,m=p.input,g=l.texData.get(m.dataId);return lo({inputs:{x:g.complexTensorInfos.real},backend:l})}var Fc={kernelName:i.Real,backendName:"webgl",kernelFunc:$n},Oc="return float(int(x));";function Mc(f,p){var l=new Or(f.shape,Oc),m=p.runWebGLProgram(l,[f],"int32");return{dataId:m.dataId,shape:m.shape,dtype:m.dtype}}function js(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=m.dtype;if(I==="complex64"){if(g.dtype==="complex64")return lo({inputs:{x:g},backend:l});var R=i.zeros(g.shape),z=js({inputs:{x:g},backend:l,attrs:{dtype:"float32"}}),L=ho({inputs:{real:z,imag:R},backend:l});return R.dispose(),l.disposeIntermediateTensorInfo(z),L}if(g.dtype==="complex64"){var G=$n({inputs:{input:g},backend:l}),L=js({inputs:{x:G},backend:l,attrs:{dtype:I}});return l.disposeIntermediateTensorInfo(G),L}if(!i.util.hasEncodingLoss(g.dtype,I)){var L=lo({inputs:{x:g},backend:l});return{dataId:L.dataId,shape:L.shape,dtype:I}}if(I==="int32")return Mc(g,l);if(I==="bool"){var Z=l.makeTensorInfo([],"bool",i.util.getTypedArrayFromDType("bool",1)),be={a:g,b:Z},L=Ss({inputs:be,backend:l});return l.disposeIntermediateTensorInfo(Z),L}throw new Error("Error in Cast: failed to cast "+g.dtype+" to "+I)}var is={kernelName:i.Cast,backendName:"webgl",kernelFunc:js},Lc=function(){function f(p){this.outputShape=[],this.outputShape=i.backend_util.computeOutShape(p,1),this.variableNames=p.map(function(L,G){return"T"+G});var l=new Array(p.length-1);l[0]=p[0][1];for(var m=1;m= "+L[G-1]+`) { return getChannel( getT`+G+"("+yu(z,Z,Te)+`), vec2(`+yu(be,Z,Te)+`)); }`}var Ge=L.length,Ze=L[L.length-1];De+=` return getChannel( getT`+Ge+"("+yu(z,Z,Ze)+`), vec2(`+yu(be,Z,Ze)+"));",this.userCode=` float getValue(`+z.map(function(s){return"int "+s})+`) { `+De+` } void main() { `+I+` coords = getOutputCoords(); vec4 result = vec4(getValue(`+R+`), 0., 0., 0.); `+R[g-1]+" = "+R[g-1]+` + 1; if (`+R[g-1]+" < "+m[g-1]+`) { result.g = getValue(`+R+`); } `+R[g-2]+" = "+R[g-2]+` + 1; if (`+R[g-2]+" < "+m[g-2]+`) { result.a = getValue(`+R+`); } `+R[g-1]+" = "+R[g-1]+` - 1; if (`+R[g-2]+" < "+m[g-2]+` && `+R[g-1]+" < "+m[g-1]+`) { result.b = getValue(`+R+`); } setOutput(result); } `}return f}();function yu(f,p,l){var m=f.indexOf(p),g=f.map(function(I,R){return R===m?I+" - "+l:I});return g.join()}function Pc(f){var p=f.inputs,l=f.backend,m=p.input,g=l.texData.get(m.dataId);return lo({inputs:{x:g.complexTensorInfos.imag},backend:l})}var Bu={kernelName:i.Imag,backendName:"webgl",kernelFunc:Pc};function bl(f,p,l){var m=[Ua(f.shape)].concat(ga(f.shape)),g={dtype:f.dtype,shape:m,dataId:f.dataId},I=[Ua(p)].concat(ga(p)),R=new rr(I,m),z=!0,L=l.runWebGLProgram(R,[g],f.dtype,null,z);return{dataId:L.dataId,shape:p,dtype:L.dtype}}function Zi(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=m.shape,R=l,z=i.util.sizeFromShape(g.shape),L=i.util.inferFromImplicitShape(I,z),G=i.util.sizeFromShape(L);i.util.assert(z===G,function(){return"The new shape ("+L+") has "+G+" elements and the old "+("shape ("+g.shape+") has "+z+" elements. The new shape and old ")+"shape must have the same number of elements."});var Z=R.texData.get(g.dataId);return Z.isPacked&&!_n(g.shape,L)&&!(Z.texture!==null&&_n(Z.shape,L))?bl(g,L,R):(R.incRef(g.dataId),{dataId:g.dataId,shape:L,dtype:g.dtype})}var Wu={kernelName:i.Reshape,backendName:"webgl",kernelFunc:Zi};function os(f,p,l){var m=f[0].dtype;if(m==="complex64"){var g=f.map(function(r){return $n({inputs:{input:r},backend:l})}),I=f.map(function(r){return Pc({inputs:{input:r},backend:l})}),R=os(g,p,l),z=os(I,p,l),L=ho({inputs:{real:R,imag:z},backend:l});return g.forEach(function(r){return l.disposeIntermediateTensorInfo(r)}),I.forEach(function(r){return l.disposeIntermediateTensorInfo(r)}),l.disposeIntermediateTensorInfo(R),l.disposeIntermediateTensorInfo(z),L}if(f.length>i.env().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var G=Math.floor(f.length/2),Z=os(f.slice(0,G),p,l),be=os(f.slice(G),p,l),Ce=os([Z,be],p,l);return l.disposeIntermediateTensorInfo(Z),l.disposeIntermediateTensorInfo(be),Ce}if(i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&f[0].shape.length>1){var De=new zc(f.map(function(r){return r.shape}),p);return l.runWebGLProgram(De,f,m)}var Te=i.backend_util.computeOutShape(f.map(function(r){return r.shape}),p),Ge=f.map(function(r){return Zi({inputs:{x:r},attrs:{shape:[-1,i.util.sizeFromShape(r.shape.slice(p))]},backend:l})}),Ze=new Lc(Ge.map(function(r){return r.shape})),s=l.runWebGLProgram(Ze,Ge,m);Ge.forEach(function(r){return l.disposeIntermediateTensorInfo(r)});var u=Zi({inputs:{x:s},attrs:{shape:Te},backend:l});return l.disposeIntermediateTensorInfo(s),u}function kl(f){var p=f.inputs,l=f.backend,m=f.attrs,g=m.axis,I=i.util.parseAxisParam(g,p[0].shape)[0],R=i.backend_util.computeOutShape(p.map(function(G){return G.shape}),I);if(i.util.sizeFromShape(R)===0)return l.makeTensorInfo(R,p[0].dtype,[]);var z=p.filter(function(G){return i.util.sizeFromShape(G.shape)>0});if(z.length===1)return z[0];var L=z.map(function(G){return G.shape});return i.backend_util.assertParamsConsistent(L,I),os(z,I,l)}var Bc={kernelName:i.Concat,backendName:"webgl",kernelFunc:kl},vu=pu+` return cos(x); `,Wc=Gs(vu),Uc={kernelName:i.Cos,backendName:"webgl",kernelFunc:Wc},Vc=` if (a == b) { return 1.0; }; return a / b;`,Hc=` // vec4 one = vec4(equal(a, b)); // return one + (vec4(1.0) - one) * a / b; vec4 result = a / b; if(a.x == b.x) { result.x = 1.; } if(a.y == b.y) { result.y = 1.; } if(a.z == b.z) { result.z = 1.; } if(a.w == b.w) { result.w = 1.; } return result; `,Gc=po({opSnippet:Vc,packedOpSnippet:Hc,checkOutOfBounds:!0}),jc={kernelName:i.Div,backendName:"webgl",kernelFunc:Gc},Uu=function(){function f(p,l,m){this.variableNames=["real","imag"];var g=l[1];this.outputShape=l;var I=m?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,R=m?g+".0":"1.0",z;if(p==="real")z="return real * expR - imag * expI;";else if(p==="imag")z="return real * expI + imag * expR;";else throw new Error('FFT component must be either "real" or "imag", got '+p+".");this.userCode=` const float exponentMultiplier = `+I+`; float unaryOpComplex(float real, float expR, float imag, float expI) { `+z+` } float mulMatDFT(int batch, int index) { float indexRatio = float(index) / float(`+g+`); float exponentMultiplierTimesIndexRatio = exponentMultiplier * indexRatio; float result = 0.0; for (int i = 0; i < `+g+`; i++) { // x = (-2|2 * PI / N) * index * i; float x = exponentMultiplierTimesIndexRatio * float(i); float expR = cos(x); float expI = sin(x); float real = getReal(batch, i); float imag = getImag(batch, i); result += unaryOpComplex(real, expR, imag, expI) / `+R+`; } return result; } void main() { ivec2 coords = getOutputCoords(); setOutput(mulMatDFT(coords[0], coords[1])); } `}return f}();function Vu(f,p,l){var m=l.texData.get(f.dataId),g=i.util.sizeFromShape(f.shape),I=f.shape[f.shape.length-1],R=g/I,z=Zi({inputs:{x:f},backend:l,attrs:{shape:[R,I]}}),L=z.shape,G=new Uu("real",L,p),Z=new Uu("imag",L,p),be=[{dataId:m.complexTensorInfos.real.dataId,dtype:m.complexTensorInfos.real.dtype,shape:L},{dataId:m.complexTensorInfos.imag.dataId,dtype:m.complexTensorInfos.imag.dtype,shape:L}],Ce=l.runWebGLProgram(G,be,"float32"),De=l.runWebGLProgram(Z,be,"float32"),Te=ho({inputs:{real:Ce,imag:De},backend:l});l.disposeIntermediateTensorInfo(Ce),l.disposeIntermediateTensorInfo(De);var Ge=Zi({inputs:{x:Te},backend:l,attrs:{shape:f.shape}});return l.disposeIntermediateTensorInfo(Ge),Ge}function qc(f){var p=f.inputs,l=f.backend,m=p.input;return Vu(m,!1,l)}var Kc={kernelName:i.FFT,backendName:"webgl",kernelFunc:qc},Sl=function(){function f(p){this.variableNames=["Image"],this.outputShape=[];var l=p[2];this.outputShape=p,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int x = coords[2]; int coordX = `+l+` - x; float outputValue; if(coordX >= 0 && coordX < `+l+`) { outputValue = getImage(coords[0], coords[1], coordX, coords[3]); } else { outputValue = getImage(coords[0], coords[1], coords[2], coords[3]); } setOutput(outputValue); } `}return f}(),Il={kernelName:i.FlipLeftRight,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.backend,m=p.image,g=l,I=new Sl(m.shape),R=g.runWebGLProgram(I,[m],m.dtype);return R}},Hu=function(){function f(p){this.variableNames=["A"];var l=tn(),m=p[0],g=p[1];this.outputShape=p,this.userCode=` void main() { ivec3 coords = getOutputCoords(); int texR = coords[0]; int texC = coords[1]; int depth = coords[2]; vec2 uv = (vec2(texC, texR) + halfCR) / vec2(`+g+".0, "+m+`.0); vec4 values = `+l.texture2D+`(A, uv); float value; if (depth == 0) { value = values.r; } else if (depth == 1) { value = values.g; } else if (depth == 2) { value = values.b; } else if (depth == 3) { value = values.a; } setOutput(floor(value * 255.0 + 0.5)); } `}return f}(),Xc=function(){function f(p){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var l=tn(),m=p[0],g=p[1];this.outputShape=p,this.userCode=` void main() { ivec3 coords = getOutputCoords(); int texR = coords[0]; int texC = coords[1]; int depth = coords[2]; vec4 result = vec4(0.); for(int row=0; row<=1; row++) { for(int col=0; col<=1; col++) { texC = coords[1] + row; depth = coords[2] + col; vec2 uv = (vec2(texC, texR) + halfCR) / vec2(`+g+".0, "+m+`.0); vec4 values = `+l.texture2D+`(A, uv); float value; if (depth == 0) { value = values.r; } else if (depth == 1) { value = values.g; } else if (depth == 2) { value = values.b; } else if (depth == 3) { value = values.a; } result[row * 2 + col] = floor(value * 255.0 + 0.5); } } `+l.output+` = result; } `}return f}(),Yc={kernelName:i.FromPixels,backendName:"webgl",kernelFunc:jo},ss;function jo(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.pixels,I=m.numChannels,R=typeof HTMLVideoElement!="undefined"&&g instanceof HTMLVideoElement,z=typeof HTMLImageElement!="undefined"&&g instanceof HTMLImageElement,L=R?[g.videoWidth,g.videoHeight]:[g.width,g.height],G=L[0],Z=L[1],be=[Z,G],Ce=[Z,G,I];(z||R)&&(ss==null&&(ss=document.createElement("canvas").getContext("2d")),ss.canvas.width=G,ss.canvas.height=Z,ss.drawImage(g,0,0,G,Z),g=ss.canvas);var De=l.makeTensorInfo(be,"int32");l.texData.get(De.dataId).usage=w.PIXELS,l.gpgpu.uploadPixelDataToTexture(l.getTexture(De.dataId),g);var Te=i.env().getBool("WEBGL_PACK")?new Xc(Ce):new Hu(Ce),Ge=l.runWebGLProgram(Te,[De],"int32");return l.disposeData(De.dataId),Ge}function Nl(f){var p=f.inputs,l=f.backend,m=p.input;return Vu(m,!0,l)}var Cl={kernelName:i.IFFT,backendName:"webgl",kernelFunc:Nl},Gu=function(){function f(p,l){this.variableNames=["x"];var m=p.windowSize,g=p.batchSize,I=p.inSize,R=p.outSize;this.outputShape=[g,R];var z=Math.floor(m/4)*4,L=m%4,G="sumValue += dot(values, ones);";if(l!=null){var Z=1/l;G="sumValue += dot(values * "+(i.util.isInt(Z)?Z.toPrecision(2):Z)+", ones);"}var be="";I%m>0&&(be=` if (inIdx < 0 || inIdx >= `+I+`) { return 0.0; } `),this.userCode=` const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); float getValue(int batch, int inIdx) { `+be+` return getX(batch, inIdx); } void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; int outIdx = coords[1]; int inOffset = outIdx * `+m+`; float sumValue = 0.0; for (int i = 0; i < `+z+`; i += 4) { int inIdx = inOffset + i; vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), getValue(batch, inIdx + 3) ); `+G+` } int inIdx = inOffset + `+z+`; if (`+(L===1)+`) { vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0); `+G+` } else if (`+(L===2)+`) { vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), 0.0, 0.0); `+G+` } else if (`+(L===3)+`) { vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), 0.0); `+G+` } setOutput(sumValue); } `}return f}();function Tl(f){for(var p=[];p.length===0||p[p.length-1].outSize!==1;){var l=p.length?p[p.length-1].outSize:f[1],m=i.backend_util.computeOptimalWindowSize(l);p.push({inSize:l,windowSize:m,outSize:Math.ceil(l/m)})}return p}function gu(f,p,l,m){for(var g=Tl(f.shape),I=f,R=0;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),z=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+"("+z+`); void main() { `+I+` outC = getOutputCoords(); for (int i = 0; i < `+g+`; i++) { if (outC[i] < start[i]) { outC[i] = start[i] * 2 - outC[i] - `+G+`; } else if(outC[i] >= end[i]) { outC[i] = (end[i] - 1) * 2 - outC[i] + `+G+`; } } `+I+` coords = outC - start; setOutput(getX(`+L+`)); } `}return f}(),Pl=function(){function f(p,l,m){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=l.map(function(Ge,Ze){return Ge[0]+p[Ze]+Ge[1]});var g=p.length,I=nn(g),R=l.map(function(Ge){return Ge[0]}).join(","),z=l.map(function(Ge,Ze){return Ge[0]+p[Ze]}).join(","),L=Vr("rc",g),G=Vr("source",g),Z=L[g-1]+" < "+this.outputShape[g-1],be=g===1?"source":"vec2("+G.slice(-2).join()+")",Ce=m==="reflect"?0:1,De="";if(g===1){var Te=` `+I+` source = rc; if (source < start) { source = start * 2 - source - `+Ce+`; } else if (source >= end) { source = (end - 1) * 2 - source + `+Ce+`; } source -= start; `;De=` `+I+` rc = outputLoc; `+Te+` result[0] = getChannel(getX(`+G.join()+"), "+be+`); `+L[g-1]+` += 1; if(`+Z+`) { `+Te+` result[1] = getChannel(getX(`+G.join()+"), "+be+`); } `}else{var Te=` `+I+` source = rc; `+I+" lt = "+I+`(lessThan(source, start)); `+I+" gte = "+I+`(greaterThanEqual(source, end)); `+I+` orig = 1 - (lt + gte); source = orig * source + lt * (start * 2 - source - `+Ce+`) + gte * ((end - 1) * 2 - source + `+Ce+`); source -= start; `;De=` `+I+` rc = outputLoc; `+Te+` result[0] = getChannel(getX(`+G.join()+"), "+be+`); `+L[g-1]+` += 1; if(`+Z+`) { `+Te+` result[1] = getChannel(getX(`+G.join()+"), "+be+`); } rc = outputLoc; `+L[g-2]+` += 1; if(`+L[g-2]+" < "+this.outputShape[g-2]+`) { `+Te+` result[2] = getChannel(getX(`+G.join()+"), "+be+`); `+L[g-1]+` += 1; if(`+Z+`) { `+Te+` result[3] = getChannel(getX(`+G.join()+"), "+be+`); } } `}this.userCode=` const `+I+" start = "+I+"("+R+`); const `+I+" end = "+I+"("+z+`); void main() { `+I+` outputLoc = getOutputCoords(); vec4 result = vec4(0.); `+De+` setOutput(result); } `}return f}(),Qc=function(f){var p=f.inputs,l=f.backend,m=f.attrs,g=p.x,I=m.paddings,R=m.mode,z=i.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Pl(g.shape,I,R):new zl(g.shape,I,R),L=l.runWebGLProgram(z,[g],g.dtype);return L},sa={kernelName:i.MirrorPad,backendName:"webgl",kernelFunc:Qc},Pa={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},xu=function(){function f(p,l,m){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=i.backend_util.assertAndGetBroadcastShape(l,m),this.userCode=` float binaryOpComplex( float areal, float aimag, float breal, float bimag) { `+p+` } void main() { float areal = getARealAtOutCoords(); float aimag = getAImagAtOutCoords(); float breal = getBRealAtOutCoords(); float bimag = getBImagAtOutCoords(); setOutput(binaryOpComplex(areal, aimag, breal, bimag)); } `}return f}(),Zc="return a * b;";function Bl(f){var p=f.inputs,l=f.backend,m=p.a,g=p.b,I=i.backend_util.upcastType(m.dtype,g.dtype);if(m.dtype==="complex64"){var R=l.texData.get(m.dataId),z=l.texData.get(g.dataId),L=new xu(Pa.REAL,m.shape,g.shape),G=new xu(Pa.IMAG,m.shape,g.shape),Z=[{dataId:R.complexTensorInfos.real.dataId,dtype:R.complexTensorInfos.real.dtype,shape:m.shape},{dataId:R.complexTensorInfos.imag.dataId,dtype:R.complexTensorInfos.imag.dtype,shape:m.shape},{dataId:z.complexTensorInfos.real.dataId,dtype:z.complexTensorInfos.real.dtype,shape:g.shape},{dataId:z.complexTensorInfos.imag.dataId,dtype:z.complexTensorInfos.imag.dtype,shape:g.shape}],be=l.runWebGLProgram(L,Z,"float32"),Ce=l.runWebGLProgram(G,Z,"float32"),De=ho({inputs:{real:be,imag:Ce},backend:l});return l.disposeIntermediateTensorInfo(be),l.disposeIntermediateTensorInfo(Ce),De}if(l.shouldExecuteOnCPU([m,g])){var R=l.texData.get(m.dataId),z=l.texData.get(g.dataId),Te=ir(m.shape,g.shape,R.values,z.values,I),Ge=Te[0],Ze=Te[1],s=l.makeTensorInfo(Ze,I),u=l.texData.get(s.dataId);return u.values=Ge,s}var r;return i.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?r=new vi(Zc,m.shape,g.shape):r=new vn(Zc,m.shape,g.shape),l.runWebGLProgram(r,[m,g],I)}var Wl={kernelName:i.Multiply,backendName:"webgl",kernelFunc:Bl},Ul={kernelName:i.NonMaxSuppressionV3,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.backend,m=f.attrs;i.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var g=p,I=g.boxes,R=g.scores,z=m,L=z.maxOutputSize,G=z.iouThreshold,Z=z.scoreThreshold,be=l,Ce=be.readSync(I.dataId),De=be.readSync(R.dataId),Te=L,Ge=G,Ze=Z;return i.kernel_impls.nonMaxSuppressionV3Impl(Ce,De,Te,Ge,Ze)}},Vl=i.kernel_impls.nonMaxSuppressionV4Impl,Hl={kernelName:i.NonMaxSuppressionV4,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.backend,m=f.attrs;i.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var g=p,I=g.boxes,R=g.scores,z=m,L=z.maxOutputSize,G=z.iouThreshold,Z=z.scoreThreshold,be=z.padToMaxOutputSize,Ce=l,De=Ce.readSync(I.dataId),Te=Ce.readSync(R.dataId),Ge=Vl(De,Te,L,G,Z,be),Ze=Ge.selectedIndices,s=Ge.validOutputs;return[Ze,s]}},Gl=i.kernel_impls.nonMaxSuppressionV5Impl,jl={kernelName:i.NonMaxSuppressionV5,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.backend,m=f.attrs;i.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var g=p,I=g.boxes,R=g.scores,z=m,L=z.maxOutputSize,G=z.iouThreshold,Z=z.scoreThreshold,be=z.softNmsSigma,Ce=l,De=Ce.readSync(I.dataId),Te=Ce.readSync(R.dataId),Ge=L,Ze=G,s=Z,u=be,r=Gl(De,Te,Ge,Ze,s,u),o=r.selectedIndices,h=r.selectedScores;return[o,h]}},ql=function(){function f(p,l,m,g){this.variableNames=["Image"],this.outputShape=[];var I=p[1],R=p[2],z=Math.sin(l).toFixed(3),L=Math.cos(l).toFixed(3);this.outputShape=p;var G=i.backend_util.getImageCenter(g,I,R),Z=G[0],be=G[1],Ce=Z.toFixed(3),De=be.toFixed(3),Te="";typeof m=="number"?Te="float outputValue = "+m.toFixed(2)+";":Te=` vec3 fill = vec3(`+m.join(",")+`); float outputValue = fill[coords[3]];`,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int x = coords[2]; int y = coords[1]; float coordXFloat = (float(x) - `+Ce+") * "+L+" - (float(y) - "+De+") * "+z+`; float coordYFloat = (float(x) - `+Ce+") * "+z+" + (float(y) - "+De+") * "+L+`; int coordX = int(round(coordXFloat + `+Ce+`)); int coordY = int(round(coordYFloat + `+De+`)); `+Te+` if(coordX >= 0 && coordX < `+R+" && coordY >= 0 && coordY < "+I+`) { outputValue = getImage(coords[0], coordY, coordX, coords[3]); } setOutput(outputValue); } `}return f}(),Kl={kernelName:i.RotateWithOffset,backendName:"webgl",kernelFunc:function(f){var p=f.inputs,l=f.attrs,m=f.backend,g=p.image,I=l,R=I.radians,z=I.fillValue,L=I.center,G=m,Z=new ql(g.shape,R,z,L),be=G.runWebGLProgram(Z,[g],g.dtype);return be}},Xl=pu+` return sin(x); `,Cr=Gs(Xl),Yl={kernelName:i.Sin,backendName:"webgl",kernelFunc:Cr},Yu="return x * x;",Ql=Gs(Yu),Br={kernelName:i.Square,backendName:"webgl",kernelFunc:Ql},Jc="return (a - b) * (a - b);",bt=po({opSnippet:Jc,packedOpSnippet:Jc}),Zl={kernelName:i.SquaredDifference,backendName:"webgl",kernelFunc:bt},ui="return a - b;",Jl=po({opSnippet:ui,packedOpSnippet:ui,supportsComplex:!0,cpuKernelImpl:ra}),$c={kernelName:i.Sub,backendName:"webgl",kernelFunc:Jl},$l="return tan(x);",el=Gs($l),eh={kernelName:i.Tan,backendName:"webgl",kernelFunc:el},th={kernelName:i.Transpose,backendName:"webgl",kernelFunc:function(f){for(var p=f.inputs,l=f.attrs,m=f.backend,g=p.x,I=l.perm,R=m,z=g.shape.length,L=new Array(z),G=0;G{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var i=ml(),ke=og(),O=sg(),H=cg(),se=gg(),xe=xg(),Q="2.7.0",Ae={"tfjs-core":i.version_core,"tfjs-backend-cpu":se.version_cpu,"tfjs-backend-webgl":xe.version_webgl,"tfjs-data":H.version_data,"tfjs-layers":ke.version_layers,"tfjs-converter":O.version_converter,tfjs:Q};Object.keys(i).forEach(function(P){P!=="default"&&Object.defineProperty(N,P,{enumerable:!0,get:function(){return i[P]}})}),Object.keys(ke).forEach(function(P){P!=="default"&&Object.defineProperty(N,P,{enumerable:!0,get:function(){return ke[P]}})}),Object.keys(O).forEach(function(P){P!=="default"&&Object.defineProperty(N,P,{enumerable:!0,get:function(){return O[P]}})}),N.data=H,N.version=Ae}),_g=Mr(N=>{const i=to(),ke=6;function O(me){const ae={strides:[me/16,me/8],anchors:[2,6]},w=[];for(let ge=0;ge{me.startEndTensor.dispose(),me.startPoint.dispose(),me.endPoint.dispose()},se=me=>({startEndTensor:me,startPoint:i.slice(me,[0,0],[-1,2]),endPoint:i.slice(me,[0,2],[-1,2])}),xe=(me,ae)=>{const w=i.mul(me.startPoint,ae),ge=i.mul(me.endPoint,ae),ze=i.concat2d([w,ge],1);return se(ze)};function Q(me,ae,w){const ge=i.slice(me,[0,1],[-1,2]),ze=i.add(ge,ae),W=i.slice(me,[0,3],[-1,2]),nt=i.div(W,w),tt=i.div(ze,w),nr=i.div(nt,2),Tt=i.sub(tt,nr),Qe=i.add(tt,nr),it=i.mul(Tt,w),xt=i.mul(Qe,w),ot=1;return i.concat2d([it,xt],ot)}function Ae(me,ae){return i.tidy(()=>{const w=me.box?me.box:me;return xe(w,ae).startEndTensor.squeeze()})}class P{constructor(me,ae){this.blazeFaceModel=me,this.width=ae.detector.inputSize,this.height=ae.detector.inputSize,this.maxFaces=ae.detector.maxFaces,this.anchorsData=O(ae.detector.inputSize),this.anchors=i.tensor2d(this.anchorsData),this.inputSize=i.tensor1d([this.width,this.height]),this.iouThreshold=ae.detector.iouThreshold,this.scaleFaces=.8,this.scoreThreshold=ae.detector.scoreThreshold}async getBoundingBoxes(me){if(!me||me.isDisposedInternal||me.shape.length!==4||me.shape[1]<1||me.shape[2]<1)return null;const[ae,w,ge]=i.tidy(()=>{const Tt=me.resizeBilinear([this.width,this.height]),Qe=i.mul(i.sub(Tt.div(255),.5),2),it=this.blazeFaceModel.predict(Qe);let xt;if(Array.isArray(it)){const yt=it.sort((Ur,jr)=>Ur.size-jr.size),Zt=i.concat([yt[0],yt[2]],2),ar=i.concat([yt[1],yt[3]],2),qt=i.concat([ar,Zt],1);xt=qt.squeeze(0)}else xt=it.squeeze();const ot=Q(xt,this.anchors,this.inputSize),ht=i.slice(xt,[0,0],[-1,1]),ut=i.sigmoid(ht).squeeze();return[xt,ot,ut]}),ze=await i.image.nonMaxSuppressionAsync(w,ge,this.maxFaces,this.iouThreshold,this.scoreThreshold),W=ze.arraySync();ze.dispose();const nt=W.map(Tt=>i.slice(w,[Tt,0],[1,-1])),tt=nt.map(Tt=>{const Qe=Tt.arraySync();return Tt.dispose(),Qe}),nr=[];for(let Tt=0;Tt[(ht[0]+Tt[0])*Qe,(ht[1]+Tt[1])*it]),ot={topLeft:tt.slice(0,2),bottomRight:tt.slice(2),landmarks:xt,probability:nr};H(ze.box),ze.landmarks.dispose(),ze.probability.dispose(),nt.dispose(),ge.push(ot)}return ge}}async function he(me){const ae=await i.loadGraphModel(me.detector.modelPath,{fromTFHub:me.detector.modelPath.includes("tfhub.dev")}),w=new P(ae,me);return w}N.load=he,N.BlazeFaceModel=P,N.disposeBox=H}),df=Mr(N=>{N.MESH_ANNOTATIONS={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[61,185,40,39,37,0,267,269,270,409,291],lipsLowerOuter:[146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[78,191,80,81,82,13,312,311,310,415,308],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},N.MESH_TO_IRIS_INDICES_MAP=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}]}),wg=Mr(N=>{const i=to();function ke(Ae,P){const he=[Ae.startPoint[0]*P[0],Ae.startPoint[1]*P[1]],me=[Ae.endPoint[0]*P[0],Ae.endPoint[1]*P[1]];return{startPoint:he,endPoint:me}}N.scaleBoxCoordinates=ke;function O(Ae){return[Math.abs(Ae.endPoint[0]-Ae.startPoint[0]),Math.abs(Ae.endPoint[1]-Ae.startPoint[1])]}N.getBoxSize=O;function H(Ae){return[Ae.startPoint[0]+(Ae.endPoint[0]-Ae.startPoint[0])/2,Ae.startPoint[1]+(Ae.endPoint[1]-Ae.startPoint[1])/2]}N.getBoxCenter=H;function se(Ae,P,he){const me=P.shape[1],ae=P.shape[2],w=[[Ae.startPoint[1]/me,Ae.startPoint[0]/ae,Ae.endPoint[1]/me,Ae.endPoint[0]/ae]];return i.image.cropAndResize(P,w,[0],he)}N.cutBoxFromImageAndResize=se;function xe(Ae,P=1.5){const he=H(Ae),me=O(Ae),ae=[P*me[0]/2,P*me[1]/2],w=[he[0]-ae[0],he[1]-ae[1]],ge=[he[0]+ae[0],he[1]+ae[1]];return{startPoint:w,endPoint:ge,landmarks:Ae.landmarks}}N.enlargeBox=xe;function Q(Ae){const P=H(Ae),he=O(Ae),me=Math.max(...he),ae=me/2,w=[P[0]-ae,P[1]-ae],ge=[P[0]+ae,P[1]+ae];return{startPoint:w,endPoint:ge,landmarks:Ae.landmarks}}N.squarifyBox=Q}),bg=Mr(N=>{N.IDENTITY_MATRIX=[[1,0,0],[0,1,0],[0,0,1]];function i(ae){return ae-2*Math.PI*Math.floor((ae+Math.PI)/(2*Math.PI))}N.normalizeRadians=i;function ke(ae,w){const ge=Math.PI/2-Math.atan2(-(w[1]-ae[1]),w[0]-ae[0]);return i(ge)}N.computeRotation=ke;function O(ae){return ae*180/Math.PI}N.radToDegrees=O;function H(ae,w){return[[1,0,ae],[0,1,w],[0,0,1]]}function se(ae,w){let ge=0;for(let ze=0;ze{const i=to(),ke=wg(),O=df(),H=bg(),se=468,xe=.25,Q=13,Ae=[Q,O.MESH_ANNOTATIONS.midwayBetweenEyes[0]],P=3,he=2,me=[P,he],ae=O.MESH_ANNOTATIONS.leftEyeLower0,w=[ae[0],ae[ae.length-1]],ge=O.MESH_ANNOTATIONS.rightEyeLower0,ze=[ge[0],ge[ge.length-1]],W=3,nt=4,tt=71,nr=76;function Tt(it,xt,ot,ht){for(let ut=0;ut[yt[0]*(tr[0]-this.meshWidth/2),yt[1]*(tr[1]-this.meshHeight/2),tr[2]]),ar=H.buildRotationMatrix(ot,[0,0]),qt=Zt.map(tr=>[...H.rotatePoint(tr,ar),tr[2]]),Ur=H.invertTransformMatrix(ht),jr=[...ke.getBoxCenter({startPoint:xt.startPoint,endPoint:xt.endPoint}),1],_r=[H.dot(jr,Ur[0]),H.dot(jr,Ur[1])];return qt.map(tr=>[tr[0]+_r[0],tr[1]+_r[1],tr[2]])}getLeftToRightEyeDepthDifference(it){const xt=it[w[0]][2],ot=it[ze[0]][2];return xt-ot}getEyeBox(it,xt,ot,ht,ut=!1){const yt=ke.squarifyBox(ke.enlargeBox(this.calculateLandmarksBoundingBox([it[ot],it[ht]]),this.irisEnlarge)),Zt=ke.getBoxSize(yt);let ar=i.image.cropAndResize(xt,[[yt.startPoint[1]/this.meshHeight,yt.startPoint[0]/this.meshWidth,yt.endPoint[1]/this.meshHeight,yt.endPoint[0]/this.meshWidth]],[0],[this.irisSize,this.irisSize]);return ut&&(ar=i.image.flipLeftRight(ar)),{box:yt,boxSize:Zt,crop:ar}}getEyeCoords(it,xt,ot,ht=!1){const ut=[];for(let yt=0;yt{let qt=yt;return ar===2?qt=ht:ar===4&&(qt=ut),[Zt[0],Zt[1],qt]})}async predict(it,xt){if(this.skipFrames=xt.detector.skipFrames,this.maxFaces=xt.detector.maxFaces,this.runsWithoutFaceDetector++,this.shouldUpdateRegionsOfInterest()){const ht=await this.boundingBoxDetector.getBoundingBoxes(it);if(!ht||!ht.boxes||ht.boxes.length===0)return this.regionsOfInterest=[],null;const ut=ht.boxes.map(yt=>{const Zt=yt.box.startPoint.squeeze(),ar=yt.box.endPoint.squeeze(),qt={startPoint:Zt.arraySync(),endPoint:ar.arraySync()};Zt.dispose(),ar.dispose();const Ur=ke.scaleBoxCoordinates(qt,ht.scaleFactor),jr=ke.enlargeBox(Ur),_r=yt.landmarks.arraySync();return yt.box.startPoint.dispose(),yt.box.endPoint.dispose(),yt.landmarks.dispose(),yt.probability.dispose(),{...jr,landmarks:_r}});this.updateRegionsOfInterest(ut),this.runsWithoutFaceDetector=0}const ot=i.tidy(()=>this.regionsOfInterest.map((ht,ut)=>{let yt=0;const Zt=ht.landmarks.length>=se;let[ar,qt]=Ae;Zt===!1&&([ar,qt]=me),yt=H.computeRotation(ht.landmarks[ar],ht.landmarks[qt]);const Ur=ke.getBoxCenter({startPoint:ht.startPoint,endPoint:ht.endPoint}),jr=[Ur[0]/it.shape[2],Ur[1]/it.shape[1]];let _r=it,tr=H.IDENTITY_MATRIX;yt!==0&&(_r=i.image.rotateWithOffset(it,yt,0,jr),tr=H.buildRotationMatrix(-yt,Ur));const Fa={startPoint:ht.startPoint,endPoint:ht.endPoint},Oa=ke.cutBoxFromImageAndResize(Fa,_r,[this.meshHeight,this.meshWidth]).div(255),[,Tn,Wa]=this.meshDetector.predict(Oa),Na=i.reshape(Wa,[-1,3]);let yn=Na.arraySync();if(xt.iris.enabled){const{box:rn,boxSize:Ca,crop:xn}=this.getEyeBox(yn,Oa,w[0],w[1],!0),{box:Hn,boxSize:_i,crop:ha}=this.getEyeBox(yn,Oa,ze[0],ze[1]),Ei=this.irisModel.predict(i.concat([xn,ha])),Gn=Ei.dataSync();Ei.dispose();const jn=Gn.slice(0,nr*3),{rawCoords:Ua,iris:ga}=this.getEyeCoords(jn,rn,Ca,!0),wi=Gn.slice(nr*3),{rawCoords:Ta,iris:on}=this.getEyeCoords(wi,Hn,_i),_n=this.getLeftToRightEyeDepthDifference(yn);Math.abs(_n)<30?(Tt(yn,Ua,"left"),Tt(yn,Ta,"right")):_n<1?Tt(yn,Ua,"left",["EyeUpper0","EyeLower0"]):Tt(yn,Ta,"right",["EyeUpper0","EyeLower0"]);const xa=this.getAdjustedIrisCoords(yn,ga,"left"),Rr=this.getAdjustedIrisCoords(yn,on,"right");yn=yn.concat(xa).concat(Rr)}const Ma=this.transformRawCoords(yn,ht,yt,tr);i.dispose(yn);const li=ke.enlargeBox(this.calculateLandmarksBoundingBox(Ma)),hi=Tn.squeeze();if(i.dispose(Tn),xt.mesh.enabled){const rn=i.tensor2d(Ma);this.regionsOfInterest[ut]={...li,landmarks:rn.arraySync()};const Ca={coords:rn,box:li,confidence:hi,image:Oa};return Ca}const la={coords:null,box:li,confidence:hi,image:Oa};return la}));return ot}updateRegionsOfInterest(it){for(let xt=0;xt=this.skipFrames}calculateLandmarksBoundingBox(it){const xt=it.map(yt=>yt[0]),ot=it.map(yt=>yt[1]),ht=[Math.min(...xt),Math.min(...ot)],ut=[Math.max(...xt),Math.max(...ot)];return{startPoint:ht,endPoint:ut,landmarks:it}}}N.Pipeline=Qe}),Sg=Mr(N=>{N.UV_COORDS=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]]}),Ig=Mr(N=>{Kh(N,{default:()=>i});var i=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255]}),Ng=Mr(N=>{const i=to(),ke=_g(),O=df(),H=kg(),se=Sg(),xe=Ig().default;class Q{constructor(P,he,me,ae){this.pipeline=new H.Pipeline(P,he,me,ae),ae&&(this.config=ae)}async estimateFaces(P,he){he&&(this.config=he);const me=await this.pipeline.predict(P,he),ae=[];for(const w of me||[]){if(w.isDisposedInternal)continue;const ge=w.confidence.arraySync();if(ge>=this.config.detector.minConfidence){const ze=w.coords?w.coords.arraySync():null,W={};if(ze&&ze.length>0)for(const nt in O.MESH_ANNOTATIONS)(this.config.iris.enabled||nt.includes("Iris")===!1)&&(W[nt]=O.MESH_ANNOTATIONS[nt].map(tt=>ze[tt]));ae.push({confidence:ge||0,box:w.box?[w.box.startPoint[0],w.box.startPoint[1],w.box.endPoint[0]-w.box.startPoint[0],w.box.endPoint[1]-w.box.startPoint[1]]:0,mesh:ze,annotations:W,image:w.image?i.clone(w.image):null})}w.confidence&&w.confidence.dispose(),w.coords&&w.coords.dispose(),w.image&&w.image.dispose()}return ae}}async function Ae(P){const he=await Promise.all([ke.load(P),i.loadGraphModel(P.mesh.modelPath,{fromTFHub:P.mesh.modelPath.includes("tfhub.dev")}),i.loadGraphModel(P.iris.modelPath,{fromTFHub:P.iris.modelPath.includes("tfhub.dev")})]),me=new Q(he[0],he[1],he[2],P);return me}N.load=Ae,N.MediaPipeFaceMesh=Q,N.uv_coords=se,N.triangulation=xe}),Bp=Mr(N=>{const i={};function ke(O,H){if(!H||!H.kernels)return;const se=5,xe=H.kernels.filter(he=>he.kernelTimeMs>0).reduce((he,me)=>he+=me.kernelTimeMs,0),Q=H.kernels.map((he,me)=>(he.id=me,he)).filter(he=>he.kernelTimeMs>0).sort((he,me)=>me.kernelTimeMs-he.kernelTimeMs),Ae=H.kernels.map((he,me)=>(he.id=me,he)).filter(he=>he.totalBytesSnapshot>0).sort((he,me)=>me.totalBytesSnapshot-he.totalBytesSnapshot);Q.length>se&&(Q.length=se),Ae.length>se&&(Ae.length=se);const P={newBytes:H.newBytes,newTensors:H.newTensors,peakBytes:H.peakBytes,numKernelOps:H.kernels.length,timeKernelOps:xe,slowestKernelOps:Q,largestKernelOps:Ae};i[O]=P}N.run=ke,N.data=i}),Cg=Mr(N=>{const i=to(),ke=Bp(),O={};let H={age:0,gender:""},se=Number.MAX_SAFE_INTEGER;async function xe(P){return O.age||(O.age=await i.loadGraphModel(P.face.age.modelPath)),O.age}async function Q(P){return O.gender||(O.gender=await i.loadGraphModel(P.face.gender.modelPath)),O.gender}async function Ae(P,he){if(seO.age.predict(ae)):{};ge=nt.result.clone(),nt.result.dispose(),ke.run("age",nt);const tt=he.face.gender.enabled?await i.profile(()=>O.gender.predict(ae)):{};ze=tt.result.clone(),tt.result.dispose(),ke.run("gender",tt)}if(ge){const nt=ge.dataSync();W.age=Math.trunc(10*nt[0])/10,i.dispose(ge)}if(ze){const nt=ze.dataSync(),tt=Math.trunc(Math.abs(1.9*100*(nt[0]-.5)))/100;tt>he.face.gender.minConfidence&&(W.gender=nt[0]<=.5?"female":"male",W.confidence=tt),i.dispose(ze)}return i.dispose(ae),H=W,W}N.predict=Ae,N.loadAge=xe,N.loadGender=Q}),Tg=Mr(N=>{const i=to(),ke=Bp(),O=["angry","discust","fear","happy","sad","surpise","neutral"],H={};let se=[],xe=Number.MAX_SAFE_INTEGER;const Q=1.5;async function Ae(he){return H.emotion||(H.emotion=await i.loadGraphModel(he.face.emotion.modelPath)),H.emotion}async function P(he,me){if(xeH.emotion.predict(nr));Qe=it.result.dataSync(),it.result.dispose(),ke.run("emotion",it)}else{const it=await H.emotion.predict(nr);Qe=it.dataSync(),i.dispose(it)}for(let it=0;itme.face.emotion.minConfidence&&Tt.push({score:Math.min(.99,Math.trunc(100*Q*Qe[it])/100),emotion:O[it]});Tt.sort((it,xt)=>xt.score-it.score)}return i.dispose(nr),se=Tt,Tt}N.predict=P,N.load=Ae}),Eg=Mr(N=>{const i=to();class ke{constructor(O,H){this.model=O,this.outputStride=H}predict(O){return i.tidy(()=>{const H=this.preprocessInput(O.toFloat()),se=H.expandDims(0),xe=this.model.predict(se),Q=xe.map(P=>P.squeeze([0])),Ae=this.nameOutputResults(Q);return{heatmapScores:Ae.heatmap.sigmoid(),offsets:Ae.offsets,displacementFwd:Ae.displacementFwd,displacementBwd:Ae.displacementBwd}})}dispose(){this.model.dispose()}}N.BaseModel=ke}),ff=Mr(N=>{const i=to(),ke=Eg();class O extends ke.BaseModel{preprocessInput(H){return i.tidy(()=>i.div(H,127.5).sub(1))}nameOutputResults(H){const[se,xe,Q,Ae]=H;return{offsets:se,heatmap:xe,displacementFwd:Q,displacementBwd:Ae}}}N.MobileNet=O}),Rg=Mr(N=>{function i(O){return Math.floor(O/2)}class ke{constructor(O,H){this.priorityQueue=new Array(O),this.numberOfElements=-1,this.getElementValue=H}enqueue(O){this.priorityQueue[++this.numberOfElements]=O,this.swim(this.numberOfElements)}dequeue(){const O=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,O}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(O){for(;O>0&&this.less(i(O),O);)this.exchange(O,i(O)),O=i(O)}sink(O){for(;2*O<=this.numberOfElements;){let H=2*O;if(H{const i=Rg();function ke(H,se,xe,Q,Ae,P){const[he,me]=P.shape;let ae=!0;const w=Math.max(xe-Ae,0),ge=Math.min(xe+Ae+1,he);for(let ze=w;zese){ae=!1;break}if(!ae)break}return ae}function O(H,se,xe){const[Q,Ae,P]=xe.shape,he=new i.MaxHeap(Q*Ae*P,({score:me})=>me);for(let me=0;me{N.partNames=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],N.NUM_KEYPOINTS=N.partNames.length,N.partIds=N.partNames.reduce((ke,O,H)=>(ke[O]=H,ke),{});const i=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]];N.poseChain=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]],N.connectedPartIndices=i.map(([ke,O])=>[N.partIds[ke],N.partIds[O]]),N.partChannels=["left_face","right_face","right_upper_leg_front","right_lower_leg_back","right_upper_leg_back","left_lower_leg_front","left_upper_leg_front","left_upper_leg_back","left_lower_leg_back","right_feet","right_lower_leg_front","left_feet","torso_front","torso_back","right_upper_arm_front","right_upper_arm_back","right_lower_arm_back","left_lower_arm_front","left_upper_arm_front","left_upper_arm_back","left_lower_arm_back","right_hand","right_lower_arm_front","left_hand"]}),mf=Mr(N=>{const i=Xh();function ke(P,he,me,ae){return{y:ae.get(P,he,me),x:ae.get(P,he,me+i.NUM_KEYPOINTS)}}N.getOffsetPoint=ke;function O(P,he,me){const{heatmapY:ae,heatmapX:w,id:ge}=P,{y:ze,x:W}=ke(ae,w,ge,me);return{x:P.heatmapX*he+W,y:P.heatmapY*he+ze}}N.getImageCoords=O;function H(P,he){const me=new Array(he);for(let ae=0;aeme?me:P}N.clamp=se;function xe(P,he,me,ae){const w=me-P,ge=ae-he;return w*w+ge*ge}N.squaredDistance=xe;function Q(P,he){return{x:P.x+he.x,y:P.y+he.y}}N.addVectors=Q;function Ae(P,he,me){return{y:se(P.y,he,me),x:se(P.x,he,me)}}N.clampVector=Ae}),Dg=Mr(N=>{const i=Xh(),ke=mf(),O=i.poseChain.map(([he,me])=>[i.partIds[he],i.partIds[me]]),H=O.map(([,he])=>he),se=O.map(([he])=>he);function xe(he,me,ae){const w=ae.shape[2]/2;return{y:ae.get(me.y,me.x,he),x:ae.get(me.y,me.x,w+he)}}function Q(he,me,ae,w){return{y:ke.clamp(Math.round(he.y/me),0,ae-1),x:ke.clamp(Math.round(he.x/me),0,w-1)}}function Ae(he,me,ae,w,ge,ze,W,nt=2){const[tt,nr]=w.shape,Tt=Q(me.position,ze,tt,nr),Qe=xe(he,Tt,W),it=ke.addVectors(me.position,Qe);let xt=it;for(let ut=0;ut=0;--it){const xt=H[it],ot=se[it];tt[xt]&&!tt[ot]&&(tt[ot]=Ae(it,tt[xt],ot,me,ae,w,ze))}for(let it=0;it{const i=Ag(),ke=Dg(),O=mf();function H(Ae,P,{x:he,y:me},ae){return Ae.some(({keypoints:w})=>{const ge=w[ae].position;return O.squaredDistance(me,he,ge.y,ge.x)<=P})}function se(Ae,P,he){const me=he.reduce((ae,{position:w,score:ge},ze)=>(H(Ae,P,w,ze)||(ae+=ge),ae),0);return me/he.length}const xe=1;function Q(Ae,P,he,me,ae,w,ge=.5,ze=20){const W=[],nt=i.buildPartWithScoreQueue(ge,xe,Ae),tt=ze*ze;for(;W.length{const i=Xh();function ke(ae,w,ge){return ae(ke(ae[ze].score,ae[W].score,w)||ge.push([ae[ze],ae[W]]),ge),[])}N.getAdjacentKeyPoints=O;const{NEGATIVE_INFINITY:H,POSITIVE_INFINITY:se}=Number;function xe(ae){return ae.reduce(({maxX:w,maxY:ge,minX:ze,minY:W},{position:{x:nt,y:tt}})=>({maxX:Math.max(w,nt),maxY:Math.max(ge,tt),minX:Math.min(ze,nt),minY:Math.min(W,tt)}),{maxX:H,maxY:H,minX:se,minY:se})}N.getBoundingBox=xe;function Q(ae){const{minX:w,minY:ge,maxX:ze,maxY:W}=xe(ae);return[{x:w,y:ge},{x:ze,y:ge},{x:ze,y:W},{x:w,y:W}]}N.getBoundingBoxPoints=Q;async function Ae(ae){return Promise.all(ae.map(w=>w.buffer()))}N.toTensorBuffers3D=Ae;function P(ae,w,ge){return{score:ae.score,keypoints:ae.keypoints.map(({score:ze,part:W,position:nt})=>({score:ze,part:W,position:{x:nt.x*ge,y:nt.y*w}}))}}N.scalePose=P;function he(ae,[w,ge]){const ze=ae.squeeze(0),W=ze.resizeBilinear([w,ge]);return ze.dispose(),W}N.resizeTo=he;function me(ae,[w,ge],[ze,W]){const nt=ae.map(tt=>P(tt,w/ze,ge/W));return nt}N.scaleAndFlipPoses=me}),Fg=Mr(N=>{const i=to(),ke=ff(),O=yf(),H=vf();class se{constructor(Ae){this.baseModel=Ae}async estimatePoses(Ae,P){const he=P.outputStride,me=Ae.shape[1],ae=Ae.shape[2],w=H.resizeTo(Ae,[P.inputResolution,P.inputResolution]),{heatmapScores:ge,offsets:ze,displacementFwd:W,displacementBwd:nt}=this.baseModel.predict(w),tt=await H.toTensorBuffers3D([ge,ze,W,nt]),nr=tt[0],Tt=tt[1],Qe=tt[2],it=tt[3],xt=await O.decodeMultiplePoses(nr,Tt,Qe,it,he,P.maxDetections,P.scoreThreshold,P.nmsRadius),ot=H.scaleAndFlipPoses(xt,[me,ae],[P.inputResolution,P.inputResolution]);return ge.dispose(),ze.dispose(),W.dispose(),nt.dispose(),w.dispose(),ot}dispose(){this.baseModel.dispose()}}N.PoseNet=se;async function xe(Ae){const P=await i.loadGraphModel(Ae.modelPath),he=new ke.MobileNet(P,Ae.outputStride);return new se(he)}async function Q(Ae){return xe(Ae)}N.load=Q}),Og=Mr(N=>{const i=ff(),ke=Fg(),O=yf(),H=Xh(),se=vf();N.load=ke.load,N.PoseNet=ke.PoseNet,N.MobileNet=i.MobileNet,N.decodeMultiplePoses=O.decodeMultiplePoses,N.partChannels=H.partChannels,N.partIds=H.partIds,N.partNames=H.partNames,N.poseChain=H.poseChain,N.getAdjacentKeyPoints=se.getAdjacentKeyPoints,N.getBoundingBox=se.getBoundingBox,N.getBoundingBoxPoints=se.getBoundingBoxPoints,N.scaleAndFlipPoses=se.scaleAndFlipPoses,N.scalePose=se.scalePose}),gf=Mr(N=>{Kh(N,{cutBoxFromImageAndResize:()=>H,enlargeBox:()=>xe,getBoxCenter:()=>O,getBoxSize:()=>ke,scaleBoxCoordinates:()=>se,shiftBox:()=>Ae,squarifyBox:()=>Q});const i=to();function ke(P){return[Math.abs(P.endPoint[0]-P.startPoint[0]),Math.abs(P.endPoint[1]-P.startPoint[1])]}function O(P){return[P.startPoint[0]+(P.endPoint[0]-P.startPoint[0])/2,P.startPoint[1]+(P.endPoint[1]-P.startPoint[1])/2]}function H(P,he,me){const ae=he.shape[1],w=he.shape[2],ge=[[P.startPoint[1]/ae,P.startPoint[0]/w,P.endPoint[1]/ae,P.endPoint[0]/w]];return i.image.cropAndResize(he,ge,[0],me)}function se(P,he){const me=[P.startPoint[0]*he[0],P.startPoint[1]*he[1]],ae=[P.endPoint[0]*he[0],P.endPoint[1]*he[1]],w=P.palmLandmarks.map(ge=>{const ze=[ge[0]*he[0],ge[1]*he[1]];return ze});return{startPoint:me,endPoint:ae,palmLandmarks:w}}function xe(P,he=1.5){const me=O(P),ae=ke(P),w=[he*ae[0]/2,he*ae[1]/2],ge=[me[0]-w[0],me[1]-w[1]],ze=[me[0]+w[0],me[1]+w[1]];return{startPoint:ge,endPoint:ze,palmLandmarks:P.palmLandmarks}}function Q(P){const he=O(P),me=ke(P),ae=Math.max(...me),w=ae/2,ge=[he[0]-w,he[1]-w],ze=[he[0]+w,he[1]+w];return{startPoint:ge,endPoint:ze,palmLandmarks:P.palmLandmarks}}function Ae(P,he){const me=[P.endPoint[0]-P.startPoint[0],P.endPoint[1]-P.startPoint[1]],ae=[me[0]*he[0],me[1]*he[1]],w=[P.startPoint[0]+ae[0],P.startPoint[1]+ae[1]],ge=[P.endPoint[0]+ae[0],P.endPoint[1]+ae[1]];return{startPoint:w,endPoint:ge,palmLandmarks:P.palmLandmarks}}}),Mg=Mr(N=>{const i=to(),ke=gf();class O{constructor(H,se,xe){this.model=H,this.width=se,this.height=se,this.anchors=xe.map(Q=>[Q.x_center,Q.y_center]),this.anchorsTensor=i.tensor2d(this.anchors),this.inputSizeTensor=i.tensor1d([se,se]),this.doubleInputSizeTensor=i.tensor1d([se*2,se*2])}normalizeBoxes(H){return i.tidy(()=>{const se=i.slice(H,[0,0],[-1,2]),xe=i.slice(H,[0,2],[-1,2]),Q=i.add(i.div(se,this.inputSizeTensor),this.anchorsTensor),Ae=i.div(xe,this.doubleInputSizeTensor),P=i.mul(i.sub(Q,Ae),this.inputSizeTensor),he=i.mul(i.add(Q,Ae),this.inputSizeTensor);return i.concat2d([P,he],1)})}normalizeLandmarks(H,se){return i.tidy(()=>{const xe=i.add(i.div(H.reshape([-1,7,2]),this.inputSizeTensor),this.anchors[se]);return i.mul(xe,this.inputSizeTensor)})}async getBoundingBoxes(H,se){const xe=i.tidy(()=>i.mul(i.sub(H,.5),2)),Q=this.model.predict(xe),Ae=Q.squeeze(),P=i.tidy(()=>i.sigmoid(i.slice(Ae,[0,0],[-1,1])).squeeze()),he=i.slice(Ae,[0,1],[-1,4]),me=this.normalizeBoxes(he),ae=i.image.nonMaxSuppression(me,P,se.maxHands,se.iouThreshold,se.scoreThreshold),w=ae.arraySync(),ge=[xe,Q,ae,Ae,me,he,P];if(w.length===0)return ge.forEach(W=>W.dispose()),null;const ze=[];for(const W of w){const nt=i.slice(me,[W,0],[1,-1]),tt=i.slice(Ae,[W,5],[1,14]),nr=i.tidy(()=>this.normalizeLandmarks(tt,W).reshape([-1,2]));tt.dispose(),ze.push({boxes:nt,palmLandmarks:nr})}return ge.forEach(W=>W.dispose()),ze}async estimateHandBounds(H,se){const xe=H.shape[1],Q=H.shape[2],Ae=i.tidy(()=>H.resizeBilinear([this.width,this.height]).div(255)),P=await this.getBoundingBoxes(Ae,se);if(!P||P.length===0)return Ae.dispose(),null;const he=[];for(const me of P){const ae=me.boxes.arraySync(),w=ae[0].slice(0,2),ge=ae[0].slice(2,4),ze=me.palmLandmarks.arraySync();Ae.dispose(),me.boxes.dispose(),me.palmLandmarks.dispose(),he.push(ke.scaleBoxCoordinates({startPoint:w,endPoint:ge,palmLandmarks:ze},[Q/this.width,xe/this.height]))}return he}}N.HandDetector=O}),Lg=Mr(N=>{Kh(N,{buildRotationMatrix:()=>Q,computeRotation:()=>ke,dot:()=>H,getColumnFrom2DArr:()=>se,invertTransformMatrix:()=>Ae,normalizeRadians:()=>i,rotatePoint:()=>P});function i(he){return he-2*Math.PI*Math.floor((he+Math.PI)/(2*Math.PI))}function ke(he,me){const ae=Math.PI/2-Math.atan2(-(me[1]-he[1]),me[0]-he[0]);return i(ae)}const O=(he,me)=>[[1,0,he],[0,1,me],[0,0,1]];function H(he,me){let ae=0;for(let w=0;w{const i=to(),ke=gf(),O=Lg(),H=.8,se=[0,-.4],xe=3,Q=[0,-.1],Ae=1.65,P=[0,5,9,13,17,1,2],he=0,me=2;class ae{constructor(w,ge,ze){this.boundingBoxDetector=w,this.meshDetector=ge,this.inputSize=ze,this.regionsOfInterest=[],this.runsWithoutHandDetector=0,this.maxHandsNumber=1,this.skipFrames=0}getBoxForPalmLandmarks(w,ge){const ze=w.map(nt=>{const tt=[...nt,1];return O.rotatePoint(tt,ge)}),W=this.calculateLandmarksBoundingBox(ze);return ke.enlargeBox(ke.squarifyBox(ke.shiftBox(W,se)),xe)}getBoxForHandLandmarks(w){const ge=this.calculateLandmarksBoundingBox(w),ze=ke.enlargeBox(ke.squarifyBox(ke.shiftBox(ge,Q)),Ae),W=[];for(let nt=0;nt[tt[0]*(ht[0]-this.inputSize/2),tt[1]*(ht[1]-this.inputSize/2),ht[2]]),Tt=O.buildRotationMatrix(ze,[0,0]),Qe=nr.map(ht=>{const ut=O.rotatePoint(ht,Tt);return[...ut,ht[2]]}),it=O.invertTransformMatrix(W),xt=[...ke.getBoxCenter(ge),1],ot=[O.dot(xt,it[0]),O.dot(xt,it[1])];return Qe.map(ht=>[ht[0]+ot[0],ht[1]+ot[1],ht[2]])}async estimateHands(w,ge){this.skipFrames=ge.skipFrames;const ze=this.shouldUpdateRegionsOfInterest();if(ze){const nt=await this.boundingBoxDetector.estimateHandBounds(w,ge);if(this.regionsOfInterest=[],!nt||nt.length===0)return w.dispose(),null;for(const tt of nt)this.regionsOfInterest.push(tt);this.runsWithoutHandDetector=0}else this.runsWithoutHandDetector++;const W=[];for(const nt in this.regionsOfInterest){const tt=this.regionsOfInterest[nt];if(!tt)continue;const nr=O.computeRotation(tt.palmLandmarks[he],tt.palmLandmarks[me]),Tt=ke.getBoxCenter(tt),Qe=[Tt[0]/w.shape[2],Tt[1]/w.shape[1]],it=i.image.rotateWithOffset(w,nr,0,Qe),xt=O.buildRotationMatrix(-nr,Tt),ot=ze?this.getBoxForPalmLandmarks(tt.palmLandmarks,xt):tt,ht=ke.cutBoxFromImageAndResize(ot,it,[this.inputSize,this.inputSize]),ut=ht.div(255);ht.dispose(),it.dispose();const yt=this.meshDetector.predict(ut),[Zt,ar]=yt;ut.dispose();const qt=Zt.dataSync()[0];if(Zt.dispose(),qttt[0]),ze=w.map(tt=>tt[1]),W=[Math.min(...ge),Math.min(...ze)],nt=[Math.max(...ge),Math.max(...ze)];return{startPoint:W,endPoint:nt}}updateRegionsOfInterest(w,ge){const ze=this.regionsOfInterest[ge];let W=0;if(ze!=null&&ze.startPoint!=null){const[nt,tt]=w.startPoint,[nr,Tt]=w.endPoint,[Qe,it]=ze.startPoint,[xt,ot]=ze.endPoint,ht=Math.max(nt,Qe),ut=Math.max(tt,it),yt=Math.min(nr,xt),Zt=Math.min(Tt,ot),ar=(yt-ht)*(Zt-ut),qt=(nr-nt)*(Tt-tt),Ur=(xt-Qe)*(ot-tt);W=ar/(qt+Ur-ar)}this.regionsOfInterest[ge]=W>H?ze:w}shouldUpdateRegionsOfInterest(){return!this.regionsOfInterest||this.regionsOfInterest.length===0||this.runsWithoutHandDetector>=this.skipFrames}}N.HandPipeline=ae}),Pg=Mr(N=>{N.anchors=[{w:1,h:1,x_center:.015625,y_center:.015625},{w:1,h:1,x_center:.015625,y_center:.015625},{w:1,h:1,x_center:.046875,y_center:.015625},{w:1,h:1,x_center:.046875,y_center:.015625},{w:1,h:1,x_center:.078125,y_center:.015625},{w:1,h:1,x_center:.078125,y_center:.015625},{w:1,h:1,x_center:.109375,y_center:.015625},{w:1,h:1,x_center:.109375,y_center:.015625},{w:1,h:1,x_center:.140625,y_center:.015625},{w:1,h:1,x_center:.140625,y_center:.015625},{w:1,h:1,x_center:.171875,y_center:.015625},{w:1,h:1,x_center:.171875,y_center:.015625},{w:1,h:1,x_center:.203125,y_center:.015625},{w:1,h:1,x_center:.203125,y_center:.015625},{w:1,h:1,x_center:.234375,y_center:.015625},{w:1,h:1,x_center:.234375,y_center:.015625},{w:1,h:1,x_center:.265625,y_center:.015625},{w:1,h:1,x_center:.265625,y_center:.015625},{w:1,h:1,x_center:.296875,y_center:.015625},{w:1,h:1,x_center:.296875,y_center:.015625},{w:1,h:1,x_center:.328125,y_center:.015625},{w:1,h:1,x_center:.328125,y_center:.015625},{w:1,h:1,x_center:.359375,y_center:.015625},{w:1,h:1,x_center:.359375,y_center:.015625},{w:1,h:1,x_center:.390625,y_center:.015625},{w:1,h:1,x_center:.390625,y_center:.015625},{w:1,h:1,x_center:.421875,y_center:.015625},{w:1,h:1,x_center:.421875,y_center:.015625},{w:1,h:1,x_center:.453125,y_center:.015625},{w:1,h:1,x_center:.453125,y_center:.015625},{w:1,h:1,x_center:.484375,y_center:.015625},{w:1,h:1,x_center:.484375,y_center:.015625},{w:1,h:1,x_center:.515625,y_center:.015625},{w:1,h:1,x_center:.515625,y_center:.015625},{w:1,h:1,x_center:.546875,y_center:.015625},{w:1,h:1,x_center:.546875,y_center:.015625},{w:1,h:1,x_center:.578125,y_center:.015625},{w:1,h:1,x_center:.578125,y_center:.015625},{w:1,h:1,x_center:.609375,y_center:.015625},{w:1,h:1,x_center:.609375,y_center:.015625},{w:1,h:1,x_center:.640625,y_center:.015625},{w:1,h:1,x_center:.640625,y_center:.015625},{w:1,h:1,x_center:.671875,y_center:.015625},{w:1,h:1,x_center:.671875,y_center:.015625},{w:1,h:1,x_center:.703125,y_center:.015625},{w:1,h:1,x_center:.703125,y_center:.015625},{w:1,h:1,x_center:.734375,y_center:.015625},{w:1,h:1,x_center:.734375,y_center:.015625},{w:1,h:1,x_center:.765625,y_center:.015625},{w:1,h:1,x_center:.765625,y_center:.015625},{w:1,h:1,x_center:.796875,y_center:.015625},{w:1,h:1,x_center:.796875,y_center:.015625},{w:1,h:1,x_center:.828125,y_center:.015625},{w:1,h:1,x_center:.828125,y_center:.015625},{w:1,h:1,x_center:.859375,y_center:.015625},{w:1,h:1,x_center:.859375,y_center:.015625},{w:1,h:1,x_center:.890625,y_center:.015625},{w:1,h:1,x_center:.890625,y_center:.015625},{w:1,h:1,x_center:.921875,y_center:.015625},{w:1,h:1,x_center:.921875,y_center:.015625},{w:1,h:1,x_center:.953125,y_center:.015625},{w:1,h:1,x_center:.953125,y_center:.015625},{w:1,h:1,x_center:.984375,y_center:.015625},{w:1,h:1,x_center:.984375,y_center:.015625},{w:1,h:1,x_center:.015625,y_center:.046875},{w:1,h:1,x_center:.015625,y_center:.046875},{w:1,h:1,x_center:.046875,y_center:.046875},{w:1,h:1,x_center:.046875,y_center:.046875},{w:1,h:1,x_center:.078125,y_center:.046875},{w:1,h:1,x_center:.078125,y_center:.046875},{w:1,h:1,x_center:.109375,y_center:.046875},{w:1,h:1,x_center:.109375,y_center:.046875},{w:1,h:1,x_center:.140625,y_center:.046875},{w:1,h:1,x_center:.140625,y_center:.046875},{w:1,h:1,x_center:.171875,y_center:.046875},{w:1,h:1,x_center:.171875,y_center:.046875},{w:1,h:1,x_center:.203125,y_center:.046875},{w:1,h:1,x_center:.203125,y_center:.046875},{w:1,h:1,x_center:.234375,y_center:.046875},{w:1,h:1,x_center:.234375,y_center:.046875},{w:1,h:1,x_center:.265625,y_center:.046875},{w:1,h:1,x_center:.265625,y_center:.046875},{w:1,h:1,x_center:.296875,y_center:.046875},{w:1,h:1,x_center:.296875,y_center:.046875},{w:1,h:1,x_center:.328125,y_center:.046875},{w:1,h:1,x_center:.328125,y_center:.046875},{w:1,h:1,x_center:.359375,y_center:.046875},{w:1,h:1,x_center:.359375,y_center:.046875},{w:1,h:1,x_center:.390625,y_center:.046875},{w:1,h:1,x_center:.390625,y_center:.046875},{w:1,h:1,x_center:.421875,y_center:.046875},{w:1,h:1,x_center:.421875,y_center:.046875},{w:1,h:1,x_center:.453125,y_center:.046875},{w:1,h:1,x_center:.453125,y_center:.046875},{w:1,h:1,x_center:.484375,y_center:.046875},{w:1,h:1,x_center:.484375,y_center:.046875},{w:1,h:1,x_center:.515625,y_center:.046875},{w:1,h:1,x_center:.515625,y_center:.046875},{w:1,h:1,x_center:.546875,y_center:.046875},{w:1,h:1,x_center:.546875,y_center:.046875},{w:1,h:1,x_center:.578125,y_center:.046875},{w:1,h:1,x_center:.578125,y_center:.046875},{w:1,h:1,x_center:.609375,y_center:.046875},{w:1,h:1,x_center:.609375,y_center:.046875},{w:1,h:1,x_center:.640625,y_center:.046875},{w:1,h:1,x_center:.640625,y_center:.046875},{w:1,h:1,x_center:.671875,y_center:.046875},{w:1,h:1,x_center:.671875,y_center:.046875},{w:1,h:1,x_center:.703125,y_center:.046875},{w:1,h:1,x_center:.703125,y_center:.046875},{w:1,h:1,x_center:.734375,y_center:.046875},{w:1,h:1,x_center:.734375,y_center:.046875},{w:1,h:1,x_center:.765625,y_center:.046875},{w:1,h:1,x_center:.765625,y_center:.046875},{w:1,h:1,x_center:.796875,y_center:.046875},{w:1,h:1,x_center:.796875,y_center:.046875},{w:1,h:1,x_center:.828125,y_center:.046875},{w:1,h:1,x_center:.828125,y_center:.046875},{w:1,h:1,x_center:.859375,y_center:.046875},{w:1,h:1,x_center:.859375,y_center:.046875},{w:1,h:1,x_center:.890625,y_center:.046875},{w:1,h:1,x_center:.890625,y_center:.046875},{w:1,h:1,x_center:.921875,y_center:.046875},{w:1,h:1,x_center:.921875,y_center:.046875},{w:1,h:1,x_center:.953125,y_center:.046875},{w:1,h:1,x_center:.953125,y_center:.046875},{w:1,h:1,x_center:.984375,y_center:.046875},{w:1,h:1,x_center:.984375,y_center:.046875},{w:1,h:1,x_center:.015625,y_center:.078125},{w:1,h:1,x_center:.015625,y_center:.078125},{w:1,h:1,x_center:.046875,y_center:.078125},{w:1,h:1,x_center:.046875,y_center:.078125},{w:1,h:1,x_center:.078125,y_center:.078125},{w:1,h:1,x_center:.078125,y_center:.078125},{w:1,h:1,x_center:.109375,y_center:.078125},{w:1,h:1,x_center:.109375,y_center:.078125},{w:1,h:1,x_center:.140625,y_center:.078125},{w:1,h:1,x_center:.140625,y_center:.078125},{w:1,h:1,x_center:.171875,y_center:.078125},{w:1,h:1,x_center:.171875,y_center:.078125},{w:1,h:1,x_center:.203125,y_center:.078125},{w:1,h:1,x_center:.203125,y_center:.078125},{w:1,h:1,x_center:.234375,y_center:.078125},{w:1,h:1,x_center:.234375,y_center:.078125},{w:1,h:1,x_center:.265625,y_center:.078125},{w:1,h:1,x_center:.265625,y_center:.078125},{w:1,h:1,x_center:.296875,y_center:.078125},{w:1,h:1,x_center:.296875,y_center:.078125},{w:1,h:1,x_center:.328125,y_center:.078125},{w:1,h:1,x_center:.328125,y_center:.078125},{w:1,h:1,x_center:.359375,y_center:.078125},{w:1,h:1,x_center:.359375,y_center:.078125},{w:1,h:1,x_center:.390625,y_center:.078125},{w:1,h:1,x_center:.390625,y_center:.078125},{w:1,h:1,x_center:.421875,y_center:.078125},{w:1,h:1,x_center:.421875,y_center:.078125},{w:1,h:1,x_center:.453125,y_center:.078125},{w:1,h:1,x_center:.453125,y_center:.078125},{w:1,h:1,x_center:.484375,y_center:.078125},{w:1,h:1,x_center:.484375,y_center:.078125},{w:1,h:1,x_center:.515625,y_center:.078125},{w:1,h:1,x_center:.515625,y_center:.078125},{w:1,h:1,x_center:.546875,y_center:.078125},{w:1,h:1,x_center:.546875,y_center:.078125},{w:1,h:1,x_center:.578125,y_center:.078125},{w:1,h:1,x_center:.578125,y_center:.078125},{w:1,h:1,x_center:.609375,y_center:.078125},{w:1,h:1,x_center:.609375,y_center:.078125},{w:1,h:1,x_center:.640625,y_center:.078125},{w:1,h:1,x_center:.640625,y_center:.078125},{w:1,h:1,x_center:.671875,y_center:.078125},{w:1,h:1,x_center:.671875,y_center:.078125},{w:1,h:1,x_center:.703125,y_center:.078125},{w:1,h:1,x_center:.703125,y_center:.078125},{w:1,h:1,x_center:.734375,y_center:.078125},{w:1,h:1,x_center:.734375,y_center:.078125},{w:1,h:1,x_center:.765625,y_center:.078125},{w:1,h:1,x_center:.765625,y_center:.078125},{w:1,h:1,x_center:.796875,y_center:.078125},{w:1,h:1,x_center:.796875,y_center:.078125},{w:1,h:1,x_center:.828125,y_center:.078125},{w:1,h:1,x_center:.828125,y_center:.078125},{w:1,h:1,x_center:.859375,y_center:.078125},{w:1,h:1,x_center:.859375,y_center:.078125},{w:1,h:1,x_center:.890625,y_center:.078125},{w:1,h:1,x_center:.890625,y_center:.078125},{w:1,h:1,x_center:.921875,y_center:.078125},{w:1,h:1,x_center:.921875,y_center:.078125},{w:1,h:1,x_center:.953125,y_center:.078125},{w:1,h:1,x_center:.953125,y_center:.078125},{w:1,h:1,x_center:.984375,y_center:.078125},{w:1,h:1,x_center:.984375,y_center:.078125},{w:1,h:1,x_center:.015625,y_center:.109375},{w:1,h:1,x_center:.015625,y_center:.109375},{w:1,h:1,x_center:.046875,y_center:.109375},{w:1,h:1,x_center:.046875,y_center:.109375},{w:1,h:1,x_center:.078125,y_center:.109375},{w:1,h:1,x_center:.078125,y_center:.109375},{w:1,h:1,x_center:.109375,y_center:.109375},{w:1,h:1,x_center:.109375,y_center:.109375},{w:1,h:1,x_center:.140625,y_center:.109375},{w:1,h:1,x_center:.140625,y_center:.109375},{w:1,h:1,x_center:.171875,y_center:.109375},{w:1,h:1,x_center:.171875,y_center:.109375},{w:1,h:1,x_center:.203125,y_center:.109375},{w:1,h:1,x_center:.203125,y_center:.109375},{w:1,h:1,x_center:.234375,y_center:.109375},{w:1,h:1,x_center:.234375,y_center:.109375},{w:1,h:1,x_center:.265625,y_center:.109375},{w:1,h:1,x_center:.265625,y_center:.109375},{w:1,h:1,x_center:.296875,y_center:.109375},{w:1,h:1,x_center:.296875,y_center:.109375},{w:1,h:1,x_center:.328125,y_center:.109375},{w:1,h:1,x_center:.328125,y_center:.109375},{w:1,h:1,x_center:.359375,y_center:.109375},{w:1,h:1,x_center:.359375,y_center:.109375},{w:1,h:1,x_center:.390625,y_center:.109375},{w:1,h:1,x_center:.390625,y_center:.109375},{w:1,h:1,x_center:.421875,y_center:.109375},{w:1,h:1,x_center:.421875,y_center:.109375},{w:1,h:1,x_center:.453125,y_center:.109375},{w:1,h:1,x_center:.453125,y_center:.109375},{w:1,h:1,x_center:.484375,y_center:.109375},{w:1,h:1,x_center:.484375,y_center:.109375},{w:1,h:1,x_center:.515625,y_center:.109375},{w:1,h:1,x_center:.515625,y_center:.109375},{w:1,h:1,x_center:.546875,y_center:.109375},{w:1,h:1,x_center:.546875,y_center:.109375},{w:1,h:1,x_center:.578125,y_center:.109375},{w:1,h:1,x_center:.578125,y_center:.109375},{w:1,h:1,x_center:.609375,y_center:.109375},{w:1,h:1,x_center:.609375,y_center:.109375},{w:1,h:1,x_center:.640625,y_center:.109375},{w:1,h:1,x_center:.640625,y_center:.109375},{w:1,h:1,x_center:.671875,y_center:.109375},{w:1,h:1,x_center:.671875,y_center:.109375},{w:1,h:1,x_center:.703125,y_center:.109375},{w:1,h:1,x_center:.703125,y_center:.109375},{w:1,h:1,x_center:.734375,y_center:.109375},{w:1,h:1,x_center:.734375,y_center:.109375},{w:1,h:1,x_center:.765625,y_center:.109375},{w:1,h:1,x_center:.765625,y_center:.109375},{w:1,h:1,x_center:.796875,y_center:.109375},{w:1,h:1,x_center:.796875,y_center:.109375},{w:1,h:1,x_center:.828125,y_center:.109375},{w:1,h:1,x_center:.828125,y_center:.109375},{w:1,h:1,x_center:.859375,y_center:.109375},{w:1,h:1,x_center:.859375,y_center:.109375},{w:1,h:1,x_center:.890625,y_center:.109375},{w:1,h:1,x_center:.890625,y_center:.109375},{w:1,h:1,x_center:.921875,y_center:.109375},{w:1,h:1,x_center:.921875,y_center:.109375},{w:1,h:1,x_center:.953125,y_center:.109375},{w:1,h:1,x_center:.953125,y_center:.109375},{w:1,h:1,x_center:.984375,y_center:.109375},{w:1,h:1,x_center:.984375,y_center:.109375},{w:1,h:1,x_center:.015625,y_center:.140625},{w:1,h:1,x_center:.015625,y_center:.140625},{w:1,h:1,x_center:.046875,y_center:.140625},{w:1,h:1,x_center:.046875,y_center:.140625},{w:1,h:1,x_center:.078125,y_center:.140625},{w:1,h:1,x_center:.078125,y_center:.140625},{w:1,h:1,x_center:.109375,y_center:.140625},{w:1,h:1,x_center:.109375,y_center:.140625},{w:1,h:1,x_center:.140625,y_center:.140625},{w:1,h:1,x_center:.140625,y_center:.140625},{w:1,h:1,x_center:.171875,y_center:.140625},{w:1,h:1,x_center:.171875,y_center:.140625},{w:1,h:1,x_center:.203125,y_center:.140625},{w:1,h:1,x_center:.203125,y_center:.140625},{w:1,h:1,x_center:.234375,y_center:.140625},{w:1,h:1,x_center:.234375,y_center:.140625},{w:1,h:1,x_center:.265625,y_center:.140625},{w:1,h:1,x_center:.265625,y_center:.140625},{w:1,h:1,x_center:.296875,y_center:.140625},{w:1,h:1,x_center:.296875,y_center:.140625},{w:1,h:1,x_center:.328125,y_center:.140625},{w:1,h:1,x_center:.328125,y_center:.140625},{w:1,h:1,x_center:.359375,y_center:.140625},{w:1,h:1,x_center:.359375,y_center:.140625},{w:1,h:1,x_center:.390625,y_center:.140625},{w:1,h:1,x_center:.390625,y_center:.140625},{w:1,h:1,x_center:.421875,y_center:.140625},{w:1,h:1,x_center:.421875,y_center:.140625},{w:1,h:1,x_center:.453125,y_center:.140625},{w:1,h:1,x_center:.453125,y_center:.140625},{w:1,h:1,x_center:.484375,y_center:.140625},{w:1,h:1,x_center:.484375,y_center:.140625},{w:1,h:1,x_center:.515625,y_center:.140625},{w:1,h:1,x_center:.515625,y_center:.140625},{w:1,h:1,x_center:.546875,y_center:.140625},{w:1,h:1,x_center:.546875,y_center:.140625},{w:1,h:1,x_center:.578125,y_center:.140625},{w:1,h:1,x_center:.578125,y_center:.140625},{w:1,h:1,x_center:.609375,y_center:.140625},{w:1,h:1,x_center:.609375,y_center:.140625},{w:1,h:1,x_center:.640625,y_center:.140625},{w:1,h:1,x_center:.640625,y_center:.140625},{w:1,h:1,x_center:.671875,y_center:.140625},{w:1,h:1,x_center:.671875,y_center:.140625},{w:1,h:1,x_center:.703125,y_center:.140625},{w:1,h:1,x_center:.703125,y_center:.140625},{w:1,h:1,x_center:.734375,y_center:.140625},{w:1,h:1,x_center:.734375,y_center:.140625},{w:1,h:1,x_center:.765625,y_center:.140625},{w:1,h:1,x_center:.765625,y_center:.140625},{w:1,h:1,x_center:.796875,y_center:.140625},{w:1,h:1,x_center:.796875,y_center:.140625},{w:1,h:1,x_center:.828125,y_center:.140625},{w:1,h:1,x_center:.828125,y_center:.140625},{w:1,h:1,x_center:.859375,y_center:.140625},{w:1,h:1,x_center:.859375,y_center:.140625},{w:1,h:1,x_center:.890625,y_center:.140625},{w:1,h:1,x_center:.890625,y_center:.140625},{w:1,h:1,x_center:.921875,y_center:.140625},{w:1,h:1,x_center:.921875,y_center:.140625},{w:1,h:1,x_center:.953125,y_center:.140625},{w:1,h:1,x_center:.953125,y_center:.140625},{w:1,h:1,x_center:.984375,y_center:.140625},{w:1,h:1,x_center:.984375,y_center:.140625},{w:1,h:1,x_center:.015625,y_center:.171875},{w:1,h:1,x_center:.015625,y_center:.171875},{w:1,h:1,x_center:.046875,y_center:.171875},{w:1,h:1,x_center:.046875,y_center:.171875},{w:1,h:1,x_center:.078125,y_center:.171875},{w:1,h:1,x_center:.078125,y_center:.171875},{w:1,h:1,x_center:.109375,y_center:.171875},{w:1,h:1,x_center:.109375,y_center:.171875},{w:1,h:1,x_center:.140625,y_center:.171875},{w:1,h:1,x_center:.140625,y_center:.171875},{w:1,h:1,x_center:.171875,y_center:.171875},{w:1,h:1,x_center:.171875,y_center:.171875},{w:1,h:1,x_center:.203125,y_center:.171875},{w:1,h:1,x_center:.203125,y_center:.171875},{w:1,h:1,x_center:.234375,y_center:.171875},{w:1,h:1,x_center:.234375,y_center:.171875},{w:1,h:1,x_center:.265625,y_center:.171875},{w:1,h:1,x_center:.265625,y_center:.171875},{w:1,h:1,x_center:.296875,y_center:.171875},{w:1,h:1,x_center:.296875,y_center:.171875},{w:1,h:1,x_center:.328125,y_center:.171875},{w:1,h:1,x_center:.328125,y_center:.171875},{w:1,h:1,x_center:.359375,y_center:.171875},{w:1,h:1,x_center:.359375,y_center:.171875},{w:1,h:1,x_center:.390625,y_center:.171875},{w:1,h:1,x_center:.390625,y_center:.171875},{w:1,h:1,x_center:.421875,y_center:.171875},{w:1,h:1,x_center:.421875,y_center:.171875},{w:1,h:1,x_center:.453125,y_center:.171875},{w:1,h:1,x_center:.453125,y_center:.171875},{w:1,h:1,x_center:.484375,y_center:.171875},{w:1,h:1,x_center:.484375,y_center:.171875},{w:1,h:1,x_center:.515625,y_center:.171875},{w:1,h:1,x_center:.515625,y_center:.171875},{w:1,h:1,x_center:.546875,y_center:.171875},{w:1,h:1,x_center:.546875,y_center:.171875},{w:1,h:1,x_center:.578125,y_center:.171875},{w:1,h:1,x_center:.578125,y_center:.171875},{w:1,h:1,x_center:.609375,y_center:.171875},{w:1,h:1,x_center:.609375,y_center:.171875},{w:1,h:1,x_center:.640625,y_center:.171875},{w:1,h:1,x_center:.640625,y_center:.171875},{w:1,h:1,x_center:.671875,y_center:.171875},{w:1,h:1,x_center:.671875,y_center:.171875},{w:1,h:1,x_center:.703125,y_center:.171875},{w:1,h:1,x_center:.703125,y_center:.171875},{w:1,h:1,x_center:.734375,y_center:.171875},{w:1,h:1,x_center:.734375,y_center:.171875},{w:1,h:1,x_center:.765625,y_center:.171875},{w:1,h:1,x_center:.765625,y_center:.171875},{w:1,h:1,x_center:.796875,y_center:.171875},{w:1,h:1,x_center:.796875,y_center:.171875},{w:1,h:1,x_center:.828125,y_center:.171875},{w:1,h:1,x_center:.828125,y_center:.171875},{w:1,h:1,x_center:.859375,y_center:.171875},{w:1,h:1,x_center:.859375,y_center:.171875},{w:1,h:1,x_center:.890625,y_center:.171875},{w:1,h:1,x_center:.890625,y_center:.171875},{w:1,h:1,x_center:.921875,y_center:.171875},{w:1,h:1,x_center:.921875,y_center:.171875},{w:1,h:1,x_center:.953125,y_center:.171875},{w:1,h:1,x_center:.953125,y_center:.171875},{w:1,h:1,x_center:.984375,y_center:.171875},{w:1,h:1,x_center:.984375,y_center:.171875},{w:1,h:1,x_center:.015625,y_center:.203125},{w:1,h:1,x_center:.015625,y_center:.203125},{w:1,h:1,x_center:.046875,y_center:.203125},{w:1,h:1,x_center:.046875,y_center:.203125},{w:1,h:1,x_center:.078125,y_center:.203125},{w:1,h:1,x_center:.078125,y_center:.203125},{w:1,h:1,x_center:.109375,y_center:.203125},{w:1,h:1,x_center:.109375,y_center:.203125},{w:1,h:1,x_center:.140625,y_center:.203125},{w:1,h:1,x_center:.140625,y_center:.203125},{w:1,h:1,x_center:.171875,y_center:.203125},{w:1,h:1,x_center:.171875,y_center:.203125},{w:1,h:1,x_center:.203125,y_center:.203125},{w:1,h:1,x_center:.203125,y_center:.203125},{w:1,h:1,x_center:.234375,y_center:.203125},{w:1,h:1,x_center:.234375,y_center:.203125},{w:1,h:1,x_center:.265625,y_center:.203125},{w:1,h:1,x_center:.265625,y_center:.203125},{w:1,h:1,x_center:.296875,y_center:.203125},{w:1,h:1,x_center:.296875,y_center:.203125},{w:1,h:1,x_center:.328125,y_center:.203125},{w:1,h:1,x_center:.328125,y_center:.203125},{w:1,h:1,x_center:.359375,y_center:.203125},{w:1,h:1,x_center:.359375,y_center:.203125},{w:1,h:1,x_center:.390625,y_center:.203125},{w:1,h:1,x_center:.390625,y_center:.203125},{w:1,h:1,x_center:.421875,y_center:.203125},{w:1,h:1,x_center:.421875,y_center:.203125},{w:1,h:1,x_center:.453125,y_center:.203125},{w:1,h:1,x_center:.453125,y_center:.203125},{w:1,h:1,x_center:.484375,y_center:.203125},{w:1,h:1,x_center:.484375,y_center:.203125},{w:1,h:1,x_center:.515625,y_center:.203125},{w:1,h:1,x_center:.515625,y_center:.203125},{w:1,h:1,x_center:.546875,y_center:.203125},{w:1,h:1,x_center:.546875,y_center:.203125},{w:1,h:1,x_center:.578125,y_center:.203125},{w:1,h:1,x_center:.578125,y_center:.203125},{w:1,h:1,x_center:.609375,y_center:.203125},{w:1,h:1,x_center:.609375,y_center:.203125},{w:1,h:1,x_center:.640625,y_center:.203125},{w:1,h:1,x_center:.640625,y_center:.203125},{w:1,h:1,x_center:.671875,y_center:.203125},{w:1,h:1,x_center:.671875,y_center:.203125},{w:1,h:1,x_center:.703125,y_center:.203125},{w:1,h:1,x_center:.703125,y_center:.203125},{w:1,h:1,x_center:.734375,y_center:.203125},{w:1,h:1,x_center:.734375,y_center:.203125},{w:1,h:1,x_center:.765625,y_center:.203125},{w:1,h:1,x_center:.765625,y_center:.203125},{w:1,h:1,x_center:.796875,y_center:.203125},{w:1,h:1,x_center:.796875,y_center:.203125},{w:1,h:1,x_center:.828125,y_center:.203125},{w:1,h:1,x_center:.828125,y_center:.203125},{w:1,h:1,x_center:.859375,y_center:.203125},{w:1,h:1,x_center:.859375,y_center:.203125},{w:1,h:1,x_center:.890625,y_center:.203125},{w:1,h:1,x_center:.890625,y_center:.203125},{w:1,h:1,x_center:.921875,y_center:.203125},{w:1,h:1,x_center:.921875,y_center:.203125},{w:1,h:1,x_center:.953125,y_center:.203125},{w:1,h:1,x_center:.953125,y_center:.203125},{w:1,h:1,x_center:.984375,y_center:.203125},{w:1,h:1,x_center:.984375,y_center:.203125},{w:1,h:1,x_center:.015625,y_center:.234375},{w:1,h:1,x_center:.015625,y_center:.234375},{w:1,h:1,x_center:.046875,y_center:.234375},{w:1,h:1,x_center:.046875,y_center:.234375},{w:1,h:1,x_center:.078125,y_center:.234375},{w:1,h:1,x_center:.078125,y_center:.234375},{w:1,h:1,x_center:.109375,y_center:.234375},{w:1,h:1,x_center:.109375,y_center:.234375},{w:1,h:1,x_center:.140625,y_center:.234375},{w:1,h:1,x_center:.140625,y_center:.234375},{w:1,h:1,x_center:.171875,y_center:.234375},{w:1,h:1,x_center:.171875,y_center:.234375},{w:1,h:1,x_center:.203125,y_center:.234375},{w:1,h:1,x_center:.203125,y_center:.234375},{w:1,h:1,x_center:.234375,y_center:.234375},{w:1,h:1,x_center:.234375,y_center:.234375},{w:1,h:1,x_center:.265625,y_center:.234375},{w:1,h:1,x_center:.265625,y_center:.234375},{w:1,h:1,x_center:.296875,y_center:.234375},{w:1,h:1,x_center:.296875,y_center:.234375},{w:1,h:1,x_center:.328125,y_center:.234375},{w:1,h:1,x_center:.328125,y_center:.234375},{w:1,h:1,x_center:.359375,y_center:.234375},{w:1,h:1,x_center:.359375,y_center:.234375},{w:1,h:1,x_center:.390625,y_center:.234375},{w:1,h:1,x_center:.390625,y_center:.234375},{w:1,h:1,x_center:.421875,y_center:.234375},{w:1,h:1,x_center:.421875,y_center:.234375},{w:1,h:1,x_center:.453125,y_center:.234375},{w:1,h:1,x_center:.453125,y_center:.234375},{w:1,h:1,x_center:.484375,y_center:.234375},{w:1,h:1,x_center:.484375,y_center:.234375},{w:1,h:1,x_center:.515625,y_center:.234375},{w:1,h:1,x_center:.515625,y_center:.234375},{w:1,h:1,x_center:.546875,y_center:.234375},{w:1,h:1,x_center:.546875,y_center:.234375},{w:1,h:1,x_center:.578125,y_center:.234375},{w:1,h:1,x_center:.578125,y_center:.234375},{w:1,h:1,x_center:.609375,y_center:.234375},{w:1,h:1,x_center:.609375,y_center:.234375},{w:1,h:1,x_center:.640625,y_center:.234375},{w:1,h:1,x_center:.640625,y_center:.234375},{w:1,h:1,x_center:.671875,y_center:.234375},{w:1,h:1,x_center:.671875,y_center:.234375},{w:1,h:1,x_center:.703125,y_center:.234375},{w:1,h:1,x_center:.703125,y_center:.234375},{w:1,h:1,x_center:.734375,y_center:.234375},{w:1,h:1,x_center:.734375,y_center:.234375},{w:1,h:1,x_center:.765625,y_center:.234375},{w:1,h:1,x_center:.765625,y_center:.234375},{w:1,h:1,x_center:.796875,y_center:.234375},{w:1,h:1,x_center:.796875,y_center:.234375},{w:1,h:1,x_center:.828125,y_center:.234375},{w:1,h:1,x_center:.828125,y_center:.234375},{w:1,h:1,x_center:.859375,y_center:.234375},{w:1,h:1,x_center:.859375,y_center:.234375},{w:1,h:1,x_center:.890625,y_center:.234375},{w:1,h:1,x_center:.890625,y_center:.234375},{w:1,h:1,x_center:.921875,y_center:.234375},{w:1,h:1,x_center:.921875,y_center:.234375},{w:1,h:1,x_center:.953125,y_center:.234375},{w:1,h:1,x_center:.953125,y_center:.234375},{w:1,h:1,x_center:.984375,y_center:.234375},{w:1,h:1,x_center:.984375,y_center:.234375},{w:1,h:1,x_center:.015625,y_center:.265625},{w:1,h:1,x_center:.015625,y_center:.265625},{w:1,h:1,x_center:.046875,y_center:.265625},{w:1,h:1,x_center:.046875,y_center:.265625},{w:1,h:1,x_center:.078125,y_center:.265625},{w:1,h:1,x_center:.078125,y_center:.265625},{w:1,h:1,x_center:.109375,y_center:.265625},{w:1,h:1,x_center:.109375,y_center:.265625},{w:1,h:1,x_center:.140625,y_center:.265625},{w:1,h:1,x_center:.140625,y_center:.265625},{w:1,h:1,x_center:.171875,y_center:.265625},{w:1,h:1,x_center:.171875,y_center:.265625},{w:1,h:1,x_center:.203125,y_center:.265625},{w:1,h:1,x_center:.203125,y_center:.265625},{w:1,h:1,x_center:.234375,y_center:.265625},{w:1,h:1,x_center:.234375,y_center:.265625},{w:1,h:1,x_center:.265625,y_center:.265625},{w:1,h:1,x_center:.265625,y_center:.265625},{w:1,h:1,x_center:.296875,y_center:.265625},{w:1,h:1,x_center:.296875,y_center:.265625},{w:1,h:1,x_center:.328125,y_center:.265625},{w:1,h:1,x_center:.328125,y_center:.265625},{w:1,h:1,x_center:.359375,y_center:.265625},{w:1,h:1,x_center:.359375,y_center:.265625},{w:1,h:1,x_center:.390625,y_center:.265625},{w:1,h:1,x_center:.390625,y_center:.265625},{w:1,h:1,x_center:.421875,y_center:.265625},{w:1,h:1,x_center:.421875,y_center:.265625},{w:1,h:1,x_center:.453125,y_center:.265625},{w:1,h:1,x_center:.453125,y_center:.265625},{w:1,h:1,x_center:.484375,y_center:.265625},{w:1,h:1,x_center:.484375,y_center:.265625},{w:1,h:1,x_center:.515625,y_center:.265625},{w:1,h:1,x_center:.515625,y_center:.265625},{w:1,h:1,x_center:.546875,y_center:.265625},{w:1,h:1,x_center:.546875,y_center:.265625},{w:1,h:1,x_center:.578125,y_center:.265625},{w:1,h:1,x_center:.578125,y_center:.265625},{w:1,h:1,x_center:.609375,y_center:.265625},{w:1,h:1,x_center:.609375,y_center:.265625},{w:1,h:1,x_center:.640625,y_center:.265625},{w:1,h:1,x_center:.640625,y_center:.265625},{w:1,h:1,x_center:.671875,y_center:.265625},{w:1,h:1,x_center:.671875,y_center:.265625},{w:1,h:1,x_center:.703125,y_center:.265625},{w:1,h:1,x_center:.703125,y_center:.265625},{w:1,h:1,x_center:.734375,y_center:.265625},{w:1,h:1,x_center:.734375,y_center:.265625},{w:1,h:1,x_center:.765625,y_center:.265625},{w:1,h:1,x_center:.765625,y_center:.265625},{w:1,h:1,x_center:.796875,y_center:.265625},{w:1,h:1,x_center:.796875,y_center:.265625},{w:1,h:1,x_center:.828125,y_center:.265625},{w:1,h:1,x_center:.828125,y_center:.265625},{w:1,h:1,x_center:.859375,y_center:.265625},{w:1,h:1,x_center:.859375,y_center:.265625},{w:1,h:1,x_center:.890625,y_center:.265625},{w:1,h:1,x_center:.890625,y_center:.265625},{w:1,h:1,x_center:.921875,y_center:.265625},{w:1,h:1,x_center:.921875,y_center:.265625},{w:1,h:1,x_center:.953125,y_center:.265625},{w:1,h:1,x_center:.953125,y_center:.265625},{w:1,h:1,x_center:.984375,y_center:.265625},{w:1,h:1,x_center:.984375,y_center:.265625},{w:1,h:1,x_center:.015625,y_center:.296875},{w:1,h:1,x_center:.015625,y_center:.296875},{w:1,h:1,x_center:.046875,y_center:.296875},{w:1,h:1,x_center:.046875,y_center:.296875},{w:1,h:1,x_center:.078125,y_center:.296875},{w:1,h:1,x_center:.078125,y_center:.296875},{w:1,h:1,x_center:.109375,y_center:.296875},{w:1,h:1,x_center:.109375,y_center:.296875},{w:1,h:1,x_center:.140625,y_center:.296875},{w:1,h:1,x_center:.140625,y_center:.296875},{w:1,h:1,x_center:.171875,y_center:.296875},{w:1,h:1,x_center:.171875,y_center:.296875},{w:1,h:1,x_center:.203125,y_center:.296875},{w:1,h:1,x_center:.203125,y_center:.296875},{w:1,h:1,x_center:.234375,y_center:.296875},{w:1,h:1,x_center:.234375,y_center:.296875},{w:1,h:1,x_center:.265625,y_center:.296875},{w:1,h:1,x_center:.265625,y_center:.296875},{w:1,h:1,x_center:.296875,y_center:.296875},{w:1,h:1,x_center:.296875,y_center:.296875},{w:1,h:1,x_center:.328125,y_center:.296875},{w:1,h:1,x_center:.328125,y_center:.296875},{w:1,h:1,x_center:.359375,y_center:.296875},{w:1,h:1,x_center:.359375,y_center:.296875},{w:1,h:1,x_center:.390625,y_center:.296875},{w:1,h:1,x_center:.390625,y_center:.296875},{w:1,h:1,x_center:.421875,y_center:.296875},{w:1,h:1,x_center:.421875,y_center:.296875},{w:1,h:1,x_center:.453125,y_center:.296875},{w:1,h:1,x_center:.453125,y_center:.296875},{w:1,h:1,x_center:.484375,y_center:.296875},{w:1,h:1,x_center:.484375,y_center:.296875},{w:1,h:1,x_center:.515625,y_center:.296875},{w:1,h:1,x_center:.515625,y_center:.296875},{w:1,h:1,x_center:.546875,y_center:.296875},{w:1,h:1,x_center:.546875,y_center:.296875},{w:1,h:1,x_center:.578125,y_center:.296875},{w:1,h:1,x_center:.578125,y_center:.296875},{w:1,h:1,x_center:.609375,y_center:.296875},{w:1,h:1,x_center:.609375,y_center:.296875},{w:1,h:1,x_center:.640625,y_center:.296875},{w:1,h:1,x_center:.640625,y_center:.296875},{w:1,h:1,x_center:.671875,y_center:.296875},{w:1,h:1,x_center:.671875,y_center:.296875},{w:1,h:1,x_center:.703125,y_center:.296875},{w:1,h:1,x_center:.703125,y_center:.296875},{w:1,h:1,x_center:.734375,y_center:.296875},{w:1,h:1,x_center:.734375,y_center:.296875},{w:1,h:1,x_center:.765625,y_center:.296875},{w:1,h:1,x_center:.765625,y_center:.296875},{w:1,h:1,x_center:.796875,y_center:.296875},{w:1,h:1,x_center:.796875,y_center:.296875},{w:1,h:1,x_center:.828125,y_center:.296875},{w:1,h:1,x_center:.828125,y_center:.296875},{w:1,h:1,x_center:.859375,y_center:.296875},{w:1,h:1,x_center:.859375,y_center:.296875},{w:1,h:1,x_center:.890625,y_center:.296875},{w:1,h:1,x_center:.890625,y_center:.296875},{w:1,h:1,x_center:.921875,y_center:.296875},{w:1,h:1,x_center:.921875,y_center:.296875},{w:1,h:1,x_center:.953125,y_center:.296875},{w:1,h:1,x_center:.953125,y_center:.296875},{w:1,h:1,x_center:.984375,y_center:.296875},{w:1,h:1,x_center:.984375,y_center:.296875},{w:1,h:1,x_center:.015625,y_center:.328125},{w:1,h:1,x_center:.015625,y_center:.328125},{w:1,h:1,x_center:.046875,y_center:.328125},{w:1,h:1,x_center:.046875,y_center:.328125},{w:1,h:1,x_center:.078125,y_center:.328125},{w:1,h:1,x_center:.078125,y_center:.328125},{w:1,h:1,x_center:.109375,y_center:.328125},{w:1,h:1,x_center:.109375,y_center:.328125},{w:1,h:1,x_center:.140625,y_center:.328125},{w:1,h:1,x_center:.140625,y_center:.328125},{w:1,h:1,x_center:.171875,y_center:.328125},{w:1,h:1,x_center:.171875,y_center:.328125},{w:1,h:1,x_center:.203125,y_center:.328125},{w:1,h:1,x_center:.203125,y_center:.328125},{w:1,h:1,x_center:.234375,y_center:.328125},{w:1,h:1,x_center:.234375,y_center:.328125},{w:1,h:1,x_center:.265625,y_center:.328125},{w:1,h:1,x_center:.265625,y_center:.328125},{w:1,h:1,x_center:.296875,y_center:.328125},{w:1,h:1,x_center:.296875,y_center:.328125},{w:1,h:1,x_center:.328125,y_center:.328125},{w:1,h:1,x_center:.328125,y_center:.328125},{w:1,h:1,x_center:.359375,y_center:.328125},{w:1,h:1,x_center:.359375,y_center:.328125},{w:1,h:1,x_center:.390625,y_center:.328125},{w:1,h:1,x_center:.390625,y_center:.328125},{w:1,h:1,x_center:.421875,y_center:.328125},{w:1,h:1,x_center:.421875,y_center:.328125},{w:1,h:1,x_center:.453125,y_center:.328125},{w:1,h:1,x_center:.453125,y_center:.328125},{w:1,h:1,x_center:.484375,y_center:.328125},{w:1,h:1,x_center:.484375,y_center:.328125},{w:1,h:1,x_center:.515625,y_center:.328125},{w:1,h:1,x_center:.515625,y_center:.328125},{w:1,h:1,x_center:.546875,y_center:.328125},{w:1,h:1,x_center:.546875,y_center:.328125},{w:1,h:1,x_center:.578125,y_center:.328125},{w:1,h:1,x_center:.578125,y_center:.328125},{w:1,h:1,x_center:.609375,y_center:.328125},{w:1,h:1,x_center:.609375,y_center:.328125},{w:1,h:1,x_center:.640625,y_center:.328125},{w:1,h:1,x_center:.640625,y_center:.328125},{w:1,h:1,x_center:.671875,y_center:.328125},{w:1,h:1,x_center:.671875,y_center:.328125},{w:1,h:1,x_center:.703125,y_center:.328125},{w:1,h:1,x_center:.703125,y_center:.328125},{w:1,h:1,x_center:.734375,y_center:.328125},{w:1,h:1,x_center:.734375,y_center:.328125},{w:1,h:1,x_center:.765625,y_center:.328125},{w:1,h:1,x_center:.765625,y_center:.328125},{w:1,h:1,x_center:.796875,y_center:.328125},{w:1,h:1,x_center:.796875,y_center:.328125},{w:1,h:1,x_center:.828125,y_center:.328125},{w:1,h:1,x_center:.828125,y_center:.328125},{w:1,h:1,x_center:.859375,y_center:.328125},{w:1,h:1,x_center:.859375,y_center:.328125},{w:1,h:1,x_center:.890625,y_center:.328125},{w:1,h:1,x_center:.890625,y_center:.328125},{w:1,h:1,x_center:.921875,y_center:.328125},{w:1,h:1,x_center:.921875,y_center:.328125},{w:1,h:1,x_center:.953125,y_center:.328125},{w:1,h:1,x_center:.953125,y_center:.328125},{w:1,h:1,x_center:.984375,y_center:.328125},{w:1,h:1,x_center:.984375,y_center:.328125},{w:1,h:1,x_center:.015625,y_center:.359375},{w:1,h:1,x_center:.015625,y_center:.359375},{w:1,h:1,x_center:.046875,y_center:.359375},{w:1,h:1,x_center:.046875,y_center:.359375},{w:1,h:1,x_center:.078125,y_center:.359375},{w:1,h:1,x_center:.078125,y_center:.359375},{w:1,h:1,x_center:.109375,y_center:.359375},{w:1,h:1,x_center:.109375,y_center:.359375},{w:1,h:1,x_center:.140625,y_center:.359375},{w:1,h:1,x_center:.140625,y_center:.359375},{w:1,h:1,x_center:.171875,y_center:.359375},{w:1,h:1,x_center:.171875,y_center:.359375},{w:1,h:1,x_center:.203125,y_center:.359375},{w:1,h:1,x_center:.203125,y_center:.359375},{w:1,h:1,x_center:.234375,y_center:.359375},{w:1,h:1,x_center:.234375,y_center:.359375},{w:1,h:1,x_center:.265625,y_center:.359375},{w:1,h:1,x_center:.265625,y_center:.359375},{w:1,h:1,x_center:.296875,y_center:.359375},{w:1,h:1,x_center:.296875,y_center:.359375},{w:1,h:1,x_center:.328125,y_center:.359375},{w:1,h:1,x_center:.328125,y_center:.359375},{w:1,h:1,x_center:.359375,y_center:.359375},{w:1,h:1,x_center:.359375,y_center:.359375},{w:1,h:1,x_center:.390625,y_center:.359375},{w:1,h:1,x_center:.390625,y_center:.359375},{w:1,h:1,x_center:.421875,y_center:.359375},{w:1,h:1,x_center:.421875,y_center:.359375},{w:1,h:1,x_center:.453125,y_center:.359375},{w:1,h:1,x_center:.453125,y_center:.359375},{w:1,h:1,x_center:.484375,y_center:.359375},{w:1,h:1,x_center:.484375,y_center:.359375},{w:1,h:1,x_center:.515625,y_center:.359375},{w:1,h:1,x_center:.515625,y_center:.359375},{w:1,h:1,x_center:.546875,y_center:.359375},{w:1,h:1,x_center:.546875,y_center:.359375},{w:1,h:1,x_center:.578125,y_center:.359375},{w:1,h:1,x_center:.578125,y_center:.359375},{w:1,h:1,x_center:.609375,y_center:.359375},{w:1,h:1,x_center:.609375,y_center:.359375},{w:1,h:1,x_center:.640625,y_center:.359375},{w:1,h:1,x_center:.640625,y_center:.359375},{w:1,h:1,x_center:.671875,y_center:.359375},{w:1,h:1,x_center:.671875,y_center:.359375},{w:1,h:1,x_center:.703125,y_center:.359375},{w:1,h:1,x_center:.703125,y_center:.359375},{w:1,h:1,x_center:.734375,y_center:.359375},{w:1,h:1,x_center:.734375,y_center:.359375},{w:1,h:1,x_center:.765625,y_center:.359375},{w:1,h:1,x_center:.765625,y_center:.359375},{w:1,h:1,x_center:.796875,y_center:.359375},{w:1,h:1,x_center:.796875,y_center:.359375},{w:1,h:1,x_center:.828125,y_center:.359375},{w:1,h:1,x_center:.828125,y_center:.359375},{w:1,h:1,x_center:.859375,y_center:.359375},{w:1,h:1,x_center:.859375,y_center:.359375},{w:1,h:1,x_center:.890625,y_center:.359375},{w:1,h:1,x_center:.890625,y_center:.359375},{w:1,h:1,x_center:.921875,y_center:.359375},{w:1,h:1,x_center:.921875,y_center:.359375},{w:1,h:1,x_center:.953125,y_center:.359375},{w:1,h:1,x_center:.953125,y_center:.359375},{w:1,h:1,x_center:.984375,y_center:.359375},{w:1,h:1,x_center:.984375,y_center:.359375},{w:1,h:1,x_center:.015625,y_center:.390625},{w:1,h:1,x_center:.015625,y_center:.390625},{w:1,h:1,x_center:.046875,y_center:.390625},{w:1,h:1,x_center:.046875,y_center:.390625},{w:1,h:1,x_center:.078125,y_center:.390625},{w:1,h:1,x_center:.078125,y_center:.390625},{w:1,h:1,x_center:.109375,y_center:.390625},{w:1,h:1,x_center:.109375,y_center:.390625},{w:1,h:1,x_center:.140625,y_center:.390625},{w:1,h:1,x_center:.140625,y_center:.390625},{w:1,h:1,x_center:.171875,y_center:.390625},{w:1,h:1,x_center:.171875,y_center:.390625},{w:1,h:1,x_center:.203125,y_center:.390625},{w:1,h:1,x_center:.203125,y_center:.390625},{w:1,h:1,x_center:.234375,y_center:.390625},{w:1,h:1,x_center:.234375,y_center:.390625},{w:1,h:1,x_center:.265625,y_center:.390625},{w:1,h:1,x_center:.265625,y_center:.390625},{w:1,h:1,x_center:.296875,y_center:.390625},{w:1,h:1,x_center:.296875,y_center:.390625},{w:1,h:1,x_center:.328125,y_center:.390625},{w:1,h:1,x_center:.328125,y_center:.390625},{w:1,h:1,x_center:.359375,y_center:.390625},{w:1,h:1,x_center:.359375,y_center:.390625},{w:1,h:1,x_center:.390625,y_center:.390625},{w:1,h:1,x_center:.390625,y_center:.390625},{w:1,h:1,x_center:.421875,y_center:.390625},{w:1,h:1,x_center:.421875,y_center:.390625},{w:1,h:1,x_center:.453125,y_center:.390625},{w:1,h:1,x_center:.453125,y_center:.390625},{w:1,h:1,x_center:.484375,y_center:.390625},{w:1,h:1,x_center:.484375,y_center:.390625},{w:1,h:1,x_center:.515625,y_center:.390625},{w:1,h:1,x_center:.515625,y_center:.390625},{w:1,h:1,x_center:.546875,y_center:.390625},{w:1,h:1,x_center:.546875,y_center:.390625},{w:1,h:1,x_center:.578125,y_center:.390625},{w:1,h:1,x_center:.578125,y_center:.390625},{w:1,h:1,x_center:.609375,y_center:.390625},{w:1,h:1,x_center:.609375,y_center:.390625},{w:1,h:1,x_center:.640625,y_center:.390625},{w:1,h:1,x_center:.640625,y_center:.390625},{w:1,h:1,x_center:.671875,y_center:.390625},{w:1,h:1,x_center:.671875,y_center:.390625},{w:1,h:1,x_center:.703125,y_center:.390625},{w:1,h:1,x_center:.703125,y_center:.390625},{w:1,h:1,x_center:.734375,y_center:.390625},{w:1,h:1,x_center:.734375,y_center:.390625},{w:1,h:1,x_center:.765625,y_center:.390625},{w:1,h:1,x_center:.765625,y_center:.390625},{w:1,h:1,x_center:.796875,y_center:.390625},{w:1,h:1,x_center:.796875,y_center:.390625},{w:1,h:1,x_center:.828125,y_center:.390625},{w:1,h:1,x_center:.828125,y_center:.390625},{w:1,h:1,x_center:.859375,y_center:.390625},{w:1,h:1,x_center:.859375,y_center:.390625},{w:1,h:1,x_center:.890625,y_center:.390625},{w:1,h:1,x_center:.890625,y_center:.390625},{w:1,h:1,x_center:.921875,y_center:.390625},{w:1,h:1,x_center:.921875,y_center:.390625},{w:1,h:1,x_center:.953125,y_center:.390625},{w:1,h:1,x_center:.953125,y_center:.390625},{w:1,h:1,x_center:.984375,y_center:.390625},{w:1,h:1,x_center:.984375,y_center:.390625},{w:1,h:1,x_center:.015625,y_center:.421875},{w:1,h:1,x_center:.015625,y_center:.421875},{w:1,h:1,x_center:.046875,y_center:.421875},{w:1,h:1,x_center:.046875,y_center:.421875},{w:1,h:1,x_center:.078125,y_center:.421875},{w:1,h:1,x_center:.078125,y_center:.421875},{w:1,h:1,x_center:.109375,y_center:.421875},{w:1,h:1,x_center:.109375,y_center:.421875},{w:1,h:1,x_center:.140625,y_center:.421875},{w:1,h:1,x_center:.140625,y_center:.421875},{w:1,h:1,x_center:.171875,y_center:.421875},{w:1,h:1,x_center:.171875,y_center:.421875},{w:1,h:1,x_center:.203125,y_center:.421875},{w:1,h:1,x_center:.203125,y_center:.421875},{w:1,h:1,x_center:.234375,y_center:.421875},{w:1,h:1,x_center:.234375,y_center:.421875},{w:1,h:1,x_center:.265625,y_center:.421875},{w:1,h:1,x_center:.265625,y_center:.421875},{w:1,h:1,x_center:.296875,y_center:.421875},{w:1,h:1,x_center:.296875,y_center:.421875},{w:1,h:1,x_center:.328125,y_center:.421875},{w:1,h:1,x_center:.328125,y_center:.421875},{w:1,h:1,x_center:.359375,y_center:.421875},{w:1,h:1,x_center:.359375,y_center:.421875},{w:1,h:1,x_center:.390625,y_center:.421875},{w:1,h:1,x_center:.390625,y_center:.421875},{w:1,h:1,x_center:.421875,y_center:.421875},{w:1,h:1,x_center:.421875,y_center:.421875},{w:1,h:1,x_center:.453125,y_center:.421875},{w:1,h:1,x_center:.453125,y_center:.421875},{w:1,h:1,x_center:.484375,y_center:.421875},{w:1,h:1,x_center:.484375,y_center:.421875},{w:1,h:1,x_center:.515625,y_center:.421875},{w:1,h:1,x_center:.515625,y_center:.421875},{w:1,h:1,x_center:.546875,y_center:.421875},{w:1,h:1,x_center:.546875,y_center:.421875},{w:1,h:1,x_center:.578125,y_center:.421875},{w:1,h:1,x_center:.578125,y_center:.421875},{w:1,h:1,x_center:.609375,y_center:.421875},{w:1,h:1,x_center:.609375,y_center:.421875},{w:1,h:1,x_center:.640625,y_center:.421875},{w:1,h:1,x_center:.640625,y_center:.421875},{w:1,h:1,x_center:.671875,y_center:.421875},{w:1,h:1,x_center:.671875,y_center:.421875},{w:1,h:1,x_center:.703125,y_center:.421875},{w:1,h:1,x_center:.703125,y_center:.421875},{w:1,h:1,x_center:.734375,y_center:.421875},{w:1,h:1,x_center:.734375,y_center:.421875},{w:1,h:1,x_center:.765625,y_center:.421875},{w:1,h:1,x_center:.765625,y_center:.421875},{w:1,h:1,x_center:.796875,y_center:.421875},{w:1,h:1,x_center:.796875,y_center:.421875},{w:1,h:1,x_center:.828125,y_center:.421875},{w:1,h:1,x_center:.828125,y_center:.421875},{w:1,h:1,x_center:.859375,y_center:.421875},{w:1,h:1,x_center:.859375,y_center:.421875},{w:1,h:1,x_center:.890625,y_center:.421875},{w:1,h:1,x_center:.890625,y_center:.421875},{w:1,h:1,x_center:.921875,y_center:.421875},{w:1,h:1,x_center:.921875,y_center:.421875},{w:1,h:1,x_center:.953125,y_center:.421875},{w:1,h:1,x_center:.953125,y_center:.421875},{w:1,h:1,x_center:.984375,y_center:.421875},{w:1,h:1,x_center:.984375,y_center:.421875},{w:1,h:1,x_center:.015625,y_center:.453125},{w:1,h:1,x_center:.015625,y_center:.453125},{w:1,h:1,x_center:.046875,y_center:.453125},{w:1,h:1,x_center:.046875,y_center:.453125},{w:1,h:1,x_center:.078125,y_center:.453125},{w:1,h:1,x_center:.078125,y_center:.453125},{w:1,h:1,x_center:.109375,y_center:.453125},{w:1,h:1,x_center:.109375,y_center:.453125},{w:1,h:1,x_center:.140625,y_center:.453125},{w:1,h:1,x_center:.140625,y_center:.453125},{w:1,h:1,x_center:.171875,y_center:.453125},{w:1,h:1,x_center:.171875,y_center:.453125},{w:1,h:1,x_center:.203125,y_center:.453125},{w:1,h:1,x_center:.203125,y_center:.453125},{w:1,h:1,x_center:.234375,y_center:.453125},{w:1,h:1,x_center:.234375,y_center:.453125},{w:1,h:1,x_center:.265625,y_center:.453125},{w:1,h:1,x_center:.265625,y_center:.453125},{w:1,h:1,x_center:.296875,y_center:.453125},{w:1,h:1,x_center:.296875,y_center:.453125},{w:1,h:1,x_center:.328125,y_center:.453125},{w:1,h:1,x_center:.328125,y_center:.453125},{w:1,h:1,x_center:.359375,y_center:.453125},{w:1,h:1,x_center:.359375,y_center:.453125},{w:1,h:1,x_center:.390625,y_center:.453125},{w:1,h:1,x_center:.390625,y_center:.453125},{w:1,h:1,x_center:.421875,y_center:.453125},{w:1,h:1,x_center:.421875,y_center:.453125},{w:1,h:1,x_center:.453125,y_center:.453125},{w:1,h:1,x_center:.453125,y_center:.453125},{w:1,h:1,x_center:.484375,y_center:.453125},{w:1,h:1,x_center:.484375,y_center:.453125},{w:1,h:1,x_center:.515625,y_center:.453125},{w:1,h:1,x_center:.515625,y_center:.453125},{w:1,h:1,x_center:.546875,y_center:.453125},{w:1,h:1,x_center:.546875,y_center:.453125},{w:1,h:1,x_center:.578125,y_center:.453125},{w:1,h:1,x_center:.578125,y_center:.453125},{w:1,h:1,x_center:.609375,y_center:.453125},{w:1,h:1,x_center:.609375,y_center:.453125},{w:1,h:1,x_center:.640625,y_center:.453125},{w:1,h:1,x_center:.640625,y_center:.453125},{w:1,h:1,x_center:.671875,y_center:.453125},{w:1,h:1,x_center:.671875,y_center:.453125},{w:1,h:1,x_center:.703125,y_center:.453125},{w:1,h:1,x_center:.703125,y_center:.453125},{w:1,h:1,x_center:.734375,y_center:.453125},{w:1,h:1,x_center:.734375,y_center:.453125},{w:1,h:1,x_center:.765625,y_center:.453125},{w:1,h:1,x_center:.765625,y_center:.453125},{w:1,h:1,x_center:.796875,y_center:.453125},{w:1,h:1,x_center:.796875,y_center:.453125},{w:1,h:1,x_center:.828125,y_center:.453125},{w:1,h:1,x_center:.828125,y_center:.453125},{w:1,h:1,x_center:.859375,y_center:.453125},{w:1,h:1,x_center:.859375,y_center:.453125},{w:1,h:1,x_center:.890625,y_center:.453125},{w:1,h:1,x_center:.890625,y_center:.453125},{w:1,h:1,x_center:.921875,y_center:.453125},{w:1,h:1,x_center:.921875,y_center:.453125},{w:1,h:1,x_center:.953125,y_center:.453125},{w:1,h:1,x_center:.953125,y_center:.453125},{w:1,h:1,x_center:.984375,y_center:.453125},{w:1,h:1,x_center:.984375,y_center:.453125},{w:1,h:1,x_center:.015625,y_center:.484375},{w:1,h:1,x_center:.015625,y_center:.484375},{w:1,h:1,x_center:.046875,y_center:.484375},{w:1,h:1,x_center:.046875,y_center:.484375},{w:1,h:1,x_center:.078125,y_center:.484375},{w:1,h:1,x_center:.078125,y_center:.484375},{w:1,h:1,x_center:.109375,y_center:.484375},{w:1,h:1,x_center:.109375,y_center:.484375},{w:1,h:1,x_center:.140625,y_center:.484375},{w:1,h:1,x_center:.140625,y_center:.484375},{w:1,h:1,x_center:.171875,y_center:.484375},{w:1,h:1,x_center:.171875,y_center:.484375},{w:1,h:1,x_center:.203125,y_center:.484375},{w:1,h:1,x_center:.203125,y_center:.484375},{w:1,h:1,x_center:.234375,y_center:.484375},{w:1,h:1,x_center:.234375,y_center:.484375},{w:1,h:1,x_center:.265625,y_center:.484375},{w:1,h:1,x_center:.265625,y_center:.484375},{w:1,h:1,x_center:.296875,y_center:.484375},{w:1,h:1,x_center:.296875,y_center:.484375},{w:1,h:1,x_center:.328125,y_center:.484375},{w:1,h:1,x_center:.328125,y_center:.484375},{w:1,h:1,x_center:.359375,y_center:.484375},{w:1,h:1,x_center:.359375,y_center:.484375},{w:1,h:1,x_center:.390625,y_center:.484375},{w:1,h:1,x_center:.390625,y_center:.484375},{w:1,h:1,x_center:.421875,y_center:.484375},{w:1,h:1,x_center:.421875,y_center:.484375},{w:1,h:1,x_center:.453125,y_center:.484375},{w:1,h:1,x_center:.453125,y_center:.484375},{w:1,h:1,x_center:.484375,y_center:.484375},{w:1,h:1,x_center:.484375,y_center:.484375},{w:1,h:1,x_center:.515625,y_center:.484375},{w:1,h:1,x_center:.515625,y_center:.484375},{w:1,h:1,x_center:.546875,y_center:.484375},{w:1,h:1,x_center:.546875,y_center:.484375},{w:1,h:1,x_center:.578125,y_center:.484375},{w:1,h:1,x_center:.578125,y_center:.484375},{w:1,h:1,x_center:.609375,y_center:.484375},{w:1,h:1,x_center:.609375,y_center:.484375},{w:1,h:1,x_center:.640625,y_center:.484375},{w:1,h:1,x_center:.640625,y_center:.484375},{w:1,h:1,x_center:.671875,y_center:.484375},{w:1,h:1,x_center:.671875,y_center:.484375},{w:1,h:1,x_center:.703125,y_center:.484375},{w:1,h:1,x_center:.703125,y_center:.484375},{w:1,h:1,x_center:.734375,y_center:.484375},{w:1,h:1,x_center:.734375,y_center:.484375},{w:1,h:1,x_center:.765625,y_center:.484375},{w:1,h:1,x_center:.765625,y_center:.484375},{w:1,h:1,x_center:.796875,y_center:.484375},{w:1,h:1,x_center:.796875,y_center:.484375},{w:1,h:1,x_center:.828125,y_center:.484375},{w:1,h:1,x_center:.828125,y_center:.484375},{w:1,h:1,x_center:.859375,y_center:.484375},{w:1,h:1,x_center:.859375,y_center:.484375},{w:1,h:1,x_center:.890625,y_center:.484375},{w:1,h:1,x_center:.890625,y_center:.484375},{w:1,h:1,x_center:.921875,y_center:.484375},{w:1,h:1,x_center:.921875,y_center:.484375},{w:1,h:1,x_center:.953125,y_center:.484375},{w:1,h:1,x_center:.953125,y_center:.484375},{w:1,h:1,x_center:.984375,y_center:.484375},{w:1,h:1,x_center:.984375,y_center:.484375},{w:1,h:1,x_center:.015625,y_center:.515625},{w:1,h:1,x_center:.015625,y_center:.515625},{w:1,h:1,x_center:.046875,y_center:.515625},{w:1,h:1,x_center:.046875,y_center:.515625},{w:1,h:1,x_center:.078125,y_center:.515625},{w:1,h:1,x_center:.078125,y_center:.515625},{w:1,h:1,x_center:.109375,y_center:.515625},{w:1,h:1,x_center:.109375,y_center:.515625},{w:1,h:1,x_center:.140625,y_center:.515625},{w:1,h:1,x_center:.140625,y_center:.515625},{w:1,h:1,x_center:.171875,y_center:.515625},{w:1,h:1,x_center:.171875,y_center:.515625},{w:1,h:1,x_center:.203125,y_center:.515625},{w:1,h:1,x_center:.203125,y_center:.515625},{w:1,h:1,x_center:.234375,y_center:.515625},{w:1,h:1,x_center:.234375,y_center:.515625},{w:1,h:1,x_center:.265625,y_center:.515625},{w:1,h:1,x_center:.265625,y_center:.515625},{w:1,h:1,x_center:.296875,y_center:.515625},{w:1,h:1,x_center:.296875,y_center:.515625},{w:1,h:1,x_center:.328125,y_center:.515625},{w:1,h:1,x_center:.328125,y_center:.515625},{w:1,h:1,x_center:.359375,y_center:.515625},{w:1,h:1,x_center:.359375,y_center:.515625},{w:1,h:1,x_center:.390625,y_center:.515625},{w:1,h:1,x_center:.390625,y_center:.515625},{w:1,h:1,x_center:.421875,y_center:.515625},{w:1,h:1,x_center:.421875,y_center:.515625},{w:1,h:1,x_center:.453125,y_center:.515625},{w:1,h:1,x_center:.453125,y_center:.515625},{w:1,h:1,x_center:.484375,y_center:.515625},{w:1,h:1,x_center:.484375,y_center:.515625},{w:1,h:1,x_center:.515625,y_center:.515625},{w:1,h:1,x_center:.515625,y_center:.515625},{w:1,h:1,x_center:.546875,y_center:.515625},{w:1,h:1,x_center:.546875,y_center:.515625},{w:1,h:1,x_center:.578125,y_center:.515625},{w:1,h:1,x_center:.578125,y_center:.515625},{w:1,h:1,x_center:.609375,y_center:.515625},{w:1,h:1,x_center:.609375,y_center:.515625},{w:1,h:1,x_center:.640625,y_center:.515625},{w:1,h:1,x_center:.640625,y_center:.515625},{w:1,h:1,x_center:.671875,y_center:.515625},{w:1,h:1,x_center:.671875,y_center:.515625},{w:1,h:1,x_center:.703125,y_center:.515625},{w:1,h:1,x_center:.703125,y_center:.515625},{w:1,h:1,x_center:.734375,y_center:.515625},{w:1,h:1,x_center:.734375,y_center:.515625},{w:1,h:1,x_center:.765625,y_center:.515625},{w:1,h:1,x_center:.765625,y_center:.515625},{w:1,h:1,x_center:.796875,y_center:.515625},{w:1,h:1,x_center:.796875,y_center:.515625},{w:1,h:1,x_center:.828125,y_center:.515625},{w:1,h:1,x_center:.828125,y_center:.515625},{w:1,h:1,x_center:.859375,y_center:.515625},{w:1,h:1,x_center:.859375,y_center:.515625},{w:1,h:1,x_center:.890625,y_center:.515625},{w:1,h:1,x_center:.890625,y_center:.515625},{w:1,h:1,x_center:.921875,y_center:.515625},{w:1,h:1,x_center:.921875,y_center:.515625},{w:1,h:1,x_center:.953125,y_center:.515625},{w:1,h:1,x_center:.953125,y_center:.515625},{w:1,h:1,x_center:.984375,y_center:.515625},{w:1,h:1,x_center:.984375,y_center:.515625},{w:1,h:1,x_center:.015625,y_center:.546875},{w:1,h:1,x_center:.015625,y_center:.546875},{w:1,h:1,x_center:.046875,y_center:.546875},{w:1,h:1,x_center:.046875,y_center:.546875},{w:1,h:1,x_center:.078125,y_center:.546875},{w:1,h:1,x_center:.078125,y_center:.546875},{w:1,h:1,x_center:.109375,y_center:.546875},{w:1,h:1,x_center:.109375,y_center:.546875},{w:1,h:1,x_center:.140625,y_center:.546875},{w:1,h:1,x_center:.140625,y_center:.546875},{w:1,h:1,x_center:.171875,y_center:.546875},{w:1,h:1,x_center:.171875,y_center:.546875},{w:1,h:1,x_center:.203125,y_center:.546875},{w:1,h:1,x_center:.203125,y_center:.546875},{w:1,h:1,x_center:.234375,y_center:.546875},{w:1,h:1,x_center:.234375,y_center:.546875},{w:1,h:1,x_center:.265625,y_center:.546875},{w:1,h:1,x_center:.265625,y_center:.546875},{w:1,h:1,x_center:.296875,y_center:.546875},{w:1,h:1,x_center:.296875,y_center:.546875},{w:1,h:1,x_center:.328125,y_center:.546875},{w:1,h:1,x_center:.328125,y_center:.546875},{w:1,h:1,x_center:.359375,y_center:.546875},{w:1,h:1,x_center:.359375,y_center:.546875},{w:1,h:1,x_center:.390625,y_center:.546875},{w:1,h:1,x_center:.390625,y_center:.546875},{w:1,h:1,x_center:.421875,y_center:.546875},{w:1,h:1,x_center:.421875,y_center:.546875},{w:1,h:1,x_center:.453125,y_center:.546875},{w:1,h:1,x_center:.453125,y_center:.546875},{w:1,h:1,x_center:.484375,y_center:.546875},{w:1,h:1,x_center:.484375,y_center:.546875},{w:1,h:1,x_center:.515625,y_center:.546875},{w:1,h:1,x_center:.515625,y_center:.546875},{w:1,h:1,x_center:.546875,y_center:.546875},{w:1,h:1,x_center:.546875,y_center:.546875},{w:1,h:1,x_center:.578125,y_center:.546875},{w:1,h:1,x_center:.578125,y_center:.546875},{w:1,h:1,x_center:.609375,y_center:.546875},{w:1,h:1,x_center:.609375,y_center:.546875},{w:1,h:1,x_center:.640625,y_center:.546875},{w:1,h:1,x_center:.640625,y_center:.546875},{w:1,h:1,x_center:.671875,y_center:.546875},{w:1,h:1,x_center:.671875,y_center:.546875},{w:1,h:1,x_center:.703125,y_center:.546875},{w:1,h:1,x_center:.703125,y_center:.546875},{w:1,h:1,x_center:.734375,y_center:.546875},{w:1,h:1,x_center:.734375,y_center:.546875},{w:1,h:1,x_center:.765625,y_center:.546875},{w:1,h:1,x_center:.765625,y_center:.546875},{w:1,h:1,x_center:.796875,y_center:.546875},{w:1,h:1,x_center:.796875,y_center:.546875},{w:1,h:1,x_center:.828125,y_center:.546875},{w:1,h:1,x_center:.828125,y_center:.546875},{w:1,h:1,x_center:.859375,y_center:.546875},{w:1,h:1,x_center:.859375,y_center:.546875},{w:1,h:1,x_center:.890625,y_center:.546875},{w:1,h:1,x_center:.890625,y_center:.546875},{w:1,h:1,x_center:.921875,y_center:.546875},{w:1,h:1,x_center:.921875,y_center:.546875},{w:1,h:1,x_center:.953125,y_center:.546875},{w:1,h:1,x_center:.953125,y_center:.546875},{w:1,h:1,x_center:.984375,y_center:.546875},{w:1,h:1,x_center:.984375,y_center:.546875},{w:1,h:1,x_center:.015625,y_center:.578125},{w:1,h:1,x_center:.015625,y_center:.578125},{w:1,h:1,x_center:.046875,y_center:.578125},{w:1,h:1,x_center:.046875,y_center:.578125},{w:1,h:1,x_center:.078125,y_center:.578125},{w:1,h:1,x_center:.078125,y_center:.578125},{w:1,h:1,x_center:.109375,y_center:.578125},{w:1,h:1,x_center:.109375,y_center:.578125},{w:1,h:1,x_center:.140625,y_center:.578125},{w:1,h:1,x_center:.140625,y_center:.578125},{w:1,h:1,x_center:.171875,y_center:.578125},{w:1,h:1,x_center:.171875,y_center:.578125},{w:1,h:1,x_center:.203125,y_center:.578125},{w:1,h:1,x_center:.203125,y_center:.578125},{w:1,h:1,x_center:.234375,y_center:.578125},{w:1,h:1,x_center:.234375,y_center:.578125},{w:1,h:1,x_center:.265625,y_center:.578125},{w:1,h:1,x_center:.265625,y_center:.578125},{w:1,h:1,x_center:.296875,y_center:.578125},{w:1,h:1,x_center:.296875,y_center:.578125},{w:1,h:1,x_center:.328125,y_center:.578125},{w:1,h:1,x_center:.328125,y_center:.578125},{w:1,h:1,x_center:.359375,y_center:.578125},{w:1,h:1,x_center:.359375,y_center:.578125},{w:1,h:1,x_center:.390625,y_center:.578125},{w:1,h:1,x_center:.390625,y_center:.578125},{w:1,h:1,x_center:.421875,y_center:.578125},{w:1,h:1,x_center:.421875,y_center:.578125},{w:1,h:1,x_center:.453125,y_center:.578125},{w:1,h:1,x_center:.453125,y_center:.578125},{w:1,h:1,x_center:.484375,y_center:.578125},{w:1,h:1,x_center:.484375,y_center:.578125},{w:1,h:1,x_center:.515625,y_center:.578125},{w:1,h:1,x_center:.515625,y_center:.578125},{w:1,h:1,x_center:.546875,y_center:.578125},{w:1,h:1,x_center:.546875,y_center:.578125},{w:1,h:1,x_center:.578125,y_center:.578125},{w:1,h:1,x_center:.578125,y_center:.578125},{w:1,h:1,x_center:.609375,y_center:.578125},{w:1,h:1,x_center:.609375,y_center:.578125},{w:1,h:1,x_center:.640625,y_center:.578125},{w:1,h:1,x_center:.640625,y_center:.578125},{w:1,h:1,x_center:.671875,y_center:.578125},{w:1,h:1,x_center:.671875,y_center:.578125},{w:1,h:1,x_center:.703125,y_center:.578125},{w:1,h:1,x_center:.703125,y_center:.578125},{w:1,h:1,x_center:.734375,y_center:.578125},{w:1,h:1,x_center:.734375,y_center:.578125},{w:1,h:1,x_center:.765625,y_center:.578125},{w:1,h:1,x_center:.765625,y_center:.578125},{w:1,h:1,x_center:.796875,y_center:.578125},{w:1,h:1,x_center:.796875,y_center:.578125},{w:1,h:1,x_center:.828125,y_center:.578125},{w:1,h:1,x_center:.828125,y_center:.578125},{w:1,h:1,x_center:.859375,y_center:.578125},{w:1,h:1,x_center:.859375,y_center:.578125},{w:1,h:1,x_center:.890625,y_center:.578125},{w:1,h:1,x_center:.890625,y_center:.578125},{w:1,h:1,x_center:.921875,y_center:.578125},{w:1,h:1,x_center:.921875,y_center:.578125},{w:1,h:1,x_center:.953125,y_center:.578125},{w:1,h:1,x_center:.953125,y_center:.578125},{w:1,h:1,x_center:.984375,y_center:.578125},{w:1,h:1,x_center:.984375,y_center:.578125},{w:1,h:1,x_center:.015625,y_center:.609375},{w:1,h:1,x_center:.015625,y_center:.609375},{w:1,h:1,x_center:.046875,y_center:.609375},{w:1,h:1,x_center:.046875,y_center:.609375},{w:1,h:1,x_center:.078125,y_center:.609375},{w:1,h:1,x_center:.078125,y_center:.609375},{w:1,h:1,x_center:.109375,y_center:.609375},{w:1,h:1,x_center:.109375,y_center:.609375},{w:1,h:1,x_center:.140625,y_center:.609375},{w:1,h:1,x_center:.140625,y_center:.609375},{w:1,h:1,x_center:.171875,y_center:.609375},{w:1,h:1,x_center:.171875,y_center:.609375},{w:1,h:1,x_center:.203125,y_center:.609375},{w:1,h:1,x_center:.203125,y_center:.609375},{w:1,h:1,x_center:.234375,y_center:.609375},{w:1,h:1,x_center:.234375,y_center:.609375},{w:1,h:1,x_center:.265625,y_center:.609375},{w:1,h:1,x_center:.265625,y_center:.609375},{w:1,h:1,x_center:.296875,y_center:.609375},{w:1,h:1,x_center:.296875,y_center:.609375},{w:1,h:1,x_center:.328125,y_center:.609375},{w:1,h:1,x_center:.328125,y_center:.609375},{w:1,h:1,x_center:.359375,y_center:.609375},{w:1,h:1,x_center:.359375,y_center:.609375},{w:1,h:1,x_center:.390625,y_center:.609375},{w:1,h:1,x_center:.390625,y_center:.609375},{w:1,h:1,x_center:.421875,y_center:.609375},{w:1,h:1,x_center:.421875,y_center:.609375},{w:1,h:1,x_center:.453125,y_center:.609375},{w:1,h:1,x_center:.453125,y_center:.609375},{w:1,h:1,x_center:.484375,y_center:.609375},{w:1,h:1,x_center:.484375,y_center:.609375},{w:1,h:1,x_center:.515625,y_center:.609375},{w:1,h:1,x_center:.515625,y_center:.609375},{w:1,h:1,x_center:.546875,y_center:.609375},{w:1,h:1,x_center:.546875,y_center:.609375},{w:1,h:1,x_center:.578125,y_center:.609375},{w:1,h:1,x_center:.578125,y_center:.609375},{w:1,h:1,x_center:.609375,y_center:.609375},{w:1,h:1,x_center:.609375,y_center:.609375},{w:1,h:1,x_center:.640625,y_center:.609375},{w:1,h:1,x_center:.640625,y_center:.609375},{w:1,h:1,x_center:.671875,y_center:.609375},{w:1,h:1,x_center:.671875,y_center:.609375},{w:1,h:1,x_center:.703125,y_center:.609375},{w:1,h:1,x_center:.703125,y_center:.609375},{w:1,h:1,x_center:.734375,y_center:.609375},{w:1,h:1,x_center:.734375,y_center:.609375},{w:1,h:1,x_center:.765625,y_center:.609375},{w:1,h:1,x_center:.765625,y_center:.609375},{w:1,h:1,x_center:.796875,y_center:.609375},{w:1,h:1,x_center:.796875,y_center:.609375},{w:1,h:1,x_center:.828125,y_center:.609375},{w:1,h:1,x_center:.828125,y_center:.609375},{w:1,h:1,x_center:.859375,y_center:.609375},{w:1,h:1,x_center:.859375,y_center:.609375},{w:1,h:1,x_center:.890625,y_center:.609375},{w:1,h:1,x_center:.890625,y_center:.609375},{w:1,h:1,x_center:.921875,y_center:.609375},{w:1,h:1,x_center:.921875,y_center:.609375},{w:1,h:1,x_center:.953125,y_center:.609375},{w:1,h:1,x_center:.953125,y_center:.609375},{w:1,h:1,x_center:.984375,y_center:.609375},{w:1,h:1,x_center:.984375,y_center:.609375},{w:1,h:1,x_center:.015625,y_center:.640625},{w:1,h:1,x_center:.015625,y_center:.640625},{w:1,h:1,x_center:.046875,y_center:.640625},{w:1,h:1,x_center:.046875,y_center:.640625},{w:1,h:1,x_center:.078125,y_center:.640625},{w:1,h:1,x_center:.078125,y_center:.640625},{w:1,h:1,x_center:.109375,y_center:.640625},{w:1,h:1,x_center:.109375,y_center:.640625},{w:1,h:1,x_center:.140625,y_center:.640625},{w:1,h:1,x_center:.140625,y_center:.640625},{w:1,h:1,x_center:.171875,y_center:.640625},{w:1,h:1,x_center:.171875,y_center:.640625},{w:1,h:1,x_center:.203125,y_center:.640625},{w:1,h:1,x_center:.203125,y_center:.640625},{w:1,h:1,x_center:.234375,y_center:.640625},{w:1,h:1,x_center:.234375,y_center:.640625},{w:1,h:1,x_center:.265625,y_center:.640625},{w:1,h:1,x_center:.265625,y_center:.640625},{w:1,h:1,x_center:.296875,y_center:.640625},{w:1,h:1,x_center:.296875,y_center:.640625},{w:1,h:1,x_center:.328125,y_center:.640625},{w:1,h:1,x_center:.328125,y_center:.640625},{w:1,h:1,x_center:.359375,y_center:.640625},{w:1,h:1,x_center:.359375,y_center:.640625},{w:1,h:1,x_center:.390625,y_center:.640625},{w:1,h:1,x_center:.390625,y_center:.640625},{w:1,h:1,x_center:.421875,y_center:.640625},{w:1,h:1,x_center:.421875,y_center:.640625},{w:1,h:1,x_center:.453125,y_center:.640625},{w:1,h:1,x_center:.453125,y_center:.640625},{w:1,h:1,x_center:.484375,y_center:.640625},{w:1,h:1,x_center:.484375,y_center:.640625},{w:1,h:1,x_center:.515625,y_center:.640625},{w:1,h:1,x_center:.515625,y_center:.640625},{w:1,h:1,x_center:.546875,y_center:.640625},{w:1,h:1,x_center:.546875,y_center:.640625},{w:1,h:1,x_center:.578125,y_center:.640625},{w:1,h:1,x_center:.578125,y_center:.640625},{w:1,h:1,x_center:.609375,y_center:.640625},{w:1,h:1,x_center:.609375,y_center:.640625},{w:1,h:1,x_center:.640625,y_center:.640625},{w:1,h:1,x_center:.640625,y_center:.640625},{w:1,h:1,x_center:.671875,y_center:.640625},{w:1,h:1,x_center:.671875,y_center:.640625},{w:1,h:1,x_center:.703125,y_center:.640625},{w:1,h:1,x_center:.703125,y_center:.640625},{w:1,h:1,x_center:.734375,y_center:.640625},{w:1,h:1,x_center:.734375,y_center:.640625},{w:1,h:1,x_center:.765625,y_center:.640625},{w:1,h:1,x_center:.765625,y_center:.640625},{w:1,h:1,x_center:.796875,y_center:.640625},{w:1,h:1,x_center:.796875,y_center:.640625},{w:1,h:1,x_center:.828125,y_center:.640625},{w:1,h:1,x_center:.828125,y_center:.640625},{w:1,h:1,x_center:.859375,y_center:.640625},{w:1,h:1,x_center:.859375,y_center:.640625},{w:1,h:1,x_center:.890625,y_center:.640625},{w:1,h:1,x_center:.890625,y_center:.640625},{w:1,h:1,x_center:.921875,y_center:.640625},{w:1,h:1,x_center:.921875,y_center:.640625},{w:1,h:1,x_center:.953125,y_center:.640625},{w:1,h:1,x_center:.953125,y_center:.640625},{w:1,h:1,x_center:.984375,y_center:.640625},{w:1,h:1,x_center:.984375,y_center:.640625},{w:1,h:1,x_center:.015625,y_center:.671875},{w:1,h:1,x_center:.015625,y_center:.671875},{w:1,h:1,x_center:.046875,y_center:.671875},{w:1,h:1,x_center:.046875,y_center:.671875},{w:1,h:1,x_center:.078125,y_center:.671875},{w:1,h:1,x_center:.078125,y_center:.671875},{w:1,h:1,x_center:.109375,y_center:.671875},{w:1,h:1,x_center:.109375,y_center:.671875},{w:1,h:1,x_center:.140625,y_center:.671875},{w:1,h:1,x_center:.140625,y_center:.671875},{w:1,h:1,x_center:.171875,y_center:.671875},{w:1,h:1,x_center:.171875,y_center:.671875},{w:1,h:1,x_center:.203125,y_center:.671875},{w:1,h:1,x_center:.203125,y_center:.671875},{w:1,h:1,x_center:.234375,y_center:.671875},{w:1,h:1,x_center:.234375,y_center:.671875},{w:1,h:1,x_center:.265625,y_center:.671875},{w:1,h:1,x_center:.265625,y_center:.671875},{w:1,h:1,x_center:.296875,y_center:.671875},{w:1,h:1,x_center:.296875,y_center:.671875},{w:1,h:1,x_center:.328125,y_center:.671875},{w:1,h:1,x_center:.328125,y_center:.671875},{w:1,h:1,x_center:.359375,y_center:.671875},{w:1,h:1,x_center:.359375,y_center:.671875},{w:1,h:1,x_center:.390625,y_center:.671875},{w:1,h:1,x_center:.390625,y_center:.671875},{w:1,h:1,x_center:.421875,y_center:.671875},{w:1,h:1,x_center:.421875,y_center:.671875},{w:1,h:1,x_center:.453125,y_center:.671875},{w:1,h:1,x_center:.453125,y_center:.671875},{w:1,h:1,x_center:.484375,y_center:.671875},{w:1,h:1,x_center:.484375,y_center:.671875},{w:1,h:1,x_center:.515625,y_center:.671875},{w:1,h:1,x_center:.515625,y_center:.671875},{w:1,h:1,x_center:.546875,y_center:.671875},{w:1,h:1,x_center:.546875,y_center:.671875},{w:1,h:1,x_center:.578125,y_center:.671875},{w:1,h:1,x_center:.578125,y_center:.671875},{w:1,h:1,x_center:.609375,y_center:.671875},{w:1,h:1,x_center:.609375,y_center:.671875},{w:1,h:1,x_center:.640625,y_center:.671875},{w:1,h:1,x_center:.640625,y_center:.671875},{w:1,h:1,x_center:.671875,y_center:.671875},{w:1,h:1,x_center:.671875,y_center:.671875},{w:1,h:1,x_center:.703125,y_center:.671875},{w:1,h:1,x_center:.703125,y_center:.671875},{w:1,h:1,x_center:.734375,y_center:.671875},{w:1,h:1,x_center:.734375,y_center:.671875},{w:1,h:1,x_center:.765625,y_center:.671875},{w:1,h:1,x_center:.765625,y_center:.671875},{w:1,h:1,x_center:.796875,y_center:.671875},{w:1,h:1,x_center:.796875,y_center:.671875},{w:1,h:1,x_center:.828125,y_center:.671875},{w:1,h:1,x_center:.828125,y_center:.671875},{w:1,h:1,x_center:.859375,y_center:.671875},{w:1,h:1,x_center:.859375,y_center:.671875},{w:1,h:1,x_center:.890625,y_center:.671875},{w:1,h:1,x_center:.890625,y_center:.671875},{w:1,h:1,x_center:.921875,y_center:.671875},{w:1,h:1,x_center:.921875,y_center:.671875},{w:1,h:1,x_center:.953125,y_center:.671875},{w:1,h:1,x_center:.953125,y_center:.671875},{w:1,h:1,x_center:.984375,y_center:.671875},{w:1,h:1,x_center:.984375,y_center:.671875},{w:1,h:1,x_center:.015625,y_center:.703125},{w:1,h:1,x_center:.015625,y_center:.703125},{w:1,h:1,x_center:.046875,y_center:.703125},{w:1,h:1,x_center:.046875,y_center:.703125},{w:1,h:1,x_center:.078125,y_center:.703125},{w:1,h:1,x_center:.078125,y_center:.703125},{w:1,h:1,x_center:.109375,y_center:.703125},{w:1,h:1,x_center:.109375,y_center:.703125},{w:1,h:1,x_center:.140625,y_center:.703125},{w:1,h:1,x_center:.140625,y_center:.703125},{w:1,h:1,x_center:.171875,y_center:.703125},{w:1,h:1,x_center:.171875,y_center:.703125},{w:1,h:1,x_center:.203125,y_center:.703125},{w:1,h:1,x_center:.203125,y_center:.703125},{w:1,h:1,x_center:.234375,y_center:.703125},{w:1,h:1,x_center:.234375,y_center:.703125},{w:1,h:1,x_center:.265625,y_center:.703125},{w:1,h:1,x_center:.265625,y_center:.703125},{w:1,h:1,x_center:.296875,y_center:.703125},{w:1,h:1,x_center:.296875,y_center:.703125},{w:1,h:1,x_center:.328125,y_center:.703125},{w:1,h:1,x_center:.328125,y_center:.703125},{w:1,h:1,x_center:.359375,y_center:.703125},{w:1,h:1,x_center:.359375,y_center:.703125},{w:1,h:1,x_center:.390625,y_center:.703125},{w:1,h:1,x_center:.390625,y_center:.703125},{w:1,h:1,x_center:.421875,y_center:.703125},{w:1,h:1,x_center:.421875,y_center:.703125},{w:1,h:1,x_center:.453125,y_center:.703125},{w:1,h:1,x_center:.453125,y_center:.703125},{w:1,h:1,x_center:.484375,y_center:.703125},{w:1,h:1,x_center:.484375,y_center:.703125},{w:1,h:1,x_center:.515625,y_center:.703125},{w:1,h:1,x_center:.515625,y_center:.703125},{w:1,h:1,x_center:.546875,y_center:.703125},{w:1,h:1,x_center:.546875,y_center:.703125},{w:1,h:1,x_center:.578125,y_center:.703125},{w:1,h:1,x_center:.578125,y_center:.703125},{w:1,h:1,x_center:.609375,y_center:.703125},{w:1,h:1,x_center:.609375,y_center:.703125},{w:1,h:1,x_center:.640625,y_center:.703125},{w:1,h:1,x_center:.640625,y_center:.703125},{w:1,h:1,x_center:.671875,y_center:.703125},{w:1,h:1,x_center:.671875,y_center:.703125},{w:1,h:1,x_center:.703125,y_center:.703125},{w:1,h:1,x_center:.703125,y_center:.703125},{w:1,h:1,x_center:.734375,y_center:.703125},{w:1,h:1,x_center:.734375,y_center:.703125},{w:1,h:1,x_center:.765625,y_center:.703125},{w:1,h:1,x_center:.765625,y_center:.703125},{w:1,h:1,x_center:.796875,y_center:.703125},{w:1,h:1,x_center:.796875,y_center:.703125},{w:1,h:1,x_center:.828125,y_center:.703125},{w:1,h:1,x_center:.828125,y_center:.703125},{w:1,h:1,x_center:.859375,y_center:.703125},{w:1,h:1,x_center:.859375,y_center:.703125},{w:1,h:1,x_center:.890625,y_center:.703125},{w:1,h:1,x_center:.890625,y_center:.703125},{w:1,h:1,x_center:.921875,y_center:.703125},{w:1,h:1,x_center:.921875,y_center:.703125},{w:1,h:1,x_center:.953125,y_center:.703125},{w:1,h:1,x_center:.953125,y_center:.703125},{w:1,h:1,x_center:.984375,y_center:.703125},{w:1,h:1,x_center:.984375,y_center:.703125},{w:1,h:1,x_center:.015625,y_center:.734375},{w:1,h:1,x_center:.015625,y_center:.734375},{w:1,h:1,x_center:.046875,y_center:.734375},{w:1,h:1,x_center:.046875,y_center:.734375},{w:1,h:1,x_center:.078125,y_center:.734375},{w:1,h:1,x_center:.078125,y_center:.734375},{w:1,h:1,x_center:.109375,y_center:.734375},{w:1,h:1,x_center:.109375,y_center:.734375},{w:1,h:1,x_center:.140625,y_center:.734375},{w:1,h:1,x_center:.140625,y_center:.734375},{w:1,h:1,x_center:.171875,y_center:.734375},{w:1,h:1,x_center:.171875,y_center:.734375},{w:1,h:1,x_center:.203125,y_center:.734375},{w:1,h:1,x_center:.203125,y_center:.734375},{w:1,h:1,x_center:.234375,y_center:.734375},{w:1,h:1,x_center:.234375,y_center:.734375},{w:1,h:1,x_center:.265625,y_center:.734375},{w:1,h:1,x_center:.265625,y_center:.734375},{w:1,h:1,x_center:.296875,y_center:.734375},{w:1,h:1,x_center:.296875,y_center:.734375},{w:1,h:1,x_center:.328125,y_center:.734375},{w:1,h:1,x_center:.328125,y_center:.734375},{w:1,h:1,x_center:.359375,y_center:.734375},{w:1,h:1,x_center:.359375,y_center:.734375},{w:1,h:1,x_center:.390625,y_center:.734375},{w:1,h:1,x_center:.390625,y_center:.734375},{w:1,h:1,x_center:.421875,y_center:.734375},{w:1,h:1,x_center:.421875,y_center:.734375},{w:1,h:1,x_center:.453125,y_center:.734375},{w:1,h:1,x_center:.453125,y_center:.734375},{w:1,h:1,x_center:.484375,y_center:.734375},{w:1,h:1,x_center:.484375,y_center:.734375},{w:1,h:1,x_center:.515625,y_center:.734375},{w:1,h:1,x_center:.515625,y_center:.734375},{w:1,h:1,x_center:.546875,y_center:.734375},{w:1,h:1,x_center:.546875,y_center:.734375},{w:1,h:1,x_center:.578125,y_center:.734375},{w:1,h:1,x_center:.578125,y_center:.734375},{w:1,h:1,x_center:.609375,y_center:.734375},{w:1,h:1,x_center:.609375,y_center:.734375},{w:1,h:1,x_center:.640625,y_center:.734375},{w:1,h:1,x_center:.640625,y_center:.734375},{w:1,h:1,x_center:.671875,y_center:.734375},{w:1,h:1,x_center:.671875,y_center:.734375},{w:1,h:1,x_center:.703125,y_center:.734375},{w:1,h:1,x_center:.703125,y_center:.734375},{w:1,h:1,x_center:.734375,y_center:.734375},{w:1,h:1,x_center:.734375,y_center:.734375},{w:1,h:1,x_center:.765625,y_center:.734375},{w:1,h:1,x_center:.765625,y_center:.734375},{w:1,h:1,x_center:.796875,y_center:.734375},{w:1,h:1,x_center:.796875,y_center:.734375},{w:1,h:1,x_center:.828125,y_center:.734375},{w:1,h:1,x_center:.828125,y_center:.734375},{w:1,h:1,x_center:.859375,y_center:.734375},{w:1,h:1,x_center:.859375,y_center:.734375},{w:1,h:1,x_center:.890625,y_center:.734375},{w:1,h:1,x_center:.890625,y_center:.734375},{w:1,h:1,x_center:.921875,y_center:.734375},{w:1,h:1,x_center:.921875,y_center:.734375},{w:1,h:1,x_center:.953125,y_center:.734375},{w:1,h:1,x_center:.953125,y_center:.734375},{w:1,h:1,x_center:.984375,y_center:.734375},{w:1,h:1,x_center:.984375,y_center:.734375},{w:1,h:1,x_center:.015625,y_center:.765625},{w:1,h:1,x_center:.015625,y_center:.765625},{w:1,h:1,x_center:.046875,y_center:.765625},{w:1,h:1,x_center:.046875,y_center:.765625},{w:1,h:1,x_center:.078125,y_center:.765625},{w:1,h:1,x_center:.078125,y_center:.765625},{w:1,h:1,x_center:.109375,y_center:.765625},{w:1,h:1,x_center:.109375,y_center:.765625},{w:1,h:1,x_center:.140625,y_center:.765625},{w:1,h:1,x_center:.140625,y_center:.765625},{w:1,h:1,x_center:.171875,y_center:.765625},{w:1,h:1,x_center:.171875,y_center:.765625},{w:1,h:1,x_center:.203125,y_center:.765625},{w:1,h:1,x_center:.203125,y_center:.765625},{w:1,h:1,x_center:.234375,y_center:.765625},{w:1,h:1,x_center:.234375,y_center:.765625},{w:1,h:1,x_center:.265625,y_center:.765625},{w:1,h:1,x_center:.265625,y_center:.765625},{w:1,h:1,x_center:.296875,y_center:.765625},{w:1,h:1,x_center:.296875,y_center:.765625},{w:1,h:1,x_center:.328125,y_center:.765625},{w:1,h:1,x_center:.328125,y_center:.765625},{w:1,h:1,x_center:.359375,y_center:.765625},{w:1,h:1,x_center:.359375,y_center:.765625},{w:1,h:1,x_center:.390625,y_center:.765625},{w:1,h:1,x_center:.390625,y_center:.765625},{w:1,h:1,x_center:.421875,y_center:.765625},{w:1,h:1,x_center:.421875,y_center:.765625},{w:1,h:1,x_center:.453125,y_center:.765625},{w:1,h:1,x_center:.453125,y_center:.765625},{w:1,h:1,x_center:.484375,y_center:.765625},{w:1,h:1,x_center:.484375,y_center:.765625},{w:1,h:1,x_center:.515625,y_center:.765625},{w:1,h:1,x_center:.515625,y_center:.765625},{w:1,h:1,x_center:.546875,y_center:.765625},{w:1,h:1,x_center:.546875,y_center:.765625},{w:1,h:1,x_center:.578125,y_center:.765625},{w:1,h:1,x_center:.578125,y_center:.765625},{w:1,h:1,x_center:.609375,y_center:.765625},{w:1,h:1,x_center:.609375,y_center:.765625},{w:1,h:1,x_center:.640625,y_center:.765625},{w:1,h:1,x_center:.640625,y_center:.765625},{w:1,h:1,x_center:.671875,y_center:.765625},{w:1,h:1,x_center:.671875,y_center:.765625},{w:1,h:1,x_center:.703125,y_center:.765625},{w:1,h:1,x_center:.703125,y_center:.765625},{w:1,h:1,x_center:.734375,y_center:.765625},{w:1,h:1,x_center:.734375,y_center:.765625},{w:1,h:1,x_center:.765625,y_center:.765625},{w:1,h:1,x_center:.765625,y_center:.765625},{w:1,h:1,x_center:.796875,y_center:.765625},{w:1,h:1,x_center:.796875,y_center:.765625},{w:1,h:1,x_center:.828125,y_center:.765625},{w:1,h:1,x_center:.828125,y_center:.765625},{w:1,h:1,x_center:.859375,y_center:.765625},{w:1,h:1,x_center:.859375,y_center:.765625},{w:1,h:1,x_center:.890625,y_center:.765625},{w:1,h:1,x_center:.890625,y_center:.765625},{w:1,h:1,x_center:.921875,y_center:.765625},{w:1,h:1,x_center:.921875,y_center:.765625},{w:1,h:1,x_center:.953125,y_center:.765625},{w:1,h:1,x_center:.953125,y_center:.765625},{w:1,h:1,x_center:.984375,y_center:.765625},{w:1,h:1,x_center:.984375,y_center:.765625},{w:1,h:1,x_center:.015625,y_center:.796875},{w:1,h:1,x_center:.015625,y_center:.796875},{w:1,h:1,x_center:.046875,y_center:.796875},{w:1,h:1,x_center:.046875,y_center:.796875},{w:1,h:1,x_center:.078125,y_center:.796875},{w:1,h:1,x_center:.078125,y_center:.796875},{w:1,h:1,x_center:.109375,y_center:.796875},{w:1,h:1,x_center:.109375,y_center:.796875},{w:1,h:1,x_center:.140625,y_center:.796875},{w:1,h:1,x_center:.140625,y_center:.796875},{w:1,h:1,x_center:.171875,y_center:.796875},{w:1,h:1,x_center:.171875,y_center:.796875},{w:1,h:1,x_center:.203125,y_center:.796875},{w:1,h:1,x_center:.203125,y_center:.796875},{w:1,h:1,x_center:.234375,y_center:.796875},{w:1,h:1,x_center:.234375,y_center:.796875},{w:1,h:1,x_center:.265625,y_center:.796875},{w:1,h:1,x_center:.265625,y_center:.796875},{w:1,h:1,x_center:.296875,y_center:.796875},{w:1,h:1,x_center:.296875,y_center:.796875},{w:1,h:1,x_center:.328125,y_center:.796875},{w:1,h:1,x_center:.328125,y_center:.796875},{w:1,h:1,x_center:.359375,y_center:.796875},{w:1,h:1,x_center:.359375,y_center:.796875},{w:1,h:1,x_center:.390625,y_center:.796875},{w:1,h:1,x_center:.390625,y_center:.796875},{w:1,h:1,x_center:.421875,y_center:.796875},{w:1,h:1,x_center:.421875,y_center:.796875},{w:1,h:1,x_center:.453125,y_center:.796875},{w:1,h:1,x_center:.453125,y_center:.796875},{w:1,h:1,x_center:.484375,y_center:.796875},{w:1,h:1,x_center:.484375,y_center:.796875},{w:1,h:1,x_center:.515625,y_center:.796875},{w:1,h:1,x_center:.515625,y_center:.796875},{w:1,h:1,x_center:.546875,y_center:.796875},{w:1,h:1,x_center:.546875,y_center:.796875},{w:1,h:1,x_center:.578125,y_center:.796875},{w:1,h:1,x_center:.578125,y_center:.796875},{w:1,h:1,x_center:.609375,y_center:.796875},{w:1,h:1,x_center:.609375,y_center:.796875},{w:1,h:1,x_center:.640625,y_center:.796875},{w:1,h:1,x_center:.640625,y_center:.796875},{w:1,h:1,x_center:.671875,y_center:.796875},{w:1,h:1,x_center:.671875,y_center:.796875},{w:1,h:1,x_center:.703125,y_center:.796875},{w:1,h:1,x_center:.703125,y_center:.796875},{w:1,h:1,x_center:.734375,y_center:.796875},{w:1,h:1,x_center:.734375,y_center:.796875},{w:1,h:1,x_center:.765625,y_center:.796875},{w:1,h:1,x_center:.765625,y_center:.796875},{w:1,h:1,x_center:.796875,y_center:.796875},{w:1,h:1,x_center:.796875,y_center:.796875},{w:1,h:1,x_center:.828125,y_center:.796875},{w:1,h:1,x_center:.828125,y_center:.796875},{w:1,h:1,x_center:.859375,y_center:.796875},{w:1,h:1,x_center:.859375,y_center:.796875},{w:1,h:1,x_center:.890625,y_center:.796875},{w:1,h:1,x_center:.890625,y_center:.796875},{w:1,h:1,x_center:.921875,y_center:.796875},{w:1,h:1,x_center:.921875,y_center:.796875},{w:1,h:1,x_center:.953125,y_center:.796875},{w:1,h:1,x_center:.953125,y_center:.796875},{w:1,h:1,x_center:.984375,y_center:.796875},{w:1,h:1,x_center:.984375,y_center:.796875},{w:1,h:1,x_center:.015625,y_center:.828125},{w:1,h:1,x_center:.015625,y_center:.828125},{w:1,h:1,x_center:.046875,y_center:.828125},{w:1,h:1,x_center:.046875,y_center:.828125},{w:1,h:1,x_center:.078125,y_center:.828125},{w:1,h:1,x_center:.078125,y_center:.828125},{w:1,h:1,x_center:.109375,y_center:.828125},{w:1,h:1,x_center:.109375,y_center:.828125},{w:1,h:1,x_center:.140625,y_center:.828125},{w:1,h:1,x_center:.140625,y_center:.828125},{w:1,h:1,x_center:.171875,y_center:.828125},{w:1,h:1,x_center:.171875,y_center:.828125},{w:1,h:1,x_center:.203125,y_center:.828125},{w:1,h:1,x_center:.203125,y_center:.828125},{w:1,h:1,x_center:.234375,y_center:.828125},{w:1,h:1,x_center:.234375,y_center:.828125},{w:1,h:1,x_center:.265625,y_center:.828125},{w:1,h:1,x_center:.265625,y_center:.828125},{w:1,h:1,x_center:.296875,y_center:.828125},{w:1,h:1,x_center:.296875,y_center:.828125},{w:1,h:1,x_center:.328125,y_center:.828125},{w:1,h:1,x_center:.328125,y_center:.828125},{w:1,h:1,x_center:.359375,y_center:.828125},{w:1,h:1,x_center:.359375,y_center:.828125},{w:1,h:1,x_center:.390625,y_center:.828125},{w:1,h:1,x_center:.390625,y_center:.828125},{w:1,h:1,x_center:.421875,y_center:.828125},{w:1,h:1,x_center:.421875,y_center:.828125},{w:1,h:1,x_center:.453125,y_center:.828125},{w:1,h:1,x_center:.453125,y_center:.828125},{w:1,h:1,x_center:.484375,y_center:.828125},{w:1,h:1,x_center:.484375,y_center:.828125},{w:1,h:1,x_center:.515625,y_center:.828125},{w:1,h:1,x_center:.515625,y_center:.828125},{w:1,h:1,x_center:.546875,y_center:.828125},{w:1,h:1,x_center:.546875,y_center:.828125},{w:1,h:1,x_center:.578125,y_center:.828125},{w:1,h:1,x_center:.578125,y_center:.828125},{w:1,h:1,x_center:.609375,y_center:.828125},{w:1,h:1,x_center:.609375,y_center:.828125},{w:1,h:1,x_center:.640625,y_center:.828125},{w:1,h:1,x_center:.640625,y_center:.828125},{w:1,h:1,x_center:.671875,y_center:.828125},{w:1,h:1,x_center:.671875,y_center:.828125},{w:1,h:1,x_center:.703125,y_center:.828125},{w:1,h:1,x_center:.703125,y_center:.828125},{w:1,h:1,x_center:.734375,y_center:.828125},{w:1,h:1,x_center:.734375,y_center:.828125},{w:1,h:1,x_center:.765625,y_center:.828125},{w:1,h:1,x_center:.765625,y_center:.828125},{w:1,h:1,x_center:.796875,y_center:.828125},{w:1,h:1,x_center:.796875,y_center:.828125},{w:1,h:1,x_center:.828125,y_center:.828125},{w:1,h:1,x_center:.828125,y_center:.828125},{w:1,h:1,x_center:.859375,y_center:.828125},{w:1,h:1,x_center:.859375,y_center:.828125},{w:1,h:1,x_center:.890625,y_center:.828125},{w:1,h:1,x_center:.890625,y_center:.828125},{w:1,h:1,x_center:.921875,y_center:.828125},{w:1,h:1,x_center:.921875,y_center:.828125},{w:1,h:1,x_center:.953125,y_center:.828125},{w:1,h:1,x_center:.953125,y_center:.828125},{w:1,h:1,x_center:.984375,y_center:.828125},{w:1,h:1,x_center:.984375,y_center:.828125},{w:1,h:1,x_center:.015625,y_center:.859375},{w:1,h:1,x_center:.015625,y_center:.859375},{w:1,h:1,x_center:.046875,y_center:.859375},{w:1,h:1,x_center:.046875,y_center:.859375},{w:1,h:1,x_center:.078125,y_center:.859375},{w:1,h:1,x_center:.078125,y_center:.859375},{w:1,h:1,x_center:.109375,y_center:.859375},{w:1,h:1,x_center:.109375,y_center:.859375},{w:1,h:1,x_center:.140625,y_center:.859375},{w:1,h:1,x_center:.140625,y_center:.859375},{w:1,h:1,x_center:.171875,y_center:.859375},{w:1,h:1,x_center:.171875,y_center:.859375},{w:1,h:1,x_center:.203125,y_center:.859375},{w:1,h:1,x_center:.203125,y_center:.859375},{w:1,h:1,x_center:.234375,y_center:.859375},{w:1,h:1,x_center:.234375,y_center:.859375},{w:1,h:1,x_center:.265625,y_center:.859375},{w:1,h:1,x_center:.265625,y_center:.859375},{w:1,h:1,x_center:.296875,y_center:.859375},{w:1,h:1,x_center:.296875,y_center:.859375},{w:1,h:1,x_center:.328125,y_center:.859375},{w:1,h:1,x_center:.328125,y_center:.859375},{w:1,h:1,x_center:.359375,y_center:.859375},{w:1,h:1,x_center:.359375,y_center:.859375},{w:1,h:1,x_center:.390625,y_center:.859375},{w:1,h:1,x_center:.390625,y_center:.859375},{w:1,h:1,x_center:.421875,y_center:.859375},{w:1,h:1,x_center:.421875,y_center:.859375},{w:1,h:1,x_center:.453125,y_center:.859375},{w:1,h:1,x_center:.453125,y_center:.859375},{w:1,h:1,x_center:.484375,y_center:.859375},{w:1,h:1,x_center:.484375,y_center:.859375},{w:1,h:1,x_center:.515625,y_center:.859375},{w:1,h:1,x_center:.515625,y_center:.859375},{w:1,h:1,x_center:.546875,y_center:.859375},{w:1,h:1,x_center:.546875,y_center:.859375},{w:1,h:1,x_center:.578125,y_center:.859375},{w:1,h:1,x_center:.578125,y_center:.859375},{w:1,h:1,x_center:.609375,y_center:.859375},{w:1,h:1,x_center:.609375,y_center:.859375},{w:1,h:1,x_center:.640625,y_center:.859375},{w:1,h:1,x_center:.640625,y_center:.859375},{w:1,h:1,x_center:.671875,y_center:.859375},{w:1,h:1,x_center:.671875,y_center:.859375},{w:1,h:1,x_center:.703125,y_center:.859375},{w:1,h:1,x_center:.703125,y_center:.859375},{w:1,h:1,x_center:.734375,y_center:.859375},{w:1,h:1,x_center:.734375,y_center:.859375},{w:1,h:1,x_center:.765625,y_center:.859375},{w:1,h:1,x_center:.765625,y_center:.859375},{w:1,h:1,x_center:.796875,y_center:.859375},{w:1,h:1,x_center:.796875,y_center:.859375},{w:1,h:1,x_center:.828125,y_center:.859375},{w:1,h:1,x_center:.828125,y_center:.859375},{w:1,h:1,x_center:.859375,y_center:.859375},{w:1,h:1,x_center:.859375,y_center:.859375},{w:1,h:1,x_center:.890625,y_center:.859375},{w:1,h:1,x_center:.890625,y_center:.859375},{w:1,h:1,x_center:.921875,y_center:.859375},{w:1,h:1,x_center:.921875,y_center:.859375},{w:1,h:1,x_center:.953125,y_center:.859375},{w:1,h:1,x_center:.953125,y_center:.859375},{w:1,h:1,x_center:.984375,y_center:.859375},{w:1,h:1,x_center:.984375,y_center:.859375},{w:1,h:1,x_center:.015625,y_center:.890625},{w:1,h:1,x_center:.015625,y_center:.890625},{w:1,h:1,x_center:.046875,y_center:.890625},{w:1,h:1,x_center:.046875,y_center:.890625},{w:1,h:1,x_center:.078125,y_center:.890625},{w:1,h:1,x_center:.078125,y_center:.890625},{w:1,h:1,x_center:.109375,y_center:.890625},{w:1,h:1,x_center:.109375,y_center:.890625},{w:1,h:1,x_center:.140625,y_center:.890625},{w:1,h:1,x_center:.140625,y_center:.890625},{w:1,h:1,x_center:.171875,y_center:.890625},{w:1,h:1,x_center:.171875,y_center:.890625},{w:1,h:1,x_center:.203125,y_center:.890625},{w:1,h:1,x_center:.203125,y_center:.890625},{w:1,h:1,x_center:.234375,y_center:.890625},{w:1,h:1,x_center:.234375,y_center:.890625},{w:1,h:1,x_center:.265625,y_center:.890625},{w:1,h:1,x_center:.265625,y_center:.890625},{w:1,h:1,x_center:.296875,y_center:.890625},{w:1,h:1,x_center:.296875,y_center:.890625},{w:1,h:1,x_center:.328125,y_center:.890625},{w:1,h:1,x_center:.328125,y_center:.890625},{w:1,h:1,x_center:.359375,y_center:.890625},{w:1,h:1,x_center:.359375,y_center:.890625},{w:1,h:1,x_center:.390625,y_center:.890625},{w:1,h:1,x_center:.390625,y_center:.890625},{w:1,h:1,x_center:.421875,y_center:.890625},{w:1,h:1,x_center:.421875,y_center:.890625},{w:1,h:1,x_center:.453125,y_center:.890625},{w:1,h:1,x_center:.453125,y_center:.890625},{w:1,h:1,x_center:.484375,y_center:.890625},{w:1,h:1,x_center:.484375,y_center:.890625},{w:1,h:1,x_center:.515625,y_center:.890625},{w:1,h:1,x_center:.515625,y_center:.890625},{w:1,h:1,x_center:.546875,y_center:.890625},{w:1,h:1,x_center:.546875,y_center:.890625},{w:1,h:1,x_center:.578125,y_center:.890625},{w:1,h:1,x_center:.578125,y_center:.890625},{w:1,h:1,x_center:.609375,y_center:.890625},{w:1,h:1,x_center:.609375,y_center:.890625},{w:1,h:1,x_center:.640625,y_center:.890625},{w:1,h:1,x_center:.640625,y_center:.890625},{w:1,h:1,x_center:.671875,y_center:.890625},{w:1,h:1,x_center:.671875,y_center:.890625},{w:1,h:1,x_center:.703125,y_center:.890625},{w:1,h:1,x_center:.703125,y_center:.890625},{w:1,h:1,x_center:.734375,y_center:.890625},{w:1,h:1,x_center:.734375,y_center:.890625},{w:1,h:1,x_center:.765625,y_center:.890625},{w:1,h:1,x_center:.765625,y_center:.890625},{w:1,h:1,x_center:.796875,y_center:.890625},{w:1,h:1,x_center:.796875,y_center:.890625},{w:1,h:1,x_center:.828125,y_center:.890625},{w:1,h:1,x_center:.828125,y_center:.890625},{w:1,h:1,x_center:.859375,y_center:.890625},{w:1,h:1,x_center:.859375,y_center:.890625},{w:1,h:1,x_center:.890625,y_center:.890625},{w:1,h:1,x_center:.890625,y_center:.890625},{w:1,h:1,x_center:.921875,y_center:.890625},{w:1,h:1,x_center:.921875,y_center:.890625},{w:1,h:1,x_center:.953125,y_center:.890625},{w:1,h:1,x_center:.953125,y_center:.890625},{w:1,h:1,x_center:.984375,y_center:.890625},{w:1,h:1,x_center:.984375,y_center:.890625},{w:1,h:1,x_center:.015625,y_center:.921875},{w:1,h:1,x_center:.015625,y_center:.921875},{w:1,h:1,x_center:.046875,y_center:.921875},{w:1,h:1,x_center:.046875,y_center:.921875},{w:1,h:1,x_center:.078125,y_center:.921875},{w:1,h:1,x_center:.078125,y_center:.921875},{w:1,h:1,x_center:.109375,y_center:.921875},{w:1,h:1,x_center:.109375,y_center:.921875},{w:1,h:1,x_center:.140625,y_center:.921875},{w:1,h:1,x_center:.140625,y_center:.921875},{w:1,h:1,x_center:.171875,y_center:.921875},{w:1,h:1,x_center:.171875,y_center:.921875},{w:1,h:1,x_center:.203125,y_center:.921875},{w:1,h:1,x_center:.203125,y_center:.921875},{w:1,h:1,x_center:.234375,y_center:.921875},{w:1,h:1,x_center:.234375,y_center:.921875},{w:1,h:1,x_center:.265625,y_center:.921875},{w:1,h:1,x_center:.265625,y_center:.921875},{w:1,h:1,x_center:.296875,y_center:.921875},{w:1,h:1,x_center:.296875,y_center:.921875},{w:1,h:1,x_center:.328125,y_center:.921875},{w:1,h:1,x_center:.328125,y_center:.921875},{w:1,h:1,x_center:.359375,y_center:.921875},{w:1,h:1,x_center:.359375,y_center:.921875},{w:1,h:1,x_center:.390625,y_center:.921875},{w:1,h:1,x_center:.390625,y_center:.921875},{w:1,h:1,x_center:.421875,y_center:.921875},{w:1,h:1,x_center:.421875,y_center:.921875},{w:1,h:1,x_center:.453125,y_center:.921875},{w:1,h:1,x_center:.453125,y_center:.921875},{w:1,h:1,x_center:.484375,y_center:.921875},{w:1,h:1,x_center:.484375,y_center:.921875},{w:1,h:1,x_center:.515625,y_center:.921875},{w:1,h:1,x_center:.515625,y_center:.921875},{w:1,h:1,x_center:.546875,y_center:.921875},{w:1,h:1,x_center:.546875,y_center:.921875},{w:1,h:1,x_center:.578125,y_center:.921875},{w:1,h:1,x_center:.578125,y_center:.921875},{w:1,h:1,x_center:.609375,y_center:.921875},{w:1,h:1,x_center:.609375,y_center:.921875},{w:1,h:1,x_center:.640625,y_center:.921875},{w:1,h:1,x_center:.640625,y_center:.921875},{w:1,h:1,x_center:.671875,y_center:.921875},{w:1,h:1,x_center:.671875,y_center:.921875},{w:1,h:1,x_center:.703125,y_center:.921875},{w:1,h:1,x_center:.703125,y_center:.921875},{w:1,h:1,x_center:.734375,y_center:.921875},{w:1,h:1,x_center:.734375,y_center:.921875},{w:1,h:1,x_center:.765625,y_center:.921875},{w:1,h:1,x_center:.765625,y_center:.921875},{w:1,h:1,x_center:.796875,y_center:.921875},{w:1,h:1,x_center:.796875,y_center:.921875},{w:1,h:1,x_center:.828125,y_center:.921875},{w:1,h:1,x_center:.828125,y_center:.921875},{w:1,h:1,x_center:.859375,y_center:.921875},{w:1,h:1,x_center:.859375,y_center:.921875},{w:1,h:1,x_center:.890625,y_center:.921875},{w:1,h:1,x_center:.890625,y_center:.921875},{w:1,h:1,x_center:.921875,y_center:.921875},{w:1,h:1,x_center:.921875,y_center:.921875},{w:1,h:1,x_center:.953125,y_center:.921875},{w:1,h:1,x_center:.953125,y_center:.921875},{w:1,h:1,x_center:.984375,y_center:.921875},{w:1,h:1,x_center:.984375,y_center:.921875},{w:1,h:1,x_center:.015625,y_center:.953125},{w:1,h:1,x_center:.015625,y_center:.953125},{w:1,h:1,x_center:.046875,y_center:.953125},{w:1,h:1,x_center:.046875,y_center:.953125},{w:1,h:1,x_center:.078125,y_center:.953125},{w:1,h:1,x_center:.078125,y_center:.953125},{w:1,h:1,x_center:.109375,y_center:.953125},{w:1,h:1,x_center:.109375,y_center:.953125},{w:1,h:1,x_center:.140625,y_center:.953125},{w:1,h:1,x_center:.140625,y_center:.953125},{w:1,h:1,x_center:.171875,y_center:.953125},{w:1,h:1,x_center:.171875,y_center:.953125},{w:1,h:1,x_center:.203125,y_center:.953125},{w:1,h:1,x_center:.203125,y_center:.953125},{w:1,h:1,x_center:.234375,y_center:.953125},{w:1,h:1,x_center:.234375,y_center:.953125},{w:1,h:1,x_center:.265625,y_center:.953125},{w:1,h:1,x_center:.265625,y_center:.953125},{w:1,h:1,x_center:.296875,y_center:.953125},{w:1,h:1,x_center:.296875,y_center:.953125},{w:1,h:1,x_center:.328125,y_center:.953125},{w:1,h:1,x_center:.328125,y_center:.953125},{w:1,h:1,x_center:.359375,y_center:.953125},{w:1,h:1,x_center:.359375,y_center:.953125},{w:1,h:1,x_center:.390625,y_center:.953125},{w:1,h:1,x_center:.390625,y_center:.953125},{w:1,h:1,x_center:.421875,y_center:.953125},{w:1,h:1,x_center:.421875,y_center:.953125},{w:1,h:1,x_center:.453125,y_center:.953125},{w:1,h:1,x_center:.453125,y_center:.953125},{w:1,h:1,x_center:.484375,y_center:.953125},{w:1,h:1,x_center:.484375,y_center:.953125},{w:1,h:1,x_center:.515625,y_center:.953125},{w:1,h:1,x_center:.515625,y_center:.953125},{w:1,h:1,x_center:.546875,y_center:.953125},{w:1,h:1,x_center:.546875,y_center:.953125},{w:1,h:1,x_center:.578125,y_center:.953125},{w:1,h:1,x_center:.578125,y_center:.953125},{w:1,h:1,x_center:.609375,y_center:.953125},{w:1,h:1,x_center:.609375,y_center:.953125},{w:1,h:1,x_center:.640625,y_center:.953125},{w:1,h:1,x_center:.640625,y_center:.953125},{w:1,h:1,x_center:.671875,y_center:.953125},{w:1,h:1,x_center:.671875,y_center:.953125},{w:1,h:1,x_center:.703125,y_center:.953125},{w:1,h:1,x_center:.703125,y_center:.953125},{w:1,h:1,x_center:.734375,y_center:.953125},{w:1,h:1,x_center:.734375,y_center:.953125},{w:1,h:1,x_center:.765625,y_center:.953125},{w:1,h:1,x_center:.765625,y_center:.953125},{w:1,h:1,x_center:.796875,y_center:.953125},{w:1,h:1,x_center:.796875,y_center:.953125},{w:1,h:1,x_center:.828125,y_center:.953125},{w:1,h:1,x_center:.828125,y_center:.953125},{w:1,h:1,x_center:.859375,y_center:.953125},{w:1,h:1,x_center:.859375,y_center:.953125},{w:1,h:1,x_center:.890625,y_center:.953125},{w:1,h:1,x_center:.890625,y_center:.953125},{w:1,h:1,x_center:.921875,y_center:.953125},{w:1,h:1,x_center:.921875,y_center:.953125},{w:1,h:1,x_center:.953125,y_center:.953125},{w:1,h:1,x_center:.953125,y_center:.953125},{w:1,h:1,x_center:.984375,y_center:.953125},{w:1,h:1,x_center:.984375,y_center:.953125},{w:1,h:1,x_center:.015625,y_center:.984375},{w:1,h:1,x_center:.015625,y_center:.984375},{w:1,h:1,x_center:.046875,y_center:.984375},{w:1,h:1,x_center:.046875,y_center:.984375},{w:1,h:1,x_center:.078125,y_center:.984375},{w:1,h:1,x_center:.078125,y_center:.984375},{w:1,h:1,x_center:.109375,y_center:.984375},{w:1,h:1,x_center:.109375,y_center:.984375},{w:1,h:1,x_center:.140625,y_center:.984375},{w:1,h:1,x_center:.140625,y_center:.984375},{w:1,h:1,x_center:.171875,y_center:.984375},{w:1,h:1,x_center:.171875,y_center:.984375},{w:1,h:1,x_center:.203125,y_center:.984375},{w:1,h:1,x_center:.203125,y_center:.984375},{w:1,h:1,x_center:.234375,y_center:.984375},{w:1,h:1,x_center:.234375,y_center:.984375},{w:1,h:1,x_center:.265625,y_center:.984375},{w:1,h:1,x_center:.265625,y_center:.984375},{w:1,h:1,x_center:.296875,y_center:.984375},{w:1,h:1,x_center:.296875,y_center:.984375},{w:1,h:1,x_center:.328125,y_center:.984375},{w:1,h:1,x_center:.328125,y_center:.984375},{w:1,h:1,x_center:.359375,y_center:.984375},{w:1,h:1,x_center:.359375,y_center:.984375},{w:1,h:1,x_center:.390625,y_center:.984375},{w:1,h:1,x_center:.390625,y_center:.984375},{w:1,h:1,x_center:.421875,y_center:.984375},{w:1,h:1,x_center:.421875,y_center:.984375},{w:1,h:1,x_center:.453125,y_center:.984375},{w:1,h:1,x_center:.453125,y_center:.984375},{w:1,h:1,x_center:.484375,y_center:.984375},{w:1,h:1,x_center:.484375,y_center:.984375},{w:1,h:1,x_center:.515625,y_center:.984375},{w:1,h:1,x_center:.515625,y_center:.984375},{w:1,h:1,x_center:.546875,y_center:.984375},{w:1,h:1,x_center:.546875,y_center:.984375},{w:1,h:1,x_center:.578125,y_center:.984375},{w:1,h:1,x_center:.578125,y_center:.984375},{w:1,h:1,x_center:.609375,y_center:.984375},{w:1,h:1,x_center:.609375,y_center:.984375},{w:1,h:1,x_center:.640625,y_center:.984375},{w:1,h:1,x_center:.640625,y_center:.984375},{w:1,h:1,x_center:.671875,y_center:.984375},{w:1,h:1,x_center:.671875,y_center:.984375},{w:1,h:1,x_center:.703125,y_center:.984375},{w:1,h:1,x_center:.703125,y_center:.984375},{w:1,h:1,x_center:.734375,y_center:.984375},{w:1,h:1,x_center:.734375,y_center:.984375},{w:1,h:1,x_center:.765625,y_center:.984375},{w:1,h:1,x_center:.765625,y_center:.984375},{w:1,h:1,x_center:.796875,y_center:.984375},{w:1,h:1,x_center:.796875,y_center:.984375},{w:1,h:1,x_center:.828125,y_center:.984375},{w:1,h:1,x_center:.828125,y_center:.984375},{w:1,h:1,x_center:.859375,y_center:.984375},{w:1,h:1,x_center:.859375,y_center:.984375},{w:1,h:1,x_center:.890625,y_center:.984375},{w:1,h:1,x_center:.890625,y_center:.984375},{w:1,h:1,x_center:.921875,y_center:.984375},{w:1,h:1,x_center:.921875,y_center:.984375},{w:1,h:1,x_center:.953125,y_center:.984375},{w:1,h:1,x_center:.953125,y_center:.984375},{w:1,h:1,x_center:.984375,y_center:.984375},{w:1,h:1,x_center:.984375,y_center:.984375},{w:1,h:1,x_center:.03125,y_center:.03125},{w:1,h:1,x_center:.03125,y_center:.03125},{w:1,h:1,x_center:.09375,y_center:.03125},{w:1,h:1,x_center:.09375,y_center:.03125},{w:1,h:1,x_center:.15625,y_center:.03125},{w:1,h:1,x_center:.15625,y_center:.03125},{w:1,h:1,x_center:.21875,y_center:.03125},{w:1,h:1,x_center:.21875,y_center:.03125},{w:1,h:1,x_center:.28125,y_center:.03125},{w:1,h:1,x_center:.28125,y_center:.03125},{w:1,h:1,x_center:.34375,y_center:.03125},{w:1,h:1,x_center:.34375,y_center:.03125},{w:1,h:1,x_center:.40625,y_center:.03125},{w:1,h:1,x_center:.40625,y_center:.03125},{w:1,h:1,x_center:.46875,y_center:.03125},{w:1,h:1,x_center:.46875,y_center:.03125},{w:1,h:1,x_center:.53125,y_center:.03125},{w:1,h:1,x_center:.53125,y_center:.03125},{w:1,h:1,x_center:.59375,y_center:.03125},{w:1,h:1,x_center:.59375,y_center:.03125},{w:1,h:1,x_center:.65625,y_center:.03125},{w:1,h:1,x_center:.65625,y_center:.03125},{w:1,h:1,x_center:.71875,y_center:.03125},{w:1,h:1,x_center:.71875,y_center:.03125},{w:1,h:1,x_center:.78125,y_center:.03125},{w:1,h:1,x_center:.78125,y_center:.03125},{w:1,h:1,x_center:.84375,y_center:.03125},{w:1,h:1,x_center:.84375,y_center:.03125},{w:1,h:1,x_center:.90625,y_center:.03125},{w:1,h:1,x_center:.90625,y_center:.03125},{w:1,h:1,x_center:.96875,y_center:.03125},{w:1,h:1,x_center:.96875,y_center:.03125},{w:1,h:1,x_center:.03125,y_center:.09375},{w:1,h:1,x_center:.03125,y_center:.09375},{w:1,h:1,x_center:.09375,y_center:.09375},{w:1,h:1,x_center:.09375,y_center:.09375},{w:1,h:1,x_center:.15625,y_center:.09375},{w:1,h:1,x_center:.15625,y_center:.09375},{w:1,h:1,x_center:.21875,y_center:.09375},{w:1,h:1,x_center:.21875,y_center:.09375},{w:1,h:1,x_center:.28125,y_center:.09375},{w:1,h:1,x_center:.28125,y_center:.09375},{w:1,h:1,x_center:.34375,y_center:.09375},{w:1,h:1,x_center:.34375,y_center:.09375},{w:1,h:1,x_center:.40625,y_center:.09375},{w:1,h:1,x_center:.40625,y_center:.09375},{w:1,h:1,x_center:.46875,y_center:.09375},{w:1,h:1,x_center:.46875,y_center:.09375},{w:1,h:1,x_center:.53125,y_center:.09375},{w:1,h:1,x_center:.53125,y_center:.09375},{w:1,h:1,x_center:.59375,y_center:.09375},{w:1,h:1,x_center:.59375,y_center:.09375},{w:1,h:1,x_center:.65625,y_center:.09375},{w:1,h:1,x_center:.65625,y_center:.09375},{w:1,h:1,x_center:.71875,y_center:.09375},{w:1,h:1,x_center:.71875,y_center:.09375},{w:1,h:1,x_center:.78125,y_center:.09375},{w:1,h:1,x_center:.78125,y_center:.09375},{w:1,h:1,x_center:.84375,y_center:.09375},{w:1,h:1,x_center:.84375,y_center:.09375},{w:1,h:1,x_center:.90625,y_center:.09375},{w:1,h:1,x_center:.90625,y_center:.09375},{w:1,h:1,x_center:.96875,y_center:.09375},{w:1,h:1,x_center:.96875,y_center:.09375},{w:1,h:1,x_center:.03125,y_center:.15625},{w:1,h:1,x_center:.03125,y_center:.15625},{w:1,h:1,x_center:.09375,y_center:.15625},{w:1,h:1,x_center:.09375,y_center:.15625},{w:1,h:1,x_center:.15625,y_center:.15625},{w:1,h:1,x_center:.15625,y_center:.15625},{w:1,h:1,x_center:.21875,y_center:.15625},{w:1,h:1,x_center:.21875,y_center:.15625},{w:1,h:1,x_center:.28125,y_center:.15625},{w:1,h:1,x_center:.28125,y_center:.15625},{w:1,h:1,x_center:.34375,y_center:.15625},{w:1,h:1,x_center:.34375,y_center:.15625},{w:1,h:1,x_center:.40625,y_center:.15625},{w:1,h:1,x_center:.40625,y_center:.15625},{w:1,h:1,x_center:.46875,y_center:.15625},{w:1,h:1,x_center:.46875,y_center:.15625},{w:1,h:1,x_center:.53125,y_center:.15625},{w:1,h:1,x_center:.53125,y_center:.15625},{w:1,h:1,x_center:.59375,y_center:.15625},{w:1,h:1,x_center:.59375,y_center:.15625},{w:1,h:1,x_center:.65625,y_center:.15625},{w:1,h:1,x_center:.65625,y_center:.15625},{w:1,h:1,x_center:.71875,y_center:.15625},{w:1,h:1,x_center:.71875,y_center:.15625},{w:1,h:1,x_center:.78125,y_center:.15625},{w:1,h:1,x_center:.78125,y_center:.15625},{w:1,h:1,x_center:.84375,y_center:.15625},{w:1,h:1,x_center:.84375,y_center:.15625},{w:1,h:1,x_center:.90625,y_center:.15625},{w:1,h:1,x_center:.90625,y_center:.15625},{w:1,h:1,x_center:.96875,y_center:.15625},{w:1,h:1,x_center:.96875,y_center:.15625},{w:1,h:1,x_center:.03125,y_center:.21875},{w:1,h:1,x_center:.03125,y_center:.21875},{w:1,h:1,x_center:.09375,y_center:.21875},{w:1,h:1,x_center:.09375,y_center:.21875},{w:1,h:1,x_center:.15625,y_center:.21875},{w:1,h:1,x_center:.15625,y_center:.21875},{w:1,h:1,x_center:.21875,y_center:.21875},{w:1,h:1,x_center:.21875,y_center:.21875},{w:1,h:1,x_center:.28125,y_center:.21875},{w:1,h:1,x_center:.28125,y_center:.21875},{w:1,h:1,x_center:.34375,y_center:.21875},{w:1,h:1,x_center:.34375,y_center:.21875},{w:1,h:1,x_center:.40625,y_center:.21875},{w:1,h:1,x_center:.40625,y_center:.21875},{w:1,h:1,x_center:.46875,y_center:.21875},{w:1,h:1,x_center:.46875,y_center:.21875},{w:1,h:1,x_center:.53125,y_center:.21875},{w:1,h:1,x_center:.53125,y_center:.21875},{w:1,h:1,x_center:.59375,y_center:.21875},{w:1,h:1,x_center:.59375,y_center:.21875},{w:1,h:1,x_center:.65625,y_center:.21875},{w:1,h:1,x_center:.65625,y_center:.21875},{w:1,h:1,x_center:.71875,y_center:.21875},{w:1,h:1,x_center:.71875,y_center:.21875},{w:1,h:1,x_center:.78125,y_center:.21875},{w:1,h:1,x_center:.78125,y_center:.21875},{w:1,h:1,x_center:.84375,y_center:.21875},{w:1,h:1,x_center:.84375,y_center:.21875},{w:1,h:1,x_center:.90625,y_center:.21875},{w:1,h:1,x_center:.90625,y_center:.21875},{w:1,h:1,x_center:.96875,y_center:.21875},{w:1,h:1,x_center:.96875,y_center:.21875},{w:1,h:1,x_center:.03125,y_center:.28125},{w:1,h:1,x_center:.03125,y_center:.28125},{w:1,h:1,x_center:.09375,y_center:.28125},{w:1,h:1,x_center:.09375,y_center:.28125},{w:1,h:1,x_center:.15625,y_center:.28125},{w:1,h:1,x_center:.15625,y_center:.28125},{w:1,h:1,x_center:.21875,y_center:.28125},{w:1,h:1,x_center:.21875,y_center:.28125},{w:1,h:1,x_center:.28125,y_center:.28125},{w:1,h:1,x_center:.28125,y_center:.28125},{w:1,h:1,x_center:.34375,y_center:.28125},{w:1,h:1,x_center:.34375,y_center:.28125},{w:1,h:1,x_center:.40625,y_center:.28125},{w:1,h:1,x_center:.40625,y_center:.28125},{w:1,h:1,x_center:.46875,y_center:.28125},{w:1,h:1,x_center:.46875,y_center:.28125},{w:1,h:1,x_center:.53125,y_center:.28125},{w:1,h:1,x_center:.53125,y_center:.28125},{w:1,h:1,x_center:.59375,y_center:.28125},{w:1,h:1,x_center:.59375,y_center:.28125},{w:1,h:1,x_center:.65625,y_center:.28125},{w:1,h:1,x_center:.65625,y_center:.28125},{w:1,h:1,x_center:.71875,y_center:.28125},{w:1,h:1,x_center:.71875,y_center:.28125},{w:1,h:1,x_center:.78125,y_center:.28125},{w:1,h:1,x_center:.78125,y_center:.28125},{w:1,h:1,x_center:.84375,y_center:.28125},{w:1,h:1,x_center:.84375,y_center:.28125},{w:1,h:1,x_center:.90625,y_center:.28125},{w:1,h:1,x_center:.90625,y_center:.28125},{w:1,h:1,x_center:.96875,y_center:.28125},{w:1,h:1,x_center:.96875,y_center:.28125},{w:1,h:1,x_center:.03125,y_center:.34375},{w:1,h:1,x_center:.03125,y_center:.34375},{w:1,h:1,x_center:.09375,y_center:.34375},{w:1,h:1,x_center:.09375,y_center:.34375},{w:1,h:1,x_center:.15625,y_center:.34375},{w:1,h:1,x_center:.15625,y_center:.34375},{w:1,h:1,x_center:.21875,y_center:.34375},{w:1,h:1,x_center:.21875,y_center:.34375},{w:1,h:1,x_center:.28125,y_center:.34375},{w:1,h:1,x_center:.28125,y_center:.34375},{w:1,h:1,x_center:.34375,y_center:.34375},{w:1,h:1,x_center:.34375,y_center:.34375},{w:1,h:1,x_center:.40625,y_center:.34375},{w:1,h:1,x_center:.40625,y_center:.34375},{w:1,h:1,x_center:.46875,y_center:.34375},{w:1,h:1,x_center:.46875,y_center:.34375},{w:1,h:1,x_center:.53125,y_center:.34375},{w:1,h:1,x_center:.53125,y_center:.34375},{w:1,h:1,x_center:.59375,y_center:.34375},{w:1,h:1,x_center:.59375,y_center:.34375},{w:1,h:1,x_center:.65625,y_center:.34375},{w:1,h:1,x_center:.65625,y_center:.34375},{w:1,h:1,x_center:.71875,y_center:.34375},{w:1,h:1,x_center:.71875,y_center:.34375},{w:1,h:1,x_center:.78125,y_center:.34375},{w:1,h:1,x_center:.78125,y_center:.34375},{w:1,h:1,x_center:.84375,y_center:.34375},{w:1,h:1,x_center:.84375,y_center:.34375},{w:1,h:1,x_center:.90625,y_center:.34375},{w:1,h:1,x_center:.90625,y_center:.34375},{w:1,h:1,x_center:.96875,y_center:.34375},{w:1,h:1,x_center:.96875,y_center:.34375},{w:1,h:1,x_center:.03125,y_center:.40625},{w:1,h:1,x_center:.03125,y_center:.40625},{w:1,h:1,x_center:.09375,y_center:.40625},{w:1,h:1,x_center:.09375,y_center:.40625},{w:1,h:1,x_center:.15625,y_center:.40625},{w:1,h:1,x_center:.15625,y_center:.40625},{w:1,h:1,x_center:.21875,y_center:.40625},{w:1,h:1,x_center:.21875,y_center:.40625},{w:1,h:1,x_center:.28125,y_center:.40625},{w:1,h:1,x_center:.28125,y_center:.40625},{w:1,h:1,x_center:.34375,y_center:.40625},{w:1,h:1,x_center:.34375,y_center:.40625},{w:1,h:1,x_center:.40625,y_center:.40625},{w:1,h:1,x_center:.40625,y_center:.40625},{w:1,h:1,x_center:.46875,y_center:.40625},{w:1,h:1,x_center:.46875,y_center:.40625},{w:1,h:1,x_center:.53125,y_center:.40625},{w:1,h:1,x_center:.53125,y_center:.40625},{w:1,h:1,x_center:.59375,y_center:.40625},{w:1,h:1,x_center:.59375,y_center:.40625},{w:1,h:1,x_center:.65625,y_center:.40625},{w:1,h:1,x_center:.65625,y_center:.40625},{w:1,h:1,x_center:.71875,y_center:.40625},{w:1,h:1,x_center:.71875,y_center:.40625},{w:1,h:1,x_center:.78125,y_center:.40625},{w:1,h:1,x_center:.78125,y_center:.40625},{w:1,h:1,x_center:.84375,y_center:.40625},{w:1,h:1,x_center:.84375,y_center:.40625},{w:1,h:1,x_center:.90625,y_center:.40625},{w:1,h:1,x_center:.90625,y_center:.40625},{w:1,h:1,x_center:.96875,y_center:.40625},{w:1,h:1,x_center:.96875,y_center:.40625},{w:1,h:1,x_center:.03125,y_center:.46875},{w:1,h:1,x_center:.03125,y_center:.46875},{w:1,h:1,x_center:.09375,y_center:.46875},{w:1,h:1,x_center:.09375,y_center:.46875},{w:1,h:1,x_center:.15625,y_center:.46875},{w:1,h:1,x_center:.15625,y_center:.46875},{w:1,h:1,x_center:.21875,y_center:.46875},{w:1,h:1,x_center:.21875,y_center:.46875},{w:1,h:1,x_center:.28125,y_center:.46875},{w:1,h:1,x_center:.28125,y_center:.46875},{w:1,h:1,x_center:.34375,y_center:.46875},{w:1,h:1,x_center:.34375,y_center:.46875},{w:1,h:1,x_center:.40625,y_center:.46875},{w:1,h:1,x_center:.40625,y_center:.46875},{w:1,h:1,x_center:.46875,y_center:.46875},{w:1,h:1,x_center:.46875,y_center:.46875},{w:1,h:1,x_center:.53125,y_center:.46875},{w:1,h:1,x_center:.53125,y_center:.46875},{w:1,h:1,x_center:.59375,y_center:.46875},{w:1,h:1,x_center:.59375,y_center:.46875},{w:1,h:1,x_center:.65625,y_center:.46875},{w:1,h:1,x_center:.65625,y_center:.46875},{w:1,h:1,x_center:.71875,y_center:.46875},{w:1,h:1,x_center:.71875,y_center:.46875},{w:1,h:1,x_center:.78125,y_center:.46875},{w:1,h:1,x_center:.78125,y_center:.46875},{w:1,h:1,x_center:.84375,y_center:.46875},{w:1,h:1,x_center:.84375,y_center:.46875},{w:1,h:1,x_center:.90625,y_center:.46875},{w:1,h:1,x_center:.90625,y_center:.46875},{w:1,h:1,x_center:.96875,y_center:.46875},{w:1,h:1,x_center:.96875,y_center:.46875},{w:1,h:1,x_center:.03125,y_center:.53125},{w:1,h:1,x_center:.03125,y_center:.53125},{w:1,h:1,x_center:.09375,y_center:.53125},{w:1,h:1,x_center:.09375,y_center:.53125},{w:1,h:1,x_center:.15625,y_center:.53125},{w:1,h:1,x_center:.15625,y_center:.53125},{w:1,h:1,x_center:.21875,y_center:.53125},{w:1,h:1,x_center:.21875,y_center:.53125},{w:1,h:1,x_center:.28125,y_center:.53125},{w:1,h:1,x_center:.28125,y_center:.53125},{w:1,h:1,x_center:.34375,y_center:.53125},{w:1,h:1,x_center:.34375,y_center:.53125},{w:1,h:1,x_center:.40625,y_center:.53125},{w:1,h:1,x_center:.40625,y_center:.53125},{w:1,h:1,x_center:.46875,y_center:.53125},{w:1,h:1,x_center:.46875,y_center:.53125},{w:1,h:1,x_center:.53125,y_center:.53125},{w:1,h:1,x_center:.53125,y_center:.53125},{w:1,h:1,x_center:.59375,y_center:.53125},{w:1,h:1,x_center:.59375,y_center:.53125},{w:1,h:1,x_center:.65625,y_center:.53125},{w:1,h:1,x_center:.65625,y_center:.53125},{w:1,h:1,x_center:.71875,y_center:.53125},{w:1,h:1,x_center:.71875,y_center:.53125},{w:1,h:1,x_center:.78125,y_center:.53125},{w:1,h:1,x_center:.78125,y_center:.53125},{w:1,h:1,x_center:.84375,y_center:.53125},{w:1,h:1,x_center:.84375,y_center:.53125},{w:1,h:1,x_center:.90625,y_center:.53125},{w:1,h:1,x_center:.90625,y_center:.53125},{w:1,h:1,x_center:.96875,y_center:.53125},{w:1,h:1,x_center:.96875,y_center:.53125},{w:1,h:1,x_center:.03125,y_center:.59375},{w:1,h:1,x_center:.03125,y_center:.59375},{w:1,h:1,x_center:.09375,y_center:.59375},{w:1,h:1,x_center:.09375,y_center:.59375},{w:1,h:1,x_center:.15625,y_center:.59375},{w:1,h:1,x_center:.15625,y_center:.59375},{w:1,h:1,x_center:.21875,y_center:.59375},{w:1,h:1,x_center:.21875,y_center:.59375},{w:1,h:1,x_center:.28125,y_center:.59375},{w:1,h:1,x_center:.28125,y_center:.59375},{w:1,h:1,x_center:.34375,y_center:.59375},{w:1,h:1,x_center:.34375,y_center:.59375},{w:1,h:1,x_center:.40625,y_center:.59375},{w:1,h:1,x_center:.40625,y_center:.59375},{w:1,h:1,x_center:.46875,y_center:.59375},{w:1,h:1,x_center:.46875,y_center:.59375},{w:1,h:1,x_center:.53125,y_center:.59375},{w:1,h:1,x_center:.53125,y_center:.59375},{w:1,h:1,x_center:.59375,y_center:.59375},{w:1,h:1,x_center:.59375,y_center:.59375},{w:1,h:1,x_center:.65625,y_center:.59375},{w:1,h:1,x_center:.65625,y_center:.59375},{w:1,h:1,x_center:.71875,y_center:.59375},{w:1,h:1,x_center:.71875,y_center:.59375},{w:1,h:1,x_center:.78125,y_center:.59375},{w:1,h:1,x_center:.78125,y_center:.59375},{w:1,h:1,x_center:.84375,y_center:.59375},{w:1,h:1,x_center:.84375,y_center:.59375},{w:1,h:1,x_center:.90625,y_center:.59375},{w:1,h:1,x_center:.90625,y_center:.59375},{w:1,h:1,x_center:.96875,y_center:.59375},{w:1,h:1,x_center:.96875,y_center:.59375},{w:1,h:1,x_center:.03125,y_center:.65625},{w:1,h:1,x_center:.03125,y_center:.65625},{w:1,h:1,x_center:.09375,y_center:.65625},{w:1,h:1,x_center:.09375,y_center:.65625},{w:1,h:1,x_center:.15625,y_center:.65625},{w:1,h:1,x_center:.15625,y_center:.65625},{w:1,h:1,x_center:.21875,y_center:.65625},{w:1,h:1,x_center:.21875,y_center:.65625},{w:1,h:1,x_center:.28125,y_center:.65625},{w:1,h:1,x_center:.28125,y_center:.65625},{w:1,h:1,x_center:.34375,y_center:.65625},{w:1,h:1,x_center:.34375,y_center:.65625},{w:1,h:1,x_center:.40625,y_center:.65625},{w:1,h:1,x_center:.40625,y_center:.65625},{w:1,h:1,x_center:.46875,y_center:.65625},{w:1,h:1,x_center:.46875,y_center:.65625},{w:1,h:1,x_center:.53125,y_center:.65625},{w:1,h:1,x_center:.53125,y_center:.65625},{w:1,h:1,x_center:.59375,y_center:.65625},{w:1,h:1,x_center:.59375,y_center:.65625},{w:1,h:1,x_center:.65625,y_center:.65625},{w:1,h:1,x_center:.65625,y_center:.65625},{w:1,h:1,x_center:.71875,y_center:.65625},{w:1,h:1,x_center:.71875,y_center:.65625},{w:1,h:1,x_center:.78125,y_center:.65625},{w:1,h:1,x_center:.78125,y_center:.65625},{w:1,h:1,x_center:.84375,y_center:.65625},{w:1,h:1,x_center:.84375,y_center:.65625},{w:1,h:1,x_center:.90625,y_center:.65625},{w:1,h:1,x_center:.90625,y_center:.65625},{w:1,h:1,x_center:.96875,y_center:.65625},{w:1,h:1,x_center:.96875,y_center:.65625},{w:1,h:1,x_center:.03125,y_center:.71875},{w:1,h:1,x_center:.03125,y_center:.71875},{w:1,h:1,x_center:.09375,y_center:.71875},{w:1,h:1,x_center:.09375,y_center:.71875},{w:1,h:1,x_center:.15625,y_center:.71875},{w:1,h:1,x_center:.15625,y_center:.71875},{w:1,h:1,x_center:.21875,y_center:.71875},{w:1,h:1,x_center:.21875,y_center:.71875},{w:1,h:1,x_center:.28125,y_center:.71875},{w:1,h:1,x_center:.28125,y_center:.71875},{w:1,h:1,x_center:.34375,y_center:.71875},{w:1,h:1,x_center:.34375,y_center:.71875},{w:1,h:1,x_center:.40625,y_center:.71875},{w:1,h:1,x_center:.40625,y_center:.71875},{w:1,h:1,x_center:.46875,y_center:.71875},{w:1,h:1,x_center:.46875,y_center:.71875},{w:1,h:1,x_center:.53125,y_center:.71875},{w:1,h:1,x_center:.53125,y_center:.71875},{w:1,h:1,x_center:.59375,y_center:.71875},{w:1,h:1,x_center:.59375,y_center:.71875},{w:1,h:1,x_center:.65625,y_center:.71875},{w:1,h:1,x_center:.65625,y_center:.71875},{w:1,h:1,x_center:.71875,y_center:.71875},{w:1,h:1,x_center:.71875,y_center:.71875},{w:1,h:1,x_center:.78125,y_center:.71875},{w:1,h:1,x_center:.78125,y_center:.71875},{w:1,h:1,x_center:.84375,y_center:.71875},{w:1,h:1,x_center:.84375,y_center:.71875},{w:1,h:1,x_center:.90625,y_center:.71875},{w:1,h:1,x_center:.90625,y_center:.71875},{w:1,h:1,x_center:.96875,y_center:.71875},{w:1,h:1,x_center:.96875,y_center:.71875},{w:1,h:1,x_center:.03125,y_center:.78125},{w:1,h:1,x_center:.03125,y_center:.78125},{w:1,h:1,x_center:.09375,y_center:.78125},{w:1,h:1,x_center:.09375,y_center:.78125},{w:1,h:1,x_center:.15625,y_center:.78125},{w:1,h:1,x_center:.15625,y_center:.78125},{w:1,h:1,x_center:.21875,y_center:.78125},{w:1,h:1,x_center:.21875,y_center:.78125},{w:1,h:1,x_center:.28125,y_center:.78125},{w:1,h:1,x_center:.28125,y_center:.78125},{w:1,h:1,x_center:.34375,y_center:.78125},{w:1,h:1,x_center:.34375,y_center:.78125},{w:1,h:1,x_center:.40625,y_center:.78125},{w:1,h:1,x_center:.40625,y_center:.78125},{w:1,h:1,x_center:.46875,y_center:.78125},{w:1,h:1,x_center:.46875,y_center:.78125},{w:1,h:1,x_center:.53125,y_center:.78125},{w:1,h:1,x_center:.53125,y_center:.78125},{w:1,h:1,x_center:.59375,y_center:.78125},{w:1,h:1,x_center:.59375,y_center:.78125},{w:1,h:1,x_center:.65625,y_center:.78125},{w:1,h:1,x_center:.65625,y_center:.78125},{w:1,h:1,x_center:.71875,y_center:.78125},{w:1,h:1,x_center:.71875,y_center:.78125},{w:1,h:1,x_center:.78125,y_center:.78125},{w:1,h:1,x_center:.78125,y_center:.78125},{w:1,h:1,x_center:.84375,y_center:.78125},{w:1,h:1,x_center:.84375,y_center:.78125},{w:1,h:1,x_center:.90625,y_center:.78125},{w:1,h:1,x_center:.90625,y_center:.78125},{w:1,h:1,x_center:.96875,y_center:.78125},{w:1,h:1,x_center:.96875,y_center:.78125},{w:1,h:1,x_center:.03125,y_center:.84375},{w:1,h:1,x_center:.03125,y_center:.84375},{w:1,h:1,x_center:.09375,y_center:.84375},{w:1,h:1,x_center:.09375,y_center:.84375},{w:1,h:1,x_center:.15625,y_center:.84375},{w:1,h:1,x_center:.15625,y_center:.84375},{w:1,h:1,x_center:.21875,y_center:.84375},{w:1,h:1,x_center:.21875,y_center:.84375},{w:1,h:1,x_center:.28125,y_center:.84375},{w:1,h:1,x_center:.28125,y_center:.84375},{w:1,h:1,x_center:.34375,y_center:.84375},{w:1,h:1,x_center:.34375,y_center:.84375},{w:1,h:1,x_center:.40625,y_center:.84375},{w:1,h:1,x_center:.40625,y_center:.84375},{w:1,h:1,x_center:.46875,y_center:.84375},{w:1,h:1,x_center:.46875,y_center:.84375},{w:1,h:1,x_center:.53125,y_center:.84375},{w:1,h:1,x_center:.53125,y_center:.84375},{w:1,h:1,x_center:.59375,y_center:.84375},{w:1,h:1,x_center:.59375,y_center:.84375},{w:1,h:1,x_center:.65625,y_center:.84375},{w:1,h:1,x_center:.65625,y_center:.84375},{w:1,h:1,x_center:.71875,y_center:.84375},{w:1,h:1,x_center:.71875,y_center:.84375},{w:1,h:1,x_center:.78125,y_center:.84375},{w:1,h:1,x_center:.78125,y_center:.84375},{w:1,h:1,x_center:.84375,y_center:.84375},{w:1,h:1,x_center:.84375,y_center:.84375},{w:1,h:1,x_center:.90625,y_center:.84375},{w:1,h:1,x_center:.90625,y_center:.84375},{w:1,h:1,x_center:.96875,y_center:.84375},{w:1,h:1,x_center:.96875,y_center:.84375},{w:1,h:1,x_center:.03125,y_center:.90625},{w:1,h:1,x_center:.03125,y_center:.90625},{w:1,h:1,x_center:.09375,y_center:.90625},{w:1,h:1,x_center:.09375,y_center:.90625},{w:1,h:1,x_center:.15625,y_center:.90625},{w:1,h:1,x_center:.15625,y_center:.90625},{w:1,h:1,x_center:.21875,y_center:.90625},{w:1,h:1,x_center:.21875,y_center:.90625},{w:1,h:1,x_center:.28125,y_center:.90625},{w:1,h:1,x_center:.28125,y_center:.90625},{w:1,h:1,x_center:.34375,y_center:.90625},{w:1,h:1,x_center:.34375,y_center:.90625},{w:1,h:1,x_center:.40625,y_center:.90625},{w:1,h:1,x_center:.40625,y_center:.90625},{w:1,h:1,x_center:.46875,y_center:.90625},{w:1,h:1,x_center:.46875,y_center:.90625},{w:1,h:1,x_center:.53125,y_center:.90625},{w:1,h:1,x_center:.53125,y_center:.90625},{w:1,h:1,x_center:.59375,y_center:.90625},{w:1,h:1,x_center:.59375,y_center:.90625},{w:1,h:1,x_center:.65625,y_center:.90625},{w:1,h:1,x_center:.65625,y_center:.90625},{w:1,h:1,x_center:.71875,y_center:.90625},{w:1,h:1,x_center:.71875,y_center:.90625},{w:1,h:1,x_center:.78125,y_center:.90625},{w:1,h:1,x_center:.78125,y_center:.90625},{w:1,h:1,x_center:.84375,y_center:.90625},{w:1,h:1,x_center:.84375,y_center:.90625},{w:1,h:1,x_center:.90625,y_center:.90625},{w:1,h:1,x_center:.90625,y_center:.90625},{w:1,h:1,x_center:.96875,y_center:.90625},{w:1,h:1,x_center:.96875,y_center:.90625},{w:1,h:1,x_center:.03125,y_center:.96875},{w:1,h:1,x_center:.03125,y_center:.96875},{w:1,h:1,x_center:.09375,y_center:.96875},{w:1,h:1,x_center:.09375,y_center:.96875},{w:1,h:1,x_center:.15625,y_center:.96875},{w:1,h:1,x_center:.15625,y_center:.96875},{w:1,h:1,x_center:.21875,y_center:.96875},{w:1,h:1,x_center:.21875,y_center:.96875},{w:1,h:1,x_center:.28125,y_center:.96875},{w:1,h:1,x_center:.28125,y_center:.96875},{w:1,h:1,x_center:.34375,y_center:.96875},{w:1,h:1,x_center:.34375,y_center:.96875},{w:1,h:1,x_center:.40625,y_center:.96875},{w:1,h:1,x_center:.40625,y_center:.96875},{w:1,h:1,x_center:.46875,y_center:.96875},{w:1,h:1,x_center:.46875,y_center:.96875},{w:1,h:1,x_center:.53125,y_center:.96875},{w:1,h:1,x_center:.53125,y_center:.96875},{w:1,h:1,x_center:.59375,y_center:.96875},{w:1,h:1,x_center:.59375,y_center:.96875},{w:1,h:1,x_center:.65625,y_center:.96875},{w:1,h:1,x_center:.65625,y_center:.96875},{w:1,h:1,x_center:.71875,y_center:.96875},{w:1,h:1,x_center:.71875,y_center:.96875},{w:1,h:1,x_center:.78125,y_center:.96875},{w:1,h:1,x_center:.78125,y_center:.96875},{w:1,h:1,x_center:.84375,y_center:.96875},{w:1,h:1,x_center:.84375,y_center:.96875},{w:1,h:1,x_center:.90625,y_center:.96875},{w:1,h:1,x_center:.90625,y_center:.96875},{w:1,h:1,x_center:.96875,y_center:.96875},{w:1,h:1,x_center:.96875,y_center:.96875},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.1875,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.3125,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.4375,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.5625,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.6875,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.8125,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.9375,y_center:.0625},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.1875,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.3125,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.4375,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.5625,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.6875,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.8125,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.9375,y_center:.1875},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.1875,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.3125,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.4375,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.5625,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.6875,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.8125,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.9375,y_center:.3125},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.1875,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.3125,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.4375,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.5625,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.6875,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.8125,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.9375,y_center:.4375},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.1875,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.3125,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.4375,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.5625,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.6875,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.8125,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.9375,y_center:.5625},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.1875,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.3125,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.4375,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.5625,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.6875,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.8125,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.9375,y_center:.6875},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.1875,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.3125,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.4375,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.5625,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.6875,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.8125,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.9375,y_center:.8125},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.0625,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.1875,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.3125,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.4375,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.5625,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.6875,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.8125,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375},{w:1,h:1,x_center:.9375,y_center:.9375}]}),Bg=Mr(N=>{const i=to(),ke=Mg(),O=zg(),H=Pg(),se={thumb:[1,2,3,4],indexFinger:[5,6,7,8],middleFinger:[9,10,11,12],ringFinger:[13,14,15,16],pinky:[17,18,19,20],palmBase:[0]};class xe{constructor(Ae){this.pipeline=Ae}static getAnnotations(){return se}async estimateHands(Ae,P){const he=await this.pipeline.estimateHands(Ae,P);if(!he)return[];const me=[];for(const ae of he){const w={};for(const ge of Object.keys(se))w[ge]=se[ge].map(ze=>ae.landmarks[ze]);me.push({confidence:ae.handInViewConfidence,box:ae.boundingBox?[ae.boundingBox.topLeft[0],ae.boundingBox.topLeft[1],ae.boundingBox.bottomRight[0]-ae.boundingBox.topLeft[0],ae.boundingBox.bottomRight[1]-ae.boundingBox.topLeft[1]]:0,landmarks:ae.landmarks,annotations:w})}return me}}N.HandPose=xe;async function Q(Ae){const[P,he]=await Promise.all([i.loadGraphModel(Ae.detector.modelPath,{fromTFHub:Ae.detector.modelPath.includes("tfhub.dev")}),i.loadGraphModel(Ae.skeleton.modelPath,{fromTFHub:Ae.skeleton.modelPath.includes("tfhub.dev")})]),me=new ke.HandDetector(P,Ae.inputSize,H.anchors),ae=new O.HandPipeline(me,he,Ae.inputSize),w=new xe(ae);return w}N.load=Q}),Wg=Mr(N=>{N.body=i=>{if(!i)return[];const ke=[];for(const O of i){const H=O.keypoints.find(P=>P.part==="leftWrist"),se=O.keypoints.find(P=>P.part==="rightWrist"),xe=O.keypoints.find(P=>P.part==="nose");xe&&H&&se&&H.position.yP.part==="leftShoulder"),Ae=O.keypoints.find(P=>P.part==="rightShoulder");Q&&Ae&&ke.push(`leaning ${Q.position.y>Ae.position.y?"left":"right"}`)}return ke},N.face=i=>{if(!i)return[];const ke=[];for(const O of i)O.annotations.rightCheek&&O.annotations.leftCheek&&O.annotations.rightCheek.length>0&&O.annotations.leftCheek.length>0&&ke.push(`facing ${O.annotations.rightCheek[0][2]>0||O.annotations.leftCheek[0][2]<0?"right":"left"}`);return ke},N.hand=i=>{if(!i)return[];const ke=[];for(const O of i){const H=[];for(const[Q,Ae]of Object.entries(O.annotations))Q!=="palmBase"&&H.push({name:Q.toLowerCase(),position:Ae[0]});const se=H.reduce((Q,Ae)=>Q.position[2]Q.position[1]{const i=function(O,H,se){const xe=function(he,me,ae){const w=new RegExp("\\b"+me+" \\w+ (\\w+)","ig");he.replace(w,(ge,ze)=>(ae[ze]=0,ge))},Q=function(he,me){const ae=O.createShader(me);if(O.shaderSource(ae,he),O.compileShader(ae),!O.getShaderParameter(ae,O.COMPILE_STATUS))throw new Error("Filter: GL compile failed",O.getShaderInfoLog(ae));return ae};this.uniform={},this.attribute={};const Ae=Q(H,O.VERTEX_SHADER),P=Q(se,O.FRAGMENT_SHADER);if(this.id=O.createProgram(),O.attachShader(this.id,Ae),O.attachShader(this.id,P),O.linkProgram(this.id),!O.getProgramParameter(this.id,O.LINK_STATUS))throw new Error("Filter: GL link failed",O.getProgramInfoLog(this.id));O.useProgram(this.id),xe(H,"attribute",this.attribute);for(const he in this.attribute)this.attribute[he]=O.getAttribLocation(this.id,he);xe(H,"uniform",this.uniform),xe(se,"uniform",this.uniform);for(const he in this.uniform)this.uniform[he]=O.getUniformLocation(this.id,he)},ke=function(O){O||(O={});let H=0,se=null,xe=!1,Q=-1,Ae=[null,null],P=[],he=-1,me=-1,ae=null,w=null;const ge=O.canvas||document.createElement("canvas"),ze={},W=ge.getContext("webgl");if(!W)throw new Error("Filter: getContext() failed");this.addFilter=function(ht){const ut=Array.prototype.slice.call(arguments,1),yt=ot[ht];P.push({func:yt,args:ut})},this.reset=function(){P=[]},this.apply=function(ht){if(nt(ht.width,ht.height),H=0,se||(se=W.createTexture()),W.bindTexture(W.TEXTURE_2D,se),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_S,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_T,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MIN_FILTER,W.NEAREST),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MAG_FILTER,W.NEAREST),W.texImage2D(W.TEXTURE_2D,0,W.RGBA,W.RGBA,W.UNSIGNED_BYTE,ht),P.length===0)return Tt(),ge;for(let ut=0;ut{const i=to(),ke=Ug();let O=null,H=null;function se(xe,Q){let Ae;if(xe instanceof i.Tensor)Ae=i.clone(xe);else{const P=xe.naturalWidth||xe.videoWidth||xe.width||xe.shape&&xe.shape[1]>0,he=xe.naturalHeight||xe.videoHeight||xe.height||xe.shape&&xe.shape[2]>0;let me=P,ae=he;Q.filter.width>0?me=Q.filter.width:Q.filter.height>0&&(me=P*(Q.filter.height/he)),Q.filter.height>0?ae=Q.filter.height:Q.filter.width>0&&(ae=he*(Q.filter.width/P)),(!O||O.width!==me||O.height!==ae)&&(O=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(me,ae):document.createElement("canvas"),O.width!==me&&(O.width=me),O.height!==ae&&(O.height=ae));const w=O.getContext("2d");xe instanceof ImageData?w.putImageData(xe,0,0):w.drawImage(xe,0,0,P,he,0,0,O.width,O.height),Q.filter.enabled&&((!this.fx||!H||O.width!==H.width||O.height!==H.height)&&(H=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(O.width,O.height):document.createElement("canvas"),H.width!==O.width&&(H.width=O.width),H.height!==O.height&&(H.height=O.height),this.fx=i.ENV.flags.IS_BROWSER&&typeof document!="undefined"?new ke.Canvas({canvas:H}):null),this.fx.reset(),this.fx.addFilter("brightness",Q.filter.brightness),Q.filter.contrast!==0&&this.fx.addFilter("contrast",Q.filter.contrast),Q.filter.sharpness!==0&&this.fx.addFilter("sharpen",Q.filter.sharpness),Q.filter.blur!==0&&this.fx.addFilter("blur",Q.filter.blur),Q.filter.saturation!==0&&this.fx.addFilter("saturation",Q.filter.saturation),Q.filter.hue!==0&&this.fx.addFilter("hue",Q.filter.hue),Q.filter.negative&&this.fx.addFilter("negative"),Q.filter.sepia&&this.fx.addFilter("sepia"),Q.filter.vintage&&this.fx.addFilter("brownie"),Q.filter.sepia&&this.fx.addFilter("sepia"),Q.filter.kodachrome&&this.fx.addFilter("kodachrome"),Q.filter.technicolor&&this.fx.addFilter("technicolor"),Q.filter.polaroid&&this.fx.addFilter("polaroid"),Q.filter.pixelate!==0&&this.fx.addFilter("pixelate",Q.filter.pixelate),this.fx.apply(O)),H||(H=O);let ge;if(Q.backend==="webgl"||H instanceof ImageData)ge=i.browser.fromPixels(H);else{const W=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(me,ae):document.createElement("canvas");W.width=me,W.height=ae;const nt=W.getContext("2d");nt.drawImage(H,0,0);const tt=nt.getImageData(0,0,me,ae);ge=i.browser.fromPixels(tt)}const ze=ge.toFloat();Ae=ze.expandDims(0),ge.dispose(),ze.dispose()}return{tensor:Ae,canvas:Q.filter.return?H:null}}N.process=se}),Hg=Mr(N=>{Kh(N,{default:()=>i});var i={backend:"webgl",console:!0,async:!1,profile:!1,deallocate:!1,scoped:!1,videoOptimized:!0,filter:{enabled:!0,width:0,height:0,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"../models/blazeface-back.json",inputSize:256,maxFaces:10,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.5},mesh:{enabled:!0,modelPath:"../models/facemesh.json",inputSize:192},iris:{enabled:!0,modelPath:"../models/iris.json",enlargeFactor:2.3,inputSize:64},age:{enabled:!0,modelPath:"../models/ssrnet-age-imdb.json",inputSize:64,skipFrames:10},gender:{enabled:!0,minConfidence:.8,modelPath:"../models/ssrnet-gender-imdb.json"},emotion:{enabled:!0,inputSize:64,minConfidence:.5,skipFrames:10,modelPath:"../models/emotion.json"}},body:{enabled:!0,modelPath:"../models/posenet.json",inputResolution:257,outputStride:16,maxDetections:10,scoreThreshold:.5,nmsRadius:20},hand:{enabled:!0,inputSize:256,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.5,enlargeFactor:1.65,maxHands:10,detector:{modelPath:"../models/handdetect.json"},skeleton:{modelPath:"../models/handskeleton.json"}}}}),Gg=Mr((N,i)=>{i.exports={name:"@vladmandic/human",version:"0.6.7",description:"human: 3D Face Detection, Body Pose, Hand & Finger Tracking, Iris Tracking, Age & Gender Prediction, Emotion Prediction & Gesture Recognition",sideEffects:!1,main:"dist/human.node.js",module:"dist/human.esm.js",browser:"dist/human.esm.js",author:"Vladimir Mandic ",bugs:{url:"https://github.com/vladmandic/human/issues"},homepage:"https://github.com/vladmandic/human#readme",license:"MIT",engines:{node:">=14.0.0"},repository:{type:"git",url:"git+https://github.com/vladmandic/human.git"},dependencies:{},peerDependencies:{},devDependencies:{"@tensorflow/tfjs":"^2.7.0","@tensorflow/tfjs-node":"^2.7.0","@vladmandic/pilogger":"^0.2.7",dayjs:"^1.9.4",esbuild:"^0.7.22",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.2","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.2.1",rimraf:"^3.0.2",seedrandom:"^3.0.5","simple-git":"^2.21.0"},scripts:{start:"node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",lint:"eslint src/*.js demo/*.js","build-iife":"esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=iife --external:fs --global-name=Human --metafile=dist/human.json --outfile=dist/human.js src/human.js","build-esm-bundle":"esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=esm --external:fs --metafile=dist/human.esm.json --outfile=dist/human.esm.js src/human.js","build-esm-nobundle":"esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=esm --external:@tensorflow --external:fs --metafile=dist/human.esm-nobundle.json --outfile=dist/human.esm-nobundle.js src/human.js","build-node":"esbuild --bundle --minify --platform=node --sourcemap --target=esnext --format=cjs --metafile=dist/human.node.json --outfile=dist/human.node.js src/human.js","build-node-nobundle":"esbuild --bundle --minify --platform=node --sourcemap --target=esnext --format=cjs --external:@tensorflow --metafile=dist/human.node.json --outfile=dist/human.node-nobundle.js src/human.js","build-demo":"esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=esm --external:fs --metafile=dist/demo-browser-index.json --outfile=dist/demo-browser-index.js demo/browser.js",build:"rimraf dist/* && npm run build-iife && npm run build-esm-bundle && npm run build-esm-nobundle && npm run build-node && npm run build-node-nobundle && npm run build-demo && ls -l dist/",update:"npm update --depth 20 --force && npm dedupe && npm prune && npm audit",changelog:"node changelog.js"},keywords:["tensorflowjs","face-detection","face-geometry","body-tracking","hand-tracking","iris-tracking","age-estimation","emotion-detection","gender-prediction","gesture-recognition"]}});const fo=to(),xf=Ng(),Yh=Cg(),Wp=Tg(),_f=Og(),wf=Bg(),Up=Wg(),jg=Vg(),qg=Bp(),Qh=Hg().default,Kg=Gg(),Xg={face:{detector:{skipFrames:0},age:{skipFrames:0},emotion:{skipFrames:0}},hand:{skipFrames:0}},ei=()=>typeof performance!="undefined"?performance.now():parseInt(Number(process.hrtime.bigint())/1e3/1e3);function Zh(...N){const i=ke=>ke&&typeof ke=="object";return N.reduce((ke,O)=>(Object.keys(O||{}).forEach(H=>{const se=ke[H],xe=O[H];Array.isArray(se)&&Array.isArray(xe)?ke[H]=se.concat(...xe):i(se)&&i(xe)?ke[H]=Zh(se,xe):ke[H]=xe}),ke),{})}class bf{constructor(){this.tf=fo,this.version=Kg.version,this.defaults=Qh,this.config=Qh,this.fx=null,this.state="idle",this.numTensors=0,this.analyzeMemoryLeaks=!1,this.checkSanity=!1,this.firstRun=!0,this.models={facemesh:null,posenet:null,handpose:null,iris:null,age:null,gender:null,emotion:null},this.facemesh=xf,this.ssrnet=Yh,this.emotion=Wp,this.posenet=_f,this.handpose=wf}log(...N){N&&this.config.console&&console.log("Human:",...N)}profile(){return this.config.profile?qg.data:{}}analyze(...N){if(!this.analyzeMemoryLeaks)return;const i=fo.engine().state.numTensors,ke=this.numTensors;this.numTensors=i;const O=i-ke;O!==0&&this.log(...N,O)}sanity(N){if(!this.checkSanity)return null;if(!N)return"input is not defined";if(fo.ENV.flags.IS_NODE&&!(N instanceof fo.Tensor))return"input must be a tensor";try{fo.getBackend()}catch{return"backend not loaded"}return null}async load(N){N&&(this.config=Zh(Qh,N)),this.firstRun&&(this.checkBackend(!0),this.log(`version: ${this.version} TensorFlow/JS version: ${fo.version_core}`),this.log("configuration:",this.config),this.log("flags:",fo.ENV.flags),this.firstRun=!1),this.config.face.enabled&&!this.models.facemesh&&(this.log("load model: face"),this.models.facemesh=await xf.load(this.config.face)),this.config.body.enabled&&!this.models.posenet&&(this.log("load model: body"),this.models.posenet=await _f.load(this.config.body)),this.config.hand.enabled&&!this.models.handpose&&(this.log("load model: hand"),this.models.handpose=await wf.load(this.config.hand)),this.config.face.enabled&&this.config.face.age.enabled&&!this.models.age&&(this.log("load model: age"),this.models.age=await Yh.loadAge(this.config)),this.config.face.enabled&&this.config.face.gender.enabled&&!this.models.gender&&(this.log("load model: gender"),this.models.gender=await Yh.loadGender(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.log("load model: emotion"),this.models.emotion=await Wp.load(this.config))}async checkBackend(N){(N||fo.getBackend()!==this.config.backend)&&(this.state="backend",this.log("setting backend:",this.config.backend),await fo.setBackend(this.config.backend),fo.enableProdMode(),this.config.deallocate&&this.config.backend==="webgl"&&(this.log("Changing WebGL: WEBGL_DELETE_TEXTURE_THRESHOLD:",this.config.deallocate),fo.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",this.config.deallocate?0:-1)),await fo.ready())}async detect(N,i={}){this.state="config";const ke={};let O;this.config=Zh(Qh,i),this.config.videoOptimized||(this.config=Zh(this.config,Xg)),this.state="check";const H=this.sanity(N);return H?(this.log(H,N),{error:H}):new Promise(async se=>{let xe,Q,Ae,P;const he=ei();O=ei(),await this.checkBackend(),ke.backend=Math.trunc(ei()-O),O=ei(),this.state="load",await this.load(),ke.load=Math.trunc(ei()-O),this.config.scoped&&fo.engine().startScope(),this.analyze("Start Detect:"),O=ei();const me=jg.process(N,this.config);ke.image=Math.trunc(ei()-O);const ae=[];if(this.config.face.enabled){this.state="run:face",O=ei(),this.analyze("Start FaceMesh:");const ge=await this.models.facemesh.estimateFaces(me.tensor,this.config.face);ke.face=Math.trunc(ei()-O);for(const ze of ge){if(!ze.image||ze.image.isDisposedInternal){this.log("Face object is disposed:",ze.image);continue}this.state="run:agegender",O=ei(),Ae=this.config.face.age.enabled||this.config.face.gender.enabled?await Yh.predict(ze.image,this.config):{},ke.agegender=Math.trunc(ei()-O),this.state="run:emotion",O=ei(),P=this.config.face.emotion.enabled?await Wp.predict(ze.image,this.config):{},ke.emotion=Math.trunc(ei()-O),ze.image.dispose();const W=ze.annotations.leftEyeIris&&ze.annotations.rightEyeIris?Math.max(ze.annotations.leftEyeIris[3][0]-ze.annotations.leftEyeIris[1][0],ze.annotations.rightEyeIris[3][0]-ze.annotations.rightEyeIris[1][0]):0;ae.push({confidence:ze.confidence,box:ze.box,mesh:ze.mesh,annotations:ze.annotations,age:Ae.age,gender:Ae.gender,agConfidence:Ae.confidence,emotion:P,iris:W!==0?Math.trunc(100*11.7/W)/100:0}),this.analyze("End FaceMesh:")}}this.config.async?xe=this.config.body.enabled?this.models.posenet.estimatePoses(me.tensor,this.config.body):[]:(this.state="run:body",O=ei(),this.analyze("Start PoseNet"),xe=this.config.body.enabled?await this.models.posenet.estimatePoses(me.tensor,this.config.body):[],this.analyze("End PoseNet:"),ke.body=Math.trunc(ei()-O)),this.config.async?Q=this.config.hand.enabled?this.models.handpose.estimateHands(me.tensor,this.config.hand):[]:(this.state="run:hand",O=ei(),this.analyze("Start HandPose:"),Q=this.config.hand.enabled?await this.models.handpose.estimateHands(me.tensor,this.config.hand):[],this.analyze("End HandPose:"),ke.hand=Math.trunc(ei()-O)),this.config.async&&([xe,Q]=await Promise.all([xe,Q])),me.tensor.dispose(),this.state="idle",this.config.scoped&&fo.engine().endScope(),this.analyze("End Scope:");let w=[];this.config.gesture.enabled&&(O=ei(),w={body:Up.body(xe),hand:Up.hand(Q),face:Up.face(ae)},ke.gesture=Math.trunc(ei()-O)),ke.total=Math.trunc(ei()-he),se({face:ae,body:xe,hand:Q,gesture:w,performance:ke,canvas:me.canvas})})}}async function Yg(N,i,ke){if(!N)return;const O=i.getContext("2d");O.font=ke.baseFont,O.fillStyle=ke.baseLabel;let H=1;for(const[se,xe]of Object.entries(N))if(xe.length>0){const Q=`${se}: ${xe.join(", ")}`;O.fillText(Q,6,H*(ke.baseLineHeight+24)),H+=1}}async function Qg(N,i,ke,O){if(!N)return;const H=i.getContext("2d");for(const se of N){H.font=ke.baseFont,H.strokeStyle=ke.baseColor,H.fillStyle=ke.baseColor,H.lineWidth=ke.baseLineWidth,H.beginPath(),ke.drawBoxes&&H.rect(se.box[0],se.box[1],se.box[2],se.box[3]);const xe=[];se.agConfidence&&xe.push(`${Math.trunc(100*se.agConfidence)}% ${se.gender||""}`),se.age&&xe.push(`age: ${se.age||""}`),se.iris&&xe.push(`iris: ${se.iris}`),se.emotion&&se.emotion[0]&&xe.push(`${Math.trunc(100*se.emotion[0].score)}% ${se.emotion[0].emotion}`),H.fillStyle=ke.baseLabel;for(const Q in xe)H.fillText(xe[Q],se.box[0]+8,se.box[1]+24+(Q+1)*ke.baseLineHeight);if(H.stroke(),H.lineWidth=1,se.mesh){if(ke.drawPoints)for(const Q of se.mesh)H.fillStyle=ke.useDepth?`rgba(${127.5+2*Q[2]}, ${127.5-2*Q[2]}, 255, 0.5)`:ke.baseColor,H.beginPath(),H.arc(Q[0],Q[1],2,0,2*Math.PI),H.fill();if(ke.drawPolygons)for(let Q=0;Qse.mesh[he]),P=new Path2D;P.moveTo(Ae[0][0],Ae[0][1]);for(const he of Ae)P.lineTo(he[0],he[1]);P.closePath(),H.strokeStyle=ke.useDepth?`rgba(${127.5+2*Ae[0][2]}, ${127.5-2*Ae[0][2]}, 255, 0.3)`:ke.baseColor,H.stroke(P),ke.fillPolygons&&(H.fillStyle=ke.useDepth?`rgba(${127.5+2*Ae[0][2]}, ${127.5-2*Ae[0][2]}, 255, 0.3)`:ke.baseColor,H.fill(P))}}}}async function Zg(N,i,ke){if(!N)return;const O=i.getContext("2d");O.lineJoin="round";for(const H of N){if(O.fillStyle=ke.baseColor,O.strokeStyle=ke.baseColor,O.font=ke.baseFont,O.lineWidth=ke.baseLineWidth,ke.drawPoints)for(const se of H.keypoints)O.beginPath(),O.arc(se.position.x,se.position.y,2,0,2*Math.PI),O.fill();if(ke.drawPolygons){const se=new Path2D;let xe;xe=H.keypoints.find(Q=>Q.part==="leftShoulder"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightShoulder"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightHip"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftHip"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftShoulder"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftHip"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftKnee"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftAnkle"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightHip"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightKnee"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightAnkle"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightShoulder"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftShoulder"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftElbow"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftWrist"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="leftShoulder"),se.moveTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightShoulder"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightElbow"),se.lineTo(xe.position.x,xe.position.y),xe=H.keypoints.find(Q=>Q.part==="rightWrist"),se.lineTo(xe.position.x,xe.position.y),O.stroke(se)}}}async function Jg(N,i,ke){if(!N)return;const O=i.getContext("2d");O.lineJoin="round";for(const H of N){if(O.font=ke.baseFont,O.lineWidth=ke.baseLineWidth,ke.drawBoxes&&(O.lineWidth=ke.baseLineWidth,O.beginPath(),O.strokeStyle=ke.baseColor,O.fillStyle=ke.baseColor,O.rect(H.box[0],H.box[1],H.box[2],H.box[3]),O.fillStyle=ke.baseLabel,O.fillText("hand",H.box[0]+2,H.box[1]+22,H.box[2]),O.stroke()),ke.drawPoints)for(const se of H.landmarks)O.fillStyle=ke.useDepth?`rgba(${127.5+2*se[2]}, ${127.5-2*se[2]}, 255, 0.5)`:ke.baseColor,O.beginPath(),O.arc(se[0],se[1],2,0,2*Math.PI),O.fill();if(ke.drawPolygons){const se=xe=>{for(let Q=0;Q0?Q-1:0][0],xe[Q>0?Q-1:0][1]),O.lineTo(xe[Q][0],xe[Q][1]),O.stroke()};se(H.annotations.indexFinger),se(H.annotations.middleFinger),se(H.annotations.ringFinger),se(H.annotations.pinky),se(H.annotations.thumb)}}}const $g={face:Qg,body:Zg,hand:Jg,gesture:Yg};var vh=$g;let gh=0,kf=!1,Ia={background:"darkslategray",hover:"lightgray",itemBackground:"black",itemColor:"white",buttonBackground:"lightblue",buttonHover:"lightgreen",checkboxOn:"lightgreen",checkboxOff:"lightcoral",rangeBackground:"lightblue",rangeLabel:"white",chartColor:"lightblue"};function ex(){if(kf)return;const N=` .menu { position: fixed; top: 0rem; right: 0; width: fit-content; padding: 0 0.8rem 0 0.8rem; line-height: 1.8rem; z-index: 10; max-height: calc(100% - 4rem); box-shadow: 0 0 8px dimgrey; background: ${Ia.background}; border-radius: 1rem; border-color: black; border-style: solid; border-width: thin; } .menu:hover { box-shadow: 0 0 8px ${Ia.hover}; } .menu-container { display: block; max-height: 100vh; } .menu-container-fadeout { max-height: 0; overflow: hidden; transition: max-height, 0.5s ease; } .menu-container-fadein { max-height: 100vh; overflow: hidden; transition: max-height, 0.5s ease; } .menu-item { display: flex; white-space: nowrap; padding: 0.2rem; width: max-content; cursor: default; } .menu-title { text-align: right; cursor: pointer; } .menu-hr { margin: 0.2rem; border: 1px solid rgba(0, 0, 0, 0.5) } .menu-label { padding: 0; } .menu-list { margin-right: 0.8rem; } select:focus { outline: none; } .menu-list-item { background: ${Ia.itemBackground}; color: ${Ia.itemColor}; border: none; padding: 0.2rem; font-family: inherit; font-variant: inherit; border-radius: 1rem; } .menu-chart-title { padding: 0; font-size: 0.8rem; font-weight: 800; align-items: center} .menu-chart-canvas { background: transparent; margin: 0.2rem 0 0.2rem 0.6rem; } .menu-button { border: 0; background: ${Ia.buttonBackground}; width: -webkit-fill-available; padding: 8px; margin: 8px 0 8px 0; cursor: pointer; box-shadow: 4px 4px 4px 0 dimgrey; border-radius: 1rem; justify-content: center; } .menu-button:hover { background: ${Ia.buttonHover}; box-shadow: 4px 4px 4px 0 black; } .menu-button:focus { outline: none; } .menu-checkbox { width: 2.8rem; height: 1rem; background: ${Ia.itemBackground}; margin: 0.5rem 0.8rem 0 0; position: relative; border-radius: 1rem; } .menu-checkbox:after { content: 'OFF'; color: ${Ia.checkboxOff}; position: absolute; right: 0.2rem; top: -0.4rem; font-weight: 800; font-size: 0.5rem; } .menu-checkbox:before { content: 'ON'; color: ${Ia.checkboxOn}; position: absolute; left: 0.3rem; top: -0.4rem; font-weight: 800; font-size: 0.5rem; } .menu-checkbox-label { width: 1.3rem; height: 0.8rem; cursor: pointer; position: absolute; top: 0.1rem; left: 0.1rem; z-index: 1; background: ${Ia.checkboxOff}; border-radius: 1rem; transition: left 0.6s ease; } input[type=checkbox] { visibility: hidden; } input[type=checkbox]:checked + label { left: 1.4rem; background: ${Ia.checkboxOn}; } .menu-range { margin: 0 0.8rem 0 0; width: 5rem; background: transparent; color: ${Ia.rangeBackground}; } .menu-range:before { content: attr(value); color: ${Ia.rangeLabel}; margin: 0 0.4rem 0 0; font-weight: 800; font-size: 0.6rem; position: relative; top: 0.3rem; } input[type=range] { -webkit-appearance: none; } input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 1rem; cursor: pointer; background: ${Ia.itemBackground}; border-radius: 1rem; border: 1px; } input[type=range]::-webkit-slider-thumb { border: 1px solid #000000; margin-top: 0.05rem; height: 0.9rem; width: 1.5rem; border-radius: 1rem; background: ${Ia.rangeBackground}; cursor: pointer; -webkit-appearance: none; } `,i=document.createElement("style");i.innerHTML=N,document.getElementsByTagName("head")[0].appendChild(i),kf=!0}class tx{constructor(N,i,ke,O){O&&(Ia={...Ia,...O}),ex(),this.createMenu(N,i,ke),this.id=0,this.instance=gh,gh++,this._maxFPS=0,this.hidden=0}createMenu(N,i="",ke={top:null,left:null,bottom:null,right:null}){if(this.menu=document.createElement("div"),this.menu.id=`menu-${gh}`,this.menu.className="menu",ke&&(ke.top&&(this.menu.style.top=ke.top),ke.bottom&&(this.menu.style.bottom=ke.bottom),ke.left&&(this.menu.style.left=ke.left),ke.right&&(this.menu.style.right=ke.right)),this.container=document.createElement("div"),this.container.id=`menu-container-${gh}`,this.container.className="menu-container menu-container-fadein",i!==""){const O=document.createElement("div");O.className="menu-title",O.id=`menu-title-${gh}`,O.innerHTML=i,this.menu.appendChild(O),O.addEventListener("click",()=>{this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"),this.menu.style.borderStyle=this.container.classList.contains("menu-container-fadeout")?"none":"solid"})}this.menu.appendChild(this.container),typeof N=="object"?N.appendChild(this.menu):document.getElementById(N).appendChild(this.menu)}get newID(){return this.id++,`menu-${this.instance}-${this.id}`}get ID(){return`menu-${this.instance}-${this.id}`}get width(){return this.menu.offsetWidth}get height(){return this.menu.offsetHeight}hide(){this.container.classList.contains("menu-container-fadein")&&(this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"))}visible(){return this.container.classList.contains("menu-container-fadein")}toggle(N){if(this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"),this.container.classList.contains("menu-container-fadein")&&N){const i=N.x||(N.touches&&N.touches[0]?N.touches[0].pageX:null),ke=N.y||(N.touches&&N.touches[0]?N.touches[0].pageY:null);i&&(this.menu.style.left=`${i-105}px`),ke&&(this.menu.style.top="5.5rem"),this.menu.offsetLeft<0&&(this.menu.style.left=0),this.menu.offsetLeft+this.menu.offsetWidth>window.innerWidth&&(this.menu.style.left=null,this.menu.style.right=0),this.menu.style.borderStyle="solid"}else this.menu.style.borderStyle="none"}addTitle(N){const i=document.createElement("div");return i.className="menu-title",i.id=this.newID,i.innerHTML=N,this.menu.appendChild(i),i.addEventListener("click",()=>{this.hidden=!this.hidden;const ke=document.getElementsByClassName("menu");for(const O of ke)O.style.display=this.hidden?"none":"block"}),i}addLabel(N){const i=document.createElement("div");return i.className="menu-item menu-label",i.id=this.newID,i.innerHTML=N,this.container.appendChild(i),i}addBool(N,i,ke,O){const H=document.createElement("div");return H.className="menu-item",H.innerHTML=`${N}`,this.container.appendChild(H),H.addEventListener("change",se=>{i[ke]=se.target.checked,O&&O(se.target.checked)}),H}async addList(N,i,ke,O){const H=document.createElement("div");H.className="menu-item";let se="";for(const xe of i){const Q=xe===ke?"selected":"";se+=``}return H.innerHTML=`${N}`,H.style.fontFamily=document.body.style.fontFamily,H.style.fontSize=document.body.style.fontSize,H.style.fontVariant=document.body.style.fontVariant,this.container.appendChild(H),H.addEventListener("change",xe=>{O&&O(i[xe.target.selectedIndex])}),H}addRange(N,i,ke,O,H,se,xe){const Q=document.createElement("div");return Q.className="menu-item",Q.innerHTML=`${N}`,this.container.appendChild(Q),Q.addEventListener("change",Ae=>{i[ke]=Ae.target.value,Ae.target.setAttribute("value",Ae.target.value),xe&&xe(Ae.target.value)}),Q}addHTML(N){const i=document.createElement("div");return i.className="menu-item",i.id=this.newID,N&&(i.innerHTML=N),this.container.appendChild(i),i}addButton(N,i,ke){const O=document.createElement("button");return O.className="menu-item menu-button",O.style.fontFamily=document.body.style.fontFamily,O.style.fontSize=document.body.style.fontSize,O.style.fontVariant=document.body.style.fontVariant,O.type="button",O.id=this.newID,O.innerText=N,this.container.appendChild(O),O.addEventListener("click",()=>{O.innerText===N?O.innerText=i:O.innerText=N,ke&&ke(O.innerText!==N)}),O}addValue(N,i,ke=""){const O=document.createElement("div");return O.className="menu-item",O.id=`menu-val-${N}`,O.innerText=`${N}: ${i}${ke}`,this.container.appendChild(O),O}updateValue(N,i,ke=""){const O=document.getElementById(`menu-val-${N}`);O?O.innerText=`${N}: ${i}${ke}`:this.addValue(N,i)}addChart(N,i,ke=200,O=40,H){H&&(Ia.chartColor=H);const se=document.createElement("div");return se.className="menu-item menu-chart-title",se.id=this.newID,se.innerHTML=`${N}`,this.container.appendChild(se),se}async updateChart(N,i){if(!i||i.length===0)return;const ke=document.getElementById(`menu-canvas-${N}`);if(!ke)return;const O=ke.getContext("2d");O.fillStyle=Ia.background,O.fillRect(0,0,ke.width,ke.height);const H=ke.width/i.length,se=1+Math.max(...i),xe=ke.height/se;for(const Q in i){const Ae=O.createLinearGradient(0,(se-i[Q])*xe,0,0);Ae.addColorStop(.1,Ia.chartColor),Ae.addColorStop(.4,Ia.background),O.fillStyle=Ae,O.fillRect(Q*H,0,H-4,ke.height),O.fillStyle=Ia.background,O.font=`${H/1.5}px "Segoe UI"`,O.fillText(Math.round(i[Q]),Q*H+1,ke.height-1,H-1)}}}var Vp=tx;const Ts=new bf,Cn={baseColor:"rgba(173, 216, 230, 0.3)",baseBackground:"rgba(50, 50, 50, 1)",baseLabel:"rgba(173, 216, 230, 0.9)",baseFontProto:'small-caps {size} "Segoe UI"',baseLineWidth:16,baseLineHeightProto:2,columns:2,busy:!1,facing:!0,useWorker:!1,worker:"worker.js",samples:["../assets/sample6.jpg","../assets/sample1.jpg","../assets/sample4.jpg","../assets/sample5.jpg","../assets/sample3.jpg","../assets/sample2.jpg"],drawBoxes:!0,drawPoints:!1,drawPolygons:!0,fillPolygons:!0,useDepth:!0,console:!0,maxFrames:10,modelsPreload:!0,modelsWarmup:!0},yr={backend:"webgl",profile:!1,deallocate:!1,wasm:{path:"../assets"},filter:{enabled:!0,width:0,height:0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},videoOptimized:!0,face:{enabled:!0,detector:{maxFaces:10,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.5},mesh:{enabled:!0},iris:{enabled:!0},age:{enabled:!0,skipFrames:10},gender:{enabled:!0},emotion:{enabled:!0,minConfidence:.5,useGrayscale:!0}},body:{enabled:!0,maxDetections:10,scoreThreshold:.5,nmsRadius:20},hand:{enabled:!0,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.5},gesture:{enabled:!0}};let Vn,ea,Jh,Hp,xh={};const yl=[];function Sf(...N){if(!Array.isArray(N))return N;let i="";for(const ke of N)typeof ke=="object"?i+=JSON.stringify(ke).replace(/{|}|"|\[|\]/g,"").replace(/,/g,", "):i+=ke;return i}const hs=(...N)=>{Cn.console&&console.log(...N)},Es=N=>{document.getElementById("status").innerText=N};function jp(N,i,ke){yl.push(1e3/(performance.now()-Hp)),yl.length>Cn.maxFrames&&yl.shift(),requestAnimationFrame(()=>Gp(N,ke)),Vn.updateChart("FPS",yl);const O=ke.getContext("2d");O.fillStyle=Cn.baseBackground,O.fillRect(0,0,ke.width,ke.height),i.canvas?(i.canvas.width!==ke.width&&(ke.width=i.canvas.width),i.canvas.height!==ke.height&&(ke.height=i.canvas.height),O.drawImage(i.canvas,0,0,i.canvas.width,i.canvas.height,0,0,i.canvas.width,i.canvas.height)):O.drawImage(N,0,0,N.width,N.height,0,0,ke.width,ke.height),vh.face(i.face,ke,Cn,Ts.facemesh.triangulation),vh.body(i.body,ke,Cn),vh.hand(i.hand,ke,Cn),vh.gesture(i.gesture,ke,Cn);const H=Ts.tf.engine(),se=H.backendInstance?`gpu: ${(H.backendInstance.numBytesInGPU?H.backendInstance.numBytesInGPU:0).toLocaleString()} bytes`:"",xe=`system: ${H.state.numBytes.toLocaleString()} bytes ${se} | tensors: ${H.state.numTensors.toLocaleString()}`,Q=i.canvas?`processing: ${i.canvas.width} x ${i.canvas.height}`:"",Ae=Math.trunc(10*yl.reduce((P,he)=>P+he)/yl.length)/10;document.getElementById("log").innerText=` video: ${xh.name} | facing: ${xh.facing} | resolution: ${xh.width} x ${xh.height} ${Q} backend: ${Ts.tf.getBackend()} | ${xe} | object size: ${Sf(i).length.toLocaleString()} bytes performance: ${Sf(i.performance)} FPS:${Ae} `}async function qp(){if(Cn.busy)return null;Cn.busy=!0;const N=document.getElementById("video"),i=document.getElementById("canvas"),ke=document.getElementById("log"),O=N.srcObject?N.srcObject.getVideoTracks()[0].readyState==="live"&&N.readyState>2&&!N.paused:!1;let H="";if(Es("starting camera"),!navigator.mediaDevices)return H="camera access not supported",ke.innerText+=` ${H}`,hs(H),Es(H),null;let se;try{se=await navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:Cn.facing?"user":"environment",width:window.innerWidth,height:window.innerHeight,resizeMode:"none",contrast:75}})}catch(Ae){ke.innerText+=` Camera permission denied`,Es("camera permission denied"),hs(Ae)}if(se)N.srcObject=se;else return null;const xe=se.getVideoTracks()[0],Q=xe.getSettings();return hs("camera settings:",Q),hs("camera track:",xe),xh={name:xe.label,width:Q.width,height:Q.height,facing:Q.facingMode==="user"?"front":"back"},new Promise(Ae=>{N.onloadeddata=async()=>{N.width=N.videoWidth,N.height=N.videoHeight,i.width=N.width,i.height=N.height,O&&N.play(),Cn.busy=!1,Ae(N)}})}function rx(N,i,ke){Jh||(hs("Creating worker thread"),Jh=new Worker(Cn.worker,{type:"module"}),Jh.addEventListener("message",O=>jp(N,O.data,ke))),Jh.postMessage({image:i.data.buffer,width:ke.width,height:ke.height,config:yr},[i.data.buffer])}function Gp(N,i){if(Hp=performance.now(),N.srcObject){const ke=N.srcObject.getVideoTracks()[0].readyState==="live"&&N.readyState>2&&!N.paused;if(!ke){N.paused||(hs(`Video not ready: state: ${N.srcObject.getVideoTracks()[0].readyState} stream state: ${N.readyState}`),setTimeout(()=>Gp(N,i),500));return}if(Cn.useWorker){const O=new OffscreenCanvas(i.width,i.height),H=O.getContext("2d");H.drawImage(N,0,0,N.width,N.height,0,0,i.width,i.height);const se=H.getImageData(0,0,i.width,i.height);rx(N,se,i)}else Ts.detect(N,yr).then(O=>{O.error?hs(O.error):jp(N,O,i),yr.profile&&hs("Profile data:",Ts.profile())})}}async function nx(N){return Hp=performance.now(),new Promise(i=>{const ke=new Image;ke.onload=async()=>{hs("Processing image:",ke.src);const O=document.getElementById("canvas");ke.width=ke.naturalWidth,ke.height=ke.naturalHeight,O.width=yr.filter.width&&yr.filter.width>0?yr.filter.width:ke.naturalWidth,O.height=yr.filter.height&&yr.filter.height>0?yr.filter.height:ke.naturalHeight;const H=await Ts.detect(ke,yr);jp(ke,H,O);const se=document.createElement("canvas");se.className="thumbnail",se.width=window.innerWidth/(Cn.columns+.1),se.height=O.height/(window.innerWidth/se.width);const xe=se.getContext("2d");xe.drawImage(O,0,0,O.width,O.height,0,0,se.width,se.height),document.getElementById("samples-container").appendChild(se),ke.src="",i(!0)},ke.src=N})}async function ax(){yr.videoOptimized=!0,document.getElementById("samples-container").style.display="none",document.getElementById("canvas").style.display="block";const N=document.getElementById("video"),i=document.getElementById("canvas");Cn.baseFont=Cn.baseFontProto.replace(/{size}/,"1.3rem"),Cn.baseLineHeight=Cn.baseLineHeightProto,N.srcObject!==null&&!N.paused?(document.getElementById("play").style.display="block",Es("paused"),N.pause()):(await qp(),document.getElementById("play").style.display="none",Es(""),N.play()),Gp(N,i)}async function ix(){document.getElementById("play").style.display="none",yr.videoOptimized=!1,Cn.baseFont=Cn.baseFontProto.replace(/{size}/,`${1.3*Cn.columns}rem`),Cn.baseLineHeight=Cn.baseLineHeightProto*Cn.columns,document.getElementById("canvas").style.display="none",document.getElementById("samples-container").style.display="block",hs("Running detection of sample images"),Es("processing images"),document.getElementById("samples-container").innerHTML="";for(const N of Cn.samples)await nx(N);Es("")}function ox(){Vn=new Vp(document.body,"...",{top:"1rem",right:"1rem"});const N=Vn.addButton("Start Video","Pause Video",()=>ax());Vn.addButton("Process Images","Process Images",()=>ix()),document.getElementById("play").addEventListener("click",()=>N.click()),Vn.addHTML('
'),Vn.addList("Backend",["cpu","webgl","wasm","webgpu"],yr.backend,i=>yr.backend=i),Vn.addBool("Enable Profiler",yr,"profile"),Vn.addBool("Memory Shield",yr,"deallocate"),Vn.addBool("Use Web Worker",Cn,"useWorker"),Vn.addHTML('
'),Vn.addLabel("Enabled Models"),Vn.addBool("Face Detect",yr.face,"enabled"),Vn.addBool("Face Mesh",yr.face.mesh,"enabled"),Vn.addBool("Face Iris",yr.face.iris,"enabled"),Vn.addBool("Face Age",yr.face.age,"enabled"),Vn.addBool("Face Gender",yr.face.gender,"enabled"),Vn.addBool("Face Emotion",yr.face.emotion,"enabled"),Vn.addBool("Body Pose",yr.body,"enabled"),Vn.addBool("Hand Pose",yr.hand,"enabled"),Vn.addBool("Gesture Analysis",yr.gesture,"enabled"),Vn.addHTML('
'),Vn.addLabel("Model Parameters"),Vn.addRange("Max Objects",yr.face.detector,"maxFaces",0,50,1,i=>{yr.face.detector.maxFaces=parseInt(i),yr.body.maxDetections=parseInt(i),yr.hand.maxHands=parseInt(i)}),Vn.addRange("Skip Frames",yr.face.detector,"skipFrames",0,50,1,i=>{yr.face.detector.skipFrames=parseInt(i),yr.face.emotion.skipFrames=parseInt(i),yr.face.age.skipFrames=parseInt(i),yr.hand.skipFrames=parseInt(i)}),Vn.addRange("Min Confidence",yr.face.detector,"minConfidence",0,1,.05,i=>{yr.face.detector.minConfidence=parseFloat(i),yr.face.emotion.minConfidence=parseFloat(i),yr.hand.minConfidence=parseFloat(i)}),Vn.addRange("Score Threshold",yr.face.detector,"scoreThreshold",.1,1,.05,i=>{yr.face.detector.scoreThreshold=parseFloat(i),yr.hand.scoreThreshold=parseFloat(i),yr.body.scoreThreshold=parseFloat(i)}),Vn.addRange("IOU Threshold",yr.face.detector,"iouThreshold",.1,1,.05,i=>{yr.face.detector.iouThreshold=parseFloat(i),yr.hand.iouThreshold=parseFloat(i)}),Vn.addHTML('
'),Vn.addChart("FPS","FPS"),ea=new Vp(document.body,"...",{top:"1rem",right:"18rem"}),ea.addLabel("UI Options"),ea.addBool("Camera Front/Back",Cn,"facing",()=>qp()),ea.addBool("Use 3D Depth",Cn,"useDepth"),ea.addBool("Draw Boxes",Cn,"drawBoxes"),ea.addBool("Draw Points",Cn,"drawPoints"),ea.addBool("Draw Polygons",Cn,"drawPolygons"),ea.addBool("Fill Polygons",Cn,"fillPolygons"),ea.addHTML('
'),ea.addLabel("Image Processing"),ea.addBool("Enabled",yr.filter,"enabled"),ea.addRange("Image width",yr.filter,"width",0,3840,10,i=>yr.filter.width=parseInt(i)),ea.addRange("Image height",yr.filter,"height",0,2160,10,i=>yr.filter.height=parseInt(i)),ea.addRange("Brightness",yr.filter,"brightness",-1,1,.05,i=>yr.filter.brightness=parseFloat(i)),ea.addRange("Contrast",yr.filter,"contrast",-1,1,.05,i=>yr.filter.contrast=parseFloat(i)),ea.addRange("Sharpness",yr.filter,"sharpness",0,1,.05,i=>yr.filter.sharpness=parseFloat(i)),ea.addRange("Blur",yr.filter,"blur",0,20,1,i=>yr.filter.blur=parseInt(i)),ea.addRange("Saturation",yr.filter,"saturation",-1,1,.05,i=>yr.filter.saturation=parseFloat(i)),ea.addRange("Hue",yr.filter,"hue",0,360,5,i=>yr.filter.hue=parseInt(i)),ea.addRange("Pixelate",yr.filter,"pixelate",0,32,1,i=>yr.filter.pixelate=parseInt(i)),ea.addBool("Negative",yr.filter,"negative"),ea.addBool("Sepia",yr.filter,"sepia"),ea.addBool("Vintage",yr.filter,"vintage"),ea.addBool("Kodachrome",yr.filter,"kodachrome"),ea.addBool("Technicolor",yr.filter,"technicolor"),ea.addBool("Polaroid",yr.filter,"polaroid")}async function sx(){if(hs("Human: demo starting ..."),ox(),document.getElementById("log").innerText=`Human: version ${Ts.version} TensorFlow/JS: version ${Ts.tf.version_core}`,Cn.modelsPreload&&(Es("loading"),await Ts.load()),Cn.modelsWarmup){Es("initializing");const N=new ImageData(50,50);await Ts.detect(N)}Es("human: ready"),document.getElementById("loader").style.display="none",document.getElementById("play").style.display="block"}window.onload=sx;window.onresize=qp; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2019 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** @license See the LICENSE file. */ //# sourceMappingURL=demo-browser-index.js.map