var XS=Object.create,Ys=Object.defineProperty,JS=Object.getPrototypeOf,ZS=Object.prototype.hasOwnProperty,QS=Object.getOwnPropertyNames,eL=Object.getOwnPropertyDescriptor,Ff=n=>Ys(n,"__esModule",{value:!0}),we=(n,t)=>()=>(t||(t={exports:{}},n(t.exports,t)),t.exports),Di=(n,t)=>{Ff(n);for(var e in t)Ys(n,e,{get:t[e],enumerable:!0})},tL=(n,t,e)=>{if(Ff(n),typeof t=="object"||typeof t=="function")for(let r of QS(t))!ZS.call(n,r)&&r!=="default"&&Ys(n,r,{get:()=>t[r],enumerable:!(e=eL(t,r))||e.enumerable});return n},Ea=n=>n&&n.__esModule?n:tL(Ys(XS(JS(n)),"default",{value:n,enumerable:!0}),n),Gf=we(nL=>{Di(nL,{FetchError:()=>Pt,Headers:()=>vn,Request:()=>$r,Response:()=>Fn,default:()=>fL});const fn=Ea(require("stream")),Bc=Ea(require("http")),js=Ea(require("url")),Wf=Ea(require("https")),gr=Ea(require("zlib")),rL=fn.default.Readable,Jn=Symbol("buffer"),zc=Symbol("type");class Da{constructor(){this[zc]="";const n=arguments[0],t=arguments[1],e=[];let r=0;if(n){const a=n,s=Number(a.length);for(let o=0;o1&&arguments[1]!==void 0?arguments[1]:{},r=e.size;let i=r===void 0?0:r;var a=e.timeout;let s=a===void 0?0:a;n==null?n=null:Bf(n)?n=Buffer.from(n.toString()):ka(n)||(Buffer.isBuffer(n)||(Object.prototype.toString.call(n)==="[object ArrayBuffer]"?n=Buffer.from(n):ArrayBuffer.isView(n)?n=Buffer.from(n.buffer,n.byteOffset,n.byteLength):n instanceof fn.default||(n=Buffer.from(String(n))))),this[Zn]={body:n,disturbed:!1,error:null},this.size=i,this.timeout=s,n instanceof fn.default&&n.on("error",function(o){const c=o.name==="AbortError"?o:new Pt(`Invalid response body while trying to fetch ${t.url}: ${o.message}`,"system",o);t[Zn].error=c})}Dt.prototype={get body(){return this[Zn].body},get bodyUsed(){return this[Zn].disturbed},arrayBuffer(){return ki.call(this).then(function(n){return n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)})},blob(){let n=this.headers&&this.headers.get("content-type")||"";return ki.call(this).then(function(t){return Object.assign(new Da([],{type:n.toLowerCase()}),{[Jn]:t})})},json(){var n=this;return ki.call(this).then(function(t){try{return JSON.parse(t.toString())}catch(e){return Dt.Promise.reject(new Pt(`invalid json response body at ${n.url} reason: ${e.message}`,"invalid-json"))}})},text(){return ki.call(this).then(function(n){return n.toString()})},buffer(){return ki.call(this)},textConverted(){var n=this;return ki.call(this).then(function(t){return iL(t,n.headers)})}};Object.defineProperties(Dt.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}});Dt.mixIn=function(n){for(const t of Object.getOwnPropertyNames(Dt.prototype))if(!(t in n)){const e=Object.getOwnPropertyDescriptor(Dt.prototype,t);Object.defineProperty(n,t,e)}};function ki(){var n=this;if(this[Zn].disturbed)return Dt.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[Zn].disturbed=!0,this[Zn].error)return Dt.Promise.reject(this[Zn].error);let t=this.body;if(t===null)return Dt.Promise.resolve(Buffer.alloc(0));if(ka(t)&&(t=t.stream()),Buffer.isBuffer(t))return Dt.Promise.resolve(t);if(!(t instanceof fn.default))return Dt.Promise.resolve(Buffer.alloc(0));let e=[],r=0,i=!1;return new Dt.Promise(function(a,s){let o;n.timeout&&(o=setTimeout(function(){i=!0,s(new Pt(`Response timeout while trying to fetch ${n.url} (over ${n.timeout}ms)`,"body-timeout"))},n.timeout)),t.on("error",function(c){c.name==="AbortError"?(i=!0,s(c)):s(new Pt(`Invalid response body while trying to fetch ${n.url}: ${c.message}`,"system",c))}),t.on("data",function(c){if(i||c===null)return;if(n.size&&r+c.length>n.size){i=!0,s(new Pt(`content size at ${n.url} over limit: ${n.size}`,"max-size"));return}r+=c.length,e.push(c)}),t.on("end",function(){if(i)return;clearTimeout(o);try{a(Buffer.concat(e,r))}catch(c){s(new Pt(`Could not create Buffer from response body for ${n.url}: ${c.message}`,"system",c))}})})}function iL(n,t){if(typeof Pc!="function")throw new Error("The package `encoding` must be installed to use the textConverted() function");const e=t.get("content-type");let r="utf-8",i,a;return e&&(i=/charset=([^;]*)/i.exec(e)),a=n.slice(0,1024).toString(),!i&&a&&(i=/0&&arguments[0]!==void 0?arguments[0]:void 0;if(this[gt]=Object.create(null),n instanceof vn){const t=n.raw(),e=Object.keys(t);for(const r of e)for(const i of t[r])this.append(r,i);return}if(!(n==null))if(typeof n=="object"){const t=n[Symbol.iterator];if(t!=null){if(typeof t!="function")throw new TypeError("Header pairs must be iterable");const e=[];for(const r of n){if(typeof r!="object"||typeof r[Symbol.iterator]!="function")throw new TypeError("Each header pair must be iterable");e.push(Array.from(r))}for(const r of e){if(r.length!==2)throw new TypeError("Each header pair must be a name/value tuple");this.append(r[0],r[1])}}else for(const e of Object.keys(n)){const r=n[e];this.append(e,r)}}else throw new TypeError("Provided initializer must be an object")}get(n){n=`${n}`,Fa(n);const t=Fi(this[gt],n);return t===void 0?null:this[gt][t].join(", ")}forEach(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,e=Hc(this),r=0;for(;r1&&arguments[1]!==void 0?arguments[1]:"key+value";const e=Object.keys(n[gt]).sort();return e.map(t==="key"?function(r){return r.toLowerCase()}:t==="value"?function(r){return n[gt][r].join(", ")}:function(r){return[r.toLowerCase(),n[gt][r].join(", ")]})}const qc=Symbol("internal");function Vc(n,t){const e=Object.create(Gc);return e[qc]={target:n,kind:t,index:0},e}const Gc=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==Gc)throw new TypeError("Value of `this` is not a HeadersIterator");var n=this[qc];const t=n.target,e=n.kind,r=n.index,i=Hc(t,e),a=i.length;return r>=a?{value:void 0,done:!0}:(this[qc].index=r+1,{value:i[r],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));Object.defineProperty(Gc,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});function sL(n){const t=Object.assign({__proto__:null},n[gt]),e=Fi(n[gt],"Host");return e!==void 0&&(t[e]=t[e][0]),t}function oL(n){const t=new vn;for(const e of Object.keys(n)){if(Hf.test(e))continue;if(Array.isArray(n[e]))for(const r of n[e]){if(Mc.test(r))continue;t[gt][e]===void 0?t[gt][e]=[r]:t[gt][e].push(r)}else Mc.test(n[e])||(t[gt][e]=[n[e]])}return t}const yr=Symbol("Response internals"),cL=Bc.default.STATUS_CODES;class Fn{constructor(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Dt.call(this,n,t);const e=t.status||200,r=new vn(t.headers);if(n!=null&&!r.has("Content-Type")){const i=Pf(n);i&&r.append("Content-Type",i)}this[yr]={url:t.url,status:e,statusText:t.statusText||cL[e],headers:r,counter:t.counter}}get url(){return this[yr].url||""}get status(){return this[yr].status}get ok(){return this[yr].status>=200&&this[yr].status<300}get redirected(){return this[yr].counter>0}get statusText(){return this[yr].statusText}get headers(){return this[yr].headers}clone(){return new Fn(zf(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}Dt.mixIn(Fn.prototype);Object.defineProperties(Fn.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}});Object.defineProperty(Fn.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const Qn=Symbol("Request internals"),Yc=js.default.parse,lL=js.default.format,uL="destroy"in fn.default.Readable.prototype;function Ks(n){return typeof n=="object"&&typeof n[Qn]=="object"}function hL(n){const t=n&&typeof n=="object"&&Object.getPrototypeOf(n);return!!(t&&t.constructor.name==="AbortSignal")}class $r{constructor(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e;Ks(n)?e=Yc(n.url):(n&&n.href?e=Yc(n.href):e=Yc(`${n}`),n={});let r=t.method||n.method||"GET";if(r=r.toUpperCase(),(t.body!=null||Ks(n)&&n.body!==null)&&(r==="GET"||r==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body");let i=t.body!=null?t.body:Ks(n)&&n.body!==null?zf(n):null;Dt.call(this,i,{timeout:t.timeout||n.timeout||0,size:t.size||n.size||0});const a=new vn(t.headers||n.headers||{});if(i!=null&&!a.has("Content-Type")){const o=Pf(i);o&&a.append("Content-Type",o)}let s=Ks(n)?n.signal:null;if("signal"in t&&(s=t.signal),s!=null&&!hL(s))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[Qn]={method:r,redirect:t.redirect||n.redirect||"follow",headers:a,parsedURL:e,signal:s},this.follow=t.follow!==void 0?t.follow:n.follow!==void 0?n.follow:20,this.compress=t.compress!==void 0?t.compress:n.compress!==void 0?n.compress:!0,this.counter=t.counter||n.counter||0,this.agent=t.agent||n.agent}get method(){return this[Qn].method}get url(){return lL(this[Qn].parsedURL)}get headers(){return this[Qn].headers}get redirect(){return this[Qn].redirect}get signal(){return this[Qn].signal}clone(){return new $r(this)}}Dt.mixIn($r.prototype);Object.defineProperty($r.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0});Object.defineProperties($r.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}});function dL(n){const t=n[Qn].parsedURL,e=new vn(n[Qn].headers);if(e.has("Accept")||e.set("Accept","*/*"),!t.protocol||!t.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(t.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(n.signal&&n.body instanceof fn.default.Readable&&!uL)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let r=null;if(n.body==null&&/^(POST|PUT)$/i.test(n.method)&&(r="0"),n.body!=null){const a=Mf(n);typeof a=="number"&&(r=String(a))}r&&e.set("Content-Length",r),e.has("User-Agent")||e.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),n.compress&&!e.has("Accept-Encoding")&&e.set("Accept-Encoding","gzip,deflate");let i=n.agent;return typeof i=="function"&&(i=i(t)),!e.has("Connection")&&!i&&e.set("Connection","close"),Object.assign({},t,{method:n.method,headers:sL(e),agent:i})}function Wa(n){Error.call(this,n),this.type="aborted",this.message=n,Error.captureStackTrace(this,this.constructor)}Wa.prototype=Object.create(Error.prototype);Wa.prototype.constructor=Wa;Wa.prototype.name="AbortError";const qf=fn.default.PassThrough,pL=js.default.resolve;function vr(n,t){if(!vr.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return Dt.Promise=vr.Promise,new vr.Promise(function(e,r){const i=new $r(n,t),a=dL(i),s=(a.protocol==="https:"?Wf.default:Bc.default).request,o=i.signal;let c=null;const l=function(){let m=new Wa("The user aborted a request.");if(r(m),i.body&&i.body instanceof fn.default.Readable&&i.body.destroy(m),!c||!c.body)return;c.body.emit("error",m)};if(o&&o.aborted){l();return}const u=function(){l(),p()},h=s(a);let d;o&&o.addEventListener("abort",u);function p(){h.abort(),o&&o.removeEventListener("abort",u),clearTimeout(d)}i.timeout&&h.once("socket",function(f){d=setTimeout(function(){r(new Pt(`network timeout at: ${i.url}`,"request-timeout")),p()},i.timeout)}),h.on("error",function(f){r(new Pt(`request to ${i.url} failed, reason: ${f.message}`,"system",f)),p()}),h.on("response",function(f){clearTimeout(d);const m=oL(f.headers);if(vr.isRedirect(f.statusCode)){const S=m.get("Location"),x=S===null?null:pL(i.url,S);switch(i.redirect){case"error":r(new Pt(`uri requested responds with a redirect, redirect mode is set to error: ${i.url}`,"no-redirect")),p();return;case"manual":if(x!==null)try{m.set("Location",x)}catch(I){r(I)}break;case"follow":if(x===null)break;if(i.counter>=i.follow){r(new Pt(`maximum redirect reached at: ${i.url}`,"max-redirect")),p();return}const N={headers:new vn(i.headers),follow:i.follow,counter:i.counter+1,agent:i.agent,compress:i.compress,method:i.method,body:i.body,signal:i.signal,timeout:i.timeout,size:i.size};if(f.statusCode!==303&&i.body&&Mf(i)===null){r(new Pt("Cannot follow redirect with body being a readable stream","unsupported-redirect")),p();return}(f.statusCode===303||(f.statusCode===301||f.statusCode===302)&&i.method==="POST")&&(N.method="GET",N.body=void 0,N.headers.delete("content-length")),e(vr(new $r(x,N))),p();return}}f.once("end",function(){o&&o.removeEventListener("abort",u)});let g=f.pipe(new qf);const y={url:i.url,status:f.statusCode,statusText:f.statusMessage,headers:m,size:i.size,timeout:i.timeout,counter:i.counter},w=m.get("Content-Encoding");if(!i.compress||i.method==="HEAD"||w===null||f.statusCode===204||f.statusCode===304){c=new Fn(g,y),e(c);return}const b={flush:gr.default.Z_SYNC_FLUSH,finishFlush:gr.default.Z_SYNC_FLUSH};if(w=="gzip"||w=="x-gzip"){g=g.pipe(gr.default.createGunzip(b)),c=new Fn(g,y),e(c);return}if(w=="deflate"||w=="x-deflate"){const S=f.pipe(new qf);S.once("data",function(x){(x[0]&15)===8?g=g.pipe(gr.default.createInflate()):g=g.pipe(gr.default.createInflateRaw()),c=new Fn(g,y),e(c)});return}if(w=="br"&&typeof gr.default.createBrotliDecompress=="function"){g=g.pipe(gr.default.createBrotliDecompress()),c=new Fn(g,y),e(c);return}c=new Fn(g,y),e(c)}),aL(h,i)})}vr.isRedirect=function(n){return n===301||n===302||n===303||n===307||n===308};vr.Promise=global.Promise;var fL=vr}),di=we(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});var jc=function(n,t){return jc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])},jc(n,t)};function er(n,t){jc(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function pe(n,t,e,r){return new(e||(e=Promise))(function(i,a){function s(l){try{c(r.next(l))}catch(u){a(u)}}function o(l){try{c(r.throw(l))}catch(u){a(u)}}function c(l){l.done?i(l.value):new e(function(u){u(l.value)}).then(s,o)}c((r=r.apply(n,t||[])).next())})}function fe(n,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,s;return s={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(a=l[0]&2?i.return:l[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,l[1])).done)return a;(i=0,a)&&(l=[l[0]&2,a.value]);switch(l[0]){case 0:case 1:a=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,i=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(!(a=e.trys,a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]0;)r=Math.random()*t|0,t--,e=n[t],n[t]=n[r],n[r]=e}function Ua(n,t,e){return Math.max(n,Math.min(t,e))}function vL(n){return n%2===0?n:n+1}function wL(n){for(var t=0,e=0;e=e){i();return}setTimeout(s,o)};s()})}function Kf(n,t){for(var e=1,r=-1,i=0;i=0)e*=n[i];else if(n[i]===-1){if(r!==-1)throw Error("Shapes can only have 1 implicit size. "+("Found -1 at dim "+r+" and dim "+i));r=i}else if(n[i]<0)throw Error("Shapes can not be < 0. Found "+n[i]+" at dim "+i);if(r===-1){if(t>0&&t!==e)throw Error("Size("+t+") must match the product of shape "+n);return n}if(e===0)throw Error("Cannot infer the missing size in ["+n+"] when there are 0 elements");if(t%e!==0)throw Error("The implicit shape can't be a fractional number. "+("Got "+t+" / "+e));var a=n.slice();return a[r]=t/e,a}function rt(n,t){var e=t.length;return n=n==null?t.map(function(r,i){return i}):[].concat(n),E(n.every(function(r){return r>=-e&&ro)&&n[o]===1&&(e.push(n[o]),r.push(o)),a[s]<=o&&s++}n[o]!==1&&(e.push(n[o]),r.push(o))}return{newShape:e,keptDims:r}}function $s(n,t){var e=null;if(n==null||n==="float32")e=new Float32Array(t);else if(n==="int32")e=new Int32Array(t);else if(n==="bool")e=new Uint8Array(t);else throw new Error("Unknown data type "+n);return e}function Xf(n,t){var e=null;if(n==null||n==="float32")e=new Float32Array(t);else if(n==="int32")e=new Int32Array(t);else if(n==="bool")e=new Uint8Array(t);else if(n==="string")e=new Array(t);else throw new Error("Unknown data type "+n);return e}function Jf(n,t){for(var e=0;e=0;--r)e[r]=e[r+1]*n[r+1];return e}function im(n,t,e){var r=new Array;if(t.length===1)for(var i=t[0],a=0;a=0,function(){return"Tensor must have a shape comprised of positive integers but got "+("shape ["+n+"].")})})}function _L(n,t,e){if(t===0)return 0;if(t===1)return n[0];for(var r=n[n.length-1],i=0;i0?m:"")+" "}}console.log("%c"+c+" %c"+o+" %c"+l+"D "+h+" %c"+u+" %c"+d+" %c"+s,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")},n}();function YL(n,t,e){for(var r={},i={},a=0;a=0;a--)for(var s=n[a],o=s.inputs,h=0;h=0;a--)i(a)}var cg=20,Pa=3,Yu=7;function $L(n,t,e,r){var i=Wi(t),a=KL(n,t,e,i),s=t.length,o=no(n,t,e,i,a),c=["Tensor"];return r&&(c.push(" dtype: "+e),c.push(" rank: "+s),c.push(" shape: ["+t+"]"),c.push(" values:")),c.push(o.map(function(l){return" "+l}).join(` `)),c.join(` `)}function KL(n,t,e,r){var i=pt(t),a=r[r.length-1],s=new Array(a).fill(0),o=t.length,c=e==="complex64"?Ha(n):n;if(o>1)for(var l=0;lcg){var u=Pa*s,h=Array.from(n.slice(0,u)),d=Array.from(n.slice((o-Pa)*s,o*s));return e==="complex64"&&(h=Ha(h),d=Ha(d)),["["+h.map(function(I,C){return Ma(I,i[C],e)}).join(", ")+", ..., "+d.map(function(I,C){return Ma(I,i[o-Pa+C],e)}).join(", ")+"]"]}var p=e==="complex64"?Ha(n):Array.from(n);return["["+p.map(function(I,C){return Ma(I,i[C],e)}).join(", ")+"]"]}var f=t.slice(1),m=r.slice(1),g=r[0]*s,y=[];if(o>cg){for(var w=0;w=this.shape[r]){var o="Requested out of range element at "+t+". "+(" Buffer shape="+this.shape);throw new Error(o)}r++}for(var c=t[t.length-1],l=0;l0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak "+("("+o+" data ids) after running '"+t+"'"))},n.prototype.runKernelFunc=function(t,e,r,i,a,s,o){var c=this,l,u=[],h=this.isTapeOn();i==null&&(i=this.state.activeScope!=null?this.state.activeScope.name:"");var d=this.state.numBytes,p=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var f,m=Mu(i,this.backendName),g;if(m!=null)f=function(){var b=c.backend.numDataIds();g=m.kernelFunc({inputs:e,attrs:a,backend:c.backend});var S=Array.isArray(g)?g:[g];c.shouldCheckForMemLeaks()&&c.checkKernelForMemLeak(i,b,S);var x=S.map(function(C){var O=C.dataId,D=C.shape,F=C.dtype;return c.makeTensorFromDataId(O,D,F)});if(h){var N=c.getTensorsForGradient(i,e,x);if(N==null){o==null&&(o=[]);var I=x.filter(function(C,O){return o[O]});N=(s||[]).slice().concat(I)}u=c.saveTensorsForBackwardMode(N)}return x};else{var y=function(b){if(!h)return;u=b.map(function(S){return c.keep(c.clone(S))})};f=function(){var b=c.backend.numDataIds();g=c.tidy(function(){return t(c.backend,y)});var S=Array.isArray(g)?g:[g];return c.shouldCheckForMemLeaks()&&c.checkKernelForMemLeak(i,b,S),S}}var w;return this.scopedRun(function(){return c.state.kernelDepth++},function(){return c.state.kernelDepth--},function(){!c.ENV.getBool("DEBUG")&&!c.state.profiling?l=f():(w=c.profiler.profileKernel(i,e,function(){return f()}),c.ENV.getBool("DEBUG")&&c.profiler.logKernelProfile(w),l=w.outputs)}),h&&this.addTapeNode(i,e,l,r,u,a),this.state.profiling&&this.state.activeProfile.kernels.push({name:i,bytesAdded:this.state.numBytes-d,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-p,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(e).map(function(b){return e[b]!=null?e[b].shape:null}),outputShapes:l.map(function(b){return b.shape}),kernelTimeMs:w.timeMs,extraInfo:w.extraInfo}),Array.isArray(g)?l:l[0]},n.prototype.saveTensorsForBackwardMode=function(t){var e=this,r=t.map(function(i){return e.keep(e.clone(i))});return r},n.prototype.getTensorsForGradient=function(t,e,r){var i=Hu(t);if(i!=null){var a=i.inputsToSave||[],s=i.outputsToSave||[],o=void 0;i.saveAllInputs?(E(Array.isArray(e),function(){return"saveAllInputs is true, expected inputs to be an array."}),o=Object.keys(e).map(function(l){return e[l]})):o=a.map(function(l){return e[l]});var c=r.filter(function(l,u){return s[u]});return o.concat(c)}return null},n.prototype.makeTensor=function(t,e,r,i){if(t==null)throw new Error("Values passed to engine.makeTensor() are null");r=r||"float32",i=i||this.backend;var a=t;r==="string"&&wr(t[0])&&(a=t.map(function(u){return Vu(u)}));var s=i.write(a,e,r),o=new j(e,r,s,this.nextTensorId());if(this.incRef(o,i),r==="string"){var c=this.state.tensorInfo.get(s),l=tm(a);this.state.numBytes+=l-c.bytes,c.bytes=l}return o},n.prototype.makeTensorFromDataId=function(t,e,r,i){r=r||"float32";var a=new j(e,r,t,this.nextTensorId());return this.incRef(a,i),a},n.prototype.makeVariable=function(t,e,r,i){e===void 0&&(e=!0),r=r||this.nextVariableId().toString(),i!=null&&i!==t.dtype&&(t=t.cast(i));var a=new Va(t,e,r,this.nextTensorId());if(this.state.registeredVariables[a.name]!=null)throw new Error("Variable with name "+a.name+" was already registered");return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a},n.prototype.incRef=function(t,e){var r=this.state.tensorInfo.has(t.dataId)?this.state.tensorInfo.get(t.dataId).refCount:0;if(this.state.numTensors++,t.dtype==="string"&&this.state.numStringTensors++,r===0){this.state.numDataBuffers++;var i=0;t.dtype!=="complex64"&&t.dtype!=="string"&&(i=t.size*em(t.dtype)),this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:i,refCount:0}),this.state.numBytes+=i}this.state.tensorInfo.get(t.dataId).refCount++,t instanceof Va||this.track(t)},n.prototype.disposeTensor=function(t){if(!this.state.tensorInfo.has(t.dataId))return;this.state.numTensors--,t.dtype==="string"&&this.state.numStringTensors--;var e=this.state.tensorInfo.get(t.dataId),r=e.refCount;r<=1?(t.dtype!=="complex64"&&(this.state.numBytes-=e.bytes),this.state.numDataBuffers--,e.backend.disposeData(t.dataId),this.state.tensorInfo.delete(t.dataId)):this.state.tensorInfo.get(t.dataId).refCount--},n.prototype.disposeVariables=function(){for(var t in this.state.registeredVariables){var e=this.state.registeredVariables[t];this.disposeVariable(e)}},n.prototype.disposeVariable=function(t){this.disposeTensor(t),this.state.registeredVariables[t.name]!=null&&delete this.state.registeredVariables[t.name]},n.prototype.memory=function(){var t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,t.reasons==null&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t},n.prototype.profile=function(t){return pe(this,void 0,void 0,function(){var e,r,i,a,s,o,c,l;return fe(this,function(u){switch(u.label){case 0:return this.state.profiling=!0,e=this.state.numBytes,r=this.state.numTensors,this.state.activeProfile.kernels=[],i=this.state.activeProfile,[4,t()];case 1:i.result=u.sent(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map(function(h){return h.totalBytesSnapshot})),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-r,a=0,s=this.state.activeProfile.kernels,u.label=2;case 2:return a0&&this.state.kernelDepth===0},n.prototype.addTapeNode=function(t,e,r,i,a,s){var o=this,c={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:r,saved:a},l=Hu(t);l!=null&&(i=l.gradFunc),i!=null&&(c.gradient=function(u){return u=u.map(function(h,d){if(h==null){var p=r[d],f=Bi(p.size,p.dtype);return o.makeTensor(f,p.shape,p.dtype)}return h}),i(u.length>1?u:u[0],a,s)}),this.state.activeTape.push(c)},n.prototype.keep=function(t){return t.kept=!0,t},n.prototype.startTape=function(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++},n.prototype.endTape=function(){this.state.gradientDepth--},n.prototype.startScope=function(t){var e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e},n.prototype.endScope=function(t){for(var e=this,r=Ju(t),i=new Set(r.map(function(c){return c.id})),a=0;a0,function(){return"gradients() received an empty list of xs."}),r!=null&&r.dtype!=="float32")throw new Error("dy must have 'float32' dtype, but has '"+r.dtype+"'");var s=this.scopedRun(function(){return a.startTape()},function(){return a.endTape()},function(){return a.tidy("forward",t)});E(s instanceof j,function(){return"The result y returned by f() must be a tensor."});var o=YL(this.state.activeTape,e,s);if(!i&&o.length===0&&e.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 c={};c[s.id]=r==null?rI(s.shape):r,jL(c,o,function(u){return a.tidy(u)},iI);var l=e.map(function(u){return c[u.id]});return a.state.gradientDepth===0&&(a.state.activeTape.forEach(function(u){for(var h=0,d=u.saved;h0,function(){return"Element arr["+e.join("][")+"] should be a primitive, "+("but is an array of "+n.length+" elements")}),E(n.length===t[0],function(){return"Element arr["+e.join("][")+"] should have "+t[0]+" "+("elements, but has "+n.length+" elements")});for(var r=t.slice(1),i=0;i=0&&(i=r),gg(r,i,t,e),n==null||!Ut(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"){var a=n==null?"null":n.constructor.name;throw new Error("Argument '"+t+"' passed to '"+e+"' must be a "+("Tensor or TensorLike, but got '"+a+"'"))}var s=Un(n,i);!Ut(n)&&!Array.isArray(n)&&(n=[n]);var o=!0,c=i!=="string"?to(n,i):Jr(n,[],o);return z.makeTensor(c,s,i)}function qa(n,t,e,r){if(r===void 0&&(r="numeric"),!Array.isArray(n))throw new Error("Argument "+t+" passed to "+e+" must be a `Tensor[]` or `TensorLike[]`");var i=n;return i.map(function(a,s){return R(a,t+"["+s+"]",e)},r)}var yg="__op";function U(n){var t=Object.keys(n);if(t.length!==1)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+(t.length+" keys."));var e=t[0],r=n[e];e.endsWith("_")&&(e=e.substring(0,e.length-1)),e=e+yg;var i=function(){for(var a=[],s=0;s>10]+(o&1023)]+t[o>>10];a[s]=c}return new Float32Array(i)}}var on=function(){function n(){this.saveRouters=[],this.loadRouters=[]}return n.getInstance=function(){return n.instance==null&&(n.instance=new n),n.instance},n.registerSaveRouter=function(t){n.getInstance().saveRouters.push(t)},n.registerLoadRouter=function(t){n.getInstance().loadRouters.push(t)},n.getSaveHandlers=function(t){return n.getHandlers(t,"save")},n.getLoadHandlers=function(t,e){return n.getHandlers(t,"load",e)},n.getHandlers=function(t,e,r){var i=[],a=e==="load"?n.getInstance().loadRouters:n.getInstance().saveRouters;return a.forEach(function(s){var o=s(t,r);o!==null&&i.push(o)}),i},n}(),vI=function(n){return on.registerSaveRouter(n)},wI=function(n){return on.registerLoadRouter(n)},bI=function(n){return on.getSaveHandlers(n)},xI=function(n,t){return on.getLoadHandlers(n,t)};var th="tensorflowjs",nh=1,Zr="models_store",Ir="model_info_store";function xg(){if(!qe().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var n=typeof window=="undefined"?self:window,t=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB||n.shimIndexedDB;if(t==null)throw new Error("The current browser does not appear to support IndexedDB.");return t}function rh(n){var t=n.result;t.createObjectStore(Zr,{keyPath:"modelPath"}),t.createObjectStore(Ir,{keyPath:"modelPath"})}var Mi=function(){function n(t){if(this.indexedDB=xg(),t==null||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t}return n.prototype.save=function(t){return pe(this,void 0,void 0,function(){return fe(this,function(e){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return[2,this.databaseAction(this.modelPath,t)]})})},n.prototype.load=function(){return pe(this,void 0,void 0,function(){return fe(this,function(t){return[2,this.databaseAction(this.modelPath)]})})},n.prototype.databaseAction=function(t,e){var r=this;return new Promise(function(i,a){var s=r.indexedDB.open(th,nh);s.onupgradeneeded=function(){return rh(s)},s.onsuccess=function(){var o=s.result;if(e==null){var c=o.transaction(Zr,"readonly"),l=c.objectStore(Zr),u=l.get(r.modelPath);u.onsuccess=function(){if(u.result==null)return o.close(),a(new Error("Cannot find model with path '"+r.modelPath+"' in IndexedDB."));i(u.result.modelArtifacts)},u.onerror=function(g){return o.close(),a(u.error)},c.oncomplete=function(){return o.close()}}else{var h=Ga(e),d=o.transaction(Ir,"readwrite"),p=d.objectStore(Ir),f=p.put({modelPath:r.modelPath,modelArtifactsInfo:h}),m;f.onsuccess=function(){m=o.transaction(Zr,"readwrite");var g=m.objectStore(Zr),y=g.put({modelPath:r.modelPath,modelArtifacts:e,modelArtifactsInfo:h});y.onsuccess=function(){return i({modelArtifactsInfo:h})},y.onerror=function(w){p=d.objectStore(Ir);var b=p.delete(r.modelPath);b.onsuccess=function(){return o.close(),a(y.error)},b.onerror=function(S){return o.close(),a(y.error)}}},f.onerror=function(g){return o.close(),a(f.error)},d.oncomplete=function(){m==null?o.close():m.oncomplete=function(){return o.close()}}}},s.onerror=function(o){return a(s.error)}})},n.URL_SCHEME="indexeddb://",n}(),Sg=function(n){return qe().getBool("IS_BROWSER")&&(!Array.isArray(n)&&n.startsWith(Mi.URL_SCHEME))?SI(n.slice(Mi.URL_SCHEME.length)):null};on.registerSaveRouter(Sg);on.registerLoadRouter(Sg);function SI(n){return new Mi(n)}function LI(n){return n.startsWith(Mi.URL_SCHEME)?n.slice(Mi.URL_SCHEME.length):n}var II=function(){function n(){this.indexedDB=xg()}return n.prototype.listModels=function(){return pe(this,void 0,void 0,function(){var t=this;return fe(this,function(e){return[2,new Promise(function(r,i){var a=t.indexedDB.open(th,nh);a.onupgradeneeded=function(){return rh(a)},a.onsuccess=function(){var s=a.result,o=s.transaction(Ir,"readonly"),c=o.objectStore(Ir),l=c.getAll();l.onsuccess=function(){for(var u={},h=0,d=l.result;h0,function(){return"scheme must not be an empty string."});var r=n.getInstance();E(r.managers[t]==null,function(){return"A model store manager is already registered for scheme '"+t+"'."}),r.managers[t]=e},n.getManager=function(t){var e=this.getInstance().managers[t];if(e==null)throw new Error("Cannot find model manager for scheme '"+t+"'");return e},n.getSchemes=function(){return Object.keys(this.getInstance().managers)},n}();function so(n){if(n.indexOf(qi)===-1)throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+(""+Ar.getSchemes().join(",")));return{scheme:n.split(qi)[0],path:n.split(qi)[1]}}function Tg(n,t,e){return e===void 0&&(e=!1),pe(this,void 0,void 0,function(){var r,i,a,s,o,c,l,u,h;return fe(this,function(d){switch(d.label){case 0:return E(n!==t,function(){return"Old path and new path are the same: '"+n+"'"}),r=on.getLoadHandlers(n),E(r.length>0,function(){return"Copying failed because no load handler is found for source URL "+n+"."}),E(r.length<2,function(){return"Copying failed because more than one ("+r.length+") "+("load handlers for source URL "+n+".")}),i=r[0],a=on.getSaveHandlers(t),E(a.length>0,function(){return"Copying failed because no save handler is found for destination "+("URL "+t+".")}),E(a.length<2,function(){return"Copying failed because more than one ("+r.length+") "+("save handlers for destination URL "+t+".")}),s=a[0],o=so(n).scheme,c=so(n).path,l=o===so(n).scheme,[4,i.load()];case 1:return u=d.sent(),e&&l?[4,Ar.getManager(o).removeModel(c)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[4,s.save(u)];case 4:return h=d.sent(),e&&!l?[4,Ar.getManager(o).removeModel(c)]:[3,6];case 5:d.sent(),d.label=6;case 6:return[2,h.modelArtifactsInfo]}})})}function DI(){return pe(this,void 0,void 0,function(){var n,t,e,r,i,a,s,o;return fe(this,function(c){switch(c.label){case 0:n=Ar.getSchemes(),t={},e=0,r=n,c.label=1;case 1:return e0,function(){return"promises must be a none empty array"})}function o(c,l){E(c>=0&&c<=1,function(){return"Progress fraction must be in range [0, 1], but "+("got startFraction "+c)}),E(l>=0&&l<=1,function(){return"Progress fraction must be in range [0, 1], but "+("got endFraction "+l)}),E(l>=c,function(){return"startFraction must be no more than endFraction, but "+("got startFraction "+c+" and endFraction ")+(""+l)})}return Promise.all(n.map(a))}function Rg(n,t){return pe(this,void 0,void 0,function(){var e,r,i,a,s,o,c,l,u,h,d;return fe(this,function(p){switch(p.label){case 0:return t==null&&(t={}),e=t.fetchFunc==null?qe().platform.fetch:t.fetchFunc,r=n.map(function(f){return e(f,t.requestInit,{isBinary:!0})}),i=0,a=.5,t.onProgress==null?[4,Promise.all(r)]:[3,2];case 1:return o=p.sent(),[3,4];case 2:return[4,Cg(r,t.onProgress,i,a)];case 3:o=p.sent(),p.label=4;case 4:return s=o,c=s.map(function(f){return f.arrayBuffer()}),l=.5,u=1,t.onProgress==null?[4,Promise.all(c)]:[3,6];case 5:return d=p.sent(),[3,8];case 6:return[4,Cg(c,t.onProgress,l,u)];case 7:d=p.sent(),p.label=8;case 8:return h=d,[2,h]}})})}function XI(n,t,e,r){return t===void 0&&(t=""),pe(this,void 0,void 0,function(){var i,a;return fe(this,function(s){return i=function(o){return Rg(o,{requestInit:r})},a=Og(i),[2,a(n,t,e)]})})}function Og(n){var t=this;return function(e,r,i){return r===void 0&&(r=""),pe(t,void 0,void 0,function(){var a,s,o,c,l,u,h,d,p,f;return fe(this,function(m){switch(m.label){case 0:if(a=e.map(function(){return!1}),s={},o=i!=null?i.map(function(){return!1}):[],c=[],e.forEach(function(g,y){var w=0;g.weights.forEach(function(b){var S="quantization"in b?b.quantization.dtype:b.dtype,x=Zu[S]*pt(b.shape),N=function(){a[y]=!0,s[y]==null&&(s[y]=[]),s[y].push({manifestEntry:b,groupOffset:w,sizeBytes:x})};i!=null?i.forEach(function(I,C){I===b.name&&(N(),o[C]=!0)}):N(),c.push(b.name),w+=x})}),!o.every(function(g){return g}))throw l=i.filter(function(g,y){return!o[y]}),new Error("Could not find weights in manifest with names: "+(l.join(", ")+`. `)+"Manifest JSON has weights with names: "+(c.join(", ")+"."));return u=a.reduce(function(g,y,w){return y&&g.push(w),g},[]),h=[],u.forEach(function(g){e[g].paths.forEach(function(y){var w=r+(r.endsWith("/")?"":"/")+y;h.push(w)})}),[4,n(h)];case 1:return d=m.sent(),p={},f=0,u.forEach(function(g){for(var y=e[g].paths.length,w=0,b=0;b0,function(){return"URL path for http must not be null, undefined or empty."}),Array.isArray(t)&&E(t.length===2,function(){return"URL paths for http must have a length of 2, "+("(actual length is "+t.length+").")}),this.path=t,e.requestInit!=null&&e.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{}}return n.prototype.save=function(t){return pe(this,void 0,void 0,function(){var e,r,i,a;return fe(this,function(s){switch(s.label){case 0:if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit),e.body=new FormData,r=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],i={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata,weightsManifest:r},e.body.append("model.json",new Blob([JSON.stringify(i)],{type:ZI}),"model.json"),t.weightData!=null&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:JI}),"model.weights.bin"),[4,this.fetch(this.path,e)];case 1:if(a=s.sent(),a.ok)return[2,{modelArtifactsInfo:Ga(t),responses:[a]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+(a.status+"."))}})})},n.prototype.load=function(){return pe(this,void 0,void 0,function(){var t,e,r,i,a,s,o,c,l,u,h,d,p,f,m;return fe(this,function(g){switch(g.label){case 0:return[4,this.fetch(this.path,this.requestInit)];case 1:if(t=g.sent(),!t.ok)throw new Error("Request to "+this.path+" failed with status code "+(t.status+". Please verify this URL points to ")+"the model JSON of the model to load.");g.label=2;case 2:return g.trys.push([2,4,,5]),[4,t.json()];case 3:return e=g.sent(),[3,5];case 4:throw r=g.sent(),i="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?i+=" 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.":i+=" Please make sure the server is serving valid JSON for this request.",new Error(i);case 5:if(a=e.modelTopology,s=e.weightsManifest,o=e.generatedBy,c=e.convertedBy,l=e.format,u=e.userDefinedMetadata,a==null&&s==null)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return s!=null?[4,this.loadWeights(s)]:[3,7];case 6:p=g.sent(),h=p[0],d=p[1],g.label=7;case 7:return f={modelTopology:a,weightSpecs:h,weightData:d,userDefinedMetadata:u,generatedBy:o,convertedBy:c,format:l},m=e.modelInitializer,m&&(f.modelInitializer=m),[2,f]}})})},n.prototype.loadWeights=function(t){return pe(this,void 0,void 0,function(){var e,r,i,a,s,o,c,l,u,h,d,p,f,m,g,y,w,b,S,x,N;return fe(this,function(I){switch(I.label){case 0:for(e=Array.isArray(this.path)?this.path[1]:this.path,r=QI(e),i=r[0],a=r[1],s=this.weightPathPrefix||i,o=[],c=0,l=t;ct?n.substring(e):"";return[r+"/",i]}function sh(n){return n.match(Eg.URL_SCHEME_REGEX)!=null}var Dg=function(n,t){if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;var e=!0;return Array.isArray(n)?e=n.every(function(r){return sh(r)}):e=sh(n),e?oh(n,t):null};on.registerSaveRouter(Dg);on.registerLoadRouter(Dg);function oh(n,t){return new Eg(n,t)}function eA(n,t){return oh(n,t)}var ch=function(){function n(t){this.modelArtifacts=t}return n.prototype.load=function(){return pe(this,void 0,void 0,function(){return fe(this,function(t){return[2,this.modelArtifacts]})})},n}(),tA=function(){function n(t){this.saveHandler=t}return n.prototype.save=function(t){return pe(this,void 0,void 0,function(){return fe(this,function(e){return[2,this.saveHandler(t)]})})},n}();function nA(n,t,e,r){if(arguments.length===1){var i=n.modelTopology!=null||n.weightSpecs!=null;return i?new ch(n):(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 ch({modelTopology:n}))}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 ch({modelTopology:n,weightSpecs:t,weightData:e,trainingConfig:r})}function rA(n){return new tA(n)}var iA={__proto__:null,browserFiles:$I,browserHTTPRequest:eA,concatenateArrayBuffers:eh,decodeWeights:vg,encodeWeights:hI,fromMemory:nA,getLoadHandlers:xI,getModelArtifactsInfoForJSON:Ga,getSaveHandlers:bI,http:oh,isHTTPScheme:sh,loadWeights:XI,registerLoadRouter:wI,registerSaveRouter:vI,weightsLoaderFactory:Og,withSaveHandler:rA,copyModel:FI,listModels:DI,moveModel:WI,removeModel:kI};function aA(n,t){var e=R(n,"x","reshape",null),r={x:e},i={shape:t},a=function(s,o){return t=Kf(t,e.size),E(e.size===pt(t),function(){return"new shape and old shape must have the same number of elements."}),o([e]),s.reshape(e,t)};return z.runKernelFunc(a,r,null,su,i)}var Y=U({reshape_:aA});function sA(n,t,e,r){var i;e===void 0&&(e=!1),r===void 0&&(r=!1);var a=R(n,"a","matMul"),s=R(t,"b","matMul");i=ct(a,s),a=i[0],s=i[1];var o=function(u,h){h([a,s]);var d=e?a.shape[a.rank-2]:a.shape[a.rank-1],p=r?s.shape[s.rank-1]:s.shape[s.rank-2],f=e?a.shape[a.rank-1]:a.shape[a.rank-2],m=r?s.shape[s.rank-2]:s.shape[s.rank-1],g=a.shape.slice(0,-2),y=s.shape.slice(0,-2),w=pt(g),b=pt(y),S=w===b||w===1||b===1;E(a.rank>=2&&s.rank>=2&&S,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 ("+g+") and ("+y+").")}),E(d===p,function(){return"Error in matMul: inner shapes ("+d+") and ("+(p+") of Tensors with shapes "+a.shape+" and ")+(s.shape+" and transposeA="+e)+(" and transposeB="+r+" must match.")});var x=w>b?g:y,N=x.concat([f,m]),I=e?Y(a,[w,d,f]):Y(a,[w,f,d]),C=r?Y(s,[b,m,p]):Y(s,[b,p,m]),O=u.batchMatMul(I,C,e,r);return Y(O,N)},c={a,b:s},l={transposeA:e,transposeB:r};return z.runKernelFunc(o,c,null,hl,l)}var Ue=U({matMul_:sA});function oA(n,t,e,r){if(e===void 0&&(e=1),r===void 0&&(r=0),t<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+t);var i=R(n,"indices","oneHot","int32"),a=i.shape.concat([t]),s=function(l,u){return u([i]),Y(l.oneHot(Y(i,[i.size]),t,e,r),a)},o={indices:i},c={depth:t,onValue:e,offValue:r};return z.runKernelFunc(s,o,null,eu,c)}var oo=U({oneHot_:oA});function cA(n,t){var e=R(n,"x","transpose");if(t==null&&(t=e.shape.map(function(a,s){return s}).reverse()),E(e.rank===t.length,function(){return"Error in transpose: rank of input "+e.rank+" "+("must match length of perm "+t+".")}),t.forEach(function(a){E(a>=0&&a0&&Number.isInteger(e),function(){return"If provided, numClasses must be a positive integer, "+("but got "+e)}),E(r.rank===1,function(){return"Expected the rank of labels to be 1, but got "+r.rank}),E(i.rank===1,function(){return"Expected the rank of predictions to be 1, "+("but got "+i.rank)}),E(r.shape[0]===i.shape[0],function(){return"Mismatch in the number of examples: "+(r.shape[0]+" vs. "+i.shape[0]+". ")+"Labels and predictions should have the same number of elements."}),E(e>0&&Number.isInteger(e),function(){return"numClasses is required to be a positive integer, but got "+(""+e)});var a=oo(he(r,"int32"),e),s=oo(he(i,"int32"),e),o=Nt(a),c=Ue(o,s);return he(c,"int32")}var uA=U({confusionMatrix_:lA});var hA={__proto__:null,confusionMatrix:uA};function kg(n,t,e){if(Xr(n),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");var r=Un(n,e);if(r.length!==3&&r.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Sr(n,t,r,e)}var Gi;function dA(n,t){if(t===void 0&&(t=3),t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(n==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var e=!1,r=!1,i=!1,a=!1,s=!1;if(n.data instanceof Uint8Array)e=!0;else if(typeof ImageData!="undefined"&&n instanceof ImageData)r=!0;else if(typeof HTMLVideoElement!="undefined"&&n instanceof HTMLVideoElement)i=!0;else if(typeof HTMLImageElement!="undefined"&&n instanceof HTMLImageElement)a=!0;else if(n.getContext!=null)s=!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 "+n.constructor.name));if(i){var o=2;if(i&&n.readyState element.")}var c=Mu(Wu,z.backendName);if(c!=null){var l={pixels:n},u={numChannels:t};return z.runKernel(Wu,l,u)}var h=i?[n.videoWidth,n.videoHeight]:[n.width,n.height],d=h[0],p=h[1],f;s?f=n.getContext("2d").getImageData(0,0,d,p).data:r||e?f=n.data:(a||i)&&(Gi==null&&(Gi=document.createElement("canvas").getContext("2d")),Gi.canvas.width=d,Gi.canvas.height=p,Gi.drawImage(n,0,0,d,p),f=Gi.getImageData(0,0,d,p).data);var m;if(t===4)m=new Int32Array(f);else{var g=d*p;m=new Int32Array(g*t);for(var y=0;y4||o===2)throw new Error("toPixels only supports depth of size "+("1, 3 or 4 but got "+o));if(e.dtype!=="float32"&&e.dtype!=="int32")throw new Error("Unsupported type for toPixels: "+e.dtype+". Please use float32 or int32 tensors.");return[4,e.data()];case 1:for(c=w.sent(),l=e.dtype==="float32"?255:1,u=new Uint8ClampedArray(s*a*4),h=0;h1)throw new Error("Tensor values for a float32 Tensor must be in the "+("range [0 - 1] but encountered "+f+"."))}else if(e.dtype==="int32"&&(f<0||f>255))throw new Error("Tensor values for a int32 Tensor must be in the "+("range [0 - 255] but encountered "+f+"."));o===1?(d[0]=f*l,d[1]=f*l,d[2]=f*l):d[p]=f*l}m=h*4,u[m+0]=Math.round(d[0]),u[m+1]=Math.round(d[1]),u[m+2]=Math.round(d[2]),u[m+3]=Math.round(d[3])}return t!=null&&(t.width=s,t.height=a,g=t.getContext("2d"),y=new ImageData(u,s,a),g.putImageData(y,0,0)),e!==n&&e.dispose(),[2,u]}})})}var fA=U({fromPixels_:dA}),mA={__proto__:null,toPixels:pA,fromPixels:fA};function Fg(n,t){if(n.rank<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher,"+(" but the rank was "+n.rank+"."));if(t.rank<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher,"+(" but the rank was "+t.rank+"."));if(t.dtype!=="int32")throw new Error("tf.gatherND() expects the indices to be int32 type,"+(" but the dtype was "+t.dtype+"."));if(t.shape[t.rank-1]>n.rank)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+(t.shape[t.rank-1]+" vs. "+n.rank));if(n.size===0)throw new Error("Requested more than 0 entries, but input is empty."+(" Input shape: "+n.shape+"."));for(var e=t.shape,r=e[e.length-1],i=1,a=0;a1?t.shape[t.rank-1]:1,i=t.rank>1?t.rank-1:1,a="Must have updates.shape = indices.shape[:batchDim] + "+("shape[sliceDim:], got updates.shape: "+e.shape)+(", indices.shape: "+t.shape+", shape: "+n)+(", sliceDim: "+r+", and batchDim: "+i+".");if(e.rank1?t.shape[r-1]:1,a=e.length,s=1,o=i;o0;)n&1&&t.push(e),n/=2,e++;return t}function Bg(n,t,e){for(var r=[],i=0;i0){var p=t[0],f=e+1;u=Hg(s,p,f,r,n),h=Vg(o,p,f,i,n),d=zg(a,p,f,n)}else for(var m=0;m-1)a[o]=0;else{var c=Pg(t,e,o),l=r[c];n&1<-1)a[o]=Number.MAX_SAFE_INTEGER;else{var c=Pg(t,e,o),l=r[c];n&1<0?s=Number.MIN_SAFE_INTEGER:s=Number.MAX_SAFE_INTEGER);var c=r[i];return s<0&&(s+=c),s=Ua(0,s,c-1),s}function Yg(n,t,e,r,i,a){var s=t[i],o=e[i]||1;(n&1<0?s=Number.MAX_SAFE_INTEGER:s=Number.MIN_SAFE_INTEGER);var c=r[i];return s<0&&(s+=c),o>0?s=Ua(0,s,c):s=Ua(-1,s,c-1),s}function vA(n,t,e){for(var r=e.length,i=0;i1){r=i;break}for(var i=r+1;i0||e[i]!==n[i])return!1;return!0}function wA(n,t){for(var e=n.length>0?n[n.length-1]:1,r=0;r=0?s:(E(s===-1,function(){return"Negative size values should be exactly -1 but got "+(s+" for the slice() size at index "+o+".")}),n.shape[o]-r[o])}),[r,a]}var Kg={__proto__:null,assertParamsValid:Ug,maskToAxes:co,computeOutShape:Bg,stridesWithElidedDims:zg,getNormalizedAxes:jg,startIndicesWithElidedDims:Hg,stopIndicesWithElidedDims:Vg,stridesForAxis:qg,startForAxis:Gg,stopForAxis:Yg,isSliceContinous:vA,computeFlatOffset:wA,parseSliceParams:hh};var $g=function(){function n(){}return n.prototype.getClassName=function(){return this.constructor.className},n.fromConfig=function(t,e){return new t(e)},n}(),Xg=function(){function n(){this.classNameMap={}}return n.getMap=function(){return n.instance==null&&(n.instance=new n),n.instance},n.register=function(t){n.getMap().classNameMap[t.className]=[t,t.fromConfig]},n}();function Tr(n){E(n.className!=null,function(){return"Class being registered does not have the static className property defined."}),E(typeof n.className=="string",function(){return"className is required to be a string, but got type "+typeof n.className}),E(n.className.length>0,function(){return"Class being registered has an empty-string as its className, which is disallowed."}),Xg.register(n)}var bA={__proto__:null,Serializable:$g,SerializationMap:Xg,registerClass:Tr};var xA=.001,Jg=.1;function SA(n,t,e){return e==null&&(e=dh()),ph(n,t,function(r,i){return fh(r,i,e)})}function dh(){return z.backend.floatPrecision()===32?xA:Jg}function ph(n,t,e){var r=!0;if((Ut(n)||Ut(t))&&(r=!1),Ut(n)&&Ut(t)&&(r=!0),r){var i=n.constructor.name,a=t.constructor.name;if(i!==a)throw new Error("Arrays are of different type. Actual: "+i+". "+("Expected: "+a))}if(Array.isArray(n)&&Array.isArray(t)){var s=Un(n),o=Un(t);if(!wn(s,o))throw new Error("Arrays have different shapes. "+("Actual: ["+s+"]. Expected: ["+o+"]"))}var c=Ut(n)?n:Jr(n),l=Ut(t)?t:Jr(t);if(c.length!==l.length)throw new Error("Arrays have different lengths actual: "+c.length+" vs "+("expected: "+l.length+`. `)+("Actual: "+c+`. `)+("Expected: "+l+"."));for(var u=0;ue)}function TA(n,t,e){for(var r=0;re)throw new Error("Value out of range:"+n[r]+" low: "+t+", high: "+e)}function NA(n,t){expect(new Float32Array(n)).toEqual(new Float32Array(t))}var _A={__proto__:null,TEST_EPSILON_FLOAT16:Jg,expectArraysClose:SA,testEpsilon:dh,expectPromiseToFail:LA,expectArraysEqual:IA,expectNumbersClose:AA,expectValuesInRange:TA,expectArrayBuffersEqual:NA};var CA="2.7.0";function RA(){qe().set("PROD",!0)}function OA(){qe().set("DEBUG",!0)}function EA(){qe().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function _t(n){qe().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(n+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function DA(){z.disposeVariables()}function kA(){return z}function FA(){return z.memory()}function WA(n){return z.profile(n)}function xt(n,t){return z.tidy(n,t)}function Vt(n){var t=Ju(n);t.forEach(function(e){return e.dispose()})}function Zg(n){return z.keep(n)}function UA(n){return z.time(n)}function BA(n){return z.setBackend(n)}function zA(){return z.ready()}function PA(){return z.backendName}function MA(n){z.removeBackend(n)}function HA(n){return z.findBackend(n)}function VA(n){return z.findBackendFactory(n)}function qA(n,t,e){return e===void 0&&(e=1),z.registerBackend(n,t,e)}function GA(){return z.backend}function YA(n,t){qe().setPlatform(n,t)}function jA(n,t){var e,r=R(n,"a","add"),i=R(t,"b","add");e=ct(r,i),r=e[0],i=e[1];var a=function(o,c){var l=o.add(r,i);return c([r,i]),l},s={a:r,b:i};return z.runKernelFunc(a,s,null,Zs)}var ge=U({add_:jA});function KA(n,t){var e,r=R(n,"a","floorDiv"),i=R(t,"b","floorDiv");e=ct(r,i),r=e[0],i=e[1];var a=function(o,c){var l=o.floorDiv(r,i);return c([r,i]),l},s={a:r,b:i};return z.runKernelFunc(a,s,null,Ol)}var mh=U({floorDiv_:KA});function $A(n,t){var e,r=R(n,"a","div"),i=R(t,"b","div");if(e=ct(r,i),r=e[0],i=e[1],r.dtype==="int32"&&i.dtype==="int32")return mh(r,i);var a=function(c,l){var u=c.realDivide(r,i);return l([r,i]),u},s={a:r,b:i},o={};return z.runKernelFunc(a,s,null,Al,o)}var Ne=U({div_:$A});function XA(n,t){var e,r=R(n,"a","mul"),i=R(t,"b","mul");e=ct(r,i),r=e[0],i=e[1];var a=function(o,c){var l=o.multiply(r,i);return c([r,i]),l},s={a:r,b:i};return z.runKernelFunc(a,s,null,Jl)}var Z=U({mul_:XA});function JA(n){var t=R(n,"x","abs"),e={x:t};return z.runKernelFunc(function(r,i){return i([t]),t.dtype==="complex64"?r.complexAbs(t):r.abs(t)},e,null,Zc)}var Zt=U({abs_:JA});function ZA(n){var t=R(n,"x","acos"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.acos(t);return i([t]),a},e,null,Qc)}var Qg=U({acos_:ZA});function QA(n){var t=R(n,"x","acosh"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.acosh(t);return i([t]),a},e,null,el)}var e0=U({acosh_:QA});function e5(n){E(Array.isArray(n),function(){return"The argument passed to tf.addN() must be a list of tensors"}),E(n.length>=1,function(){return"Must pass at least one tensor to tf.addN(), but got "+(""+n.length)});var t=n.map(function(a,s){return R(a,"tensors"+s,"addN")}),e=t[0];t.forEach(function(a){if(a.dtype!==e.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(function(a){if(!wn(a.shape,e.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});var r=function(a,s){var o=a.addN(t);return s(t),o},i=t;return z.runKernelFunc(r,i,null,tl)}var t5=U({addN_:e5});function gh(n,t){for(var e=0;e=0&&t=1,function(){return"Pass at least one tensor to concat"});var e=qa(n,"tensors","concat");e[0].dtype==="complex64"&&e.forEach(function(s){if(s.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor with dtype `+s.dtype+". ")});var r=function(s,o){var c=rt(t,e[0].shape)[0],l=p0(e.map(function(d){return d.shape}),c);if(pt(l)===0)return Lr([],l);if(e=e.filter(function(d){return d.size>0}),e.length===1)return e[0];var u=e.map(function(d){return d.shape});d0(u,c);var h=s.concat(e,c);return o(e),h},i=e,a={axis:t};return z.runKernelFunc(r,i,null,gl,a)}var kt=U({concat_:b5});function x5(n){var t=R(n,"x","sigmoid"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.sigmoid(t);return i([a]),a},e,null,wu)}var ti=U({sigmoid_:x5});function S5(n,t,e){var r=R(n,"x","slice");if(r.rank===0)throw new Error("Slicing scalar is not possible");var i=function(o,c){var l=hh(r,t,e),u=l[0],h=l[1];return Ug(r,u,h),c([r]),o.slice(r,u,h)},a={x:r},s={begin:t,size:e};return z.runKernelFunc(i,a,null,mu,s)}var Me=U({slice_:S5});function L5(n){var t=R(n,"x","tanh"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.tanh(t);return i([a]),a},e,null,Cu)}var ho=U({tanh_:L5});function I5(n,t,e,r,i,a){var s=R(n,"forgetBias","basicLSTMCell"),o=R(t,"lstmKernel","basicLSTMCell"),c=R(e,"lstmBias","basicLSTMCell"),l=R(r,"data","basicLSTMCell"),u=R(i,"c","basicLSTMCell"),h=R(a,"h","basicLSTMCell"),d=kt([l,h],1),p=Ue(d,o),f=ge(p,c),m=f.shape[0],g=f.shape[1]/4,y=[m,g],w=Me(f,[0,0],y),b=Me(f,[0,g],y),S=Me(f,[0,g*2],y),x=Me(f,[0,g*3],y),N=ge(Z(ti(w),ho(b)),Z(u,ti(ge(s,S)))),I=Z(ho(N),ti(x));return[N,I]}var A5=U({basicLSTMCell_:I5});function T5(n,t,e){var r=R(n,"x","batchToSpaceND"),i=t.reduce(function(c,l){return c*l});E(r.rank>=1+t.length,function(){return"input rank is "+r.rank+" but should be > than blockShape.length "+t.length}),E(e.length===t.length,function(){return"crops.length is "+e.length+" but should be equal to blockShape.length "+t.length}),E(r.shape[0]%i===0,function(){return"input tensor batch is "+r.shape[0]+" but is not divisible by the product of "+("the elements of blockShape "+t.join(" * ")+" === "+i)});var a=function(c){return c.batchToSpaceND(r,t,e)},s={x:r},o={blockShape:t,crops:e};return z.runKernelFunc(a,s,null,dl,o)}var po=U({batchToSpaceND_:T5});function N5(n){var t;return n.rank===0||n.rank===1?t=Y(n,[1,1,1,n.size]):n.rank===2?t=Y(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?t=Y(n,[1,n.shape[0],n.shape[1],n.shape[2]]):t=n,t}function _5(n,t,e,r,i,a){a==null&&(a=.001);var s=R(n,"x","batchNorm"),o=R(t,"mean","batchNorm"),c=R(e,"variance","batchNorm"),l;i!=null&&(l=R(i,"scale","batchNorm"));var u;r!=null&&(u=R(r,"offset","batchNorm")),E(o.rank===c.rank,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),E(u==null||o.rank===u.rank,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),E(l==null||o.rank===l.rank,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var h=N5(s),d=function(g,y){return y([h,o,c,l]),g.batchNorm(h,fo(o),fo(c),fo(u),fo(l),a)},p={x:h,scale:l,offset:u,mean:o,variance:c},f={varianceEpsilon:a},m=z.runKernelFunc(d,p,null,El,f);return Y(m,s.shape)}function fo(n){return n==null?null:n.rank===0?Y(n,[n.size]):n.rank===1?n:n.rank===2?Y(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?Y(n,[1,n.shape[0],n.shape[1],n.shape[2]]):n}var $a=U({batchNorm_:_5});function C5(n,t,e,r,i,a){var s=R(n,"x","batchNorm"),o=R(t,"mean","batchNorm"),c=R(e,"variance","batchNorm"),l;i!=null&&(l=R(i,"scale","batchNorm"));var u;return r!=null&&(u=R(r,"offset","batchNorm")),E(s.rank===2,function(){return"Error in batchNorm2D: x must be rank 2 but got rank "+(s.rank+".")}),E(o.rank===2||o.rank===1,function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but "+("got rank "+o.rank+".")}),E(c.rank===2||c.rank===1,function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 "+("but got rank "+c.rank+".")}),l!=null&&E(l.rank===2||l.rank===1,function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 "+("but got rank "+l.rank+".")}),u!=null&&E(u.rank===2||u.rank===1,function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 "+("but got rank "+u.rank+".")}),$a(s,o,c,u,l,a)}var R5=U({batchNorm2d_:C5});function O5(n,t,e,r,i,a){var s=R(n,"x","batchNorm"),o=R(t,"mean","batchNorm"),c=R(e,"variance","batchNorm"),l;i!=null&&(l=R(i,"scale","batchNorm"));var u;return r!=null&&(u=R(r,"offset","batchNorm")),E(s.rank===3,function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+(s.rank+".")}),E(o.rank===3||o.rank===1,function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but "+("got rank "+o.rank+".")}),E(c.rank===3||c.rank===1,function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 "+("but got rank "+c.rank+".")}),l!=null&&E(l.rank===3||l.rank===1,function(){return"Error in batchNorm3D: scale must be rank 3 or rank 1 "+("but got rank "+l.rank+".")}),u!=null&&E(u.rank===3||u.rank===1,function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 "+("but got rank "+u.rank+".")}),$a(s,o,c,u,l,a)}var E5=U({batchNorm3d_:O5});function D5(n,t,e,r,i,a){var s=R(n,"x","batchNorm"),o=R(t,"mean","batchNorm"),c=R(e,"variance","batchNorm"),l;i!=null&&(l=R(i,"scale","batchNorm"));var u;return r!=null&&(u=R(r,"offset","batchNorm")),E(s.rank===4,function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+(s.rank+".")}),E(o.rank===4||o.rank===1,function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but "+("got rank "+o.rank+".")}),E(c.rank===4||c.rank===1,function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 "+("but got rank "+c.rank+".")}),l!=null&&E(l.rank===4||l.rank===1,function(){return"Error in batchNorm4D: scale must be rank 4 or rank 1 "+("but got rank "+l.rank+".")}),u!=null&&E(u.rank===4||u.rank===1,function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 "+("but got rank "+u.rank+".")}),$a(s,o,c,u,l,a)}var k5=U({batchNorm4d_:D5});function F5(n,t){var e=R(n,"broadcastTo","x"),r=e.shape;if(t.some(function(d){return!(d>0)||d%1!==0}))throw new Error("broadcastTo(): Invalid broadcast shape ["+t+"].");if(t.lengthe.rank){for(var i=e.shape.slice();i.length=0;o--)if(a[o]===t[o])s[o]=1;else if(e.shape[o]!==1)throw new Error("broadcastTo(): ["+r+"] cannot be broadcast to ["+t+"].");var c=s.map(function(d,p){return d>1?p:-1}).filter(function(d){return d>=0});if(c.length===0)return Qr(e);var l=function(d){return d.tile(e,s)},u={x:e},h={shape:t,inputShape:a};return z.runKernelFunc(l,u,null,pl,h)}var mo=U({broadcastTo_:F5});function W5(n){var t=R(n,"x","ceil"),e={x:t};return z.runKernelFunc(function(r){return r.ceil(t)},e,null,fl)}var f0=U({ceil_:W5});function U5(n,t,e){var r=R(n,"x","clipByValue");E(t<=e,function(){return"Error in clip: min ("+t+") must be "+("less than or equal to max ("+e+").")});var i={x:r},a={clipValueMin:t,clipValueMax:e};return z.runKernelFunc(function(s,o){var c=s.clip(r,t,e);return o([r]),c},i,null,ml,a)}var m0=U({clipByValue_:U5});function B5(n){return kt(n,0)}var z5=U({concat1d_:B5});function P5(n,t){return kt(n,t)}var M5=U({concat2d_:P5});function H5(n,t){return kt(n,t)}var V5=U({concat3d_:H5});function q5(n,t){return kt(n,t)}var G5=U({concat4d_:q5});function Y5(n,t,e,r,i,a,s){i===void 0&&(i="NHWC"),a===void 0&&(a=[1,1]);var o=R(n,"x","conv2d"),c=R(t,"filter","conv2d"),l=o,u=!1;o.rank===3&&(u=!0,l=Y(o,[1,o.shape[0],o.shape[1],o.shape[2]])),E(l.rank===4,function(){return"Error in conv2d: input must be rank 4, but got rank "+l.rank+"."}),E(c.rank===4,function(){return"Error in conv2d: filter must be rank 4, but got rank "+(c.rank+".")}),s!=null&&E(ot(r),function(){return"Error in conv2d: pad must be an integer when using, "+("dimRoundingMode "+s+" but got pad "+r+".")});var h=i==="NHWC"?l.shape[3]:l.shape[1];E(h===c.shape[2],function(){return"Error in conv2d: depth of input ("+h+") must match "+("input depth for filter "+c.shape[2]+".")}),E(qt(e,a),function(){return"Error in conv2D: Either strides or dilations must be 1. "+("Got strides "+e+" and dilations '"+a+"'")});var d=function(g,y){var w=Ya(i),b=xn(l.shape,c.shape,e,a,r,s,!1,w),S=g.conv2d(l,c,b);return y([l,c]),S},p={x:l,filter:c},f={strides:e,pad:r,dataFormat:i,dilations:a,dimRoundingMode:s},m=z.runKernelFunc(d,p,null,yl,f);return u?Y(m,[m.shape[1],m.shape[2],m.shape[3]]):m}var Ki=U({conv2d_:Y5});function j5(n,t,e,r,i,a,s){i===void 0&&(i="NWC"),a===void 0&&(a=1);var o=R(n,"x","conv1d"),c=R(t,"filter","conv1d"),l=o,u=!1;o.rank===2&&(u=!0,l=Y(o,[1,o.shape[0],o.shape[1]])),E(l.rank===3,function(){return"Error in conv1d: input must be rank 3, but got rank "+l.rank+"."}),E(c.rank===3,function(){return"Error in conv1d: filter must be rank 3, but got rank "+(c.rank+".")}),s!=null&&E(ot(r),function(){return"Error in conv1d: pad must be an integer when using, "+("dimRoundingMode "+s+" but got pad "+r+".")}),E(l.shape[2]===c.shape[1],function(){return"Error in conv1d: depth of input ("+l.shape[2]+") must match "+("input depth for filter "+c.shape[1]+".")}),E(qt(e,a),function(){return"Error in conv1D: Either stride or dilation must be 1. "+("Got stride "+e+" and dilation '"+a+"'")}),E(i==="NWC",function(){return"Error in conv1d: got dataFormat of "+i+" but only NWC is currently supported."});var h=Y(c,[1,c.shape[0],c.shape[1],c.shape[2]]),d=Y(l,[l.shape[0],1,l.shape[1],l.shape[2]]),p=[1,e],f=[1,a],m="NHWC",g=Ki(d,h,p,r,m,f,s);return u?Y(g,[g.shape[2],g.shape[3]]):Y(g,[g.shape[0],g.shape[2],g.shape[3]])}var g0=U({conv1d_:j5});function K5(n,t,e,r,i,a,s){a===void 0&&(a="NHWC"),E(n.length===t.rank,function(){return"Length of inShape "+("("+n.length+") and rank of dy ("+t.rank+") must match")});var o=n,c=t,l=!1;t.rank===3&&(l=!0,c=Y(t,[1,t.shape[0],t.shape[1],t.shape[2]]),o=[1,n[0],n[1],n[2]]),E(o.length===4,function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+(o.length+".")}),E(c.rank===4,function(){return"Error in conv2dDerInput: dy must be rank 4, but got "+("rank "+c.rank)}),E(e.rank===4,function(){return"Error in conv2dDerInput: filter must be rank 4, but got "+("rank "+e.rank)});var u=a==="NHWC"?o[3]:o[1],h=a==="NHWC"?c.shape[3]:c.shape[1];E(u===e.shape[2],function(){return"Error in conv2dDerInput: depth of input ("+u+") must "+("match input depth for filter "+e.shape[2]+".")}),E(h===e.shape[3],function(){return"Error in conv2dDerInput: depth of output ("+h+") must "+("match output depth for filter "+e.shape[3]+".")}),s!=null&&E(ot(i),function(){return"Error in conv2dDerInput: pad must be an integer when using, "+("dimRoundingMode "+s+" but got pad "+i+".")});var d=function(g,y){var w=1,b=Ya(a),S=xn(o,e.shape,r,w,i,s,!1,b),x=g.conv2dDerInput(c,e,S);return y([c,e]),x},p={dy:c,filter:e},f={strides:r,pad:i,dataFormat:a,dimRoundingMode:s,inputShape:o},m=z.runKernelFunc(d,p,null,vl,f);return l?Y(m,[m.shape[1],m.shape[2],m.shape[3]]):m}var bh=U({conv2DBackpropInput_:K5});function $5(n,t,e,r,i,a){var s=R(n,"x","conv2dTranspose"),o=R(t,"filter","conv2dTranspose");return bh(e,s,o,r,i,"NHWC",a)}var y0=U({conv2dTranspose_:$5});function X5(n,t,e,r,i,a){i===void 0&&(i="NDHWC"),a===void 0&&(a=[1,1,1]);var s=R(n,"x","conv3d"),o=R(t,"filter","conv3d"),c=s,l=!1;s.rank===4&&(l=!0,c=Y(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),E(c.rank===5,function(){return"Error in conv3d: input must be rank 5, but got rank "+c.rank+"."}),E(o.rank===5,function(){return"Error in conv3d: filter must be rank 5, but got rank "+(o.rank+".")}),E(c.shape[4]===o.shape[3],function(){return"Error in conv3d: depth of input ("+c.shape[4]+") must match "+("input depth for filter "+o.shape[3]+".")}),E(qt(e,a),function(){return"Error in conv3D: Either strides or dilations must be 1. "+("Got strides "+e+" and dilations '"+a+"'")}),E(i==="NDHWC",function(){return"Error in conv3d: got dataFormat of "+i+" but only NDHWC is currently supported."});var u=function(f,m){var g=ja(c.shape,o.shape,e,a,r),y=f.conv3d(c,o,g);return m([c,o]),y},h={x:c,filter:o},d={strides:e,pad:r,dataFormat:i,dilations:a},p=z.runKernelFunc(u,h,null,wl,d);return l?Y(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var J5=U({conv3d_:X5});function Z5(n,t,e,r,i){E(n.length===t.rank,function(){return"Length of inShape "+("("+n.length+") and rank of dy ("+t.rank+") must match")});var a=n,s=t,o=!1;t.rank===4&&(o=!0,s=Y(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),a=[1,n[0],n[1],n[2],n[3]]);var c=a[4],l=s.shape[4];E(a.length===5,function(){return"Error in conv3dDerInput: inShape must be length 5, but got length "+(a.length+".")}),E(s.rank===5,function(){return"Error in conv3dDerInput: dy must be rank 5, but got "+("rank "+s.rank)}),E(e.rank===5,function(){return"Error in conv3dDerInput: filter must be rank 5, but got "+("rank "+e.rank)}),E(c===e.shape[3],function(){return"Error in conv3dDerInput: depth of input ("+c+") must "+("match input depth for filter "+e.shape[3]+".")}),E(l===e.shape[4],function(){return"Error in conv3dDerInput: depth of output ("+l+") must "+("match output depth for filter "+e.shape[4]+".")});var u=function(f){var m=1,g=ja(a,e.shape,r,m,i);return f.conv3dDerInput(s,e,g)},h={dy:s,filter:e},d={pad:i,strides:r,inputShape:a},p=z.runKernelFunc(u,h,null,gm,d);return o?Y(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var v0=U({conv3DBackpropInput_:Z5});function Q5(n,t,e,r,i){var a=R(n,"x","conv3dTranspose"),s=R(t,"filter","conv3dTranspose");return v0(e,a,s,r,i)}var eT=U({conv3dTranspose_:Q5});function tT(n){var t=R(n,"x","cos"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.cos(t);return i([t]),a},e,null,bl)}var go=U({cos_:tT});function nT(n){var t=R(n,"x","cosh"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.cosh(t);return i([t]),a},e,null,xl)}var xh=U({cosh_:nT});function rT(n,t,e,r){t===void 0&&(t=0),e===void 0&&(e=!1),r===void 0&&(r=!1);var i=R(n,"x","cumsum"),a=function(c,l){var u=bn([t],i.rank),h=i;u!=null&&(h=Nt(i,u));var d=zn(1,i.rank)[0],p=c.cumsum(h,d,e,r);if(l([i]),u!=null){var f=lo(u);p=Nt(p,f)}return p},s={x:i},o={axis:t,exclusive:e,reverse:r};return z.runKernelFunc(a,s,null,Sl,o)}var Sh=U({cumsum_:rT});function iT(n,t,e){e===void 0&&(e="NHWC");var r=R(n,"x","depthToSpace"),i=e==="NHWC"?r.shape[1]:r.shape[2],a=e==="NHWC"?r.shape[2]:r.shape[3],s=e==="NHWC"?r.shape[3]:r.shape[1];E(i*t>=0,function(){return`Negative dimension size caused by overflow when multiplying `+i+" and "+t+` for depthToSpace with input shape `+r.shape}),E(a*t>=0,function(){return`Negative dimension size caused by overflow when multiplying `+a+" and "+t+` for depthToSpace with input shape `+r.shape}),E(s%(t*t)===0,function(){return"Dimension size must be evenly divisible by "+t*t+" but is "+s+" for depthToSpace with input shape "+r.shape});var o=function(u){return u.depthToSpace(r,t,e)},c={x:r},l={blockSize:t,dataFormat:e};return z.runKernelFunc(o,c,null,vm,l)}var w0=U({depthToSpace_:iT});function aT(n,t,e,r,i,a,s){i===void 0&&(i="NHWC"),a===void 0&&(a=[1,1]);var o=R(n,"x","depthwiseConv2d"),c=R(t,"filter","depthwiseConv2d"),l=o,u=!1;o.rank===3&&(u=!0,l=Y(o,[1,o.shape[0],o.shape[1],o.shape[2]])),E(l.rank===4,function(){return"Error in depthwiseConv2d: input must be rank 4, but got "+("rank "+l.rank+".")}),E(c.rank===4,function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+(c.rank+".")}),E(l.shape[3]===c.shape[2],function(){return"Error in depthwiseConv2d: number of input channels "+("("+l.shape[3]+") must match the inChannels dimension in ")+("filter "+c.shape[2]+".")}),s!=null&&E(ot(r),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+s+" but got pad "+r+".")});var h=function(m,g){a==null&&(a=[1,1]),E(qt(e,a),function(){return"Error in depthwiseConv2d: Either strides or dilations must be "+("1. Got strides "+e+" and dilations '"+a+"'")});var y=xn(l.shape,c.shape,e,a,r,s,!0),w=m.depthwiseConv2D(l,c,y);return g([l,c]),w},d={x:l,filter:c},p={strides:e,pad:r,dataFormat:i,dilations:a,dimRoundingMode:s},f=z.runKernelFunc(h,d,null,Ll,p);return u?Y(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var Xa=U({depthwiseConv2d_:aT});function sT(n){var t=R(n,"x","diag"),e=function(i){var a=Y(t,[t.size]),s=i.diag(a),o=n.shape.concat(n.shape);return Y(s,o)},r={x:t};return z.runKernelFunc(e,r,null,xm)}var oT=U({diag_:sT});function cT(n,t,e,r,i,a){i===void 0&&(i=[1,1]),a===void 0&&(a="NHWC");var s=R(n,"x","dilation2d"),o=R(t,"filter","dilation2d");E(s.rank===3||s.rank===4,function(){return"Error in dilation2d: input must be rank 3 or 4, but got rank "+(s.rank+".")}),E(o.rank===3,function(){return"Error in dilation2d: filter must be rank 3, but got rank "+(o.rank+".")}),E(a==="NHWC",function(){return"Error in dilation2d: Only NHWC is currently supported, "+("but got dataFormat of "+a)});var c=s,l=!1;s.rank===3&&(c=Y(s,[1,s.shape[0],s.shape[1],s.shape[2]]),l=!0);var u={x:c,filter:o},h={strides:e,pad:r,dilations:i},d=z.runKernel(Il,u,h);return l?Y(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var b0=U({dilation2d_:cT});function lT(n,t){for(var e=n.length,r=[],i=0;i1&&s===1&&r.unshift(a)}return r}function St(n,t){for(var e=[],r=0;r1)&&e.unshift(a)}return e}function it(n,t){for(var e=[],r=Math.max(n.length,t.length),i=0;it||r===n?e=!0:r=Js(n,r+1);return r}function AT(n,t,e){for(var r=[],i=n.length,a=0;a0,function(){return"variableGrads() expects at least one of the input variables to "+("be trainable, but none of the "+a+" variables is ")+"trainable."});var s=!0,o=z.gradients(n,t,null,s),c=o.value,l=o.grads;E(l.some(function(h){return h!=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()."}),E(c.rank===0,function(){return"The f passed in variableGrads(f) must return a scalar, but it "+("returned a rank-"+c.rank+" tensor")});var u={};return t.forEach(function(h,d){l[d]!=null&&(u[h.name]=l[d])}),i!=null&&i.forEach(function(h){return u[h.name]=null}),{value:c,grads:u}}function Pn(n){return z.customGrad(n)}function xo(n){var t=n.filter(function(e){return e==null}).length;if(t>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 YT(n){var t=R(n,"x","neg"),e={x:t};return z.runKernelFunc(function(r){return r.neg(t)},e,null,Zl)}var Lt=U({neg_:YT});function jT(n){var t=R(n,"x","softplus"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.softplus(t);return i([t]),a},e,null,bu)}var Nh=U({softplus_:jT});function KT(n){var t=R(n,"x","logSigmoid"),e=Pn(function(r){var i=Lt(Nh(Lt(r))),a=function(s){var o=Z(s,ti(Lt(r)));return o};return{value:i,gradFunc:a}});return e(t)}var D0=U({logSigmoid_:KT});function $T(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var r=R(n,"x","max"),i=function(o,c){var l=rt(t,r.shape),u=l,h=bn(u,r.rank),d=r;h!=null&&(d=Nt(r,h),u=zn(u.length,d.rank));var p=o.max(d,u);h!=null&&d.dispose();var f=p;if(e){var m=cn(f.shape,rt(t,r.shape));f=Y(f,m),p.dispose()}return c([r,f]),f},a={x:r},s={reductionIndices:t,keepDims:e};return z.runKernelFunc(i,a,null,Vl,s)}var ai=U({max_:$T});function XT(n,t){var e,r=R(n,"a","sub"),i=R(t,"b","sub");e=ct(r,i),r=e[0],i=e[1];var a=function(o,c){var l=o.subtract(r,i);return c([r,i]),l},s={a:r,b:i};return z.runKernelFunc(a,s,null,Nu)}var be=U({sub_:XT});function JT(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var r=R(n,"x","sum");r.dtype==="bool"&&(r=he(r,"int32"));var i=function(o,c){c([r]);var l=rt(t,r.shape),u=bn(l,r.rank),h=l,d=r;u!=null&&(d=Nt(r,u),h=zn(h.length,r.rank));var p=o.sum(d,h);if(e){var f=cn(p.shape,l);p=Y(p,f)}return p},a={x:r},s={axis:t,keepDims:e};return z.runKernelFunc(i,a,null,Su,s)}var _e=U({sum_:JT});function ZT(n,t){t===void 0&&(t=-1);var e=R(n,"logits","logSoftmax");if(t===-1&&(t=e.rank-1),t!==e.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. "+("Logits was rank "+e.rank+" and axis was "+t));var r=function(s,o){var c=!0,l=ai(n,t,!0),u=be(n,l),h=be(he(u,"float32"),ii(_e(Ln(u),t,c)));return o([h]),h},i={logits:e},a={axis:t};return z.runKernelFunc(r,i,null,Ml,a)}var k0=U({logSoftmax_:ZT});function QT(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var r=R(n,"x","logSumExp"),i=rt(t,r.shape),a=ai(r,i,!0),s=be(r,a),o=Ln(s),c=_e(o,i),l=ii(c),u=ge(Y(a,l.shape),l);if(e){var h=cn(u.shape,i);return Y(u,h)}return u}var _h=U({logSumExp_:QT});function eN(n,t){var e=R(n,"a","logicalAnd","bool"),r=R(t,"b","logicalAnd","bool");it(e.shape,r.shape);var i={a:e,b:r};return z.runKernelFunc(function(a){return a.logicalAnd(e,r)},i,null,Wm)}var si=U({logicalAnd_:eN});function tN(n){var t=R(n,"x","logicalNot","bool"),e={x:t};return z.runKernelFunc(function(r){return r.logicalNot(t)},e,null,Um)}var So=U({logicalNot_:tN});function nN(n,t){var e=R(n,"a","logicalOr","bool"),r=R(t,"b","logicalOr","bool");it(e.shape,r.shape);var i={a:e,b:r};return z.runKernelFunc(function(a){return a.logicalOr(e,r)},i,null,Bm)}var Ch=U({logicalOr_:nN});function rN(n,t){var e=R(n,"a","logicalXor","bool"),r=R(t,"b","logicalXor","bool");return it(e.shape,r.shape),si(Ch(n,t),So(si(n,t)))}var F0=U({logicalXor_:rN});function iN(n,t,e,r,i){var a=R(n,"x","maxPool"),s=1,o=a,c=!1;a.rank===3&&(c=!0,o=Y(a,[1,a.shape[0],a.shape[1],a.shape[2]])),E(o.rank===4,function(){return"Error in maxPool: input must be rank 4 but got rank "+o.rank+"."}),E(qt(e,s),function(){return"Error in maxPool: Either strides or dilations must be 1. "+("Got strides "+e+" and dilations '"+s+"'")}),i!=null&&E(ot(r),function(){return"Error in maxPool: pad must be an integer when using, "+("dimRoundingMode "+i+" but got pad "+r+".")});var l=function(p,f){var m=Yi(o.shape,t,e,1,r,i),g;return m.filterWidth===1&&m.filterHeight===1&&wn(m.inShape,m.outShape)?g=o.clone():g=p.maxPool(o,m),f([o,g]),g},u={x:o},h={filterSize:t,strides:e,pad:r,dimRoundingMode:i},d=z.runKernelFunc(l,u,null,Gl,h);return c?Y(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Rh=U({maxPool_:iN});function aN(n,t,e,r,i,a,s){t===void 0&&(t=[1,1,1]),a===void 0&&(a="NDHWC"),s==null?s=[1,1,1]:_t("dilations is deprecated, this field will be gone in v3.0.0.");var o=R(n,"x","maxPool3d"),c=o,l=!1;o.rank===4&&(l=!0,c=Y(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),E(c.rank===5,function(){return"Error in maxPool3d: x must be rank 5 but got rank "+c.rank+"."}),E(a==="NDHWC",function(){return"Error in maxPool3d: Only NDHWC is currently supported, "+("but got dataFormat of "+a)}),E(qt(e,s),function(){return"Error in maxPool3d: Either strides or dilations must be 1. "+("Got strides "+e+" and dilations '"+s+"'")}),i!=null&&E(ot(r),function(){return"Error in maxPool3d: pad must be an integer when using, "+("dimRoundingMode "+i+" but got pad "+r+".")});var u=function(f,m){s==null&&(s=[1,1,1]);var g=Ka(c.shape,t,e,s,r,i,a),y=f.maxPool3d(c,g);return m([c,y]),y},h={x:c},d={filterSize:t,strides:e,pad:r,dimRoundingMode:i,dataFormat:a,dilations:s},p=z.runKernelFunc(u,h,null,Yl,d);return l?Y(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var sN=U({maxPool3d_:aN});function oN(n,t,e,r,i){i===void 0&&(i=!1);var a=R(n,"x","maxPoolWithArgmax"),s={x:a},o={filterSize:t,strides:e,pad:r,includeBatchInIndex:i},c=z.runKernel(Hm,s,o);return{result:c[0],indexes:c[1]}}var cN=U({maxPoolWithArgmax_:oN});function rr(n,t){if(t===void 0&&(t="float32"),t==="complex64"){var e=rr(n,"float32"),r=rr(n,"float32");return xr(e,r)}var i=Bi(pt(n),t);return z.makeTensor(i,n,t)}function Ji(n,t){if(t===void 0&&(t="float32"),t==="complex64"){var e=Ji(n,"float32"),r=rr(n,"float32");return xr(e,r)}var i=Kc(pt(n),t);return z.makeTensor(i,n,t)}function lN(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var r=R(n,"x","mean"),i=rt(t,r.shape),a=n0(r.shape,i),s=a[1],o=pt(s),c={x:r},l={axis:t,keepDims:e},u=function(){var d=Se(o),p=d.dtype===r.dtype?r:he(r,d.dtype),f=Ne(p,d);return _e(f,t,e)},h=Pn(function(d){var p=z.runKernelFunc(u,c,null,Vm,l),f=function(m){var g=d.shape.slice();i.forEach(function(b){g[b]=1});var y=Y(m,g),w=Ne(Z(y,Ji(d.shape,"float32")),o);return w};return{value:p,gradFunc:f}});return h(r)}var Za=U({mean_:lN});function uN(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var r=R(n,"x","min"),i=function(o,c){var l=rt(t,r.shape),u=l,h=bn(u,r.rank),d=r;h!=null&&(d=Nt(r,h),u=zn(u.length,r.rank));var p=o.min(d,u);h!=null&&d.dispose();var f=p;if(e){var m=cn(f.shape,l);f=Y(p,m),p.dispose()}return c([r,f]),f},a={x:r},s={axis:t,keepDims:e};return z.runKernelFunc(i,a,null,jl,s)}var Lo=U({min_:uN});function hN(n,t){var e,r=R(n,"a","minimum"),i=R(t,"b","minimum");e=ct(r,i),r=e[0],i=e[1],r.dtype==="bool"&&(r=he(r,"int32"),i=he(i,"int32")),it(r.shape,i.shape);var a=function(o,c){var l=o.minimum(r,i);return c([r,i]),l},s={a:r,b:i};return z.runKernelFunc(a,s,null,Kl)}var Io=U({minimum_:hN});function dN(n,t,e){E(e==="reflect"||e==="symmetric",function(){return"Invalid mode. Mode must be either reflect or symmetric. "+("Got "+e+".")});var r=R(n,"x","mirrorPad");if(r.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");E(t.length===r.rank,function(){return"Padding doesn't match input. Must be "+r.rank+". "+("Got "+t.length+".")});for(var i=e==="reflect"?1:0,a=function(l){E(t[l].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),E(t[l][0]>=0&&t[l][0]<=r.shape[l]-i&&t[l][1]>=0&&t[l][1]<=r.shape[l]-i,function(){return"Padding in dimension "+l+" cannot be greater than or equal "+("to "+(r.shape[l]-i)+" or less than 0 for input of ")+("shape "+r.shape)})},s=0;s2)throw new Error("Rank of probabilities must be 1 or 2, but is "+s);e=e||Math.random();var o=s===1?Y(i,[1,-1]):i,c=z.runKernelFunc(function(l){return l.multinomial(o,r,t,e)},{logits2D:o});return s===1?Y(c,[c.size]):c}var bN=U({multinomial_:wN});function xN(n,t){var e,r=R(n,"a","notEqual"),i=R(t,"b","notEqual");e=ct(r,i),r=e[0],i=e[1],it(r.shape,i.shape);var a=function(o){return o.notEqual(r,i)},s={a:r,b:i};return z.runKernelFunc(a,s,null,qm)}var Ao=U({notEqual_:xN});function SN(n){var t=R(n,"input","real"),e=function(i){return i.real(t)},r={input:t};return z.runKernelFunc(e,r,null,Xm)}var Qa=U({real_:SN});function LN(n){var t=R(n,"x","onesLike"),e=function(i,a){if(t.dtype==="complex64"){var s=Eh(Qa(t)),o=ke(wo(t));return xr(s,o)}return i.onesLike(t)},r={x:t};return z.runKernelFunc(e,r,null,Ql)}var Eh=U({onesLike_:LN});function IN(n,t){var e=R(n,"v1","outerProduct"),r=R(t,"v2","outerProduct");E(e.rank===1&&r.rank===1,function(){return"Error in outerProduct: inputs must be rank 1, but got ranks "+(e.rank+" and "+r.rank+".")});var i=Y(e,[-1,1]),a=Y(r,[1,-1]);return Ue(i,a)}var AN=U({outerProduct_:IN});function TN(n,t,e){e===void 0&&(e=0);var r=R(n,"x","pad");if(r.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var i=function(o,c){return c([r]),o.pad(r,t,e)},a={paddings:t,constantValue:e},s={x:r};return z.runKernelFunc(i,s,null,tu,a)}var oi=U({pad_:TN});function NN(n,t,e){return e===void 0&&(e=0),E(t.length===2,function(){return"Invalid number of paddings. Must be length of 2."}),oi(n,[t],e)}var _N=U({pad1d_:NN});function CN(n,t,e){return e===void 0&&(e=0),E(t.length===2&&t[0].length===2&&t[1].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),oi(n,t,e)}var RN=U({pad2d_:CN});function ON(n,t,e){return e===void 0&&(e=0),E(t.length===3&&t[0].length===2&&t[1].length===2&&t[2].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),oi(n,t,e)}var EN=U({pad3d_:ON});function DN(n,t,e){return e===void 0&&(e=0),E(t.length===4&&t[0].length===2&&t[1].length===2&&t[2].length===2&&t[3].length===2,function(){return"Invalid number of paddings. Must be length of 2 each."}),oi(n,t,e)}var kN=U({pad4d_:DN});function FN(n,t,e){var r=R(n,"x","spaceToBatchND");E(r.rank>=1+t.length,function(){return"input rank "+r.rank+" should be > than [blockShape] "+t.length}),E(e.length===t.length,function(){return"paddings.shape[0] "+e.length+" must be equal to [blockShape] "+t.length}),E(r.shape.reduce(function(o,c,l){return l>0&&l<=t.length?o&&(c+e[l-1][0]+e[l-1][1])%t[l-1]===0:o},!0),function(){return"input spatial dimensions "+r.shape.slice(1)+" with paddings "+e.toString()+" must be divisible by blockShapes "+t.toString()});var i=function(o){return o.spaceToBatchND(r,t,e)},a={x:r},s={blockShape:t,paddings:e};return z.runKernelFunc(i,a,null,Lu,s)}var To=U({spaceToBatchND_:FN});function BN(n,t,e,r,i,a){i==null&&(i=[1,1]),a==null&&(a=1),r===0&&(r="valid");var s=R(n,"x","maxPool"),o=s,c=!1;s.rank===3&&(c=!0,o=Y(s,[1,s.shape[0],s.shape[1],s.shape[2]])),E(qt(a,i),function(){return"Error in pool: Either strides or dilations must be 1. "+("Got strides "+a+" and dilations '"+i+"'")});var l=Yi(o.shape,t,a,i,r),u=[l.dilationHeight,l.dilationWidth],h;r==="same"?h=UN([l.filterHeight,l.filterWidth],u):h=[[0,0],[0,0]];var d=u[0]===1&&u[1]===1,p=WN([l.inHeight,l.inWidth],u,h),f=p[0],m=p[1],g=d?r:"valid",y=d?o:To(o,u,f),w=e==="avg"?function(){return wh(y,t,a,g)}:function(){return Rh(y,t,a,g)},b=w(),S=d?b:po(b,u,m);return c?Y(S,[S.shape[1],S.shape[2],S.shape[3]]):S}function WN(n,t,e){var r=e.map(function(u){return u[0]}),i=e.map(function(u){return u[1]}),a=n.concat(r,i),s=t.map(function(u,h){return(u-a[h]%u)%u}),o=i.map(function(u,h){return u+s[h]}),c=t.map(function(u,h){return[r[h],o[h]]}),l=t.map(function(u,h){return[0,s[h]]});return[c,l]}function UN(n,t){var e=n.map(function(s,o){return s+(s-1)*(t[o]-1)}),r=e.map(function(s){return s-1}),i=r.map(function(s){return Math.floor(s/2)}),a=r.map(function(s,o){return s-i[o]});return r.map(function(s,o){return[i[o],a[o]]})}var U0=U({pool_:BN});function zN(n,t){var e,r=R(n,"base","pow"),i=R(t,"exp","pow");e=ct(r,i),r=e[0],i=e[1];var a={a:r,b:i},s=function(o,c){var l=o.pow(r,i);return c([r,i,l]),l};return z.runKernelFunc(s,a,null,nu)}var ir=U({pow_:zN});function PN(n,t){var e=R(n,"x","prelu"),r=R(t,"alpha","prelu"),i=function(s,o){var c=s.prelu(e,r);return o([e,r]),c},a={x:e,alpha:r};return z.runKernelFunc(i,a,null,ru)}var Dh=U({prelu_:PN});function MN(n,t,e){t===void 0&&(t=null),e===void 0&&(e=!1);var r=R(n,"x","prod");r.dtype==="bool"&&(r=he(r,"int32"));var i=function(o){var c=rt(t,r.shape),l=bn(c,r.rank),u=c,h=r;l!=null&&(h=Nt(r,l),u=zn(u.length,r.rank));var d=o.prod(h,u);if(e){var p=cn(d.shape,c);d=Y(d,p)}return d},a={x:r},s={axis:t,keepDims:e};return z.runKernelFunc(i,a,null,Km,s)}var B0=U({prod_:MN});function HN(n,t,e){var r=pt(n),i=null;if(e==null||e==="float32")i=new Float32Array(r);else if(e==="int32")i=new Int32Array(r);else if(e==="bool")i=new Uint8Array(r);else throw new Error("Unknown data type "+e);for(var a=0;a>>0,d-=c,d*=c,c=d>>>0,d-=c,c+=d*4294967296}return(c>>>0)*23283064365386963e-26};return l}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.alea=s})(Zi,n,!1)}),GN=ci(function(n){(function(t,e,r){function i(o){var c=this,l="";c.x=0,c.y=0,c.z=0,c.w=0,c.next=function(){var h=c.x^c.x<<11;return c.x=c.y,c.y=c.z,c.z=c.w,c.w^=c.w>>>19^h^h>>>8},o===(o|0)?c.x=o:l+=o;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(typeof u=="object"&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.xor128=s})(Zi,n,!1)}),YN=ci(function(n){(function(t,e,r){function i(o){var c=this,l="";c.next=function(){var h=c.x^c.x>>>2;return c.x=c.y,c.y=c.z,c.z=c.w,c.w=c.v,(c.d=c.d+362437|0)+(c.v=c.v^c.v<<4^(h^h<<1))|0},c.x=0,c.y=0,c.z=0,c.w=0,c.v=0,o===(o|0)?c.x=o:l+=o;for(var u=0;u>>4),c.next()}function a(o,c){return c.x=o.x,c.y=o.y,c.z=o.z,c.w=o.w,c.v=o.v,c.d=o.d,c}function s(o,c){var l=new i(o),u=c&&c.state,h=function(){return(l.next()>>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(typeof u=="object"&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.xorwow=s})(Zi,n,!1)}),jN=ci(function(n){(function(t,e,r){function i(o){var c=this;c.next=function(){var u=c.x,h=c.i,d,p;return d=u[h],d^=d>>>7,p=d^d<<24,d=u[h+1&7],p^=d^d>>>10,d=u[h+3&7],p^=d^d>>>3,d=u[h+4&7],p^=d^d<<7,d=u[h+7&7],d=d^d<<13,p^=d^d<<9,u[h]=p,c.i=h+1&7,p};function l(u,h){var d,p,f=[];if(h===(h|0))p=f[0]=h;else for(h=""+h,d=0;d0;--d)u.next()}l(c,o)}function a(o,c){return c.x=o.x.slice(),c.i=o.i,c}function s(o,c){o==null&&(o=+new Date);var l=new i(o),u=c&&c.state,h=function(){return(l.next()>>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(u.x&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.xorshift7=s})(Zi,n,!1)}),KN=ci(function(n){(function(t,e,r){function i(o){var c=this;c.next=function(){var u=c.w,h=c.X,d=c.i,p,f;return c.w=u=u+1640531527|0,f=h[d+34&127],p=h[d=d+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,f=h[d]=f^p,c.i=d,f+(u^u>>>16)|0};function l(u,h){var d,p,f,m,g,y=[],w=128;for(h===(h|0)?(p=h,h=null):(h=h+"\0",p=0,w=Math.max(w,h.length)),f=0,m=-32;m>>15,p^=p<<4,p^=p>>>13,m>=0&&(g=g+1640531527|0,d=y[m&127]^=p+g,f=d==0?f+1:0);for(f>=128&&(y[(h&&h.length||0)&127]=-1),f=127,m=4*128;m>0;--m)p=y[f+34&127],d=y[f=f+1&127],p^=p<<13,d^=d<<17,p^=p>>>15,d^=d>>>12,y[f]=p^d;u.w=g,u.X=y,u.i=f}l(c,o)}function a(o,c){return c.i=o.i,c.w=o.w,c.X=o.X.slice(),c}function s(o,c){o==null&&(o=+new Date);var l=new i(o),u=c&&c.state,h=function(){return(l.next()>>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(u.X&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.xor4096=s})(Zi,n,!1)}),$N=ci(function(n){(function(t,e,r){function i(o){var c=this,l="";c.next=function(){var h=c.b,d=c.c,p=c.d,f=c.a;return h=h<<25^h>>>7^d,d=d-p|0,p=p<<24^p>>>8^f,f=f-h|0,c.b=h=h<<20^h>>>12^d,c.c=d=d-p|0,c.d=p<<16^d>>>16^f,c.a=f-h|0},c.a=0,c.b=0,c.c=2654435769|0,c.d=1367130551,o===Math.floor(o)?(c.a=o/4294967296|0,c.b=o|0):l+=o;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(typeof u=="object"&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.tychei=s})(Zi,n,!1)}),li=ci(function(n){(function(t,e){var r=this,i=256,a=6,s=52,o="random",c=e.pow(i,a),l=e.pow(2,s),u=l*2,h=i-1,d;function p(S,x,N){var I=[];x=x==!0?{entropy:!0}:x||{};var C=y(g(x.entropy?[S,b(t)]:S==null?w():S,3),I),O=new f(I),D=function(){for(var F=O.g(a),k=c,B=0;F=u;)F/=2,k/=2,B>>>=1;return(F+B)/k};return D.int32=function(){return O.g(4)|0},D.quick=function(){return O.g(4)/4294967296},D.double=D,y(b(O.S),t),(x.pass||N||function(F,k,B,V){return V&&(V.S&&m(V,O),F.state=function(){return m(O,{})}),B?(e[o]=F,k):F})(D,C,"global"in x?x.global:this==e,x.state)}e["seed"+o]=p;function f(S){var x,N=S.length,I=this,C=0,O=I.i=I.j=0,D=I.S=[];for(N||(S=[N++]);C=1||o===0);var c=Math.sqrt(-2*Math.log(o)/o);e=this.mean+this.stdDev*a*c,r=this.mean+this.stdDev*s*c,(!this.truncated||this.isValidTruncated(e))&&(i=!0)}return(!this.truncated||this.isValidTruncated(r))&&(this.nextVal=this.convertValue(r)),this.convertValue(e)},n.prototype.convertValue=function(t){return this.dtype==null||this.dtype==="float32"?t:Math.round(t)},n.prototype.isValidTruncated=function(t){return t<=this.upper&&t>=this.lower},n}(),JN=function(){function n(t,e,r,i){this.alpha=t,this.beta=1/e,this.dtype=r;var a=i||Math.random();this.randu=kh(a.toString()),this.randn=new Fh(0,1,r,!1,this.randu()),t<1?this.d=t+2/3:this.d=t-1/3,this.c=1/Math.sqrt(9*this.d)}return n.prototype.nextValue=function(){for(var t,e,r,i,a,s;;){do i=this.randn.nextValue(),s=1+this.c*i;while(s<=0);if(s*=s*s,t=i*i,e=1-.331*t*t,r=.5*t+this.d*(1-s+Math.log(s)),a=this.randu(),a1;if(s||o||c)return rr([0],r);var l=Math.abs(Math.ceil((t-n)/e)),u=Bi(l,r);t0?o+c:o});t[a]=n.shape[e]-s}E(n.shape[e]===t.reduce(function(o,c){return o+c}),function(){return"The sum of sizes must match the size of the axis dimension."}),r=t}return r}function U_(n,t,e){e===void 0&&(e=0);var r=R(n,"x","split"),i=function(o,c){var l=rt(e,r.shape)[0],u=Y0(r,t,l);return o.split(r,u,l)},a={x:r},s={numOrSizeSplits:t,axis:e};return z.runKernelFunc(i,a,null,Iu,s)}var ea=U({split_:U_});function B_(n,t){E(n.dtype==="float32",function(){return"The dtype for rfft() must be real value but got "+n.dtype});var e=n.shape[n.shape.length-1],r=n.size/e,i;if(t!=null&&te){var o=n.shape.map(function(y){return y});o[n.shape.length-1]=t-e,i=kt([n,rr(o)],n.shape.length-1),e=t}else i=n;var c=ke(i),l=Y(xr(i,c),[r,e]),u=No(l),h=Math.floor(e/2)+1,d=Qa(u),p=wo(u),f=ea(d,[h,e-h],d.shape.length-1),m=ea(p,[h,e-h],p.shape.length-1),g=i.shape.slice();return g[i.shape.length-1]=h,Y(xr(f[0],m[0]),g)}var _o=U({rfft_:B_});function z_(n){var t=R(n,"x","sqrt"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.sqrt(t);return i([t]),a},e,null,xu)}var Gt=U({sqrt_:z_});function P_(n,t){var e,r=R(n,"a","squaredDifference"),i=R(t,"b","squaredDifference");e=ct(r,i),r=e[0],i=e[1],it(r.shape,i.shape);var a=function(c,l){var u=c.squaredDifference(r,i);return l([r,i]),u},s={a:r,b:i},o={};return z.runKernelFunc(a,s,null,Tu,o)}var Co=U({squaredDifference_:P_});function M_(n,t){var e=R(n,"x","squeeze");return Y(e,$f(e.shape,t).newShape)}var Ro=U({squeeze_:M_});function H_(n,t){t===void 0&&(t=0);var e=qa(n,"tensors","stack");if(E(e.length>=1,function(){return"Pass at least one tensor to tf.stack"}),e.length===1)return In(e[0],t);var r=e[0].rank,i=e[0].shape,a=e[0].dtype;E(t<=r,function(){return"Axis must be <= rank of the tensor"}),e.forEach(function(o){Pe(i,o.shape,"All tensors passed to stack must have matching shapes"),E(a===o.dtype,function(){return"All tensors passed to stack must have matching dtypes"})});var s=e.map(function(o){return In(o,t)});return kt(s,t)}var ui=U({stack_:H_});function V_(n,t){t===void 0&&(t=0);var e=R(n,"x","step"),r={x:e},i={alpha:t};return z.runKernelFunc(function(a){return a.step(e,t)},r,null,Fu,i)}var ta=U({step_:V_});function q_(n,t,e,r,i,a,s,o,c){i===void 0&&(i=0),a===void 0&&(a=0),s===void 0&&(s=0),o===void 0&&(o=0),c===void 0&&(c=0);var l=R(n,"x","stridedSlice"),u=function(p){r==null&&(r=new Array(t.length));var f=co(s);if(f.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(s!==0&&o!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(s!==0&&c!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");var m=l.rank-t.length,g=co(o),y=l.shape.slice();g.forEach(function(F){t[F]=0,e[F]=1,y.splice(F,0,1)}),l=Y(l,y);var w=jg(l.shape,f,m,t,e,r,i,a,s),b=w.begin,S=w.end,x=w.strides;t=b,e=S,r=x;var N=co(c);N.forEach(function(F){e[F]=t[F]+1,r[F]=1});var I=Bg(t,e,r),C=I.filter(function(F,k){return N.indexOf(k)===-1}),O=r.every(function(F){return F===1});if(O)return Y(Me(l,t,I),C);var D=p.stridedSlice(l,t,e,r);return Y(D,C)},h={x:l},d={begin:t,end:e,strides:r,beginMask:i,endMask:a,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:c};return z.runKernelFunc(u,h,null,ng,d)}var j0=U({stridedSlice_:q_});function G_(n){var t=R(n,"x","tan"),e={x:t};return z.runKernelFunc(function(r,i){var a=r.tan(t);return i([t]),a},e,null,_u)}var K0=U({tan_:G_});function ns(n,t,e){if(Xr(n),t!=null&&t.length!==2)throw new Error("tensor2d() requires shape to have two numbers");var r=Un(n,e);if(r.length!==2&&r.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Sr(n,t,r,e)}function Y_(n,t,e){if(Xr(n),t!=null&&t.length!==4)throw new Error("tensor4d() requires shape to have four numbers");var r=Un(n,e);if(r.length!==4&&r.length!==1)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Sr(n,t,r,e)}function j_(n,t,e){if(Xr(n),t!=null&&t.length!==5)throw new Error("tensor5d() requires shape to have five numbers");var r=Un(n,e);if(r.length!==5&&r.length!==1)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Sr(n,t,r,e)}function K_(n,t,e){if(Xr(n),t!=null&&t.length!==6)throw new Error("tensor6d() requires shape to have six numbers");var r=Un(n,e);if(r.length!==6&&r.length!==1)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return t=t||r,Sr(n,t,r,e)}function $_(n,t,e){t===void 0&&(t=1),e===void 0&&(e=!0);var r=R(n,"x","topk");if(r.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");var i=r.shape[r.shape.length-1];if(t>i)throw new Error("'k' passed to topk() must be <= the last dimension ("+i+") "+("but got "+t));var a={x:r},s={k:t,sorted:e},o=z.runKernelFunc(function(u){return u.topk(r,t,e)},a,null,rg,s),c=o[0],l=o[1];return{values:c,indices:l}}var $0=U({topk_:$_});function X_(n,t,e,r,i){if(t===void 0&&(t=0),e===void 0&&(e=1),r!=null&&r==="bool")throw new Error("Unsupported data type $ { dtype }");for(var a=new Fh(t,e,r,!0,i),s=Bn(n,r),o=0;o0,function(){return"The input tensor must be at least 1D"});var r={x:e},i={axis:t},a=z.runKernel(ig,r,i),s=a[0],o=a[1];return{values:s,indices:o}}var X0=U({unique_:Z_});function Q_(n,t,e){var r=R(n,"x","unsortedSegmentSum"),i=R(t,"segmentIds","unsortedSegmentSum","int32");E(ot(e),function(){return"numSegments must be of dtype int"});var a={x:r,segmentIds:i},s={numSegments:e},o=function(c,l){var u=c.unsortedSegmentSum(r,i,e);return l([i]),u};return z.runKernelFunc(o,a,null,Du,s)}var Hh=U({unsortedSegmentSum_:Q_});function eC(n,t){t===void 0&&(t=0);var e=R(n,"x","unstack");E(t>=-e.shape.length&&t0,function(){return"mask cannot be scalar"}),Pe(o.slice(a,a+s),i.shape,"mask's shape must match the first K dimensions of tensor's shape,"),c=1,l=a;l2)throw new Error("sparseIndices should be a scalar, vector, or matrix,"+(" but got shape "+n.shape+"."));var i=n.rank>0?n.shape[0]:1,a=n.rank>1?n.shape[1]:1;if(e.length!==a)throw new Error("outputShape has incorrect number of elements:,"+(" "+e.length+", should be: "+a+"."));var s=t.size;if(!(t.rank===0||t.rank===1&&s===i))throw new Error("sparseValues has incorrect shape "+(t.shape+", should be [] or ["+i+"]"));if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}function TC(n,t,e,r){r===void 0&&(r=0);var i=R(n,"sparseIndices","sparseToDense","int32"),a=R(t,"sparseValues","sparseToDense"),s=R(r,"defaultValue","sparseToDense",a.dtype);AC(i,a,e,s);var o={sparseIndices:i,sparseValues:a,defaultValue:s},c={outputShape:e};return z.runKernelFunc(function(l){return l.sparseToDense(i,a,e,s)},o,null,tg,c)}var NC=U({sparseToDense_:TC});function _C(n,t){var e=R(t,"indices","gatherND","int32"),r=R(n,"x","gatherND"),i=function(s){return s.gatherND(r,e)},a={params:r,indices:e};return z.runKernelFunc(i,a,null,Cm)}var CC=U({gatherND_:_C});function RC(n,t){if(t==null)return n.shape.slice();if(wn(n.shape,t))return t;if(n.shape.length===t.length){for(var e=[],r=0;r=0&&t<1,function(){return"rate must be a float in the range [0, 1), but got "+t+"."}),t===0)return n instanceof j?i.clone():i;var a=RC(i,e),s=1-t,o=Ne(yo(ge(z0(a,0,1,"float32",r),s)),s);return Z(i,o)}var EC=U({dropout_:OC});function my(n){return Math.floor(Math.pow(2,Math.ceil(Math.log(n)/Math.log(2))))}function Vh(n,t,e){for(var r=1-n%2,i=new Float32Array(n),a=0;a1,function(){return"inTopK() expects the predictions to be of rank 2 or higher, "+("but got "+r.rank)}),E(r.rank-1===i.rank,function(){return"predictions rank should be 1 larger than targets rank, but got predictions rank "+(r.rank+" and targets rank "+i.rank)}),Pe(r.shape.slice(0,r.shape.length-1),i.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),a=r.shape[r.shape.length-1],E(e>0&&e<=a,function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last "+("dimension ("+a+"), but got "+e)}),[4,r.data()];case 1:return s=y.sent(),[4,i.data()];case 2:for(o=y.sent(),c=[s.length/a,a],l=c[0],u=c[1],h=$s("bool",l),d=0;d0&&(e=_e(e,r)),Y(e,n.shape)}function Fo(n,t,e){if(t==="linear")return n;if(t==="relu")return es(n);if(t==="elu")return Lh(n);if(t==="relu6")return Uh(n);if(t==="prelu")return Dh(n,e);throw new Error("Unknown fused activation "+t+".")}var Wo=function(n,t){var e=n>0;return!e||t==="linear"};function WC(n){var t=n.x,e=n.filter,r=n.strides,i=n.pad,a=n.dataFormat,s=a===void 0?"NHWC":a,o=n.dilations,c=o===void 0?[1,1]:o,l=n.dimRoundingMode,u=n.bias,h=n.activation,d=h===void 0?"linear":h,p=n.preluActivationWeights;if(d=d||"linear",Wo(z.state.gradientDepth,d)===!1){var f=Ki(t,e,r,i,s,c,l);return u!=null&&(f=ge(f,u)),Fo(f,d,p)}var m=R(t,"x","conv2d"),g=R(e,"filter","conv2d"),y=m,w=!1;m.rank===3&&(w=!0,y=Y(m,[1,m.shape[0],m.shape[1],m.shape[2]])),E(y.rank===4,function(){return"Error in fused conv2d: input must be rank 4, but got rank "+(y.rank+".")}),E(g.rank===4,function(){return"Error in fused conv2d: filter must be rank 4, but got rank "+(g.rank+".")}),l!=null&&E(ot(i),function(){return"Error in fused conv2d: pad must be an integer when using, "+("dimRoundingMode "+l+" but got pad "+i+".")}),E(y.shape[3]===g.shape[2],function(){return"Error in conv2d: depth of input ("+y.shape[3]+") must match "+("input depth for filter "+g.shape[2]+".")}),E(qt(r,c),function(){return"Error in conv2D: Either strides or dilations must be 1. "+("Got strides "+r+" and dilations '"+c+"'")}),E(s==="NHWC",function(){return"Error in conv2d: got dataFormat of "+s+" but only NHWC is currently supported."});var b=xn(y.shape,g.shape,r,c,i,l),S;u!=null&&(S=R(u,"bias","fused conv2d"),S=ct(S,m)[0],it(b.outShape,S.shape));var x;p!=null&&(x=R(p,"prelu weights","fused conv2d"));var N=function(k,B){var V=B,P=V[0],q=V[1],K=V[2],G=V[3],H=Do(k,K,d);E(Nr(c),function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 "+("are not yet supported in gradients. Got dilations '"+c+"'")});var J=bh(q.shape,H,P,r,i),$=qh(q,H,P.shape,r,i),ee=[J,$];if(G!=null){var te=ko(G,H);ee.push(te)}return ee},I=function(k){var B=k.fusedConv2d({input:y,filter:g,convInfo:b,bias:S,activation:d,preluActivationWeights:x});return B},C={x:y,filter:g,bias:S,preluActivationWeights:x},O={strides:r,pad:i,dataFormat:s,dilations:c,dimRoundingMode:l,activation:d};if(u==null){var D=Pn(function(k,B,V){var P=z.runKernelFunc(I,C,null,Bu,O);return V([B,k,P]),w&&(P=Y(P,[P.shape[1],P.shape[2],P.shape[3]])),{value:P,gradFunc:N}});return D(y,g)}else{var F=Pn(function(k,B,V,P){var q=z.runKernelFunc(I,C,null,Bu,O);return P([B,k,q,V]),w&&(q=Y(q,[q.shape[1],q.shape[2],q.shape[3]])),{value:q,gradFunc:N}});return F(y,g,S)}}var UC=U({fusedConv2d_:WC});function BC(n,t,e,r,i,a,s){a===void 0&&(a=[1,1]);var o=n;n.rank===3&&(o=Y(n,[1,n.shape[0],n.shape[1],n.shape[2]]));var c=t;c.rank===3&&(c=Y(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var l=function(d){var p=xn(n.shape,e,r,a,i,s,!0);return d.depthwiseConv2DDerFilter(o,c,p)},u={x:o,dy:c},h={strides:r,pad:i,dimRoundingMode:s,dilations:a,filterShape:e};return z.runKernelFunc(l,u,null,wm,h)}var gy=U({depthwiseConv2dNativeBackpropFilter_:BC});function zC(n,t,e,r,i,a,s){a===void 0&&(a=[1,1]);var o=t,c=!1;t.rank===3&&(c=!0,o=Y(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var l=function(p){var f=xn(n,e.shape,r,a,i,s,!0);return p.depthwiseConv2DDerInput(o,e,f)},u={dy:o,filter:e},h={strides:r,pad:i,dimRoundingMode:s,dilations:a,inputShape:n},d=z.runKernelFunc(l,u,null,bm,h);return c?Y(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var yy=U({depthwiseConv2dNativeBackpropInput_:zC});function PC(n){var t=n.x,e=n.filter,r=n.strides,i=n.pad,a=n.dataFormat,s=a===void 0?"NHWC":a,o=n.dilations,c=o===void 0?[1,1]:o,l=n.dimRoundingMode,u=n.bias,h=n.activation,d=h===void 0?"linear":h,p=n.preluActivationWeights;if(Wo(z.state.gradientDepth,d)===!1){var f=Xa(t,e,r,i,s,c,l);return u!=null&&(f=ge(f,u)),Fo(f,d,p)}var m=R(t,"x","depthwiseConv2d"),g=R(e,"filter","depthwiseConv2d"),y=m,w=!1;m.rank===3&&(w=!0,y=Y(m,[1,m.shape[0],m.shape[1],m.shape[2]])),E(y.rank===4,function(){return"Error in fused depthwiseConv2d: input must be rank 4, but got "+("rank "+y.rank+".")}),E(g.rank===4,function(){return"Error in fused depthwiseConv2d: filter must be rank 4, "+("but got rank "+g.rank+".")}),E(y.shape[3]===g.shape[2],function(){return"Error in fused depthwiseConv2d: number of input channels "+("("+y.shape[3]+") must match the inChannels dimension in ")+("filter "+g.shape[2]+".")}),c==null&&(c=[1,1]),E(qt(r,c),function(){return"Error in fused depthwiseConv2d: Either strides or dilations must "+("be 1. Got strides "+r+" and dilations '"+c+"'")}),l!=null&&E(ot(i),function(){return"Error in fused depthwiseConv2d: pad must be an integer when "+("using dimRoundingMode "+l+" but got pad "+i+".")});var b=xn(y.shape,g.shape,r,c,i,l,!0),S;u!=null&&(S=R(u,"bias","fused conv2d"),S=ct(S,m)[0],it(b.outShape,S.shape));var x;p!=null&&(x=R(p,"prelu weights","fused depthwiseConv2d"));var N=function(k,B){E(Nr(c),function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations "+("'"+c+"'")});var V=B[0],P=B[1],q=B[2],K=B[3],G=Do(k,q,d),H=yy(P.shape,G,V,r,i,c,l),J=gy(P,G,V.shape,r,i,c,l);if(K!=null){var $=ko(S,G);return[H,J,$]}return[H,J]},I=function(k){var B=k.fusedDepthwiseConv2D({input:y,filter:g,convInfo:b,bias:S,activation:d,preluActivationWeights:x});return B},C={x:y,filter:g,bias:S,preluActivationWeights:x},O={strides:r,pad:i,dataFormat:s,dilations:c,dimRoundingMode:l,activation:d};if(u==null){var D=Pn(function(k,B,V){var P=z.runKernelFunc(I,C,null,zu,O);return V([B,k,P]),w&&(P=Y(P,[P.shape[1],P.shape[2],P.shape[3]])),{value:P,gradFunc:N}});return D(y,g)}else{var F=Pn(function(k,B,V,P){var q=z.runKernelFunc(I,C,null,zu,O);return P([B,k,q,V]),w&&(q=Y(q,[q.shape[1],q.shape[2],q.shape[3]])),{value:q,gradFunc:N}});return F(y,g,S)}}var MC=U({fusedDepthwiseConv2d_:PC});function HC(n){var t,e=n.a,r=n.b,i=n.transposeA,a=i===void 0?!1:i,s=n.transposeB,o=s===void 0?!1:s,c=n.bias,l=n.activation,u=l===void 0?"linear":l,h=n.preluActivationWeights;if(Wo(z.state.gradientDepth,u)===!1){var d=Ue(e,r,a,o);return c!=null&&(d=ge(d,c)),Fo(d,u,h)}var p=R(e,"a","fused matMul"),f=R(r,"b","fused matMul");t=ct(p,f),p=t[0],f=t[1];var m=a?p.shape[p.rank-2]:p.shape[p.rank-1],g=o?f.shape[f.rank-1]:f.shape[f.rank-2],y=a?p.shape[p.rank-1]:p.shape[p.rank-2],w=o?f.shape[f.rank-2]:f.shape[f.rank-1],b=p.shape.slice(0,-2),S=f.shape.slice(0,-2),x=pt(b),N=pt(S);E(p.rank>=2&&f.rank>=2&&p.rank===f.rank,function(){return"Error in fused matMul: inputs must have the same rank of at least "+("2, got ranks "+p.rank+" and "+f.rank+".")}),E(wn(b,S),function(){return"Error in fused matMul: outer dimensions ("+b+") and ("+(S+") of Tensors with shapes "+p.shape+" and ")+(f.shape+" must match.")}),E(m===g,function(){return"Error in fused matMul: inner shapes ("+m+") and ("+(g+") of Tensors with shapes "+p.shape+" and ")+(f.shape+" and transposeA="+a)+(" and transposeB="+o+" must match.")});var I=p.shape.slice(0,-2).concat([y,w]),C=a?Y(p,[x,m,y]):Y(p,[x,y,m]),O=o?Y(f,[N,w,g]):Y(f,[N,g,w]),D;c!=null&&(D=R(c,"bias","fused matMul"),D=ct(D,p)[0],it(I,D.shape));var F;h!=null&&(F=R(h,"prelu weights","fused matMul"));var k=function(G,H){var J=H[0],$=H[1],ee=H[2],te=H[3],ne=Do(Y(G,ee.shape),ee,u),re,ie;if(!a&&!o?(re=Ue(ne,$,!1,!0),ie=Ue(J,ne,!0,!1)):!a&&o?(re=Ue(ne,$,!1,!1),ie=Ue(ne,J,!0,!1)):a&&!o?(re=Ue($,ne,!1,!0),ie=Ue(J,ne,!1,!1)):(re=Ue($,ne,!0,!0),ie=Ue(ne,J,!0,!0)),c!=null){var oe=ko(te,ne);return[re,ie,oe]}else return[re,ie]},B=function(G){var H=G.fusedBatchMatMul({a:C,b:O,transposeA:a,transposeB:o,bias:D,activation:u,preluActivationWeights:F});return H},V={a:C,b:O,bias:D,preluActivationWeights:F},P={transposeA:a,transposeB:o,activation:u};if(c==null){var q=Pn(function(G,H,J){var $=z.runKernelFunc(B,V,null,Uu,P);return J([G,H,$]),{value:Y($,I),gradFunc:k}});return q(C,O)}else{var K=Pn(function(G,H,J,$){var ee=z.runKernelFunc(B,V,null,Uu,P);return $([G,H,ee,J]),{value:Y(ee,I),gradFunc:k}});return K(C,O,D)}}var VC=U({fusedMatMul_:HC});var qC={__proto__:null,conv2d:UC,depthwiseConv2d:MC,matMul:VC};function GC(n){return Vh(n,.54,.46)}var YC=U({hammingWindow_:GC});function jC(n){return Vh(n,.5,.5)}var vy=U({hannWindow_:jC});function KC(n,t,e,r,i){r===void 0&&(r=!1),i===void 0&&(i=0);for(var a=0,s=[];a+t<=n.size;)s.push(Me(n,a,t)),a+=e;if(r)for(;a=1&&r[1]>=1,function(){return"cropSize must be atleast [1,1], but was "+r}),E(i==="bilinear"||i==="nearest",function(){return"method must be bilinear or nearest, but was "+i});var u=function(f){return f.cropAndResize(s,o,c,r,i,a)},h={image:s,boxes:o,boxInd:c},d={method:i,extrapolationValue:a,cropSize:r},p=z.runKernelFunc(u,h,null,ym,d);return p}var ZC=U({cropAndResize_:JC});function QC(n){var t=R(n,"image","flipLeftRight","float32");E(t.rank===4,function(){return"Error in flipLeftRight: image must be rank 4,"+("but got rank "+t.rank+".")});var e={image:t},r=z.runKernel(_m,e,{});return r}var eR=U({flipLeftRight_:QC});function tR(n,t,e,r){e===void 0&&(e=0),r===void 0&&(r=.5);var i=R(n,"image","rotateWithOffset","float32");E(i.rank===4,function(){return"Error in rotateWithOffset: image must be rank 4,"+("but got rank "+i.rank+".")});var a={image:i},s={radians:t,fillValue:e,center:r},o=z.runKernel(ag,a,s);return o}var nR=U({rotateWithOffset_:tR});function na(n,t,e,r,i,a){r==null&&(r=.5),i==null&&(i=Number.NEGATIVE_INFINITY),a==null&&(a=0);var s=n.shape[0];return e=Math.min(e,s),E(0<=r&&r<=1,function(){return"iouThreshold must be in [0, 1], but was '"+r+"'"}),E(n.rank===2,function(){return"boxes must be a 2D tensor, but was of rank '"+n.rank+"'"}),E(n.shape[1]===4,function(){return"boxes must have 4 columns, but 2nd dimension was "+n.shape[1]}),E(t.rank===1,function(){return"scores must be a 1D tensor"}),E(t.shape[0]===s,function(){return"scores has incompatible shape with boxes. Expected "+s+", "+("but was "+t.shape[0])}),E(0<=a&&a<=1,function(){return"softNmsSigma must be in [0, 1], but was '"+a+"'"}),{maxOutputSize:e,iouThreshold:r,scoreThreshold:i,softNmsSigma:a}}function rR(n,t,e,r,i){r===void 0&&(r=.5),i===void 0&&(i=Number.NEGATIVE_INFINITY);var a=R(n,"boxes","nonMaxSuppression"),s=R(t,"scores","nonMaxSuppression"),o=na(a,s,e,r,i);e=o.maxOutputSize,r=o.iouThreshold,i=o.scoreThreshold;var c={maxOutputSize:e,iouThreshold:r,scoreThreshold:i};return z.runKernelFunc(function(l){return l.nonMaxSuppression(a,s,e,r,i)},{boxes:a,scores:s},null,Gm,c)}var iR=U({nonMaxSuppression_:rR});function sR(n,t,e){var r=aR(n,t,e),i=r<0?-(r+1):r;n.splice(i,0,t)}function aR(n,t,e){return cR(n,t,e||oR)}function oR(n,t){return n>t?1:n>>1);var o=e(t,n[a]);o>0?r=a+1:(i=a,s=!o)}return s?r:-r-1}function by(n,t,e,r,i){return Gh(n,t,e,r,i,0).selectedIndices}function xy(n,t,e,r,i,a){return Gh(n,t,e,r,i,0,!1,a,!0)}function Sy(n,t,e,r,i,a){return Gh(n,t,e,r,i,a,!0)}function Gh(n,t,e,r,i,a,s,o,c){s===void 0&&(s=!1),o===void 0&&(o=!1),c===void 0&&(c=!1);for(var l=[],u=0;ui&&l.push({score:t[u],boxIndex:u,suppressBeginIndex:0});l.sort(Ly);for(var h=a>0?-.5/a:0,d=[],p=[];d.length0;){var f=l.pop(),m=f.score,g=f.boxIndex,y=f.suppressBeginIndex;if(m=y;--b){var S=lR(n,g,d[b]);if(S>=r){w=!0;break}if(f.score=f.score*uR(r,h,S),f.score<=i)break}f.suppressBeginIndex=d.length,w||(f.score===m?(d.push(g),p.push(f.score)):f.score>i&&sR(l,f,Ly))}var x=d.length,N=e-x;o&&N>0&&(d.push.apply(d,new Array(N).fill(0)),p.push.apply(p,new Array(N).fill(0)));var I={selectedIndices:Qi(d,"int32")};return s&&(I.selectedScores=Qi(p,"float32")),c&&(I.validOutputs=Se(x,"int32")),I}function lR(n,t,e){var r=n.subarray(t*4,t*4+4),i=n.subarray(e*4,e*4+4),a=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),o=Math.max(r[0],r[2]),c=Math.max(r[1],r[3]),l=Math.min(i[0],i[2]),u=Math.min(i[1],i[3]),h=Math.max(i[0],i[2]),d=Math.max(i[1],i[3]),p=(o-a)*(c-s),f=(h-l)*(d-u);if(p<=0||f<=0)return 0;var m=Math.max(a,l),g=Math.max(s,u),y=Math.min(o,h),w=Math.min(c,d),b=Math.max(y-m,0)*Math.max(w-g,0);return b/(p+f-b)}function uR(n,t,e){var r=Math.exp(t*e*e);return e<=n?r:0}function Ly(n,t){return n.score-t.score||n.score===t.score&&t.boxIndex-n.boxIndex}function hR(n,t,e,r,i){return r===void 0&&(r=.5),i===void 0&&(i=Number.NEGATIVE_INFINITY),pe(this,void 0,void 0,function(){var a,s,o,c,l,u,h;return fe(this,function(d){switch(d.label){case 0:return a=R(n,"boxes","nonMaxSuppressionAsync"),s=R(t,"scores","nonMaxSuppressionAsync"),o=na(a,s,e,r,i),e=o.maxOutputSize,r=o.iouThreshold,i=o.scoreThreshold,[4,Promise.all([a.data(),s.data()])];case 1:return c=d.sent(),l=c[0],u=c[1],h=by(l,u,e,r,i),a!==n&&a.dispose(),s!==t&&s.dispose(),[2,h]}})})}var dR=hR;function pR(n,t,e,r,i,a){r===void 0&&(r=.5),i===void 0&&(i=Number.NEGATIVE_INFINITY),a===void 0&&(a=0);var s=R(n,"boxes","nonMaxSuppression"),o=R(t,"scores","nonMaxSuppression"),c=na(s,o,e,r,i,a);e=c.maxOutputSize,r=c.iouThreshold,i=c.scoreThreshold,a=c.softNmsSigma;var l={boxes:s,scores:o},u={maxOutputSize:e,iouThreshold:r,scoreThreshold:i,softNmsSigma:a},h=z.runKernel(jm,l,u);return{selectedIndices:h[0],selectedScores:h[1]}}var fR=U({nonMaxSuppressionWithScore_:pR});function mR(n,t,e,r,i,a){return r===void 0&&(r=.5),i===void 0&&(i=Number.NEGATIVE_INFINITY),a===void 0&&(a=0),pe(this,void 0,void 0,function(){var s,o,c,l,u,h,d;return fe(this,function(p){switch(p.label){case 0:return s=R(n,"boxes","nonMaxSuppressionAsync"),o=R(t,"scores","nonMaxSuppressionAsync"),c=na(s,o,e,r,i,a),e=c.maxOutputSize,r=c.iouThreshold,i=c.scoreThreshold,a=c.softNmsSigma,[4,Promise.all([s.data(),o.data()])];case 1:return l=p.sent(),u=l[0],h=l[1],d=Sy(u,h,e,r,i,a),s!==n&&s.dispose(),o!==t&&o.dispose(),[2,d]}})})}var gR=mR;function yR(n,t,e,r,i,a){r===void 0&&(r=.5),i===void 0&&(i=Number.NEGATIVE_INFINITY),a===void 0&&(a=!1);var s=R(n,"boxes","nonMaxSuppression"),o=R(t,"scores","nonMaxSuppression"),c=na(s,o,e,r,i,null),l=c.maxOutputSize,u=c.iouThreshold,h=c.scoreThreshold,d={boxes:s,scores:o},p={maxOutputSize:l,iouThreshold:u,scoreThreshold:h,padToMaxOutputSize:a},f=z.runKernel(Ym,d,p);return{selectedIndices:f[0],validOutputs:f[1]}}var vR=U({nonMaxSuppressionPadded_:yR});function wR(n,t,e,r,i,a){return r===void 0&&(r=.5),i===void 0&&(i=Number.NEGATIVE_INFINITY),a===void 0&&(a=!1),pe(this,void 0,void 0,function(){var s,o,c,l,u,h,d,p,f,m;return fe(this,function(g){switch(g.label){case 0:return s=R(n,"boxes","nonMaxSuppressionAsync"),o=R(t,"scores","nonMaxSuppressionAsync"),c=na(s,o,e,r,i,null),l=c.maxOutputSize,u=c.iouThreshold,h=c.scoreThreshold,[4,Promise.all([s.data(),o.data()])];case 1:return d=g.sent(),p=d[0],f=d[1],m=xy(p,f,l,u,h,a),s!==n&&s.dispose(),o!==t&&o.dispose(),[2,m]}})})}var bR=wR;function xR(n,t,e){e===void 0&&(e=!1);var r=R(n,"images","resizeBilinear");E(r.rank===3||r.rank===4,function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got "+("rank "+r.rank+".")}),E(t.length===2,function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+(t+".")});var i=r,a=!1;r.rank===3&&(a=!0,i=Y(r,[1,r.shape[0],r.shape[1],r.shape[2]]));var s=t[0],o=t[1],c=function(d,p){return p([i]),d.resizeBilinear(i,s,o,e)},l={images:i},u={alignCorners:e,size:t},h=z.runKernelFunc(c,l,null,cu,u);return a?Y(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var Iy=U({resizeBilinear_:xR});function SR(n,t,e){e===void 0&&(e=!1);var r=R(n,"images","resizeNearestNeighbor");E(r.rank===3||r.rank===4,function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got "+("rank "+r.rank+".")}),E(t.length===2,function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+(t+".")}),E(r.dtype==="float32"||r.dtype==="int32",function(){return"`images` must have `int32` or `float32` as dtype"});var i=r,a=!1;r.rank===3&&(a=!0,i=Y(r,[1,r.shape[0],r.shape[1],r.shape[2]]));var s=t[0],o=t[1],c={images:i},l={alignCorners:e,size:t},u=function(d,p){return p([i]),d.resizeNearestNeighbor(i,s,o,e)},h=z.runKernelFunc(u,c,null,ou,l);return a?Y(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var Ay=U({resizeNearestNeighbor_:SR});function LR(n,t,e){E(t%1===0,function(){return"bandPart(): numLower must be an integer, got "+t+"."}),E(e%1===0,function(){return"bandPart(): numUpper must be an integer, got "+e+"."});var r=R(n,"a","bandPart");E(r.rank>=2,function(){return"bandPart(): Rank must be at least 2, got "+r.rank+"."});var i=r.shape,a=r.shape.slice(-2),s=a[0],o=a[1];if(!(t<=s))throw new Error("bandPart(): numLower ("+t+")"+(" must not be greater than the number of rows ("+s+")."));if(!(e<=o))throw new Error("bandPart(): numUpper ("+e+")"+(" must not be greater than the number of columns ("+o+")."));t<0&&(t=s),e<0&&(e=o);var c=Y(Wh(0,s,1,"int32"),[-1,1]),l=Wh(0,o,1,"int32"),u=be(c,l),h=si(ri(u,Se(+t,"int32")),ni(u,Se(-e,"int32"))),d=rr([s,o],r.dtype);return Y(ui(Oo(Y(r,[-1,s,o])).map(function(p){return Sn(h,p,d)})),i)}var IR=U({bandPart_:LR});function AR(n){var t;if(Array.isArray(n)){t=!1,E(n!=null&&n.length>0,function(){return"Gram-Schmidt process: input must not be null, undefined, or empty"});for(var e=n[0].shape[0],r=function(c){E(n[c].shape[0]===e,function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: "+("("+n[c].shape[0]+" vs. "+e+")")})},i=1;i0)for(var u=0;u=2,function(){return"qr() requires input tensor to have a rank >= 2, but got rank "+n.rank}),n.rank===2)return Ty(n,t);var e=n.shape.slice(0,n.shape.length-2).reduce(function(c,l){return c*l}),r=Oo(Y(n,[e,n.shape[n.shape.length-2],n.shape[n.shape.length-1]]),0),i=[],a=[];r.forEach(function(c){var l=Ty(c,t),u=l[0],h=l[1];i.push(u),a.push(h)});var s=Y(ui(i,0),n.shape),o=Y(ui(a,0),n.shape);return[s,o]}function Ty(n,t){return t===void 0&&(t=!1),z.tidy(function(){E(n.shape.length===2,function(){return"qr2d() requires a 2D Tensor, but got a "+n.shape.length+"D Tensor."});for(var e=n.shape[0],r=n.shape[1],i=A0(e),a=Qr(n),s=ns([[1]],[1,1]),o=Qr(s),c=e>=r?r:e,l=function(h){var d,p=a,f=o,m=i;d=z.tidy(function(){var g=Me(a,[h,h],[e-h,1]),y=Eo(g),w=Me(a,[h,h],[1,1]),b=Sn(_r(w,0),ns([[-1]]),ns([[1]])),S=be(w,Z(b,y)),x=Ne(g,S);x.shape[0]===1?o=Qr(s):o=kt([s,Me(x,[1,0],[x.shape[0]-1,x.shape[1]])],0);var N=Lt(Ne(Ue(b,S),y)),I=Me(a,[h,0],[e-h,r]),C=Z(N,o),O=Nt(o);if(h===0)a=be(I,Ue(C,Ue(O,I)));else{var D=be(I,Ue(C,Ue(O,I)));a=kt([Me(a,[0,0],[h,r]),D],0)}var F=Nt(C),k=Me(i,[0,h],[e,i.shape[1]-h]);if(h===0)i=be(k,Ue(Ue(k,o),F));else{var B=be(k,Ue(Ue(k,o),F));i=kt([Me(i,[0,0],[e,h]),B],1)}return[o,a,i]}),o=d[0],a=d[1],i=d[2],Vt([p,f,m])},u=0;ur&&(i=Me(i,[0,0],[e,r]),a=Me(a,[0,0],[r,r])),[i,a]})}var _R=U({qr_:NR});(function(n){n[n.NONE=0]="NONE",n[n.MEAN=1]="MEAN",n[n.SUM=2]="SUM",n[n.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"})(A.Reduction||(A.Reduction={}));function CR(n,t,e){e===void 0&&(e=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var r=R(n,"losses","computeWeightedLoss"),i=null;t!=null&&(i=R(t,"weights","computeWeightedLoss"));var a=i==null?r:Z(r,i);if(e===A.Reduction.NONE)return a;if(e===A.Reduction.SUM)return _e(a);if(e===A.Reduction.MEAN){if(i==null)return Za(a);var s=r.size/i.size,o=Ne(_e(a),_e(i));return s>1?Ne(o,Se(s)):o}if(e===A.Reduction.SUM_BY_NONZERO_WEIGHTS){if(i==null)return Ne(_e(a),Se(r.size));var c=Z(i,Ji(r.shape)),l=he(_e(Ao(c,Se(0))),"float32");return Ne(_e(a),l)}throw Error("Unknown reduction: "+e)}var sr=U({computeWeightedLoss_:CR});function RR(n,t,e,r){r===void 0&&(r=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=R(n,"labels","absoluteDifference"),a=R(t,"predictions","absoluteDifference"),s=null;e!=null&&(s=R(e,"weights","absoluteDifference")),Pe(i.shape,a.shape,"Error in absoluteDifference: ");var o=Zt(be(i,a));return sr(o,s,r)}var OR=U({absoluteDifference_:RR});function ER(n,t,e,r,i){i===void 0&&(i=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=R(n,"labels","cosineDistance"),s=R(t,"predictions","cosineDistance"),o=null;r!=null&&(o=R(r,"weights","cosineDistance")),Pe(a.shape,s.shape,"Error in cosineDistance: ");var c=Se(1),l=be(c,_e(Z(a,s),e,!0));return sr(l,o,i)}var DR=U({cosineDistance_:ER});function kR(n,t,e,r){r===void 0&&(r=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=R(n,"labels","hingeLoss"),a=R(t,"predictions","hingeLoss"),s=null;e!=null&&(s=R(e,"weights","hingeLoss")),Pe(i.shape,a.shape,"Error in hingeLoss: ");var o=Se(1);i=be(Z(Se(2),i),o);var c=es(be(o,Z(i,a)));return sr(c,s,r)}var FR=U({hingeLoss_:kR});function WR(n,t,e,r,i){r===void 0&&(r=1),i===void 0&&(i=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=R(n,"labels","huberLoss"),s=R(t,"predictions","huberLoss"),o=null;e!=null&&(o=R(e,"weights","huberLoss")),Pe(a.shape,s.shape,"Error in huberLoss: ");var c=Se(r),l=Zt(be(s,a)),u=Io(l,c),h=be(l,u),d=ge(Z(Se(.5),$e(u)),Z(c,h));return sr(d,o,i)}var UR=U({huberLoss_:WR});function BR(n,t,e,r,i){r===void 0&&(r=1e-7),i===void 0&&(i=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=R(n,"labels","logLoss"),s=R(t,"predictions","logLoss"),o=null;e!=null&&(o=R(e,"weights","logLoss")),Pe(a.shape,s.shape,"Error in logLoss: ");var c=Se(1),l=Se(r),u=Lt(Z(a,ii(ge(s,l)))),h=Z(be(c,a),ii(ge(be(c,s),l))),d=be(u,h);return sr(d,o,i)}var zR=U({logLoss_:BR});function PR(n,t,e,r){r===void 0&&(r=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=R(n,"labels","meanSquaredError"),a=R(t,"predictions","meanSquaredError"),s=null;e!=null&&(s=R(e,"weights","meanSquaredError")),Pe(i.shape,a.shape,"Error in meanSquaredError: ");var o=Co(i,a);return sr(o,s,r)}var MR=U({meanSquaredError_:PR});function HR(n,t){var e=R(n,"labels","sigmoidCrossEntropyWithLogits"),r=R(t,"logits","sigmoidCrossEntropyWithLogits");Pe(e.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var i=es(r),a=Z(r,e),s=Th(Ln(Lt(Zt(r))));return ge(be(i,a),s)}function VR(n,t,e,r,i){r===void 0&&(r=0),i===void 0&&(i=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=R(n,"multiClassLabels","sigmoidCrossEntropy"),s=R(t,"logits","sigmoidCrossEntropy"),o=null;if(e!=null&&(o=R(e,"weights","sigmoidCrossEntropy")),Pe(a.shape,s.shape,"Error in sigmoidCrossEntropy: "),r>0){var c=Se(r),l=Se(1),u=Se(.5);a=ge(Z(a,be(l,c)),Z(u,c))}var h=HR(a,s);return sr(h,o,i)}var qR=U({sigmoidCrossEntropy_:VR});function GR(n,t,e){if(e===void 0&&(e=-1),e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet "+("supported. Labels / logits was rank "+t.rank+" ")+("and dim was "+e));var r=Pn(function(i,a,s){var o=!0,c=_h(a,[e],o),l=be(he(a,"float32"),c);s([i,l]);var u=Lt(Z(l,i)),h=_e(u,[e]),d=function(p,f){var m=f[0],g=f[1],y=cn(p.shape,[e]);return[Z(Y(p,y),be(he(m,"float32"),Ln(g))),Z(Y(p,y),be(Ln(g),he(m,"float32")))]};return{value:h,gradFunc:d}});return r(n,t)}function YR(n,t,e,r,i){r===void 0&&(r=0),i===void 0&&(i=A.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=R(n,"onehotLabels","softmaxCrossEntropy"),s=R(t,"logits","softmaxCrossEntropy"),o=null;if(e!=null&&(o=R(e,"weights","softmaxCrossEntropy")),Pe(a.shape,s.shape,"Error in softmaxCrossEntropy: "),r>0){var c=Se(r),l=Se(1),u=Se(a.shape[1]);a=ge(Z(a,be(l,c)),Ne(c,u))}var h=GR(a,s);return sr(h,o,i)}var jR=U({softmaxCrossEntropy_:YR});var KR={fft:No,ifft:ts,rfft:_o,irfft:Mh},$R={hammingWindow:YC,hannWindow:vy,frame:wy,stft:XC},XR={flipLeftRight:eR,resizeNearestNeighbor:Ay,resizeBilinear:Iy,rotateWithOffset:nR,cropAndResize:ZC,nonMaxSuppression:iR,nonMaxSuppressionAsync:dR,nonMaxSuppressionWithScore:fR,nonMaxSuppressionWithScoreAsync:gR,nonMaxSuppressionPadded:vR,nonMaxSuppressionPaddedAsync:bR},JR={bandPart:IR,gramSchmidt:TR,qr:_R},ZR={absoluteDifference:OR,computeWeightedLoss:sr,cosineDistance:DR,hingeLoss:FR,huberLoss:UR,logLoss:zR,meanSquaredError:MR,sigmoidCrossEntropy:qR,softmaxCrossEntropy:jR};var Cr=function(n){er(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.minimize=function(e,r,i){r===void 0&&(r=!1);var a=this.computeGradients(e,i),s=a.value,o=a.grads;if(i!=null){var c=i.map(function(l){return{name:l.name,tensor:o[l.name]}});this.applyGradients(c)}else this.applyGradients(o);return Vt(o),r?s:(s.dispose(),null)},Object.defineProperty(t.prototype,"iterations",{get:function(){return this.iterations_==null&&(this.iterations_=0),this.iterations_},enumerable:!0,configurable:!0}),t.prototype.incrementIterations=function(){this.iterations_=this.iterations+1},t.prototype.computeGradients=function(e,r){return E0(e,r)},t.prototype.dispose=function(){this.iterations_!=null&&Vt(this.iterations_)},t.prototype.saveIterations=function(){return pe(this,void 0,void 0,function(){return fe(this,function(e){return this.iterations_==null&&(this.iterations_=0),[2,{name:"iter",tensor:Se(this.iterations_,"int32")}]})})},t.prototype.getWeights=function(){return pe(this,void 0,void 0,function(){return fe(this,function(e){throw new Error("getWeights() is not implemented for this optimizer yet.")})})},t.prototype.setWeights=function(e){return pe(this,void 0,void 0,function(){return fe(this,function(r){throw new Error("setWeights() is not implemented for this optimizer class "+(""+this.getClassName()))})})},t.prototype.extractIterations=function(e){return pe(this,void 0,void 0,function(){var r;return fe(this,function(i){switch(i.label){case 0:return r=this,[4,e[0].tensor.data()];case 1:return r.iterations_=i.sent()[0],[2,e.slice(1)]}})})},t}($g);Object.defineProperty(Cr,Symbol.hasInstance,{value:function(n){return n.minimize!=null&&n.computeGradients!=null&&n.applyGradients!=null}});var Yh=function(n){er(t,n);function t(e,r,i){i===void 0&&(i=null);var a=n.call(this)||this;return a.learningRate=e,a.rho=r,a.epsilon=i,a.accumulatedGrads=[],a.accumulatedUpdates=[],i==null&&(a.epsilon=z.backend.epsilon()),a}return t.prototype.applyGradients=function(e){var r=this,i=Array.isArray(e)?e.map(function(a){return a.name}):Object.keys(e);i.forEach(function(a,s){var o=z.registeredVariables[a],c=!1;r.accumulatedGrads[s]==null&&(r.accumulatedGrads[s]={originalName:a+"/accum_grad",variable:xt(function(){return ke(o).variable(c)})}),r.accumulatedUpdates[s]==null&&(r.accumulatedUpdates[s]={originalName:a+"/accum_var",variable:xt(function(){return ke(o).variable(c)})});var l=Array.isArray(e)?e[s].tensor:e[a];if(l==null)return;var u=r.accumulatedGrads[s].variable,h=r.accumulatedUpdates[s].variable;xt(function(){var d=ge(Z(u,r.rho),Z($e(l),1-r.rho)),p=Z(Ne(Gt(ge(h,r.epsilon)),Gt(ge(u,r.epsilon))),l),f=ge(Z(h,r.rho),Z($e(p),1-r.rho));u.assign(d),h.assign(f);var m=ge(Z(p,-r.learningRate),o);o.assign(m)})}),this.incrementIterations()},t.prototype.dispose=function(){this.accumulatedUpdates!=null&&(Vt(this.accumulatedGrads.map(function(e){return e.variable})),Vt(this.accumulatedUpdates.map(function(e){return e.variable})))},t.prototype.getWeights=function(){return pe(this,void 0,void 0,function(){var e;return fe(this,function(r){switch(r.label){case 0:return e=this.accumulatedGrads.concat(this.accumulatedUpdates),[4,this.saveIterations()];case 1:return[2,[r.sent()].concat(e.map(function(i){return{name:i.originalName,tensor:i.variable}}))]}})})},t.prototype.setWeights=function(e){return pe(this,void 0,void 0,function(){var r,i;return fe(this,function(a){switch(a.label){case 0:return[4,this.extractIterations(e)];case 1:return e=a.sent(),r=e.length/2,i=!1,this.accumulatedGrads=e.slice(0,r).map(function(s){return{originalName:s.name,variable:s.tensor.variable(i)}}),this.accumulatedUpdates=e.slice(r,r*2).map(function(s){return{originalName:s.name,variable:s.tensor.variable(i)}}),[2]}})})},t.prototype.getConfig=function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}},t.fromConfig=function(e,r){return new e(r.learningRate,r.rho,r.epsilon)},t.className="Adadelta",t}(Cr);Tr(Yh);var jh=function(n){er(t,n);function t(e,r){r===void 0&&(r=.1);var i=n.call(this)||this;return i.learningRate=e,i.initialAccumulatorValue=r,i.accumulatedGrads=[],i}return t.prototype.applyGradients=function(e){var r=this,i=Array.isArray(e)?e.map(function(a){return a.name}):Object.keys(e);i.forEach(function(a,s){var o=z.registeredVariables[a];if(r.accumulatedGrads[s]==null){var c=!1;r.accumulatedGrads[s]={originalName:a+"/accumulator",variable:xt(function(){return Ih(o.shape,r.initialAccumulatorValue).variable(c)})}}var l=Array.isArray(e)?e[s].tensor:e[a];if(l==null)return;var u=r.accumulatedGrads[s].variable;xt(function(){var h=ge(u,$e(l));u.assign(h);var d=ge(Z(Ne(l,Gt(ge(h,z.backend.epsilon()))),-r.learningRate),o);o.assign(d)})}),this.incrementIterations()},t.prototype.dispose=function(){this.accumulatedGrads!=null&&Vt(this.accumulatedGrads.map(function(e){return e.variable}))},t.prototype.getWeights=function(){return pe(this,void 0,void 0,function(){return fe(this,function(e){switch(e.label){case 0:return[4,this.saveIterations()];case 1:return[2,[e.sent()].concat(this.accumulatedGrads.map(function(r){return{name:r.originalName,tensor:r.variable}}))]}})})},t.prototype.setWeights=function(e){return pe(this,void 0,void 0,function(){var r;return fe(this,function(i){switch(i.label){case 0:return[4,this.extractIterations(e)];case 1:return e=i.sent(),r=!1,this.accumulatedGrads=e.map(function(a){return{originalName:a.name,variable:a.tensor.variable(r)}}),[2]}})})},t.prototype.getConfig=function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}},t.fromConfig=function(e,r){return new e(r.learningRate,r.initialAccumulatorValue)},t.className="Adagrad",t}(Cr);Tr(jh);var Kh=function(n){er(t,n);function t(e,r,i,a){a===void 0&&(a=null);var s=n.call(this)||this;return s.learningRate=e,s.beta1=r,s.beta2=i,s.epsilon=a,s.accumulatedFirstMoment=[],s.accumulatedSecondMoment=[],xt(function(){s.accBeta1=Se(r).variable(),s.accBeta2=Se(i).variable()}),a==null&&(s.epsilon=z.backend.epsilon()),s}return t.prototype.applyGradients=function(e){var r=this,i=Array.isArray(e)?e.map(function(a){return a.name}):Object.keys(e);xt(function(){var a=be(1,r.accBeta1),s=be(1,r.accBeta2);i.forEach(function(o,c){var l=z.registeredVariables[o],u=!1;r.accumulatedFirstMoment[c]==null&&(r.accumulatedFirstMoment[c]={originalName:o+"/m",variable:xt(function(){return ke(l).variable(u)})}),r.accumulatedSecondMoment[c]==null&&(r.accumulatedSecondMoment[c]={originalName:o+"/v",variable:xt(function(){return ke(l).variable(u)})});var h=Array.isArray(e)?e[c].tensor:e[o];if(h==null)return;var d=r.accumulatedFirstMoment[c].variable,p=r.accumulatedSecondMoment[c].variable,f=ge(Z(d,r.beta1),Z(h,1-r.beta1)),m=ge(Z(p,r.beta2),Z($e(h),1-r.beta2)),g=Ne(f,a),y=Ne(m,s);d.assign(f),p.assign(m);var w=ge(Z(Ne(g,ge(Gt(y),r.epsilon)),-r.learningRate),l);l.assign(w)}),r.accBeta1.assign(Z(r.accBeta1,r.beta1)),r.accBeta2.assign(Z(r.accBeta2,r.beta2))}),this.incrementIterations()},t.prototype.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&Vt(this.accumulatedFirstMoment.map(function(e){return e.variable})),this.accumulatedSecondMoment!=null&&Vt(this.accumulatedSecondMoment.map(function(e){return e.variable}))},t.prototype.getWeights=function(){return pe(this,void 0,void 0,function(){var e;return fe(this,function(r){switch(r.label){case 0:return e=this.accumulatedFirstMoment.concat(this.accumulatedSecondMoment),[4,this.saveIterations()];case 1:return[2,[r.sent()].concat(e.map(function(i){return{name:i.originalName,tensor:i.variable}}))]}})})},t.prototype.setWeights=function(e){return pe(this,void 0,void 0,function(){var r,i,a=this;return fe(this,function(s){switch(s.label){case 0:return[4,this.extractIterations(e)];case 1:return e=s.sent(),xt(function(){a.accBeta1.assign(ir(a.beta1,a.iterations_+1)),a.accBeta2.assign(ir(a.beta2,a.iterations_+1))}),r=e.length/2,i=!1,this.accumulatedFirstMoment=e.slice(0,r).map(function(o){return{originalName:o.name,variable:o.tensor.variable(i)}}),this.accumulatedSecondMoment=e.slice(r,r*2).map(function(o){return{originalName:o.name,variable:o.tensor.variable(i)}}),[2]}})})},t.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}},t.fromConfig=function(e,r){return new e(r.learningRate,r.beta1,r.beta2,r.epsilon)},t.className="Adam",t}(Cr);Tr(Kh);var $h=function(n){er(t,n);function t(e,r,i,a,s){a===void 0&&(a=null),s===void 0&&(s=0);var o=n.call(this)||this;return o.learningRate=e,o.beta1=r,o.beta2=i,o.epsilon=a,o.decay=s,o.accumulatedFirstMoment=[],o.accumulatedWeightedInfNorm=[],xt(function(){o.iteration=Se(0).variable(),o.accBeta1=Se(r).variable()}),a==null&&(o.epsilon=z.backend.epsilon()),o}return t.prototype.applyGradients=function(e){var r=this,i=Array.isArray(e)?e.map(function(a){return a.name}):Object.keys(e);xt(function(){var a=be(1,r.accBeta1),s=Ne(-r.learningRate,ge(Z(r.iteration,r.decay),1));i.forEach(function(o,c){var l=z.registeredVariables[o],u=!1;r.accumulatedFirstMoment[c]==null&&(r.accumulatedFirstMoment[c]={originalName:o+"/m",variable:ke(l).variable(u)}),r.accumulatedWeightedInfNorm[c]==null&&(r.accumulatedWeightedInfNorm[c]={originalName:o+"/v",variable:ke(l).variable(u)});var h=Array.isArray(e)?e[c].tensor:e[o];if(h==null)return;var d=r.accumulatedFirstMoment[c].variable,p=r.accumulatedWeightedInfNorm[c].variable,f=ge(Z(d,r.beta1),Z(h,1-r.beta1)),m=Z(p,r.beta2),g=Zt(h),y=Xi(m,g);d.assign(f),p.assign(y);var w=ge(Z(Ne(s,a),Ne(f,ge(y,r.epsilon))),l);l.assign(w)}),r.iteration.assign(ge(r.iteration,1)),r.accBeta1.assign(Z(r.accBeta1,r.beta1))}),this.incrementIterations()},t.prototype.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&Vt(this.accumulatedFirstMoment.map(function(e){return e.variable})),this.accumulatedWeightedInfNorm!=null&&Vt(this.accumulatedWeightedInfNorm.map(function(e){return e.variable}))},t.prototype.getWeights=function(){return pe(this,void 0,void 0,function(){return fe(this,function(e){throw new Error("getWeights() is not implemented for Adamax yet.")})})},t.prototype.setWeights=function(e){return pe(this,void 0,void 0,function(){return fe(this,function(r){throw new Error("setWeights() is not implemented for Adamax yet.")})})},t.prototype.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}},t.fromConfig=function(e,r){return new e(r.learningRate,r.beta1,r.beta2,r.epsilon,r.decay)},t.className="Adamax",t}(Cr);Tr($h);var Uo=function(n){er(t,n);function t(e){var r=n.call(this)||this;return r.learningRate=e,r.setLearningRate(e),r}return t.prototype.applyGradients=function(e){var r=this,i=Array.isArray(e)?e.map(function(a){return a.name}):Object.keys(e);i.forEach(function(a,s){var o=Array.isArray(e)?e[s].tensor:e[a];if(o==null)return;var c=z.registeredVariables[a];xt(function(){var l=ge(Z(r.c,o),c);c.assign(l)})}),this.incrementIterations()},t.prototype.setLearningRate=function(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=Zg(Se(-e))},t.prototype.dispose=function(){this.c.dispose()},t.prototype.getWeights=function(){return pe(this,void 0,void 0,function(){return fe(this,function(e){switch(e.label){case 0:return[4,this.saveIterations()];case 1:return[2,[e.sent()]]}})})},t.prototype.setWeights=function(e){return pe(this,void 0,void 0,function(){return fe(this,function(r){switch(r.label){case 0:return[4,this.extractIterations(e)];case 1:if(e=r.sent(),e.length!==0)throw new Error("SGD optimizer does not have settable weights.");return[2]}})})},t.prototype.getConfig=function(){return{learningRate:this.learningRate}},t.fromConfig=function(e,r){return new e(r.learningRate)},t.className="SGD",t}(Cr);Tr(Uo);var Xh=function(n){er(t,n);function t(e,r,i){i===void 0&&(i=!1);var a=n.call(this,e)||this;return a.learningRate=e,a.momentum=r,a.useNesterov=i,a.accumulations=[],a.m=Se(a.momentum),a}return t.prototype.applyGradients=function(e){var r=this,i=Array.isArray(e)?e.map(function(a){return a.name}):Object.keys(e);i.forEach(function(a,s){var o=z.registeredVariables[a];if(r.accumulations[s]==null){var c=!1;r.accumulations[s]={originalName:a+"/momentum",variable:xt(function(){return ke(o).variable(c)})}}var l=r.accumulations[s].variable,u=Array.isArray(e)?e[s].tensor:e[a];if(u==null)return;xt(function(){var h,d=ge(Z(r.m,l),u);r.useNesterov?h=ge(Z(r.c,ge(u,Z(d,r.m))),o):h=ge(Z(r.c,d),o),l.assign(d),o.assign(h)})}),this.incrementIterations()},t.prototype.dispose=function(){this.m.dispose(),this.accumulations!=null&&Vt(this.accumulations.map(function(e){return e.variable}))},t.prototype.setMomentum=function(e){this.momentum=e},t.prototype.getWeights=function(){return pe(this,void 0,void 0,function(){return fe(this,function(e){switch(e.label){case 0:return[4,this.saveIterations()];case 1:return[2,[e.sent()].concat(this.accumulations.map(function(r){return{name:r.originalName,tensor:r.variable}}))]}})})},t.prototype.setWeights=function(e){return pe(this,void 0,void 0,function(){var r;return fe(this,function(i){switch(i.label){case 0:return[4,this.extractIterations(e)];case 1:return e=i.sent(),r=!1,this.accumulations=e.map(function(a){return{originalName:a.name,variable:a.tensor.variable(r)}}),[2]}})})},t.prototype.getConfig=function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}},t.fromConfig=function(e,r){return new e(r.learningRate,r.momentum,r.useNesterov)},t.className="Momentum",t}(Uo);Tr(Xh);var Jh=function(n){er(t,n);function t(e,r,i,a,s){r===void 0&&(r=.9),i===void 0&&(i=0),a===void 0&&(a=null),s===void 0&&(s=!1);var o=n.call(this)||this;if(o.learningRate=e,o.decay=r,o.momentum=i,o.epsilon=a,o.accumulatedMeanSquares=[],o.accumulatedMoments=[],o.accumulatedMeanGrads=[],o.centered=s,a==null&&(o.epsilon=z.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.");return o}return t.prototype.applyGradients=function(e){var r=this,i=Array.isArray(e)?e.map(function(a){return a.name}):Object.keys(e);i.forEach(function(a,s){var o=z.registeredVariables[a],c=!1;r.accumulatedMeanSquares[s]==null&&(r.accumulatedMeanSquares[s]={originalName:a+"/rms",variable:xt(function(){return ke(o).variable(c)})}),r.accumulatedMoments[s]==null&&(r.accumulatedMoments[s]={originalName:a+"/momentum",variable:xt(function(){return ke(o).variable(c)})}),r.accumulatedMeanGrads[s]==null&&r.centered&&(r.accumulatedMeanGrads[s]={originalName:a+"/mg",variable:xt(function(){return ke(o).variable(c)})});var l=Array.isArray(e)?e[s].tensor:e[a];if(l==null)return;var u=r.accumulatedMeanSquares[s].variable,h=r.accumulatedMoments[s].variable;xt(function(){var d=ge(Z(u,r.decay),Z($e(l),1-r.decay));if(r.centered){var p=r.accumulatedMeanGrads[s].variable,f=ge(Z(p,r.decay),Z(l,1-r.decay)),m=Ne(Z(l,r.learningRate),Gt(be(d,ge($e(f),r.epsilon)))),g=ge(Z(h,r.momentum),m);u.assign(d),p.assign(f),h.assign(g);var y=be(o,g);o.assign(y)}else{var w=ge(Z(u,r.decay),Z($e(l),1-r.decay)),g=ge(Z(h,r.momentum),Ne(Z(l,r.learningRate),Gt(ge(w,r.epsilon))));u.assign(w),h.assign(g);var y=be(o,g);o.assign(y)}})}),this.incrementIterations()},t.prototype.dispose=function(){this.accumulatedMeanSquares!=null&&Vt(this.accumulatedMeanSquares.map(function(e){return e.variable})),this.accumulatedMeanGrads!=null&&this.centered&&Vt(this.accumulatedMeanGrads.map(function(e){return e.variable})),this.accumulatedMoments!=null&&Vt(this.accumulatedMoments.map(function(e){return e.variable}))},t.prototype.getWeights=function(){return pe(this,void 0,void 0,function(){var e;return fe(this,function(r){switch(r.label){case 0:return e=this.accumulatedMeanSquares.concat(this.accumulatedMoments),this.centered&&e.push.apply(e,this.accumulatedMeanGrads),[4,this.saveIterations()];case 1:return[2,[r.sent()].concat(e.map(function(i){return{name:i.originalName,tensor:i.variable}}))]}})})},t.prototype.setWeights=function(e){return pe(this,void 0,void 0,function(){var r,i;return fe(this,function(a){switch(a.label){case 0:return[4,this.extractIterations(e)];case 1:return e=a.sent(),r=this.centered?e.length/3:e.length/2,i=!1,this.accumulatedMeanSquares=e.slice(0,r).map(function(s){return{originalName:s.name,variable:s.tensor.variable(i)}}),this.accumulatedMoments=e.slice(r,r*2).map(function(s){return{originalName:s.name,variable:s.tensor.variable(i)}}),this.centered&&(this.accumulatedMeanGrads=e.slice(r*2,r*3).map(function(s){return{originalName:s.name,variable:s.tensor.variable(i)}})),[2]}})})},t.prototype.getConfig=function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}},t.fromConfig=function(e,r){return new e(r.learningRate,r.decay,r.momentum,r.epsilon,r.centered)},t.className="RMSProp",t}(Cr);Tr(Jh);var hi=function(){function n(){}return n.sgd=function(t){return new Uo(t)},n.momentum=function(t,e,r){return r===void 0&&(r=!1),new Xh(t,e,r)},n.rmsprop=function(t,e,r,i,a){return e===void 0&&(e=.9),r===void 0&&(r=0),i===void 0&&(i=null),a===void 0&&(a=!1),new Jh(t,e,r,i,a)},n.adam=function(t,e,r,i){return t===void 0&&(t=.001),e===void 0&&(e=.9),r===void 0&&(r=.999),i===void 0&&(i=null),new Kh(t,e,r,i)},n.adadelta=function(t,e,r){return t===void 0&&(t=.001),e===void 0&&(e=.95),r===void 0&&(r=null),new Yh(t,e,r)},n.adamax=function(t,e,r,i,a){return t===void 0&&(t=.002),e===void 0&&(e=.9),r===void 0&&(r=.999),i===void 0&&(i=null),a===void 0&&(a=0),new $h(t,e,r,i,a)},n.adagrad=function(t,e){return e===void 0&&(e=.1),new jh(t,e)},n}();var QR={sgd:hi.sgd,momentum:hi.momentum,adadelta:hi.adadelta,adagrad:hi.adagrad,rmsprop:hi.rmsprop,adamax:hi.adamax,adam:hi.adam};var e3=function(){return typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:function(n){return n()}}();function t3(){return new Promise(function(n){return e3(function(){return n()})})}function n3(n,t,e){var r=e*(typeof n=="number"?n:n[0]),i=t*(typeof n=="number"?n:n[1]);return[r,i]}function r3(n,t,e,r){r===void 0&&(r=!0);var i=[];if(r)i=i.concat(t.slice(0)),i.push(n[0]/e),i=i.concat(n.slice(1));else{i=i.concat(n[0]);for(var a=t.length,s=0;s=t*2+1||i%2===1?s.push(i):a.push(i);r.push.apply(r,a),r.push(0),r.push.apply(r,s)}return r}function a3(n,t,e,r){r===void 0&&(r=!0);var i=[];r?i.push(n[0]/e):i.push(n[0]*e);for(var a=1;a0&&(o=_e(o,c)),Y(o,e.shape)},s=function(){var o=n,c=St(r.shape,i);return c.length>0&&(o=_e(o,c)),Y(o,r.shape)};return{a,b:s}}};var W3={kernelName:tl,saveAllInputs:!0,gradFunc:function(n,t){var e={};return t.forEach(function(r,i){e[i]=function(){return n.clone()}}),e}};var U3={kernelName:nl,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return ke(e)}}}};var B3={kernelName:rl,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return ke(e)}}}};var z3={kernelName:il,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Ne(n,Gt(be(Se(1),$e(he(e,"float32")))))}}}};var P3={kernelName:al,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){var r=Gt(ge(Se(1),$e(he(e,"float32"))));return Ne(n,r)}}}};var M3={kernelName:cl,inputsToSave:["a","b"],gradFunc:function(n,t){var e=t[0],r=t[1],i=it(e.shape,r.shape),a=function(){var o=ge($e(e),$e(r)),c=Z(n,Ne(r,o)),l=St(e.shape,i);return l.length>0&&(c=_e(c,l)),Y(c,e.shape)},s=function(){var o=ge($e(e),$e(r)),c=Lt(Z(n,Ne(e,o))),l=St(r.shape,i);return l.length>0&&(c=_e(c,l)),Y(c,r.shape)};return{a,b:s}}};var H3={kernelName:sl,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Ne(n,ge($e(he(e,"float32")),1))}}}};var V3={kernelName:ol,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Ne(n,be(Se(1),$e(he(e,"float32"))))}}}};function q3(n,t,e,r,i,a,s){i===void 0&&(i=[1,1,1]);var o=R(n,"dy","avgPool3dBackprop"),c=R(t,"input","avgPool3dBackprop"),l=o,u=c,h=!1;c.rank===4&&(h=!0,l=Y(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),u=Y(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),E(l.rank===5,function(){return"Error in avgPool3dBackprop: dy must be rank 5 but got rank "+(l.rank+".")}),E(u.rank===5,function(){return"Error in avgPool3dBackprop: input must be rank 5 but got rank "+(u.rank+".")}),E(qt(r,i),function(){return"Error in avgPool3dBackprop: Either strides or dilations "+("must be 1. Got strides "+r+" and dilations '"+i+"'")}),s!=null&&E(ot(a),function(){return"Error in maxPool3dBackprop: pad must be an integer when "+("using, dimRoundingMode "+s+" but got pad "+a+".")});var d=function(g){var y=Ka(u.shape,e,r,i,a,s);return g.avgPool3dBackprop(l,u,y)},p={dy:l,input:u},f={filterSize:e,strides:r,dilations:i,pad:a,dimRoundingMode:s},m=z.runKernelFunc(d,p,null,dm,f);return h?Y(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}var G3=U({avgPool3dBackprop_:q3});var Y3={kernelName:ul,inputsToSave:["x"],gradFunc:function(n,t,e){var r=t[0],i=e,a=i.filterSize,s=i.strides,o=i.dilations,c=i.pad,l=i.dimRoundingMode,u=o==null?[1,1,1]:o;return{x:function(){return G3(n,r,a,s,u,c,l)}}}};function j3(n,t,e,r,i){var a=R(n,"dy","avgPoolBackprop"),s=R(t,"input","avgPoolBackprop");E(s.rank===a.rank,function(){return"Rank of input ("+s.rank+") does not match rank of dy ("+a.rank+")"});var o=s,c=a,l=!1;s.rank===3&&(l=!0,o=Y(s,[1,s.shape[0],s.shape[1],s.shape[2]]),c=Y(a,[1,a.shape[0],a.shape[1],a.shape[2]])),E(c.rank===4,function(){return"Error in avgPoolBackprop: dy must be rank 4 but got rank "+(c.rank+".")}),E(o.rank===4,function(){return"Error in avgPoolBackprop: input must be rank 4 but got rank "+(o.rank+".")});var u=function(f){var m=Yi(o.shape,e,r,1,i);return f.avgPoolBackprop(c,o,m)},h={dy:c,input:o},d={filterSize:e,strides:r,pad:i},p=z.runKernelFunc(u,h,null,hm,d);return l?Y(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var K3=U({avgPoolBackprop_:j3});var $3={kernelName:ll,inputsToSave:["x"],gradFunc:function(n,t,e){var r=t[0],i=e,a=i.filterSize,s=i.strides,o=i.pad;return{x:function(){return K3(n,r,a,s,o)}}}};var X3={kernelName:hl,inputsToSave:["a","b"],gradFunc:function(n,t,e){var r=t[0],i=t[1],a=e,s=a.transposeA,o=a.transposeB;return!s&&!o?{a:function(){return Ue(n,i,!1,!0)},b:function(){return Ue(r,n,!0,!1)}}:!s&&o?{a:function(){return Ue(n,i,!1,!1)},b:function(){return Ue(n,r,!0,!1)}}:s&&!o?{a:function(){return Ue(i,n,!1,!0)},b:function(){return Ue(r,n,!1,!1)}}:{a:function(){return Ue(i,n,!0,!0)},b:function(){return Ue(n,r,!0,!0)}}}};var J3={kernelName:dl,gradFunc:function(n,t,e){var r=e,i=r.blockShape,a=r.crops;return{x:function(){return To(n,i,a)}}}};var Z3={kernelName:pl,gradFunc:function(n,t,e){for(var r=e,i=r.inputShape,a=r.shape,s=Array.from(a),o=i.length-1;o>=0;o--)if(i[o]===a[o])s[o]=1;else if(i[o]!==1)throw new Error("broadcastTo(): ["+i+"] cannot be broadcast to ["+a+"].");for(var c=[],o=0;o1&&c.push(o);return{x:function(){return _e(n,c,!0)}}}};var Q3={kernelName:Qs,gradFunc:function(n){return{x:function(){return n.clone()}}}};var eO={kernelName:fl,gradFunc:function(n){return{x:function(){return ke(n)}}}};var tO={kernelName:ml,inputsToSave:["x"],gradFunc:function(n,t,e){var r=t[0],i=e,a=i.clipValueMin,s=i.clipValueMax;return{x:function(){return Sn(si(ni(r,a),ri(r,s)),n,ke(n))}}}};var nO={kernelName:gl,saveAllInputs:!0,gradFunc:function(n,t,e){var r=t.map(function(c){return c.shape}),i=e.axis,a=rt(i,t[0].shape)[0],s=r.map(function(c){return c[a]}),o=ea(n,s,a);return o.map(function(c){return function(){return c}})}};var rO={kernelName:yl,inputsToSave:["x","filter"],gradFunc:function(n,t,e){var r=t,i=r[0],a=r[1],s=e,o=s.dilations,c=s.strides,l=s.pad,u=s.dataFormat;return E(Nr(o),function(){return"Error in gradient of conv2D: dilation rates greater than 1 "+("are not yet supported in gradients. Got dilations '"+o+"'")}),{x:function(){return bh(i.shape,n,a,c,l,u)},filter:function(){return qh(i,n,a.shape,c,l,u)}}}};var iO={kernelName:vl,inputsToSave:["dy","filter"],gradFunc:function(n,t,e){var r=t,i=r[0],a=r[1],s=e,o=s.strides,c=s.pad,l=s.dataFormat,u=s.dimRoundingMode;return{dy:function(){return Ki(n,a,o,c,l,1,u)},filter:function(){return qh(n,i,a.shape,o,c,l,u)}}}};function aO(n,t,e,r,i){var a=n;n.rank===4&&(a=Y(n,[1,n.shape[0],n.shape[1],n.shape[2],n.shape[3]]));var s=t;s.rank===4&&(s=Y(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),E(a.rank===5,function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+(a.shape+".")}),E(s.rank===5,function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+(s.shape+".")}),E(e.length===5,function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+(e+".")}),E(a.shape[4]===e[3],function(){return"Error in conv3dDerFilter: depth of input "+a.shape[4]+") must "+("match input depth in filter ("+e[3]+".")}),E(s.shape[4]===e[4],function(){return"Error in conv3dDerFilter: depth of dy ("+s.shape[4]+") must "+("match output depth for filter ("+e[4]+").")});var o=function(u){var h=1,d=ja(a.shape,e,r,h,i);return u.conv3dDerFilter(a,s,d)},c={x:a,dy:s},l={strides:r,pad:i,filterShape:e};return z.runKernelFunc(o,c,null,mm,l)}var sO=U({conv3DBackpropFilter_:aO});var oO={kernelName:wl,inputsToSave:["x","filter"],gradFunc:function(n,t,e){var r=e,i=r.dilations,a=r.strides,s=r.pad;E(Nr(i),function(){return"Error in gradient of conv3D: dilation rates greater than 1 are "+("not yet supported in gradients. Got dilations '"+i+"'")});var o=t[0],c=t[1];return{x:function(){return v0(o.shape,n,c,a,s)},filter:function(){return sO(o,n,c.shape,a,s)}}}};var cO={kernelName:bl,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(Lt(zh(he(e,"float32"))),n)}}}};var lO={kernelName:xl,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(Ph(he(e,"float32")),n)}}}};var uO={kernelName:Sl,inputsToSave:["x"],gradFunc:function(n,t,e){var r=t[0],i=e,a=i.axis,s=i.exclusive,o=i.reverse;return{x:function(){var c=bn([a],r.rank),l=Sh(n,a,s,!o);return c!=null&&(l=Nt(l,c)),l}}}};var hO={kernelName:Ll,inputsToSave:["x","filter"],gradFunc:function(n,t,e){var r=e,i=r.dilations,a=r.strides,s=r.pad,o=r.dimRoundingMode,c=i==null?[1,1]:i;E(Nr(c),function(){return"Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations "+("'"+c+"'")});var l=t,u=l[0],h=l[1];return E(u.rank===4,function(){return"Error in gradient of depthwiseConv2dNative: input must be "+("rank 4, but got rank "+u.rank+".")}),E(h.rank===4,function(){return"Error in gradient of depthwiseConv2dNative: filter must be "+("rank 4, but got rank "+h.rank+".")}),E(u.shape[3]===h.shape[2],function(){return"Error in gradient of depthwiseConv2d: number of input "+("channels ("+u.shape[3]+") must match the inChannels dimension ")+("in filter "+h.shape[2]+".")}),E(qt(a,c),function(){return"Error in gradient of depthwiseConv2d: Either strides or "+("dilations must be 1. Got strides "+a+" and dilations ")+("'"+c+"'.")}),o!=null&&E(ot(s),function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+("dimRoundingMode "+o+" but got pad "+s+".")}),{x:function(){return yy(u.shape,n,h,a,s,i,o)},filter:function(){return gy(u,n,h.shape,a,s,i,o)}}}};var dO={kernelName:Il,inputsToSave:["x","filter"],gradFunc:function(n,t,e){var r=t,i=r[0],a=r[1],s={x:i,filter:a,dy:n},o={x:i,filter:a,dy:n};return{x:function(){return z.runKernel(Sm,s,e)},filter:function(){return z.runKernel(Lm,o,e)}}}};var pO={kernelName:Al,inputsToSave:["a","b"],gradFunc:function(n,t){var e=t[0],r=t[1],i=it(e.shape,r.shape),a=function(){var o=Ne(n,he(r,"float32")),c=St(e.shape,i);return c.length>0?Y(_e(o,c),e.shape):o},s=function(){var o=Z(n,he(e,"float32")),c=St(r.shape,i);c.length>0&&(o=Y(_e(o,c),r.shape));var l=$e(r);return Lt(Ne(o,he(l,"float32")))};return{a,b:s}}};var fO={kernelName:Tl,outputsToSave:[!0],gradFunc:function(n,t){var e=t[0],r=function(a){return a.eluDer(n,e)},i={dy:n,y:e};return{x:function(){return z.runKernelFunc(r,i,null,Im)}}}};var mO={kernelName:Nl,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0],r=Z(Ln(Lt($e(e))),2/Math.sqrt(Math.PI));return{x:function(){return Z(n,r)}}}};var gO={kernelName:_l,outputsToSave:[!0],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(n,e)}}}};var yO={kernelName:Cl,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(n,Ln(e))}}}};var vO={kernelName:Rl,gradFunc:function(n){return{x:function(){return ke(n)}}}};var wO={kernelName:Ol,inputsToSave:["a","b"],gradFunc:function(n,t){var e=t[0],r=t[1],i=it(e.shape,r.shape),a=function(){var o=Ne(n,he(r,"float32")),c=St(e.shape,i);return c.length>0?Y(_e(o,c),e.shape):o},s=function(){var o=Z(n,he(e,"float32")),c=St(r.shape,i);c.length>0&&(o=Y(_e(o,c),r.shape));var l=$e(r);return Lt(Ne(o,he(l,"float32")))};return{a,b:s}}};var bO={kernelName:El,inputsToSave:["x","mean","variance","scale"],gradFunc:function(n,t,e){var r=e.varianceEpsilon,i=t[0],a=t[1],s=t[2],o=t[3],c=o==null?Se(1):o,l=St(a.shape,i.shape),u=[];if(a.rank===1){for(var h=0;h0?Y(_e(n,o),e.shape):n},s=function(){var o=Z(n,Lt(yo(Ne(e,r)))),c=St(r.shape,i);return c.length>0?Y(_e(o,c),r.shape):o};return{a,b:s}}};var qO={kernelName:Jl,inputsToSave:["a","b"],gradFunc:function(n,t){var e=t[0],r=t[1],i=it(e.shape,r.shape),a=function(){var o=Z(n,he(r,"float32")),c=St(e.shape,i);return c.length>0?Y(_e(o,c),e.shape):o},s=function(){var o=Z(n,he(e,"float32")),c=St(r.shape,i);return c.length>0?Y(_e(o,c),r.shape):o};return{a,b:s}}};var GO={kernelName:Zl,gradFunc:function(n){return{x:function(){return Lt(n)}}}};var YO={kernelName:eu,inputsToSave:["indices"],gradFunc:function(n,t){var e=t[0];return{indices:function(){return rr(e.shape,"float32")}}}};var jO={kernelName:Ql,gradFunc:function(n){return{x:function(){return ke(n)}}}};var Dy={kernelName:tu,inputsToSave:["x"],gradFunc:function(n,t,e){var r=t[0],i=e.paddings,a=i.map(function(s){return s[0]});return{x:function(){return Me(n,a,r.shape)}}}};var KO={kernelName:nu,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:function(n,t){var e=t[0],r=t[1],i=t[2],a=e,s=r,o=it(a.shape,s.shape),c=function(){var u=he(s,"float32"),h=Z(n,Z(u,ir(a,be(u,Se(1))))),d=St(a.shape,o);return d.length>0&&(h=_e(h,d)),Y(h,a.shape)},l=function(){var u=_r(a,0),h=Sn(u,ii(a),ke(a)),d=Z(n,Z(i,h)),p=St(s.shape,o);return p.length>0&&(d=_e(d,p)),Y(d,s.shape)};return{a:c,b:l}}};var $O={kernelName:ru,inputsToSave:["x","alpha"],gradFunc:function(n,t){var e=t[0],r=t[1],i=_r(e,0);return{x:function(){return Sn(i,n,Z(n,r))},alpha:function(){var a=Sn(i,ke(n),Z(n,e)),s=St(r.shape,n.shape);return s.length>0&&(a=_e(a,s)),Y(a,r.shape)}}}};var XO={kernelName:iu,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Ne(n,Lt($e(e)))}}}};var JO={kernelName:lu,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0],r=Z(ri(e,6),ta(e));return{x:function(){return Z(n,he(r,"float32"))}}}};var ZO={kernelName:au,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(n,he(ta(e),"float32"))}}}};var QO={kernelName:su,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Y(n,e.shape)}}}};var eE={kernelName:cu,inputsToSave:["images"],gradFunc:function(n,t,e){var r=t[0],i=function(o){var c=e.alignCorners;return o.resizeBilinearBackprop(n,r,c)},a={images:r},s=function(){return z.runKernelFunc(i,a,null,Zm,e)};return{images:s}}};var tE={kernelName:ou,inputsToSave:["images"],gradFunc:function(n,t,e){var r=t[0],i=function(o){var c=e.alignCorners;return o.resizeNearestNeighborBackprop(n,r,c)},a={images:r},s=function(){return z.runKernelFunc(i,a,null,Jm,e)};return{images:s}}};var nE={kernelName:uu,gradFunc:function(n,t,e){var r=e.dims,i=rt(r,n.shape);return{x:function(){return ar(n,i)}}}};var rE={kernelName:hu,gradFunc:function(n){return{x:function(){return ke(n)}}}};var iE={kernelName:du,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Lt(Ne(n,Z(ir(e,1.5),2)))}}}};var aE={kernelName:pu,inputsToSave:["condition"],gradFunc:function(n,t){var e=t[0];return{condition:function(){return he(ke(e),"float32")},t:function(){return Z(n,he(e,n.dtype))},e:function(){return Z(n,he(So(e),n.dtype))}}}};var sE={kernelName:fu,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){var r=_r(e,Se(0)),i=Se(Ny),a=Se(_y),s=Z(n,a),o=Z(Z(n,i),Ln(he(e,"float32")));return Sn(r,s,o)}}}};var oE={kernelName:wu,outputsToSave:[!0],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(n,Z(e,be(Se(1),e)))}}}};var cE={kernelName:vu,gradFunc:function(n){return{x:function(){return ke(n)}}}};var lE={kernelName:gu,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(go(he(e,"float32")),n)}}}};var uE={kernelName:yu,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(xh(he(e,"float32")),n)}}}};var hE={kernelName:mu,inputsToSave:["x"],gradFunc:function(n,t,e){for(var r=t[0],i=e,a=i.begin,s=i.size,o=r.shape,c=hh(r,a,s),l=c[0],u=c[1],h=[],d=0;d0&&(o=_e(o,c)),Y(o,e.shape)},s=function(){var o=n,c=St(r.shape,i);return c.length>0&&(o=_e(o,c)),Y(Lt(o),r.shape)};return{a,b:s}}};var wE={kernelName:Su,inputsToSave:["x"],gradFunc:function(n,t,e){var r=t[0],i=r.shape.slice(),a=e.axis,s=rt(a,r.shape);s.forEach(function(l){i[l]=1});var o=Y(n,i),c=Z(o,Ji(r.shape,"float32"));return{x:function(){return c}}}};var bE={kernelName:_u,inputsToSave:["x"],gradFunc:function(n,t){var e=t[0];return{x:function(){return Ne(n,$e(go(e)))}}}};var xE={kernelName:Cu,outputsToSave:[!0],gradFunc:function(n,t){var e=t[0];return{x:function(){return Z(be(Se(1),$e(e)),n)}}}};var SE={kernelName:Ru,inputsToSave:["x"],gradFunc:function(n,t,e){var r=t[0],i=e.reps,a=function(){var s=ke(r);if(r.rank===1)for(var o=0;o{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});var v=di();var Qh=function(n,t){return Qh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])},Qh(n,t)};function Q(n,t){Qh(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Qt=function(){return Qt=Object.assign||function(t){for(var e,r=1,i=arguments.length;r0&&a[a.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]t?1:0}function Bo(n,t){return-1*EE(n,t)}function Or(n){if(n==null)return n;for(var t=[],e=0,r=n;e=0),Hn(r>=e),Array.isArray(n)&&n.length>=e&&n.length<=r&&n.every(function(i){return typeof i===t})}function Ct(n,t){Array.isArray(n)?(v.util.assert(n.length>0,function(){return t+" is unexpectedly an empty array."}),n.forEach(function(e,r){return Ct(e,"element "+(r+1)+" of "+t)})):v.util.assert(Number.isInteger(n)&&n>0,function(){return"Expected "+t+" to be a positive integer, but got "+(By(n)+".")})}function By(n){return n===null?"null":Array.isArray(n)?"["+n.map(function(t){return By(t)}).join(",")+"]":typeof n=="string"?'"'+n+'"':""+n}function kE(n,t){var e=v.util.now(),r,i=function(){for(var a=[],s=0;s0){var e=n+"_"+t;return ia.set(e,1),e}else return n}var GE=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function Ky(n){return!!n.match(GE)}function YE(n){return n===parseInt(n.toString(),10)}function Er(n,t,e){t==null&&(t=0),e==null&&(e=n.length);for(var r=1,i=t;i= 2"+(" but got x shape = "+n.shape+" and y shape = "+t.shape));if(t.rank>=3){var i=n.shape.slice(-1)[0],a=t.shape.slice(-2)[0];if(i!==a)throw new Re("If rank y >= 3, then the second last dim"+(" of y must equal the last dim of x but got x shape = "+n.shape+" and ")+(" y shape = "+t.shape))}if(n.rank===2&&t.rank===2){var s=!1,o=!1;return v.fused.matMul({a:n,b:t,transposeA:s,transposeB:o,bias:r?cd(n.rank,r,An()):null,activation:e})}else{var c=n.shape.slice(),l=c.pop();n=n.reshape([-1,l]);var u=t.shape.slice(),h=u.pop(),a=u.pop(),d=u.concat([h]),p=Array.from({length:t.rank},function(w,b){return b===0?t.rank-2:b<=t.rank-2?b-1:b});t=t.transpose(p).reshape([a,-1]);var f=c.concat(d),s=!1,o=!1;return v.fused.matMul({a:n,b:t,transposeA:s,transposeB:o,bias:r?cd(n.rank,r,An()):null,activation:e}).reshape(f)}}function Qy(n,t,e){return v.tidy(function(){return Array.isArray(t)?t=v.tensor1d(t,"int32"):t=t.toInt(),v.gather(n,t,e)})}function cs(n){return v.mul(n,n)}function cd(n,t,e){var r=t.shape;if(t.rank!==1&&t.rank!==n)throw new M("Unexpected bias dimensions: "+t.rank+("; expected it to be 1 or "+n));if(n===5){if(e==="channelsFirst")return r.length===1?t.reshape([1,r[0],1,1,1]):t.reshape([1,r[3],r[0],r[1],r[2]]);if(e==="channelsLast")return r.length===1?t.reshape([1,1,1,1,r[0]]):t.reshape([1].concat(r))}else if(n===4){if(e==="channelsFirst")return r.length===1?t.reshape([1,r[0],1,1]):t.reshape([1,r[2],r[0],r[1]]);if(e==="channelsLast")return r.length===1?t.reshape([1,1,1,r[0]]):t.reshape([1].concat(r))}else if(n===3){if(e==="channelsFirst")return r.length===1?t.reshape([1,r[0],1]):t.reshape([1,r[1],r[0]]);if(e==="channelsLast")return r.length===1?t.reshape([1,1,r[0]]):t.reshape([1].concat(r))}else if(n<3)return t;throw new M("Unsupported input rank by biasAdd: "+t.rank)}function qn(n,t,e){return v.tidy(function(){return e==null&&(e=An()),yt(e),n.add(cd(n.rank,t,e))})}function XE(n,t){if(t===void 0&&(t=1),t!==1)throw new Re("Support for alpha values other than 1 ("+t+") is not implemented yet.");return v.elu(n)}function JE(n){return v.tidy(function(){return v.div(n,v.abs(n).add(1))})}function ev(n,t,e,r){return v.tidy(function(){return v.dropout(n,t,e,r)})}function ZE(n){return v.tidy(function(){var t=v.add(.5,v.mul(.2,n));return v.clipByValue(t,0,1)})}function ls(n,t,e){return e===void 0&&(e=!1),e?n():t()}var QE=["fanIn","fanOut","fanAvg"],e7=["normal","uniform","truncatedNormal"];function t7(n){ra(QE,"FanMode",n)}function n7(n){ra(e7,"Distribution",n)}var gn=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.fromConfigUsesCustomObjects=function(){return!1},t.prototype.getConfig=function(){return{}},t}(v.serialization.Serializable),tv=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.apply=function(e,r){return v.zeros(e,r)},t.className="Zeros",t}(gn);v.serialization.registerClass(tv);var ld=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.apply=function(e,r){return v.ones(e,r)},t.className="Ones",t}(gn);v.serialization.registerClass(ld);var nv=function(n){Q(t,n);function t(e){var r=n.call(this)||this;if(typeof e!="object")throw new M("Expected argument of type ConstantConfig but got "+e);if(e.value===void 0)throw new M("config must have value set but got "+e);return r.value=e.value,r}return t.prototype.apply=function(e,r){var i=this;return v.tidy(function(){return v.mul(v.scalar(i.value),v.ones(e,r))})},t.prototype.getConfig=function(){return{value:this.value}},t.className="Constant",t}(gn);v.serialization.registerClass(nv);var rv=function(n){Q(t,n);function t(e){var r=n.call(this)||this;return r.DEFAULT_MINVAL=-.05,r.DEFAULT_MAXVAL=.05,r.minval=e.minval||r.DEFAULT_MINVAL,r.maxval=e.maxval||r.DEFAULT_MAXVAL,r.seed=e.seed,r}return t.prototype.apply=function(e,r){return v.randomUniform(e,this.minval,this.maxval,r)},t.prototype.getConfig=function(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}},t.className="RandomUniform",t}(gn);v.serialization.registerClass(rv);var iv=function(n){Q(t,n);function t(e){var r=n.call(this)||this;return r.DEFAULT_MEAN=0,r.DEFAULT_STDDEV=.05,r.mean=e.mean||r.DEFAULT_MEAN,r.stddev=e.stddev||r.DEFAULT_STDDEV,r.seed=e.seed,r}return t.prototype.apply=function(e,r){if(r=r||"float32",r!=="float32"&&r!=="int32")throw new Re("randomNormal does not support dType "+r+".");return Po(e,this.mean,this.stddev,r,this.seed)},t.prototype.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},t.className="RandomNormal",t}(gn);v.serialization.registerClass(iv);var av=function(n){Q(t,n);function t(e){var r=n.call(this)||this;return r.DEFAULT_MEAN=0,r.DEFAULT_STDDEV=.05,r.mean=e.mean||r.DEFAULT_MEAN,r.stddev=e.stddev||r.DEFAULT_STDDEV,r.seed=e.seed,r}return t.prototype.apply=function(e,r){if(r=r||"float32",r!=="float32"&&r!=="int32")throw new Re("truncatedNormal does not support dType "+r+".");return v.truncatedNormal(e,this.mean,this.stddev,r,this.seed)},t.prototype.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},t.className="TruncatedNormal",t}(gn);v.serialization.registerClass(av);var sv=function(n){Q(t,n);function t(e){var r=n.call(this)||this;return r.gain=e.gain!=null?e.gain:1,r}return t.prototype.apply=function(e,r){var i=this;return v.tidy(function(){if(e.length!==2||e[0]!==e[1])throw new M("Identity matrix initializer can only be used for 2D square matrices.");return v.mul(i.gain,v.eye(e[0]))})},t.prototype.getConfig=function(){return{gain:this.gain}},t.className="Identity",t}(gn);v.serialization.registerClass(sv);function r7(n,t){t===void 0&&(t="channelsLast");var e,r;if(yt(t),n.length===2)e=n[0],r=n[1];else if([3,4,5].indexOf(n.length)!==-1){if(t==="channelsFirst"){var i=Er(n,2);e=n[1]*i,r=n[0]*i}else if(t==="channelsLast"){var i=Er(n,0,n.length-2);e=n[n.length-2]*i,r=n[n.length-1]*i}}else{var a=Er(n);e=Math.sqrt(a),r=Math.sqrt(a)}return[e,r]}var en=function(n){Q(t,n);function t(e){var r=n.call(this)||this;if(e.scale<0)throw new M("scale must be a positive float. Got: "+e.scale);return r.scale=e.scale==null?1:e.scale,r.mode=e.mode==null?"fanIn":e.mode,t7(r.mode),r.distribution=e.distribution==null?"normal":e.distribution,n7(r.distribution),r.seed=e.seed,r}return t.prototype.apply=function(e,r){var i=r7(e),a=i[0],s=i[1],o=this.scale;if(this.mode==="fanIn"?o/=Math.max(1,a):this.mode==="fanOut"?o/=Math.max(1,s):o/=Math.max(1,(a+s)/2),this.distribution==="normal"){var c=Math.sqrt(o);if(r=r||"float32",r!=="float32"&&r!=="int32")throw new Re(this.getClassName()+" does not support dType "+r+".");return v.truncatedNormal(e,0,c,r,this.seed)}else{var l=Math.sqrt(3*o);return v.randomUniform(e,-l,l,r)}},t.prototype.getConfig=function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}},t.className="VarianceScaling",t}(gn);v.serialization.registerClass(en);var ud=function(n){Q(t,n);function t(e){return n.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})||this}return t.prototype.getClassName=function(){return en.className},t.className="GlorotUniform",t}(en);v.serialization.registerClass(ud);var hd=function(n){Q(t,n);function t(e){return n.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})||this}return t.prototype.getClassName=function(){return en.className},t.className="GlorotNormal",t}(en);v.serialization.registerClass(hd);var dd=function(n){Q(t,n);function t(e){return n.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})||this}return t.prototype.getClassName=function(){return en.className},t.className="HeNormal",t}(en);v.serialization.registerClass(dd);var pd=function(n){Q(t,n);function t(e){return n.call(this,{scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})||this}return t.prototype.getClassName=function(){return en.className},t.className="HeUniform",t}(en);v.serialization.registerClass(pd);var fd=function(n){Q(t,n);function t(e){return n.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})||this}return t.prototype.getClassName=function(){return en.className},t.className="LeCunNormal",t}(en);v.serialization.registerClass(fd);var md=function(n){Q(t,n);function t(e){return n.call(this,{scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})||this}return t.prototype.getClassName=function(){return en.className},t.className="LeCunNormal",t}(en);v.serialization.registerClass(md);var ov=function(n){Q(t,n);function t(e){var r=n.call(this)||this;if(r.DEFAULT_GAIN=1,r.gain=e.gain==null?r.DEFAULT_GAIN:e.gain,r.seed=e.seed,r.seed!=null)throw new Re("Random seed is not implemented for Orthogonal Initializer yet.");return r}return t.prototype.apply=function(e,r){var i=this;return v.tidy(function(){if(e.length<2)throw new Re("Shape must be at least 2D.");e[0]*e[1]>2e3&&console.warn("Orthogonal initializer is being called on a matrix with more "+("than 2000 ("+e[0]*e[1]+") elements: ")+"Slowness may result.");var a=e[0]>e[1]?[e[1],e[0]]:e,s=Po(a,0,1,"float32"),o=v.linalg.gramSchmidt(s);return e[0]>e[1]&&(o=o.transpose()),v.mul(i.gain,o)})},t.prototype.getConfig=function(){return{gain:this.gain,seed:this.seed}},t.className="Orthogonal",t}(gn);v.serialization.registerClass(ov);var cv={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 lv(n,t){return t===void 0&&(t={}),rs(n,v.serialization.SerializationMap.getMap().classNameMap,t,"initializer")}function lt(n){return td(n)}function at(n){if(typeof n=="string"){var t=n in cv?cv[n]:n;if(t==="GlorotNormal")return new hd;if(t==="GlorotUniform")return new ud;if(t==="HeNormal")return new dd;if(t==="HeUniform")return new pd;if(t==="LeCunNormal")return new fd;if(t==="LeCunUniform")return new md;var e={};return e.className=t,e.config={},lv(e)}else return n instanceof gn?n:lv(n)}function i7(){return new tv}function a7(){return new ld}function s7(n){return new nv(n)}function o7(n){return new rv(n)}function c7(n){return new iv(n)}function l7(n){return new av(n)}function u7(n){return new sv(n)}function h7(n){return new en(n)}function d7(n){return new ud(n)}function p7(n){return new hd(n)}function f7(n){return new dd(n)}function m7(n){return new pd(n)}function g7(n){return new fd(n)}function y7(n){return new md(n)}function v7(n){return new ov(n)}var w7={__proto__:null,zeros:i7,ones:a7,constant:s7,randomUniform:o7,randomNormal:c7,truncatedNormal:l7,identity:u7,varianceScaling:h7,glorotUniform:d7,glorotNormal:p7,heNormal:f7,heUniform:m7,leCunNormal:g7,leCunUniform:y7,orthogonal:v7};var b7=0;function uv(){return b7++}var Mo={};function Ho(n){return n===void 0&&(n=""),n in Mo||(Mo[n]=0),Mo[n]+=1,n+Mo[n].toString()}function gd(n){return Array.isArray(n)&&Array.isArray(n[0])}function Vo(n){return n.length===0?[]:Array.isArray(n[0])?n:[n]}function Oe(n){var t;if(Array.isArray(n)){if(n.length!==1)throw new M("Expected Tensor length to be 1; got "+n.length);t=n[0]}else t=n;return t}function Xe(n){if(Array.isArray(n)&&Array.isArray(n[0])){if(n.length===1)return n=n,n[0];throw new M("Expected exactly 1 Shape; got "+n.length)}else return n}function qo(n){for(var t=0,e=0,r=n;e1)throw new Rr("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 Rr("Layer "+this.name+" is not connected, no input to return.");return Yt(this.getNodeAtIndex(0,"input").inputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){if(this.inboundNodes.length===0)throw new Rr("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new Rr("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return Yt(this.getNodeAtIndex(0,"output").outputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"losses",{get:function(){return this._losses},enumerable:!0,configurable:!0}),t.prototype.calculateLosses=function(){return this.losses.map(function(e){return e()})},Object.defineProperty(t.prototype,"updates",{get:function(){return this._updates},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"built",{get:function(){return this._built},set:function(e){this._built=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"trainable",{get:function(){return this.trainable_},set:function(e){this._trainableWeights.forEach(function(r){return r.trainable=e}),this.trainable_=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"trainableWeights",{get:function(){return this.trainable_?this._trainableWeights.filter(function(e){return e.trainable}):[]},set:function(e){this._trainableWeights=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nonTrainableWeights",{get:function(){return this.trainable?this._trainableWeights.filter(function(e){return!e.trainable}).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)},set:function(e){this._nonTrainableWeights=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"weights",{get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stateful",{get:function(){return this._stateful},enumerable:!0,configurable:!0}),t.prototype.resetStates=function(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")},t.prototype.assertInputCompatibility=function(e){if(e=nt(e),this.inputSpec==null||this.inputSpec.length===0)return;var r=nt(this.inputSpec);if(e.length!==r.length)throw new M("Layer "+this.name+" expects "+r.length+" inputs, "+("but it received "+e.length+" input tensors. ")+("Input received: "+e));for(var i=0;i=0?c[u]:c[c.length+u];if(h!=null&&[h,null].indexOf(d)===-1)throw new M("Input "+i+" is incompatible with layer "+(this.name+": expected axis "+u+" of input shape to ")+("have value "+h+" but got shape "+c+"."))}}if(s.shape!=null)for(var p=0;p0&&Array.isArray(C[0])?y=C.map(function(F,k){return new Nn(O,F,i,nt(e),r,i.name,k)}):y=new Nn(O,C,i,nt(e),r,i.name),i.addInboundNode(e,y,null,null,I,C,r),i._refCount++,i.activityRegularizer!=null)throw new Re("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return y}})},t.prototype.warnOnIncompatibleInputShape=function(e){if(this.batchInputShape==null)return;if(e.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+(JSON.stringify(e)+") does not match that of the ")+("batchInputShape ("+JSON.stringify(this.batchInputShape)+") ")+("of the layer "+this.name));else{var r=!1;this.batchInputShape.forEach(function(i,a){i!=null&&e[a]!=null&&e[a]!==i&&(r=!0)}),r&&console.warn("The shape of the input tensor "+("("+JSON.stringify(e)+") does not ")+("match the expectation of layer "+this.name+": ")+(""+JSON.stringify(this.batchInputShape)))}},Object.defineProperty(t.prototype,"outputShape",{get:function(){if(this.inboundNodes==null||this.inboundNodes.length===0)throw new Rr("The layer "+this.name+" has never been called and thus has no defined output shape.");for(var e=[],r=0,i=this.inboundNodes;r0)&&(t=n.sourceLayer,e=n.nodeIndex),t.inboundNodes.length===0)return[n];var r=t.inboundNodes[e];if(r.inboundLayers.length===0)return r.inputTensors;for(var i=[],a=0;a0?[4,Promise.all(t)]:[3,2];case 1:for(o=l.sent(),c=0;c=0&&Number.isInteger(t),function(){return"Verbosity level is expected to be an integer >= 0, "+("but got "+t)}),n.checkForDuplicate(e),n.constructors[t]==null&&(n.constructors[t]=[]),n.constructors[t].push(e)},n.checkForDuplicate=function(t){for(var e in n.constructors){var r=n.constructors[+e];r.forEach(function(i){if(i===t)throw new M("Duplicate callback constructor.")})}},n.clear=function(){n.constructors={}},n.createCallbacks=function(t){var e=[];for(var r in n.constructors){var i=+r;t>=i&&e.push.apply(e,n.constructors[i])}return e.map(function(a){return new a})},n.constructors={},n}();function Sv(n,t,e,r,i,a,s,o,c){var l=new vv,u=[new N7].concat(xv.createCallbacks(t));n!=null&&u.push.apply(u,n),u.push(l);var h=new yv(u);return h.setParams({epochs:e,initialEpoch:r,samples:i,steps:a,batchSize:s,verbose:t,doValidation:o,metrics:c}),{callbackList:h,history:l}}function _n(n,t,e){return t===void 0&&(t={}),e===void 0&&(e=!1),rs(n,v.serialization.SerializationMap.getMap().classNameMap,t,"layer",e)}function Yo(n,t){return v.tidy(function(){n.dtype!=="float32"&&(n=n.asType("float32"));var e=v.sum(cs(n),t,!0),r=v.fill(e.shape,It()),i=v.sqrt(v.maximum(e,r));return v.div(n,i)})}function yi(n,t){return v.tidy(function(){return v.mean(cs(v.sub(t,n)),-1)})}function jo(n,t){return v.tidy(function(){return v.mean(v.abs(v.sub(t,n)),-1)})}function oa(n,t){return v.tidy(function(){var e=v.sub(n,t),r=v.clipByValue(v.abs(n),It(),Number.MAX_VALUE),i=v.abs(v.div(e,r));return v.mul(100,v.mean(i,-1))})}function _7(n,t){return v.tidy(function(){var e=v.clipByValue(t,It(),Number.MAX_VALUE),r=v.log(v.add(1,e)),i=v.clipByValue(n,It(),Number.MAX_VALUE),a=v.log(v.add(1,i));return v.mean(cs(v.sub(r,a)),-1)})}function C7(n,t){return v.tidy(function(){var e=v.maximum(0,v.sub(1,v.mul(n,t)));return v.mean(cs(e),-1)})}function R7(n,t){return v.tidy(function(){var e=v.maximum(0,v.sub(1,v.mul(n,t)));return v.mean(e,-1)})}function O7(n,t){return v.tidy(function(){var e=v.sum(v.mul(n,t),-1),r=v.max(v.mul(v.sub(1,n),t),-1);return v.maximum(0,v.add(1,v.sub(r,e)))})}function E7(n,t){return v.tidy(function(){var e=Math.log(2),r=v.sub(t,n),i=v.sub(v.add(r,v.softplus(v.mul(-2,r))),e);return v.mean(i,-1)})}function hs(n,t,e){return e===void 0&&(e=!1),v.tidy(function(){if(e)t=v.softmax(t);else{var r=v.sum(t,t.shape.length-1,!0);t=v.div(t,r)}return t=v.clipByValue(t,It(),1-It()),v.neg(v.sum(v.mul(n.toFloat(),v.log(t)),t.shape.length-1))})}function Ko(n,t,e){return e===void 0&&(e=!1),v.tidy(function(){var r=v.floor(KE(n)).toInt();t=v.clipByValue(t,It(),1-It());var i=t.shape,a=v.oneHot(r,i[i.length-1]).reshape(i);return hs(a,t,e)})}function D7(n,t){if(!v.util.arraysEqual(n.shape,t.shape))throw new M("logits and labels must have the same shape, but got shapes "+(JSON.stringify(n.shape)+" and "+JSON.stringify(t.shape)));return v.tidy(function(){var e=t.relu(),r=t.abs().neg();return e.sub(t.mul(n)).add(r.exp().log1p())})}function $o(n,t){return v.tidy(function(){var e;return e=v.clipByValue(t,It(),1-It()),e=v.log(v.div(e,v.sub(1,e))),v.mean(D7(n,e),-1)})}function k7(n,t){return v.tidy(function(){var e=v.clipByValue(n,It(),1),r=v.clipByValue(t,It(),1);return v.sum(v.mul(n,v.log(v.div(e,r))),-1)})}function F7(n,t){return v.tidy(function(){var e=v.log(v.add(It(),t));return v.mean(v.sub(t,v.mul(n,e)),-1)})}function wd(n,t){return v.tidy(function(){var e=Yo(n,-1),r=Yo(t,-1),i=v.mul(e,r);return v.neg(v.sum(i,-1))})}var Xo={meanSquaredError:yi,meanAbsoluteError:jo,meanAbsolutePercentageError:oa,meanSquaredLogarithmicError:_7,squaredHinge:C7,hinge:R7,categoricalHinge:O7,logcosh:E7,categoricalCrossentropy:hs,sparseCategoricalCrossentropy:Ko,binaryCrossentropy:$o,kullbackLeiblerDivergence:k7,poisson:F7,cosineProximity:wd};function bd(n){if(typeof n=="string"){if(n in Xo)return Xo[n];var t="Unknown loss "+n;throw n.toLowerCase().includes("softmaxcrossentropy")&&(t="Unknown loss "+n+'. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'),new M(t)}else return n}function xd(n,t){return v.tidy(function(){var e=v.mul(.5,v.onesLike(t)),r=ss(v.greater(t,e),n.dtype);return v.mean(v.equal(n,r),-1)})}function Sd(n,t){return v.tidy(function(){return ss(v.equal(v.argMax(n,-1),v.argMax(t,-1)),"float32")})}function Lv(n,t){return v.tidy(function(){return v.logicalAnd(n.equal(1),t.equal(1)).sum().cast("float32")})}function W7(n,t){return v.tidy(function(){return v.logicalAnd(n.equal(1),t.equal(0)).sum().cast("float32")})}function U7(n,t){return v.tidy(function(){return v.logicalAnd(n.equal(0),t.equal(1)).sum().cast("float32")})}function Iv(n,t){return v.tidy(function(){var e=Lv(n,t),r=U7(n,t),i=e.add(r);return v.where(v.greater(i,0),e.div(i),0).cast("float32")})}function B7(n,t){return v.tidy(function(){var e=Lv(n,t),r=W7(n,t),i=e.add(r);return v.where(v.greater(i,0),e.div(i),0).cast("float32")})}function Av(n,t){return $o(n,t)}function Tv(n,t){return n.rank===t.rank&&(n=n.squeeze([n.rank-1])),t=t.argMax(-1),t.dtype!==n.dtype&&(t=t.asType(n.dtype)),v.equal(n,t).asType("float32")}var z7=yi,P7=yi,M7=jo,H7=jo,V7=oa,q7=oa,Ld=hs,G7=wd,Nv=Ko,Jo={binaryAccuracy:xd,categoricalAccuracy:Sd,precision:Iv,categoricalCrossentropy:Ld,sparseCategoricalCrossentropy:Nv,mse:z7,MSE:P7,mae:M7,MAE:H7,mape:V7,MAPE:q7,cosine:G7};function Y7(n){if(typeof n=="string"&&n in Jo)return Jo[n];if(typeof n!="string"&&n!=null)return n;throw new M("Unknown metric "+n)}function Zo(n){if(Hn(n!==null,"Unknown LossOrMetricFn "+n),typeof n=="string")return n;for(var t=void 0,e=0,r=Object.keys(Xo);e_v&&console.warn('User-defined metadata of model "'+t+'" is too large in '+("size (length="+r.length+" when serialized). It is not ")+"recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= "+(_v+"."))}}function Id(n){if(n===null)return!0;if(typeof n=="object")if(Object.getPrototypeOf(n)===Object.prototype){for(var t=Object.keys(n),e=0,r=t;e1||o.length===1&&o[0].inboundLayers.length>1){t=!1;break}r.push.apply(r,o)}if(t)for(var c=0,l=n.layers;c0&&(r=r.slice(0,r.length-1)+" "),r+=n[i],r=r.slice(0,t[i]),r+=" ".repeat(t[i]-r.length);e(r)}function X7(n,t,e){var r;try{r=JSON.stringify(n.outputShape)}catch(o){r="multiple"}var i=n.name,a=n.getClassName(),s=[i+" ("+a+")",r,n.countParams().toString()];Qo(s,t,e)}function J7(n,t,e,r){var i;try{i=JSON.stringify(n.outputShape)}catch(y){i="multiple"}for(var a=[],s=0,o=n.inboundNodes;s0&&e.indexOf(c)===-1)continue;for(var l=0;lr.maxNumTensors&&(r.maxNumTensors=b),b0,function(){return"Expected at least one fetch, got none"});var e=[],r={};if(n.length===1){var i=Ev(n[0],t);e=i.sorted,r=i.recipientMap}else for(var a=new Set,s=0,o=n;s0;){var u=c[c.length-1];if(e.has(u.name)){c.pop();continue}var h=l[l.length-1]===c.length-1;if(u.inputs.length===0||h)c.pop(),r.push(u),e.add(u.name),h&&l.pop();else{l.push(c.length-1);for(var d=0,p=u.inputs;d1 nodes"),Hn(u===0,"input layer has >1 tensors"),r.inputLayers.push(c),r.inputLayersNodeIndices.push(l),r.inputLayersTensorIndices.push(u)}r.inputNames=[],r.outputNames=[],r.feedInputShapes=[],r.feedInputNames=[],r.feedOutputNames=[];for(var p=0;p=0;)mt.splice(mt.indexOf(Wt),1);x.push(Wt)},I=[],C=[],O=0,D=r.outputs;OJt?1:0});for(var se=0,me=oe;se0)throw new M("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 e=[],r=0,i=this.layers;r0)throw new M(y.length+" of "+a+" weights are not set: "+(""+y))}vd(d)},t.prototype.updatedConfig=function(){var e=this.getConfig(),r={};return r.className=this.getClassName(),r.config=e,r.kerasVersion="tfjs-layers "+Td,r.backend="TensorFlow.js",r},t.prototype.toJSON=function(e,r){r===void 0&&(r=!0);var i=Ad(this.updatedConfig());return r?JSON.stringify(i):i},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){e=nt(e);for(var a=new ca,s=0;s1)for(var u=0,h=l;u0){for(var m=[],g=0;g0&&H.apply(Yt($),ee)}function u(H){var J=H.name,$=_n(H,r.customObjects!=null?r.customObjects:{});$.setFastWeightInitDuringBuild(a),s[J]=$;var ee=H.inboundNodes;ee.forEach(function(te){if(!(te instanceof Array))throw new M("Corrupted configuration, expected array for nodeData: "+te);c($,te)})}for(var h=r.name,d=r.layers,p=0,f=d;p0&&typeof n[Object.keys(n)[0]]=="object"){var i=[];return t.forEach(function(a){a in n?i.push(n[a]):i.push(null)}),i}else throw new Error("The model has multiple ("+r+") outputs, "+("so "+e+" must be either an array with ")+(r+" elements or an object with "+t+" keys. ")+("Provided "+e+" not understood: "+JSON.stringify(n)))}function Dv(n,t){return i4(n,t,"classWeight")}function kv(n,t,e,r){return Ae(this,void 0,void 0,function(){var i,a,s,o,c;return xe(this,function(l){switch(l.label){case 0:if(t!=null||r!=null)throw new Error("Support sampleWeight is not implemented yet");return e!=null?(i=v.tidy(function(){if(n.shape.length===1)return n.clone();if(n.shape.length===2)if(n.shape[1]>1){var u=1;return n.argMax(u)}else{if(n.shape[1]===1)return n.reshape([n.shape[0]]);throw new Error("Encountered unexpected last-dimension size ("+n.shape[1]+") during handling of class weights. The size is expected to be >= 1.")}else throw new Error("Unexpected rank of target (y) tensor ("+n.rank+") during handling of class weights. The rank is expected to be 1 or 2.")}),o=(s=Array).from,[4,i.data()]):[3,2];case 1:return a=o.apply(s,[l.sent()]),v.dispose(i),c=[],a.forEach(function(u){if(e[u]==null)throw new Error("classWeight must contain all classes in the training data. "+("The class "+u+" exists in the data but not in ")+"classWeight");c.push(e[u])}),[2,v.tensor1d(c,"float32")];case 2:return[2,null]}})})}function a4(n,t){return v.mul(n,t)}var s4=32;function Wv(n,t){var e,r,i=t;e=i.xs,r=i.ys,v.util.assert(e!=null&&r!=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 "+(""+t)});var a=Fv("input",n.inputNames,e),s=Fv("output",n.outputNames,r),o=a[0].shape[0];v.util.assert(a.length===n.inputs.length,function(){return"LayersModel has "+n.inputs.length+" inputs, but the dataset "+("provides "+a.length+" inputs. (Expected input keys: ")+(JSON.stringify(n.inputNames)+")")}),v.util.assert(s.length===n.outputs.length,function(){return"LayersModel has "+n.outputs.length+" outputs, but the dataset "+("provides "+s.length+" outputs. (Expected output keys: ")+(JSON.stringify(n.outputNames)+")")});for(var c=function(d){v.util.assert(a[d].shape[0]===o,function(){return"Batch size mismatch: input "+(n.inputNames[d]+" has "+a[d].shape[0]+"; ")+("expected "+o+" based on input "+n.inputNames[0]+".")})},l=0;l0&&Number.isInteger(e.epochs),function(){return"For fitDataset(), config.epochs is expected to be a positive "+("integer, but got "+e.epochs)}),v.util.assert(!r||e.batchesPerEpoch>0&&Number.isInteger(e.batchesPerEpoch),function(){return"For fitDataset(), config.batchesPerEpoch is expected to be a "+("positive integer if specified, but got "+e.batchesPerEpoch)}),v.util.assert(e.validationSplit==null,function(){return"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."}),n.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");n.isTraining=!0,$.label=1;case 1:return $.trys.push([1,,26,27]),i=e.validationData!=null,a=void 0,s=void 0,i&&(Uv(e.validationData)?v.util.assert(e.validationBatches==null||e.validationBatches>0&&Number.isInteger(e.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 "+e.validationBatches)}):(o=o4(e.validationData),a=o.xs,s=o.ys)),c=n.makeTrainFunction(),l=n.getDedupedMetricsNames(),u=void 0,i?u=l.slice().concat(l.map(function(ee){return"val_"+ee})):u=l.slice(),h=bv(e.callbacks,e.yieldEvery),d=e.verbose==null?1:e.verbose,p=Sv(h,d,e.epochs,null,null,c4(t,e),null,i,u),f=p.callbackList,m=p.history,f.setModel(n),n.history=m,[4,f.onTrainBegin()];case 2:return $.sent(),n.stopTraining_=!1,g=e.initialEpoch==null?0:e.initialEpoch,[4,t.iterator()];case 3:y=$.sent(),$.label=4;case 4:return g=e.batchesPerEpoch:x.done)?i?(H=void 0,Uv(e.validationData)?(J=nt,[4,n.evaluateDataset(e.validationData,{batches:e.validationBatches})]):[3,17]):[3,19]:[3,20];case 16:return H=J.apply(void 0,[$.sent()]),[3,18];case 17:H=nt(n.evaluate(a,s,{batchSize:e.validationBatchSize==null?s4:e.validationBatchSize,verbose:0})),$.label=18;case 18:for(k=0;k0)throw new Re("Verbose mode is not implemented yet.");return v.util.assert(!r||e.batches>0&&Number.isInteger(e.batches),function(){return"Test loop expects `batches` to be a positive integer, but "+("received "+JSON.stringify(e.batches))}),u4(t)?(o=t,[3,3]):[3,1];case 1:return[4,t.iterator()];case 2:o=f.sent(),f.label=3;case 3:s=o,c=0,l=0,u=function(){var m;return xe(this,function(g){switch(g.label){case 0:return[4,s.next()];case 1:return m=g.sent(),a=v.tidy(function(){if(m.value){var y=Wv(n,m.value),w=y.xs,b=y.ys,S=w.concat(b),x=v.tidy(function(){return i(S)});if(v.dispose(S),l===0)for(var N=0;N0&&v.dispose(F)},N=0;N0&&Number.isInteger(n),function(){return"batchSize is required to be a positive integer, but got "+n})}function fs(n,t,e){return n==null?[null]:Array.isArray(n)?n.map(function(r){return gi(r,t,e-t)}):gi(n,t,e-t)}function Cd(n,t){return v.tidy(function(){return n==null?null:Array.isArray(n)?n.map(function(e){return Cd(e,t)}):Qy(n,t.dtype==="int32"?t:t.toInt())})}function Rd(n,t){for(var e=[],r=0,i=null;r=n&&(i=n),e.push([r,i]),r=i;return e}function d4(n,t,e,r,i,a,s,o,c,l,u,h,d,p,f){return Ae(this,void 0,void 0,function(){var m,g,y,w,b,S,x,N,I;return xe(this,function(C){switch(C.label){case 0:if(i==null&&(i=32),a==null&&(a=1),u==null&&(u=!0),d==null&&(d=0),m=!1,c!=null&&l!=null&&(m=!0),f!=null&&(m=!0,p==null))throw new M("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");return g=n.checkNumSamples(e,i,p,"steps_per_epoch"),g!=null&&(y=Tn(0,g)),s==null&&(s=1),w=Sv(o,s,a,d,g,p,i,m,h),b=w.callbackList,S=w.history,b.setModel(n),n.history=S,[4,b.onTrainBegin()];case 1:C.sent(),n.stopTraining_=!1,x=function(O){var D,F,k,B,V,P;return xe(this,function(q){switch(q.label){case 0:return[4,b.onEpochBegin(O)];case 1:if(q.sent(),D={},!(p!=null))return[3,2];throw new Re("stepsPerEpoch mode is not implemented yet.");case 2:if(u==="batch")throw new Re("batch shuffling is not implemneted yet");u&&v.util.shuffle(y),F=v.tensor1d(y),k=Rd(g,i),B=function(K){var G;return xe(this,function(H){switch(H.label){case 0:return G={},[4,b.onBatchBegin(K,G)];case 1:return H.sent(),v.tidy(function(){var J=k[K][0],$=k[K][1],ee=gi(F,J,$-J);G.batch=K,G.size=$-J;for(var te=Cd(e,ee),ne=t(te),re=0;re0))return[3,4];if(f=!0,r.validationData.length===2)s=r.validationData[0],o=r.validationData[1];else throw r.validationData.length===3?new Re("validationData including sample weights is not supported yet."):new M("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+(r.validationData+" is invalid."));return g=!0,[4,n.standardizeUserData(s,o,null,null,g,h)];case 3:return y=F.sent(),c=y[0],l=y[1],m=c.concat(l),[3,5];case 4:r.validationSplit!=null&&r.validationSplit>0&&r.validationSplit<1?(f=!0,w=Math.floor(i[0].shape[0]*(1-r.validationSplit)),b=i[0].shape[0],c=fs(i,w,b),i=fs(i,0,w),l=fs(a,w,b),a=fs(a,0,w),m=c.concat(l)):r.validationSteps!=null&&(f=!0),F.label=5;case 5:return S=i.concat(a).concat(u),n.checkTrainableWeightsConsistency(),x=n.makeTrainFunction(),N=n.getDedupedMetricsNames(),I=void 0,C=void 0,f?(n.makeTestFunction(),I=n.testFunction,C=N.slice().concat(N.map(function(k){return"val_"+k}))):(I=null,m=[],C=N.slice()),O=bv(r.callbacks,r.yieldEvery),[4,d4(n,x,S,N,h,r.epochs,r.verbose,O,I,m,r.shuffle,C,r.initialEpoch,null,null)];case 6:return D=F.sent(),[2,D];case 7:return n.isTraining=!1,vi(i,t),vi(a,e),vi(c,s),vi(l,o),u!=null&&v.dispose(u),[7];case 8:return[2]}})})}function Bv(n){var t=[];n instanceof v.Tensor&&(n=[n]);for(var e=0;e0)a=!0;else if(zv(n)){for(var s in n)if(n.hasOwnProperty(s)){a=!0;break}}else a=!0;if(a)throw new M("Error when checking model "+i+" expected no data, "+("but got "+n))}return[]}if(n==null)return t.map(function(g){return null});var o;if(zv(n)){n=n,o=[];for(var c=0,l=t;c1)throw new M("The model "+i+" expects "+t.length+" Tensor(s), "+("but only received one Tensor. Found: Tensor with shape "+n.shape));o=[n]}if(o=Bv(o),e!=null)for(var h=0;h=0&&f!==m)throw new M("Error when checking "+i+": expected "+t[h]+" "+("to have shape ["+e[h]+"], but got array with shape ")+("["+d.shape+"]."))}}return o}function m4(n,t,e){var r=Or(n.map(function(a){return a.shape[0]}));r.sort();var i=Or(t.map(function(a){return a.shape[0]}));if(i.sort(),r.length>1)throw new M("All input Tensors (x) should have the same number of samples. Got array shapes: "+(""+JSON.stringify(n.map(function(a){return a.shape}))));if(i.length>1)throw new M("All target Tensors (y) should have the same number of samples. Got array shapes: "+(""+JSON.stringify(t.map(function(a){return a.shape}))));if(r.length>0&&i.length>0&&!v.util.arraysEqual(r,i))throw new M("Input Tensors should have the same number of samples as target "+("Tensors. Found "+r[0]+" input sample(s) and "+i[0]+" target ")+"sample(s).")}function g4(n,t,e){for(var r=[yi,$o,hs],i=0;i1)throw new M("The model expects "+t.length+" "+i+" Tensors, but only received one Tensor. Found: array with shape "+(JSON.stringify(n.shape)+"."));a=[n]}if(e!=null)for(var s=0;s1&&(r.metricsTensors.push([w,y]),r.metricsNames.push(r.outputNames[y]+"_loss"))}});var m=y4(e.metrics,this.outputNames),g=function(y,w,b){r.outputNames.length>1&&(w=r.outputNames[y]+"_"+w),r.metricsNames.push(w),r.metricsTensors.push([b,y])};mi("metric",function(){for(var y=function(b){if(f.indexOf(b)!==-1)return"continue";var S=m[b],x=function(N){for(var I="",C,O,D,F=function(P){if(typeof P=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(P)!==-1){var q=r.internalOutputShapes[b];q[q.length-1]===1||r.lossFunctions[b]===$o?["accuracy","acc"].indexOf(P)!==-1?O=xd:["crossentropy","ce"].indexOf(P)!==-1&&(O=Av):r.lossFunctions[b]===Ko?["accuracy","acc"].indexOf(P)!==-1?O=Tv:["crossentropy","ce"].indexOf(P)!==-1&&(O=Nv):["accuracy","acc"].indexOf(P)!==-1?O=Sd:["crossentropy","ce"].indexOf(P)!==-1&&(O=Ld);var K=void 0;["accuracy","acc"].indexOf(P)!==-1?K="acc":["crossentropy","ce"].indexOf(P)!==-1&&(K="ce"),D=O,C=I+K}else{var G=Y7(P);D=G,C=I+Zo(P)}var H;mi(C,function(){H=D}),g(b,C,H)},k=0,B=N;k0){var d=[];throw r.forEach(function(p,f){p==null&&d.push(e[f])}),new M("Cannot find SymbolicTensors for output name(s): "+(""+JSON.stringify(d)))}return r},t.prototype.predictLoop=function(e,r,i){var a=this;return r===void 0&&(r=32),i===void 0&&(i=!1),v.tidy(function(){var s=a.checkNumSamples(e);if(i)throw new Re("Verbose predictLoop() is not implemented yet.");for(var o=Rd(s,r),c=a.outputs.map(function(h){return[]}),l=function(h){var d=v.tidy(function(){var p=o[h][0],f=o[h][1],m=fs(e,p,f),g=[];if(Array.isArray(m))for(var y=0;y0&&e[0].shape[0]%a!==0)throw new M("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+(a+". Found: "+e[0].shape[0]+" sample(s)."));return[e,r]},t.prototype.standardizeUserData=function(e,r,i,a,s,o){return s===void 0&&(s=!0),Ae(this,void 0,void 0,function(){var c,l,u,h,d,p,f,m;return xe(this,function(g){switch(g.label){case 0:if(c=this.standardizeUserDataXY(e,r,s,o),l=c[0],u=c[1],i!=null)throw new Error("sample weight is not supported yet.");if(h=null,!(a!=null))return[3,4];d=Dv(a,this.outputNames),h=[],p=0,g.label=1;case 1:return p0)throw new Re("Verbose mode is not implemented yet.");if(s!=null)throw new Re("steps mode in testLoop() is not implemented yet");for(var u=Rd(c,i),h=v.tensor1d(Tn(0,c)),d=0;d1){var o=Uy(e.slice(0,i),a);s+="_"+o}r.push(s)}return r},t.prototype.makeTrainFunction=function(){var e=this;return function(r){var i=[],a=r.slice(0,e.inputs.length),s=r.slice(e.inputs.length,e.inputs.length+e.outputs.length),o=r.slice(e.inputs.length+e.outputs.length,e.inputs.length+e.outputs.length*2),c=[],l=function(){for(var p=[],f=0;f1&&f1)throw new M("Found more than one ("+i.length+") save handlers for "+("URL '"+e+"'"));e=i[0]}if(e.save==null)throw new M("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return[4,v.io.encodeWeights(this.getNamedWeights(r))];case 1:return a=b.sent(),s=!1,o=null,c=this.toJSON(o,s),l={modelTopology:c,format:v4,generatedBy:"TensorFlow.js tfjs-layers v"+Td,convertedBy:null},u=r==null?!1:r.includeOptimizer,u&&this.optimizer!=null?(l.trainingConfig=this.getTrainingConfig(),h="optimizer",g=(m=v.io).encodeWeights,[4,this.optimizer.getWeights()]):[3,4];case 2:return[4,g.apply(m,[b.sent(),h])];case 3:d=b.sent(),p=d.data,f=d.specs,(w=a.specs).push.apply(w,f),a.data=v.io.concatenateArrayBuffers([a.data,p]),b.label=4;case 4:return this.userDefinedMetadata!=null&&(y=!0,Cv(this.userDefinedMetadata,this.name,y),l.userDefinedMetadata=this.userDefinedMetadata),l.weightData=a.data,l.weightSpecs=a.specs,[2,e.save(l)]}})})},t.prototype.setUserDefinedMetadata=function(e){Cv(e,this.name),this.userDefinedMetadata=e},t.prototype.getUserDefinedMetadata=function(){return this.userDefinedMetadata},t.className="Model",t}(r4);v.serialization.registerClass(Fr);var w4=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.className="Functional",t}(Fr);v.serialization.registerClass(w4);function b4(n,t){return Ae(this,void 0,void 0,function(){var e,r,i,a,s,o,c,l;return xe(this,function(u){switch(u.label){case 0:return"modelTopology"in n||(n={modelTopology:n}),n=n,e=n.modelTopology,e.model_config!=null&&(e=e.model_config),r=ds(e),i=_n(r,t),n.weightsManifest!=null?[4,v.io.loadWeights(n.weightsManifest,n.pathPrefix,i.weights.map(function(h){return h.originalName}))]:[3,2];case 1:for(a=u.sent(),s={},o=0,c=i.weights;o1)throw new M("Found more than one ("+e.length+") load handlers for "+("URL '"+n+"'"));n=e[0]}return[2,x4(n,void 0,t)]})})}function x4(n,t,e){return Ae(this,void 0,void 0,function(){var r,i,a,s,o,c,l,u,h;return xe(this,function(d){switch(d.label){case 0:if(e==null&&(e={}),n.load==null)throw new M("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");return[4,n.load()];case 1:if(r=d.sent(),i=r.modelTopology,i.model_config!=null&&(i=i.model_config),a=e.strict==null?!0:e.strict,s=r.weightData!=null&&r.weightSpecs!=null&&a,o=_n(ds(i),t,s),c=r.trainingConfig,c!=null&&o.loadTrainingConfig(c),r.userDefinedMetadata!=null&&o.setUserDefinedMetadata(r.userDefinedMetadata),!(r.weightData!=null))return[3,4];if(r.weightSpecs==null)throw new M("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");return l=L4(r.weightData,r.weightSpecs),u=l.modelWeights,h=l.optimizerWeights,o.loadWeights(u,a),o.optimizer!=null&&h.length>0?[4,o.optimizer.setWeights(h)]:[3,3];case 2:d.sent(),d.label=3;case 3:v.dispose(u),v.dispose(h.map(function(p){return p.tensor})),d.label=4;case 4:return[2,o]}})})}function L4(n,t){var e=v.io.decodeWeights(n,t),r={},i=[];return t.forEach(function(a){a.group==="optimizer"?i.push({name:a.name,tensor:e[a.name]}):r[a.name]=e[a.name]}),{modelWeights:r,optimizerWeights:i}}var Ed=function(n){Q(t,n);function t(e){var r=n.call(this,{inputs:[],outputs:[]})||this;if(e=e||{},r.trainable=!0,r.built=!1,r.name=e.name!=null?e.name:Ho("sequential_"),e.layers!=null)for(var i=0,a=e.layers;i 0 "+("but got "+JSON.stringify(e.filters)))},t}(t1),Wd=function(n){Q(t,n);function t(e){var r=n.call(this,2,e)||this;return t.verifyArgs(e),r}return t.prototype.getConfig=function(){var e=n.prototype.getConfig.call(this);return delete e.rank,e},t.verifyArgs=function(e){if(typeof e.kernelSize!="number"&&!rd(e.kernelSize,"number",1,2))throw new M("Conv2D expects config.kernelSize to be number or number[] with "+("length 1 or 2, but received "+JSON.stringify(e.kernelSize)+"."))},t.className="Conv2D",t}(nc);v.serialization.registerClass(Wd);var n1=function(n){Q(t,n);function t(e){var r=n.call(this,3,e)||this;return t.verifyArgs(e),r}return t.prototype.getConfig=function(){var e=n.prototype.getConfig.call(this);return delete e.rank,e},t.verifyArgs=function(e){if(typeof e.kernelSize!="number"&&!(Array.isArray(e.kernelSize)&&(e.kernelSize.length===1||e.kernelSize.length===3)))throw new M("Conv3D expects config.kernelSize to be number or"+(" [number, number, number], but received "+JSON.stringify(e.kernelSize)+"."))},t.className="Conv3D",t}(nc);v.serialization.registerClass(n1);var r1=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;if(r.inputSpec=[new Rt({ndim:4})],r.padding!=="same"&&r.padding!=="valid")throw new M("Conv2DTranspose currently supports only padding modes 'same' "+("and 'valid', but received padding mode "+r.padding));return r}return t.prototype.build=function(e){var r;if(e=Xe(e),e.length!==4)throw new M("Input should have rank 4; Received input shape: "+JSON.stringify(e));var i=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[i]==null)throw new M("The channel dimension of the inputs should be defined. Found `None`.");var a=e[i],s=this.kernelSize.concat([this.filters,a]);this.kernel=this.addWeight("kernel",s,"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 Rt({ndim:4,axes:(r={},r[i]=a,r)})],this.built=!0},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){var a=Oe(e);if(a.shape.length!==4)throw new M("Conv2DTranspose.call() expects input tensor to be rank-4, but "+("received a tensor of rank-"+a.shape.length));var s=a.shape,o=s[0],c,l;i.dataFormat==="channelsFirst"?(c=2,l=3):(c=1,l=2);var u=s[c],h=s[l],d=i.kernelSize[0],p=i.kernelSize[1],f=i.strides[0],m=i.strides[1],g=tc(u,f,d,i.padding),y=tc(h,m,p,i.padding),w=[o,g,y,i.filters];i.dataFormat!=="channelsLast"&&(a=v.transpose(a,[0,2,3,1]));var b=v.conv2dTranspose(a,i.kernel.read(),w,i.strides,i.padding);return i.dataFormat!=="channelsLast"&&(b=v.transpose(b,[0,3,1,2])),i.bias!=null&&(b=qn(b,i.bias.read(),i.dataFormat)),i.activation!=null&&(b=i.activation.apply(b)),b})},t.prototype.computeOutputShape=function(e){e=Xe(e);var r=e.slice(),i,a,s;this.dataFormat==="channelsFirst"?(i=1,a=2,s=3):(i=3,a=1,s=2);var o=this.kernelSize[0],c=this.kernelSize[1],l=this.strides[0],u=this.strides[1];return r[i]=this.filters,r[a]=tc(r[a],l,o,this.padding),r[s]=tc(r[s],u,c,this.padding),r},t.prototype.getConfig=function(){var e=n.prototype.getConfig.call(this);return delete e.dilationRate,e},t.className="Conv2DTranspose",t}(Wd);v.serialization.registerClass(r1);var q4=function(n){Q(t,n);function t(e,r){var i=n.call(this,e,r)||this;if(i.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",i.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",i.depthwiseKernel=null,i.pointwiseKernel=null,r.filters==null)throw new M("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(r.kernelInitializer!=null||r.kernelRegularizer!=null||r.kernelConstraint!=null)throw new M("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(r.padding!=null&&r.padding!=="same"&&r.padding!=="valid")throw new M("SeparableConv"+i.rank+"D supports only padding modes: "+("'same' and 'valid', but received "+JSON.stringify(r.padding)));return i.depthMultiplier=r.depthMultiplier==null?1:r.depthMultiplier,i.depthwiseInitializer=at(r.depthwiseInitializer||i.DEFAULT_DEPTHWISE_INITIALIZER),i.depthwiseRegularizer=st(r.depthwiseRegularizer),i.depthwiseConstraint=Tt(r.depthwiseConstraint),i.pointwiseInitializer=at(r.depthwiseInitializer||i.DEFAULT_POINTWISE_INITIALIZER),i.pointwiseRegularizer=st(r.pointwiseRegularizer),i.pointwiseConstraint=Tt(r.pointwiseConstraint),i}return t.prototype.build=function(e){var r;if(e=Xe(e),e.length1&&(t=n.slice(1,n.length)),n=n[0]}function i(a){return a==null||Array.isArray(a)?a:[a]}return t=i(t),e=i(e),{inputs:n,initialState:t,constants:e}}function u1(n,t,e,r,i,a,s,o){return r===void 0&&(r=!1),s===void 0&&(s=!1),o===void 0&&(o=!1),v.tidy(function(){var c=t.shape.length;if(c<3)throw new M("Input should be at least 3D, but is "+c+"D.");var l=[1,0].concat(Tn(2,c));if(t=v.transpose(t,l),a!=null)throw new Re("The rnn() functoin of the deeplearn.js backend does not support constants yet.");s&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),i!=null&&(i=i.asType("bool").asType("float32"),i.rank===c-1&&(i=v.expandDims(i,-1)),i=v.transpose(i,l)),r&&(t=v.reverse(t,0),i!=null&&(i=v.reverse(i,0)));var u=[],h,d=e,p=t.shape[0],f=v.unstack(t),m;i!=null&&(m=v.unstack(i));for(var g=function(S){var x=f[S],N=v.tidy(function(){return n(x,d)});if(i==null)h=N[0],d=N[1];else{var I=v.tidy(function(){var C=m[S],O=v.onesLike(C).sub(C),D=N[0].mul(C).add(d[0].mul(O)),F=d.map(function(k,B){return N[1][B].mul(C).add(k.mul(O))});return{output:D,newStates:F}});h=I.output,d=I.newStates}o&&u.push(h)},y=0;y1?ad(i,[1,a]):i}):r.cell.stateSize>1?[ad(i,[1,r.cell.stateSize])]:[i]})},Object.defineProperty(t.prototype,"trainableWeights",{get:function(){return this.trainable?this.cell.trainableWeights:[]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nonTrainableWeights",{get:function(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights},enumerable:!0,configurable:!0}),t.prototype.setFastWeightInitDuringBuild=function(e){n.prototype.setFastWeightInitDuringBuild.call(this,e),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(e)},t.prototype.getConfig=function(){var e=n.prototype.getConfig.call(this),r={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(r.numConstants=this.numConstants);var i=this.cell.getConfig();return this.getClassName()===t.className&&(r.cell={className:this.cell.getClassName(),config:i}),Qt({},i,e,r)},t.fromConfig=function(e,r,i){i===void 0&&(i={});var a=r.cell,s=_n(a,i);return new e(Object.assign(r,{cell:s}))},t.className="RNN",t}(Fe);v.serialization.registerClass(Br);var ua=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t}(Fe),Bd=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;return r.DEFAULT_ACTIVATION="tanh",r.DEFAULT_KERNEL_INITIALIZER="glorotNormal",r.DEFAULT_RECURRENT_INITIALIZER="orthogonal",r.DEFAULT_BIAS_INITIALIZER="zeros",r.units=e.units,Ct(r.units,"units"),r.activation=Ur(e.activation==null?r.DEFAULT_ACTIVATION:e.activation),r.useBias=e.useBias==null?!0:e.useBias,r.kernelInitializer=at(e.kernelInitializer||r.DEFAULT_KERNEL_INITIALIZER),r.recurrentInitializer=at(e.recurrentInitializer||r.DEFAULT_RECURRENT_INITIALIZER),r.biasInitializer=at(e.biasInitializer||r.DEFAULT_BIAS_INITIALIZER),r.kernelRegularizer=st(e.kernelRegularizer),r.recurrentRegularizer=st(e.recurrentRegularizer),r.biasRegularizer=st(e.biasRegularizer),r.kernelConstraint=Tt(e.kernelConstraint),r.recurrentConstraint=Tt(e.recurrentConstraint),r.biasConstraint=Tt(e.biasConstraint),r.dropout=aa([1,Dr([0,e.dropout==null?0:e.dropout])]),r.recurrentDropout=aa([1,Dr([0,e.recurrentDropout==null?0:e.recurrentDropout])]),r.stateSize=r.units,r.dropoutMask=null,r.recurrentDropoutMask=null,r}return t.prototype.build=function(e){e=Xe(e),this.kernel=this.addWeight("kernel",[e[e.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},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){if(e=e,e.length!==2)throw new M("SimpleRNNCell expects 2 input Tensors, got "+e.length+".");var a=e[1];e=e[0];var s=r.training==null?!1:r.training;01){for(var s=[0],o=2;o1)throw new M("Can not merge tensors with different batch sizes. "+("Got tensors with shapes: "+JSON.stringify(e)+"."));for(var o=e[0]==null?null:e[0].slice(1),c=1;c1){var S=Tn(1,h).concat([0]);a.push(v.transpose(u,S)),p=!0}else a.push(u)}var x=i.mergeFunction(a),N=x.rank;if(p){if(N==null){var I=x.shape,C=I.length,y=I[C-1],w=[y].concat(I.slice(0,I.length-1));x=v.transpose(x.reshape([-1,y]),[1,0]).reshape(w)}else if(N>1){var S=[N-1].concat(Tn(0,N-1));x=v.transpose(x,S)}}return x}}else return i.mergeFunction(e)})},t.prototype.computeOutputShape=function(e){e=e;var r;e[0]==null?r=null:r=e[0].slice(1);for(var i=1;i1)throw new M("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))},t.prototype.mergeFunction=function(e){var r=this;return v.tidy(function(){return od(e,r.axis)})},t.prototype.computeOutputShape=function(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new M("A `Concatenate` layer should be called on a list of inputs.");for(var r=e,i=r[0].slice(),a=this.axis<0?i.length+this.axis:this.axis,s=0,o=r.slice(1);s3||t.shape.length>3)throw new Re("batchDot is not implemented for tensors of 4D or higher rank yet");if(v.util.assert(n.shape.length>=2,function(){return"batchDot requires the rank of x to be >= 2, "+("but got "+n.shape.length)}),v.util.assert(n.shape.length>=2,function(){return"batchDot requires the rank of y to be >= 2, "+("but got "+t.shape.length)}),typeof e=="number"&&(e=[e,e]),n.dtype==="complex64"||t.dtype==="complex64")throw new Re("batchDot is not implemented for complex64-type Tensors yet.");var r=n.shape.length,i=t.shape.length;e==null&&(e=[r-1,i-2]);var a=e;return v.tidy(function(){var s;if(r>i){s=r-i;for(var o=[],c=0;cr){s=i-r;for(var o=[],c=0;c0){var d=void 0;r>i?d=r+i-3:d=r-1;for(var p=[],c=d;c3||i.length>3)throw new Re("Dot layer does not support tensors of 4D or higher rank yet.");var a=this.interpretAxes(r,i);if(r[a[0]]!==i[a[1]])throw new M("Dimension incompatibility: "+(r[a[0]]+" !== "+i[a[1]]))},t.prototype.mergeFunction=function(e){if(e.length!==2)throw new M("A `Dot` layer must be called on exactly 2 inputs, "+("but received "+e.length+" input(s)."));var r=e[0],i=e[1],a;return Array.isArray(this.axes)?a=this.axes.map(function(s,o){return ms(s,e[o].shape.length)}):a=[ms(this.axes,r.shape.length),ms(this.axes,i.shape.length)],this.normalize&&(r=Yo(r,a[0]),i=Yo(i,a[1])),j4(r,i,a)},t.prototype.interpretAxes=function(e,r){var i;return Array.isArray(this.axes)?i=this.axes:i=[ms(this.axes,e.length),ms(this.axes,r.length)],i},t.prototype.computeOutputShape=function(e){v.util.assert(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."});var r=e[0].slice(),i=e[1].slice();if(r.length>3||i.length>3)throw new Re("Dot layer does not support tensors of 4D or higher rank yet.");var a=this.interpretAxes(r,i);r.splice(a[0],1),i.splice(a[1],1),i.splice(0,1);var s=r.concat(i);return s.length===1&&s.push(1),s},t.prototype.computeMask=function(e,r){return null},t.prototype.getConfig=function(){var e={axes:this.axes,normalize:this.normalize},r=n.prototype.getConfig.call(this);return Object.assign(e,r),e},t.className="Dot",t}(wi);v.serialization.registerClass(R1);var O1=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;return r.supportsMasking=!0,r.stddev=e.stddev,r}return t.prototype.computeOutputShape=function(e){return e},t.prototype.getConfig=function(){var e=n.prototype.getConfig.call(this),r={stddev:this.stddev};return Object.assign(r,e),r},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){i.invokeCallHook(e,r);var a=Oe(e),s=function(){return Po(a.shape,0,i.stddev).add(a)},o=ls(s,function(){return a},r.training||!1);return o})},t.className="GaussianNoise",t}(Fe);v.serialization.registerClass(O1);var E1=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;return r.supportsMasking=!0,r.rate=e.rate,r}return t.prototype.computeOutputShape=function(e){return e},t.prototype.getConfig=function(){var e=n.prototype.getConfig.call(this),r={rate:this.rate};return Object.assign(r,e),r},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){i.invokeCallHook(e,r);var a=Oe(e);if(i.rate>0&&i.rate<1){var s=function(){var o=Math.sqrt(i.rate/(1-i.rate));return a.mul(Po(a.shape,1,o))};return ls(s,function(){return a},r.training||!1)}return a})},t.className="GaussianDropout",t}(Fe);v.serialization.registerClass(E1);var D1=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;return r.supportsMasking=!0,r.rate=e.rate,r.noiseShape=e.noiseShape,r}return t.prototype._getNoiseShape=function(e){return this.noiseShape||Oe(e).shape},t.prototype.computeOutputShape=function(e){return e},t.prototype.getConfig=function(){var e=n.prototype.getConfig.call(this),r={rate:this.rate};return Object.assign(r,e),r},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){if(i.rate<1&&i.rate>0){var a=i._getNoiseShape(e),s=function(){var o=Oe(e),c=1.6732632423543772,l=1.0507009873554805,u=-c*l,h=v.greaterEqual(v.randomUniform(a),i.rate);h=ss(h,"float32");var d=Math.pow((1-i.rate)*(1+i.rate*Math.pow(u,2)),-.5),p=-d*u*i.rate,f=o.mul(h).add(h.add(-1).mul(u));return f.mul(d).add(p)};return ls(s,function(){return Oe(e)},r.training||!1)}return e})},t.className="AlphaDropout",t}(Fe);v.serialization.registerClass(D1);function gs(n,t,e,r,i,a){a===void 0&&(a=.001);var s;if(n.rank===2)s=v.batchNorm2d(n,t,e,r,i,a);else if(n.rank===3)s=v.batchNorm3d(n,t,e,r,i,a);else if(n.rank===4)s=v.batchNorm4d(n,t,e,r,i,a);else throw new Re("batchNormalization is not implemented for array of rank "+n.rank+" yet");return s}function K4(n,t,e,r,i){return i===void 0&&(i=.001),v.tidy(function(){var a=v.moments(n,r),s=a.mean,o=a.variance,c=gs(n,s,o,e,t,i);return[c,s,o]})}function $4(n,t,e,r,i){return i===void 0&&(i=.001),v.tidy(function(){for(var a=v.moments(n,r),s=a.mean,o=a.variance,c=[],l=0,u=Tn(0,n.rank);l=0?this.axis:this.axis+e.length,a=e[i];if(a==null)throw new M("Axis "+i+" of input tensor should have a defined dimension but the layer received an input with shape "+(JSON.stringify(e)+"."));this.inputSpec=[new Rt({ndim:e.length,axes:(r={},r[i]=a,r)})];var s=[a];this.scale&&(this.gamma=this.addWeight("gamma",s,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",s,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",s,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",s,null,this.movingVarianceInitializer,null,!1),this.built=!0},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){var a=r.training==null?!1:r.training,s=Oe(e),o=s.shape,c=o.length,l=Tn(0,c),u=i.axis>=0?i.axis:i.axis+c;l.splice(u,1);var h=pi(1,c);h[u]=o[u];var d=l.slice();d.sort();var p=!v.util.arraysEqual(d,Tn(0,c).slice(0,c-1)),f=function(){if(p){var x=i.movingMean.read().reshape(h),N=i.movingVariance.read().reshape(h),I=i.center?i.beta.read().reshape(h):null,C=i.scale?i.gamma.read().reshape(h):null;return gs(s,x,N,I,C,i.epsilon)}else return gs(s,i.movingMean.read(),i.movingVariance.read(),i.beta==null?null:i.beta.read(),i.gamma==null?null:i.gamma.read(),i.epsilon)};if(!a)return f();var m=X4(s,i.gamma.read(),i.beta.read(),l,i.epsilon),g=m[0],y=m[1],w=m[2],b=function(x,N,I){v.tidy(function(){var C=1-I,O=x.read(),D=O.sub(N).mul(C);x.write(O.sub(D))})},S=function(){b(i.movingMean,y,i.momentum),b(i.movingVariance,w,i.momentum)};return S(),g})},t.prototype.getConfig=function(){var e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:lt(this.betaInitializer),gammaInitializer:lt(this.gammaInitializer),movingMeanInitializer:lt(this.movingMeanInitializer),movingVarianceInitializer:lt(this.movingVarianceInitializer),betaRegularizer:Je(this.betaRegularizer),gammaRegularizer:Je(this.gammaRegularizer),betaConstraint:At(this.betaConstraint),gammaConstraint:At(this.gammaConstraint)},r=n.prototype.getConfig.call(this);return Object.assign(e,r),e},t.className="BatchNormalization",t}(Fe);v.serialization.registerClass(k1);var F1=function(n){Q(t,n);function t(e){var r=this;if(e==null&&(e={}),r=n.call(this,e)||this,r.axis=e.axis==null?-1:e.axis,typeof r.axis=="number"){if(!Number.isInteger(r.axis))throw new Error("Expected axis to be an integer, but received "+r.axis)}else if(Array.isArray(r.axis))for(var i=0,a=r.axis;i=r)throw new Error("Invalid axis: "+o)}if(this.axis.length!==Or(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);var c=this.axis.map(function(u){return e[u]}),l=!0;this.scale?this.gamma=this.addWeight("gamma",c,"float32",this.gammaInitializer,this.gammaRegularizer,l):this.gamma=null,this.center?this.beta=this.addWeight("beta",c,"float32",this.betaInitializer,this.betaRegularizer,l):this.beta=null,this.built=!0},t.prototype.call=function(e,r){var i=this,a=Oe(e),s=a.shape,o=s.length;return v.tidy(function(){for(var c=!0,l=v.moments(a,i.axis,c),u=l.mean,h=l.variance,d=pi(1,o),p=0,f=i.axis;p=0?r=e[2]+this.padding[0][0]+this.padding[0][1]:r=null,e[3]!=null&&e[3]>=0?i=e[3]+this.padding[1][0]+this.padding[1][1]:i=null,[e[0],e[1],r,i]):(e[1]!=null&&e[1]>=0?r=e[1]+this.padding[0][0]+this.padding[0][1]:r=null,e[2]!=null&&e[2]>=0?i=e[2]+this.padding[1][0]+this.padding[1][1]:i=null,[e[0],r,i,e[3]])},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){return J4(Oe(e),i.padding,i.dataFormat)})},t.prototype.getConfig=function(){var e={padding:this.padding,dataFormat:this.dataFormat},r=n.prototype.getConfig.call(this);return Object.assign(e,r),e},t.className="ZeroPadding2D",t}(Fe);v.serialization.registerClass(W1);function ic(n,t,e,r,i,a){return v.tidy(function(){yt(i),Yy(a),ln(r),e==null&&(e=[1,1]),r==null&&(r="valid"),i==null&&(i=An()),a==null&&(a="max"),n=Fd(n,i);var s,o=r==="same"?"same":"valid";return a==="max"?s=v.maxPool(n,t,e,o):s=v.avgPool(n,t,e,o),i==="channelsFirst"&&(s=v.transpose(s,[0,3,1,2])),s})}function U1(n,t,e,r,i,a){return v.tidy(function(){yt(i),Yy(a),ln(r),e==null&&(e=[1,1,1]),r==null&&(r="valid"),i==null&&(i=An()),a==null&&(a="max"),n=Qv(n,i);var s,o=r==="same"?"same":"valid";return a==="max"?s=v.maxPool3d(n,t,e,o):s=v.avgPool3d(n,t,e,o),i==="channelsFirst"&&(s=v.transpose(s,[0,4,1,2,3])),s})}var B1=function(n){Q(t,n);function t(e){var r=this;if(e.poolSize==null&&(e.poolSize=2),r=n.call(this,e)||this,typeof e.poolSize=="number")r.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")r.poolSize=e.poolSize;else throw new M("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+(""+JSON.stringify(e.poolSize)));if(Ct(r.poolSize,"poolSize"),e.strides==null)r.strides=r.poolSize;else if(typeof e.strides=="number")r.strides=[e.strides];else if(Array.isArray(e.strides)&&e.strides.length===1&&typeof e.strides[0]=="number")r.strides=e.strides;else throw new M("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+(""+JSON.stringify(e.strides)));return Ct(r.strides,"strides"),r.padding=e.padding==null?"valid":e.padding,ln(r.padding),r.inputSpec=[new Rt({ndim:3})],r}return t.prototype.computeOutputShape=function(e){e=Xe(e);var r=Cn(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],r,e[2]]},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){i.invokeCallHook(e,r),e=os(Oe(e),2);var a=i.poolingFunction(Oe(e),[i.poolSize[0],1],[i.strides[0],1],i.padding,"channelsLast");return v.squeeze(a,[2])})},t.prototype.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},r=n.prototype.getConfig.call(this);return Object.assign(e,r),e},t}(Fe),z1=function(n){Q(t,n);function t(e){return n.call(this,e)||this}return t.prototype.poolingFunction=function(e,r,i,a,s){return yt(s),ln(a),ic(e,r,i,a,s,"max")},t.className="MaxPooling1D",t}(B1);v.serialization.registerClass(z1);var P1=function(n){Q(t,n);function t(e){return n.call(this,e)||this}return t.prototype.poolingFunction=function(e,r,i,a,s){return yt(s),ln(a),ic(e,r,i,a,s,"avg")},t.className="AveragePooling1D",t}(B1);v.serialization.registerClass(P1);var M1=function(n){Q(t,n);function t(e){var r=this;if(e.poolSize==null&&(e.poolSize=[2,2]),r=n.call(this,e)||this,r.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)r.strides=r.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new M("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length "+(e.strides.length+"."));r.strides=e.strides}else r.strides=[e.strides,e.strides];return Ct(r.poolSize,"poolSize"),Ct(r.strides,"strides"),r.padding=e.padding==null?"valid":e.padding,r.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,yt(r.dataFormat),ln(r.padding),r.inputSpec=[new Rt({ndim:4})],r}return t.prototype.computeOutputShape=function(e){e=Xe(e);var r=this.dataFormat==="channelsFirst"?e[2]:e[1],i=this.dataFormat==="channelsFirst"?e[3]:e[2];return r=Cn(r,this.poolSize[0],this.padding,this.strides[0]),i=Cn(i,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[e[0],e[1],r,i]:[e[0],r,i,e[3]]},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){return i.invokeCallHook(e,r),i.poolingFunction(Oe(e),i.poolSize,i.strides,i.padding,i.dataFormat)})},t.prototype.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},r=n.prototype.getConfig.call(this);return Object.assign(e,r),e},t}(Fe),H1=function(n){Q(t,n);function t(e){return n.call(this,e)||this}return t.prototype.poolingFunction=function(e,r,i,a,s){return yt(s),ln(a),ic(e,r,i,a,s,"max")},t.className="MaxPooling2D",t}(M1);v.serialization.registerClass(H1);var V1=function(n){Q(t,n);function t(e){return n.call(this,e)||this}return t.prototype.poolingFunction=function(e,r,i,a,s){return yt(s),ln(a),ic(e,r,i,a,s,"avg")},t.className="AveragePooling2D",t}(M1);v.serialization.registerClass(V1);var q1=function(n){Q(t,n);function t(e){var r=this;if(e.poolSize==null&&(e.poolSize=[2,2,2]),r=n.call(this,e)||this,r.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)r.strides=r.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new M("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length "+(e.strides.length+"."));r.strides=e.strides}else r.strides=[e.strides,e.strides,e.strides];return Ct(r.poolSize,"poolSize"),Ct(r.strides,"strides"),r.padding=e.padding==null?"valid":e.padding,r.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,yt(r.dataFormat),ln(r.padding),r.inputSpec=[new Rt({ndim:5})],r}return t.prototype.computeOutputShape=function(e){e=Xe(e);var r=this.dataFormat==="channelsFirst"?e[2]:e[1],i=this.dataFormat==="channelsFirst"?e[3]:e[2],a=this.dataFormat==="channelsFirst"?e[4]:e[3];return r=Cn(r,this.poolSize[0],this.padding,this.strides[0]),i=Cn(i,this.poolSize[1],this.padding,this.strides[1]),a=Cn(a,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],r,i,a]:[e[0],r,i,a,e[4]]},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){return i.invokeCallHook(e,r),i.poolingFunction(Oe(e),i.poolSize,i.strides,i.padding,i.dataFormat)})},t.prototype.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},r=n.prototype.getConfig.call(this);return Object.assign(e,r),e},t}(Fe),G1=function(n){Q(t,n);function t(e){return n.call(this,e)||this}return t.prototype.poolingFunction=function(e,r,i,a,s){return yt(s),ln(a),U1(e,r,i,a,s,"max")},t.className="MaxPooling3D",t}(q1);v.serialization.registerClass(G1);var Y1=function(n){Q(t,n);function t(e){return n.call(this,e)||this}return t.prototype.poolingFunction=function(e,r,i,a,s){return yt(s),ln(a),U1(e,r,i,a,s,"avg")},t.className="AveragePooling3D",t}(q1);v.serialization.registerClass(Y1);var j1=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;return r.inputSpec=[new Rt({ndim:3})],r}return t.prototype.computeOutputShape=function(e){return[e[0],e[2]]},t.prototype.call=function(e,r){throw new Re},t}(Fe),K1=function(n){Q(t,n);function t(e){return n.call(this,e||{})||this}return t.prototype.call=function(e,r){return v.tidy(function(){var i=Oe(e);return v.mean(i,1)})},t.className="GlobalAveragePooling1D",t}(j1);v.serialization.registerClass(K1);var $1=function(n){Q(t,n);function t(e){return n.call(this,e||{})||this}return t.prototype.call=function(e,r){return v.tidy(function(){var i=Oe(e);return v.max(i,1)})},t.className="GlobalMaxPooling1D",t}(j1);v.serialization.registerClass($1);var X1=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;return r.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,yt(r.dataFormat),r.inputSpec=[new Rt({ndim:4})],r}return t.prototype.computeOutputShape=function(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]},t.prototype.call=function(e,r){throw new Re},t.prototype.getConfig=function(){var e={dataFormat:this.dataFormat},r=n.prototype.getConfig.call(this);return Object.assign(e,r),e},t}(Fe),J1=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.call=function(e,r){var i=this;return v.tidy(function(){var a=Oe(e);return i.dataFormat==="channelsLast"?v.mean(a,[1,2]):v.mean(a,[2,3])})},t.className="GlobalAveragePooling2D",t}(X1);v.serialization.registerClass(J1);var Z1=function(n){Q(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.call=function(e,r){var i=this;return v.tidy(function(){var a=Oe(e);return i.dataFormat==="channelsLast"?v.max(a,[1,2]):v.max(a,[2,3])})},t.className="GlobalMaxPooling2D",t}(X1);v.serialization.registerClass(Z1);var Q1=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;return r.layer=e.layer,r}return t.prototype.build=function(e){this.built=!0},Object.defineProperty(t.prototype,"trainable",{get:function(){return this.layer!=null?this.layer.trainable:!1},set:function(e){this.layer!=null&&(this.layer.trainable=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"trainableWeights",{get:function(){return this.layer.trainableWeights},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nonTrainableWeights",{get:function(){return this.layer.nonTrainableWeights},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"updates",{get:function(){return this.layer._updates},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"losses",{get:function(){return this.layer.losses},enumerable:!0,configurable:!0}),t.prototype.getWeights=function(){return this.layer.getWeights()},t.prototype.setWeights=function(e){this.layer.setWeights(e)},t.prototype.getConfig=function(){var e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},r=n.prototype.getConfig.call(this);return Object.assign(e,r),e},t.prototype.setFastWeightInitDuringBuild=function(e){n.prototype.setFastWeightInitDuringBuild.call(this,e),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(e)},t.fromConfig=function(e,r,i){i===void 0&&(i={});var a=r.layer,s=_n(a,i);delete r.layer;var o={layer:s};return Object.assign(o,r),new e(o)},t}(Fe),ew=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this;return r.supportsMasking=!0,r}return t.prototype.build=function(e){if(e=Xe(e),e.length<3)throw new M("TimeDistributed layer expects an input shape >= 3D, but received "+("input shape "+JSON.stringify(e)));this.inputSpec=[{shape:e}];var r=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(r),this.layer.built=!0),n.prototype.build.call(this,e)},t.prototype.computeOutputShape=function(e){e=Xe(e);var r=[e[0]].concat(e.slice(2)),i=this.layer.computeOutputShape(r),a=e[1];return[i[0],a].concat(i.slice(1))},t.prototype.call=function(e,r){var i=this;return v.tidy(function(){e=Oe(e);var a=function(c,l){var u=Oe(i.layer.call(c,r));return[u,[]]},s=u1(a,e,[],!1,null,null,!1,!0),o=s[1];return o})},t.className="TimeDistributed",t}(Q1);v.serialization.registerClass(ew);function Z4(n){ra(VE,"BidirectionalMergeMode",n)}var Q4="concat",tw=function(n){Q(t,n);function t(e){var r=n.call(this,e)||this,i=e.layer.getConfig(),a={};a.className=e.layer.getClassName(),a.config=i,r.forwardLayer=_n(a),i.goBackwards=!(i.goBackwards===!0);var s={};if(s.className=e.layer.getClassName(),s.config=i,r.backwardLayer=_n(s),r.forwardLayer.name="forward_"+r.forwardLayer.name,r.backwardLayer.name="backward_"+r.backwardLayer.name,r.mergeMode=e.mergeMode===void 0?Q4:e.mergeMode,Z4(r.mergeMode),e.weights)throw new Re("weights support is not implemented for Bidirectional layer yet.");return r._stateful=e.layer.stateful,r.returnSequences=e.layer.returnSequences,r.returnState=e.layer.returnState,r.supportsMasking=!0,r._trainable=!0,r.inputSpec=e.layer.inputSpec,r.numConstants=null,r}return Object.defineProperty(t.prototype,"trainable",{get:function(){return this._trainable},set:function(e){this._trainable=e,this.forwardLayer!=null&&(this.forwardLayer.trainable=e),this.backwardLayer!=null&&(this.backwardLayer.trainable=e)},enumerable:!0,configurable:!0}),t.prototype.getWeights=function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())},t.prototype.setWeights=function(e){var r=e.length,i=Math.floor(r/2);this.forwardLayer.setWeights(e.slice(0,i)),this.backwardLayer.setWeights(e.slice(i))},t.prototype.computeOutputShape=function(e){var r=this.forwardLayer.computeOutputShape(e);Array.isArray(r)&&Array.isArray(r[0])||(r=[r]),r=r;var i,a,s;return this.returnState&&(s=r.slice(1)),i=r[0],i=i,this.mergeMode==="concat"?(i[i.length-1]*=2,a=[i]):this.mergeMode==null?a=[i,i.slice()]:a=[i],this.returnState?this.mergeMode==null?a.concat(s).concat(s.slice()):[i].concat(s).concat(s.slice()):Yt(a)},t.prototype.apply=function(e,r){var i=r==null?null:r.initialState,a=r==null?null:r.constants;r==null&&(r={});var s=l1(e,i,a,this.numConstants);if(e=s.inputs,i=s.initialState,a=s.constants,Array.isArray(e)&&(i=e.slice(1),e=e[0]),(i==null||i.length===0)&&a==null)return n.prototype.apply.call(this,e,r);var o=[],c=[];if(i!=null){var l=i.length;if(l%2>0)throw new M("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");r.initialState=i,o.push.apply(o,i);var u=i.map(function(b){return new Rt({shape:b.shape})});this.forwardLayer.stateSpec=u.slice(0,l/2),this.backwardLayer.stateSpec=u.slice(l/2),c.push.apply(c,u)}if(a!=null)throw new Re("Support for constants in Bidirectional layers is not implemented yet.");for(var h=o[0]instanceof Nn,d=0,p=o;dt}var cw=function(n){Q(t,n);function t(e){var r=n.call(this)||this;if(e==null&&(e={}),e.restoreBestWeights)throw new Re("restoreBestWeights = True is not implemented in EarlyStopping yet.");return r.monitor=e.monitor||"val_loss",r.minDelta=Math.abs(e.minDelta||0),r.patience=e.patience||0,r.verbose=e.verbose||0,r.mode=e.mode||"auto",r.baseline=e.baseline,["auto","min","max"].indexOf(r.mode)===-1&&(console.warn("EarlyStopping mode '"+r.mode+"' is invalid. Falling back to mode 'auto'."),r.mode="auto"),r.mode==="min"?r.monitorFunc=ac:r.mode==="max"||r.monitor.indexOf("acc")!==-1?r.monitorFunc=ow:r.monitorFunc=ac,r.monitorFunc===ac&&(r.minDelta*=-1),r}return t.prototype.onTrainBegin=function(e){return Ae(this,void 0,void 0,function(){return xe(this,function(r){return this.wait=0,this.stoppedEpoch=0,this.baseline!=null?this.best=this.baseline:this.best=this.monitorFunc===ac?Infinity:-Infinity,[2]})})},t.prototype.onEpochEnd=function(e,r){return Ae(this,void 0,void 0,function(){var i;return xe(this,function(a){switch(a.label){case 0:return[4,kr(r)];case 1:return a.sent(),i=this.getMonitorValue(r),i==null?[2]:(this.monitorFunc(i-this.minDelta,this.best)?(this.best=i,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0)),[2])}})})},t.prototype.onTrainEnd=function(e){return Ae(this,void 0,void 0,function(){return xe(this,function(r){return this.stoppedEpoch>0&&this.verbose&&console.log("Epoch "+this.stoppedEpoch+": early stopping."),[2]})})},t.prototype.getMonitorValue=function(e){e==null&&(e={});var r=e[this.monitor];return r==null&&console.warn("Metric for EarlyStopping "+this.monitor+" is not available. "+("Available metrics are: "+Object.keys(e))),r},t}(sw);function Ok(n){return new cw(n)}var Ek={earlyStopping:Ok};tt.Callback=sw;tt.CallbackList=yv;tt.CustomCallback=wv;tt.EarlyStopping=cw;tt.History=vv;tt.InputSpec=Rt;tt.LayerVariable=dv;tt.LayersModel=Fr;tt.RNN=Br;tt.Sequential=Ed;tt.SymbolicTensor=Nn;tt.callbacks=Ek;tt.constraints=zE;tt.initializers=w7;tt.input=Hv;tt.layers=lk;tt.loadLayersModel=T4;tt.metrics=Ak;tt.model=I4;tt.models=Tk;tt.registerCallbackConstructor=N4;tt.regularizers=Rk;tt.sequential=A4;tt.version_layers=Td}),Iw=we(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});var W=di();var uw=Object.assign||function(t){for(var e,r=1,i=arguments.length;r0&&a[a.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]0)&&!(i=r.next()).done;)a.push(i.value)}catch(o){s={error:o}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return a}function Pr(){for(var n=[],t=0;t0?Object.keys(h).forEach(function(g){var y=vt(cr(g),1),w=y[0],b=c[w];b&&(b.signatureKey=h[g],l.push(b))}):l=a;var f={};t.library!=null&&t.library.function!=null&&(f=t.library.function.reduce(function(g,y){return g[y.signature.name]=r.mapFunction(y),g},{}));var m={nodes:c,inputs:l,outputs:u,weights:s,placeholders:a,signature:e,functions:f};return o.length>0&&(m.initNodes=o),m},n.prototype.mapSignatureEntries=function(t){return Object.keys(t||{}).reduce(function(e,r){return e[t[r].name]=r,e},{})},n.prototype.mapNode=function(t){var e=dw(t.op)||this.opMappers[t.op]||{};t.attr==null&&(t.attr={});var r={name:t.name,op:t.op,category:e.category,inputNames:(t.input||[]).map(function(i){return i.startsWith("^")?i.substr(1):i}),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:t.attr};return e.inputs!=null&&(r.inputParams=e.inputs.reduce(function(i,a){return i[a.name]={type:a.type,inputIndexStart:a.start,inputIndexEnd:a.end},i},{})),e.attrs!=null&&(r.attrParams=e.attrs.reduce(function(i,a){var s=a.type,o=void 0;switch(a.type){case"string":o=Yd(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=Yd(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"string[]":o=ep(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=ep(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"number":o=Kd(t.attr,a.tfName,a.defaultValue||0),o===void 0&&!!a.tfDeprecatedName&&(o=Kd(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"number[]":o=Qd(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=Qd(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"bool":o=jd(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=jd(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"bool[]":o=np(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=np(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"shape":o=Zd(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=Zd(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"shape[]":o=tp(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=tp(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"dtype":o=Xd(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=Xd(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"dtype[]":o=Jd(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=Jd(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"func":o=pw(t.attr,a.tfName,a.defaultValue),o===void 0&&!!a.tfDeprecatedName&&(o=pw(t.attr,a.tfDeprecatedName,a.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: "+a.type+" for op: "+t.op)}return i[a.name]={value:o,type:s},i},{})),r},n.prototype.mapFunction=function(t){var e=this,r=t.nodeDef,i=[],a=[],s={};r!=null&&(s=r.reduce(function(d,p){return d[p.name]=e.mapNode(p),p.op==="Const"&&a.push(d[p.name]),d},{}));var o=[],c=[];t.signature.inputArg.forEach(function(d){var p=vt(cr(d.name),1),f=p[0],m={name:f,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:$d(d.type),type:"dtype"}},children:[]};m.signatureKey=d.name,o.push(m),s[f]=m});var l=Object.keys(s);l.forEach(function(d){var p=s[d];p.inputNames.forEach(function(f){var m=vt(cr(f),1),g=m[0];p.inputs.push(s[g]),s[g].children.push(p)})});var u=t.ret;t.signature.outputArg.forEach(function(d){var p=vt(cr(u[d.name]),2),f=p[0],m=p[1],g=s[f];g!=null&&(g.defaultOutput=m,c.push(g))});var h=this.mapArgsToSignature(t);return{nodes:s,inputs:o,outputs:c,weights:a,placeholders:i,signature:h}},n.prototype.mapArgsToSignature=function(t){var e=this;return{methodName:t.signature.name,inputs:t.signature.inputArg.reduce(function(r,i){return r[i.name]=e.mapArgToTensorInfo(i),r},{}),outputs:t.signature.outputArg.reduce(function(r,i){return r[i.name]=e.mapArgToTensorInfo(i,t.ret),r},{})}},n.prototype.mapArgToTensorInfo=function(t,e){var r=t.name;return e!=null&&(r=e[r]),{name:r,dtype:t.type}},n}();function g6(n){var t=W.env().global;if(typeof t.atob!="undefined")return t.atob(n);if(typeof Buffer!="undefined")return new Buffer(n,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}function mw(n,t){var e=Array.isArray(n)?String.fromCharCode.apply(null,n):g6(n);return t?e:e.toLowerCase()}function Yd(n,t,e,r){r===void 0&&(r=!1);var i=n[t];return i!=null?mw(i.s,r):e}function jd(n,t,e){var r=n[t];return r?r.b:e}function Kd(n,t,e){var r=n[t]||{},i=r.i!=null?r.i:r.f!=null?r.f:e;return typeof i=="number"?i:parseInt(i,10)}function $d(n){typeof n=="string"&&(n=Rn[n]);switch(n){case Rn.DT_FLOAT:return"float32";case Rn.DT_INT32:case Rn.DT_INT64:case Rn.DT_INT8:case Rn.DT_UINT8:return"int32";case Rn.DT_BOOL:return"bool";case Rn.DT_DOUBLE:return"float32";case Rn.DT_STRING:return"string";default:return null}}function pw(n,t,e){var r=n[t];return r&&r.func?r.func.name:e}function Xd(n,t,e){var r=n[t];return r&&r.type?$d(r.type):e}function Jd(n,t,e){var r=n[t];return r&&r.list&&r.list.type?r.list.type.map(function(i){return $d(i)}):e}function gw(n){return n.unknownRank?void 0:n.dim!=null?n.dim.map(function(t){return typeof t.size=="number"?t.size:parseInt(t.size,10)}):[]}function Zd(n,t,e){var r=n[t];return r&&r.shape?gw(r.shape):e}function Qd(n,t,e){var r=n[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map(function(i){return typeof i=="number"?i:parseInt(i,10)}):e}function ep(n,t,e,r){r===void 0&&(r=!1);var i=n[t];return i&&i.list&&i.list.s?i.list.s.map(function(a){return mw(a,r)}):e}function tp(n,t,e){var r=n[t];return r&&r.list&&r.list.shape?r.list.shape.map(function(i){return gw(i)}):e}function np(n,t,e){var r=n[t];return r&&r.list&&r.list.b?r.list.b:e}var y6=function(){function n(t,e,r){var i=this;this.node=t,this.tensorMap=e,this.context=r,this.inputs=[],this.attrs={},this.inputs=t.inputNames.map(function(a){return i.getInput(a)}),t.rawAttrs!=null&&(this.attrs=Object.keys(t.rawAttrs).reduce(function(a,s){return a[s]=i.getAttr(s),a},{}))}return n.prototype.getInput=function(t){return jt(t,this.tensorMap,this.context)},n.prototype.getAttr=function(t,e){var r=this.node.rawAttrs[t];if(r.tensor!=null)return jt(t,this.tensorMap,this.context);if(r.i!=null||r.f!=null)return Kd(this.node.rawAttrs,t,e);if(r.s!=null)return Yd(this.node.rawAttrs,t,e);if(r.b!=null)return jd(this.node.rawAttrs,t,e);if(r.shape!=null)return Zd(this.node.rawAttrs,t,e);if(r.type!=null)return Xd(this.node.rawAttrs,t,e);if(r.list!=null){if(r.list.i!=null||r.list.f!=null)return Qd(this.node.rawAttrs,t,e);if(r.list.s!=null)return ep(this.node.rawAttrs,t,e);if(r.list.shape!=null)return tp(this.node.rawAttrs,t,e);if(r.list.b!=null)return np(this.node.rawAttrs,t,e);if(r.list.type!=null)return Jd(this.node.rawAttrs,t,e)}return e},n}();var v6=function(n,t,e){switch(n.op){case"BiasAdd":case"AddV2":case"Add":return[W.add(T("a",n,t,e),T("b",n,t,e))];case"AddN":return[W.addN(T("tensors",n,t,e))];case"FloorMod":case"Mod":return[W.mod(T("a",n,t,e),T("b",n,t,e))];case"Mul":return[W.mul(T("a",n,t,e),T("b",n,t,e))];case"RealDiv":case"Div":return[W.div(T("a",n,t,e),T("b",n,t,e))];case"DivNoNan":return[W.divNoNan(T("a",n,t,e),T("b",n,t,e))];case"FloorDiv":return[W.floorDiv(T("a",n,t,e),T("b",n,t,e))];case"Sub":return[W.sub(T("a",n,t,e),T("b",n,t,e))];case"Minimum":return[W.minimum(T("a",n,t,e),T("b",n,t,e))];case"Maximum":return[W.maximum(T("a",n,t,e),T("b",n,t,e))];case"Pow":return[W.pow(T("a",n,t,e),T("b",n,t,e))];case"SquaredDifference":return[W.squaredDifference(T("a",n,t,e),T("b",n,t,e))];default:throw TypeError("Node type "+n.op+" is not implemented")}};var w6=function(n,t,e){switch(n.op){case"Abs":case"ComplexAbs":return[W.abs(T("x",n,t,e))];case"Acos":return[W.acos(T("x",n,t,e))];case"Acosh":return[W.acosh(T("x",n,t,e))];case"Asin":return[W.asin(T("x",n,t,e))];case"Asinh":return[W.asinh(T("x",n,t,e))];case"Atan":return[W.atan(T("x",n,t,e))];case"Atan2":return[W.atan2(T("x",n,t,e),T("y",n,t,e))];case"Atanh":return[W.atanh(T("x",n,t,e))];case"Ceil":return[W.ceil(T("x",n,t,e))];case"Complex":return[W.complex(T("real",n,t,e),T("imag",n,t,e))];case"Cos":return[W.cos(T("x",n,t,e))];case"Cosh":return[W.cosh(T("x",n,t,e))];case"Elu":return[W.elu(T("x",n,t,e))];case"Erf":return[W.erf(T("x",n,t,e))];case"Exp":return[W.exp(T("x",n,t,e))];case"Expm1":return[W.expm1(T("x",n,t,e))];case"Floor":return[W.floor(T("x",n,t,e))];case"Log":return[W.log(T("x",n,t,e))];case"Log1p":return[W.log1p(T("x",n,t,e))];case"Imag":return[W.imag(T("x",n,t,e))];case"Neg":return[W.neg(T("x",n,t,e))];case"Reciprocal":return[W.reciprocal(T("x",n,t,e))];case"Real":return[W.real(T("x",n,t,e))];case"Relu":return[W.relu(T("x",n,t,e))];case"Round":return[W.round(T("x",n,t,e))];case"Selu":return[W.selu(T("x",n,t,e))];case"Sigmoid":return[W.sigmoid(T("x",n,t,e))];case"Sin":return[W.sin(T("x",n,t,e))];case"Sign":return[W.sign(T("x",n,t,e))];case"Sinh":return[W.sinh(T("x",n,t,e))];case"Softplus":return[W.softplus(T("x",n,t,e))];case"Sqrt":return[W.sqrt(T("x",n,t,e))];case"Square":return[W.square(T("x",n,t,e))];case"Tanh":return[W.tanh(T("x",n,t,e))];case"Tan":return[W.tan(T("x",n,t,e))];case"Relu6":case"ClipByValue":return[W.clipByValue(T("x",n,t,e),T("clipValueMin",n,t,e),T("clipValueMax",n,t,e))];case"Rsqrt":return[W.rsqrt(jt(n.inputNames[0],t,e))];case"Prod":return[W.prod(T("x",n,t,e),T("axes",n,t,e))];case"LeakyRelu":return[W.leakyRelu(T("x",n,t,e),T("alpha",n,t,e))];case"Prelu":return[W.prelu(T("x",n,t,e),T("alpha",n,t,e))];default:throw TypeError("Node type "+n.op+" is not implemented")}};function yn(n,t,e){e===void 0&&(e=""),W.util.assert(b6(n,t),function(){return e+(" Shapes "+n+" and "+t+" must match")})}function b6(n,t){if(n.length!==t.length)return!1;for(var e=0;e=this.size())throw new Error("Tried to read from index "+t+", but array size is: "+this.size());var e=this.tensors[t];if(e.cleared)throw new Error("TensorArray "+this.name+": Could not read index "+t+" twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).");return this.clearAfterRead&&(e.cleared=!0),e.read=!0,e.tensor},n.prototype.readMany=function(t){var e=this;return t.map(function(r){return e.read(r)})},n.prototype.write=function(t,e){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(t<0||!this.dynamicSize&&t>=this.maxSize)throw new Error("Tried to write to index "+t+", but array is not resizeable and size is: "+this.maxSize);var r=this.tensors[t]||{};if(e.dtype!==this.dtype)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+`, because the value dtype is `+e.dtype+", but TensorArray dtype is "+this.dtype+".");if(this.size()===0&&(this.elementShape==null||this.elementShape.length===0)&&(this.elementShape=e.shape),yn(this.elementShape,e.shape,"TensorArray "+this.name+": Could not write to TensorArray index "+t+"."),r.read)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+", because it has already been read.");if(r.written)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+", because it has already been written.");r.tensor=e,W.keep(e),r.written=!0,this.tensors[t]=r},n.prototype.writeMany=function(t,e){var r=this;if(t.length!==e.length)throw new Error("TensorArray "+this.name+": could not write multiple tensors,"+("because the index size: "+t.length+" is not the same as tensors size: "+e.length+"."));t.forEach(function(i,a){return r.write(i,e[a])})},n.prototype.gather=function(t,e){if(!!e&&e!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but gather requested dtype "+e);if(t)t=t.slice(0,this.size());else{t=[];for(var r=0;r=this.maxSize)throw new Error("Max index must be < array size ("+r+" vs. "+this.maxSize+")");this.writeMany(t,W.unstack(e,0))},n.prototype.split=function(t,e){var r=this;if(e.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+e.dtype);var i=0,a=t.map(function(u){return i+=u,i});if(i!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to tensor.shape[0], but sum of lengths is `+i+", and tensor's shape is: "+e.shape);if(!this.dynamicSize&&t.length!==this.maxSize)throw new Error("TensorArray's size is not equal to the size of lengths ("+this.maxSize+" vs. "+t.length+"), and the TensorArray is not marked as dynamically resizeable");var s=i===0?0:e.size/i,o=[];W.tidy(function(){e=W.reshape(e,[1,i,s]);for(var u=0;uthis.maxNumElements)throw new Error("TensorListResize input size "+t+" is greater maxNumElement "+this.maxNumElements+".");this.tensors.length=t},n.prototype.getItem=function(t,e,r){if(r!==this.elementDtype)throw new Error("Invalid data types; op elements "+r+", but list elements "+this.elementDtype);if(t<0||t>this.tensors.length)throw new Error("Trying to access element "+t+" in a list with "+this.tensors.length+" elements.");if(this.tensors[t]==null)throw new Error("element at index "+t+" is null.");return yn(this.tensors[t].shape,e,"TensorList shape mismatch: "),this.tensors[t]},n.prototype.setItem=function(t,e){if(e.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+e.dtype+", but list elements "+this.elementDtype);if(t<0||this.maxNumElements!==-1&&t>=this.maxNumElements)throw new Error("Trying to set element "+t+" in a list with max "+this.maxNumElements+" elements.");yn(this.elementShape,e.shape,"TensorList shape mismatch: "),W.keep(e),this.tensors[t]=e},n.prototype.gather=function(t,e,r){var i=this;if(e!==this.elementDtype)throw new Error("Invalid data types; op elements "+e+", but list elements "+this.elementDtype);return yn(this.elementShape,r,"TensorList shape mismatch: "),t=t.slice(0,this.size()),t.length===0?W.tensor([],[0].concat(this.elementShape)):W.tidy(function(){var a=t.map(function(s){return W.reshape(i.tensors[s],r)});return W.stack(a,0)})},n.prototype.concat=function(t,e){var r=this;if(!!t&&t!==this.elementDtype)throw new Error("TensorList dtype is "+this.elementDtype+" but concat requested dtype "+t);return yn(this.elementShape,e,"TensorList shape mismatch: "),this.size()===0?W.tensor([],[0].concat(this.elementShape)):W.tidy(function(){var i=r.tensors.map(function(a){return W.reshape(a,e)});return W.concat(i,0)})},n}();function S6(n,t,e){var r=n.dtype;if(n.shape.length<1)throw new Error("Tensor must be at least a vector, but saw shape: "+n.shape);if(n.dtype!==e)throw new Error("Invalid data types; op elements "+n.dtype+", but list elements "+e);var i=n.shape.slice(1);yn(i,t,"TensorList shape mismatch: ");var a=W.unstack(n);return new cc(a,t,r)}function L6(n,t,e){return new cc([],n,t,e)}function I6(n,t,e,r){if(t.length!==n.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+t.length+" vs. "+n.shape[0]);var i=Math.max.apply(Math,Pr(t));if(r!=null&&r!==-1&&i>=r)throw new Error("Max index must be < array size ("+i+" vs. "+r+")");var a=new cc([],e,n.dtype,r),s=W.unstack(n,0);return t.forEach(function(o,c){a.setItem(o,s[c])}),a}function A6(n,t,e){var r=0,i=t.map(function(l){return r+=l,r});if(r!==n.shape[0])throw new Error(`Expected sum of lengths to be equal to tensor.shape[0], but sum of lengths is `+r+", and tensor's shape is: "+n.shape);for(var a=r===0?0:n.size/r,s=W.tidy(function(){var l=[];n=W.reshape(n,[1,r,a]);for(var u=0;u1)this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift();else throw new Error("Cannot exit frame, the context is empty")},n.prototype.nextIteration=function(){if(this.contexts&&this.contexts.length>0){this.contexts=this.contexts.slice(),this.lastId++;var t=Object.assign({},this.contexts[this.contexts.length-1]);t.iterationId+=1,t.id=this.lastId,this.contexts.splice(-1,1,t),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}else throw new Error("Cannot increase frame iteration, the context is empty")},n.prototype.getWeight=function(t){return this.weightMap[t]},n.prototype.addTensorArray=function(t){this.tensorArrayMap[t.id]=t},n.prototype.getTensorArray=function(t){return this.tensorArrayMap[t]},n.prototype.addTensorList=function(t){this.tensorListMap[t.id]=t},n.prototype.getTensorList=function(t){return this.tensorListMap[t]},n.prototype.dispose=function(t){for(var e in this.tensorArrayMap)this.tensorArrayMap[e].clearAndClose(t);for(var e in this.tensorListMap)this.tensorListMap[e].clearAndClose(t)},n}();function xw(n,t,e,r){var i=new Set,a=[],s=null,o=null,c=new Set,l=Object.keys(n).map(function(p){return rn(p)[0]}),u=[];r!=null&&(u=r.map(function(p){return rn(p.name)[0]}));for(var h=Pr(t);h.length>0;){var d=h.pop();if((bw(d)||G6(d)||Y6(d))&&(s==null&&(s=d,o=s.children.map(function(p){return p.name}).filter(function(p){return i.has(p)}))),i.add(d.name),e[d.name]!=null)continue;if(l.indexOf(d.name)!==-1)continue;if(u.indexOf(d.name)!==-1)continue;if(d.inputs.length===0){a.push(d.name);continue}d.inputs.forEach(function(p){if(c.has(p.name))return;c.add(p.name),h.push(p)})}return{inputs:n,outputs:t,usedNodes:i,missingInputs:a,dynamicNode:s,syncInputs:o}}function j6(n,t,e){var r=e.usedNodes,i=e.inputs,a=[],s=Object.keys(i).map(function(h){return rn(h)[0]}).map(function(h){return n.nodes[h]}),o=n.initNodes;s.forEach(function(h){r.has(h.name)&&a.push(h)}),n.weights.forEach(function(h){r.has(h.name)&&a.push(h)}),o!=null&&o.forEach(function(h){r.has(h.name)&&a.push(h)});for(var c=new Set,l=[];a.length>0;){var u=a.pop();c.add(u.name),t[u.name]||l.push(u),u.children.forEach(function(h){!c.has(h.name)&&r.has(h.name)&&h.inputs.every(function(d){return c.has(d.name)})&&a.push(h)})}return l}var K6=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],$6=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],X6=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2"];function bw(n){return K6.indexOf(n.op)>=0}function G6(n){return $6.indexOf(n.op)>=0}function Y6(n){return X6.indexOf(n.op)>=0}var Sw=function(){function n(t,e){var r=this;this.graph=t,this.parent=e,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this._outputs=t.outputs,this._inputs=t.inputs,this._initNodes=t.initNodes,this._signature=t.signature,this._functions=t.functions,t.functions!=null&&Object.keys(t.functions).forEach(function(i){r._functionExecutorMap[i]=new n(t.functions[i],r)})}return Object.defineProperty(n.prototype,"weightIds",{get:function(){return this.parent?this.parent.weightIds:this._weightIds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"functionExecutorMap",{get:function(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"weightMap",{get:function(){return this.parent?this.parent.weightMap:this._weightMap},set:function(t){var e=Object.keys(t).map(function(r){return t[r].map(function(i){return i.id})});this._weightIds=[].concat.apply([],Pr(e)),this._weightMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"resourceManager",{set:function(t){this._resourceManager=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputs",{get:function(){return this._inputs.map(function(t){return{name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0}})},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"outputs",{get:function(){return this._outputs.map(function(t){return{name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0}})},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputNodes",{get:function(){return this._inputs.map(function(t){return t.signatureKey||t.name})},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"outputNodes",{get:function(){return this._outputs.map(function(t){var e=t.signatureKey||t.name;return t.defaultOutput?e+":"+t.defaultOutput:e})},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"functions",{get:function(){var t=this;return Object.keys(this._functions).reduce(function(e,r){return e[r]=t._functions[r].signature,e},{})},enumerable:!0,configurable:!0}),n.prototype.getCompilationKey=function(t,e){var r=t.map(function(a){return a.name}).sort(),i=e.map(function(a){return a.name}).sort();return r.join(this.SEPERATOR)+"--"+i.join(this.SEPERATOR)},n.prototype.compile=function(t,e){var r=xw(t,e,this.weightMap,this._initNodes),i=r.missingInputs,a=r.dynamicNode,s=r.syncInputs;if(a!=null)throw new Error("This execution contains the node '"+a.name+"', which has "+("the dynamic op '"+a.op+"'. Please use ")+"model.executeAsync() instead. Alternatively, to avoid the "+("dynamic ops, specify the inputs ["+s+"]"));if(i.length>0){var o=e.map(function(l){return l.name}),c=Object.keys(t);throw new Error("Cannot compute the outputs ["+o+"] from the provided inputs "+("["+c+"]. Missing the following inputs: ["+i+"]"))}return j6(this.graph,this.weightMap,r)},n.prototype.execute=function(t,e){var r=this;t=this.mapInputs(t);var i=Object.keys(t).sort();this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e);var a=i.map(function(d){return r.graph.nodes[rn(d)[0]]}),s=e.map(function(d){return rn(d)[0]}),o=s.map(function(d){return r.graph.nodes[d]});o.length===0&&(o=this._outputs);var c=this.getCompilationKey(a,o),l=this.compiledMap.get(c);l==null&&(l=this.compile(t,o),this.compiledMap.set(c,l));var u={},h={};return W.tidy(function(){var d=new ww(r.weightMap,u,h,r.functionExecutorMap),p=uw({},r.weightMap);Object.keys(t).forEach(function(b){var S=vt(rn(b),2),x=S[0],N=S[1],I=[];I[N]=t[b],p[x]=I});for(var f=r.getFrozenTensorIds(p),m={},g=0;g0?(b=this.processStack(s,f,e,m,w,y,o,g,u),[4,Promise.all(b)]):[3,3];case 2:return I.sent(),[3,1];case 3:if(d==null&&!i&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."),S=c.filter(function(C){return!bw(C)&&!jt(C.name,m,e)}).map(function(C){return C.name}),S.length>0)throw x="",d!=null&&(x="Alternatively, to avoid the dynamic ops, use model.execute() "+("and specify the inputs ["+p+"]")),new Error("Cannot compute the outputs ["+S+"] from the provided "+("inputs ["+a+"]. Consider providing the following inputs: ")+("["+h+"]. "+x));return[2,m]}})})},n.prototype.processStack=function(t,e,r,i,a,s,o,c,l){for(var u=this,h=[],d=function(){var f,m,g=e.pop();r.currentContext=g.contexts;var y="";if(g.node.op==="Enter"&&T("isConstant",g.node,i,r)&&(f=vt(cr(g.node.name,r),1),y=f[0]),i[g.node.name]==null){var w=vw(g.node,i,r,p._resourceManager);y||(m=vt(cr(g.node.name,r),1),y=m[0]);var b=r.currentContext;W.util.isPromise(w)?h.push(w.then(function(S){return i[y]=S,r.currentContext=b,u.checkTensorForDisposal(y,g.node,i,r,s,o,c),u.processChildNodes(g.node,e,r,i,a,l),S})):(i[y]=w,p.checkTensorForDisposal(y,g.node,i,r,s,o,c),p.processChildNodes(g.node,e,r,i,a,l))}else p.processChildNodes(g.node,e,r,i,a,l)},p=this;e.length>0;)d();return h},n.prototype.processChildNodes=function(t,e,r,i,a,s){t.children.forEach(function(o){var c=vt(cr(o.name,r),1),l=c[0];if(a[l]||!s.has(o.name))return;o.op==="Merge"?o.inputNames.some(function(u){return!!jt(u,i,r)})&&(a[l]=!0,e.push({contexts:r.currentContext,node:o})):o.inputNames.every(function(u){return!!jt(u,i,r)})&&(a[l]=!0,e.push({contexts:r.currentContext,node:o}))})},n.prototype.dispose=function(){var t=this;Object.keys(this.weightMap).forEach(function(e){return t.weightMap[e].forEach(function(r){return r.dispose()})})},n.prototype.checkInputShapeAndType=function(t){var e=this;Object.keys(t).forEach(function(r){var i=t[r],a=vt(rn(r),1),s=a[0],o=e.graph.nodes[s];if(o.attrParams.shape&&o.attrParams.shape.value){var c=o.attrParams.shape.value,l=c.length===i.shape.length&&i.shape.every(function(u,h){return c[h]===-1||c[h]===u});W.util.assert(l,function(){return"The shape of dict['"+o.name+"'] provided in "+("model.execute(dict) must be ["+c+"], but was ")+("["+i.shape+"]")})}o.attrParams.dtype&&o.attrParams.dtype.value&&W.util.assert(i.dtype===o.attrParams.dtype.value,function(){return"The dtype of dict['"+o.name+"'] provided in model.execute(dict) must be "+(o.attrParams.dtype.value+", but was "+i.dtype)})})},n.prototype.mapInputs=function(t){var e={};for(var r in t)if(this._signature!=null&&this._signature.inputs!=null&&this._signature.inputs[r]!=null){var i=this._signature.inputs[r];e[i.name]=t[r]}else e[r]=t[r];return e},n.prototype.checkInputs=function(t){var e=this,r=Object.keys(t).filter(function(i){var a=vt(rn(i),1),s=a[0];return e.graph.nodes[s]==null});if(r.length>0)throw new Error("The dict provided in model.execute(dict) has "+("keys: ["+r+"] that are not part of graph"))},n.prototype.mapOutputs=function(t){var e=this;return t.map(function(r){if(e._signature!=null&&e._signature.outputs!=null&&e._signature.outputs[r]!=null){var i=e._signature.outputs[r];return i.name}return r},{})},n.prototype.checkOutputs=function(t){var e=this;t.forEach(function(r){var i=vt(rn(r),1),a=i[0];if(!e.graph.nodes[a])throw new Error("The output '"+r+"' is not found in the graph")})},n}(),J6=function(){function n(t,e){t===void 0&&(t={}),e===void 0&&(e={}),this.hashTableNameToHandle=t,this.hashTableMap=e}return n.prototype.addHashTable=function(t,e){this.hashTableNameToHandle[t]=e.handle,this.hashTableMap[e.id]=e},n.prototype.getHashTableHandleByName=function(t){return this.hashTableNameToHandle[t]},n.prototype.getHashTableById=function(t){return this.hashTableMap[t]},n.prototype.dispose=function(){for(var t in this.hashTableMap)this.hashTableMap[t].clearAndClose(),delete this.hashTableMap[t];for(var e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]},n}();var Z6="?tfjs-format=file",Q6="model.json",Lw=function(){function n(t,e){e===void 0&&(e={}),this.modelUrl=t,this.loadOptions=e,this.version="n/a",e==null&&(this.loadOptions={}),this.resourceManager=new J6}return Object.defineProperty(n.prototype,"modelVersion",{get:function(){return this.version},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputNodes",{get:function(){return this.executor.inputNodes},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"outputNodes",{get:function(){return this.executor.outputNodes},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputs",{get:function(){return this.executor.inputs},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"outputs",{get:function(){return this.executor.outputs},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"weights",{get:function(){return this.executor.weightMap},enumerable:!0,configurable:!0}),n.prototype.findIOHandler=function(){var t=this.modelUrl;if(t.load!=null)this.handler=t;else if(this.loadOptions.requestInit!=null)this.handler=W.io.browserHTTPRequest(t,this.loadOptions);else{var e=W.io.getLoadHandlers(t,this.loadOptions);if(e.length===0)e.push(W.io.browserHTTPRequest(t,this.loadOptions));else if(e.length>1)throw new Error("Found more than one ("+e.length+") load handlers for "+("URL '"+[t]+"'"));this.handler=e[0]}},n.prototype.load=function(){return un(this,void 0,void 0,function(){var t;return nn(this,function(e){switch(e.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 t=e.sent(),[2,this.loadSync(t)]}})})},n.prototype.loadSync=function(t){this.artifacts=t;var e=this.artifacts.modelTopology,r={};this.artifacts.userDefinedMetadata!=null&&(r=this.artifacts.userDefinedMetadata.signature),this.version=e.versions.producer+"."+e.versions.minConsumer;var i=W.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new Sw(fw.Instance.transformGraph(e,r)),this.executor.weightMap=this.convertTensorMapToTensorsMap(i),this.executor.resourceManager=this.resourceManager,t.modelInitializer!=null){var a=fw.Instance.transformGraph(t.modelInitializer);this.initializer=new Sw(a),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0},n.prototype.save=function(t,e){return un(this,void 0,void 0,function(){var r;return nn(this,function(i){if(typeof t=="string"){if(r=W.io.getSaveHandlers(t),r.length===0)throw new Error("Cannot find any save handlers for URL '"+t+"'");if(r.length>1)throw new Error("Found more than one ("+r.length+") save handlers for "+("URL '"+t+"'"));t=r[0]}if(t.save==null)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return[2,t.save(this.artifacts)]})})},n.prototype.predict=function(t,e){return this.execute(t,this.outputNodes)},n.prototype.normalizeInputs=function(t){if(!(t instanceof W.Tensor)&&!Array.isArray(t))return t;if(t=Array.isArray(t)?t:[t],t.length!==this.inputNodes.length)throw new Error("Input tensor count mismatch,"+("the graph model has "+this.inputNodes.length+" placeholders, ")+("while there are "+t.length+" input tensors."));return this.inputNodes.reduce(function(e,r,i){return e[r]=t[i],e},{})},n.prototype.normalizeOutputs=function(t){return t=t||this.outputNodes,Array.isArray(t)?t:[t]},n.prototype.execute=function(t,e){t=this.normalizeInputs(t),e=this.normalizeOutputs(e);var r=this.executor.execute(t,e);return r.length>1?r:r[0]},n.prototype.executeAsync=function(t,e){return un(this,void 0,void 0,function(){var r;return nn(this,function(i){switch(i.label){case 0:return t=this.normalizeInputs(t),e=this.normalizeOutputs(e),[4,this.executor.executeAsync(t,e)];case 1:return r=i.sent(),[2,r.length>1?r:r[0]]}})})},n.prototype.convertTensorMapToTensorsMap=function(t){return Object.keys(t).reduce(function(e,r){return e[r]=[t[r]],e},{})},n.prototype.dispose=function(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()},n}();function e8(n,t){return t===void 0&&(t={}),un(this,void 0,void 0,function(){var e;return nn(this,function(r){switch(r.label){case 0:if(n==null)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");return t==null&&(t={}),t.fromTFHub&&(n.load==null&&(n.endsWith("/")||(n=n+"/"),n=""+n+Q6+Z6)),e=new Lw(n,t),[4,e.load()];case 1:return r.sent(),[2,e]}})})}var t8="2.7.0";bi.GraphModel=Lw;bi.deregisterOp=kk;bi.loadGraphModel=e8;bi.registerOp=Dk;bi.version_converter=t8}),qw=we(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});var Ce=di();var ip=function(n,t){return ip=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])},ip(n,t)};function Ge(n,t){ip(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function ce(n,t,e,r){return new(e||(e=Promise))(function(i,a){function s(l){try{c(r.next(l))}catch(u){a(u)}}function o(l){try{c(r.throw(l))}catch(u){a(u)}}function c(l){l.done?i(l.value):new e(function(u){u(l.value)}).then(s,o)}c((r=r.apply(n,t||[])).next())})}function le(n,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,s;return s={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(a=l[0]&2?i.return:l[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,l[1])).done)return a;(i=0,a)&&(l=[l[0]&2,a.value]);switch(l[0]){case 0:case 1:a=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,i=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(!(a=e.trys,a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]>>0,d-=c,d*=c,c=d>>>0,d-=c,c+=d*4294967296}return(c>>>0)*23283064365386963e-26};return l}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.alea=s})(ha,n,!1)}),r8=xi(function(n){(function(t,e,r){function i(o){var c=this,l="";c.x=0,c.y=0,c.z=0,c.w=0,c.next=function(){var h=c.x^c.x<<11;return c.x=c.y,c.y=c.z,c.z=c.w,c.w^=c.w>>>19^h^h>>>8},o===(o|0)?c.x=o:l+=o;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(typeof u=="object"&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.xor128=s})(ha,n,!1)}),i8=xi(function(n){(function(t,e,r){function i(o){var c=this,l="";c.next=function(){var h=c.x^c.x>>>2;return c.x=c.y,c.y=c.z,c.z=c.w,c.w=c.v,(c.d=c.d+362437|0)+(c.v=c.v^c.v<<4^(h^h<<1))|0},c.x=0,c.y=0,c.z=0,c.w=0,c.v=0,o===(o|0)?c.x=o:l+=o;for(var u=0;u>>4),c.next()}function a(o,c){return c.x=o.x,c.y=o.y,c.z=o.z,c.w=o.w,c.v=o.v,c.d=o.d,c}function s(o,c){var l=new i(o),u=c&&c.state,h=function(){return(l.next()>>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(typeof u=="object"&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.xorwow=s})(ha,n,!1)}),a8=xi(function(n){(function(t,e,r){function i(o){var c=this;c.next=function(){var u=c.x,h=c.i,d,p;return d=u[h],d^=d>>>7,p=d^d<<24,d=u[h+1&7],p^=d^d>>>10,d=u[h+3&7],p^=d^d>>>3,d=u[h+4&7],p^=d^d<<7,d=u[h+7&7],d=d^d<<13,p^=d^d<<9,u[h]=p,c.i=h+1&7,p};function l(u,h){var d,p,f=[];if(h===(h|0))p=f[0]=h;else for(h=""+h,d=0;d0;--d)u.next()}l(c,o)}function a(o,c){return c.x=o.x.slice(),c.i=o.i,c}function s(o,c){o==null&&(o=+new Date);var l=new i(o),u=c&&c.state,h=function(){return(l.next()>>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(u.x&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.xorshift7=s})(ha,n,!1)}),s8=xi(function(n){(function(t,e,r){function i(o){var c=this;c.next=function(){var u=c.w,h=c.X,d=c.i,p,f;return c.w=u=u+1640531527|0,f=h[d+34&127],p=h[d=d+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,f=h[d]=f^p,c.i=d,f+(u^u>>>16)|0};function l(u,h){var d,p,f,m,g,y=[],w=128;for(h===(h|0)?(p=h,h=null):(h=h+"\0",p=0,w=Math.max(w,h.length)),f=0,m=-32;m>>15,p^=p<<4,p^=p>>>13,m>=0&&(g=g+1640531527|0,d=y[m&127]^=p+g,f=d==0?f+1:0);for(f>=128&&(y[(h&&h.length||0)&127]=-1),f=127,m=4*128;m>0;--m)p=y[f+34&127],d=y[f=f+1&127],p^=p<<13,d^=d<<17,p^=p>>>15,d^=d>>>12,y[f]=p^d;u.w=g,u.X=y,u.i=f}l(c,o)}function a(o,c){return c.i=o.i,c.w=o.w,c.X=o.X.slice(),c}function s(o,c){o==null&&(o=+new Date);var l=new i(o),u=c&&c.state,h=function(){return(l.next()>>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(u.X&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.xor4096=s})(ha,n,!1)}),o8=xi(function(n){(function(t,e,r){function i(o){var c=this,l="";c.next=function(){var h=c.b,d=c.c,p=c.d,f=c.a;return h=h<<25^h>>>7^d,d=d-p|0,p=p<<24^p>>>8^f,f=f-h|0,c.b=h=h<<20^h>>>12^d,c.c=d=d-p|0,c.d=p<<16^d>>>16^f,c.a=f-h|0},c.a=0,c.b=0,c.c=2654435769|0,c.d=1367130551,o===Math.floor(o)?(c.a=o/4294967296|0,c.b=o|0):l+=o;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=l.next()>>>11,p=(l.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=l.next,h.quick=h,u&&(typeof u=="object"&&a(u,l),h.state=function(){return a(l,{})}),h}e&&e.exports?e.exports=s:r&&r.amd?r(function(){return s}):this.tychei=s})(ha,n,!1)}),Si=xi(function(n){(function(t,e){var r=this,i=256,a=6,s=52,o="random",c=e.pow(i,a),l=e.pow(2,s),u=l*2,h=i-1,d;function p(S,x,N){var I=[];x=x==!0?{entropy:!0}:x||{};var C=y(g(x.entropy?[S,b(t)]:S==null?w():S,3),I),O=new f(I),D=function(){for(var F=O.g(a),k=c,B=0;F=u;)F/=2,k/=2,B>>>=1;return(F+B)/k};return D.int32=function(){return O.g(4)|0},D.quick=function(){return O.g(4)/4294967296},D.double=D,y(b(O.S),t),(x.pass||N||function(F,k,B,V){return V&&(V.S&&m(V,O),F.state=function(){return m(O,{})}),B?(e[o]=F,k):F})(D,C,"global"in x?x.global:this==e,x.state)}e["seed"+o]=p;function f(S){var x,N=S.length,I=this,C=0,O=I.i=I.j=0,D=I.S=[];for(N||(S=[N++]);C=this.items.length?[2,{value:null,done:!0}]:(e=this.items[this.trav],this.trav++,[2,{value:f8(e),done:!1}])})})},t}(Ot),y8=function(n){Ge(t,n);function t(e){var r=n.call(this)||this;return r.nextFn=e,r}return t.prototype.summary=function(){return"Function call"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){try{return[2,this.nextFn()]}catch(r){throw r.message="Error thrown while iterating through a dataset: "+r.message,r}return[2]})})},t}(Ot),x8=function(n){Ge(t,n);function t(e){var r=n.call(this)||this;return r.upstream=e,r.lastRead=Promise.resolve({value:null,done:!1}),r}return t.prototype.summary=function(){return this.upstream.summary()+" -> Serial"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e=this;return le(this,function(r){return this.lastRead=this.lastRead.then(function(){return e.serialNext()}),[2,this.lastRead]})})},t.prototype.serialNext=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){return[2,this.upstream.next()]})})},t}(Ot),S8=function(n){Ge(t,n);function t(e,r){var i=n.call(this)||this;return i.upstream=e,i.maxCount=r,i.count=0,i.lastRead=Promise.resolve({value:null,done:!1}),i}return t.prototype.summary=function(){return this.upstream.summary()+" -> Skip"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e=this;return le(this,function(r){return this.lastRead=this.lastRead.then(function(){return e.serialNext()}),[2,this.lastRead]})})},t.prototype.serialNext=function(){return ce(this,void 0,void 0,function(){var e;return le(this,function(r){switch(r.label){case 0:return this.count++ Take"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]})})},t}(Ot),I8=function(n){Ge(t,n);function t(e,r,i){i===void 0&&(i=!0);var a=n.call(this)||this;return a.upstream=e,a.batchSize=r,a.enableSmallLastBatch=i,a.lastRead=Promise.resolve({value:null,done:!1}),a}return t.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e=this;return le(this,function(r){return this.lastRead=this.lastRead.then(function(){return e.serialNext()}),[2,this.lastRead]})})},t.prototype.serialNext=function(){return ce(this,void 0,void 0,function(){var e,r;return le(this,function(i){switch(i.label){case 0:e=[],i.label=1;case 1:return e.length0?[2,{value:e,done:!1}]:[2,{value:null,done:!0}]:(e.push(r.value),[3,1]);case 3:return[2,{value:e,done:!1}]}})})},t}(Ot),A8=function(n){Ge(t,n);function t(e,r){var i=n.call(this)||this;return i.upstream=e,i.predicate=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return t.prototype.summary=function(){return this.upstream.summary()+" -> Filter"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e=this;return le(this,function(r){return this.lastRead=this.lastRead.then(function(){return e.serialNext()}),[2,this.lastRead]})})},t.prototype.serialNext=function(){return ce(this,void 0,void 0,function(){var e;return le(this,function(r){switch(r.label){case 0:return[4,this.upstream.next()];case 1:return e=r.sent(),e.done||this.predicate(e.value)?[2,e]:(Ce.dispose(e.value),[3,0]);case 2:return[2]}})})},t}(Ot),T8=function(n){Ge(t,n);function t(e,r){var i=n.call(this)||this;return i.upstream=e,i.transform=r,i}return t.prototype.summary=function(){return this.upstream.summary()+" -> Map"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e,r,i,a,s,o,c;return le(this,function(l){switch(l.label){case 0:return[4,this.upstream.next()];case 1:if(e=l.sent(),e.done)return[2,{value:null,done:!0}];for(r=Ce.tensor_util.getTensorsInContainer(e.value),i=this.transform(e.value),a=Ce.tensor_util.getTensorsInContainer(i),s=0,o=r;s handleErrors"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e=this;return le(this,function(r){return this.lastRead=this.lastRead.then(function(){return e.serialNext()}),[2,this.lastRead]})})},t.prototype.serialNext=function(){return ce(this,void 0,void 0,function(){var e;return le(this,function(r){switch(r.label){case 0:r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,r.sent()];case 3:return e=r.sent(),this.handler(e)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}})})},t}(Ot),Ew=function(n){Ge(t,n);function t(e,r){var i=n.call(this)||this;return i.upstream=e,i.transform=r,i}return t.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e,r,i,a,s,o,c;return le(this,function(l){switch(l.label){case 0:return[4,this.upstream.next()];case 1:return e=l.sent(),e.done?[2,{value:null,done:!0}]:(r=Ce.tensor_util.getTensorsInContainer(e.value),[4,this.transform(e.value)]);case 2:for(i=l.sent(),a=Ce.tensor_util.getTensorsInContainer(i),s=0,o=r;s Flatmap"},t.prototype.pump=function(){return ce(this,void 0,void 0,function(){var e,r,i,a,s,o,c;return le(this,function(l){switch(l.label){case 0:return[4,this.upstream.next()];case 1:if(e=l.sent(),e.done)return[2,!1];for(r=Ce.tensor_util.getTensorsInContainer(e.value),i=this.transform(e.value),a=Ce.tensor_util.getTensorsInContainer(i),this.outputQueue.pushAll(i),s=0,o=r;s Chained"},t.prototype.next=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]})})},t.prototype.readFromChain=function(e){return ce(this,void 0,void 0,function(){var r,i;return le(this,function(a){switch(a.label){case 0:return[4,e];case 1:return a.sent(),this.iterator==null?[4,this.moreIterators.next()]:[3,3];case 2:if(r=a.sent(),r.done)return[2,{value:null,done:!0}];this.iterator=r.value,this.baseErrorHandler!=null&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),a.label=3;case 3:return[4,this.iterator.next()];case 4:return i=a.sent(),i.done?(this.iterator=null,[2,this.readFromChain(e)]):[2,i]}})})},t}(Ot),Mr;(function(n){n[n.FAIL=0]="FAIL",n[n.SHORTEST=1]="SHORTEST",n[n.LONGEST=2]="LONGEST"})(Mr||(Mr={}));var w8=function(n){Ge(t,n);function t(e,r){r===void 0&&(r=Mr.FAIL);var i=n.call(this)||this;return i.iterators=e,i.mismatchMode=r,i.count=0,i.currentPromise=null,i}return t.prototype.summary=function(){var e="TODO: fill in upstream of zip summaries";return"{"+e+"} -> Zip"},t.prototype.nextState=function(e){return ce(this,void 0,void 0,function(){function r(o){if(o instanceof Ot){var c=o.next();return{value:c.then(function(l){return i++,l.done&&a++,l.value}),recurse:!1}}else return{value:null,recurse:!0}}var i,a,s;return le(this,function(o){switch(o.label){case 0:return[4,e];case 1:return o.sent(),i=0,a=0,[4,_w(this.iterators,r)];case 2:if(s=o.sent(),i===a)return[2,{value:null,done:!0}];if(a>0)switch(this.mismatchMode){case Mr.FAIL:throw new Error("Zipped streams should have the same length. "+("Mismatched at element "+this.count+"."));case Mr.SHORTEST:return[2,{value:null,done:!0}];case Mr.LONGEST:}return this.count++,[2,{value:s,done:!1}]}})})},t.prototype.next=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]})})},t}(Ot),Dw=function(n){Ge(t,n);function t(e,r){var i=n.call(this)||this;return i.upstream=e,i.bufferSize=r,i.buffer=new Cw(r),i}return t.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch"},t.prototype.refill=function(){for(;!this.buffer.isFull();){var e=this.upstream.next();this.buffer.push(e)}},t.prototype.next=function(){return this.refill(),this.buffer.shift()},t}(Ot),C8=function(n){Ge(t,n);function t(e,r,i){var a=n.call(this,e,r)||this;return a.upstream=e,a.windowSize=r,a.upstreamExhausted=!1,a.random=Aw(i||Ce.util.now().toString()),a.lastRead=Promise.resolve({value:null,done:!1}),a}return t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e=this;return le(this,function(r){return this.lastRead=this.lastRead.then(function(){return e.serialNext()}),[2,this.lastRead]})})},t.prototype.randomInt=function(e){return Math.floor(this.random()*e)},t.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},t.prototype.serialNext=function(){return ce(this,void 0,void 0,function(){var e,r;return le(this,function(i){switch(i.label){case 0:this.upstreamExhausted||this.refill(),i.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(e=this.chooseIndex(),[4,this.buffer.shuffleExcise(e)]);case 2:if(r=i.sent(),r.done)this.upstreamExhausted=!0;else return this.refill(),[2,r];return[3,1];case 3:return[2,{value:null,done:!0}]}})})},t}(Dw);var ys=function(){function n(){this.size=null}return n.prototype.batch=function(t,e){var r=this;e===void 0&&(e=!0);var i=this;Ce.util.assert(t>0,function(){return`batchSize needs to be positive, but it is `+t});var a;return this.size===Infinity||this.size==null?a=this.size:e?a=Math.ceil(this.size/t):a=Math.floor(this.size/t),an(function(){return ce(r,void 0,void 0,function(){return le(this,function(s){switch(s.label){case 0:return[4,i.iterator()];case 1:return[2,s.sent().columnMajorBatch(t,e,R8)]}})})},a)},n.prototype.concatenate=function(t){var e=this,r=this,i;return this.size===Infinity||t.size===Infinity?i=Infinity:this.size!=null&&t.size!=null?i=this.size+t.size:i=null,an(function(){return ce(e,void 0,void 0,function(){var a,s;return le(this,function(o){switch(o.label){case 0:return[4,r.iterator()];case 1:return s=(a=o.sent()).concatenate,[4,t.iterator()];case 2:return[2,s.apply(a,[o.sent()])]}})})},i)},n.prototype.filter=function(t){var e=this,r=this,i;return this.size===Infinity?i=Infinity:i=null,an(function(){return ce(e,void 0,void 0,function(){return le(this,function(a){switch(a.label){case 0:return[4,r.iterator()];case 1:return[2,a.sent().filter(function(s){return Ce.tidy(function(){return t(s)})})]}})})},i)},n.prototype.forEachAsync=function(t){return ce(this,void 0,void 0,function(){return le(this,function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}})})},n.prototype.map=function(t){var e=this,r=this;return an(function(){return ce(e,void 0,void 0,function(){return le(this,function(i){switch(i.label){case 0:return[4,r.iterator()];case 1:return[2,i.sent().map(function(a){return Ce.tidy(function(){return t(a)})})]}})})},this.size)},n.prototype.mapAsync=function(t){var e=this,r=this;return an(function(){return ce(e,void 0,void 0,function(){return le(this,function(i){switch(i.label){case 0:return[4,r.iterator()];case 1:return[2,i.sent().mapAsync(t)]}})})},this.size)},n.prototype.prefetch=function(t){var e=this;if(t==null)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var r=this;return an(function(){return ce(e,void 0,void 0,function(){return le(this,function(i){switch(i.label){case 0:return[4,r.iterator()];case 1:return[2,i.sent().prefetch(t)]}})})},this.size)},n.prototype.repeat=function(t){var e=this,r=this,i;return this.size!=null&&t>0?i=this.size*t:t===0?i=0:this.size!=null&&(t===void 0||t<0)?i=Infinity:i=null,an(function(){return ce(e,void 0,void 0,function(){var a,s=this;return le(this,function(o){return a=ap(function(){return ce(s,void 0,void 0,function(){var c;return le(this,function(l){switch(l.label){case 0:return c={},[4,r.iterator()];case 1:return[2,(c.value=l.sent(),c.done=!1,c)]}})})}),[2,v8(a.take(t))]})})},i)},n.prototype.skip=function(t){var e=this,r=this,i;return this.size!=null&&t>=0&&this.size>=t?i=this.size-t:this.size!=null&&(this.sizet?i=t:this.size!=null&&this.size<=t?i=this.size:i=null,an(function(){return ce(e,void 0,void 0,function(){return le(this,function(a){switch(a.label){case 0:return[4,r.iterator()];case 1:return[2,a.sent().take(t)]}})})},i)},n.prototype.toArray=function(){return ce(this,void 0,void 0,function(){return le(this,function(t){switch(t.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,t.sent().toArray()]}})})},n.prototype.toArrayForTest=function(){return ce(this,void 0,void 0,function(){return le(this,function(t){switch(t.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,t.sent().toArrayForTest()]}})})},n.MAX_BUFFER_SIZE=1e4,n}();function an(n,t){return t===void 0&&(t=null),new(function(e){Ge(r,e);function r(){var i=e!==null&&e.apply(this,arguments)||this;return i.size=t,i}return r.prototype.iterator=function(){return ce(this,void 0,void 0,function(){return le(this,function(i){return[2,n()]})})},r}(ys))}function O8(n){var t=this;return an(function(){return ce(t,void 0,void 0,function(){return le(this,function(e){return[2,Rw(n)]})})},n.length)}function E8(n){var t=this;if(!da(n))throw new Error("The argument to zip() must be an object or array.");var e;if(Array.isArray(n))for(var r=0;r1}),Ce.util.assert(i.length===0,function(){return"Duplicate column names found: "+i.toString()}),this.columnConfigs){for(a=0,s=Object.keys(this.columnConfigs);a14||!Number.isInteger(i))throw new Error("Invalid fftSize: it must be a power of 2 between "+("2 to 4 and 2 to 14, but got "+r.fftSize));if(r.numFrames=e.numFramesPerSpectrogram||43,r.sampleRateHz=e.sampleRateHz,r.columnTruncateLength=e.columnTruncateLength||r.fftSize,r.audioTrackConstraints=e.audioTrackConstraints,r.smoothingTimeConstant=e.smoothingTimeConstant||0,r.includeSpectrogram=!(e.includeSpectrogram===!1),r.includeWaveform=e.includeWaveform===!0,!r.includeSpectrogram&&!r.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return r}return t.prototype.summary=function(){return"microphone"},t.create=function(e){return e===void 0&&(e={}),ce(this,void 0,void 0,function(){var r;return le(this,function(i){switch(i.label){case 0:if(Ce.env().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return r=new t(e),[4,r.start()];case 1:return i.sent(),[2,r]}})})},t.prototype.start=function(){return ce(this,void 0,void 0,function(){var e,r,i,a;return le(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),e=this,[4,navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints==null?!0:this.audioTrackConstraints,video:!1})];case 1:return e.stream=s.sent(),[3,3];case 2:throw r=s.sent(),new Error("Error thrown while initializing video stream: "+r.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(i=window.AudioContext||window.webkitAudioContext,this.audioContext=new i,!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 a=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=this.fftSize*2,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,a.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}})})},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e,r,i,a,s;return le(this,function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return i=o.sent(),this.includeSpectrogram&&(a=this.flattenQueue(i.freqDataQueue),e=this.getTensorFromAudioDataArray(a,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(s=this.flattenQueue(i.timeDataQueue),r=this.getTensorFromAudioDataArray(s,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:e,waveform:r},done:!1}]}})})},t.prototype.capture=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){switch(e.label){case 0:return[4,this.next()];case 1:return[2,e.sent().value]}})})},t.prototype.getAudioData=function(){return ce(this,void 0,void 0,function(){var e,r,i,a=this;return le(this,function(s){return e=[],r=[],i=0,[2,new Promise(function(o){var c=setInterval(function(){a.includeSpectrogram&&(a.analyser.getFloatFrequencyData(a.freqData),a.freqData[0]===-Infinity&&o({freqDataQueue:e,timeDataQueue:r}),e.push(a.freqData.slice(0,a.columnTruncateLength))),a.includeWaveform&&(a.analyser.getFloatTimeDomainData(a.timeData),r.push(a.timeData.slice())),++i===a.numFrames&&(clearInterval(c),o({freqDataQueue:e,timeDataQueue:r}))},a.fftSize/a.sampleRateHz*1e3)})]})})},t.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())},t.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},t.prototype.getSampleRate=function(){return this.sampleRateHz},t.prototype.flattenQueue=function(e){var r=e[0].length,i=new Float32Array(e.length*r);return e.forEach(function(a,s){return i.set(a,s*r)}),i},t.prototype.getTensorFromAudioDataArray=function(e,r){var i=new Float32Array(Ce.util.sizeFromShape(r));return i.set(e,i.length-e.length),Ce.tensor(i,r)},t}(Ot);var F8=function(n){Ge(t,n);function t(e,r){var i=n.call(this)||this;if(i.webcamVideoElement=e,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=Ce.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var a=i.webcamConfig.resizeWidth*1/i.webcamVideoElement.width,s=i.webcamConfig.resizeHeight*1/i.webcamVideoElement.height,o=(1-a)/2,c=(1-s)/2,l=o+a,u=s+c;i.cropBox=Ce.tensor2d([c,o,u,l],[1,4])}else i.cropBox=Ce.tensor2d([0,0,1,1],[1,4]);return i}return t.prototype.summary=function(){return"webcam"},t.create=function(e,r){return r===void 0&&(r={}),ce(this,void 0,void 0,function(){var i;return le(this,function(a){switch(a.label){case 0:if(Ce.env().get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");e.width=r.resizeWidth,e.height=r.resizeHeight}return i=new t(e,r),[4,i.start()];case 1:return a.sent(),[2,i]}})})},t.prototype.start=function(){return ce(this,void 0,void 0,function(){var e,r,i=this;return le(this,function(a){switch(a.label){case 0:this.webcamConfig.facingMode&&Ce.util.assert(this.webcamConfig.facingMode==="user"||this.webcamConfig.facingMode==="environment",function(){return"Invalid webcam facing mode: "+i.webcamConfig.facingMode+". Please provide 'user' or 'environment'"}),a.label=1;case 1:return a.trys.push([1,3,,4]),e=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 e.stream=a.sent(),[3,4];case 3:throw r=a.sent(),r.message="Error thrown while initializing video stream: "+r.message,r;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(s){console.log(s),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(s){i.webcamVideoElement.onloadedmetadata=function(){s()}})]}})})},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e;return le(this,function(r){if(this.isClosed)return[2,{value:null,done:!0}];try{e=Ce.browser.fromPixels(this.webcamVideoElement)}catch(i){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(i))}if(this.resize)try{return[2,{value:this.cropAndResizeFrame(e),done:!1}]}catch(i){throw new Error("Error thrown cropping the video: "+i.message)}finally{e.dispose()}else return[2,{value:e,done:!1}];return[2]})})},t.prototype.needToResize=function(){return!!(this.webcamConfig.resizeWidth&&this.webcamConfig.resizeHeight&&(this.webcamVideoElement.width!==this.webcamConfig.resizeWidth||this.webcamVideoElement.height!==this.webcamConfig.resizeHeight))},t.prototype.cropAndResizeFrame=function(e){var r=this;return Ce.tidy(function(){var i=e.toFloat().expandDims(0),a;a=Ce.image.cropAndResize(i,r.cropBox,r.cropBoxInd,r.cropSize,"bilinear");var s=a.shape;return a.reshape(s.slice(1))})},t.prototype.capture=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){switch(e.label){case 0:return[4,this.next()];case 1:return[2,e.sent().value]}})})},t.prototype.stop=function(){var e=this.stream.getTracks();e.forEach(function(r){return r.stop()});try{this.webcamVideoElement.srcObject=null}catch(r){console.log(r),this.webcamVideoElement.src=null}this.isClosed=!0},t.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},t}(Ot);var Bw=function(){function n(){}return n}();var zw=function(n){Ge(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.split=function(e){return new W8(this,e)},t}(Ot),W8=function(n){Ge(t,n);function t(e,r){var i=n.call(this)||this;return i.upstream=e,i.impl=new U8(e,r),i}return t.prototype.summary=function(){return this.impl.summary()},t.prototype.next=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){return[2,this.impl.next()]})})},t}(zw),U8=function(n){Ge(t,n);function t(e,r){var i=n.call(this)||this;return i.upstream=e,i.separator=r,i.carryover="",i}return t.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},t.prototype.pump=function(){return ce(this,void 0,void 0,function(){var e,r,i,a,s;return le(this,function(o){switch(o.label){case 0:return[4,this.upstream.next()];case 1:if(e=o.sent(),e.done)return this.carryover===""?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for(r=e.value.split(this.separator),r[0]=this.carryover+r[0],i=0,a=r.slice(0,-1);i Utf8"},t.prototype.pump=function(){return ce(this,void 0,void 0,function(){var e,r,i;return le(this,function(a){switch(a.label){case 0:return[4,this.upstream.next()];case 1:return e=a.sent(),e.done?[2,!1]:(r=e.value,Ce.env().get("IS_BROWSER")?i=this.decoder.decode(r,{stream:!0}):i=this.decoder.write(Buffer.from(r.buffer)),this.outputQueue.push(i),[2,!0])}})})},t}(sp);var Pw=function(n){Ge(t,n);function t(e,r){r===void 0&&(r={});var i=n.call(this)||this;return i.file=e,i.options=r,Ce.util.assert(e instanceof Uint8Array||(Ce.env().get("IS_BROWSER")?e instanceof File||e instanceof Blob:!1),function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."}),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1024*1024,i}return t.prototype.summary=function(){return"FileChunks "+this.file},t.prototype.next=function(){return ce(this,void 0,void 0,function(){var e,r,i=this;return le(this,function(a){switch(a.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(e=new Promise(function(s,o){var c=i.offset+i.chunkSize;if(i.file instanceof Uint8Array)s(new Uint8Array(i.file.slice(i.offset,c)));else{var l=new FileReader;l.onload=function(h){var d=l.result;if(d instanceof ArrayBuffer&&(d=new Uint8Array(d)),!(d instanceof Uint8Array))return o(new TypeError("FileReader returned unknown type."));s(d)},l.onabort=function(h){return o(new Error("Aborted"))},l.onerror=function(h){return o(new Error(h.type))};var u=i.file.slice(i.offset,c);l.readAsArrayBuffer(u)}i.offset=c}),r={},[4,e]);case 1:return[2,(r.value=a.sent(),r.done=!1,r)]}})})},t}(z8);function H8(n,t){return t===void 0&&(t={}),ce(this,void 0,void 0,function(){var e,r,i,a,s;return le(this,function(o){switch(o.label){case 0:return typeof n=="string"?e=n:(e=n.url,r=M8(n)),[4,Ce.util.fetch(e,r)];case 1:return i=o.sent(),i.ok?(s=Uint8Array.bind,[4,i.arrayBuffer()]):[3,3];case 2:return a=new(s.apply(Uint8Array,[void 0,o.sent()])),[2,new Pw(a,t)];case 3:throw new Error(i.statusText)}})})}var M8=function(n){var t={method:n.method,headers:n.headers,body:n.body,mode:n.mode,credentials:n.credentials,cache:n.cache,redirect:n.redirect,referrer:n.referrer,integrity:n.integrity};return t};function Mw(n){return typeof n=="string"&&n.substr(0,7)==="file://"}var Hw=function(n){Ge(t,n);function t(e,r){r===void 0&&(r={});var i=n.call(this)||this;return i.input=e,i.options=r,i}return t.prototype.iterator=function(){return ce(this,void 0,void 0,function(){var e;return le(this,function(r){return Mw(this.input)&&Ce.env().get("IS_NODE")&&(e=require("fs"),this.input=e.readFileSync(this.input.substr(7))),[2,new Pw(this.input,this.options)]})})},t}(Bw);var Vw=function(n){Ge(t,n);function t(e,r){r===void 0&&(r={});var i=n.call(this)||this;return i.url=e,i.fileOptions=r,i}return t.prototype.iterator=function(){return ce(this,void 0,void 0,function(){return le(this,function(e){return Mw(this.url)?[2,new Hw(this.url,this.fileOptions).iterator()]:[2,H8(this.url,this.fileOptions)]})})},t}(Bw);function V8(n,t){return t===void 0&&(t={}),new Uw(new Vw(n),t)}function q8(n){var t=this,e=ap(n);return an(function(){return ce(t,void 0,void 0,function(){return le(this,function(r){return[2,e]})})})}function G8(n){var t=this;return an(function(){return ce(t,void 0,void 0,function(){var e;return le(this,function(r){switch(r.label){case 0:return[4,n()];case 1:return e=r.sent(),[2,ap(function(){return e.next()})]}})})})}function Y8(n,t){return ce(this,void 0,void 0,function(){return le(this,function(e){return[2,F8.create(n,t)]})})}function j8(n){return ce(this,void 0,void 0,function(){return le(this,function(t){return[2,k8.create(n)]})})}var K8="2.7.0";Kt.CSVDataset=Uw;Kt.Dataset=ys;Kt.FileDataSource=Hw;Kt.TextLineDataset=kw;Kt.URLDataSource=Vw;Kt.array=O8;Kt.csv=V8;Kt.func=q8;Kt.generator=G8;Kt.microphone=j8;Kt.version_data=K8;Kt.webcam=Y8;Kt.zip=E8}),Yw=we((Gw,cp)=>{(function(n,t,e){function r(o){var c=this,l=s();c.next=function(){var u=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=u-(c.c=u|0)},c.c=1,c.s0=l(" "),c.s1=l(" "),c.s2=l(" "),c.s0-=l(o),c.s0<0&&(c.s0+=1),c.s1-=l(o),c.s1<0&&(c.s1+=1),c.s2-=l(o),c.s2<0&&(c.s2+=1),l=null}function i(o,c){return c.c=o.c,c.s0=o.s0,c.s1=o.s1,c.s2=o.s2,c}function a(o,c){var l=new r(o),u=c&&c.state,h=l.next;return h.int32=function(){return l.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,u&&(typeof u=="object"&&i(u,l),h.state=function(){return i(l,{})}),h}function s(){var o=4022871197,c=function(l){l=l.toString();for(var u=0;u>>0,h-=o,h*=o,o=h>>>0,h-=o,o+=h*4294967296}return(o>>>0)*23283064365386963e-26};return c}t&&t.exports?t.exports=a:e&&e.amd?e(function(){return a}):this.alea=a})(Gw,typeof cp=="object"&&cp,typeof define=="function"&&define)}),Kw=we((jw,lp)=>{(function(n,t,e){function r(s){var o=this,c="";o.x=0,o.y=0,o.z=0,o.w=0,o.next=function(){var u=o.x^o.x<<11;return o.x=o.y,o.y=o.z,o.z=o.w,o.w^=o.w>>>19^u^u>>>8},s===(s|0)?o.x=s:c+=s;for(var l=0;l>>0)/4294967296};return u.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,p=(h+d)/(1<<21);while(p===0);return p},u.int32=c.next,u.quick=u,l&&(typeof l=="object"&&i(l,c),u.state=function(){return i(c,{})}),u}t&&t.exports?t.exports=a:e&&e.amd?e(function(){return a}):this.xor128=a})(jw,typeof lp=="object"&&lp,typeof define=="function"&&define)}),Xw=we(($w,up)=>{(function(n,t,e){function r(s){var o=this,c="";o.next=function(){var u=o.x^o.x>>>2;return o.x=o.y,o.y=o.z,o.z=o.w,o.w=o.v,(o.d=o.d+362437|0)+(o.v=o.v^o.v<<4^(u^u<<1))|0},o.x=0,o.y=0,o.z=0,o.w=0,o.v=0,s===(s|0)?o.x=s:c+=s;for(var l=0;l>>4),o.next()}function i(s,o){return o.x=s.x,o.y=s.y,o.z=s.z,o.w=s.w,o.v=s.v,o.d=s.d,o}function a(s,o){var c=new r(s),l=o&&o.state,u=function(){return(c.next()>>>0)/4294967296};return u.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,p=(h+d)/(1<<21);while(p===0);return p},u.int32=c.next,u.quick=u,l&&(typeof l=="object"&&i(l,c),u.state=function(){return i(c,{})}),u}t&&t.exports?t.exports=a:e&&e.amd?e(function(){return a}):this.xorwow=a})($w,typeof up=="object"&&up,typeof define=="function"&&define)}),Zw=we((Jw,hp)=>{(function(n,t,e){function r(s){var o=this;o.next=function(){var l=o.x,u=o.i,h,d,p;return h=l[u],h^=h>>>7,d=h^h<<24,h=l[u+1&7],d^=h^h>>>10,h=l[u+3&7],d^=h^h>>>3,h=l[u+4&7],d^=h^h<<7,h=l[u+7&7],h=h^h<<13,d^=h^h<<9,l[u]=d,o.i=u+1&7,d};function c(l,u){var h,d,p=[];if(u===(u|0))d=p[0]=u;else for(u=""+u,h=0;h0;--h)l.next()}c(o,s)}function i(s,o){return o.x=s.x.slice(),o.i=s.i,o}function a(s,o){s==null&&(s=+new Date);var c=new r(s),l=o&&o.state,u=function(){return(c.next()>>>0)/4294967296};return u.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,p=(h+d)/(1<<21);while(p===0);return p},u.int32=c.next,u.quick=u,l&&(l.x&&i(l,c),u.state=function(){return i(c,{})}),u}t&&t.exports?t.exports=a:e&&e.amd?e(function(){return a}):this.xorshift7=a})(Jw,typeof hp=="object"&&hp,typeof define=="function"&&define)}),eb=we((Qw,dp)=>{(function(n,t,e){function r(s){var o=this;o.next=function(){var l=o.w,u=o.X,h=o.i,d,p;return o.w=l=l+1640531527|0,p=u[h+34&127],d=u[h=h+1&127],p^=p<<13,d^=d<<17,p^=p>>>15,d^=d>>>12,p=u[h]=p^d,o.i=h,p+(l^l>>>16)|0};function c(l,u){var h,d,p,f,m,g=[],y=128;for(u===(u|0)?(d=u,u=null):(u=u+"\0",d=0,y=Math.max(y,u.length)),p=0,f=-32;f>>15,d^=d<<4,d^=d>>>13,f>=0&&(m=m+1640531527|0,h=g[f&127]^=d+m,p=h==0?p+1:0);for(p>=128&&(g[(u&&u.length||0)&127]=-1),p=127,f=4*128;f>0;--f)d=g[p+34&127],h=g[p=p+1&127],d^=d<<13,h^=h<<17,d^=d>>>15,h^=h>>>12,g[p]=d^h;l.w=m,l.X=g,l.i=p}c(o,s)}function i(s,o){return o.i=s.i,o.w=s.w,o.X=s.X.slice(),o}function a(s,o){s==null&&(s=+new Date);var c=new r(s),l=o&&o.state,u=function(){return(c.next()>>>0)/4294967296};return u.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,p=(h+d)/(1<<21);while(p===0);return p},u.int32=c.next,u.quick=u,l&&(l.X&&i(l,c),u.state=function(){return i(c,{})}),u}t&&t.exports?t.exports=a:e&&e.amd?e(function(){return a}):this.xor4096=a})(Qw,typeof dp=="object"&&dp,typeof define=="function"&&define)}),nb=we((tb,pp)=>{(function(n,t,e){function r(s){var o=this,c="";o.next=function(){var u=o.b,h=o.c,d=o.d,p=o.a;return u=u<<25^u>>>7^h,h=h-d|0,d=d<<24^d>>>8^p,p=p-u|0,o.b=u=u<<20^u>>>12^h,o.c=h=h-d|0,o.d=d<<16^h>>>16^p,o.a=p-u|0},o.a=0,o.b=0,o.c=2654435769|0,o.d=1367130551,s===Math.floor(s)?(o.a=s/4294967296|0,o.b=s|0):c+=s;for(var l=0;l>>0)/4294967296};return u.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,p=(h+d)/(1<<21);while(p===0);return p},u.int32=c.next,u.quick=u,l&&(typeof l=="object"&&i(l,c),u.state=function(){return i(c,{})}),u}t&&t.exports?t.exports=a:e&&e.amd?e(function(){return a}):this.tychei=a})(tb,typeof pp=="object"&&pp,typeof define=="function"&&define)}),rb=we((SG,dc)=>{(function(n,t){var e=this,r=256,i=6,a=52,s="random",o=t.pow(r,i),c=t.pow(2,a),l=c*2,u=r-1,h;function d(b,S,x){var N=[];S=S==!0?{entropy:!0}:S||{};var I=g(m(S.entropy?[b,w(n)]:b==null?y():b,3),N),C=new p(N),O=function(){for(var D=C.g(i),F=o,k=0;D=l;)D/=2,F/=2,k>>>=1;return(D+k)/F};return O.int32=function(){return C.g(4)|0},O.quick=function(){return C.g(4)/4294967296},O.double=O,g(w(C.S),n),(S.pass||x||function(D,F,k,B){return B&&(B.S&&f(B,C),D.state=function(){return f(C,{})}),k?(t[s]=D,F):D})(O,I,"global"in S?S.global:this==t,S.state)}t["seed"+s]=d;function p(b){var S,x=b.length,N=this,I=0,C=N.i=N.j=0,O=N.S=[];for(x||(b=[x++]);I{var $8=Yw(),X8=Kw(),J8=Xw(),Z8=Zw(),Q8=eb(),e9=nb(),Li=rb();Li.alea=$8;Li.xor128=X8;Li.xorwow=J8;Li.xorshift7=Z8;Li.xor4096=Q8;Li.tychei=e9;ib.exports=Li}),zb=we(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});var L=di(),t9=ab();var fp=function(n,t){return fp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])},fp(n,t)};function n9(n,t){fp(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function sb(n,t,e,r){function i(a){return a instanceof e?a:new e(function(s){s(a)})}return new(e||(e=Promise))(function(a,s){function o(u){try{l(r.next(u))}catch(h){s(h)}}function c(u){try{l(r.throw(u))}catch(h){s(h)}}function l(u){u.done?a(u.value):i(u.value).then(o,c)}l((r=r.apply(n,t||[])).next())})}function ob(n,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,s;return s={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(a=l[0]&2?i.return:l[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,l[1])).done)return a;(i=0,a)&&(l=[l[0]&2,a.value]);switch(l[0]){case 0:case 1:a=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,i=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(!(a=e.trys,a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]0&&L.util.isString(i[0])){var s=i.map(function(o){return L.util.encodeString(o)});a=this.write(s,e,r)}else a=this.write(i,e,r);return{dataId:a,shape:e,dtype:r}},t.prototype.incRef=function(e){var r=this.data.get(e);r.refCount++},t.prototype.decRef=function(e){if(this.data.has(e)){var r=this.data.get(e);r.refCount--}},t.prototype.move=function(e,r,i,a){this.data.set(e,{values:r,dtype:a,refCount:1})},t.prototype.numDataIds=function(){return this.data.numDataIds()},t.prototype.read=function(e){return sb(this,void 0,void 0,function(){return ob(this,function(r){return[2,this.readSync(e)]})})},t.prototype.readSync=function(e){var r=this.data.get(e),i=r.dtype,a=r.complexTensorInfos;if(i==="complex64"){var s=this.readSync(a.real.dataId),o=this.readSync(a.imag.dataId);return L.backend_util.mergeRealAndImagArrays(s,o)}return this.data.get(e).values},t.prototype.bufferSync=function(e){var r=this.readSync(e.dataId),i=r;if(e.dtype==="string")try{i=r.map(function(a){return L.util.decodeString(a)})}catch(a){throw new Error("Failed to decode encoded string bytes into utf-8")}return L.buffer(e.shape,e.dtype,i)},t.prototype.makeOutput=function(e,r,i){var a=this.write(e,r,i);return L.engine().makeTensorFromDataId(a,r,i,this)},t.prototype.disposeData=function(e){if(this.data.has(e)){var r=this.data.get(e).complexTensorInfos;r!=null&&(this.disposeData(r.real.dataId),this.disposeData(r.imag.dataId)),this.data.delete(e)}},t.prototype.disposeIntermediateTensorInfo=function(e){var r=e.dataId;if(this.data.has(r)){var i=this.data.get(r);i.refCount--,i.refCount<1&&this.disposeData(r)}},t.prototype.time=function(e){return sb(this,void 0,void 0,function(){var r,i;return ob(this,function(a){return r=L.util.now(),e(),i=L.util.now()-r,[2,{kernelMs:i}]})})},t.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."]}},t.prototype.stridedSlice=function(e,r,i,a){ae(e,"stridedSlice");var s=L.slice_util.computeOutShape(r,i,a);if(s.some(function(p){return p===0}))return L.tensor([],s);for(var o=L.buffer(s,e.dtype),c=this.bufferSync(e),l=0;lf&&(f=y,m=g)}u[d]=m}return c},t.prototype.cumsum=function(e,r,i,a){if(ae(e,"cumsum"),r!==e.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(e.rank-1)+" "+("but got axis="+r));for(var s=L.upcastType(e.dtype,"int32"),o=L.zeros(e.shape,s),c=this.readSync(o.dataId),l=this.readSync(e.dataId),u=e.shape[e.rank-1],h=a?function(g,y){return g+u-y-1}:function(g,y){return g+y},d=0;da?1:0})},t.prototype.greaterEqual=function(e,r){return ae([e,r],"greaterEqual"),this.broadcastedBinaryOp(e,r,"bool",function(i,a){return i>=a?1:0})},t.prototype.logicalAnd=function(e,r){return ae([e,r],"logicalAnd"),this.broadcastedBinaryOp(e,r,"bool",function(i,a){return i&&a})},t.prototype.logicalOr=function(e,r){return ae([e,r],"logicalOr"),this.broadcastedBinaryOp(e,r,"bool",function(i,a){return i||a})},t.prototype.select=function(e,r,i){ae([e,r,i],"select");for(var a=this.readSync(e.dataId),s=this.readSync(r.dataId),o=this.readSync(i.dataId),c=L.zeros(r.shape,L.upcastType(r.dtype,i.dtype)),l=this.readSync(c.dataId),u=0,h=e.rank===0||e.rank>1||r.rank===1?1:L.util.sizeFromShape(r.shape.slice(1)),d=0;d=0&&a>=0?s:(s+a)%a})},t.prototype.maximum=function(e,r){return ae([e,r],"maximum"),this.broadcastedBinaryOp(e,r,e.dtype,function(i,a){return Math.max(i,a)})},t.prototype.all=function(e,r){ae(e,"all"),L.backend_util.assertAxesAreInnerMostDims("all",r,e.rank);for(var i=L.backend_util.computeOutAndReduceShapes(e.shape,r),a=i[0],s=i[1],o=L.zeros(a,e.dtype),c=L.util.sizeFromShape(s),l=this.readSync(o.dataId),u=this.readSync(e.dataId),h=0;h=1?i[o]=s[o]:i[o]=s[o]*(c+1)}return this.makeOutput(i,r.shape,"float32")},t.prototype.atan2=function(e,r){return ae([e,r],"atan2"),this.broadcastedBinaryOp(e,r,e.dtype,function(i,a){return Math.atan2(i,a)})},t.prototype.tile=function(e,r){return ae(e,"tile"),a9(this.bufferSync(e),r)},t.prototype.gather=function(e,r,i){ae([e,r],"gather");var a=e.shape.slice(),s=this.readSync(r.dataId);a[i]=s.length;for(var o=L.buffer(a,e.dtype),c=this.bufferSync(e),l=0;lse?se=Ie:i==="avg"&&(me+=Ie,ye++),isNaN(se))break}if(isNaN(se))break}if(isNaN(se))break}var ue=oe+k;S[ue]=i==="avg"?me/ye:se}}}return b.toTensor()},t.prototype.avgPool3d=function(e,r){return ae(e,"avgPool3d"),this.pool3d(e,r,"avg").toFloat()},t.prototype.avgPool3dBackprop=function(e,r,i){ae([e,r],"avgPool3dBackprop");for(var a=i.strideDepth,s=i.strideHeight,o=i.strideWidth,c=i.filterDepth,l=i.filterHeight,u=i.filterWidth,h=i.dilationDepth,d=i.dilationHeight,p=i.dilationWidth,f=i.effectiveFilterDepth,m=i.effectiveFilterHeight,g=i.effectiveFilterWidth,y=f-1-i.padInfo.front,w=g-1-i.padInfo.left,b=m-1-i.padInfo.top,S=L.buffer(r.shape,"float32"),x=1/(c*l*u),N=this.bufferSync(e),I=0;I=i.outDepth||Math.floor(K)!==K)continue;for(var G=0;G=i.outHeight||Math.floor(H)!==H)continue;for(var J=0;J=i.outWidth||Math.floor($)!==$)continue;var ee=N.get(I,K,H,$,C);P+=ee}}}S.set(P*x,I,O,D,F,C)}return S.toTensor()},t.prototype.maxPool3d=function(e,r){return ae(e,"maxPool3d"),this.pool3d(e,r,"max").toFloat()},t.prototype.maxPool3dPositions=function(e,r){for(var i=L.buffer(r.outShape,"int32"),a=r.strideDepth,s=r.strideHeight,o=r.strideWidth,c=r.dilationDepth,l=r.dilationHeight,u=r.dilationWidth,h=r.effectiveFilterDepth,d=r.effectiveFilterHeight,p=r.effectiveFilterWidth,f=r.padInfo.front,m=r.padInfo.top,g=r.padInfo.left,y=this.bufferSync(e),w=0;w=q&&(q=ne,K=H*d*p+$*d+te)}i.set(K,w,S,C,k,b)}}}return i.toTensor()},t.prototype.maxPool3dBackprop=function(e,r,i,a){ae([r,i],"maxPool3dBackprop");for(var s=this.maxPool3dPositions(r,a),o=a.strideDepth,c=a.strideHeight,l=a.strideWidth,u=a.dilationDepth,h=a.dilationHeight,d=a.dilationWidth,p=a.effectiveFilterDepth,f=a.effectiveFilterHeight,m=a.effectiveFilterWidth,g=p-1-a.padInfo.front,y=m-1-a.padInfo.left,w=f-1-a.padInfo.top,b=L.buffer(r.shape,"float32"),S=this.bufferSync(s),x=this.bufferSync(e),N=0;N=a.outDepth||Math.floor(q)!==q)continue;for(var K=0;K=a.outHeight||Math.floor(G)!==G)continue;for(var H=0;H=a.outWidth||Math.floor(J)!==J)continue;var $=p*f*m-1-S.get(N,q,G,J,I),ee=P*f*m+K*m+H,te=$===ee?1:0;if(te===0)continue;var ne=x.get(N,q,G,J,I);V+=ne*te}}}b.set(V,N,C,O,D,I)}return b.toTensor()},t.prototype.resizeBilinear=function(e,r,i,a){ae(e,"resizeBilinear");for(var s=e.shape,o=s[0],c=s[1],l=s[2],u=s[3],h=this.readSync(e.dataId),d=new Float32Array(L.util.sizeFromShape([o,r,i,u])),p=[a&&r>1?c-1:c,a&&i>1?l-1:l],f=[a&&r>1?r-1:r,a&&i>1?i-1:i],m=0,g=p[0]/f[0],y=p[1]/f[1],w=0;w1?o-1:o,i&&d>1?c-1:c],m=[i&&h>1?h-1:h,i&&d>1?d-1:d],g=f[0]/m[0],y=f[1]/m[1],w=this.readSync(e.dataId),b=0,S=0;S1?c-1:c,a&&i>1?l-1:l],f=[a&&r>1?r-1:r,a&&i>1?i-1:i],m=p[0]/f[0],g=p[1]/f[1],y=0,w=0;w1?o-1:o,i&&d>1?c-1:c],g=[i&&h>1?h-1:h,i&&d>1?d-1:d],y=m[0]/g[0],w=m[1]/g[1],b=1/y,S=1/w,x=Math.ceil(b)*2+2,N=Math.ceil(S)*2+2,I=0;I=h)continue;var $=C+J*e.strides[1],ee=J*y,te=Math.min(o-1,i?Math.round(ee):Math.floor(ee));if(O!==te)continue;for(var ne=0;ne=d)continue;var ie=$+re*e.strides[2],oe=re*w,se=Math.min(c-1,i?Math.round(oe):Math.floor(oe));B===se&&(G+=f[ie+K])}}p[V+K]=G}return L.tensor4d(p,r.shape,r.dtype)},t.prototype.localResponseNormalization4D=function(e,r,i,a,s){ae(e,"localResponseNormalization4D");var o=e.shape[3],c=o-1,l=this.readSync(e.dataId),u=e.size,h=new Float32Array(u);function d(g){for(var y=g%o,w=g-y+Math.max(0,y-r),b=g-y+Math.min(y+r,c),S=0;w<=b;w++){var x=l[w];S+=x*x}return S}for(var p=0;p=0&&o[c]1,function(){return"blockSize should be > 1 for depthToSpace, but was: "+r});for(var a=e.shape[0],s=e.shape[1],o=e.shape[2],c=e.shape[3],l=s*r,u=o*r,h=c/(r*r),d=this.readSync(e.dataId),p=new Float32Array(a*l*u*h),f=0,m=0;m=l)continue;for(var B=f>1?(D-C)*(u-1)/(f-1):0,V=m>1?(F-O)*(h-1)/(m-1):0,P=0;P1?C*(u-1)+P*B:.5*(C+D)*(u-1);if(q<0||q>u-1){for(var K=0;K1?O*(h-1)+K*V:.5*(O+F)*(h-1);if(te<0||te>h-1){for(var G=0;G1?O*(h-1)+K*V:.5*(O+F)*(h-1);if(te<0||te>h-1){for(var G=0;G=e.size/l)throw new Error("Invalid indices: "+m+" does not index into "+e.shape);for(var b=0;b=a/s)throw new Error("Invalid indices: "+y+" does not index into "+i);for(var x=0;xo&&(o=l)}i[a]=o}return i}var yb=Hr(function(n,t){return n*t}),T9=mp(function(n,t,e,r){return{real:n*e-t*r,imag:n*r+t*e}}),vb=pa(L.Multiply,yb,T9),N9={kernelName:L.Multiply,backendName:"cpu",kernelFunc:vb};var wb=Hr(function(n,t){return n!==t?1:0}),_9=pa(L.NotEqual,wb,null,"bool"),C9={kernelName:L.NotEqual,backendName:"cpu",kernelFunc:_9};var bb=fa(function(n){return 1/Math.sqrt(n)}),R9=ma(L.Rsqrt,bb),O9={kernelName:L.Rsqrt,backendName:"cpu",kernelFunc:R9};function xb(n,t,e,r,i){var a=L.slice_util.isSliceContinous(r,t,e),s=L.util.sizeFromShape(e),o=L.util.computeStrides(r);if(a){var c=L.slice_util.computeFlatOffset(t,o);return n.subarray(c,c+s)}for(var l=L.util.getTypedArrayFromDType(i,s),u=0;u=0?n:Math.exp(n)-1}),z9={kernelName:L.Elu,backendName:"cpu",kernelFunc:Tb};var P9=Hr(function(n,t){return n<0?t*n:n});function Nb(n){var t=n.inputs,e=n.backend,r=t.x,i=t.alpha;ae([r,i],"prelu");var a=e.data.get(r.dataId).values,s=e.data.get(i.dataId).values,o=P9(r.shape,i.shape,a,s,r.dtype),c=o[0],l=o[1];return e.makeTensorInfo(l,r.dtype,c)}var M9={kernelName:L.Prelu,backendName:"cpu",kernelFunc:Nb};var _b=Ke(L.Relu,function(n){return Math.max(0,n)}),H9={kernelName:L.Relu,backendName:"cpu",kernelFunc:_b};var Cb=Ke(L.Relu6,function(n){return Math.min(Math.max(0,n),6)}),V9={kernelName:L.Relu6,backendName:"cpu",kernelFunc:Cb};function vp(n,t,e,r){if(e==="linear")return Ii({inputs:{x:t},backend:n});if(e==="relu")return _b({inputs:{x:t},backend:n});if(e==="elu")return Tb({inputs:{x:t},backend:n});if(e==="relu6")return Cb({inputs:{x:t},backend:n});if(e==="prelu")return Nb({inputs:{x:t,alpha:r},backend:n});throw new Error("Activation "+e+" has not been implemented for the CPU backend.")}function Gn(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x,a=r.shape,s=L.util.sizeFromShape(i.shape),o=L.util.inferFromImplicitShape(a,s),c=L.util.sizeFromShape(o);L.util.assert(s===c,function(){return"The new shape ("+o+") has "+c+" elements and the old "+("shape ("+i.shape+") has "+s+" elements. The new shape and old ")+"shape must have the same number of elements."}),e.incRef(i.dataId);var l=e.data.get(i.dataId);if(l.complexTensorInfos!=null){var u=l.complexTensorInfos.real,h=l.complexTensorInfos.imag;u.shape=o,h.shape=o}return{dataId:i.dataId,shape:o,dtype:i.dtype}}var q9={kernelName:L.Reshape,backendName:"cpu",kernelFunc:Gn};function Rb(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.a,a=t.b,s=r.transposeA,o=r.transposeB;ae([i,a],"matMul");var c=i.shape.length,l=a.shape.length,u=s?i.shape[c-2]:i.shape[c-1],h=o?a.shape[l-1]:a.shape[l-2],d=s?i.shape[c-1]:i.shape[c-2],p=o?a.shape[l-2]:a.shape[l-1],f=i.shape.slice(0,-2),m=a.shape.slice(0,-2),g=L.util.sizeFromShape(f),y=L.util.sizeFromShape(m),w=g===y||g===1||y===1;L.util.assert(c>=2&&l>=2&&w,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 ("+f+") and ("+m+").")});var b=g>y?i.shape.slice(0,-2):a.shape.slice(0,-2),S=b.concat([d,p]);L.util.assert(u===h,function(){return"Error in matMul: inner shapes ("+u+") and ("+(h+") of Tensors with shapes "+i.shape+" and ")+(a.shape+" and transposeA="+s)+(" and transposeB="+o+" must match.")});for(var x=s?[g,u,d]:[g,d,u],N=o?[y,p,h]:[y,h,p],I=Gn({inputs:{x:i},backend:e,attrs:{shape:x}}),C=Gn({inputs:{x:a},backend:e,attrs:{shape:N}}),O=s?I.shape[1]:I.shape[2],D=s?I.shape[2]:I.shape[1],F=o?C.shape[1]:C.shape[2],k=Math.max(g,y),B=e.data.get(I.dataId).values,V=e.data.get(C.dataId).values,P=L.util.computeStrides(I.shape),q=L.util.computeStrides(C.shape),K=s?[P[0],1,P[1]]:[P[0],P[1],1],G=K[0],H=K[1],J=K[2],$=o?[1,q[1],q[0]]:[q[1],1,q[0]],ee=$[0],te=$[1],ne=$[2],re=D*F,ie=L.buffer([k,D,F],I.dtype),oe=ie.values,se=e.blockSize,me=0;meK?K=ne:a==="avg"&&(G+=ne,H++)}if(isNaN(K))break}var re=k+B*b+I;g[re]=a==="avg"?G/H:K}return m}function Ob(n,t,e,r,i,a){i===void 0&&(i=!1),a===void 0&&(a=!1);for(var s=L.buffer(r.outShape,"int32"),o=r.strideHeight,c=r.strideWidth,l=r.dilationHeight,u=r.dilationWidth,h=r.effectiveFilterHeight,d=r.effectiveFilterWidth,p=r.padInfo.top,f=r.padInfo.left,m=L.buffer(t,e,n),g=0;gD&&(D=q,i?F=a?((g*r.inHeight+k)*r.inWidth+V)*r.inChannels+y:(k*r.inWidth+V)*r.inChannels+y:F=B*d+P)}s.set(F,g,w,N,y)}}return s}function sF(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x;ae(i,"avgPool");var a=r.filterSize,s=r.strides,o=r.pad,c=r.dimRoundingMode,l=1;L.util.assert(L.backend_util.eitherStridesOrDilationsAreOne(s,l),function(){return"Error in avgPool: Either strides or dilations must be 1. "+("Got strides "+s+" and dilations '"+l+"'")});var u=L.backend_util.computePool2DInfo(i.shape,a,s,l,o,c),h;if(u.filterWidth===1&&u.filterHeight===1&&L.util.arraysEqual(u.inShape,u.outShape))h=Ii({inputs:{x:i},backend:e});else{var d=e.data.get(i.dataId).values,p=L.util.computeStrides(i.shape),f=wp(d,i.shape,i.dtype,p,u,"avg");h=e.makeTensorInfo(u.outShape,i.dtype,f.values)}return h}var oF={kernelName:L.AvgPool,backendName:"cpu",kernelFunc:sF};function cF(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.dy,a=t.input,s=a;ae([i,a],"avgPoolBackprop");for(var o=r.filterSize,c=r.strides,l=r.pad,u=L.backend_util.computePool2DInfo(s.shape,o,c,1,l),h=u.strideHeight,d=u.strideWidth,p=u.filterHeight,f=u.filterWidth,m=u.dilationHeight,g=u.dilationWidth,y=u.effectiveFilterHeight,w=u.effectiveFilterWidth,b=w-1-u.padInfo.left,S=y-1-u.padInfo.top,x=L.buffer(s.shape,"float32"),N=1/(p*f),I=e.data.get(i.dataId).values,C=L.buffer(i.shape,"float32",I),O=0;O=u.outHeight||Math.floor(K)!==K)continue;for(var G=0;G=u.outWidth||Math.floor(H)!==H)continue;var J=C.get(O,K,H,D);P+=J}}x.set(P*N,O,F,k,D)}return e.makeTensorInfo(x.shape,x.dtype,x.values)}var lF={kernelName:L.AvgPoolBackprop,backendName:"cpu",kernelFunc:cF};function uF(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x,a=t.scale,s=t.offset,o=t.mean,c=t.variance;L.util.assert(o.shape.length===c.shape.length,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),L.util.assert(s==null||o.shape.length===s.shape.length,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),L.util.assert(a==null||o.shape.length===a.shape.length,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}),ae([i,o,c,a,s],"batchNorm");var l=r.varianceEpsilon;l==null&&(l=.001);for(var u=e.data.get(i.dataId).values,h=e.data.get(o.dataId).values,d=e.data.get(c.dataId).values,p=a?e.data.get(a.dataId).values:new Float32Array([1]),f=s?e.data.get(s.dataId).values:new Float32Array([0]),m=new Float32Array(u.length),g=f.length,y=p.length,w=d.length,b=h.length,S=0,x=0,N=0,I=0,C=0;C=g&&(S=0),x>=b&&(x=0),N>=y&&(N=0),I>=w&&(I=0);return e.makeTensorInfo(i.shape,i.dtype,m)}var hF={kernelName:L.FusedBatchNorm,backendName:"cpu",kernelFunc:uF};var dF=Ke(L.ClipByValue,function(n,t){var e=t;return n>e.clipValueMax?e.clipValueMax:n0});if(o.length===1)return o[0];var c=o.map(function(S){return S.shape});if(L.backend_util.assertParamsConsistent(c,a),o[0].dtype==="complex64"){var l=o.map(function(S){return bs({inputs:{input:S},backend:e})}),u=o.map(function(S){return pc({inputs:{input:S},backend:e})}),h=Ls({inputs:l,backend:e,attrs:{axis:a}}),d=Ls({inputs:u,backend:e,attrs:{axis:a}}),p=On({inputs:{real:h,imag:d},backend:e});return l.forEach(function(S){return e.disposeIntermediateTensorInfo(S)}),u.forEach(function(S){return e.disposeIntermediateTensorInfo(S)}),e.disposeIntermediateTensorInfo(h),e.disposeIntermediateTensorInfo(d),p}var f=o.map(function(S){var x=L.util.sizeFromShape(S.shape.slice(a)),N=[-1,x];return Gn({inputs:{x:S},backend:e,attrs:{shape:N}})});s=L.backend_util.computeOutShape(f.map(function(S){return S.shape}),1);var m=L.util.getTypedArrayFromDType(o[0].dtype,L.util.sizeFromShape(s));if(f[0].shape[0]===1){var g=0;f.forEach(function(S){var x=e.data.get(S.dataId).values,N=L.util.sizeFromShape(S.shape);m.set(x,g),g+=N})}else{var y=0;f.forEach(function(S){for(var x=e.data.get(S.dataId).values,N=0,I=0;I=d.inHeight)continue;for(var ie=ne*N[0],oe=H+re*C,se=0;se=d.inWidth)continue;for(var Be=ie+ve*N[1],We=oe+Ee*O,je=Be,ze=0;ze=l.inDepth)continue;for(var G=q*O[0],H=F+K*C[1],J=0;J=l.inHeight)continue;for(var re=G+te*O[1],ie=H+ne*C[2],oe=0;oe=l.inWidth)continue;for(var Ee=re+ye*O[2],Be=ie+ve*l.inChannels,We=Ee,je=0;je=p.inHeight)continue;for(var G=q*h[0],H=F+K*u[1],J=0;J=p.inWidth)continue;for(var re=G+te*h[1],ie=H+ne*p.inChannels,oe=$,se=re,me=0;me=0&&ie=0&&sene&&(ne=ve)}}}var Ee=L.util.locToIndex([G,H,$,te],q,L.util.computeStrides(V));K[Ee]=ne}var Be=h.write(L.util.toTypedArray(K,a.dtype),V,a.dtype);return{dataId:Be,shape:V,dtype:a.dtype}}};var UF={kernelName:L.Dilation2DBackpropFilter,backendName:"cpu",kernelFunc:function(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t,a=i.x,s=i.filter,o=i.dy,c=r,l=c.strides,u=c.pad,h=c.dilations,d=e,p=L.util.toNestedArray(a.shape,d.data.get(a.dataId).values),f=L.util.toNestedArray(s.shape,d.data.get(s.dataId).values),m=L.backend_util.computeDilation2DInfo(a.shape,s.shape,l,u,"NHWC",h),g=m.batchSize,y=m.inHeight,w=m.inWidth,b=m.inChannels,S=m.outHeight,x=m.outWidth,N=m.padInfo,I=m.strideHeight,C=m.strideWidth,O=m.filterHeight,D=m.filterWidth,F=m.dilationHeight,k=m.dilationWidth,B=m.outShape;L.util.assert(o.rank===B.length,function(){return"Error in "+L.Dilation2DBackpropFilter+", dy "+("must have the same rank as output "+B.length+", but got ")+(""+o.rank)});for(var V=L.util.toNestedArray(B,d.data.get(o.dataId).values),P=L.util.makeZerosNestedTypedArray(s.shape,s.dtype),q=0;q=0&&ie=0&&seee&&(ee=me,te=re,ne=oe)}}}P[te][ne][$]+=V[q][K][H][$]}var ye=d.write(L.util.toTypedArray(P,a.dtype),s.shape,s.dtype);return{dataId:ye,shape:s.shape,dtype:s.dtype}}};var BF={kernelName:L.Dilation2DBackpropInput,backendName:"cpu",kernelFunc:function(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t,a=i.x,s=i.filter,o=i.dy,c=r,l=c.strides,u=c.pad,h=c.dilations,d=e,p=L.util.toNestedArray(a.shape,d.data.get(a.dataId).values),f=L.util.toNestedArray(s.shape,d.data.get(s.dataId).values),m=L.backend_util.computeDilation2DInfo(a.shape,s.shape,l,u,"NHWC",h),g=m.batchSize,y=m.inHeight,w=m.inWidth,b=m.inChannels,S=m.outHeight,x=m.outWidth,N=m.padInfo,I=m.strideHeight,C=m.strideWidth,O=m.filterHeight,D=m.filterWidth,F=m.dilationHeight,k=m.dilationWidth,B=m.outShape;L.util.assert(o.rank===B.length,function(){return"Error in "+L.Dilation2DBackpropInput+", dy "+("must have the same rank as output "+B.length+", but got ")+(""+o.rank)});for(var V=L.util.toNestedArray(B,d.data.get(o.dataId).values),P=L.util.makeZerosNestedTypedArray(a.shape,a.dtype),q=0;q=0&&ie=0&&seee&&(ee=me,te=ie,ne=se)}}}P[q][te][ne][$]+=V[q][K][H][$]}var ye=d.write(L.util.toTypedArray(P,a.dtype),a.shape,a.dtype);return{dataId:ye,shape:a.shape,dtype:a.dtype}}};var zF=Hr(function(n,t){return n/t}),PF=pa(L.Div,zF),bp={kernelName:L.Div,backendName:"cpu",kernelFunc:PF};var MF=L.backend_util.ERF_P,HF=L.backend_util.ERF_A1,VF=L.backend_util.ERF_A2,qF=L.backend_util.ERF_A3,GF=L.backend_util.ERF_A4,YF=L.backend_util.ERF_A5,jF=Ke(L.Erf,function(n){var t=Math.sign(n),e=Math.abs(n),r=1/(1+MF*e);return t*(1-((((YF*r+GF)*r+qF)*r+VF)*r+HF)*r*Math.exp(-e*e))}),KF={kernelName:L.Erf,backendName:"cpu",kernelFunc:jF};function kb(n,t,e){for(var r=n.shape,i=r[0],a=r[1],s=e.data.get(n.dataId),o=s.complexTensorInfos.real,c=s.complexTensorInfos.imag,l=[i,a],u=L.util.sizeFromShape(l),h=L.util.getTypedArrayFromDType("float32",u),d=L.util.getTypedArrayFromDType("float32",u),p=0;p=0&&N=d.outHeight||Math.floor(G)!==G)continue;for(var H=0;H=d.outWidth||Math.floor(J)!==J)continue;var $=b*S-1-f.get(D,G,J,F),ee=K*S+H,te=$===ee?1:0;if(te===0)continue;var ne=O.get(D,G,J,F);q+=ne*te}}I.set(q,D,k,B,F)}return e.makeTensorInfo(I.shape,I.dtype,I.values)}var IW={kernelName:L.MaxPoolBackprop,backendName:"cpu",kernelFunc:LW};function AW(n,t,e,r,i){var a=L.util.computeStrides(t),s=wp(n,t,e,a,i,"max"),o=Ob(n,t,e,i,!0,r);return[s.values,o.values]}var TW={kernelName:L.MaxPoolWithArgmax,backendName:"cpu",kernelFunc:function(n){var t=n.inputs,e=n.attrs,r=n.backend,i=t.x,a=e,s=a.filterSize,o=a.strides,c=a.pad,l=a.includeBatchInIndex,u=r;ae(i,"MaxPoolWithArgmax");var h=u.data.get(i.dataId).values,d=L.backend_util.computePool2DInfo(i.shape,s,o,[1,1],c),p=AW(h,i.shape,i.dtype,l,d),f=p[0],m=p[1],g=u.write(f,d.outShape,i.dtype),y=u.write(m,d.outShape,i.dtype);return[{dataId:g,shape:d.outShape,dtype:i.dtype},{dataId:y,shape:d.outShape,dtype:"int32"}]}};function NW(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x,a=r.paddings,s=r.mode;ae(i,"mirrorPad");for(var o=a.map(function(I,C){return I[0]+i.shape[C]+I[1]}),c=a.map(function(I){return I[0]}),l=a.map(function(I,C){return I[0]+i.shape[C]}),u=s==="reflect"?0:1,h=e.data.get(i.dataId).values,d=i.shape.length,p=L.util.computeStrides(i.shape),f=L.util.sizeFromShape(o),m=o.length,g=L.util.computeStrides(o),y=L.util.getTypedArrayFromDType(i.dtype,f),w=0;w=l[S]&&(b[S]=(l[S]-1)*2-b[S]+u);b=b.map(function(I,C){return I-c[C]});var x=L.util.locToIndex(b,d,p);y[w]=h[x]}var N=e.write(y,o,i.dtype);return{dataId:N,shape:o,dtype:i.dtype}}var _W={kernelName:L.MirrorPad,backendName:"cpu",kernelFunc:NW};var CW=L.kernel_impls.nonMaxSuppressionV4Impl,RW={kernelName:L.NonMaxSuppressionV4,backendName:"cpu",kernelFunc:function(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t,a=i.boxes,s=i.scores,o=r,c=o.maxOutputSize,l=o.iouThreshold,u=o.scoreThreshold,h=o.padToMaxOutputSize,d=e;ae(a,"NonMaxSuppressionPadded");var p=d.data.get(a.dataId).values,f=d.data.get(s.dataId).values,m=CW(p,f,c,l,u,h),g=m.selectedIndices,y=m.validOutputs;return[g,y]}};var OW=L.kernel_impls.nonMaxSuppressionV5Impl,EW={kernelName:L.NonMaxSuppressionV5,backendName:"cpu",kernelFunc:function(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t,a=i.boxes,s=i.scores,o=r,c=o.maxOutputSize,l=o.iouThreshold,u=o.scoreThreshold,h=o.softNmsSigma,d=e;ae(a,"NonMaxSuppressionWithScore");var p=d.data.get(a.dataId).values,f=d.data.get(s.dataId).values,m=c,g=l,y=u,w=h,b=OW(p,f,m,g,y,w),S=b.selectedIndices,x=b.selectedScores;return[S,x]}};function DW(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x,a=r.paddings,s=r.constantValue;ae(i,"pad");var o=a.map(function(N,I){return N[0]+i.shape[I]+N[1]}),c=a.map(function(N){return N[0]}),l=e.data.get(i.dataId).values,u=L.util.sizeFromShape(i.shape),h=i.shape.length,d=L.util.computeStrides(i.shape),p=L.util.sizeFromShape(o),f=o.length,m=L.util.computeStrides(o),g=L.util.getTypedArrayFromDType(i.dtype,p);s!==0&&g.fill(s);for(var y=0;y=0&&K=0&&G.5?Math.ceil(n):t%2===0?t:t+1}),BW={kernelName:L.Round,backendName:"cpu",kernelFunc:UW};var zW=L.backend_util.SELU_SCALEALPHA,PW=L.backend_util.SELU_SCALE,MW=Ke(L.Selu,function(n){return n>=0?PW*n:zW*(Math.exp(n)-1)}),HW={kernelName:L.Selu,backendName:"cpu",kernelFunc:MW};var VW=Ke(L.Sigmoid,function(n){return 1/(1+Math.exp(-n))}),qW={kernelName:L.Sigmoid,backendName:"cpu",kernelFunc:VW};var GW=Ke(L.Sign,function(n){return n<0?-1:n>0?1:0}),YW={kernelName:L.Sign,backendName:"cpu",kernelFunc:GW};var jW=Ke(L.Sin,function(n){return Math.sin(n)}),KW={kernelName:L.Sin,backendName:"cpu",kernelFunc:jW};var $W=Ke(L.Sinh,function(n){return Math.sinh(n)}),XW={kernelName:L.Sinh,backendName:"cpu",kernelFunc:$W};var JW=11920928955078125e-23,Wb=Math.log(JW)+2,ZW=Ke(L.Softplus,function(n){var t=n>-Wb,e=n0?1:e.alpha}),oU={kernelName:L.Step,backendName:"cpu",kernelFunc:sU};var cU=Ke(L.Tan,function(n){return Math.tan(n)}),lU={kernelName:L.Tan,backendName:"cpu",kernelFunc:cU};var uU=Ke(L.Tanh,function(n){return Math.tanh(n)}),hU={kernelName:L.Tanh,backendName:"cpu",kernelFunc:uU};function dU(n){var t=n.inputs,e=n.attrs,r=n.backend,i=e.axis,a=t.x;ae(a,"unique");var s=r.data.get(a.dataId).values,o=Ab(s,i,a.shape,a.dtype),c=o.outputValues,l=o.outputShape,u=o.indices;return[r.makeTensorInfo(l,a.dtype,c),r.makeTensorInfo([u.length],"int32",u)]}var pU={kernelName:L.Unique,backendName:"cpu",kernelFunc:dU};var fU=[j9,l9,$9,J9,m9,Q9,tF,rF,aF,oF,lF,G9,hF,p9,y9,pF,u9,mF,vF,bF,gF,IF,TF,SF,_F,RF,OF,DF,FF,WF,BF,UF,bp,z9,KF,w9,x9,QF,nW,rW,L9,aW,oW,h9,lW,fF,hW,pW,mW,A9,yW,wW,SW,IW,TW,bW,_W,N9,RW,EW,C9,Fb,M9,d9,FW,H9,V9,q9,WW,BW,O9,HW,qW,YW,KW,XW,E9,QW,nU,iU,aU,k9,oU,W9,lU,hU,eU,pU];for(var Sp=0,Bb=fU;Sp{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});var _=di();var Lp=function(n,t){return Lp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])},Lp(n,t)};function gU(n,t){Lp(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function fc(n,t,e,r){function i(a){return a instanceof e?a:new e(function(s){s(a)})}return new(e||(e=Promise))(function(a,s){function o(u){try{l(r.next(u))}catch(h){s(h)}}function c(u){try{l(r.throw(u))}catch(h){s(h)}}function l(u){u.done?a(u.value):i(u.value).then(o,c)}l((r=r.apply(n,t||[])).next())})}function mc(n,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,s;return s={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(u){return c([l,u])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,i&&(a=l[0]&2?i.return:l[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,l[1])).done)return a;(i=0,a)&&(l=[l[0]&2,a.value]);switch(l[0]){case 0:case 1:a=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,i=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(!(a=e.trys,a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]e||t>e){var r="["+n+"x"+t+"]",i="["+e+"x"+e+"]";throw new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU "+i+".")}}function Jb(n){return ur(n,function(){return n.createFramebuffer()},"Unable to create WebGLFramebuffer.")}function Tp(n,t,e,r,i,a,s){var o=n.getAttribLocation(t,e);return o===-1?!1:(de(n,function(){return n.bindBuffer(n.ARRAY_BUFFER,r)}),de(n,function(){return n.vertexAttribPointer(o,i,n.FLOAT,!1,a,s)}),de(n,function(){return n.enableVertexAttribArray(o)}),!0)}function Qb(n,t,e){Zb(n,e),de(n,function(){return n.activeTexture(n.TEXTURE0+e)}),de(n,function(){return n.bindTexture(n.TEXTURE_2D,t)})}function NU(n,t){Zb(n,t),de(n,function(){return n.activeTexture(n.TEXTURE0+t)}),de(n,function(){return n.bindTexture(n.TEXTURE_2D,null)})}function e2(n,t,e){return ur(n,function(){return n.getUniformLocation(t,e)},'uniform "'+e+'" not present in program.')}function t2(n,t,e){return n.getUniformLocation(t,e)}function n2(n,t,e,r){de(n,function(){return Qb(n,t,r)}),de(n,function(){return n.uniform1i(e,r)})}function _U(n){de(n,function(){return n.bindFramebuffer(n.FRAMEBUFFER,null)}),de(n,function(){return n.viewport(0,0,n.canvas.width,n.canvas.height)}),de(n,function(){return n.scissor(0,0,n.canvas.width,n.canvas.height)})}function yc(n,t,e){de(n,function(){return n.bindFramebuffer(n.FRAMEBUFFER,e)}),de(n,function(){return n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0)})}function Np(n,t){de(n,function(){return n.bindFramebuffer(n.FRAMEBUFFER,t)}),de(n,function(){return n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,null,0)})}function _s(n){var t=n.checkFramebufferStatus(n.FRAMEBUFFER);if(t!==n.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+r2(n,t))}function r2(n,t){switch(t){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case n.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+t}}function ur(n,t,e){var r=de(n,function(){return t()});if(r==null)throw new Error(e);return r}function Zb(n,t){var e=n.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+n.TEXTURE0;if(re){var i="[gl.TEXTURE0, gl.TEXTURE"+e+"]";throw new Error("textureUnit must be in "+i+".")}}function Ti(n,t){return t===void 0&&(t=2),_.util.sizeFromShape(n.slice(0,n.length-t))}function Ni(n){if(n.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[n.length>1?n[n.length-2]:1,n[n.length-1]]}function vc(n){var t=[1,1,1],e=n.length===0||n.length===1&&n[0]===1;return e||(t=[Ti(n)].concat(Ni(n))),t}function i2(n,t){var e;t===void 0&&(t=!1);var r=_.env().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(r=r*2,n=n.map(function(l,u){return u>=n.length-2?_.util.nearestLargerEven(n[u]):n[u]}),n.length===1&&(n=[2,n[0]])),n.length!==2){var i=_.util.squeezeShape(n);n=i.newShape}var a=_.util.sizeFromShape(n);if(n.length<=1&&a<=r)return[1,a];if(n.length===2&&n[0]<=r&&n[1]<=r)return n;if(n.length===3&&n[0]*n[1]<=r&&n[2]<=r)return[n[0]*n[1],n[2]];if(n.length===3&&n[0]<=r&&n[1]*n[2]<=r)return[n[0],n[1]*n[2]];if(n.length===4&&n[0]*n[1]*n[2]<=r&&n[3]<=r)return[n[0]*n[1]*n[2],n[3]];if(n.length===4&&n[0]<=r&&n[1]*n[2]*n[3]<=r)return[n[0],n[1]*n[2]*n[3]];if(t){var s=Ti(n),o=2,c=2;return n.length&&(e=Ni(n),o=e[0],c=e[1]),a=s*(o/2)*(c/2),_.util.sizeToSquarishShape(a).map(function(l){return l*2})}return _.util.sizeToSquarishShape(a)}function wc(n){return n%2===0}function Cs(n,t){if(n=n.slice(-2),t=t.slice(-2),_.util.arraysEqual(n,t))return!0;if(!n.length||!t.length)return!0;if(n[0]===0||n[1]===0||t[0]===0||t[1]===0)return!0;if(n.length!==t.length){var e=n.slice(-1)[0],r=t.slice(-1)[0];if(e===r)return!0;if(wc(e)&&wc(r)&&(n[0]===1||t[0]===1))return!0}return n[1]===t[1]&&wc(n[0])&&wc(t[0])}var bc,xc;function a2(n){if(bc==null){var t=jn(n);bc=t.getParameter(t.MAX_TEXTURE_SIZE)}return bc}function CU(){bc=null}function RU(){xc=null}function s2(n){if(xc==null){var t=jn(n);xc=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,xc)}function o2(n){if(n===0)return 0;var t,e=jn(n);return dn(e,"EXT_disjoint_timer_query_webgl2")&&n===2?t=2:dn(e,"EXT_disjoint_timer_query")?t=1:t=0,t}function dn(n,t){var e=n.getExtension(t);return e!=null}function _p(n){try{var t=jn(n);if(t!=null)return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function c2(n){if(n===0)return!1;var t=jn(n);if(n===1){if(!dn(t,"OES_texture_float"))return!1}else if(!dn(t,"EXT_color_buffer_float"))return!1;var e=Cp(t);return e}function l2(n){if(n===0)return!1;var t=jn(n);if(n===1){if(!dn(t,"OES_texture_float"))return!1;if(!dn(t,"WEBGL_color_buffer_float"))return!1}else{if(dn(t,"EXT_color_buffer_float"))return Cp(t);var e="EXT_color_buffer_half_float";if(dn(t,e)){var r=t.getExtension(e);return OU(t,r)}return!1}var i=Cp(t);return i}function Cp(n){var t=Ap(n),e=n.createTexture();n.bindTexture(n.TEXTURE_2D,e);var r=1,i=1;n.texImage2D(n.TEXTURE_2D,0,t.internalFormatFloat,r,i,0,t.textureFormatFloat,t.textureTypeFloat,null);var a=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,a),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0);var s=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(e),n.deleteFramebuffer(a),s}function OU(n,t){var e=Ap(n,t),r=n.createTexture();n.bindTexture(n.TEXTURE_2D,r);var i=1,a=1;n.texImage2D(n.TEXTURE_2D,0,e.internalFormatHalfFloat,i,a,0,e.textureFormatFloat,e.textureTypeHalfFloat,null);var s=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,s),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,r,0);var o=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(r),n.deleteFramebuffer(s),o}function u2(n){if(n!==2)return!1;var t=jn(n),e=t.fenceSync!=null;return e}function ya(n,t){Array.isArray(n)||(n=[n]),n.forEach(function(e){e!=null&&_.util.assert(e.dtype!=="complex64",function(){return t+" does not support complex64 tensors in the WebGL backend."})})}var EU={__proto__:null,callAndCheck:de,canBeRepresented:Hb,getWebGLErrorMessage:Mb,getExtensionOrThrow:Ns,createVertexShader:Vb,createFragmentShader:qb,createProgram:Gb,linkProgram:Yb,validateProgram:gc,createStaticVertexBuffer:jb,createStaticIndexBuffer:Kb,getNumChannels:TU,createTexture:$b,validateTextureSize:Xb,createFramebuffer:Jb,bindVertexBufferToProgramAttribute:Tp,bindTextureUnit:Qb,unbindTextureUnit:NU,getProgramUniformLocationOrThrow:e2,getProgramUniformLocation:t2,bindTextureToProgramUniformSampler:n2,bindCanvasToFramebuffer:_U,bindColorTextureToFramebuffer:yc,unbindColorTextureFromFramebuffer:Np,validateFramebuffer:_s,getFramebufferErrorMessage:r2,getBatchDim:Ti,getRowsCols:Ni,getShapeAs3D:vc,getTextureShapeFromLogicalShape:i2,isReshapeFree:Cs,getWebGLMaxTextureSize:a2,resetMaxTextureSize:CU,resetMaxTexturesInShader:RU,getMaxTexturesInShader:s2,getWebGLDisjointQueryTimerVersion:o2,hasExtension:dn,isWebGLVersionEnabled:_p,isCapableOfRenderingToFloatTexture:c2,isDownloadFloatTextureEnabled:l2,isWebGLFenceEnabled:u2,assertNotComplex:ya};var Le=_.env();Le.registerFlag("HAS_WEBGL",function(){return Le.getNumber("WEBGL_VERSION")>0});Le.registerFlag("WEBGL_VERSION",function(){return _p(2)?2:_p(1)?1:0});Le.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",function(){return!1});Le.registerFlag("WEBGL_BUFFER_SUPPORTED",function(){return Le.get("WEBGL_VERSION")===2});Le.registerFlag("WEBGL_CPU_FORWARD",function(){return!0});Le.registerFlag("WEBGL_FORCE_F16_TEXTURES",function(){return!1});Le.registerFlag("WEBGL_PACK",function(){return Le.getBool("HAS_WEBGL")});Le.registerFlag("WEBGL_PACK_NORMALIZATION",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_PACK_CLIP",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_PACK_DEPTHWISECONV",function(){return!1});Le.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_PACK_REDUCE",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_LAZILY_UNPACK",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_CONV_IM2COL",function(){return Le.getBool("WEBGL_PACK")});Le.registerFlag("WEBGL_MAX_TEXTURE_SIZE",function(){return a2(Le.getNumber("WEBGL_VERSION"))});Le.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",function(){return s2(Le.getNumber("WEBGL_VERSION"))});Le.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",function(){var n=Le.getNumber("WEBGL_VERSION");return n===0?0:o2(n)});Le.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",function(){return Le.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!_.device_util.isMobile()});Le.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",function(){return c2(Le.getNumber("WEBGL_VERSION"))});Le.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",function(){return Le.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:Le.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")});Le.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",function(){return l2(Le.getNumber("WEBGL_VERSION"))});Le.registerFlag("WEBGL_FENCE_API_ENABLED",function(){return u2(Le.getNumber("WEBGL_VERSION"))});Le.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",function(){var n=Le.getBool("WEBGL_RENDER_FLOAT32_ENABLED");return n?4:0});Le.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",function(){return-1},function(n){if(n<0&&n!==-1)throw new Error("WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never "+("delete) or at least 0, but got "+n+"."))});function DU(n){const t=new Float32Array(n.length);for(let e=0;e{const s=_.backend_util.assertAndGetBroadcastShape(t,e),o=s.length,c=_.util.computeStrides(s),l=_.util.sizeFromShape(s),u=_.util.getTypedArrayFromDType(a,l),h=t.length,d=e.length,p=_.util.computeStrides(t),f=_.util.computeStrides(e),m=_.backend_util.getBroadcastDims(t,s),g=_.backend_util.getBroadcastDims(e,s);if(m.length+g.length===0)for(let y=0;yb[I]=0);const S=_.util.locToIndex(b,h,p),x=w.slice(-d);g.forEach(I=>x[I]=0);const N=_.util.locToIndex(x,d,f);u[y]=n(r[S],i[N])}return[u,s]}}const kU=Rp((n,t)=>n+t);function va(n){return(t,e,r)=>{const i=_.util.getTypedArrayFromDType(e,t.length);for(let a=0;aMath.ceil(n));const WU=va(n=>Math.exp(n));const UU=va(n=>Math.expm1(n));const BU=va(n=>Math.floor(n));const zU=va(n=>Math.log(n));function PU(n,t,e,r){const i=_.util.getTypedArrayFromDType(r,_.util.sizeFromShape(e));for(let a=0;ao&&(o=l)}i[a]=o}return i}const MU=Rp((n,t)=>n*t);const HU=va(n=>1/Math.sqrt(n));function VU(n,t,e,r,i){const a=_.slice_util.isSliceContinous(r,t,e),s=_.util.sizeFromShape(e),o=_.util.computeStrides(r);if(a){const l=_.slice_util.computeFlatOffset(t,o);return n.subarray(l,l+s)}const c=_.util.getTypedArrayFromDType(i,s);for(let l=0;lm+t[g]),f=_.util.locToIndex(p,r.length,o);c[l]=n[f]}return c}const qU=Rp((n,t)=>n-t);function GU(n,t,e,r,i){const a=t.length,s=_.util.sizeFromShape(t),o=_.util.computeStrides(t),c=_.util.computeStrides(i),l=_.util.getTypedArrayFromDType(e,_.util.sizeFromShape(i));for(let u=0;u{for(let g=0;g":"<",c=r?"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 * `+i+`; int bestIndex = inOffset; float bestValue = getA(batch, bestIndex); for (int i = 0; i < `+i+`; i++) { int inIdx = `+c+`; float candidate = getA(batch, inIdx); if (candidate `+o+` bestValue) { bestValue = candidate; bestIndex = inIdx; } } setOutput(float(bestIndex)); } `}return n}();function h2(n,t){return["x","y","z","w","u","v"].slice(0,t).map(function(e){return n+"."+e})}function Mt(n,t){return t===1?[n]:h2(n,t)}function lB(n,t){if(n===1)return"rc";for(var e="",r=0;r 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) `,c="",l=` #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))); } `):(n="",t="attribute",e="varying",r="varying",i="texture2D",a="gl_FragColor",s="",o=` #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)); } `,c=` uniform float INFINITY; bool isinf(float val) { return abs(val) == INFINITY; } bvec4 isinf(vec4 val) { return equal(abs(val), vec4(INFINITY)); } `,l=` int round(float value) { return int(floor(value + 0.5)); } ivec4 round(vec4 value) { return ivec4(floor(value + vec4(0.5))); } `),{version:n,attribute:t,varyingVs:e,varyingFs:r,texture2D:i,output:a,defineOutput:s,defineSpecialNaN:o,defineSpecialInf:c,defineRound:l}}function _i(n,t,e){e===void 0&&(e="index");var r=_.util.computeStrides(t);return r.map(function(i,a){var s="int "+n[a]+" = "+e+" / "+i,o=a===r.length-1?"int "+n[a+1]+" = "+e+" - "+n[a]+" * "+i:"index -= "+n[a]+" * "+i;return s+"; "+o+";"}).join("")}function Ep(n){var t=_.util.computeStrides(n).map(function(e){return e.toString()});return` int getFlatIndex(ivec3 coords) { return coords.x * `+t[0]+" + coords.y * "+t[1]+` + coords.z; } `}var d2=` 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; } `;var p2=_.backend_util.getBroadcastDims;function vB(n,t,e,r){var i=[];n.forEach(function(f){var m=_.util.sizeFromShape(f.shapeInfo.logicalShape);f.shapeInfo.isUniform?i.push("uniform float "+f.name+(m>1?"["+m+"]":"")+";"):(i.push("uniform sampler2D "+f.name+";"),i.push("uniform int offset"+f.name+";"))});var a=i.join(` `),s=n.map(function(f){return uB(f,t,r)}).join(` `),o=t.texShape,c=Ht(),l=pB(c),u,h,d=gB(c);t.isPacked?(u=hB(t.logicalShape,o),h=mB(c)):(u=dB(t.logicalShape,o),h=fB(c)),r&&(d+=yB);var p=[d,l,h,a,u,s,e].join(` `);return p}function wa(n){var t=n.shapeInfo.logicalShape;switch(t.length){case 0:return wB(n);case 1:return bB(n);case 2:return xB(n);case 3:return SB(n);case 4:return LB(n);case 5:return IB(n);case 6:return AB(n);default:throw new Error(t.length+"-D input sampling is not yet supported")}}function f2(n){var t=n.shapeInfo.logicalShape;switch(t.length){case 0:return TB(n);case 1:return NB(n);case 2:return _B(n);case 3:return CB(n);default:return RB(n)}}function uB(n,t,e){e===void 0&&(e=!1);var r="";e?r+=f2(n):r+=wa(n);var i=n.shapeInfo.logicalShape,a=t.logicalShape;return i.length<=a.length&&(e?r+=OB(n,t):r+=EB(n,t)),r}function hB(n,t){switch(n.length){case 0:return m2();case 1:return DB(n,t);case 2:return WB(n,t);case 3:return kB(n,t);default:return FB(n,t)}}function dB(n,t){switch(n.length){case 0:return m2();case 1:return UB(n,t);case 2:return HB(n,t);case 3:return BB(n,t);case 4:return zB(n,t);case 5:return PB(n,t);case 6:return MB(n,t);default:throw new Error(n.length+"-D output sampling is not yet supported")}}function pB(n){return` float sampleTexture(sampler2D textureSampler, vec2 uv) { return `+n.texture2D+`(textureSampler, uv).r; } `}function fB(n){return` void setOutput(float val) { `+n.output+` = vec4(val, 0, 0, 0); } `}function mB(n){return` void setOutput(vec4 val) { `+n.output+` = val; } `}function gB(n){var t=n.version+` precision highp float; precision highp int; precision highp sampler2D; `+n.varyingFs+` vec2 resultUV; `+n.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; `+n.defineSpecialNaN+` `+n.defineSpecialInf+` `+n.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); } `+VB+` `+qB+` `+GB+` `;return t}var VB=` 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); } `,qB=` 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); } `,GB=` 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); } `,yB=` 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 m2(){return` int getOutputCoords() { return 0; } `}function DB(n,t){var e=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return e[0]===1?` int getOutputCoords() { return 2 * int(resultUV.x * `+e[1]+`.0); } `:e[1]===1?` int getOutputCoords() { return 2 * int(resultUV.y * `+e[0]+`.0); } `:` int getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+e[0]+", "+e[1]+`)); return 2 * (resTexRC.x * `+e[1]+` + resTexRC.y); } `}function UB(n,t){return t[0]===1?` int getOutputCoords() { return int(resultUV.x * `+t[1]+`.0); } `:t[1]===1?` int getOutputCoords() { return int(resultUV.y * `+t[0]+`.0); } `:` int getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+t[0]+", "+t[1]+`)); return resTexRC.x * `+t[1]+` + resTexRC.y; } `}function kB(n,t){var e=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(n[2]/2),i=r*Math.ceil(n[1]/2);return` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+e[0]+", "+e[1]+`)); int index = resTexRC.x * `+e[1]+` + resTexRC.y; int b = index / `+i+`; index -= b * `+i+`; int r = 2 * (index / `+r+`); int c = imod(index, `+r+`) * 2; return ivec3(b, r, c); } `}function BB(n,t){var e=_i(["r","c","d"],n);return` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+t[0]+", "+t[1]+`)); int index = resTexRC.x * `+t[1]+` + resTexRC.y; `+e+` return ivec3(r, c, d); } `}function FB(n,t){for(var e=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(n[n.length-1]/2),i=r*Math.ceil(n[n.length-2]/2),a=i,s="",o="b, r, c",c=2;c=1?u="coords = 0;":u=o.map(function(S){return"coords."+h[S+l]+" = 0;"}).join(` `);var d="";s<2&&a>0?d="coords":d=n.shapeInfo.logicalShape.map(function(S,x){return"coords."+h[x+l]}).join(", ");var p="return outputValue;",f=_.util.sizeFromShape(n.shapeInfo.logicalShape),m=f===1,g=_.util.sizeFromShape(t.logicalShape),y=g===1;if(a===1&&!m&&!y)p=` return vec4(outputValue.xy, outputValue.xy); `;else if(m&&!y)s===1?p=` return vec4(outputValue.x, outputValue.x, 0., 0.); `:p=` return vec4(outputValue.x); `;else if(o.length){var w=a-2,b=a-1;o.indexOf(w)>-1&&o.indexOf(b)>-1?p="return vec4(outputValue.x);":o.indexOf(w)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(b)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}return` vec4 `+i+`() { `+c+` coords = getOutputCoords(); `+u+` vec4 outputValue = get`+r+"("+d+`); `+p+` } `}function EB(n,t){var e=n.name,r=e.charAt(0).toUpperCase()+e.slice(1),i="get"+r+"AtOutCoords",a=t.texShape,s=n.shapeInfo.texShape,o=n.shapeInfo.logicalShape.length,c=t.logicalShape.length;if(!n.shapeInfo.isUniform&&o===c&&n.shapeInfo.flatOffset==null&&_.util.arraysEqual(s,a))return` float `+i+`() { return sampleTexture(`+e+`, resultUV); } `;var l=Ze(c),u=p2(n.shapeInfo.logicalShape,t.logicalShape),h=c-o,d,p=["x","y","z","w","u","v"];o===0?d="":c<2&&u.length>=1?d="coords = 0;":d=u.map(function(m){return"coords."+p[m+h]+" = 0;"}).join(` `);var f="";return c<2&&o>0?f="coords":f=n.shapeInfo.logicalShape.map(function(m,g){return"coords."+p[g+h]}).join(", "),` float `+i+`() { `+l+` coords = getOutputCoords(); `+d+` return get`+r+"("+f+`); } `}function Ze(n){if(n<=1)return"int";if(n===2)return"ivec2";if(n===3)return"ivec3";if(n===4)return"ivec4";if(n===5)return"ivec5";if(n===6)return"ivec6";throw Error("GPU for rank "+n+" is not yet supported")}function xa(n,t){var e=JSON.parse(JSON.stringify(n));return e.shapeInfo.logicalShape=t,e}function Sa(n,t){return t.map(function(e){return n[e]}).join(", ")}var YB=function(){function n(t,e,r,i){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,_.util.assert(t.length>2,function(){return"Packed arg"+(r.charAt(0).toUpperCase()+r.slice(1))+" supports only inputs with rank above 2."});var a=t[t.length-1],s=Math.ceil(a/e);this.outputShape=t.slice(0,-1),s>1&&this.outputShape.push(s),i||this.variableNames.push("bestIndicesA");var o=this.outputShape,c=o.length,l=Ze(c),u=Mt("coords",c),h,d;if(s===1){d=c+1;var p=Ze(d);h=` `+p+" sourceLocR = "+p+"("+u.join()+`, 0); ++`+u[c-1]+`; `+p+" sourceLocG = "+p+"("+u.join()+`, 0); ++`+u[c-2]+`; `+p+" sourceLocA = "+p+"("+u.join()+`, 0); --`+u[c-1]+`; `+p+" sourceLocB = "+p+"("+u.join()+`, 0); --`+u[c-2]+";"}else d=c,h=` `+l+` sourceLocR = coords; ++`+u[c-1]+`; `+l+` sourceLocG = coords; ++`+u[c-2]+`; `+l+` sourceLocA = coords; --`+u[c-1]+`; `+l+` sourceLocB = coords; --`+u[c-2]+";";var f=["x","y","z","w","u","v"].slice(0,d),m="."+f[d-1],g=f.map(function(O){return"int "+O}),y=Mt("sourceLocR",d-1).concat("inIdx.r"),w=Mt("sourceLocG",d-1).concat("inIdx.g"),b=Mt("sourceLocB",d-1).concat("inIdx.b"),S=Mt("sourceLocA",d-1).concat("inIdx.a"),x=r==="max"?"greaterThan":"lessThan",N=i?"":` inIdx = round(vec4(getBestIndicesAChannel(`+y.join()+`), getBestIndicesAChannel(`+w.join()+`), getBestIndicesAChannel(`+b.join()+`), getBestIndicesAChannel(`+S.join()+")));",I=`vec4( getAChannel(`+y.join()+`), hasNextCol ? getAChannel(`+w.join()+`) : 0., hasNextRow ? getAChannel(`+b.join()+`) : 0., hasNextRow && hasNextCol ? getAChannel(`+S.join()+") : 0.)",C=i?"":` float getBestIndicesAChannel(`+g.join()+`) { return getChannel(getBestIndicesA(`+f.join()+`), vec2(`+f.slice(-2).join()+`)); }`;this.userCode=` float getAChannel(`+g.join()+`) { return getChannel(getA(`+f.join()+`), vec2(`+f.slice(-2).join()+`)); } `+C+` void main() { `+l+` coords = getOutputCoords(); bool hasNextCol = `+u[c-1]+" < "+(o[c-1]-1)+`; bool hasNextRow = `+u[c-2]+" < "+(o[c-2]-1)+`; `+h+` ivec4 srcIdx = ivec4(sourceLocR`+m+", sourceLocG"+m+`, sourceLocB`+m+", sourceLocA"+m+") * "+e+`; ivec4 inIdx = srcIdx; vec4 bestIndex = vec4(inIdx); vec4 bestValue = `+I+`; for (int i = 0; i < `+e+`; i++) { inIdx = srcIdx; `+N+` vec4 candidate = `+I+`; bvec4 nan = isnan(candidate); bvec4 replace = bvec4( vec4(`+x+`(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 n}();var jB=function(){function n(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterHeight,r=t.filterWidth,i=t.strideHeight,a=t.strideWidth,s=t.dilationHeight,o=t.dilationWidth,c=t.effectiveFilterHeight,l=t.effectiveFilterWidth,u=c-1-t.padInfo.top,h=l-1-t.padInfo.left,d=1/(e*r);this.userCode=` const ivec2 pads = ivec2(`+u+", "+h+`); const float avgMultiplier = float(`+d+`); 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 < `+c+`; wR += `+s+`) { float dyR = float(dyRCorner + wR) / `+i+`.0; if (dyR < 0.0 || dyR >= `+t.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); for (int wC = 0; wC < `+l+`; wC+= `+o+`) { float dyC = float(dyCCorner + wC) / `+a+`.0; if (dyC < 0.0 || dyC >= `+t.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); float dyValue = getDy(b, idyR, idyC, d); dotProd += dyValue * avgMultiplier; } } setOutput(dotProd); } `}return n}(),KB=function(){function n(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterDepth,r=t.filterHeight,i=t.filterWidth,a=t.strideDepth,s=t.strideHeight,o=t.strideWidth,c=t.dilationDepth,l=t.dilationHeight,u=t.dilationWidth,h=t.effectiveFilterDepth,d=t.effectiveFilterHeight,p=t.effectiveFilterWidth,f=h-1-t.padInfo.front,m=d-1-t.padInfo.top,g=p-1-t.padInfo.left,y=1/(e*r*i);this.userCode=` const ivec3 pads = ivec3(`+f+", "+m+", "+g+`); const float avgMultiplier = float(`+y+`); 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 < `+h+`; wD += `+c+`) { float dyD = float(dyDCorner + wD) / `+a+`.0; if (dyD < 0.0 || dyD >= `+t.outDepth+`.0 || fract(dyD) > 0.0) { continue; } int idyD = int(dyD); for (int wR = 0; wR < `+d+`; wR += `+l+`) { float dyR = float(dyRCorner + wR) / `+s+`.0; if (dyR < 0.0 || dyR >= `+t.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); for (int wC = 0; wC < `+p+`; wC += `+u+`) { float dyC = float(dyCCorner + wC) / `+o+`.0; if (dyC < 0.0 || dyC >= `+t.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 n}();var g2=` if (isnan(a)) return a; if (isnan(b)) return b; `,$B=` 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; } `,XB=` 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); `,JB="return float(a == b);",ZB="return float(a < b);",QB="return float(a <= b);",ez="return float(a > b);",tz="return float(a >= b);",nz="return float(a >= 1.0 && b >= 1.0);",rz="return float(a >= 1.0 || b >= 1.0);",iz=g2+` return max(a, b); `,az=g2+` return min(a, b); `,sz=`if (b == 0.0) return NAN; return mod(a, b);`,oz="return (b >= 1.0) ? a : a * (b + 1.0);",y2="return (a < 0.) ? b * a : a;",Bt=function(){function n(t,e,r){this.variableNames=["A","B"],this.outputShape=_.backend_util.assertAndGetBroadcastShape(e,r),this.userCode=` float binaryOperation(float a, float b) { `+t+` } void main() { float a = getAAtOutCoords(); float b = getBAtOutCoords(); setOutput(binaryOperation(a, b)); } `}return n}();var Sc=` 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; `,cz=` 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); `,lz=` // 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)); `+Sc+` return result; `,v2=` vec4 aLessThanZero = vec4(lessThan(a, vec4(0.))); return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); `,uz=` vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.))); return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); `,hz=` return vec4(equal(a, b)); `,dz=` return vec4(lessThan(a, b)); `,pz=` return vec4(lessThanEqual(a, b)); `,fz=` return vec4(greaterThan(a, b)); `,mz=` return vec4(greaterThanEqual(a, b)); `,gz=` return vec4( vec4(greaterThanEqual(a, vec4(1.0))) * vec4(greaterThanEqual(b, vec4(1.0)))); `,yz=` return min( vec4(greaterThanEqual(a, vec4(1.0))) + vec4(greaterThanEqual(b, vec4(1.0))), vec4(1.0)); `,vz=` vec4 result = vec4(max(a, b)); vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0)); `+Sc+` return result; `,wz=` vec4 result = vec4(min(a, b)); vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0)); `+Sc+` return result; `,bz=` vec4 result = mod(a, b); vec4 isNaN = vec4(equal(b, vec4(0.0))); `+Sc+` return result; `,hr=function(){function n(t,e,r,i){i===void 0&&(i=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=_.backend_util.assertAndGetBroadcastShape(e,r);var a=this.outputShape.length,s="";if(i)if(a===0||_.util.sizeFromShape(this.outputShape)===1)s=` result.y = 0.; result.z = 0.; result.w = 0.; `;else{var o=Ze(a);if(s=` `+o+` coords = getOutputCoords(); `,a===1)s+=` result.y = (coords + 1) >= `+this.outputShape[0]+` ? 0. : result.y; result.z = 0.; result.w = 0.; `;else{var c=Mt("coords",a);s+=` bool nextRowOutOfBounds = (`+c[a-2]+" + 1) >= "+this.outputShape[a-2]+`; bool nextColOutOfBounds = (`+c[a-1]+" + 1) >= "+this.outputShape[a-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) { `+t+` } void main() { vec4 a = getAAtOutCoords(); vec4 b = getBAtOutCoords(); vec4 result = binaryOperation(a, b); `+s+` setOutput(result); } `}return n}();var xz=function(){function n(t){this.variableNames=["A"],this.outputShape=t,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 n.prototype.getCustomSetupFunc=function(t,e){var r=this;return function(i,a){r.minLoc==null&&(r.minLoc=i.getUniformLocationNoThrow(a,"minVal"),r.maxLoc=i.getUniformLocationNoThrow(a,"maxVal")),i.gl.uniform1f(r.minLoc,t),i.gl.uniform1f(r.maxLoc,e)}},n}();var Sz=function(){function n(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,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 n.prototype.getCustomSetupFunc=function(t,e){var r=this;return function(i,a){r.minLoc==null&&(r.minLoc=i.getUniformLocationNoThrow(a,"minVal"),r.maxLoc=i.getUniformLocationNoThrow(a,"maxVal")),i.gl.uniform1f(r.minLoc,t),i.gl.uniform1f(r.maxLoc,e)}},n}();var Lz=function(){function n(t){this.variableNames=["real","imag"],this.outputShape=t,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 n}();var Iz=function(){function n(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,r=t.strideWidth,i=t.padInfo.top,a=t.padInfo.left,s=t.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 < `+t.batchSize+`; b++) { for (int yR = 0; yR < `+t.outHeight+`; yR++) { int xR = wR + yR * `+e+" - "+i+`; if (xR < 0 || xR >= `+t.inHeight+`) { continue; } for (int yC = 0; yC < `+t.outWidth+`; yC++) { int xC = wC + yC * `+r+" - "+a+`; if (xC < 0 || xC >= `+t.inWidth+`) { continue; } if (`+s+`) { 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 n}(),Az=function(){function n(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,r=t.filterWidth,i=t.strideHeight,a=t.strideWidth,s=t.dataFormat==="channelsLast",o=e-1-t.padInfo.top,c=r-1-t.padInfo.left,l=s?1:2,u=s?2:3,h=s?3:1;this.userCode=` const ivec2 pads = ivec2(`+o+", "+c+`); void main() { ivec4 coords = getOutputCoords(); int batch = coords[0]; int d1 = coords[`+h+`]; ivec2 dyCorner = ivec2(coords[`+l+"], coords["+u+`]) - 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 < `+e+`; wR++) { float dyR = float(dyRCorner + wR) / `+i+`.0; if (dyR < 0.0 || dyR >= `+t.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); int wRPerm = `+e+` - 1 - wR; for (int wC = 0; wC < `+r+`; wC++) { float dyC = float(dyCCorner + wC) / `+a+`.0; if (dyC < 0.0 || dyC >= `+t.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); int wCPerm = `+r+` - 1 - wC; for (int d2 = 0; d2 < `+t.outChannels+`; d2++) { if (`+s+`) { 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 n}(),Tz=function(){function n(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideDepth,r=t.strideHeight,i=t.strideWidth,a=t.padInfo.front,s=t.padInfo.top,o=t.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 < `+t.batchSize+`; b++) { for (int yF = 0; yF < `+t.outDepth+`; yF++) { int xF = wF + yF * `+e+" - "+a+`; if (xF < 0 || xF >= `+t.inDepth+`) { continue; } for (int yR = 0; yR < `+t.outHeight+`; yR++) { int xR = wR + yR * `+r+" - "+s+`; if (xR < 0 || xR >= `+t.inHeight+`) { continue; } for (int yC = 0; yC < `+t.outWidth+`; yC++) { int xC = wC + yC * `+i+" - "+o+`; if (xC < 0 || xC >= `+t.inWidth+`) { continue; } float dyValue = getDy(b, yF, yR, yC, d2); float xValue = getX(b, xF, xR, xC, d1); dotProd += (xValue * dyValue); } } } } setOutput(dotProd); } `}return n}(),Nz=function(){function n(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterDepth,r=t.filterHeight,i=t.filterWidth,a=t.strideDepth,s=t.strideHeight,o=t.strideWidth,c=e-1-t.padInfo.front,l=r-1-t.padInfo.top,u=i-1-t.padInfo.left;this.userCode=` const ivec3 pads = ivec3(`+c+", "+l+", "+u+`); 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 < `+e+`; wF++) { float dyF = float(dyFCorner + wF) / `+a+`.0; if (dyF < 0.0 || dyF >= `+t.outDepth+`.0 || fract(dyF) > 0.0) { continue; } int idyF = int(dyF); int wFPerm = `+e+` - 1 - wF; for (int wR = 0; wR < `+r+`; wR++) { float dyR = float(dyRCorner + wR) / `+s+`.0; if (dyR < 0.0 || dyR >= `+t.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); int wRPerm = `+r+` - 1 - wR; for (int wC = 0; wC < `+i+`; wC++) { float dyC = float(dyCCorner + wC) / `+o+`.0; if (dyC < 0.0 || dyC >= `+t.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); int wCPerm = `+i+` - 1 - wC; for (int d2 = 0; d2 < `+t.outChannels+`; d2++) { float xValue = getDy(batch, idyF, idyR, idyC, d2); float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2); dotProd += xValue * wValue; } } } } setOutput(dotProd); } `}return n}();var _z=function(){function n(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,r=t.strideWidth,i=t.padInfo.top,a=t.padInfo.left,s=t.outChannels/t.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 * `+s+` + dm; float dotProd = 0.0; // TO DO: Vec4 over the batch size for (int b = 0; b < `+t.batchSize+`; b++) { for (int yR = 0; yR < `+t.outHeight+`; yR++) { int xR = wR + yR * `+e+" - "+i+`; if (xR < 0 || xR >= `+t.inHeight+`) { continue; } for (int yC = 0; yC < `+t.outWidth+`; yC++) { int xC = wC + yC * `+r+" - "+a+`; if (xC < 0 || xC >= `+t.inWidth+`) { continue; } float dyValue = getDy(b, yR, yC, d2); float xValue = getX(b, xR, xC, d1); dotProd += (xValue * dyValue); } } } setOutput(dotProd); } `}return n}(),Cz=function(){function n(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,r=t.filterWidth,i=t.strideHeight,a=t.strideWidth,s=e-1-t.padInfo.top,o=r-1-t.padInfo.left,c=t.outChannels/t.inChannels;this.userCode=` const ivec2 pads = ivec2(`+s+", "+o+`); 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 < `+e+`; wR++) { float dyR = float(dyRCorner + wR) / `+i+`.0; if (dyR < 0.0 || dyR >= `+t.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); int wRPerm = `+e+` - 1 - wR; for (int wC = 0; wC < `+r+`; wC++) { float dyC = float(dyCCorner + wC) / `+a+`.0; if (dyC < 0.0 || dyC >= `+t.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); int wCPerm = `+r+` - 1 - wC; // TO DO: Vec4 over the channelMul for (int dm = 0; dm < `+c+`; dm++) { int d2 = d1 * `+c+` + dm; float xValue = getDy(batch, idyR, idyC, d2); float wValue = getW(wRPerm, wCPerm, d1, dm); dotProd += xValue * wValue; } } } setOutput(dotProd); } `}return n}();var w2=function(){function n(t,e,r,i){e===void 0&&(e=!1),r===void 0&&(r=null),i===void 0&&(i=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var a=t.padInfo.top,s=t.padInfo.left,o=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,u=t.dilationWidth,h=t.filterHeight,d=t.filterWidth,p=Math.floor(t.inChannels/4)*4,f=t.inChannels%4,m=t.dataFormat==="channelsLast",g=m?1:2,y=m?2:3,w=m?3:1,b="",S="";r&&(i?b=`float activation(float a) { float b = getPreluActivationWeightsAtOutCoords(); `+r+` }`:b=` float activation(float x) { `+r+` } `,S="result = activation(result);");var x=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),this.userCode=` `+b+` const ivec2 strides = ivec2(`+o+", "+c+`); const ivec2 pads = ivec2(`+a+", "+s+`); void main() { ivec4 coords = getOutputCoords(); int batch = coords[0]; int d2 = coords[`+w+`]; ivec2 xRCCorner = ivec2(coords[`+g+"], coords["+y+`]) * 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 < `+h+`; wR++) { int xR = xRCorner + wR * `+l+`; if (xR < 0 || xR >= `+t.inHeight+`) { continue; } for (int wC = 0; wC < `+d+`; wC++) { int xC = xCCorner + wC * `+u+`; if (xC < 0 || xC >= `+t.inWidth+`) { continue; } for (int d1 = 0; d1 < `+p+`; 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 (`+m+`) { 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 (`+(f===1)+`) { if (`+m+`) { dotProd += getX(batch, xR, xC, `+p+`) * getW(wR, wC, `+p+`, d2); } else { dotProd += getX(batch, `+p+`, xR, xC) * getW(wR, wC, `+p+`, d2); } } else if (`+(f===2)+`) { vec2 wValues = vec2( getW(wR, wC, `+p+`, d2), getW(wR, wC, `+p+` + 1, d2) ); if (`+m+`) { vec2 xValues = vec2( getX(batch, xR, xC, `+p+`), getX(batch, xR, xC, `+p+` + 1) ); dotProd += dot(xValues, wValues); } else { vec2 xValues = vec2( getX(batch, `+p+`, xR, xC), getX(batch, `+p+` + 1, xR, xC) ); dotProd += dot(xValues, wValues); } } else if (`+(f===3)+`) { vec3 wValues = vec3( getW(wR, wC, `+p+`, d2), getW(wR, wC, `+p+` + 1, d2), getW(wR, wC, `+p+` + 2, d2) ); if (`+m+`) { vec3 xValues = vec3( getX(batch, xR, xC, `+p+`), getX(batch, xR, xC, `+p+` + 1), getX(batch, xR, xC, `+p+` + 2) ); dotProd += dot(xValues, wValues); } else { vec3 xValues = vec3( getX(batch, `+p+`, xR, xC), getX(batch, `+p+` + 1, xR, xC), getX(batch, `+p+` + 2, xR, xC) ); dotProd += dot(xValues, wValues); } } } } float result = dotProd; `+x+` `+S+` setOutput(result); } `}return n}(),Rz=function(){function n(t){this.variableNames=["x","W"],this.outputShape=t.outShape;var e=t.padInfo.front,r=t.padInfo.top,i=t.padInfo.left,a=t.strideDepth,s=t.strideHeight,o=t.strideWidth,c=t.dilationDepth,l=t.dilationHeight,u=t.dilationWidth,h=t.filterDepth,d=t.filterHeight,p=t.filterWidth,f=Math.floor(t.inChannels/4)*4,m=t.inChannels%4;this.userCode=` const ivec3 strides = ivec3(`+a+", "+s+", "+o+`); const ivec3 pads = ivec3(`+e+", "+r+", "+i+`); 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 < `+h+`; wF++) { int xF = xFCorner + wF * `+c+`; if (xF < 0 || xF >= `+t.inDepth+`) { continue; } for (int wR = 0; wR < `+d+`; wR++) { int xR = xRCorner + wR * `+l+`; if (xR < 0 || xR >= `+t.inHeight+`) { continue; } for (int wC = 0; wC < `+p+`; wC++) { int xC = xCCorner + wC * `+u+`; if (xC < 0 || xC >= `+t.inWidth+`) { continue; } for (int d1 = 0; d1 < `+f+`; 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 (`+(m===1)+`) { dotProd += getX(batch, xF, xR, xC, `+f+`) * getW(wF, wR, wC, `+f+`, d2); } else if (`+(m===2)+`) { vec2 xValues = vec2( getX(batch, xF, xR, xC, `+f+`), getX(batch, xF, xR, xC, `+f+` + 1) ); vec2 wValues = vec2( getW(wF, wR, wC, `+f+`, d2), getW(wF, wR, wC, `+f+` + 1, d2) ); dotProd += dot(xValues, wValues); } else if (`+(m===3)+`) { vec3 xValues = vec3( getX(batch, xF, xR, xC, `+f+`), getX(batch, xF, xR, xC, `+f+` + 1), getX(batch, xF, xR, xC, `+f+` + 2) ); vec3 wValues = vec3( getW(wF, wR, wC, `+f+`, d2), getW(wF, wR, wC, `+f+` + 1, d2), getW(wF, wR, wC, `+f+` + 2, d2) ); dotProd += dot(xValues, wValues); } } } } setOutput(dotProd); } `}return n}();var b2=function(){function n(t,e,r,i){e===void 0&&(e=!1),r===void 0&&(r=null),i===void 0&&(i=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var a=t.inHeight,s=t.inWidth,o=t.padInfo.top,c=t.padInfo.left,l=t.strideHeight,u=t.strideWidth,h=t.dilationHeight,d=t.dilationWidth,p=t.filterHeight,f=t.filterWidth,m=t.outChannels/t.inChannels,g="",y="";r&&(i?g=`float activation(float a) { float b = getPreluActivationWeightsAtOutCoords(); `+r+` }`:g=` float activation(float x) { `+r+` } `,y="result = activation(result);");var w=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),this.userCode=` `+g+` const ivec2 strides = ivec2(`+l+", "+u+`); const ivec2 pads = ivec2(`+o+", "+c+`); void main() { ivec4 coords = getOutputCoords(); int batch = coords.x; ivec2 xRCCorner = coords.yz * strides - pads; int d2 = coords.w; int d1 = d2 / `+m+`; int q = d2 - d1 * `+m+`; 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 < `+p+`; wR++) { int xR = xRCorner + wR * `+h+`; if (xR < 0 || xR >= `+a+`) { continue; } for (int wC = 0; wC < `+f+`; wC++) { int xC = xCCorner + wC * `+d+`; if (xC < 0 || xC >= `+s+`) { continue; } float xVal = getX(batch, xR, xC, d1); float wVal = getW(wR, wC, d1, q); dotProd += xVal * wVal; } } float result = dotProd; `+w+` `+y+` setOutput(result); } `}return n}();var x2=function(){function n(t,e,r,i){e===void 0&&(e=!1),r===void 0&&(r=null),i===void 0&&(i=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.outShape;for(var a=t.inHeight,s=t.inWidth,o=t.padInfo.top,c=t.padInfo.left,l=t.strideHeight,u=t.strideWidth,h=t.dilationHeight,d=t.dilationWidth,p=t.filterHeight,f=t.filterWidth,m=f,g="int xR; int xC; int xCOffset;",y=0;y= 0 && xR < `+a+" && xCOffset >= 0 && xCOffset < "+s+`) { xTexelR`+y+"C"+w+` = getX(batch, xR, xCOffset, d1); // Need to manually clear unused channels in case // we're reading from recycled texture. if(xCOffset + 1 >= `+s+`) { xTexelR`+y+"C"+w+`.zw = vec2(0.); } } else { xTexelR`+y+"C"+w+` = vec4(0.); } xCOffset = xC + 1 - 2; if(xR >= 0 && xR < `+a+" && xCOffset >= 0 && xCOffset < "+s+`) { vec4 previous = getX(batch, xR, xCOffset, d1); // Need to manually clear unused channels in case // we're reading from recycled texture. if(xCOffset + 1 >= `+s+`) { previous.zw = vec2(0.); } xR`+y+"C"+w+" = vec4(previous.zw, xTexelR"+y+"C"+w+`.xy); } else { xR`+y+"C"+w+" = vec4(0, 0, xTexelR"+y+"C"+w+`.xy); } `:g+=` if(xR >= 0 && xR < `+a+" && xC >= 0 && xC < "+s+`) { xTexelR`+y+"C"+w+` = getX(batch, xR, xC, d1); } else { xTexelR`+y+"C"+w+` = vec4(0.); } xR`+y+"C"+w+" = xTexelR"+y+"C"+w+`; `,w+1= 0 && xR < `+a+` && xCOffset >= 0 && xCOffset < `+s+`) { xTexelR`+y+"C"+(w+2)+` = getX(batch, xR, xCOffset, d1); } `,d>1&&(g+=` xCOffset -= 2; if(xR >= 0 && xR < `+a+` && xCOffset >= 0 && xCOffset < `+s+`) { xTexelR`+y+"C"+w+` = getX(batch, xR, xCOffset, d1); } else { xTexelR`+y+"C"+w+` = vec4(0.); } `),g+=` xR`+y+"C"+(w+1)+` = vec4( xTexelR`+y+"C"+w+".zw, xTexelR"+y+"C"+(w+2)+`.xy); `):g+=` xCOffset = xC + `+S+`; if(xR >= 0 && xR < `+a+` && xCOffset >= 0 && xCOffset < `+s+`) { xTexelR`+y+"C"+(w+2)+` = getX(batch, xR, xCOffset, d1); } xR`+y+"C"+(w+1)+" = xTexelR"+y+"C"+(w+2)+`; `}}else w= 0 && xR < `+a+`) { `,c%2===1?(g+=` xCOffset = xC + 1 - `+u+`; if(xCOffset >= 0 && xCOffset < `+s+`) { xTexelR`+y+"C"+w+` = getX(batch, xR, xCOffset, d1); } else { xTexelR`+y+"C"+w+` = vec4(0.); } if(xC + 1 >= 0 && xC + 1 < `+s+`) { xTexelR`+y+"C"+(w+2)+` = getX(batch, xR, xC + 1, d1); } else { xTexelR`+y+"C"+(w+2)+` = vec4(0.); } xR`+y+"C"+w+` = vec4( xTexelR`+y+"C"+w+".zw, xTexelR"+y+"C"+(w+2)+`.zw); `,w+1= 0 && xCOffset < `+s+`) { final = getX(batch, xR, xCOffset, d1); } xR`+y+"C"+(w+1)+" = vec4(xTexelR"+y+"C"+(w+2)+`.xy, final.xy); `)):(g+=` if(xC >= 0 && xC < `+s+`) { xTexelR`+y+"C"+w+` = getX(batch, xR, xC, d1); } else { xTexelR`+y+"C"+w+` = vec4(0.); } xCOffset = xC + `+u+`; if(xCOffset >= 0 && xCOffset < `+s+`) { xTexelR`+y+"C"+(w+2)+` = getX(batch, xR, xCOffset, d1); } else { xTexelR`+y+"C"+(w+2)+` = vec4(0.); } xR`+y+"C"+w+` = vec4( xTexelR`+y+"C"+w+".xy, xTexelR"+y+"C"+(w+2)+`.xy); `,w+11?[""+(o-1)/(h-1),"(y2-y1) * height_ratio","y1*"+m+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+m],w=y[0],b=y[1],S=y[2],x=d>1?[""+(c-1)/(d-1),"(x2-x1) * width_ratio","x1*"+g+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+g],N=x[0],I=x[1],C=x[2];this.userCode=` const float height_ratio = float(`+w+`); const float width_ratio = float(`+N+`); 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 >= `+s+`) { return; } float height_scale = `+b+`; float width_scale = `+I+`; float in_y = `+S+`; if( in_y < 0.0 || in_y > `+m+` ) { setOutput(float(`+a+`)); return; } float in_x = `+C+`; if( in_x < 0.0 || in_x > `+g+` ) { setOutput(float(`+a+`)); return; } vec2 sourceFracIndexCR = vec2(in_x,in_y); if(`+p+` == 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 n}(),I2=function(){function n(t,e,r){this.variableNames=["x"],this.outputShape=t;var i=t.length,a=e?"0.0":"getX("+S2(i,"coords")+")",s=t[t.length-1],o="",c="";e?(o=r?"end != "+(s-1):"end != 0",c=r?"end + 1":"end - 1"):(o=r?"end + pow2 < "+s:"end >= pow2",c=r?"end + pow2":"end - pow2"),this.userCode=` uniform float index; void main() { `+Ze(i)+` coords = getOutputCoords(); int end = `+L2(i,"coords")+`; float val = `+a+`; int pow2 = int(pow(2.0, index)); if (`+o+`) { int idx = `+c+`; `+L2(i,"coords")+` = idx; val += getX(`+S2(i,"coords")+`); } setOutput(val); } `}return n.prototype.getCustomSetupFunc=function(t){var e=this;return function(r,i){e.index==null&&(e.index=r.getUniformLocation(i,"index")),r.gl.uniform1f(e.index,t)}},n}();function S2(n,t){if(n===1)return""+t;if(n===2)return t+".x, "+t+".y";if(n===3)return t+".x, "+t+".y, "+t+".z";if(n===4)return t+".x, "+t+".y, "+t+".z, "+t+".w";throw Error("Cumulative sum for rank "+n+" is not yet supported")}function L2(n,t){if(n===1)return""+t;if(n===2)return t+".y";if(n===3)return t+".z";if(n===4)return t+".w";throw Error("Cumulative sum for rank "+n+" is not yet supported")}var Ez=function(){function n(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=Is.DENSE;var e=Ts(t),r=Ht();this.outputShape=t,this.userCode=` ivec3 outCoordsFromFlatIndex(int index) { `+_i(["r","c","d"],t)+` return ivec3(r, c, d); } void main() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+e[0]+", "+e[1]+`)); int index = 4 * (resTexRC.x * `+e[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); } `+r.output+` = result; } `}return n}();var Dz=function(){function n(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=Is.DENSE;var e=Ts(t),r=Ht();this.outputShape=t,this.userCode=` ivec3 outCoordsFromFlatIndex(int index) { `+_i(["r","c","d"],t)+` return ivec3(r, c, d); } void main() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(`+e[0]+", "+e[1]+`)); int index = 4 * (resTexRC.x * `+e[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)); } `+r.output+` = result; } `}return n}();var kz=function(){function n(t,e,r){this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=e,this.dataFormat=r,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 / `+e+`; int offset_h = imod(h, `+e+`); int in_w = w / `+e+`; int offset_w = imod(w, `+e+`); int offset_d = (offset_h * `+e+` + offset_w) * `+this.getOutputDepthSize()+`; int in_d = d + offset_d; float result = `+this.getInputSamplingString()+`; setOutput(result); } `}return n.prototype.getHeightCoordString=function(){return this.dataFormat==="NHWC"?"coords[1]":"coords[2]"},n.prototype.getWidthCoordString=function(){return this.dataFormat==="NHWC"?"coords[2]":"coords[3]"},n.prototype.getDepthCoordString=function(){return this.dataFormat==="NHWC"?"coords[3]":"coords[1]"},n.prototype.getOutputDepthSize=function(){return this.dataFormat==="NHWC"?this.outputShape[3]:this.outputShape[1]},n.prototype.getInputSamplingString=function(){return this.dataFormat==="NHWC"?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"},n}();var Fz=function(){function n(t){this.variableNames=["X"],this.outputShape=[t,t],this.userCode=` void main() { ivec2 coords = getOutputCoords(); float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; setOutput(val); } `}return n}();var Wz=function(){function n(t){this.variableNames=["A"],this.outTexUsage=hn.DOWNLOAD;var e=Ht();this.outputShape=t,this.userCode=` `+d2+` void main() { float x = getAAtOutCoords(); `+e.output+` = encode_float(x); } `}return n}();var Uz=function(){function n(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=hn.DOWNLOAD;var e=Ht();this.outputShape=t,this.userCode=` `+d2+` void main() { ivec3 coords = getOutputCoords(); float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z)); `+e.output+` = encode_float(x); } `}return n}();var Bz=function(){function n(t,e,r){r===void 0&&(r=!1),this.variableNames=["A"];var i=Ht(),a=e[0],s=e[1];this.outputShape=t;var o="result";r&&(o="floor(result * 255. + 0.5)"),this.userCode=` `+Ep(t)+` void main() { ivec3 coords = getOutputCoords(); int flatIndex = getFlatIndex(coords); int offset = imod(flatIndex, 4); flatIndex = idiv(flatIndex, 4, 1.); int r = flatIndex / `+s+`; int c = imod(flatIndex, `+s+`); vec2 uv = (vec2(c, r) + halfCR) / vec2(`+s+".0, "+a+`.0); vec4 values = `+i.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]; } `+i.output+" = vec4("+o+`, 0., 0., 0.); } `}return n}();var zz=function(){function n(t,e,r){r===void 0&&(r=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var i=Ht(),a=e[0],s=e[1];this.outputShape=t;var o="",c="result";r&&(c="floor(result * 255. + 0.5)");for(var l=0;l<=1;l++)for(var u=0;u<=1;u++){var h=l*2+u;o+=` localCoords = coords; if(localCoords[2] + `+u+" < "+t[2]+`) { localCoords[2] += `+u+`; if(localCoords[1] + `+l+" < "+t[1]+`) { localCoords[1] += `+l+`; flatIndex = getFlatIndex(localCoords); offset = imod(flatIndex, 4); flatIndex = idiv(flatIndex, 4, 1.); r = flatIndex / `+s+`; c = imod(flatIndex, `+s+`); uv = (vec2(c, r) + halfCR) / vec2(`+s+".0, "+a+`.0); values = `+i.texture2D+`(A, uv); if(offset == 0) { result[`+h+`] = values[0]; } else if(offset == 1) { result[`+h+`] = values[1]; } else if(offset == 2) { result[`+h+`] = values[2]; } else { result[`+h+`] = values[3]; } } } `}this.userCode=` `+Ep(t)+` void main() { ivec3 coords = getOutputCoords(); vec4 result = vec4(0.); int flatIndex, r, c, offset; ivec3 localCoords; vec2 uv; vec4 values; `+o+` `+i.output+" = "+c+`; } `}return n}();var Pz=function(){function n(t,e){this.outputShape=[],this.variableNames=["x"],this.outputShape=t,this.userCode=` uniform float value; void main() { // Input can be obtained from uniform value. setOutput(value); } `}return n.prototype.getCustomSetupFunc=function(t){var e=this;return function(r,i){e.valueLoc==null&&(e.valueLoc=r.getUniformLocationNoThrow(i,"value")),r.gl.uniform1f(e.valueLoc,t)}},n}();var Hz=function(){function n(t,e,r){this.variableNames=["A","indices"];var i=t.slice();i[r]=e,this.outputShape=i,this.rank=i.length;var a=Ze(this.rank),s=Mz(t,r);this.userCode=` void main() { `+a+` resRC = getOutputCoords(); setOutput(getA(`+s+`)); } `}return n}();function Mz(n,t){var e=n.length;if(e>4)throw Error("Gather for rank "+e+" is not yet supported");if(e===1)return"int(getIndices(resRC))";for(var r=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],a=0;a1?"strides[j]":"strides";this.userCode=` `+i+" strides = "+i+"("+this.strides+`); void main() { `+a+` coords = getOutputCoords(); int flattenIndex = 0; for (int j = 0; j < `+this.sliceDim+`; j++) { int index = round(getIndices(coords[0], j)); flattenIndex += index * `+s+`; } setOutput(getX(flattenIndex, coords[1])); } `}return n}();function A2(n){var t=Ht(),e=t.version+` precision highp float; `+t.attribute+` vec3 clipSpacePos; `+t.attribute+` vec2 uv; `+t.varyingVs+` vec2 resultUV; void main() { gl_Position = vec4(clipSpacePos, 1); resultUV = uv; }`;return Vb(n,e)}function T2(n){var t=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return jb(n,t)}function N2(n){var t=new Uint16Array([0,1,2,2,1,3]);return Kb(n,t)}function Rs(n,t,e,r,i,a){Xb(t,e);var s=$b(n),o=n.TEXTURE_2D;return de(n,function(){return n.bindTexture(o,s)}),de(n,function(){return n.texParameteri(o,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE)}),de(n,function(){return n.texParameteri(o,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}),de(n,function(){return n.texParameteri(o,n.TEXTURE_MIN_FILTER,n.NEAREST)}),de(n,function(){return n.texParameteri(o,n.TEXTURE_MAG_FILTER,n.NEAREST)}),de(n,function(){return n.texImage2D(o,0,r,t,e,0,i,a,null)}),de(n,function(){return n.bindTexture(n.TEXTURE_2D,null)}),s}function Dp(n){return n.internalFormatFloat}function _2(n,t,e,r){var i=As(t,e),a=i[0],s=i[1];return Rs(n,a,s,Dp(r),r.textureFormatFloat,n.FLOAT)}function kp(n){return n.internalFormatHalfFloat}function C2(n,t,e,r){var i=As(t,e),a=i[0],s=i[1];return Rs(n,a,s,kp(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function Fp(n){return n.downloadTextureFormat}function R2(n,t,e,r){var i=As(t,e),a=i[0],s=i[1];return Rs(n,a,s,Fp(r),n.RGBA,n.UNSIGNED_BYTE)}function Wp(n){return n.internalFormatPackedFloat}function O2(n,t,e,r){var i=ga(t,e),a=i[0],s=i[1];return Rs(n,a,s,Wp(r),n.RGBA,n.FLOAT)}function Up(n){return n.internalFormatPackedHalfFloat}function E2(n,t,e,r){var i=ga(t,e),a=i[0],s=i[1];return Rs(n,a,s,Up(r),n.RGBA,r.textureTypeHalfFloat)}function D2(n,t,e){var r=0,i=3*4,a=3*4+2*4;de(n,function(){return n.bindBuffer(n.ARRAY_BUFFER,e)});var s=Tp(n,t,"clipSpacePos",e,3,a,r);return s&&Tp(n,t,"uv",e,2,a,i)}function k2(n,t,e,r,i,a){de(n,function(){return n.bindTexture(n.TEXTURE_2D,t)});var s,o,c;i instanceof Uint8Array?(s=new Uint8Array(e*r*4),o=n.UNSIGNED_BYTE,c=n.RGBA):(s=new Float32Array(e*r*4),o=n.FLOAT,c=a.internalFormatPackedFloat),s.set(i),de(n,function(){return n.texImage2D(n.TEXTURE_2D,0,c,e,r,0,n.RGBA,o,s)}),de(n,function(){return n.bindTexture(n.TEXTURE_2D,null)})}function F2(n,t,e){de(n,function(){return n.bindTexture(n.TEXTURE_2D,t)}),e.data instanceof Uint8Array?de(n,function(){return n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e.width,e.height,0,n.RGBA,n.UNSIGNED_BYTE,e.data)}):de(n,function(){return n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e)}),de(n,function(){return n.bindTexture(n.TEXTURE_2D,null)})}function W2(n,t,e,r){var i=n.createBuffer();de(n,function(){return n.bindBuffer(n.PIXEL_PACK_BUFFER,i)});var a=4,s=4,o=a*s*t*e;return de(n,function(){return n.bufferData(n.PIXEL_PACK_BUFFER,o,n.STREAM_READ)}),de(n,function(){return n.readPixels(0,0,e,t,n.RGBA,n.FLOAT,0)}),de(n,function(){return n.bindBuffer(n.PIXEL_PACK_BUFFER,null)}),i}function U2(n,t,e){var r=n,i=new Float32Array(e);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,i),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),i}function B2(n,t,e,r){var i=As(t,e),a=i[0],s=i[1],o=4,c=new Uint8Array(wU(t*e,o));return de(n,function(){return n.readPixels(0,0,a,s,r.downloadTextureFormat,n.UNSIGNED_BYTE,c)}),new Float32Array(c.buffer)}function z2(n,t,e,r,i,a,s,o){var c=n,l=new Float32Array(bU(a,s));return c.bindBuffer(c.PIXEL_PACK_BUFFER,t),c.getBufferSubData(c.PIXEL_PACK_BUFFER,0,l),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),l}function P2(n,t,e){var r=new Float32Array(t*e*4);return de(n,function(){return n.readPixels(0,0,e,t,n.RGBA,n.FLOAT,r)}),r}var qz={__proto__:null,createVertexShader:A2,createVertexBuffer:T2,createIndexBuffer:N2,getInternalFormatForFloat32MatrixTexture:Dp,createFloat32MatrixTexture:_2,getInternalFormatForFloat16MatrixTexture:kp,createFloat16MatrixTexture:C2,getInternalFormatForUnsignedBytesMatrixTexture:Fp,createUnsignedBytesMatrixTexture:R2,getInternalFormatForPackedMatrixTexture:Wp,createPackedMatrixTexture:O2,getInternalFormatForFloat16PackedMatrixTexture:Up,createFloat16PackedMatrixTexture:E2,bindVertexProgramAttributeStreams:D2,uploadDenseMatrixToTexture:k2,uploadPixelDataToTexture:F2,createBufferFromOutputTexture:W2,downloadFloat32MatrixFromBuffer:U2,downloadByteEncodedFloatMatrixFromOutputTexture:B2,downloadPackedMatrixFromBuffer:z2,downloadMatrixFromPackedOutputTexture:P2};var M2=function(){function n(t){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var e=_.env().getNumber("WEBGL_VERSION");t!=null?(this.gl=t,Pb(e,t)):this.gl=jn(e);var r="WEBGL_color_buffer_float",i="EXT_color_buffer_half_float";if(_.env().getNumber("WEBGL_VERSION")===1){var a="OES_texture_float",s="OES_texture_half_float";if(this.textureFloatExtension=Ns(this.gl,a),dn(this.gl,s))this.textureHalfFloatExtension=Ns(this.gl,s);else if(_.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(r),dn(this.gl,i))this.colorBufferHalfFloatExtension=Ns(this.gl,i);else if(_.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(r="EXT_color_buffer_float",dn(this.gl,r))this.colorBufferFloatExtension=this.gl.getExtension(r);else if(dn(this.gl,i))this.colorBufferHalfFloatExtension=this.gl.getExtension(i);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=T2(this.gl),this.indexBuffer=N2(this.gl),this.framebuffer=Jb(this.gl),this.textureConfig=Ap(this.gl,this.textureHalfFloatExtension)}return Object.defineProperty(n.prototype,"debug",{get:function(){return _.env().getBool("DEBUG")},enumerable:!0,configurable:!0}),n.prototype.dispose=function(){var t=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 e=this.gl;de(e,function(){return e.finish()}),de(e,function(){return e.bindFramebuffer(e.FRAMEBUFFER,null)}),de(e,function(){return e.deleteFramebuffer(t.framebuffer)}),de(e,function(){return e.bindBuffer(e.ARRAY_BUFFER,null)}),de(e,function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)}),de(e,function(){return e.deleteBuffer(t.indexBuffer)}),this.disposed=!0},n.prototype.createFloat32MatrixTexture=function(t,e){return this.throwIfDisposed(),_2(this.gl,t,e,this.textureConfig)},n.prototype.createFloat16MatrixTexture=function(t,e){return this.throwIfDisposed(),C2(this.gl,t,e,this.textureConfig)},n.prototype.createUnsignedBytesMatrixTexture=function(t,e){return this.throwIfDisposed(),R2(this.gl,t,e,this.textureConfig)},n.prototype.uploadPixelDataToTexture=function(t,e){this.throwIfDisposed(),F2(this.gl,t,e)},n.prototype.uploadDenseMatrixToTexture=function(t,e,r,i){this.throwIfDisposed(),k2(this.gl,t,e,r,i,this.textureConfig)},n.prototype.createFloat16PackedMatrixTexture=function(t,e){return this.throwIfDisposed(),E2(this.gl,t,e,this.textureConfig)},n.prototype.createPackedMatrixTexture=function(t,e){return this.throwIfDisposed(),O2(this.gl,t,e,this.textureConfig)},n.prototype.deleteMatrixTexture=function(t){var e=this;this.throwIfDisposed(),this.outputTexture===t&&(Np(this.gl,this.framebuffer),this.outputTexture=null),de(this.gl,function(){return e.gl.deleteTexture(t)})},n.prototype.downloadByteEncodedFloatMatrixFromOutputTexture=function(t,e,r){var i=this;return this.downloadMatrixDriver(t,function(){return B2(i.gl,e,r,i.textureConfig)})},n.prototype.downloadPackedMatrixFromBuffer=function(t,e,r,i,a,s){return z2(this.gl,t,e,r,i,a,s,this.textureConfig)},n.prototype.downloadFloat32MatrixFromBuffer=function(t,e){return U2(this.gl,t,e)},n.prototype.createBufferFromTexture=function(t,e,r){this.bindTextureToFrameBuffer(t);var i=W2(this.gl,e,r,this.textureConfig);return this.unbindTextureToFrameBuffer(),i},n.prototype.createAndWaitForFence=function(){var t=this.createFence(this.gl);return this.pollFence(t)},n.prototype.createFence=function(t){var e=this,r,i;if(_.env().getBool("WEBGL_FENCE_API_ENABLED")){var a=t,s=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),i=function(){var o=a.clientWaitSync(s,0,0);return o===a.ALREADY_SIGNALED||o===a.CONDITION_SATISFIED},r=s}else _.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(r=this.beginQuery(),this.endQuery(),i=function(){return e.isQueryAvailable(r,_.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):i=function(){return!0};return{query:r,isFencePassed:i}},n.prototype.downloadMatrixFromPackedTexture=function(t,e,r){var i=this;return this.downloadMatrixDriver(t,function(){return P2(i.gl,e,r)})},n.prototype.createProgram=function(t){this.throwIfDisposed();var e=this.gl,r=qb(e,t),i=A2(e),a=Gb(e);return de(e,function(){return e.attachShader(a,i)}),de(e,function(){return e.attachShader(a,r)}),Yb(e,a),this.debug&&gc(e,a),this.vertexAttrsAreBound||(this.setProgram(a),this.vertexAttrsAreBound=D2(e,this.program,this.vertexBuffer)),a},n.prototype.deleteProgram=function(t){var e=this;this.throwIfDisposed(),t===this.program&&(this.program=null),t!=null&&de(this.gl,function(){return e.gl.deleteProgram(t)})},n.prototype.setProgram=function(t){var e=this;this.throwIfDisposed(),this.program=t,this.program!=null&&this.debug&&gc(this.gl,this.program),de(this.gl,function(){return e.gl.useProgram(t)})},n.prototype.getUniformLocation=function(t,e,r){return r===void 0&&(r=!0),this.throwIfDisposed(),r?e2(this.gl,t,e):t2(this.gl,t,e)},n.prototype.getAttributeLocation=function(t,e){var r=this;return this.throwIfDisposed(),de(this.gl,function(){return r.gl.getAttribLocation(t,e)})},n.prototype.getUniformLocationNoThrow=function(t,e){return this.throwIfDisposed(),this.gl.getUniformLocation(t,e)},n.prototype.setInputMatrixTexture=function(t,e,r){this.throwIfDisposed(),this.throwIfNoProgram(),n2(this.gl,t,e,r)},n.prototype.setOutputMatrixTexture=function(t,e,r){this.setOutputMatrixTextureDriver(t,r,e)},n.prototype.setOutputPackedMatrixTexture=function(t,e,r){this.throwIfDisposed();var i=ga(e,r),a=i[0],s=i[1];this.setOutputMatrixTextureDriver(t,a,s)},n.prototype.setOutputMatrixWriteRegion=function(t,e,r,i){this.setOutputMatrixWriteRegionDriver(r,t,i,e)},n.prototype.setOutputPackedMatrixWriteRegion=function(t,e,r,i){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")},n.prototype.debugValidate=function(){this.program!=null&&gc(this.gl,this.program),_s(this.gl)},n.prototype.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var t=this.gl;this.debug&&this.debugValidate(),de(t,function(){return t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0)})},n.prototype.blockUntilAllProgramsCompleted=function(){var t=this;this.throwIfDisposed(),de(this.gl,function(){return t.gl.finish()})},n.prototype.getQueryTimerExtension=function(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=Ns(this.gl,_.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension},n.prototype.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension()},n.prototype.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension()},n.prototype.beginQuery=function(){if(_.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){var t=this.gl,e=this.getQueryTimerExtensionWebGL2(),r=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,r),r}var i=this.getQueryTimerExtensionWebGL1(),a=i.createQueryEXT();return i.beginQueryEXT(i.TIME_ELAPSED_EXT,a),a},n.prototype.endQuery=function(){if(_.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){var t=this.gl,e=this.getQueryTimerExtensionWebGL2();t.endQuery(e.TIME_ELAPSED_EXT);return}var r=this.getQueryTimerExtensionWebGL1();r.endQueryEXT(r.TIME_ELAPSED_EXT)},n.prototype.waitForQueryAndGetTime=function(t){return fc(this,void 0,void 0,function(){var e=this;return mc(this,function(r){switch(r.label){case 0:return[4,_.util.repeatedTry(function(){return e.disposed||e.isQueryAvailable(t,_.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))})];case 1:return r.sent(),[2,this.getQueryTime(t,_.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))]}})})},n.prototype.getQueryTime=function(t,e){if(e===0)return null;if(e===2){var r=this.gl,i=r.getQueryParameter(t,r.QUERY_RESULT);return i/1e6}else{var a=this.getQueryTimerExtensionWebGL1(),i=a.getQueryObjectEXT(t,a.QUERY_RESULT_EXT);return i/1e6}},n.prototype.isQueryAvailable=function(t,e){if(e===0)return!0;if(e===2){var r=this.gl,i=this.getQueryTimerExtensionWebGL2(),a=r.getQueryParameter(t,r.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(i.GPU_DISJOINT_EXT)),a&&!this.disjoint}else{var i=this.getQueryTimerExtensionWebGL1(),a=i.getQueryObjectEXT(t,i.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(i.GPU_DISJOINT_EXT)),a&&!this.disjoint}},n.prototype.pollFence=function(t){var e=this;return new Promise(function(r){e.addItemToPoll(function(){return t.isFencePassed()},function(){return r()})})},n.prototype.pollItems=function(){for(var t=Gz(this.itemsToPoll.map(function(i){return i.isDoneFn})),e=0;e<=t;++e){var r=this.itemsToPoll[e].resolveFn;r()}this.itemsToPoll=this.itemsToPoll.slice(t+1)},n.prototype.addItemToPoll=function(t,e){var r=this;if(this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1)return;_.util.repeatedTry(function(){return r.pollItems(),r.itemsToPoll.length===0})},n.prototype.bindTextureToFrameBuffer=function(t){this.throwIfDisposed(),yc(this.gl,t,this.framebuffer),this.debug&&_s(this.gl)},n.prototype.unbindTextureToFrameBuffer=function(){this.outputTexture!=null?(yc(this.gl,this.outputTexture,this.framebuffer),this.debug&&_s(this.gl)):Np(this.gl,this.framebuffer)},n.prototype.downloadMatrixDriver=function(t,e){this.bindTextureToFrameBuffer(t);var r=e();return this.unbindTextureToFrameBuffer(),r},n.prototype.setOutputMatrixTextureDriver=function(t,e,r){this.throwIfDisposed();var i=this.gl;yc(i,t,this.framebuffer),this.debug&&_s(i),this.outputTexture=t,de(i,function(){return i.viewport(0,0,e,r)}),de(i,function(){return i.scissor(0,0,e,r)})},n.prototype.setOutputMatrixWriteRegionDriver=function(t,e,r,i){var a=this;this.throwIfDisposed(),de(this.gl,function(){return a.gl.scissor(t,e,r,i)})},n.prototype.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")},n.prototype.throwIfNoProgram=function(){if(this.program==null)throw new Error("No GPU program is currently set.")},n}();function Gz(n){for(var t=0;t0&&(w.flatOffset=g.texData.slice.flatOffset),{name:t.variableNames[y],shapeInfo:w}}),s=a.map(function(g){return g.shapeInfo}),o={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},c=vB(a,o,i,t.packedInputs),l=n.createProgram(c),u=null,h=n.getUniformLocation(l,"NAN",!1);_.env().getNumber("WEBGL_VERSION")===1&&(u=n.getUniformLocation(l,"INFINITY",!1));for(var d={},p=0;p0,c=s.isUniform?"uniform":s.texData.texShape;r+=s.shape+"_"+c+"_"+o});var i=n.userCode,a=n.constructor.name;return a+="_"+r+"_"+i,a}var $z=function(){function n(t,e,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var i=r.filterWidth,a=r.inChannels,s=r.strideWidth,o=r.strideHeight,c=r.padInfo,l=r.outWidth,u=r.dilationWidth,h=r.dilationHeight,d=r.dataFormat,p=c.left,f=c.top,m=a*i,g=Ht(),y=d==="channelsLast",w=y?0:1,b=y?1:2,S="",x=0;x<=1;x++)for(var N=0;N<=1;N++)S+=` blockIndex = rc.y + `+N+`; pos = rc.x + `+x+`; if(blockIndex < `+t[1]+" && pos < "+t[0]+`) { offsetY = int(blockIndex / (`+l+")) * "+o+" - "+f+`; d0 = offsetY + `+h+" * (pos / "+m+`); if(d0 < `+e[w]+` && d0 >= 0) { offsetX = int(mod(float(blockIndex), `+l+".) * "+s+". - "+p+`.); d1 = offsetX + `+u+" * (int(mod(float(pos), "+m+".) / "+a+`.)); if(d1 < `+e[b]+` && d1 >= 0) { ch = int(mod(float(pos), `+a+`.)); if (`+y+`) { innerDims = vec2(d1, ch); result[`+(x*2+N)+`] = getChannel( getA(d0, int(innerDims.x), int(innerDims.y)), innerDims); } else { innerDims = vec2(d0, d1); result[`+(x*2+N)+`] = 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; `+S+` `+g.output+` = result; } `}return n}();var Xz=function(){function n(t,e,r,i,a){this.variableNames=["x"],this.outputShape=[];var s=e,o=t[3]-1;this.outputShape=t;var c,l="float("+r+") + float("+i+") * sum";a===.5?c="inversesqrt("+l+")":a===1?c="1.0/("+l+")":c="exp(log("+l+") * float(-"+a+"));",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 = -`+s+"; j <= "+s+`; j++) { int idx = d + j; if (idx >= 0 && idx <= `+o+`) { float z = getX(b, r, c, idx); sum += z * z; } } float val = x * `+c+`; setOutput(val); } `}return n}();var Jz=function(){function n(t,e,r,i,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=t,this.depth=t[3],this.depthRadius=e,this.bias=r,this.alpha=i,this.beta=a,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 - `+e+`))); int depthEnd = int(min(float(`+this.depth+`), float(d + `+e+` + 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(`+i+") * norm + float("+r+`); 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(`+i+`) * float(`+a+`) * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d) / norm; if (k == d) { dyi += pow(norm, -1.0 * `+a+`); } if (k == coords[3]) { dyi *= getDy(b, r, c, d); result += dyi; } } else { break; } } } setOutput(result); } `}return n}();var Zz=function(){function n(t,e,r,i,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var s=e,o=t[3]-1;this.outputShape=t;var c,l="float("+r+") + float("+i+") * sum";a===.5?c="inversesqrt("+l+")":a===1?c="1.0/("+l+")":c="exp(log("+l+") * float(-"+a+"));",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 - `+s+`; 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 = - `+s+"; j <= "+s+`; j++) { ivec2 idx = depth + j; bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0)); bvec2 belowUpperBound = lessThanEqual(idx, ivec2(`+o+`)); 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 * `+c+`; setOutput(result); } `}return n}();var Qz=function(){function n(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideHeight,r=t.strideWidth,i=t.dilationHeight,a=t.effectiveFilterHeight,s=t.effectiveFilterWidth,o=a-1-t.padInfo.top,c=s-1-t.padInfo.left,l=a*s-1;this.userCode=` const ivec2 pads = ivec2(`+o+", "+c+`); 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 < `+a+`; wR += `+i+`) { float dyR = float(dyRCorner + wR) / `+e+`.0; if (dyR < 0.0 || dyR >= `+t.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); for (int wC = 0; wC < `+s+`; wC++) { float dyC = float(dyCCorner + wC) / `+r+`.0; if (dyC < 0.0 || dyC >= `+t.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); float dyValue = getDy(b, idyR, idyC, d); int maxPosValue = `+l+` - int(getMaxPos(b, idyR, idyC, d)); // Get the current value, check it against the value from the // position matrix. int curPosValue = wR * `+s+` + wC; float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); dotProd += dyValue * mask; } } setOutput(dotProd); } `}return n}(),eP=function(){function n(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideDepth,r=t.strideHeight,i=t.strideWidth,a=t.dilationDepth,s=t.dilationHeight,o=t.dilationWidth,c=t.effectiveFilterDepth,l=t.effectiveFilterHeight,u=t.effectiveFilterWidth,h=c-1-t.padInfo.front,d=l-1-t.padInfo.top,p=u-1-t.padInfo.left,f=c*l*u-1;this.userCode=` const ivec3 pads = ivec3(`+h+", "+d+", "+p+`); 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 < `+c+`; wD += `+a+`) { float dyD = float(dyDCorner + wD) / `+e+`.0; if (dyD < 0.0 || dyD >= `+t.outDepth+`.0 || fract(dyD) > 0.0) { continue; } int idyD = int(dyD); for (int wR = 0; wR < `+l+`; wR += `+s+`) { float dyR = float(dyRCorner + wR) / `+r+`.0; if (dyR < 0.0 || dyR >= `+t.outHeight+`.0 || fract(dyR) > 0.0) { continue; } int idyR = int(dyR); for (int wC = 0; wC < `+u+`; wC += `+o+`) { float dyC = float(dyCCorner + wC) / `+i+`.0; if (dyC < 0.0 || dyC >= `+t.outWidth+`.0 || fract(dyC) > 0.0) { continue; } int idyC = int(dyC); float dyValue = getDy(batch, idyD, idyR, idyC, ch); int maxPosValue = `+f+` - int(getMaxPos(batch, idyD, idyR, idyC, ch)); // Get the current value, check it against the value from the // position matrix. int curPosValue = wD * `+l+" * "+u+` + wR * `+u+` + wC; float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); dotProd += dyValue * mask; } } } setOutput(dotProd); } `}return n}();var Bp=function(){function n(t,e,r,i,a,s,o,c){i===void 0&&(i=!1),a===void 0&&(a=!1),s===void 0&&(s=!1),o===void 0&&(o=null),c===void 0&&(c=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r;var l=i?t[1]:t[2],u=Math.ceil(l/2),h=i?"i * 2, rc.y":"rc.y, i * 2",d=a?"rc.z, i * 2":"i * 2, rc.z",p=i?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",g="";o&&(c?m=`vec4 activation(vec4 a) { vec4 b = getPreluActivationWeightsAtOutCoords(); `+o+` }`:m=`vec4 activation(vec4 x) { `+o+` }`,g="result = activation(result);");var y=s?"result += getBiasAtOutCoords();":"";s&&this.variableNames.push("bias"),c&&this.variableNames.push("preluActivationWeights");var w="rc.x",b="rc.x";t[0] "+t[0];for(var r="",i=n-2;i= "+t[i],i= `+t+`; bool rEdge = rp1 >= `+e+`; `}function aP(n,t){var e=n.length,r=oP(e,t);return e===1?`getA(rc), rc + 1 >= `+n[0]+` ? 0. : getA(rc + 1), 0, 0`:"getA("+r[0]+`), cEdge ? 0. : getA(`+r[1]+`), rEdge ? 0. : getA(`+r[2]+`), rEdge || cEdge ? 0. : getA(`+r[3]+")"}var cP=function(){function n(t,e,r){this.variableNames=["x"],this.outputShape=e.map(function(l,u){return l[0]+t[u]+l[1]});var i=t.length,a=Ze(i),s=e.map(function(l){return l[0]}).join(","),o=e.map(function(l,u){return l[0]+t[u]}).join(","),c=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,i);if(i===1){this.userCode=` int start = `+s+`; int end = `+o+`; void main() { int outC = getOutputCoords(); if (outC < start || outC >= end) { setOutput(float(`+r+`)); } else { setOutput(getX(outC - start)); } } `;return}this.userCode=` `+a+" start = "+a+"("+s+`); `+a+" end = "+a+"("+o+`); void main() { `+a+` outC = getOutputCoords(); if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) { setOutput(float(`+r+`)); } else { `+a+` coords = outC - start; setOutput(getX(`+c+`)); } } `}return n}();var lP=function(){function n(t,e,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map(function(y,w){return y[0]+t[w]+y[1]});for(var i=t.length,a=Ze(i),s=e.map(function(y){return y[0]}).join(","),o=e.map(function(y,w){return y[0]+t[w]}).join(","),c=Mt("rc",i),l=Mt("source",i),u=c[i-1]+" < "+this.outputShape[i-1],h=i===1?"source":"vec2("+l.slice(-2).join()+")",d=[a+" rc = outputLoc;",c[i-1]+` += 1; if(`+u+`) { `,i===1?"":`} rc = outputLoc; `+c[i-2]+` += 1; if(`+c[i-2]+" < "+this.outputShape[i-2]+") {",i===1?"":" "+c[i-1]+` += 1; if(`+u+") {"],p=i===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",f="",m=0,g=i===1?2:4;m= `+t.inHeight+`) { continue; } for (int wC = 0; wC < `+d+`; wC += `+u+`) { int xC = xCCorner + wC; if (xC < 0 || xC >= `+t.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 `+b+` currMinMaxValue) { minMaxValue = value; minMaxValueFound = 1.0; minMaxPosition = `+(i?a?g:y:"wR * "+d+" + wC")+`; } } } setOutput(float(minMaxPosition)); } `;return}var S="max",x=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";e==="avg"&&(x="avgValue / count");var N=Math.floor(s/4)*4,I=s%4,C=` if (`+m+`) { avgValue += dot(values, ones); } else { minMaxValue = `+S+`(values, minMaxValue); } `;this.userCode=` const ivec2 strides = ivec2(`+o+", "+c+`); const ivec2 pads = ivec2(`+p+", "+f+`); const float initializationValue = `+w+`; 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 >= `+t.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(`+w+`); float avgValue = 0.0; count = 0.0; for (int wR = 0; wR < `+h+`; wR += `+l+`) { int xR = xRCorner + wR; if (xR < 0 || xR >= `+t.inHeight+`) { continue; } for (int wC = 0; wC < `+N+`; wC += 4) { int xC = xCCorner + wC * `+u+`; vec4 values = vec4( getValue(batch, xR, xC, d), getValue(batch, xR, xC + `+u+`, d), getValue(batch, xR, xC + 2 * `+u+`, d), getValue(batch, xR, xC + 3 * `+u+`, d) ); `+C+` } int xC = xCCorner + `+N+`; if (`+(I===1)+`) { vec4 values = vec4( getValue(batch, xR, xC, d), initializationValue, initializationValue, initializationValue ); `+C+` } else if (`+(I===2)+`) { vec4 values = vec4( getValue(batch, xR, xC, d), getValue(batch, xR, xC + `+u+`, d), initializationValue, initializationValue ); `+C+` } else if (`+(I===3)+`) { vec4 values = vec4( getValue(batch, xR, xC, d), getValue(batch, xR, xC + `+u+`, d), getValue(batch, xR, xC + 2 * `+u+`, d), initializationValue ); `+C+` } } setOutput(`+x+`); } `}return n}(),zp=function(){function n(t,e,r,i,a){if(i===void 0&&(i=!1),a===void 0&&(a=!1),this.variableNames=["x"],e==="avg"&&r)throw new Error("Cannot compute positions for average pool.");var s=t.filterWidth,o=t.strideDepth,c=t.strideHeight,l=t.strideWidth,u=t.dilationDepth,h=t.dilationHeight,d=t.dilationWidth,p=t.effectiveFilterDepth,f=t.effectiveFilterHeight,m=t.effectiveFilterWidth,g=t.padInfo.front,y=t.padInfo.top,w=t.padInfo.left;this.outputShape=t.outShape;var b=e==="avg",S="0.0";if(b||(S="-1.0 / 1e-20"),r){var x=">=";this.userCode=` const ivec3 strides = ivec3(`+o+", "+c+", "+l+`); const ivec3 pads = ivec3(`+g+", "+y+", "+w+`); 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 < `+p+`; wD += `+u+`) { int xD = xDCorner + wD; if (xD < 0 || xD >= `+t.inDepth+`) { continue; } for (int wR = 0; wR < `+f+`; wR += `+h+`) { int xR = xRCorner + wR; if (xR < 0 || xR >= `+t.inHeight+`) { continue; } for (int wC = 0; wC < `+m+`; wC += `+d+`) { int xC = xCCorner + wC; if (xC < 0 || xC >= `+t.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 `+x+` currMinMaxValue) { minMaxValue = value; minMaxValueFound = 1.0; minMaxPosition = `+(i?a?"(((batch * "+t.inDepth+" + xD) * "+t.inHeight+" + xR) * "+t.inWidth+" + xC) * "+t.inChannels+" + ch":"((xD * "+t.inHeight+" + xR) * "+t.inWidth+" + xC) * "+t.inChannels+" + ch":"wD * "+f+" * "+m+` + wR * `+m+" + wC")+`; } } } } setOutput(float(minMaxPosition)); } `;return}var N="max",I=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";e==="avg"&&(I="avgValue / count");var C=Math.floor(s/4)*4,O=s%4,D=` if (`+b+`) { avgValue += dot(values, ones); } else { minMaxValue = `+N+`(values, minMaxValue); } `;this.userCode=` const ivec3 strides = ivec3(`+o+", "+c+", "+l+`); const ivec3 pads = ivec3(`+g+", "+y+", "+w+`); const float initializationValue = `+S+`; 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 >= `+t.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(`+S+`); float avgValue = 0.0; count = 0.0; for (int wD = 0; wD < `+p+`; wD += `+u+`) { int xD = xDCorner + wD; if (xD < 0 || xD >= `+t.inDepth+`) { continue; } for (int wR = 0; wR < `+f+`; wR += `+h+`) { int xR = xRCorner + wR; if (xR < 0 || xR >= `+t.inHeight+`) { continue; } for (int wC = 0; wC < `+C+`; wC += 4) { int xC = xCCorner + wC * `+d+`; vec4 values = vec4( getValue(batch, xD, xR, xC, ch), getValue(batch, xD, xR, xC + `+d+`, ch), getValue(batch, xD, xR, xC + 2 * `+d+`, ch), getValue(batch, xD, xR, xC + 3 * `+d+`, ch) ); `+D+` } int xC = xCCorner + `+C+`; if (`+(O===1)+`) { vec4 values = vec4( getValue(batch, xD, xR, xC, ch), initializationValue, initializationValue, initializationValue ); `+D+` } else if (`+(O===2)+`) { vec4 values = vec4( getValue(batch, xD, xR, xC, ch), getValue(batch, xD, xR, xC + `+d+`, ch), initializationValue, initializationValue ); `+D+` } else if (`+(O===3)+`) { vec4 values = vec4( getValue(batch, xD, xR, xC, ch), getValue(batch, xD, xR, xC + `+d+`, ch), getValue(batch, xD, xR, xC + 2 * `+d+`, ch), initializationValue ); `+D+` } } setOutput(`+I+`); } } `}return n}();var V2=function(){function n(t,e){this.variableNames=["x"];var r=t.windowSize,i=t.batchSize,a=t.inSize,s=t.outSize;this.outputShape=[i,s];var o="0.0",c="";e==="prod"?o="1.0":e==="min"?(o="1.0 / 1e-20",c="min"):e==="max"&&(o="-1.0 / 1e-20",c="max");var l=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";e==="sum"?l="sumValue":e==="prod"?l="prodValue":e==="all"?l="allValue":e==="any"&&(l="anyValue");var u=Math.floor(r/4)*4,h=r%4,d=` if (`+(e==="sum")+`) { sumValue += dot(values, ones); } else if (`+(e==="prod")+`) { vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]); prodValue *= tmp[0] * tmp[1]; } else { minMaxValue = `+c+`(values, minMaxValue); } `,p="vec4";e==="all"?(o="1.0",d=` bool reducedAllValue = all(values); float floatedReducedAllValue = float(reducedAllValue); allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0); `,p="bvec4"):e==="any"&&(o="0.0",d=` bool reducedAnyValue = any(values); float floatedReducedAnyValue = float(reducedAnyValue); anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0); `,p="bvec4");var f="";a%r>0&&(f=` if (inIdx < 0 || inIdx >= `+a+`) { return initializationValue; } `),this.userCode=` const float initializationValue = `+o+`; const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); float getValue(int batch, int inIdx) { `+f+` return getX(batch, inIdx); } void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; int outIdx = coords[1]; int inOffset = outIdx * `+r+`; vec4 minMaxValue = vec4(`+o+`); float prodValue = 1.0; float sumValue = 0.0; float allValue = 1.0; float anyValue = 0.0; for (int i = 0; i < `+u+`; i += 4) { int inIdx = inOffset + i; `+p+" values = "+p+`( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), getValue(batch, inIdx + 3) ); `+d+` } int inIdx = inOffset + `+u+`; if (`+(h===1)+`) { `+p+" values = "+p+`( getValue(batch, inIdx), initializationValue, initializationValue, initializationValue ); `+d+` } else if (`+(h===2)+`) { `+p+" values = "+p+`( getValue(batch, inIdx), getValue(batch, inIdx + 1), initializationValue, initializationValue ); `+d+` } else if (`+(h===3)+`) { `+p+" values = "+p+`( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), initializationValue ); `+d+` } setOutput(`+l+`); } `}return n}();var q2=function(){function n(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var r="",i=0;i<4;i++){var a="thisRC = rc;";i%2===1&&(a+="thisRC.z += 1;"),i>1&&(a+="thisRC.y += 1;"),r+=` `+a+` `+(i>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[`+i+`] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims); `+(i>0?"}":"")+` `}this.userCode=` `+uP(e)+` `+Ep(t)+` void main() { ivec3 rc = getOutputCoords(); vec4 result = vec4(0.); ivec3 thisRC; int rows = `+t[1]+`; int cols = `+t[2]+`; `+r+` setOutput(result); } `}return n}();function uP(n){var t=_i(["r","c","d"],n);return` ivec3 inputCoordsFromReshapedOutCoords(int index) { `+t+` return ivec3(r, c, d); } `}var hP=function(){function n(t,e,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var i=e.shape,a=i[1],s=i[2],o=t.shape,c=o[1],l=o[2],u=[r&&c>1?a-1:a,r&&l>1?s-1:s],h=[r&&c>1?c-1:c,r&&l>1?l-1:l],d=u[0]/h[0],p=u[1]/h[1],f=1/d,m=1/p,g=Math.ceil(f)*2+2,y=Math.ceil(m)*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(`+d+`); const float widthScale = float(`+p+`); const float invHeightScale = float(`+f+`); const float invWidthScale = float(`+m+`); const int winHeight = int(`+g+`); const int winWidth = int(`+y+`); // 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 >= `+c+`) { 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 >= `+l+`) { continue; } float dxR = float(dyR) * heightScale; int topDxRIndex = int(floor(dxR)); int bottomDxRIndex = int(min(ceil(dxR), `+(a-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), `+(s-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 n}();var dP=function(){function n(t,e,r,i){this.variableNames=["A"],this.outputShape=[];var a=t[0],s=t[1],o=t[2],c=t[3];this.outputShape=[a,e,r,c];var l=[i&&e>1?s-1:s,i&&r>1?o-1:o],u=[i&&e>1?e-1:e,i&&r>1?r-1:r];this.userCode=` const vec2 effectiveInputOverOutputRatioRC = vec2( `+l[0]/u[0]+`, `+l[1]/u[1]+`); const vec2 inputShapeRC = vec2(`+s+".0, "+o+`.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 n}();var pP=function(){function n(t,e,r,i){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var a=t[0],s=t[1],o=t[2],c=t[3];this.outputShape=[a,e,r,c];var l=[i&&e>1?s-1:s,i&&r>1?o-1:o],u=[i&&e>1?e-1:e,i&&r>1?r-1:r];this.userCode=` const vec3 effectiveInputOverOutputRatioRC = vec3( `+l[0]/u[0]+`, `+l[1]/u[1]+`, `+l[1]/u[1]+`); const vec3 inputShapeRC = vec3(`+s+".0, "+o+`.0, `+o+`.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 < `+(c-1)+`; bool hasNextRow = coords.z < `+(r-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 n}();var fP=function(){function n(t,e,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var i=e.shape,a=i[1],s=i[2],o=t.shape,c=o[1],l=o[2],u=[r&&c>1?a-1:a,r&&l>1?s-1:s],h=[r&&c>1?c-1:c,r&&l>1?l-1:l],d=u[0]/h[0],p=u[1]/h[1],f=1/d,m=1/p,g=Math.ceil(f)*2+2,y=Math.ceil(m)*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(`+d+`); const float widthScale = float(`+p+`); const float invHeightScale = float(`+f+`); const float invWidthScale = float(`+m+`); const int winHeight = int(`+g+`); const int winWidth = int(`+y+`); // 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 >= `+c+`) { 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 >= `+l+`) { continue; } float sourceFracRow = float(`+u[0]+`) * (float(dyR) / float(`+h[0]+`)); float sourceFracCol = float(`+u[1]+`) * (float(dyC) / float(`+h[1]+`)); int sourceNearestRow = int(min( float(int(`+a+`) - 1), `+r+` ? float(round(sourceFracRow)) : float(floor(sourceFracRow)))); int sourceNearestCol = int(min( float(int(`+s+`) - 1), `+r+` ? float(round(sourceFracCol)) : float(floor(sourceFracCol)))); if (r == sourceNearestRow && c == sourceNearestCol) { accumulator += getDy(b, dyR, dyC, d); } } } // End loop over dy setOutput(accumulator); } `}return n}();var mP=function(){function n(t,e,r,i){this.variableNames=["A"],this.outputShape=[];var a=t[0],s=t[1],o=t[2],c=t[3];this.outputShape=[a,e,r,c];var l=[i&&e>1?s-1:s,i&&r>1?o-1:o],u=[i&&e>1?e-1:e,i&&r>1?r-1:r],h=i?"0.5":"0.0";this.userCode=` const vec2 effectiveInputOverOutputRatioRC = vec2( `+l[0]/u[0]+`, `+l[1]/u[1]+`); const vec2 inputShapeRC = vec2(`+s+".0, "+o+`.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 + `+h+`))); float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d); setOutput(newValue); } `}return n}();var gP=function(){function n(t,e){this.variableNames=["x"];var r=t.length;if(r>4)throw new Error("WebGL backend: Reverse of rank-"+r+" tensor is not yet supported");if(this.outputShape=t,r===1){this.userCode=` void main() { int coord = getOutputCoords(); setOutput(getX(`+t[0]+` - coord - 1)); } `;return}var i=function(o){return e.indexOf(o)!==-1&&t[o]!==1?t[o]+" - coords["+o+"] - 1":"coords["+o+"]"},a=t.map(function(o,c){return i(c)}).join(","),s=Ze(r);this.userCode=` void main() { `+s+` coords = getOutputCoords(); setOutput(getX(`+a+`)); } `}return n}();var yP=function(){function n(t,e){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var r=t.length;if(r>4)throw new Error("WebGL backend: Reverse of rank-"+r+" tensor is not yet supported");this.outputShape=t;var i=Mt("rc",r),a=i[r-1]+" + 1 < "+this.outputShape[r-1],s=i[r-2]+" + 1 < "+this.outputShape[r-2],o=Ze(r);r===1?this.userCode=` void main(){ int rc = getOutputCoords(); vec4 result = vec4(0.); result.r = getChannel(getX(`+t[0]+` - rc - 1), `+t[0]+` - rc - 1); if(`+a+`){ result.g = getChannel(getX(`+t[0]+` - (rc + 1) - 1), `+t[0]+` - (rc + 1) - 1); } setOutput(result); } `:this.userCode=` void main() { `+o+` rc = getOutputCoords(); vec4 result = vec4(0.); result.r = `+c(i.slice())+`; if(`+a+`){ result.g = `+l(i.slice())+`; } if(`+s+`) { result.b = `+u(i.slice())+`; if(`+a+`) { result.a = `+h(i.slice())+`; } } setOutput(result); } `;function c(f){return d(f)}function l(f){return f[r-1]="("+f[r-1]+" + 1)",d(f)}function u(f){return f[r-2]="("+f[r-2]+" + 1)",d(f)}function h(f){return f[r-1]="("+f[r-1]+" + 1)",f[r-2]="("+f[r-2]+" + 1)",d(f)}function d(f){var m=t.map(function(w,b){return p(b,f)}),g=m.join(","),y=m.slice(-2).join(",");return"getChannel(getX("+g+"), vec2("+y+"))"}function p(f,m){return e.indexOf(f)!==-1&&t[f]!==1?t[f]+" - "+m[f]+" - 1":""+m[f]}}return n}();var G2=function(){function n(t,e,r,i,a,s,o){this.variableNames=["updates","indices","defaultValue"],this.outputShape=s;var c=Ze(a.length),l=Ze(s.length),u="";r===1?u="i":r===2&&(u="i, j");var h="getIndices("+u+")",d="";i===1?d="i":i===2&&(d="i, coords[1]");var p="getUpdates("+d+")",f=e>1?"strides[j]":"strides";this.userCode=` `+c+" strides = "+c+"("+a+`); void main() { `+l+` coords = getOutputCoords(); float sum = 0.0; bool found = false; for (int i = 0; i < `+t+`; i++) { int flattenedIndex = 0; for (int j = 0; j < `+e+`; j++) { int index = round(`+h+`); flattenedIndex += index * `+f+`; } if (flattenedIndex == coords[0]) { sum += `+p+`; found = true; } } setOutput(mix(getDefaultValue(), sum, float(found))); } `}return n}();var vP=function(){function n(t,e){this.variableNames=["x","segmentIds"];var r=t.windowSize,i=t.batchSize,a=t.inSize,s=t.numSegments,o=s*Math.ceil(a/r);this.outputShape=[i,o];var c="0.0",l="sumValue",u=Math.floor(r/4)*4,h=r%4,d=` sumValue += dot(values, segFilter); `,p="";a%r>0&&(p=` if (inIdx < 0 || inIdx >= `+a+`) { return initializationValue; } `);var f="";a%r>0&&(f=` if (inIdx < 0 || inIdx >= `+a+`) { return -1.0; } `),this.userCode=` const float initializationValue = `+c+`; float getValue(int batch, int inIdx) { `+p+` return getX(batch, inIdx); } float getSegmentIdAtIndex(int inIdx) { `+f+` return getSegmentIds(inIdx); } void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; int outIdx = coords[1]; int inOffset = int(floor(float(outIdx) / float( `+s+")) * float("+r+`)); int currentSeg = int(mod(float(outIdx), float(`+s+`))); float sumValue = 0.0; for (int i = 0; i < `+u+`; 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 ); `+d+` } int inIdx = inOffset + `+u+`; if (`+(h===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 ); `+d+` } else if (`+(h===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 ); `+d+` } else if (`+(h===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 ); `+d+` } setOutput(`+l+`); } `}return n}();var wP=function(){function n(t,e,r){this.variableNames=["c","a","b"],this.outputShape=e;var i,a;if(r>4)throw Error("Where for rank "+r+" is not yet supported");if(r===1)a="resRC",i="resRC";else{for(var s=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],c=[],l=0;l= 1.0) { setOutput(getA(`+a+`)); } else { setOutput(getB(`+a+`)); } } `}return n}();var xP=function(){function n(t){this.variableNames=["source"],this.outputShape=t,this.rank=t.length;var e=Ze(this.rank),r="uniform int start["+this.rank+"];",i=bP(this.rank),a,s=t.map(function(o,c){return"sourceLoc."+Pp[c]+" = start["+c+"] + coords."+Pp[c]+";"});a=` `+e+` sourceLoc; `+e+` coords = getOutputCoords(); `+s.join(` `)+` `,this.userCode=` `+r+` void main() { `+a+` setOutput(getSource(`+i+`)); } `}return n.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the "+("length of start ("+t.length+")"));return function(r,i){if(e.startLoc==null&&(e.startLoc=r.getUniformLocationNoThrow(i,"start"),e.startLoc==null))return;r.gl.uniform1iv(e.startLoc,t)}},n}(),Pp=["x","y","z","w","u","v"];function bP(n){if(n===1)return"sourceLoc";if(n<=6)return Pp.slice(0,n).map(function(t){return"sourceLoc."+t}).join(",");throw Error("Slicing for rank "+n+" is not yet supported")}var SP=function(){function n(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length;var e=Ze(this.rank),r=Mt("coords",this.rank),i=Mt("sourceLoc",this.rank),a=this.rank===1?"sourceLoc":"vec2("+i.slice(-2).join()+")",s="getChannel(getSource("+i.join()+"), "+a+")",o=` result.x = `+s+`; if (++`+r[this.rank-1]+" < "+t[this.rank-1]+`) { ++`+i[this.rank-1]+`; result.y = `+s+`; --`+i[this.rank-1]+`; } `,c=this.rank===1?"":` --`+r[this.rank-1]+`; if (++`+r[this.rank-2]+" < "+t[this.rank-2]+`) { ++`+i[this.rank-2]+`; result.z = `+s+`; if (++`+r[this.rank-1]+" < "+t[this.rank-1]+`) { ++`+i[this.rank-1]+`; result.w = `+s+`; } } `,l=this.rank<=4?`sourceLoc = coords + `+e+"("+t.map(function(u,h){return"start["+h+"]"}).join()+");":t.map(function(u,h){return i[h]+" = "+r[h]+" + start["+h+"];"}).join(` `);this.userCode=` uniform int start[`+this.rank+`]; void main() { `+e+` coords = getOutputCoords(); `+e+` sourceLoc; `+l+` vec4 result = vec4(0.); `+o+` `+c+` setOutput(result); } `}return n.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the "+("length of start ("+t.length+")"));return function(r,i){if(e.startLoc==null&&(e.startLoc=r.getUniformLocationNoThrow(i,"start"),e.startLoc==null))return;r.gl.uniform1iv(e.startLoc,t)}},n}();var LP=function(){function n(t,e,r){this.variableNames=["x"],this.outputShape=r;var i=r.length,a=Ze(r.length),s=Ze(r.length),o="";if(i===1)o="coords * strides + begin";else{var c=0;o=r.map(function(l,u){return c++,r.length===1?"coords * strides["+u+"] + begin["+u+"]":"coords["+(c-1)+"] * strides["+u+"] + begin["+u+"]"}).join(",")}this.userCode=` `+a+" begin = "+a+"("+t+`); `+a+" strides = "+a+"("+e+`); void main() { `+s+` coords = getOutputCoords(); setOutput(getX(`+o+`)); } `}return n}();var IP=function(){function n(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}return n.prototype.acquireTexture=function(t,e,r){var i=j2(e,r),a=K2(t,i,r);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);var s=Y2(t,i,this.gpgpu.gl,this.gpgpu.textureConfig,r);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=s,this.log();var o=this.freeTextures[a].shift();return this.usedTextures[a].push(o),o}var c;return i===Ft.PACKED_2X2_FLOAT32?c=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):i===Ft.PACKED_2X2_FLOAT16?c=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):i===Ft.UNPACKED_FLOAT32?c=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):i===Ft.UNPACKED_FLOAT16?c=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):i===Ft.PACKED_4X1_UNSIGNED_BYTE&&(c=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[a].push(c),this.numUsedTextures++,this._numBytesAllocated+=s,this.log(),c},n.prototype.releaseTexture=function(t,e,r,i){if(this.freeTextures==null)return;var a=j2(r,i),s=K2(e,a,i);s in this.freeTextures||(this.freeTextures[s]=[]);var o=Y2(e,a,this.gpgpu.gl,this.gpgpu.textureConfig,i),c=_.env().get("WEBGL_DELETE_TEXTURE_THRESHOLD");c!==-1&&this._numBytesAllocated>c?(this.gpgpu.deleteMatrixTexture(t),this._numBytesAllocated-=o):(this.freeTextures[s].push(t),this.numFreeTextures++,this._numBytesFree+=o),this.numUsedTextures--;var l=this.usedTextures[s],u=l.indexOf(t);if(u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(u,1),this.log()},n.prototype.log=function(){if(!this.logEnabled)return;var t=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+t+")");var e=this._numBytesFree/this._numBytesAllocated;console.log("Bytes allocated: "+this._numBytesAllocated),console.log("Bytes unused: "+this._numBytesFree+" ("+Math.round(100*e)+"%)")},Object.defineProperty(n.prototype,"numBytesAllocated",{get:function(){return this._numBytesAllocated},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"numBytesFree",{get:function(){return this._numBytesFree},enumerable:!0,configurable:!0}),n.prototype.getNumUsedTextures=function(){return this.numUsedTextures},n.prototype.getNumFreeTextures=function(){return this.numFreeTextures},n.prototype.dispose=function(){var t=this;if(this.freeTextures==null)return;for(var e in this.freeTextures)this.freeTextures[e].forEach(function(r){t.gpgpu.deleteMatrixTexture(r)});for(var e in this.usedTextures)this.usedTextures[e].forEach(function(i){t.gpgpu.deleteMatrixTexture(i)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0},n}();function AP(n,t){var e=n;if(t===e.R32F)return 4;if(t===e.R16F)return 2;if(t===e.RGBA32F)return 16;if(t===n.RGBA)return 16;if(t===e.RGBA16F)return 8;throw new Error("Unknown internal format "+t)}function Y2(n,t,e,r,i){var a=TP(t,r),s;if(i){var o=ga(n[0],n[1]),c=o[0],l=o[1];s=c*l}else{var u=As(n[0],n[1]),h=u[0],d=u[1];s=h*d}var p=AP(e,a);return s*p}function TP(n,t){switch(n){case Ft.PACKED_2X2_FLOAT32:return Wp(t);case Ft.PACKED_2X2_FLOAT16:return Up(t);case Ft.UNPACKED_FLOAT32:return Dp(t);case Ft.UNPACKED_FLOAT16:return kp(t);case Ft.PACKED_4X1_UNSIGNED_BYTE:return Fp(t);default:throw new Error("Unknown physical texture type "+n)}}function NP(n){return _.env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?n?Ft.PACKED_2X2_FLOAT32:Ft.UNPACKED_FLOAT32:n?Ft.PACKED_2X2_FLOAT16:Ft.UNPACKED_FLOAT16}function j2(n,t){if(n===hn.UPLOAD)return Ft.PACKED_2X2_FLOAT32;if(n===hn.RENDER||n==null)return NP(t);if(n===hn.DOWNLOAD||n===hn.PIXELS)return Ft.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+n)}function K2(n,t,e){return n[0]+"_"+n[1]+"_"+t+"_"+e}var CP=function(){function n(t,e){this.variableNames=["A"];for(var r=new Array(t.length),i=0;i5)throw Error("Tile for rank "+t+" is not yet supported");if(t===1)return"imod(resRC, "+n[0]+")";for(var e=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],i=0;i= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); `;function EP(n){return n===void 0&&(n=0),dr+(` return x > 0.0 ? 1.0 : float(`+n+`); `)}var Q2="return -x;",ex="return ceil(x);",tx="return floor(x);",DP=` if (isnan(x)) { return 0.0; } return sign(x); `,kP="return float(isnan(x));",FP="return float(isinf(x));",WP="return float(!isnan(x) && !isinf(x));",UP=` // 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; } } `,nx="return exp(x);",rx="return exp(x) - 1.0;",BP=`if (x < 0.0) return NAN; return log(x);`,zP="return log(1.0 + x);",PP="return sqrt(x);",MP="return inversesqrt(x);",HP="return 1.0 / (1.0 + exp(-1.0 * x));",VP=` 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; `,qP=dr+` if (abs(x) > 1.) { return NAN; } return asin(x); `,GP=dr+` if (abs(x) > 1.) { return NAN; } return acos(x); `,YP=dr+` return atan(x); `,jP=` float e2x = exp(x); return (e2x - 1.0 / e2x) / 2.0; `,KP=` float e2x = exp(-x); return (e2x + 1.0 / e2x) / 2.0; `,$P=` float e2x = exp(-2.0 * abs(x)); return sign(x) * (1.0 - e2x) / (1.0 + e2x); `,XP=dr+"return log(x + sqrt(x * x + 1.0));",JP=dr+` if (x < 1.0) return NAN; return log(x + sqrt(x * x - 1.0));`,ZP=dr+` if ((x < -1.0) || (x > 1.0)) return NAN; return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,QP=` // Error function is calculated approximately with elementary function. // See "Handbook of Mathematical Functions with Formulas, // Graphs, and Mathematical Tables", Abramowitz and Stegun. float p = `+_.backend_util.ERF_P+`; float a1 = `+_.backend_util.ERF_A1+`; float a2 = `+_.backend_util.ERF_A2+`; float a3 = `+_.backend_util.ERF_A3+`; float a4 = `+_.backend_util.ERF_A4+`; float a5 = `+_.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)); `,eM="return 1.0 / x;",tM="return float(!(x >= 1.0));",Lc="return x;";var nM="return x;",rM=` 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; `,ix=` 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; `,ax=` 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; `,sx=` 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; `,Es=function(){function n(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode=` vec4 unaryOperation(vec4 x) { `+e+` } void main() { vec4 x = getAAtOutCoords(); vec4 y = unaryOperation(x); setOutput(y); } `}return n}();var iM=function(){function n(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t;var e=t.length,r=Mt("rc",e),i=Ze(e),a=lB(e,r),s=r.slice(-2),o=e<=1?"rc":"vec2("+s.join(",")+")";this.userCode=` void main() { `+i+` rc = getOutputCoords(); vec4 packedInput = getA(`+a+`); setOutput(getChannel(packedInput, `+o+`)); } `}return n}();var ox=_.backend_util.segment_util,aM=_.kernel_impls.split,sM=_.kernel_impls.tile,oM=_.kernel_impls.topkImpl,cM=_.kernel_impls.whereImpl,lM=1e-7,uM=1e-4,Ic={};function hM(n){return n in Ic||(Ic[n]={}),Ic[n]}function Ac(n,t){if(t===void 0&&(t=!1),n==="linear")return t?nM:RP;if(n==="relu")return t?ix:X2;if(n==="elu")return t?sx:Z2;if(n==="relu6")return t?ax:J2;if(n==="prelu")return t?v2:y2;throw new Error("Activation "+n+" has not been implemented for the WebGL backend.")}var dM=128,pM=600;function fM(){return _.env().global.screen==null?1024:_.env().global.screen.height*_.env().global.screen.width*window.devicePixelRatio*pM/1024/1024}var cx=1e3,lx=function(n){gU(t,n);function t(e){var r=n.call(this)||this;if(r.pendingRead=new WeakMap,r.pendingDisposal=new WeakSet,r.dataRefCount=new WeakMap,r.numBytesInGPU=0,r.uploadWaitMs=0,r.downloadWaitMs=0,r.warnedAboutMemory=!1,r.warnedAboutCPUBackend=!1,r.pendingDeletes=0,r.disposed=!1,!_.env().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(e==null){var i=jn(_.env().getNumber("WEBGL_VERSION"));r.binaryCache=hM(_.env().getNumber("WEBGL_VERSION")),r.gpgpu=new M2(i),r.canvas=i.canvas,r.gpgpuCreatedLocally=!0}else r.gpgpu=e,r.binaryCache={},r.gpgpuCreatedLocally=!1,r.canvas=e.gl.canvas;return r.textureManager=new IP(r.gpgpu),r.numMBBeforeWarning=fM(),r.texData=new _.DataStorage(r,_.engine()),r}return t.prototype.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes},t.prototype.write=function(e,r,i){if((_.env().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||_.env().getBool("DEBUG"))&&this.checkNumericalProblems(e),i==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var a={};return this.texData.set(a,{shape:r,dtype:i,values:e,usage:hn.UPLOAD,refCount:1,complexParentRefCount:0}),a},t.prototype.incRef=function(e){var r=this.texData.get(e);r.refCount++},t.prototype.decRef=function(e){if(this.texData.has(e)){var r=this.texData.get(e);r.refCount--}},t.prototype.move=function(e,r,i,a){if(_.env().getBool("DEBUG")&&this.checkNumericalProblems(r),a==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:i,dtype:a,values:r,usage:hn.UPLOAD,refCount:1,complexParentRefCount:0})},t.prototype.disposeIntermediateTensorInfo=function(e){var r=e.dataId;if(this.texData.has(r)){var i=this.texData.get(r);i.refCount--,i.refCount<1&&this.disposeData(r)}},t.prototype.readSync=function(e){var r=this.texData.get(e),i=r.values,a=r.dtype,s=r.complexTensorInfos,o=r.slice,c=r.shape,l=r.isPacked;if(o!=null){var u=void 0;l?u=new Es(c,Lc):u=new De(c,Lc);var h=this.runWebGLProgram(u,[{dataId:e,shape:c,dtype:a}],a),d=this.readSync(h.dataId);return this.disposeIntermediateTensorInfo(h),d}if(i!=null)return this.convertAndCacheOnCPU(e);if(a==="string")return i;var p=this.activeTimers!=null,f;p&&(f=_.util.now());var m;if(a==="complex64"){var g=this.readSync(s.real.dataId),y=this.readSync(s.imag.dataId);m=_.backend_util.mergeRealAndImagArrays(g,y)}else m=this.getValuesFromTexture(e);return p&&(this.downloadWaitMs+=_.util.now()-f),this.convertAndCacheOnCPU(e,m)},t.prototype.read=function(e){return fc(this,void 0,void 0,function(){var r,i,a,s,o,c,l,u,h,d,p,f,m,g,y,w,b,S,x,N,I,C;return mc(this,function(O){switch(O.label){case 0:if(this.pendingRead.has(e))return r=this.pendingRead.get(e),[2,new Promise(function(D){return r.push(D)})];if(i=this.texData.get(e),a=i.values,s=i.shape,o=i.slice,c=i.dtype,l=i.complexTensorInfos,u=i.isPacked,o!=null)return h=void 0,u?h=new Es(s,Lc):h=new De(s,Lc),d=this.runWebGLProgram(h,[{dataId:e,shape:s,dtype:c}],c),p=this.read(d.dataId),this.disposeIntermediateTensorInfo(d),[2,p];if(a!=null)return[2,this.convertAndCacheOnCPU(e)];if(!_.env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&_.env().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");return f=null,c!=="complex64"&&_.env().get("WEBGL_BUFFER_SUPPORTED")&&(m=this.decode(e),g=this.texData.get(m.dataId),f=(C=this.gpgpu).createBufferFromTexture.apply(C,[g.texture].concat(Ts(s)))),this.pendingRead.set(e,[]),c!=="complex64"?[4,this.gpgpu.createAndWaitForFence()]:[3,2];case 1:O.sent(),O.label=2;case 2:return c==="complex64"?[4,Promise.all([this.read(l.real.dataId),this.read(l.imag.dataId)])]:[3,4];case 3:return w=O.sent(),b=w[0],S=w[1],y=_.backend_util.mergeRealAndImagArrays(b,S),[3,5];case 4:f==null?y=this.getValuesFromTexture(e):(x=_.util.sizeFromShape(s),y=this.gpgpu.downloadFloat32MatrixFromBuffer(f,x)),O.label=5;case 5:return m!=null&&this.disposeIntermediateTensorInfo(m),N=this.convertAndCacheOnCPU(e,y),I=this.pendingRead.get(e),this.pendingRead.delete(e),I.forEach(function(D){return D(N)}),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e),this.pendingDeletes--),[2,N]}})})},t.prototype.checkNumericalProblems=function(e){if(e==null)return;for(var r=0;r0?[4,Promise.all(s)]:[3,2];case 1:return l=u.sent(),c.kernelMs=_.util.sum(l),c.getExtraProfileInfo=function(){return l.map(function(h,d){return{name:o[d],ms:h}}).map(function(h){return h.name+": "+h.ms}).join(", ")},[3,3];case 2:c.kernelMs={error:"WebGL query timers are not supported in this environment."},u.label=3;case 3:return this.uploadWaitMs=0,this.downloadWaitMs=0,[2,c]}})})},t.prototype.memory=function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}},t.prototype.startTimer=function(){return _.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:_.util.now(),endMs:null}},t.prototype.endTimer=function(e){return _.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=_.util.now(),e)},t.prototype.getQueryTime=function(e){return fc(this,void 0,void 0,function(){var r;return mc(this,function(i){return _.env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?[2,this.gpgpu.waitForQueryAndGetTime(e)]:(r=e,[2,r.endMs-r.startMs])})})},t.prototype.disposeData=function(e){if(this.pendingDisposal.has(e))return;if(this.pendingRead.has(e)){this.pendingDisposal.add(e),this.pendingDeletes++;return}if(!this.texData.has(e))return;if(this.texData.get(e).complexParentRefCount>0){this.texData.get(e).refCount--;return}this.releaseGPUData(e);var r=this.texData.get(e).complexTensorInfos;r!=null&&(this.texData.get(r.real.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(r.real),this.texData.get(r.imag.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(r.imag)),this.texData.delete(e)},t.prototype.releaseGPUData=function(e){var r=this.texData.get(e),i=r.texture,a=r.dtype,s=r.texShape,o=r.usage,c=r.isPacked,l=r.slice,u=l&&l.origDataId||e,h=this.dataRefCount.get(u);h>1?this.dataRefCount.set(u,h-1):(this.dataRefCount.delete(u),i!=null&&(this.numBytesInGPU-=this.computeBytes(s,a),this.textureManager.releaseTexture(i,s,o,c)));var d=this.texData.get(e);d.texture=null,d.texShape=null,d.isPacked=!1,d.slice=null},t.prototype.getTexture=function(e){return this.uploadToGPU(e),this.texData.get(e).texture},t.prototype.getDataInfo=function(e){return this.texData.get(e)},t.prototype.getCPUBackend=function(){return _.env().getBool("WEBGL_CPU_FORWARD")?(this.cpuBackend==null&&(this.cpuBackend=_.engine().findBackend("cpu")),this.cpuBackend):null},t.prototype.shouldExecuteOnCPU=function(e,r){var i=this;r===void 0&&(r=dM);var a=this.getCPUBackend();return!this.warnedAboutCPUBackend&&a==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),a!=null&&e.every(function(s){return i.texData.get(s.dataId).texture==null&&_.util.sizeFromShape(s.shape)cx){i&&(e=_.transpose(e,[0,2,1])),a&&(r=_.transpose(r,[0,2,1]));var u=o===1?e:e.as3D(l,c,1),h=o===1?2:1,d=o===1?r.as3D(l,1,c):r,p=_.mul(u,d);return p.sum(h,!0)}var f=_.upcastType(e.dtype,r.dtype),m=new Bp(e.shape,r.shape,[l,s,o],i,a);return this.compileAndRun(m,[e,r],f)},t.prototype.fusedBatchMatMul=function(e){var r=e.a,i=e.b,a=e.transposeA,s=e.transposeB,o=e.bias,c=e.activation,l=e.preluActivationWeights,u=a?r.shape[2]:r.shape[1],h=s?i.shape[1]:i.shape[2],d=Math.max(r.shape[0],i.shape[0]),p=_.upcastType(r.dtype,i.dtype),f=o!=null,m=l!=null,g=c?Ac(c,!0):null,y=new Bp(r.shape,i.shape,[d,u,h],a,s,f,g,m),w=[r,i];return o&&w.push(o),l&&w.push(l),this.compileAndRun(y,w,p)},t.prototype.localResponseNormalization4D=function(e,r,i,a,s){var o=_.env().getBool("WEBGL_PACK_NORMALIZATION")?new Zz(e.shape,r,i,a,s):new Xz(e.shape,r,i,a,s);return this.compileAndRun(o,[e])},t.prototype.LRNGrad=function(e,r,i,a,s,o,c){var l=new Jz(r.shape,a,s,o,c);return this.compileAndRun(l,[r,i,e])},t.prototype.tile=function(e,r){if(e.dtype==="string"){var i=this.readSync(e.dataId),a=i.map(function(c){return _.util.decodeString(c)}),s=_.buffer(e.shape,e.dtype,a);return sM(s,r)}var o=new CP(e.shape,r);return this.compileAndRun(o,[e])},t.prototype.pad=function(e,r,i){var a=_.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new lP(e.shape,r,i):new cP(e.shape,r,i);return this.compileAndRun(a,[e])},t.prototype.gather=function(e,r,i){var a=this,s=this.tryRunOnCpuOrThrow([e,r],function(){return a.cpuBackend.gather(e,r,i)});if(s)return s;var o=new Hz(e.shape,r.size,i);return this.compileAndRun(o,[e,r])},t.prototype.batchToSpaceND=function(e,r,i){_.util.assert(e.rank<=4,function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"});var a=r.reduce(function(h,d){return h*d}),s=_.backend_util.getReshaped(e.shape,r,a),o=_.backend_util.getPermuted(s.length,r.length),c=_.backend_util.getReshapedPermuted(e.shape,r,a),l=_.backend_util.getSliceBeginCoords(i,r.length),u=_.backend_util.getSliceSize(c,i,r.length);return _.transpose(e.reshape(s),o).reshape(c).slice(l,u)},t.prototype.spaceToBatchND=function(e,r,i){_.util.assert(e.rank<=4,function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"});var a=r.reduce(function(p,f){return p*f}),s=[[0,0]];s.push.apply(s,i);for(var o=1+r.length;o_.env().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var r=Math.floor(e.length/2),i=this.addN(e.slice(0,r)),a=this.addN(e.slice(r));return this.addN([i,a])}var s=e.map(function(u){return u.dtype}).reduce(function(u,h){return _.upcastType(u,h)}),o=e.map(function(u){return u.shape}),c=_.env().getBool("WEBGL_PACK"),l=c?new oB(e[0].shape,o):new sB(e[0].shape,o);return this.compileAndRun(l,e,s)},t.prototype.pow=function(e,r){var i=_.env().getBool("WEBGL_PACK_BINARY_OPERATIONS"),a=i?new hr(lz,e.shape,r.shape):new Bt(XB,e.shape,r.shape),s=_.upcastType(e.dtype,r.dtype);return this.compileAndRun(a,[e,r],s)},t.prototype.ceil=function(e){if(this.shouldExecuteOnCPU([e])){var r=$U(this.texData.get(e.dataId).values,e.dtype);return this.makeOutput(e.shape,e.dtype,r)}if(_.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,ex,e.dtype);var i=new De(e.shape,ex);return this.compileAndRun(i,[e])},t.prototype.floor=function(e){if(this.shouldExecuteOnCPU([e])){var r=ZU(this.texData.get(e.dataId).values,e.dtype);return this.makeOutput(e.shape,e.dtype,r)}if(_.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,tx,e.dtype);var i=new De(e.shape,tx);return this.compileAndRun(i,[e])},t.prototype.sign=function(e){var r=new De(e.shape,DP);return this.compileAndRun(r,[e])},t.prototype.isNaN=function(e){var r=new De(e.shape,kP);return this.compileAndRun(r,[e],"bool")},t.prototype.isInf=function(e){var r=new De(e.shape,FP);return this.compileAndRun(r,[e],"bool")},t.prototype.isFinite=function(e){var r=new De(e.shape,WP);return this.compileAndRun(r,[e],"bool")},t.prototype.round=function(e){var r=new De(e.shape,UP);return this.compileAndRun(r,[e])},t.prototype.exp=function(e){if(this.shouldExecuteOnCPU([e])){var r=XU(this.texData.get(e.dataId).values,e.dtype);return this.makeOutput(e.shape,e.dtype,r)}if(_.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,nx,e.dtype);var i=new De(e.shape,nx);return this.compileAndRun(i,[e])},t.prototype.expm1=function(e){if(this.shouldExecuteOnCPU([e])){var r=JU(this.texData.get(e.dataId).values,e.dtype);return this.makeOutput(e.shape,e.dtype,r)}if(_.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,rx,e.dtype);var i=new De(e.shape,rx);return this.compileAndRun(i,[e])},t.prototype.softmax=function(e,r){var i=_.util.parseAxisParam([r],e.shape),a=_.max(e,i),s=_.backend_util.expandShapeToKeepDim(a.shape,i),o=_.sub(e,a.reshape(s)),c=this.exp(o),l=this.sum(c,i).reshape(s);return _.div(c,l)},t.prototype.log=function(e){if(this.shouldExecuteOnCPU([e])){var r=QU(this.texData.get(e.dataId).values,e.dtype);return this.makeOutput(e.shape,e.dtype,r)}if(_.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,rM,e.dtype);var i=new De(e.shape,BP);return this.compileAndRun(i,[e])},t.prototype.log1p=function(e){var r=new De(e.shape,zP);return this.compileAndRun(r,[e])},t.prototype.sqrt=function(e){var r=new De(e.shape,PP);return this.compileAndRun(r,[e])},t.prototype.rsqrt=function(e){if(this.shouldExecuteOnCPU([e])){var r=nB(this.texData.get(e.dataId).values,e.dtype);return this.makeOutput(e.shape,e.dtype,r)}var i=new De(e.shape,MP);return this.compileAndRun(i,[e])},t.prototype.reciprocal=function(e){var r=new De(e.shape,eM);return this.compileAndRun(r,[e])},t.prototype.relu=function(e){var r;return _.env().getBool("WEBGL_PACK")?r=new Es(e.shape,ix):r=new De(e.shape,X2),this.compileAndRun(r,[e])},t.prototype.relu6=function(e){var r;return _.env().getBool("WEBGL_PACK")?r=new Es(e.shape,ax):r=new De(e.shape,J2),this.compileAndRun(r,[e])},t.prototype.prelu=function(e,r){var i=_.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new hr(v2,e.shape,r.shape):new Bt(y2,e.shape,r.shape);return this.compileAndRun(i,[e,r])},t.prototype.elu=function(e){if(_.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,sx,e.dtype);var r=new De(e.shape,Z2);return this.compileAndRun(r,[e])},t.prototype.eluDer=function(e,r){var i=_.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new hr(uz,e.shape,r.shape):new Bt(oz,e.shape,r.shape);return this.compileAndRun(i,[e,r])},t.prototype.selu=function(e){var r=new De(e.shape,OP);return this.compileAndRun(r,[e])},t.prototype.clip=function(e,r,i){var a;_.env().getBool("WEBGL_PACK_CLIP")?a=new Sz(e.shape):a=new xz(e.shape);var s=a.getCustomSetupFunc(r,i);return this.compileAndRun(a,[e],null,s)},t.prototype.abs=function(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){var r=jU(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,r)}if(_.env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,$2,e.dtype);var i=new De(e.shape,$2);return this.compileAndRun(i,[e])},t.prototype.complexAbs=function(e){var r=this.texData.get(e.dataId),i=new Lz(e.shape),a=[this.makeComplexComponentTensorInfo(e,r.complexTensorInfos.real),this.makeComplexComponentTensorInfo(e,r.complexTensorInfos.imag)];return this.compileAndRun(i,a)},t.prototype.sigmoid=function(e){var r=new De(e.shape,HP);return this.compileAndRun(r,[e])},t.prototype.softplus=function(e){var r=new De(e.shape,VP);return this.compileAndRun(r,[e])},t.prototype.asin=function(e){var r=new De(e.shape,qP);return this.compileAndRun(r,[e])},t.prototype.acos=function(e){var r=new De(e.shape,GP);return this.compileAndRun(r,[e])},t.prototype.atan=function(e){var r=new De(e.shape,YP);return this.compileAndRun(r,[e])},t.prototype.sinh=function(e){var r=new De(e.shape,jP);return this.compileAndRun(r,[e])},t.prototype.cosh=function(e){var r=new De(e.shape,KP);return this.compileAndRun(r,[e])},t.prototype.tanh=function(e){var r=new De(e.shape,$P);return this.compileAndRun(r,[e])},t.prototype.asinh=function(e){var r=new De(e.shape,XP);return this.compileAndRun(r,[e])},t.prototype.acosh=function(e){var r=new De(e.shape,JP);return this.compileAndRun(r,[e])},t.prototype.atanh=function(e){var r=new De(e.shape,ZP);return this.compileAndRun(r,[e])},t.prototype.erf=function(e){var r=new De(e.shape,QP);return this.compileAndRun(r,[e])},t.prototype.step=function(e,r){var i=new De(e.shape,EP(r));return this.compileAndRun(i,[e])},t.prototype.conv2dByMatMul=function(e,r,i,a,s,o){var c=e.shape,l=this.texData.get(e.dataId),u=i.inChannels,h=c[0]*c[1]*c[2],d=i.outChannels,p=i.dataFormat==="channelsLast",f=!1,m=!1,g=(h===1||d===1)&&u>cx,y=c[2]%2!==0&&!!l.isPacked;if(g||!_.env().getBool("WEBGL_LAZILY_UNPACK")||!_.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!y){var w=p?c[0]*c[1]*c[2]:c[0]*c[2]*c[3],b=_.reshape(e,[1,w,i.inChannels]),S=_.reshape(r,[1,i.inChannels,i.outChannels]),x=this.fusedBatchMatMul({a:b,b:S,transposeA:f,transposeB:m,bias:a,activation:s,preluActivationWeights:o});return _.reshape(x,i.outShape)}var N=p?c[0]*c[1]*(c[2]+1):c[0]*c[2]*(c[3]+1),I={dataId:e.dataId,shape:[1,N,i.inChannels],dtype:e.dtype},C=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,_.util.assert(Cs(l.shape,I.shape),function(){return"packed reshape "+l.shape+" to "+I.shape+" isn't free"});var O=_.reshape(r,[1,i.inChannels,i.outChannels]),D=this.fusedBatchMatMul({a:I,b:O,transposeA:f,transposeB:m,bias:a,activation:s,preluActivationWeights:o}),F=this.texData.get(D.dataId);return _.util.assert(F.isPacked,function(){return"batchMatMul result is expected to be packed"}),l.shape=C,F.shape=i.outShape,_.engine().makeTensorFromDataId(D.dataId,i.outShape,D.dtype)},t.prototype.conv2dWithIm2Row=function(e,r,i,a,s,o){var c=i.filterWidth,l=i.filterHeight,u=i.inChannels,h=i.outWidth,d=i.outHeight,p=i.dataFormat,f=p==="channelsLast",m=c*l*u,g=d*h,y=[m,g],w=!0,b=!1,S=e.squeeze([0]),x=r.reshape([1,m,-1]),N=new $z(y,S.shape,i),I=this.compileAndRun(N,[S]).reshape([1,y[0],y[1]]),C=a!=null,O=o!=null,D=s?Ac(s,!0):null,F=new Bp(I.shape,x.shape,[1,g,i.outChannels],w,b,C,D,O),k=[I,x];a&&k.push(a),O&&k.push(o);var B=this.compileAndRun(F,k);return f?B.reshape([1,d,h,i.outChannels]):B.reshape([1,i.outChannels,d,h])},t.prototype.fusedConv2d=function(e){var r=e.input,i=e.filter,a=e.convInfo,s=e.bias,o=e.activation,c=e.preluActivationWeights;if(a.filterHeight===1&&a.filterWidth===1&&a.dilationHeight===1&&a.dilationWidth===1&&a.strideHeight===1&&a.strideWidth===1&&(a.padInfo.type==="SAME"||a.padInfo.type==="VALID"))return this.conv2dByMatMul(r,i,a,s,o,c);if(_.env().getBool("WEBGL_CONV_IM2COL")&&r.shape[0]===1)return this.conv2dWithIm2Row(r,i,a,s,o,c);var l=s!=null,u=c!=null,h=o?Ac(o,!1):null,d=new w2(a,l,h,u),p=[r,i];return s&&p.push(s),c&&p.push(c),this.compileAndRun(d,p)},t.prototype.conv2d=function(e,r,i){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(e,r,i);if(_.env().getBool("WEBGL_CONV_IM2COL")&&e.shape[0]===1)return this.conv2dWithIm2Row(e,r,i);var a=new w2(i);return this.compileAndRun(a,[e,r])},t.prototype.conv2dDerInput=function(e,r,i){var a=new Az(i);return this.compileAndRun(a,[e,r])},t.prototype.conv2dDerFilter=function(e,r,i){var a=new Iz(i);return this.compileAndRun(a,[e,r])},t.prototype.fusedDepthwiseConv2D=function(e){var r=e.input,i=e.filter,a=e.convInfo,s=e.bias,o=e.activation,c=e.preluActivationWeights,l=_.env().getBool("WEBGL_PACK_DEPTHWISECONV")&&a.strideWidth<=2&&a.outChannels/a.inChannels===1,u=o?Ac(o,l):null,h=[r,i],d=s!=null,p=c!=null;d&&h.push(s),p&&h.push(c);var f;return l?(f=new x2(a,d,u,p),this.compileAndRun(f,h)):(f=new b2(a,d,u,p),this.compileAndRun(f,h))},t.prototype.depthwiseConv2D=function(e,r,i){var a;return _.env().getBool("WEBGL_PACK_DEPTHWISECONV")&&i.strideWidth<=2&&i.outChannels/i.inChannels===1?(a=new x2(i),this.compileAndRun(a,[e,r])):(a=new b2(i),this.compileAndRun(a,[e,r]))},t.prototype.depthwiseConv2DDerInput=function(e,r,i){var a=new Cz(i);return this.compileAndRun(a,[e,r])},t.prototype.depthwiseConv2DDerFilter=function(e,r,i){var a=new _z(i);return this.compileAndRun(a,[e,r])},t.prototype.conv3d=function(e,r,i){var a=new Rz(i);return this.compileAndRun(a,[e,r])},t.prototype.conv3dDerInput=function(e,r,i){var a=new Nz(i);return this.compileAndRun(a,[e,r])},t.prototype.conv3dDerFilter=function(e,r,i){var a=new Tz(i);return this.compileAndRun(a,[e,r])},t.prototype.unstack=function(e,r){for(var i=e.shape[r],a=new Array(e.rank-1),s=0,o=0;o1,function(){return"blockSize should be > 1 for depthToSpace, but was: "+r});var a=e.shape[0],s=i==="NHWC"?e.shape[1]:e.shape[2],o=i==="NHWC"?e.shape[2]:e.shape[3],c=i==="NHWC"?e.shape[3]:e.shape[1],l=s*r,u=o*r,h=c/(r*r),d=i==="NHWC"?[a,l,u,h]:[a,h,l,u],p=new kz(d,r,i);return this.compileAndRun(p,[e])},t.prototype.split=function(e,r,i){return aM(e,r,i)},t.prototype.scatterND=function(e,r,i){var a=_.backend_util.calculateShapes(r,e,i),s=a.sliceRank,o=a.numUpdates,c=a.sliceSize,l=a.strides,u=a.outputSize,h=[u/c,c],d=e.reshape([o,s]),p=r.reshape([o,c]);if(u===0)return _.backend_util.reshapeTensor(_.tensor([]),i);var f=_.scalar(0),m=new G2(o,s,d.rank,p.rank,l,h),g=this.compileAndRun(m,[p,d,f]);return g.reshape(i)},t.prototype.sparseToDense=function(e,r,i,a){var s=_.backend_util.calculateShapes(r,e,i),o=s.sliceRank,c=s.numUpdates,l=s.strides,u=s.outputSize,h=!1,d=new G2(c,o,e.rank,r.rank,l,[u,1],h),p=this.compileAndRun(d,[r,e,a]);return p.reshape(i)},t.prototype.gatherND=function(e,r){var i=r.shape,a=i[i.length-1],s=_.backend_util.prepareAndValidate(e,r),o=s[0],c=s[1],l=s[2],u=s[3],h=r.reshape([c,a]),d=e.reshape([e.size/l,l]),p=new Vz(a,u,[c,l]),f=this.compileAndRun(p,[d,h]);return f.reshape(o)},t.prototype.fill=function(e,r,i){if(i=i||_.util.inferDtype(r),i==="string"){var a=_.util.getArrayFromDType(i,_.util.sizeFromShape(e));return a.fill(r),_.engine().makeTensor(a,e,i,this)}else{var s=new Pz(e,r),o=s.getCustomSetupFunc(r);return this.compileAndRun(s,[],i,o)}},t.prototype.onesLike=function(e){if(e.dtype==="string")throw new Error("onesLike is not supported under string dtype");return this.fill(e.shape,1,e.dtype)},t.prototype.zerosLike=function(e){return this.fill(e.shape,e.dtype==="string"?"":0,e.dtype)},t.prototype.linspace=function(e,r,i){return _.backend_util.linspaceImpl(e,r,i)},t.prototype.makeTensorInfo=function(e,r,i){var a=this.write(i,e,r);return this.texData.get(a).usage=null,{dataId:a,shape:e,dtype:r}},t.prototype.makeOutput=function(e,r,i){var a=this.makeTensorInfo(e,r,i).dataId;return _.engine().makeTensorFromDataId(a,e,r,this)},t.prototype.unpackTensor=function(e){var r=new iM(e.shape);return this.runWebGLProgram(r,[e],e.dtype)},t.prototype.packTensor=function(e){var r=new sP(e.shape),i=!0;return this.runWebGLProgram(r,[e],e.dtype,null,i)},t.prototype.packedReshape=function(e,r){var i=[Ti(e.shape)].concat(Ni(e.shape)),a={dtype:e.dtype,shape:i,dataId:e.dataId},s=[Ti(r)].concat(Ni(r)),o=new q2(s,i),c=!0,l=this.runWebGLProgram(o,[a],e.dtype,null,c);return{dataId:l.dataId,shape:r,dtype:l.dtype}},t.prototype.decode=function(e){var r=this.texData.get(e),i=r.isPacked,a=r.shape,s=r.dtype,o=vc(a),c;i?c=new Dz(o):c=new Ez(o);var l=!0,u=this.runWebGLProgram(c,[{shape:o,dtype:s,dataId:e}],s,null,l);return{dtype:s,shape:a,dataId:u.dataId}},t.prototype.runWebGLProgram=function(e,r,i,a,s){var o=this;s===void 0&&(s=!1);var c=this.makeTensorInfo(e.outputShape,i),l=this.texData.get(c.dataId);if(e.packedOutput&&(l.isPacked=!0),e.outPackingScheme===Is.DENSE){var u=Ts(e.outputShape);l.texShape=u.map(function(b){return b*2})}if(e.outTexUsage!=null&&(l.usage=e.outTexUsage),_.util.sizeFromShape(c.shape)===0)return l.values=_.util.getTypedArrayFromDType(c.dtype,0),c;var h=[],d=r.map(function(b){if(b.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var S=o.texData.get(b.dataId);if(S.texture==null){if(!e.packedInputs&&_.util.sizeFromShape(b.shape)<=_.env().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:b.shape,texData:null,isUniform:!0,uniformValues:S.values};e.packedInputs&&(S.isPacked=!0,S.shape=b.shape)}else if(!!S.isPacked!==!!e.packedInputs)b=S.isPacked?o.unpackTensor(b):o.packTensor(b),h.push(b),S=o.texData.get(b.dataId);else if(S.isPacked&&!Cs(S.shape,b.shape)){var x=b,N=b.shape;b.shape=S.shape,b=o.packedReshape(b,N),h.push(b),S=o.texData.get(b.dataId),x.shape=N}return o.uploadToGPU(b.dataId),{shape:b.shape,texData:S,isUniform:!1}});this.uploadToGPU(c.dataId);var p={shape:c.shape,texData:l,isUniform:!1},f=Kz(e,d,p),m=this.getAndSaveBinary(f,function(){return Yz(o.gpgpu,e,d,p)}),g=this.activeTimers!=null,y;if(g&&(y=this.startTimer()),jz(this.gpgpu,m,d,p,a),h.forEach(function(b){return o.disposeIntermediateTensorInfo(b)}),g&&(y=this.endTimer(y),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(y)})),!_.env().getBool("WEBGL_LAZILY_UNPACK")&&l.isPacked&&s===!1){var w=this.unpackTensor(c);return this.disposeIntermediateTensorInfo(c),w}return c},t.prototype.compileAndRun=function(e,r,i,a,s){s===void 0&&(s=!1),i=i||r[0].dtype;var o=this.runWebGLProgram(e,r,i,a,s);return _.engine().makeTensorFromDataId(o.dataId,o.shape,o.dtype)},t.prototype.getAndSaveBinary=function(e,r){return e in this.binaryCache||(this.binaryCache[e]=r()),this.binaryCache[e]},t.prototype.getTextureManager=function(){return this.textureManager},t.prototype.dispose=function(){var e=this;if(this.disposed)return;if(!_.env().getBool("IS_TEST")){var r=Object.keys(this.binaryCache);r.forEach(function(i){e.gpgpu.deleteProgram(e.binaryCache[i].webGLProgram),delete e.binaryCache[i]})}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},t.prototype.floatPrecision=function(){var e=this;return this.floatPrecisionValue==null&&(this.floatPrecisionValue=_.tidy(function(){if(!_.env().get("WEBGL_RENDER_FLOAT32_ENABLED")){var r=_.env().getBool("DEBUG");_.env().set("DEBUG",!1);var i=e.abs(_.scalar(1e-8)).dataSync()[0];if(_.env().set("DEBUG",r),i>0)return 32}return 16})),this.floatPrecisionValue},t.prototype.epsilon=function(){return this.floatPrecision()===32?lM:uM},t.prototype.uploadToGPU=function(e){var r,i=this.texData.get(e),a=i.shape,s=i.dtype,o=i.values,c=i.texture,l=i.usage,u=i.isPacked;if(c!=null)return;var h=this.activeTimers!=null,d;h&&(d=_.util.now());var p=i.texShape;if(p==null&&(p=i2(a,u),i.texShape=p),o!=null){var f=vc(a),m=void 0,g=p[1],y=p[0],w=o instanceof Uint8Array;u?(r=ga(p[0],p[1]),g=r[0],y=r[1],m=new zz(f,[y,g],w)):m=new Bz(f,[y,g],w);var b=this.makeTensorInfo([y,g],s);w?this.texData.get(b.dataId).usage=hn.PIXELS:this.texData.get(b.dataId).usage=hn.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(b.dataId),g,y,o);var S=!0,x=this.runWebGLProgram(m,[b],s,null,S),N=this.texData.get(x.dataId);i.texture=N.texture,i.texShape=N.texShape,i.isPacked=N.isPacked,i.usage=N.usage,this.disposeIntermediateTensorInfo(b),this.texData.delete(x.dataId),i.values=null,h&&(this.uploadWaitMs+=_.util.now()-d)}else{var I=this.acquireTexture(p,l,s,u);i.texture=I}},t.prototype.convertAndCacheOnCPU=function(e,r){var i=this.texData.get(e),a=i.dtype;return this.releaseGPUData(e),r!=null&&(i.values=mM(r,a)),i.values},t.prototype.acquireTexture=function(e,r,i,a){if(this.numBytesInGPU+=this.computeBytes(e,i),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){var s=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: "+s+" MB, most likely due to a memory leak")}return this.textureManager.acquireTexture(e,r,a)},t.prototype.computeBytes=function(e,r){return e[0]*e[1]*_.util.bytesPerElement(r)},t.prototype.tryRunOnCpuOrThrow=function(e,r){if(this.shouldExecuteOnCPU(e))try{return r()}catch(i){if(_.env().getBool("IS_TEST"))throw new Error("CPU forwarding failed")}return null},t}(_.KernelBackend);function mM(n,t){if(t==="float32"||t==="complex64")return n;if(t==="int32"||t==="bool"){for(var e=t==="int32"?new Int32Array(n.length):new Uint8Array(n.length),r=0;r 0. ? NAN : result.r; result.g = isNaN.g > 0. ? NAN : result.g; result.b = isNaN.b > 0. ? NAN : result.b; result.a = isNaN.a > 0. ? NAN : result.a; `;function Tc(n){return function(t){var e=t.inputs,r=t.backend,i=e.x,a=r,s=new De(i.shape,n);return a.runWebGLProgram(s,[i],i.dtype)}}function Ia(n){var t=n.opSnippet,e=n.packedOpSnippet,r=n.checkOutOfBounds,i=r===void 0?!1:r,a=n.supportsComplex,s=a===void 0?!1:a,o=n.cpuKernelImpl,c=n.dtype;return function(l){var u=l.inputs,h=l.backend,d=u,p=d.a,f=d.b,m=h;if(s&&p.dtype==="complex64"){var g=m.texData.get(p.dataId),y=m.texData.get(f.dataId),w=[[g.complexTensorInfos.real,y.complexTensorInfos.real],[g.complexTensorInfos.imag,y.complexTensorInfos.imag]].map(function(V){var P=V[0],q=V[1],K={dataId:P.dataId,dtype:P.dtype,shape:p.shape},G={dataId:q.dataId,dtype:q.dtype,shape:f.shape},H=new Bt(t,p.shape,f.shape);return m.runWebGLProgram(H,[K,G],_.upcastType(P.dtype,q.dtype))}),b=w[0],S=w[1],x=La({inputs:{real:b,imag:S},backend:m});return m.disposeIntermediateTensorInfo(b),m.disposeIntermediateTensorInfo(S),x}var N=c||_.upcastType(p.dtype,f.dtype);if(m.shouldExecuteOnCPU([p,f])&&o!=null){var g=m.texData.get(p.dataId),y=m.texData.get(f.dataId),I=o(p.shape,f.shape,g.values,y.values,N),C=I[0],O=I[1],D=m.makeTensorInfo(O,N),F=m.texData.get(D.dataId);return F.values=C,D}var k=_.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null,B;return k?B=new hr(e,p.shape,f.shape,i):B=new Bt(t,p.shape,f.shape),m.runWebGLProgram(B,[p,f],N)}}var dx="return a + b;",SM=Ia({opSnippet:dx,packedOpSnippet:dx,supportsComplex:!0,cpuKernelImpl:KU}),LM={kernelName:_.Add,backendName:"webgl",kernelFunc:SM};var IM=bM+` return atan(a, b); `,AM=` vec4 result = atan(a, b); vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0)); `+xM+` return result; `,TM=Ia({opSnippet:IM,packedOpSnippet:AM}),NM={kernelName:_.Atan2,backendName:"webgl",kernelFunc:TM};function _M(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x;ya(i,"avgPool");var a=r.filterSize,s=r.strides,o=r.pad,c=r.dimRoundingMode,l=1;_.util.assert(_.backend_util.eitherStridesOrDilationsAreOne(s,l),function(){return"Error in avgPool: Either strides or dilations must be 1. "+("Got strides "+s+" and dilations '"+l+"'")});var u=_.backend_util.computePool2DInfo(i.shape,a,s,l,o,c);if(u.filterWidth===1&&u.filterHeight===1&&_.util.arraysEqual(u.inShape,u.outShape))return pr({inputs:{x:i},backend:e});var h=new Os(u,"avg",!1);return e.runWebGLProgram(h,[i],"float32")}var CM={kernelName:_.AvgPool,backendName:"webgl",kernelFunc:_M};function RM(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.dy,a=t.input,s=a;ya([i,a],"avgPoolBackprop");var o=r.filterSize,c=r.strides,l=r.pad,u=_.backend_util.computePool2DInfo(s.shape,o,c,1,l),h=new jB(u);return e.runWebGLProgram(h,[i],s.dtype)}var OM={kernelName:_.AvgPoolBackprop,backendName:"webgl",kernelFunc:RM};var EM=function(){function n(t,e,r,i,a,s){this.outputShape=[],this.variableNames=["x","mean","variance"],_.backend_util.assertAndGetBroadcastShape(t,e),_.backend_util.assertAndGetBroadcastShape(t,r);var o="0.0";i!=null&&(_.backend_util.assertAndGetBroadcastShape(t,i),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");var c="1.0";a!=null&&(_.backend_util.assertAndGetBroadcastShape(t,a),this.variableNames.push("scale"),c="getScaleAtOutCoords()"),this.outputShape=t,this.userCode=` void main() { float x = getXAtOutCoords(); float mean = getMeanAtOutCoords(); float variance = getVarianceAtOutCoords(); float offset = `+o+`; float scale = `+c+`; float inv = scale * inversesqrt(variance + float(`+s+`)); setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1))); } `}return n}();var DM=function(){function n(t,e,r,i,a,s){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],_.backend_util.assertAndGetBroadcastShape(t,e),_.backend_util.assertAndGetBroadcastShape(t,r);var o="vec4(0.0)";i!=null&&(_.backend_util.assertAndGetBroadcastShape(t,i),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");var c="vec4(1.0)";a!=null&&(_.backend_util.assertAndGetBroadcastShape(t,a),this.variableNames.push("scale"),c="getScaleAtOutCoords()"),this.outputShape=t,this.userCode=` void main() { vec4 offset = `+o+`; vec4 scale = `+c+`; vec4 x = getXAtOutCoords(); vec4 mean = getMeanAtOutCoords(); vec4 variance = getVarianceAtOutCoords(); vec4 inv = scale * inversesqrt(variance + vec4(`+s+`)); setOutput((x - mean) * inv + offset); } `}return n}();var kM=function(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x,a=t.mean,s=t.variance,o=t.offset,c=t.scale;_.util.assert(a.shape.length===s.shape.length,function(){return"Batch normalization gradient requires mean and variance to have equal ranks."}),_.util.assert(o==null||a.shape.length===o.shape.length,function(){return"Batch normalization gradient requires mean and offset to have equal ranks."}),_.util.assert(c==null||a.shape.length===c.shape.length,function(){return"Batch normalization gradient requires mean and scale to have equal ranks."});var l=r.varianceEpsilon;l==null&&(l=.001);var u=[i,a,s],h=null;o!=null&&(h=o.shape,u.push(o));var d=null;c!=null&&(d=c.shape,u.push(c));var p=_.env().getBool("WEBGL_PACK_NORMALIZATION")?new DM(i.shape,a.shape,s.shape,h,d,l):new EM(i.shape,a.shape,s.shape,h,d,l),f=e.runWebGLProgram(p,u,u[0].dtype);return f},FM={kernelName:_.FusedBatchNorm,backendName:"webgl",kernelFunc:kM};var WM="return float(a != b);",px=Ia({opSnippet:WM,dtype:"bool"}),UM={kernelName:_.NotEqual,backendName:"webgl",kernelFunc:px};function Mp(n){var t=n.inputs,e=n.backend,r=t.input,i=e.texData.get(r.dataId);return pr({inputs:{x:i.complexTensorInfos.real},backend:e})}var BM={kernelName:_.Real,backendName:"webgl",kernelFunc:Mp};var zM="return float(int(x));";function PM(n,t){var e=new De(n.shape,zM),r=t.runWebGLProgram(e,[n],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}function Hp(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x,a=r.dtype;if(a==="complex64"){if(i.dtype==="complex64")return pr({inputs:{x:i},backend:e});var s=_.zeros(i.shape),o=Hp({inputs:{x:i},backend:e,attrs:{dtype:"float32"}}),c=La({inputs:{real:o,imag:s},backend:e});return s.dispose(),e.disposeIntermediateTensorInfo(o),c}if(i.dtype==="complex64"){var l=Mp({inputs:{input:i},backend:e}),c=Hp({inputs:{x:l},backend:e,attrs:{dtype:a}});return e.disposeIntermediateTensorInfo(l),c}if(!_.util.hasEncodingLoss(i.dtype,a)){var c=pr({inputs:{x:i},backend:e});return{dataId:c.dataId,shape:c.shape,dtype:a}}if(a==="int32")return PM(i,e);if(a==="bool"){var u=e.makeTensorInfo([],"bool",_.util.getTypedArrayFromDType("bool",1)),h={a:i,b:u},c=px({inputs:h,backend:e});return e.disposeIntermediateTensorInfo(u),c}throw new Error("Error in Cast: failed to cast "+i.dtype+" to "+a)}var MM={kernelName:_.Cast,backendName:"webgl",kernelFunc:Hp};var HM=function(){function n(t){this.outputShape=[],this.outputShape=_.backend_util.computeOutShape(t,1),this.variableNames=t.map(function(c,l){return"T"+l});var e=new Array(t.length-1);e[0]=t[0][1];for(var r=1;r= "+c[l-1]+`) { return getChannel( getT`+l+"("+Nc(o,u,f)+`), vec2(`+Nc(h,u,f)+`)); }`}var m=c.length,g=c[c.length-1];p+=` return getChannel( getT`+m+"("+Nc(o,u,g)+`), vec2(`+Nc(h,u,g)+"));",this.userCode=` float getValue(`+o.map(function(y){return"int "+y})+`) { `+p+` } void main() { `+a+` coords = getOutputCoords(); vec4 result = vec4(getValue(`+s+`), 0., 0., 0.); `+s[i-1]+" = "+s[i-1]+` + 1; if (`+s[i-1]+" < "+r[i-1]+`) { result.g = getValue(`+s+`); } `+s[i-2]+" = "+s[i-2]+` + 1; if (`+s[i-2]+" < "+r[i-2]+`) { result.a = getValue(`+s+`); } `+s[i-1]+" = "+s[i-1]+` - 1; if (`+s[i-2]+" < "+r[i-2]+` && `+s[i-1]+" < "+r[i-1]+`) { result.b = getValue(`+s+`); } setOutput(result); } `}return n}();function Nc(n,t,e){var r=n.indexOf(t),i=n.map(function(a,s){return s===r?a+" - "+e:a});return i.join()}function fx(n){var t=n.inputs,e=n.backend,r=t.input,i=e.texData.get(r.dataId);return pr({inputs:{x:i.complexTensorInfos.imag},backend:e})}var qM={kernelName:_.Imag,backendName:"webgl",kernelFunc:fx};function GM(n,t,e){var r=[Ti(n.shape)].concat(Ni(n.shape)),i={dtype:n.dtype,shape:r,dataId:n.dataId},a=[Ti(t)].concat(Ni(t)),s=new q2(a,r),o=!0,c=e.runWebGLProgram(s,[i],n.dtype,null,o);return{dataId:c.dataId,shape:t,dtype:c.dtype}}function fr(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x,a=r.shape,s=e,o=_.util.sizeFromShape(i.shape),c=_.util.inferFromImplicitShape(a,o),l=_.util.sizeFromShape(c);_.util.assert(o===l,function(){return"The new shape ("+c+") has "+l+" elements and the old "+("shape ("+i.shape+") has "+o+" elements. The new shape and old ")+"shape must have the same number of elements."});var u=s.texData.get(i.dataId);return u.isPacked&&!Cs(i.shape,c)&&!(u.texture!==null&&Cs(u.shape,c))?GM(i,c,s):(s.incRef(i.dataId),{dataId:i.dataId,shape:c,dtype:i.dtype})}var YM={kernelName:_.Reshape,backendName:"webgl",kernelFunc:fr};function Aa(n,t,e){var r=n[0].dtype;if(r==="complex64"){var i=n.map(function(b){return Mp({inputs:{input:b},backend:e})}),a=n.map(function(b){return fx({inputs:{input:b},backend:e})}),s=Aa(i,t,e),o=Aa(a,t,e),c=La({inputs:{real:s,imag:o},backend:e});return i.forEach(function(b){return e.disposeIntermediateTensorInfo(b)}),a.forEach(function(b){return e.disposeIntermediateTensorInfo(b)}),e.disposeIntermediateTensorInfo(s),e.disposeIntermediateTensorInfo(o),c}if(n.length>_.env().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var l=Math.floor(n.length/2),u=Aa(n.slice(0,l),t,e),h=Aa(n.slice(l),t,e),d=Aa([u,h],t,e);return e.disposeIntermediateTensorInfo(u),e.disposeIntermediateTensorInfo(h),d}if(_.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&n[0].shape.length>1){var p=new VM(n.map(function(b){return b.shape}),t);return e.runWebGLProgram(p,n,r)}var f=_.backend_util.computeOutShape(n.map(function(b){return b.shape}),t),m=n.map(function(b){return fr({inputs:{x:b},attrs:{shape:[-1,_.util.sizeFromShape(b.shape.slice(t))]},backend:e})}),g=new HM(m.map(function(b){return b.shape})),y=e.runWebGLProgram(g,m,r);m.forEach(function(b){return e.disposeIntermediateTensorInfo(b)});var w=fr({inputs:{x:y},attrs:{shape:f},backend:e});return e.disposeIntermediateTensorInfo(y),w}function jM(n){var t=n.inputs,e=n.backend,r=n.attrs,i=r.axis,a=_.util.parseAxisParam(i,t[0].shape)[0],s=_.backend_util.computeOutShape(t.map(function(l){return l.shape}),a);if(_.util.sizeFromShape(s)===0)return e.makeTensorInfo(s,t[0].dtype,[]);var o=t.filter(function(l){return _.util.sizeFromShape(l.shape)>0});if(o.length===1)return o[0];var c=o.map(function(l){return l.shape});return _.backend_util.assertParamsConsistent(c,a),Aa(o,a,e)}var KM={kernelName:_.Concat,backendName:"webgl",kernelFunc:jM};var $M=hx+` return cos(x); `,XM=Tc($M),JM={kernelName:_.Cos,backendName:"webgl",kernelFunc:XM};var ZM=` if (a == b) { return 1.0; }; return a / b;`,QM=` // 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; `,eH=Ia({opSnippet:ZM,packedOpSnippet:QM,checkOutOfBounds:!0}),tH={kernelName:_.Div,backendName:"webgl",kernelFunc:eH};var mx=function(){function n(t,e,r){this.variableNames=["real","imag"];var i=e[1];this.outputShape=e;var a=r?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,s=r?i+".0":"1.0",o;if(t==="real")o="return real * expR - imag * expI;";else if(t==="imag")o="return real * expI + imag * expR;";else throw new Error('FFT component must be either "real" or "imag", got '+t+".");this.userCode=` const float exponentMultiplier = `+a+`; float unaryOpComplex(float real, float expR, float imag, float expI) { `+o+` } float mulMatDFT(int batch, int index) { float indexRatio = float(index) / float(`+i+`); float exponentMultiplierTimesIndexRatio = exponentMultiplier * indexRatio; float result = 0.0; for (int i = 0; i < `+i+`; 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) / `+s+`; } return result; } void main() { ivec2 coords = getOutputCoords(); setOutput(mulMatDFT(coords[0], coords[1])); } `}return n}();function gx(n,t,e){var r=e.texData.get(n.dataId),i=_.util.sizeFromShape(n.shape),a=n.shape[n.shape.length-1],s=i/a,o=fr({inputs:{x:n},backend:e,attrs:{shape:[s,a]}}),c=o.shape,l=new mx("real",c,t),u=new mx("imag",c,t),h=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:c},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:c}],d=e.runWebGLProgram(l,h,"float32"),p=e.runWebGLProgram(u,h,"float32"),f=La({inputs:{real:d,imag:p},backend:e});e.disposeIntermediateTensorInfo(d),e.disposeIntermediateTensorInfo(p);var m=fr({inputs:{x:f},backend:e,attrs:{shape:n.shape}});return e.disposeIntermediateTensorInfo(m),m}function nH(n){var t=n.inputs,e=n.backend,r=t.input;return gx(r,!1,e)}var rH={kernelName:_.FFT,backendName:"webgl",kernelFunc:nH};var iH=function(){function n(t){this.variableNames=["Image"],this.outputShape=[];var e=t[2];this.outputShape=t,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int x = coords[2]; int coordX = `+e+` - x; float outputValue; if(coordX >= 0 && coordX < `+e+`) { outputValue = getImage(coords[0], coords[1], coordX, coords[3]); } else { outputValue = getImage(coords[0], coords[1], coords[2], coords[3]); } setOutput(outputValue); } `}return n}();var aH={kernelName:_.FlipLeftRight,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.backend,r=t.image,i=e,a=new iH(r.shape),s=i.runWebGLProgram(a,[r],r.dtype);return s}};var sH=function(){function n(t){this.variableNames=["A"];var e=Ht(),r=t[0],i=t[1];this.outputShape=t,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(`+i+".0, "+r+`.0); vec4 values = `+e.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 n}();var oH=function(){function n(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var e=Ht(),r=t[0],i=t[1];this.outputShape=t,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(`+i+".0, "+r+`.0); vec4 values = `+e.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); } } `+e.output+` = result; } `}return n}();var lH={kernelName:_.FromPixels,backendName:"webgl",kernelFunc:cH},Ta;function cH(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.pixels,a=r.numChannels,s=typeof HTMLVideoElement!="undefined"&&i instanceof HTMLVideoElement,o=typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement,c=s?[i.videoWidth,i.videoHeight]:[i.width,i.height],l=c[0],u=c[1],h=[u,l],d=[u,l,a];(o||s)&&(Ta==null&&(Ta=document.createElement("canvas").getContext("2d")),Ta.canvas.width=l,Ta.canvas.height=u,Ta.drawImage(i,0,0,l,u),i=Ta.canvas);var p=e.makeTensorInfo(h,"int32");e.texData.get(p.dataId).usage=hn.PIXELS,e.gpgpu.uploadPixelDataToTexture(e.getTexture(p.dataId),i);var f=_.env().getBool("WEBGL_PACK")?new oH(d):new sH(d),m=e.runWebGLProgram(f,[p],"int32");return e.disposeData(p.dataId),m}function uH(n){var t=n.inputs,e=n.backend,r=t.input;return gx(r,!0,e)}var hH={kernelName:_.IFFT,backendName:"webgl",kernelFunc:uH};var yx=function(){function n(t,e){this.variableNames=["x"];var r=t.windowSize,i=t.batchSize,a=t.inSize,s=t.outSize;this.outputShape=[i,s];var o=Math.floor(r/4)*4,c=r%4,l="sumValue += dot(values, ones);";if(e!=null){var u=1/e;l="sumValue += dot(values * "+(_.util.isInt(u)?u.toPrecision(2):u)+", ones);"}var h="";a%r>0&&(h=` if (inIdx < 0 || inIdx >= `+a+`) { return 0.0; } `),this.userCode=` const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); float getValue(int batch, int inIdx) { `+h+` return getX(batch, inIdx); } void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; int outIdx = coords[1]; int inOffset = outIdx * `+r+`; float sumValue = 0.0; for (int i = 0; i < `+o+`; i += 4) { int inIdx = inOffset + i; vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), getValue(batch, inIdx + 3) ); `+l+` } int inIdx = inOffset + `+o+`; if (`+(c===1)+`) { vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0); `+l+` } else if (`+(c===2)+`) { vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), 0.0, 0.0); `+l+` } else if (`+(c===3)+`) { vec4 values = vec4( getValue(batch, inIdx), getValue(batch, inIdx + 1), getValue(batch, inIdx + 2), 0.0); `+l+` } setOutput(sumValue); } `}return n}();function dH(n){for(var t=[];t.length===0||t[t.length-1].outSize!==1;){var e=t.length?t[t.length-1].outSize:n[1],r=_.backend_util.computeOptimalWindowSize(e);t.push({inSize:e,windowSize:r,outSize:Math.ceil(e/r)})}return t}function vx(n,t,e,r){for(var i=dH(n.shape),a=n,s=0;s6)throw Error("Transpose for rank "+t+" is not yet supported");for(var e=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t),i=0;i6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");for(var a=Ze(this.rank),s=h2("rc",this.rank),o=new Array(this.rank),i=0;i= end) { outC = (end - 1) * 2 - outC + `+l+`; } setOutput(getX(outC - start)); } `;return}this.userCode=` `+a+" start = "+a+"("+s+`); `+a+" end = "+a+"("+o+`); void main() { `+a+` outC = getOutputCoords(); for (int i = 0; i < `+i+`; i++) { if (outC[i] < start[i]) { outC[i] = start[i] * 2 - outC[i] - `+l+`; } else if(outC[i] >= end[i]) { outC[i] = (end[i] - 1) * 2 - outC[i] + `+l+`; } } `+a+` coords = outC - start; setOutput(getX(`+c+`)); } `}return n}();var NH=function(){function n(t,e,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map(function(m,g){return m[0]+t[g]+m[1]});var i=t.length,a=Ze(i),s=e.map(function(m){return m[0]}).join(","),o=e.map(function(m,g){return m[0]+t[g]}).join(","),c=Mt("rc",i),l=Mt("source",i),u=c[i-1]+" < "+this.outputShape[i-1],h=i===1?"source":"vec2("+l.slice(-2).join()+")",d=r==="reflect"?0:1,p="";if(i===1){var f=` `+a+` source = rc; if (source < start) { source = start * 2 - source - `+d+`; } else if (source >= end) { source = (end - 1) * 2 - source + `+d+`; } source -= start; `;p=` `+a+` rc = outputLoc; `+f+` result[0] = getChannel(getX(`+l.join()+"), "+h+`); `+c[i-1]+` += 1; if(`+u+`) { `+f+` result[1] = getChannel(getX(`+l.join()+"), "+h+`); } `}else{var f=` `+a+` source = rc; `+a+" lt = "+a+`(lessThan(source, start)); `+a+" gte = "+a+`(greaterThanEqual(source, end)); `+a+` orig = 1 - (lt + gte); source = orig * source + lt * (start * 2 - source - `+d+`) + gte * ((end - 1) * 2 - source + `+d+`); source -= start; `;p=` `+a+` rc = outputLoc; `+f+` result[0] = getChannel(getX(`+l.join()+"), "+h+`); `+c[i-1]+` += 1; if(`+u+`) { `+f+` result[1] = getChannel(getX(`+l.join()+"), "+h+`); } rc = outputLoc; `+c[i-2]+` += 1; if(`+c[i-2]+" < "+this.outputShape[i-2]+`) { `+f+` result[2] = getChannel(getX(`+l.join()+"), "+h+`); `+c[i-1]+` += 1; if(`+u+`) { `+f+` result[3] = getChannel(getX(`+l.join()+"), "+h+`); } } `}this.userCode=` const `+a+" start = "+a+"("+s+`); const `+a+" end = "+a+"("+o+`); void main() { `+a+` outputLoc = getOutputCoords(); vec4 result = vec4(0.); `+p+` setOutput(result); } `}return n}();var _H=function(n){var t=n.inputs,e=n.backend,r=n.attrs,i=t.x,a=r.paddings,s=r.mode,o=_.env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new NH(i.shape,a,s):new TH(i.shape,a,s),c=e.runWebGLProgram(o,[i],i.dtype);return c},CH={kernelName:_.MirrorPad,backendName:"webgl",kernelFunc:_H};var wx={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},bx=function(){function n(t,e,r){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=_.backend_util.assertAndGetBroadcastShape(e,r),this.userCode=` float binaryOpComplex( float areal, float aimag, float breal, float bimag) { `+t+` } void main() { float areal = getARealAtOutCoords(); float aimag = getAImagAtOutCoords(); float breal = getBRealAtOutCoords(); float bimag = getBImagAtOutCoords(); setOutput(binaryOpComplex(areal, aimag, breal, bimag)); } `}return n}();var xx="return a * b;";function RH(n){var t=n.inputs,e=n.backend,r=t.a,i=t.b,a=_.backend_util.upcastType(r.dtype,i.dtype);if(r.dtype==="complex64"){var s=e.texData.get(r.dataId),o=e.texData.get(i.dataId),c=new bx(wx.REAL,r.shape,i.shape),l=new bx(wx.IMAG,r.shape,i.shape),u=[{dataId:s.complexTensorInfos.real.dataId,dtype:s.complexTensorInfos.real.dtype,shape:r.shape},{dataId:s.complexTensorInfos.imag.dataId,dtype:s.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:o.complexTensorInfos.real.dataId,dtype:o.complexTensorInfos.real.dtype,shape:i.shape},{dataId:o.complexTensorInfos.imag.dataId,dtype:o.complexTensorInfos.imag.dtype,shape:i.shape}],h=e.runWebGLProgram(c,u,"float32"),d=e.runWebGLProgram(l,u,"float32"),p=La({inputs:{real:h,imag:d},backend:e});return e.disposeIntermediateTensorInfo(h),e.disposeIntermediateTensorInfo(d),p}if(e.shouldExecuteOnCPU([r,i])){var s=e.texData.get(r.dataId),o=e.texData.get(i.dataId),f=tB(r.shape,i.shape,s.values,o.values,a),m=f[0],g=f[1],y=e.makeTensorInfo(g,a),w=e.texData.get(y.dataId);return w.values=m,y}var b;return _.env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?b=new hr(xx,r.shape,i.shape):b=new Bt(xx,r.shape,i.shape),e.runWebGLProgram(b,[r,i],a)}var OH={kernelName:_.Multiply,backendName:"webgl",kernelFunc:RH};var EH={kernelName:_.NonMaxSuppressionV3,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.backend,r=n.attrs;_.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var i=t,a=i.boxes,s=i.scores,o=r,c=o.maxOutputSize,l=o.iouThreshold,u=o.scoreThreshold,h=e,d=h.readSync(a.dataId),p=h.readSync(s.dataId),f=c,m=l,g=u;return _.kernel_impls.nonMaxSuppressionV3Impl(d,p,f,m,g)}};var DH=_.kernel_impls.nonMaxSuppressionV4Impl,kH={kernelName:_.NonMaxSuppressionV4,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.backend,r=n.attrs;_.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var i=t,a=i.boxes,s=i.scores,o=r,c=o.maxOutputSize,l=o.iouThreshold,u=o.scoreThreshold,h=o.padToMaxOutputSize,d=e,p=d.readSync(a.dataId),f=d.readSync(s.dataId),m=DH(p,f,c,l,u,h),g=m.selectedIndices,y=m.validOutputs;return[g,y]}};var FH=_.kernel_impls.nonMaxSuppressionV5Impl,WH={kernelName:_.NonMaxSuppressionV5,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.backend,r=n.attrs;_.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var i=t,a=i.boxes,s=i.scores,o=r,c=o.maxOutputSize,l=o.iouThreshold,u=o.scoreThreshold,h=o.softNmsSigma,d=e,p=d.readSync(a.dataId),f=d.readSync(s.dataId),m=c,g=l,y=u,w=h,b=FH(p,f,m,g,y,w),S=b.selectedIndices,x=b.selectedScores;return[S,x]}};var UH=function(){function n(t,e,r,i){this.variableNames=["Image"],this.outputShape=[];var a=t[1],s=t[2],o=Math.sin(e).toFixed(3),c=Math.cos(e).toFixed(3);this.outputShape=t;var l=_.backend_util.getImageCenter(i,a,s),u=l[0],h=l[1],d=u.toFixed(3),p=h.toFixed(3),f="";typeof r=="number"?f="float outputValue = "+r.toFixed(2)+";":f=` vec3 fill = vec3(`+r.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) - `+d+") * "+c+" - (float(y) - "+p+") * "+o+`; float coordYFloat = (float(x) - `+d+") * "+o+" + (float(y) - "+p+") * "+c+`; int coordX = int(round(coordXFloat + `+d+`)); int coordY = int(round(coordYFloat + `+p+`)); `+f+` if(coordX >= 0 && coordX < `+s+" && coordY >= 0 && coordY < "+a+`) { outputValue = getImage(coords[0], coordY, coordX, coords[3]); } setOutput(outputValue); } `}return n}();var BH={kernelName:_.RotateWithOffset,backendName:"webgl",kernelFunc:function(n){var t=n.inputs,e=n.attrs,r=n.backend,i=t.image,a=e,s=a.radians,o=a.fillValue,c=a.center,l=r,u=new UH(i.shape,s,o,c),h=l.runWebGLProgram(u,[i],i.dtype);return h}};var zH=hx+` return sin(x); `,PH=Tc(zH),MH={kernelName:_.Sin,backendName:"webgl",kernelFunc:PH};var HH="return x * x;",VH=Tc(HH),qH={kernelName:_.Square,backendName:"webgl",kernelFunc:VH};var Sx="return (a - b) * (a - b);",GH=Ia({opSnippet:Sx,packedOpSnippet:Sx}),YH={kernelName:_.SquaredDifference,backendName:"webgl",kernelFunc:GH};var Lx="return a - b;",jH=Ia({opSnippet:Lx,packedOpSnippet:Lx,supportsComplex:!0,cpuKernelImpl:iB}),KH={kernelName:_.Sub,backendName:"webgl",kernelFunc:jH};var $H="return tan(x);",XH=Tc($H),JH={kernelName:_.Tan,backendName:"webgl",kernelFunc:XH};var ZH={kernelName:_.Transpose,backendName:"webgl",kernelFunc:function(n){for(var t=n.inputs,e=n.attrs,r=n.backend,i=t.x,a=e.perm,s=r,o=i.shape.length,c=new Array(o),l=0;l{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});var Gp=di(),Yp=lw(),jp=Iw(),Tx=qw(),rV=zb(),iV=Ax();var aV="2.7.0";var sV={"tfjs-core":Gp.version_core,"tfjs-backend-cpu":rV.version_cpu,"tfjs-backend-webgl":iV.version_webgl,"tfjs-data":Tx.version_data,"tfjs-layers":Yp.version_layers,"tfjs-converter":jp.version_converter,tfjs:aV};Object.keys(Gp).forEach(function(n){n!=="default"&&Object.defineProperty(Ri,n,{enumerable:!0,get:function(){return Gp[n]}})});Object.keys(Yp).forEach(function(n){n!=="default"&&Object.defineProperty(Ri,n,{enumerable:!0,get:function(){return Yp[n]}})});Object.keys(jp).forEach(function(n){n!=="default"&&Object.defineProperty(Ri,n,{enumerable:!0,get:function(){return jp[n]}})});Ri.data=Tx;Ri.version=sV}),Ex=we(_c=>{const Ye=zt(),Nx=6;function oV(n){const t={strides:[n/16,n/8],anchors:[2,6]},e=[];for(let r=0;r{n.startEndTensor.dispose(),n.startPoint.dispose(),n.endPoint.dispose()},Cx=n=>({startEndTensor:n,startPoint:Ye.slice(n,[0,0],[-1,2]),endPoint:Ye.slice(n,[0,2],[-1,2])}),Rx=(n,t)=>{const e=Ye.mul(n.startPoint,t),r=Ye.mul(n.endPoint,t),i=Ye.concat2d([e,r],1);return Cx(i)};function cV(n,t,e){const r=Ye.slice(n,[0,1],[-1,2]),i=Ye.add(r,t),a=Ye.slice(n,[0,3],[-1,2]),s=Ye.div(a,e),o=Ye.div(i,e),c=Ye.div(s,2),l=Ye.sub(o,c),u=Ye.add(o,c),h=Ye.mul(l,e),d=Ye.mul(u,e),p=1;return Ye.concat2d([h,d],p)}function lV(n,t){return Ye.tidy(()=>{const e=n.box?n.box:n;return Rx(e,t).startEndTensor.squeeze()})}class Ox{constructor(n,t){this.blazeFaceModel=n,this.width=t.detector.inputSize,this.height=t.detector.inputSize,this.anchorsData=oV(t.detector.inputSize),this.anchors=Ye.tensor2d(this.anchorsData),this.inputSize=Ye.tensor1d([this.width,this.height]),this.config=t,this.scaleFaces=.8}async getBoundingBoxes(n){if(!n||n.isDisposedInternal||n.shape.length!==4||n.shape[1]<1||n.shape[2]<1)return null;const[t,e,r]=Ye.tidy(()=>{const l=n.resizeBilinear([this.width,this.height]),u=Ye.sub(l.div(127.5),1),h=this.blazeFaceModel.predict(u);let d;if(Array.isArray(h)){const g=h.sort((S,x)=>S.size-x.size),y=Ye.concat([g[0],g[2]],2),w=Ye.concat([g[1],g[3]],2),b=Ye.concat([w,y],1);d=b.squeeze(0)}else d=h.squeeze();const p=cV(d,this.anchors,this.inputSize),f=Ye.slice(d,[0,0],[-1,1]),m=Ye.sigmoid(f).squeeze();return[d,p,m]}),i=await Ye.image.nonMaxSuppressionAsync(e,r,this.config.detector.maxFaces,this.config.detector.iouThreshold,this.config.detector.scoreThreshold),a=i.arraySync();i.dispose();const s=a.map(l=>Ye.slice(e,[l,0],[1,-1])),o=s.map(l=>{const u=l.arraySync();return l.dispose(),u}),c=[];for(let l=0;l[(f[0]+l[0])*u,(f[1]+l[1])*h]),p={topLeft:o.slice(0,2),bottomRight:o.slice(2),landmarks:d,probability:c};_x(i.box),i.landmarks.dispose(),i.probability.dispose(),s.dispose(),r.push(p)}return r}}async function uV(n){const t=await Ye.loadGraphModel(n.detector.modelPath,{fromTFHub:n.detector.modelPath.includes("tfhub.dev")}),e=new Ox(t,n);return console.log(`Human: load model: ${n.detector.modelPath.match(/\/(.*)\./)[1]}`),e}_c.load=uV;_c.BlazeFaceModel=Ox;_c.disposeBox=_x}),$p=we(Kp=>{Kp.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]};Kp.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]}]}),Dx=we(Oi=>{const hV=zt();function dV(n,t){const e=[n.startPoint[0]*t[0],n.startPoint[1]*t[1]],r=[n.endPoint[0]*t[0],n.endPoint[1]*t[1]];return{startPoint:e,endPoint:r}}Oi.scaleBoxCoordinates=dV;function Xp(n){return[Math.abs(n.endPoint[0]-n.startPoint[0]),Math.abs(n.endPoint[1]-n.startPoint[1])]}Oi.getBoxSize=Xp;function Jp(n){return[n.startPoint[0]+(n.endPoint[0]-n.startPoint[0])/2,n.startPoint[1]+(n.endPoint[1]-n.startPoint[1])/2]}Oi.getBoxCenter=Jp;function pV(n,t,e){const r=t.shape[1],i=t.shape[2],a=[[n.startPoint[1]/r,n.startPoint[0]/i,n.endPoint[1]/r,n.endPoint[0]/i]];return hV.image.cropAndResize(t,a,[0],e)}Oi.cutBoxFromImageAndResize=pV;function fV(n,t=1.5){const e=Jp(n),r=Xp(n),i=[t*r[0]/2,t*r[1]/2],a=[e[0]-i[0],e[1]-i[1]],s=[e[0]+i[0],e[1]+i[1]];return{startPoint:a,endPoint:s,landmarks:n.landmarks}}Oi.enlargeBox=fV;function mV(n){const t=Jp(n),e=Xp(n),r=Math.max(...e),i=r/2,a=[t[0]-i,t[1]-i],s=[t[0]+i,t[1]+i];return{startPoint:a,endPoint:s,landmarks:n.landmarks}}Oi.squarifyBox=mV}),Bx=we(En=>{En.IDENTITY_MATRIX=[[1,0,0],[0,1,0],[0,0,1]];function kx(n){return n-2*Math.PI*Math.floor((n+Math.PI)/(2*Math.PI))}En.normalizeRadians=kx;function gV(n,t){const e=Math.PI/2-Math.atan2(-(t[1]-n[1]),t[0]-n[0]);return kx(e)}En.computeRotation=gV;function yV(n){return n*180/Math.PI}En.radToDegrees=yV;function Fx(n,t){return[[1,0,n],[0,1,t],[0,0,1]]}function Na(n,t){let e=0;for(let r=0;r{const Vr=zt(),Kn=Dx(),qr=$p(),Gr=Bx(),SV=468,LV=.25,IV=13,AV=[IV,qr.MESH_ANNOTATIONS.midwayBetweenEyes[0]],TV=3,NV=2,_V=[TV,NV],Zp=qr.MESH_ANNOTATIONS.leftEyeLower0,Qp=[Zp[0],Zp[Zp.length-1]],ef=qr.MESH_ANNOTATIONS.rightEyeLower0,tf=[ef[0],ef[ef.length-1]],CV=3,RV=4,OV=71,nf=76;function Cc(n,t,e,r){for(let i=0;i[a[0]*(d[0]-this.meshWidth/2),a[1]*(d[1]-this.meshHeight/2),d[2]]),o=Gr.buildRotationMatrix(e,[0,0]),c=s.map(d=>[...Gr.rotatePoint(d,o),d[2]]),l=Gr.invertTransformMatrix(r),u=[...Kn.getBoxCenter({startPoint:t.startPoint,endPoint:t.endPoint}),1],h=[Gr.dot(u,l[0]),Gr.dot(u,l[1])];return c.map(d=>[d[0]+h[0],d[1]+h[1],d[2]])}getLeftToRightEyeDepthDifference(n){const t=n[Qp[0]][2],e=n[tf[0]][2];return t-e}getEyeBox(n,t,e,r,i=!1){const a=Kn.squarifyBox(Kn.enlargeBox(this.calculateLandmarksBoundingBox([n[e],n[r]]),this.irisEnlarge)),s=Kn.getBoxSize(a);let o=Vr.image.cropAndResize(t,[[a.startPoint[1]/this.meshHeight,a.startPoint[0]/this.meshWidth,a.endPoint[1]/this.meshHeight,a.endPoint[0]/this.meshWidth]],[0],[this.irisSize,this.irisSize]);return i&&(o=Vr.image.flipLeftRight(o)),{box:a,boxSize:s,crop:o}}getEyeCoords(n,t,e,r=!1){const i=[];for(let a=0;a{let c=a;return o===2?c=r:o===4&&(c=i),[s[0],s[1],c]})}async predict(n,t){this.runsWithoutFaceDetector+=1;let e=this.detectedFaces===0||this.detectedFaces!==this.regionsOfInterest.length,r;if((e||this.runsWithoutFaceDetector>t.detector.skipFrames)&&(r=await this.boundingBoxDetector.getBoundingBoxes(n)),t.detector.maxFaces>1&&r&&r.boxes&&r.boxes.length>0&&r.boxes.length!==this.detectedFaces&&(e=!0),e){if(!r||!r.boxes||r.boxes.length===0)return this.regionsOfInterest=[],this.detectedFaces=0,null;const a=r.boxes.map(s=>{const o=s.box.startPoint.squeeze(),c=s.box.endPoint.squeeze(),l={startPoint:o.arraySync(),endPoint:c.arraySync()};o.dispose(),c.dispose();const u=Kn.scaleBoxCoordinates(l,r.scaleFactor),h=Kn.enlargeBox(u),d=s.landmarks.arraySync();return{...h,landmarks:d}});this.updateRegionsOfInterest(a),this.runsWithoutFaceDetector=0}r&&r.boxes&&r.boxes.forEach(a=>{a.box.startPoint.dispose(),a.box.endPoint.dispose(),a.landmarks.dispose(),a.probability.dispose()});let i=Vr.tidy(()=>this.regionsOfInterest.map((a,s)=>{let o=0;const c=a.landmarks.length>=SV;let[l,u]=AV;c===!1&&([l,u]=_V),o=Gr.computeRotation(a.landmarks[l],a.landmarks[u]);const h=Kn.getBoxCenter({startPoint:a.startPoint,endPoint:a.endPoint}),d=[h[0]/n.shape[2],h[1]/n.shape[1]];let p=n,f=Gr.IDENTITY_MATRIX;o!==0&&(p=Vr.image.rotateWithOffset(n,o,0,d),f=Gr.buildRotationMatrix(-o,h));const m={startPoint:a.startPoint,endPoint:a.endPoint},g=Kn.cutBoxFromImageAndResize(m,p,[this.meshHeight,this.meshWidth]).div(255),[,y,w]=this.meshDetector.predict(g),b=y.dataSync()[0];if(y.dispose(),ba!==null),this.detectedFaces=i.length,i}updateRegionsOfInterest(n){for(let t=0;ta[0]),e=n.map(a=>a[1]),r=[Math.min(...t),Math.min(...e)],i=[Math.max(...t),Math.max(...e)];return{startPoint:r,endPoint:i,landmarks:n}}}zx.Pipeline=EV}),Hx=we(Mx=>{Mx.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]]}),Vx=we(DV=>{Di(DV,{default:()=>kV});var kV=[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]}),Yx=we(Ds=>{const rf=zt(),FV=Ex(),qx=$p(),WV=Px(),UV=Hx(),BV=Vx().default;class Gx{constructor(n,t,e,r){this.pipeline=new WV.Pipeline(n,t,e,r),r&&(this.config=r)}async estimateFaces(n,t){t&&(this.config=t);const e=await this.pipeline.predict(n,t),r=[];for(const i of e||[]){if(i.isDisposedInternal)continue;const a=i.coords?i.coords.arraySync():null,s={};if(a&&a.length>0)for(const o in qx.MESH_ANNOTATIONS)(this.config.iris.enabled||o.includes("Iris")===!1)&&(s[o]=qx.MESH_ANNOTATIONS[o].map(c=>a[c]));r.push({confidence:i.confidence||0,box:i.box?[i.box.startPoint[0],i.box.startPoint[1],i.box.endPoint[0]-i.box.startPoint[0],i.box.endPoint[1]-i.box.startPoint[1]]:0,mesh:a,annotations:s,image:i.image?rf.clone(i.image):null}),i.coords&&i.coords.dispose(),i.image&&i.image.dispose()}return r}}async function zV(n){const t=await Promise.all([FV.load(n),rf.loadGraphModel(n.mesh.modelPath,{fromTFHub:n.mesh.modelPath.includes("tfhub.dev")}),rf.loadGraphModel(n.iris.modelPath,{fromTFHub:n.iris.modelPath.includes("tfhub.dev")})]),e=new Gx(t[0],t[1],t[2],n);return console.log(`Human: load model: ${n.mesh.modelPath.match(/\/(.*)\./)[1]}`),console.log(`Human: load model: ${n.iris.modelPath.match(/\/(.*)\./)[1]}`),e}Ds.load=zV;Ds.MediaPipeFaceMesh=Gx;Ds.uv_coords=UV;Ds.triangulation=BV}),ks=we(jx=>{const PV={};function MV(n,t){if(!t||!t.kernels)return;const e=5,r=t.kernels.filter(o=>o.kernelTimeMs>0).reduce((o,c)=>o+=c.kernelTimeMs,0),i=t.kernels.map((o,c)=>(o.id=c,o)).filter(o=>o.kernelTimeMs>0).sort((o,c)=>c.kernelTimeMs-o.kernelTimeMs),a=t.kernels.map((o,c)=>(o.id=c,o)).filter(o=>o.totalBytesSnapshot>0).sort((o,c)=>c.totalBytesSnapshot-o.totalBytesSnapshot);i.length>e&&(i.length=e),a.length>e&&(a.length=e);const s={newBytes:t.newBytes,newTensors:t.newTensors,peakBytes:t.peakBytes,numKernelOps:t.kernels.length,timeKernelOps:r,slowestKernelOps:i,largestKernelOps:a};PV[n]=s,console.log("Human profiler",n,s)}jx.run=MV}),Kx=we(af=>{const Fs=zt(),HV=ks(),Ws={};let Rc={age:0},sf=Number.MAX_SAFE_INTEGER;const Oc=[0,0];async function VV(n){return Ws.age||(Ws.age=await Fs.loadGraphModel(n.face.age.modelPath),console.log(`Human: load model: ${n.face.age.modelPath.match(/\/(.*)\./)[1]}`)),Ws.age}async function qV(n,t){return sf0?(sf+=1,Rc):(sf=0,new Promise(async e=>{const r=[[n.shape[1]*Oc[0]/n.shape[1],n.shape[2]*Oc[1]/n.shape[2],(n.shape[1]-n.shape[1]*Oc[0])/n.shape[1],(n.shape[2]-n.shape[2]*Oc[1])/n.shape[2]]],i=Fs.image.cropAndResize(n,r,[0],[t.face.age.inputSize,t.face.age.inputSize]),a=Fs.mul(i,[255]);Fs.dispose(i);let s;const o={};if(!t.profile)t.face.age.enabled&&(s=await Ws.age.predict(a));else{const c=t.face.age.enabled?await Fs.profile(()=>Ws.age.predict(a)):{};s=c.result.clone(),c.result.dispose(),HV.run("age",c)}if(a.dispose(),s){const c=s.dataSync();o.age=Math.trunc(10*c[0])/10}s.dispose(),Rc=o,e(o)}))}af.predict=qV;af.load=VV}),$x=we(of=>{const Dn=zt(),GV=ks(),_a={};let cf={gender:""},lf=Number.MAX_SAFE_INTEGER,uf=!1;const Ec=[0,0],hf=[.2989,.587,.114];async function YV(n){return _a.gender||(_a.gender=await Dn.loadGraphModel(n.face.gender.modelPath),uf=_a.gender.inputs[0].shape[3]===1,console.log(`Human: load model: ${n.face.gender.modelPath.match(/\/(.*)\./)[1]}`)),_a.gender}async function jV(n,t){return lf{const r=[[n.shape[1]*Ec[0]/n.shape[1],n.shape[2]*Ec[1]/n.shape[2],(n.shape[1]-n.shape[1]*Ec[0])/n.shape[1],(n.shape[2]-n.shape[2]*Ec[1])/n.shape[2]]],i=Dn.image.cropAndResize(n,r,[0],[t.face.gender.inputSize,t.face.gender.inputSize]);let a;uf?a=Dn.tidy(()=>{const[c,l,u]=Dn.split(i,3,3),h=Dn.mul(c,hf[0]),d=Dn.mul(l,hf[1]),p=Dn.mul(u,hf[2]),f=Dn.addN([h,d,p]);return f.sub(.5).mul(2)}):a=Dn.mul(i,[255]),Dn.dispose(i);let s;const o={};if(!t.profile)t.face.gender.enabled&&(s=await _a.gender.predict(a));else{const c=t.face.gender.enabled?await Dn.profile(()=>_a.gender.predict(a)):{};s=c.result.clone(),c.result.dispose(),GV.run("gender",c)}if(a.dispose(),s){const c=s.dataSync();if(uf){const l=Math.trunc(100*Math.abs(c[0]-c[1]))/100;l>t.face.gender.minConfidence&&(o.gender=c[0]>c[1]?"female":"male",o.confidence=l)}else{const l=Math.trunc(200*Math.abs(c[0]-.5))/100;l>t.face.gender.minConfidence&&(o.gender=c[0]<=.5?"female":"male",o.confidence=l)}}s.dispose(),cf=o,e(o)}))}of.predict=jV;of.load=YV}),Jx=we(df=>{const $n=zt(),KV=ks(),$V=["angry","disgust","fear","happy","sad","surpise","neutral"],Us={};let pf=[],ff=Number.MAX_SAFE_INTEGER;const Dc=[0,0],mf=[.2989,.587,.114],Xx=1;async function XV(n){return Us.emotion||(Us.emotion=await $n.loadGraphModel(n.face.emotion.modelPath),console.log(`Human: load model: ${n.face.emotion.modelPath.match(/\/(.*)\./)[1]}`)),Us.emotion}async function JV(n,t){return ff0?(ff+=1,pf):(ff=0,new Promise(async e=>{const r=[[n.shape[1]*Dc[0]/n.shape[1],n.shape[2]*Dc[1]/n.shape[2],(n.shape[1]-n.shape[1]*Dc[0])/n.shape[1],(n.shape[2]-n.shape[2]*Dc[1])/n.shape[2]]],i=$n.image.cropAndResize(n,r,[0],[t.face.emotion.inputSize,t.face.emotion.inputSize]),[a,s,o]=$n.split(i,3,3);i.dispose();const c=$n.mul(a,mf[0]),l=$n.mul(s,mf[1]),u=$n.mul(o,mf[2]);a.dispose(),s.dispose(),o.dispose();const h=$n.addN([c,l,u]);c.dispose(),l.dispose(),u.dispose();const d=$n.tidy(()=>h.sub(.5).mul(2));h.dispose();const p=[];if(t.face.emotion.enabled){let f;if(t.profile){const m=await $n.profile(()=>Us.emotion.predict(d));f=m.result.dataSync(),m.result.dispose(),KV.run("emotion",m)}else{const m=await Us.emotion.predict(d);f=m.dataSync(),$n.dispose(m)}for(let m=0;mt.face.emotion.minConfidence&&p.push({score:Math.min(.99,Math.trunc(100*Xx*f[m])/100),emotion:$V[m]});p.sort((m,g)=>g.score-m.score)}d.dispose(),pf=p,e(p)}))}df.predict=JV;df.load=XV}),Qx=we(Zx=>{const ZV=zt();class QV{constructor(n,t){this.model=n,this.outputStride=t}predict(n){return ZV.tidy(()=>{const t=this.preprocessInput(n.toFloat()),e=t.expandDims(0),r=this.model.predict(e),i=r.map(s=>s.squeeze([0])),a=this.nameOutputResults(i);return{heatmapScores:a.heatmap.sigmoid(),offsets:a.offsets,displacementFwd:a.displacementFwd,displacementBwd:a.displacementBwd}})}dispose(){this.model.dispose()}}Zx.BaseModel=QV}),gf=we(eS=>{const tS=zt(),eq=Qx();class tq extends eq.BaseModel{preprocessInput(n){return tS.tidy(()=>tS.div(n,127.5).sub(1))}nameOutputResults(n){const[t,e,r,i]=n;return{offsets:t,heatmap:e,displacementFwd:r,displacementBwd:i}}}eS.MobileNet=tq}),rS=we(nS=>{function yf(n){return Math.floor(n/2)}class nq{constructor(n,t){this.priorityQueue=new Array(n),this.numberOfElements=-1,this.getElementValue=t}enqueue(n){this.priorityQueue[++this.numberOfElements]=n,this.swim(this.numberOfElements)}dequeue(){const n=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,n}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(n){for(;n>0&&this.less(yf(n),n);)this.exchange(n,yf(n)),n=yf(n)}sink(n){for(;2*n<=this.numberOfElements;){let t=2*n;if(t{const rq=rS();function iq(n,t,e,r,i,a){const[s,o]=a.shape;let c=!0;const l=Math.max(e-i,0),u=Math.min(e+i+1,s);for(let h=l;ht){c=!1;break}if(!c)break}return c}function aq(n,t,e){const[r,i,a]=e.shape,s=new rq.MaxHeap(r*i*a,({score:o})=>o);for(let o=0;o{kn.partNames=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"];kn.NUM_KEYPOINTS=kn.partNames.length;kn.partIds=kn.partNames.reduce((n,t,e)=>(n[t]=e,n),{});const sq=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]];kn.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"]];kn.connectedPartIndices=sq.map(([n,t])=>[kn.partIds[n],kn.partIds[t]]);kn.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"]}),wf=we(Yr=>{const oq=Bs();function sS(n,t,e,r){return{y:r.get(n,t,e),x:r.get(n,t,e+oq.NUM_KEYPOINTS)}}Yr.getOffsetPoint=sS;function cq(n,t,e){const{heatmapY:r,heatmapX:i,id:a}=n,{y:s,x:o}=sS(r,i,a,e);return{x:n.heatmapX*t+o,y:n.heatmapY*t+s}}Yr.getImageCoords=cq;function lq(n,t){const e=new Array(t);for(let r=0;re?e:n}Yr.clamp=vf;function uq(n,t,e,r){const i=e-n,a=r-t;return i*i+a*a}Yr.squaredDistance=uq;function hq(n,t){return{x:n.x+t.x,y:n.y+t.y}}Yr.addVectors=hq;function dq(n,t,e){return{y:vf(n.y,t,e),x:vf(n.x,t,e)}}Yr.clampVector=dq}),hS=we(oS=>{const zs=Bs(),Ca=wf(),cS=zs.poseChain.map(([n,t])=>[zs.partIds[n],zs.partIds[t]]),bf=cS.map(([,n])=>n),lS=cS.map(([n])=>n);function pq(n,t,e){const r=e.shape[2]/2;return{y:e.get(t.y,t.x,n),x:e.get(t.y,t.x,r+n)}}function xf(n,t,e,r){return{y:Ca.clamp(Math.round(n.y/t),0,e-1),x:Ca.clamp(Math.round(n.x/t),0,r-1)}}function uS(n,t,e,r,i,a,s,o=2){const[c,l]=r.shape,u=xf(t.position,a,c,l),h=pq(n,u,s),d=Ca.addVectors(t.position,h);let p=d;for(let g=0;g=0;--d){const p=bf[d],f=lS[d];c[p]&&!c[f]&&(c[f]=uS(d,c[p],f,t,e,r,a))}for(let d=0;d{const mq=aS(),gq=hS(),pS=wf();function fS(n,t,{x:e,y:r},i){return n.some(({keypoints:a})=>{const s=a[i].position;return pS.squaredDistance(r,e,s.y,s.x)<=t})}function yq(n,t,e){const r=e.reduce((i,{position:a,score:s},o)=>(fS(n,t,a,o)||(i+=s),i),0);return r/e.length}const vq=1;function wq(n,t,e,r,i,a,s=.5,o=20){const c=[],l=mq.buildPartWithScoreQueue(s,vq,n),u=o*o;for(;c.length{const bq=Bs();function xq(n,t,e){return n(xq(n[r].score,n[i].score,t)||e.push([n[r],n[i]]),e),[])}jr.getAdjacentKeyPoints=Sq;const{NEGATIVE_INFINITY:mS,POSITIVE_INFINITY:gS}=Number;function yS(n){return n.reduce(({maxX:t,maxY:e,minX:r,minY:i},{position:{x:a,y:s}})=>({maxX:Math.max(t,a),maxY:Math.max(e,s),minX:Math.min(r,a),minY:Math.min(i,s)}),{maxX:mS,maxY:mS,minX:gS,minY:gS})}jr.getBoundingBox=yS;function Lq(n){const{minX:t,minY:e,maxX:r,maxY:i}=yS(n);return[{x:t,y:e},{x:r,y:e},{x:r,y:i},{x:t,y:i}]}jr.getBoundingBoxPoints=Lq;async function Iq(n){return Promise.all(n.map(t=>t.buffer()))}jr.toTensorBuffers3D=Iq;function vS(n,t,e){return{score:n.score,keypoints:n.keypoints.map(({score:r,part:i,position:a})=>({score:r,part:i,position:{x:a.x*e,y:a.y*t}}))}}jr.scalePose=vS;function Aq(n,[t,e]){const r=n.squeeze(0),i=r.resizeBilinear([t,e]);return r.dispose(),i}jr.resizeTo=Aq;function Tq(n,[t,e],[r,i]){const a=n.map(s=>vS(s,t/r,e/i));return a}jr.scaleAndFlipPoses=Tq}),bS=we(If=>{const Nq=zt(),_q=gf(),Cq=Sf(),Af=Lf();class wS{constructor(n){this.baseModel=n,this.outputStride=16}async estimatePoses(n,t){return new Promise(async e=>{const r=n.shape[1],i=n.shape[2],a=Af.resizeTo(n,[t.body.inputSize,t.body.inputSize]),s=this.baseModel.predict(a),o=await Af.toTensorBuffers3D([s.heatmapScores,s.offsets,s.displacementFwd,s.displacementBwd]),c=o[0],l=o[1],u=o[2],h=o[3],d=await Cq.decodeMultiplePoses(c,l,u,h,this.outputStride,t.body.maxDetections,t.body.scoreThreshold,t.body.nmsRadius),p=Af.scaleAndFlipPoses(d,[r,i],[t.body.inputSize,t.body.inputSize]);s.heatmapScores.dispose(),s.offsets.dispose(),s.displacementFwd.dispose(),s.displacementBwd.dispose(),a.dispose(),e(p)})}dispose(){this.baseModel.dispose()}}If.PoseNet=wS;async function Rq(n){const t=await Nq.loadGraphModel(n.body.modelPath),e=new _q.MobileNet(t,this.outputStride);return console.log(`Human: load model: ${n.body.modelPath.match(/\/(.*)\./)[1]}`),new wS(e)}If.load=Rq}),SS=we(sn=>{const Oq=gf(),xS=bS(),Eq=Sf(),kc=Bs(),Ps=Lf();sn.load=xS.load;sn.PoseNet=xS.PoseNet;sn.MobileNet=Oq.MobileNet;sn.decodeMultiplePoses=Eq.decodeMultiplePoses;sn.partChannels=kc.partChannels;sn.partIds=kc.partIds;sn.partNames=kc.partNames;sn.poseChain=kc.poseChain;sn.getAdjacentKeyPoints=Ps.getAdjacentKeyPoints;sn.getBoundingBox=Ps.getBoundingBox;sn.getBoundingBoxPoints=Ps.getBoundingBoxPoints;sn.scaleAndFlipPoses=Ps.scaleAndFlipPoses;sn.scalePose=Ps.scalePose}),_f=we(Dq=>{Di(Dq,{cutBoxFromImageAndResize:()=>Fq,enlargeBox:()=>Uq,getBoxCenter:()=>Nf,getBoxSize:()=>Tf,scaleBoxCoordinates:()=>Wq,shiftBox:()=>zq,squarifyBox:()=>Bq});const kq=zt();function Tf(n){return[Math.abs(n.endPoint[0]-n.startPoint[0]),Math.abs(n.endPoint[1]-n.startPoint[1])]}function Nf(n){return[n.startPoint[0]+(n.endPoint[0]-n.startPoint[0])/2,n.startPoint[1]+(n.endPoint[1]-n.startPoint[1])/2]}function Fq(n,t,e){const r=t.shape[1],i=t.shape[2],a=[[n.startPoint[1]/r,n.startPoint[0]/i,n.endPoint[1]/r,n.endPoint[0]/i]];return kq.image.cropAndResize(t,a,[0],e)}function Wq(n,t){const e=[n.startPoint[0]*t[0],n.startPoint[1]*t[1]],r=[n.endPoint[0]*t[0],n.endPoint[1]*t[1]],i=n.palmLandmarks.map(a=>{const s=[a[0]*t[0],a[1]*t[1]];return s});return{startPoint:e,endPoint:r,palmLandmarks:i,confidence:n.confidence}}function Uq(n,t=1.5){const e=Nf(n),r=Tf(n),i=[t*r[0]/2,t*r[1]/2],a=[e[0]-i[0],e[1]-i[1]],s=[e[0]+i[0],e[1]+i[1]];return{startPoint:a,endPoint:s,palmLandmarks:n.palmLandmarks}}function Bq(n){const t=Nf(n),e=Tf(n),r=Math.max(...e),i=r/2,a=[t[0]-i,t[1]-i],s=[t[0]+i,t[1]+i];return{startPoint:a,endPoint:s,palmLandmarks:n.palmLandmarks}}function zq(n,t){const e=[n.endPoint[0]-n.startPoint[0],n.endPoint[1]-n.startPoint[1]],r=[e[0]*t[0],e[1]*t[1]],i=[n.startPoint[0]+r[0],n.startPoint[1]+r[1]],a=[n.endPoint[0]+r[0],n.endPoint[1]+r[1]];return{startPoint:i,endPoint:a,palmLandmarks:n.palmLandmarks}}}),IS=we(LS=>{const et=zt(),Pq=_f();class Mq{constructor(n,t,e){this.model=n,this.anchors=e.map(r=>[r.x_center,r.y_center]),this.anchorsTensor=et.tensor2d(this.anchors),this.inputSizeTensor=et.tensor1d([t,t]),this.doubleInputSizeTensor=et.tensor1d([t*2,t*2])}normalizeBoxes(n){return et.tidy(()=>{const t=et.slice(n,[0,0],[-1,2]),e=et.slice(n,[0,2],[-1,2]),r=et.add(et.div(t,this.inputSizeTensor),this.anchorsTensor),i=et.div(e,this.doubleInputSizeTensor),a=et.mul(et.sub(r,i),this.inputSizeTensor),s=et.mul(et.add(r,i),this.inputSizeTensor);return et.concat2d([a,s],1)})}normalizeLandmarks(n,t){return et.tidy(()=>{const e=et.add(et.div(n.reshape([-1,7,2]),this.inputSizeTensor),this.anchors[t]);return et.mul(e,this.inputSizeTensor)})}async getBoxes(n,t){const e=this.model.predict(n),r=e.squeeze();e.dispose();const i=et.tidy(()=>et.sigmoid(et.slice(r,[0,0],[-1,1])).squeeze()),a=i.dataSync(),s=et.slice(r,[0,1],[-1,4]),o=this.normalizeBoxes(s);s.dispose();const c=await et.image.nonMaxSuppressionAsync(o,i,t.maxHands,t.iouThreshold,t.scoreThreshold),l=c.arraySync();i.dispose(),c.dispose();const u=[];for(const h of l)if(a[h]>=t.minConfidence){const d=et.slice(o,[h,0],[1,-1]),p=et.slice(r,[h,5],[1,14]),f=et.tidy(()=>this.normalizeLandmarks(p,h).reshape([-1,2]));p.dispose(),u.push({box:d,palmLandmarks:f,confidence:a[h]})}return r.dispose(),o.dispose(),u}async estimateHandBounds(n,t){const e=n.shape[1],r=n.shape[2],i=et.tidy(()=>n.resizeBilinear([t.inputSize,t.inputSize]).div(127.5).sub(1)),a=await this.getBoxes(i,t);if(i.dispose(),!a||a.length===0)return null;const s=[];for(const o of a){const c=o.box.dataSync(),l=c.slice(0,2),u=c.slice(2,4),h=o.palmLandmarks.arraySync();o.box.dispose(),o.palmLandmarks.dispose(),s.push(Pq.scaleBoxCoordinates({startPoint:l,endPoint:u,palmLandmarks:h,confidence:o.confidence},[r/t.inputSize,e/t.inputSize]))}return s}}LS.HandDetector=Mq}),CS=we(Hq=>{Di(Hq,{buildRotationMatrix:()=>qq,computeRotation:()=>Vq,dot:()=>Ra,getColumnFrom2DArr:()=>NS,invertTransformMatrix:()=>Gq,normalizeRadians:()=>AS,rotatePoint:()=>Yq});function AS(n){return n-2*Math.PI*Math.floor((n+Math.PI)/(2*Math.PI))}function Vq(n,t){const e=Math.PI/2-Math.atan2(-(t[1]-n[1]),t[0]-n[0]);return AS(e)}const TS=(n,t)=>[[1,0,n],[0,1,t],[0,0,1]];function Ra(n,t){let e=0;for(let r=0;r{const OS=zt(),pn=_f(),Kr=CS(),jq=[0,-.4],Kq=3,ES=[0,-.1],DS=1.65,kS=[0,5,9,13,17,1,2],$q=0,Xq=2;class Jq{constructor(n,t,e){this.boxDetector=n,this.meshDetector=t,this.inputSize=e,this.storedBoxes=[],this.skipped=0,this.detectedHands=0}getBoxForPalmLandmarks(n,t){const e=n.map(i=>{const a=[...i,1];return Kr.rotatePoint(a,t)}),r=this.calculateLandmarksBoundingBox(e);return pn.enlargeBox(pn.squarifyBox(pn.shiftBox(r,jq)),Kq)}getBoxForHandLandmarks(n){const t=this.calculateLandmarksBoundingBox(n),e=pn.enlargeBox(pn.squarifyBox(pn.shiftBox(t,ES)),DS),r=[];for(let i=0;i[a[0]*(d[0]-this.inputSize/2),a[1]*(d[1]-this.inputSize/2),d[2]]),o=Kr.buildRotationMatrix(e,[0,0]),c=s.map(d=>{const p=Kr.rotatePoint(d,o);return[...p,d[2]]}),l=Kr.invertTransformMatrix(r),u=[...pn.getBoxCenter(t),1],h=[Kr.dot(u,l[0]),Kr.dot(u,l[1])];return c.map(d=>[d[0]+h[0],d[1]+h[1],d[2]])}async estimateHands(n,t){this.skipped++;let e=!1,r;if((this.skipped>t.skipFrames||!t.landmarks)&&(r=await this.boxDetector.estimateHandBounds(n,t),this.skipped=0),r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==t.maxHands||!t.landmarks)){this.storedBoxes=[],this.detectedHands=0;for(const a of r)this.storedBoxes.push(a);this.storedBoxes.length>0&&(e=!0)}const i=[];for(const a in this.storedBoxes){const s=this.storedBoxes[a];if(!s)continue;if(t.landmarks){const o=Kr.computeRotation(s.palmLandmarks[$q],s.palmLandmarks[Xq]),c=pn.getBoxCenter(s),l=[c[0]/n.shape[2],c[1]/n.shape[1]],u=OS.image.rotateWithOffset(n,o,0,l),h=Kr.buildRotationMatrix(-o,c),d=e?this.getBoxForPalmLandmarks(s.palmLandmarks,h):s,p=pn.cutBoxFromImageAndResize(d,u,[this.inputSize,this.inputSize]),f=p.div(255);p.dispose(),u.dispose();const[m,g]=await this.meshDetector.predict(f);f.dispose();const y=m.dataSync()[0];if(m.dispose(),y>=t.minConfidence){const w=OS.reshape(g,[-1,3]),b=w.arraySync();g.dispose(),w.dispose();const S=this.transformRawCoords(b,d,o,h),x=this.getBoxForHandLandmarks(S);this.storedBoxes[a]=x;const N={landmarks:S,confidence:y,box:{topLeft:x.startPoint,bottomRight:x.endPoint}};i.push(N)}else this.storedBoxes[a]=null;g.dispose()}else{const o=pn.enlargeBox(pn.squarifyBox(pn.shiftBox(s,ES)),DS),c={confidence:s.confidence,box:{topLeft:o.startPoint,bottomRight:o.endPoint}};i.push(c)}}return this.storedBoxes=this.storedBoxes.filter(a=>a!==null),this.detectedHands=i.length,i}calculateLandmarksBoundingBox(n){const t=n.map(a=>a[0]),e=n.map(a=>a[1]),r=[Math.min(...t),Math.min(...e)],i=[Math.max(...t),Math.max(...e)];return{startPoint:r,endPoint:i}}}RS.HandPipeline=Jq}),US=we(WS=>{WS.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}]}),PS=we(Cf=>{const BS=zt(),Zq=IS(),Qq=FS(),eG=US(),Rf={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 zS{constructor(n){this.pipeline=n}static getAnnotations(){return Rf}async estimateHands(n,t){const e=await this.pipeline.estimateHands(n,t);if(!e)return[];const r=[];for(const i of e){const a={};if(i.landmarks)for(const s of Object.keys(Rf))a[s]=Rf[s].map(o=>i.landmarks[o]);r.push({confidence:i.confidence,box:i.box?[i.box.topLeft[0],i.box.topLeft[1],i.box.bottomRight[0]-i.box.topLeft[0],i.box.bottomRight[1]-i.box.topLeft[1]]:0,landmarks:i.landmarks,annotations:a})}return r}}Cf.HandPose=zS;async function tG(n){const[t,e]=await Promise.all([BS.loadGraphModel(n.detector.modelPath,{fromTFHub:n.detector.modelPath.includes("tfhub.dev")}),BS.loadGraphModel(n.skeleton.modelPath,{fromTFHub:n.skeleton.modelPath.includes("tfhub.dev")})]),r=new Zq.HandDetector(t,n.inputSize,eG.anchors),i=new Qq.HandPipeline(r,e,n.inputSize),a=new zS(i);return console.log(`Human: load model: ${n.detector.modelPath.match(/\/(.*)\./)[1]}`),console.log(`Human: load model: ${n.skeleton.modelPath.match(/\/(.*)\./)[1]}`),a}Cf.load=tG}),MS=we(Fc=>{Fc.body=n=>{if(!n)return[];const t=[];for(const e of n){const r=e.keypoints.find(c=>c.part==="leftWrist"),i=e.keypoints.find(c=>c.part==="rightWrist"),a=e.keypoints.find(c=>c.part==="nose");a&&r&&i&&r.position.yc.part==="leftShoulder"),o=e.keypoints.find(c=>c.part==="rightShoulder");s&&o&&t.push(`leaning ${s.position.y>o.position.y?"left":"right"}`)}return t};Fc.face=n=>{if(!n)return[];const t=[];for(const e of n){e.annotations.rightCheek&&e.annotations.leftCheek&&e.annotations.rightCheek.length>0&&e.annotations.leftCheek.length>0&&t.push(`facing ${e.annotations.rightCheek[0][2]>0||e.annotations.leftCheek[0][2]<0?"right":"left"}`);const r=Math.abs(e.mesh[374][1]-e.mesh[386][1])/Math.abs(e.mesh[443][1]-e.mesh[450][1]);r<.2&&t.push("blink left eye");const i=Math.abs(e.mesh[145][1]-e.mesh[159][1])/Math.abs(e.mesh[223][1]-e.mesh[230][1]);i<.2&&t.push("blink right eye")}return t};Fc.hand=n=>{if(!n)return[];const t=[];for(const e of n){const r=[];for(const[i,a]of Object.entries(e.annotations))i!=="palmBase"&&r.push({name:i.toLowerCase(),position:a[0]});if(r&&r.length>0){const i=r.reduce((s,o)=>s.position[2]s.position[1]{const nG=function(n,t,e){const r=function(o,c,l){const u=new RegExp("\\b"+c+" \\w+ (\\w+)","ig");o.replace(u,(h,d)=>(l[d]=0,h))},i=function(o,c){const l=n.createShader(c);if(n.shaderSource(l,o),n.compileShader(l),!n.getShaderParameter(l,n.COMPILE_STATUS))throw new Error("Filter: GL compile failed",n.getShaderInfoLog(l));return l};this.uniform={},this.attribute={};const a=i(t,n.VERTEX_SHADER),s=i(e,n.FRAGMENT_SHADER);if(this.id=n.createProgram(),n.attachShader(this.id,a),n.attachShader(this.id,s),n.linkProgram(this.id),!n.getProgramParameter(this.id,n.LINK_STATUS))throw new Error("Filter: GL link failed",n.getProgramInfoLog(this.id));n.useProgram(this.id),r(t,"attribute",this.attribute);for(const o in this.attribute)this.attribute[o]=n.getAttribLocation(this.id,o);r(t,"uniform",this.uniform),r(e,"uniform",this.uniform);for(const o in this.uniform)this.uniform[o]=n.getUniformLocation(this.id,o)},rG=function(n){n||(n={});let t=0,e=null,r=!1,i=-1,a=[null,null],s=[],o=-1,c=-1,l=null,u=null;const h=n.canvas||document.createElement("canvas"),d={},p=h.getContext("webgl");if(!p)throw new Error("Filter: getContext() failed");this.addFilter=function(N){const I=Array.prototype.slice.call(arguments,1),C=x[N];s.push({func:C,args:I})},this.reset=function(){s=[]},this.apply=function(N){if(f(N.width,N.height),t=0,e||(e=p.createTexture()),p.bindTexture(p.TEXTURE_2D,e),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,N),s.length===0)return y(),h;for(let I=0;I{const Ms=zt(),iG=VS();let wt=null,$t=null;function aG(n,t){let e;if(n instanceof Ms.Tensor)e=Ms.clone(n);else{const r=n.naturalWidth||n.videoWidth||n.width||n.shape&&n.shape[1]>0,i=n.naturalHeight||n.videoHeight||n.height||n.shape&&n.shape[2]>0;let a=r,s=i;t.filter.width>0?a=t.filter.width:t.filter.height>0&&(a=r*(t.filter.height/i)),t.filter.height>0?s=t.filter.height:t.filter.width>0&&(s=i*(t.filter.width/r)),(!wt||wt.width!==a||wt.height!==s)&&(wt=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(a,s):document.createElement("canvas"),wt.width!==a&&(wt.width=a),wt.height!==s&&(wt.height=s));const o=wt.getContext("2d");n instanceof ImageData?o.putImageData(n,0,0):o.drawImage(n,0,0,r,i,0,0,wt.width,wt.height),t.filter.enabled&&((!this.fx||!$t||wt.width!==$t.width||wt.height!==$t.height)&&($t=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(wt.width,wt.height):document.createElement("canvas"),$t.width!==wt.width&&($t.width=wt.width),$t.height!==wt.height&&($t.height=wt.height),this.fx=Ms.ENV.flags.IS_BROWSER?new iG.Canvas({canvas:$t}):null),this.fx.reset(),this.fx.addFilter("brightness",t.filter.brightness),t.filter.contrast!==0&&this.fx.addFilter("contrast",t.filter.contrast),t.filter.sharpness!==0&&this.fx.addFilter("sharpen",t.filter.sharpness),t.filter.blur!==0&&this.fx.addFilter("blur",t.filter.blur),t.filter.saturation!==0&&this.fx.addFilter("saturation",t.filter.saturation),t.filter.hue!==0&&this.fx.addFilter("hue",t.filter.hue),t.filter.negative&&this.fx.addFilter("negative"),t.filter.sepia&&this.fx.addFilter("sepia"),t.filter.vintage&&this.fx.addFilter("brownie"),t.filter.sepia&&this.fx.addFilter("sepia"),t.filter.kodachrome&&this.fx.addFilter("kodachrome"),t.filter.technicolor&&this.fx.addFilter("technicolor"),t.filter.polaroid&&this.fx.addFilter("polaroid"),t.filter.pixelate!==0&&this.fx.addFilter("pixelate",t.filter.pixelate),this.fx.apply(wt)),$t||($t=wt);let c;if(t.backend==="webgl"||$t instanceof ImageData)c=Ms.browser.fromPixels($t);else{const u=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(a,s):document.createElement("canvas");u.width=a,u.height=s;const h=u.getContext("2d");h.drawImage($t,0,0);const d=h.getImageData(0,0,a,s);c=Ms.browser.fromPixels(d)}const l=c.toFloat();e=l.expandDims(0),c.dispose(),l.dispose()}return{tensor:e,canvas:t.filter.return?$t:null}}qS.process=aG}),YS=we(sG=>{Di(sG,{default:()=>oG});var oG={backend:"webgl",console:!0,async:!0,profile:!1,deallocate:!1,scoped:!1,videoOptimized:!0,filter:{enabled:!0,width:0,height:0,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"../models/blazeface-back.json",inputSize:256,maxFaces:10,skipFrames:15,minConfidence:.1,iouThreshold:.1,scoreThreshold:.2},mesh:{enabled:!0,modelPath:"../models/facemesh.json",inputSize:192},iris:{enabled:!0,modelPath:"../models/iris.json",inputSize:64},age:{enabled:!0,modelPath:"../models/age-ssrnet-imdb.json",inputSize:64,skipFrames:15},gender:{enabled:!0,minConfidence:.1,modelPath:"../models/gender-ssrnet-imdb.json",inputSize:64,skipFrames:15},emotion:{enabled:!0,inputSize:64,minConfidence:.2,skipFrames:15,modelPath:"../models/emotion-large.json"}},body:{enabled:!0,modelPath:"../models/posenet.json",inputSize:257,maxDetections:10,scoreThreshold:.8,nmsRadius:20},hand:{enabled:!0,inputSize:256,skipFrames:15,minConfidence:.5,iouThreshold:.1,scoreThreshold:.8,maxHands:1,landmarks:!0,detector:{modelPath:"../models/handdetect.json"},skeleton:{modelPath:"../models/handskeleton.json"}}}}),KS=we((sY,jS)=>{jS.exports={name:"@vladmandic/human",version:"0.8.3",description:"human: 3D Face Detection, Body Pose, Hand & Finger Tracking, Iris Tracking, Age & Gender Prediction, Emotion Prediction & Gesture Recognition",sideEffects:!1,main:"dist/human.node.js",module:"dist/human.esm.js",browser:"dist/human.esm.js",author:"Vladimir Mandic ",bugs:{url:"https://github.com/vladmandic/human/issues"},homepage:"https://github.com/vladmandic/human#readme",license:"MIT",engines:{node:">=14.0.0"},repository:{type:"git",url:"git+https://github.com/vladmandic/human.git"},dependencies:{},peerDependencies:{},devDependencies:{"@tensorflow/tfjs":"^2.7.0","@tensorflow/tfjs-node":"^2.7.0","@vladmandic/pilogger":"^0.2.7",chokidar:"^3.4.3",dayjs:"^1.9.5",esbuild:"^0.7.22",eslint:"^7.13.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.2","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.2.1",rimraf:"^3.0.2",seedrandom:"^3.0.5","simple-git":"^2.21.0"},scripts:{start:"node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",lint:"eslint src/*.js demo/*.js",dev:"npm install && node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation dev-server/dev-server.js",changelog:"node dev-server/changelog.js","build-iife":"esbuild --bundle --minify --platform=browser --sourcemap --target=es2018 --format=iife --external:fs --global-name=Human --metafile=dist/human.json --outfile=dist/human.js src/human.js","build-esm-bundle":"esbuild --bundle --minify --platform=browser --sourcemap --target=es2018 --format=esm --external:fs --metafile=dist/human.esm.json --outfile=dist/human.esm.js src/human.js","build-esm-nobundle":"esbuild --bundle --minify --platform=browser --sourcemap --target=es2018 --format=esm --external:@tensorflow --external:fs --metafile=dist/human.esm-nobundle.json --outfile=dist/human.esm-nobundle.js src/human.js","build-node":"esbuild --bundle --minify --platform=node --sourcemap --target=es2018 --format=cjs --metafile=dist/human.node.json --outfile=dist/human.node.js src/human.js","build-node-nobundle":"esbuild --bundle --minify --platform=node --sourcemap --target=es2018 --format=cjs --external:@tensorflow --metafile=dist/human.node.json --outfile=dist/human.node-nobundle.js src/human.js","build-demo":"esbuild --bundle --log-level=error --platform=browser --sourcemap --target=es2018 --format=esm --external:fs --metafile=dist/demo-browser-index.json --outfile=dist/demo-browser-index.js demo/browser.js",build:"rimraf dist/* && npm run build-iife && npm run build-esm-bundle && npm run build-esm-nobundle && npm run build-node && npm run build-node-nobundle && npm run build-demo && npm run changelog",update:"npm update --depth 20 --force && npm dedupe && npm prune && npm audit"},keywords:["tensorflowjs","face-detection","face-geometry","body-tracking","hand-tracking","iris-tracking","age-estimation","emotion-detection","gender-prediction","gesture-recognition"]}});Di(exports,{default:()=>pG});const Xt=zt(),Of=Yx(),Hs=Kx(),Vs=$x(),qs=Jx(),Ef=SS(),Df=PS(),kf=MS(),cG=GS(),lG=ks(),uG=YS().default,hG=KS(),dG={face:{detector:{skipFrames:0},age:{skipFrames:0},gender:{skipFrames:0},emotion:{skipFrames:0}},hand:{skipFrames:0}},ut=()=>typeof performance!="undefined"?performance.now():parseInt(Number(process.hrtime.bigint())/1e3/1e3);function Gs(...n){const t=e=>e&&typeof e=="object";return n.reduce((e,r)=>(Object.keys(r||{}).forEach(i=>{const a=e[i],s=r[i];Array.isArray(a)&&Array.isArray(s)?e[i]=a.concat(...s):t(a)&&t(s)?e[i]=Gs(a,s):e[i]=s}),e),{})}class pG{constructor(n={}){this.tf=Xt,this.version=hG.version,this.config=Gs(uG,n),this.fx=null,this.state="idle",this.numTensors=0,this.analyzeMemoryLeaks=!1,this.checkSanity=!1,this.firstRun=!0,this.perf={},this.models={facemesh:null,posenet:null,handpose:null,iris:null,age:null,gender:null,emotion:null},this.facemesh=Of,this.age=Hs,this.gender=Vs,this.emotion=qs,this.body=Ef,this.hand=Df}log(...n){n&&this.config.console&&console.log("Human:",...n)}profile(){return this.config.profile?lG.data:{}}analyze(...n){if(!this.analyzeMemoryLeaks)return;const t=Xt.engine().state.numTensors,e=this.numTensors;this.numTensors=t;const r=t-e;r!==0&&this.log(...n,r)}sanity(n){if(!this.checkSanity)return null;if(!n)return"input is not defined";if(Xt.ENV.flags.IS_NODE&&!(n instanceof Xt.Tensor))return"input must be a tensor";try{Xt.getBackend()}catch(t){return"backend not loaded"}return null}async load(n){this.state="load";const t=ut();n&&(this.config=Gs(this.config,n)),this.firstRun&&(this.checkBackend(!0),this.log(`version: ${this.version} TensorFlow/JS version: ${Xt.version_core}`),this.log("configuration:",this.config),this.log("flags:",Xt.ENV.flags),this.firstRun=!1),this.config.async?[this.models.age,this.models.gender,this.models.emotion,this.models.facemesh,this.models.posenet,this.models.handpose]=await Promise.all([this.models.age||Hs.load(this.config),this.models.gender||Vs.load(this.config),this.models.emotion||qs.load(this.config),this.models.facemesh||Of.load(this.config.face),this.models.posenet||Ef.load(this.config),this.models.handpose||Df.load(this.config.hand)]):(this.config.face.enabled&&!this.models.facemesh&&(this.models.facemesh=await Of.load(this.config.face)),this.config.body.enabled&&!this.models.posenet&&(this.models.posenet=await Ef.load(this.config)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await Df.load(this.config.hand)),this.config.face.enabled&&this.config.face.age.enabled&&!this.models.age&&(this.models.age=await Hs.load(this.config)),this.config.face.enabled&&this.config.face.gender.enabled&&!this.models.gender&&(this.models.gender=await Vs.load(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await qs.load(this.config)));const e=Math.trunc(ut()-t);e>(this.perf.load||0)&&(this.perf.load=e)}async checkBackend(n){const t=ut();(this.config.backend&&this.config.backend!==""&&n||Xt.getBackend()!==this.config.backend)&&(this.state="backend",this.log("setting backend:",this.config.backend),await Xt.setBackend(this.config.backend),Xt.enableProdMode(),this.config.backend==="webgl"&&(this.config.deallocate&&(this.log("Changing WebGL: WEBGL_DELETE_TEXTURE_THRESHOLD:",this.config.deallocate),Xt.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",this.config.deallocate?0:-1)),Xt.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0)),await Xt.ready());const e=Math.trunc(ut()-t);e>(this.perf.backend||0)&&(this.perf.backend=e)}async detectFace(n){let t,e,r,i;const a=[];this.state="run:face",t=ut();const s=await this.models.facemesh.estimateFaces(n,this.config.face);this.perf.face=Math.trunc(ut()-t);for(const o of s){if(this.analyze("Get Face"),!o.image||o.image.isDisposedInternal){this.log("Face object is disposed:",o.image);continue}this.analyze("Start Age:"),this.config.async?e=this.config.face.age.enabled?Hs.predict(o.image,this.config):{}:(this.state="run:age",t=ut(),e=this.config.face.age.enabled?await Hs.predict(o.image,this.config):{},this.perf.age=Math.trunc(ut()-t)),this.analyze("Start Gender:"),this.config.async?r=this.config.face.gender.enabled?Vs.predict(o.image,this.config):{}:(this.state="run:gender",t=ut(),r=this.config.face.gender.enabled?await Vs.predict(o.image,this.config):{},this.perf.gender=Math.trunc(ut()-t)),this.analyze("Start Emotion:"),this.config.async?i=this.config.face.emotion.enabled?qs.predict(o.image,this.config):{}:(this.state="run:emotion",t=ut(),i=this.config.face.emotion.enabled?await qs.predict(o.image,this.config):{},this.perf.emotion=Math.trunc(ut()-t)),this.analyze("End Emotion:"),this.config.async&&([e,r,i]=await Promise.all([e,r,i])),this.analyze("Finish Face:"),o.image.dispose();const c=o.annotations.leftEyeIris&&o.annotations.rightEyeIris?11.7*Math.max(Math.abs(o.annotations.leftEyeIris[3][0]-o.annotations.leftEyeIris[1][0]),Math.abs(o.annotations.rightEyeIris[4][1]-o.annotations.rightEyeIris[2][1])):0;a.push({confidence:o.confidence,box:o.box,mesh:o.mesh,annotations:o.annotations,age:e.age,gender:r.gender,genderConfidence:r.confidence,emotion:i,iris:c!==0?Math.trunc(c)/100:0}),this.analyze("End Face")}return this.analyze("End FaceMesh:"),this.config.async&&(this.perf.face&&delete this.perf.face,this.perf.age&&delete this.perf.age,this.perf.gender&&delete this.perf.gender,this.perf.emotion&&delete this.perf.emotion),a}async detect(n,t={}){this.state="config";let e;this.config=Gs(this.config,t),this.config.videoOptimized||(this.config=Gs(this.config,dG)),this.state="check";const r=this.sanity(n);return r?(this.log(r,n),{error:r}):new Promise(async i=>{let a,s,o;const c=ut();await this.checkBackend(),await this.load(),this.config.scoped&&Xt.engine().startScope(),this.analyze("Start Scope:"),e=ut();const l=cG.process(n,this.config);this.perf.image=Math.trunc(ut()-e),this.analyze("Get Image:"),this.config.async?(o=this.config.face.enabled?this.detectFace(l.tensor):[],this.perf.face&&delete this.perf.face):(this.state="run:face",e=ut(),o=this.config.face.enabled?await this.detectFace(l.tensor):[],this.perf.face=Math.trunc(ut()-e)),this.analyze("Start Body:"),this.config.async?(a=this.config.body.enabled?this.models.posenet.estimatePoses(l.tensor,this.config):[],this.perf.body&&delete this.perf.body):(this.state="run:body",e=ut(),a=this.config.body.enabled?await this.models.posenet.estimatePoses(l.tensor,this.config):[],this.perf.body=Math.trunc(ut()-e)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(s=this.config.hand.enabled?this.models.handpose.estimateHands(l.tensor,this.config.hand):[],this.perf.hand&&delete this.perf.hand):(this.state="run:hand",e=ut(),s=this.config.hand.enabled?await this.models.handpose.estimateHands(l.tensor,this.config.hand):[],this.perf.hand=Math.trunc(ut()-e)),this.config.async&&([o,a,s]=await Promise.all([o,a,s])),l.tensor.dispose(),this.config.scoped&&Xt.engine().endScope(),this.analyze("End Scope:");let u=[];this.config.gesture.enabled&&(e=ut(),u={body:kf.body(a),hand:kf.hand(s),face:kf.face(o)},this.config.async?this.perf.gesture&&delete this.perf.gesture:this.perf.gesture=Math.trunc(ut()-e)),this.perf.total=Math.trunc(ut()-c),this.state="idle",i({face:o,body:a,hand:s,gesture:u,performance:this.perf,canvas:l.canvas})})}} /*! ***************************************************************************** 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=human.node.js.map