Files
mixio/js/tf.min.js
2024-08-22 15:43:01 +08:00

18 lines
1023 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @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.
* =============================================================================
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).tf=t.tf||{})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(t,e){return t(e={exports:{}},e.exports),e.exports}var r=function(t){return t&&t.Math==Math&&t},a=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof e&&e)||Function("return this")(),i=function(t){try{return!!t()}catch(t){return!0}},o=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),s={}.propertyIsEnumerable,u=Object.getOwnPropertyDescriptor,c={f:u&&!s.call({1:2},1)?function(t){var e=u(this,t);return!!e&&e.enumerable}:s},l=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},h={}.toString,f=function(t){return h.call(t).slice(8,-1)},p="".split,d=i((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==f(t)?p.call(t,""):Object(t)}:Object,m=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},v=function(t){return d(m(t))},g=function(t){return"object"==typeof t?null!==t:"function"==typeof t},y=function(t,e){if(!g(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!g(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!g(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!g(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},b={}.hasOwnProperty,x=function(t,e){return b.call(t,e)},w=a.document,k=g(w)&&g(w.createElement),S=function(t){return k?w.createElement(t):{}},C=!o&&!i((function(){return 7!=Object.defineProperty(S("div"),"a",{get:function(){return 7}}).a})),R=Object.getOwnPropertyDescriptor,N={f:o?R:function(t,e){if(t=v(t),e=y(e,!0),C)try{return R(t,e)}catch(t){}if(x(t,e))return l(!c.f.call(t,e),t[e])}},E=function(t){if(!g(t))throw TypeError(String(t)+" is not an object");return t},I=Object.defineProperty,A={f:o?I:function(t,e,n){if(E(t),e=y(e,!0),E(n),C)try{return I(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},T=o?function(t,e,n){return A.f(t,e,l(1,n))}:function(t,e,n){return t[e]=n,t},D=function(t,e){try{T(a,t,e)}catch(n){a[t]=e}return e},_=a["__core-js_shared__"]||D("__core-js_shared__",{}),O=Function.toString;"function"!=typeof _.inspectSource&&(_.inspectSource=function(t){return O.call(t)});var F,M,L,z=_.inspectSource,B=a.WeakMap,P="function"==typeof B&&/native code/.test(z(B)),W=n((function(t){(t.exports=function(t,e){return _[t]||(_[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),V=0,U=Math.random(),j=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++V+U).toString(36)},G=W("keys"),q=function(t){return G[t]||(G[t]=j(t))},H={},K=a.WeakMap;if(P){var X=new K,Y=X.get,J=X.has,$=X.set;F=function(t,e){return $.call(X,t,e),e},M=function(t){return Y.call(X,t)||{}},L=function(t){return J.call(X,t)}}else{var Z=q("state");H[Z]=!0,F=function(t,e){return T(t,Z,e),e},M=function(t){return x(t,Z)?t[Z]:{}},L=function(t){return x(t,Z)}}var Q,tt={set:F,get:M,has:L,enforce:function(t){return L(t)?M(t):F(t,{})},getterFor:function(t){return function(e){var n;if(!g(e)||(n=M(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},et=n((function(t){var e=tt.get,n=tt.enforce,r=String(String).split("String");(t.exports=function(t,e,i,o){var s=!!o&&!!o.unsafe,u=!!o&&!!o.enumerable,c=!!o&&!!o.noTargetGet;"function"==typeof i&&("string"!=typeof e||x(i,"name")||T(i,"name",e),n(i).source=r.join("string"==typeof e?e:"")),t!==a?(s?!c&&t[e]&&(u=!0):delete t[e],u?t[e]=i:T(t,e,i)):u?t[e]=i:D(e,i)})(Function.prototype,"toString",(function(){return"function"==typeof this&&e(this).source||z(this)}))})),nt=a,rt=function(t){return"function"==typeof t?t:void 0},at=function(t,e){return arguments.length<2?rt(nt[t])||rt(a[t]):nt[t]&&nt[t][e]||a[t]&&a[t][e]},it=Math.ceil,ot=Math.floor,st=function(t){return isNaN(t=+t)?0:(t>0?ot:it)(t)},ut=Math.min,ct=function(t){return t>0?ut(st(t),9007199254740991):0},lt=Math.max,ht=Math.min,ft=function(t,e){var n=st(t);return n<0?lt(n+e,0):ht(n,e)},pt=function(t){return function(e,n,r){var a,i=v(e),o=ct(i.length),s=ft(r,o);if(t&&n!=n){for(;o>s;)if((a=i[s++])!=a)return!0}else for(;o>s;s++)if((t||s in i)&&i[s]===n)return t||s||0;return!t&&-1}},dt={includes:pt(!0),indexOf:pt(!1)},mt=dt.indexOf,vt=function(t,e){var n,r=v(t),a=0,i=[];for(n in r)!x(H,n)&&x(r,n)&&i.push(n);for(;e.length>a;)x(r,n=e[a++])&&(~mt(i,n)||i.push(n));return i},gt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],yt=gt.concat("length","prototype"),bt={f:Object.getOwnPropertyNames||function(t){return vt(t,yt)}},xt={f:Object.getOwnPropertySymbols},wt=at("Reflect","ownKeys")||function(t){var e=bt.f(E(t)),n=xt.f;return n?e.concat(n(t)):e},kt=function(t,e){for(var n=wt(e),r=A.f,a=N.f,i=0;i<n.length;i++){var o=n[i];x(t,o)||r(t,o,a(e,o))}},St=/#|\.prototype\./,Ct=function(t,e){var n=Nt[Rt(t)];return n==It||n!=Et&&("function"==typeof e?i(e):!!e)},Rt=Ct.normalize=function(t){return String(t).replace(St,".").toLowerCase()},Nt=Ct.data={},Et=Ct.NATIVE="N",It=Ct.POLYFILL="P",At=Ct,Tt=N.f,Dt=function(t,e){var n,r,i,o,s,u=t.target,c=t.global,l=t.stat;if(n=c?a:l?a[u]||D(u,{}):(a[u]||{}).prototype)for(r in e){if(o=e[r],i=t.noTargetGet?(s=Tt(n,r))&&s.value:n[r],!At(c?r:u+(l?".":"#")+r,t.forced)&&void 0!==i){if(typeof o==typeof i)continue;kt(o,i)}(t.sham||i&&i.sham)&&T(o,"sham",!0),et(n,r,o,t)}},_t=!!Object.getOwnPropertySymbols&&!i((function(){return!String(Symbol())})),Ot=_t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ft=Array.isArray||function(t){return"Array"==f(t)},Mt=function(t){return Object(m(t))},Lt=Object.keys||function(t){return vt(t,gt)},zt=o?Object.defineProperties:function(t,e){E(t);for(var n,r=Lt(e),a=r.length,i=0;a>i;)A.f(t,n=r[i++],e[n]);return t},Bt=at("document","documentElement"),Pt=q("IE_PROTO"),Wt=function(){},Vt=function(t){return"<script>"+t+"<\/script>"},Ut=function(){try{Q=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;Ut=Q?function(t){t.write(Vt("")),t.close();var e=t.parentWindow.Object;return t=null,e}(Q):((e=S("iframe")).style.display="none",Bt.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(Vt("document.F=Object")),t.close(),t.F);for(var n=gt.length;n--;)delete Ut.prototype[gt[n]];return Ut()};H[Pt]=!0;var jt=Object.create||function(t,e){var n;return null!==t?(Wt.prototype=E(t),n=new Wt,Wt.prototype=null,n[Pt]=t):n=Ut(),void 0===e?n:zt(n,e)},Gt=bt.f,qt={}.toString,Ht="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Kt={f:function(t){return Ht&&"[object Window]"==qt.call(t)?function(t){try{return Gt(t)}catch(t){return Ht.slice()}}(t):Gt(v(t))}},Xt=W("wks"),Yt=a.Symbol,Jt=Ot?Yt:Yt&&Yt.withoutSetter||j,$t=function(t){return x(Xt,t)||(_t&&x(Yt,t)?Xt[t]=Yt[t]:Xt[t]=Jt("Symbol."+t)),Xt[t]},Zt={f:$t},Qt=A.f,te=function(t){var e=nt.Symbol||(nt.Symbol={});x(e,t)||Qt(e,t,{value:Zt.f(t)})},ee=A.f,ne=$t("toStringTag"),re=function(t,e,n){t&&!x(t=n?t:t.prototype,ne)&&ee(t,ne,{configurable:!0,value:e})},ae=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},ie=function(t,e,n){if(ae(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,a){return t.call(e,n,r,a)}}return function(){return t.apply(e,arguments)}},oe=$t("species"),se=function(t,e){var n;return Ft(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!Ft(n.prototype)?g(n)&&null===(n=n[oe])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},ue=[].push,ce=function(t){var e=1==t,n=2==t,r=3==t,a=4==t,i=6==t,o=5==t||i;return function(s,u,c,l){for(var h,f,p=Mt(s),m=d(p),v=ie(u,c,3),g=ct(m.length),y=0,b=l||se,x=e?b(s,g):n?b(s,0):void 0;g>y;y++)if((o||y in m)&&(f=v(h=m[y],y,p),t))if(e)x[y]=f;else if(f)switch(t){case 3:return!0;case 5:return h;case 6:return y;case 2:ue.call(x,h)}else if(a)return!1;return i?-1:r||a?a:x}},le={forEach:ce(0),map:ce(1),filter:ce(2),some:ce(3),every:ce(4),find:ce(5),findIndex:ce(6)},he=le.forEach,fe=q("hidden"),pe=$t("toPrimitive"),de=tt.set,me=tt.getterFor("Symbol"),ve=Object.prototype,ge=a.Symbol,ye=at("JSON","stringify"),be=N.f,xe=A.f,we=Kt.f,ke=c.f,Se=W("symbols"),Ce=W("op-symbols"),Re=W("string-to-symbol-registry"),Ne=W("symbol-to-string-registry"),Ee=W("wks"),Ie=a.QObject,Ae=!Ie||!Ie.prototype||!Ie.prototype.findChild,Te=o&&i((function(){return 7!=jt(xe({},"a",{get:function(){return xe(this,"a",{value:7}).a}})).a}))?function(t,e,n){var r=be(ve,e);r&&delete ve[e],xe(t,e,n),r&&t!==ve&&xe(ve,e,r)}:xe,De=function(t,e){var n=Se[t]=jt(ge.prototype);return de(n,{type:"Symbol",tag:t,description:e}),o||(n.description=e),n},_e=Ot?function(t){return"symbol"==typeof t}:function(t){return Object(t)instanceof ge},Oe=function(t,e,n){t===ve&&Oe(Ce,e,n),E(t);var r=y(e,!0);return E(n),x(Se,r)?(n.enumerable?(x(t,fe)&&t[fe][r]&&(t[fe][r]=!1),n=jt(n,{enumerable:l(0,!1)})):(x(t,fe)||xe(t,fe,l(1,{})),t[fe][r]=!0),Te(t,r,n)):xe(t,r,n)},Fe=function(t,e){E(t);var n=v(e),r=Lt(n).concat(Be(n));return he(r,(function(e){o&&!Me.call(n,e)||Oe(t,e,n[e])})),t},Me=function(t){var e=y(t,!0),n=ke.call(this,e);return!(this===ve&&x(Se,e)&&!x(Ce,e))&&(!(n||!x(this,e)||!x(Se,e)||x(this,fe)&&this[fe][e])||n)},Le=function(t,e){var n=v(t),r=y(e,!0);if(n!==ve||!x(Se,r)||x(Ce,r)){var a=be(n,r);return!a||!x(Se,r)||x(n,fe)&&n[fe][r]||(a.enumerable=!0),a}},ze=function(t){var e=we(v(t)),n=[];return he(e,(function(t){x(Se,t)||x(H,t)||n.push(t)})),n},Be=function(t){var e=t===ve,n=we(e?Ce:v(t)),r=[];return he(n,(function(t){!x(Se,t)||e&&!x(ve,t)||r.push(Se[t])})),r};if(_t||(et((ge=function(){if(this instanceof ge)throw TypeError("Symbol is not a constructor");var t=arguments.length&&void 0!==arguments[0]?String(arguments[0]):void 0,e=j(t),n=function t(n){this===ve&&t.call(Ce,n),x(this,fe)&&x(this[fe],e)&&(this[fe][e]=!1),Te(this,e,l(1,n))};return o&&Ae&&Te(ve,e,{configurable:!0,set:n}),De(e,t)}).prototype,"toString",(function(){return me(this).tag})),et(ge,"withoutSetter",(function(t){return De(j(t),t)})),c.f=Me,A.f=Oe,N.f=Le,bt.f=Kt.f=ze,xt.f=Be,Zt.f=function(t){return De($t(t),t)},o&&(xe(ge.prototype,"description",{configurable:!0,get:function(){return me(this).description}}),et(ve,"propertyIsEnumerable",Me,{unsafe:!0}))),Dt({global:!0,wrap:!0,forced:!_t,sham:!_t},{Symbol:ge}),he(Lt(Ee),(function(t){te(t)})),Dt({target:"Symbol",stat:!0,forced:!_t},{for:function(t){var e=String(t);if(x(Re,e))return Re[e];var n=ge(e);return Re[e]=n,Ne[n]=e,n},keyFor:function(t){if(!_e(t))throw TypeError(t+" is not a symbol");if(x(Ne,t))return Ne[t]},useSetter:function(){Ae=!0},useSimple:function(){Ae=!1}}),Dt({target:"Object",stat:!0,forced:!_t,sham:!o},{create:function(t,e){return void 0===e?jt(t):Fe(jt(t),e)},defineProperty:Oe,defineProperties:Fe,getOwnPropertyDescriptor:Le}),Dt({target:"Object",stat:!0,forced:!_t},{getOwnPropertyNames:ze,getOwnPropertySymbols:Be}),Dt({target:"Object",stat:!0,forced:i((function(){xt.f(1)}))},{getOwnPropertySymbols:function(t){return xt.f(Mt(t))}}),ye){var Pe=!_t||i((function(){var t=ge();return"[null]"!=ye([t])||"{}"!=ye({a:t})||"{}"!=ye(Object(t))}));Dt({target:"JSON",stat:!0,forced:Pe},{stringify:function(t,e,n){for(var r,a=[t],i=1;arguments.length>i;)a.push(arguments[i++]);if(r=e,(g(e)||void 0!==t)&&!_e(t))return Ft(e)||(e=function(t,e){if("function"==typeof r&&(e=r.call(this,t,e)),!_e(e))return e}),a[1]=e,ye.apply(null,a)}})}ge.prototype[pe]||T(ge.prototype,pe,ge.prototype.valueOf),re(ge,"Symbol"),H[fe]=!0,te("asyncIterator");var We=A.f,Ve=a.Symbol;if(o&&"function"==typeof Ve&&(!("description"in Ve.prototype)||void 0!==Ve().description)){var Ue={},je=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),e=this instanceof je?new Ve(t):void 0===t?Ve():Ve(t);return""===t&&(Ue[e]=!0),e};kt(je,Ve);var Ge=je.prototype=Ve.prototype;Ge.constructor=je;var qe=Ge.toString,He="Symbol(test)"==String(Ve("test")),Ke=/^Symbol\((.*)\)[^)]+$/;We(Ge,"description",{configurable:!0,get:function(){var t=g(this)?this.valueOf():this,e=qe.call(t);if(x(Ue,t))return"";var n=He?e.slice(7,-1):e.replace(Ke,"$1");return""===n?void 0:n}}),Dt({global:!0,forced:!0},{Symbol:je})}te("hasInstance"),te("isConcatSpreadable"),te("iterator"),te("match"),te("matchAll"),te("replace"),te("search"),te("species"),te("split"),te("toPrimitive"),te("toStringTag"),te("unscopables");var Xe=Object.assign,Ye=Object.defineProperty,Je=!Xe||i((function(){if(o&&1!==Xe({b:1},Xe(Ye({},"a",{enumerable:!0,get:function(){Ye(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol();return t[n]=7,"abcdefghijklmnopqrst".split("").forEach((function(t){e[t]=t})),7!=Xe({},t)[n]||"abcdefghijklmnopqrst"!=Lt(Xe({},e)).join("")}))?function(t,e){for(var n=Mt(t),r=arguments.length,a=1,i=xt.f,s=c.f;r>a;)for(var u,l=d(arguments[a++]),h=i?Lt(l).concat(i(l)):Lt(l),f=h.length,p=0;f>p;)u=h[p++],o&&!s.call(l,u)||(n[u]=l[u]);return n}:Xe;Dt({target:"Object",stat:!0,forced:Object.assign!==Je},{assign:Je}),Dt({target:"Object",stat:!0,sham:!o},{create:jt}),Dt({target:"Object",stat:!0,forced:!o,sham:!o},{defineProperty:A.f}),Dt({target:"Object",stat:!0,forced:!o,sham:!o},{defineProperties:zt});var $e=c.f,Ze=function(t){return function(e){for(var n,r=v(e),a=Lt(r),i=a.length,s=0,u=[];i>s;)n=a[s++],o&&!$e.call(r,n)||u.push(t?[n,r[n]]:r[n]);return u}},Qe={entries:Ze(!0),values:Ze(!1)},tn=Qe.entries;Dt({target:"Object",stat:!0},{entries:function(t){return tn(t)}});var en=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),nn=n((function(t){var e=A.f,n=j("meta"),r=0,a=Object.isExtensible||function(){return!0},i=function(t){e(t,n,{value:{objectID:"O"+ ++r,weakData:{}}})},o=t.exports={REQUIRED:!1,fastKey:function(t,e){if(!g(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!x(t,n)){if(!a(t))return"F";if(!e)return"E";i(t)}return t[n].objectID},getWeakData:function(t,e){if(!x(t,n)){if(!a(t))return!0;if(!e)return!1;i(t)}return t[n].weakData},onFreeze:function(t){return en&&o.REQUIRED&&a(t)&&!x(t,n)&&i(t),t}};H[n]=!0})),rn=(nn.REQUIRED,nn.fastKey,nn.getWeakData,nn.onFreeze,nn.onFreeze),an=Object.freeze,on=i((function(){an(1)}));Dt({target:"Object",stat:!0,forced:on,sham:!en},{freeze:function(t){return an&&g(t)?an(rn(t)):t}});var sn={},un=$t("iterator"),cn=Array.prototype,ln=function(t){return void 0!==t&&(sn.Array===t||cn[un]===t)},hn={};hn[$t("toStringTag")]="z";var fn="[object z]"===String(hn),pn=$t("toStringTag"),dn="Arguments"==f(function(){return arguments}()),mn=fn?f:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),pn))?n:dn?f(e):"Object"==(r=f(e))&&"function"==typeof e.callee?"Arguments":r},vn=$t("iterator"),gn=function(t){if(null!=t)return t[vn]||t["@@iterator"]||sn[mn(t)]},yn=function(t,e,n,r){try{return r?e(E(n)[0],n[1]):e(n)}catch(e){var a=t.return;throw void 0!==a&&E(a.call(t)),e}},bn=n((function(t){var e=function(t,e){this.stopped=t,this.result=e};(t.exports=function(t,n,r,a,i){var o,s,u,c,l,h,f,p=ie(n,r,a?2:1);if(i)o=t;else{if("function"!=typeof(s=gn(t)))throw TypeError("Target is not iterable");if(ln(s)){for(u=0,c=ct(t.length);c>u;u++)if((l=a?p(E(f=t[u])[0],f[1]):p(t[u]))&&l instanceof e)return l;return new e(!1)}o=s.call(t)}for(h=o.next;!(f=h.call(o)).done;)if("object"==typeof(l=yn(o,p,f.value,a))&&l&&l instanceof e)return l;return new e(!1)}).stop=function(t){return new e(!0,t)}})),xn=function(t,e,n){var r=y(e);r in t?A.f(t,r,l(0,n)):t[r]=n};Dt({target:"Object",stat:!0},{fromEntries:function(t){var e={};return bn(t,(function(t,n){xn(e,t,n)}),void 0,!0),e}});var wn=N.f,kn=i((function(){wn(1)}));Dt({target:"Object",stat:!0,forced:!o||kn,sham:!o},{getOwnPropertyDescriptor:function(t,e){return wn(v(t),e)}}),Dt({target:"Object",stat:!0,sham:!o},{getOwnPropertyDescriptors:function(t){for(var e,n,r=v(t),a=N.f,i=wt(r),o={},s=0;i.length>s;)void 0!==(n=a(r,e=i[s++]))&&xn(o,e,n);return o}});var Sn=Kt.f,Cn=i((function(){return!Object.getOwnPropertyNames(1)}));Dt({target:"Object",stat:!0,forced:Cn},{getOwnPropertyNames:Sn});var Rn=!i((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),Nn=q("IE_PROTO"),En=Object.prototype,In=Rn?Object.getPrototypeOf:function(t){return t=Mt(t),x(t,Nn)?t[Nn]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?En:null},An=i((function(){In(1)}));Dt({target:"Object",stat:!0,forced:An,sham:!Rn},{getPrototypeOf:function(t){return In(Mt(t))}});var Tn=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e};Dt({target:"Object",stat:!0},{is:Tn});var Dn=Object.isExtensible,_n=i((function(){Dn(1)}));Dt({target:"Object",stat:!0,forced:_n},{isExtensible:function(t){return!!g(t)&&(!Dn||Dn(t))}});var On=Object.isFrozen,Fn=i((function(){On(1)}));Dt({target:"Object",stat:!0,forced:Fn},{isFrozen:function(t){return!g(t)||!!On&&On(t)}});var Mn=Object.isSealed,Ln=i((function(){Mn(1)}));Dt({target:"Object",stat:!0,forced:Ln},{isSealed:function(t){return!g(t)||!!Mn&&Mn(t)}});var zn=i((function(){Lt(1)}));Dt({target:"Object",stat:!0,forced:zn},{keys:function(t){return Lt(Mt(t))}});var Bn=nn.onFreeze,Pn=Object.preventExtensions,Wn=i((function(){Pn(1)}));Dt({target:"Object",stat:!0,forced:Wn,sham:!en},{preventExtensions:function(t){return Pn&&g(t)?Pn(Bn(t)):t}});var Vn=nn.onFreeze,Un=Object.seal,jn=i((function(){Un(1)}));Dt({target:"Object",stat:!0,forced:jn,sham:!en},{seal:function(t){return Un&&g(t)?Un(Vn(t)):t}});var Gn=function(t){if(!g(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype");return t},qn=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return E(n),Gn(r),e?t.call(n,r):n.__proto__=r,n}}():void 0);Dt({target:"Object",stat:!0},{setPrototypeOf:qn});var Hn=Qe.values;Dt({target:"Object",stat:!0},{values:function(t){return Hn(t)}});var Kn=fn?{}.toString:function(){return"[object "+mn(this)+"]"};fn||et(Object.prototype,"toString",Kn,{unsafe:!0});var Xn=!i((function(){var t=Math.random();__defineSetter__.call(null,t,(function(){})),delete a[t]}));o&&Dt({target:"Object",proto:!0,forced:Xn},{__defineGetter__:function(t,e){A.f(Mt(this),t,{get:ae(e),enumerable:!0,configurable:!0})}}),o&&Dt({target:"Object",proto:!0,forced:Xn},{__defineSetter__:function(t,e){A.f(Mt(this),t,{set:ae(e),enumerable:!0,configurable:!0})}});var Yn=N.f;o&&Dt({target:"Object",proto:!0,forced:Xn},{__lookupGetter__:function(t){var e,n=Mt(this),r=y(t,!0);do{if(e=Yn(n,r))return e.get}while(n=In(n))}});var Jn=N.f;o&&Dt({target:"Object",proto:!0,forced:Xn},{__lookupSetter__:function(t){var e,n=Mt(this),r=y(t,!0);do{if(e=Jn(n,r))return e.set}while(n=In(n))}});var $n=[].slice,Zn={},Qn=function(t,e,n){if(!(e in Zn)){for(var r=[],a=0;a<e;a++)r[a]="a["+a+"]";Zn[e]=Function("C,a","return new C("+r.join(",")+")")}return Zn[e](t,n)},tr=Function.bind||function(t){var e=ae(this),n=$n.call(arguments,1),r=function(){var a=n.concat($n.call(arguments));return this instanceof r?Qn(e,a.length,a):e.apply(t,a)};return g(e.prototype)&&(r.prototype=e.prototype),r};Dt({target:"Function",proto:!0},{bind:tr});var er=A.f,nr=Function.prototype,rr=nr.toString,ar=/^\s*function ([^ (]*)/;o&&!("name"in nr)&&er(nr,"name",{configurable:!0,get:function(){try{return rr.call(this).match(ar)[1]}catch(t){return""}}});var ir=$t("hasInstance"),or=Function.prototype;ir in or||A.f(or,ir,{value:function(t){if("function"!=typeof this||!g(t))return!1;if(!g(this.prototype))return t instanceof this;for(;t=In(t);)if(this.prototype===t)return!0;return!1}}),Dt({global:!0},{globalThis:a});var sr=function(t){var e,n,r,a,i,o,s=Mt(t),u="function"==typeof this?this:Array,c=arguments.length,l=c>1?arguments[1]:void 0,h=void 0!==l,f=gn(s),p=0;if(h&&(l=ie(l,c>2?arguments[2]:void 0,2)),null==f||u==Array&&ln(f))for(n=new u(e=ct(s.length));e>p;p++)o=h?l(s[p],p):s[p],xn(n,p,o);else for(i=(a=f.call(s)).next,n=new u;!(r=i.call(a)).done;p++)o=h?yn(a,l,[r.value,p],!0):r.value,xn(n,p,o);return n.length=p,n},ur=$t("iterator"),cr=!1;try{var lr=0,hr={next:function(){return{done:!!lr++}},return:function(){cr=!0}};hr[ur]=function(){return this},Array.from(hr,(function(){throw 2}))}catch(t){}var fr=function(t,e){if(!e&&!cr)return!1;var n=!1;try{var r={};r[ur]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},pr=!fr((function(t){Array.from(t)}));Dt({target:"Array",stat:!0,forced:pr},{from:sr}),Dt({target:"Array",stat:!0},{isArray:Ft});var dr=i((function(){function t(){}return!(Array.of.call(t)instanceof t)}));Dt({target:"Array",stat:!0,forced:dr},{of:function(){for(var t=0,e=arguments.length,n=new("function"==typeof this?this:Array)(e);e>t;)xn(n,t,arguments[t++]);return n.length=e,n}});var mr,vr,gr=at("navigator","userAgent")||"",yr=a.process,br=yr&&yr.versions,xr=br&&br.v8;xr?vr=(mr=xr.split("."))[0]+mr[1]:gr&&(!(mr=gr.match(/Edge\/(\d+)/))||mr[1]>=74)&&(mr=gr.match(/Chrome\/(\d+)/))&&(vr=mr[1]);var wr=vr&&+vr,kr=$t("species"),Sr=function(t){return wr>=51||!i((function(){var e=[];return(e.constructor={})[kr]=function(){return{foo:1}},1!==e[t](Boolean).foo}))},Cr=$t("isConcatSpreadable"),Rr=wr>=51||!i((function(){var t=[];return t[Cr]=!1,t.concat()[0]!==t})),Nr=Sr("concat"),Er=function(t){if(!g(t))return!1;var e=t[Cr];return void 0!==e?!!e:Ft(t)};Dt({target:"Array",proto:!0,forced:!Rr||!Nr},{concat:function(t){var e,n,r,a,i,o=Mt(this),s=se(o,0),u=0;for(e=-1,r=arguments.length;e<r;e++)if(i=-1===e?o:arguments[e],Er(i)){if(u+(a=ct(i.length))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(n=0;n<a;n++,u++)n in i&&xn(s,u,i[n])}else{if(u>=9007199254740991)throw TypeError("Maximum allowed index exceeded");xn(s,u++,i)}return s.length=u,s}});var Ir=Math.min,Ar=[].copyWithin||function(t,e){var n=Mt(this),r=ct(n.length),a=ft(t,r),i=ft(e,r),o=arguments.length>2?arguments[2]:void 0,s=Ir((void 0===o?r:ft(o,r))-i,r-a),u=1;for(i<a&&a<i+s&&(u=-1,i+=s-1,a+=s-1);s-- >0;)i in n?n[a]=n[i]:delete n[a],a+=u,i+=u;return n},Tr=$t("unscopables"),Dr=Array.prototype;null==Dr[Tr]&&A.f(Dr,Tr,{configurable:!0,value:jt(null)});var _r=function(t){Dr[Tr][t]=!0};Dt({target:"Array",proto:!0},{copyWithin:Ar}),_r("copyWithin");var Or=function(t,e){var n=[][t];return!!n&&i((function(){n.call(null,e||function(){throw 1},1)}))},Fr=Object.defineProperty,Mr={},Lr=function(t){throw t},zr=function(t,e){if(x(Mr,t))return Mr[t];e||(e={});var n=[][t],r=!!x(e,"ACCESSORS")&&e.ACCESSORS,a=x(e,0)?e[0]:Lr,s=x(e,1)?e[1]:void 0;return Mr[t]=!!n&&!i((function(){if(r&&!o)return!0;var t={length:-1};r?Fr(t,1,{enumerable:!0,get:Lr}):t[1]=1,n.call(t,a,s)}))},Br=le.every,Pr=Or("every"),Wr=zr("every");Dt({target:"Array",proto:!0,forced:!Pr||!Wr},{every:function(t){return Br(this,t,arguments.length>1?arguments[1]:void 0)}});var Vr=function(t){for(var e=Mt(this),n=ct(e.length),r=arguments.length,a=ft(r>1?arguments[1]:void 0,n),i=r>2?arguments[2]:void 0,o=void 0===i?n:ft(i,n);o>a;)e[a++]=t;return e};Dt({target:"Array",proto:!0},{fill:Vr}),_r("fill");var Ur=le.filter,jr=Sr("filter"),Gr=zr("filter");Dt({target:"Array",proto:!0,forced:!jr||!Gr},{filter:function(t){return Ur(this,t,arguments.length>1?arguments[1]:void 0)}});var qr=le.find,Hr=!0,Kr=zr("find");"find"in[]&&Array(1).find((function(){Hr=!1})),Dt({target:"Array",proto:!0,forced:Hr||!Kr},{find:function(t){return qr(this,t,arguments.length>1?arguments[1]:void 0)}}),_r("find");var Xr=le.findIndex,Yr=!0,Jr=zr("findIndex");"findIndex"in[]&&Array(1).findIndex((function(){Yr=!1})),Dt({target:"Array",proto:!0,forced:Yr||!Jr},{findIndex:function(t){return Xr(this,t,arguments.length>1?arguments[1]:void 0)}}),_r("findIndex");var $r=function t(e,n,r,a,i,o,s,u){for(var c,l=i,h=0,f=!!s&&ie(s,u,3);h<a;){if(h in r){if(c=f?f(r[h],h,n):r[h],o>0&&Ft(c))l=t(e,n,c,ct(c.length),l,o-1)-1;else{if(l>=9007199254740991)throw TypeError("Exceed the acceptable array length");e[l]=c}l++}h++}return l};Dt({target:"Array",proto:!0},{flat:function(){var t=arguments.length?arguments[0]:void 0,e=Mt(this),n=ct(e.length),r=se(e,0);return r.length=$r(r,e,e,n,0,void 0===t?1:st(t)),r}}),Dt({target:"Array",proto:!0},{flatMap:function(t){var e,n=Mt(this),r=ct(n.length);return ae(t),(e=se(n,0)).length=$r(e,n,n,r,0,1,t,arguments.length>1?arguments[1]:void 0),e}});var Zr=le.forEach,Qr=Or("forEach"),ta=zr("forEach"),ea=Qr&&ta?[].forEach:function(t){return Zr(this,t,arguments.length>1?arguments[1]:void 0)};Dt({target:"Array",proto:!0,forced:[].forEach!=ea},{forEach:ea});var na=dt.includes,ra=zr("indexOf",{ACCESSORS:!0,1:0});Dt({target:"Array",proto:!0,forced:!ra},{includes:function(t){return na(this,t,arguments.length>1?arguments[1]:void 0)}}),_r("includes");var aa=dt.indexOf,ia=[].indexOf,oa=!!ia&&1/[1].indexOf(1,-0)<0,sa=Or("indexOf"),ua=zr("indexOf",{ACCESSORS:!0,1:0});Dt({target:"Array",proto:!0,forced:oa||!sa||!ua},{indexOf:function(t){return oa?ia.apply(this,arguments)||0:aa(this,t,arguments.length>1?arguments[1]:void 0)}});var ca=[].join,la=d!=Object,ha=Or("join",",");Dt({target:"Array",proto:!0,forced:la||!ha},{join:function(t){return ca.call(v(this),void 0===t?",":t)}});var fa=Math.min,pa=[].lastIndexOf,da=!!pa&&1/[1].lastIndexOf(1,-0)<0,ma=Or("lastIndexOf"),va=zr("indexOf",{ACCESSORS:!0,1:0}),ga=da||!ma||!va?function(t){if(da)return pa.apply(this,arguments)||0;var e=v(this),n=ct(e.length),r=n-1;for(arguments.length>1&&(r=fa(r,st(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in e&&e[r]===t)return r||0;return-1}:pa;Dt({target:"Array",proto:!0,forced:ga!==[].lastIndexOf},{lastIndexOf:ga});var ya=le.map,ba=Sr("map"),xa=zr("map");Dt({target:"Array",proto:!0,forced:!ba||!xa},{map:function(t){return ya(this,t,arguments.length>1?arguments[1]:void 0)}});var wa=function(t){return function(e,n,r,a){ae(n);var i=Mt(e),o=d(i),s=ct(i.length),u=t?s-1:0,c=t?-1:1;if(r<2)for(;;){if(u in o){a=o[u],u+=c;break}if(u+=c,t?u<0:s<=u)throw TypeError("Reduce of empty array with no initial value")}for(;t?u>=0:s>u;u+=c)u in o&&(a=n(a,o[u],u,i));return a}},ka={left:wa(!1),right:wa(!0)},Sa=ka.left,Ca=Or("reduce"),Ra=zr("reduce",{1:0});Dt({target:"Array",proto:!0,forced:!Ca||!Ra},{reduce:function(t){return Sa(this,t,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Na=ka.right,Ea=Or("reduceRight"),Ia=zr("reduce",{1:0});Dt({target:"Array",proto:!0,forced:!Ea||!Ia},{reduceRight:function(t){return Na(this,t,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Aa=[].reverse,Ta=[1,2];Dt({target:"Array",proto:!0,forced:String(Ta)===String(Ta.reverse())},{reverse:function(){return Ft(this)&&(this.length=this.length),Aa.call(this)}});var Da=Sr("slice"),_a=zr("slice",{ACCESSORS:!0,0:0,1:2}),Oa=$t("species"),Fa=[].slice,Ma=Math.max;Dt({target:"Array",proto:!0,forced:!Da||!_a},{slice:function(t,e){var n,r,a,i=v(this),o=ct(i.length),s=ft(t,o),u=ft(void 0===e?o:e,o);if(Ft(i)&&("function"!=typeof(n=i.constructor)||n!==Array&&!Ft(n.prototype)?g(n)&&null===(n=n[Oa])&&(n=void 0):n=void 0,n===Array||void 0===n))return Fa.call(i,s,u);for(r=new(void 0===n?Array:n)(Ma(u-s,0)),a=0;s<u;s++,a++)s in i&&xn(r,a,i[s]);return r.length=a,r}});var La=le.some,za=Or("some"),Ba=zr("some");Dt({target:"Array",proto:!0,forced:!za||!Ba},{some:function(t){return La(this,t,arguments.length>1?arguments[1]:void 0)}});var Pa=[],Wa=Pa.sort,Va=i((function(){Pa.sort(void 0)})),Ua=i((function(){Pa.sort(null)})),ja=Or("sort");Dt({target:"Array",proto:!0,forced:Va||!Ua||!ja},{sort:function(t){return void 0===t?Wa.call(Mt(this)):Wa.call(Mt(this),ae(t))}});var Ga=Sr("splice"),qa=zr("splice",{ACCESSORS:!0,0:0,1:2}),Ha=Math.max,Ka=Math.min;Dt({target:"Array",proto:!0,forced:!Ga||!qa},{splice:function(t,e){var n,r,a,i,o,s,u=Mt(this),c=ct(u.length),l=ft(t,c),h=arguments.length;if(0===h?n=r=0:1===h?(n=0,r=c-l):(n=h-2,r=Ka(Ha(st(e),0),c-l)),c+n-r>9007199254740991)throw TypeError("Maximum allowed length exceeded");for(a=se(u,r),i=0;i<r;i++)(o=l+i)in u&&xn(a,i,u[o]);if(a.length=r,n<r){for(i=l;i<c-r;i++)s=i+n,(o=i+r)in u?u[s]=u[o]:delete u[s];for(i=c;i>c-r+n;i--)delete u[i-1]}else if(n>r)for(i=c-r;i>l;i--)s=i+n-1,(o=i+r-1)in u?u[s]=u[o]:delete u[s];for(i=0;i<n;i++)u[i+l]=arguments[i+2];return u.length=c-r+n,a}});var Xa=$t("species"),Ya=function(t){var e=at(t),n=A.f;o&&e&&!e[Xa]&&n(e,Xa,{configurable:!0,get:function(){return this}})};Ya("Array"),_r("flat"),_r("flatMap");var Ja,$a,Za,Qa=$t("iterator"),ti=!1;[].keys&&("next"in(Za=[].keys())?($a=In(In(Za)))!==Object.prototype&&(Ja=$a):ti=!0),null==Ja&&(Ja={}),x(Ja,Qa)||T(Ja,Qa,(function(){return this}));var ei={IteratorPrototype:Ja,BUGGY_SAFARI_ITERATORS:ti},ni=ei.IteratorPrototype,ri=function(){return this},ai=function(t,e,n){var r=e+" Iterator";return t.prototype=jt(ni,{next:l(1,n)}),re(t,r,!1),sn[r]=ri,t},ii=ei.IteratorPrototype,oi=ei.BUGGY_SAFARI_ITERATORS,si=$t("iterator"),ui=function(){return this},ci=function(t,e,n,r,a,i,o){ai(n,e,r);var s,u,c,l=function(t){if(t===a&&m)return m;if(!oi&&t in p)return p[t];switch(t){case"keys":case"values":case"entries":return function(){return new n(this,t)}}return function(){return new n(this)}},h=e+" Iterator",f=!1,p=t.prototype,d=p[si]||p["@@iterator"]||a&&p[a],m=!oi&&d||l(a),v="Array"==e&&p.entries||d;if(v&&(s=In(v.call(new t)),ii!==Object.prototype&&s.next&&(In(s)!==ii&&(qn?qn(s,ii):"function"!=typeof s[si]&&T(s,si,ui)),re(s,h,!0))),"values"==a&&d&&"values"!==d.name&&(f=!0,m=function(){return d.call(this)}),p[si]!==m&&T(p,si,m),sn[e]=m,a)if(u={values:l("values"),keys:i?m:l("keys"),entries:l("entries")},o)for(c in u)(oi||f||!(c in p))&&et(p,c,u[c]);else Dt({target:e,proto:!0,forced:oi||f},u);return u},li=tt.set,hi=tt.getterFor("Array Iterator"),fi=ci(Array,"Array",(function(t,e){li(this,{type:"Array Iterator",target:v(t),index:0,kind:e})}),(function(){var t=hi(this),e=t.target,n=t.kind,r=t.index++;return!e||r>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:e[r],done:!1}:{value:[r,e[r]],done:!1}}),"values");sn.Arguments=sn.Array,_r("keys"),_r("values"),_r("entries");var pi=String.fromCharCode,di=String.fromCodePoint,mi=!!di&&1!=di.length;Dt({target:"String",stat:!0,forced:mi},{fromCodePoint:function(t){for(var e,n=[],r=arguments.length,a=0;r>a;){if(e=+arguments[a++],ft(e,1114111)!==e)throw RangeError(e+" is not a valid code point");n.push(e<65536?pi(e):pi(55296+((e-=65536)>>10),e%1024+56320))}return n.join("")}}),Dt({target:"String",stat:!0},{raw:function(t){for(var e=v(t.raw),n=ct(e.length),r=arguments.length,a=[],i=0;n>i;)a.push(String(e[i++])),i<r&&a.push(String(arguments[i]));return a.join("")}});var vi=function(t){return function(e,n){var r,a,i=String(m(e)),o=st(n),s=i.length;return o<0||o>=s?t?"":void 0:(r=i.charCodeAt(o))<55296||r>56319||o+1===s||(a=i.charCodeAt(o+1))<56320||a>57343?t?i.charAt(o):r:t?i.slice(o,o+2):a-56320+(r-55296<<10)+65536}},gi={codeAt:vi(!1),charAt:vi(!0)},yi=gi.codeAt;Dt({target:"String",proto:!0},{codePointAt:function(t){return yi(this,t)}});var bi,xi=$t("match"),wi=function(t){var e;return g(t)&&(void 0!==(e=t[xi])?!!e:"RegExp"==f(t))},ki=function(t){if(wi(t))throw TypeError("The method doesn't accept regular expressions");return t},Si=$t("match"),Ci=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[Si]=!1,"/./"[t](e)}catch(t){}}return!1},Ri=N.f,Ni="".endsWith,Ei=Math.min,Ii=Ci("endsWith"),Ai=!(Ii||(bi=Ri(String.prototype,"endsWith"),!bi||bi.writable));Dt({target:"String",proto:!0,forced:!Ai&&!Ii},{endsWith:function(t){var e=String(m(this));ki(t);var n=arguments.length>1?arguments[1]:void 0,r=ct(e.length),a=void 0===n?r:Ei(ct(n),r),i=String(t);return Ni?Ni.call(e,i,a):e.slice(a-i.length,a)===i}}),Dt({target:"String",proto:!0,forced:!Ci("includes")},{includes:function(t){return!!~String(m(this)).indexOf(ki(t),arguments.length>1?arguments[1]:void 0)}});var Ti=function(){var t=E(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e};function Di(t,e){return RegExp(t,e)}var _i={UNSUPPORTED_Y:i((function(){var t=Di("a","y");return t.lastIndex=2,null!=t.exec("abcd")})),BROKEN_CARET:i((function(){var t=Di("^r","gy");return t.lastIndex=2,null!=t.exec("str")}))},Oi=RegExp.prototype.exec,Fi=String.prototype.replace,Mi=Oi,Li=function(){var t=/a/,e=/b*/g;return Oi.call(t,"a"),Oi.call(e,"a"),0!==t.lastIndex||0!==e.lastIndex}(),zi=_i.UNSUPPORTED_Y||_i.BROKEN_CARET,Bi=void 0!==/()??/.exec("")[1];(Li||Bi||zi)&&(Mi=function(t){var e,n,r,a,i=this,o=zi&&i.sticky,s=Ti.call(i),u=i.source,c=0,l=t;return o&&(-1===(s=s.replace("y","")).indexOf("g")&&(s+="g"),l=String(t).slice(i.lastIndex),i.lastIndex>0&&(!i.multiline||i.multiline&&"\n"!==t[i.lastIndex-1])&&(u="(?: "+u+")",l=" "+l,c++),n=new RegExp("^(?:"+u+")",s)),Bi&&(n=new RegExp("^"+u+"$(?!\\s)",s)),Li&&(e=i.lastIndex),r=Oi.call(o?n:i,l),o?r?(r.input=r.input.slice(c),r[0]=r[0].slice(c),r.index=i.lastIndex,i.lastIndex+=r[0].length):i.lastIndex=0:Li&&r&&(i.lastIndex=i.global?r.index+r[0].length:e),Bi&&r&&r.length>1&&Fi.call(r[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(r[a]=void 0)})),r});var Pi=Mi;Dt({target:"RegExp",proto:!0,forced:/./.exec!==Pi},{exec:Pi});var Wi=$t("species"),Vi=!i((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")})),Ui="$0"==="a".replace(/./,"$0"),ji=$t("replace"),Gi=!!/./[ji]&&""===/./[ji]("a","$0"),qi=!i((function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),Hi=function(t,e,n,r){var a=$t(t),o=!i((function(){var e={};return e[a]=function(){return 7},7!=""[t](e)})),s=o&&!i((function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[Wi]=function(){return n},n.flags="",n[a]=/./[a]),n.exec=function(){return e=!0,null},n[a](""),!e}));if(!o||!s||"replace"===t&&(!Vi||!Ui||Gi)||"split"===t&&!qi){var u=/./[a],c=n(a,""[t],(function(t,e,n,r,a){return e.exec===Pi?o&&!a?{done:!0,value:u.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),{REPLACE_KEEPS_$0:Ui,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:Gi}),l=c[0],h=c[1];et(String.prototype,t,l),et(RegExp.prototype,a,2==e?function(t,e){return h.call(t,this,e)}:function(t){return h.call(t,this)})}r&&T(RegExp.prototype[a],"sham",!0)},Ki=gi.charAt,Xi=function(t,e,n){return e+(n?Ki(t,e).length:1)},Yi=function(t,e){var n=t.exec;if("function"==typeof n){var r=n.call(t,e);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==f(t))throw TypeError("RegExp#exec called on incompatible receiver");return Pi.call(t,e)};Hi("match",1,(function(t,e,n){return[function(e){var n=m(this),r=null==e?void 0:e[t];return void 0!==r?r.call(e,n):new RegExp(e)[t](String(n))},function(t){var r=n(e,t,this);if(r.done)return r.value;var a=E(t),i=String(this);if(!a.global)return Yi(a,i);var o=a.unicode;a.lastIndex=0;for(var s,u=[],c=0;null!==(s=Yi(a,i));){var l=String(s[0]);u[c]=l,""===l&&(a.lastIndex=Xi(i,ct(a.lastIndex),o)),c++}return 0===c?null:u}]}));var Ji=$t("species"),$i=function(t,e){var n,r=E(t).constructor;return void 0===r||null==(n=E(r)[Ji])?e:ae(n)},Zi=$t("matchAll"),Qi=tt.set,to=tt.getterFor("RegExp String Iterator"),eo=RegExp.prototype,no=eo.exec,ro="".matchAll,ao=!!ro&&!i((function(){"a".matchAll(/./)})),io=ai((function(t,e,n,r){Qi(this,{type:"RegExp String Iterator",regexp:t,string:e,global:n,unicode:r,done:!1})}),"RegExp String",(function(){var t=to(this);if(t.done)return{value:void 0,done:!0};var e=t.regexp,n=t.string,r=function(t,e){var n,r=t.exec;if("function"==typeof r){if("object"!=typeof(n=r.call(t,e)))throw TypeError("Incorrect exec result");return n}return no.call(t,e)}(e,n);return null===r?{value:void 0,done:t.done=!0}:t.global?(""==String(r[0])&&(e.lastIndex=Xi(n,ct(e.lastIndex),t.unicode)),{value:r,done:!1}):(t.done=!0,{value:r,done:!1})})),oo=function(t){var e,n,r,a,i,o,s=E(this),u=String(t);return e=$i(s,RegExp),void 0===(n=s.flags)&&s instanceof RegExp&&!("flags"in eo)&&(n=Ti.call(s)),r=void 0===n?"":String(n),a=new e(e===RegExp?s.source:s,r),i=!!~r.indexOf("g"),o=!!~r.indexOf("u"),a.lastIndex=ct(s.lastIndex),new io(a,u,i,o)};Dt({target:"String",proto:!0,forced:ao},{matchAll:function(t){var e,n,r=m(this);if(null!=t){if(wi(t)&&!~String(m("flags"in eo?t.flags:Ti.call(t))).indexOf("g"))throw TypeError("`.matchAll` does not allow non-global regexes");if(ao)return ro.apply(r,arguments);if(null!=(n=t[Zi]))return ae(n).call(t,r)}else if(ao)return ro.apply(r,arguments);return e=String(r),new RegExp(t,"g")[Zi](e)}}),Zi in eo||T(eo,Zi,oo);var so="".repeat||function(t){var e=String(m(this)),n="",r=st(t);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(e+=e))1&r&&(n+=e);return n},uo=Math.ceil,co=function(t){return function(e,n,r){var a,i,o=String(m(e)),s=o.length,u=void 0===r?" ":String(r),c=ct(n);return c<=s||""==u?o:(a=c-s,(i=so.call(u,uo(a/u.length))).length>a&&(i=i.slice(0,a)),t?o+i:i+o)}},lo={start:co(!1),end:co(!0)},ho=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(gr),fo=lo.end;Dt({target:"String",proto:!0,forced:ho},{padEnd:function(t){return fo(this,t,arguments.length>1?arguments[1]:void 0)}});var po=lo.start;Dt({target:"String",proto:!0,forced:ho},{padStart:function(t){return po(this,t,arguments.length>1?arguments[1]:void 0)}}),Dt({target:"String",proto:!0},{repeat:so});var mo=Math.max,vo=Math.min,go=Math.floor,yo=/\$([$&'`]|\d\d?|<[^>]*>)/g,bo=/\$([$&'`]|\d\d?)/g;Hi("replace",2,(function(t,e,n,r){var a=r.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,i=r.REPLACE_KEEPS_$0,o=a?"$":"$0";return[function(n,r){var a=m(this),i=null==n?void 0:n[t];return void 0!==i?i.call(n,a,r):e.call(String(a),n,r)},function(t,r){if(!a&&i||"string"==typeof r&&-1===r.indexOf(o)){var u=n(e,t,this,r);if(u.done)return u.value}var c=E(t),l=String(this),h="function"==typeof r;h||(r=String(r));var f=c.global;if(f){var p=c.unicode;c.lastIndex=0}for(var d=[];;){var m=Yi(c,l);if(null===m)break;if(d.push(m),!f)break;""===String(m[0])&&(c.lastIndex=Xi(l,ct(c.lastIndex),p))}for(var v,g="",y=0,b=0;b<d.length;b++){m=d[b];for(var x=String(m[0]),w=mo(vo(st(m.index),l.length),0),k=[],S=1;S<m.length;S++)k.push(void 0===(v=m[S])?v:String(v));var C=m.groups;if(h){var R=[x].concat(k,w,l);void 0!==C&&R.push(C);var N=String(r.apply(void 0,R))}else N=s(x,l,w,k,C,r);w>=y&&(g+=l.slice(y,w)+N,y=w+x.length)}return g+l.slice(y)}];function s(t,n,r,a,i,o){var s=r+t.length,u=a.length,c=bo;return void 0!==i&&(i=Mt(i),c=yo),e.call(o,c,(function(e,o){var c;switch(o.charAt(0)){case"$":return"$";case"&":return t;case"`":return n.slice(0,r);case"'":return n.slice(s);case"<":c=i[o.slice(1,-1)];break;default:var l=+o;if(0===l)return e;if(l>u){var h=go(l/10);return 0===h?e:h<=u?void 0===a[h-1]?o.charAt(1):a[h-1]+o.charAt(1):e}c=a[l-1]}return void 0===c?"":c}))}})),Hi("search",1,(function(t,e,n){return[function(e){var n=m(this),r=null==e?void 0:e[t];return void 0!==r?r.call(e,n):new RegExp(e)[t](String(n))},function(t){var r=n(e,t,this);if(r.done)return r.value;var a=E(t),i=String(this),o=a.lastIndex;Tn(o,0)||(a.lastIndex=0);var s=Yi(a,i);return Tn(a.lastIndex,o)||(a.lastIndex=o),null===s?-1:s.index}]}));var xo=[].push,wo=Math.min,ko=!i((function(){return!RegExp(4294967295,"y")}));Hi("split",2,(function(t,e,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(t,n){var r=String(m(this)),a=void 0===n?4294967295:n>>>0;if(0===a)return[];if(void 0===t)return[r];if(!wi(t))return e.call(r,t,a);for(var i,o,s,u=[],c=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),l=0,h=new RegExp(t.source,c+"g");(i=Pi.call(h,r))&&!((o=h.lastIndex)>l&&(u.push(r.slice(l,i.index)),i.length>1&&i.index<r.length&&xo.apply(u,i.slice(1)),s=i[0].length,l=o,u.length>=a));)h.lastIndex===i.index&&h.lastIndex++;return l===r.length?!s&&h.test("")||u.push(""):u.push(r.slice(l)),u.length>a?u.slice(0,a):u}:"0".split(void 0,0).length?function(t,n){return void 0===t&&0===n?[]:e.call(this,t,n)}:e,[function(e,n){var a=m(this),i=null==e?void 0:e[t];return void 0!==i?i.call(e,a,n):r.call(String(a),e,n)},function(t,a){var i=n(r,t,this,a,r!==e);if(i.done)return i.value;var o=E(t),s=String(this),u=$i(o,RegExp),c=o.unicode,l=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(ko?"y":"g"),h=new u(ko?o:"^(?:"+o.source+")",l),f=void 0===a?4294967295:a>>>0;if(0===f)return[];if(0===s.length)return null===Yi(h,s)?[s]:[];for(var p=0,d=0,m=[];d<s.length;){h.lastIndex=ko?d:0;var v,g=Yi(h,ko?s:s.slice(d));if(null===g||(v=wo(ct(h.lastIndex+(ko?0:d)),s.length))===p)d=Xi(s,d,c);else{if(m.push(s.slice(p,d)),m.length===f)return m;for(var y=1;y<=g.length-1;y++)if(m.push(g[y]),m.length===f)return m;d=p=v}}return m.push(s.slice(p)),m}]}),!ko);var So=N.f,Co="".startsWith,Ro=Math.min,No=Ci("startsWith"),Eo=!No&&!!function(){var t=So(String.prototype,"startsWith");return t&&!t.writable}();Dt({target:"String",proto:!0,forced:!Eo&&!No},{startsWith:function(t){var e=String(m(this));ki(t);var n=ct(Ro(arguments.length>1?arguments[1]:void 0,e.length)),r=String(t);return Co?Co.call(e,r,n):e.slice(n,n+r.length)===r}});var Io="\t\n\v\f\r   \u2028\u2029\ufeff",Ao="["+Io+"]",To=RegExp("^"+Ao+Ao+"*"),Do=RegExp(Ao+Ao+"*$"),_o=function(t){return function(e){var n=String(m(e));return 1&t&&(n=n.replace(To,"")),2&t&&(n=n.replace(Do,"")),n}},Oo={start:_o(1),end:_o(2),trim:_o(3)},Fo=function(t){return i((function(){return!!Io[t]()||"…"!="…"[t]()||Io[t].name!==t}))},Mo=Oo.trim;Dt({target:"String",proto:!0,forced:Fo("trim")},{trim:function(){return Mo(this)}});var Lo=Oo.start,zo=Fo("trimStart"),Bo=zo?function(){return Lo(this)}:"".trimStart;Dt({target:"String",proto:!0,forced:zo},{trimStart:Bo,trimLeft:Bo});var Po=Oo.end,Wo=Fo("trimEnd"),Vo=Wo?function(){return Po(this)}:"".trimEnd;Dt({target:"String",proto:!0,forced:Wo},{trimEnd:Vo,trimRight:Vo});var Uo=gi.charAt,jo=tt.set,Go=tt.getterFor("String Iterator");ci(String,"String",(function(t){jo(this,{type:"String Iterator",string:String(t),index:0})}),(function(){var t,e=Go(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=Uo(n,r),e.index+=t.length,{value:t,done:!1})}));var qo=/"/g,Ho=function(t,e,n,r){var a=String(m(t)),i="<"+e;return""!==n&&(i+=" "+n+'="'+String(r).replace(qo,"&quot;")+'"'),i+">"+a+"</"+e+">"},Ko=function(t){return i((function(){var e=""[t]('"');return e!==e.toLowerCase()||e.split('"').length>3}))};Dt({target:"String",proto:!0,forced:Ko("anchor")},{anchor:function(t){return Ho(this,"a","name",t)}}),Dt({target:"String",proto:!0,forced:Ko("big")},{big:function(){return Ho(this,"big","","")}}),Dt({target:"String",proto:!0,forced:Ko("blink")},{blink:function(){return Ho(this,"blink","","")}}),Dt({target:"String",proto:!0,forced:Ko("bold")},{bold:function(){return Ho(this,"b","","")}}),Dt({target:"String",proto:!0,forced:Ko("fixed")},{fixed:function(){return Ho(this,"tt","","")}}),Dt({target:"String",proto:!0,forced:Ko("fontcolor")},{fontcolor:function(t){return Ho(this,"font","color",t)}}),Dt({target:"String",proto:!0,forced:Ko("fontsize")},{fontsize:function(t){return Ho(this,"font","size",t)}}),Dt({target:"String",proto:!0,forced:Ko("italics")},{italics:function(){return Ho(this,"i","","")}}),Dt({target:"String",proto:!0,forced:Ko("link")},{link:function(t){return Ho(this,"a","href",t)}}),Dt({target:"String",proto:!0,forced:Ko("small")},{small:function(){return Ho(this,"small","","")}}),Dt({target:"String",proto:!0,forced:Ko("strike")},{strike:function(){return Ho(this,"strike","","")}}),Dt({target:"String",proto:!0,forced:Ko("sub")},{sub:function(){return Ho(this,"sub","","")}}),Dt({target:"String",proto:!0,forced:Ko("sup")},{sup:function(){return Ho(this,"sup","","")}});var Xo=function(t,e,n){var r,a;return qn&&"function"==typeof(r=e.constructor)&&r!==n&&g(a=r.prototype)&&a!==n.prototype&&qn(t,a),t},Yo=A.f,Jo=bt.f,$o=tt.set,Zo=$t("match"),Qo=a.RegExp,ts=Qo.prototype,es=/a/g,ns=/a/g,rs=new Qo(es)!==es,as=_i.UNSUPPORTED_Y;if(o&&At("RegExp",!rs||as||i((function(){return ns[Zo]=!1,Qo(es)!=es||Qo(ns)==ns||"/a/i"!=Qo(es,"i")})))){for(var is=function(t,e){var n,r=this instanceof is,a=wi(t),i=void 0===e;if(!r&&a&&t.constructor===is&&i)return t;rs?a&&!i&&(t=t.source):t instanceof is&&(i&&(e=Ti.call(t)),t=t.source),as&&(n=!!e&&e.indexOf("y")>-1)&&(e=e.replace(/y/g,""));var o=Xo(rs?new Qo(t,e):Qo(t,e),r?this:ts,is);return as&&n&&$o(o,{sticky:n}),o},os=function(t){t in is||Yo(is,t,{configurable:!0,get:function(){return Qo[t]},set:function(e){Qo[t]=e}})},ss=Jo(Qo),us=0;ss.length>us;)os(ss[us++]);ts.constructor=is,is.prototype=ts,et(a,"RegExp",is)}Ya("RegExp"),o&&("g"!=/./g.flags||_i.UNSUPPORTED_Y)&&A.f(RegExp.prototype,"flags",{configurable:!0,get:Ti});var cs=_i.UNSUPPORTED_Y,ls=A.f,hs=tt.get,fs=RegExp.prototype;o&&cs&&ls(RegExp.prototype,"sticky",{configurable:!0,get:function(){if(this!==fs){if(this instanceof RegExp)return!!hs(this).sticky;throw TypeError("Incompatible receiver, RegExp required")}}});var ps=function(){var t=!1,e=/[ac]/;return e.exec=function(){return t=!0,/./.exec.apply(this,arguments)},!0===e.test("abc")&&t}(),ds=/./.test;Dt({target:"RegExp",proto:!0,forced:!ps},{test:function(t){if("function"!=typeof this.exec)return ds.call(this,t);var e=this.exec(t);if(null!==e&&!g(e))throw new Error("RegExp exec method returned something other than an Object or null");return!!e}});var ms=RegExp.prototype,vs=ms.toString,gs=i((function(){return"/a/b"!=vs.call({source:"a",flags:"b"})})),ys="toString"!=vs.name;(gs||ys)&&et(RegExp.prototype,"toString",(function(){var t=E(this),e=String(t.source),n=t.flags;return"/"+e+"/"+String(void 0===n&&t instanceof RegExp&&!("flags"in ms)?Ti.call(t):n)}),{unsafe:!0});var bs=Oo.trim,xs=a.parseInt,ws=/^[+-]?0[Xx]/,ks=8!==xs(Io+"08")||22!==xs(Io+"0x16")?function(t,e){var n=bs(String(t));return xs(n,e>>>0||(ws.test(n)?16:10))}:xs;Dt({global:!0,forced:parseInt!=ks},{parseInt:ks});var Ss=Oo.trim,Cs=a.parseFloat,Rs=1/Cs(Io+"-0")!=-1/0?function(t){var e=Ss(String(t)),n=Cs(e);return 0===n&&"-"==e.charAt(0)?-0:n}:Cs;Dt({global:!0,forced:parseFloat!=Rs},{parseFloat:Rs});var Ns=bt.f,Es=N.f,Is=A.f,As=Oo.trim,Ts=a.Number,Ds=Ts.prototype,_s="Number"==f(jt(Ds)),Os=function(t){var e,n,r,a,i,o,s,u,c=y(t,!1);if("string"==typeof c&&c.length>2)if(43===(e=(c=As(c)).charCodeAt(0))||45===e){if(88===(n=c.charCodeAt(2))||120===n)return NaN}else if(48===e){switch(c.charCodeAt(1)){case 66:case 98:r=2,a=49;break;case 79:case 111:r=8,a=55;break;default:return+c}for(o=(i=c.slice(2)).length,s=0;s<o;s++)if((u=i.charCodeAt(s))<48||u>a)return NaN;return parseInt(i,r)}return+c};if(At("Number",!Ts(" 0o1")||!Ts("0b1")||Ts("+0x1"))){for(var Fs,Ms=function(t){var e=arguments.length<1?0:t,n=this;return n instanceof Ms&&(_s?i((function(){Ds.valueOf.call(n)})):"Number"!=f(n))?Xo(new Ts(Os(e)),n,Ms):Os(e)},Ls=o?Ns(Ts):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),zs=0;Ls.length>zs;zs++)x(Ts,Fs=Ls[zs])&&!x(Ms,Fs)&&Is(Ms,Fs,Es(Ts,Fs));Ms.prototype=Ds,Ds.constructor=Ms,et(a,"Number",Ms)}Dt({target:"Number",stat:!0},{EPSILON:Math.pow(2,-52)});var Bs=a.isFinite,Ps=Number.isFinite||function(t){return"number"==typeof t&&Bs(t)};Dt({target:"Number",stat:!0},{isFinite:Ps});var Ws=Math.floor,Vs=function(t){return!g(t)&&isFinite(t)&&Ws(t)===t};Dt({target:"Number",stat:!0},{isInteger:Vs}),Dt({target:"Number",stat:!0},{isNaN:function(t){return t!=t}});var Us=Math.abs;Dt({target:"Number",stat:!0},{isSafeInteger:function(t){return Vs(t)&&Us(t)<=9007199254740991}}),Dt({target:"Number",stat:!0},{MAX_SAFE_INTEGER:9007199254740991}),Dt({target:"Number",stat:!0},{MIN_SAFE_INTEGER:-9007199254740991}),Dt({target:"Number",stat:!0,forced:Number.parseFloat!=Rs},{parseFloat:Rs}),Dt({target:"Number",stat:!0,forced:Number.parseInt!=ks},{parseInt:ks});var js=function(t){if("number"!=typeof t&&"Number"!=f(t))throw TypeError("Incorrect invocation");return+t},Gs=1..toFixed,qs=Math.floor,Hs=function t(e,n,r){return 0===n?r:n%2==1?t(e,n-1,r*e):t(e*e,n/2,r)},Ks=Gs&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!i((function(){Gs.call({})}));Dt({target:"Number",proto:!0,forced:Ks},{toFixed:function(t){var e,n,r,a,i=js(this),o=st(t),s=[0,0,0,0,0,0],u="",c="0",l=function(t,e){for(var n=-1,r=e;++n<6;)r+=t*s[n],s[n]=r%1e7,r=qs(r/1e7)},h=function(t){for(var e=6,n=0;--e>=0;)n+=s[e],s[e]=qs(n/t),n=n%t*1e7},f=function(){for(var t=6,e="";--t>=0;)if(""!==e||0===t||0!==s[t]){var n=String(s[t]);e=""===e?n:e+so.call("0",7-n.length)+n}return e};if(o<0||o>20)throw RangeError("Incorrect fraction digits");if(i!=i)return"NaN";if(i<=-1e21||i>=1e21)return String(i);if(i<0&&(u="-",i=-i),i>1e-21)if(n=(e=function(t){for(var e=0,n=t;n>=4096;)e+=12,n/=4096;for(;n>=2;)e+=1,n/=2;return e}(i*Hs(2,69,1))-69)<0?i*Hs(2,-e,1):i/Hs(2,e,1),n*=4503599627370496,(e=52-e)>0){for(l(0,n),r=o;r>=7;)l(1e7,0),r-=7;for(l(Hs(10,r,1),0),r=e-1;r>=23;)h(1<<23),r-=23;h(1<<r),l(1,1),h(2),c=f()}else l(0,n),l(1<<-e,0),c=f()+so.call("0",o);return c=o>0?u+((a=c.length)<=o?"0."+so.call("0",o-a)+c:c.slice(0,a-o)+"."+c.slice(a-o)):u+c}});var Xs=1..toPrecision,Ys=i((function(){return"1"!==Xs.call(1,void 0)}))||!i((function(){Xs.call({})}));Dt({target:"Number",proto:!0,forced:Ys},{toPrecision:function(t){return void 0===t?Xs.call(js(this)):Xs.call(js(this),t)}});var Js=Math.log,$s=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:Js(1+t)},Zs=Math.acosh,Qs=Math.log,tu=Math.sqrt,eu=Math.LN2,nu=!Zs||710!=Math.floor(Zs(Number.MAX_VALUE))||Zs(1/0)!=1/0;Dt({target:"Math",stat:!0,forced:nu},{acosh:function(t){return(t=+t)<1?NaN:t>94906265.62425156?Qs(t)+eu:$s(t-1+tu(t-1)*tu(t+1))}});var ru=Math.asinh,au=Math.log,iu=Math.sqrt;Dt({target:"Math",stat:!0,forced:!(ru&&1/ru(0)>0)},{asinh:function t(e){return isFinite(e=+e)&&0!=e?e<0?-t(-e):au(e+iu(e*e+1)):e}});var ou=Math.atanh,su=Math.log;Dt({target:"Math",stat:!0,forced:!(ou&&1/ou(-0)<0)},{atanh:function(t){return 0==(t=+t)?t:su((1+t)/(1-t))/2}});var uu=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1},cu=Math.abs,lu=Math.pow;Dt({target:"Math",stat:!0},{cbrt:function(t){return uu(t=+t)*lu(cu(t),1/3)}});var hu=Math.floor,fu=Math.log,pu=Math.LOG2E;Dt({target:"Math",stat:!0},{clz32:function(t){return(t>>>=0)?31-hu(fu(t+.5)*pu):32}});var du=Math.expm1,mu=Math.exp,vu=!du||du(10)>22025.465794806718||du(10)<22025.465794806718||-2e-17!=du(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:mu(t)-1}:du,gu=Math.cosh,yu=Math.abs,bu=Math.E;Dt({target:"Math",stat:!0,forced:!gu||gu(710)===1/0},{cosh:function(t){var e=vu(yu(t)-1)+1;return(e+1/(e*bu*bu))*(bu/2)}}),Dt({target:"Math",stat:!0,forced:vu!=Math.expm1},{expm1:vu});var xu=Math.abs,wu=Math.pow,ku=wu(2,-52),Su=wu(2,-23),Cu=wu(2,127)*(2-Su),Ru=wu(2,-126),Nu=Math.fround||function(t){var e,n,r=xu(t),a=uu(t);return r<Ru?a*(r/Ru/Su+1/ku-1/ku)*Ru*Su:(n=(e=(1+Su/ku)*r)-(e-r))>Cu||n!=n?a*(1/0):a*n};Dt({target:"Math",stat:!0},{fround:Nu});var Eu=Math.hypot,Iu=Math.abs,Au=Math.sqrt,Tu=!!Eu&&Eu(1/0,NaN)!==1/0;Dt({target:"Math",stat:!0,forced:Tu},{hypot:function(t,e){for(var n,r,a=0,i=0,o=arguments.length,s=0;i<o;)s<(n=Iu(arguments[i++]))?(a=a*(r=s/n)*r+1,s=n):a+=n>0?(r=n/s)*r:n;return s===1/0?1/0:s*Au(a)}});var Du=Math.imul,_u=i((function(){return-5!=Du(4294967295,5)||2!=Du.length}));Dt({target:"Math",stat:!0,forced:_u},{imul:function(t,e){var n=+t,r=+e,a=65535&n,i=65535&r;return 0|a*i+((65535&n>>>16)*i+a*(65535&r>>>16)<<16>>>0)}});var Ou=Math.log,Fu=Math.LOG10E;Dt({target:"Math",stat:!0},{log10:function(t){return Ou(t)*Fu}}),Dt({target:"Math",stat:!0},{log1p:$s});var Mu=Math.log,Lu=Math.LN2;Dt({target:"Math",stat:!0},{log2:function(t){return Mu(t)/Lu}}),Dt({target:"Math",stat:!0},{sign:uu});var zu=Math.abs,Bu=Math.exp,Pu=Math.E,Wu=i((function(){return-2e-17!=Math.sinh(-2e-17)}));Dt({target:"Math",stat:!0,forced:Wu},{sinh:function(t){return zu(t=+t)<1?(vu(t)-vu(-t))/2:(Bu(t-1)-Bu(-t-1))*(Pu/2)}});var Vu=Math.exp;Dt({target:"Math",stat:!0},{tanh:function(t){var e=vu(t=+t),n=vu(-t);return e==1/0?1:n==1/0?-1:(e-n)/(Vu(t)+Vu(-t))}}),re(Math,"Math",!0);var Uu=Math.ceil,ju=Math.floor;Dt({target:"Math",stat:!0},{trunc:function(t){return(t>0?ju:Uu)(t)}}),Dt({target:"Date",stat:!0},{now:function(){return(new Date).getTime()}});var Gu=i((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}));Dt({target:"Date",proto:!0,forced:Gu},{toJSON:function(t){var e=Mt(this),n=y(e);return"number"!=typeof n||isFinite(n)?e.toISOString():null}});var qu=lo.start,Hu=Math.abs,Ku=Date.prototype,Xu=Ku.getTime,Yu=Ku.toISOString,Ju=i((function(){return"0385-07-25T07:06:39.999Z"!=Yu.call(new Date(-50000000000001))}))||!i((function(){Yu.call(new Date(NaN))}))?function(){if(!isFinite(Xu.call(this)))throw RangeError("Invalid time value");var t=this.getUTCFullYear(),e=this.getUTCMilliseconds(),n=t<0?"-":t>9999?"+":"";return n+qu(Hu(t),n?6:4,0)+"-"+qu(this.getUTCMonth()+1,2,0)+"-"+qu(this.getUTCDate(),2,0)+"T"+qu(this.getUTCHours(),2,0)+":"+qu(this.getUTCMinutes(),2,0)+":"+qu(this.getUTCSeconds(),2,0)+"."+qu(e,3,0)+"Z"}:Yu;Dt({target:"Date",proto:!0,forced:Date.prototype.toISOString!==Ju},{toISOString:Ju});var $u=Date.prototype,Zu=$u.toString,Qu=$u.getTime;new Date(NaN)+""!="Invalid Date"&&et($u,"toString",(function(){var t=Qu.call(this);return t==t?Zu.call(this):"Invalid Date"}));var tc=$t("toPrimitive"),ec=Date.prototype;tc in ec||T(ec,tc,(function(t){if("string"!==t&&"number"!==t&&"default"!==t)throw TypeError("Incorrect hint");return y(E(this),"number"!==t)}));var nc=at("JSON","stringify"),rc=/[\uD800-\uDFFF]/g,ac=/^[\uD800-\uDBFF]$/,ic=/^[\uDC00-\uDFFF]$/,oc=function(t,e,n){var r=n.charAt(e-1),a=n.charAt(e+1);return ac.test(t)&&!ic.test(a)||ic.test(t)&&!ac.test(r)?"\\u"+t.charCodeAt(0).toString(16):t},sc=i((function(){return'"\\udf06\\ud834"'!==nc("\udf06\ud834")||'"\\udead"'!==nc("\udead")}));nc&&Dt({target:"JSON",stat:!0,forced:sc},{stringify:function(t,e,n){var r=nc.apply(null,arguments);return"string"==typeof r?r.replace(rc,oc):r}}),re(a.JSON,"JSON",!0);var uc,cc,lc,hc=a.Promise,fc=function(t,e,n){for(var r in e)et(t,r,e[r],n);return t},pc=function(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return t},dc=/(iphone|ipod|ipad).*applewebkit/i.test(gr),mc=a.location,vc=a.setImmediate,gc=a.clearImmediate,yc=a.process,bc=a.MessageChannel,xc=a.Dispatch,wc=0,kc={},Sc=function(t){if(kc.hasOwnProperty(t)){var e=kc[t];delete kc[t],e()}},Cc=function(t){return function(){Sc(t)}},Rc=function(t){Sc(t.data)},Nc=function(t){a.postMessage(t+"",mc.protocol+"//"+mc.host)};vc&&gc||(vc=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return kc[++wc]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},uc(wc),wc},gc=function(t){delete kc[t]},"process"==f(yc)?uc=function(t){yc.nextTick(Cc(t))}:xc&&xc.now?uc=function(t){xc.now(Cc(t))}:bc&&!dc?(lc=(cc=new bc).port2,cc.port1.onmessage=Rc,uc=ie(lc.postMessage,lc,1)):!a.addEventListener||"function"!=typeof postMessage||a.importScripts||i(Nc)||"file:"===mc.protocol?uc="onreadystatechange"in S("script")?function(t){Bt.appendChild(S("script")).onreadystatechange=function(){Bt.removeChild(this),Sc(t)}}:function(t){setTimeout(Cc(t),0)}:(uc=Nc,a.addEventListener("message",Rc,!1)));var Ec,Ic,Ac,Tc,Dc,_c,Oc,Fc,Mc={set:vc,clear:gc},Lc=N.f,zc=Mc.set,Bc=a.MutationObserver||a.WebKitMutationObserver,Pc=a.process,Wc=a.Promise,Vc="process"==f(Pc),Uc=Lc(a,"queueMicrotask"),jc=Uc&&Uc.value;jc||(Ec=function(){var t,e;for(Vc&&(t=Pc.domain)&&t.exit();Ic;){e=Ic.fn,Ic=Ic.next;try{e()}catch(t){throw Ic?Tc():Ac=void 0,t}}Ac=void 0,t&&t.enter()},Vc?Tc=function(){Pc.nextTick(Ec)}:Bc&&!dc?(Dc=!0,_c=document.createTextNode(""),new Bc(Ec).observe(_c,{characterData:!0}),Tc=function(){_c.data=Dc=!Dc}):Wc&&Wc.resolve?(Oc=Wc.resolve(void 0),Fc=Oc.then,Tc=function(){Fc.call(Oc,Ec)}):Tc=function(){zc.call(a,Ec)});var Gc,qc,Hc,Kc,Xc=jc||function(t){var e={fn:t,next:void 0};Ac&&(Ac.next=e),Ic||(Ic=e,Tc()),Ac=e},Yc=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=ae(e),this.reject=ae(n)},Jc={f:function(t){return new Yc(t)}},$c=function(t,e){if(E(t),g(e)&&e.constructor===t)return e;var n=Jc.f(t);return(0,n.resolve)(e),n.promise},Zc=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Qc=Mc.set,tl=$t("species"),el="Promise",nl=tt.get,rl=tt.set,al=tt.getterFor(el),il=hc,ol=a.TypeError,sl=a.document,ul=a.process,cl=at("fetch"),ll=Jc.f,hl=ll,fl="process"==f(ul),pl=!!(sl&&sl.createEvent&&a.dispatchEvent),dl=At(el,(function(){if(!(z(il)!==String(il))){if(66===wr)return!0;if(!fl&&"function"!=typeof PromiseRejectionEvent)return!0}if(wr>=51&&/native code/.test(il))return!1;var t=il.resolve(1),e=function(t){t((function(){}),(function(){}))};return(t.constructor={})[tl]=e,!(t.then((function(){}))instanceof e)})),ml=dl||!fr((function(t){il.all(t).catch((function(){}))})),vl=function(t){var e;return!(!g(t)||"function"!=typeof(e=t.then))&&e},gl=function(t,e,n){if(!e.notified){e.notified=!0;var r=e.reactions;Xc((function(){for(var a=e.value,i=1==e.state,o=0;r.length>o;){var s,u,c,l=r[o++],h=i?l.ok:l.fail,f=l.resolve,p=l.reject,d=l.domain;try{h?(i||(2===e.rejection&&wl(t,e),e.rejection=1),!0===h?s=a:(d&&d.enter(),s=h(a),d&&(d.exit(),c=!0)),s===l.promise?p(ol("Promise-chain cycle")):(u=vl(s))?u.call(s,f,p):f(s)):p(a)}catch(t){d&&!c&&d.exit(),p(t)}}e.reactions=[],e.notified=!1,n&&!e.rejection&&bl(t,e)}))}},yl=function(t,e,n){var r,i;pl?((r=sl.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),a.dispatchEvent(r)):r={promise:e,reason:n},(i=a["on"+t])?i(r):"unhandledrejection"===t&&function(t,e){var n=a.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))}("Unhandled promise rejection",n)},bl=function(t,e){Qc.call(a,(function(){var n,r=e.value;if(xl(e)&&(n=Zc((function(){fl?ul.emit("unhandledRejection",r,t):yl("unhandledrejection",t,r)})),e.rejection=fl||xl(e)?2:1,n.error))throw n.value}))},xl=function(t){return 1!==t.rejection&&!t.parent},wl=function(t,e){Qc.call(a,(function(){fl?ul.emit("rejectionHandled",t):yl("rejectionhandled",t,e.value)}))},kl=function(t,e,n,r){return function(a){t(e,n,a,r)}},Sl=function(t,e,n,r){e.done||(e.done=!0,r&&(e=r),e.value=n,e.state=2,gl(t,e,!0))},Cl=function t(e,n,r,a){if(!n.done){n.done=!0,a&&(n=a);try{if(e===r)throw ol("Promise can't be resolved itself");var i=vl(r);i?Xc((function(){var a={done:!1};try{i.call(r,kl(t,e,a,n),kl(Sl,e,a,n))}catch(t){Sl(e,a,t,n)}})):(n.value=r,n.state=1,gl(e,n,!1))}catch(t){Sl(e,{done:!1},t,n)}}};dl&&(il=function(t){pc(this,il,el),ae(t),Gc.call(this);var e=nl(this);try{t(kl(Cl,this,e),kl(Sl,this,e))}catch(t){Sl(this,e,t)}},(Gc=function(t){rl(this,{type:el,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=fc(il.prototype,{then:function(t,e){var n=al(this),r=ll($i(this,il));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=fl?ul.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&gl(this,n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),qc=function(){var t=new Gc,e=nl(t);this.promise=t,this.resolve=kl(Cl,t,e),this.reject=kl(Sl,t,e)},Jc.f=ll=function(t){return t===il||t===Hc?new qc(t):hl(t)},"function"==typeof hc&&(Kc=hc.prototype.then,et(hc.prototype,"then",(function(t,e){var n=this;return new il((function(t,e){Kc.call(n,t,e)})).then(t,e)}),{unsafe:!0}),"function"==typeof cl&&Dt({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return $c(il,cl.apply(a,arguments))}}))),Dt({global:!0,wrap:!0,forced:dl},{Promise:il}),re(il,el,!1),Ya(el),Hc=at(el),Dt({target:el,stat:!0,forced:dl},{reject:function(t){var e=ll(this);return e.reject.call(void 0,t),e.promise}}),Dt({target:el,stat:!0,forced:dl},{resolve:function(t){return $c(this,t)}}),Dt({target:el,stat:!0,forced:ml},{all:function(t){var e=this,n=ll(e),r=n.resolve,a=n.reject,i=Zc((function(){var n=ae(e.resolve),i=[],o=0,s=1;bn(t,(function(t){var u=o++,c=!1;i.push(void 0),s++,n.call(e,t).then((function(t){c||(c=!0,i[u]=t,--s||r(i))}),a)})),--s||r(i)}));return i.error&&a(i.value),n.promise},race:function(t){var e=this,n=ll(e),r=n.reject,a=Zc((function(){var a=ae(e.resolve);bn(t,(function(t){a.call(e,t).then(n.resolve,r)}))}));return a.error&&r(a.value),n.promise}}),Dt({target:"Promise",stat:!0},{allSettled:function(t){var e=this,n=Jc.f(e),r=n.resolve,a=n.reject,i=Zc((function(){var n=ae(e.resolve),a=[],i=0,o=1;bn(t,(function(t){var s=i++,u=!1;a.push(void 0),o++,n.call(e,t).then((function(t){u||(u=!0,a[s]={status:"fulfilled",value:t},--o||r(a))}),(function(t){u||(u=!0,a[s]={status:"rejected",reason:t},--o||r(a))}))})),--o||r(a)}));return i.error&&a(i.value),n.promise}});var Rl=!!hc&&i((function(){hc.prototype.finally.call({then:function(){}},(function(){}))}));Dt({target:"Promise",proto:!0,real:!0,forced:Rl},{finally:function(t){var e=$i(this,at("Promise")),n="function"==typeof t;return this.then(n?function(n){return $c(e,t()).then((function(){return n}))}:t,n?function(n){return $c(e,t()).then((function(){throw n}))}:t)}}),"function"!=typeof hc||hc.prototype.finally||et(hc.prototype,"finally",at("Promise").prototype.finally);var Nl=function(t,e,n){var r=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),s=r?"set":"add",u=a[t],c=u&&u.prototype,l=u,h={},f=function(t){var e=c[t];et(c,t,"add"==t?function(t){return e.call(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!g(t))&&e.call(this,0===t?0:t)}:"get"==t?function(t){return o&&!g(t)?void 0:e.call(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!g(t))&&e.call(this,0===t?0:t)}:function(t,n){return e.call(this,0===t?0:t,n),this})};if(At(t,"function"!=typeof u||!(o||c.forEach&&!i((function(){(new u).entries().next()})))))l=n.getConstructor(e,t,r,s),nn.REQUIRED=!0;else if(At(t,!0)){var p=new l,d=p[s](o?{}:-0,1)!=p,m=i((function(){p.has(1)})),v=fr((function(t){new u(t)})),y=!o&&i((function(){for(var t=new u,e=5;e--;)t[s](e,e);return!t.has(-0)}));v||((l=e((function(e,n){pc(e,l,t);var a=Xo(new u,e,l);return null!=n&&bn(n,a[s],a,r),a}))).prototype=c,c.constructor=l),(m||y)&&(f("delete"),f("has"),r&&f("get")),(y||d)&&f(s),o&&c.clear&&delete c.clear}return h[t]=l,Dt({global:!0,forced:l!=u},h),re(l,t),o||n.setStrong(l,t,r),l},El=A.f,Il=nn.fastKey,Al=tt.set,Tl=tt.getterFor,Dl={getConstructor:function(t,e,n,r){var a=t((function(t,i){pc(t,a,e),Al(t,{type:e,index:jt(null),first:void 0,last:void 0,size:0}),o||(t.size=0),null!=i&&bn(i,t[r],t,n)})),i=Tl(e),s=function(t,e,n){var r,a,s=i(t),c=u(t,e);return c?c.value=n:(s.last=c={index:a=Il(e,!0),key:e,value:n,previous:r=s.last,next:void 0,removed:!1},s.first||(s.first=c),r&&(r.next=c),o?s.size++:t.size++,"F"!==a&&(s.index[a]=c)),t},u=function(t,e){var n,r=i(t),a=Il(e);if("F"!==a)return r.index[a];for(n=r.first;n;n=n.next)if(n.key==e)return n};return fc(a.prototype,{clear:function(){for(var t=i(this),e=t.index,n=t.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete e[n.index],n=n.next;t.first=t.last=void 0,o?t.size=0:this.size=0},delete:function(t){var e=i(this),n=u(this,t);if(n){var r=n.next,a=n.previous;delete e.index[n.index],n.removed=!0,a&&(a.next=r),r&&(r.previous=a),e.first==n&&(e.first=r),e.last==n&&(e.last=a),o?e.size--:this.size--}return!!n},forEach:function(t){for(var e,n=i(this),r=ie(t,arguments.length>1?arguments[1]:void 0,3);e=e?e.next:n.first;)for(r(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!u(this,t)}}),fc(a.prototype,n?{get:function(t){var e=u(this,t);return e&&e.value},set:function(t,e){return s(this,0===t?0:t,e)}}:{add:function(t){return s(this,t=0===t?0:t,t)}}),o&&El(a.prototype,"size",{get:function(){return i(this).size}}),a},setStrong:function(t,e,n){var r=e+" Iterator",a=Tl(e),i=Tl(r);ci(t,e,(function(t,e){Al(this,{type:r,target:t,state:a(t),kind:e,last:void 0})}),(function(){for(var t=i(this),e=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?"keys"==e?{value:n.key,done:!1}:"values"==e?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(t.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),Ya(e)}},_l=(Nl("Map",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),Dl),Nl("Set",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),Dl),nn.getWeakData),Ol=tt.set,Fl=tt.getterFor,Ml=le.find,Ll=le.findIndex,zl=0,Bl=function(t){return t.frozen||(t.frozen=new Pl)},Pl=function(){this.entries=[]},Wl=function(t,e){return Ml(t.entries,(function(t){return t[0]===e}))};Pl.prototype={get:function(t){var e=Wl(this,t);if(e)return e[1]},has:function(t){return!!Wl(this,t)},set:function(t,e){var n=Wl(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=Ll(this.entries,(function(e){return e[0]===t}));return~e&&this.entries.splice(e,1),!!~e}};var Vl={getConstructor:function(t,e,n,r){var a=t((function(t,i){pc(t,a,e),Ol(t,{type:e,id:zl++,frozen:void 0}),null!=i&&bn(i,t[r],t,n)})),i=Fl(e),o=function(t,e,n){var r=i(t),a=_l(E(e),!0);return!0===a?Bl(r).set(e,n):a[r.id]=n,t};return fc(a.prototype,{delete:function(t){var e=i(this);if(!g(t))return!1;var n=_l(t);return!0===n?Bl(e).delete(t):n&&x(n,e.id)&&delete n[e.id]},has:function(t){var e=i(this);if(!g(t))return!1;var n=_l(t);return!0===n?Bl(e).has(t):n&&x(n,e.id)}}),fc(a.prototype,n?{get:function(t){var e=i(this);if(g(t)){var n=_l(t);return!0===n?Bl(e).get(t):n?n[e.id]:void 0}},set:function(t,e){return o(this,t,e)}}:{add:function(t){return o(this,t,!0)}}),a}};n((function(t){var e,n=tt.enforce,r=!a.ActiveXObject&&"ActiveXObject"in a,i=Object.isExtensible,o=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},s=t.exports=Nl("WeakMap",o,Vl);if(P&&r){e=Vl.getConstructor(o,"WeakMap",!0),nn.REQUIRED=!0;var u=s.prototype,c=u.delete,l=u.has,h=u.get,f=u.set;fc(u,{delete:function(t){if(g(t)&&!i(t)){var r=n(this);return r.frozen||(r.frozen=new e),c.call(this,t)||r.frozen.delete(t)}return c.call(this,t)},has:function(t){if(g(t)&&!i(t)){var r=n(this);return r.frozen||(r.frozen=new e),l.call(this,t)||r.frozen.has(t)}return l.call(this,t)},get:function(t){if(g(t)&&!i(t)){var r=n(this);return r.frozen||(r.frozen=new e),l.call(this,t)?h.call(this,t):r.frozen.get(t)}return h.call(this,t)},set:function(t,r){if(g(t)&&!i(t)){var a=n(this);a.frozen||(a.frozen=new e),l.call(this,t)?f.call(this,t,r):a.frozen.set(t,r)}else f.call(this,t,r);return this}})}}));Nl("WeakSet",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),Vl);var Ul="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,jl=function(t){if(void 0===t)return 0;var e=st(t),n=ct(e);if(e!==n)throw RangeError("Wrong length or index");return n},Gl=Math.abs,ql=Math.pow,Hl=Math.floor,Kl=Math.log,Xl=Math.LN2,Yl=function(t,e,n){var r,a,i,o=new Array(n),s=8*n-e-1,u=(1<<s)-1,c=u>>1,l=23===e?ql(2,-24)-ql(2,-77):0,h=t<0||0===t&&1/t<0?1:0,f=0;for((t=Gl(t))!=t||t===1/0?(a=t!=t?1:0,r=u):(r=Hl(Kl(t)/Xl),t*(i=ql(2,-r))<1&&(r--,i*=2),(t+=r+c>=1?l/i:l*ql(2,1-c))*i>=2&&(r++,i/=2),r+c>=u?(a=0,r=u):r+c>=1?(a=(t*i-1)*ql(2,e),r+=c):(a=t*ql(2,c-1)*ql(2,e),r=0));e>=8;o[f++]=255&a,a/=256,e-=8);for(r=r<<e|a,s+=e;s>0;o[f++]=255&r,r/=256,s-=8);return o[--f]|=128*h,o},Jl=function(t,e){var n,r=t.length,a=8*r-e-1,i=(1<<a)-1,o=i>>1,s=a-7,u=r-1,c=t[u--],l=127&c;for(c>>=7;s>0;l=256*l+t[u],u--,s-=8);for(n=l&(1<<-s)-1,l>>=-s,s+=e;s>0;n=256*n+t[u],u--,s-=8);if(0===l)l=1-o;else{if(l===i)return n?NaN:c?-1/0:1/0;n+=ql(2,e),l-=o}return(c?-1:1)*n*ql(2,l-e)},$l=bt.f,Zl=A.f,Ql=tt.get,th=tt.set,eh=a.ArrayBuffer,nh=eh,rh=a.DataView,ah=rh&&rh.prototype,ih=Object.prototype,oh=a.RangeError,sh=Yl,uh=Jl,ch=function(t){return[255&t]},lh=function(t){return[255&t,t>>8&255]},hh=function(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]},fh=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},ph=function(t){return sh(t,23,4)},dh=function(t){return sh(t,52,8)},mh=function(t,e){Zl(t.prototype,e,{get:function(){return Ql(this)[e]}})},vh=function(t,e,n,r){var a=jl(n),i=Ql(t);if(a+e>i.byteLength)throw oh("Wrong index");var o=Ql(i.buffer).bytes,s=a+i.byteOffset,u=o.slice(s,s+e);return r?u:u.reverse()},gh=function(t,e,n,r,a,i){var o=jl(n),s=Ql(t);if(o+e>s.byteLength)throw oh("Wrong index");for(var u=Ql(s.buffer).bytes,c=o+s.byteOffset,l=r(+a),h=0;h<e;h++)u[c+h]=l[i?h:e-h-1]};if(Ul){if(!i((function(){eh(1)}))||!i((function(){new eh(-1)}))||i((function(){return new eh,new eh(1.5),new eh(NaN),"ArrayBuffer"!=eh.name}))){for(var yh,bh=(nh=function(t){return pc(this,nh),new eh(jl(t))}).prototype=eh.prototype,xh=$l(eh),wh=0;xh.length>wh;)(yh=xh[wh++])in nh||T(nh,yh,eh[yh]);bh.constructor=nh}qn&&In(ah)!==ih&&qn(ah,ih);var kh=new rh(new nh(2)),Sh=ah.setInt8;kh.setInt8(0,2147483648),kh.setInt8(1,2147483649),!kh.getInt8(0)&&kh.getInt8(1)||fc(ah,{setInt8:function(t,e){Sh.call(this,t,e<<24>>24)},setUint8:function(t,e){Sh.call(this,t,e<<24>>24)}},{unsafe:!0})}else nh=function(t){pc(this,nh,"ArrayBuffer");var e=jl(t);th(this,{bytes:Vr.call(new Array(e),0),byteLength:e}),o||(this.byteLength=e)},rh=function(t,e,n){pc(this,rh,"DataView"),pc(t,nh,"DataView");var r=Ql(t).byteLength,a=st(e);if(a<0||a>r)throw oh("Wrong offset");if(a+(n=void 0===n?r-a:ct(n))>r)throw oh("Wrong length");th(this,{buffer:t,byteLength:n,byteOffset:a}),o||(this.buffer=t,this.byteLength=n,this.byteOffset=a)},o&&(mh(nh,"byteLength"),mh(rh,"buffer"),mh(rh,"byteLength"),mh(rh,"byteOffset")),fc(rh.prototype,{getInt8:function(t){return vh(this,1,t)[0]<<24>>24},getUint8:function(t){return vh(this,1,t)[0]},getInt16:function(t){var e=vh(this,2,t,arguments.length>1?arguments[1]:void 0);return(e[1]<<8|e[0])<<16>>16},getUint16:function(t){var e=vh(this,2,t,arguments.length>1?arguments[1]:void 0);return e[1]<<8|e[0]},getInt32:function(t){return fh(vh(this,4,t,arguments.length>1?arguments[1]:void 0))},getUint32:function(t){return fh(vh(this,4,t,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(t){return uh(vh(this,4,t,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(t){return uh(vh(this,8,t,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(t,e){gh(this,1,t,ch,e)},setUint8:function(t,e){gh(this,1,t,ch,e)},setInt16:function(t,e){gh(this,2,t,lh,e,arguments.length>2?arguments[2]:void 0)},setUint16:function(t,e){gh(this,2,t,lh,e,arguments.length>2?arguments[2]:void 0)},setInt32:function(t,e){gh(this,4,t,hh,e,arguments.length>2?arguments[2]:void 0)},setUint32:function(t,e){gh(this,4,t,hh,e,arguments.length>2?arguments[2]:void 0)},setFloat32:function(t,e){gh(this,4,t,ph,e,arguments.length>2?arguments[2]:void 0)},setFloat64:function(t,e){gh(this,8,t,dh,e,arguments.length>2?arguments[2]:void 0)}});re(nh,"ArrayBuffer"),re(rh,"DataView");var Ch={ArrayBuffer:nh,DataView:rh},Rh=Ch.ArrayBuffer,Nh=a.ArrayBuffer;Dt({global:!0,forced:Nh!==Rh},{ArrayBuffer:Rh}),Ya("ArrayBuffer");var Eh,Ih=A.f,Ah=a.Int8Array,Th=Ah&&Ah.prototype,Dh=a.Uint8ClampedArray,_h=Dh&&Dh.prototype,Oh=Ah&&In(Ah),Fh=Th&&In(Th),Mh=Object.prototype,Lh=Mh.isPrototypeOf,zh=$t("toStringTag"),Bh=j("TYPED_ARRAY_TAG"),Ph=Ul&&!!qn&&"Opera"!==mn(a.opera),Wh=!1,Vh={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Uh=function(t){return g(t)&&x(Vh,mn(t))};for(Eh in Vh)a[Eh]||(Ph=!1);if((!Ph||"function"!=typeof Oh||Oh===Function.prototype)&&(Oh=function(){throw TypeError("Incorrect invocation")},Ph))for(Eh in Vh)a[Eh]&&qn(a[Eh],Oh);if((!Ph||!Fh||Fh===Mh)&&(Fh=Oh.prototype,Ph))for(Eh in Vh)a[Eh]&&qn(a[Eh].prototype,Fh);if(Ph&&In(_h)!==Fh&&qn(_h,Fh),o&&!x(Fh,zh))for(Eh in Wh=!0,Ih(Fh,zh,{get:function(){return g(this)?this[Bh]:void 0}}),Vh)a[Eh]&&T(a[Eh],Bh,Eh);var jh={NATIVE_ARRAY_BUFFER_VIEWS:Ph,TYPED_ARRAY_TAG:Wh&&Bh,aTypedArray:function(t){if(Uh(t))return t;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(t){if(qn){if(Lh.call(Oh,t))return t}else for(var e in Vh)if(x(Vh,Eh)){var n=a[e];if(n&&(t===n||Lh.call(n,t)))return t}throw TypeError("Target is not a typed array constructor")},exportTypedArrayMethod:function(t,e,n){if(o){if(n)for(var r in Vh){var i=a[r];i&&x(i.prototype,t)&&delete i.prototype[t]}Fh[t]&&!n||et(Fh,t,n?e:Ph&&Th[t]||e)}},exportTypedArrayStaticMethod:function(t,e,n){var r,i;if(o){if(qn){if(n)for(r in Vh)(i=a[r])&&x(i,t)&&delete i[t];if(Oh[t]&&!n)return;try{return et(Oh,t,n?e:Ph&&Ah[t]||e)}catch(t){}}for(r in Vh)!(i=a[r])||i[t]&&!n||et(i,t,e)}},isView:function(t){var e=mn(t);return"DataView"===e||x(Vh,e)},isTypedArray:Uh,TypedArray:Oh,TypedArrayPrototype:Fh};Dt({target:"ArrayBuffer",stat:!0,forced:!jh.NATIVE_ARRAY_BUFFER_VIEWS},{isView:jh.isView});var Gh=Ch.ArrayBuffer,qh=Ch.DataView,Hh=Gh.prototype.slice,Kh=i((function(){return!new Gh(2).slice(1,void 0).byteLength}));Dt({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:Kh},{slice:function(t,e){if(void 0!==Hh&&void 0===e)return Hh.call(E(this),t);for(var n=E(this).byteLength,r=ft(t,n),a=ft(void 0===e?n:e,n),i=new($i(this,Gh))(ct(a-r)),o=new qh(this),s=new qh(i),u=0;r<a;)s.setUint8(u++,o.getUint8(r++));return i}}),Dt({global:!0,forced:!Ul},{DataView:Ch.DataView});var Xh=jh.NATIVE_ARRAY_BUFFER_VIEWS,Yh=a.ArrayBuffer,Jh=a.Int8Array,$h=!Xh||!i((function(){Jh(1)}))||!i((function(){new Jh(-1)}))||!fr((function(t){new Jh,new Jh(null),new Jh(1.5),new Jh(t)}),!0)||i((function(){return 1!==new Jh(new Yh(2),1,void 0).length})),Zh=function(t,e){var n=function(t){var e=st(t);if(e<0)throw RangeError("The argument can't be less than 0");return e}(t);if(n%e)throw RangeError("Wrong offset");return n},Qh=jh.aTypedArrayConstructor,tf=function(t){var e,n,r,a,i,o,s=Mt(t),u=arguments.length,c=u>1?arguments[1]:void 0,l=void 0!==c,h=gn(s);if(null!=h&&!ln(h))for(o=(i=h.call(s)).next,s=[];!(a=o.call(i)).done;)s.push(a.value);for(l&&u>2&&(c=ie(c,arguments[2],2)),n=ct(s.length),r=new(Qh(this))(n),e=0;n>e;e++)r[e]=l?c(s[e],e):s[e];return r},ef=n((function(t){var e=bt.f,n=le.forEach,r=tt.get,i=tt.set,s=A.f,u=N.f,c=Math.round,h=a.RangeError,f=Ch.ArrayBuffer,p=Ch.DataView,d=jh.NATIVE_ARRAY_BUFFER_VIEWS,m=jh.TYPED_ARRAY_TAG,v=jh.TypedArray,b=jh.TypedArrayPrototype,w=jh.aTypedArrayConstructor,k=jh.isTypedArray,S=function(t,e){for(var n=0,r=e.length,a=new(w(t))(r);r>n;)a[n]=e[n++];return a},C=function(t,e){s(t,e,{get:function(){return r(this)[e]}})},R=function(t){var e;return t instanceof f||"ArrayBuffer"==(e=mn(t))||"SharedArrayBuffer"==e},E=function(t,e){return k(t)&&"symbol"!=typeof e&&e in t&&String(+e)==String(e)},I=function(t,e){return E(t,e=y(e,!0))?l(2,t[e]):u(t,e)},D=function(t,e,n){return!(E(t,e=y(e,!0))&&g(n)&&x(n,"value"))||x(n,"get")||x(n,"set")||n.configurable||x(n,"writable")&&!n.writable||x(n,"enumerable")&&!n.enumerable?s(t,e,n):(t[e]=n.value,t)};o?(d||(N.f=I,A.f=D,C(b,"buffer"),C(b,"byteOffset"),C(b,"byteLength"),C(b,"length")),Dt({target:"Object",stat:!0,forced:!d},{getOwnPropertyDescriptor:I,defineProperty:D}),t.exports=function(t,o,u){var l=t.match(/\d+$/)[0]/8,y=t+(u?"Clamped":"")+"Array",x="get"+t,w="set"+t,C=a[y],N=C,E=N&&N.prototype,I={},A=function(t,e){s(t,e,{get:function(){return function(t,e){var n=r(t);return n.view[x](e*l+n.byteOffset,!0)}(this,e)},set:function(t){return function(t,e,n){var a=r(t);u&&(n=(n=c(n))<0?0:n>255?255:255&n),a.view[w](e*l+a.byteOffset,n,!0)}(this,e,t)},enumerable:!0})};d?$h&&(N=o((function(t,e,n,r){return pc(t,N,y),Xo(g(e)?R(e)?void 0!==r?new C(e,Zh(n,l),r):void 0!==n?new C(e,Zh(n,l)):new C(e):k(e)?S(N,e):tf.call(N,e):new C(jl(e)),t,N)})),qn&&qn(N,v),n(e(C),(function(t){t in N||T(N,t,C[t])})),N.prototype=E):(N=o((function(t,e,n,r){pc(t,N,y);var a,o,s,u=0,c=0;if(g(e)){if(!R(e))return k(e)?S(N,e):tf.call(N,e);a=e,c=Zh(n,l);var d=e.byteLength;if(void 0===r){if(d%l)throw h("Wrong length");if((o=d-c)<0)throw h("Wrong length")}else if((o=ct(r)*l)+c>d)throw h("Wrong length");s=o/l}else s=jl(e),a=new f(o=s*l);for(i(t,{buffer:a,byteOffset:c,byteLength:o,length:s,view:new p(a)});u<s;)A(t,u++)})),qn&&qn(N,v),E=N.prototype=jt(b)),E.constructor!==N&&T(E,"constructor",N),m&&T(E,m,y),I[y]=N,Dt({global:!0,forced:N!=C,sham:!d},I),"BYTES_PER_ELEMENT"in N||T(N,"BYTES_PER_ELEMENT",l),"BYTES_PER_ELEMENT"in E||T(E,"BYTES_PER_ELEMENT",l),Ya(y)}):t.exports=function(){}}));ef("Int8",(function(t){return function(e,n,r){return t(this,e,n,r)}})),ef("Uint8",(function(t){return function(e,n,r){return t(this,e,n,r)}})),ef("Uint8",(function(t){return function(e,n,r){return t(this,e,n,r)}}),!0),ef("Int16",(function(t){return function(e,n,r){return t(this,e,n,r)}})),ef("Uint16",(function(t){return function(e,n,r){return t(this,e,n,r)}})),ef("Int32",(function(t){return function(e,n,r){return t(this,e,n,r)}})),ef("Uint32",(function(t){return function(e,n,r){return t(this,e,n,r)}})),ef("Float32",(function(t){return function(e,n,r){return t(this,e,n,r)}})),ef("Float64",(function(t){return function(e,n,r){return t(this,e,n,r)}})),(0,jh.exportTypedArrayStaticMethod)("from",tf,$h);var nf=jh.aTypedArrayConstructor;(0,jh.exportTypedArrayStaticMethod)("of",(function(){for(var t=0,e=arguments.length,n=new(nf(this))(e);e>t;)n[t]=arguments[t++];return n}),$h);var rf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("copyWithin",(function(t,e){return Ar.call(rf(this),t,e,arguments.length>2?arguments[2]:void 0)}));var af=le.every,of=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("every",(function(t){return af(of(this),t,arguments.length>1?arguments[1]:void 0)}));var sf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("fill",(function(t){return Vr.apply(sf(this),arguments)}));var uf=le.filter,cf=jh.aTypedArray,lf=jh.aTypedArrayConstructor;(0,jh.exportTypedArrayMethod)("filter",(function(t){for(var e=uf(cf(this),t,arguments.length>1?arguments[1]:void 0),n=$i(this,this.constructor),r=0,a=e.length,i=new(lf(n))(a);a>r;)i[r]=e[r++];return i}));var hf=le.find,ff=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("find",(function(t){return hf(ff(this),t,arguments.length>1?arguments[1]:void 0)}));var pf=le.findIndex,df=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("findIndex",(function(t){return pf(df(this),t,arguments.length>1?arguments[1]:void 0)}));var mf=le.forEach,vf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("forEach",(function(t){mf(vf(this),t,arguments.length>1?arguments[1]:void 0)}));var gf=dt.includes,yf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("includes",(function(t){return gf(yf(this),t,arguments.length>1?arguments[1]:void 0)}));var bf=dt.indexOf,xf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("indexOf",(function(t){return bf(xf(this),t,arguments.length>1?arguments[1]:void 0)}));var wf=$t("iterator"),kf=a.Uint8Array,Sf=fi.values,Cf=fi.keys,Rf=fi.entries,Nf=jh.aTypedArray,Ef=jh.exportTypedArrayMethod,If=kf&&kf.prototype[wf],Af=!!If&&("values"==If.name||null==If.name),Tf=function(){return Sf.call(Nf(this))};Ef("entries",(function(){return Rf.call(Nf(this))})),Ef("keys",(function(){return Cf.call(Nf(this))})),Ef("values",Tf,!Af),Ef(wf,Tf,!Af);var Df=jh.aTypedArray,_f=[].join;(0,jh.exportTypedArrayMethod)("join",(function(t){return _f.apply(Df(this),arguments)}));var Of=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("lastIndexOf",(function(t){return ga.apply(Of(this),arguments)}));var Ff=le.map,Mf=jh.aTypedArray,Lf=jh.aTypedArrayConstructor;(0,jh.exportTypedArrayMethod)("map",(function(t){return Ff(Mf(this),t,arguments.length>1?arguments[1]:void 0,(function(t,e){return new(Lf($i(t,t.constructor)))(e)}))}));var zf=ka.left,Bf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("reduce",(function(t){return zf(Bf(this),t,arguments.length,arguments.length>1?arguments[1]:void 0)}));var Pf=ka.right,Wf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("reduceRight",(function(t){return Pf(Wf(this),t,arguments.length,arguments.length>1?arguments[1]:void 0)}));var Vf=jh.aTypedArray,Uf=jh.exportTypedArrayMethod,jf=Math.floor;Uf("reverse",(function(){for(var t,e=Vf(this).length,n=jf(e/2),r=0;r<n;)t=this[r],this[r++]=this[--e],this[e]=t;return this}));var Gf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("set",(function(t){Gf(this);var e=Zh(arguments.length>1?arguments[1]:void 0,1),n=this.length,r=Mt(t),a=ct(r.length),i=0;if(a+e>n)throw RangeError("Wrong length");for(;i<a;)this[e+i]=r[i++]}),i((function(){new Int8Array(1).set({})})));var qf=jh.aTypedArray,Hf=jh.aTypedArrayConstructor,Kf=[].slice;(0,jh.exportTypedArrayMethod)("slice",(function(t,e){for(var n=Kf.call(qf(this),t,e),r=$i(this,this.constructor),a=0,i=n.length,o=new(Hf(r))(i);i>a;)o[a]=n[a++];return o}),i((function(){new Int8Array(1).slice()})));var Xf=le.some,Yf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("some",(function(t){return Xf(Yf(this),t,arguments.length>1?arguments[1]:void 0)}));var Jf=jh.aTypedArray,$f=[].sort;(0,jh.exportTypedArrayMethod)("sort",(function(t){return $f.call(Jf(this),t)}));var Zf=jh.aTypedArray;(0,jh.exportTypedArrayMethod)("subarray",(function(t,e){var n=Zf(this),r=n.length,a=ft(t,r);return new($i(n,n.constructor))(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,ct((void 0===e?r:ft(e,r))-a))}));var Qf=a.Int8Array,tp=jh.aTypedArray,ep=jh.exportTypedArrayMethod,np=[].toLocaleString,rp=[].slice,ap=!!Qf&&i((function(){np.call(new Qf(1))}));ep("toLocaleString",(function(){return np.apply(ap?rp.call(tp(this)):tp(this),arguments)}),i((function(){return[1,2].toLocaleString()!=new Qf([1,2]).toLocaleString()}))||!i((function(){Qf.prototype.toLocaleString.call([1,2])})));var ip=jh.exportTypedArrayMethod,op=a.Uint8Array,sp=op&&op.prototype||{},up=[].toString,cp=[].join;i((function(){up.call({})}))&&(up=function(){return cp.call(this)});var lp=sp.toString!=up;ip("toString",up,lp);var hp=at("Reflect","apply"),fp=Function.apply,pp=!i((function(){hp((function(){}))}));Dt({target:"Reflect",stat:!0,forced:pp},{apply:function(t,e,n){return ae(t),E(n),hp?hp(t,e,n):fp.call(t,e,n)}});var dp=at("Reflect","construct"),mp=i((function(){function t(){}return!(dp((function(){}),[],t)instanceof t)})),vp=!i((function(){dp((function(){}))})),gp=mp||vp;Dt({target:"Reflect",stat:!0,forced:gp,sham:gp},{construct:function(t,e){ae(t),E(e);var n=arguments.length<3?t:ae(arguments[2]);if(vp&&!mp)return dp(t,e,n);if(t==n){switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3])}var r=[null];return r.push.apply(r,e),new(tr.apply(t,r))}var a=n.prototype,i=jt(g(a)?a:Object.prototype),o=Function.apply.call(t,i,e);return g(o)?o:i}});var yp=i((function(){Reflect.defineProperty(A.f({},1,{value:1}),1,{value:2})}));Dt({target:"Reflect",stat:!0,forced:yp,sham:!o},{defineProperty:function(t,e,n){E(t);var r=y(e,!0);E(n);try{return A.f(t,r,n),!0}catch(t){return!1}}});var bp=N.f;Dt({target:"Reflect",stat:!0},{deleteProperty:function(t,e){var n=bp(E(t),e);return!(n&&!n.configurable)&&delete t[e]}}),Dt({target:"Reflect",stat:!0},{get:function t(e,n){var r,a,i=arguments.length<3?e:arguments[2];return E(e)===i?e[n]:(r=N.f(e,n))?x(r,"value")?r.value:void 0===r.get?void 0:r.get.call(i):g(a=In(e))?t(a,n,i):void 0}}),Dt({target:"Reflect",stat:!0,sham:!o},{getOwnPropertyDescriptor:function(t,e){return N.f(E(t),e)}}),Dt({target:"Reflect",stat:!0,sham:!Rn},{getPrototypeOf:function(t){return In(E(t))}}),Dt({target:"Reflect",stat:!0},{has:function(t,e){return e in t}});var xp=Object.isExtensible;Dt({target:"Reflect",stat:!0},{isExtensible:function(t){return E(t),!xp||xp(t)}}),Dt({target:"Reflect",stat:!0},{ownKeys:wt}),Dt({target:"Reflect",stat:!0,sham:!en},{preventExtensions:function(t){E(t);try{var e=at("Object","preventExtensions");return e&&e(t),!0}catch(t){return!1}}});var wp=i((function(){var t=A.f({},"a",{configurable:!0});return!1!==Reflect.set(In(t),"a",1,t)}));Dt({target:"Reflect",stat:!0,forced:wp},{set:function t(e,n,r){var a,i,o=arguments.length<4?e:arguments[3],s=N.f(E(e),n);if(!s){if(g(i=In(e)))return t(i,n,r,o);s=l(0)}if(x(s,"value")){if(!1===s.writable||!g(o))return!1;if(a=N.f(o,n)){if(a.get||a.set||!1===a.writable)return!1;a.value=r,A.f(o,n,a)}else A.f(o,n,l(0,r));return!0}return void 0!==s.set&&(s.set.call(o,r),!0)}}),qn&&Dt({target:"Reflect",stat:!0},{setPrototypeOf:function(t,e){E(t),Gn(e);try{return qn(t,e),!0}catch(t){return!1}}});var kp={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0};for(var Sp in kp){var Cp=a[Sp],Rp=Cp&&Cp.prototype;if(Rp&&Rp.forEach!==ea)try{T(Rp,"forEach",ea)}catch(t){Rp.forEach=ea}}var Np=$t("iterator"),Ep=$t("toStringTag"),Ip=fi.values;for(var Ap in kp){var Tp=a[Ap],Dp=Tp&&Tp.prototype;if(Dp){if(Dp[Np]!==Ip)try{T(Dp,Np,Ip)}catch(t){Dp[Np]=Ip}if(Dp[Ep]||T(Dp,Ep,Ap),kp[Ap])for(var _p in fi)if(Dp[_p]!==fi[_p])try{T(Dp,_p,fi[_p])}catch(t){Dp[_p]=fi[_p]}}}var Op=!a.setImmediate||!a.clearImmediate;Dt({global:!0,bind:!0,enumerable:!0,forced:Op},{setImmediate:Mc.set,clearImmediate:Mc.clear});var Fp=a.process,Mp="process"==f(Fp);Dt({global:!0,enumerable:!0,noTargetGet:!0},{queueMicrotask:function(t){var e=Mp&&Fp.domain;Xc(e?e.bind(t):t)}});var Lp=[].slice,zp=/MSIE .\./.test(gr),Bp=function(t){return function(e,n){var r=arguments.length>2,a=r?Lp.call(arguments,2):void 0;return t(r?function(){("function"==typeof e?e:Function(e)).apply(this,a)}:e,n)}};Dt({global:!0,bind:!0,forced:zp},{setTimeout:Bp(a.setTimeout),setInterval:Bp(a.setInterval)});var Pp=$t("iterator"),Wp=!i((function(){var t=new URL("b?a=1&b=2&c=3","http://a"),e=t.searchParams,n="";return t.pathname="c%20d",e.forEach((function(t,r){e.delete("b"),n+=r+t})),!e.sort||"http://a/c%20d?a=1&c=3"!==t.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[Pp]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),Vp=/[^\0-\u007E]/,Up=/[.\u3002\uFF0E\uFF61]/g,jp="Overflow: input needs wider integers to process",Gp=Math.floor,qp=String.fromCharCode,Hp=function(t){return t+22+75*(t<26)},Kp=function(t,e,n){var r=0;for(t=n?Gp(t/700):t>>1,t+=Gp(t/e);t>455;r+=36)t=Gp(t/35);return Gp(r+36*t/(t+38))},Xp=function(t){var e,n,r=[],a=(t=function(t){for(var e=[],n=0,r=t.length;n<r;){var a=t.charCodeAt(n++);if(a>=55296&&a<=56319&&n<r){var i=t.charCodeAt(n++);56320==(64512&i)?e.push(((1023&a)<<10)+(1023&i)+65536):(e.push(a),n--)}else e.push(a)}return e}(t)).length,i=128,o=0,s=72;for(e=0;e<t.length;e++)(n=t[e])<128&&r.push(qp(n));var u=r.length,c=u;for(u&&r.push("-");c<a;){var l=2147483647;for(e=0;e<t.length;e++)(n=t[e])>=i&&n<l&&(l=n);var h=c+1;if(l-i>Gp((2147483647-o)/h))throw RangeError(jp);for(o+=(l-i)*h,i=l,e=0;e<t.length;e++){if((n=t[e])<i&&++o>2147483647)throw RangeError(jp);if(n==i){for(var f=o,p=36;;p+=36){var d=p<=s?1:p>=s+26?26:p-s;if(f<d)break;var m=f-d,v=36-d;r.push(qp(Hp(d+m%v))),f=Gp(m/v)}r.push(qp(Hp(f))),s=Kp(o,h,c==u),o=0,++c}}++o,++i}return r.join("")},Yp=function(t){var e=gn(t);if("function"!=typeof e)throw TypeError(String(t)+" is not iterable");return E(e.call(t))},Jp=at("fetch"),$p=at("Headers"),Zp=$t("iterator"),Qp=tt.set,td=tt.getterFor("URLSearchParams"),ed=tt.getterFor("URLSearchParamsIterator"),nd=/\+/g,rd=Array(4),ad=function(t){return rd[t-1]||(rd[t-1]=RegExp("((?:%[\\da-f]{2}){"+t+"})","gi"))},id=function(t){try{return decodeURIComponent(t)}catch(e){return t}},od=function(t){var e=t.replace(nd," "),n=4;try{return decodeURIComponent(e)}catch(t){for(;n;)e=e.replace(ad(n--),id);return e}},sd=/[!'()~]|%20/g,ud={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},cd=function(t){return ud[t]},ld=function(t){return encodeURIComponent(t).replace(sd,cd)},hd=function(t,e){if(e)for(var n,r,a=e.split("&"),i=0;i<a.length;)(n=a[i++]).length&&(r=n.split("="),t.push({key:od(r.shift()),value:od(r.join("="))}))},fd=function(t){this.entries.length=0,hd(this.entries,t)},pd=function(t,e){if(t<e)throw TypeError("Not enough arguments")},dd=ai((function(t,e){Qp(this,{type:"URLSearchParamsIterator",iterator:Yp(td(t).entries),kind:e})}),"Iterator",(function(){var t=ed(this),e=t.kind,n=t.iterator.next(),r=n.value;return n.done||(n.value="keys"===e?r.key:"values"===e?r.value:[r.key,r.value]),n})),md=function(){pc(this,md,"URLSearchParams");var t,e,n,r,a,i,o,s,u,c=arguments.length>0?arguments[0]:void 0,l=this,h=[];if(Qp(l,{type:"URLSearchParams",entries:h,updateURL:function(){},updateSearchParams:fd}),void 0!==c)if(g(c))if("function"==typeof(t=gn(c)))for(n=(e=t.call(c)).next;!(r=n.call(e)).done;){if((o=(i=(a=Yp(E(r.value))).next).call(a)).done||(s=i.call(a)).done||!i.call(a).done)throw TypeError("Expected sequence with length 2");h.push({key:o.value+"",value:s.value+""})}else for(u in c)x(c,u)&&h.push({key:u,value:c[u]+""});else hd(h,"string"==typeof c?"?"===c.charAt(0)?c.slice(1):c:c+"")},vd=md.prototype;fc(vd,{append:function(t,e){pd(arguments.length,2);var n=td(this);n.entries.push({key:t+"",value:e+""}),n.updateURL()},delete:function(t){pd(arguments.length,1);for(var e=td(this),n=e.entries,r=t+"",a=0;a<n.length;)n[a].key===r?n.splice(a,1):a++;e.updateURL()},get:function(t){pd(arguments.length,1);for(var e=td(this).entries,n=t+"",r=0;r<e.length;r++)if(e[r].key===n)return e[r].value;return null},getAll:function(t){pd(arguments.length,1);for(var e=td(this).entries,n=t+"",r=[],a=0;a<e.length;a++)e[a].key===n&&r.push(e[a].value);return r},has:function(t){pd(arguments.length,1);for(var e=td(this).entries,n=t+"",r=0;r<e.length;)if(e[r++].key===n)return!0;return!1},set:function(t,e){pd(arguments.length,1);for(var n,r=td(this),a=r.entries,i=!1,o=t+"",s=e+"",u=0;u<a.length;u++)(n=a[u]).key===o&&(i?a.splice(u--,1):(i=!0,n.value=s));i||a.push({key:o,value:s}),r.updateURL()},sort:function(){var t,e,n,r=td(this),a=r.entries,i=a.slice();for(a.length=0,n=0;n<i.length;n++){for(t=i[n],e=0;e<n;e++)if(a[e].key>t.key){a.splice(e,0,t);break}e===n&&a.push(t)}r.updateURL()},forEach:function(t){for(var e,n=td(this).entries,r=ie(t,arguments.length>1?arguments[1]:void 0,3),a=0;a<n.length;)r((e=n[a++]).value,e.key,this)},keys:function(){return new dd(this,"keys")},values:function(){return new dd(this,"values")},entries:function(){return new dd(this,"entries")}},{enumerable:!0}),et(vd,Zp,vd.entries),et(vd,"toString",(function(){for(var t,e=td(this).entries,n=[],r=0;r<e.length;)t=e[r++],n.push(ld(t.key)+"="+ld(t.value));return n.join("&")}),{enumerable:!0}),re(md,"URLSearchParams"),Dt({global:!0,forced:!Wp},{URLSearchParams:md}),Wp||"function"!=typeof Jp||"function"!=typeof $p||Dt({global:!0,enumerable:!0,forced:!0},{fetch:function(t){var e,n,r,a=[t];return arguments.length>1&&(e=arguments[1],g(e)&&(n=e.body,"URLSearchParams"===mn(n)&&((r=e.headers?new $p(e.headers):new $p).has("content-type")||r.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),e=jt(e,{body:l(0,String(n)),headers:l(0,r)}))),a.push(e)),Jp.apply(this,a)}});var gd,yd={URLSearchParams:md,getState:td},bd=gi.codeAt,xd=a.URL,wd=yd.URLSearchParams,kd=yd.getState,Sd=tt.set,Cd=tt.getterFor("URL"),Rd=Math.floor,Nd=Math.pow,Ed=/[A-Za-z]/,Id=/[\d+-.A-Za-z]/,Ad=/\d/,Td=/^(0x|0X)/,Dd=/^[0-7]+$/,_d=/^\d+$/,Od=/^[\dA-Fa-f]+$/,Fd=/[\u0000\u0009\u000A\u000D #%/:?@[\\]]/,Md=/[\u0000\u0009\u000A\u000D #/:?@[\\]]/,Ld=/^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g,zd=/[\u0009\u000A\u000D]/g,Bd=function(t,e){var n,r,a;if("["==e.charAt(0)){if("]"!=e.charAt(e.length-1))return"Invalid host";if(!(n=Wd(e.slice(1,-1))))return"Invalid host";t.host=n}else if(Xd(t)){if(e=function(t){var e,n,r=[],a=t.toLowerCase().replace(Up,".").split(".");for(e=0;e<a.length;e++)n=a[e],r.push(Vp.test(n)?"xn--"+Xp(n):n);return r.join(".")}(e),Fd.test(e))return"Invalid host";if(null===(n=Pd(e)))return"Invalid host";t.host=n}else{if(Md.test(e))return"Invalid host";for(n="",r=sr(e),a=0;a<r.length;a++)n+=Hd(r[a],Ud);t.host=n}},Pd=function(t){var e,n,r,a,i,o,s,u=t.split(".");if(u.length&&""==u[u.length-1]&&u.pop(),(e=u.length)>4)return t;for(n=[],r=0;r<e;r++){if(""==(a=u[r]))return t;if(i=10,a.length>1&&"0"==a.charAt(0)&&(i=Td.test(a)?16:8,a=a.slice(8==i?1:2)),""===a)o=0;else{if(!(10==i?_d:8==i?Dd:Od).test(a))return t;o=parseInt(a,i)}n.push(o)}for(r=0;r<e;r++)if(o=n[r],r==e-1){if(o>=Nd(256,5-e))return null}else if(o>255)return null;for(s=n.pop(),r=0;r<n.length;r++)s+=n[r]*Nd(256,3-r);return s},Wd=function(t){var e,n,r,a,i,o,s,u=[0,0,0,0,0,0,0,0],c=0,l=null,h=0,f=function(){return t.charAt(h)};if(":"==f()){if(":"!=t.charAt(1))return;h+=2,l=++c}for(;f();){if(8==c)return;if(":"!=f()){for(e=n=0;n<4&&Od.test(f());)e=16*e+parseInt(f(),16),h++,n++;if("."==f()){if(0==n)return;if(h-=n,c>6)return;for(r=0;f();){if(a=null,r>0){if(!("."==f()&&r<4))return;h++}if(!Ad.test(f()))return;for(;Ad.test(f());){if(i=parseInt(f(),10),null===a)a=i;else{if(0==a)return;a=10*a+i}if(a>255)return;h++}u[c]=256*u[c]+a,2!=++r&&4!=r||c++}if(4!=r)return;break}if(":"==f()){if(h++,!f())return}else if(f())return;u[c++]=e}else{if(null!==l)return;h++,l=++c}}if(null!==l)for(o=c-l,c=7;0!=c&&o>0;)s=u[c],u[c--]=u[l+o-1],u[l+--o]=s;else if(8!=c)return;return u},Vd=function(t){var e,n,r,a;if("number"==typeof t){for(e=[],n=0;n<4;n++)e.unshift(t%256),t=Rd(t/256);return e.join(".")}if("object"==typeof t){for(e="",r=function(t){for(var e=null,n=1,r=null,a=0,i=0;i<8;i++)0!==t[i]?(a>n&&(e=r,n=a),r=null,a=0):(null===r&&(r=i),++a);return a>n&&(e=r,n=a),e}(t),n=0;n<8;n++)a&&0===t[n]||(a&&(a=!1),r===n?(e+=n?":":"::",a=!0):(e+=t[n].toString(16),n<7&&(e+=":")));return"["+e+"]"}return t},Ud={},jd=Je({},Ud,{" ":1,'"':1,"<":1,">":1,"`":1}),Gd=Je({},jd,{"#":1,"?":1,"{":1,"}":1}),qd=Je({},Gd,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Hd=function(t,e){var n=bd(t,0);return n>32&&n<127&&!x(e,t)?t:encodeURIComponent(t)},Kd={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Xd=function(t){return x(Kd,t.scheme)},Yd=function(t){return""!=t.username||""!=t.password},Jd=function(t){return!t.host||t.cannotBeABaseURL||"file"==t.scheme},$d=function(t,e){var n;return 2==t.length&&Ed.test(t.charAt(0))&&(":"==(n=t.charAt(1))||!e&&"|"==n)},Zd=function(t){var e;return t.length>1&&$d(t.slice(0,2))&&(2==t.length||"/"===(e=t.charAt(2))||"\\"===e||"?"===e||"#"===e)},Qd=function(t){var e=t.path,n=e.length;!n||"file"==t.scheme&&1==n&&$d(e[0],!0)||e.pop()},tm=function(t){return"."===t||"%2e"===t.toLowerCase()},em={},nm={},rm={},am={},im={},om={},sm={},um={},cm={},lm={},hm={},fm={},pm={},dm={},mm={},vm={},gm={},ym={},bm={},xm={},wm={},km=function(t,e,n,r){var a,i,o,s,u,c=n||em,l=0,h="",f=!1,p=!1,d=!1;for(n||(t.scheme="",t.username="",t.password="",t.host=null,t.port=null,t.path=[],t.query=null,t.fragment=null,t.cannotBeABaseURL=!1,e=e.replace(Ld,"")),e=e.replace(zd,""),a=sr(e);l<=a.length;){switch(i=a[l],c){case em:if(!i||!Ed.test(i)){if(n)return"Invalid scheme";c=rm;continue}h+=i.toLowerCase(),c=nm;break;case nm:if(i&&(Id.test(i)||"+"==i||"-"==i||"."==i))h+=i.toLowerCase();else{if(":"!=i){if(n)return"Invalid scheme";h="",c=rm,l=0;continue}if(n&&(Xd(t)!=x(Kd,h)||"file"==h&&(Yd(t)||null!==t.port)||"file"==t.scheme&&!t.host))return;if(t.scheme=h,n)return void(Xd(t)&&Kd[t.scheme]==t.port&&(t.port=null));h="","file"==t.scheme?c=dm:Xd(t)&&r&&r.scheme==t.scheme?c=am:Xd(t)?c=um:"/"==a[l+1]?(c=im,l++):(t.cannotBeABaseURL=!0,t.path.push(""),c=bm)}break;case rm:if(!r||r.cannotBeABaseURL&&"#"!=i)return"Invalid scheme";if(r.cannotBeABaseURL&&"#"==i){t.scheme=r.scheme,t.path=r.path.slice(),t.query=r.query,t.fragment="",t.cannotBeABaseURL=!0,c=wm;break}c="file"==r.scheme?dm:om;continue;case am:if("/"!=i||"/"!=a[l+1]){c=om;continue}c=cm,l++;break;case im:if("/"==i){c=lm;break}c=ym;continue;case om:if(t.scheme=r.scheme,i==gd)t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,t.path=r.path.slice(),t.query=r.query;else if("/"==i||"\\"==i&&Xd(t))c=sm;else if("?"==i)t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,t.path=r.path.slice(),t.query="",c=xm;else{if("#"!=i){t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,t.path=r.path.slice(),t.path.pop(),c=ym;continue}t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,t.path=r.path.slice(),t.query=r.query,t.fragment="",c=wm}break;case sm:if(!Xd(t)||"/"!=i&&"\\"!=i){if("/"!=i){t.username=r.username,t.password=r.password,t.host=r.host,t.port=r.port,c=ym;continue}c=lm}else c=cm;break;case um:if(c=cm,"/"!=i||"/"!=h.charAt(l+1))continue;l++;break;case cm:if("/"!=i&&"\\"!=i){c=lm;continue}break;case lm:if("@"==i){f&&(h="%40"+h),f=!0,o=sr(h);for(var m=0;m<o.length;m++){var v=o[m];if(":"!=v||d){var g=Hd(v,qd);d?t.password+=g:t.username+=g}else d=!0}h=""}else if(i==gd||"/"==i||"?"==i||"#"==i||"\\"==i&&Xd(t)){if(f&&""==h)return"Invalid authority";l-=sr(h).length+1,h="",c=hm}else h+=i;break;case hm:case fm:if(n&&"file"==t.scheme){c=vm;continue}if(":"!=i||p){if(i==gd||"/"==i||"?"==i||"#"==i||"\\"==i&&Xd(t)){if(Xd(t)&&""==h)return"Invalid host";if(n&&""==h&&(Yd(t)||null!==t.port))return;if(s=Bd(t,h))return s;if(h="",c=gm,n)return;continue}"["==i?p=!0:"]"==i&&(p=!1),h+=i}else{if(""==h)return"Invalid host";if(s=Bd(t,h))return s;if(h="",c=pm,n==fm)return}break;case pm:if(!Ad.test(i)){if(i==gd||"/"==i||"?"==i||"#"==i||"\\"==i&&Xd(t)||n){if(""!=h){var y=parseInt(h,10);if(y>65535)return"Invalid port";t.port=Xd(t)&&y===Kd[t.scheme]?null:y,h=""}if(n)return;c=gm;continue}return"Invalid port"}h+=i;break;case dm:if(t.scheme="file","/"==i||"\\"==i)c=mm;else{if(!r||"file"!=r.scheme){c=ym;continue}if(i==gd)t.host=r.host,t.path=r.path.slice(),t.query=r.query;else if("?"==i)t.host=r.host,t.path=r.path.slice(),t.query="",c=xm;else{if("#"!=i){Zd(a.slice(l).join(""))||(t.host=r.host,t.path=r.path.slice(),Qd(t)),c=ym;continue}t.host=r.host,t.path=r.path.slice(),t.query=r.query,t.fragment="",c=wm}}break;case mm:if("/"==i||"\\"==i){c=vm;break}r&&"file"==r.scheme&&!Zd(a.slice(l).join(""))&&($d(r.path[0],!0)?t.path.push(r.path[0]):t.host=r.host),c=ym;continue;case vm:if(i==gd||"/"==i||"\\"==i||"?"==i||"#"==i){if(!n&&$d(h))c=ym;else if(""==h){if(t.host="",n)return;c=gm}else{if(s=Bd(t,h))return s;if("localhost"==t.host&&(t.host=""),n)return;h="",c=gm}continue}h+=i;break;case gm:if(Xd(t)){if(c=ym,"/"!=i&&"\\"!=i)continue}else if(n||"?"!=i)if(n||"#"!=i){if(i!=gd&&(c=ym,"/"!=i))continue}else t.fragment="",c=wm;else t.query="",c=xm;break;case ym:if(i==gd||"/"==i||"\\"==i&&Xd(t)||!n&&("?"==i||"#"==i)){if(".."===(u=(u=h).toLowerCase())||"%2e."===u||".%2e"===u||"%2e%2e"===u?(Qd(t),"/"==i||"\\"==i&&Xd(t)||t.path.push("")):tm(h)?"/"==i||"\\"==i&&Xd(t)||t.path.push(""):("file"==t.scheme&&!t.path.length&&$d(h)&&(t.host&&(t.host=""),h=h.charAt(0)+":"),t.path.push(h)),h="","file"==t.scheme&&(i==gd||"?"==i||"#"==i))for(;t.path.length>1&&""===t.path[0];)t.path.shift();"?"==i?(t.query="",c=xm):"#"==i&&(t.fragment="",c=wm)}else h+=Hd(i,Gd);break;case bm:"?"==i?(t.query="",c=xm):"#"==i?(t.fragment="",c=wm):i!=gd&&(t.path[0]+=Hd(i,Ud));break;case xm:n||"#"!=i?i!=gd&&("'"==i&&Xd(t)?t.query+="%27":t.query+="#"==i?"%23":Hd(i,Ud)):(t.fragment="",c=wm);break;case wm:i!=gd&&(t.fragment+=Hd(i,jd))}l++}},Sm=function(t){var e,n,r=pc(this,Sm,"URL"),a=arguments.length>1?arguments[1]:void 0,i=String(t),s=Sd(r,{type:"URL"});if(void 0!==a)if(a instanceof Sm)e=Cd(a);else if(n=km(e={},String(a)))throw TypeError(n);if(n=km(s,i,null,e))throw TypeError(n);var u=s.searchParams=new wd,c=kd(u);c.updateSearchParams(s.query),c.updateURL=function(){s.query=String(u)||null},o||(r.href=Rm.call(r),r.origin=Nm.call(r),r.protocol=Em.call(r),r.username=Im.call(r),r.password=Am.call(r),r.host=Tm.call(r),r.hostname=Dm.call(r),r.port=_m.call(r),r.pathname=Om.call(r),r.search=Fm.call(r),r.searchParams=Mm.call(r),r.hash=Lm.call(r))},Cm=Sm.prototype,Rm=function(){var t=Cd(this),e=t.scheme,n=t.username,r=t.password,a=t.host,i=t.port,o=t.path,s=t.query,u=t.fragment,c=e+":";return null!==a?(c+="//",Yd(t)&&(c+=n+(r?":"+r:"")+"@"),c+=Vd(a),null!==i&&(c+=":"+i)):"file"==e&&(c+="//"),c+=t.cannotBeABaseURL?o[0]:o.length?"/"+o.join("/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},Nm=function(){var t=Cd(this),e=t.scheme,n=t.port;if("blob"==e)try{return new URL(e.path[0]).origin}catch(t){return"null"}return"file"!=e&&Xd(t)?e+"://"+Vd(t.host)+(null!==n?":"+n:""):"null"},Em=function(){return Cd(this).scheme+":"},Im=function(){return Cd(this).username},Am=function(){return Cd(this).password},Tm=function(){var t=Cd(this),e=t.host,n=t.port;return null===e?"":null===n?Vd(e):Vd(e)+":"+n},Dm=function(){var t=Cd(this).host;return null===t?"":Vd(t)},_m=function(){var t=Cd(this).port;return null===t?"":String(t)},Om=function(){var t=Cd(this),e=t.path;return t.cannotBeABaseURL?e[0]:e.length?"/"+e.join("/"):""},Fm=function(){var t=Cd(this).query;return t?"?"+t:""},Mm=function(){return Cd(this).searchParams},Lm=function(){var t=Cd(this).fragment;return t?"#"+t:""},zm=function(t,e){return{get:t,set:e,configurable:!0,enumerable:!0}};if(o&&zt(Cm,{href:zm(Rm,(function(t){var e=Cd(this),n=String(t),r=km(e,n);if(r)throw TypeError(r);kd(e.searchParams).updateSearchParams(e.query)})),origin:zm(Nm),protocol:zm(Em,(function(t){var e=Cd(this);km(e,String(t)+":",em)})),username:zm(Im,(function(t){var e=Cd(this),n=sr(String(t));if(!Jd(e)){e.username="";for(var r=0;r<n.length;r++)e.username+=Hd(n[r],qd)}})),password:zm(Am,(function(t){var e=Cd(this),n=sr(String(t));if(!Jd(e)){e.password="";for(var r=0;r<n.length;r++)e.password+=Hd(n[r],qd)}})),host:zm(Tm,(function(t){var e=Cd(this);e.cannotBeABaseURL||km(e,String(t),hm)})),hostname:zm(Dm,(function(t){var e=Cd(this);e.cannotBeABaseURL||km(e,String(t),fm)})),port:zm(_m,(function(t){var e=Cd(this);Jd(e)||(""==(t=String(t))?e.port=null:km(e,t,pm))})),pathname:zm(Om,(function(t){var e=Cd(this);e.cannotBeABaseURL||(e.path=[],km(e,t+"",gm))})),search:zm(Fm,(function(t){var e=Cd(this);""==(t=String(t))?e.query=null:("?"==t.charAt(0)&&(t=t.slice(1)),e.query="",km(e,t,xm)),kd(e.searchParams).updateSearchParams(e.query)})),searchParams:zm(Mm),hash:zm(Lm,(function(t){var e=Cd(this);""!=(t=String(t))?("#"==t.charAt(0)&&(t=t.slice(1)),e.fragment="",km(e,t,wm)):e.fragment=null}))}),et(Cm,"toJSON",(function(){return Rm.call(this)}),{enumerable:!0}),et(Cm,"toString",(function(){return Rm.call(this)}),{enumerable:!0}),xd){var Bm=xd.createObjectURL,Pm=xd.revokeObjectURL;Bm&&et(Sm,"createObjectURL",(function(t){return Bm.apply(xd,arguments)})),Pm&&et(Sm,"revokeObjectURL",(function(t){return Pm.apply(xd,arguments)}))}re(Sm,"URL"),Dt({global:!0,forced:!Wp,sham:!o},{URL:Sm}),Dt({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return URL.prototype.toString.call(this)}});n((function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function s(t,e,n,r){var a=e&&e.prototype instanceof l?e:l,i=Object.create(a.prototype),o=new k(r||[]);return i._invoke=function(t,e,n){var r="suspendedStart";return function(a,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw i;return C()}for(n.method=a,n.arg=i;;){var o=n.delegate;if(o){var s=b(o,n);if(s){if(s===c)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=u(t,e,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===c)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}(t,n,o),i}function u(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var c={};function l(){}function h(){}function f(){}var p={};p[a]=function(){return this};var d=Object.getPrototypeOf,m=d&&d(d(S([])));m&&m!==e&&n.call(m,a)&&(p=m);var v=f.prototype=l.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function y(t,e){var r;this._invoke=function(a,i){function o(){return new e((function(r,o){!function r(a,i,o,s){var c=u(t[a],t,i);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,o,s)}),(function(t){r("throw",t,o,s)})):e.resolve(h).then((function(t){l.value=t,o(l)}),(function(t){return r("throw",t,o,s)}))}s(c.arg)}(a,i,r,o)}))}return r=r?r.then(o,o):o()}}function b(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return c;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=u(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,c;var a=r.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,c):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,c)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function w(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=v.constructor=f,f.constructor=h,f[o]=h.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,o in t||(t[o]="GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},g(y.prototype),y.prototype[i]=function(){return this},t.AsyncIterator=y,t.async=function(e,n,r,a,i){void 0===i&&(i=Promise);var o=new y(s(e,n,r,a),i);return t.isGeneratorFunction(n)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},g(v),v[o]="Generator",v[a]=function(){return this},v.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=S,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return o.type="throw",o.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),c},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),w(n),c}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var a=r.arg;w(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function Wm(t,e,n,r,a,i,o){try{var s=t[i](o),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,a)}function Vm(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var i=t.apply(e,n);function o(t){Wm(i,r,a,o,s,"next",t)}function s(t){Wm(i,r,a,o,s,"throw",t)}o(void 0)}))}}function Um(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function jm(t,e,n){return e&&Um(t.prototype,e),n&&Um(t,n),t}function Gm(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function qm(t){return(qm=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Hm(t,e){return(Hm=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Km(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function Xm(t,e,n){return(Xm=Km()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var a=new(Function.bind.apply(t,r));return n&&Hm(a,n.prototype),a}).apply(null,arguments)}function Ym(t){var e="function"==typeof Map?new Map:void 0;return(Ym=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return Xm(t,arguments,qm(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Hm(r,t)})(t)}function Jm(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function $m(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Zm(t){var e=0;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=function(t,e){if(t){if("string"==typeof t)return $m(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$m(t,e):void 0}}(t)))return function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(e=t[Symbol.iterator]()).next.bind(e)}var Qm,tv=function(){function t(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags()}var e=t.prototype;return e.setPlatform=function(t,e){null!=this.platform&&console.warn("Platform "+this.platformName+" has already been set. Overwriting the platform with "+e+"."),this.platformName=t,this.platform=e},e.registerFlag=function(t,e,n){if(this.flagRegistry[t]={evaluationFn:e,setHook:n},null!=this.urlFlags[t]){var r=this.urlFlags[t];console.warn("Setting feature override from URL "+t+": "+r+"."),this.set(t,r)}},e.get=function(t){return t in this.flags||(this.flags[t]=this.evaluateFlag(t)),this.flags[t]},e.getNumber=function(t){return this.get(t)},e.getBool=function(t){return this.get(t)},e.getFlags=function(){return this.flags},e.set=function(t,e){if(null==this.flagRegistry[t])throw new Error("Cannot set flag "+t+" as it has not been registered.");this.flags[t]=e,null!=this.flagRegistry[t].setHook&&this.flagRegistry[t].setHook(e)},e.evaluateFlag=function(t){if(null==this.flagRegistry[t])throw new Error("Cannot evaluate flag '"+t+"': no evaluation function found.");return this.flagRegistry[t].evaluationFn()},e.setFlags=function(t){this.flags=Object.assign({},t)},e.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags()},e.populateURLFlags=function(){var t=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var e,n,r=(e=this.global.location.search,n={},e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),a=1;a<e;a++)r[a-1]=arguments[a];return ev(n,r[0],r[1]),r.join("=")})),n);if("tfjsflags"in r)r.tfjsflags.split(",").forEach((function(e){var n=e.split(":"),r=n[0],a=n[1];t.urlFlags[r]=function(t,e){if("true"===(e=e.toLowerCase())||"false"===e)return"true"===e;if(""+ +e===e)return+e;throw new Error("Could not parse value flag value "+e+" for flag "+t+".")}(r,a)}))}},jm(t,[{key:"features",get:function(){return this.flags}}]),t}();function ev(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}function nv(){return t.ENV}function rv(){if(null==Qm){var t;if("undefined"!=typeof window)t=window;else if("undefined"!=typeof global)t=global;else if("undefined"!=typeof process)t=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");t=self}Qm=t}return Qm}function av(t,e){var n,r=(null==(n=rv())._tfGlobals&&(n._tfGlobals=new Map),n._tfGlobals);if(r.has(t))return r.get(t);var a=e();return r.set(t,a),r.get(t)}t.ENV=null;var iv=av("kernelRegistry",(function(){return new Map})),ov=av("gradRegistry",(function(){return new Map}));function sv(t,e){var n=fv(t,e);return iv.get(n)}function uv(t){return ov.get(t)}function cv(t){for(var e=iv.entries(),n=[];;){var r=e.next(),a=r.done,i=r.value;if(a)break;var o=i[0],s=i[1];o.split("_")[0]===t&&n.push(s)}return n}function lv(t){var e=t.kernelName,n=t.backendName,r=fv(e,n);iv.has(r)&&console.warn("The kernel '"+e+"' for backend '"+n+"' is already registered"),iv.set(r,t)}function hv(t){var e=t.kernelName;ov.has(e)&&console.warn("Overriding the gradient for '"+e+"'"),ov.set(e,t)}function fv(t,e){return e+"_"+t}function pv(t){for(var e=t.length,n=0,r=0;e>0;)r=Math.random()*e|0,n=t[--e],t[e]=t[r],t[r]=n}function dv(t,e,n){return Math.max(t,Math.min(e,n))}function mv(t){return t%2==0?t:t+1}function vv(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return e}function gv(t,e){if(!t)throw new Error("string"==typeof e?e:e())}function yv(t,e,n){void 0===n&&(n=""),gv(kv(t,e),(function(){return n+" Shapes "+t+" and "+e+" must match"}))}function bv(t){gv(null!=t,(function(){return"The input to the tensor constructor must be a non-null value."}))}function xv(t,e,n){if(void 0===e&&(e=[]),void 0===n&&(n=!1),null==e&&(e=[]),Array.isArray(t)||Lv(t)&&!n)for(var r=0;r<t.length;++r)xv(t[r],e,n);else e.push(t);return e}function wv(t){if(0===t.length)return 1;for(var e=t[0],n=1;n<t.length;n++)e*=t[n];return e}function kv(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function Sv(t){return t%1==0}function Cv(t){if(null!=Math.tanh)return Math.tanh(t);if(t===1/0)return 1;if(t===-1/0)return-1;var e=Math.exp(2*t);return(e-1)/(e+1)}function Rv(t){var e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}function Nv(t,e){return e<=t.length?t:t+" ".repeat(e-t.length)}function Ev(t,e,n){return void 0===e&&(e=function(t){return 0}),new Promise((function(r,a){var i=0;!function o(){if(t())r();else{i++;var s=e(i);null!=n&&i>=n?a():setTimeout(o,s)}}()}))}function Iv(t,e){for(var n=1,r=-1,a=0;a<t.length;++a)if(t[a]>=0)n*=t[a];else if(-1===t[a]){if(-1!==r)throw Error("Shapes can only have 1 implicit size. Found -1 at dim "+r+" and dim "+a);r=a}else if(t[a]<0)throw Error("Shapes can not be < 0. Found "+t[a]+" at dim "+a);if(-1===r){if(e>0&&e!==n)throw Error("Size("+e+") must match the product of shape "+t);return t}if(0===n)throw Error("Cannot infer the missing size in ["+t+"] when there are 0 elements");if(e%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+e+" / "+n);var i=t.slice();return i[r]=e/n,i}function Av(t,e){var n=e.length;return gv((t=null==t?e.map((function(t,e){return e})):[].concat(t)).every((function(t){return t>=-n&&t<n})),(function(){return"All values in axis param must be in range [-"+n+", "+n+") but got axis "+t})),gv(t.every((function(t){return Sv(t)})),(function(){return"All values in axis param must be integers but got axis "+t})),t.map((function(t){return t<0?n+t:t}))}function Tv(t,e){for(var n=[],r=[],a=null!=e&&Array.isArray(e)&&0===e.length,i=null==e||a?null:Av(e,t).sort(),o=0,s=0;s<t.length;++s){if(null!=i){if(i[o]===s&&1!==t[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+t[s]+"' is not 1");(null==i[o]||i[o]>s)&&1===t[s]&&(n.push(t[s]),r.push(s)),i[o]<=s&&o++}1!==t[s]&&(n.push(t[s]),r.push(s))}return{newShape:n,keptDims:r}}function Dv(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else{if("bool"!==t)throw new Error("Unknown data type "+t);n=new Uint8Array(e)}return n}function _v(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else{if("string"!==t)throw new Error("Unknown data type "+t);n=new Array(e)}return n}function Ov(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+e+" being uploaded contains "+r+".")}}function Fv(t){return"bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t}function Mv(t,e){return"complex64"!==e&&(("float32"!==e||"complex64"===t)&&(("int32"!==e||"float32"===t||"complex64"===t)&&("bool"!==e||"bool"!==t)))}function Lv(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array}function zv(t){if("float32"===t||"int32"===t)return 4;if("complex64"===t)return 8;if("bool"===t)return 1;throw new Error("Unknown dtype "+t)}function Bv(t){if(null==t)return 0;var e=0;return t.forEach((function(t){return e+=t.length})),e}function Pv(t){return"string"==typeof t||t instanceof String}function Wv(t){return"boolean"==typeof t}function Vv(t){return"number"==typeof t}function Uv(t){return Array.isArray(t)?Uv(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":Vv(t)?"float32":Pv(t)?"string":Wv(t)?"bool":"float32"}function jv(t){return!!(t&&t.constructor&&t.call&&t.apply)}function Gv(t,e){for(var n=e;n<t;++n)if(t%n==0)return n;return t}function qv(t){var e=t.length;if(e<2)return[];var n=new Array(e-1);n[e-2]=t[e-1];for(var r=e-3;r>=0;--r)n[r]=n[r+1]*t[r+1];return n}function Hv(t,e,n){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=xv(t)),n&&Ov(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){for(var r=new Uint8Array(t.length),a=0;a<r.length;++a)0!==Math.round(t[a])&&(r[a]=1);return r}throw new Error("Unknown data type "+e)}function Kv(t,e){if(0===t.length)return e[0];var n=t.reduce((function(t,e){return t*e}));if(0===n)return[];if(n!==e.length)throw new Error("["+t+"] does not match the input size.");return function t(e,n,r){var a=new Array;if(1===n.length)for(var i=n[0],o=0;o<i;o++)a[o]=r[e+o];else for(var s=n[0],u=n.slice(1),c=u.reduce((function(t,e){return t*e})),l=0;l<s;l++)a[l]=t(e+l*c,u,r);return a}(0,t,e)}function Xv(t,e){for(var n=Yv(t,e),r=0;r<n.length;r++)n[r]=1;return n}function Yv(t,e){if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e)return new Uint8Array(t);throw new Error("Unknown data type "+e)}function Jv(){return nv().platform.now()}function $v(t){t.forEach((function(e){gv(Number.isInteger(e)&&e>=0,(function(){return"Tensor must have a shape comprised of positive integers but got shape ["+t+"]."}))}))}function Zv(t,e){return nv().platform.fetch(t,e)}function Qv(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",nv().platform.encode(t,e)}function tg(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",nv().platform.decode(t,e)}function eg(t,e,n){if(0===e)return 0;if(1===e)return t[0];for(var r=t[t.length-1],a=0;a<t.length-1;++a)r+=n[a]*t[a];return r}function ng(t,e,n){if(0===e)return[];if(1===e)return[t];for(var r=new Array(e),a=0;a<r.length-1;++a)r[a]=Math.floor(t/n[a]),t-=r[a]*n[a];return r[r.length-1]=t,r}var rg={__proto__:null,shuffle:pv,clamp:dv,nearestLargerEven:mv,sum:vv,randUniform:function(t,e){var n=Math.random();return e*n+(1-n)*t},distSquared:function(t,e){for(var n=0,r=0;r<t.length;r++){var a=Number(t[r])-Number(e[r]);n+=a*a}return n},assert:gv,assertShapesMatch:yv,assertNonNull:bv,flatten:xv,sizeFromShape:wv,isScalarShape:function(t){return 0===t.length},arraysEqual:kv,isInt:Sv,tanh:Cv,sizeToSquarishShape:Rv,createShuffledIndices:function(t){for(var e=new Uint32Array(t),n=0;n<t;++n)e[n]=n;return pv(e),e},rightPad:Nv,repeatedTry:Ev,inferFromImplicitShape:Iv,parseAxisParam:Av,squeezeShape:Tv,getTypedArrayFromDType:Dv,getArrayFromDType:_v,checkConversionForErrors:Ov,isValidDtype:Fv,hasEncodingLoss:Mv,isTypedArray:Lv,bytesPerElement:zv,bytesFromStringArray:Bv,isString:Pv,isBoolean:Wv,isNumber:Vv,inferDtype:Uv,isFunction:jv,nearestDivisor:Gv,computeStrides:qv,toTypedArray:Hv,toNestedArray:Kv,makeOnesTypedArray:Xv,makeZerosTypedArray:Yv,now:Jv,assertNonNegativeIntegerDimensions:$v,fetch:Zv,encodeString:Qv,decodeString:tg,locToIndex:eg,indexToLoc:ng},ag=function(){function t(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new ig)}return t.prototype.profileKernel=function(t,e,n){var r,a=this,i=this.backendTimer.time((function(){r=n()}));return r.forEach((function(n){n.data().then((function(r){!function(t,e,n){if("float32"!==e)return!1;for(var r=0;r<t.length;r++){var a=t[r];if(isNaN(a)||!isFinite(a))return console.warn("Found "+a+" in the result of '"+n+"'"),!0}}(r,n.dtype,t),i.then((function(i){var o="";null!=i.getExtraProfileInfo&&(o=i.getExtraProfileInfo()),a.logger.logKernelProfile(t,n,r,i.kernelMs,e,o)}))}))})),r},t}();var ig=function(){function t(){}return t.prototype.logKernelProfile=function(t,e,n,r,a,i){var o="number"==typeof r?Nv(r+"ms",9):r.error,s=Nv(t,25),u=e.rank,c=e.size,l=Nv(e.shape.toString(),14),h="";for(var f in a){var p=a[f].shape||e.shape,d=p.length;h+=f+": "+d+"D "+(d>0?p:"")+" "}console.log("%c"+s+"\t%c"+o+"\t%c"+u+"D "+l+"\t%c"+c+"\t%c"+h+"\t%c"+i,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")},t}();function og(t,e,n,r){var a=qv(e),i=function(t,e,n,r){var a=wv(e),i=r[r.length-1],o=new Array(i).fill(0),s=e.length,u="complex64"===n?cg(t):t;if(s>1)for(var c=0;c<a/i;c++)for(var l=c*i,h=0;h<i;h++)o[h]=Math.max(o[h],sg(u[l+h],0,n).length);return o}(t,e,n,a),o=e.length,s=function t(e,n,r,a,i,o){void 0===o&&(o=!0);var s="complex64"===r?2:1,u=n[0],c=n.length;if(0===c){return"complex64"===r?[sg(cg(e)[0],0,r)]:"bool"===r?[ug(e[0])]:[e[0].toString()]}if(1===c){if(u>20){var l=3*s,h=Array.from(e.slice(0,l)),f=Array.from(e.slice((u-3)*s,u*s));return"complex64"===r&&(h=cg(h),f=cg(f)),["["+h.map((function(t,e){return sg(t,i[e],r)})).join(", ")+", ..., "+f.map((function(t,e){return sg(t,i[u-3+e],r)})).join(", ")+"]"]}return["["+("complex64"===r?cg(e):Array.from(e)).map((function(t,e){return sg(t,i[e],r)})).join(", ")+"]"]}var p=n.slice(1),d=a.slice(1),m=a[0]*s,v=[];if(u>20){for(var g=0;g<3;g++){var y=g*m,b=y+m;v.push.apply(v,t(e.slice(y,b),p,r,d,i,!1))}v.push("...");for(var x=u-3;x<u;x++){var w=x*m,k=w+m;v.push.apply(v,t(e.slice(w,k),p,r,d,i,x===u-1))}}else for(var S=0;S<u;S++){var C=S*m,R=C+m;v.push.apply(v,t(e.slice(C,R),p,r,d,i,S===u-1))}var N=2===c?",":"";v[0]="["+v[0]+N;for(var E=1;E<v.length-1;E++)v[E]=" "+v[E]+N;for(var I=",\n",A=2;A<c;A++)I+="\n";return v[v.length-1]=" "+v[v.length-1]+"]"+(o?"":I),v}(t,e,n,a,i),u=["Tensor"];return r&&(u.push(" dtype: "+n),u.push(" rank: "+o),u.push(" shape: ["+e+"]"),u.push(" values:")),u.push(s.map((function(t){return" "+t})).join("\n")),u.join("\n")}function sg(t,e,n){return Nv(Array.isArray(t)?parseFloat(t[0].toFixed(7))+" + "+parseFloat(t[1].toFixed(7))+"j":Pv(t)?"'"+t+"'":"bool"===n?ug(t):parseFloat(t.toFixed(7)).toString(),e)}function ug(t){return 0===t?"false":"true"}function cg(t){for(var e=[],n=0;n<t.length;n+=2)e.push([t[n],t[n+1]]);return e}var lg=function(){function t(t,e,n){var r=this;if(this.dtype=e,this.shape=t.slice(),this.size=wv(t),null!=n){var a=n.length;gv(a===this.size,(function(){return"Length of values '"+a+"' does not match the size inferred by the shape '"+r.size+"'."}))}if("complex64"===e)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||_v(e,this.size),this.strides=qv(t)}var e=t.prototype;return e.set=function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];0===r.length&&(r=[0]),gv(r.length===this.rank,(function(){return"The number of provided coordinates ("+r.length+") must match the rank ("+e.rank+")"}));var i=this.locToIndex(r);this.values[i]=t},e.get=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];0===e.length&&(e=[0]);for(var r=0,a=0,i=e;a<i.length;a++){var o=i[a];if(o<0||o>=this.shape[r]){var s="Requested out of range element at "+e+". Buffer shape="+this.shape;throw new Error(s)}r++}for(var u=e[e.length-1],c=0;c<e.length-1;++c)u+=this.strides[c]*e[c];return this.values[u]},e.locToIndex=function(t){if(0===this.rank)return 0;if(1===this.rank)return t[0];for(var e=t[t.length-1],n=0;n<t.length-1;++n)e+=this.strides[n]*t[n];return e},e.indexToLoc=function(t){if(0===this.rank)return[];if(1===this.rank)return[t];for(var e=new Array(this.shape.length),n=0;n<e.length-1;++n)e[n]=Math.floor(t/this.strides[n]),t-=e[n]*this.strides[n];return e[e.length-1]=t,e},e.toTensor=function(){return hg().makeTensor(this.values,this.shape,this.dtype)},jm(t,[{key:"rank",get:function(){return this.shape.length}}]),t}(),hg=null,fg=null;var pg=function(){function t(t,e,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=wv(t),this.strides=qv(t),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}var e=t.prototype;return e.flatten=function(){return this.throwIfDisposed(),this.as1D()},e.asScalar=function(){return this.throwIfDisposed(),gv(1===this.size,(function(){return"The array must have only 1 element."})),this.reshape([])},e.as1D=function(){return this.throwIfDisposed(),this.reshape([this.size])},e.as2D=function(t,e){return this.throwIfDisposed(),this.reshape([t,e])},e.as3D=function(t,e,n){return this.throwIfDisposed(),this.reshape([t,e,n])},e.as4D=function(t,e,n,r){return this.throwIfDisposed(),this.reshape([t,e,n,r])},e.as5D=function(t,e,n,r,a){return this.throwIfDisposed(),this.reshape([t,e,n,r,a])},e.asType=function(t){return this.throwIfDisposed(),fg.cast(this,t)},e.buffer=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.data();case 2:return e=t.sent,t.abrupt("return",fg.buffer(this.shape,this.dtype,e));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.bufferSync=function(){return fg.buffer(this.shape,this.dtype,this.dataSync())},e.array=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.data();case 2:return e=t.sent,t.abrupt("return",Kv(this.shape,e));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.arraySync=function(){return Kv(this.shape,this.dataSync())},e.data=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.throwIfDisposed(),e=hg().read(this.dataId),"string"!==this.dtype){t.next=13;break}return t.next=5,e;case 5:return n=t.sent,t.prev=6,t.abrupt("return",n.map((function(t){return tg(t)})));case 10:throw t.prev=10,t.t0=t.catch(6),new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");case 13:return t.abrupt("return",e);case 14:case"end":return t.stop()}}),t,this,[[6,10]])})));return function(){return t.apply(this,arguments)}}(),e.dataSync=function(){this.throwIfDisposed();var t=hg().readSync(this.dataId);if("string"===this.dtype)try{return t.map((function(t){return tg(t)}))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t},e.bytes=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.throwIfDisposed(),t.next=3,hg().read(this.dataId);case 3:if(e=t.sent,"string"!==this.dtype){t.next=8;break}return t.abrupt("return",e);case 8:return t.abrupt("return",new Uint8Array(e.buffer));case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.dispose=function(){this.isDisposed||(hg().disposeTensor(this),this.isDisposedInternal=!0)},e.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.")},e.toFloat=function(){return this.asType("float32")},e.toInt=function(){return this.asType("int32")},e.toBool=function(){return this.asType("bool")},e.print=function(t){return void 0===t&&(t=!1),fg.print(this,t)},e.reshape=function(t){return this.throwIfDisposed(),fg.reshape(this,t)},e.reshapeAs=function(t){return this.throwIfDisposed(),this.reshape(t.shape)},e.expandDims=function(t){return void 0===t&&(t=0),fg.expandDims(this,t)},e.cumsum=function(t,e,n){return void 0===t&&(t=0),void 0===e&&(e=!1),void 0===n&&(n=!1),fg.cumsum(this,t,e,n)},e.squeeze=function(t){return this.throwIfDisposed(),fg.squeeze(this,t)},e.clone=function(){return this.throwIfDisposed(),fg.clone(this)},e.toString=function(t){return void 0===t&&(t=!1),og(this.dataSync(),this.shape,this.dtype,t)},e.gather=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),fg.gather(this,t,e)},e.norm=function(t,e,n){return void 0===t&&(t="euclidean"),void 0===e&&(e=null),void 0===n&&(n=!1),this.throwIfDisposed(),fg.norm(this,t,e,n)},e.slice=function(t,e){return this.throwIfDisposed(),fg.slice(this,t,e)},e.reverse=function(t){return this.throwIfDisposed(),fg.reverse(this,t)},e.stack=function(t,e){return void 0===e&&(e=0),fg.stack([this,t],e)},e.unstack=function(t){return void 0===t&&(t=0),fg.unstack(this,t)},e.all=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),fg.all(this,t,e)},e.any=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),fg.any(this,t,e)},e.logSumExp=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),fg.logSumExp(this,t,e)},e.sum=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),fg.sum(this,t,e)},e.prod=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),fg.prod(this,t,e)},e.mean=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),fg.mean(this,t,e)},e.min=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),fg.min(this,t,e)},e.argMin=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),fg.argMin(this,t)},e.argMax=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),fg.argMax(this,t)},e.cast=function(t){return this.throwIfDisposed(),fg.cast(this,t)},e.addStrict=function(t){return this.throwIfDisposed(),fg.addStrict(this,t)},e.atan2=function(t){return this.throwIfDisposed(),fg.atan2(this,t)},e.subStrict=function(t){return this.throwIfDisposed(),fg.subStrict(this,t)},e.pow=function(t){return this.throwIfDisposed(),fg.pow(this,t)},e.powStrict=function(t){return this.throwIfDisposed(),fg.powStrict(this,t)},e.mul=function(t){return this.throwIfDisposed(),fg.mul(this,t)},e.mulStrict=function(t){return this.throwIfDisposed(),fg.mulStrict(this,t)},e.floorDiv=function(t){return this.throwIfDisposed(),fg.floorDiv(this,t)},e.divStrict=function(t){return this.throwIfDisposed(),fg.divStrict(this,t)},e.minimum=function(t){return this.throwIfDisposed(),fg.minimum(this,t)},e.minimumStrict=function(t){return this.throwIfDisposed(),fg.minimumStrict(this,t)},e.maximum=function(t){return this.throwIfDisposed(),fg.maximum(this,t)},e.maximumStrict=function(t){return this.throwIfDisposed(),fg.maximumStrict(this,t)},e.mod=function(t){return this.throwIfDisposed(),fg.mod(this,t)},e.modStrict=function(t){return this.throwIfDisposed(),fg.modStrict(this,t)},e.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),fg.squaredDifferenceStrict(this,t)},e.notEqualStrict=function(t){return this.throwIfDisposed(),fg.notEqualStrict(this,t)},e.lessStrict=function(t){return this.throwIfDisposed(),fg.lessStrict(this,t)},e.equalStrict=function(t){return this.throwIfDisposed(),fg.equalStrict(this,t)},e.lessEqualStrict=function(t){return this.throwIfDisposed(),fg.lessEqualStrict(this,t)},e.greaterStrict=function(t){return this.throwIfDisposed(),fg.greaterStrict(this,t)},e.greaterEqualStrict=function(t){return this.throwIfDisposed(),fg.greaterEqualStrict(this,t)},e.logicalAnd=function(t){return this.throwIfDisposed(),fg.logicalAnd(this,t)},e.logicalOr=function(t){return this.throwIfDisposed(),fg.logicalOr(this,t)},e.logicalNot=function(){return this.throwIfDisposed(),fg.logicalNot(this)},e.logicalXor=function(t){return this.throwIfDisposed(),fg.logicalXor(this,t)},e.where=function(t,e){return this.throwIfDisposed(),fg.where(t,this,e)},e.neg=function(){return this.throwIfDisposed(),fg.neg(this)},e.ceil=function(){return this.throwIfDisposed(),fg.ceil(this)},e.floor=function(){return this.throwIfDisposed(),fg.floor(this)},e.sign=function(){return this.throwIfDisposed(),fg.sign(this)},e.isNaN=function(){return this.throwIfDisposed(),fg.isNaN(this)},e.isInf=function(){return this.throwIfDisposed(),fg.isInf(this)},e.isFinite=function(){return this.throwIfDisposed(),fg.isFinite(this)},e.exp=function(){return this.throwIfDisposed(),fg.exp(this)},e.expm1=function(){return this.throwIfDisposed(),fg.expm1(this)},e.log=function(){return this.throwIfDisposed(),fg.log(this)},e.log1p=function(){return this.throwIfDisposed(),fg.log1p(this)},e.sqrt=function(){return this.throwIfDisposed(),fg.sqrt(this)},e.rsqrt=function(){return this.throwIfDisposed(),fg.rsqrt(this)},e.square=function(){return this.throwIfDisposed(),fg.square(this)},e.reciprocal=function(){return this.throwIfDisposed(),fg.reciprocal(this)},e.abs=function(){return this.throwIfDisposed(),fg.abs(this)},e.clipByValue=function(t,e){return this.throwIfDisposed(),fg.clipByValue(this,t,e)},e.relu=function(){return this.throwIfDisposed(),fg.relu(this)},e.relu6=function(){return this.throwIfDisposed(),fg.relu6(this)},e.elu=function(){return this.throwIfDisposed(),fg.elu(this)},e.selu=function(){return this.throwIfDisposed(),fg.selu(this)},e.leakyRelu=function(t){return void 0===t&&(t=.2),this.throwIfDisposed(),fg.leakyRelu(this,t)},e.prelu=function(t){return this.throwIfDisposed(),fg.prelu(this,t)},e.sigmoid=function(){return this.throwIfDisposed(),fg.sigmoid(this)},e.logSigmoid=function(){return this.throwIfDisposed(),fg.logSigmoid(this)},e.softplus=function(){return this.throwIfDisposed(),fg.softplus(this)},e.zerosLike=function(){return this.throwIfDisposed(),fg.zerosLike(this)},e.onesLike=function(){return this.throwIfDisposed(),fg.onesLike(this)},e.sin=function(){return this.throwIfDisposed(),fg.sin(this)},e.cos=function(){return this.throwIfDisposed(),fg.cos(this)},e.tan=function(){return this.throwIfDisposed(),fg.tan(this)},e.asin=function(){return this.throwIfDisposed(),fg.asin(this)},e.acos=function(){return this.throwIfDisposed(),fg.acos(this)},e.atan=function(){return this.throwIfDisposed(),fg.atan(this)},e.sinh=function(){return this.throwIfDisposed(),fg.sinh(this)},e.cosh=function(){return this.throwIfDisposed(),fg.cosh(this)},e.tanh=function(){return this.throwIfDisposed(),fg.tanh(this)},e.asinh=function(){return this.throwIfDisposed(),fg.asinh(this)},e.acosh=function(){return this.throwIfDisposed(),fg.acosh(this)},e.atanh=function(){return this.throwIfDisposed(),fg.atanh(this)},e.erf=function(){return this.throwIfDisposed(),fg.erf(this)},e.round=function(){return this.throwIfDisposed(),fg.round(this)},e.step=function(t){return void 0===t&&(t=0),this.throwIfDisposed(),fg.step(this,t)},e.softmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),fg.softmax(this,t)},e.logSoftmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),fg.logSoftmax(this,t)},e.resizeBilinear=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),fg.image.resizeBilinear(this,t,e)},e.resizeNearestNeighbor=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),fg.image.resizeNearestNeighbor(this,t,e)},e.avgPool=function(t,e,n,r){return this.throwIfDisposed(),fg.avgPool(this,t,e,n,r)},e.maxPool=function(t,e,n,r){return this.throwIfDisposed(),fg.maxPool(this,t,e,n,r)},e.pool=function(t,e,n,r,a){return this.throwIfDisposed(),fg.pool(this,t,e,n,r,a)},e.variable=function(t,e,n){return void 0===t&&(t=!0),this.throwIfDisposed(),hg().makeVariable(this,t,e,n)},e.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),fg.unsortedSegmentSum(this,t,e)},e.topk=function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!0),this.throwIfDisposed(),fg.topk(this,t,e)},e.stridedSlice=function(t,e,n,r,a,i,o,s){return void 0===r&&(r=0),void 0===a&&(a=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),this.throwIfDisposed(),fg.stridedSlice(this,t,e,n,r,a,i,o,s)},e.fft=function(){return this.throwIfDisposed(),fg.spectral.fft(this)},e.ifft=function(){return this.throwIfDisposed(),fg.spectral.ifft(this)},e.rfft=function(){return this.throwIfDisposed(),fg.spectral.rfft(this)},e.irfft=function(){return this.throwIfDisposed(),fg.spectral.irfft(this)},jm(t,[{key:"rank",get:function(){return this.shape.length}},{key:"isDisposed",get:function(){return this.isDisposedInternal}}]),t}();Object.defineProperty(pg,Symbol.hasInstance,{value:function(t){return!!t&&null!=t.dataId&&null!=t.shape&&null!=t.dtype}});var dg,mg,vg,gg,yg,bg=function(t){function e(e,n,r,a){var i;return(i=t.call(this,e.shape,e.dtype,e.dataId,a)||this).trainable=n,i.name=r,i}Gm(e,t);var n=e.prototype;return n.assign=function(t){if(t.dtype!==this.dtype)throw new Error("dtype of the new value ("+t.dtype+") and previous value ("+this.dtype+") must match");if(!kv(t.shape,this.shape))throw new Error("shape of the new value ("+t.shape+") and previous value ("+this.shape+") must match");hg().disposeTensor(this),this.dataId=t.dataId,hg().incRef(this,null)},n.dispose=function(){hg().disposeVariable(this),this.isDisposedInternal=!0},e}(pg);Object.defineProperty(bg,Symbol.hasInstance,{value:function(t){return t instanceof pg&&null!=t.assign&&t.assign instanceof Function}}),(dg=t.Rank||(t.Rank={})).R0="R0",dg.R1="R1",dg.R2="R2",dg.R3="R3",dg.R4="R4",dg.R5="R5",dg.R6="R6",function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"}(mg||(mg={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"}(vg||(vg={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"}(gg||(gg={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"}(yg||(yg={}));var xg={float32:gg,int32:mg,bool:vg,complex64:yg};function wg(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return"string";throw new Error("Can not upcast "+t+" with "+e)}return xg[t][e]}function kg(t){return wg(t,"int32")}function Sg(t,e){if(t.dtype===e.dtype)return[t,e];var n=wg(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function Cg(t,e){gv(t.dtype===e.dtype,(function(){return"The dtypes of the first("+t.dtype+") and second("+e.dtype+") input must match"}))}function Rg(t,e){return e.some((function(e){return e.id===t.id}))}function Ng(t){var e=[];return function t(e,n,r){if(null==e)return;if(e instanceof pg)return void n.push(e);if(a=e,!Array.isArray(a)&&"object"!=typeof a)return;var a;var i=e;for(var o in i){var s=i[o];r.has(s)||(r.add(s),t(s,n,r))}}(t,e,new Set),e}var Eg={__proto__:null,makeTypesMatch:Sg,assertTypesMatch:Cg,isTensorInList:Rg,getTensorsInContainer:Ng},Ig=function(){function t(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null}}return t.prototype.dispose=function(){for(var t in this.registeredVariables)this.registeredVariables[t].dispose()},t}(),Ag=function(){function t(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Ig}var e=t.prototype;return e.ready=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==this.pendingBackendInit){t.next=2;break}return t.abrupt("return",this.pendingBackendInit.then((function(){})));case 2:if(null==this.backendInstance){t.next=4;break}return t.abrupt("return");case 4:e=this.getSortedBackends(),n=0;case 6:if(!(n<e.length)){t.next=18;break}return r=e[n],t.next=10,this.initializeBackend(r).success;case 10:if(!t.sent){t.next=15;break}return t.next=14,this.setBackend(r);case 14:return t.abrupt("return");case 15:n++,t.next=6;break;case 18:throw new Error("Could not initialize any backends, all backend initializations failed.");case 19:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.backendNames=function(){return Object.keys(this.registryFactory)},e.findBackend=function(t){if(!(t in this.registry)){if(!(t in this.registryFactory))return null;if(this.initializeBackend(t).asyncInit)return null}return this.registry[t]},e.findBackendFactory=function(t){return t in this.registryFactory?this.registryFactory[t].factory:null},e.registerBackend=function(t,e,n){return void 0===n&&(n=1),t in this.registryFactory?(console.warn(t+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[t]={factory:e,priority:n},!0)},e.setBackend=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=this.registryFactory[e]){t.next=2;break}throw new Error("Backend name '"+e+"' not found in registry");case 2:if(this.backendName=e,null!=this.registry[e]){t.next=16;break}if(this.backendInstance=null,n=this.initializeBackend(e),r=n.success,!n.asyncInit){t.next=12;break}return t.next=9,r;case 9:t.t0=t.sent,t.next=13;break;case 12:t.t0=r;case 13:if(t.t0){t.next=16;break}return t.abrupt("return",!1);case 16:return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new ag(this.backendInstance),t.abrupt("return",!0);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.setupRegisteredKernels=function(){var t=this;cv(this.backendName).forEach((function(e){null!=e.setupFunc&&e.setupFunc(t.backendInstance)}))},e.disposeRegisteredKernels=function(t){var e=this;cv(t).forEach((function(n){null!=n.disposeFunc&&n.disposeFunc(e.registry[t])}))},e.initializeBackend=function(t){var e=this,n=this.registryFactory[t];if(null==n)throw new Error("Cannot initialize backend "+t+", no registration found.");try{var r=n.factory();if(Promise.resolve(r)===r){var a=++this.pendingBackendInitId,i=r.then((function(n){return!(a<e.pendingBackendInitId)&&(e.registry[t]=n,e.pendingBackendInit=null,!0)})).catch((function(n){return a<e.pendingBackendInitId||(e.pendingBackendInit=null,console.warn("Initialization of backend "+t+" failed"),console.warn(n.stack||n.message)),!1}));return this.pendingBackendInit=i,{success:i,asyncInit:!0}}return this.registry[t]=r,{success:!0,asyncInit:!1}}catch(e){return console.warn("Initialization of backend "+t+" failed"),console.warn(e.stack||e.message),{success:!1,asyncInit:!1}}},e.removeBackend=function(t){if(!(t in this.registryFactory))throw new Error(t+" backend not found in registry");this.backendName===t&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,t in this.registry&&(this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t]),delete this.registryFactory[t],this.backendName===t&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)},e.getSortedBackends=function(){var t=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((function(e,n){return t.registryFactory[n].priority-t.registryFactory[e].priority}))},e.initializeBackendsAndReturnBest=function(){for(var t=this.getSortedBackends(),e=0;e<t.length;e++){var n=t[e],r=this.initializeBackend(n),a=r.success,i=r.asyncInit;if(i||a)return{name:n,asyncInit:i}}throw new Error("Could not initialize any backends, all backend initializations failed.")},e.moveData=function(t,e){var n=this.state.tensorInfo.get(e),r=n.backend,a=this.readSync(e);r.disposeData(e),n.backend=t,t.move(e,a,n.shape,n.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++},e.tidy=function(t,e){var n,r=this,a=null;if(null==e){if("function"!=typeof t)throw new Error("Please provide a function to tidy()");e=t}else{if("string"!=typeof t&&!(t instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof e)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");a=t}return this.scopedRun((function(){return r.startScope(a)}),(function(){return r.endScope(n)}),(function(){return(n=e())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n}))},e.scopedRun=function(t,e,n){t();try{var r=n();return e(),r}catch(t){throw e(),t}},e.nextTensorId=function(){return t.nextTensorId++},e.nextVariableId=function(){return t.nextVariableId++},e.clone=function(t){var e=this.makeTensorFromDataId(t.dataId,t.shape,t.dtype),n={x:t};return this.addTapeNode(this.state.activeScope.name,n,[e],(function(t){return{x:function(){return t.toFloat()}}}),[],{}),e},e.runKernel=function(t,e,n,r,a){return this.runKernelFunc(null,e,null,t,n,r,a)},e.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST")},e.checkKernelForMemLeak=function(t,e,n){var r=this.backend.numDataIds(),a=0;n.forEach((function(t){a+="complex64"===t.dtype?3:1}));var i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],o=r-e-a-i;if(o>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak ("+o+" data ids) after running '"+t+"'")},e.runKernelFunc=function(t,e,n,r,a,i,o){var s,u=this,c=[],l=this.isTapeOn();null==r&&(r=null!=this.state.activeScope?this.state.activeScope.name:"");var h,f=this.state.numBytes,p=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var d,m=sv(r,this.backendName);if(null!=m)h=function(){var t=u.backend.numDataIds();d=m.kernelFunc({inputs:e,attrs:a,backend:u.backend});var n=Array.isArray(d)?d:[d];u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(r,t,n);var s=n.map((function(t){var e=t.dataId,n=t.shape,r=t.dtype;return u.makeTensorFromDataId(e,n,r)}));if(l){var h=u.getTensorsForGradient(r,e,s);if(null==h){null==o&&(o=[]);var f=s.filter((function(t,e){return o[e]}));h=(i||[]).slice().concat(f)}c=u.saveTensorsForBackwardMode(h)}return s};else{var v=function(t){l&&(c=t.map((function(t){return u.keep(u.clone(t))})))};h=function(){var e=u.backend.numDataIds();d=u.tidy((function(){return t(u.backend,v)}));var n=Array.isArray(d)?d:[d];return u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(r,e,n),n}}return this.scopedRun((function(){return u.state.kernelDepth++}),(function(){return u.state.kernelDepth--}),(function(){s=u.ENV.getBool("DEBUG")?u.profiler.profileKernel(r,e,(function(){return h()})):h()})),l&&this.addTapeNode(r,e,s,n,c,a),this.state.profiling&&this.state.activeProfile.kernels.push({name:r,bytesAdded:this.state.numBytes-f,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-p,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(e).map((function(t){return e[t].shape})),outputShapes:s.map((function(t){return t.shape}))}),Array.isArray(d)?s:s[0]},e.saveTensorsForBackwardMode=function(t){var e=this;return t.map((function(t){return e.keep(e.clone(t))}))},e.getTensorsForGradient=function(t,e,n){var r=uv(t);if(null!=r){var a,i=r.inputsToSave||[],o=r.outputsToSave||[];r.saveAllInputs?(gv(Array.isArray(e),(function(){return"saveAllInputs is true, expected inputs to be an array."})),a=Object.keys(e).map((function(t){return e[t]}))):a=i.map((function(t){return e[t]}));var s=n.filter((function(t,e){return o[e]}));return a.concat(s)}return null},e.makeTensor=function(t,e,n,r){if(null==t)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;var a=t;"string"===n&&Pv(t[0])&&(a=t.map((function(t){return Qv(t)})));var i=r.write(a,e,n),o=new pg(e,n,i,this.nextTensorId());if(this.incRef(o,r),"string"===n){var s=this.state.tensorInfo.get(i),u=Bv(a);this.state.numBytes+=u-s.bytes,s.bytes=u}return o},e.makeTensorFromDataId=function(t,e,n,r){var a=new pg(e,n=n||"float32",t,this.nextTensorId());return this.incRef(a,r),a},e.makeVariable=function(t,e,n,r){void 0===e&&(e=!0),n=n||this.nextVariableId().toString(),null!=r&&r!==t.dtype&&(t=t.asType(r));var a=new bg(t,e,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error("Variable with name "+a.name+" was already registered");return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a},e.incRef=function(t,e){var n=this.state.tensorInfo.has(t.dataId)?this.state.tensorInfo.get(t.dataId).refCount:0;if(this.state.numTensors++,"string"===t.dtype&&this.state.numStringTensors++,0===n){this.state.numDataBuffers++;var r=0;"complex64"!==t.dtype&&"string"!==t.dtype&&(r=t.size*zv(t.dtype)),this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:r,refCount:0}),this.state.numBytes+=r}this.state.tensorInfo.get(t.dataId).refCount++,t instanceof bg||this.track(t)},e.disposeTensor=function(t){if(this.state.tensorInfo.has(t.dataId)){this.state.numTensors--,"string"===t.dtype&&this.state.numStringTensors--;var e=this.state.tensorInfo.get(t.dataId);e.refCount<=1?("complex64"!==t.dtype&&(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--}},e.disposeVariables=function(){for(var t in this.state.registeredVariables){var e=this.state.registeredVariables[t];this.disposeVariable(e)}},e.disposeVariable=function(t){this.disposeTensor(t),null!=this.state.registeredVariables[t.name]&&delete this.state.registeredVariables[t.name]},e.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,null==t.reasons&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t},e.profile=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.state.profiling=!0,n=this.state.numBytes,r=this.state.numTensors,this.state.activeProfile.kernels=[],this.state.activeProfile.result=e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map((function(t){return t.totalBytesSnapshot}))),this.state.activeProfile.newBytes=this.state.numBytes-n,this.state.activeProfile.newTensors=this.state.numTensors-r,t.abrupt("return",this.state.activeProfile);case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.isTapeOn=function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth},e.addTapeNode=function(t,e,n,r,a,i){var o=this,s={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:n,saved:a},u=uv(t);null!=u&&(r=u.gradFunc),null!=r&&(s.gradient=function(t){return t=t.map((function(t,e){if(null==t){var r=n[e],a=Yv(r.size,r.dtype);return o.makeTensor(a,r.shape,r.dtype)}return t})),r(t.length>1?t:t[0],a,i)}),this.state.activeTape.push(s)},e.keep=function(t){return t.kept=!0,t},e.startTape=function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++},e.endTape=function(){this.state.gradientDepth--},e.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},e.endScope=function(t){for(var e=this,n=Ng(t),r=new Set(n.map((function(t){return t.id}))),a=0;a<this.state.activeScope.track.length;a++){var i=this.state.activeScope.track[a];i.kept||r.has(i.id)||i.dispose()}var o=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],n.forEach((function(t){t.kept||t.scopeId!==o.id||e.track(t)}))},e.gradients=function(t,e,n,r){var a=this;if(void 0===r&&(r=!1),gv(e.length>0,(function(){return"gradients() received an empty list of xs."})),null!=n&&"float32"!==n.dtype)throw new Error("dy must have 'float32' dtype, but has '"+n.dtype+"'");var i=this.scopedRun((function(){return a.startTape()}),(function(){return a.endTape()}),(function(){return a.tidy("forward",t)}));gv(i instanceof pg,(function(){return"The result y returned by f() must be a tensor."}));var o=function(t,e,n){for(var r={},a={},i=0;i<e.length;i++)r[e[i].id]=!0;for(var o=0;o<t.length;o++){var s=t[o],u=s.inputs;for(var c in u){for(var l=u[c],h=!1,f=0;f<e.length;f++)if(r[l.id]){s.outputs.forEach((function(t){return r[t.id]=!0})),h=!0,a[s.id]=!0;break}if(h)break}}var p={};p[n.id]=!0;for(var d={},m=t.length-1;m>=0;m--)for(var v=t[m],g=v.inputs,y=0;y<v.outputs.length;y++)if(p[v.outputs[y].id]){for(var b in g)p[g[b].id]=!0,d[v.id]=!0;break}for(var x=[],w=0;w<t.length;w++){var k=t[w];if(a[k.id]&&d[k.id]){var S={};for(var C in k.inputs){var R=k.inputs[C];r[R.id]&&(S[C]=R)}var N=Object.assign({},k);N.inputs=S,N.outputs=k.outputs,x.push(N)}}return x}(this.state.activeTape,e,i);if(!r&&0===o.length&&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 t,r,s={};s[i.id]=null==n?(t=i.shape,r=Xv(wv(t),"float32"),Tg.makeTensor(r,t,"float32")):n,function(t,e,n){for(var r=function(r){var a=e[r],i=[];if(a.outputs.forEach((function(e){var n=t[e.id];null!=n?i.push(n):i.push(null)})),null==a.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+a.kernelName+".");var o=a.gradient(i),s=function(e){if(!(e in o))throw new Error("Cannot backprop through input "+e+". Available gradients found: "+Object.keys(o)+".");var r=n((function(){return o[e]()}));if("float32"!==r.dtype)throw new Error("Error in gradient for op "+a.kernelName+". The gradient of input "+e+" must have 'float32' dtype, but has '"+r.dtype+"'");var i=a.inputs[e];if(!kv(r.shape,i.shape))throw new Error("Error in gradient for op "+a.kernelName+". The gradient of input '"+e+"' has shape '"+r.shape+"', which does not match the shape of the input '"+i.shape+"'");if(null==t[i.id])t[i.id]=r;else{var s=t[i.id];t[i.id]=s.add(r),s.dispose()}};for(var u in a.inputs)s(u)},a=e.length-1;a>=0;a--)r(a)}(s,o,(function(t){return a.tidy(t)}));var u=e.map((function(t){return s[t.id]}));return 0===a.state.gradientDepth&&(a.state.activeTape.forEach((function(t){for(var e,n=Zm(t.saved);!(e=n()).done;){e.value.dispose()}})),a.state.activeTape=null),{value:i,grads:u}}))},e.customGrad=function(t){var e=this;return gv(jv(t),(function(){return"The f passed in customGrad(f) must be a function."})),function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];var i;gv(r.every((function(t){return t instanceof pg})),(function(){return"The args passed in customGrad(f)(x1, x2,...) must all be tensors"}));var o={};return r.forEach((function(t,e){o[e]=t})),e.runKernelFunc((function(e,n){return gv((i=t.apply(void 0,[].concat(r,[n]))).value instanceof pg,(function(){return"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"})),gv(jv(i.gradFunc),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."})),i.value}),o,(function(t,e){var n=i.gradFunc(t,e),a=Array.isArray(n)?n:[n];gv(a.length===r.length,(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."})),gv(a.every((function(t){return t instanceof pg})),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."}));var o={};return a.forEach((function(t,e){o[e]=function(){return t}})),o}))}},e.readSync=function(t){return this.state.tensorInfo.get(t).backend.readSync(t)},e.read=function(t){return this.state.tensorInfo.get(t).backend.read(t)},e.time=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Jv(),t.next=3,this.backend.time(e);case 3:return(r=t.sent).wallMs=Jv()-n,t.abrupt("return",r);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.track=function(t){return null!=this.state.activeScope&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t},e.reset=function(){for(var t in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new Ig,this.registry)this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null},jm(t,[{key:"backend",get:function(){if(null!=this.pendingBackendInit)throw new Error("Backend '"+this.backendName+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");if(null==this.backendInstance){var t=this.initializeBackendsAndReturnBest(),e=t.name;if(t.asyncInit)throw new Error("The highest priority backend '"+e+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");this.setBackend(e)}return this.backendInstance}},{key:"registeredVariables",get:function(){return this.state.registeredVariables}}]),t}();Ag.nextTensorId=0,Ag.nextVariableId=0;var Tg=function(){var e=rv();if(null==e._tfengine){var n=new tv(e);e._tfengine=new Ag(n)}return function(e){t.ENV=e}(e._tfengine.ENV),hg=function(){return e._tfengine},e._tfengine}();function Dg(){if("undefined"!=typeof navigator&&null!=navigator){var t=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function _g(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var Og={__proto__:null,isMobile:Dg,isBrowser:_g},Fg=nv();Fg.registerFlag("DEBUG",(function(){return!1}),(function(t){t&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),Fg.registerFlag("IS_BROWSER",(function(){return _g()})),Fg.registerFlag("IS_NODE",(function(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node})),Fg.registerFlag("IS_CHROME",(function(){return"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)})),Fg.registerFlag("PROD",(function(){return!1})),Fg.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(function(){return Fg.getBool("DEBUG")})),Fg.registerFlag("DEPRECATION_WARNINGS_ENABLED",(function(){return!0})),Fg.registerFlag("IS_TEST",(function(){return!1}));function Mg(t,e){for(var n=t.length,r=[],a=0;a<n;a++){var i=n-1-a,o=t[i]||1;(e[e.length-1-a]||1)>1&&1===o&&r.unshift(i)}return r}function Lg(t,e){for(var n=[],r=0;r<e.length;r++){var a=t[t.length-r-1],i=e.length-r-1,o=e[i];(null==a||1===a&&o>1)&&n.unshift(i)}return n}function zg(t,e){for(var n=[],r=Math.max(t.length,e.length),a=0;a<r;a++){var i=t[t.length-a-1];null==i&&(i=1);var o=e[e.length-a-1];if(null==o&&(o=1),1===i)n.unshift(o);else if(1===o)n.unshift(i);else{if(i!==o)throw Error("Operands could not be broadcast together with shapes "+t+" and "+e+".");n.unshift(i)}}return n}var Bg={kernelName:"Add",inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],r=e[1],a=zg(n.shape,r.shape);return{a:function(){var e=t,r=Lg(n.shape,a);return r.length>0&&(e=e.sum(r)),e.reshape(n.shape)},b:function(){var e=t,n=Lg(r.shape,a);return n.length>0&&(e=e.sum(n)),e.reshape(r.shape)}}}},Pg={kernelName:"AddN",saveAllInputs:!0,gradFunc:function(t,e){var n={};return e.forEach((function(e,r){n[r]=function(){return t.clone()}})),n}};function Wg(t,e){var n=t;if(Lv(t))return"string"===e?[]:[t.length];if(!Array.isArray(t))return[];for(var r=[];Array.isArray(n)||Lv(n)&&"string"!==e;)r.push(n.length),n=n[0];return Array.isArray(t)&&nv().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function t(e,n,r){if(r=r||[],!Array.isArray(e)&&!Lv(e))return void gv(0===n.length,(function(){return"Element arr["+r.join("][")+"] is a primitive, but should be an array/TypedArray of "+n[0]+" elements"}));gv(n.length>0,(function(){return"Element arr["+r.join("][")+"] should be a primitive, but is an array of "+e.length+" elements"})),gv(e.length===n[0],(function(){return"Element arr["+r.join("][")+"] should have "+n[0]+" elements, but has "+e.length+" elements"}));for(var a=n.slice(1),i=0;i<e.length;++i)t(e[i],a,r.concat(i))}(t,r,[]),r}function Vg(t,e,n,r){if(null!=t&&("numeric"!==t&&t!==e||"numeric"===t&&"string"===e))throw new Error("Argument '"+n+"' passed to '"+r+"' must be "+t+" tensor, but got "+e+" tensor")}function Ug(t,e,n,r){if(void 0===r&&(r="numeric"),t instanceof pg)return Vg(r,t.dtype,e,n),t;var a=Uv(t);if("string"!==a&&["bool","int32","float32"].indexOf(r)>=0&&(a=r),Vg(r,a,e,n),null==t||!Lv(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t){var i=null==t?"null":t.constructor.name;throw new Error("Argument '"+e+"' passed to '"+n+"' must be a Tensor or TensorLike, but got '"+i+"'")}var o=Wg(t,a);Lv(t)||Array.isArray(t)||(t=[t]);var s="string"!==a?Hv(t,a,nv().getBool("DEBUG")):xv(t,[],!0);return Tg.makeTensor(s,o,a)}function jg(t,e,n,r){if(void 0===r&&(r="numeric"),!Array.isArray(t))throw new Error("Argument "+e+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");return t.map((function(t,r){return Ug(t,e+"["+r+"]",n)}),r)}function Gg(t,e){for(var n=0;n<t.length;++n)if(t[t.length-n-1]!==e-1-n)return!1;return!0}function qg(t,e,n){for(var r=t.length+e.length,a=[],i=0,o=0,s=0;s<r;s++)-1===n.indexOf(s)?a.push(t[i++]):a.push(e[o++]);return a}function Hg(t,e){for(var n=[],r=t.length,a=0;a<r;a++)-1===e.indexOf(a)&&n.push(t[a]);return[n,e.map((function(e){return t[e]}))]}function Kg(t,e){return qg(t,e.map((function(t){return 1})),e)}function Xg(t,e,n){gv(Gg(e,n),(function(){return t+" supports only inner-most axes for now. Got axes "+e+" and rank-"+n+" input."}))}function Yg(t,e){if(Gg(t,e))return null;for(var n=[],r=0;r<e;++r)-1===t.indexOf(r)&&n.push(r);return t.forEach((function(t){return n.push(t)})),n}function Jg(t){return t.map((function(t,e){return[e,t]})).sort((function(t,e){return t[1]-e[1]})).map((function(t){return t[0]}))}function $g(t,e){for(var n=[],r=e-t;r<e;++r)n.push(r);return n}function Zg(t,e){var n=t[0].length;t.forEach((function(t,e){gv(t.length===n,(function(){return"Error in concat"+n+"D: rank of tensors["+e+"] must be the same as the rank of the rest ("+n+")"}))})),gv(e>=0&&e<n,(function(){return"Error in concat"+n+"D: axis must be between 0 and "+(n-1)+"."}));var r=t[0];t.forEach((function(t,a){for(var i=0;i<n;i++)gv(i===e||t[i]===r[i],(function(){return"Error in concat"+n+"D: Shape of tensors["+a+"] ("+t+") does not match the shape of the rest ("+r+") along the non-concatenated axis "+a+"."}))}))}function Qg(t,e){for(var n=t[0].slice(),r=1;r<t.length;r++)n[e]+=t[r][e];return n}function ty(t){var e=Object.keys(t);if(1!==e.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+e.length+" keys.");var n=e[0],r=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1));var a=function(){Tg.startScope(n);try{var t=r.apply(void 0,arguments);return t instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),Tg.endScope(t),t}catch(t){throw Tg.endScope(null),t}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}var ey=ty({complex_:function(t,e){var n=Ug(t,"real","complex"),r=Ug(e,"imag","complex");return yv(n.shape,r.shape,"real and imag shapes, "+n.shape+" and "+r.shape+", must match in call to tf.complex()."),Tg.runKernelFunc((function(t){return t.complex(n,r)}),{$real:n,$imag:r})}}),ny=ty({real_:function(t){var e=Ug(t,"input","real");return Tg.runKernelFunc((function(t){return t.real(e)}),{$input:e})}}),ry=ty({imag_:function(t){var e=Ug(t,"input","imag");return Tg.runKernelFunc((function(t){return t.imag(e)}),{$input:e})}});function ay(t,e,n){return iy(t,e,Wg(t,n),n)}function iy(t,e,n,r){if(null==r&&(r=Uv(t)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Lv(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=e){$v(e);var a=wv(e),i=wv(n);gv(a===i,(function(){return"Based on the provided shape, ["+e+"], the tensor should have "+a+" values but has "+i}));for(var o=0;o<n.length;++o){var s=n[o],u=o!==n.length-1||s!==wv(e.slice(o));gv(n[o]===e[o]||!u,(function(){return"Error creating a new Tensor. Inferred shape ("+n+") does not match the provided shape ("+e+"). "}))}}return Lv(t)||Array.isArray(t)||(t=[t]),e=e||n,t="string"!==r?Hv(t,r,nv().getBool("DEBUG")):xv(t,[],!0),Tg.makeTensor(t,e,r)}function oy(t,e){if((Lv(t)&&"string"!==e||Array.isArray(t))&&"complex64"!==e)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===e&&Lv(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return iy(t,[],[],e)}function sy(t,e){bv(t);var n=Wg(t,e);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return iy(t,null,n,e)}function uy(t,e,n){if(bv(t),null!=e&&2!==e.length)throw new Error("tensor2d() requires shape to have two numbers");var r=Wg(t,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return iy(t,e,r,n)}function cy(t,e,n){if(bv(t),null!=e&&3!==e.length)throw new Error("tensor3d() requires shape to have three numbers");var r=Wg(t,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return iy(t,e,r,n)}function ly(t,e,n){if(bv(t),null!=e&&4!==e.length)throw new Error("tensor4d() requires shape to have four numbers");var r=Wg(t,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return iy(t,e,r,n)}function hy(t,e,n){if(bv(t),null!=e&&5!==e.length)throw new Error("tensor5d() requires shape to have five numbers");var r=Wg(t,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return iy(t,e,r,n)}function fy(t,e,n){if(bv(t),null!=e&&6!==e.length)throw new Error("tensor6d() requires shape to have six numbers");var r=Wg(t,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return iy(t,e=e||r,r,n)}function py(t,e,n,r){return void 0===e&&(e=!0),Tg.makeVariable(t,e,n,r)}function dy(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=dy(t,"float32"),r=my(t,"float32");return ey(n,r)}var a=Xv(wv(t),e);return Tg.makeTensor(a,t,e)}function my(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=my(t,"float32"),r=my(t,"float32");return ey(n,r)}var a=Yv(wv(t),e);return Tg.makeTensor(a,t,e)}function vy(t,e,n){return Tg.runKernelFunc((function(r){return r.fill(t,e,n)}),{})}function gy(t,e,n){if(n<=0)throw new Error("The number of values should be positive.");return Tg.runKernelFunc((function(r){return r.linspace(t,e,n)}),{})}function yy(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r="float32"),0===n)throw new Error("Cannot have a step of zero");if(t===e||t<e&&n<0||e<t&&n>1)return my([0],r);var a=Yv(Math.abs(Math.ceil((e-t)/n)),r);e<t&&1===n&&(n=-1),a[0]=t;for(var i=1;i<a.length;i++)a[i]=a[i-1]+n;return sy(a,r)}var by=ty({onesLike_:function(t){var e=Ug(t,"x","onesLike");if("complex64"===e.dtype){var n=by(ny(e)),r=xy(ry(e));return ey(n,r)}return Tg.runKernelFunc((function(t){return t.onesLike(e)}),{x:e},(function(t,e){return{x:function(){return xy(t)}}}),"OnesLike")}}),xy=ty({zerosLike_:function(t){var e=Ug(t,"x","zerosLike");return Tg.runKernelFunc((function(t){return t.zerosLike(e)}),{x:e},(function(t,e){return{x:function(){return xy(t)}}}),"ZerosLike")}});var wy=ty({concat_:function(t,e){void 0===e&&(e=0),gv(t.length>=1,(function(){return"Pass at least one tensor to concat"}));var n=jg(t,"tensors","concat");"complex64"===n[0].dtype&&n.forEach((function(t){if("complex64"!==t.dtype)throw new Error("Cannot concatenate complex64 tensors with a tensor\n with dtype "+t.dtype+". ")}));var r=Av(e,n[0].shape)[0],a=Qg(n.map((function(t){return t.shape})),r);if(0===wv(a))return ay([],a);if(1===(n=n.filter((function(t){return t.size>0}))).length)return n[0];Zg(n.map((function(t){return t.shape})),r);var i=n,o={axis:e};return Tg.runKernelFunc((function(t,r){var a=Av(e,n[0].shape)[0],i=t.concat(n,a);return r(n),i}),i,null,"Concat",o)}});function ky(){return(ky=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u,c,l,h,f,p;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Ug(e,"x","setdiff1d"),a=Ug(n,"y","setdiff1d"),gv(r.dtype===a.dtype,(function(){return"x and y should have the same dtype, but got x ("+r.dtype+") and y ("+a.dtype+")."})),gv(1===r.rank,(function(){return"x should be 1D tensor, but got x ("+r.shape+")."})),gv(1===a.rank,(function(){return"y should be 1D tensor, but got y ("+a.shape+")."})),t.next=7,r.data();case 7:return i=t.sent,t.next=10,a.data();case 10:for(o=t.sent,s=new Set(o),u=0,c=0;c<i.length;c++)s.has(i[c])||u++;for(l=new lg([u],r.dtype),h=new lg([u],"int32"),f=0,p=0;f<i.length;f++)s.has(i[f])||(l.values[p]=i[f],h.values[p]=f,p++);return t.abrupt("return",[l.toTensor(),h.toTensor()]);case 18:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Sy(t,e,n){return void 0===e&&(e="float32"),e=e||"float32",$v(t),new lg(t,e,n)}function Cy(t,e){void 0===e&&(e=!1),console.log(t.toString(e))}var Ry=ty({cast_:function(t,e){var n=Ug(t,"x","cast");if(!Fv(e))throw new Error("Failed to cast to unknown dtype "+e);if("string"===e&&"string"!==n.dtype||"string"!==e&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var r={dtype:e};return Tg.runKernelFunc((function(t){return t.cast(n,e)}),{x:n},(function(t){return{x:function(){return t.clone()}}}),"Cast",r)}}),Ny=ty({cumsum_:function(t,e,n,r){void 0===e&&(e=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var a=Ug(t,"x","cumsum"),i=Yg([e|=0],a.rank),o=a;null!=i&&(o=a.transpose(i));var s=$g(1,a.rank)[0],u=Tg.runKernelFunc((function(t){return t.cumsum(o,s,n,r)}),{permutedX:o},(function(t){return{permutedX:function(){return t.cumsum(e,n,!r)}}}));return null!=i&&(u=u.transpose(i)),u}}),Ey=ty({expandDims_:function(t,e){void 0===e&&(e=0);var n=Ug(t,"x","expandDims",null);gv(e<=n.rank,(function(){return"Axis must be <= rank of the tensor"}));var r=n.shape.slice();return e<0&&(gv(-(n.rank+1)<=e,(function(){return"Axis must be in the interval ["+-(n.rank+1)+", "+n.rank+"]"})),e=n.rank+e+1),r.splice(e,0,1),Iy(n,r)}}),Iy=ty({reshape_:function(t,e){var n=Ug(t,"x","reshape",null);e=Iv(e,n.size),gv(n.size===wv(e),(function(){return"new shape and old shape must have the same number of elements."}));var r={shape:e};return Tg.runKernelFunc((function(t){return t.reshape(n,e)}),{x:n},(function(t){return{x:function(){return t.reshape(n.shape)}}}),"Reshape",r)}}),Ay=ty({squeeze_:function(t,e){var n=Ug(t,"x","squeeze");return Iy(n,Tv(n.shape,e).newShape)}}),Ty=ty({stack_:function(t,e){void 0===e&&(e=0);var n=jg(t,"tensors","stack");if(gv(n.length>=1,(function(){return"Pass at least one tensor to tf.stack"})),1===n.length)return n[0].expandDims(e);var r=n[0].rank,a=n[0].shape,i=n[0].dtype;gv(e<=r,(function(){return"Axis must be <= rank of the tensor"})),n.forEach((function(t){yv(a,t.shape,"All tensors passed to stack must have matching shapes")})),n.forEach((function(t){gv(i===t.dtype,(function(){return"All tensors passed to stack must have matching dtypes"}))}));var o=n.map((function(t){return t.expandDims(e)}));return wy(o,e)}}),Dy=ty({unstack_:function(t,e){void 0===e&&(e=0),e=e||0;var n=Ug(t,"x","unstack");gv(e>=-n.shape.length&&e<n.shape.length,(function(){return"Axis = "+e+" is not in [-"+n.shape.length+", "+n.shape.length+")"})),e<0&&(e+=n.shape.length);var r={axis:e};return Tg.runKernelFunc((function(t){return t.unstack(n,e)}),{x:n},(function(t){return{x:function(){return Ty(t,e)}}}),"Unpack",r)}}),_y=function(t,e){return ky.apply(this,arguments)};var Oy=ty({matMul_:function(t,e,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var a=Ug(t,"a","matMul"),i=Ug(e,"b","matMul"),o=Sg(a,i);a=o[0],i=o[1],gv(a.rank>=2&&i.rank>=2&&a.rank===i.rank,(function(){return"Error in matMul: inputs must have the same rank of at least 2, got ranks "+a.rank+" and "+i.rank+"."}));var s=n?a.shape[a.rank-2]:a.shape[a.rank-1],u=r?i.shape[i.rank-1]:i.shape[i.rank-2],c=n?a.shape[a.rank-1]:a.shape[a.rank-2],l=r?i.shape[i.rank-2]:i.shape[i.rank-1],h=a.shape.slice(0,-2),f=i.shape.slice(0,-2),p=wv(h),d=wv(f);gv(kv(h,f),(function(){return"Error in matMul: outer dimensions ("+h+") and ("+f+") of Tensors with shapes "+a.shape+" and "+i.shape+" must match."})),gv(s===u,(function(){return"Error in matMul: inner shapes ("+s+") and ("+u+") of Tensors with shapes "+a.shape+" and "+i.shape+" and transposeA="+n+" and transposeB="+r+" must match."}));var m=a.shape.slice(0,-2).concat([c,l]),v=Iy(a,n?[p,s,c]:[p,c,s]),g=Iy(i,r?[d,l,u]:[d,u,l]),y={a:v,b:g},b={transposeA:n,transposeB:r},x=Tg.runKernelFunc((function(t,e){return e([v,g]),t.batchMatMul(v,g,n,r)}),y,null,"BatchMatMul",b);return Iy(x,m)}}),Fy={kernelName:"BatchMatMul",inputsToSave:["a","b"],gradFunc:function(t,e,n){var r=e[0],a=e[1],i=n.transposeA,o=n.transposeB;return i||o?!i&&o?{a:function(){return Oy(t,a,!1,!1)},b:function(){return Oy(t,r,!0,!1)}}:i&&!o?{a:function(){return Oy(a,t,!1,!0)},b:function(){return Oy(r,t,!1,!1)}}:{a:function(){return Oy(a,t,!0,!0)},b:function(){return Oy(t,r,!0,!0)}}:{a:function(){return Oy(t,a,!1,!0)},b:function(){return Oy(r,t,!0,!1)}}}};var My=ty({spaceToBatchND_:function(t,e,n){var r=Ug(t,"x","spaceToBatchND");gv(r.rank>=1+e.length,(function(){return"input rank "+r.rank+" should be > than [blockShape] "+e.length})),gv(n.length===e.length,(function(){return"paddings.shape[0] "+n.length+" must be equal to [blockShape] "+e.length})),gv(r.shape.reduce((function(t,r,a){return a>0&&a<=e.length?t&&(r+n[a-1][0]+n[a-1][1])%e[a-1]==0:t}),!0),(function(){return"input spatial dimensions "+r.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+e.toString()}));var a={x:r},i={blockShape:e,paddings:n};return Tg.runKernelFunc((function(t){return t.spaceToBatchND(r,e,n)}),a,null,"SpaceToBatchND",i)}}),Ly={kernelName:"BatchToSpaceND",gradFunc:function(t,e,n){var r=n.blockShape,a=n.crops;return{x:function(){return My(t,r,a)}}}};function zy(t,e){gv(jv(t),(function(){return"The f passed in variableGrads(f) must be a function"})),gv(null==e||Array.isArray(e)&&e.every((function(t){return t instanceof bg})),(function(){return"The varList passed in variableGrads(f, varList) must be an array of variables"}));var n=null!=e;if(!n)for(var r in e=[],Tg.registeredVariables)e.push(Tg.registeredVariables[r]);var a=n?e.filter((function(t){return!t.trainable})):null,i=e.length;gv((e=e.filter((function(t){return t.trainable}))).length>0,(function(){return"variableGrads() expects at least one of the input variables to be trainable, but none of the "+i+" variables is trainable."}));var o=Tg.gradients(t,e,null,!0),s=o.value,u=o.grads;gv(u.some((function(t){return null!=t})),(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()."})),gv(0===s.rank,(function(){return"The f passed in variableGrads(f) must return a scalar, but it returned a rank-"+s.rank+" tensor"}));var c={};return e.forEach((function(t,e){null!=u[e]&&(c[t.name]=u[e])})),null!=a&&a.forEach((function(t){return c[t.name]=null})),{value:s,grads:c}}function By(t){return Tg.customGrad(t)}function Py(t){if(t.filter((function(t){return null==t})).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.")}function Wy(t,e,n,r,a){return e.rank<n.rank&&(e=e.reshape(Kg(e.shape,r))),t.rank<n.rank&&(t=t.reshape(Kg(t.shape,r))),{x:function(){var r=t.mul(n.equal(e).cast(t.dtype));return null==a?r:r.transpose(a)}}}var Vy=ty({all_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Ug(t,"x","all","bool"),a=Av(e,r.shape),i=a,o=Yg(i,r.rank);null!=o&&(r=r.transpose(o),i=$g(i.length,r.rank));var s=Tg.runKernelFunc((function(t){return t.all(r,i)}),{$x:r});if(n){var u=Kg(s.shape,a);return s.reshape(u)}return s}}),Uy=ty({any_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Ug(t,"x","any","bool"),a=Av(e,r.shape),i=a,o=Yg(i,r.rank);null!=o&&(r=r.transpose(o),i=$g(i.length,r.rank));var s=Tg.runKernelFunc((function(t){return t.any(r,i)}),{$x:r});if(n){var u=Kg(s.shape,a);return s.reshape(u)}return s}}),jy=ty({argMax_:function(t,e){void 0===e&&(e=0);var n=Ug(t,"x","argMax");null==e&&(e=0);var r=Av(e,n.shape),a=Yg(r,n.rank);null!=a&&(n=n.transpose(a),r=$g(r.length,n.rank));var i={axis:r[0]},o=[n];return Tg.runKernelFunc((function(t,e){var a=t.argMax(n,r[0]);return e([n]),a}),{x:n},(function(t,e){var n=e[0];return{x:function(){return xy(n)}}}),"ArgMax",i,o)}}),Gy=ty({argMin_:function(t,e){void 0===e&&(e=0);var n=Ug(t,"x","argMin");null==e&&(e=0);var r=Av(e,n.shape),a=Yg(r,n.rank);return null!=a&&(n=n.transpose(a),r=$g(r.length,n.rank)),Tg.runKernelFunc((function(t,e){var a=t.argMin(n,r[0]);return e([n]),a}),{$x:n},(function(t,e){var n=e[0];return{$x:function(){return xy(n)}}}))}}),qy=ty({logSumExp_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Ug(t,"x","logSumExp"),a=Av(e,r.shape),i=r.max(a,!0),o=r.sub(i).exp().sum(a).log(),s=i.reshape(o.shape).add(o);if(n){var u=Kg(s.shape,a);return s.reshape(u)}return s}}),Hy=ty({mean_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Ug(t,"x","mean"),a=Av(e,r.shape),i=wv(Hg(r.shape,a)[1]);return By((function(t){var r=oy(i);return{value:(r.dtype===t.dtype?t:t.cast(r.dtype)).div(r).sum(e,n),gradFunc:function(e){var n=t.shape.slice();return a.forEach((function(t){n[t]=1})),e.reshape(n).mul(dy(t.shape,"float32")).div(i)}}}))(r)}}),Ky=ty({min_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Ug(t,"x","min"),a=r,i=Av(e,r.shape),o=i,s=Yg(o,r.rank);null!=s&&(r=r.transpose(s),o=$g(o.length,r.rank));var u=[r],c=Tg.runKernelFunc((function(t,e){var n=t.min(r,o);return e([a,n]),n}),{x:r},(function(t,e){return Wy(t,e[1],e[0],i,s)}),"Min",{axes:o},u,[!0]);if(n){var l=Kg(c.shape,i);c=c.reshape(l)}return c}}),Xy=ty({moments_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Av(e,(t=Ug(t,"x","moments")).shape),a=t.mean(r,n),i=a.shape;n||(i=Kg(a.shape,r));var o=t.toFloat().sub(a.reshape(i)).square();return{mean:a,variance:o.mean(r,n)}}}),Yy=ty({sum_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Ug(t,"x","sum");"bool"===r.dtype&&(r=r.toInt());var a=Av(e,r.shape);return By((function(t){var e=Yg(a,t.rank),r=a,i=t;null!=e&&(i=t.transpose(e),r=$g(r.length,t.rank));var o=function(e){var n=t.shape.slice();return a.forEach((function(t){n[t]=1})),e.reshape(n).mul(dy(t.shape,"float32"))},s={axes:r},u=Tg.runKernelFunc((function(t){return t.sum(i,r)}),{x:i},(function(t){return{x:function(){return o(t)}}}),"Sum",s);if(n){var c=Kg(u.shape,a);u=u.reshape(c)}return{value:u,gradFunc:o}}))(r)}}),Jy=ty({prod_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Ug(t,"x","prod");"bool"===r.dtype&&(r=r.toInt());var a=Av(e,r.shape),i=Yg(a,r.rank),o=a,s=r;null!=i&&(s=r.transpose(i),o=$g(o.length,r.rank));var u=Tg.runKernelFunc((function(t){return t.prod(s,o)}),{permutedX:s});if(n){var c=Kg(u.shape,a);u=u.reshape(c)}return u}}),$y={kernelName:"BroadcastTo",gradFunc:function(t,e,n){for(var r=n,a=r.inputShape,i=r.shape,o=Array.from(i),s=a.length-1;s>=0;s--)if(a[s]===i[s])o[s]=1;else if(1!==a[s])throw new Error("broadcastTo(): ["+a+"] cannot be broadcast to ["+i+"].");for(var u=[],c=0;c<o.length;c++)o[c]>1&&u.push(c);return{x:function(){return Yy(t,u,!0)}}}};var Zy=ty({split_:function(t,e,n){void 0===n&&(n=0);var r,a=Ug(t,"x","split"),i=Av(n,a.shape)[0];"number"==typeof e?(gv(a.shape[i]%e==0,(function(){return"Number of splits must evenly divide the axis."})),r=new Array(e).fill(a.shape[i]/e)):(gv(a.shape[i]===e.reduce((function(t,e){return t+e})),(function(){return"The sum of sizes must match the size of the axis dimension."})),r=e);var o={x:a},s={numOrSizeSplits:e,axis:n};return Tg.runKernelFunc((function(t,e){return t.split(a,r,i)}),o,null,"SplitV",s)}}),Qy={kernelName:"Concat",saveAllInputs:!0,gradFunc:function(t,e,n){var r=e.map((function(t){return t.shape})),a=Av(n.axis,e[0].shape)[0],i=r.map((function(t){return t[a]}));return Zy(t,i,a).map((function(t){return function(){return t}}))}};function tb(t,e,n,r,a,i,o){void 0===o&&(o="channelsLast");var s,u=ib(e),c=u[0],l=u[1];if("channelsLast"===o)s=[c,l,t[3],t[3]];else{if("channelsFirst"!==o)throw new Error("Unknown dataFormat "+o);s=[c,l,t[1],t[1]]}return nb(t,s,n,r,a,i,!1,o)}function eb(t,e,n,r,a,i,o){void 0===o&&(o="NDHWC");var s,u,c=ob(e),l=c[0],h=c[1],f=c[2];if("NDHWC"===o)u="channelsLast",s=[l,h,f,t[4],t[4]];else{if("NCDHW"!==o)throw new Error("Unknown dataFormat "+o);u="channelsFirst",s=[l,h,f,t[1],t[1]]}return rb(t,s,n,r,a,!1,u,i)}function nb(t,e,n,r,a,i,o,s){void 0===o&&(o=!1),void 0===s&&(s="channelsLast");var u=-1,c=-1,l=-1,h=-1;if("channelsLast"===s)u=t[0],c=t[1],l=t[2],h=t[3];else{if("channelsFirst"!==s)throw new Error("Unknown dataFormat "+s);u=t[0],h=t[1],c=t[2],l=t[3]}var f,p=e[0],d=e[1],m=e[3],v=ib(n),g=v[0],y=v[1],b=ib(r),x=b[0],w=b[1],k=sb(p,x),S=sb(d,w),C=function(t,e,n,r,a,i,o,s){var u,c,l;if("number"==typeof t){u={top:t,bottom:t,left:t,right:t,type:0===t?"VALID":"NUMBER"};var h=function(t,e,n,r,a){null==r&&(r=ab(t,e,n));var i=t[0],o=t[1],s=ub((i-e+2*r)/n+1,a);gv(Sv(s),(function(){return"The output # of rows ("+s+") must be an integer. Change the stride and/or zero pad parameters"}));var u=ub((o-e+2*r)/n+1,a);return gv(Sv(u),(function(){return"The output # of columns ("+u+") must be an integer. Change the stride and/or zero pad parameters"})),[s,u]}([e,n],i,r,t,s);c=h[0],l=h[1]}else if("same"===t){c=Math.ceil(e/r),l=Math.ceil(n/a);var f=Math.max(0,(c-1)*r+i-e),p=Math.max(0,(l-1)*a+o-n),d=Math.floor(f/2),m=f-d,v=Math.floor(p/2);u={top:d,bottom:m,left:v,right:p-v,type:"SAME"}}else{if("valid"!==t)throw Error("Unknown padding parameter: "+t);u={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((e-i+1)/r),l=Math.ceil((n-o+1)/a)}return{padInfo:u,outHeight:c,outWidth:l}}(a,c,l,g,y,k,S,i),R=C.padInfo,N=C.outHeight,E=C.outWidth,I=o?m*h:m;return"channelsFirst"===s?f=[u,I,N,E]:"channelsLast"===s&&(f=[u,N,E,I]),{batchSize:u,dataFormat:s,inHeight:c,inWidth:l,inChannels:h,outHeight:N,outWidth:E,outChannels:I,padInfo:R,strideHeight:g,strideWidth:y,filterHeight:p,filterWidth:d,effectiveFilterHeight:k,effectiveFilterWidth:S,dilationHeight:x,dilationWidth:w,inShape:t,outShape:f,filterShape:e}}function rb(t,e,n,r,a,i,o,s){void 0===i&&(i=!1),void 0===o&&(o="channelsLast");var u=-1,c=-1,l=-1,h=-1,f=-1;if("channelsLast"===o)u=t[0],c=t[1],l=t[2],h=t[3],f=t[4];else{if("channelsFirst"!==o)throw new Error("Unknown dataFormat "+o);u=t[0],f=t[1],c=t[2],l=t[3],h=t[4]}var p,d=e[0],m=e[1],v=e[2],g=e[4],y=ob(n),b=y[0],x=y[1],w=y[2],k=ob(r),S=k[0],C=k[1],R=k[2],N=sb(d,S),E=sb(m,C),I=sb(v,R),A=function(t,e,n,r,a,i,o,s,u,c,l){var h,f,p,d;if("number"==typeof t){h={top:t,bottom:t,left:t,right:t,front:t,back:t,type:0===t?"VALID":"NUMBER"};var m=function(t,e,n,r,a,i){null==a&&(a=ab(t,e,r));var o=t[0],s=t[1],u=t[2],c=ub((o-e+2*a)/r+1,i);gv(Sv(c),(function(){return"The output # of depths ("+c+") must be an integer. Change the stride and/or zero pad parameters"}));var l=ub((s-e+2*a)/r+1,i);gv(Sv(l),(function(){return"The output # of rows ("+l+") must be an integer. Change the stride and/or zero pad parameters"}));var h=ub((u-e+2*a)/r+1,i);return gv(Sv(h),(function(){return"The output # of columns ("+h+") must be an integer. Change the stride and/or zero pad parameters"})),[c,l,h,n]}([e,n,r,1],s,1,a,t,l);f=m[0],p=m[1],d=m[2]}else if("same"===t){f=Math.ceil(e/a),p=Math.ceil(n/i),d=Math.ceil(r/o);var v=(f-1)*a+s-e,g=(p-1)*i+u-n,y=(d-1)*o+c-r,b=Math.floor(v/2),x=v-b,w=Math.floor(g/2),k=g-w,S=Math.floor(y/2);h={top:w,bottom:k,left:S,right:y-S,front:b,back:x,type:"SAME"}}else{if("valid"!==t)throw Error("Unknown padding parameter: "+t);h={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},f=Math.ceil((e-s+1)/a),p=Math.ceil((n-u+1)/i),d=Math.ceil((r-c+1)/o)}return{padInfo:h,outDepth:f,outHeight:p,outWidth:d}}(a,c,l,h,b,x,w,N,E,I,s),T=A.padInfo,D=A.outDepth,_=A.outHeight,O=A.outWidth,F=i?g*f:g;return"channelsFirst"===o?p=[u,F,D,_,O]:"channelsLast"===o&&(p=[u,D,_,O,F]),{batchSize:u,dataFormat:o,inDepth:c,inHeight:l,inWidth:h,inChannels:f,outDepth:D,outHeight:_,outWidth:O,outChannels:F,padInfo:T,strideDepth:b,strideHeight:x,strideWidth:w,filterDepth:d,filterHeight:m,filterWidth:v,effectiveFilterDepth:N,effectiveFilterHeight:E,effectiveFilterWidth:I,dilationDepth:S,dilationHeight:C,dilationWidth:R,inShape:t,outShape:p,filterShape:e}}function ab(t,e,n,r){void 0===r&&(r=1);var a=sb(e,r);return Math.floor((t[0]*(n-1)-n+a)/2)}function ib(t){return"number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t}function ob(t){return"number"==typeof t?[t,t,t]:t}function sb(t,e){return e<=1?t:t+(t-1)*(e-1)}function ub(t,e){if(!e)return t;switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error("Unknown roundingMode "+e)}}function cb(t){var e=ib(t),n=e[0],r=e[1],a=e[2];return 1===n&&1===r&&1===a}function lb(t,e){return cb(t)||cb(e)}function hb(t){if("NHWC"===t)return"channelsLast";if("NCHW"===t)return"channelsFirst";throw new Error("Unknown dataFormat "+t)}var fb=ty({conv2DBackpropFilter_:function(t,e,n,r,a,i,o){void 0===i&&(i="NHWC");var s=t;3===t.rank&&(s=Iy(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var u=e;3===u.rank&&(u=Iy(e,[1,e.shape[0],e.shape[1],e.shape[2]])),gv(4===s.rank,(function(){return"Error in conv2dDerFilter: input must be rank 4, but got shape "+s.shape+"."})),gv(4===u.rank,(function(){return"Error in conv2dDerFilter: dy must be rank 4, but got shape "+u.shape+"."})),gv(4===n.length,(function(){return"Error in conv2dDerFilter: filterShape must be length 4, but got "+n+"."}));var c="NHWC"===i?s.shape[3]:s.shape[1],l="NHWC"===i?u.shape[3]:u.shape[1];gv(c===n[2],(function(){return"Error in conv2dDerFilter: depth of input "+c+") must match input depth in filter ("+n[2]+"."})),gv(l===n[3],(function(){return"Error in conv2dDerFilter: depth of dy ("+l+") must match output depth for filter ("+n[3]+")."})),null!=o&&gv(Sv(a),(function(){return"Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+a+"."}));var h={x:s,dy:u},f={strides:r,pad:a,dataFormat:i,dimRoundingMode:o};return Tg.runKernelFunc((function(t){var e=hb(i),c=nb(s.shape,n,r,1,a,o,!1,e);return t.conv2dDerFilter(s,u,c)}),h,null,"Conv2DBackpropFilter",f)}});var pb=ty({conv2DBackpropInput_:function(t,e,n,r,a,i,o){void 0===i&&(i="NHWC"),gv(t.length===e.rank,(function(){return"Length of inShape ("+t.length+") and rank of dy ("+e.rank+") must match"}));var s=t,u=e,c=!1;3===e.rank&&(c=!0,u=Iy(e,[1,e.shape[0],e.shape[1],e.shape[2]]),s=[1,t[0],t[1],t[2]]),gv(4===s.length,(function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+s.length+"."})),gv(4===u.rank,(function(){return"Error in conv2dDerInput: dy must be rank 4, but got rank "+u.rank})),gv(4===n.rank,(function(){return"Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank}));var l="NHWC"===i?s[3]:s[1],h="NHWC"===i?u.shape[3]:u.shape[1];gv(l===n.shape[2],(function(){return"Error in conv2dDerInput: depth of input ("+l+") must match input depth for filter "+n.shape[2]+"."})),gv(h===n.shape[3],(function(){return"Error in conv2dDerInput: depth of output ("+h+") must match output depth for filter "+n.shape[3]+"."})),null!=o&&gv(Sv(a),(function(){return"Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+a+"."}));var f={dy:u,filter:n},p={strides:r,pad:a,dataFormat:i,dimRoundingMode:o},d=Tg.runKernelFunc((function(t,e){var c=hb(i),l=nb(s,n.shape,r,1,a,o,!1,c),h=t.conv2dDerInput(u,n,l);return e([u,n]),h}),f,null,"Conv2DBackpropInput",p);return c?Iy(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),db={kernelName:"Conv2D",inputsToSave:["x","filter"],gradFunc:function(t,e,n){var r=e[0],a=e[1],i=n.dilations,o=n.strides,s=n.pad,u=n.dataFormat;return gv(cb(i),(function(){return"Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+i+"'"})),{x:function(){return pb(r.shape,t,a,o,s,u)},filter:function(){return fb(r,t,a.shape,o,s,u)}}}};var mb=ty({conv2d_:function(t,e,n,r,a,i,o){void 0===a&&(a="NHWC"),void 0===i&&(i=[1,1]);var s=Ug(t,"x","conv2d"),u=Ug(e,"filter","conv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=Iy(s,[1,s.shape[0],s.shape[1],s.shape[2]])),gv(4===c.rank,(function(){return"Error in conv2d: input must be rank 4, but got rank "+c.rank+"."})),gv(4===u.rank,(function(){return"Error in conv2d: filter must be rank 4, but got rank "+u.rank+"."})),null!=o&&gv(Sv(r),(function(){return"Error in conv2d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."}));var h="NHWC"===a?c.shape[3]:c.shape[1];gv(h===u.shape[2],(function(){return"Error in conv2d: depth of input ("+h+") must match input depth for filter "+u.shape[2]+"."})),gv(lb(n,i),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"}));var f={x:c,filter:u},p={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:o},d=Tg.runKernelFunc((function(t,e){var s=hb(a),l=nb(c.shape,u.shape,n,i,r,o,!1,s),h=t.conv2d(c,u,l);return e([c,u]),h}),f,null,"Conv2D",p);return l?Iy(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),vb={kernelName:"Conv2DBackpropInput",inputsToSave:["dy","filter"],gradFunc:function(t,e,n){var r=e[0],a=e[1],i=n.strides,o=n.pad,s=n.dataFormat,u=n.dimRoundingMode;return{dy:function(){return mb(t,a,i,o,s,1,u)},filter:function(){return fb(t,r,a.shape,i,o,s,u)}}}};var gb=ty({conv3DBackpropFilter_:function(t,e,n,r,a){var i=t;4===t.rank&&(i=Iy(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]));var o=e;4===o.rank&&(o=Iy(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),gv(5===i.rank,(function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+i.shape+"."})),gv(5===o.rank,(function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+o.shape+"."})),gv(5===n.length,(function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+n+"."})),gv(i.shape[4]===n[3],(function(){return"Error in conv3dDerFilter: depth of input "+i.shape[4]+") must match input depth in filter ("+n[3]+"."})),gv(o.shape[4]===n[4],(function(){return"Error in conv3dDerFilter: depth of dy ("+o.shape[4]+") must match output depth for filter ("+n[4]+")."}));var s={x:i,y:o},u={strides:r,pad:a};return Tg.runKernelFunc((function(t){var e=rb(i.shape,n,r,1,a);return t.conv3dDerFilter(i,o,e)}),s,null,"Conv3DBackpropFilterV2",u)}});var yb=ty({conv3DBackpropInput_:function(t,e,n,r,a){gv(t.length===e.rank,(function(){return"Length of inShape ("+t.length+") and rank of dy ("+e.rank+") must match"}));var i=t,o=e,s=!1;4===e.rank&&(s=!0,o=Iy(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),i=[1,t[0],t[1],t[2],t[3]]);var u=i[4],c=o.shape[4];gv(5===i.length,(function(){return"Error in conv3dDerInput: inShape must be length 5, but got length "+i.length+"."})),gv(5===o.rank,(function(){return"Error in conv3dDerInput: dy must be rank 5, but got rank "+o.rank})),gv(5===n.rank,(function(){return"Error in conv3dDerInput: filter must be rank 5, but got rank "+n.rank})),gv(u===n.shape[3],(function(){return"Error in conv3dDerInput: depth of input ("+u+") must match input depth for filter "+n.shape[3]+"."})),gv(c===n.shape[4],(function(){return"Error in conv3dDerInput: depth of output ("+c+") must match output depth for filter "+n.shape[4]+"."}));var l={dy:o},h={pad:a},f=Tg.runKernelFunc((function(t){var e=rb(i,n.shape,r,1,a);return t.conv3dDerInput(o,n,e)}),l,null,"Conv3DBackpropInputV2",h);return s?Iy(f,[f.shape[1],f.shape[2],f.shape[3],f.shape[4]]):f}}),bb={kernelName:"Conv3D",inputsToSave:["x","filter"],gradFunc:function(t,e,n){var r=n.dilations,a=n.strides,i=n.pad;gv(cb(r),(function(){return"Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+r+"'"}));var o=e[0],s=e[1];return{x:function(){return yb(o.shape,t,s,a,i)},filter:function(){return gb(o,t,s.shape,a,i)}}}};var xb=ty({depthwiseConv2dNativeBackpropFilter_:function(t,e,n,r){var a=t;3===t.rank&&(a=Iy(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var i=e;3===i.rank&&(i=Iy(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var o={x:a,dy:i};return Tg.runKernelFunc((function(t){return t.depthwiseConv2DDerFilter(a,i,r)}),o,null,"DepthwiseConv2dNativeBackpropFilter")}});var wb=ty({depthwiseConv2dNativeBackpropInput_:function(t,e,n,r){var a=e,i=!1;3===e.rank&&(i=!0,a=Iy(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var o={dy:a},s=Tg.runKernelFunc((function(t){return t.depthwiseConv2DDerInput(a,n,r)}),o,null,"DepthwiseConv2dNativeBackpropInput");return i?Iy(s,[s.shape[1],s.shape[2],s.shape[3]]):s}}),kb={kernelName:"DepthwiseConv2dNative",inputsToSave:["x","filter"],gradFunc:function(t,e,n){var r=n.dilations,a=n.strides,i=n.pad,o=n.dimRoundingMode,s=null==r?[1,1]:r;gv(cb(s),(function(){return"Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '"+s+"'"}));var u=e[0],c=e[1];gv(4===u.rank,(function(){return"Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank "+u.rank+"."})),gv(4===c.rank,(function(){return"Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank "+c.rank+"."})),gv(u.shape[3]===c.shape[2],(function(){return"Error in gradient of depthwiseConv2d: number of input channels ("+u.shape[3]+") must match the inChannels dimension in filter "+c.shape[2]+"."})),gv(lb(a,s),(function(){return"Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides "+a+" and dilations '"+s+"'."})),null!=o&&gv(Sv(i),(function(){return"Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+"."}));var l=nb(u.shape,c.shape,a,s,i,o,!0);return{x:function(){return wb(u.shape,t,c,l)},filter:function(){return xb(u,t,c.shape,l)}}}};function Sb(t){nv().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function Cb(){return Tg}function Rb(){return Tg.memory()}function Nb(t,e){return Tg.tidy(t,e)}function Eb(t){Ng(t).forEach((function(t){return t.dispose()}))}function Ib(t){return Tg.keep(t)}function Ab(t,e,n){return void 0===n&&(n=1),Tg.registerBackend(t,e,n)}function Tb(){return Tg.backend}var Db=ty({add_:function(t,e){var n=Ug(t,"a","add"),r=Ug(e,"b","add"),a=Sg(n,r);n=a[0],r=a[1];var i={a:n,b:r};return Tg.runKernelFunc((function(t,e){var a=t.add(n,r);return e([n,r]),a}),i,null,"Add")}});var _b=ty({abs_:function(t){var e=Ug(t,"x","abs");return"complex64"===e.dtype?Tg.runKernelFunc((function(t){return t.complexAbs(e)}),{$x:e}):Tg.runKernelFunc((function(t,n){var r=t.abs(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.mul(n.toFloat().step(-1))}}}),"Abs")}}),Ob=ty({acos_:function(t){var e=Ug(t,"x","acos");return Tg.runKernelFunc((function(t,n){var r=t.acos(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){var e=n.toFloat().square(),r=oy(1).sub(e).sqrt();return t.div(r).neg()}}}))}}),Fb=ty({acosh_:function(t){var e=Ug(t,"x","acosh");return Tg.runKernelFunc((function(t,n){var r=t.acosh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){var e=n.toFloat().square().sub(1).sqrt();return t.div(e)}}}))}}),Mb=ty({asin_:function(t){var e=Ug(t,"x","asin");return Tg.runKernelFunc((function(t,n){var r=t.asin(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(oy(1).sub(n.toFloat().square()).sqrt())}}}))}}),Lb=ty({asinh_:function(t){var e=Ug(t,"x","asinh");return Tg.runKernelFunc((function(t,n){var r=t.asinh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){var e=oy(1).add(n.toFloat().square()).sqrt();return t.div(e)}}}))}}),zb=ty({atan_:function(t){var e=Ug(t,"x","atan");return Tg.runKernelFunc((function(t,n){var r=t.atan(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.toFloat().square().add(1))}}}))}}),Bb=ty({atanh_:function(t){var e=Ug(t,"x","atanh");return Tg.runKernelFunc((function(t,n){var r=t.atanh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(oy(1).sub(n.toFloat().square()))}}}))}}),Pb=ty({ceil_:function(t){var e=Ug(t,"x","ceil");return Tg.runKernelFunc((function(t){return t.ceil(e)}),{$x:e},(function(t){return{$x:function(){return xy(t)}}}))}}),Wb=ty({clipByValue_:function(t,e,n){var r=Ug(t,"x","clipByValue");gv(e<=n,(function(){return"Error in clip: min ("+e+") must be less than or equal to max ("+n+")."}));var a=[r],i={min:e,max:n};return Tg.runKernelFunc((function(t,a){var i=t.clip(r,e,n);return a([r]),i}),{x:r},(function(t,r){var a=r[0];return{x:function(){return t.where(a.greaterEqual(e).logicalAnd(a.lessEqual(n)),xy(t))}}}),"ClipByValue",i,a)}}),Vb=ty({cos_:function(t){var e=Ug(t,"x","cos"),n=[e];return Tg.runKernelFunc((function(t,n){var r=t.cos(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return n.toFloat().sin().neg().mul(t)}}}),"Cos",{},n)}}),Ub=ty({cosh_:function(t){var e=Ug(t,"x","cosh");return Tg.runKernelFunc((function(t,n){var r=t.cosh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return n.toFloat().sinh().mul(t)}}}))}}),jb=ty({erf_:function(t){var e=Ug(t,"x","erf");return gv("int32"===e.dtype||"float32"===e.dtype,(function(){return"Input dtype must be `int32` or `float32`."})),"int32"===e.dtype&&(e=e.toFloat()),Tg.runKernelFunc((function(t,n){var r=t.erf(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.mul(n.square().neg().exp().mul(2/Math.sqrt(Math.PI)))}}}))}}),Gb=ty({exp_:function(t){var e=Ug(t,"x","exp");return Tg.runKernelFunc((function(t,n){var r=t.exp(e);return n([r]),r}),{x:e},(function(t,e){return{x:function(){return t.mul(e[0])}}}),"Exp",{},[],[!0])}}),qb=ty({expm1_:function(t){var e=Ug(t,"x","expm1");return Tg.runKernelFunc((function(t,n){var r=t.expm1(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.mul(n.exp())}}}))}}),Hb=ty({floor_:function(t){var e=Ug(t,"x","floor");return Tg.runKernelFunc((function(t){return t.floor(e)}),{$x:e},(function(t){return{$x:function(){return xy(t)}}}))}}),Kb=ty({log_:function(t){var e=Ug(t,"x","log"),n=[e];return Tg.runKernelFunc((function(t,n){var r=t.log(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.div(n.toFloat())}}}),"Log",{},n)}}),Xb=ty({log1p_:function(t){var e=Ug(t,"x","log1p");return Tg.runKernelFunc((function(t,n){var r=t.log1p(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.add(1))}}}))}}),Yb=ty({logSigmoid_:function(t){var e=Ug(t,"x","logSigmoid");return Tg.runKernelFunc((function(t,n){var r=t.softplus(e.neg()).neg();return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.mul(n.neg().sigmoid())}}}))}}),Jb=ty({neg_:function(t){var e=Ug(t,"x","neg"),n=[e];return Tg.runKernelFunc((function(t){return t.neg(e)}),{x:e},(function(t){return{x:function(){return t.neg()}}}),"Neg",{},n)}}),$b=ty({reciprocal_:function(t){var e=Ug(t,"x","reciprocal");return Tg.runKernelFunc((function(t,n){var r=t.reciprocal(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.square().neg())}}}))}}),Zb=ty({round_:function(t){var e=Ug(t,"x","round");return Tg.runKernelFunc((function(t){return t.round(e)}),{$x:e},(function(t){return{$x:function(){return xy(t)}}}))}}),Qb=ty({rsqrt_:function(t){var e=Ug(t,"x","rsqrt"),n=[e];return Tg.runKernelFunc((function(t,n){var r=t.rsqrt(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.div(n.pow(1.5).mul(2)).neg()}}}),"Rsqrt",{},n)}}),tx=ty({sigmoid_:function(t){var e=Ug(t,"x","sigmoid");return Tg.runKernelFunc((function(t,n){var r=t.sigmoid(e);return n([r]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.mul(n.mul(oy(1).sub(n)))}}}),"Sigmoid")}}),ex=ty({sign_:function(t){var e=Ug(t,"x","sign");return Tg.runKernelFunc((function(t){return t.sign(e)}),{$x:e},(function(t){return{$x:function(){return xy(t)}}}))}}),nx=ty({isNaN_:function(t){var e=Ug(t,"x","isNaN");return Tg.runKernelFunc((function(t){return t.isNaN(e)}),{$x:e},(function(t){return{$x:function(){return xy(t)}}}))}}),rx=ty({isInf_:function(t){var e=Ug(t,"x","isInf");return Tg.runKernelFunc((function(t){return t.isInf(e)}),{$x:e},(function(t){return{$x:function(){return xy(t)}}}))}}),ax=ty({isFinite_:function(t){var e=Ug(t,"x","isFinite");return Tg.runKernelFunc((function(t){return t.isFinite(e)}),{$x:e},(function(t){return{$x:function(){return xy(t)}}}))}}),ix=ty({sin_:function(t){var e=Ug(t,"x","sin"),n=[e];return Tg.runKernelFunc((function(t,n){var r=t.sin(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return n.toFloat().cos().mul(t)}}}),"Sin",{},n)}}),ox=ty({sinh_:function(t){var e=Ug(t,"x","sinh");return Tg.runKernelFunc((function(t,n){var r=t.sinh(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return n.toFloat().cosh().mul(t)}}}))}}),sx=ty({softplus_:function(t){var e=Ug(t,"x","softplus");return Tg.runKernelFunc((function(t,n){var r=t.softplus(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.mul(n.sigmoid())}}}))}}),ux=ty({sqrt_:function(t){var e=Ug(t,"x","sqrt");return Tg.runKernelFunc((function(t,n){var r=t.sqrt(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return t.div(n.toFloat().sqrt().mul(2))}}}),"Sqrt",{})}}),cx=ty({step_:function(t,e){void 0===e&&(e=0);var n=Ug(t,"x","step");return Tg.runKernelFunc((function(t){return t.step(n,e)}),{$x:n},(function(t){return{$x:function(){return xy(t)}}}))}}),lx=ty({tan_:function(t){var e=Ug(t,"x","tan");return Tg.runKernelFunc((function(t,n){var r=t.tan(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return t.div(n.cos().square())}}}))}}),hx=ty({tanh_:function(t){var e=Ug(t,"x","tanh");return Tg.runKernelFunc((function(t,n){var r=t.tanh(e);return n([r]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return oy(1).sub(n.square()).mul(t)}}}),"Tanh",{},null,[!0])}});var fx=ty({addStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","addStrict"),r=Ug(e,"b","addStrict");return yv(n.shape,r.shape,"Error in addStrict: "),n.add(r)}}),px=ty({atan2_:function(t,e){var n=Ug(t,"a","atan2"),r=Ug(e,"b","atan2"),a=Sg(n,r);n=a[0],r=a[1];var i=zg(n.shape,r.shape);return Tg.runKernelFunc((function(t,e){var a=t.atan2(n,r);return e([n,r]),a}),{$a:n,$b:r},(function(t,e){var n=e[0],r=e[1];return{$a:function(){var e=Db(n.square(),r.square()),a=t.mul(r.div(e)),o=Lg(n.shape,i);return o.length>0&&(a=a.sum(o)),a.reshape(n.shape)},$b:function(){var e=Db(n.square(),r.square()),a=Jb(t.mul(n.div(e))),o=Lg(r.shape,i);return o.length>0&&(a=a.sum(o)),a.reshape(r.shape)}}}))}}),dx=ty({divStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","div"),r=Ug(e,"b","div");return yv(n.shape,r.shape,"Error in divideStrict: "),n.div(r)}}),mx=ty({floorDiv_:function(t,e){var n=Ug(t,"a","floorDiv"),r=Ug(e,"b","floorDiv"),a=Sg(n,r);n=a[0],r=a[1];var i=zg(n.shape,r.shape);return Tg.runKernelFunc((function(t,e){var a=t.floorDiv(n,r);return e([n,r]),a}),{a:n,b:r},(function(t,e){var n=e[0],r=e[1];return{a:function(){var e=t.div(r.toFloat()),a=Lg(n.shape,i);return a.length>0?e.sum(a).reshape(n.shape):e},b:function(){var e=t.mul(n.toFloat()),a=Lg(r.shape,i);a.length>0&&(e=e.sum(a).reshape(r.shape));var o=r.square();return e.div(o.toFloat()).neg()}}}),"FloorDiv")}}),vx=ty({maximum_:function(t,e){var n=Ug(t,"a","maximum"),r=Ug(e,"b","maximum"),a=Sg(n,r);return n=a[0],r=a[1],"bool"===n.dtype&&(n=n.toInt(),r=r.toInt()),zg(n.shape,r.shape),Tg.runKernelFunc((function(t,e){var a=t.maximum(n,r);return e([n,r]),a}),{a:n,b:r},(function(t,e){var n=e[0],r=e[1];return{a:function(){return t.mul(n.greaterEqual(r).toFloat())},b:function(){return t.mul(n.less(r).toFloat())}}}),"Maximum")}}),gx=ty({maximumStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","maximumStrict"),r=Ug(e,"b","maximumStrict");return yv(n.shape,r.shape,"Error in maximumStrict: "),n.maximum(r)}}),yx=ty({minimum_:function(t,e){var n=Ug(t,"a","minimum"),r=Ug(e,"b","minimum"),a=Sg(n,r);return n=a[0],r=a[1],"bool"===n.dtype&&(n=n.toInt(),r=r.toInt()),zg(n.shape,r.shape),Tg.runKernelFunc((function(t,e){var a=t.minimum(n,r);return e([n,r]),a}),{a:n,b:r},(function(t,e){var n=e[0],r=e[1];return{a:function(){return t.mul(n.lessEqual(r).toFloat())},b:function(){return t.mul(n.greater(r).toFloat())}}}),"Minimum")}}),bx=ty({minimumStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","minimumStrict"),r=Ug(e,"b","minimumStrict");return yv(n.shape,r.shape,"Error in minimumStrict: "),n.minimum(r)}}),xx=ty({mod_:function(t,e){var n=Ug(t,"a","mod"),r=Ug(e,"b","mod"),a=Sg(n,r);n=a[0],r=a[1];var i=zg(n.shape,r.shape);return Tg.runKernelFunc((function(t,e){var a=t.mod(n,r);return e([n,r]),a}),{$a:n,$b:r},(function(t,e){var n=e[0],r=e[1];return{$a:function(){var e=Lg(n.shape,i);return e.length>0?t.sum(e).reshape(n.shape):t},$b:function(){var e=t.mul(n.div(r).floor().neg()),a=Lg(r.shape,i);return a.length>0?e.sum(a).reshape(r.shape):e}}}))}}),wx=ty({modStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","modStrict"),r=Ug(e,"b","modStrict");return yv(n.shape,r.shape,"Error in modStrict: "),n.mod(r)}}),kx=ty({mul_:function(t,e){var n=Ug(t,"a","mul"),r=Ug(e,"b","mul"),a=Sg(n,r);n=a[0],r=a[1];var i=zg(n.shape,r.shape);return Tg.runKernelFunc((function(t,e){var a=t.multiply(n,r);return e([n,r]),a}),{a:n,b:r},(function(t,e){var n=e[0],r=e[1];return{a:function(){var e=t.mul(r.toFloat()),a=Lg(n.shape,i);return a.length>0?e.sum(a).reshape(n.shape):e},b:function(){var e=t.mul(n.toFloat()),a=Lg(r.shape,i);return a.length>0?e.sum(a).reshape(r.shape):e}}}),"Mul")}}),Sx=ty({mulStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","mul"),r=Ug(e,"b","mul");return yv(n.shape,r.shape,"Error in multiplyStrict: "),n.mul(r)}}),Cx=ty({pow_:function(t,e){var n=Ug(t,"base","pow"),r=Ug(e,"exp","pow"),a=Sg(n,r);n=a[0],r=a[1];var i=zg(n.shape,r.shape),o=[n,r];return Tg.runKernelFunc((function(t,e){var a=t.pow(n,r);return e([n,r,a]),a}),{a:n,b:r},(function(t,e){var n=e[0],r=e[1],a=e[2];return{a:function(){var e=r.toFloat(),a=t.mul(e.mul(n.pow(e.sub(oy(1))))),o=Lg(n.shape,i);return o.length>0&&(a=a.sum(o)),a.reshape(n.shape)},b:function(){var e=n.greater(0),o=n.log().where(e,xy(n)),s=t.mul(a.mul(o)),u=Lg(r.shape,i);return u.length>0&&(s=s.sum(u)),s.reshape(r.shape)}}}),"Pow",{},o,[!0])}}),Rx=ty({powStrict_:function(t,e){return Sb("strict variants of ops have been deprecated and will be removed in future"),yv(t.shape,e.shape,"Error in powStrict: "),t.pow(e)}}),Nx=ty({squaredDifferenceStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","squaredDifferenceStrict"),r=Ug(e,"b","squaredDifferenceStrict");return yv(n.shape,r.shape,"Error in squaredDifferenceStrict: "),n.squaredDifference(r)}}),Ex=ty({subStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","subStrict"),r=Ug(e,"b","subStrict");return yv(n.shape,r.shape,"Error in subStrict: "),n.sub(r)}});var Ix=ty({div_:function(t,e){var n=Ug(t,"a","div"),r=Ug(e,"b","div"),a=Sg(n,r);if(n=a[0],r=a[1],"int32"===n.dtype&&"int32"===r.dtype)return mx(n,r);var i={a:n,b:r};return Tg.runKernelFunc((function(t,e){var a=t.realDivide(n,r);return e([n,r]),a}),i,null,"Div",{})}});var Ax=ty({square_:function(t){var e=Ug(t,"x","square"),n=[e];return Tg.runKernelFunc((function(t,n){return n([e]),t.square(e)}),{x:e},null,"Square",{},n,[])}}),Tx={kernelName:"Div",inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],r=e[1],a=zg(n.shape,r.shape);return{a:function(){var e=Ix(t,r.toFloat()),i=Lg(n.shape,a);return i.length>0?Yy(e,i).reshape(n.shape):e},b:function(){var e=kx(t,n.toFloat()),i=Lg(r.shape,a);i.length>0&&(e=Iy(Yy(e,i),r.shape));var o=Ax(r);return Jb(Ix(e,o.toFloat()))}}}};var Dx=ty({sub_:function(t,e){var n=Ug(t,"a","sub"),r=Ug(e,"b","sub"),a=Sg(n,r);n=a[0],r=a[1];var i={a:n,b:r};return Tg.runKernelFunc((function(t,e){var a=t.subtract(n,r);return e([n,r]),a}),i,null,"Sub")}});var _x=ty({tile_:function(t,e){var n=Ug(t,"x","tile",null);gv(n.rank===e.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of reps "+e+"."}));var r=[n],a={x:n},i={reps:e};return Tg.runKernelFunc((function(t,r){var a=t.tile(n,e);return r([n]),a}),a,null,"Tile",i,r)}}),Ox={kernelName:"FusedBatchNorm",inputsToSave:["x","mean","variance","scale"],gradFunc:function(t,e,n){var r=n.varianceEpsilon,a=e[0],i=e[1],o=e[2],s=e[3],u=null==s?oy(1):s,c=Lg(i.shape,a.shape),l=[];if(1===i.rank){for(var h=0;h<a.shape.length-1;++h)l.push(a.shape[h]);l.push(1)}var f=Dx(a,i),p=kx(t,u),d=Qb(Db(o,oy(r))),m=kx(kx(kx(d,d),d),oy(-.5));return{x:function(){return 1===i.rank?Iy(kx(kx(t,_x(d.as4D(1,1,1,i.shape[0]),l)),u),a.shape):Iy(kx(kx(t,d),u),a.shape)},mean:function(){var t=kx(kx(d,oy(-1)),p);return 1===i.rank&&(t=Yy(t,c)),Iy(t,i.shape)},variance:function(){var t=kx(kx(m,f),p);return 1===i.rank&&(t=Yy(t,c)),Iy(t,i.shape)},scale:function(){var e=kx(f,d),n=kx(t,e);return 1===i.rank&&(n=Yy(n,c)),Iy(n,i.shape)},offset:function(){var e=t;return 1===i.rank&&(e=Yy(e,c)),Iy(e,i.shape)}}}},Fx={kernelName:"GreaterEqual",inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],r=e[1];return{a:function(){return xy(n)},b:function(){return xy(r)}}}},Mx={kernelName:"Identity",gradFunc:function(t){return{x:function(){return t.toFloat()}}}};var Lx=ty({localResponseNormalizationBackprop_:function(t,e,n,r,a,i,o){void 0===r&&(r=5),void 0===a&&(a=1),void 0===i&&(i=1),void 0===o&&(o=.5);var s={x:t,y:e,dy:n},u={depthRadius:r,bias:a,alpha:i,beta:o};return Tg.runKernelFunc((function(s){return s.LRNGrad(n,t,e,r,a,i,o)}),s,null,"LRNBackprop",u)}}),zx={kernelName:"LRN",inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var r=e[0],a=e[1],i=n.depthRadius,o=n.bias,s=n.alpha,u=n.beta;return{x:function(){return Lx(r,a,t,i,o,s,u)}}}};var Bx=ty({transpose_:function(t,e){var n=Ug(t,"x","transpose");if(null==e&&(e=n.shape.map((function(t,e){return e})).reverse()),gv(n.rank===e.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of perm "+e+"."})),e.forEach((function(t){gv(t>=0&&t<n.rank,(function(){return"All entries in 'perm' must be between 0 and "+(n.rank-1)+" but got "+e}))})),n.rank<=1)return n.clone();var r={perm:e};return Tg.runKernelFunc((function(t){return t.transpose(n,e)}),{x:n},null,"Transpose",r)}}),Px={kernelName:"Max",inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(t,e,n){var r=n.reductionIndices,a=e[0],i=e[1],o=Av(r,a.shape),s=Yg(o,a.rank),u=Wy(t,i,a,o,s);return{x:function(){var t=u.x();return null!=s&&(t=Bx(t)),t}}}},Wx={kernelName:"OneHot",inputsToSave:["indices"],gradFunc:function(t,e){var n=e[0];return{indices:function(){return my(n.shape,"float32")}}}},Vx={kernelName:"PadV2",inputsToSave:["x"],gradFunc:function(t,e,n){var r=e[0],a=n.paddings.map((function(t){return t[0]}));return{x:function(){return t.slice(a,r.shape)}}}};var Ux=ty({batchToSpaceND_:function(t,e,n){var r=Ug(t,"x","batchToSpaceND"),a=e.reduce((function(t,e){return t*e}));gv(r.rank>=1+e.length,(function(){return"input rank is "+r.rank+" but should be > than blockShape.length "+e.length})),gv(n.length===e.length,(function(){return"crops.length is "+n.length+" but should be equal to blockShape.length "+e.length})),gv(r.shape[0]%a==0,(function(){return"input tensor batch is "+r.shape[0]+" but is not divisible by the product of the elements of blockShape "+e.join(" * ")+" === "+a}));var i={x:r},o={blockShape:e,crops:n};return Tg.runKernelFunc((function(t){return t.batchToSpaceND(r,e,n)}),i,null,"BatchToSpaceND",o)}}),jx={kernelName:"SpaceToBatchND",gradFunc:function(t,e,n){var r=n.blockShape,a=n.paddings;return{x:function(){return Ux(t,r,a)}}}},Gx={kernelName:"SplitV",gradFunc:function(t,e,n){var r=n.axis;return{x:function(){return wy(t,r)}}}},qx={kernelName:"Square",inputsToSave:["x"],gradFunc:function(t,e){var n=e[0];return{x:function(){return kx(t,kx(n.toFloat(),2))}}}},Hx={kernelName:"SquaredDifference",inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],r=e[1],a=oy(2);return{a:function(){return kx(t,kx(a,Dx(n,r)))},b:function(){return kx(t,kx(a,Dx(r,n)))}}}},Kx={kernelName:"Sub",inputsToSave:["a","b"],gradFunc:function(t,e){var n=e[0],r=e[1],a=zg(n.shape,r.shape);return{a:function(){var e=t,r=Lg(n.shape,a);return r.length>0&&(e=Yy(e,r)),Iy(e,n.shape)},b:function(){var e=t,n=Lg(r.shape,a);return n.length>0&&(e=Yy(e,n)),Iy(Jb(e),r.shape)}}}};var Xx=ty({pad_:function(t,e,n){void 0===n&&(n=0);var r=Ug(t,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var a={paddings:e,constantValue:n},i={x:r};return Tg.runKernelFunc((function(t,a){return a([r]),t.pad(r,e,n)}),i,null,"PadV2",a)}});function Yx(t,e,n){gv(t.rank===e.length,(function(){return"Error in slice"+t.rank+"D: Length of begin "+e+" must match the rank of the array ("+t.rank+")."})),gv(t.rank===n.length,(function(){return"Error in slice"+t.rank+"D: Length of size "+n+" must match the rank of the array ("+t.rank+")."}));for(var r=function(r){gv(e[r]+n[r]<=t.shape[r],(function(){return"Error in slice"+t.rank+"D: begin["+r+"] + size["+r+"] ("+(e[r]+n[r])+") would overflow input.shape["+r+"] ("+t.shape[r]+")"}))},a=0;a<t.rank;++a)r(a)}function Jx(t){for(var e=[],n=0;t>0;)1&t&&e.push(n),t/=2,n++;return e}function $x(t,e,n){for(var r=[],a=0;a<t.length;a++)r[a]=Math.ceil((e[a]-t[a])/n[a]);return r}function Zx(t,e,n,r,a){var i=e[a],o=n[a]||1;(t&1<<a||null==i)&&(i=o>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);var s=r[a];return i<0&&(i+=s),i=dv(0,i,s-1)}function Qx(t,e,n,r,a){var i=e[a],o=n[a]||1;(t&1<<a||null==i)&&(i=o>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);var s=r[a];return i<0&&(i+=s),i=o>0?dv(0,i,s):dv(-1,i,s-1)}function tw(t,e,n){for(var r=n.length,a=0;a<n.length;a++)if(n[a]>1){r=a;break}for(var i=r+1;i<n.length;i++)if(e[i]>0||n[i]!==t[i])return!1;return!0}function ew(t,e){for(var n=t.length>0?t[t.length-1]:1,r=0;r<t.length-1;r++)n+=t[r]*e[r];return n}var nw={__proto__:null,assertParamsValid:Yx,maskToAxes:Jx,computeOutShape:$x,startForAxis:Zx,stopForAxis:Qx,isSliceContinous:tw,computeFlatOffset:ew};for(var rw=ty({slice_:function(t,e,n){var r,a,i=Ug(t,"x","slice");if(0===i.rank)throw new Error("Slicing scalar is not possible");(r="number"==typeof e?[e].concat(new Array(i.rank-1).fill(0)):e.length<i.rank?e.concat(new Array(i.rank-e.length).fill(0)):e.slice()).forEach((function(t){gv(-1!==t,(function(){return"slice() does not support negative begin indexing."}))})),a=(a=null==n?new Array(i.rank).fill(-1):"number"==typeof n?[n].concat(new Array(i.rank-1).fill(-1)):n.length<i.rank?n.concat(new Array(i.rank-n.length).fill(-1)):n).map((function(t,e){return t>=0?t:(gv(-1===t,(function(){return"Negative size values should be exactly -1 but got "+t+" for the slice() size at index "+e+"."})),i.shape[e]-r[e])})),Yx(i,r,a);var o=i.shape,s={begin:r,size:a};return Tg.runKernelFunc((function(t){return t.slice(i,r,a)}),{x:i},(function(t){for(var e=[],n=0;n<t.rank;n++)e.push([r[n],o[n]-r[n]-a[n]]);return{x:function(){return Xx(t,e)}}}),"Slice",s)}}),aw=ty({slice1d_:function(t,e,n){var r=Ug(t,"x","slice1d");return gv(1===r.rank,(function(){return"slice1d expects a rank-1 tensor, but got a rank-"+r.rank+" tensor"})),rw(r,[e],[n])}}),iw=ty({slice2d_:function(t,e,n){var r=Ug(t,"x","slice2d");return gv(2===r.rank,(function(){return"slice2d expects a rank-2 tensor, but got a rank-"+r.rank+" tensor"})),rw(r,e,n)}}),ow=ty({slice3d_:function(t,e,n){var r=Ug(t,"x","slice3d");return gv(3===r.rank,(function(){return"slice3d expects a rank-3 tensor, but got a rank-"+r.rank+" tensor"})),rw(r,e,n)}}),sw=ty({slice4d_:function(t,e,n){var r=Ug(t,"x","slice4d");return gv(4===r.rank,(function(){return"slice4d expects a rank-4 tensor, but got a rank-"+r.rank+" tensor"})),rw(r,e,n)}}),uw={kernelName:"Tile",inputsToSave:["x"],gradFunc:function(t,e,n){var r=e[0],a=n.reps;return{x:function(){var e=xy(r);if(1===r.rank)for(var n=0;n<a[0];++n)e=Db(e,rw(t,[n*r.shape[0]],[r.shape[0]]));else if(2===r.rank)for(var i=0;i<a[0];++i)for(var o=0;o<a[1];++o)e=Db(e,rw(t,[i*r.shape[0],o*r.shape[1]],[r.shape[0],r.shape[1]]));else if(3===r.rank)for(var s=0;s<a[0];++s)for(var u=0;u<a[1];++u)for(var c=0;c<a[2];++c)e=Db(e,rw(t,[s*r.shape[0],u*r.shape[1],c*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));else{if(4!==r.rank)throw new Error("Gradient for tile operation is not implemented for rank-"+r.rank+" tensors yet.");for(var l=0;l<a[0];++l)for(var h=0;h<a[1];++h)for(var f=0;f<a[2];++f)for(var p=0;p<a[3];++p)e=Db(e,rw(t,[l*r.shape[0],h*r.shape[1],f*r.shape[2],p*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]))}return e}}}},cw=0,lw=[Bg,Pg,Fy,Ly,$y,Qy,db,vb,bb,kb,Tx,Ox,Fx,Mx,zx,Wx,Vx,Gx,Px,jx,qx,Hx,uw,{kernelName:"Transpose",gradFunc:function(t,e,n){var r=Jg(n.perm);return{x:function(){return Bx(t,r)}}}},Kx];cw<lw.length;cw++){hv(lw[cw])}var hw=function(){function t(){}var e=t.prototype;return e.fetch=function(t){function e(e,n){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t,e){return fetch(t,e)})),e.now=function(){return performance.now()},e.encode=function(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Browser's encoder only supports utf-8, but got "+e);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(t)},e.decode=function(t,e){return new TextDecoder(e).decode(t)},t}();nv().get("IS_BROWSER")&&nv().setPlatform("browser",new hw);var fw,pw=function(){return require("node-fetch")},dw=function(){function t(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}var e=t.prototype;return e.fetch=function(t,e){return null!=nv().global.fetch?nv().global.fetch(t,e):(null==fw&&(fw=pw()),fw(t,e))},e.now=function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6},e.encode=function(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Node built-in encoder only supports utf-8, but got "+e);return this.textEncoder.encode(t)},e.decode=function(t,e){return 0===t.length?"":new this.util.TextDecoder(e).decode(t)},t}();nv().get("IS_NODE")&&nv().setPlatform("node",new dw);var mw={float32:4,int32:4,uint16:2,uint8:1,bool:1};function vw(t,e){return gw.apply(this,arguments)}function gw(){return(gw=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=[],a=[],i=Array.isArray(e)?e.map((function(t){return t.name})):Object.keys(e),o=function(t){var o=i[t],s=Array.isArray(e)?e[t].tensor:e[o];if("float32"!==s.dtype&&"int32"!==s.dtype&&"bool"!==s.dtype&&"string"!==s.dtype)throw new Error("Unsupported dtype in weight '"+o+"': "+s.dtype);var u={name:o,shape:s.shape,dtype:s.dtype};if("string"===s.dtype){var c=new Promise(function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a,i,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.bytes();case 2:for(n=t.sent,r=n.reduce((function(t,e){return t+e.length}),0)+4*n.length,a=new Uint8Array(r),i=0,o=0;o<n.length;o++)u=n[o],c=new Uint8Array(new Uint32Array([u.length]).buffer),a.set(c,i),i+=4,a.set(u,i),i+=u.length;e(a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());a.push(c)}else a.push(s.data());null!=n&&(u.group=n),r.push(u)},s=0;s<i.length;++s)o(s);return t.next=7,Promise.all(a);case 7:return u=t.sent,t.abrupt("return",{data:bw(u),specs:r});case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function yw(t,e){for(var n,r={},a=0,i=Zm(e);!(n=i()).done;){var o=n.value,s=o.name,u=o.dtype,c=o.shape,l=wv(c),h=void 0;if("quantization"in o){var f=o.quantization;if("uint8"!==f.dtype&&"uint16"!==f.dtype)throw new Error("Weight "+o.name+" has unknown quantization dtype "+f.dtype+". Supported quantization dtypes are: 'uint8' and 'uint16'.");var p=mw[f.dtype],d=t.slice(a,a+l*p),m="uint8"===f.dtype?new Uint8Array(d):new Uint16Array(d);if("float32"===u){h=new Float32Array(m.length);for(var v=0;v<m.length;v++){var g=m[v];h[v]=g*f.scale+f.min}}else{if("int32"!==u)throw new Error("Unsupported dtype in weight '"+s+"': "+u);h=new Int32Array(m.length);for(var y=0;y<m.length;y++){var b=m[y];h[y]=Math.round(b*f.scale+f.min)}}a+=l*p}else if("string"===u){var x=wv(o.shape);h=[];for(var w=0;w<x;w++){var k=new Uint32Array(t.slice(a,a+4))[0];a+=4;var S=new Uint8Array(t.slice(a,a+k));h.push(S),a+=k}}else{var C=mw[u],R=t.slice(a,a+l*C);if("float32"===u)h=new Float32Array(R);else if("int32"===u)h=new Int32Array(R);else{if("bool"!==u)throw new Error("Unsupported dtype in weight '"+s+"': "+u);h=new Uint8Array(R)}a+=l*C}r[s]=ay(h,c,u)}return r}function bw(t){if(null===t)throw new Error("Invalid input value: "+JSON.stringify(t));var e=0,n=[];t.forEach((function(t){if(e+=t.byteLength,n.push(t.byteLength===t.buffer.byteLength?t:new t.constructor(t)),!(t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+t.constructor.name)}));var r=new Uint8Array(e),a=0;return n.forEach((function(t){r.set(new Uint8Array(t.buffer),a),a+=t.byteLength})),r.buffer}var xw="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function ww(t){return xw?Buffer.byteLength(t):new Blob([t]).size}function kw(t){if(xw)return Buffer.from(t).toString("base64");for(var e=new Uint8Array(t),n="",r=0,a=e.length;r<a;r++)n+=String.fromCharCode(e[r]);return btoa(n)}function Sw(t){if(xw){var e=Buffer.from(t,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}for(var n=atob(t),r=new Uint8Array(n.length),a=0;a<n.length;++a)r.set([n.charCodeAt(a)],a);return r.buffer}function Cw(t){if(1===t.length)return t[0];var e=0;t.forEach((function(t){e+=t.byteLength}));var n=new Uint8Array(e),r=0;return t.forEach((function(t){n.set(new Uint8Array(t),r),r+=t.byteLength})),n.buffer}function Rw(t){for(t=t.trim();t.endsWith("/");)t=t.slice(0,t.length-1);var e=t.split("/");return e[e.length-1]}function Nw(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==t.modelTopology?0:ww(JSON.stringify(t.modelTopology)),weightSpecsBytes:null==t.weightSpecs?0:ww(JSON.stringify(t.weightSpecs)),weightDataBytes:null==t.weightData?0:t.weightData.byteLength}}var Ew=function(){function t(){this.saveRouters=[],this.loadRouters=[]}return t.getInstance=function(){return null==t.instance&&(t.instance=new t),t.instance},t.registerSaveRouter=function(e){t.getInstance().saveRouters.push(e)},t.registerLoadRouter=function(e){t.getInstance().loadRouters.push(e)},t.getSaveHandlers=function(e){return t.getHandlers(e,"save")},t.getLoadHandlers=function(e,n){return t.getHandlers(e,"load",n)},t.getHandlers=function(e,n,r){var a=[];return("load"===n?t.getInstance().loadRouters:t.getInstance().saveRouters).forEach((function(t){var n=t(e,r);null!==n&&a.push(n)})),a},t}(),Iw=function(t){return Ew.getSaveHandlers(t)},Aw=function(t,e){return Ew.getLoadHandlers(t,e)},Tw=function(){function t(){this.managers={}}return t.getInstance=function(){return null==t.instance&&(t.instance=new t),t.instance},t.registerManager=function(e,n){gv(null!=e,(function(){return"scheme must not be undefined or null."})),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),gv(e.length>0,(function(){return"scheme must not be an empty string."}));var r=t.getInstance();gv(null==r.managers[e],(function(){return"A model store manager is already registered for scheme '"+e+"'."})),r.managers[e]=n},t.getManager=function(t){var e=this.getInstance().managers[t];if(null==e)throw new Error("Cannot find model manager for scheme '"+t+"'");return e},t.getSchemes=function(){return Object.keys(this.getInstance().managers)},t}();function Dw(t){if(-1===t.indexOf("://"))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+Tw.getSchemes().join(","));return{scheme:t.split("://")[0],path:t.split("://")[1]}}function _w(t,e,n){return Ow.apply(this,arguments)}function Ow(){return(Ow=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!1),gv(e!==n,(function(){return"Old path and new path are the same: '"+e+"'"})),gv((a=Ew.getLoadHandlers(e)).length>0,(function(){return"Copying failed because no load handler is found for source URL "+e+"."})),gv(a.length<2,(function(){return"Copying failed because more than one ("+a.length+") load handlers for source URL "+e+"."})),i=a[0],gv((o=Ew.getSaveHandlers(n)).length>0,(function(){return"Copying failed because no save handler is found for destination URL "+n+"."})),gv(o.length<2,(function(){return"Copying failed because more than one ("+a.length+") save handlers for destination URL "+n+"."})),s=o[0],u=Dw(e).scheme,c=Dw(e).path,l=u===Dw(e).scheme,t.next=15,i.load();case 15:if(h=t.sent,!r||!l){t.next=19;break}return t.next=19,Tw.getManager(u).removeModel(c);case 19:return t.next=21,s.save(h);case 21:if(f=t.sent,!r||l){t.next=25;break}return t.next=25,Tw.getManager(u).removeModel(c);case 25:return t.abrupt("return",f.modelArtifactsInfo);case 26:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Fw(){return(Fw=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Tw.getSchemes(),n={},r=Zm(e);case 3:if((a=r()).done){t.next=11;break}return i=a.value,t.next=7,Tw.getManager(i).listModels();case 7:for(s in o=t.sent)n[i+"://"+s]=o[s];case 9:t.next=3;break;case 11:return t.abrupt("return",n);case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Mw(){return(Mw=Vm(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Dw(e),r=Tw.getManager(n.scheme),t.abrupt("return",r.removeModel(n.path));case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lw(){return(Lw=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return!1,t.abrupt("return",_w(e,n,!1));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function zw(){return(zw=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return!0,t.abrupt("return",_w(e,n,!0));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bw(){if(!nv().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var t=window||self,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(null==e)throw new Error("The current browser does not appear to support IndexedDB.");return e}function Pw(t){var e=t.result;e.createObjectStore("models_store",{keyPath:"modelPath"}),e.createObjectStore("model_info_store",{keyPath:"modelPath"})}var Ww=function(){function t(t){if(this.indexedDB=Bw(),null==t||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t}var e=t.prototype;return e.save=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.modelTopology instanceof ArrayBuffer)){t.next=2;break}throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");case 2:return t.abrupt("return",this.databaseAction(this.modelPath,e));case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.load=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.databaseAction(this.modelPath));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.databaseAction=function(t,e){var n=this;return new Promise((function(t,r){var a=n.indexedDB.open("tensorflowjs",1);a.onupgradeneeded=function(){return Pw(a)},a.onsuccess=function(){var i=a.result;if(null==e){var o=i.transaction("models_store","readonly"),s=o.objectStore("models_store").get(n.modelPath);s.onsuccess=function(){if(null==s.result)return i.close(),r(new Error("Cannot find model with path '"+n.modelPath+"' in IndexedDB."));t(s.result.modelArtifacts)},s.onerror=function(t){return i.close(),r(s.error)},o.oncomplete=function(){return i.close()}}else{var u,c=Nw(e),l=i.transaction("model_info_store","readwrite"),h=l.objectStore("model_info_store"),f=h.put({modelPath:n.modelPath,modelArtifactsInfo:c});f.onsuccess=function(){var a=(u=i.transaction("models_store","readwrite")).objectStore("models_store").put({modelPath:n.modelPath,modelArtifacts:e,modelArtifactsInfo:c});a.onsuccess=function(){return t({modelArtifactsInfo:c})},a.onerror=function(t){var e=(h=l.objectStore("model_info_store")).delete(n.modelPath);e.onsuccess=function(){return i.close(),r(a.error)},e.onerror=function(t){return i.close(),r(a.error)}}},f.onerror=function(t){return i.close(),r(f.error)},l.oncomplete=function(){null==u?i.close():u.oncomplete=function(){return i.close()}}}},a.onerror=function(t){return r(a.error)}}))},t}();Ww.URL_SCHEME="indexeddb://";var Vw=function(t){return nv().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Ww.URL_SCHEME)?(e=t.slice(Ww.URL_SCHEME.length),new Ww(e)):null;var e};function Uw(t){return t.startsWith(Ww.URL_SCHEME)?t.slice(Ww.URL_SCHEME.length):t}Ew.registerSaveRouter(Vw),Ew.registerLoadRouter(Vw);var jw=function(){function t(){this.indexedDB=Bw()}var e=t.prototype;return e.listModels=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){var r=e.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=function(){return Pw(r)},r.onsuccess=function(){var e=r.result,a=e.transaction("model_info_store","readonly"),i=a.objectStore("model_info_store").getAll();i.onsuccess=function(){for(var e,n={},r=Zm(i.result);!(e=r()).done;){var a=e.value;n[a.modelPath]=a.modelArtifactsInfo}t(n)},i.onerror=function(t){return e.close(),n(i.error)},a.oncomplete=function(){return e.close()}},r.onerror=function(t){return n(r.error)}})));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),e.removeModel=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=Uw(e),t.abrupt("return",new Promise((function(t,r){var a=n.indexedDB.open("tensorflowjs",1);a.onupgradeneeded=function(){return Pw(a)},a.onsuccess=function(){var n,i=a.result,o=i.transaction("model_info_store","readwrite"),s=o.objectStore("model_info_store"),u=s.get(e);u.onsuccess=function(){if(null==u.result)return i.close(),r(new Error("Cannot find model with path '"+e+"' in IndexedDB."));var a=s.delete(e),o=function(){var a=(n=i.transaction("models_store","readwrite")).objectStore("models_store").delete(e);a.onsuccess=function(){return t(u.result.modelArtifactsInfo)},a.onerror=function(t){return r(u.error)}};a.onsuccess=o,a.onerror=function(t){return o(),i.close(),r(u.error)}},u.onerror=function(t){return i.close(),r(u.error)},o.oncomplete=function(){null==n?i.close():n.oncomplete=function(){return i.close()}}},a.onerror=function(t){return r(a.error)}})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t}();if(nv().getBool("IS_BROWSER"))try{Tw.registerManager(Ww.URL_SCHEME,new jw)}catch(t){}var Gw="tensorflowjs_models",qw="info",Hw="model_topology",Kw="weight_specs",Xw="weight_data",Yw="model_metadata";function Jw(t){return{info:[Gw,t,qw].join("/"),topology:[Gw,t,Hw].join("/"),weightSpecs:[Gw,t,Kw].join("/"),weightData:[Gw,t,Xw].join("/"),modelMetadata:[Gw,t,Yw].join("/")}}function $w(t){var e=t.split("/");if(e.length<3)throw new Error("Invalid key format: "+t);return e.slice(1,e.length-1).join("/")}function Zw(t){return t.startsWith(Qw.URL_SCHEME)?t.slice(Qw.URL_SCHEME.length):t}var Qw=function(){function t(t){if(!nv().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==t||!t)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=t,this.keys=Jw(this.modelPath)}var e=t.prototype;return e.save=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.modelTopology instanceof ArrayBuffer)){t.next=4;break}throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");case 4:return n=JSON.stringify(e.modelTopology),r=JSON.stringify(e.weightSpecs),a=Nw(e),t.prev=7,this.LS.setItem(this.keys.info,JSON.stringify(a)),this.LS.setItem(this.keys.topology,n),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,kw(e.weightData)),this.LS.setItem(this.keys.modelMetadata,JSON.stringify({format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,userDefinedMetadata:e.userDefinedMetadata})),t.abrupt("return",{modelArtifactsInfo:a});case 16:throw t.prev=16,t.t0=t.catch(7),this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error("Failed to save model '"+this.modelPath+"' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes="+a.modelTopologyBytes+", weightSpecsBytes="+a.weightSpecsBytes+", weightDataBytes="+a.weightDataBytes+".");case 24:case"end":return t.stop()}}),t,this,[[7,16]])})));return function(e){return t.apply(this,arguments)}}(),e.load=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=(e=JSON.parse(this.LS.getItem(this.keys.info)))){t.next=3;break}throw new Error("In local storage, there is no model with name '"+this.modelPath+"'");case 3:if("JSON"===e.modelTopologyType){t.next=5;break}throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");case 5:if(n={},null!=(r=JSON.parse(this.LS.getItem(this.keys.topology)))){t.next=9;break}throw new Error("In local storage, the topology of model '"+this.modelPath+"' is missing.");case 9:if(n.modelTopology=r,null!=(a=JSON.parse(this.LS.getItem(this.keys.weightSpecs)))){t.next=13;break}throw new Error("In local storage, the weight specs of model '"+this.modelPath+"' are missing.");case 13:if(n.weightSpecs=a,null!=(i=this.LS.getItem(this.keys.modelMetadata))&&(o=JSON.parse(i),n.format=o.format,n.generatedBy=o.generatedBy,n.convertedBy=o.convertedBy,n.userDefinedMetadata=o.userDefinedMetadata),null!=(s=this.LS.getItem(this.keys.weightData))){t.next=19;break}throw new Error("In local storage, the binary weight values of model '"+this.modelPath+"' are missing.");case 19:return n.weightData=Sw(s),t.abrupt("return",n);case 21:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();Qw.URL_SCHEME="localstorage://";var tk=function(t){return nv().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Qw.URL_SCHEME)?(e=t.slice(Qw.URL_SCHEME.length),new Qw(e)):null;var e};Ew.registerSaveRouter(tk),Ew.registerLoadRouter(tk);var ek=function(){function t(){gv(nv().getBool("IS_BROWSER"),(function(){return"Current environment is not a web browser"})),gv("undefined"==typeof window||void 0!==window.localStorage,(function(){return"Current browser does not appear to support localStorage"})),this.LS=window.localStorage}var e=t.prototype;return e.listModels=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e={},n=Gw+"/",r="/"+qw,a=0;a<this.LS.length;++a)(i=this.LS.key(a)).startsWith(n)&&i.endsWith(r)&&(o=$w(i),e[o]=JSON.parse(this.LS.getItem(i)));return t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.removeModel=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=Zw(e),n=Jw(e),null!=this.LS.getItem(n.info)){t.next=4;break}throw new Error("Cannot find model at path '"+e+"'");case 4:return r=JSON.parse(this.LS.getItem(n.info)),this.LS.removeItem(n.info),this.LS.removeItem(n.topology),this.LS.removeItem(n.weightSpecs),this.LS.removeItem(n.weightData),t.abrupt("return",r);case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();if(nv().getBool("IS_BROWSER"))try{Tw.registerManager(Qw.URL_SCHEME,new ek)}catch(t){}function nk(t){return new Promise((function(t){return setTimeout(t)})).then(t)}var rk=function(){function t(e){if(!nv().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(t.URL_SCHEME)&&(e=e.slice(t.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelTopologyFileName=e+".json",this.weightDataFileName=e+".weights.bin"}return t.prototype.save=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a,i,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("undefined"!=typeof document){t.next=2;break}throw new Error("Browser downloads are not supported in this environment since `document` is not present");case 2:if(n=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"})),!(e.modelTopology instanceof ArrayBuffer)){t.next=7;break}throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");case 7:return r=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],a={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:r},i=window.URL.createObjectURL(new Blob([JSON.stringify(a)],{type:"application/json"})),(o=null==this.jsonAnchor?document.createElement("a"):this.jsonAnchor).download=this.modelTopologyFileName,o.href=i,t.next=15,nk((function(){return o.dispatchEvent(new MouseEvent("click"))}));case 15:if(null==e.weightData){t.next=21;break}return(s=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor).download=this.weightDataFileName,s.href=n,t.next=21,nk((function(){return s.dispatchEvent(new MouseEvent("click"))}));case 21:return t.abrupt("return",{modelArtifactsInfo:Nw(e)});case 22:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();rk.URL_SCHEME="downloads://";var ak=function(){function t(t){if(null==t||t.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+t);this.files=t}var e=t.prototype;return e.load=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.files[0],n=this.files.slice(1),t.abrupt("return",new Promise((function(t,a){var i=new FileReader;i.onload=function(i){var o=JSON.parse(i.target.result),s=o.modelTopology;if(null!=s){0===n.length&&t({modelTopology:s});var u=o.weightsManifest;if(null!=u){var c;try{c=r.checkManifestAndWeightFiles(u,n)}catch(t){return void a(t)}var l=[],h=[],f=[];u.forEach((function(t){t.paths.forEach((function(t){h.push(t),f.push(null)})),l.push.apply(l,t.weights)})),u.forEach((function(e){e.paths.forEach((function(e){var n=new FileReader;n.onload=function(n){var r=n.target.result,a=h.indexOf(e);f[a]=r,-1===f.indexOf(null)&&t({modelTopology:s,weightSpecs:l,weightData:Cw(f),format:o.format,generatedBy:o.generatedBy,convertedBy:o.convertedBy,userDefinedMetadata:o.userDefinedMetadata})},n.onerror=function(t){return a("Failed to weights data from file of path '"+e+"'.")},n.readAsArrayBuffer(c[e])}))}))}else a(new Error("weightManifest field is missing from file "+e.name))}else a(new Error("modelTopology field is missing from file "+e.name))},i.onerror=function(t){return a("Failed to read model topology and weights manifest JSON from file '"+e.name+"'. BrowserFiles supports loading Keras-style tf.Model artifacts only.")},i.readAsText(e)})));case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.checkManifestAndWeightFiles=function(t,e){for(var n,r=[],a=e.map((function(t){return Rw(t.name)})),i={},o=Zm(t);!(n=o()).done;){n.value.paths.forEach((function(t){var n=Rw(t);if(-1!==r.indexOf(n))throw new Error("Duplicate file basename found in weights manifest: '"+n+"'");if(r.push(n),-1===a.indexOf(n))throw new Error("Weight file with basename '"+n+"' is not provided.");i[t]=e[a.indexOf(n)]}))}if(r.length!==e.length)throw new Error("Mismatch in the number of files in weights manifest ("+r.length+") and the number of weight files provided ("+e.length+").");return i},t}();function ik(t,e,n,r){!function(t){gv(null!=t&&Array.isArray(t)&&t.length>0,(function(){return"promises must be a none empty array"}))}(t),function(t,e){gv(t>=0&&t<=1,(function(){return"Progress fraction must be in range [0, 1], but got startFraction "+t})),gv(e>=0&&e<=1,(function(){return"Progress fraction must be in range [0, 1], but got endFraction "+e})),gv(e>=t,(function(){return"startFraction must be no more than endFraction, but got startFraction "+t+" and endFraction "+e}))}(n=null==n?0:n,r=null==r?1:r);var a=0;return Promise.all(t.map((function(i){return i.then((function(i){var o=n+ ++a/t.length*(r-n);return e(o),i})),i})))}function ok(t,e){return sk.apply(this,arguments)}function sk(){return(sk=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u,c,l,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==n&&(n={}),r=null==n.fetchFunc?nv().platform.fetch:n.fetchFunc,a=e.map((function(t){return r(t,n.requestInit,{isBinary:!0})})),i=0,o=.5,null!=n.onProgress){t.next=11;break}return t.next=8,Promise.all(a);case 8:t.t0=t.sent,t.next=14;break;case 11:return t.next=13,ik(a,n.onProgress,i,o);case 13:t.t0=t.sent;case 14:if(s=t.t0,u=s.map((function(t){return t.arrayBuffer()})),c=.5,l=1,null!=n.onProgress){t.next=24;break}return t.next=21,Promise.all(u);case 21:t.t1=t.sent,t.next=27;break;case 24:return t.next=26,ik(u,n.onProgress,c,l);case 26:t.t1=t.sent;case 27:return h=t.t1,t.abrupt("return",h);case 29:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function uk(t,e,n,r){return ck.apply(this,arguments)}function ck(){return(ck=Vm(regeneratorRuntime.mark((function t(e,n,r,a){var i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n=""),i=lk((function(t){return ok(t,{requestInit:a})})),t.abrupt("return",i(e,n,r));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function lk(t){return function(){var e=Vm(regeneratorRuntime.mark((function e(n,r,a){var i,o,s,u,c,l,h,f,p,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r=""),i=n.map((function(){return!1})),o={},s=null!=a?a.map((function(){return!1})):[],u=[],n.forEach((function(t,e){var n=0;t.weights.forEach((function(t){var r="quantization"in t?t.quantization.dtype:t.dtype,c=mw[r]*wv(t.shape),l=function(){i[e]=!0,null==o[e]&&(o[e]=[]),o[e].push({manifestEntry:t,groupOffset:n,sizeBytes:c})};null!=a?a.forEach((function(e,n){e===t.name&&(l(),s[n]=!0)})):l(),u.push(t.name),n+=c}))})),s.every((function(t){return t}))){e.next=9;break}throw c=a.filter((function(t,e){return!s[e]})),new Error("Could not find weights in manifest with names: "+c.join(", ")+". \nManifest JSON has weights with names: "+u.join(", ")+".");case 9:return l=i.reduce((function(t,e,n){return e&&t.push(n),t}),[]),h=[],l.forEach((function(t){n[t].paths.forEach((function(t){var e=r+(r.endsWith("/")?"":"/")+t;h.push(e)}))})),e.next=14,t(h);case 14:return f=e.sent,p={},d=0,l.forEach((function(t){for(var e=n[t].paths.length,r=0,a=0;a<e;a++)r+=f[d+a].byteLength;for(var i=new ArrayBuffer(r),s=new Uint8Array(i),u=0,c=0;c<e;c++){var l=new Uint8Array(f[d+c]);s.set(l,u),u+=l.byteLength}o[t].forEach((function(t){var e=yw(i.slice(t.groupOffset,t.groupOffset+t.sizeBytes),[t.manifestEntry]);for(var n in e)p[n]=e[n]})),d+=e})),e.abrupt("return",p);case 19:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}()}Ew.registerSaveRouter((function(t){return nv().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(rk.URL_SCHEME)?function(t){void 0===t&&(t="model");return new rk(t)}(t.slice(rk.URL_SCHEME.length)):null}));var hk=function(){function t(t,e){if(this.DEFAULT_METHOD="POST",null==e&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.onProgress=e.onProgress,null!=e.fetchFunc?(gv("function"==typeof e.fetchFunc,(function(){return"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"})),this.fetch=e.fetchFunc):this.fetch=nv().platform.fetch,gv(null!=t&&t.length>0,(function(){return"URL path for http must not be null, undefined or empty."})),Array.isArray(t)&&gv(2===t.length,(function(){return"URL paths for http must have a length of 2, (actual length is "+t.length+")."})),this.path=t,null!=e.requestInit&&null!=e.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{}}var e=t.prototype;return e.save=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.modelTopology instanceof ArrayBuffer)){t.next=2;break}throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");case 2:return(n=Object.assign({method:this.DEFAULT_METHOD},this.requestInit)).body=new FormData,r=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],a={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,userDefinedMetadata:e.userDefinedMetadata,weightsManifest:r},n.body.append("model.json",new Blob([JSON.stringify(a)],{type:"application/json"}),"model.json"),null!=e.weightData&&n.body.append("model.weights.bin",new Blob([e.weightData],{type:"application/octet-stream"}),"model.weights.bin"),t.next=10,this.fetch(this.path,n);case 10:if(!(i=t.sent).ok){t.next=15;break}return t.abrupt("return",{modelArtifactsInfo:Nw(e),responses:[i]});case 15:throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+i.status+".");case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.load=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o,s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch(this.path,this.requestInit);case 2:if((e=t.sent).ok){t.next=5;break}throw new Error("Request to "+this.path+" failed with status code "+e.status+". Please verify this URL points to the model JSON of the model to load.");case 5:return t.prev=5,t.next=8,e.json();case 8:n=t.sent,t.next=16;break;case 11:throw t.prev=11,t.t0=t.catch(5),r="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?r+=" 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.":r+=" Please make sure the server is serving valid JSON for this request.",new Error(r);case 16:if(a=n.modelTopology,i=n.weightsManifest,o=n.generatedBy,s=n.convertedBy,u=n.format,c=n.userDefinedMetadata,null!=a||null!=i){t.next=24;break}throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");case 24:if(null==i){t.next=30;break}return t.next=27,this.loadWeights(i);case 27:f=t.sent,l=f[0],h=f[1];case 30:return t.abrupt("return",{modelTopology:a,weightSpecs:l,weightData:h,userDefinedMetadata:c,generatedBy:o,convertedBy:s,format:u});case 31:case"end":return t.stop()}}),t,this,[[5,11]])})));return function(){return t.apply(this,arguments)}}(),e.loadWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a,i,o,s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=Array.isArray(this.path)?this.path[1]:this.path,r=fk(n),a=r[0],i=r[1],o=this.weightPathPrefix||a,s=[],u=Zm(e);!(c=u()).done;)l=c.value,s.push.apply(s,l.weights);return h=[],e.forEach((function(t){t.paths.forEach((function(t){h.push(o+t+i)}))})),t.next=9,ok(h,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});case 9:return f=t.sent,t.abrupt("return",[s,Cw(f)]);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();function fk(t){var e=t.lastIndexOf("/"),n=t.lastIndexOf("?");return[t.substring(0,e)+"/",n>e?t.substring(n):""]}function pk(t){return null!=t.match(hk.URL_SCHEME_REGEX)}hk.URL_SCHEME_REGEX=/^https?:\/\//;var dk=function(t,e){if("undefined"==typeof fetch&&(null==e||null==e.fetchFunc))return null;return(Array.isArray(t)?t.every((function(t){return pk(t)})):pk(t))?mk(t,e):null};function mk(t,e){return new hk(t,e)}function vk(t,e){return mk(t,e)}Ew.registerSaveRouter(dk),Ew.registerLoadRouter(dk);var gk=function(){function t(t){this.modelArtifacts=t}return t.prototype.load=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.modelArtifacts);case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),yk=function(){function t(t){this.saveHandler=t}return t.prototype.save=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.saveHandler(e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();var bk={__proto__:null,browserFiles:function(t){return new ak(t)},browserHTTPRequest:vk,concatenateArrayBuffers:Cw,decodeWeights:yw,encodeWeights:vw,fromMemory:function(t,e,n,r){if(1===arguments.length){var a=null!=t.modelTopology||null!=t.weightSpecs;return a?new gk(t):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new gk({modelTopology:t}))}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 gk({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:r})},getLoadHandlers:Aw,getModelArtifactsInfoForJSON:Nw,getSaveHandlers:Iw,http:mk,isHTTPScheme:pk,loadWeights:uk,registerLoadRouter:function(t){return Ew.registerLoadRouter(t)},registerSaveRouter:function(t){return Ew.registerSaveRouter(t)},weightsLoaderFactory:lk,withSaveHandler:function(t){return new yk(t)},copyModel:function(t,e){return Lw.apply(this,arguments)},listModels:function(){return Fw.apply(this,arguments)},moveModel:function(t,e){return zw.apply(this,arguments)},removeModel:function(t){return Mw.apply(this,arguments)}};var xk=ty({oneHot_:function(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r=0),e<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+e);var a=Ug(t,"indices","oneHot","int32"),i=[].concat(a.shape,[e]),o={indices:a=a.flatten()},s={depth:e,onValue:n,offValue:r};return Tg.runKernelFunc((function(t,o){return o([a]),Iy(t.oneHot(a,e,n,r),i)}),o,null,"OneHot",s)}});var wk,kk={__proto__:null,confusionMatrix:ty({confusionMatrix_:function(t,e,n){var r=Ug(t,"labels","confusionMatrix"),a=Ug(e,"predictions","confusionMatrix");gv(null==n||n>0&&Number.isInteger(n),(function(){return"If provided, numClasses must be a positive integer, but got "+n})),gv(1===r.rank,(function(){return"Expected the rank of labels to be 1, but got "+r.rank})),gv(1===a.rank,(function(){return"Expected the rank of predictions to be 1, but got "+a.rank})),gv(r.shape[0]===a.shape[0],(function(){return"Mismatch in the number of examples: "+r.shape[0]+" vs. "+a.shape[0]+". Labels and predictions should have the same number of elements."})),gv(n>0&&Number.isInteger(n),(function(){return"numClasses is required to be a positive integer, but got "+n}));var i=xk(r.asType("int32"),n),o=xk(a.asType("int32"),n);return i.transpose().matMul(o).asType("int32")}})};function Sk(){return(Sk=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u,c,l,h,f,p,d,m,v,g,y,b,x,w,k,S,C,R,N;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Ug(e,"img","toPixels"),e instanceof pg||(r=(a=r).toInt(),a.dispose()),2===r.rank||3===r.rank){t.next=4;break}throw new Error("toPixels only supports rank 2 or 3 tensors, got rank "+r.rank+".");case 4:if(i=r.shape.slice(0,2),o=i[0],s=i[1],!((u=2===r.rank?1:r.shape[2])>4||2===u)){t.next=8;break}throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+u);case 8:return t.next=10,r.data();case 10:return c=t.sent,l=r.min(),h=r.max(),t.next=15,Promise.all([l.data(),h.data()]);case 15:if(f=t.sent,p=f[0],d=f[1],m=p[0],v=d[0],l.dispose(),h.dispose(),"float32"!==r.dtype){t.next=27;break}if(!(m<0||v>1)){t.next=25;break}throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but got range ["+m+" - "+v+"].");case 25:t.next=33;break;case 27:if("int32"!==r.dtype){t.next=32;break}if(!(m<0||v>255)){t.next=30;break}throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but got range ["+m+" - "+v+"].");case 30:t.next=33;break;case 32:throw new Error("Unsupported type for toPixels: "+r.dtype+". Please use float32 or int32 tensors.");case 33:for(g="float32"===r.dtype?255:1,y=new Uint8ClampedArray(s*o*4),b=0;b<o*s;++b)x=void 0,w=void 0,k=void 0,S=void 0,1===u?(x=c[b]*g,w=c[b]*g,k=c[b]*g,S=255):3===u?(x=c[3*b]*g,w=c[3*b+1]*g,k=c[3*b+2]*g,S=255):4===u&&(x=c[4*b]*g,w=c[4*b+1]*g,k=c[4*b+2]*g,S=c[4*b+3]*g),y[(C=4*b)+0]=Math.round(x),y[C+1]=Math.round(w),y[C+2]=Math.round(k),y[C+3]=Math.round(S);return null!=n&&(n.width=s,n.height=o,R=n.getContext("2d"),N=new ImageData(y,s,o),R.putImageData(N,0,0)),r!==e&&r.dispose(),t.abrupt("return",y);case 39:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Ck=ty({fromPixels_:function(t,e){if(void 0===e&&(e=3),e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==t)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,r=!1,a=!1,i=!1,o=!1;if(t.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&t instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement)i=!0;else{if(null==t.getContext)throw new Error("pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was "+t.constructor.name);o=!0}if(a){if(a&&t.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.")}if(null!=sv("FromPixels",Tg.backendName))return Tg.runKernel("FromPixels",{pixels:t},{numChannels:e});var s,u,c=a?[t.videoWidth,t.videoHeight]:[t.width,t.height],l=c[0],h=c[1];if(o?s=t.getContext("2d").getImageData(0,0,l,h).data:r||n?s=t.data:(i||a)&&(null==wk&&(wk=document.createElement("canvas").getContext("2d")),wk.canvas.width=l,wk.canvas.height=h,wk.drawImage(t,0,0,l,h),s=wk.getImageData(0,0,l,h).data),4===e)u=new Int32Array(s);else{var f=l*h;u=new Int32Array(f*e);for(var p=0;p<f;p++)for(var d=0;d<e;++d)u[p*e+d]=s[4*p+d]}return cy(u,[h,l,e],"int32")}}),Rk={__proto__:null,toPixels:function(t,e){return Sk.apply(this,arguments)},fromPixels:Ck};function Nk(t,e){if(t.rank<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher, but the rank was "+t.rank+".");if(e.rank<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher, but the rank was "+e.rank+".");if("int32"!==e.dtype)throw new Error("tf.gatherND() expects the indices to be int32 type, but the dtype was "+e.dtype+".");if(e.shape[e.rank-1]>t.rank)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+e.shape[e.rank-1]+" vs. "+t.rank);if(0===t.size)throw new Error("Requested more than 0 entries, but input is empty. Input shape: "+t.shape+".");for(var n=e.shape,r=n[n.length-1],a=1,i=0;i<n.length-1;++i)a*=n[i];var o=t.shape,s=n.slice();s.pop();for(var u=1,c=r;c<t.rank;++c)u*=o[c],s.push(o[c]);var l=[].concat(qv(t.shape).map((function(t){return t/u})),[1]).slice(0,r);return[s,a,u,l]}var Ek={__proto__:null,prepareAndValidate:Nk};function Ik(t,e,n){var r=e.rank>1?e.shape[e.rank-1]:1,a=e.rank>1?e.rank-1:1,i="Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: "+n.shape+", indices.shape: "+e.shape+", shape: "+t+", sliceDim: "+r+", and batchDim: "+a+".";if(n.rank<a)throw new Error(i+" update.rank < "+a+". ");if(t.length<r+(n.rank-a))throw new Error(i+" Output shape length < "+(r+(n.rank-a)));if(n.rank!==a+t.length-r)throw new Error(i+" update.rank != "+(a+t.length-r));for(var o=0;o<a;++o)if(n.shape[o]!==e.shape[o])throw new Error(i+" updates.shape["+o+"] ("+n.shape[o]+") != indices.shape["+o+"] ("+e.shape[o]+").");for(var s=0;s<n.rank-a;++s)if(n.shape[s+a]!==t[s+r])throw new Error(i+" updates.shape["+(s+a)+"] ("+n.shape[s+a]+") != shape["+(s+a)+"] ("+t[s+a]+")")}function Ak(t,e,n){if(e.rank<1)throw new Error("tf.scatterND() expects the indices to be rank 1 or higher, but the rank was "+e.rank+".");if(t.rank<1)throw new Error("tf.scatterND() expects the updates to be rank 1 or higher, but the rank was "+t.rank+".");if("int32"!==e.dtype)throw new Error("The dtype of 'indices' should be int32, but got dtype: "+e.dtype);if(n.length<1)throw new Error("Output rank must be greater or equal to 1, but got shape: "+n);if(0===n.length){if(0===e.size)throw new Error("Indices specified for empty output. indices shape: "+e.shape);if(0===t.size)throw new Error("Updates specified for empty output. updates shape: "+t.shape)}Ik(n,e,t)}function Tk(t,e,n){for(var r=e.shape.length,a=r>1?e.shape[r-1]:1,i=n.length,o=1,s=a;s<i;++s)o*=n[s];var u=a<1?1:a;return{sliceRank:a,numUpdates:wv(e.shape)/u,sliceSize:o,strides:[].concat(qv(n.slice(0,a)),[1]),outputSize:wv(n)}}var Dk={__proto__:null,validateUpdateShape:Ik,validateInput:Ak,calculateShapes:Tk},_k=function(){function t(){}return t.prototype.getClassName=function(){return this.constructor.className},t.fromConfig=function(t,e){return new t(e)},t}(),Ok=function(){function t(){this.classNameMap={}}return t.getMap=function(){return null==t.instance&&(t.instance=new t),t.instance},t.register=function(e){t.getMap().classNameMap[e.className]=[e,e.fromConfig]},t}();function Fk(t){gv(null!=t.className,(function(){return"Class being registered does not have the static className property defined."})),gv("string"==typeof t.className,(function(){return"className is required to be a string, but got type "+typeof t.className})),gv(t.className.length>0,(function(){return"Class being registered has an empty-string as its className, which is disallowed."})),Ok.register(t)}var Mk={__proto__:null,Serializable:_k,SerializationMap:Ok,registerClass:Fk};function Lk(){return 32===Tg.backend.floatPrecision()?.001:.1}function zk(t,e,n){var r=!0;if((Lv(t)||Lv(e))&&(r=!1),Lv(t)&&Lv(e)&&(r=!0),r){var a=t.constructor.name,i=e.constructor.name;if(a!==i)throw new Error("Arrays are of different type. Actual: "+a+". Expected: "+i)}if(Array.isArray(t)&&Array.isArray(e)){var o=Wg(t),s=Wg(e);if(!kv(o,s))throw new Error("Arrays have different shapes. Actual: ["+o+"]. Expected: ["+s+"]")}var u=Lv(t)?t:xv(t),c=Lv(e)?e:xv(e);if(u.length!==c.length)throw new Error("Arrays have different lengths actual: "+u.length+" vs expected: "+c.length+".\nActual: "+u+".\nExpected: "+c+".");for(var l=0;l<c.length;++l){var h=u[l],f=c[l];if(!n(h,f))throw new Error("Arrays differ: actual["+l+"] = "+h+", expected["+l+"] = "+f+".\nActual: "+u+".\nExpected: "+c+".")}}function Bk(t,e,n){return!isFinite(t)&&!isFinite(e)||!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n)}var Pk={__proto__:null,TEST_EPSILON_FLOAT16:.1,expectArraysClose:function(t,e,n){return null==n&&(n=Lk()),zk(t,e,(function(t,e){return Bk(t,e,n)}))},testEpsilon:Lk,expectPromiseToFail:function(t,e){t().then((function(){return e.fail()}),(function(){return e()}))},expectArraysEqual:function(t,e){var n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?[e]:e;return Pv(t)||Pv(t[0])||Pv(e)||Pv(e[0])?zk(t,n,(function(t,e){return t==e})):zk(t,e,(function(t,e){return Bk(t,e,0)}))},expectNumbersClose:function(t,e,n){if(null==n&&(n=Lk()),!Bk(t,e,n))throw new Error("Numbers differ: actual === "+t+", expected === "+e)},expectValuesInRange:function(t,e,n){for(var r=0;r<t.length;r++)if(t[r]<e||t[r]>n)throw new Error("Value out of range:"+t[r]+" low: "+e+", high: "+n)},expectArrayBuffersEqual:function(t,e){expect(new Float32Array(t)).toEqual(new Float32Array(e))}};var Wk=ty({addN_:function(t){gv(Array.isArray(t),(function(){return"The argument passed to tf.addN() must be a list of tensors"})),gv(t.length>=1,(function(){return"Must pass at least one tensor to tf.addN(), but got "+t.length}));var e=t.map((function(t,e){return Ug(t,"tensors"+e,"addN")})),n=e[0];e.forEach((function(t){if(t.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),e.forEach((function(t){if(!kv(t.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));var r=e;return Tg.runKernelFunc((function(t,n){var r=t.addN(e);return n(e),r}),r,null,"AddN")}});function Vk(t){return null==t?null:0===t.rank?t.as1D():1===t.rank?t:2===t.rank?t.as4D(1,1,t.shape[0],t.shape[1]):3===t.rank?t.as4D(1,t.shape[0],t.shape[1],t.shape[2]):t}var Uk=ty({batchNorm_:function(t,e,n,r,a,i){null==i&&(i=.001);var o,s,u=Ug(t,"x","batchNorm"),c=Ug(e,"mean","batchNorm"),l=Ug(n,"variance","batchNorm");null!=a&&(o=Ug(a,"scale","batchNorm")),null!=r&&(s=Ug(r,"offset","batchNorm")),gv(c.rank===l.rank,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),gv(null==s||c.rank===s.rank,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),gv(null==o||c.rank===o.rank,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}));var h=function(t){return 0===t.rank||1===t.rank?t.as4D(1,1,1,t.size):2===t.rank?t.as4D(1,1,t.shape[0],t.shape[1]):3===t.rank?t.as4D(1,t.shape[0],t.shape[1],t.shape[2]):t}(u),f={x:h,scale:o,offset:s,mean:c,variance:l},p={varianceEpsilon:i},d=Tg.runKernelFunc((function(t,e){return e([h,c,l,o]),t.batchNorm(h,Vk(c),Vk(l),Vk(s),Vk(o),i)}),f,null,"FusedBatchNorm",p);return Iy(d,u.shape)}});var jk=ty({batchNorm2d_:function(t,e,n,r,a,i){var o,s,u=Ug(t,"x","batchNorm"),c=Ug(e,"mean","batchNorm"),l=Ug(n,"variance","batchNorm");return null!=a&&(o=Ug(a,"scale","batchNorm")),null!=r&&(s=Ug(r,"offset","batchNorm")),gv(2===u.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+"."})),gv(2===c.rank||1===c.rank,(function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank "+c.rank+"."})),gv(2===l.rank||1===l.rank,(function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank "+l.rank+"."})),null!=o&&gv(2===o.rank||1===o.rank,(function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank "+o.rank+"."})),null!=s&&gv(2===s.rank||1===s.rank,(function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank "+s.rank+"."})),Uk(u,c,l,s,o,i)}});var Gk=ty({batchNorm3d_:function(t,e,n,r,a,i){var o,s,u=Ug(t,"x","batchNorm"),c=Ug(e,"mean","batchNorm"),l=Ug(n,"variance","batchNorm");return null!=a&&(o=Ug(a,"scale","batchNorm")),null!=r&&(s=Ug(r,"offset","batchNorm")),gv(3===u.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+"."})),gv(3===c.rank||1===c.rank,(function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank "+c.rank+"."})),gv(3===l.rank||1===l.rank,(function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank "+l.rank+"."})),null!=o&&gv(3===o.rank||1===o.rank,(function(){return"Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank "+o.rank+"."})),null!=s&&gv(3===s.rank||1===s.rank,(function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank "+s.rank+"."})),Uk(u,c,l,s,o,i)}});var qk=ty({batchNorm4d_:function(t,e,n,r,a,i){var o,s,u=Ug(t,"x","batchNorm"),c=Ug(e,"mean","batchNorm"),l=Ug(n,"variance","batchNorm");return null!=a&&(o=Ug(a,"scale","batchNorm")),null!=r&&(s=Ug(r,"offset","batchNorm")),gv(4===u.rank,(function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+u.rank+"."})),gv(4===c.rank||1===c.rank,(function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank "+c.rank+"."})),gv(4===l.rank||1===l.rank,(function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank "+l.rank+"."})),null!=o&&gv(4===o.rank||1===o.rank,(function(){return"Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank "+o.rank+"."})),null!=s&&gv(4===s.rank||1===s.rank,(function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank "+s.rank+"."})),Uk(u,c,l,s,o,i)}});var Hk=ty({clone_:function(t){var e=Ug(t,"x","clone",null);return Tg.runKernelFunc((function(){return Tg.makeTensorFromDataId(e.dataId,e.shape,e.dtype)}),{x:e},null,"Identity")}});var Kk=ty({broadcastTo_:function(t,e){var n=Ug(t,"broadcastTo","x"),r=n.shape;if(e.some((function(t){return!(t>0)||t%1!=0})))throw new Error("broadcastTo(): Invalid broadcast shape ["+e+"].");if(e.length<n.rank)throw new Error("broadcastTo(): shape.length="+e.length+" < input.rank="+n.rank+".");if(e.length>n.rank){for(var a=n.shape.slice();a.length<e.length;)a.unshift(1);n=Iy(n,a)}for(var i=n.shape,o=Array.from(e),s=e.length-1;s>=0;s--)if(i[s]===e[s])o[s]=1;else if(1!==n.shape[s])throw new Error("broadcastTo(): ["+r+"] cannot be broadcast to ["+e+"].");if(0===o.map((function(t,e){return t>1?e:-1})).filter((function(t){return t>=0})).length)return Hk(n);var u={x:n},c={shape:e,inputShape:i};return Tg.runKernelFunc((function(t){return t.tile(n,o)}),u,null,"BroadcastTo",c)}});var Xk=ty({concat1d_:function(t){return wy(t,0)}});var Yk=ty({concat2d_:function(t,e){return wy(t,e)}});var Jk=ty({concat3d_:function(t,e){return wy(t,e)}});var $k=ty({concat4d_:function(t,e){return wy(t,e)}});var Zk=ty({conv1d_:function(t,e,n,r,a,i,o){void 0===a&&(a="NWC"),void 0===i&&(i=1);var s=Ug(t,"x","conv1d"),u=Ug(e,"filter","conv1d"),c=s,l=!1;2===s.rank&&(l=!0,c=Iy(s,[1,s.shape[0],s.shape[1]])),gv(3===c.rank,(function(){return"Error in conv1d: input must be rank 3, but got rank "+c.rank+"."})),gv(3===u.rank,(function(){return"Error in conv1d: filter must be rank 3, but got rank "+u.rank+"."})),null!=o&&gv(Sv(r),(function(){return"Error in conv1d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."})),gv(c.shape[2]===u.shape[1],(function(){return"Error in conv1d: depth of input ("+c.shape[2]+") must match input depth for filter "+u.shape[1]+"."})),gv(lb(n,i),(function(){return"Error in conv1D: Either stride or dilation must be 1. Got stride "+n+" and dilation '"+i+"'"})),gv("NWC"===a,(function(){return"Error in conv1d: got dataFormat of "+a+" but only NWC is currently supported."}));var h=Iy(u,[1,u.shape[0],u.shape[1],u.shape[2]]),f=Iy(c,[c.shape[0],1,c.shape[1],c.shape[2]]),p=mb(f,h,[1,n],r,"NHWC",[1,i],o);return Iy(p,l?[p.shape[2],p.shape[3]]:[p.shape[0],p.shape[2],p.shape[3]])}});var Qk=ty({conv2dTranspose_:function(t,e,n,r,a,i){var o=Ug(t,"x","conv2dTranspose"),s=Ug(e,"filter","conv2dTranspose");return pb(n,o,s,r,a,"NHWC",i)}});var tS=ty({conv3d_:function(t,e,n,r,a,i){void 0===a&&(a="NDHWC"),void 0===i&&(i=[1,1,1]);var o=Ug(t,"x","conv3d"),s=Ug(e,"filter","conv3d"),u=o,c=!1;4===o.rank&&(c=!0,u=Iy(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),gv(5===u.rank,(function(){return"Error in conv3d: input must be rank 5, but got rank "+u.rank+"."})),gv(5===s.rank,(function(){return"Error in conv3d: filter must be rank 5, but got rank "+s.rank+"."})),gv(u.shape[4]===s.shape[3],(function(){return"Error in conv3d: depth of input ("+u.shape[4]+") must match input depth for filter "+s.shape[3]+"."})),gv(lb(n,i),(function(){return"Error in conv3D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"})),gv("NDHWC"===a,(function(){return"Error in conv3d: got dataFormat of "+a+" but only NDHWC is currently supported."}));var l={x:u,filter:s},h={strides:n,pad:r,dataFormat:a,dilations:i},f=Tg.runKernelFunc((function(t,e){var a=rb(u.shape,s.shape,n,i,r),o=t.conv3d(u,s,a);return e([u,s]),o}),l,null,"Conv3D",h);return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f}});var eS=ty({conv3dTranspose_:function(t,e,n,r,a){var i=Ug(t,"x","conv3dTranspose"),o=Ug(e,"filter","conv3dTranspose");return yb(n,i,o,r,a)}});var nS=ty({depthToSpace_:function(t,e,n){void 0===n&&(n="NHWC");var r=Ug(t,"x","depthToSpace"),a="NHWC"===n?r.shape[1]:r.shape[2],i="NHWC"===n?r.shape[2]:r.shape[3],o="NHWC"===n?r.shape[3]:r.shape[1];gv(a*e>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n "+a+" and "+e+" for depthToSpace with input shape\n "+r.shape})),gv(i*e>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n "+i+" and "+e+" for depthToSpace with input shape\n "+r.shape})),gv(o%(e*e)==0,(function(){return"Dimension size must be evenly divisible by "+e*e+" but is "+o+" for depthToSpace with input shape "+r.shape}));var s={x:r},u={blockSize:e,dataFormat:n};return Tg.runKernelFunc((function(t){return t.depthToSpace(r,e,n)}),s,null,"DepthToSpace",u)}});var rS=ty({depthwiseConv2d_:function(t,e,n,r,a,i,o){void 0===a&&(a="NHWC"),void 0===i&&(i=[1,1]);var s=Ug(t,"x","depthwiseConv2d"),u=Ug(e,"filter","depthwiseConv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=Iy(s,[1,s.shape[0],s.shape[1],s.shape[2]])),gv(4===c.rank,(function(){return"Error in depthwiseConv2d: input must be rank 4, but got rank "+c.rank+"."})),gv(4===u.rank,(function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+u.rank+"."})),gv(c.shape[3]===u.shape[2],(function(){return"Error in depthwiseConv2d: number of input channels ("+c.shape[3]+") must match the inChannels dimension in filter "+u.shape[2]+"."})),null!=o&&gv(Sv(r),(function(){return"Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."}));var h={x:c,filter:u},f={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:o},p=Tg.runKernelFunc((function(t,e){null==i&&(i=[1,1]),gv(lb(n,i),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"}));var a=nb(c.shape,u.shape,n,i,r,o,!0),s=t.depthwiseConv2D(c,u,a);return e([c,u]),s}),h,null,"DepthwiseConv2dNative",f);return l?Iy(p,[p.shape[1],p.shape[2],p.shape[3]]):p}});var aS=ty({diag_:function(t){var e=Ug(t,"x","diag").flatten(),n={x:e};return Tg.runKernelFunc((function(n){var r=n.diag(e),a=[].concat(t.shape,t.shape);return Iy(r,a)}),n,null,"Diag")}});function iS(t,e){for(var n=[],r=0;r<e.length;r++)e[r]&&n.push(r);for(var a=Sy(t,"int32"),i=Sy([n.length,t.length],"int32"),o=0;o<n.length;o++){var s=a.indexToLoc(n[o]),u=o*t.length;i.values.set(s,u)}return i.toTensor()}function oS(){return(oS=Vm(regeneratorRuntime.mark((function t(e){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Ug(e,"condition","whereAsync","bool"),t.next=3,n.data();case 3:return r=t.sent,a=iS(n.shape,r),e!==n&&n.dispose(),t.abrupt("return",a);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var sS=ty({logicalAnd_:function(t,e){var n=Ug(t,"a","logicalAnd","bool"),r=Ug(e,"b","logicalAnd","bool");return zg(n.shape,r.shape),Tg.runKernelFunc((function(t){return t.logicalAnd(n,r)}),{a:n,b:r},null,"LogicalAnd")}}),uS=ty({logicalNot_:function(t){var e=Ug(t,"x","logicalNot","bool");return Tg.runKernelFunc((function(t){return t.logicalNot(e)}),{$x:e})}}),cS=ty({logicalOr_:function(t,e){var n=Ug(t,"a","logicalOr","bool"),r=Ug(e,"b","logicalOr","bool");return zg(n.shape,r.shape),Tg.runKernelFunc((function(t){return t.logicalOr(n,r)}),{$a:n,$b:r})}}),lS=ty({logicalXor_:function(t,e){var n=Ug(t,"a","logicalXor","bool"),r=Ug(e,"b","logicalXor","bool");return zg(n.shape,r.shape),cS(t,e).logicalAnd(sS(t,e).logicalNot())}}),hS=ty({where_:function(t,e,n){var r=Ug(e,"a","where"),a=Ug(n,"b","where"),i=Ug(t,"condition","where","bool");return yv(r.shape,a.shape,"Error in where: "),1===i.rank?gv(i.shape[0]===r.shape[0],(function(){return"The first dimension of `a` must match the size of `condition`."})):yv(i.shape,a.shape,"Error in where: "),Tg.runKernelFunc((function(t,e){var n=t.select(i,r,a);return e([i]),n}),{$condition:i,$a:r,$b:a},(function(t,e){var n=e[0];return{$condition:function(){return xy(n).toFloat()},$a:function(){return t.mul(n.cast(t.dtype))},$b:function(){return t.mul(n.logicalNot().cast(t.dtype))}}}))}}),fS=function(t){return oS.apply(this,arguments)};var pS=ty({divNoNan_:function(t,e){var n=Ug(t,"a","div"),r=Ug(e,"b","div"),a=Sg(n,r);n=a[0],r=a[1];var i=Ix(n,r),o=xy(i),s=r.equal(o);return hS(s,o,i)}});var dS=ty({dot_:function(t,e){var n=Ug(t,"t1","dot"),r=Ug(e,"t2","dot");gv(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(function(){return"Error in dot: inputs must all be rank 1 or 2, but got ranks "+n.rank+" and "+r.rank+"."}));var a=1===n.rank?n.size:n.shape[1],i=1===r.rank?r.size:r.shape[0];if(gv(a===i,(function(){return"Error in dot: inner dimensions of inputs must match, but got "+a+" and "+i+"."})),1===n.rank&&1===r.rank){var o=Iy(n,[1,-1]),s=Iy(r,[-1,1]),u=Oy(o,s);return Iy(u,[])}if(1===n.rank&&2===r.rank){var c=Iy(n,[1,-1]),l=Iy(r,[r.shape[0],r.shape[1]]),h=Oy(c,l);return Iy(h,[h.size])}if(2===n.rank&&1===r.rank){var f=Iy(r,[-1,1]),p=Oy(n,f);return Iy(p,[p.size])}var d=Iy(r,[r.shape[0],r.shape[1]]);return Oy(n,d)}});var mS=ty({equal_:function(t,e){var n=Ug(t,"a","equal"),r=Ug(e,"b","equal"),a=Sg(n,r);n=a[0],r=a[1],zg(n.shape,r.shape);var i={a:n,b:r};return Tg.runKernelFunc((function(t){return t.equal(n,r)}),i,null,"Equal")}});var vS=ty({eye_:function(t,e,n,r){void 0===r&&(r="float32"),null==e&&(e=t);for(var a=Sy([t,e],r),i=t<=e?t:e,o=0;o<i;++o)a.set(1,o,o);var s=a.toTensor().as2D(t,e);if(null==n)return s;if(1===n.length)return _x(Ey(s,0),[n[0],1,1]);if(2===n.length)return _x(Ey(Ey(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return _x(Ey(Ey(Ey(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error("eye() currently supports only 1D and 2D batchShapes, but received "+n.length+"D.")}});var gS=ty({greater_:function(t,e){var n=Ug(t,"a","greater"),r=Ug(e,"b","greater"),a=Sg(n,r);n=a[0],r=a[1],zg(n.shape,r.shape);var i={a:n,b:r};return Tg.runKernelFunc((function(t){return t.greater(n,r)}),i,null,"Greater")}});var yS=ty({greaterEqual_:function(t,e){var n=Ug(t,"a","greaterEqual"),r=Ug(e,"b","greaterEqual"),a=Sg(n,r);n=a[0],r=a[1],zg(n.shape,r.shape);var i={a:n,b:r};return Tg.runKernelFunc((function(t,e){var a=t.greaterEqual(n,r);return e([n,r]),a}),i,null,"GreaterEqual")}});var bS=ty({less_:function(t,e){var n=Ug(t,"a","less"),r=Ug(e,"b","less"),a=Sg(n,r);n=a[0],r=a[1],zg(n.shape,r.shape);var i={a:n,b:r};return Tg.runKernelFunc((function(t){return t.less(n,r)}),i,null,"Less")}});var xS=ty({lessEqual_:function(t,e){var n=Ug(t,"a","lessEqual"),r=Ug(e,"b","lessEqual"),a=Sg(n,r);n=a[0],r=a[1],zg(n.shape,r.shape);var i={a:n,b:r};return Tg.runKernelFunc((function(t,e){var a=t.lessEqual(n,r);return e([n,r]),a}),i,null,"LessEqual")}});var wS=ty({localResponseNormalization_:function(t,e,n,r,a){void 0===e&&(e=5),void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=.5);var i=Ug(t,"x","localResponseNormalization");gv(4===i.rank||3===i.rank,(function(){return"Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank "+i.rank+"."})),gv(Sv(e),(function(){return"Error in localResponseNormalization: depthRadius must be an integer but got depthRadius "+e+"."}));var o=i,s=!1;3===i.rank&&(s=!0,o=Iy(i,[1,i.shape[0],i.shape[1],i.shape[2]]));var u={x:o},c={depthRadius:e,bias:n,alpha:r,beta:a},l=Tg.runKernelFunc((function(t,i){var s=t.localResponseNormalization4D(o,e,n,r,a);return i([o,s]),s}),u,null,"LRN",c);return s?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l}});var kS=ty({max_:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=Ug(t,"x","max"),a={x:r},i={reductionIndices:e,keepDims:n},o=Tg.runKernelFunc((function(t,n){var a=Av(e,r.shape),i=Yg(a,r.rank),o=r;null!=i&&(o=Bx(r,i),a=$g(a.length,o.rank));var s=t.max(o,a);return n([r,s]),null!=i&&t.disposeData(o.dataId),s}),a,null,"Max",i);return n?Iy(o,Kg(o.shape,Av(e,r.shape))):o}});var SS=ty({multinomial_:function(t,e,n,r){void 0===r&&(r=!1);var a=Ug(t,"logits","multinomial"),i=a.size,o=a.rank;if(i<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+i+".");if(o>2)throw new Error("Rank of probabilities must be 1 or 2, but is "+o);n=n||Math.random();var s=1===o?a.as2D(1,-1):a,u=Tg.runKernelFunc((function(t){return t.multinomial(s,r,e,n)}),{logits2D:s});return 1===o?u.as1D():u}});var CS=ty({notEqual_:function(t,e){var n=Ug(t,"a","notEqual"),r=Ug(e,"b","notEqual"),a=Sg(n,r);n=a[0],r=a[1],zg(n.shape,r.shape);var i={a:n,b:r};return Tg.runKernelFunc((function(t){return t.notEqual(n,r)}),i,null,"NotEqual")}});var RS=ty({outerProduct_:function(t,e){var n=Ug(t,"v1","outerProduct"),r=Ug(e,"v2","outerProduct");gv(1===n.rank&&1===r.rank,(function(){return"Error in outerProduct: inputs must be rank 1, but got ranks "+n.rank+" and "+r.rank+"."}));var a=Iy(n,[-1,1]),i=Iy(r,[1,-1]);return Oy(a,i)}});var NS=ty({pad1d_:function(t,e,n){return void 0===n&&(n=0),gv(2===e.length,(function(){return"Invalid number of paddings. Must be length of 2."})),Xx(t,[e],n)}});var ES=ty({pad2d_:function(t,e,n){return void 0===n&&(n=0),gv(2===e.length&&2===e[0].length&&2===e[1].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Xx(t,e,n)}});var IS=ty({pad3d_:function(t,e,n){return void 0===n&&(n=0),gv(3===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Xx(t,e,n)}});var AS=ty({pad4d_:function(t,e,n){return void 0===n&&(n=0),gv(4===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length&&2===e[3].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Xx(t,e,n)}});var TS=ty({rand_:function(t,e,n){var r=wv(t),a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error("Unknown data type "+n);a=new Uint8Array(r)}for(var i=0;i<r;i++)a[i]=e();return Tg.makeTensor(a,t,n)}}),DS=n((function(t){!function(t,e,n){function r(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}function a(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var n=new r(t),i=e&&e.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0},o.double=function(){return o()+11102230246251565e-32*(2097152*o()|0)},o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n((function(){return i})):this.alea=i}(0,t,!1)})),_S=n((function(t){!function(t,e,n){function r(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}function a(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var n=new r(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n((function(){return i})):this.xor128=i}(0,t,!1)})),OS=n((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function a(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var n=new r(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n((function(){return i})):this.xorwow=i}(0,t,!1)})),FS=n((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.x,a=e.i;return t=r[a],n=(t^=t>>>7)^t<<24,n^=(t=r[a+1&7])^t>>>10,n^=(t=r[a+3&7])^t>>>3,n^=(t=r[a+4&7])^t<<7,t=r[a+7&7],n^=(t^=t<<13)^t<<9,r[a]=n,e.i=a+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}function a(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var n=new r(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.x&&a(i,n),o.state=function(){return a(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n((function(){return i})):this.xorshift7=i}(0,t,!1)})),MS=n((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.w,a=e.X,i=e.i;return e.w=r=r+1640531527|0,n=a[i+34&127],t=a[i=i+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=a[i]=n^t,e.i=i,n+(r^r>>>16)|0},function(t,e){var n,r,a,i,o,s=[],u=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,u=Math.max(u,e.length)),a=0,i=-32;i<u;++i)e&&(r^=e.charCodeAt((i+32)%e.length)),0===i&&(o=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,i>=0&&(o=o+1640531527|0,a=0==(n=s[127&i]^=r+o)?a+1:0);for(a>=128&&(s[127&(e&&e.length||0)]=-1),a=127,i=512;i>0;--i)r=s[a+34&127],n=s[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[a]=r^n;t.w=o,t.X=s,t.i=a}(e,t)}function a(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var n=new r(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&(i.X&&a(i,n),o.state=function(){return a(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n((function(){return i})):this.xor4096=i}(0,t,!1)})),LS=n((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,a=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^a,e.a=a-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}function a(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var n=new r(t),i=e&&e.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}e&&e.exports?e.exports=i:n&&n.amd?n((function(){return i})):this.tychei=i}(0,t,!1)})),zS=n((function(t){!function(e,n){var r,a=this,i=n.pow(256,6),o=n.pow(2,52),s=2*o;function u(t,u,p){var d=[],m=h(function t(e,n){var r,a=[],i=typeof e;if(n&&"object"==i)for(r in e)try{a.push(t(e[r],n-1))}catch(t){}return a.length?a:"string"==i?e:e+"\0"}((u=1==u?{entropy:!0}:u||{}).entropy?[t,f(e)]:null==t?function(){try{var t;return r&&(t=r.randomBytes)?t=t(256):(t=new Uint8Array(256),(a.crypto||a.msCrypto).getRandomValues(t)),f(t)}catch(t){var n=a.navigator,i=n&&n.plugins;return[+new Date,a,i,a.screen,f(e)]}}():t,3),d),v=new c(d),g=function(){for(var t=v.g(6),e=i,n=0;t<o;)t=256*(t+n),e*=256,n=v.g(1);for(;t>=s;)t/=2,e/=2,n>>>=1;return(t+n)/e};return g.int32=function(){return 0|v.g(4)},g.quick=function(){return v.g(4)/4294967296},g.double=g,h(f(v.S),e),(u.pass||p||function(t,e,r,a){return a&&(a.S&&l(a,v),t.state=function(){return l(v,{})}),r?(n.random=t,e):t})(g,m,"global"in u?u.global:this==n,u.state)}function c(t){var e,n=t.length,r=this,a=0,i=r.i=r.j=0,o=r.S=[];for(n||(t=[n++]);a<256;)o[a]=a++;for(a=0;a<256;a++)o[a]=o[i=255&i+t[a%n]+(e=o[a])],o[i]=e;(r.g=function(t){for(var e,n=0,a=r.i,i=r.j,o=r.S;t--;)e=o[a=255&a+1],n=256*n+o[255&(o[a]=o[i=255&i+e])+(o[i]=e)];return r.i=a,r.j=i,n})(256)}function l(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function h(t,e){for(var n,r=t+"",a=0;a<r.length;)e[255&a]=255&(n^=19*e[255&a])+r.charCodeAt(a++);return f(e)}function f(t){return String.fromCharCode.apply(0,t)}if(n.seedrandom=u,h(n.random(),e),t.exports){t.exports=u;try{r=require("crypto")}catch(t){}}}([],Math)}));zS.alea=DS,zS.xor128=_S,zS.xorwow=OS,zS.xorshift7=FS,zS.xor4096=MS,zS.tychei=LS;var BS=zS.alea,PS=function(){function t(t,e,n,r,a){this.mean=t,this.stdDev=e,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);var i=a||Math.random();this.random=BS(i.toString())}var e=t.prototype;return e.nextValue=function(){if(!isNaN(this.nextVal)){var t=this.nextVal;return this.nextVal=NaN,t}for(var e,n,r=!1;!r;){var a=void 0,i=void 0,o=void 0;do{o=(a=2*this.random()-1)*a+(i=2*this.random()-1)*i}while(o>=1||0===o);var s=Math.sqrt(-2*Math.log(o)/o);e=this.mean+this.stdDev*a*s,n=this.mean+this.stdDev*i*s,this.truncated&&!this.isValidTruncated(e)||(r=!0)}return this.truncated&&!this.isValidTruncated(n)||(this.nextVal=this.convertValue(n)),this.convertValue(e)},e.convertValue=function(t){return null==this.dtype||"float32"===this.dtype?t:Math.round(t)},e.isValidTruncated=function(t){return t<=this.upper&&t>=this.lower},t}(),WS=function(){function t(t,e,n,r){this.alpha=t,this.beta=1/e,this.dtype=n;var a=r||Math.random();this.randu=BS(a.toString()),this.randn=new PS(0,1,n,!1,this.randu()),this.d=t<1?t+2/3:t-1/3,this.c=1/Math.sqrt(9*this.d)}var e=t.prototype;return e.nextValue=function(){for(var t,e,n,r,a,i;;){do{r=this.randn.nextValue(),i=1+this.c*r}while(i<=0);if(i*=i*i,e=1-.331*(t=r*r)*t,n=.5*t+this.d*(1-i+Math.log(i)),(a=this.randu())<e||Math.log(a)<n)break}return i=1/this.beta*this.d*i,this.alpha<1&&(i*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(i)},e.convertValue=function(t){return"float32"===this.dtype?t:Math.round(t)},t}(),VS=function(){function t(t,e,n,r){var a=this;if(void 0===t&&(t=0),void 0===e&&(e=1),this.canReturnFloat=function(){return null==a.dtype||"float32"===a.dtype},this.min=t,this.range=e-t,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error("The difference between "+t+" - "+e+" <= 1 and dtype is not float");this.random=BS(r)}var e=t.prototype;return e.convertValue=function(t){return this.canReturnFloat()?t:Math.round(t)},e.nextValue=function(){return this.convertValue(this.min+this.range*this.random())},t}();var US=ty({randomGamma_:function(t,e,n,r,a){if(void 0===n&&(n=1),void 0===r&&(r="float32"),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type "+r);for(var i=new WS(e,n,r,a),o=Sy(t,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});var jS=ty({randomNormal_:function(t,e,n,r,a){if(void 0===e&&(e=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var i=new PS(e,n,r,!1,a),o=Sy(t,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});var GS=ty({randomUniform_:function(t,e,n,r,a){void 0===e&&(e=0),void 0===n&&(n=1),void 0===r&&(r="float32");for(var i=Sy(t,r),o=new VS(e,n,null,a),s=0;s<i.values.length;s++)i.values[s]=o.nextValue();return i.toTensor()}});var qS=ty({separableConv2d_:function(t,e,n,r,a,i,o){void 0===i&&(i=[1,1]),void 0===o&&(o="NHWC");var s=Ug(t,"x","separableConv2d"),u=Ug(e,"depthwiseFilter","separableConv2d"),c=Ug(n,"pointwiseFilter","separableConv2d"),l=s,h=!1;if(3===s.rank&&(h=!0,l=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),"NCHW"===o)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");gv(4===l.rank,(function(){return"Error in separableConv2d: input must be rank 4, but got rank "+l.rank+"."})),gv(4===u.rank,(function(){return"Error in separableConv2d: depthwise filter must be rank 4, but got rank "+u.rank+"."})),gv(4===c.rank,(function(){return"Error in separableConv2d: pointwise filter must be rank 4, but got rank "+u.rank+"."})),gv(1===c.shape[0],(function(){return"Error in separableConv2d: the first dimension of pointwise filter must be 1, but got "+c.shape[0]+"."})),gv(1===c.shape[1],(function(){return"Error in separableConv2d: the second dimension of pointwise filter must be 1, but got "+c.shape[1]+"."}));var f=u.shape[2],p=u.shape[3];gv(c.shape[2]===f*p,(function(){return"Error in separableConv2d: the third dimension of pointwise filter must be "+f*p+", but got "+c.shape[2]+"."}));var d=rS(l,u,r,a,o,i),m=mb(d,c,1,"valid",o);return h?m.as3D(m.shape[1],m.shape[2],m.shape[3]):m}});var HS=ty({squaredDifference_:function(t,e){var n=Ug(t,"a","squaredDifference"),r=Ug(e,"b","squaredDifference"),a=Sg(n,r);n=a[0],r=a[1],zg(n.shape,r.shape);var i={a:n,b:r};return Tg.runKernelFunc((function(t,e){var a=t.squaredDifference(n,r);return e([n,r]),a}),i,null,"SquaredDifference",{})}});var KS=ty({truncatedNormal_:function(t,e,n,r,a){if(void 0===e&&(e=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");for(var i=new PS(e,n,r,!0,a),o=Sy(t,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});function XS(t){return t<=30?t:Gv(t,Math.floor(Math.sqrt(t)))}function YS(t,e,n){for(var r=t.shape[n],a=[],i=1,o=1,s=0;s<n;s++)a.push(t.shape[s]),i*=t.shape[s];for(var u=0;u<e.rank;u++)a.push(e.shape[u]);for(var c=n+1;c<t.rank;c++)a.push(t.shape[c]),o*=t.shape[c];return{batchSize:i,sliceSize:o,dimSize:r,outputShape:a}}var JS={__proto__:null,segOpComputeOptimalWindowSize:function(t,e){var n,r=!1;for(t<=30?(n=t,r=!0):n=Gv(t,Math.floor(Math.sqrt(t)));!r;)n>e||n===t?r=!0:n=Gv(t,n+1);return n},computeOutShape:function(t,e,n){for(var r=[],a=t.length,i=0;i<a;i++)i!==e?r.push(t[i]):r.push(n);return r},collectGatherOpShapeInfo:YS};function $S(t,e){for(var n=[],r=t;r<e;++r)n.push(r);return n}function ZS(t){for(var e=[],n=0;n<t.length;++n)for(var r=0;r<t[n].length;++r)e.push(t[n][r]);return e}var QS=ty({gather_:function(t,e,n){void 0===n&&(n=0);var r=Ug(t,"x","gather"),a=Ug(e,"indices","gather","int32");n=Av(n,r.shape)[0];var i=YS(r,a,n);return Tg.runKernelFunc((function(t,e){var i=t.gather(r,a.flatten(),n);return e([a]),i}),{x:r,indices:a},(function(t,e){var a=e[0];return{x:function(){var e=r.shape,i=a.size,o=e.slice(0,n),s=o.length,u=e.slice(n,e.length).slice(1),c=u.length,l=$S(0,s),h=$S(s+1,s+1+c),f=ZS([o,[i],u]),p=t.reshape(f),d=a.reshape([i]),m=ZS([[s],l,h]),v=p.transpose(m),g=tC(v,d,r.shape[n]),y=Jg(m);return g=g.transpose(y)},indices:function(){return a}}}),"Gather",{axis:n}).reshape(i.outputShape)}}),tC=ty({unsortedSegmentSum_:function(t,e,n){var r=Ug(t,"x","unsortedSegmentSum"),a=Ug(e,"segmentIds","unsortedSegmentSum","int32");return gv(Sv(n),(function(){return"numSegments must be of dtype int"})),Tg.runKernelFunc((function(t,e){var i=t.unsortedSegmentSum(r,a,n);return e([a]),i}),{$x:r},(function(t,e){var n=e[0];return{$x:function(){return function(t,e){for(var n=vx(e,xy(e)),r=QS(t,n),a=yS(e,oy(0,"int32")),i=r.rank-a.rank,o=0;o<i;++o)a=Ey(a,o+1);a=sS(a,dy(r.shape,"bool"));var s=xy(r);return hS(a,r,s)}(t,n)}}}))}});function eC(){return(eC=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f,p,d,m,v;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(a=Ug(e,"tensor","boolMask"),i=Ug(n,"mask","boolMask","bool"),o=null==r?0:r,s=i.rank,u=a.shape,gv(s>0,(function(){return"mask cannot be scalar"})),yv(u.slice(o,o+s),i.shape,"mask's shape must match the first K dimensions of tensor's shape,"),c=1,l=o;l<o+s;l++)c*=u[l];return h=u.slice(0,o).concat([c],u.slice(o+s)),f=a.reshape(h),p=i.reshape([-1]),t.next=14,fS(p);case 14:return d=t.sent,m=d.squeeze([1]),v=QS(f,m,o),e!==a&&a.dispose(),n!==i&&i.dispose(),m.dispose(),f.dispose(),p.dispose(),d.dispose(),t.abrupt("return",v);case 24:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var nC=function(t,e,n){return eC.apply(this,arguments)};var rC=ty({reverse_:function(t,e){var n=Ug(t,"x","reverse");if(0===n.rank)return n.clone();var r=Av(e,n.shape);return Tg.runKernelFunc((function(t){return t.reverse(n,r)}),{$x:n},(function(t){return{$x:function(){return t.reverse(r)}}})).reshapeAs(n)}}),aC=ty({reverse1d_:function(t){var e=Ug(t,"x","reverse");return gv(1===e.rank,(function(){return"Error in reverse1D: x must be rank 1 but got rank "+e.rank+"."})),rC(e,0)}}),iC=ty({reverse2d_:function(t,e){var n=Ug(t,"x","reverse");return gv(2===n.rank,(function(){return"Error in reverse2D: x must be rank 2 but got rank "+n.rank+"."})),rC(n,e)}}),oC=ty({reverse3d_:function(t,e){var n=Ug(t,"x","reverse");return gv(3===n.rank,(function(){return"Error in reverse3D: x must be rank 3 but got rank "+n.rank+"."})),rC(n,e)}}),sC=ty({reverse4d_:function(t,e){var n=Ug(t,"x","reverse");return gv(4===n.rank,(function(){return"Error in reverse4D: x must be rank 4 but got rank "+n.rank+"."})),rC(n,e)}});function uC(t,e,n,r,a,i){var o=Ug(t,"x","maxPool"),s=o,u=!1;3===o.rank&&(u=!0,s=o.as4D(1,o.shape[0],o.shape[1],o.shape[2])),null==r&&(r=[1,1]),gv(4===s.rank,(function(){return"Error in maxPool: input must be rank 4 but got rank "+s.rank+"."})),gv(lb(n,r),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'"})),null!=i&&gv(Sv(a),(function(){return"Error in maxPool: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+a+"."}));var c=tb(s.shape,e,n,r,a,i);if(1===c.filterWidth&&1===c.filterHeight&&kv(c.inShape,c.outShape))return o.clone();var l=[s],h=Tg.runKernelFunc((function(t,e){var n=t.maxPool(s,c);return e([s,n]),n}),{x:s},(function(t,i){var o=i[0],s=i[1];return{x:function(){return function(t,e,n,r,a,i,o,s){var u=Ug(t,"dy","maxPoolBackprop"),c=Ug(e,"input","maxPoolBackprop"),l=Ug(n,"output","maxPoolBackprop");gv(c.rank===u.rank,(function(){return"Rank of input ("+c.rank+") does not match rank of dy ("+u.rank+")"})),null==i&&(i=[1,1]);gv(lb(a,i),(function(){return"Error in maxPoolBackProp: Either strides or dilations must be 1. Got strides "+a+" and dilations '"+i+"'"})),gv(4===u.rank,(function(){return"Error in maxPoolBackprop: dy must be rank 4 but got rank "+u.rank+"."})),gv(4===c.rank,(function(){return"Error in maxPoolBackprop: input must be rank 4 but got rank "+c.rank+"."})),null!=s&&gv(Sv(o),(function(){return"Error in maxPoolBackprop: pad must be an integer when using, dimRoundingMode "+s+" but got pad "+o+"."}));var h=tb(c.shape,r,a,i,o,s);return Tg.runKernelFunc((function(t){return t.maxPoolBackprop(u,c,l,h)}),{$dy:u,$input:c})}(t,o,s,e,n,r,a)}}}),"MaxPool",c,l);return u?h.as3D(h.shape[1],h.shape[2],h.shape[3]):h}function cC(t,e,n,r,a,i){var o=Ug(t,"x","avgPool","float32");null==r&&(r=[1,1]),gv(lb(n,r),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'"}));var s=o,u=!1;3===o.rank&&(u=!0,s=o.as4D(1,o.shape[0],o.shape[1],o.shape[2])),gv(4===s.rank,(function(){return"Error in avgPool: x must be rank 4 but got rank "+s.rank+"."})),null!=i&&gv(Sv(a),(function(){return"Error in avgPool: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+a+"."}));var c=tb(s.shape,e,n,r,a,i);if(1===c.filterWidth&&1===c.filterHeight&&kv(c.inShape,c.outShape))return o.clone();var l=Tg.runKernelFunc((function(t){return t.avgPool(s,c)}),{x:s},(function(t){return{x:function(){return function(t,e,n,r,a,i){var o=Ug(t,"dy","avgPoolBackprop"),s=Ug(e,"input","avgPoolBackprop");gv(s.rank===o.rank,(function(){return"Rank of input ("+s.rank+") does not match rank of dy ("+o.rank+")"})),null==a&&(a=[1,1]);gv(lb(r,a),(function(){return"Error in avgPoolBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+a+"'"}));var u=s,c=o,l=!1;3===s.rank&&(l=!0,u=s.as4D(1,s.shape[0],s.shape[1],s.shape[2]),c=o.as4D(1,o.shape[0],o.shape[1],o.shape[2]));gv(4===c.rank,(function(){return"Error in avgPoolBackprop: dy must be rank 4 but got rank "+c.rank+"."})),gv(4===u.rank,(function(){return"Error in avgPoolBackprop: input must be rank 4 but got rank "+u.rank+"."}));var h=tb(u.shape,n,r,a,i),f=Tg.runKernelFunc((function(t){return t.avgPoolBackprop(c,u,h)}),{dy4D:c,input4D:u});if(l)return f.as3D(f.shape[1],f.shape[2],f.shape[3]);return f}(t,s,e,n,r,a)}}}),"AvgPool",c);return l=l.cast(o.dtype),u?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l}var lC=ty({maxPool_:function(t,e,n,r,a){return uC(t,e,n,1,r,a)}}),hC=ty({avgPool_:function(t,e,n,r,a){return cC(t,e,n,1,r,a)}}),fC=ty({pool_:function(t,e,n,r,a,i){null==a&&(a=[1,1]),null==i&&(i=1),0===r&&(r="valid");var o=Ug(t,"x","maxPool"),s=o,u=!1;3===o.rank&&(u=!0,s=o.as4D(1,o.shape[0],o.shape[1],o.shape[2])),gv(lb(i,a),(function(){return"Error in pool: Either strides or dilations must be 1. Got strides "+i+" and dilations '"+a+"'"}));var c,l=tb(s.shape,e,i,a,r),h=[l.dilationHeight,l.dilationWidth];c="same"===r?function(t,e){var n=t.map((function(t,n){return t+(t-1)*(e[n]-1)})).map((function(t){return t-1})),r=n.map((function(t){return Math.floor(t/2)})),a=n.map((function(t,e){return t-r[e]}));return n.map((function(t,e){return[r[e],a[e]]}))}([l.filterHeight,l.filterWidth],h):[[0,0],[0,0]];var f=1===h[0]&&1===h[1],p=function(t,e,n){var r=n.map((function(t){return t[0]})),a=n.map((function(t){return t[1]})),i=t.concat(r,a),o=e.map((function(t,e){return(t-i[e]%t)%t})),s=a.map((function(t,e){return t+o[e]})),u=e.map((function(t,e){return[r[e],s[e]]})),c=e.map((function(t,e){return[0,o[e]]}));return[u,c]}([l.inHeight,l.inWidth],h,c),d=p[0],m=p[1],v=f?r:"valid",g=f?s:My(s,h,d),y=("avg"===n?function(){return cC(g,e,i,1,v)}:function(){return uC(g,e,i,1,v)})(),b=f?y:Ux(y,h,m);return u?b.as3D(b.shape[1],b.shape[2],b.shape[3]):b}}),pC=ty({maxPool3d_:function(t,e,n,r,a,i,o){void 0===i&&(i="NDHWC");var s=Ug(t,"x","maxPool3d"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==o&&(o=[1,1,1]),gv(5===u.rank,(function(){return"Error in maxPool3d: x must be rank 5 but got rank "+u.rank+"."})),gv("NDHWC"===i,(function(){return"Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of "+i})),gv(lb(n,o),(function(){return"Error in maxPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'"})),null!=a&&gv(Sv(r),(function(){return"Error in maxPool3d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+"."}));var l=eb(u.shape,e,n,o,r,a,i),h=Tg.runKernelFunc((function(t,e){var n=t.maxPool3d(u,l);return e([u,n]),n}),{x:u},(function(t,i){var s=i[0],u=i[1];return{x:function(){return function(t,e,n,r,a,i,o,s){var u=Ug(t,"dy","maxPool3dBackprop"),c=Ug(e,"input","maxPool3dBackprop"),l=Ug(n,"output","maxPool3dBackprop"),h=u,f=c,p=l,d=!1;4===c.rank&&(d=!0,h=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]),f=c.as5D(1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]),p=l.as5D(1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]));gv(5===h.rank,(function(){return"Error in maxPool3dBackprop: dy must be rank 5 but got rank "+h.rank+"."})),gv(5===f.rank,(function(){return"Error in maxPool3dBackprop: input must be rank 5 but got rank "+f.rank+"."})),gv(5===p.rank,(function(){return"Error in maxPool3dBackprop: output must be rank 5 but got rank "+p.rank+"."})),null==i&&(i=[1,1,1]);gv(lb(a,i),(function(){return"Error in maxPool3dBackprop: Either strides or dilations must be 1. Got strides "+a+" and dilations '"+i+"'"})),null!=s&&gv(Sv(o),(function(){return"Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+s+" but got pad "+o+"."}));var m=eb(f.shape,r,a,i,o,s),v=Tg.runKernelFunc((function(t){return t.maxPool3dBackprop(h,f,p,m)}),{dy5D:h,input5D:f});if(d)return v.as4D(v.shape[1],v.shape[2],v.shape[3],v.shape[4]);return v}(t,s,u,e,n,o,r,a)}}}));return c?h.as4D(h.shape[1],h.shape[2],h.shape[3],h.shape[4]):h}}),dC=ty({avgPool3d_:function(t,e,n,r,a,i,o){void 0===i&&(i="NDHWC");var s=Ug(t,"x","avgPool3d","float32"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==o&&(o=[1,1,1]),gv(5===u.rank,(function(){return"Error in avgPool3d: x must be rank 5 but got rank "+u.rank+"."})),gv("NDHWC"===i,(function(){return"Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of "+i})),gv(lb(n,o),(function(){return"Error in avgPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'"})),null!=a&&gv(Sv(r),(function(){return"Error in avgPool3d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+"."}));var l=eb(u.shape,e,n,o,r,a,i),h=Tg.runKernelFunc((function(t){return t.avgPool3d(u,l)}),{x:u},(function(t){return{x:function(){return function(t,e,n,r,a,i,o){var s=Ug(t,"dy","avgPool3dBackprop"),u=Ug(e,"input","avgPool3dBackprop"),c=s,l=u,h=!1;4===u.rank&&(h=!0,c=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]),l=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]));gv(5===c.rank,(function(){return"Error in avgPool3dBackprop: dy must be rank 5 but got rank "+c.rank+"."})),gv(5===l.rank,(function(){return"Error in avgPool3dBackprop: input must be rank 5 but got rank "+l.rank+"."})),null==a&&(a=[1,1,1]);gv(lb(r,a),(function(){return"Error in avgPool3dBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+a+"'"})),null!=o&&gv(Sv(i),(function(){return"Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+"."}));var f=eb(l.shape,n,r,a,i,o),p=Tg.runKernelFunc((function(t){return t.avgPool3dBackprop(c,l,f)}),{dy5D:c,input5D:l});if(h)return p.as4D(p.shape[1],p.shape[2],p.shape[3],p.shape[4]);return p}(t,u,e,n,o,r,a)}}}));return h=h.cast(u.dtype),c?h.as4D(h.shape[1],h.shape[2],h.shape[3],h.shape[4]):h}}),mC=ty({maxPoolWithArgmax_:function(t,e,n,r,a){void 0===a&&(a=!1);var i=Ug(t,"x","maxPoolWithArgmax"),o={filterSize:e,strides:n,pad:r,includeBatchInIndex:a},s=Tg.runKernel("MaxPoolWithArgmax",{x:i},o);return{result:s[0],indexes:s[1]}}});var vC=ty({equalStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","equalStrict"),r=Ug(e,"b","equalStrict");return yv(n.shape,r.shape,"Error in equalStrict: "),n.equal(r)}}),gC=ty({greaterEqualStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","greaterEqualStrict"),r=Ug(e,"b","greaterEqualStrict");return yv(n.shape,r.shape,"Error in greaterEqualStrict: "),n.greaterEqual(r)}}),yC=ty({greaterStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","greaterStrict"),r=Ug(e,"b","greaterStrict");return yv(n.shape,r.shape,"Error in greaterStrict: "),n.greater(r)}}),bC=ty({lessEqualStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","lessEqualStrict"),r=Ug(e,"b","lessEqualStrict");return yv(n.shape,r.shape,"Error in lessEqualStrict: "),n.lessEqual(r)}}),xC=ty({lessStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","lessStrict"),r=Ug(e,"b","lessStrict");return yv(n.shape,r.shape,"Error in lessStrict: "),n.less(r)}}),wC=ty({notEqualStrict_:function(t,e){Sb("strict variants of ops have been deprecated and will be removed in future");var n=Ug(t,"a","notEqualStrict"),r=Ug(e,"b","notEqualStrict");return yv(n.shape,r.shape,"Error in notEqualStrict: "),n.notEqual(r)}}),kC=1.0507009873554805;var SC=ty({elu_:function(t){var e=Ug(t,"x","elu");return Tg.runKernelFunc((function(t,n){var r=t.elu(e);return n([r]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){return Tg.runKernelFunc((function(e){return e.eluDer(t,n)}),{dy:t,y:n})}}}))}}),CC=ty({leakyRelu_:function(t,e){void 0===e&&(e=.2);var n=Ug(t,"x","leakyRelu");return vx(oy(e).mul(n),n)}}),RC=ty({prelu_:function(t,e){var n=Ug(t,"x","prelu"),r=Ug(e,"alpha","prelu");return Tg.runKernelFunc((function(t,e){var a=t.prelu(n,r);return e([n,r]),a}),{x:n,alpha:r},(function(t,e){var n=e[0],r=e[1],a=n.greater(0);return{x:function(){return hS(a,t,t.mul(r))},alpha:function(){var e=hS(a,xy(t),t.mul(n)),i=Lg(r.shape,t.shape);return i.length>0&&(e=e.sum(i)),e.reshape(r.shape)}}}),"Prelu")}}),NC=ty({relu_:function(t){var e=Ug(t,"x","relu");return"bool"===e.dtype?e.toInt():Tg.runKernelFunc((function(t,n){var r=t.relu(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0];return{x:function(){return kx(t,n.step().toFloat())}}}),"Relu")}}),EC=ty({relu6_:function(t){var e=Ug(t,"x","relu6");return"bool"===e.dtype?e.toInt():Tg.runKernelFunc((function(t,n){var r=t.relu6(e);return n([e]),r}),{x:e},(function(t,e){var n=e[0],r=n.lessEqual(6).mul(n.step());return{x:function(){return kx(t,r.toFloat())}}}),"Relu6")}}),IC=ty({selu_:function(t){var e=Ug(t,"x","selu");return Tg.runKernelFunc((function(t,n){var r=t.selu(e);return n([e]),r}),{$x:e},(function(t,e){var n=e[0];return{$x:function(){var e=n.greater(oy(0)),r=oy(1.7580993408473768),a=oy(kC),i=t.mul(a),o=t.mul(r).mul(n.toFloat().exp());return hS(e,i,o)}}}))}});var AC=ty({softmax_:function(t,e){void 0===e&&(e=-1);var n=Ug(t,"logits","softmax","float32");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and dim was "+e);return Tg.runKernelFunc((function(t,r){var a=t.softmax(n,e);return r([a]),a}),{logits:n},(function(t,n){var r=n[0],a=t.mul(r);return{logits:function(){return a.sub(a.sum([e],!0).mul(r))}}}),"Softmax",{dim:e},[],[!0])}}),TC=ty({logSoftmax_:function(t,e){void 0===e&&(e=-1);var n=Ug(t,"logits","logSoftmax");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and axis was "+e);return By((function(t,n){var r=t.max(e,!0),a=t.sub(r),i=a.toFloat().sub(a.exp().sum(e,!0).log());n([i]);return{value:i,gradFunc:function(t,n){var r=n[0].exp();return t.sub(t.sum(e,!0).mul(r))}}}))(n)}});var DC=ty({norm_:function(t,e,n,r){void 0===e&&(e="euclidean"),void 0===n&&(n=null),void 0===r&&(r=!1);var a=function t(e,n,r){void 0===r&&(r=null);if(0===e.rank)return e.abs();if(1!==e.rank&&null===r)return t(e.reshape([-1]),n,r);if(1===e.rank||"number"==typeof r||Array.isArray(r)&&1===r.length){if(1===n)return e.abs().sum(r);if(n===1/0)return e.abs().max(r);if(n===-1/0)return e.abs().min(r);if("euclidean"===n||2===n)return e.abs().pow(oy(2,"int32")).sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n)}if(Array.isArray(r)&&2===r.length){if(1===n)return e.abs().sum(r[0]).max(r[1]-1);if(n===1/0)return e.abs().sum(r[1]).max(r[0]);if(n===-1/0)return e.abs().sum(r[1]).min(r[0]);if("fro"===n||"euclidean"===n)return e.square().sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n)}throw new Error("Error in norm: invalid axis: "+r)}(t=Ug(t,"x","norm"),e,n),i=a.shape;if(r){var o=Av(n,t.shape);i=Kg(a.shape,o)}return a.reshape(i)}});var _C=ty({basicLSTMCell_:function(t,e,n,r,a,i){var o=Ug(t,"forgetBias","basicLSTMCell"),s=Ug(e,"lstmKernel","basicLSTMCell"),u=Ug(n,"lstmBias","basicLSTMCell"),c=Ug(r,"data","basicLSTMCell"),l=Ug(a,"c","basicLSTMCell"),h=Ug(i,"h","basicLSTMCell"),f=c.concat(h,1).matMul(s).add(u),p=f.shape[0],d=f.shape[1]/4,m=[p,d],v=f.slice([0,0],m),g=f.slice([0,d],m),y=f.slice([0,2*d],m),b=f.slice([0,3*d],m),x=v.sigmoid().mul(g.tanh()).add(l.mul(o.add(y).sigmoid())),w=x.tanh().mul(b.sigmoid());return[x,w]}}),OC=ty({multiRNNCell_:function(t,e,n,r){for(var a=Ug(e,"data","multiRNNCell"),i=jg(n,"c","multiRNNCell"),o=jg(r,"h","multiRNNCell"),s=a,u=[],c=0;c<t.length;c++){var l=t[c](s,i[c],o[c]);u.push(l[0]),u.push(l[1]),s=l[1]}for(var h=[],f=[],p=0;p<u.length;p+=2)h.push(u[p]),f.push(u[p+1]);return[h,f]}});var FC=ty({movingAverage_:function(t,e,n,r,a){void 0===a&&(a=!0);var i=Ug(t,"v","movingAverage"),o=Ug(e,"x","movingAverage"),s=Ug(n,"decay","movingAverage");Cg(i,o),gv(kv(i.shape,o.shape),(function(){return"Shape mismatch in v and x"}));var u=oy(1),c=u.sub(s),l=o.sub(i).mul(c);if(a){gv(null!=r,(function(){return"When using zeroDebias: true, step is required."}));var h=Ug(r,"step","movingAverage");l=l.div(u.sub(Cx(s,h)))}return i.add(l)}});var MC=ty({stridedSlice_:function(t,e,n,r,a,i,o,s,u){if(void 0===a&&(a=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===u&&(u=0),null==r&&(r=new Array(e.length)),0!==o)throw new Error("ellipsis mask is not yet supported");var c=Ug(t,"x","stridedSlice"),l=Jx(s),h=c.shape.slice();l.forEach((function(t){e[t]=0,n[t]=1,h.splice(t,0,1)})),c=c.reshape(h);for(var f=0;f<c.rank;f++)e[f]=Zx(a,e,r,c.shape,f),n[f]=Qx(i,n,r,c.shape,f),r[f]=r[f]||1;var p=Jx(u);p.forEach((function(t){n[t]=e[t]+1,r[t]=1}));var d=$x(e,n,r),m=d.filter((function(t,e){return-1===p.indexOf(e)}));return r.every((function(t){return 1===t}))?rw(c,e,d).reshape(m):Tg.runKernelFunc((function(t){return t.stridedSlice(c,e,n,r)}),{$x:c}).reshape(m)}});var LC=ty({topk_:function(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!0);var r=Ug(t,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");var a=r.shape[r.shape.length-1];if(e>a)throw new Error("'k' passed to topk() must be <= the last dimension ("+a+") but got "+e);var i=Tg.runKernelFunc((function(t){return t.topk(r,e,n)}),{$x:r});return{values:i[0],indices:i[1]}}});var zC=ty({scatterND_:function(t,e,n){var r=Ug(t,"indices","scatterND","int32"),a=Ug(e,"updates","scatterND");return Ak(a,r,n),Tg.runKernelFunc((function(t){return t.scatterND(r,a,n)}),{indices:r,updates:a},null,"ScatterNd",{shape:n})}});var BC=ty({fft_:function(t){gv("complex64"===t.dtype,(function(){return"The dtype for tf.spectral.fft() must be complex64 but got "+t.dtype+"."}));var e=t.shape[t.shape.length-1],n=t.size/e,r=t.as2D(n,e);return Tg.runKernelFunc((function(t){return t.fft(r)}),{input:t}).reshape(t.shape)}}),PC=ty({ifft_:function(t){gv("complex64"===t.dtype,(function(){return"The dtype for tf.spectral.ifft() must be complex64 but got "+t.dtype+"."}));var e=t.shape[t.shape.length-1],n=t.size/e,r=t.as2D(n,e);return Tg.runKernelFunc((function(t){return t.ifft(r)}),{input:t}).reshape(t.shape)}}),WC=ty({rfft_:function(t,e){gv("float32"===t.dtype,(function(){return"The dtype for rfft() must be real value but got "+t.dtype}));var n,r=t.shape[t.shape.length-1],a=t.size/r;if(null!=e&&e<r){var i=t.shape.map((function(t){return 0})),o=t.shape.map((function(t){return t}));o[t.shape.length-1]=e,n=t.slice(i,o),r=e}else if(null!=e&&e>r){var s=t.shape.map((function(t){return t}));s[t.shape.length-1]=e-r,n=t.concat(my(s),t.shape.length-1),r=e}else n=t;var u=n.zerosLike(),c=ey(n,u).as2D(a,r),l=BC(c),h=Math.floor(r/2)+1,f=ny(l),p=ry(l),d=f.split([h,r-h],f.shape.length-1),m=p.split([h,r-h],p.shape.length-1),v=n.shape.slice();return v[n.shape.length-1]=h,ey(d[0],m[0]).reshape(v)}}),VC=ty({irfft_:function(t){var e=t.shape[t.shape.length-1],n=t.size/e;if(e<=2){var r=t.as2D(n,e),a=PC(r);return ny(a)}var i=[n,2*(e-1)],o=ny(t).as2D(n,e),s=ry(t).as2D(n,e),u=o.slice([0,1],[n,e-2]).reverse(1),c=s.slice([0,1],[n,e-2]).reverse(1).mul(oy(-1)),l=o.concat(u,1),h=s.concat(c,1),f=ey(l,h).as2D(i[0],i[1]),p=PC(f);return ny(p)}}),UC={__proto__:null,fft:BC,ifft:PC,rfft:WC,irfft:VC};var jC=ty({sparseToDense_:function(t,e,n,r){void 0===r&&(r=0);var a=Ug(t,"sparseIndices","sparseToDense","int32"),i=Ug(e,"sparseValues","sparseToDense"),o=Ug(r,"defaultValue","sparseToDense",i.dtype);return function(t,e,n,r){if("int32"!==t.dtype)throw new Error("tf.sparseToDense() expects the indices to be int32 type, but the dtype was "+t.dtype+".");if(t.rank>2)throw new Error("sparseIndices should be a scalar, vector, or matrix, but got shape "+t.shape+".");var a=t.rank>0?t.shape[0]:1,i=t.rank>1?t.shape[1]:1;if(n.length!==i)throw new Error("outputShape has incorrect number of elements:, "+n.length+", should be: "+i+".");var o=e.size;if(0!==e.rank&&(1!==e.rank||o!==a))throw new Error("sparseValues has incorrect shape "+e.shape+", should be [] or ["+a+"]");if(e.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,i,n,o),Tg.runKernelFunc((function(t){return t.sparseToDense(a,i,n,o)}),{$sparseIndices:a,$sparseValues:i,$defaultValue:o})}});var GC=ty({gatherND_:function(t,e){var n=Ug(e,"indices","gatherND","int32"),r=Ug(t,"x","gatherND");return Tg.runKernelFunc((function(t){return t.gatherND(r,n)}),{x:r,indices:n},null,"GatherNd")}});var qC=ty({dropout_:function(t,e,n,r){var a=Ug(t,"x","dropout");if(gv("float32"===a.dtype,(function(){return"x has to be a floating point tensor since it's going to be scaled, but got a "+a.dtype+" tensor instead."})),gv(e>=0&&e<1,(function(){return"rate must be a float in the range [0, 1), but got "+e+"."})),0===e)return t instanceof pg?a.clone():a;var i=function(t,e){if(null==e)return t.shape.slice();if(kv(t.shape,e))return e;if(t.shape.length===e.length){for(var n=[],r=0;r<t.shape.length;r++)null==e[r]&&null!=t.shape[r]?n.push(t.shape[r]):n.push(e[r]);return n}return e}(a,n),o=1-e,s=GS(i,0,1,"float32",r).add(o).floor().div(o);return a.mul(s)}});function HC(t,e,n){for(var r=1-t%2,a=new Float32Array(t),i=0;i<t;++i){var o=2*Math.PI*i/(t+r-1);a[i]=e-n*Math.cos(o)}return sy(a,"float32")}var KC=ty({hannWindow_:function(t){return HC(t,.5,.5)}}),XC=ty({hammingWindow_:function(t){return HC(t,.54,.46)}}),YC=ty({frame_:function(t,e,n,r,a){void 0===r&&(r=!1),void 0===a&&(a=0);for(var i=0,o=[];i+e<=t.size;)o.push(rw(t,i,e)),i+=n;if(r)for(;i<t.size;){var s=i+e-t.size,u=wy([rw(t,i,e-s),vy([s],a)]);o.push(u),i+=n}return 0===o.length?uy([],[0,e]):wy(o).as2D(o.length,e)}}),JC=ty({stft_:function(t,e,n,r,a){var i;void 0===a&&(a=KC),null==r&&(i=e,r=Math.floor(Math.pow(2,Math.ceil(Math.log(i)/Math.log(2)))));for(var o=YC(t,e,n),s=kx(o,a(e)),u=[],c=0;c<o.shape[0];c++)u.push(WC(s.slice([c,0],[1,e]),r));return wy(u)}}),$C={__proto__:null,hannWindow:KC,hammingWindow:XC,frame:YC,stft:JC};function ZC(){return(ZC=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f,p,d,m,v,g;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=1),a=Ug(e,"predictions","inTopK"),i=Ug(n,"targets","inTopK"),gv(a.rank>1,(function(){return"inTopK() expects the predictions to be of rank 2 or higher, but got "+a.rank})),gv(a.rank-1===i.rank,(function(){return"predictions rank should be 1 larger than targets rank, but got predictions rank "+a.rank+" and targets rank "+i.rank})),yv(a.shape.slice(0,a.shape.length-1),i.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),o=a.shape[a.shape.length-1],gv(r>0&&r<=o,(function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last dimension ("+o+"), but got "+r})),t.next=10,a.data();case 10:return s=t.sent,t.next=13,i.data();case 13:u=t.sent,c=s.length/o,l=o,h=Dv("bool",c),f=0;case 17:if(!(f<c)){t.next=35;break}for(p=f*l,d=s.subarray(p,p+l),m=[],v=0;v<d.length;v++)m.push({value:d[v],index:v});m.sort((function(t,e){return e.value-t.value})),h[f]=0,g=0;case 25:if(!(g<r)){t.next=32;break}if(m[g].index!==u[f]){t.next=29;break}return h[f]=1,t.abrupt("break",32);case 29:g++,t.next=25;break;case 32:f++,t.next=17;break;case 35:return e!==a&&a.dispose(),n!==i&&i.dispose(),t.abrupt("return",ay(h,i.shape,"bool"));case 38:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var QC,tR=function(t,e,n){return ZC.apply(this,arguments)};(QC=t.Reduction||(t.Reduction={}))[QC.NONE=0]="NONE",QC[QC.MEAN=1]="MEAN",QC[QC.SUM=2]="SUM",QC[QC.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS";var eR=ty({absoluteDifference_:function(e,n,r,a){void 0===a&&(a=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=Ug(e,"labels","absoluteDifference"),o=Ug(n,"predictions","absoluteDifference"),s=null;null!=r&&(s=Ug(r,"weights","absoluteDifference")),yv(i.shape,o.shape,"Error in absoluteDifference: ");var u=i.sub(o).abs();return nR(u,s,a)}}),nR=ty({computeWeightedLoss_:function(e,n,r){void 0===r&&(r=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=Ug(e,"losses","computeWeightedLoss"),i=null;null!=n&&(i=Ug(n,"weights","computeWeightedLoss"));var o=null==i?a:a.mul(i);if(r===t.Reduction.NONE)return o;if(r===t.Reduction.SUM)return o.sum();if(r===t.Reduction.MEAN){if(null==i)return o.mean();var s=a.size/i.size,u=o.sum().div(i.sum());return s>1?u.div(oy(s)):u}if(r===t.Reduction.SUM_BY_NONZERO_WEIGHTS){if(null==i)return o.sum().div(oy(a.size));var c=i.mul(dy(a.shape)).notEqual(oy(0)).sum().toFloat();return o.sum().div(c)}throw Error("Unknown reduction: "+r)}}),rR=ty({cosineDistance_:function(e,n,r,a,i){void 0===i&&(i=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=Ug(e,"labels","cosineDistance"),s=Ug(n,"predictions","cosineDistance"),u=null;null!=a&&(u=Ug(a,"weights","cosineDistance")),yv(o.shape,s.shape,"Error in cosineDistance: ");var c=oy(1).sub(o.mul(s).sum(r,!0));return nR(c,u,i)}}),aR=ty({hingeLoss_:function(e,n,r,a){void 0===a&&(a=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=Ug(e,"labels","hingeLoss"),o=Ug(n,"predictions","hingeLoss"),s=null;null!=r&&(s=Ug(r,"weights","hingeLoss")),yv(i.shape,o.shape,"Error in hingeLoss: ");var u=oy(1);i=oy(2).mul(i).sub(u);var c=u.sub(i.mul(o)).relu();return nR(c,s,a)}}),iR=ty({huberLoss_:function(e,n,r,a,i){void 0===a&&(a=1),void 0===i&&(i=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=Ug(e,"labels","huberLoss"),s=Ug(n,"predictions","huberLoss"),u=null;null!=r&&(u=Ug(r,"weights","huberLoss")),yv(o.shape,s.shape,"Error in huberLoss: ");var c=oy(a),l=s.sub(o).abs(),h=yx(l,c),f=l.sub(h),p=oy(.5).mul(h.square()).add(c.mul(f));return nR(p,u,i)}}),oR=ty({logLoss_:function(e,n,r,a,i){void 0===a&&(a=1e-7),void 0===i&&(i=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=Ug(e,"labels","logLoss"),s=Ug(n,"predictions","logLoss"),u=null;null!=r&&(u=Ug(r,"weights","logLoss")),yv(o.shape,s.shape,"Error in logLoss: ");var c=oy(1),l=oy(a),h=o.mul(s.add(l).log()).neg().sub(c.sub(o).mul(c.sub(s).add(l).log()));return nR(h,u,i)}}),sR=ty({meanSquaredError_:function(e,n,r,a){void 0===a&&(a=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=Ug(e,"labels","meanSquaredError"),o=Ug(n,"predictions","meanSquaredError"),s=null;null!=r&&(s=Ug(r,"weights","meanSquaredError")),yv(i.shape,o.shape,"Error in meanSquaredError: ");var u=i.squaredDifference(o);return nR(u,s,a)}}),uR=ty({sigmoidCrossEntropy_:function(e,n,r,a,i){void 0===a&&(a=0),void 0===i&&(i=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=Ug(e,"multiClassLabels","sigmoidCrossEntropy"),s=Ug(n,"logits","sigmoidCrossEntropy"),u=null;if(null!=r&&(u=Ug(r,"weights","sigmoidCrossEntropy")),yv(o.shape,s.shape,"Error in sigmoidCrossEntropy: "),a>0){var c=oy(a),l=oy(1),h=oy(.5);o=o.mul(l.sub(c)).add(h.mul(c))}var f=function(t,e){var n=Ug(t,"labels","sigmoidCrossEntropyWithLogits"),r=Ug(e,"logits","sigmoidCrossEntropyWithLogits");yv(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var a=r.relu(),i=r.mul(n),o=r.abs().neg().exp().log1p();return a.sub(i).add(o)}(o,s);return nR(f,u,i)}}),cR=ty({softmaxCrossEntropy_:function(e,n,r,a,i){void 0===a&&(a=0),void 0===i&&(i=t.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=Ug(e,"onehotLabels","softmaxCrossEntropy"),s=Ug(n,"logits","softmaxCrossEntropy"),u=null;if(null!=r&&(u=Ug(r,"weights","softmaxCrossEntropy")),yv(o.shape,s.shape,"Error in softmaxCrossEntropy: "),a>0){var c=oy(a),l=oy(1),h=oy(o.shape[1]);o=o.mul(l.sub(c)).add(c.div(h))}var f=function(t,e,n){if(void 0===n&&(n=-1),-1===n&&(n=e.rank-1),n!==e.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank "+e.rank+" and dim was "+n);return By((function(t,e,r){var a=e.logSumExp([n],!0),i=e.toFloat().sub(a);r([t,i]);return{value:i.mul(t).neg().sum([n]),gradFunc:function(t,e){var r=e[0],a=e[1],i=Kg(t.shape,[n]);return[t.reshape(i).mul(r.toFloat().sub(a.exp())),t.reshape(i).mul(a.exp().sub(r.toFloat()))]}}}))(t,e)}(o,s);return nR(f,u,i)}}),lR={__proto__:null,get Reduction(){return t.Reduction},absoluteDifference:eR,computeWeightedLoss:nR,cosineDistance:rR,hingeLoss:aR,huberLoss:iR,logLoss:oR,meanSquaredError:sR,sigmoidCrossEntropy:uR,softmaxCrossEntropy:cR};function hR(t,e){return void 0===e&&(e=!1),Tg.tidy((function(){if(2!==t.shape.length)throw new Error("qr2d() requires a 2D Tensor, but got a "+t.shape.length+"D Tensor.");for(var n=t.shape[0],r=t.shape[1],a=vS(n),i=t.clone(),o=uy([[1]],[1,1]),s=o.clone(),u=n>=r?r:n,c=function(t){var e=i,u=s,c=a,l=Tg.tidy((function(){var e=i.slice([t,t],[n-t,1]),u=e.norm(),c=i.slice([t,t],[1,1]),l=uy([[-1]]).where(c.greater(0),uy([[1]])),h=c.sub(l.mul(u)),f=e.div(h);s=1===f.shape[0]?o.clone():o.concat(f.slice([1,0],[f.shape[0]-1,f.shape[1]]),0);var p=l.matMul(h).div(u).neg(),d=i.slice([t,0],[n-t,r]),m=p.mul(s),v=s.transpose();if(0===t)i=d.sub(m.matMul(v.matMul(d)));else{var g=d.sub(m.matMul(v.matMul(d)));i=i.slice([0,0],[t,r]).concat(g,0)}var y=m.transpose(),b=a.slice([0,t],[n,a.shape[1]-t]);if(0===t)a=b.sub(b.matMul(s).matMul(y));else{var x=b.sub(b.matMul(s).matMul(y));a=a.slice([0,0],[n,t]).concat(x,1)}return[s,i,a]}));s=l[0],i=l[1],a=l[2],Eb([e,u,c])},l=0;l<u;++l)c(l);return!e&&n>r&&(a=a.slice([0,0],[n,r]),i=i.slice([0,0],[r,r])),[a,i]}))}var fR=ty({bandPart_:function(t,e,n){if(e%1!=0)throw new Error("bandPart(): numLower must be an integer, got "+e+".");if(n%1!=0)throw new Error("bandPart(): numUpper must be an integer, got "+n+".");var r=Ug(t,"a","bandPart");if(r.rank<2)throw new Error("bandPart(): Rank must be at least 2, got "+r.rank+".");var a=r.shape,i=r.shape.slice(-2),o=i[0],s=i[1];if(!(e<=o))throw new Error("bandPart(): numLower ("+e+") must not be greater than the number of rows ("+o+").");if(!(n<=s))throw new Error("bandPart(): numUpper ("+n+") must not be greater than the number of columns ("+s+").");e<0&&(e=o),n<0&&(n=s);var u=yy(0,o,1,"int32").reshape([-1,1]),c=yy(0,s,1,"int32"),l=Dx(u,c),h=sS(l.lessEqual(oy(+e,"int32")),l.greaterEqual(oy(-n,"int32"))),f=my([o,s],r.dtype);return Ty(Dy(r.reshape([-1,o,s])).map((function(t){return hS(h,t,f)}))).reshape(a)}}),pR=ty({gramSchmidt_:function(t){var e;Array.isArray(t)?function(){e=!1,gv(null!=t&&t.length>0,(function(){return"Gram-Schmidt process: input must not be null, undefined, or empty"}));for(var n=t[0].shape[0],r=function(e){gv(t[e].shape[0]===n,(function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: ("+t[e].shape[0]+" vs. "+n+")"}))},a=1;a<t.length;++a)r(a)}():(e=!0,t=Zy(t,t.shape[0],0).map((function(t){return Ay(t,[0])}))),gv(t.length<=t[0].shape[0],(function(){return"Gram-Schmidt: Number of vectors ("+t.length+") exceeds number of dimensions ("+t[0].shape[0]+")."}));for(var n=[],r=t,a=function(t){n.push(Tg.tidy((function(){var e=r[t];if(t>0)for(var a=0;a<t;++a){var i=Yy(n[a].mul(e)).mul(n[a]);e=e.sub(i)}return e.div(DC(e,"euclidean"))})))},i=0;i<t.length;++i)a(i);return e?Ty(n,0):n}}),dR=ty({qr_:function(t,e){if(void 0===e&&(e=!1),t.rank<2)throw new Error("qr() requires input tensor to have a rank >= 2, but got rank "+t.rank);if(2===t.rank)return hR(t,e);var n=t.shape.slice(0,t.shape.length-2).reduce((function(t,e){return t*e})),r=Dy(t.reshape([n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),a=[],i=[];return r.forEach((function(t){var n=hR(t,e),r=n[0],o=n[1];a.push(r),i.push(o)})),[Ty(a,0).reshape(t.shape),Ty(i,0).reshape(t.shape)]}}),mR={__proto__:null,bandPart:fR,gramSchmidt:pR,qr:dR};function vR(t,e,n){var r=function(t,e,n){return function(t,e,n){var r=0,a=t.length,i=0,o=!1;for(;r<a;){var s=n(e,t[i=r+(a-r>>>1)]);s>0?r=i+1:(a=i,o=!s)}return o?r:-r-1}(t,e,n||gR)}(t,e,n),a=r<0?-(r+1):r;t.splice(a,0,e)}function gR(t,e){return t>e?1:t<e?-1:0}function yR(t,e,n,r,a){var i=xR(t,e,n,r,a,0);return i.selectedScores.dispose(),i.numValidOutputs.dispose(),i.selectedIndices}function bR(t,e,n,r,a,i){var o=xR(t,e,n,r,a,i);return o.numValidOutputs.dispose(),{selectedIndices:o.selectedIndices,selectedScores:o.selectedScores}}function xR(t,e,n,r,a,i,o,s){void 0===s&&(s=!1);for(var u=Array.from(e).map((function(t,e){return{score:t,boxIndex:e,suppressBeginIndex:0}})).filter((function(t){return t.score>a})).sort(SR),c=i>0?-.5/i:0,l=[],h=[];l.length<n&&u.length>0;){var f=u.pop(),p=f.score,d=f.boxIndex,m=f.suppressBeginIndex;if(p<a)break;for(var v=!1,g=l.length-1;g>=m;--g){var y=wR(t,d,l[g]);if(y>=r){v=!0;break}if(f.score=f.score*kR(r,c,y),f.score<=a)break}f.suppressBeginIndex=l.length,v||(f.score===p?(l.push(d),h.push(f.score)):f.score>a&&vR(u,f,SR))}var b=l.length;return s&&(l.fill(0,b),h.fill(0,b)),{selectedIndices:sy(l,"int32"),selectedScores:sy(h,"float32"),numValidOutputs:oy(b,"int32")}}function wR(t,e,n){var r=t.subarray(4*e,4*e+4),a=t.subarray(4*n,4*n+4),i=Math.min(r[0],r[2]),o=Math.min(r[1],r[3]),s=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),c=Math.min(a[0],a[2]),l=Math.min(a[1],a[3]),h=Math.max(a[0],a[2]),f=Math.max(a[1],a[3]),p=(s-i)*(u-o),d=(h-c)*(f-l);if(p<=0||d<=0)return 0;var m=Math.max(i,c),v=Math.max(o,l),g=Math.min(s,h),y=Math.min(u,f),b=Math.max(g-m,0)*Math.max(y-v,0);return b/(p+d-b)}function kR(t,e,n){var r=Math.exp(e*n*n);return n<=t?r:0}function SR(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}function CR(t,e,n,r,a,i){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==i&&(i=0);var o=t.shape[0];return n=Math.min(n,o),gv(0<=r&&r<=1,(function(){return"iouThreshold must be in [0, 1], but was '"+r+"'"})),gv(2===t.rank,(function(){return"boxes must be a 2D tensor, but was of rank '"+t.rank+"'"})),gv(4===t.shape[1],(function(){return"boxes must have 4 columns, but 2nd dimension was "+t.shape[1]})),gv(1===e.rank,(function(){return"scores must be a 1D tensor"})),gv(e.shape[0]===o,(function(){return"scores has incompatible shape with boxes. Expected "+o+", but was "+e.shape[0]})),gv(0<=i&&i<=1,(function(){return"softNmsSigma must be in [0, 1], but was '"+i+"'"})),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}var RR=ty({nonMaxSuppression_:function(t,e,n,r,a){void 0===r&&(r=.5),void 0===a&&(a=Number.NEGATIVE_INFINITY);var i=Ug(t,"boxes","nonMaxSuppression"),o=Ug(e,"scores","nonMaxSuppression"),s=CR(i,o,n,r,a);n=s.maxOutputSize,r=s.iouThreshold,a=s.scoreThreshold;var u={maxOutputSize:n,iouThreshold:r,scoreThreshold:a};return Tg.runKernelFunc((function(t){return t.nonMaxSuppression(i,o,n,r,a)}),{boxes:i,scores:o},null,"NonMaxSuppressionV3",u)}});function NR(){return(NR=Vm(regeneratorRuntime.mark((function t(e,n,r,a,i){var o,s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),o=Ug(e,"boxes","nonMaxSuppressionAsync"),s=Ug(n,"scores","nonMaxSuppressionAsync"),u=CR(o,s,r,a,i),r=u.maxOutputSize,a=u.iouThreshold,i=u.scoreThreshold,t.next=10,Promise.all([o.data(),s.data()]);case 10:return c=t.sent,l=c[0],h=c[1],f=yR(l,h,r,a,i),o!==e&&o.dispose(),s!==n&&s.dispose(),t.abrupt("return",f);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ER(){return(ER=Vm(regeneratorRuntime.mark((function t(e,n,r,a,i,o){var s,u,c,l,h,f,p;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=0),s=Ug(e,"boxes","nonMaxSuppressionAsync"),u=Ug(n,"scores","nonMaxSuppressionAsync"),c=CR(s,u,r,a,i,o),r=c.maxOutputSize,a=c.iouThreshold,i=c.scoreThreshold,o=c.softNmsSigma,t.next=12,Promise.all([s.data(),u.data()]);case 12:return l=t.sent,h=l[0],f=l[1],p=bR(h,f,r,a,i,o),s!==e&&s.dispose(),u!==n&&u.dispose(),t.abrupt("return",p);case 19:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var IR=ty({resizeBilinear_:function(t,e,n){void 0===n&&(n=!1);var r=Ug(t,"images","resizeBilinear");gv(3===r.rank||4===r.rank,(function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got rank "+r.rank+"."})),gv(2===e.length,(function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+e+"."}));var a=r,i=!1;3===r.rank&&(i=!0,a=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var o=e[0],s=e[1],u=Tg.runKernelFunc((function(t,e){return e([a]),t.resizeBilinear(a,o,s,n)}),{x:a},(function(t,e){return{x:function(){return Tg.runKernelFunc((function(r){return r.resizeBilinearBackprop(t,e[0],n)}),{})}}}),"ResizeBilinear",{alignCorners:n,newHeight:o,newWidth:s});return i?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u}}),AR=ty({resizeNearestNeighbor_:function(t,e,n){void 0===n&&(n=!1);var r=Ug(t,"images","resizeNearestNeighbor");gv(3===r.rank||4===r.rank,(function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank "+r.rank+"."})),gv(2===e.length,(function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+e+"."})),gv("float32"===r.dtype||"int32"===r.dtype,(function(){return"`images` must have `int32` or `float32` as dtype"}));var a=r,i=!1;3===r.rank&&(i=!0,a=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var o=e[0],s=e[1],u=Tg.runKernelFunc((function(t,e){return e([a]),t.resizeNearestNeighbor(a,o,s,n)}),{batchImages:a},(function(t,e){return{batchImages:function(){return Tg.runKernelFunc((function(r){return r.resizeNearestNeighborBackprop(t,e[0],n)}),{})}}}));return i?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u}}),TR=function(t,e,n,r,a){return NR.apply(this,arguments)},DR=ty({nonMaxSuppressionWithScore_:function(t,e,n,r,a,i){void 0===r&&(r=.5),void 0===a&&(a=Number.NEGATIVE_INFINITY),void 0===i&&(i=0);var o=Ug(t,"boxes","nonMaxSuppression"),s=Ug(e,"scores","nonMaxSuppression"),u=CR(o,s,n,r,a,i),c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:i=u.softNmsSigma},l=Tg.runKernel("NonMaxSuppressionV5",{boxes:o,scores:s},c);return{selectedIndices:l[0],selectedScores:l[1]}}}),_R=function(t,e,n,r,a,i){return ER.apply(this,arguments)},OR=ty({cropAndResize_:function(t,e,n,r,a,i){var o=Ug(t,"image","cropAndResize"),s=Ug(e,"boxes","cropAndResize","float32"),u=Ug(n,"boxInd","cropAndResize","int32");a=a||"bilinear",i=i||0;var c=s.shape[0];return gv(4===o.rank,(function(){return"Error in cropAndResize: image must be rank 4,but got rank "+o.rank+"."})),gv(2===s.rank&&4===s.shape[1],(function(){return"Error in cropAndResize: boxes must be have size ["+c+",4] but had shape "+s.shape+"."})),gv(1===u.rank&&u.shape[0]===c,(function(){return"Error in cropAndResize: boxInd must be have size ["+c+"] but had shape "+s.shape+"."})),gv(2===r.length,(function(){return"Error in cropAndResize: cropSize must be of length 2, but got length "+r.length+"."})),gv(r[0]>=1&&r[1]>=1,(function(){return"cropSize must be atleast [1,1], but was "+r})),gv("bilinear"===a||"nearest"===a,(function(){return"method must be bilinear or nearest, but was "+a})),Tg.runKernelFunc((function(t,e){return t.cropAndResize(o,s,u,r,a,i)}),{images:o,boxes:s,boxInd:u},null,"CropAndResize",{method:a,extrapolationValue:i,cropSize:r})}}),FR={__proto__:null,resizeBilinear:IR,resizeNearestNeighbor:AR,nonMaxSuppressionAsync:TR,nonMaxSuppressionWithScore:DR,nonMaxSuppressionWithScoreAsync:_R,cropAndResize:OR,nonMaxSuppression:RR},MR=function(t,e){return!(t>0)||"linear"===e},LR=function(t,e,n){if(null==n||"linear"===n)return t;if("relu"===n)return t.mul(e.step());throw new Error("Gradient for activation "+n+" has not been implemented yet.")},zR=function(t,e){var n=e,r=Lg(t.shape,e.shape);return r.length>0&&(n=n.sum(r)),n.reshape(t.shape)},BR=function(t,e,n){if("linear"===e)return t;if("relu"===e)return NC(t);if("elu"===e)return SC(t);if("relu6"===e)return EC(t);if("prelu"===e)return RC(t,n);throw new Error("Unknown fused activation "+e+".")};var PR=ty({fusedMatMul_:function(t){var e=t.a,n=t.b,r=t.transposeA,a=void 0!==r&&r,i=t.transposeB,o=void 0!==i&&i,s=t.bias,u=t.activation,c=void 0===u?"linear":u,l=t.preluActivationWeights;if(!1===MR(Tg.state.gradientDepth,c)){var h=Oy(e,n,a,o);return null!=s&&(h=Db(h,s)),BR(h,c,l)}var f=Ug(e,"a","fused matMul"),p=Ug(n,"b","fused matMul"),d=Sg(f,p);f=d[0],p=d[1];var m=a?f.shape[f.rank-2]:f.shape[f.rank-1],v=o?p.shape[p.rank-1]:p.shape[p.rank-2],g=a?f.shape[f.rank-1]:f.shape[f.rank-2],y=o?p.shape[p.rank-2]:p.shape[p.rank-1],b=f.shape.slice(0,-2),x=p.shape.slice(0,-2),w=wv(b),k=wv(x);gv(f.rank>=2&&p.rank>=2&&f.rank===p.rank,(function(){return"Error in fused matMul: inputs must have the same rank of at least 2, got ranks "+f.rank+" and "+p.rank+"."})),gv(kv(b,x),(function(){return"Error in fused matMul: outer dimensions ("+b+") and ("+x+") of Tensors with shapes "+f.shape+" and "+p.shape+" must match."})),gv(m===v,(function(){return"Error in fused matMul: inner shapes ("+m+") and ("+v+") of Tensors with shapes "+f.shape+" and "+p.shape+" and transposeA="+a+" and transposeB="+o+" must match."}));var S,C,R=f.shape.slice(0,-2).concat([g,y]),N=a?f.as3D(w,m,g):f.as3D(w,g,m),E=o?p.as3D(k,y,v):p.as3D(k,v,y);if(null!=s){var I=Sg(S=Ug(s,"bias","fused matMul"),f);zg(R,(S=I[0]).shape)}null!=l&&(C=Ug(l,"prelu weights","fused matMul"));var A={a:N,b:E};null!=s&&(A.bias=S),null!=l&&(A.preluActivationWeights=C);var T=[N,E];return Tg.runKernelFunc((function(t,e){var n=t.fusedBatchMatMul({a:N,b:E,transposeA:a,transposeB:o,bias:S,activation:c,preluActivationWeights:C});return e([N,E,n]),n}),A,(function(t,e){var n=e[0],r=e[1],i=e[2],u=LR(t,i,c),l={};return null!=s&&(l={bias:function(){return zR(S,u)}}),a||o?!a&&o?Object.assign({a:function(){return u.matMul(r,!1,!1)},b:function(){return u.matMul(n,!0,!1)}},l):a&&!o?Object.assign({a:function(){return r.matMul(u,!1,!0)},b:function(){return n.matMul(u,!1,!1)}},l):Object.assign({a:function(){return r.matMul(u,!0,!0)},b:function(){return u.matMul(n,!0,!0)}},l):Object.assign({a:function(){return u.matMul(r,!1,!0)},b:function(){return n.matMul(u,!0,!1)}},l)}),"_FusedMatMul",{transposeA:a,transposeB:o,activation:c},T,[!0]).reshape(R)}}),WR=ty({fusedConv2d_:function(t){var e=t.x,n=t.filter,r=t.strides,a=t.pad,i=t.dataFormat,o=void 0===i?"NHWC":i,s=t.dilations,u=void 0===s?[1,1]:s,c=t.dimRoundingMode,l=t.bias,h=t.activation,f=void 0===h?"linear":h,p=t.preluActivationWeights;if(f=f||"linear",!1===MR(Tg.state.gradientDepth,f)){var d=mb(e,n,r,a,o,u,c);return null!=l&&(d=Db(d,l)),BR(d,f,p)}var m=Ug(e,"x","conv2d"),v=Ug(n,"filter","conv2d"),g=m,y=!1;3===m.rank&&(y=!0,g=m.as4D(1,m.shape[0],m.shape[1],m.shape[2])),gv(4===g.rank,(function(){return"Error in fused conv2d: input must be rank 4, but got rank "+g.rank+"."})),gv(4===v.rank,(function(){return"Error in fused conv2d: filter must be rank 4, but got rank "+v.rank+"."})),null!=c&&gv(Sv(a),(function(){return"Error in fused conv2d: pad must be an integer when using, dimRoundingMode "+c+" but got pad "+a+"."})),gv(g.shape[3]===v.shape[2],(function(){return"Error in conv2d: depth of input ("+g.shape[3]+") must match input depth for filter "+v.shape[2]+"."})),gv(lb(r,u),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),gv("NHWC"===o,(function(){return"Error in conv2d: got dataFormat of "+o+" but only NHWC is currently supported."}));var b,x,w=nb(g.shape,v.shape,r,u,a,c);if(null!=l){var k=Sg(b=Ug(l,"bias","fused conv2d"),m);b=k[0],zg(w.outShape,b.shape)}null!=p&&(x=Ug(p,"prelu weights","fused conv2d"));var S={x:g,filter:v};null!=l&&(S.bias=b),null!=p&&(S.preluActivationWeights=x);var C=[v,g],R=Tg.runKernelFunc((function(t,e){var n=t.fusedConv2d({input:g,filter:v,convInfo:w,bias:b,activation:f,preluActivationWeights:x});return e([v,g,n]),n}),S,(function(t,e){var n=e[0],i=e[1],o=e[2],s=LR(t,o,f);gv(cb(u),(function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+u+"'"}));var c={};return null!=l&&(c={bias:function(){return zR(b,s)}}),Object.assign({x:function(){return pb(i.shape,s,n,r,a)},filter:function(){return fb(i,s,n.shape,r,a)}},c)}),"FusedConv2D",{convInfo:w,activation:f},C,[!0]);return y?R.as3D(R.shape[1],R.shape[2],R.shape[3]):R}}),VR=ty({fusedDepthwiseConv2d_:function(t){var e=t.x,n=t.filter,r=t.strides,a=t.pad,i=t.dataFormat,o=void 0===i?"NHWC":i,s=t.dilations,u=void 0===s?[1,1]:s,c=t.dimRoundingMode,l=t.bias,h=t.activation,f=void 0===h?"linear":h,p=t.preluActivationWeights;if(!1===MR(Tg.state.gradientDepth,f)){var d=rS(e,n,r,a,o,u,c);return null!=l&&(d=Db(d,l)),BR(d,f,p)}var m=Ug(e,"x","depthwiseConv2d"),v=Ug(n,"filter","depthwiseConv2d"),g=m,y=!1;3===m.rank&&(y=!0,g=m.as4D(1,m.shape[0],m.shape[1],m.shape[2])),gv(4===g.rank,(function(){return"Error in fused depthwiseConv2d: input must be rank 4, but got rank "+g.rank+"."})),gv(4===v.rank,(function(){return"Error in fused depthwiseConv2d: filter must be rank 4, but got rank "+v.rank+"."})),gv(g.shape[3]===v.shape[2],(function(){return"Error in fused depthwiseConv2d: number of input channels ("+g.shape[3]+") must match the inChannels dimension in filter "+v.shape[2]+"."})),null==u&&(u=[1,1]),gv(lb(r,u),(function(){return"Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),null!=c&&gv(Sv(a),(function(){return"Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode "+c+" but got pad "+a+"."}));var b,x,w=nb(g.shape,v.shape,r,u,a,c,!0);if(null!=l){var k=Sg(b=Ug(l,"bias","fused conv2d"),m);b=k[0],zg(w.outShape,b.shape)}null!=p&&(x=Ug(p,"prelu weights","fused depthwiseConv2d"));var S={x:g,filter:v};null!=l&&(S.bias=b),null!=p&&(S.preluActivationWeights=x);var C=[v,g],R=Tg.runKernelFunc((function(t,e){var n=t.fusedDepthwiseConv2D({input:g,filter:v,convInfo:w,bias:b,activation:f,preluActivationWeights:x});return e([v,g,n]),n}),S,(function(t,e){gv(cb(u),(function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+u+"'"}));var n=e[0],r=e[1],a=e[2],i=LR(t,a,f),o={};return null!=l&&(o={bias:function(){return zR(b,i)}}),Object.assign({x:function(){return wb(r.shape,i,n,w)},filter:function(){return xb(r,i,n.shape,w)}},o)}),"FusedDepthwiseConv2D",{convInfo:w,activation:f},C,[!0]);return y?R.as3D(R.shape[1],R.shape[2],R.shape[3]):R}}),UR={__proto__:null,matMul:PR,conv2d:WR,depthwiseConv2d:VR},jR={__proto__:null,image:FR,linalg:mR,losses:lR,spectral:UC,fused:UR,signal:$C,add:Db,addN:Wk,batchToSpaceND:Ux,batchNorm:Uk,batchNorm2d:jk,batchNorm3d:Gk,batchNorm4d:qk,broadcastTo:Kk,clone:Hk,concat:wy,concat1d:Xk,concat2d:Yk,concat3d:Jk,concat4d:$k,conv1d:Zk,conv2d:mb,conv2dTranspose:Qk,conv3d:tS,conv3dTranspose:eS,depthToSpace:nS,depthwiseConv2d:rS,diag:aS,div:Ix,divNoNan:pS,dot:dS,equal:mS,eye:vS,greater:gS,greaterEqual:yS,less:bS,lessEqual:xS,localResponseNormalization:wS,matMul:Oy,max:kS,multinomial:SS,notEqual:CS,oneHot:xk,outerProduct:RS,pad:Xx,pad1d:NS,pad2d:ES,pad3d:IS,pad4d:AS,rand:TS,randomGamma:US,randomNormal:jS,randomUniform:GS,separableConv2d:qS,spaceToBatchND:My,split:Zy,square:Ax,squaredDifference:HS,sub:Dx,tile:_x,truncatedNormal:KS,op:ty,booleanMaskAsync:nC,complex:ey,real:ny,imag:ry,reverse:rC,reverse1d:aC,reverse2d:iC,reverse3d:oC,reverse4d:sC,maxPool:lC,avgPool:hC,pool:fC,maxPool3d:pC,avgPool3d:dC,maxPoolWithArgmax:mC,slice:rw,slice1d:aw,slice2d:iw,slice3d:ow,slice4d:sw,abs:_b,acos:Ob,acosh:Fb,asin:Mb,asinh:Lb,atan:zb,atanh:Bb,ceil:Pb,clipByValue:Wb,cos:Vb,cosh:Ub,erf:jb,exp:Gb,expm1:qb,floor:Hb,log:Kb,log1p:Xb,logSigmoid:Yb,neg:Jb,reciprocal:$b,round:Zb,rsqrt:Qb,sigmoid:tx,sign:ex,isNaN:nx,isInf:rx,isFinite:ax,sin:ix,sinh:ox,softplus:sx,sqrt:ux,step:cx,tan:lx,tanh:hx,all:Vy,any:Uy,argMax:jy,argMin:Gy,logSumExp:qy,mean:Hy,min:Ky,moments:Xy,sum:Yy,prod:Jy,equalStrict:vC,greaterEqualStrict:gC,greaterStrict:yC,lessEqualStrict:bC,lessStrict:xC,notEqualStrict:wC,addStrict:fx,atan2:px,divStrict:dx,floorDiv:mx,maximum:vx,maximumStrict:gx,minimum:yx,minimumStrict:bx,mod:xx,modStrict:wx,mul:kx,mulStrict:Sx,pow:Cx,powStrict:Rx,squaredDifferenceStrict:Nx,subStrict:Ex,elu:SC,leakyRelu:CC,prelu:RC,relu:NC,relu6:EC,selu:IC,logicalAnd:sS,logicalNot:uS,logicalOr:cS,logicalXor:lS,where:hS,whereAsync:fS,buffer:Sy,print:Cy,cast:Ry,cumsum:Ny,expandDims:Ey,reshape:Iy,squeeze:Ay,stack:Ty,unstack:Dy,setdiff1dAsync:_y,fill:vy,linspace:gy,ones:dy,range:yy,scalar:oy,tensor:ay,tensor1d:sy,tensor2d:uy,tensor3d:cy,tensor4d:ly,tensor5d:hy,tensor6d:fy,variable:py,zeros:my,onesLike:by,zerosLike:xy,transpose:Bx,softmax:AC,logSoftmax:TC,norm:DC,gather:QS,unsortedSegmentSum:tC,basicLSTMCell:_C,multiRNNCell:OC,movingAverage:FC,stridedSlice:MC,topk:LC,scatterND:zC,fft:BC,ifft:PC,rfft:WC,irfft:VC,sparseToDense:jC,gatherND:GC,dropout:qC,hannWindow:KC,hammingWindow:XC,frame:YC,stft:JC,inTopKAsync:tR},GR=function(t){function e(){return t.apply(this,arguments)||this}Gm(e,t);var n=e.prototype;return n.minimize=function(t,e,n){void 0===e&&(e=!1);var r=this.computeGradients(t,n),a=r.value,i=r.grads;if(null!=n){var o=n.map((function(t){return{name:t.name,tensor:i[t.name]}}));this.applyGradients(o)}else this.applyGradients(i);return Eb(i),e?a:(a.dispose(),null)},n.incrementIterations=function(){this.iterations_=this.iterations+1},n.computeGradients=function(t,e){return zy(t,e)},n.dispose=function(){null!=this.iterations_&&Eb(this.iterations_)},n.saveIterations=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null==this.iterations_&&(this.iterations_=0),t.abrupt("return",{name:"iter",tensor:oy(this.iterations_,"int32")});case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw new Error("getWeights() is not implemented for this optimizer yet.");case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),n.setWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw new Error("setWeights() is not implemented for this optimizer class "+this.getClassName());case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.extractIterations=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e[0].tensor.data();case 2:return this.iterations_=t.sent[0],t.abrupt("return",e.slice(1));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),jm(e,[{key:"iterations",get:function(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}}]),e}(_k);Object.defineProperty(GR,Symbol.hasInstance,{value:function(t){return null!=t.minimize&&null!=t.computeGradients&&null!=t.applyGradients}});var qR=function(t){function e(e,n,r){var a;return void 0===r&&(r=null),(a=t.call(this)||this).learningRate=e,a.rho=n,a.epsilon=r,a.accumulatedGrads=[],a.accumulatedUpdates=[],null==r&&(a.epsilon=Tg.backend.epsilon()),a}Gm(e,t);var n=e.prototype;return n.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var a=Tg.registeredVariables[n];null==e.accumulatedGrads[r]&&(e.accumulatedGrads[r]={originalName:n+"/accum_grad",variable:Nb((function(){return xy(a).variable(!1)}))}),null==e.accumulatedUpdates[r]&&(e.accumulatedUpdates[r]={originalName:n+"/accum_var",variable:Nb((function(){return xy(a).variable(!1)}))});var i=Array.isArray(t)?t[r].tensor:t[n];if(null!=i){var o=e.accumulatedGrads[r].variable,s=e.accumulatedUpdates[r].variable;Nb((function(){var t=o.mul(e.rho).add(i.square().mul(1-e.rho)),n=s.add(e.epsilon).sqrt().div(o.add(e.epsilon).sqrt()).mul(i),r=s.mul(e.rho).add(n.square().mul(1-e.rho));o.assign(t),s.assign(r);var u=n.mul(-e.learningRate).add(a);a.assign(u)}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedUpdates&&(Eb(this.accumulatedGrads.map((function(t){return t.variable}))),Eb(this.accumulatedUpdates.map((function(t){return t.variable}))))},n.getWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[].concat(this.accumulatedGrads,this.accumulatedUpdates),t.next=3,this.saveIterations();case 3:return t.t0=t.sent,t.abrupt("return",[t.t0].concat(e.map((function(t){return{name:t.originalName,tensor:t.variable}}))));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.setWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractIterations(e);case 2:e=t.sent,n=e.length/2,!1,this.accumulatedGrads=e.slice(0,n).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),this.accumulatedUpdates=e.slice(n,2*n).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}}));case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}},e.fromConfig=function(t,e){return new t(e.learningRate,e.rho,e.epsilon)},e}(GR);qR.className="Adadelta",Fk(qR);var HR=function(t){function e(e,n){var r;return void 0===n&&(n=.1),(r=t.call(this)||this).learningRate=e,r.initialAccumulatorValue=n,r.accumulatedGrads=[],r}Gm(e,t);var n=e.prototype;return n.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var a=Tg.registeredVariables[n];if(null==e.accumulatedGrads[r]){e.accumulatedGrads[r]={originalName:n+"/accumulator",variable:Nb((function(){return vy(a.shape,e.initialAccumulatorValue).variable(!1)}))}}var i=Array.isArray(t)?t[r].tensor:t[n];if(null!=i){var o=e.accumulatedGrads[r].variable;Nb((function(){var t=o.add(i.square());o.assign(t);var n=i.div(t.add(Tg.backend.epsilon()).sqrt()).mul(-e.learningRate).add(a);a.assign(n)}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedGrads&&Eb(this.accumulatedGrads.map((function(t){return t.variable})))},n.getWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.saveIterations();case 2:return t.t0=t.sent,t.abrupt("return",[t.t0].concat(this.accumulatedGrads.map((function(t){return{name:t.originalName,tensor:t.variable}}))));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.setWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractIterations(e);case 2:e=t.sent,!1,this.accumulatedGrads=e.map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}},e.fromConfig=function(t,e){return new t(e.learningRate,e.initialAccumulatorValue)},e}(GR);HR.className="Adagrad",Fk(HR);var KR=function(t){function e(e,n,r,a){var i;return void 0===a&&(a=null),(i=t.call(this)||this).learningRate=e,i.beta1=n,i.beta2=r,i.epsilon=a,i.accumulatedFirstMoment=[],i.accumulatedSecondMoment=[],Nb((function(){i.accBeta1=oy(n).variable(),i.accBeta2=oy(r).variable()})),null==a&&(i.epsilon=Tg.backend.epsilon()),i}Gm(e,t);var n=e.prototype;return n.applyGradients=function(t){var e=this,n=Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t);Nb((function(){var r=Dx(1,e.accBeta1),a=Dx(1,e.accBeta2);n.forEach((function(n,i){var o=Tg.registeredVariables[n];null==e.accumulatedFirstMoment[i]&&(e.accumulatedFirstMoment[i]={originalName:n+"/m",variable:Nb((function(){return xy(o).variable(!1)}))}),null==e.accumulatedSecondMoment[i]&&(e.accumulatedSecondMoment[i]={originalName:n+"/v",variable:Nb((function(){return xy(o).variable(!1)}))});var s=Array.isArray(t)?t[i].tensor:t[n];if(null!=s){var u=e.accumulatedFirstMoment[i].variable,c=e.accumulatedSecondMoment[i].variable,l=u.mul(e.beta1).add(s.mul(1-e.beta1)),h=c.mul(e.beta2).add(s.square().mul(1-e.beta2)),f=l.div(r),p=h.div(a);u.assign(l),c.assign(h);var d=f.div(p.sqrt().add(e.epsilon)).mul(-e.learningRate).add(o);o.assign(d)}})),e.accBeta1.assign(e.accBeta1.mul(e.beta1)),e.accBeta2.assign(e.accBeta2.mul(e.beta2))})),this.incrementIterations()},n.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&Eb(this.accumulatedFirstMoment.map((function(t){return t.variable}))),null!=this.accumulatedSecondMoment&&Eb(this.accumulatedSecondMoment.map((function(t){return t.variable})))},n.getWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[].concat(this.accumulatedFirstMoment,this.accumulatedSecondMoment),t.next=3,this.saveIterations();case 3:return t.t0=t.sent,t.abrupt("return",[t.t0].concat(e.map((function(t){return{name:t.originalName,tensor:t.variable}}))));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.setWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractIterations(e);case 2:e=t.sent,Nb((function(){r.accBeta1.assign(Cx(r.beta1,r.iterations_+1)),r.accBeta2.assign(Cx(r.beta2,r.iterations_+1))})),n=e.length/2,!1,this.accumulatedFirstMoment=e.slice(0,n).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),this.accumulatedSecondMoment=e.slice(n,2*n).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}}));case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}},e.fromConfig=function(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon)},e}(GR);KR.className="Adam",Fk(KR);var XR=function(t){function e(e,n,r,a,i){var o;return void 0===a&&(a=null),void 0===i&&(i=0),(o=t.call(this)||this).learningRate=e,o.beta1=n,o.beta2=r,o.epsilon=a,o.decay=i,o.accumulatedFirstMoment=[],o.accumulatedWeightedInfNorm=[],Nb((function(){o.iteration=oy(0).variable(),o.accBeta1=oy(n).variable()})),null==a&&(o.epsilon=Tg.backend.epsilon()),o}Gm(e,t);var n=e.prototype;return n.applyGradients=function(t){var e=this,n=Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t);Nb((function(){var r=Dx(1,e.accBeta1),a=Ix(-e.learningRate,e.iteration.mul(e.decay).add(1));n.forEach((function(n,i){var o=Tg.registeredVariables[n];null==e.accumulatedFirstMoment[i]&&(e.accumulatedFirstMoment[i]={originalName:n+"/m",variable:xy(o).variable(!1)}),null==e.accumulatedWeightedInfNorm[i]&&(e.accumulatedWeightedInfNorm[i]={originalName:n+"/v",variable:xy(o).variable(!1)});var s=Array.isArray(t)?t[i].tensor:t[n];if(null!=s){var u=e.accumulatedFirstMoment[i].variable,c=e.accumulatedWeightedInfNorm[i].variable,l=u.mul(e.beta1).add(s.mul(1-e.beta1)),h=c.mul(e.beta2),f=s.abs(),p=h.maximum(f);u.assign(l),c.assign(p);var d=a.div(r).mul(l.div(p.add(e.epsilon))).add(o);o.assign(d)}})),e.iteration.assign(e.iteration.add(1)),e.accBeta1.assign(e.accBeta1.mul(e.beta1))})),this.incrementIterations()},n.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&Eb(this.accumulatedFirstMoment.map((function(t){return t.variable}))),null!=this.accumulatedWeightedInfNorm&&Eb(this.accumulatedWeightedInfNorm.map((function(t){return t.variable})))},n.getWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw new Error("getWeights() is not implemented for Adamax yet.");case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),n.setWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw new Error("setWeights() is not implemented for Adamax yet.");case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}},e.fromConfig=function(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon,e.decay)},e}(GR);XR.className="Adamax",Fk(XR);var YR=function(t){function e(e){var n;return(n=t.call(this)||this).learningRate=e,n.setLearningRate(e),n}Gm(e,t);var n=e.prototype;return n.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var a=Array.isArray(t)?t[r].tensor:t[n];if(null!=a){var i=Tg.registeredVariables[n];Nb((function(){var t=e.c.mul(a).add(i);i.assign(t)}))}})),this.incrementIterations()},n.setLearningRate=function(t){this.learningRate=t,null!=this.c&&this.c.dispose(),this.c=Ib(oy(-t))},n.dispose=function(){this.c.dispose()},n.getWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.saveIterations();case 2:return t.t0=t.sent,t.abrupt("return",[t.t0]);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.setWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractIterations(e);case 2:if(0===(e=t.sent).length){t.next=5;break}throw new Error("SGD optimizer does not have settable weights.");case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate}},e.fromConfig=function(t,e){return new t(e.learningRate)},e}(GR);YR.className="SGD",Fk(YR);var JR=function(t){function e(e,n,r){var a;return void 0===r&&(r=!1),(a=t.call(this,e)||this).learningRate=e,a.momentum=n,a.useNesterov=r,a.accumulations=[],a.m=oy(a.momentum),a}Gm(e,t);var n=e.prototype;return n.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var a=Tg.registeredVariables[n];if(null==e.accumulations[r]){e.accumulations[r]={originalName:n+"/momentum",variable:Nb((function(){return xy(a).variable(!1)}))}}var i=e.accumulations[r].variable,o=Array.isArray(t)?t[r].tensor:t[n];null!=o&&Nb((function(){var t,n=e.m.mul(i).add(o);t=e.useNesterov?e.c.mul(o.add(n.mul(e.m))).add(a):e.c.mul(n).add(a),i.assign(n),a.assign(t)}))})),this.incrementIterations()},n.dispose=function(){this.m.dispose(),null!=this.accumulations&&Eb(this.accumulations.map((function(t){return t.variable})))},n.setMomentum=function(t){this.momentum=t},n.getWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.saveIterations();case 2:return t.t0=t.sent,t.abrupt("return",[t.t0].concat(this.accumulations.map((function(t){return{name:t.originalName,tensor:t.variable}}))));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.setWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractIterations(e);case 2:e=t.sent,!1,this.accumulations=e.map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}},e.fromConfig=function(t,e){return new t(e.learningRate,e.momentum,e.useNesterov)},e}(YR);JR.className="Momentum",Fk(JR);var $R=function(t){function e(e,n,r,a,i){var o;if(void 0===n&&(n=.9),void 0===r&&(r=0),void 0===a&&(a=null),void 0===i&&(i=!1),(o=t.call(this)||this).learningRate=e,o.decay=n,o.momentum=r,o.epsilon=a,o.accumulatedMeanSquares=[],o.accumulatedMoments=[],o.accumulatedMeanGrads=[],o.centered=i,null==a&&(o.epsilon=Tg.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.");return o}Gm(e,t);var n=e.prototype;return n.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map((function(t){return t.name})):Object.keys(t)).forEach((function(n,r){var a=Tg.registeredVariables[n];null==e.accumulatedMeanSquares[r]&&(e.accumulatedMeanSquares[r]={originalName:n+"/rms",variable:Nb((function(){return xy(a).variable(!1)}))}),null==e.accumulatedMoments[r]&&(e.accumulatedMoments[r]={originalName:n+"/momentum",variable:Nb((function(){return xy(a).variable(!1)}))}),null==e.accumulatedMeanGrads[r]&&e.centered&&(e.accumulatedMeanGrads[r]={originalName:n+"/mg",variable:Nb((function(){return xy(a).variable(!1)}))});var i=Array.isArray(t)?t[r].tensor:t[n];if(null!=i){var o=e.accumulatedMeanSquares[r].variable,s=e.accumulatedMoments[r].variable;Nb((function(){var t=o.mul(e.decay).add(i.square().mul(1-e.decay));if(e.centered){var n=e.accumulatedMeanGrads[r].variable,u=n.mul(e.decay).add(i.mul(1-e.decay)),c=s.mul(e.momentum).add(i.mul(e.learningRate).div(t.sub(u.square().add(e.epsilon)).sqrt()));o.assign(t),n.assign(u),s.assign(c);var l=a.sub(c);a.assign(l)}else{var h=o.mul(e.decay).add(i.square().mul(1-e.decay)),f=s.mul(e.momentum).add(i.mul(e.learningRate).div(h.add(e.epsilon).sqrt()));o.assign(h),s.assign(f);var p=a.sub(f);a.assign(p)}}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedMeanSquares&&Eb(this.accumulatedMeanSquares.map((function(t){return t.variable}))),null!=this.accumulatedMeanGrads&&this.centered&&Eb(this.accumulatedMeanGrads.map((function(t){return t.variable}))),null!=this.accumulatedMoments&&Eb(this.accumulatedMoments.map((function(t){return t.variable})))},n.getWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[].concat(this.accumulatedMeanSquares,this.accumulatedMoments),this.centered&&e.push.apply(e,this.accumulatedMeanGrads),t.next=4,this.saveIterations();case 4:return t.t0=t.sent,t.abrupt("return",[t.t0].concat(e.map((function(t){return{name:t.originalName,tensor:t.variable}}))));case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.setWeights=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractIterations(e);case 2:e=t.sent,n=this.centered?e.length/3:e.length/2,!1,this.accumulatedMeanSquares=e.slice(0,n).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),this.accumulatedMoments=e.slice(n,2*n).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})),this.centered&&(this.accumulatedMeanGrads=e.slice(2*n,3*n).map((function(t){return{originalName:t.name,variable:t.tensor.variable(!1)}})));case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}},e.fromConfig=function(t,e){return new t(e.learningRate,e.decay,e.momentum,e.epsilon,e.centered)},e}(GR);$R.className="RMSProp",Fk($R);var ZR=function(){function t(){}return t.sgd=function(t){return new YR(t)},t.momentum=function(t,e,n){return void 0===n&&(n=!1),new JR(t,e,n)},t.rmsprop=function(t,e,n,r,a){return void 0===e&&(e=.9),void 0===n&&(n=0),void 0===r&&(r=null),void 0===a&&(a=!1),new $R(t,e,n,r,a)},t.adam=function(t,e,n,r){return void 0===t&&(t=.001),void 0===e&&(e=.9),void 0===n&&(n=.999),void 0===r&&(r=null),new KR(t,e,n,r)},t.adadelta=function(t,e,n){return void 0===t&&(t=.001),void 0===e&&(e=.95),void 0===n&&(n=null),new qR(t,e,n)},t.adamax=function(t,e,n,r,a){return void 0===t&&(t=.002),void 0===e&&(e=.9),void 0===n&&(n=.999),void 0===r&&(r=null),void 0===a&&(a=0),new XR(t,e,n,r,a)},t.adagrad=function(t,e){return void 0===e&&(e=.1),new HR(t,e)},t}(),QR={sgd:ZR.sgd,momentum:ZR.momentum,adadelta:ZR.adadelta,adagrad:ZR.adagrad,rmsprop:ZR.rmsprop,adamax:ZR.adamax,adam:ZR.adam},tN="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:function(t){return t()};function eN(){return new Promise((function(t){return tN((function(){return t()}))}))}function nN(t,e,n,r){void 0===r&&(r=!0);var a=[];if(r)(a=a.concat(e.slice(0))).push(t[0]/n),a=a.concat(t.slice(1));else{a=a.concat(t[0]);for(var i=e.length,o=0;o<i;++o)a=a.concat([t[o+1]/e[o],e[o]]);a=a.concat(t.slice(i+1))}return a}function rN(t,e,n){void 0===n&&(n=!0);var r=[];if(n){r.push(e);for(var a=e+1;a<t;++a)a<=2*e?(r.push(a),r.push(a-(e+1))):r.push(a)}else{for(var i=[],o=[],s=1;s<t;++s)s>=2*e+1||s%2==1?o.push(s):i.push(s);r.push.apply(r,i),r.push(0),r.push.apply(r,o)}return r}function aN(t,e,n,r){void 0===r&&(r=!0);var a=[];r?a.push(t[0]/n):a.push(t[0]*n);for(var i=1;i<t.length;++i)i<=e.length?r?a.push(e[i-1]*t[i]):a.push(t[i]/e[i-1]):a.push(t[i]);return a}function iN(t,e){for(var n=[0],r=0;r<e;++r)n.push(t[r][0]);return n}function oN(t,e,n){for(var r=t.slice(0,1),a=0;a<n;++a)r.push(t[a+1]-e[a][0]-e[a][1]);return r}function sN(){var t;nv().getBool("IS_TEST")||(t=console).warn.apply(t,arguments)}function uN(t,e){if(t.length!==e.length)throw new Error("Cannot merge real and imag arrays of different lengths. real:"+t.length+", imag: "+e.length+".");for(var n=new Float32Array(2*t.length),r=0;r<n.length;r+=2)n[r]=t[r/2],n[r+1]=e[r/2];return n}function cN(t){for(var e=new Float32Array(t.length/2),n=new Float32Array(t.length/2),r=0;r<t.length;r+=2)e[r/2]=t[r],n[r/2]=t[r+1];return{real:e,imag:n}}function lN(t){for(var e=Math.ceil(t.length/4),n=new Float32Array(e),r=new Float32Array(e),a=0;a<t.length;a+=4)n[Math.floor(a/4)]=t[a],r[Math.floor(a/4)]=t[a+1];return{real:n,imag:r}}function hN(t){for(var e=Math.floor(t.length/4),n=new Float32Array(e),r=new Float32Array(e),a=2;a<t.length;a+=4)n[Math.floor(a/4)]=t[a],r[Math.floor(a/4)]=t[a+1];return{real:n,imag:r}}function fN(t,e){return{real:t[2*e],imag:t[2*e+1]}}function pN(t,e,n,r){t[2*r]=e,t[2*r+1]=n}function dN(t,e){for(var n=new Float32Array(t/2),r=new Float32Array(t/2),a=0;a<Math.ceil(t/2);a++){var i=(e?2:-2)*Math.PI*(a/t);n[a]=Math.cos(i),r[a]=Math.sin(i)}return{real:n,imag:r}}function mN(t,e,n){var r=(n?2:-2)*Math.PI*(t/e);return{real:Math.cos(r),imag:Math.sin(r)}}function vN(t,e,n){if("complex64"===e){if("complex64"===t.dtype)return t.clone();var r=my(t.shape),a=t.toFloat(),i=n.complex(a,r);return r.dispose(),a.dispose(),i}if(!Mv(t.dtype,e))return Tg.makeTensorFromDataId(t.dataId,t.shape,e);if("complex64"===t.dtype){var o=n.real(t),s=o.cast(e);return o.dispose(),s}if("int32"===e)return n.int(t);if("bool"===e){var u=oy(0,t.dtype),c=n.notEqual(t,u);return u.dispose(),c}throw new Error("Error in Cast: failed to cast "+t.dtype+" to "+e)}function gN(t,e){return Tg.makeTensorFromDataId(t.dataId,e,t.dtype)}function yN(t,e,n){var r=(e-t)/(n-1),a=Yv(n,"float32");a[0]=t;for(var i=1;i<a.length;i++)a[i]=a[i-1]+r;return sy(a,"float32")}var bN={__proto__:null,segment_util:JS,castTensor:vN,reshapeTensor:gN,linspaceImpl:yN,nonMaxSuppressionV3:yR,nonMaxSuppressionV5:bR,upcastType:wg,axesAreInnerMostDims:Gg,combineLocations:qg,computeOutAndReduceShapes:Hg,expandShapeToKeepDim:Kg,assertAxesAreInnerMostDims:Xg,getAxesPermutation:Yg,getUndoAxesPermutation:Jg,getInnerMostAxes:$g,getBroadcastDims:Mg,getReductionAxes:Lg,assertAndGetBroadcastShape:zg,assertParamsConsistent:Zg,computeOutShape:Qg,computePool2DInfo:tb,computePool3DInfo:eb,computeConv2DInfo:nb,computeConv3DInfo:rb,computeDefaultPad:ab,tupleValuesAreOne:cb,eitherStridesOrDilationsAreOne:lb,convertConv2DDataFormat:hb,PARALLELIZE_THRESHOLD:30,computeOptimalWindowSize:XS,getReshaped:nN,getPermuted:rN,getReshapedPermuted:aN,getSliceBeginCoords:iN,getSliceSize:oN,prepareAndValidate:Nk,validateUpdateShape:Ik,validateInput:Ak,calculateShapes:Tk,SELU_SCALEALPHA:1.7580993408473768,SELU_SCALE:kC,shouldFuse:MR,ERF_P:.3275911,ERF_A1:.254829592,ERF_A2:-.284496736,ERF_A3:1.421413741,ERF_A4:-1.453152027,ERF_A5:1.061405429,warn:sN,log:function(){var t;nv().getBool("IS_TEST")||(t=console).log.apply(t,arguments)},mergeRealAndImagArrays:uN,splitRealAndImagArrays:cN,complexWithEvenIndex:lN,complexWithOddIndex:hN,getComplexWithIndex:fN,assignToTypedArray:pN,exponents:dN,exponent:mN};function xN(t,e,n){var r=new Array(t.rank).fill(0),a=t.shape.slice();return e.map((function(e){var i=[].concat(a);i[n]=e;var o=t.slice(r,i);return r[n]+=e,o}))}function wN(t,e){for(var n=new Array(t.rank),r=0;r<n.length;r++)n[r]=t.shape[r]*e[r];for(var a=Sy(n,t.dtype),i=0;i<a.values.length;++i){for(var o=a.indexToLoc(i),s=new Array(t.rank),u=0;u<s.length;u++)s[u]=o[u]%t.shape[u];var c=t.locToIndex(s);a.values[i]=t.values[c]}return a.toTensor()}function kN(t,e,n,r,a){for(var i=e[e.length-1],o=t.length/i,s=i,u=Dv(n,o*r),c=Dv("int32",o*r),l=0;l<o;l++){for(var h=l*s,f=t.subarray(h,h+s),p=[],d=0;d<f.length;d++)p.push({value:f[d],index:d});p.sort((function(t,e){return e.value-t.value}));for(var m=l*r,v=u.subarray(m,m+r),g=c.subarray(m,m+r),y=0;y<r;y++)v[y]=p[y].value,g[y]=p[y].index}var b=e.slice();return b[b.length-1]=r,[ay(u,b,n),ay(c,b,"int32")]}var SN,CN={__proto__:null,nonMaxSuppressionV3:yR,nonMaxSuppressionV5:bR,split:xN,tile:wN,topkImpl:kN,whereImpl:iS},RN=function(){function t(t,e){this.backend=t,this.dataMover=e,this.data=new WeakMap,this.dataIdsCount=0}var e=t.prototype;return e.get=function(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t)},e.set=function(t,e){this.dataIdsCount++,this.data.set(t,e)},e.has=function(t){return this.data.has(t)},e.delete=function(t){return this.dataIdsCount--,this.data.delete(t)},e.numDataIds=function(){return this.dataIdsCount},t}(),NN=function(){function t(){}var e=t.prototype;return e.time=function(t){return EN("time")},e.read=function(t){return EN("read")},e.readSync=function(t){return EN("readSync")},e.numDataIds=function(){return EN("numDataIds")},e.disposeData=function(t){return EN("disposeData")},e.write=function(t,e,n){return EN("write")},e.move=function(t,e,n,r){return EN("move")},e.memory=function(){return EN("memory")},e.floatPrecision=function(){return EN("floatPrecision")},e.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},e.batchMatMul=function(t,e,n,r){return EN("batchMatMul")},e.fusedBatchMatMul=function(t){t.a,t.b,t.transposeA,t.transposeB,t.bias,t.activation,t.preluActivationWeights;return EN("fusedBatchMatMul")},e.slice=function(t,e,n){return EN("slice")},e.stridedSlice=function(t,e,n,r){return EN("stridedSlice")},e.unstack=function(t,e){return EN("unstack")},e.reverse=function(t,e){return EN("reverse")},e.concat=function(t,e){return EN("concat")},e.neg=function(t){return EN("neg")},e.add=function(t,e){return EN("add")},e.addN=function(t){return EN("addN")},e.subtract=function(t,e){return EN("subtract")},e.multiply=function(t,e){return EN("multiply")},e.realDivide=function(t,e){return EN("realDivide")},e.floorDiv=function(t,e){return EN("floorDiv")},e.sum=function(t,e){return EN("sum")},e.prod=function(t,e){return EN("prod")},e.unsortedSegmentSum=function(t,e,n){return EN("unsortedSegmentSum")},e.argMin=function(t,e){return EN("argMin")},e.argMax=function(t,e){return EN("argMax")},e.equal=function(t,e){return EN("equal")},e.notEqual=function(t,e){return EN("notEqual")},e.less=function(t,e){return EN("less")},e.lessEqual=function(t,e){return EN("lessEqual")},e.greater=function(t,e){return EN("greater")},e.greaterEqual=function(t,e){return EN("greaterEqual")},e.logicalNot=function(t){return EN("logicalNot")},e.logicalAnd=function(t,e){return EN("logicalAnd")},e.logicalOr=function(t,e){return EN("logicalOr")},e.where=function(t){return EN("where")},e.select=function(t,e,n){return EN("select")},e.topk=function(t,e,n){return EN("topk")},e.min=function(t,e){return EN("min")},e.minimum=function(t,e){return EN("minimum")},e.mod=function(t,e){return EN("mod")},e.max=function(t,e){return EN("max")},e.maximum=function(t,e){return EN("maximum")},e.all=function(t,e){return EN("all")},e.any=function(t,e){return EN("any")},e.squaredDifference=function(t,e){return EN("squaredDifference")},e.ceil=function(t){return EN("ceil")},e.floor=function(t){return EN("floor")},e.round=function(t){return EN("round")},e.sign=function(t){return EN("sign")},e.isNaN=function(t){return EN("isNaN")},e.isInf=function(t){return EN("isInf")},e.isFinite=function(t){return EN("isFinite")},e.pow=function(t,e){return EN("pow")},e.exp=function(t){return EN("exp")},e.expm1=function(t){return EN("expm1")},e.softmax=function(t,e){return EN("softmax")},e.log=function(t){return EN("log")},e.log1p=function(t){return EN("log1p")},e.sqrt=function(t){return EN("sqrt")},e.rsqrt=function(t){return EN("rsqrt")},e.square=function(t){return EN("square")},e.reciprocal=function(t){return EN("reciprocal")},e.relu=function(t){return EN("relu")},e.relu6=function(t){return EN("relu6")},e.prelu=function(t,e){return EN("prelu")},e.elu=function(t){return EN("elu")},e.eluDer=function(t,e){return EN("eluDer")},e.selu=function(t){return EN("selu")},e.int=function(t){return EN("int")},e.clip=function(t,e,n){return EN("clip")},e.abs=function(t){return EN("abs")},e.complexAbs=function(t){return EN("complexAbs")},e.sigmoid=function(t){return EN("sigmoid")},e.softplus=function(t){return EN("softplus")},e.sin=function(t){return EN("sin")},e.cos=function(t){return EN("cos")},e.tan=function(t){return EN("tan")},e.asin=function(t){return EN("asin")},e.acos=function(t){return EN("acos")},e.atan=function(t){return EN("atan")},e.atan2=function(t,e){return EN("atan2")},e.sinh=function(t){return EN("sinh")},e.cosh=function(t){return EN("cosh")},e.tanh=function(t){return EN("tanh")},e.asinh=function(t){return EN("asinh")},e.acosh=function(t){return EN("acosh")},e.atanh=function(t){return EN("atanh")},e.erf=function(t){return EN("erf")},e.step=function(t,e){return EN("step")},e.fusedConv2d=function(t){t.input,t.filter,t.convInfo,t.bias,t.activation,t.preluActivationWeights;return EN("fusedConv2d")},e.conv2d=function(t,e,n){return EN("conv2d")},e.conv2dDerInput=function(t,e,n){return EN("conv2dDerInput")},e.conv2dDerFilter=function(t,e,n){return EN("conv2dDerFilter")},e.fusedDepthwiseConv2D=function(t){t.input,t.filter,t.convInfo,t.bias,t.activation,t.preluActivationWeights;return EN("fusedDepthwiseConv2D")},e.depthwiseConv2D=function(t,e,n){return EN("depthwiseConv2D")},e.depthwiseConv2DDerInput=function(t,e,n){return EN("depthwiseConv2DDerInput")},e.depthwiseConv2DDerFilter=function(t,e,n){return EN("depthwiseConv2DDerFilter")},e.conv3d=function(t,e,n){return EN("conv3d")},e.conv3dDerInput=function(t,e,n){return EN("conv3dDerInput")},e.conv3dDerFilter=function(t,e,n){return EN("conv3dDerFilter")},e.maxPool=function(t,e){return EN("maxPool")},e.maxPoolBackprop=function(t,e,n,r){return EN("maxPoolBackprop")},e.avgPool=function(t,e){return EN("avgPool")},e.avgPoolBackprop=function(t,e,n){return EN("avgPoolBackprop")},e.avgPool3d=function(t,e){return EN("avgPool3d")},e.avgPool3dBackprop=function(t,e,n){return EN("avgPool3dBackprop")},e.maxPool3d=function(t,e){return EN("maxPool3d")},e.maxPool3dBackprop=function(t,e,n,r){return EN("maxPool3dBackprop")},e.reshape=function(t,e){return EN("reshape")},e.cast=function(t,e){return EN("cast")},e.tile=function(t,e){return EN("tile")},e.pad=function(t,e,n){return EN("pad")},e.transpose=function(t,e){return EN("transpose")},e.gather=function(t,e,n){return EN("gather")},e.gatherND=function(t,e){return EN("gatherND")},e.scatterND=function(t,e,n){return EN("scatterND")},e.batchToSpaceND=function(t,e,n){return EN("batchToSpaceND")},e.spaceToBatchND=function(t,e,n){return EN("spaceToBatchND")},e.resizeBilinear=function(t,e,n,r){return EN("resizeBilinear")},e.resizeBilinearBackprop=function(t,e,n){return EN("resizeBilinearBackprop")},e.resizeNearestNeighbor=function(t,e,n,r){return EN("resizeNearestNeighbor")},e.resizeNearestNeighborBackprop=function(t,e,n){return EN("resizeNearestNeighborBackprop")},e.batchNorm=function(t,e,n,r,a,i){return EN("batchNorm")},e.localResponseNormalization4D=function(t,e,n,r,a){return EN("localResponseNormalization4D")},e.LRNGrad=function(t,e,n,r,a,i,o){return EN("LRNGrad")},e.multinomial=function(t,e,n,r){return EN("multinomial")},e.oneHot=function(t,e,n,r){return EN("oneHot")},e.cumsum=function(t,e,n,r){return EN("cumsum")},e.nonMaxSuppression=function(t,e,n,r,a){return EN("nonMaxSuppression")},e.fft=function(t){return EN("fft")},e.ifft=function(t){return EN("ifft")},e.complex=function(t,e){return EN("complex")},e.real=function(t){return EN("real")},e.imag=function(t){return EN("imag")},e.cropAndResize=function(t,e,n,r,a,i){return EN("cropAndResize")},e.depthToSpace=function(t,e,n){return EN("depthToSpace")},e.split=function(t,e,n){return EN("split")},e.sparseToDense=function(t,e,n,r){return EN("sparseToDense")},e.diag=function(t){return EN("diag")},e.fill=function(t,e,n){return EN("fill")},e.onesLike=function(t){return EN("onesLike")},e.zerosLike=function(t){return EN("zerosLike")},e.linspace=function(t,e,n){return EN("linspace")},e.dispose=function(){return EN("dispose")},t}();function EN(t){throw new Error("'"+t+"' not yet implemented or not found in the registry. Did you forget to import the kernel?")}function IN(){return null==SN&&(SN=Tb().epsilon()),SN}pg.prototype.add=function(t){return this.throwIfDisposed(),Db(this,t)},pg.prototype.batchNorm=function(t,e,n,r,a){return this.throwIfDisposed(),Uk(this,t,e,n,r,a)},pg.prototype.broadcastTo=function(t){return this.throwIfDisposed(),Kk(this,t)},pg.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),Ux(this,t,e)},pg.prototype.max=function(t,e){return this.throwIfDisposed(),kS(this,t,e)},pg.prototype.concat=function(t,e){return this.throwIfDisposed(),t instanceof pg&&(t=[t]),wy([this].concat(t),e)},pg.prototype.conv1d=function(t,e,n,r,a,i){return this.throwIfDisposed(),Zk(this,t,e,n,r,a,i)},pg.prototype.conv2d=function(t,e,n,r,a,i){return this.throwIfDisposed(),mb(this,t,e,n,r,a,i)},pg.prototype.conv2dTranspose=function(t,e,n,r,a){return this.throwIfDisposed(),Qk(this,t,e,n,r,a)},pg.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),nS(this,t,e)},pg.prototype.depthwiseConv2d=function(t,e,n,r,a,i){return this.throwIfDisposed(),rS(this,t,e,n,r,a,i)},pg.prototype.depthwiseConv2D=function(t,e,n,r,a,i){return Sb("depthwiseConv2D is deprecated, use depthwiseConv2d instead"),this.throwIfDisposed(),rS(this,t,e,n,r,a,i)},pg.prototype.div=function(t){return this.throwIfDisposed(),Ix(this,t)},pg.prototype.divNoNan=function(t){return this.throwIfDisposed(),pS(this,t)},pg.prototype.dot=function(t){return this.throwIfDisposed(),dS(this,t)},pg.prototype.equal=function(t){return this.throwIfDisposed(),mS(this,t)},pg.prototype.greater=function(t){return this.throwIfDisposed(),gS(this,t)},pg.prototype.greaterEqual=function(t){return this.throwIfDisposed(),yS(this,t)},pg.prototype.less=function(t){return this.throwIfDisposed(),bS(this,t)},pg.prototype.lessEqual=function(t){return this.throwIfDisposed(),xS(this,t)},pg.prototype.localResponseNormalization=function(t,e,n,r){return this.throwIfDisposed(),wS(this,t,e,n,r)},pg.prototype.matMul=function(t,e,n){return this.throwIfDisposed(),Oy(this,t,e,n)},pg.prototype.oneHot=function(t,e,n){return void 0===e&&(e=1),void 0===n&&(n=0),this.throwIfDisposed(),xk(this,t,e,n)},pg.prototype.notEqual=function(t){return this.throwIfDisposed(),CS(this,t)},pg.prototype.pad=function(t,e){return this.throwIfDisposed(),Xx(this,t,e)},pg.prototype.separableConv2d=function(t,e,n,r,a,i){return this.throwIfDisposed(),qS(this,t,e,n,r,a,i)},pg.prototype.split=function(t,e){return this.throwIfDisposed(),Zy(this,t,e)},pg.prototype.squaredDifference=function(t){return this.throwIfDisposed(),HS(this,t)},pg.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),My(this,t,e)},pg.prototype.sub=function(t){return this.throwIfDisposed(),Dx(this,t)},pg.prototype.tile=function(t){return this.throwIfDisposed(),_x(this,t)},pg.prototype.transpose=function(t){return this.throwIfDisposed(),Bx(this,t)},fg=jR;var AN=function(t){function e(n){var r;return r=t.call(this,n)||this,Object.setPrototypeOf(Jm(r),e.prototype),r}return Gm(e,t),e}(Ym(Error)),TN=function(t){function e(n){var r;return r=t.call(this,n)||this,Object.setPrototypeOf(Jm(r),e.prototype),r}return Gm(e,t),e}(Ym(Error)),DN=function(t){function e(n){var r;return r=t.call(this,n)||this,Object.setPrototypeOf(Jm(r),e.prototype),r}return Gm(e,t),e}(Ym(Error)),_N=function(t){function e(n){var r;return r=t.call(this,n)||this,Object.setPrototypeOf(Jm(r),e.prototype),r}return Gm(e,t),e}(Ym(Error)),ON=function(t){function e(n){var r;return r=t.call(this,n)||this,Object.setPrototypeOf(Jm(r),e.prototype),r}return Gm(e,t),e}(Ym(Error));function FN(t,e){if(Array.isArray(t)){for(var n=[],r=0;r<e;r++)n=n.concat(t);return n}var a=new Array(e);return a.fill(t),a}function MN(t,e){if(!t)throw new ON(e)}function LN(t,e){for(var n,r=0,a=Zm(t);!(n=a()).done;){n.value===e&&r++}return r}function zN(t){return 1===t.length?t[0]:t}function BN(t){return Array.isArray(t)?t:[t]}function PN(t){var e=t.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return"_"!==e[0]?e:"private"+e}function WN(t){return t.length<=1||-1===t.indexOf("_")?t:t.replace(/[_]+(\w|$)/g,(function(t,e){return e.toUpperCase()}))}var VN={};function UN(t){if(null==t)return null;var e={};return e.className=t.getClassName(),e.config=t.getConfig(),e}function jN(t,e,n,r,a){if(void 0===e&&(e={}),void 0===n&&(n={}),void 0===r&&(r="object"),void 0===a&&(a=!1),"string"==typeof t){var i,o=t;if(o in n)i=n[o];else if(o in VN)i=VN[o];else if(null==(i=e[o]))throw new DN("Unknown "+r+": "+t+". This may be due to one of the following reasons:\n1. The "+r+" is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom "+r+" is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().");return i}var s=t;if(null==s.className||null==s.config)throw new DN(r+": Improper config format: "+JSON.stringify(s)+".\n'className' and 'config' must set.");var u,c,l=s.className;if(l in n){var h=n[l];u=h[0],c=h[1]}else if(l in VN){var f=VN.className;u=f[0],c=f[1]}else if(l in e){var p=e[l];u=p[0],c=p[1]}if(null==u)throw new DN("Unknown "+r+": "+l+". This may be due to one of the following reasons:\n1. The "+r+" is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom "+r+" is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().");if(null!=c){for(var d={},m=0,v=Object.keys(VN);m<v.length;m++){var g=v[m];d[g]=VN[g]}for(var y=0,b=Object.keys(n);y<b.length;y++){var x=b[y];d[x]=n[x]}s.config.customObjects=d;for(var w=Object.assign({},VN),k=0,S=Object.keys(n);k<S.length;k++){var C=S[k];VN[C]=n[C]}!function t(e){if(null!=e&&"object"==typeof e)if(Array.isArray(e))e.forEach((function(e){return t(e)}));else for(var n=0,r=Object.keys(e);n<r.length;n++){var a=r[n],i=e[a];null!=i&&"object"==typeof i&&(Array.isArray(i)||"ndarray"!==i.type||"number"!=typeof i.value?t(i):e[a]=i.value)}}(s.config);var R=c(u,s.config,n,a);return VN=Object.assign({},w),R}for(var N=Object.assign({},VN),E=0,I=Object.keys(n);E<I.length;E++){var A=I[E];VN[A]=n[A]}var T=new u(s.config);return VN=Object.assign({},N),T}function GN(t,e){return-1*function(t,e){return t<e?-1:t>e?1:0}(t,e)}function qN(t){if(null==t)return t;for(var e,n=[],r=Zm(t);!(e=r()).done;){var a=e.value;-1===n.indexOf(a)&&n.push(a)}return n}function HN(t){if(null==t)throw new DN("Invalid value in obj: "+JSON.stringify(t));for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}function KN(t,e,n){if(null!=n&&t.indexOf(n)<0)throw new DN(n+" is not a valid "+e+". Valid values are "+t+" or null/undefined.")}function XN(t,e,n,r){return void 0===n&&(n=0),void 0===r&&(r=1/0),MN(n>=0),MN(r>=n),Array.isArray(t)&&t.length>=n&&t.length<=r&&t.every((function(t){return typeof t===e}))}function YN(t,e){Array.isArray(t)?(gv(t.length>0,(function(){return e+" is unexpectedly an empty array."})),t.forEach((function(t,n){return YN(t,"element "+(n+1)+" of "+e)}))):gv(Number.isInteger(t)&&t>0,(function(){return"Expected "+e+" to be a positive integer, but got "+function t(e){return null===e?"null":Array.isArray(e)?"["+e.map((function(e){return t(e)})).join(",")+"]":"string"==typeof e?'"'+e+'"':""+e}(t)+"."}))}function JN(t){return"relu"===t?"relu":"linear"===t?"linear":"elu"===t?"elu":null}function $N(t,e){return Nb((function(){return ux(Yy(kx(t,t),e,!0))}))}var ZN=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.getConfig=function(){return{}},e}(_k),QN=function(t){function e(e){var n;return(n=t.call(this)||this).defaultMaxValue=2,n.defaultAxis=0,n.maxValue=null!=e.maxValue?e.maxValue:n.defaultMaxValue,n.axis=null!=e.axis?e.axis:n.defaultAxis,n}Gm(e,t);var n=e.prototype;return n.apply=function(t){var e=this;return Nb((function(){var n=$N(t,e.axis),r=Wb(n,0,e.maxValue);return kx(t,Ix(r,Db(IN(),n)))}))},n.getConfig=function(){return{maxValue:this.maxValue,axis:this.axis}},e}(ZN);QN.className="MaxNorm",Fk(QN);var tE=function(t){function e(e){var n;return(n=t.call(this)||this).defaultAxis=0,n.axis=null!=e.axis?e.axis:n.defaultAxis,n}Gm(e,t);var n=e.prototype;return n.apply=function(t){var e=this;return Nb((function(){return Ix(t,Db(IN(),$N(t,e.axis)))}))},n.getConfig=function(){return{axis:this.axis}},e}(ZN);tE.className="UnitNorm",Fk(tE);var eE=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return NC(t)},e}(ZN);eE.className="NonNeg",Fk(eE);var nE=function(t){function e(e){var n;return(n=t.call(this)||this).defaultMinValue=0,n.defaultMaxValue=1,n.defaultRate=1,n.defaultAxis=0,n.minValue=null!=e.minValue?e.minValue:n.defaultMinValue,n.maxValue=null!=e.maxValue?e.maxValue:n.defaultMaxValue,n.rate=null!=e.rate?e.rate:n.defaultRate,n.axis=null!=e.axis?e.axis:n.defaultAxis,n}Gm(e,t);var n=e.prototype;return n.apply=function(t){var e=this;return Nb((function(){var n=$N(t,e.axis),r=Db(kx(e.rate,Wb(n,e.minValue,e.maxValue)),kx(1-e.rate,n));return kx(t,Ix(r,Db(IN(),n)))}))},n.getConfig=function(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}},e}(ZN);nE.className="MinMaxNorm",Fk(nE);var rE={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function aE(t){return UN(t)}function iE(t,e){return void 0===e&&(e={}),jN(t,Ok.getMap().classNameMap,e,"constraint")}function oE(t){return null==t?null:"string"==typeof t?iE({className:t in rE?rE[t]:t,config:{}}):t instanceof ZN?t:iE(t)}var sE={__proto__:null,maxNorm:function(t){return new QN(t)},unitNorm:function(t){return new tE(t)},nonNeg:function(){return new eE},minMaxNorm:function(t){return new nE(t)}},uE=["channelsFirst","channelsLast"],cE=["valid","same","causal"],lE=["max","avg"],hE=["sum","mul","concat","ave"],fE=new Map;function pE(t){KN(uE,"DataFormat",t)}function dE(t){KN(cE,"PaddingMode",t)}function mE(t){KN(lE,"PoolMode",t)}var vE=[];function gE(t,e){vE.push(t);try{var n=e();return vE.pop(),n}catch(t){throw vE.pop(),t}}function yE(t){if(!wE(t))throw new Error("Not a valid tensor name: '"+t+"'");return(0===vE.length?"":vE.join("/")+"/")+t}function bE(t){if(!wE(t))throw new Error("Not a valid tensor name: '"+t+"'");fE.has(t)||fE.set(t,0);var e=fE.get(t);if(fE.set(t,fE.get(t)+1),e>0){var n=t+"_"+e;return fE.set(n,1),n}return t}var xE=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function wE(t){return!!t.match(xE)}function kE(t,e,n){null==e&&(e=0),null==n&&(n=t.length);for(var r=1,a=e;a<n;++a)r*=t[a];return r}function SE(t){return sy(t=Array.isArray(t)?new Float32Array(t):t)}function CE(t){return Ky(SE(t)).dataSync()[0]}function RE(t){return kS(SE(t)).dataSync()[0]}function NE(t,e){if(e<t)throw new DN("end ("+e+") < begin ("+t+") is forbidden.");for(var n=[],r=t;r<e;++r)n.push(r);return n}function EE(t,e){return t.asType(e)}function IE(t,e){void 0===e&&(e=-1);var n=t.shape.slice();return e<0&&(e=n.length+e+1),n.splice(e,0,1),t.reshape(n)}function AE(t,e,n){return Nb((function(){switch(t.rank){case 1:return aw(t,e,n);case 2:return iw(t,[e,0],[n,t.shape[1]]);case 3:return ow(t,[e,0,0],[n,t.shape[1],t.shape[2]]);case 4:return sw(t,[e,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3]]);case 5:return rw(t,[e,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4]]);case 6:return rw(t,[e,0,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4],t.shape[5]]);default:throw new DN("sliceAlongFirstAxis() received an unsupported tensor rank: "+t.rank)}}))}function TE(t,e,n){return Nb((function(){switch(t.rank){case 1:return aw(t,e,n);case 2:return iw(t,[0,e],[t.shape[0],n]);case 3:return ow(t,[0,0,e],[t.shape[0],t.shape[1],n]);case 4:return sw(t,[0,0,0,e],[t.shape[0],t.shape[1],t.shape[2],n]);default:throw new DN("sliceAlongLastAxis() received an unsupported tensor rank: "+t.rank)}}))}function DE(t,e,n,r){return Nb((function(){switch(t.rank){case 1:return aw(t,e,n);case 2:switch(r){case 1:return AE(t,e,n);case 2:return TE(t,e,n);default:throw new DN("The axis is not within the rank of the tensor "+r)}case 3:switch(r){case 1:return AE(t,e,n);case 2:return ow(t,[0,e,0],[t.shape[0],n,t.shape[2]]);case 3:return TE(t,e,n);default:throw new DN("The axis is not within the rank of the tensor "+r)}case 4:switch(r){case 1:return AE(t,e,n);case 2:return sw(t,[0,e,0,0],[t.shape[0],n,t.shape[2],t.shape[3]]);case 3:return sw(t,[0,0,e,0],[t.shape[0],t.shape[1],n,t.shape[3]]);case 4:return TE(t,e,n);default:throw new DN("The axis is not within the rank of the tensor "+r)}default:throw new DN("sliceAlongLastAxis() received an unsupported tensor rank: "+t.rank)}}))}function _E(t,e){var n;return void 0===e&&(e=-1),e<0&&(e=0!==(n=t[0].rank)?n:0),e===t[0].rank&&(e=-1),wy(t,e)}function OE(t,e){switch(t.rank){case 1:return Xk([t,e]);case 2:return Yk([t,e],0);case 3:return Jk([t,e],0);case 4:return $k([t,e],0);default:throw new DN("concatAlongFirstAxis() received an unsupported tensor rank: "+t.rank)}}function FE(t,e){if(Array.isArray(e)||(e=[e]),t.rank!==e.length)throw new DN("The length of input n ("+e.length+") does not match the number of dimensions in input x ("+t.rank+")");return _x(t,e)}function ME(t,e,n,r,a){return void 0===e&&(e=0),void 0===n&&(n=1),jS(t,e,n,r,a)}function LE(t,e,n,r){if(t.rank<2||e.rank<2)throw new _N("dot requires both inputs to be rank >= 2 but got x shape = "+t.shape+" and y shape = "+e.shape);if(e.rank>=3&&t.shape.slice(-1)[0]!==e.shape.slice(-2)[0])throw new _N("If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = "+t.shape+" and y shape = "+e.shape);if(2===t.rank&&2===e.rank){return PR({a:t,b:e,transposeA:!1,transposeB:!1,bias:r?PE(t.rank,r,"channelsLast"):null,activation:n})}var a=t.shape.slice(),i=a.pop();t=t.reshape([-1,i]);var o=e.shape.slice(),s=o.pop(),u=o.pop(),c=[].concat(o,[s]),l=Array.from({length:e.rank},(function(t,n){return 0===n?e.rank-2:n<=e.rank-2?n-1:n}));e=e.transpose(l).reshape([u,-1]);var h=[].concat(a,c);return PR({a:t,b:e,transposeA:!1,transposeB:!1,bias:r?PE(t.rank,r,"channelsLast"):null,activation:n}).reshape(h)}function zE(t,e,n){return Nb((function(){return e=Array.isArray(e)?sy(e,"int32"):e.toInt(),QS(t,e,n)}))}function BE(t){return kx(t,t)}function PE(t,e,n){var r=e.shape;if(1!==e.rank&&e.rank!==t)throw new DN("Unexpected bias dimensions: "+e.rank+"; expected it to be 1 or "+t);if(5===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1,1,1]):e.reshape([1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,1,1,r[0]]):e.reshape([1].concat(r))}else if(4===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1,1]):e.reshape([1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,1,r[0]]):e.reshape([1].concat(r))}else if(3===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1]):e.reshape([1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,r[0]]):e.reshape([1].concat(r))}else if(t<3)return e;throw new DN("Unsupported input rank by biasAdd: "+e.rank)}function WE(t,e,n){return Nb((function(){return null==n&&(n="channelsLast"),pE(n),t.add(PE(t.rank,e,n))}))}function VE(t,e,n,r){return Nb((function(){return qC(t,e,n,r)}))}function UE(t,e,n){return void 0===n&&(n=!1),n?t():e()}var jE=["fanIn","fanOut","fanAvg"],GE=["normal","uniform","truncatedNormal"];var qE=function(t){function e(){return t.apply(this,arguments)||this}Gm(e,t);var n=e.prototype;return n.fromConfigUsesCustomObjects=function(){return!1},n.getConfig=function(){return{}},e}(_k),HE=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t,e){return my(t,e)},e}(qE);HE.className="Zeros",Fk(HE);var KE=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t,e){return dy(t,e)},e}(qE);KE.className="Ones",Fk(KE);var XE=function(t){function e(e){var n;if(n=t.call(this)||this,"object"!=typeof e)throw new DN("Expected argument of type ConstantConfig but got "+e);if(void 0===e.value)throw new DN("config must have value set but got "+e);return n.value=e.value,n}Gm(e,t);var n=e.prototype;return n.apply=function(t,e){var n=this;return Nb((function(){return kx(oy(n.value),dy(t,e))}))},n.getConfig=function(){return{value:this.value}},e}(qE);XE.className="Constant",Fk(XE);var YE=function(t){function e(e){var n;return(n=t.call(this)||this).DEFAULT_MINVAL=-.05,n.DEFAULT_MAXVAL=.05,n.minval=e.minval||n.DEFAULT_MINVAL,n.maxval=e.maxval||n.DEFAULT_MAXVAL,n.seed=e.seed,n}Gm(e,t);var n=e.prototype;return n.apply=function(t,e){return GS(t,this.minval,this.maxval,e)},n.getConfig=function(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}},e}(qE);YE.className="RandomUniform",Fk(YE);var JE=function(t){function e(e){var n;return(n=t.call(this)||this).DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=e.mean||n.DEFAULT_MEAN,n.stddev=e.stddev||n.DEFAULT_STDDEV,n.seed=e.seed,n}Gm(e,t);var n=e.prototype;return n.apply=function(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new _N("randomNormal does not support dType "+e+".");return ME(t,this.mean,this.stddev,e,this.seed)},n.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},e}(qE);JE.className="RandomNormal",Fk(JE);var $E=function(t){function e(e){var n;return(n=t.call(this)||this).DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=e.mean||n.DEFAULT_MEAN,n.stddev=e.stddev||n.DEFAULT_STDDEV,n.seed=e.seed,n}Gm(e,t);var n=e.prototype;return n.apply=function(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new _N("truncatedNormal does not support dType "+e+".");return KS(t,this.mean,this.stddev,e,this.seed)},n.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},e}(qE);$E.className="TruncatedNormal",Fk($E);var ZE=function(t){function e(e){var n;return(n=t.call(this)||this).gain=null!=e.gain?e.gain:1,n}Gm(e,t);var n=e.prototype;return n.apply=function(t,e){var n=this;return Nb((function(){if(2!==t.length||t[0]!==t[1])throw new DN("Identity matrix initializer can only be used for 2D square matrices.");return kx(n.gain,vS(t[0]))}))},n.getConfig=function(){return{gain:this.gain}},e}(qE);ZE.className="Identity",Fk(ZE);var QE=function(t){function e(e){var n,r;if(n=t.call(this)||this,e.scale<0)throw new DN("scale must be a positive float. Got: "+e.scale);return n.scale=null==e.scale?1:e.scale,n.mode=null==e.mode?"fanIn":e.mode,r=n.mode,KN(jE,"FanMode",r),n.distribution=null==e.distribution?"normal":e.distribution,function(t){KN(GE,"Distribution",t)}(n.distribution),n.seed=e.seed,n}Gm(e,t);var n=e.prototype;return n.apply=function(t,e){var n=function(t,e){var n,r;if(void 0===e&&(e="channelsLast"),pE(e),2===t.length)n=t[0],r=t[1];else if(-1!==[3,4,5].indexOf(t.length)){if("channelsFirst"===e){var a=kE(t,2);n=t[1]*a,r=t[0]*a}else if("channelsLast"===e){var i=kE(t,0,t.length-2);n=t[t.length-2]*i,r=t[t.length-1]*i}}else{var o=kE(t);n=Math.sqrt(o),r=Math.sqrt(o)}return[n,r]}(t),r=n[0],a=n[1],i=this.scale;if("fanIn"===this.mode?i/=Math.max(1,r):"fanOut"===this.mode?i/=Math.max(1,a):i/=Math.max(1,(r+a)/2),"normal"===this.distribution){var o=Math.sqrt(i);if("float32"!==(e=e||"float32")&&"int32"!==e)throw new _N(this.getClassName()+" does not support dType "+e+".");return KS(t,0,o,e,this.seed)}var s=Math.sqrt(3*i);return GS(t,-s,s,e)},n.getConfig=function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}},e}(qE);QE.className="VarianceScaling",Fk(QE);var tI=function(t){function e(e){return t.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})||this}return Gm(e,t),e.prototype.getClassName=function(){return QE.className},e}(QE);tI.className="GlorotUniform",Fk(tI);var eI=function(t){function e(e){return t.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})||this}return Gm(e,t),e.prototype.getClassName=function(){return QE.className},e}(QE);eI.className="GlorotNormal",Fk(eI);var nI=function(t){function e(e){return t.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})||this}return Gm(e,t),e.prototype.getClassName=function(){return QE.className},e}(QE);nI.className="HeNormal",Fk(nI);var rI=function(t){function e(e){return t.call(this,{scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})||this}return Gm(e,t),e.prototype.getClassName=function(){return QE.className},e}(QE);rI.className="HeUniform",Fk(rI);var aI=function(t){function e(e){return t.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})||this}return Gm(e,t),e.prototype.getClassName=function(){return QE.className},e}(QE);aI.className="LeCunNormal",Fk(aI);var iI=function(t){function e(e){return t.call(this,{scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})||this}return Gm(e,t),e.prototype.getClassName=function(){return QE.className},e}(QE);iI.className="LeCunNormal",Fk(iI);var oI=function(t){function e(e){var n;if((n=t.call(this)||this).DEFAULT_GAIN=1,n.gain=null==e.gain?n.DEFAULT_GAIN:e.gain,n.seed=e.seed,null!=n.seed)throw new _N("Random seed is not implemented for Orthogonal Initializer yet.");return n}Gm(e,t);var n=e.prototype;return n.apply=function(t,e){var n=this;return Nb((function(){if(2!==t.length)throw new _N("The Orthogonal Initializer does not support non-2D shapes yet.");t[0]*t[1]>2e3&&console.warn("Orthogonal initializer is being called on a matrix with more than 2000 ("+t[0]*t[1]+") elements: Slowness may result.");var e=ME(t[0]>t[1]?[t[1],t[0]]:t,0,1,"float32"),r=pR(e);return t[0]>t[1]&&(r=r.transpose()),kx(n.gain,r)}))},n.getConfig=function(){return{gain:this.gain,seed:this.seed}},e}(qE);oI.className="Orthogonal",Fk(oI);var sI={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 uI(t,e){return void 0===e&&(e={}),jN(t,Ok.getMap().classNameMap,e,"initializer")}function cI(t){return UN(t)}function lI(t){if("string"==typeof t){var e=t in sI?sI[t]:t;if("GlorotNormal"===e)return new eI;if("GlorotUniform"===e)return new tI;if("HeNormal"===e)return new nI;if("HeUniform"===e)return new rI;if("LeCunNormal"===e)return new aI;if("LeCunUniform"===e)return new iI;var n={};return n.className=e,n.config={},uI(n)}return t instanceof qE?t:uI(t)}var hI={__proto__:null,zeros:function(){return new HE},ones:function(){return new KE},constant:function(t){return new XE(t)},randomUniform:function(t){return new YE(t)},randomNormal:function(t){return new JE(t)},truncatedNormal:function(t){return new $E(t)},identity:function(t){return new ZE(t)},varianceScaling:function(t){return new QE(t)},glorotUniform:function(t){return new tI(t)},glorotNormal:function(t){return new eI(t)},heNormal:function(t){return new nI(t)},heUniform:function(t){return new rI(t)},leCunNormal:function(t){return new aI(t)},leCunUniform:function(t){return new iI(t)},orthogonal:function(t){return new oI(t)}},fI=0;function pI(){return fI++}var dI={};function mI(t){return void 0===t&&(t=""),t in dI||(dI[t]=0),dI[t]+=1,t+dI[t].toString()}function vI(t){return Array.isArray(t)&&Array.isArray(t[0])}function gI(t){return 0===t.length?[]:Array.isArray(t[0])?t:[t]}function yI(t){var e;if(Array.isArray(t)){if(1!==t.length)throw new DN("Expected Tensor length to be 1; got "+t.length);e=t[0]}else e=t;return e}function bI(t){if(Array.isArray(t)&&Array.isArray(t[0])){if(1===t.length)return(t=t)[0];throw new DN("Expected exactly 1 Shape; got "+t.length)}return t}function xI(t){for(var e,n=0,r=Zm(t);!(e=r()).done;){var a=e.value;0===a.shape.length?n+=1:n+=a.shape.reduce((function(t,e){return t*e}))}return n}var wI=function(){function t(t,e,n,r,a){void 0===e&&(e="float32"),void 0===n&&(n="Variable"),void 0===r&&(r=!0),void 0===a&&(a=null),this.dtype=null==e?"float32":e,this.shape=t.shape,this.id=pI(),n=null==n?"Variable":n,this.originalName=yE(n),this.name=bE(this.originalName),this.trainable_=r,this.constraint=a,this.val=py(t,this.trainable_,this.name,this.dtype)}var e=t.prototype;return e.read=function(){return this.assertNotDisposed(),this.val},e.write=function(t){return this.assertNotDisposed(),function(t,e){if(t.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(t.shape)+" vs. "+JSON.stringify(e.shape))}(this.val,t),this.val.id!==t.id&&(this.val.assign(t),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this},e.dispose=function(){this.assertNotDisposed(),this.val.dispose()},e.assertNotDisposed=function(){if(this.val.isDisposed)throw new Error("LayersVariable "+this.name+" is already disposed.")},jm(t,[{key:"trainable",get:function(){return this.trainable_},set:function(t){this.trainable_=t,this.val.trainable=t}}]),t}();function kI(t){return t.map((function(t){return t.read()}))}function SI(t){t.forEach((function(t){t[0].write(t[1])}))}var CI=function(t){this.dtype=t.dtype,this.shape=t.shape,null!=t.shape?this.ndim=t.shape.length:this.ndim=t.ndim,this.maxNDim=t.maxNDim,this.minNDim=t.minNDim,this.axes=t.axes||{}},RI=function(t,e,n,r,a,i,o){this.dtype=t,this.shape=e,this.sourceLayer=n,this.inputs=r,this.callArgs=a,this.outputTensorIndex=o,this.id=pI(),null!=i&&(this.originalName=yE(i),this.name=bE(this.originalName)),this.rank=e.length},NI=0,EI=function(){function t(t,e){this.callArgs=e,this.id=NI++,this.outboundLayer=t.outboundLayer,this.inboundLayers=t.inboundLayers,this.nodeIndices=t.nodeIndices,this.tensorIndices=t.tensorIndices,this.inputTensors=t.inputTensors,this.outputTensors=t.outputTensors,this.inputMasks=t.inputMasks,this.outputMasks=t.outputMasks,this.inputShapes=t.inputShapes,this.outputShapes=t.outputShapes;for(var n,r=Zm(t.inboundLayers);!(n=r()).done;){var a=n.value;null!=a&&a.outboundNodes.push(this)}t.outboundLayer.inboundNodes.push(this)}return t.prototype.getConfig=function(){for(var t,e=[],n=Zm(this.inboundLayers);!(t=n()).done;){var r=t.value;null!=r?e.push(r.name):e.push(null)}return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}},t}(),II=0,AI=function(t){function e(e){var n;void 0===e&&(e={}),(n=t.call(this)||this)._callHook=null,n._addedWeightNames=[],n._stateful=!1,n.id=II++,n.activityRegularizer=null,n.inputSpec=null,n.supportsMasking=!1,n._trainableWeights=[],n._nonTrainableWeights=[],n._losses=[],n._updates=[],n._built=!1,n.inboundNodes=[],n.outboundNodes=[];var r=e.name;if(!r){var a=n.getClassName();r=PN(a)+"_"+mI(a)}if(n.name=r,n.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){var i;if(null!=e.batchInputShape)i=e.batchInputShape;else if(null!=e.inputShape){var o=null;null!=e.batchSize&&(o=e.batchSize),i=[o].concat(e.inputShape)}n.batchInputShape=i;var s=e.dtype;null==s&&(s=e.inputDType),null==s&&(s="float32"),n.dtype=s}return null!=e.weights?n.initialWeights=e.weights:n.initialWeights=null,n._refCount=null,n.fastWeightInitDuringBuild=!1,n}Gm(e,t),e.nodeKey=function(t,e){return t.name+"_ib-"+e.toString()};var n=e.prototype;return n.getNodeAtIndex=function(t,e){if(0===this.inboundNodes.length)throw new TN("The layer has never been called and thus has no defined "+e+".");if(this.inboundNodes.length<=t)throw new DN("Asked to get "+e+" at node "+t+", but the layer has only "+this.inboundNodes.length+" inbound nodes.");return this.inboundNodes[t]},n.getInputAt=function(t){return zN(this.getNodeAtIndex(t,"input").inputTensors)},n.getOutputAt=function(t){return zN(this.getNodeAtIndex(t,"output").outputTensors)},n.calculateLosses=function(){return this.losses.map((function(t){return t()}))},n.resetStates=function(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")},n.assertInputCompatibility=function(t){if(t=BN(t),null!=this.inputSpec&&0!==this.inputSpec.length){var e=BN(this.inputSpec);if(t.length!==e.length)throw new DN("Layer "+this.name+" expects "+e.length+" inputs, but it received "+t.length+" input tensors. Input received: "+t);for(var n=0;n<t.length;n++){var r=t[n],a=e[n];if(null!=a){var i=r.rank;if(null!=a.ndim&&i!==a.ndim)throw new DN("Input "+n+" is incompatible with layer "+this.name+": expected ndim="+a.ndim+", found ndim="+i);if(null!=a.maxNDim&&i>a.maxNDim)throw new DN("Input "+n+" is incompatible with layer "+this.name+": expected max_ndim="+a.maxNDim+", found ndim="+i);if(null!=a.minNDim&&i<a.minNDim)throw new DN("Input "+n+" is incompatible with layer "+this.name+": expected min_ndim="+a.minNDim+", found ndim="+i+".");if(null!=a.dtype&&r.dtype!==a.dtype)throw new DN("Input "+n+" is incompatible with layer "+this.name+" : expected dtype="+a.dtype+", found dtype="+r.dtype+".");if(a.axes){var o=r.shape;for(var s in a.axes){var u=Number(s),c=a.axes[s],l=u>=0?o[u]:o[o.length+u];if(null!=c&&-1===[c,null].indexOf(l))throw new DN("Input "+n+" is incompatible with layer "+this.name+": expected axis "+u+" of input shape to have value "+c+" but got shape "+o+".")}}if(null!=a.shape)for(var h=0;h<a.shape.length;++h){var f=a.shape[h],p=r.shape[h];if(null!=f&&null!=p&&f!==p)throw new DN("Input "+n+" is incompatible with layer "+this.name+": expected shape="+a.shape+", found shape="+r.shape+".")}}}}},n.call=function(t,e){return t},n.invokeCallHook=function(t,e){null!=this._callHook&&this._callHook(t,e)},n.setCallHook=function(t){this._callHook=t},n.clearCallHook=function(){this._callHook=null},n.apply=function(t,e){var n=this;e=e||{},this.assertNotDisposed();for(var r,a=BN(t),i=!0,o=Zm(a);!(r=o()).done;){if(!(r.value instanceof RI)){i=!1;break}}for(var s,u=!0,c=Zm(a);!(s=c()).done;){if(s.value instanceof RI){u=!1;break}}if(i===u)throw new DN("Arguments to apply() must be all SymbolicTensors or all Tensors");return gE(this.name,(function(){if(!n.built){n.assertInputCompatibility(t);for(var r,i=[],o=Zm(BN(t));!(r=o()).done;){var s=r.value;i.push(s.shape)}n.build(zN(i)),n.built=!0,n.initialWeights&&n.setWeights(n.initialWeights),null===n._refCount&&u&&(n._refCount=1)}if(n.assertInputCompatibility(t),u){for(var c,l=n.call(t,e),h=[],f=Zm(BN(l));!(c=f()).done;){var p=c.value;-1!==a.indexOf(p)&&(p=p.clone()),h.push(p)}if(l=zN(h),null!=n.activityRegularizer)throw new _N("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return l}var d,m=function(t){t=BN(t);for(var e,n=[],r=Zm(t);!(e=r()).done;){var a=e.value;n.push(a.shape)}return zN(n)}(t),v=n.computeOutputShape(m);if(n.warnOnIncompatibleInputShape(Array.isArray(t)?m[0]:m),d=null!=v&&v.length>0&&Array.isArray(v[0])?v.map((function(r,a){return new RI("float32",r,n,BN(t),e,n.name,a)})):new RI("float32",v,n,BN(t),e,n.name),n.addInboundNode(t,d,null,null,m,v,e),n._refCount++,null!=n.activityRegularizer)throw new _N("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return d}))},n.warnOnIncompatibleInputShape=function(t){if(null!=this.batchInputShape)if(t.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+JSON.stringify(t)+") does not match that of the batchInputShape ("+JSON.stringify(this.batchInputShape)+") of the layer "+this.name);else{var e=!1;this.batchInputShape.forEach((function(n,r){null!=n&&null!=t[r]&&t[r]!==n&&(e=!0)})),e&&console.warn("The shape of the input tensor ("+JSON.stringify(t)+") does not match the expectation of layer "+this.name+": "+JSON.stringify(this.batchInputShape))}},n.countParams=function(){if(!this.built)throw new TN("You tried to call countParams() on "+this.name+", but the layer is not built yet. Build it first by calling build(batchInputShape).");return xI(this.weights)},n.build=function(t){this.built=!0},n.getWeights=function(t){return void 0===t&&(t=!1),kI(t?this.trainableWeights:this.weights)},n.setWeights=function(t){var e=this;Nb((function(){var n=e.weights;if(n.length!==t.length)throw new DN('You called setWeights(weights) on layer "'+e.name+'" with a weight list of length '+t.length+", but the layer was expecting "+n.length+" weights. Provided weights: "+t+"...");if(0!==n.length){for(var r=[],a=kI(n),i=0;i<a.length;++i){var o=a[i],s=n[i],u=t[i];if(!kv(o.shape,u.shape))throw new DN("Layer weight shape "+o.shape+" not compatible with provided weight shape "+u.shape);r.push([s,u])}SI(r)}}))},n.addWeight=function(t,e,n,r,a,i,o){if(-1!==this._addedWeightNames.indexOf(t))throw new DN("Duplicate weight name "+t+" for layer "+this.name);this._addedWeightNames.push(t),null==n&&(n="float32"),this.fastWeightInitDuringBuild&&(r=lI("zeros"));var s=r.apply(e,n),u=new wI(s,n,t,i,o);return s.dispose(),null!=a&&this.addLoss((function(){return a.apply(u.read())})),null==i&&(i=!0),i?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u},n.setFastWeightInitDuringBuild=function(t){this.fastWeightInitDuringBuild=t},n.addLoss=function(t){var e;null==t||Array.isArray(t)&&0===t.length||(t=BN(t),void 0!==this._losses&&null!==this._losses&&(e=this.losses).push.apply(e,t))},n.computeOutputShape=function(t){return t},n.computeMask=function(t,e){var n=this;if(!this.supportsMasking){if(null!=e){if(!Array.isArray(e))throw new TypeError("Layer "+this.name+" does not support masking, but was passed an inputMask.");e.forEach((function(t){if(null!=t)throw new TypeError("Layer "+n.name+" does not support masking, but was passed an inputMask.")}))}return null}return e},n.addInboundNode=function(t,e,n,r,a,i,o){void 0===o&&(o=null);var s=BN(t);e=BN(e),n=BN(n),r=BN(r),a=gI(a),i=gI(i);for(var u,c=[],l=[],h=[],f=Zm(s);!(u=f()).done;){var p=u.value;c.push(p.sourceLayer),l.push(p.nodeIndex),h.push(p.tensorIndex)}new EI({outboundLayer:this,inboundLayers:c,nodeIndices:l,tensorIndices:h,inputTensors:s,outputTensors:e,inputMasks:n,outputMasks:r,inputShapes:a,outputShapes:i},o);for(var d=0;d<e.length;d++)e[d].sourceLayer=this,e[d].nodeIndex=this.inboundNodes.length-1,e[d].tensorIndex=d},n.getConfig=function(){var t={name:this.name,trainable:this.trainable};return null!=this.batchInputShape&&(t.batchInputShape=this.batchInputShape),null!=this.dtype&&(t.dtype=this.dtype),t},n.disposeWeights=function(){return this.weights.forEach((function(t){return t.dispose()})),this.weights.length},n.assertNotDisposed=function(){if(0===this._refCount)throw new Error("Layer '"+this.name+"' is already disposed.")},n.dispose=function(){if(!this.built)throw new Error("Cannot dispose Layer "+this.name+" because it has not been built yet.");if(null===this._refCount)throw new Error("Cannot dispose Layer "+this.name+" because it has not been used yet.");this.assertNotDisposed();var t=0;return 0==--this._refCount&&(t=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:t}},jm(e,[{key:"input",get:function(){if(this.inboundNodes.length>1)throw new AN("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use `getInputAt(nodeIndex)` instead.');if(0===this.inboundNodes.length)throw new AN("Layer "+this.name+" is not connected, no input to return.");return zN(this.getNodeAtIndex(0,"input").inputTensors)}},{key:"output",get:function(){if(0===this.inboundNodes.length)throw new AN("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new AN("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return zN(this.getNodeAtIndex(0,"output").outputTensors)}},{key:"losses",get:function(){return this._losses}},{key:"updates",get:function(){return this._updates}},{key:"built",get:function(){return this._built},set:function(t){this._built=t}},{key:"trainable",get:function(){return this.trainable_},set:function(t){this._trainableWeights.forEach((function(e){return e.trainable=t})),this.trainable_=t}},{key:"trainableWeights",get:function(){return this.trainable_?this._trainableWeights.filter((function(t){return t.trainable})):[]},set:function(t){this._trainableWeights=t}},{key:"nonTrainableWeights",get:function(){return this.trainable?this._trainableWeights.filter((function(t){return!t.trainable})).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)},set:function(t){this._nonTrainableWeights=t}},{key:"weights",get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)}},{key:"stateful",get:function(){return this._stateful}},{key:"outputShape",get:function(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new AN("The layer "+this.name+" has never been called and thus has no defined output shape.");for(var t,e=[],n=Zm(this.inboundNodes);!(t=n()).done;){var r=t.value,a=JSON.stringify(r.outputShapes);-1===e.indexOf(a)&&e.push(a)}if(1===e.length){var i=this.inboundNodes[0].outputShapes;return Array.isArray(i)&&Array.isArray(i[0])&&1===i.length?i[0]:i}throw new AN("The layer "+this.name+' has multiple inbound nodes with different output shapes. Hence the notion of "outut shape" is ill-defined for the layer.')}}]),e}(_k);var TI,DI=function(t){function e(e){var n;if(n=t.call(this,{dtype:e.dtype,name:null!=e.name?e.name:mI("input").toString()})||this,null==e.batchSize&&(e.batchSize=null),null==e.sparse&&(e.sparse=!1),n.trainable=!1,n.built=!0,n.sparse=e.sparse,null!=e.inputShape&&null!=e.batchInputShape)throw new DN("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");var r=e.batchInputShape;if(null==r){if(null==e.inputShape)throw new DN("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");r=[e.batchSize].concat(e.inputShape)}else if(null!=e.batchSize)throw new DN("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");var a=e.dtype||"float32";n.batchInputShape=r,n.dtype=a,n.inputSpec=[{shape:r}];var i=new RI(n.dtype,n.batchInputShape,Jm(n),[],{},n.name);return i.nodeIndex=0,i.tensorIndex=0,new EI({outboundLayer:Jm(n),inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[i],outputTensors:[i],inputMasks:[null],outputMasks:[null],inputShapes:[r],outputShapes:[r]}),n}Gm(e,t);var n=e.prototype;return n.apply=function(t,e){throw new DN("Cannot pass any input to an InputLayer's apply() method. InputLayer name: "+this.name)},n.dispose=function(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}},n.getConfig=function(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}},e}(AI);function _I(t){if(null==t.batchShape&&null==t.shape)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(null!=t.batchShape&&null!=t.shape)throw new DN("Please provide either a `shape` or `batchShape` argument to Input, but not both.");var e=t.batchShape;null!=t.shape&&null==e&&(e=[null].concat(t.shape));var n=t.dtype;return null==n&&(n="float32"),new DI({batchInputShape:e,name:t.name,dtype:n,sparse:t.sparse}).inboundNodes[0].outputTensors[0]}function OI(t){return FI.apply(this,arguments)}function FI(){return(FI=Vm(regeneratorRuntime.mark((function t(e){var n,r,a,i,o,s,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=e){t.next=2;break}return t.abrupt("return");case 2:for(i in n=[],r=[],a=[],e)"number"!=typeof(o=e[i])&&(s=o,n.push(s.data()),r.push(i),a.push(s));if(!(n.length>0)){t.next=12;break}return t.next=9,Promise.all(n);case 9:for(u=t.sent,c=0;c<u.length;++c)e[r[c]]=u[c][0];Eb(a);case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function MI(t){if(null!=t)for(var e in t){var n=t[e];"number"!=typeof n&&n.dispose()}}DI.className="InputLayer",Fk(DI),function(t){t[t.SILENT=0]="SILENT",t[t.VERBOSE=1]="VERBOSE"}(TI||(TI={}));var LI=function(){function t(){this.validationData=null}var e=t.prototype;return e.setParams=function(t){this.params=t},e.onEpochBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),e.onEpochEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),e.onBatchBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),e.onBatchEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),e.onTrainBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),e.onTrainEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),e.setModel=function(t){},t}(),zI=function(){function t(t,e){void 0===e&&(e=10),null==t&&(t=[]),this.callbacks=t,this.queueLength=e}var e=t.prototype;return e.append=function(t){this.callbacks.push(t)},e.setParams=function(t){for(var e,n=Zm(this.callbacks);!(e=n()).done;){e.value.setParams(t)}},e.setModel=function(t){for(var e,n=Zm(this.callbacks);!(e=n()).done;){e.value.setModel(t)}},e.onEpochBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==n&&(n={}),r=Zm(this.callbacks);case 2:if((a=r()).done){t.next=8;break}return i=a.value,t.next=6,i.onEpochBegin(e,n);case 6:t.next=2;break;case 8:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.onEpochEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==n&&(n={}),r=Zm(this.callbacks);case 2:if((a=r()).done){t.next=8;break}return i=a.value,t.next=6,i.onEpochEnd(e,n);case 6:t.next=2;break;case 8:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.onBatchBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==n&&(n={}),r=Zm(this.callbacks);case 2:if((a=r()).done){t.next=8;break}return i=a.value,t.next=6,i.onBatchBegin(e,n);case 6:t.next=2;break;case 8:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.onBatchEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==n&&(n={}),r=Zm(this.callbacks);case 2:if((a=r()).done){t.next=8;break}return i=a.value,t.next=6,i.onBatchEnd(e,n);case 6:t.next=2;break;case 8:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.onTrainBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==e&&(e={}),n=Zm(this.callbacks);case 2:if((r=n()).done){t.next=8;break}return a=r.value,t.next=6,a.onTrainBegin(e);case 6:t.next=2;break;case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.onTrainEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==e&&(e={}),n=Zm(this.callbacks);case 2:if((r=n()).done){t.next=8;break}return a=r.value,t.next=6,a.onTrainEnd(e);case 6:t.next=2;break;case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),BI=function(t){function e(){return t.call(this)||this}Gm(e,t);var n=e.prototype;return n.onEpochBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.seen=0,this.totals={};case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.onBatchEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(i in null==n&&(n={}),r=null==n.size?0:n.size,this.seen+=r,a=function(t){var e=n[t];if("number"==typeof e)o.totals.hasOwnProperty(t)||(o.totals[t]=0),o.totals[t]=o.totals[t]+e*r;else{var a;t in o.totals?a=o.totals[t]:o.totals[t]=0;var i=Nb((function(){return Db(o.totals[t],kx(e,r))}));o.totals[t]=i,null!=a&&a.dispose()}},n)a(i);case 5:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.onEpochEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==n){t.next=9;break}r=function(){var t=i.value;if(null==o.totals[t])return"continue";"number"==typeof o.totals[t]?n[t]=o.totals[t]/o.seen:Nb((function(){var e=kx(Ix(1,o.seen),o.totals[t]);n[t]=e,o.totals[t].dispose(),Ib(n[t])}))},a=Zm(this.params.metrics);case 3:if((i=a()).done){t.next=9;break}if("continue"!==r()){t.next=7;break}return t.abrupt("continue",7);case 7:t.next=3;break;case 9:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e}(LI),PI=function(t){function e(){return t.apply(this,arguments)||this}Gm(e,t);var n=e.prototype;return n.onTrainBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.epoch=[],this.history={};case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.onEpochEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r in null==n&&(n={}),this.epoch.push(e),n)null==this.history[r]&&(this.history[r]=[]),this.history[r].push(n[r]);case 3:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.syncData=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o,s,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(a in e=[],n=[],r=[],this.history)for(i=this.history[a],o=0;o<i.length;++o)"number"!=typeof i[o]&&(s=i[o],e.push(s.data()),n.push(a),r.push(o));return t.next=6,Promise.all(e);case 6:for(u=t.sent,c=0;c<u.length;++c)this.history[n[c]][r[c]].dispose(),this.history[n[c]][r[c]]=u[c][0];case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LI),WI=function(t){function e(e,n){var r;if((r=t.call(this)||this).currentEpoch=0,r.yieldEvery=n||"auto","auto"===r.yieldEvery&&(r.yieldEvery=125),"never"===r.yieldEvery&&null!=e.onYield)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");return Vv(r.yieldEvery)&&(r.maybeWait=function(t,e){var n,r=Jv();return function(){var a=Jv();return a-r<e?n:(r=a,n=t.apply(void 0,arguments))}}(r.maybeWait.bind(Jm(r)),r.yieldEvery)),r.trainBegin=e.onTrainBegin,r.trainEnd=e.onTrainEnd,r.epochBegin=e.onEpochBegin,r.epochEnd=e.onEpochEnd,r.batchBegin=e.onBatchBegin,r.batchEnd=e.onBatchEnd,r.yield=e.onYield,r}Gm(e,t);var n=e.prototype;return n.maybeWait=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n,r){var a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],null==this.yield){t.next=5;break}return t.next=4,OI(r);case 4:a.push(this.yield(e,n,r));case 5:return a.push(eN()),t.next=8,Promise.all(a);case 8:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),n.onEpochBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.currentEpoch=e,null==this.epochBegin){t.next=6;break}return t.next=4,OI(n);case 4:return t.next=6,this.epochBegin(e,n);case 6:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.onEpochEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],null==this.epochEnd){t.next=5;break}return t.next=4,OI(n);case 4:r.push(this.epochEnd(e,n));case 5:return"epoch"===this.yieldEvery&&r.push(eN()),t.next=8,Promise.all(r);case 8:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.onBatchBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==this.batchBegin){t.next=5;break}return t.next=3,OI(n);case 3:return t.next=5,this.batchBegin(e,n);case 5:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.onBatchEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],null==this.batchEnd){t.next=5;break}return t.next=4,OI(n);case 4:r.push(this.batchEnd(e,n));case 5:return"batch"===this.yieldEvery?r.push(eN()):Vv(this.yieldEvery)&&r.push(this.maybeWait(this.currentEpoch,e,n)),t.next=8,Promise.all(r);case 8:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.onTrainBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==this.trainBegin){t.next=5;break}return t.next=3,OI(e);case 3:return t.next=5,this.trainBegin(e);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.onTrainEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==this.trainEnd){t.next=5;break}return t.next=3,OI(e);case 3:return t.next=5,this.trainEnd(e);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(LI);function VI(t,e){return null==t&&(t={}),t instanceof LI?[t]:Array.isArray(t)&&t[0]instanceof LI?t:BN(t).map((function(t){return new WI(t,e)}))}var UI=function(){function t(){}return t.registerCallbackConstructor=function(e,n){gv(e>=0&&Number.isInteger(e),(function(){return"Verbosity level is expected to be an integer >= 0, but got "+e})),t.checkForDuplicate(n),null==t.constructors[e]&&(t.constructors[e]=[]),t.constructors[e].push(n)},t.checkForDuplicate=function(e){for(var n in t.constructors){t.constructors[+n].forEach((function(t){if(t===e)throw new DN("Duplicate callback constructor.")}))}},t.clear=function(){t.constructors={}},t.createCallbacks=function(e){var n=[];for(var r in t.constructors){var a=+r;e>=a&&n.push.apply(n,t.constructors[a])}return n.map((function(t){return new t}))},t}();function jI(t,e,n,r,a,i,o,s,u){var c=new PI,l=[new BI].concat(UI.createCallbacks(e));null!=t&&l.push.apply(l,t),l.push(c);var h=new zI(l);return h.setParams({epochs:n,initialEpoch:r,samples:a,steps:i,batchSize:o,verbose:e,doValidation:s,metrics:u}),{callbackList:h,history:c}}function GI(t,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),jN(t,Ok.getMap().classNameMap,e,"layer",n)}function qI(t,e){return Nb((function(){"float32"!==t.dtype&&(t=t.asType("float32"));var n=Yy(BE(t),e,!0),r=vy(n.shape,IN()),a=ux(vx(n,r));return Ix(t,a)}))}function HI(t,e){return Nb((function(){return Hy(BE(Dx(e,t)),-1)}))}function KI(t,e){return Nb((function(){return Hy(_b(Dx(e,t)),-1)}))}function XI(t,e){return Nb((function(){var n=Dx(t,e),r=Wb(_b(t),IN(),Number.MAX_VALUE),a=_b(Ix(n,r));return kx(100,Hy(a,-1))}))}function YI(t,e,n){return void 0===n&&(n=!1),Nb((function(){if(n)e=AC(e);else{var r=Yy(e,e.shape.length-1,!0);e=Ix(e,r)}return e=Wb(e,IN(),1-IN()),Jb(Yy(kx(t.toFloat(),Kb(e)),e.shape.length-1))}))}function JI(t,e,n){return void 0===n&&(n=!1),Nb((function(){var r,a,i=Hb((r=t,a=[kE(r.shape)],r.reshape(a))).toInt(),o=(e=Wb(e,IN(),1-IN())).shape;return YI(xk(i,o[o.length-1]).reshape(o),e,n)}))}function $I(t,e){return Nb((function(){var n;return n=Wb(e,IN(),1-IN()),n=Kb(Ix(n,Dx(1,n))),Hy(function(t,e){if(!kv(t.shape,e.shape))throw new DN("logits and labels must have the same shape, but got shapes "+JSON.stringify(t.shape)+" and "+JSON.stringify(e.shape));return Nb((function(){var n=e.relu(),r=e.abs().neg();return n.sub(e.mul(t)).add(r.exp().log1p())}))}(t,n),-1)}))}function ZI(t,e){return Nb((function(){var n=qI(t,-1),r=qI(e,-1),a=kx(n,r);return Jb(Yy(a,-1))}))}UI.constructors={};var QI={meanSquaredError:HI,meanAbsoluteError:KI,meanAbsolutePercentageError:XI,meanSquaredLogarithmicError:function(t,e){return Nb((function(){var n=Wb(e,IN(),Number.MAX_VALUE),r=Kb(Db(1,n)),a=Wb(t,IN(),Number.MAX_VALUE),i=Kb(Db(1,a));return Hy(BE(Dx(r,i)),-1)}))},squaredHinge:function(t,e){return Nb((function(){var n=vx(0,Dx(1,kx(t,e)));return Hy(BE(n),-1)}))},hinge:function(t,e){return Nb((function(){var n=vx(0,Dx(1,kx(t,e)));return Hy(n,-1)}))},categoricalHinge:function(t,e){return Nb((function(){var n=Yy(kx(t,e),-1),r=kS(kx(Dx(1,t),e),-1);return vx(0,Db(1,Dx(r,n)))}))},logcosh:function(t,e){return Nb((function(){var n=Math.log(2),r=Dx(e,t),a=Dx(Db(r,sx(kx(-2,r))),n);return Hy(a,-1)}))},categoricalCrossentropy:YI,sparseCategoricalCrossentropy:JI,binaryCrossentropy:$I,kullbackLeiblerDivergence:function(t,e){return Nb((function(){var n=Wb(t,IN(),1),r=Wb(e,IN(),1);return Yy(kx(t,Kb(Ix(n,r))),-1)}))},poisson:function(t,e){return Nb((function(){var n=Kb(Db(IN(),e));return Hy(Dx(e,kx(t,n)),-1)}))},cosineProximity:ZI};function tA(t){if("string"==typeof t){if(t in QI)return QI[t];var e="Unknown loss "+t;throw t.toLowerCase().includes("softmaxcrossentropy")&&(e="Unknown loss "+t+'. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'),new DN(e)}return t}function eA(t,e){return Nb((function(){var n=kx(.5,by(e)),r=EE(gS(e,n),t.dtype);return Hy(mS(t,r),-1)}))}function nA(t,e){return Nb((function(){return EE(mS(jy(t,-1),jy(e,-1)),"float32")}))}function rA(t,e){return Nb((function(){return sS(t.equal(1),e.equal(1)).sum().cast("float32")}))}function aA(t,e){return Nb((function(){var n=rA(t,e),r=function(t,e){return Nb((function(){return sS(t.equal(0),e.equal(1)).sum().cast("float32")}))}(t,e),a=n.add(r);return hS(gS(a,0),n.div(a),0).cast("float32")}))}function iA(t,e){return Nb((function(){var n=rA(t,e),r=function(t,e){return Nb((function(){return sS(t.equal(1),e.equal(0)).sum().cast("float32")}))}(t,e),a=n.add(r);return hS(gS(a,0),n.div(a),0).cast("float32")}))}function oA(t,e){return $I(t,e)}function sA(t,e){return t.rank===e.rank&&(t=t.squeeze([t.rank-1])),(e=e.argMax(-1)).dtype!==t.dtype&&(e=e.asType(t.dtype)),mS(t,e).asType("float32")}var uA=YI,cA=JI,lA={binaryAccuracy:eA,categoricalAccuracy:nA,precision:aA,categoricalCrossentropy:uA,sparseCategoricalCrossentropy:cA,mse:HI,MSE:HI,mae:KI,MAE:KI,mape:XI,MAPE:XI,cosine:ZI};function hA(t){if("string"==typeof t&&t in lA)return lA[t];if("string"!=typeof t&&null!=t)return t;throw new DN("Unknown metric "+t)}function fA(t){if(MN(null!==t,"Unknown LossOrMetricFn "+t),"string"==typeof t)return t;for(var e,n=0,r=Object.keys(QI);n<r.length;n++){var a=r[n];if(QI[a]===t){e=a;break}}if(void 0!==e)return e;for(var i=0,o=Object.keys(lA);i<o.length;i++){var s=o[i];if(lA[s]===t){e=s;break}}return void 0!==e?e:t.name}function pA(t,e,n){if(void 0===n&&(n=!1),null==t||"object"!=typeof t||Object.getPrototypeOf(t)!==Object.prototype||!function t(e){if(null===e)return!0;if("object"==typeof e){if(Object.getPrototypeOf(e)===Object.prototype){for(var n=Object.keys(e),r=0,a=n;r<a.length;r++){var i=a[r];if("string"!=typeof i)return!1;if(!t(e[i]))return!1}return!0}if(Array.isArray(e)){for(var o,s=Zm(e);!(o=s()).done;){var u=o.value;if(!t(u))return!1}return!0}return!1}var c=typeof e;return"string"===c||"number"===c||"boolean"===c}(t))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){var r=JSON.stringify(t);r.length>1048576&&console.warn('User-defined metadata of model "'+e+'" 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 <= 1048576.")}}function dA(t,e,n,r){void 0===r&&(r=console.log);var a,i=function(t){var e=!0,n=[],r=[];for(var a in t.nodesByDepth)n.push(t.nodesByDepth[a]);for(var i=0,o=n;i<o.length;i++){var s=o[i];if(s.length>1||1===s.length&&s[0].inboundLayers.length>1){e=!1;break}r.push.apply(r,s)}if(e)for(var u,c=Zm(t.layers);!(u=c()).done;){for(var l,h=u.value,f=!1,p=Zm(h.inboundNodes);!(l=p()).done;){var d=l.value;if(-1!==r.indexOf(d)){if(f){e=!1;break}f=!0}}if(!e)break}return e}(t),o=["Layer (type)","Output shape","Param #"];if(i?(e=e||65,n=n||[.45,.85,1]):(e=e||98,n=n||[.33,.55,.67,1]),n[n.length-1]<=1&&(n=n.map((function(t){return Math.floor(e*t)}))),!i)for(var s in o.push("Receives inputs"),a=[],t.nodesByDepth){var u;(u=a).push.apply(u,t.nodesByDepth[s])}r("_".repeat(e)),mA(o,n,r),r("=".repeat(e));for(var c=t.layers,l=0;l<c.length;++l)i?vA(c[l],n,r):gA(c[l],n,a,r),r((l===c.length-1?"=":"_").repeat(e));t.checkTrainableWeightsConsistency();var h=function(t){var e;e=null!=t.collectedTrainableWeights?xI(t.collectedTrainableWeights):xI(t.trainableWeights);return e}(t),f=xI(t.nonTrainableWeights);r("Total params: "+(h+f)),r("Trainable params: "+h),r("Non-trainable params: "+f),r("_".repeat(e))}function mA(t,e,n){void 0===n&&(n=console.log);for(var r="",a=0;a<t.length;++a)a>0&&(r=r.slice(0,r.length-1)+" "),r=(r+=t[a]).slice(0,e[a]),r+=" ".repeat(e[a]-r.length);n(r)}function vA(t,e,n){var r;try{r=JSON.stringify(t.outputShape)}catch(t){r="multiple"}mA([t.name+" ("+t.getClassName()+")",r,t.countParams().toString()],e,n)}function gA(t,e,n,r){var a;try{a=JSON.stringify(t.outputShape)}catch(t){a="multiple"}for(var i,o=[],s=Zm(t.inboundNodes);!(i=s()).done;){var u=i.value;if(!(null!=n&&n.length>0&&-1===n.indexOf(u)))for(var c=0;c<u.inboundLayers.length;++c){var l=u.inboundLayers[c].name,h=u.nodeIndices[c],f=u.tensorIndices[c];o.push(l+"["+h+"]["+f+"]")}}var p=t.name,d=t.getClassName(),m=0===o.length?"":o[0];mA([p+" ("+d+")",a,t.countParams().toString(),m],e,r);for(var v=1;v<o.length;++v)mA(["","","",o[v]],e,r)}function yA(t,e,n){return("inboundNodes"===t||"outputLayers"===t||"inputLayers"===t)&&0===e&&"string"==typeof n}function bA(t,e){if(null===t)return null;if("string"==typeof t)return WN(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){for(var n=[],r=t.length,a=0;a<r;++a){var i=t[a];yA(e,a,i)?n.push(i):n.push(bA(i,e))}return n}for(var o={},s=0,u=Object.keys(t);s<u.length;s++){var c=u[s],l=t[c];if("name"===c&&"string"==typeof l)o[c]=l;else{var h=WN(c);o[h]=bA(l,h)}}return o}var xA=function(){function t(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof t)for(var n in e.id2Value)this.id2Value[n]=e.id2Value[n],n in e.id2Mask&&(this.id2Mask[n]=e.id2Mask[n]);else{if(null==e)return;for(var r,a=Zm(e);!(r=a()).done;){var i=r.value;this.add(i.key,i.value)}}}var e=t.prototype;return e.add=function(t,e,n){if(null!=this.id2Value[t.id])throw new DN("Duplicate key: name="+t.name+", id="+t.id);return this.id2Value[t.id]=function(t,e){if(null==t.dtype||t.dtype===e.dtype)return e;try{return Ry(e,t.dtype)}catch(n){throw new DN("The dtype of the feed ("+e.dtype+") can not be cast to the dtype of the key '"+t.name+"' ("+t.dtype+").")}}(t,e),this.name2Id[t.name]=t.id,null!=n&&(this.id2Mask[t.id]=n),this},e.addFeed=function(t){this.add(t.key,t.value)},e.hasKey=function(t){return null!=this.id2Value[t.id]},e.names=function(){return Object.keys(this.name2Id)},e.getValue=function(t){if(t instanceof RI){if(null==this.id2Value[t.id])throw new DN("Nonexistent key: "+t.name);return this.id2Value[t.id]}var e=this.name2Id[t];if(null==e)throw new DN("Feed dict has no SymbolicTensor name: "+t);return this.id2Value[e]},e.getMask=function(t){if(t instanceof RI){if(null==this.id2Value[t.id])throw new DN("Nonexistent key: "+t.name);return this.id2Mask[t.id]}var e=this.name2Id[t];if(null==e)throw new DN("Feed dict has no SymbolicTensor name: "+t);return this.id2Mask[e]},e.disposeMasks=function(){null!=this.id2Mask&&Eb(this.id2Mask)},t}(),wA={},kA={};function SA(t,e,n,r){for(var a,i=null!=n&&n.training,o=Array.isArray(t),s=o?t:[t],u=s.map((function(t){return t.name})),c=[],l=e.names(),h=Zm(u);!(a=h()).done;){var f=a.value;-1!==l.indexOf(f)?c.push(e.getValue(f)):c.push(null)}null!=r&&(r.maxNumTensors=-1/0,r.minNumTensors=1/0);var p,d,m=u.join(",")+"|"+e.names().join(",");if(null==wA[m]){var v=function(t,e){gv(null!=t&&t.length>0,(function(){return"Expected at least one fetch, got none"}));var n=[],r={};if(1===t.length){var a=RA(t[0],e);n=a.sorted,r=a.recipientMap}else for(var i,o=new Set,s=Zm(t);!(i=s()).done;){for(var u,c=RA(i.value,e),l=c.sorted,h=c.recipientMap,f=Zm(l);!(u=f()).done;){var p=u.value;o.has(p.name)||(n.push(p),o.add(p.name))}var d=function(t){null==r[t]&&(r[t]=new Set),h[t].forEach((function(e){return r[t].add(e)}))};for(var m in h)d(m)}return{sorted:n,recipientCounts:CA(r)}}(s,e);p=v.sorted,d=v.recipientCounts,wA[m]=p,kA[m]=d}p=wA[m],d={},i||Object.assign(d,kA[m]);for(var g=new xA(e),y=0;y<p.length;++y){if(null!=r){var b=Rb().numTensors;b>r.maxNumTensors&&(r.maxNumTensors=b),b<r.minNumTensors&&(r.minNumTensors=b)}var x=p[y],w=x.sourceLayer;if(!(w instanceof DI)){for(var k,S=[],C=[],R=[],N=!1,E=Zm(x.inputs);!(k=E()).done;){var I=k.value,A=g.getValue(I),T=g.getMask(I);S.push(A),C.push(T),null!=T&&(N=!0),i||(d[I.name]--,0!==d[I.name]||e.hasKey(I)||-1!==u.indexOf(I.name)||A.isDisposed||!0===I.sourceLayer.stateful||R.push(A))}N&&((n=n||{}).mask=C[0]);var D=BN(w.apply(S,n)),_=null;w.supportsMasking&&(_=w.computeMask(S,C));for(var O=NA(x),F=Array.isArray(O)?O:[O],M=0;M<F.length;++M){g.hasKey(F[M])||g.add(F[M],D[M],Array.isArray(_)?_[0]:_);var L=u.indexOf(F[M].name);-1!==L&&(c[L]=D[M])}i||Eb(R)}}return g.disposeMasks(),o?c:c[0]}function CA(t){var e={};for(var n in t)e[n]=t[n].size;return e}function RA(t,e){for(var n,r=new Set,a=[],i={},o=Zm(e.names());!(n=o()).done;){var s=n.value;r.add(s)}var u=[],c=[];for(u.push(t);u.length>0;){var l=u[u.length-1];if(r.has(l.name))u.pop();else{var h=c[c.length-1]===u.length-1;if(0===l.inputs.length||h)u.pop(),a.push(l),r.add(l.name),h&&c.pop();else{c.push(u.length-1);for(var f,p=Zm(l.inputs);!(f=p()).done;){var d=f.value;null==i[d.name]&&(i[d.name]=new Set),i[d.name].add(l.name),r.has(d.name)||u.push(d)}}}}return{sorted:a,recipientMap:i}}function NA(t){var e;if(1===t.sourceLayer.inboundNodes.length)e=t.sourceLayer.output;else{for(var n=null,r=0;r<t.sourceLayer.inboundNodes.length;++r)for(var a,i=Zm(t.sourceLayer.inboundNodes[r].outputTensors);!(a=i()).done;){if(a.value.id===t.id){n=r;break}}e=t.sourceLayer.getOutputAt(n)}return e}function EA(t,e){return function(t,e,n){var r=e.length;if(null==t||Array.isArray(t)&&0===t.length)return e.map((function(t){return null}));if(1===r)return Array.isArray(t)&&1===t.length?t:"object"==typeof t&&e[0]in t?[t[e[0]]]:[t];if(Array.isArray(t)){if(t.length!==r)throw new Error("Provided "+n+" is an array of "+t.length+" element(s), but the model has "+r+" outputs. Make sure a set of weights is provided for each model output.");return t}if("object"==typeof t&&Object.keys(t).length>0&&"object"==typeof t[Object.keys(t)[0]]){var a=[];return e.forEach((function(e){e in t?a.push(t[e]):a.push(null)})),a}throw new Error("The model has multiple ("+r+") outputs, so "+n+" must be either an array with "+r+" elements or an object with "+e+" keys. Provided "+n+" not understood: "+JSON.stringify(t))}(t,e,"classWeight")}function IA(t,e,n,r){return AA.apply(this,arguments)}function AA(){return(AA=Vm(regeneratorRuntime.mark((function t(e,n,r,a){var i,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==n&&null==a){t.next=2;break}throw new Error("Support sampleWeight is not implemented yet");case 2:if(null==r){t.next=15;break}return i=Nb((function(){if(1===e.shape.length)return e.clone();if(2===e.shape.length){if(e.shape[1]>1){return e.argMax(1)}if(1===e.shape[1])return e.reshape([e.shape[0]]);throw new Error("Encountered unexpected last-dimension size ("+e.shape[1]+") during handling of class weights. The size is expected to be >= 1.")}throw new Error("Unexpected rank of target (y) tensor ("+e.rank+") during handling of class weights. The rank is expected to be 1 or 2.")})),t.t0=Array,t.next=7,i.data();case 7:return t.t1=t.sent,o=t.t0.from.call(t.t0,t.t1),Eb(i),s=[],o.forEach((function(t){if(null==r[t])throw new Error("classWeight must contain all classes in the training data. The class "+t+" exists in the data but not in classWeight");s.push(r[t])})),t.abrupt("return",sy(s,"float32"));case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function TA(t,e){return kx(t,e)}function DA(t,e){var n,r,a=e;n=a.xs,r=a.ys,gv(null!=n&&null!=r,(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 "+e}));var i=_A("input",t.inputNames,n),o=_A("output",t.outputNames,r),s=i[0].shape[0];gv(i.length===t.inputs.length,(function(){return"LayersModel has "+t.inputs.length+" inputs, but the dataset provides "+i.length+" inputs. (Expected input keys: "+JSON.stringify(t.inputNames)+")"})),gv(o.length===t.outputs.length,(function(){return"LayersModel has "+t.outputs.length+" outputs, but the dataset provides "+o.length+" outputs. (Expected output keys: "+JSON.stringify(t.outputNames)+")"}));for(var u=function(e){gv(i[e].shape[0]===s,(function(){return"Batch size mismatch: input "+t.inputNames[e]+" has "+i[e].shape[0]+"; expected "+s+" based on input "+t.inputNames[0]+"."}))},c=0;c<i.length;c++)u(c);for(var l=function(e){gv(o[e].shape[0]===s,(function(){return"Batch size mismatch: output "+t.outputNames[e]+" has "+o[e].shape[0]+"; expected "+s+" based on input "+t.inputNames[0]+"."}))},h=0;h<o.length;h++)l(h);return{xs:i,ys:o}}function _A(t,e,n){if(n instanceof pg)return[n];if(Array.isArray(n))return gv(n.length===e.length,(function(){return"Received an array of "+n.length+" Tensors, but expected "+e.length+" to match the "+t+" keys "+e+"."})),n;for(var r,a=[],i=Zm(e);!(r=i()).done;){var o=r.value;if(null==n[o])throw new DN("The feature data generated by the dataset lacks the required "+t+" key '"+o+"'.");a.push(n[o])}return a}function OA(t){if(3===t.length)throw new _N("Validation with sample weights is not implemented yet.");return{xs:t[0],ys:t[1]}}function FA(t,e,n){return MA.apply(this,arguments)}function MA(){return(MA=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f,p,d,m,v,g,y,b,x,w,k,S,C,R,N,E,I,A,T,D,_,O,F,M,L;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null!=r.batchesPerEpoch,gv(null!=e.optimizer,(function(){return"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."})),gv(null!=r,(function(){return"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."})),gv(null!=r.epochs&&r.epochs>0&&Number.isInteger(r.epochs),(function(){return"For fitDataset(), config.epochs is expected to be a positive integer, but got "+r.epochs})),gv(!a||r.batchesPerEpoch>0&&Number.isInteger(r.batchesPerEpoch),(function(){return"For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got "+r.batchesPerEpoch})),gv(null==r.validationSplit,(function(){return"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."})),!e.isTraining){t.next=8;break}throw new Error("Cannot start training because another fit() call is ongoing.");case 8:return e.isTraining=!0,t.prev=9,(i=null!=r.validationData)&&(zA(r.validationData)?gv(null==r.validationBatches||r.validationBatches>0&&Number.isInteger(r.validationBatches),(function(){return"For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got "+r.validationBatches})):(u=OA(r.validationData),o=u.xs,s=u.ys)),c=e.makeTrainFunction(),l=e.getDedupedMetricsNames(),h=i?l.slice().concat(l.map((function(t){return"val_"+t}))):l.slice(),f=VI(r.callbacks,r.yieldEvery),p=null==r.verbose?1:r.verbose,d=jI(f,p,r.epochs,null,null,LA(n,r),null,i,h),m=d.callbackList,v=d.history,m.setModel(e),e.history=v,t.next=22,m.onTrainBegin();case 22:return e.stopTraining_=!1,g=null==r.initialEpoch?0:r.initialEpoch,t.next=26,n.iterator();case 26:y=t.sent;case 27:if(!(g<r.epochs)){t.next=98;break}return b={},t.next=31,m.onEpochBegin(g);case 31:if(x=0,w=0,a){t.next=37;break}return t.next=36,n.iterator();case 36:y=t.sent;case 37:if(a&&!(x<r.batchesPerEpoch)){t.next=91;break}return t.next=40,y.next();case 40:if(k=t.sent,!a||!k.done){t.next=44;break}return console.warn("You provided `batchesPerEpoch` as "+r.batchesPerEpoch+", but your dataset iterator ran out of data after "+x+" batches; interrupting training. Make sure that your dataset can generate at least `batchesPerEpoch * epochs` batches (in this case, "+r.batchesPerEpoch*r.epochs+" batches). You may need to use the repeat() function when building your dataset."),t.abrupt("break",91);case 44:if(null==k.value){t.next=73;break}return S=DA(e,k.value),C=S.xs,R=S.ys,(N={}).batch=w,N.size=C[0].shape[0],t.next=51,m.onBatchBegin(w,N);case 51:if(E=[],null==r.classWeight){t.next=64;break}I=EA(r.classWeight,e.outputNames),A=0;case 55:if(!(A<I.length)){t.next=64;break}return t.t0=E,t.next=59,IA(R[A],null,I[A]);case 59:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 61:++A,t.next=55;break;case 64:for(T=C.concat(R).concat(E),D=c(T),Eb(T),_=0;_<l.length;++_)O=l[_],F=D[_],N[O]=F,Ib(F);return t.next=70,m.onBatchEnd(w,N);case 70:MI(N),w++,x++;case 73:if(!(a?x>=r.batchesPerEpoch:k.done)){t.next=87;break}if(!i){t.next=86;break}if(M=void 0,!zA(r.validationData)){t.next=84;break}return t.t2=BN,t.next=80,e.evaluateDataset(r.validationData,{batches:r.validationBatches});case 80:t.t3=t.sent,M=(0,t.t2)(t.t3),t.next=85;break;case 84:M=BN(e.evaluate(o,s,{batchSize:null==r.validationBatchSize?32:r.validationBatchSize,verbose:0}));case 85:for(L=0;L<e.metricsNames.length;++L)b["val_"+e.metricsNames[L]]=M[L];case 86:return t.abrupt("break",91);case 87:if(!e.stopTraining_){t.next=89;break}return t.abrupt("break",91);case 89:t.next=37;break;case 91:return t.next=93,m.onEpochEnd(g,b);case 93:if(g++,!e.stopTraining_){t.next=96;break}return t.abrupt("break",98);case 96:t.next=27;break;case 98:return t.next=100,m.onTrainEnd();case 100:return t.next=102,e.history.syncData();case 102:return t.abrupt("return",e.history);case 103:return t.prev=103,e.isTraining=!1,t.finish(103);case 106:case"end":return t.stop()}}),t,null,[[9,,103,106]])})))).apply(this,arguments)}function LA(t,e){var n=null;return null!=e.batchesPerEpoch?n=e.batchesPerEpoch:Number.isFinite(t.size)&&(n=t.size),n}function zA(t){return"function"==typeof t.iterator}function BA(t){return"function"==typeof t.next}function PA(t,e,n){return WA.apply(this,arguments)}function WA(){return(WA=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null!=(r=r||{}).batches,i=e.testFunction,o=[],!(r.verbose>0)){t.next=6;break}throw new _N("Verbose mode is not implemented yet.");case 6:if(gv(!a||r.batches>0&&Number.isInteger(r.batches),(function(){return"Test loop expects `batches` to be a positive integer, but received "+JSON.stringify(r.batches)})),!BA(n)){t.next=11;break}t.t0=n,t.next=14;break;case 11:return t.next=13,n.iterator();case 13:t.t0=t.sent;case 14:s=t.t0,u=0,c=0,l=regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.next();case 2:if(n=t.sent,o=Nb((function(){return n.value&&function(){var t=DA(e,n.value),r=t.xs,a=t.ys,s=r.concat(a),l=Nb((function(){return i(s)}));if(Eb(s),0===c)for(var h=0;h<l.length;++h)o.push(oy(0));for(var f=s[0].shape[0],p=function(t){var e=l[t],n=o[t];o[t]=Nb((function(){return Db(o[t],kx(f,e))})),c>0&&Eb(n)},d=0;d<l.length;++d)p(d);Eb(l),u+=f,++c}(),o})),!n.done){t.next=7;break}return a&&console.warn("Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least `batches` batches (in this case, "+r.batches+" batches). You may need to use the repeat() function when building your dataset."),t.abrupt("return","break");case 7:case"end":return t.stop()}}),t)}));case 18:if(a&&!(c<r.batches)){t.next=25;break}return t.delegateYield(l(),"t1",20);case 20:if("break"!==t.t1){t.next=23;break}return t.abrupt("break",25);case 23:t.next=18;break;case 25:for(h=0;h<o.length;++h)f=o[h],o[h]=Ix(o[h],u),Eb(f);return t.abrupt("return",zN(o));case 27:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function VA(t){gv(t>0&&Number.isInteger(t),(function(){return"batchSize is required to be a positive integer, but got "+t}))}function UA(t,e,n){return null==t?[null]:Array.isArray(t)?t.map((function(t){return AE(t,e,n-e)})):AE(t,e,n-e)}function jA(t,e){return Nb((function(){return null==t?null:Array.isArray(t)?t.map((function(t){return jA(t,e)})):zE(t,"int32"===e.dtype?e:e.toInt())}))}function GA(t,e){for(var n=[],r=0,a=null;r<t;)(a=r+e)>=t&&(a=t),n.push([r,a]),r=a;return n}function qA(t,e,n,r,a,i,o,s,u,c,l,h,f,p,d){return HA.apply(this,arguments)}function HA(){return(HA=Vm(regeneratorRuntime.mark((function t(e,n,r,a,i,o,s,u,c,l,h,f,p,d,m){var v,g,y,b,x,w,k,S;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==i&&(i=32),null==o&&(o=1),null==h&&(h=!0),null==p&&(p=0),v=!1,null!=c&&null!=l&&(v=!0),null==m){t.next=10;break}if(v=!0,null!=d){t.next=10;break}throw new DN("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");case 10:return null!=(g=e.checkNumSamples(r,i,d,"steps_per_epoch"))&&(y=NE(0,g)),null==s&&(s=1),b=jI(u,s,o,p,g,d,i,v,f),x=b.callbackList,w=b.history,x.setModel(e),e.history=w,t.next=18,x.onTrainBegin();case 18:e.stopTraining_=!1,k=regeneratorRuntime.mark((function t(o){var s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,x.onEpochBegin(o);case 2:if(s={},null==d){t.next=7;break}throw new _N("stepsPerEpoch mode is not implemented yet.");case 7:return t.delegateYield(regeneratorRuntime.mark((function t(){var o,u,f,p;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("batch"!==h){t.next=4;break}throw new _N("batch shuffling is not implemneted yet");case 4:h&&pv(y);case 5:o=sy(y),u=GA(g,i),f=regeneratorRuntime.mark((function t(h){var f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return f={},t.next=3,x.onBatchBegin(h,f);case 3:return Nb((function(){var t=u[h][0],p=u[h][1],d=AE(o,t,p-t);f.batch=h,f.size=p-t;for(var m=jA(r,d),g=n(m),y=0;y<a.length;++y){var b=a[y],x=g[y];f[b]=x,Ib(x)}if(h===u.length-1&&v)for(var w=e.testLoop(c,l,i),k=0;k<a.length;++k){var S=a[k],C=w[k];Ib(C),s["val_"+S]=C}})),t.next=6,x.onBatchEnd(h,f);case 6:if(MI(f),!e.stopTraining_){t.next=9;break}return t.abrupt("return","break");case 9:case"end":return t.stop()}}),t)})),p=0;case 9:if(!(p<u.length)){t.next=17;break}return t.delegateYield(f(p),"t0",11);case 11:if("break"!==t.t0){t.next=14;break}return t.abrupt("break",17);case 14:++p,t.next=9;break;case 17:o.dispose();case 18:case"end":return t.stop()}}),t)}))(),"t0",8);case 8:return t.next=10,x.onEpochEnd(o,s);case 10:if(!e.stopTraining_){t.next=12;break}return t.abrupt("return","break");case 12:case"end":return t.stop()}}),t)})),S=p;case 21:if(!(S<o)){t.next=29;break}return t.delegateYield(k(S),"t0",23);case 23:if("break"!==t.t0){t.next=26;break}return t.abrupt("break",29);case 26:++S,t.next=21;break;case 29:return t.next=31,x.onTrainEnd();case 31:return t.next=33,e.history.syncData();case 33:return t.abrupt("return",e.history);case 34:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function KA(t,e,n,r){return XA.apply(this,arguments)}function XA(){return(XA=Vm(regeneratorRuntime.mark((function t(e,n,r,a){var i,o,s,u,c,l,h,f,p,d,m,v,g,y,b,x,w,k,S,C,R;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===a&&(a={}),!e.isTraining){t.next=3;break}throw new Error("Cannot start training because another fit() call is ongoing.");case 3:return e.isTraining=!0,t.prev=4,VA(f=null==a.batchSize?32:a.batchSize),!1,t.next=10,e.standardizeUserData(n,r,a.sampleWeight,a.classWeight,!1,f);case 10:if(p=t.sent,i=p[0],o=p[1],h=p[2],d=!1,!(null!=a.validationData&&a.validationData.length>0)){t.next=36;break}if(d=!0,2!==a.validationData.length){t.next=22;break}s=a.validationData[0],u=a.validationData[1],t.next=27;break;case 22:if(3!==a.validationData.length){t.next=26;break}throw new _N("validationData including sample weights is not supported yet.");case 26:throw new DN("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+a.validationData+" is invalid.");case 27:return!0,t.next=30,e.standardizeUserData(s,u,null,null,!0,f);case 30:v=t.sent,c=v[0],l=v[1],m=c.concat(l),t.next=37;break;case 36:null!=a.validationSplit&&a.validationSplit>0&&a.validationSplit<1?(d=!0,g=Math.floor(i[0].shape[0]*(1-a.validationSplit)),y=i[0].shape[0],c=UA(i,g,y),i=UA(i,0,g),l=UA(o,g,y),o=UA(o,0,g),m=c.concat(l)):null!=a.validationSteps&&(d=!0);case 37:return b=i.concat(o).concat(h),e.checkTrainableWeightsConsistency(),x=e.makeTrainFunction(),w=e.getDedupedMetricsNames(),d?(e.makeTestFunction(),k=e.testFunction,S=w.slice().concat(w.map((function(t){return"val_"+t})))):(k=null,m=[],S=w.slice()),C=VI(a.callbacks,a.yieldEvery),t.next=45,qA(e,x,b,w,f,a.epochs,a.verbose,C,k,m,a.shuffle,S,a.initialEpoch,null,null);case 45:return R=t.sent,t.abrupt("return",R);case 47:return t.prev=47,e.isTraining=!1,JA(i,n),JA(o,r),JA(c,s),JA(l,u),null!=h&&Eb(h),t.finish(47);case 55:case"end":return t.stop()}}),t,null,[[4,,47,55]])})))).apply(this,arguments)}function YA(t){var e=[];t instanceof pg&&(t=[t]);for(var n=0;n<t.length;++n){var r=t[n];if(1===r.rank)e.push(IE(r,1));else{if(0===r.rank)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");e.push(r)}}return e}function JA(t,e){if(null!=t){var n=[];if(e instanceof pg)n.push(e.id);else if(Array.isArray(e))e.forEach((function(t){return n.push(t.id)}));else if(null!=e)for(var r in e){var a=e[r];n.push(a.id)}var i=[];if(t instanceof pg)-1===n.indexOf(t.id)&&i.push(t);else if(Array.isArray(t))t.forEach((function(t){-1===n.indexOf(t.id)&&i.push(t)}));else if(null!=t)for(var o in t){var s=t[o];-1===n.indexOf(s.id)&&i.push(s)}i.forEach((function(t){t.isDisposed||t.dispose()}))}}function $A(t){return Array.isArray(t)}function ZA(t){return!function(t){return t instanceof pg}(t)&&!$A(t)}function QA(t,e,n,r,a){if(void 0===r&&(r=!0),void 0===a&&(a=""),null==e||0===e.length){if(null!=t){var i=!1;if($A(t)&&t.length>0)i=!0;else if(ZA(t)){for(var o in t)if(t.hasOwnProperty(o)){i=!0;break}}else i=!0;if(i)throw new DN("Error when checking model "+a+" expected no data, but got "+t)}return[]}if(null==t)return e.map((function(t){return null}));var s;if(ZA(t)){t=t,s=[];for(var u,c=Zm(e);!(u=c()).done;){var l=u.value;if(null==t[l])throw new DN('No data provided for "'+l+'". Need data for each key in: '+e);s.push(t[l])}}else if($A(t)){if((t=t).length!==e.length)throw new DN("Error when checking model "+a+": the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see "+e.length+" Tensor(s), but instead got the following list of Tensor(s): "+t);s=t}else{if(t=t,e.length>1)throw new DN("The model "+a+" expects "+e.length+" Tensor(s), but only received one Tensor. Found: Tensor with shape "+t.shape);s=[t]}if(s=YA(s),null!=n)for(var h=0;h<e.length;++h)if(null!=n[h]){var f=s[h];if(f.shape.length!==n[h].length)throw new DN("Error when checking "+a+": expected "+e[h]+" to have "+n[h].length+" dimension(s). but got array with shape "+f.shape);for(var p=0;p<n[h].length;++p)if(0!==p||r){var d=f.shape[p],m=n[h][p];if(null!=m&&m>=0&&d!==m)throw new DN("Error when checking "+a+": expected "+e[h]+" to have shape ["+n[h]+"], but got array with shape ["+f.shape+"].")}}return s}function tT(t,e,n,r,a){var i;if(void 0===r&&(r=!0),void 0===a&&(a=""),Array.isArray(t)){if(t.length!==e.length)throw new DN("Error when checking model "+a+": the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see "+e.length+" Tensor(s), but instead got "+t.length+" Tensors(s).");i=t}else{if(e.length>1)throw new DN("The model expects "+e.length+" "+a+" Tensors, but only received one Tensor. Found: array with shape "+JSON.stringify(t.shape)+".");i=[t]}if(null!=n)for(var o=0;o<e.length;++o)if(null!=n[o]){var s=i[o];if(s.shape.length!==n[o].length)throw new DN("Error when checking "+a+": expected "+e[o]+" to have "+n[o].length+" dimension(s), but got array with shape "+JSON.stringify(s.shape));for(var u=0;u<n[o].length;++u)if(0!==u||r){var c=s.shape[u],l=n[o][u];if(null!=l&&l!==c)throw new DN("Error when checking "+a+": expected "+e[o]+" to have shape "+JSON.stringify(n[o])+" but got array with shape "+JSON.stringify(s.shape)+".")}}}var eT=function(t){function e(e){var n;return(n=t.call(this,e)||this).isTraining=!1,n}Gm(e,t);var n=e.prototype;return n.summary=function(t,e,n){if(void 0===n&&(n=console.log),!this.built)throw new DN("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");dA(this,t,e,n)},n.compile=function(t){var e=this;if(null==t.loss&&(t.loss=[]),this.loss=t.loss,"string"==typeof t.optimizer)this.optimizer_=function(t){var e={Adagrad:function(){return QR.adagrad(.01)},Adadelta:function(){return QR.adadelta(1,.95,IN())},Adam:function(){return QR.adam(.001,.9,.999,IN())},Adamax:function(){return QR.adamax(.002,.9,.999,IN(),0)},RMSProp:function(){return QR.rmsprop(.001,.9,0,IN())},SGD:function(){return QR.sgd(.01)}};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,t in e)return e[t]();throw new DN("Unknown Optimizer "+t)}(t.optimizer),this.isOptimizerOwned=!0;else{if(!(t.optimizer instanceof GR))throw new DN("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=t.optimizer,this.isOptimizerOwned=!1}var n=[];if(Array.isArray(t.loss)||"string"==typeof t.loss||"function"==typeof t.loss)if(Array.isArray(t.loss)){if(t.loss.length!==this.outputs.length)throw new DN("When passing an Array as loss, it should have one entry per model output. The model has "+this.outputs.length+" output(s), but you passed loss="+t.loss+".");var r=t.loss;n=r.map((function(t){return tA(t)}))}else{var a=tA(t.loss);this.outputs.forEach((function(t){n.push(a)}))}else{for(var i in t.loss=t.loss,t.loss)if(-1===this.outputNames.indexOf(i))throw new DN('Unknown entry in loss dictionary: "'+i+'". Only expected the following keys: '+this.outputNames);for(var o,s=Zm(this.outputNames);!(o=s()).done;){var u=o.value;null==t.loss[u]&&console.warn('Output "'+u+'" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to '+u+" during training"),n.push(tA(t.loss[u]))}}this.lossFunctions=n,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(var c=0;c<this.outputs.length;++c){var l=this.internalOutputShapes[c],h=this.outputNames[c];this.feedOutputNames.push(h),this.feedOutputShapes.push(l),this.feedLossFns.push(this.lossFunctions[c])}var f=[];this.metrics=t.metrics,this.metricsNames=["loss"],this.metricsTensors=[],gE("loss",(function(){for(var t=0;t<e.outputs.length;++t)if(-1===f.indexOf(t)){var n=e.lossFunctions[t];e.outputs.length>1&&(e.metricsTensors.push([n,t]),e.metricsNames.push(e.outputNames[t]+"_loss"))}}));var p=function(t,e){if(null==t||Array.isArray(t)&&0===t.length)return e.map((function(t){return[]}));var n;if("string"==typeof t||"function"==typeof t)n=[t];else{if(!Array.isArray(t)&&"object"!=typeof t)throw new TypeError("Type of metrics argument not understood. Expected an string,function, Array, or Object, found: "+t);n=t}if(Array.isArray(n))return e.map((function(t){return n}));for(var r,a=[],i=Zm(e);!(r=i()).done;){var o=r.value,s=n.hasOwnProperty(o)?n[o]:[];Array.isArray(s)||(s=[s]),a.push(s)}return a}(t.metrics,this.outputNames),d=function(t,n,r){e.outputNames.length>1&&(n=e.outputNames[t]+"_"+n),e.metricsNames.push(n),e.metricsTensors.push([r,t])};gE("metric",(function(){for(var t=function(t){if(-1!==f.indexOf(t))return"continue";!function(n){for(var r,a,i,o,s=Zm(n);!(o=s()).done;){var u=o.value;if("string"==typeof u&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(u)){var c=e.internalOutputShapes[t];1===c[c.length-1]||e.lossFunctions[t]===$I?-1!==["accuracy","acc"].indexOf(u)?a=eA:-1!==["crossentropy","ce"].indexOf(u)&&(a=oA):e.lossFunctions[t]===JI?-1!==["accuracy","acc"].indexOf(u)?a=sA:-1!==["crossentropy","ce"].indexOf(u)&&(a=cA):-1!==["accuracy","acc"].indexOf(u)?a=nA:-1!==["crossentropy","ce"].indexOf(u)&&(a=uA);var l=void 0;-1!==["accuracy","acc"].indexOf(u)?l="acc":-1!==["crossentropy","ce"].indexOf(u)&&(l="ce"),i=a,r=""+l}else{var h=hA(u);i=h,r=""+fA(u)}var f=void 0;gE(r,(function(){f=i})),d(t,r,f)}}(p[t])},n=0;n<e.outputs.length;++n)t(n)})),this.collectedTrainableWeights=this.trainableWeights},n.checkTrainableWeightsConsistency=function(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")},n.evaluate=function(t,e,n){void 0===n&&(n={});var r=null==n.batchSize?32:n.batchSize;VA(r);var a=this.standardizeUserDataXY(t,e,!0,r);try{var i=a[0].concat(a[1]);this.makeTestFunction();var o=this.testFunction;return zN(this.testLoop(o,i,r,n.verbose,n.steps))}finally{JA(a[0],t),JA(a[1],e)}},n.evaluateDataset=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.makeTestFunction(),t.abrupt("return",PA(this,e,n));case 2:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.checkNumSamples=function(t,e,n,r){var a;if(void 0===r&&(r="steps"),null!=n){if(a=null,null!=e)throw new DN("If "+r+" is set, batchSize must be null or undefined.Got batchSize = "+e)}else{if(null==t)throw new DN("Either the input data should have a defined shape, or "+r+" shoud be specified.");a=Array.isArray(t)?t[0].shape[0]:t.shape[0]}return a},n.execute=function(t,e){if(Array.isArray(e)&&0===e.length)throw new DN("`outputs` is an empty Array, which is not allowed.");var n=Array.isArray(e),r=n?e:[e],a=this.retrieveSymbolicTensors(r),i=new xA;if(t instanceof pg&&(t=[t]),Array.isArray(t)){if(t.length!==this.inputs.length)throw new DN("The number of inputs provided ("+t.length+") does not match the number of inputs of this model ("+this.inputs.length+").");for(var o=0;o<this.inputs.length;++o)i.add(this.inputs[o],t[o])}else for(var s,u=Zm(this.inputs);!(s=u()).done;){var c=s.value,l=t[c.name];if(null==l)throw new DN("No value is provided for the model's input "+c.name);i.add(c,l)}var h=SA(a,i);return n?h:h[0]},n.retrieveSymbolicTensors=function(t){for(var e,n=FN(null,t.length),r=t.length,a=Zm(this.layers);!(e=a()).done;){for(var i=e.value,o=Array.isArray(i.output)?i.output:[i.output],s=o.map((function(t){return t.name})),u=0;u<t.length;++u){var c=s.indexOf(t[u]);if(-1!==c&&(n[u]=o[c],r--),0===r)break}if(0===r)break}if(r>0){var l=[];throw n.forEach((function(e,n){null==e&&l.push(t[n])})),new DN("Cannot find SymbolicTensors for output name(s): "+JSON.stringify(l))}return n},n.predictLoop=function(t,e,n){var r=this;return void 0===e&&(e=32),void 0===n&&(n=!1),Nb((function(){var a=r.checkNumSamples(t);if(n)throw new _N("Verbose predictLoop() is not implemented yet.");for(var i=GA(a,e),o=r.outputs.map((function(t){return[]})),s=function(e){Nb((function(){var n=i[e][0],a=i[e][1],o=UA(t,n,a),s=[];if(Array.isArray(o))for(var u=0;u<o.length;++u)s.push({key:r.inputs[u],value:o[u]});else s.push({key:r.inputs[0],value:o});var c=new xA(s);return SA(r.outputs,c)})).forEach((function(t,e){return o[e].push(t)}))},u=0;u<i.length;++u)s(u);return zN(o.map((function(t){return wy(t,0)})))}))},n.predict=function(t,e){void 0===e&&(e={});var n=YA(t);tT(n,this.inputNames,this.feedInputShapes,!1);try{var r=null==e.batchSize?32:e.batchSize;return VA(r),this.predictLoop(n,r)}finally{JA(n,t)}},n.predictOnBatch=function(t){tT(t,this.inputNames,this.feedInputShapes,!0);var e=(Array.isArray(t)?t[0]:t).shape[0];return this.predictLoop(t,e)},n.standardizeUserDataXY=function(t,e,n,r){if(null==this.optimizer_)throw new TN("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");for(var a=[],i=0;i<this.feedOutputShapes.length;++i){var o=this.feedOutputShapes[i];this.feedLossFns[i]===JI?a.push(o.slice(0,o.length-1).concat([1])):a.push(o)}if(function(t,e,n){var r=qN(t.map((function(t){return t.shape[0]})));r.sort();var a=qN(e.map((function(t){return t.shape[0]})));if(a.sort(),r.length>1)throw new DN("All input Tensors (x) should have the same number of samples. Got array shapes: "+JSON.stringify(t.map((function(t){return t.shape}))));if(a.length>1)throw new DN("All target Tensors (y) should have the same number of samples. Got array shapes: "+JSON.stringify(e.map((function(t){return t.shape}))));if(r.length>0&&a.length>0&&!kv(r,a))throw new DN("Input Tensors should have the same number of samples as target Tensors. Found "+r[0]+" input sample(s) and "+a[0]+" target sample(s).")}(t=QA(t,this.feedInputNames,this.feedInputShapes,!1,"input"),e=QA(e,this.feedOutputNames,a,!1,"target")),function(t,e,n){for(var r=[HI,$I,YI],a=0;a<t.length;++a){var i=t[a],o=e[a],s=n[a];if(null!=o){if(o===YI&&1===i.shape[i.shape.length-1])throw new DN("You are passing a target array of shape "+i.shape+" while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].");if(-1!==r.indexOf(o))for(var u=i.shape.slice(1),c=s.slice(1),l=0;l<u.length;++l){var h=u[l],f=c[l];if(null!=f&&h!==f)throw new DN("A target Tensor with shape "+i.shape+" was passed for an output of shape "+s+", while using a loss function that expects targets to have the same shape as the output.")}}}}(e,this.feedLossFns,this.feedOutputShapes),this.stateful&&null!=r&&r>0&&t[0].shape[0]%r!=0)throw new DN("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+r+". Found: "+t[0].shape[0]+" sample(s).");return[t,e]},n.standardizeUserData=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n,r,a,i,o){var s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===i&&(i=!0),s=this.standardizeUserDataXY(e,n,i,o),u=s[0],c=s[1],null==r){t.next=4;break}throw new Error("sample weight is not supported yet.");case 4:if(l=null,null==a){t.next=18;break}h=EA(a,this.outputNames),l=[],f=0;case 9:if(!(f<h.length)){t.next=18;break}return t.t0=l,t.next=13,IA(c[f],null,h[f]);case 13:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 15:++f,t.next=9;break;case 18:return t.abrupt("return",[u,c,l]);case 19:case"end":return t.stop()}}),t,this)})));return function(e,n,r,a,i,o){return t.apply(this,arguments)}}(),n.testLoop=function(t,e,n,r,a){var i=this;return void 0===r&&(r=0),Nb((function(){var o=i.checkNumSamples(e,n,a,"steps"),s=[];if(r>0)throw new _N("Verbose mode is not implemented yet.");if(null!=a)throw new _N("steps mode in testLoop() is not implemented yet");for(var u=GA(o,n),c=sy(NE(0,o)),l=0;l<u.length;++l){var h=u[l][0],f=u[l][1],p=AE(c,h,f-h),d=jA(e,p),m=t(d);if(0===l)for(var v=0;v<m.length;++v)s.push(oy(0));for(var g=0;g<m.length;++g){var y=m[g];s[g]=Db(s[g],kx(f-h,y))}}for(var b=0;b<s.length;++b)s[b]=Ix(s[b],o);return s}))},n.getDedupedMetricsNames=function(){for(var t=this.metricsNames,e=[],n=0;n<t.length;++n){var r=t[n],a=r;if(LN(t,r)>1)a+="_"+LN(t.slice(0,n),r);e.push(a)}return e},n.makeTrainFunction=function(){var t=this;return function(e){var n=[],r=e.slice(0,t.inputs.length),a=e.slice(t.inputs.length,t.inputs.length+t.outputs.length),i=e.slice(t.inputs.length+t.outputs.length,t.inputs.length+2*t.outputs.length),o=[],s=t.collectedTrainableWeights.map((function(t){return t.read()}));return[t.optimizer_.minimize((function(){for(var e=[],s=0;s<t.inputs.length;++s)e.push({key:t.inputs[s],value:r[s]});for(var u,c=new xA(e),l=SA(t.outputs,c,{training:!0}),h=0;h<t.lossFunctions.length;++h){var f=(0,t.lossFunctions[h])(a[h],l[h]);null!=i[h]&&(f=TA(f,i[h]));var p=Hy(f);n.push(p),u=0===h?f:Db(u,f)}for(var d=0;d<t.metricsTensors.length;++d){var m=void 0;if(t.outputs.length>1&&d<t.outputs.length)m=n[d];else{var v=t.metricsTensors[d][0],g=t.metricsTensors[d][1];m=Hy(v(a[g],l[g]))}Ib(m),o.push(m)}return u=Hy(u),t.calculateLosses().forEach((function(t){u=Db(u,t)})),u}),!0,s)].concat(o)}},n.makeTestFunction=function(){var t=this;this.testFunction=function(e){return Nb((function(){for(var n,r=[],a=e.slice(0,t.inputs.length),i=e.slice(t.inputs.length,t.inputs.length+t.outputs.length),o=[],s=0;s<t.inputs.length;++s)o.push({key:t.inputs[s],value:a[s]});for(var u=new xA(o),c=SA(t.outputs,u),l=0;l<t.lossFunctions.length;++l){var h=t.lossFunctions[l],f=Hy(h(i[l],c[l]));n=0===l?f:Db(n,f),r.push(n)}for(var p=0;p<t.metricsTensors.length;++p){var d=t.metricsTensors[p][0],m=t.metricsTensors[p][1],v=Hy(d(i[m],c[m]));r.push(v)}return r}))}},n.fit=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n,r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r={}),t.abrupt("return",KA(this,e,n,r));case 2:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),n.fitDataset=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",FA(this,e,n));case 1:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.trainOnBatch=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.standardizeUserData(e,n);case 2:r=t.sent,a=r[0],i=r[1],o=this.makeTrainFunction(),s=o(a.concat(i)),u=[],c=Zm(s);case 9:if((l=c()).done){t.next=17;break}return h=l.value,t.next=13,h.data();case 13:f=t.sent,u.push(f[0]);case 15:t.next=9;break;case 17:return Eb(s),t.abrupt("return",zN(u));case 19:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.getNamedWeights=function(t){for(var e=[],n=null!=t&&t.trainableOnly,r=n?this.trainableWeights:this.weights,a=this.getWeights(n),i=0;i<r.length;++i)n&&!r[i].trainable||e.push({name:r[i].originalName,tensor:a[i]});return e},n.dispose=function(){var e=t.prototype.dispose.call(this);if(0===e.refCountAfterDispose&&null!=this.optimizer&&this.isOptimizerOwned){var n=Rb().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=n-Rb().numTensors}return e},n.getLossIdentifiers=function(){var t;if("string"==typeof this.loss)t=PN(this.loss);else if(Array.isArray(this.loss)){for(var e,n=Zm(this.loss);!(e=n()).done;){if("string"!=typeof e.value)throw new Error("Serialization of non-string loss is not supported.")}t=this.loss.map((function(t){return PN(t)}))}else{var r=Object.keys(this.loss);t={};for(var a=this.loss,i=0,o=r;i<o.length;i++){var s=o[i];if("string"!=typeof a[s])throw new Error("Serialization of non-string loss is not supported.");t[s]=PN(a[s])}}return t},n.getMetricIdentifiers=function(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[PN(fA(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((function(t){return PN(fA(t))}));var t={};for(var e in this.metrics)t[e]=PN(fA(this.metrics[e]));return t},n.getTrainingConfig=function(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}},n.loadTrainingConfig=function(t){if(null!=t.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=t.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=t.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");var e,n,r=GI(bA(t.optimizer_config));if("string"==typeof t.loss)e=WN(t.loss);else if(Array.isArray(t.loss))e=t.loss.map((function(t){return WN(t)}));else if(null!=t.loss)for(var a in e={},t.loss)e[a]=WN(t.loss[a]);if(Array.isArray(t.metrics))n=t.metrics.map((function(t){return WN(t)}));else if(null!=t.metrics)for(var i in n={},t.metrics)n[i]=WN(t.metrics[i]);this.compile({loss:e,metrics:n,optimizer:r})},n.save=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u,c,l,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=9;break}if(0!==(r=Iw(e)).length){t.next=6;break}throw new DN("Cannot find any save handlers for URL '"+e+"'");case 6:if(!(r.length>1)){t.next=8;break}throw new DN("Found more than one ("+r.length+") save handlers for URL '"+e+"'");case 8:e=r[0];case 9:if(null!=e.save){t.next=11;break}throw new DN("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");case 11:return t.next=13,vw(this.getNamedWeights(n));case 13:if(a=t.sent,!1,null,i=this.toJSON(null,!1),o={modelTopology:i,format:"layers-model",generatedBy:"TensorFlow.js tfjs-layers v2.0.0",convertedBy:null},!(null!=n&&n.includeOptimizer)||null==this.optimizer){t.next=34;break}return o.trainingConfig=this.getTrainingConfig(),u="optimizer",t.t0=bk,t.next=25,this.optimizer.getWeights();case 25:return t.t1=t.sent,t.t2=u,t.next=29,t.t0.encodeWeights.call(t.t0,t.t1,t.t2);case 29:c=t.sent,l=c.data,h=c.specs,(s=a.specs).push.apply(s,h),a.data=Cw([a.data,l]);case 34:return null!=this.userDefinedMetadata&&(!0,pA(this.userDefinedMetadata,this.name,!0),o.userDefinedMetadata=this.userDefinedMetadata),o.weightData=a.data,o.weightSpecs=a.specs,t.abrupt("return",e.save(o));case 38:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.setUserDefinedMetadata=function(t){pA(t,this.name),this.userDefinedMetadata=t},n.getUserDefinedMetadata=function(){return this.userDefinedMetadata},jm(e,[{key:"stopTraining",set:function(t){this.stopTraining_=t},get:function(){return this.stopTraining_}},{key:"optimizer",get:function(){return this.optimizer_},set:function(t){this.optimizer_!==t&&(this.optimizer_=t,this.isOptimizerOwned=!1)}}]),e}(function(t){function e(n){var r;if((r=t.call(this,{})||this).containerNodes=new Set,r.name=n.name,null==r.name){var a=r.getClassName().toLowerCase();r.name=mI(a)}if(r.supportsMasking=!1,r.trainable_=!0,Array.isArray(n.inputs)?r.inputs=n.inputs.slice():r.inputs=[n.inputs],Array.isArray(n.outputs)?r.outputs=n.outputs.slice():r.outputs=[n.outputs],qN(r.inputs).length!==r.inputs.length)throw new DN("The list of inputs passed to the model is redundant. All inputs should only appear once. Found: "+r.inputs.map((function(t){return t.name})));qN(r.outputs).length!==r.outputs.length&&console.warn("The list of outputs passed to the model is redundant. All outputs should only appear once. Found: "+r.outputs.map((function(t){return t.name}))),r.inputLayers=[],r.inputLayersNodeIndices=[],r.inputLayersTensorIndices=[],r.outputLayers=[],r.outputLayersNodeIndices=[],r.outputLayersTensorIndices=[],r.layers=[],r.internalContainerRefs=[];for(var i,o=Zm(r.outputs);!(i=o()).done;){var s=i.value,u=s.sourceLayer,c=s.nodeIndex,l=s.tensorIndex;r.outputLayers.push(u),r.outputLayersNodeIndices.push(c),r.outputLayersTensorIndices.push(l)}for(var h,f=Zm(r.inputs);!(h=f()).done;){var p=h.value,d=p.sourceLayer,m=p.nodeIndex,v=p.tensorIndex;MN(0===m,"input layer has >1 nodes"),MN(0===v,"input layer has >1 tensors"),r.inputLayers.push(d),r.inputLayersNodeIndices.push(m),r.inputLayersTensorIndices.push(v)}r.inputNames=[],r.outputNames=[],r.feedInputShapes=[],r.feedInputNames=[],r.feedOutputNames=[];for(var g=0;g<r.inputLayers.length;g++){var y=r.inputLayers[g];if(!(y instanceof DI))throw new TypeError("Input layers to a LayersModel must be InputLayer objects. Received inputs: "+n.inputs+". Input "+g+" (0-based) originates from layer type "+y.getClassName()+".");r.inputNames.push(y.name),r.feedInputShapes.push(y.batchInputShape),r.feedInputNames.push(y.name)}for(var b,x=Zm(r.outputLayers);!(b=x()).done;){var w=b.value;r.outputNames.push(w.name)}r.internalInputShapes=r.inputs.map((function(t){return t.shape})),r.internalOutputShapes=r.outputs.map((function(t){return t.shape}));for(var k,S={},C={},R={},N={},E={},I=[],A=function t(n,a,i,o,s,u){null!=o&&null!=s&&null!=u||(o=n.sourceLayer,s=n.nodeIndex,u=n.tensorIndex);var c=o.inboundNodes[s];if(-1!==i.indexOf(c))throw new TN("The tensor "+n.name+' at layer "'+o.name+'" is part of a cycle.');if(-1===a.indexOf(c)){r.containerNodes.add(e.nodeKey(o,s)),o.id in E||(E[o.id]=Object.keys(E).length),-1===i.indexOf(c)&&i.push(c);for(var l=c.inboundLayers.length,h=0;h<l;h++){t(c.inputTensors[h],a,i,c.inboundLayers[h],c.nodeIndices[h],c.tensorIndices[h])}for(a.push(c);i.indexOf(c)>=0;)i.splice(i.indexOf(c),1);I.push(c)}},T=[],D=[],_=Zm(r.outputs);!(k=_()).done;){A(k.value,T,D)}for(var O,F=Zm(I.slice().reverse());!(O=F()).done;){var M=O.value;C[M.id]=M,M.id in S||(S[M.id]=0);var L=S[M.id],z=null==R[M.outboundLayer.id]?0:R[M.outboundLayer.id];L=Math.max(L,z),R[M.outboundLayer.id]=L,N[M.outboundLayer.id]=M.outboundLayer,S[M.id]=L;for(var B=0;B<M.inboundLayers.length;B++){var P=M.inboundLayers[B],W=M.nodeIndices[B],V=P.inboundNodes[W],U=null==S[V.id]?0:S[V.id];S[V.id]=Math.max(L+1,U),C[V.id]=V}}var j={};for(var G in S){var q=S[G];q in j||(j[q]=[]),j[q].push(C[G])}var H={};for(var K in R){var X=R[K];X in H||(H[X]=[]),H[X].push(N[K])}var Y=Object.keys(H).map((function(t){return parseInt(t,10)})).sort(GN);r.layers=[];for(var J,$=Zm(Y);!(J=$()).done;){var Z=H[J.value];Z.sort((function(t,e){var n=E[t.id],r=E[e.id];return n<r?-1:n>r?1:0}));for(var Q,tt=Zm(Z);!(Q=tt()).done;){var et=Q.value;et instanceof e&&r.internalContainerRefs.push(et),r.layers.push(et)}}r.layersByDepth=H,Y=Object.keys(j).map((function(t){return parseInt(t,10)})).sort(GN);for(var nt,rt=r.inputs.slice(),at=[],it=Zm(Y);!(nt=it()).done;)for(var ot,st=Zm(j[nt.value]);!(ot=st()).done;){var ut=ot.value,ct=ut.outboundLayer;if(null!=ct){for(var lt,ht=Zm(ut.inputTensors);!(lt=ht()).done;){var ft=lt.value;if(-1===rt.indexOf(ft))throw new TN("Graph disconnected: cannot obtain value for tensor "+ft+' at layer "'+ct.name+'". The following previous layers were accessed without issue: '+at)}for(var pt,dt=Zm(ut.outputTensors);!(pt=dt()).done;){var mt=pt.value;rt.push(mt)}at.push(ct.name)}}r.nodesByDepth=j;for(var vt,gt=r.layers.map((function(t){return t.name})),yt=function(){var t=vt.value,e=gt.filter((function(e){return e===t})).length;if(1!==e)throw new TN('The name "'+t+'" is used '+e+" times in the model. All layer names should be unique. Layer names: "+JSON.stringify(gt))},bt=Zm(gt);!(vt=bt()).done;)yt();return r.outboundNodes=[],r.inboundNodes=[],new EI({outboundLayer:Jm(r),inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:r.inputs,outputTensors:r.outputs,inputMasks:r.inputs.map((function(t){return null})),outputMasks:r.outputs.map((function(t){return null})),inputShapes:r.inputs.map((function(t){return t.shape})),outputShapes:r.outputs.map((function(t){return t.shape}))}),r.built=!0,r._refCount=1,r}Gm(e,t);var n=e.prototype;return n.assertNotDisposed=function(){if(0===this._refCount)throw new Error("Container '"+this.name+"' is already disposed.")},n.dispose=function(){this.assertNotDisposed();var t={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(var e,n=Zm(this.layers);!(e=n()).done;){var r=e.value;t.numDisposedVariables+=r.dispose().numDisposedVariables}for(var a,i=Zm(this.internalContainerRefs);!(a=i()).done;){var o=a.value;t.numDisposedVariables+=o.dispose().numDisposedVariables}}return t.refCountAfterDispose=this._refCount,t},n.loadWeights=function(t,e){void 0===e&&(e=!0);for(var n,r={},a=0,i=Zm(this.layers);!(n=i()).done;)for(var o,s=Zm(n.value.weights);!(o=s()).done;){var u=o.value;if(null!=r[u.originalName])throw new DN("Duplicate weight name: "+u.originalName);r[u.originalName]=u,a++}var c=[];for(var l in t){if(null!=r[l])c.push([r[l],t[l]]);else if(e)throw new DN("Provided weight data has no target variable: "+l);delete r[l]}if(e){var h=[];for(var f in r)h.push(f);if(h.length>0)throw new DN(h.length+" of "+a+" weights are not set: "+h)}SI(c)},n.updatedConfig=function(){var t=this.getConfig(),e={};return e.className=this.getClassName(),e.config=t,e.kerasVersion="tfjs-layers 2.0.0",e.backend="TensorFlow.js",e},n.toJSON=function(t,e){void 0===e&&(e=!0);var n=function t(e,n){if(null==e)return null;if("string"==typeof e)return PN(e);if("number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Array){for(var r=[],a=e.length,i=0;i<a;++i){var o=e[i];yA(n,i,o)?r.push(o):r.push(t(o,n))}return r}for(var s={},u=0,c=Object.keys(e);u<c.length;u++){var l=c[u],h=e[l],f=PN(l);s[f]="name"!==l&&"className"!==l||"string"!=typeof h?t(h,l):h}return s}(this.updatedConfig());return e?JSON.stringify(n):n},n.call=function(t,e){var n=this;return Nb((function(){t=BN(t);for(var r=new xA,a=0;a<n.inputs.length;++a)r.add(n.inputs[a],t[a]);return SA(n.outputs,r,e)}))},n.computeMask=function(t,e){var n=this;return Nb((function(){var r;return t=BN(t),r=null==e?FN(null,t.length):BN(e),n.runInternalGraph(t,r)[1]}))},n.computeOutputShape=function(t){var e=gI(t);if(e.length!==this.inputLayers.length)throw new DN("Invalid inputShape argument "+t+": model has "+this.inputLayers.length+" tensor inputs.");for(var n={},r=0;r<e.length;r++){var a=this.inputLayers[r],i=e[r];n[a.name+"_0_0"]=i}var o=Object.keys(this.nodesByDepth).map((function(t){return parseInt(t,10)})).sort(GN);if(o.length>1)for(var s,u=Zm(o);!(s=u()).done;)for(var c,l=s.value,h=Zm(this.nodesByDepth[l]);!(c=h()).done;){var f=c.value,p=f.outboundLayer;if(-1===this.inputLayers.map((function(t){return t.id})).indexOf(p.id)){for(var d=[],m=0;m<f.inboundLayers.length;m++){var v=f.inboundLayers[m],g=f.nodeIndices[m],y=f.tensorIndices[m],b=n[v.name+"_"+g+"_"+y];d.push(b)}for(var x=gI(p.computeOutputShape(zN(d))),w=p.inboundNodes.indexOf(f),k=0;k<x.length;k++){n[p.name+"_"+w+"_"+k]=x[k]}}}for(var S=[],C=[],R=0;R<this.outputLayers.length;R++){var N=this.outputLayers[R],E=this.outputLayersNodeIndices[R],I=this.outputLayersTensorIndices[R],A=N.name+"_"+E+"_"+I;C.push(A)}for(var T=0;T<C.length;T++){var D=C[T];MN(D in n),S.push(n[D])}return zN(S)},n.runInternalGraph=function(t,e){null==e&&(e=FN(null,t.length));for(var n={},r=0;r<this.inputs.length;++r){var a=this.inputs[r],i=t[r],o=e[r];n[a.id]=[i,o]}for(var s,u=Zm(Object.keys(this.nodesByDepth).map((function(t){return parseInt(t,10)})).sort(GN));!(s=u()).done;)for(var c,l=s.value,h=Zm(this.nodesByDepth[l]);!(c=h()).done;){for(var f,p=c.value,d=p.outboundLayer,m=p.inputTensors,v=p.outputTensors,g=new Array,y=Zm(m);!(f=y()).done;){var b=f.value;b.id in n&&g.push(n[b.id])}if(g.length===m.length){var x={},w=void 0,k=void 0,S=void 0,C=void 0;if(null!=p.callArgs&&(x=p.callArgs),1===g.length){var R=g[0],N=R[0],E=R[1];null==x.mask&&(x.mask=E),S=BN(d.call(N,x)),C=BN(d.computeMask(N,E)),w=[N],k=[E]}else w=g.map((function(t){return t[0]})),k=g.map((function(t){return t[1]})),null==x.mask&&(x.mask=k),S=BN(d.call(w,x)),C=BN(d.computeMask(w,k));if(d.activityRegularizer)throw new _N("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(var I=0;I<v.length;++I){var A=v[I],T=S[I],D=C[I];n[A.id]=[T,D]}}}for(var _,O=[],F=[],M=[],L=Zm(this.outputs);!(_=L()).done;){var z=_.value;MN(z.id in n,"Could not compute output "+z.name+" : "+z.id);var B=n[z.id],P=B[0],W=B[1];M.push(P.shape),O.push(P),F.push(W)}return[O,F,M]},n.buildNodeConversionMap=function(t){for(var n,r,a={},i=Zm(this.layers);!(r=i()).done;){var o=r.value;n=o instanceof e?1:0;for(var s=0;s<o.inboundNodes.length;s++){var u=e.nodeKey(o,s);this.containerNodes.has(u)&&(a[u]=n,n+=1)}}return a},n.getLayer=function(t,e){if(null!=e){if(this.layers.length<=e)throw new DN("Was asked to retrieve layer at index "+e+", but model only has "+this.layers.length+" layer(s).");return this.layers[e]}if(null==t)throw new DN("Provide either a layer name or layer index");for(var n,r=Zm(this.layers);!(n=r()).done;){var a=n.value;if(a.name===t)return a}throw new DN("No such layer: "+t)},n.calculateLosses=function(){var t=this;return Nb((function(){for(var n,r=[],a=Zm(t.layers);!(n=a()).done;)for(var i=n.value,o=0;o<i.inboundNodes.length;++o){var s=e.nodeKey(i,o);t.containerNodes.has(s)&&r.push.apply(r,i.calculateLosses())}return r}))},n.getConfig=function(){for(var t,n={name:this.name},r=this.buildNodeConversionMap(this.layers),a=[],i=Zm(this.layers);!(t=i()).done;){for(var o=t.value,s=o.getClassName(),u=o.getConfig(),c=[],l=0;l<o.inboundNodes.length;l++){var h=o.inboundNodes[l],f=e.nodeKey(o,l),p={};if(this.containerNodes.has(f)){if(h.callArgs)try{JSON.stringify(h.callArgs),p=h.callArgs}catch(t){console.warn("Layer "+o.name+" was passed non-serializable keyword arguments: "+h.callArgs+". They will not be included in the serialized model (and thus will be missing at deserialization time)."),p={}}if(h.inboundLayers.length>0){for(var d=[],m=0;m<h.inboundLayers.length;m++){var v=h.inboundLayers[m],g=h.nodeIndices[m],y=h.tensorIndices[m],b=r[e.nodeKey(v,g)];null==b&&(b=0),d.push([v.name,b,y,p])}c.push(d)}}}var x={};x.name=o.name,x.className=s,x.config=u,x.inboundNodes=c,a.push(x)}n.layers=a;for(var w=[],k=0;k<this.inputLayers.length;k++){var S=this.inputLayers[k],C=this.inputLayersNodeIndices[k],R=e.nodeKey(S,C);if(this.containerNodes.has(R)){var N=r[R];null==N&&(N=0);var E=this.inputLayersTensorIndices[k];w.push([S.name,N,E])}}n.inputLayers=w;for(var I=[],A=0;A<this.outputLayers.length;A++){var T=this.outputLayers[A],D=this.outputLayersNodeIndices[A],_=e.nodeKey(T,D);if(this.containerNodes.has(_)){var O=r[_];null==O&&(O=0);var F=this.outputLayersTensorIndices[A];I.push([T.name,O,F])}}return n.outputLayers=I,n},e.fromConfig=function(t,e,n,r){void 0===r&&(r=!1);var a={},i={};function o(t,e){t.name in i?i[t.name].push(e):i[t.name]=[e]}function s(t,e){for(var n,r,i=[],s=Zm(e);!(r=s()).done;){var u=r.value,c=u[0],l=u[1],h=u[2];if(n=null==u[3]?{}:u[3],!(c in a))return void o(t,e);var f=a[c];if(f.inboundNodes.length<=l)return void o(t,e);var p=f.inboundNodes[l];i.push(p.outputTensors[h])}i.length>0&&t.apply(zN(i),n)}function u(t){var n=t.name,i=GI(t,null!=e.customObjects?e.customObjects:{});i.setFastWeightInitDuringBuild(r),a[n]=i,t.inboundNodes.forEach((function(t){if(!(t instanceof Array))throw new DN("Corrupted configuration, expected array for nodeData: "+t);o(i,t)}))}for(var c,l=e.name,h=e.layers,f=Zm(h);!(c=f()).done;){u(c.value)}for(;!HN(i);)for(var p,d=Zm(h);!(p=d()).done;){var m=p.value,v=a[m.name];if(v.name in i){var g=i[v.name];delete i[v.name];for(var y,b=Zm(g);!(y=b()).done;){s(v,y.value)}}}for(var x,w=[],k=[],S=Zm(e.inputLayers);!(x=S()).done;){var C=x.value,R=C[0],N=C[1],E=C[2];MN(R in a);var I=a[R].inboundNodes[N].outputTensors;w.push(I[E])}for(var A,T=Zm(e.outputLayers);!(A=T()).done;){var D=A.value,_=D[0],O=D[1],F=D[2];MN(_ in a);var M=a[_].inboundNodes[O].outputTensors;k.push(M[F])}return new t({inputs:w,outputs:k,name:l})},n.resetStates=function(){var t=this;Nb((function(){t.layers.forEach((function(t){t.stateful&&t.resetStates()}))}))},jm(e,[{key:"trainable",get:function(){return this.trainable_},set:function(t){this.layers.forEach((function(e){e._trainableWeights.forEach((function(e){return e.trainable=t}))})),this.trainable_=t}},{key:"trainableWeights",get:function(){if(this._trainableWeights.length>0)throw new DN("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 t,e=[],n=Zm(this.layers);!(t=n()).done;){var r=t.value;e=e.concat(r.trainableWeights)}return e}},{key:"nonTrainableWeights",get:function(){for(var t,e=[],n=Zm(this.layers);!(t=n()).done;){var r=t.value;e.push.apply(e,r.nonTrainableWeights)}if(!this.trainable){for(var a,i=[],o=Zm(this.layers);!(a=o()).done;){var s=a.value;i.push.apply(i,s.trainableWeights)}return i.concat(e)}return e}},{key:"weights",get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)}},{key:"stateful",get:function(){if(this._stateful)throw new DN("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(var t,e=Zm(this.layers);!(t=e()).done;){if(t.value.stateful)return!0}return!1}}]),e}(AI));function nT(){return(nT=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u,c,l;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("modelTopology"in e||(e={modelTopology:e}),null!=(r=(e=e).modelTopology).model_config&&(r=r.model_config),a=bA(r),i=GI(a,n),null==e.weightsManifest){t.next=14;break}return t.next=9,uk(e.weightsManifest,e.pathPrefix,i.weights.map((function(t){return t.originalName})));case 9:for(o=t.sent,s={},u=Zm(i.weights);!(c=u()).done;)l=c.value,s[l.originalName]=o[l.originalName];i.loadWeights(s),Eb(o);case 14:return t.abrupt("return",i);case 15:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function rT(){return(rT=Vm(regeneratorRuntime.mark((function t(e,n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==n&&(n={}),"string"!=typeof e){t.next=10;break}if(0!==(r=Aw(e,n)).length){t.next=7;break}r.push(vk(e,n)),t.next=9;break;case 7:if(!(r.length>1)){t.next=9;break}throw new DN("Found more than one ("+r.length+") load handlers for URL '"+e+"'");case 9:e=r[0];case 10:return t.abrupt("return",aT(e,void 0,n));case 11:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function aT(t,e,n){return iT.apply(this,arguments)}function iT(){return(iT=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==r&&(r={}),null!=e.load){t.next=3;break}throw new DN("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");case 3:return t.next=5,e.load();case 5:if(a=t.sent,null!=(i=a.modelTopology).model_config&&(i=i.model_config),o=null==r.strict||r.strict,s=null!=a.weightData&&null!=a.weightSpecs&&o,u=GI(bA(i),n,s),null!=(c=a.trainingConfig)&&u.loadTrainingConfig(c),null!=a.userDefinedMetadata&&u.setUserDefinedMetadata(a.userDefinedMetadata),null==a.weightData){t.next=24;break}if(null!=a.weightSpecs){t.next=17;break}throw new DN("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");case 17:if(l=oT(a.weightData,a.weightSpecs),h=l.modelWeights,f=l.optimizerWeights,u.loadWeights(h,o),!(null!=u.optimizer&&f.length>0)){t.next=22;break}return t.next=22,u.optimizer.setWeights(f);case 22:Eb(h),Eb(f.map((function(t){return t.tensor})));case 24:return t.abrupt("return",u);case 25:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function oT(t,e){var n=yw(t,e),r={},a=[];return e.forEach((function(t){"optimizer"===t.group?a.push({name:t.name,tensor:n[t.name]}):r[t.name]=n[t.name]})),{modelWeights:r,optimizerWeights:a}}eT.className="Model",Fk(eT);var sT=function(t){function e(e){var n;if(e=e||{},(n=t.call(this,{inputs:[],outputs:[]})||this).trainable=!0,n.built=!1,n.name=null!=e.name?e.name:mI("sequential_"),null!=e.layers)for(var r,a=Zm(e.layers);!(r=a()).done;){var i=r.value;n.add(i)}return n}Gm(e,t);var n=e.prototype;return n.checkShape=function(t){if(t.inboundNodes[0].outputTensors[0].shape.some((function(t){return t<0})))throw new DN("Negative dimension size caused by adding layer "+t.name+" with input shape ["+t.inboundNodes[0].inputTensors[0].shape+"]")},n.add=function(t){var n,r=t instanceof e||t instanceof eT;if(r){if(1!==(n=t).outputs.length)throw new DN("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new DN("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===t.inboundNodes.length){if(null==t.batchInputShape)throw new DN("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");var a=_I({batchShape:t.batchInputShape,dtype:t.dtype,name:t.name+"_input"});t.apply(a)}if(r)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==t.inboundNodes.length)throw new DN("A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer "+t.name+" which has "+t.inboundNodes.length+" pre-existing inbound connections.");if(1!==t.inboundNodes[0].outputTensors.length)throw new DN("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[t.inboundNodes[0].outputTensors[0]],this.inputs=function t(e,n,r){if((null==n||null!=r&&r>0)&&(n=e.sourceLayer,r=e.nodeIndex),0===n.inboundNodes.length)return[e];var a=n.inboundNodes[r];if(0===a.inboundLayers.length)return a.inputTensors;for(var i=[],o=0;o<a.inboundLayers.length;o++)for(var s,u=Zm(t(a.inputTensors[o],a.inboundLayers[o],a.nodeIndices[o]));!(s=u()).done;){var c=s.value;-1===i.indexOf(c)&&i.push(c)}return i}(this.outputs[0])}this.inboundNodes=[],new EI({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:FN(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((function(t){return t.shape})),outputShapes:this.outputs[0].shape})}else{var i=t.apply(this.outputs[0]);if(Array.isArray(i))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[i],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(t),this.built=!1},n.pop=function(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{var t=this.layers.length-1;this.layers[t].outboundNodes=[],this.outputs=[this.layers[t].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}},n.call=function(t,e){return null==this.model&&this.build(),this.model.call(t,e)},n.build=function(t){if(bI(t),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new eT({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0},n.countParams=function(){return this.built||this.build(),t.prototype.countParams.call(this)},n.summary=function(e,n,r){void 0===r&&(r=console.log),this.built||this.build(),t.prototype.summary.call(this,e,n,r)},n.setWeights=function(t){null==this.model&&this.build(),this.model.setWeights(t)},n.evaluate=function(t,e,n){if(void 0===n&&(n={}),!this.built)throw new TN("The model needs to be compiled before being used.");return this.model.evaluate(t,e,n)},n.evaluateDataset=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.built){t.next=2;break}throw new TN("The model needs to be compiled before being used.");case 2:return t.abrupt("return",this.model.evaluateDataset(e,n));case 3:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.predict=function(t,e){return void 0===e&&(e={}),null==this.model&&this.build(),this.model.predict(t,e)},n.predictOnBatch=function(t){return null==this.model&&this.build(),this.model.predictOnBatch(t)},n.compile=function(t){this.build(),this.model.compile(t),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames},n.fit=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n,r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r={}),this.built){t.next=3;break}throw new TN("The model needs to be compiled before being used.");case 3:return t.abrupt("return",this.model.fit(e,n,r));case 4:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),n.fitDataset=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.built){t.next=2;break}throw new TN("The model needs to be compiled before being used.");case 2:return t.abrupt("return",this.model.fitDataset(e,n));case 3:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.trainOnBatch=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.model.trainOnBatch(e,n));case 1:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.fromConfig=function(t,n,r,a){var i;void 0===a&&(a=!1);var o={};if(n instanceof Array){if(null==n[0].className||"Merge"===n[0].className)throw new DN("Legacy serialization format not supported yet.");i=n}else gv(null!=n.layers,(function(){return"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."})),i=n.layers,delete n.layers,o=n;var s=new t(o);if(!(s instanceof e))throw new _N("Sequential.fromConfig called on non-Sequential input: "+s);for(var u,c=Zm(i);!(u=c()).done;){var l=GI(u.value,void 0,a);a&&l.setFastWeightInitDuringBuild(!0),s.add(l)}return s},n.getConfig=function(){for(var t,e=[],n=Zm(this.layers);!(t=n()).done;){var r=t.value,a={};a.className=r.getClassName(),a.config=r.getConfig(),e.push(a)}return{name:this.name,layers:e}},jm(e,[{key:"optimizer",get:function(){return null==this.model?void 0:this.model.optimizer},set:function(t){this.model.optimizer=t}},{key:"stopTraining",set:function(t){if(null==this.model)throw new DN("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=t},get:function(){if(null==this.model)throw new DN("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}}]),e}(eT);function uT(t){return _I(t)}sT.className="Sequential",Fk(sT);var cT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.getConfig=function(){return{}},e}(_k),lT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t,e){return void 0===e&&(e=1),function(t,e){if(void 0===e&&(e=1),1!==e)throw new _N("Support for alpha values other than 1 ("+e+") is not implemented yet.");return SC(t)}(t,e)},e}(cT);lT.className="elu",Fk(lT);var hT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return IC(t)},e}(cT);hT.className="selu",Fk(hT);var fT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return NC(t)},e}(cT);fT.className="relu",Fk(fT);var pT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return Nb((function(){return yx(6,NC(t))}))},e}(cT);pT.className="relu6",Fk(pT);var dT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return t},e}(cT);dT.className="linear",Fk(dT);var mT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return tx(t)},e}(cT);mT.className="sigmoid",Fk(mT);var vT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return function(t){return Nb((function(){var e=Db(.5,kx(.2,t));return Wb(e,0,1)}))}(t)},e}(cT);vT.className="hardSigmoid",Fk(vT);var gT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return sx(t)},e}(cT);gT.className="softplus",Fk(gT);var yT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return function(t){return Nb((function(){return Ix(t,_b(t).add(1))}))}(t)},e}(cT);yT.className="softsign",Fk(yT);var bT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t){return hx(t)},e}(cT);bT.className="tanh",Fk(bT);var xT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t,e){return void 0===e&&(e=-1),AC(t,e)},e}(cT);xT.className="softmax",Fk(xT);var wT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t,e){return void 0===e&&(e=-1),TC(t,e)},e}(cT);function kT(t){return t.getClassName()}function ST(t,e){return void 0===e&&(e={}),jN(t,Ok.getMap().classNameMap,e,"activation")}function CT(t){if(null==t){var e={className:"linear",config:{}};return ST(e)}if("string"==typeof t){var n={};return n.className=t,n.config={},ST(n)}return t instanceof cT?t:ST(t)}function RT(t){if(null!=t&&"object"!=typeof t)throw new Error("Argument to L1L2 regularizer's constructor is expected to be an object, but received: "+t)}wT.className="logSoftmax",Fk(wT);var NT=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e}(_k),ET=function(t){function e(e){var n;return n=t.call(this)||this,RT(e),n.l1=null==e||null==e.l1?.01:e.l1,n.l2=null==e||null==e.l2?.01:e.l2,n.hasL1=0!==n.l1,n.hasL2=0!==n.l2,n}Gm(e,t);var n=e.prototype;return n.apply=function(t){var e=this;return Nb((function(){var n=my([1]);return e.hasL1&&(n=Db(n,Yy(kx(e.l1,_b(t))))),e.hasL2&&(n=Db(n,Yy(kx(e.l2,BE(t))))),n.asScalar()}))},n.getConfig=function(){return{l1:this.l1,l2:this.l2}},e.fromConfig=function(t,e){return new t({l1:e.l1,l2:e.l2})},e}(NT);ET.className="L1L2",Fk(ET);var IT={l1l2:"L1L2"};function AT(t){return UN(t)}function TT(t,e){return void 0===e&&(e={}),jN(t,Ok.getMap().classNameMap,e,"regularizer")}function DT(t){return null==t?null:"string"==typeof t?TT({className:t in IT?IT[t]:t,config:{}}):t instanceof NT?t:TT(t)}var _T=function(t){function e(e){var n;return(n=t.call(this,null==e?{}:e)||this).supportsMasking=!0,null!=e&&(n.maxValue=e.maxValue),n}Gm(e,t);var n=e.prototype;return n.call=function(t,e){t=yI(t);var n=NC(t);return null!=this.maxValue&&(n=Wb(n,0,this.maxValue)),n},n.computeOutputShape=function(t){return t},n.getConfig=function(){var e={maxValue:this.maxValue},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);_T.className="ReLU",Fk(_T);var OT=function(t){function e(e){var n;return(n=t.call(this,null==e?{}:e)||this).DEFAULT_ALPHA=.3,null==e&&(e={}),n.alpha=null==e.alpha?n.DEFAULT_ALPHA:e.alpha,n}Gm(e,t);var n=e.prototype;return n.call=function(t,e){var n=yI(t);return CC(n,this.alpha)},n.computeOutputShape=function(t){return t},n.getConfig=function(){var e={alpha:this.alpha},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);OT.className="LeakyReLU",Fk(OT);var FT=function(t){function e(e){var n;if((n=t.call(this,null==e?{}:e)||this).DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),n.supportsMasking=!0,n.alphaInitializer=lI(e.alphaInitializer||n.DEFAULT_ALPHA_INITIALIZER),n.alphaRegularizer=DT(e.alphaRegularizer),n.alphaConstraint=oE(e.alphaConstraint),null==e.sharedAxes)n.sharedAxes=null;else if(Array.isArray(e.sharedAxes))n.sharedAxes=e.sharedAxes;else{if("number"!=typeof e.sharedAxes)throw new DN("Expected sharedAxes to be a number or an array of numbers, but got "+e.sharedAxes);n.sharedAxes=[e.sharedAxes]}return n}Gm(e,t);var n=e.prototype;return n.build=function(t){var e=(t=bI(t)).slice(1);if(null!=this.sharedAxes)for(var n,r=Zm(this.sharedAxes);!(n=r()).done;){e[n.value-1]=1}this.alpha=this.addWeight("alpha",e,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);var a={};if(null!=this.sharedAxes)for(var i=1;i<t.length;++i)a[i]=t[i];this.inputSpec=[new CI({ndim:t.length,axes:a})],this.built=!0},n.call=function(t,e){return t=yI(t),RC(t,this.alpha.read())},n.getConfig=function(){var e={alphaInitializer:cI(this.alphaInitializer),alphaRegularizer:AT(this.alphaRegularizer),alphaConstraint:aE(this.alphaConstraint),sharedAxes:this.sharedAxes},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);FT.className="PReLU",Fk(FT);var MT=function(t){function e(e){var n;if((n=t.call(this,null==e?{}:e)||this).DEFAULT_ALPHA=1,null==e&&(e={}),null!=e.alpha&&e.alpha!==n.DEFAULT_ALPHA)throw new _N("Non-default alpha value ("+e.alpha+") is not supported by the ELU layer yet.");return n.alpha=null==e.alpha?n.DEFAULT_ALPHA:e.alpha,n}Gm(e,t);var n=e.prototype;return n.call=function(t,e){var n=yI(t);return SC(n)},n.computeOutputShape=function(t){return t},n.getConfig=function(){var e={alpha:this.alpha},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);MT.className="ELU",Fk(MT);var LT=function(t){function e(e){var n;return(n=t.call(this,null==e?{}:e)||this).DEFAULT_THETA=1,null==e&&(e={}),n.theta=null==e.theta?n.DEFAULT_THETA:e.theta,n}Gm(e,t);var n=e.prototype;return n.call=function(t,e){var n=yI(t);return n.mul(EE(n.greater(this.theta),"float32"))},n.computeOutputShape=function(t){return t},n.getConfig=function(){var e={theta:this.theta},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);LT.className="ThresholdedReLU",Fk(LT);var zT=function(t){function e(e){var n;return(n=t.call(this,null==e?{}:e)||this).DEFAULT_AXIS=1,null==e&&(e={}),n.softmax=(new xT).apply,n.axis=null==e.axis?n.DEFAULT_AXIS:e.axis,n}Gm(e,t);var n=e.prototype;return n.call=function(t,e){var n=yI(t);return this.softmax(n,this.axis)},n.computeOutputShape=function(t){return t},n.getConfig=function(){var e={axis:this.axis},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);function BT(t,e,n){if("number"==typeof t)return FN(t,e);if(t.length!==e)throw new DN("The "+n+" argument must be an integer or tuple of "+e+" integers. Received: "+t.length+" elements.");for(var r=0;r<e;++r){var a=t[r];if((i=a)!==parseInt(i.toString(),10))throw new DN("The "+n+" argument must be an integer or tuple of "+e+" integers. Received: "+JSON.stringify(t)+" including a non-integer number "+a)}return t;var i}function PT(t,e,n,r,a){return void 0===a&&(a=1),null==t?t:(i="same"===n?t:t-(e+(e-1)*(a-1))+1,Math.floor((i+r-1)/r));var i}function WT(t,e,n,r){if(null==t)return null;if("valid"===r)t=t*e+RE([n-e,0]);else{if("same"!==r)throw new DN("Unsupport padding mode: "+r+".");t*=e}return t}function VT(t,e){return Nb((function(){return pE(e),"channelsFirst"===e?Bx(t,[0,2,3,1]):t}))}function UT(t,e){return Nb((function(){return pE(e),"channelsFirst"===e?Bx(t,[0,2,3,4,1]):t}))}function jT(t,e,n,r,a,i,o,s){return void 0===r&&(r=[1,1]),void 0===a&&(a="valid"),void 0===s&&(s=null),Nb((function(){if(null==i&&(i="channelsLast"),pE(i),3!==t.rank&&4!==t.rank)throw new DN("conv2dWithBiasActivation expects input to be of rank 3 or 4, but received "+t.rank+".");if(3!==e.rank&&4!==e.rank)throw new DN("conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received "+t.rank+".");var u=VT(t,i);if("causal"===a)throw new _N("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=WR({x:u,filter:e,strides:r,pad:"same"===a?"same":"valid",dilations:o,dataFormat:"NHWC",bias:n,activation:s}),"channelsFirst"===i&&(u=Bx(u,[0,3,1,2])),u}))}zT.className="Softmax",Fk(zT);var GT=function(t){function e(n,r){var a;if((a=t.call(this,r)||this).bias=null,a.DEFAULT_KERNEL_INITIALIZER="glorotNormal",a.DEFAULT_BIAS_INITIALIZER="zeros",e.verifyArgs(r),a.rank=n,YN(a.rank,"rank"),1!==a.rank&&2!==a.rank&&3!==a.rank)throw new _N("Convolution layer for rank other than 1, 2, or 3 ("+a.rank+") is not implemented yet.");if(a.kernelSize=BT(r.kernelSize,n,"kernelSize"),a.strides=BT(null==r.strides?1:r.strides,n,"strides"),a.padding=null==r.padding?"valid":r.padding,dE(a.padding),a.dataFormat=null==r.dataFormat?"channelsLast":r.dataFormat,pE(a.dataFormat),a.activation=CT(r.activation),a.useBias=null==r.useBias||r.useBias,a.biasInitializer=lI(r.biasInitializer||a.DEFAULT_BIAS_INITIALIZER),a.biasConstraint=oE(r.biasConstraint),a.biasRegularizer=DT(r.biasRegularizer),a.activityRegularizer=DT(r.activityRegularizer),a.dilationRate=BT(null==r.dilationRate?1:r.dilationRate,n,"dilationRate"),1===a.rank&&Array.isArray(a.dilationRate)&&1!==a.dilationRate.length)throw new DN("dilationRate must be a number or an array of a single number for 1D convolution, but received "+JSON.stringify(a.dilationRate));if(2===a.rank){if("number"==typeof a.dilationRate)a.dilationRate=[a.dilationRate,a.dilationRate];else if(2!==a.dilationRate.length)throw new DN("dilationRate must be a number or array of two numbers for 2D convolution, but received "+JSON.stringify(a.dilationRate))}else if(3===a.rank)if("number"==typeof a.dilationRate)a.dilationRate=[a.dilationRate,a.dilationRate,a.dilationRate];else if(3!==a.dilationRate.length)throw new DN("dilationRate must be a number or array of three numbers for 3D convolution, but received "+JSON.stringify(a.dilationRate));return a}return Gm(e,t),e.verifyArgs=function(t){if(MN("kernelSize"in t,"required key 'kernelSize' not in config"),"number"!=typeof t.kernelSize&&!XN(t.kernelSize,"number",1,3))throw new DN("BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received "+JSON.stringify(t.kernelSize)+".")},e.prototype.getConfig=function(){var e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:kT(this.activation),useBias:this.useBias,biasInitializer:cI(this.biasInitializer),biasRegularizer:AT(this.biasRegularizer),activityRegularizer:AT(this.activityRegularizer),biasConstraint:aE(this.biasConstraint)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI),qT=function(t){function e(n,r){var a;return(a=t.call(this,n,r)||this).kernel=null,e.verifyArgs(r),a.filters=r.filters,YN(a.filters,"filters"),a.kernelInitializer=lI(r.kernelInitializer||a.DEFAULT_KERNEL_INITIALIZER),a.kernelConstraint=oE(r.kernelConstraint),a.kernelRegularizer=DT(r.kernelRegularizer),a}Gm(e,t);var n=e.prototype;return n.build=function(t){var e;t=bI(t);var n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n])throw new DN("The channel dimension of the input should be defined. Found "+t[n]);var r=t[n],a=this.kernelSize.concat([r,this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:(e={},e[n]=r,e)}],this.built=!0},n.call=function(t,e){var n=this;return Nb((function(){var e;t=yI(t);var r,a,i,o,s,u,c,l=null==n.bias?null:n.bias.read(),h=JN(n.activation.getClassName());if(null!=h&&2===n.rank)e=jT(t,n.kernel.read(),l,n.strides,n.padding,n.dataFormat,n.dilationRate,h);else{if(1===n.rank)r=t,a=n.kernel.read(),i=l,o=n.strides[0],s=n.padding,u=n.dataFormat,c=n.dilationRate[0],void 0===o&&(o=1),void 0===s&&(s="valid"),void 0===c&&(c=1),e=Nb((function(){if(null==u&&(u="channelsLast"),pE(u),3!==r.shape.length)throw new DN("The input of a conv1dWithBias operation should be 3, but is "+r.shape.length+" instead.");if(3!==a.shape.length)throw new DN("The kernel for a conv1dWithBias operation should be 3, but is "+a.shape.length+" instead");if(null!=i&&1!==i.shape.length)throw new DN("The bias for a conv1dWithBias operation should be 1, but is "+a.shape.length+" instead");if("channelsFirst"===u&&(r=Bx(r,[0,2,1])),"causal"===s)throw new _N("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");var t=Zk(r,a,o,"same"===s?"same":"valid","NWC",c);return null!=i&&(t=WE(t,i)),t}));else if(2===n.rank)e=jT(t,n.kernel.read(),l,n.strides,n.padding,n.dataFormat,n.dilationRate);else{if(3!==n.rank)throw new _N("convolutions greater than 3D are not implemented yet.");e=function(t,e,n,r,a,i,o){return void 0===r&&(r=[1,1,1]),void 0===a&&(a="valid"),Nb((function(){if(null==i&&(i="channelsLast"),pE(i),4!==t.rank&&5!==t.rank)throw new DN("conv3dWithBias expects input to be of rank 4 or 5, but received "+t.rank+".");if(4!==e.rank&&5!==e.rank)throw new DN("conv3dWithBias expects kernel to be of rank 4 or 5, but received "+t.rank+".");var s=UT(t,i);if("causal"===a)throw new _N("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return s=tS(s,e,r,"same"===a?"same":"valid","NDHWC",o),null!=n&&(s=WE(s,n)),"channelsFirst"===i&&(s=Bx(s,[0,4,1,2,3])),s}))}(t,n.kernel.read(),l,n.strides,n.padding,n.dataFormat,n.dilationRate)}null!=n.activation&&(e=n.activation.apply(e))}return e}))},n.computeOutputShape=function(t){t=bI(t);for(var e=[],n="channelsLast"===this.dataFormat?t.slice(1,t.length-1):t.slice(2),r=0;r<n.length;++r){var a=PT(n[r],this.kernelSize[r],this.padding,this.strides[r],"number"==typeof this.dilationRate?this.dilationRate:this.dilationRate[r]);e.push(a)}var i=[t[0]];return"channelsLast"===this.dataFormat?(i=i.concat(e)).push(this.filters):(i.push(this.filters),i=i.concat(e)),i},n.getConfig=function(){var e={filters:this.filters,kernelInitializer:cI(this.kernelInitializer),kernelRegularizer:AT(this.kernelRegularizer),kernelConstraint:aE(this.kernelConstraint)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e.verifyArgs=function(t){if(!("filters"in t)||"number"!=typeof t.filters||t.filters<1)throw new DN("Convolution layer expected config.filters to be a 'number' > 0 but got "+JSON.stringify(t.filters))},e}(GT),HT=function(t){function e(n){var r;return r=t.call(this,2,n)||this,e.verifyArgs(n),r}return Gm(e,t),e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.rank,e},e.verifyArgs=function(t){if("number"!=typeof t.kernelSize&&!XN(t.kernelSize,"number",1,2))throw new DN("Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received "+JSON.stringify(t.kernelSize)+".")},e}(qT);HT.className="Conv2D",Fk(HT);var KT=function(t){function e(n){var r;return r=t.call(this,3,n)||this,e.verifyArgs(n),r}return Gm(e,t),e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.rank,e},e.verifyArgs=function(t){if("number"!=typeof t.kernelSize&&(!Array.isArray(t.kernelSize)||1!==t.kernelSize.length&&3!==t.kernelSize.length))throw new DN("Conv3D expects config.kernelSize to be number or [number, number, number], but received "+JSON.stringify(t.kernelSize)+".")},e}(qT);KT.className="Conv3D",Fk(KT);var XT=function(t){function e(e){var n;if((n=t.call(this,e)||this).inputSpec=[new CI({ndim:4})],"same"!==n.padding&&"valid"!==n.padding)throw new DN("Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode "+n.padding);return n}Gm(e,t);var n=e.prototype;return n.build=function(t){var e;if(4!==(t=bI(t)).length)throw new DN("Input should have rank 4; Received input shape: "+JSON.stringify(t));var n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n])throw new DN("The channel dimension of the inputs should be defined. Found `None`.");var r=t[n],a=this.kernelSize.concat([this.filters,r]);this.kernel=this.addWeight("kernel",a,"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 CI({ndim:4,axes:(e={},e[n]=r,e)})],this.built=!0},n.call=function(t,e){var n=this;return Nb((function(){var e=yI(t);if(4!==e.shape.length)throw new DN("Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-"+e.shape.length);var r,a,i=e.shape,o=i[0];"channelsFirst"===n.dataFormat?(r=2,a=3):(r=1,a=2);var s=i[r],u=i[a],c=n.kernelSize[0],l=n.kernelSize[1],h=n.strides[0],f=n.strides[1],p=[o,WT(s,h,c,n.padding),WT(u,f,l,n.padding),n.filters];"channelsLast"!==n.dataFormat&&(e=Bx(e,[0,2,3,1]));var d=Qk(e,n.kernel.read(),p,n.strides,n.padding);return"channelsLast"!==n.dataFormat&&(d=Bx(d,[0,3,1,2])),null!=n.bias&&(d=WE(d,n.bias.read(),n.dataFormat)),null!=n.activation&&(d=n.activation.apply(d)),d}))},n.computeOutputShape=function(t){var e,n,r,a=(t=bI(t)).slice();"channelsFirst"===this.dataFormat?(e=1,n=2,r=3):(e=3,n=1,r=2);var i=this.kernelSize[0],o=this.kernelSize[1],s=this.strides[0],u=this.strides[1];return a[e]=this.filters,a[n]=WT(a[n],s,i,this.padding),a[r]=WT(a[r],u,o,this.padding),a},n.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.dilationRate,e},e}(HT);XT.className="Conv2DTranspose",Fk(XT);var YT=function(t){function e(e,n){var r;if((r=t.call(this,e,n)||this).DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",r.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",r.depthwiseKernel=null,r.pointwiseKernel=null,null==n.filters)throw new DN("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=n.kernelInitializer||null!=n.kernelRegularizer||null!=n.kernelConstraint)throw new DN("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=n.padding&&"same"!==n.padding&&"valid"!==n.padding)throw new DN("SeparableConv"+r.rank+"D supports only padding modes: 'same' and 'valid', but received "+JSON.stringify(n.padding));return r.depthMultiplier=null==n.depthMultiplier?1:n.depthMultiplier,r.depthwiseInitializer=lI(n.depthwiseInitializer||r.DEFAULT_DEPTHWISE_INITIALIZER),r.depthwiseRegularizer=DT(n.depthwiseRegularizer),r.depthwiseConstraint=oE(n.depthwiseConstraint),r.pointwiseInitializer=lI(n.depthwiseInitializer||r.DEFAULT_POINTWISE_INITIALIZER),r.pointwiseRegularizer=DT(n.pointwiseRegularizer),r.pointwiseConstraint=oE(n.pointwiseConstraint),r}Gm(e,t);var n=e.prototype;return n.build=function(t){var e;if((t=bI(t)).length<this.rank+2)throw new DN("Inputs to SeparableConv"+this.rank+"D should have rank "+(this.rank+2)+", but received input shape: "+JSON.stringify(t));var n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n]||t[n]<0)throw new DN("The channel dimension of the inputs should be defined, but found "+JSON.stringify(t[n]));for(var r=t[n],a=this.kernelSize.concat([r,this.depthMultiplier]),i=[],o=0;o<this.rank;++o)i.push(1);i.push(r*this.depthMultiplier,this.filters);this.depthwiseKernel=this.addWeight("depthwise_kernel",a,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",i,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,!0,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.inputSpec=[new CI({ndim:this.rank+2,axes:(e={},e[n]=r,e)})],this.built=!0},n.call=function(t,e){var n=this;return Nb((function(){var e;if(t=yI(t),1===n.rank)throw new _N("1D separable convolution is not implemented yet.");return 2===n.rank&&("channelsFirst"===n.dataFormat&&(t=Bx(t,[0,2,3,1])),e=qS(t,n.depthwiseKernel.read(),n.pointwiseKernel.read(),n.strides,n.padding,n.dilationRate,"NHWC")),n.useBias&&(e=WE(e,n.bias.read(),n.dataFormat)),null!=n.activation&&(e=n.activation.apply(e)),"channelsFirst"===n.dataFormat&&(e=Bx(e,[0,3,1,2])),e}))},n.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=cI(this.depthwiseInitializer),e.pointwiseInitializer=cI(this.pointwiseInitializer),e.depthwiseRegularizer=AT(this.depthwiseRegularizer),e.pointwiseRegularizer=AT(this.pointwiseRegularizer),e.depthwiseConstraint=aE(this.depthwiseConstraint),e.pointwiseConstraint=aE(this.pointwiseConstraint),e},e}(qT);YT.className="SeparableConv";var JT=function(t){function e(e){return t.call(this,2,e)||this}return Gm(e,t),e}(YT);JT.className="SeparableConv2D",Fk(JT);var $T=function(t){function e(n){var r;return r=t.call(this,1,n)||this,e.verifyArgs(n),r.inputSpec=[{ndim:3}],r}return Gm(e,t),e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.rank,delete e.dataFormat,e},e.verifyArgs=function(t){if("number"!=typeof t.kernelSize&&!XN(t.kernelSize,"number",1,1))throw new DN("Conv1D expects config.kernelSize to be number or number[] with length 1, but received "+JSON.stringify(t.kernelSize)+".")},e}(qT);$T.className="Conv1D",Fk($T);var ZT=function(t){function e(e){var n;return n=t.call(this,e)||this,"number"==typeof e.cropping?n.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:"number"==typeof e.cropping[0]?n.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:n.cropping=e.cropping,n.dataFormat=void 0===e.dataFormat?"channelsLast":e.dataFormat,n.inputSpec=[{ndim:4}],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){return"channelsFirst"===this.dataFormat?[t[0],t[1],t[2]-this.cropping[0][0]-this.cropping[0][1],t[3]-this.cropping[1][0]-this.cropping[1][1]]:[t[0],t[1]-this.cropping[0][0]-this.cropping[0][1],t[2]-this.cropping[1][0]-this.cropping[1][1],t[3]]},n.call=function(t,e){var n=this;return Nb((function(){if(t=yI(t),"channelsLast"===n.dataFormat){var e=DE(t,n.cropping[0][0],t.shape[1]-n.cropping[0][0]-n.cropping[0][1],2);return DE(e,n.cropping[1][0],t.shape[2]-n.cropping[1][1]-n.cropping[1][0],3)}var r=DE(t,n.cropping[0][0],t.shape[2]-n.cropping[0][0]-n.cropping[0][1],3);return DE(r,n.cropping[1][0],t.shape[3]-n.cropping[1][1]-n.cropping[1][0],4)}))},n.getConfig=function(){var e={cropping:this.cropping,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);ZT.className="Cropping2D",Fk(ZT);var QT=function(t){function e(e){var n;return(n=t.call(this,e)||this).DEFAULT_SIZE=[2,2],n.inputSpec=[{ndim:4}],n.size=null==e.size?n.DEFAULT_SIZE:e.size,n.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){if("channelsFirst"===this.dataFormat){var e=null==t[2]?null:this.size[0]*t[2],n=null==t[3]?null:this.size[1]*t[3];return[t[0],t[1],e,n]}var r=null==t[1]?null:this.size[0]*t[1],a=null==t[2]?null:this.size[1]*t[2];return[t[0],r,a,t[3]]},n.call=function(t,e){var n=this;return Nb((function(){var e=yI(t),r=e.shape;if("channelsFirst"===n.dataFormat){e=Bx(e,[0,2,3,1]);var a=n.size[0]*r[2],i=n.size[1]*r[3],o=e.resizeNearestNeighbor([a,i]);return Bx(o,[0,3,1,2])}var s=n.size[0]*r[1],u=n.size[1]*r[2];return e.resizeNearestNeighbor([s,u])}))},n.getConfig=function(){var e={size:this.size,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);QT.className="UpSampling2D",Fk(QT);var tD=function(t){function e(e){var n;return(n=t.call(this,2,e)||this).depthwiseKernel=null,n.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,n.depthwiseInitializer=lI(e.depthwiseInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.depthwiseConstraint=oE(e.depthwiseConstraint),n.depthwiseRegularizer=DT(e.depthwiseRegularizer),n}Gm(e,t);var n=e.prototype;return n.build=function(t){if((t=bI(t)).length<4)throw new DN("Inputs to DepthwiseConv2D should have rank 4. Received input shape: "+JSON.stringify(t)+".");var e="channelsFirst"===this.dataFormat?1:3;if(null==t[e]||t[e]<0)throw new DN("The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not ("+t[e]+").");var n=t[e],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},n.call=function(t,e){var n=this;return Nb((function(){t=yI(t);var e,r,a,i,o,s,u=(e=t,r=n.depthwiseKernel.read(),a=n.strides,i=n.padding,o=n.dataFormat,s=null,void 0===a&&(a=[1,1]),void 0===i&&(i="valid"),Nb((function(){null==o&&(o="channelsLast"),pE(o);var t=VT(e,o);if(4!==e.rank)throw new DN("Input for depthwiseConv2d is required to be 4-D, but is instead "+e.rank+"-D");if(4!==r.rank)throw new DN("depthwiseKernel is required to be 4-D, but is instead "+r.rank+"-D");return t=rS(t,r,a,"same"===i?"same":"valid","NHWC",s),"channelsFirst"===o&&(t=Bx(t,[0,3,1,2])),t})));return n.useBias&&(u=WE(u,n.bias.read(),n.dataFormat)),null!=n.activation&&(u=n.activation.apply(u)),u}))},n.computeOutputShape=function(t){t=bI(t);var e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],r="channelsFirst"===this.dataFormat?t[1]*this.depthMultiplier:t[3]*this.depthMultiplier,a=PT(e,this.kernelSize[0],this.padding,this.strides[0]),i=PT(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[t[0],r,a,i]:[t[0],a,i,r]},n.getConfig=function(){var e=t.prototype.getConfig.call(this);return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=cI(this.depthwiseInitializer),e.depthwiseRegularizer=AT(this.depthwiseRegularizer),e.depthwiseConstraint=aE(this.depthwiseRegularizer),e},e}(GT);tD.className="DepthwiseConv2D",Fk(tD);var eD=function(t){function e(e){var n;return(n=t.call(this,e)||this).rate=Math.max(Math.min(e.rate,1),0),n.noiseShape=e.noiseShape,n.seed=e.seed,n.supportsMasking=!0,n}Gm(e,t);var n=e.prototype;return n.getNoiseShape=function(t){if(null==this.noiseShape)return this.noiseShape;for(var e=t.shape,n=[],r=0;r<this.noiseShape.length;++r)n.push(null==this.noiseShape[r]?e[r]:this.noiseShape[r]);return n},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r=yI(t);if(0<n.rate&&n.rate<1){var a=null!=e.training&&e.training,i=n.getNoiseShape(r);return UE((function(){return VE(r,n.rate,i,n.seed)}),(function(){return r}),a)}return t}))},n.getConfig=function(){var e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},n.dispose=function(){return t.prototype.dispose.call(this)},e}(AI);eD.className="Dropout",Fk(eD);var nD=function(t){function e(e){var n;return(n=t.call(this,e)||this).inputSpec=[{ndim:3}],n}return Gm(e,t),e.prototype.getNoiseShape=function(t){var e=t.shape;return[e[0],1,e[2]]},e}(eD);nD.className="SpatialDropout1D",Fk(nD);var rD=function(t){function e(e){var n;if((n=t.call(this,e)||this).activation=null,n.useBias=!0,n.kernel=null,n.bias=null,n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_BIAS_INITIALIZER="zeros",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){var r=null;null!=e.batchSize&&(r=e.batchSize),n.batchInputShape=[r,e.inputDim]}return n.units=e.units,YN(n.units,"units"),n.activation=CT(e.activation),null!=e.useBias&&(n.useBias=e.useBias),n.kernelInitializer=lI(e.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.biasInitializer=lI(e.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelConstraint=oE(e.kernelConstraint),n.biasConstraint=oE(e.biasConstraint),n.kernelRegularizer=DT(e.kernelRegularizer),n.biasRegularizer=DT(e.biasRegularizer),n.activityRegularizer=DT(e.activityRegularizer),n.supportsMasking=!0,n.inputSpec=[{minNDim:2}],n}Gm(e,t);var n=e.prototype;return n.build=function(t){var e,n=(t=bI(t))[t.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[n,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:(e={},e[-1]=n,e)}],this.built=!0},n.computeOutputShape=function(t){var e=(t=bI(t)).slice();return e[e.length-1]=this.units,e},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r,a=yI(t),i=JN(n.activation.getClassName());return null!=i?r=LE(a,n.kernel.read(),i,n.bias?n.bias.read():null):(r=LE(a,n.kernel.read()),null!=n.bias&&(r=WE(r,n.bias.read())),null!=n.activation&&(r=n.activation.apply(r))),r}))},n.getConfig=function(){var e={units:this.units,activation:kT(this.activation),useBias:this.useBias,kernelInitializer:cI(this.kernelInitializer),biasInitializer:cI(this.biasInitializer),kernelRegularizer:AT(this.kernelRegularizer),biasRegularizer:AT(this.biasRegularizer),activityRegularizer:AT(this.activityRegularizer),kernelConstraint:aE(this.kernelConstraint),biasConstraint:aE(this.biasConstraint)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);rD.className="Dense",Fk(rD);var aD=function(t){function e(e){var n;return e=e||{},(n=t.call(this,e)||this).inputSpec=[{minNDim:3}],n.dataFormat=e.dataFormat,n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){for(var e,n=Zm((t=bI(t)).slice(1));!(e=n()).done;){if(null==e.value)throw new DN('The shape of the input to "Flatten" is not fully defined (got '+t.slice(1)+'). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.')}return[t[0],kE(t,1)]},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r=yI(t);if("channelsFirst"===n.dataFormat&&r.rank>1){for(var a=[0],i=2;i<r.rank;++i)a.push(i);a.push(1),r=r.transpose(a)}return function(t){if(t.rank<=1)throw new DN("batchFlatten requires a minimum rank of 2. Got rank: "+t.rank+".");var e=[t.shape[0],kE(t.shape,1)];return t.reshape(e)}(r)}))},n.getConfig=function(){var e={};null!=this.dataFormat&&(e.dataFormat=this.dataFormat);var n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);aD.className="Flatten",Fk(aD);var iD=function(t){function e(e){var n;return(n=t.call(this,e)||this).supportsMasking=!0,n.activation=CT(e.activation),n}Gm(e,t);var n=e.prototype;return n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r=yI(t);return n.activation.apply(r)}))},n.getConfig=function(){var e={activation:kT(this.activation)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);iD.className="Activation",Fk(iD);var oD=function(t){function e(e){var n;return(n=t.call(this,e)||this).n=e.n,n.inputSpec=[{ndim:2}],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){return[t[0],this.n,t[1]]},n.call=function(t,e){var n=this;return Nb((function(){return t=yI(t),e=t,r=n.n,Nb((function(){if(2!==e.shape.length)throw new DN("repeat() expects a rank-2 tensor, but received a rank-"+e.shape.length+" tensor.");return FE(IE(e,1),[1,r,1])}));var e,r}))},n.getConfig=function(){var e={n:this.n},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);oD.className="RepeatVector",Fk(oD);var sD=function(t){function e(e){var n;(n=t.call(this,e)||this).targetShape=e.targetShape;for(var r=0;r<n.targetShape.length;++r)n.isUnknown(n.targetShape[r])&&(n.targetShape[r]=null);return n}Gm(e,t);var n=e.prototype;return n.isUnknown=function(t){return t<0||null==t},n.fixUnknownDimension=function(t,e){for(var n="Total size of new array must be unchanged.",r=e.slice(),a=1,i=null,o=0;o<r.length;++o){var s=r[o];if(this.isUnknown(s)){if(null!==i)throw new DN("Can only specifiy one unknown dimension.");i=o}else a*=s}var u=kE(t);if(null!==i){if(0===a||u%a!=0)throw new DN(n);r[i]=u/a}else if(u!==a)throw new DN(n);return r},n.computeOutputShape=function(t){for(var e=!1,n=0;n<t.length;++n)if(this.isUnknown(t[n])){e=!0;break}return e?t.slice(0,1).concat(this.targetShape):t.slice(0,1).concat(this.fixUnknownDimension(t.slice(1),this.targetShape))},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r=yI(t),a=r.shape,i=a.slice(0,1).concat(n.fixUnknownDimension(a.slice(1),n.targetShape));return r.reshape(i)}))},n.getConfig=function(){var e={targetShape:this.targetShape},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);sD.className="Reshape",Fk(sD);var uD=function(t){function e(e){var n;if(n=t.call(this,e)||this,null==e.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error("Permute constructor requires `dims` to be an Array, but received "+e.dims+" instead.");var r=NE(1,e.dims.length+1);if(!kv(e.dims.slice().sort(),r))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");return n.dims=e.dims,n.dimsIncludingBatch=[0].concat(n.dims),n.inputSpec=[new CI({ndim:n.dims.length+1})],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){var e=(t=bI(t)).slice();return this.dims.forEach((function(n,r){e[r+1]=t[n]})),e},n.call=function(t,e){return Bx(yI(t),this.dimsIncludingBatch)},n.getConfig=function(){var e={dims:this.dims},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);uD.className="Permute",Fk(uD);var cD=function(t){function e(e){var n;return(n=t.call(this,null==e?{}:e)||this).supportsMasking=!0,n.maskValue=null!=e?null==e.maskValue?0:e.maskValue:0,n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){return t},n.getConfig=function(){var e=t.prototype.getConfig.call(this),n={maskValue:this.maskValue};return Object.assign(n,e),n},n.computeMask=function(t,e){var n=yI(t);return Uy(CS(n,this.maskValue),-1)},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r=yI(t),a=Uy(CS(r,n.maskValue),-1,!0);return r.mul(a.asType(r.dtype))}))},e}(AI);cD.className="Masking",Fk(cD);var lD=function(t){function e(e){var n;if((n=t.call(this,e)||this).embeddings=null,n.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){var r=null;null!=e.batchSize&&(r=e.batchSize),null==e.inputLength?n.batchInputShape=[r,null]:n.batchInputShape=[r].concat(BN(e.inputLength))}return n.inputDim=e.inputDim,YN(n.inputDim,"inputDim"),n.outputDim=e.outputDim,YN(n.outputDim,"outputDim"),n.embeddingsInitializer=lI(e.embeddingsInitializer||n.DEFAULT_EMBEDDINGS_INITIALIZER),n.embeddingsRegularizer=DT(e.embeddingsRegularizer),n.activityRegularizer=DT(e.activityRegularizer),n.embeddingsConstraint=oE(e.embeddingsConstraint),n.maskZero=e.maskZero,n.supportsMasking=e.maskZero,n.inputLength=e.inputLength,n}Gm(e,t);var n=e.prototype;return n.build=function(t){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0},n.warnOnIncompatibleInputShape=function(t){},n.computeMask=function(t,e){var n=this;return Nb((function(){return n.maskZero?(t=yI(t),CS(t,xy(t))):null}))},n.computeOutputShape=function(t){if(t=bI(t),null==this.inputLength)return[].concat(t,[this.outputDim]);var e=BN(this.inputLength);if(e.length!==t.length-1)throw new DN('"inputLength" is '+this.inputLength+", but received input shape has shape "+t);for(var n=0,r=0;r<e.length;++r){var a=e[r],i=t[r+1];if(null!=a&&null!=i&&a!==i)throw new DN('"inputLength" is '+this.inputLength+", but received input shape has shape "+t);null==a&&(e[n]=i),n++}return[t[0]].concat(e,[this.outputDim])},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r=yI(t);return"int32"!==r.dtype&&(r=EE(r,"int32")),zE(n.embeddings.read(),r.as1D()).reshape(bI(n.computeOutputShape(r.shape)))}))},n.getConfig=function(){var e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:cI(this.embeddingsInitializer),embeddingsRegularizer:AT(this.embeddingsRegularizer),activityRegularizer:AT(this.activityRegularizer),embeddingsConstraint:aE(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);lD.className="Embedding",Fk(lD);var hD=function(t){function e(e){var n;return(n=t.call(this,e||{})||this).supportsMasking=!0,n}Gm(e,t);var n=e.prototype;return n.mergeFunction=function(t){throw new _N},n.computeElementwiseOpOutputShape=function(t,e){if(null==t||null==e)return null;if(t.length<e.length)return this.computeElementwiseOpOutputShape(e,t);if(0===e.length)return t;for(var n=t.slice(0,t.length-e.length),r=0;r<e.length;++r){var a=t[t.length-e.length+r],i=e[r];if(null==a||null==i||a<0||i<0)n.push(null);else if(1===a)n.push(i);else if(1===i)n.push(a);else{if(a!==i)throw new DN("Operands could not be broadcast together with shapes "+JSON.stringify(t)+" "+JSON.stringify(e));n.push(a)}}return n},n.build=function(t){if(Array.isArray(t)&&!Array.isArray(t[0])&&(t=[bI(t)]),(t=t).length<2)throw new DN("A merge layer should be called on an Array of at least 2 inputs. Got "+t.length+" input(s).");for(var e,n=[],r=Zm(t);!(e=r()).done;){var a=e.value;null!=a&&null!==a[0]&&n.push(a[0])}if((n=qN(n)).length>1)throw new DN("Can not merge tensors with different batch sizes. Got tensors with shapes: "+JSON.stringify(t)+".");for(var i=null==t[0]?null:t[0].slice(1),o=1;o<t.length;++o){var s=null==t[o]?null:t[o].slice(1);i=this.computeElementwiseOpOutputShape(i,s)}var u=t.map((function(t){return t.length}));-1===t.indexOf(null)&&1===qN(u).length?this.reshapeRequired=!1:this.reshapeRequired=!0},n.call=function(t,e){var n=this;return Nb((function(){if(t=t,n.reshapeRequired){var e=[],r=t.map((function(t){return t.rank}));if(-1===r.indexOf(null)){for(var a,i=RE(r),o=Zm(t);!(a=o()).done;){for(var s=a.value,u=s.rank,c=0;c<i-u;++c)s=IE(s,1);e.push(s)}return n.mergeFunction(e)}for(var l,h=!1,f=Zm(t);!(l=f()).done;){var p=l.value,d=p.rank;if(null==d){var m=p.shape,v=m[0],g=m.slice(1).concat([v]),y=p.reshape([v].concat(kE(m.slice(1))));y=(y=Bx(y,[1,0])).reshape(g),e.push(y),h=!0}else if(d>1){var b=NE(1,d).concat([0]);e.push(Bx(p,b)),h=!0}else e.push(p)}var x=n.mergeFunction(e),w=x.rank;if(h)if(null==w){var k=x.shape,S=k[k.length-1],C=[S].concat(k.slice(0,k.length-1));x=Bx(x.reshape([-1,S]),[1,0]).reshape(C)}else if(w>1){var R=[w-1].concat(NE(0,w-1));x=Bx(x,R)}return x}return n.mergeFunction(t)}))},n.computeOutputShape=function(t){var e;e=null==(t=t)[0]?null:t[0].slice(1);for(var n=1;n<t.length;++n){var r=null==t[n]?null:t[n].slice(1);e=this.computeElementwiseOpOutputShape(e,r)}for(var a,i=[],o=Zm(t);!(a=o()).done;){var s=a.value;null!=s&&null!==s[0]&&i.push(s[0])}return e=1===(i=qN(i)).length?i.concat(e):[null].concat(e)},n.computeMask=function(t,e){return Nb((function(){if(null==e)return null;if(!Array.isArray(e))throw new DN("`mask` should be an Array");if(!Array.isArray(t))throw new DN("`inputs` should be an Array");if(e.length!==t.length)throw new DN("The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths ("+t.length+" vs "+e.length+")");if(e.every((function(t){return null==t})))return null;for(var n=(e=e.map((function(t){return null==t?t:Ey(t,0)})))[0],r=1;r<e.length-1;++r)n=sS(n,e[r]);return n}))},e}(AI),fD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.mergeFunction=function(t){return Nb((function(){for(var e=t[0].clone(),n=1;n<t.length;++n)e=Db(e,t[n]);return e}))},e}(hD);fD.className="Add",Fk(fD);var pD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.mergeFunction=function(t){return Nb((function(){for(var e=t[0].clone(),n=1;n<t.length;++n)e=kx(e,t[n]);return e}))},e}(hD);pD.className="Multiply",Fk(pD);var dD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.mergeFunction=function(t){return Nb((function(){for(var e=t[0].clone(),n=1;n<t.length;++n)e=Db(e,t[n]);return kx(1/t.length,e)}))},e}(hD);dD.className="Average",Fk(dD);var mD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.mergeFunction=function(t){return Nb((function(){for(var e=t[0],n=1;n<t.length;++n)e=vx(e,t[n]);return e}))},e}(hD);mD.className="Maximum",Fk(mD);var vD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.mergeFunction=function(t){return Nb((function(){for(var e=t[0],n=1;n<t.length;++n)e=yx(e,t[n]);return e}))},e}(hD);vD.className="Minimum",Fk(vD);var gD=function(t){function e(e){var n;return(n=t.call(this,e)||this).DEFAULT_AXIS=-1,null==e&&(e={}),n.axis=null==e.axis?n.DEFAULT_AXIS:e.axis,n.supportsMasking=!0,n.reshapeRequired=!1,n}Gm(e,t);var n=e.prototype;return n.build=function(t){if(!Array.isArray(t)||!Array.isArray(t[0])||1===t.length)throw new DN("A `Concatenate` layer should be called on a list of at least 2 inputs");for(var e,n=!0,r=Zm(t=t);!(e=r()).done;){if(null!=e.value){n=!1;break}}if(!n){for(var a=[],i=0;i<t.length;++i){var o=t[i].slice();o.splice(this.axis,1);for(var s,u=!1,c=Zm(a);!(s=c()).done;){if(kv(s.value,o)){u=!0;break}}u||a.push(o)}if(a.length>1)throw new DN("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(t))}},n.mergeFunction=function(t){var e=this;return Nb((function(){return _E(t,e.axis)}))},n.computeOutputShape=function(t){if(!Array.isArray(t)||!Array.isArray(t[0]))throw new DN("A `Concatenate` layer should be called on a list of inputs.");for(var e,n=t,r=n[0].slice(),a=this.axis<0?r.length+this.axis:this.axis,i=Zm(n.slice(1));!(e=i()).done;){var o=e.value;if(null==r[a]||null==o[a]){r[a]=null;break}r[a]+=o[a]}return r},n.computeMask=function(t,e){var n=this;if(null==e)return null;if(!Array.isArray(e))throw new DN("`mask` should be an array for Concatenate");if(!Array.isArray(t))throw new DN("`inputs` should be an array for Concatenate");if(e.length!==t.length)throw new DN("Mismatch in the length of mask ("+e.length+") and the legnth of inputs ("+t.length+")");return Nb((function(){var r=!0;if(e.forEach((function(t){null==t||(r=!1)})),r)return null;for(var a=[],i=0;i<t.length;++i)null==e[i]?a.push(by(t[i]).asType("bool")):e[i].rank<t[i].rank?a.push(Ey(e[i],-1)):a.push(e[i]);var o=wy(a,n.axis);return Vy(o,-1,!1)}))},n.getConfig=function(){var e={axis:this.axis},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(hD);function yD(t,e){for(;t<0;)t+=e;return t}gD.className="Concatenate",Fk(gD);var bD=function(t){function e(e){var n;return(n=t.call(this,e)||this).axes=e.axes,n.normalize=null!=e.normalize&&e.normalize,n.supportsMasking=!0,n.reshapeRequired=!1,n}Gm(e,t);var n=e.prototype;return n.build=function(t){gv(Array.isArray(t)&&2===t.length&&Array.isArray(t[0])&&Array.isArray(t[1]),(function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."}));var e=t[0],n=t[1];if(e.length>3||n.length>3)throw new _N("Dot layer does not support tensors of 4D or higher rank yet.");var r=this.interpretAxes(e,n);if(e[r[0]]!==n[r[1]])throw new DN("Dimension incompatibility: "+e[r[0]]+" !== "+n[r[1]])},n.mergeFunction=function(t){if(2!==t.length)throw new DN("A `Dot` layer must be called on exactly 2 inputs, but received "+t.length+" input(s).");var e,n=t[0],r=t[1];return e=Array.isArray(this.axes)?this.axes.map((function(e,n){return yD(e,t[n].shape.length)})):[yD(this.axes,n.shape.length),yD(this.axes,r.shape.length)],this.normalize&&(n=qI(n,e[0]),r=qI(r,e[1])),function(t,e,n){if(t.shape.length>3||e.shape.length>3)throw new _N("batchDot is not implemented for tensors of 4D or higher rank yet");if(gv(t.shape.length>=2,(function(){return"batchDot requires the rank of x to be >= 2, but got "+t.shape.length})),gv(t.shape.length>=2,(function(){return"batchDot requires the rank of y to be >= 2, but got "+e.shape.length})),"number"==typeof n&&(n=[n,n]),"complex64"===t.dtype||"complex64"===e.dtype)throw new _N("batchDot is not implemented for complex64-type Tensors yet.");var r=t.shape.length,a=e.shape.length;null==n&&(n=[r-1,a-2]);var i=n;return Nb((function(){var n,o;if(r>a){n=r-a;for(var s=[],u=0;u<n;++u)s.push(1);e=e.reshape(e.shape.concat(s))}else if(a>r){n=a-r;for(var c=[],l=0;l<n;++l)c.push(1);t=t.reshape(t.shape.concat(c))}else n=0;if(2===t.shape.length&&2===e.shape.length)o=i[0]===i[1]?t.mul(e).sum(i[0]):t.transpose([1,0]).mul(e).sum(i[1]);else{var h=i[0]!==t.shape.length-1,f=i[1]===e.shape.length-1;o=t.matMul(e,h,f)}if(n>0){for(var p,d=[],m=p=r>a?r+a-3:r-1;m<p+n;++m)d.push(m);o=o.squeeze(d)}return 1===o.shape.length&&(o=o.expandDims(1)),o}))}(n,r,e)},n.interpretAxes=function(t,e){return Array.isArray(this.axes)?this.axes:[yD(this.axes,t.length),yD(this.axes,e.length)]},n.computeOutputShape=function(t){gv(Array.isArray(t)&&2===t.length&&Array.isArray(t[0])&&Array.isArray(t[1]),(function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."}));var e=t[0].slice(),n=t[1].slice();if(e.length>3||n.length>3)throw new _N("Dot layer does not support tensors of 4D or higher rank yet.");var r=this.interpretAxes(e,n);e.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);var a=e.concat(n);return 1===a.length&&a.push(1),a},n.computeMask=function(t,e){return null},n.getConfig=function(){var e={axes:this.axes,normalize:this.normalize},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(hD);bD.className="Dot",Fk(bD);var xD=function(t){function e(e){var n;return(n=t.call(this,e)||this).supportsMasking=!0,n.stddev=e.stddev,n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){return t},n.getConfig=function(){var e=t.prototype.getConfig.call(this),n={stddev:this.stddev};return Object.assign(n,e),n},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r=yI(t);return UE((function(){return ME(r.shape,0,n.stddev).add(r)}),(function(){return r}),e.training||!1)}))},e}(AI);xD.className="GaussianNoise",Fk(xD);var wD=function(t){function e(e){var n;return(n=t.call(this,e)||this).supportsMasking=!0,n.rate=e.rate,n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){return t},n.getConfig=function(){var e=t.prototype.getConfig.call(this),n={rate:this.rate};return Object.assign(n,e),n},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e);var r=yI(t);if(n.rate>0&&n.rate<1){return UE((function(){var t=Math.sqrt(n.rate/(1-n.rate));return r.mul(ME(r.shape,1,t))}),(function(){return r}),e.training||!1)}return r}))},e}(AI);wD.className="GaussianDropout",Fk(wD);var kD=function(t){function e(e){var n;return(n=t.call(this,e)||this).supportsMasking=!0,n.rate=e.rate,n.noiseShape=e.noiseShape,n}Gm(e,t);var n=e.prototype;return n._getNoiseShape=function(t){return this.noiseShape||yI(t).shape},n.computeOutputShape=function(t){return t},n.getConfig=function(){var e=t.prototype.getConfig.call(this),n={rate:this.rate};return Object.assign(n,e),n},n.call=function(t,e){var n=this;return Nb((function(){if(n.rate<1&&n.rate>0){var r=n._getNoiseShape(t);return UE((function(){var e=yI(t),a=-1.7580993408473766,i=yS(GS(r),n.rate);i=EE(i,"float32");var o=Math.pow((1-n.rate)*(1+n.rate*Math.pow(a,2)),-.5),s=-o*a*n.rate;return e.mul(i).add(i.add(-1).mul(a)).mul(o).add(s)}),(function(){return yI(t)}),e.training||!1)}return t}))},e}(AI);function SD(t,e,n,r,a,i){var o;if(void 0===i&&(i=.001),2===t.rank)o=jk(t,e,n,r,a,i);else if(3===t.rank)o=Gk(t,e,n,r,a,i);else{if(4!==t.rank)throw new _N("batchNormalization is not implemented for array of rank "+t.rank+" yet");o=qk(t,e,n,r,a,i)}return o}function CD(t,e,n,r,a){return void 0===a&&(a=.001),kv(r.slice().sort(),NE(0,t.rank-1))?function(t,e,n,r,a){return void 0===a&&(a=.001),Nb((function(){var i=Xy(t,r),o=i.mean,s=i.variance;return[SD(t,o,s,n,e,a),o,s]}))}(t,e,n,r,a):function(t,e,n,r,a){return void 0===a&&(a=.001),Nb((function(){for(var i,o=Xy(t,r),s=o.mean,u=o.variance,c=[],l=Zm(NE(0,t.rank));!(i=l()).done;){var h=i.value;-1!==r.indexOf(h)?c.push(1):c.push(t.shape[h])}var f=s.reshape(c),p=u.reshape(c),d=null==e?null:e.reshape(c),m=null==n?null:n.reshape(c);return[SD(t,f,p,m,d,a),s,u]}))}(t,e,n,r,a)}kD.className="AlphaDropout",Fk(kD);var RD=function(t){function e(e){var n;return null==e&&(e={}),(n=t.call(this,e)||this).supportsMasking=!0,n.axis=null==e.axis?-1:e.axis,n.momentum=null==e.momentum?.99:e.momentum,n.epsilon=null==e.epsilon?.001:e.epsilon,n.center=null==e.center||e.center,n.scale=null==e.scale||e.scale,n.betaInitializer=lI(e.betaInitializer||"zeros"),n.gammaInitializer=lI(e.gammaInitializer||"ones"),n.movingMeanInitializer=lI(e.movingMeanInitializer||"zeros"),n.movingVarianceInitializer=lI(e.movingVarianceInitializer||"ones"),n.betaConstraint=oE(e.betaConstraint),n.gammaConstraint=oE(e.gammaConstraint),n.betaRegularizer=DT(e.betaRegularizer),n.gammaRegularizer=DT(e.gammaRegularizer),n}Gm(e,t);var n=e.prototype;return n.build=function(t){var e;t=bI(t);var n=this.axis>=0?this.axis:this.axis+t.length,r=t[n];if(null==r)throw new DN("Axis "+n+" of input tensor should have a defined dimension but the layer received an input with shape "+JSON.stringify(t)+".");this.inputSpec=[new CI({ndim:t.length,axes:(e={},e[n]=r,e)})];var a=[r];this.scale&&(this.gamma=this.addWeight("gamma",a,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",a,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",a,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",a,null,this.movingVarianceInitializer,null,!1),this.built=!0},n.call=function(t,e){var n=this;return Nb((function(){var r=null!=e.training&&e.training,a=yI(t),i=a.shape,o=i.length,s=NE(0,o),u=n.axis>=0?n.axis:n.axis+o;s.splice(u,1);var c=FN(1,o);c[u]=i[u];var l=s.slice();l.sort();var h=!kv(l,NE(0,o).slice(0,o-1));if(!r)return function(){if(h){var t=n.movingMean.read().reshape(c),e=n.movingVariance.read().reshape(c),r=n.center?n.beta.read().reshape(c):null,i=n.scale?n.gamma.read().reshape(c):null;return SD(a,t,e,r,i,n.epsilon)}return SD(a,n.movingMean.read(),n.movingVariance.read(),null==n.beta?null:n.beta.read(),null==n.gamma?null:n.gamma.read(),n.epsilon)}();var f=CD(a,n.gamma.read(),n.beta.read(),s,n.epsilon),p=f[0],d=f[1],m=f[2],v=function(t,e,n){Nb((function(){var r=1-n,a=t.read(),i=a.sub(e).mul(r);t.write(a.sub(i))}))};return v(n.movingMean,d,n.momentum),v(n.movingVariance,m,n.momentum),p}))},n.getConfig=function(){var e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:cI(this.betaInitializer),gammaInitializer:cI(this.gammaInitializer),movingMeanInitializer:cI(this.movingMeanInitializer),movingVarianceInitializer:cI(this.movingVarianceInitializer),betaRegularizer:AT(this.betaRegularizer),gammaRegularizer:AT(this.gammaRegularizer),betaConstraint:aE(this.betaConstraint),gammaConstraint:aE(this.gammaConstraint)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);RD.className="BatchNormalization",Fk(RD);var ND=function(t){function e(e){var n;if(null==e&&(e={}),(n=t.call(this,e)||this).axis=null==e.axis?-1:e.axis,"number"==typeof n.axis){if(!Number.isInteger(n.axis))throw new Error("Expected axis to be an integer, but received "+n.axis)}else{if(!Array.isArray(n.axis))throw new Error("Expected axis to be an integer or an array of integers, but received "+JSON.stringify(n.axis));for(var r,a=Zm(n.axis);!(r=a()).done;){var i=r.value;if(!Number.isInteger(i))throw new Error("Expected axis to be an array of integers, but received "+JSON.stringify(n.axis))}}return n.epsilon=null==e.epsilon?.001:e.epsilon,n.center=null==e.center||e.center,n.scale=null==e.scale||e.scale,n.betaInitializer=lI(e.betaInitializer||"zeros"),n.gammaInitializer=lI(e.gammaInitializer||"ones"),n.betaRegularizer=DT(e.betaRegularizer),n.gammaRegularizer=DT(e.gammaRegularizer),n.supportsMasking=!0,n}Gm(e,t);var n=e.prototype;return n.build=function(t){var e=(t=bI(t)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(var n=0;n<this.axis.length;++n)this.axis[n]<0&&(this.axis[n]+=e);for(var r,a=Zm(this.axis);!(r=a()).done;){var i=r.value;if(i<0||i>=e)throw new Error("Invalid axis: "+i)}if(this.axis.length!==qN(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);var o=this.axis.map((function(e){return t[e]}));this.scale?this.gamma=this.addWeight("gamma",o,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",o,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0},n.call=function(t,e){var n=this,r=yI(t),a=r.shape,i=a.length;return Nb((function(){for(var t,e=Xy(r,n.axis,!0),o=e.mean,s=e.variance,u=FN(1,i),c=Zm(n.axis);!(t=c()).done;){var l=t.value;u[l]=a[l]}for(var h=function(t){return null!=t&&t.shape.length!==i&&n.axis!==[i-1]?t.reshape(u):t},f=h(n.gamma.read()),p=h(n.beta.read()),d=[],m=[],v=0;v<i;++v)-1!==n.axis.indexOf(v)?(d.push(a[v]),m.push(1)):(d.push(1),m.push(a[v]));return o=o.tile(d),s=s.tile(d),f=f.tile(m),p=p.tile(m),SD(r,o,s,p,f,n.epsilon)}))},n.getConfig=function(){var e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:cI(this.betaInitializer),gammaInitializer:cI(this.gammaInitializer),betaRegularizer:AT(this.betaRegularizer),gammaRegularizer:AT(this.gammaRegularizer)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);ND.className="LayerNormalization",Fk(ND);var ED=function(t){function e(e){var n;if(null==e&&(e={}),(n=t.call(this,e)||this).dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,null==e.padding)n.padding=[[1,1],[1,1]];else if("number"==typeof e.padding)n.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,2!==e.padding.length)throw new DN("ZeroPadding2D expects padding to be a length-2 array, but received a length-"+e.padding.length+" array.");var r,a;if("number"==typeof e.padding[0])r=[e.padding[0],e.padding[0]],a=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,2!==e.padding[0].length)throw new DN("ZeroPadding2D expects height padding to be a length-2 array, but received a length-"+e.padding[0].length+" array.");if(r=e.padding[0],2!==e.padding[1].length)throw new DN("ZeroPadding2D expects width padding to be a length-2 array, but received a length-"+e.padding[1].length+" array.");a=e.padding[1]}n.padding=[r,a]}return n.inputSpec=[new CI({ndim:4})],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){var e,n;return t=bI(t),"channelsFirst"===this.dataFormat?(e=null!=t[2]&&t[2]>=0?t[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[3]&&t[3]>=0?t[3]+this.padding[1][0]+this.padding[1][1]:null,[t[0],t[1],e,n]):(e=null!=t[1]&&t[1]>=0?t[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[2]&&t[2]>=0?t[2]+this.padding[1][0]+this.padding[1][1]:null,[t[0],e,n,t[3]])},n.call=function(t,e){var n=this;return Nb((function(){return e=yI(t),r=n.padding,a=n.dataFormat,Nb((function(){if(4!==e.rank)throw new DN("temporalPadding expects input tensor to be 4-D, but received a "+e.rank+"-D tensor.");if(null==r&&(r=[[1,1],[1,1]]),2!==r.length||2!==r[0].length||2!==r[1].length)throw new DN("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==a&&(a="channelsLast"),"channelsLast"!==a&&"channelsFirst"!==a)throw new DN("Unknown data format: "+a+". Supported data formats are 'channelsLast' and 'channelsFirst.");var t;return t="channelsFirst"===a?[[0,0],[0,0],r[0],r[1]]:[[0,0],r[0],r[1],[0,0]],Xx(e,t)}));var e,r,a}))},n.getConfig=function(){var e={padding:this.padding,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI);function ID(t,e,n,r,a,i){return Nb((function(){var o;pE(a),mE(i),dE(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),t=VT(t,a);var s="same"===r?"same":"valid";return o="max"===i?lC(t,e,n,s):hC(t,e,n,s),"channelsFirst"===a&&(o=Bx(o,[0,3,1,2])),o}))}function AD(t,e,n,r,a,i){return Nb((function(){var o;pE(a),mE(i),dE(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),t=UT(t,a);var s="same"===r?"same":"valid";return o="max"===i?pC(t,e,n,s):dC(t,e,n,s),"channelsFirst"===a&&(o=Bx(o,[0,4,1,2,3])),o}))}ED.className="ZeroPadding2D",Fk(ED);var TD=function(t){function e(e){var n;if(null==e.poolSize&&(e.poolSize=2),n=t.call(this,e)||this,"number"==typeof e.poolSize)n.poolSize=[e.poolSize];else{if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!=typeof e.poolSize[0])throw new DN("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(e.poolSize));n.poolSize=e.poolSize}if(YN(n.poolSize,"poolSize"),null==e.strides)n.strides=n.poolSize;else if("number"==typeof e.strides)n.strides=[e.strides];else{if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!=typeof e.strides[0])throw new DN("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(e.strides));n.strides=e.strides}return YN(n.strides,"strides"),n.padding=null==e.padding?"valid":e.padding,dE(n.padding),n.inputSpec=[new CI({ndim:3})],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){var e=PT((t=bI(t))[1],this.poolSize[0],this.padding,this.strides[0]);return[t[0],e,t[2]]},n.call=function(t,e){var n=this;return Nb((function(){n.invokeCallHook(t,e),t=IE(yI(t),2);var r=n.poolingFunction(yI(t),[n.poolSize[0],1],[n.strides[0],1],n.padding,"channelsLast");return Ay(r,[2])}))},n.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI),DD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.poolingFunction=function(t,e,n,r,a){return pE(a),dE(r),ID(t,e,n,r,a,"max")},e}(TD);DD.className="MaxPooling1D",Fk(DD);var _D=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.poolingFunction=function(t,e,n,r,a){return pE(a),dE(r),ID(t,e,n,r,a,"avg")},e}(TD);_D.className="AveragePooling1D",Fk(_D);var OD=function(t){function e(e){var n;if(null==e.poolSize&&(e.poolSize=[2,2]),(n=t.call(this,e)||this).poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)n.strides=n.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new DN("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+".");n.strides=e.strides}else n.strides=[e.strides,e.strides];return YN(n.poolSize,"poolSize"),YN(n.strides,"strides"),n.padding=null==e.padding?"valid":e.padding,n.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,pE(n.dataFormat),dE(n.padding),n.inputSpec=[new CI({ndim:4})],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){t=bI(t);var e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2];return e=PT(e,this.poolSize[0],this.padding,this.strides[0]),n=PT(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n]:[t[0],e,n,t[3]]},n.call=function(t,e){var n=this;return Nb((function(){return n.invokeCallHook(t,e),n.poolingFunction(yI(t),n.poolSize,n.strides,n.padding,n.dataFormat)}))},n.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI),FD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.poolingFunction=function(t,e,n,r,a){return pE(a),dE(r),ID(t,e,n,r,a,"max")},e}(OD);FD.className="MaxPooling2D",Fk(FD);var MD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.poolingFunction=function(t,e,n,r,a){return pE(a),dE(r),ID(t,e,n,r,a,"avg")},e}(OD);MD.className="AveragePooling2D",Fk(MD);var LD=function(t){function e(e){var n;if(null==e.poolSize&&(e.poolSize=[2,2,2]),(n=t.call(this,e)||this).poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)n.strides=n.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new DN("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+".");n.strides=e.strides}else n.strides=[e.strides,e.strides,e.strides];return YN(n.poolSize,"poolSize"),YN(n.strides,"strides"),n.padding=null==e.padding?"valid":e.padding,n.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,pE(n.dataFormat),dE(n.padding),n.inputSpec=[new CI({ndim:5})],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){t=bI(t);var e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],r="channelsFirst"===this.dataFormat?t[4]:t[3];return e=PT(e,this.poolSize[0],this.padding,this.strides[0]),n=PT(n,this.poolSize[1],this.padding,this.strides[1]),r=PT(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n,r]:[t[0],e,n,r,t[4]]},n.call=function(t,e){var n=this;return Nb((function(){return n.invokeCallHook(t,e),n.poolingFunction(yI(t),n.poolSize,n.strides,n.padding,n.dataFormat)}))},n.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI),zD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.poolingFunction=function(t,e,n,r,a){return pE(a),dE(r),AD(t,e,n,r,a,"max")},e}(LD);zD.className="MaxPooling3D",Fk(zD);var BD=function(t){function e(e){return t.call(this,e)||this}return Gm(e,t),e.prototype.poolingFunction=function(t,e,n,r,a){return pE(a),dE(r),AD(t,e,n,r,a,"avg")},e}(LD);BD.className="AveragePooling3D",Fk(BD);var PD=function(t){function e(e){var n;return(n=t.call(this,e)||this).inputSpec=[new CI({ndim:3})],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){return[t[0],t[2]]},n.call=function(t,e){throw new _N},e}(AI),WD=function(t){function e(e){return t.call(this,e||{})||this}return Gm(e,t),e.prototype.call=function(t,e){return Nb((function(){var e=yI(t);return Hy(e,1)}))},e}(PD);WD.className="GlobalAveragePooling1D",Fk(WD);var VD=function(t){function e(e){return t.call(this,e||{})||this}return Gm(e,t),e.prototype.call=function(t,e){return Nb((function(){var e=yI(t);return kS(e,1)}))},e}(PD);VD.className="GlobalMaxPooling1D",Fk(VD);var UD=function(t){function e(e){var n;return(n=t.call(this,e)||this).dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,pE(n.dataFormat),n.inputSpec=[new CI({ndim:4})],n}Gm(e,t);var n=e.prototype;return n.computeOutputShape=function(t){return t=t,"channelsLast"===this.dataFormat?[t[0],t[3]]:[t[0],t[1]]},n.call=function(t,e){throw new _N},n.getConfig=function(){var e={dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(AI),jD=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.call=function(t,e){var n=this;return Nb((function(){var e=yI(t);return"channelsLast"===n.dataFormat?Hy(e,[1,2]):Hy(e,[2,3])}))},e}(UD);jD.className="GlobalAveragePooling2D",Fk(jD);var GD=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.call=function(t,e){var n=this;return Nb((function(){var e=yI(t);return"channelsLast"===n.dataFormat?kS(e,[1,2]):kS(e,[2,3])}))},e}(UD);function qD(t,e,n,r){if(Array.isArray(t)){if(null!=e||null!=n)throw new DN("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=t.slice(t.length-r,t.length),t=t.slice(0,t.length-r)),t.length>1&&(e=t.slice(1,t.length)),t=t[0]}function a(t){return null==t||Array.isArray(t)?t:[t]}return{inputs:t,initialState:e=a(e),constants:n=a(n)}}function HD(t,e,n,r,a,i,o,s){return void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),Nb((function(){var u=e.shape.length;if(u<3)throw new DN("Input should be at least 3D, but is "+u+"D.");var c=[1,0].concat(NE(2,u));if(e=Bx(e,c),null!=i)throw new _N("The rnn() functoin of the deeplearn.js backend does not support constants yet.");o&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=a&&((a=a.asType("bool").asType("float32")).rank===u-1&&(a=Ey(a,-1)),a=Bx(a,c)),r&&(e=rC(e,0),null!=a&&(a=rC(a,0)));var l,h,f=[],p=n,d=e.shape[0],m=Dy(e);null!=a&&(h=Dy(a));for(var v,g=function(e){var n=m[e],r=Nb((function(){return t(n,p)}));if(null==a)l=r[0],p=r[1];else{var i=Nb((function(){var t=h[e],n=by(t).sub(t);return{output:r[0].mul(t).add(p[0].mul(n)),newStates:p.map((function(e,a){return r[1][a].mul(t).add(e.mul(n))}))}}));l=i.output,p=i.newStates}s&&f.push(l)},y=0;y<d;++y)g(y);if(s){v=Ty(f,1)}return[l,v,p]}))}GD.className="GlobalMaxPooling2D",Fk(GD);var KD=function(t){function e(e){var n,r;if(n=t.call(this,e)||this,null==e.cell)throw new DN("cell property is missing for the constructor of RNN.");if(null==(r=Array.isArray(e.cell)?new e_({cells:e.cell}):e.cell).stateSize)throw new DN("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");return n.cell=r,n.returnSequences=null!=e.returnSequences&&e.returnSequences,n.returnState=null!=e.returnState&&e.returnState,n.goBackwards=null!=e.goBackwards&&e.goBackwards,n._stateful=null!=e.stateful&&e.stateful,n.unroll=null!=e.unroll&&e.unroll,n.supportsMasking=!0,n.inputSpec=[new CI({ndim:3})],n.stateSpec=null,n.states_=null,n.numConstants=null,n.keptStates=[],n}Gm(e,t);var n=e.prototype;return n.getStates=function(){return null==this.states_?NE(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((function(t){return null})):this.states_},n.setStates=function(t){this.states_=t},n.computeOutputShape=function(t){vI(t)&&(t=t[0]),t=t;var e=this.cell.stateSize;Array.isArray(e)||(e=[e]);var n,r=e[0];if(n=this.returnSequences?[t[0],t[1],r]:[t[0],r],this.returnState){for(var a,i=[],o=Zm(e);!(a=o()).done;){var s=a.value;i.push([t[0],s])}return[n].concat(i)}return n},n.computeMask=function(t,e){var n=this;return Nb((function(){Array.isArray(e)&&(e=e[0]);var t=n.returnSequences?e:null;if(n.returnState){var r=n.states.map((function(t){return null}));return[t].concat(r)}return t}))},n.build=function(t){if(null!=this.numConstants)throw new _N("Constants support is not implemented in RNN yet.");vI(t)&&(t=t[0]),t=t;var e=this.stateful?t[0]:null,n=t[t.length-1];this.inputSpec[0]=new CI({shape:[e,null,n]});var r,a=[t[0]].concat(t.slice(2));if(this.cell.build(a),r=Array.isArray(this.cell.stateSize)?this.cell.stateSize:[this.cell.stateSize],null!=this.stateSpec){if(!kv(this.stateSpec.map((function(t){return t.shape[t.shape.length-1]})),r))throw new DN("An initialState was passed that is not compatible with cell.stateSize. Received stateSpec="+this.stateSpec+"; However cell.stateSize is "+this.cell.stateSize)}else this.stateSpec=r.map((function(t){return new CI({shape:[null,t]})}));this.stateful&&this.resetStates()},n.resetStates=function(t,e){var n=this;void 0===e&&(e=!1),Nb((function(){if(!n.stateful)throw new AN("Cannot call resetStates() on an RNN Layer that is not stateful.");var r=n.inputSpec[0].shape[0];if(null==r)throw new DN("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==n.states_)Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(t){return my([r,t])})):n.states_=[my([r,n.cell.stateSize])];else if(null==t)Eb(n.states_),null!=n.keptStates&&(Eb(n.keptStates),n.keptStates=[]),Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(t){return my([r,t])})):n.states_[0]=my([r,n.cell.stateSize]);else{if(Array.isArray(t)||(t=[t]),t.length!==n.states_.length)throw new DN("Layer "+n.name+" expects "+n.states_.length+" state(s), but it received "+t.length+" state value(s). Input received: "+t);!0===e?n.keptStates.push(n.states_.slice()):Eb(n.states_);for(var a=0;a<n.states_.length;++a){var i=t[a],o=Array.isArray(n.cell.stateSize)?n.cell.stateSize[a]:n.cell.stateSize,s=[r,o];if(!kv(i.shape,s))throw new DN("State "+a+" is incompatible with layer "+n.name+": expected shape="+s+", received shape="+i.shape);n.states_[a]=i}}n.states_=n.states_.map((function(t){return Ib(t.clone())}))}))},n.apply=function(e,n){var r=null==n?null:n.initialState,a=null==n?null:n.constants;null==n&&(n={});var i=qD(e,r,a,this.numConstants);e=i.inputs,r=i.initialState,a=i.constants;var o=[],s=[];if(null!=r){n.initialState=r,o=o.concat(r),this.stateSpec=[];for(var u,c=Zm(r);!(u=c()).done;){var l=u.value;this.stateSpec.push(new CI({shape:l.shape}))}s=s.concat(this.stateSpec)}if(null!=a&&(n.constants=a,o=o.concat(a),this.numConstants=a.length),o[0]instanceof RI){var h=[e].concat(o),f=this.inputSpec.concat(s),p=this.inputSpec;this.inputSpec=f;var d=t.prototype.apply.call(this,h,n);return this.inputSpec=p,d}return t.prototype.apply.call(this,e,n)},n.call=function(t,e){var n=this;return Nb((function(){var r=null==e?null:e.mask,a=null==e?null:e.training,i=null==e?null:e.initialState;t=yI(t),null==i&&(i=n.stateful?n.states_:n.getInitialState(t));var o=Array.isArray(n.cell.stateSize)?n.cell.stateSize.length:1;if(i.length!==o)throw new DN("RNN Layer has "+o+" state(s) but was passed "+i.length+" initial state(s).");n.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");var s={training:a},u=HD((function(t,e){var r=n.cell.call([t].concat(e),s);return[r[0],r.slice(1)]}),t,i,n.goBackwards,r,null,n.unroll,n.returnSequences),c=u[0],l=u[1],h=u[2];n.stateful&&n.resetStates(h,a);var f=n.returnSequences?l:c;return n.returnState?[f].concat(h):f}))},n.getInitialState=function(t){var e=this;return Nb((function(){var n=my(t.shape);return n=IE(n=Yy(n,[1,2])),Array.isArray(e.cell.stateSize)?e.cell.stateSize.map((function(t){return t>1?FE(n,[1,t]):n})):e.cell.stateSize>1?[FE(n,[1,e.cell.stateSize])]:[n]}))},n.setFastWeightInitDuringBuild=function(e){t.prototype.setFastWeightInitDuringBuild.call(this,e),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(e)},n.getConfig=function(){var e={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(e.numConstants=this.numConstants);var n=this.cell.getConfig();e.cell={className:this.cell.getClassName(),config:n};var r=t.prototype.getConfig.call(this);return Object.assign(e,r),e},e.fromConfig=function(t,e,n){void 0===n&&(n={});var r=GI(e.cell,n);return new t(Object.assign(e,{cell:r}))},jm(e,[{key:"states",get:function(){if(null==this.states_){for(var t=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,e=[],n=0;n<t;++n)e.push(null);return e}return this.states_},set:function(t){this.states_=t}},{key:"trainableWeights",get:function(){return this.trainable?this.cell.trainableWeights:[]}},{key:"nonTrainableWeights",get:function(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}}]),e}(AI);KD.className="RNN",Fk(KD);var XD=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e}(AI),YD=function(t){function e(e){var n;return(n=t.call(this,e)||this).DEFAULT_ACTIVATION="tanh",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=e.units,YN(n.units,"units"),n.activation=CT(null==e.activation?n.DEFAULT_ACTIVATION:e.activation),n.useBias=null==e.useBias||e.useBias,n.kernelInitializer=lI(e.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=lI(e.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=lI(e.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=DT(e.kernelRegularizer),n.recurrentRegularizer=DT(e.recurrentRegularizer),n.biasRegularizer=DT(e.biasRegularizer),n.kernelConstraint=oE(e.kernelConstraint),n.recurrentConstraint=oE(e.recurrentConstraint),n.biasConstraint=oE(e.biasConstraint),n.dropout=CE([1,RE([0,null==e.dropout?0:e.dropout])]),n.recurrentDropout=CE([1,RE([0,null==e.recurrentDropout?0:e.recurrentDropout])]),n.stateSize=n.units,n.dropoutMask=null,n.recurrentDropoutMask=null,n}Gm(e,t);var n=e.prototype;return n.build=function(t){t=bI(t),this.kernel=this.addWeight("kernel",[t[t.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},n.call=function(t,e){var n=this;return Nb((function(){if(2!==(t=t).length)throw new DN("SimpleRNNCell expects 2 input Tensors, got "+t.length+".");var r=t[1];t=t[0];var a,i=null!=e.training&&e.training;0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=n_((function(){return by(t)}),n.dropout,i)),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=n_((function(){return by(r)}),n.recurrentDropout,i));var o=n.dropoutMask,s=n.recurrentDropoutMask;a=LE(null!=o?kx(t,o):t,n.kernel.read()),null!=n.bias&&(a=WE(a,n.bias.read())),null!=s&&(r=kx(r,s));var u=Db(a,LE(r,n.recurrentKernel.read()));return null!=n.activation&&(u=n.activation.apply(u)),[u,u]}))},n.getConfig=function(){var e={units:this.units,activation:kT(this.activation),useBias:this.useBias,kernelInitializer:cI(this.kernelInitializer),recurrentInitializer:cI(this.recurrentInitializer),biasInitializer:cI(this.biasInitializer),kernelRegularizer:AT(this.kernelRegularizer),recurrentRegularizer:AT(this.recurrentRegularizer),biasRegularizer:AT(this.biasRegularizer),activityRegularizer:AT(this.activityRegularizer),kernelConstraint:aE(this.kernelConstraint),recurrentConstraint:aE(this.recurrentConstraint),biasConstraint:aE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(XD);YD.className="SimpleRNNCell",Fk(YD);var JD=function(t){function e(e){return e.cell=new YD(e),t.call(this,e)||this}Gm(e,t);var n=e.prototype;return n.call=function(e,n){var r=this;return Nb((function(){null!=r.cell.dropoutMask&&(Eb(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(Eb(r.cell.recurrentDropoutMask),r.cell.recurrentDropoutMask=null);var a=null==n?null:n.mask,i=null==n?null:n.training,o=null==n?null:n.initialState;return t.prototype.call.call(r,e,{mask:a,training:i,initialState:o})}))},n.getConfig=function(){var e={units:this.units,activation:kT(this.activation),useBias:this.useBias,kernelInitializer:cI(this.kernelInitializer),recurrentInitializer:cI(this.recurrentInitializer),biasInitializer:cI(this.biasInitializer),kernelRegularizer:AT(this.kernelRegularizer),recurrentRegularizer:AT(this.recurrentRegularizer),biasRegularizer:AT(this.biasRegularizer),activityRegularizer:AT(this.activityRegularizer),kernelConstraint:aE(this.kernelConstraint),recurrentConstraint:aE(this.recurrentConstraint),biasConstraint:aE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout},n=t.prototype.getConfig.call(this);return delete n.cell,Object.assign(e,n),e},e.fromConfig=function(t,e){return new t(e)},jm(e,[{key:"units",get:function(){return this.cell.units}},{key:"activation",get:function(){return this.cell.activation}},{key:"useBias",get:function(){return this.cell.useBias}},{key:"kernelInitializer",get:function(){return this.cell.kernelInitializer}},{key:"recurrentInitializer",get:function(){return this.cell.recurrentInitializer}},{key:"biasInitializer",get:function(){return this.cell.biasInitializer}},{key:"kernelRegularizer",get:function(){return this.cell.kernelRegularizer}},{key:"recurrentRegularizer",get:function(){return this.cell.recurrentRegularizer}},{key:"biasRegularizer",get:function(){return this.cell.biasRegularizer}},{key:"kernelConstraint",get:function(){return this.cell.kernelConstraint}},{key:"recurrentConstraint",get:function(){return this.cell.recurrentConstraint}},{key:"biasConstraint",get:function(){return this.cell.biasConstraint}},{key:"dropout",get:function(){return this.cell.dropout}},{key:"recurrentDropout",get:function(){return this.cell.recurrentDropout}}]),e}(KD);JD.className="SimpleRNN",Fk(JD);var $D=function(t){function e(e){var n;return(n=t.call(this,e)||this).DEFAULT_ACTIVATION="tanh",n.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=e.units,YN(n.units,"units"),n.activation=CT(void 0===e.activation?n.DEFAULT_ACTIVATION:e.activation),n.recurrentActivation=CT(void 0===e.recurrentActivation?n.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),n.useBias=null==e.useBias||e.useBias,n.kernelInitializer=lI(e.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=lI(e.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=lI(e.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=DT(e.kernelRegularizer),n.recurrentRegularizer=DT(e.recurrentRegularizer),n.biasRegularizer=DT(e.biasRegularizer),n.kernelConstraint=oE(e.kernelConstraint),n.recurrentConstraint=oE(e.recurrentConstraint),n.biasConstraint=oE(e.biasConstraint),n.dropout=CE([1,RE([0,null==e.dropout?0:e.dropout])]),n.recurrentDropout=CE([1,RE([0,null==e.recurrentDropout?0:e.recurrentDropout])]),n.implementation=e.implementation,n.stateSize=n.units,n.dropoutMask=null,n.recurrentDropoutMask=null,n}Gm(e,t);var n=e.prototype;return n.build=function(t){var e=(t=bI(t))[t.length-1];this.kernel=this.addWeight("kernel",[e,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},n.call=function(t,e){var n=this;return Nb((function(){if(2!==(t=t).length)throw new DN("GRUCell expects 2 input Tensors (inputs, h, c), got "+t.length+".");var r=null!=e.training&&e.training,a=t[1];t=t[0],0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=n_((function(){return by(t)}),n.dropout,r,3)),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=n_((function(){return by(a)}),n.recurrentDropout,r,3));var i,o,s,u=n.dropoutMask,c=n.recurrentDropoutMask;0<n.dropout&&n.dropout<1&&(t=kx(t,u[0]));var l=LE(t,n.kernel.read());n.useBias&&(l=WE(l,n.bias.read())),0<n.recurrentDropout&&n.recurrentDropout<1&&(a=kx(a,c[0]));var h=n.recurrentKernel.read(),f=Zy(h,[2*n.units,n.units],h.rank-1),p=f[0],d=f[1],m=LE(a,p),v=Zy(l,3,l.rank-1),g=v[0],y=v[1],b=v[2],x=Zy(m,2,m.rank-1),w=x[0],k=x[1];i=n.recurrentActivation.apply(Db(g,w)),o=n.recurrentActivation.apply(Db(y,k));var S=LE(kx(o,a),d);s=n.activation.apply(Db(b,S));var C=Db(kx(i,a),kx(Db(1,Jb(i)),s));return[C,C]}))},n.getConfig=function(){var e={units:this.units,activation:kT(this.activation),recurrentActivation:kT(this.recurrentActivation),useBias:this.useBias,kernelInitializer:cI(this.kernelInitializer),recurrentInitializer:cI(this.recurrentInitializer),biasInitializer:cI(this.biasInitializer),kernelRegularizer:AT(this.kernelRegularizer),recurrentRegularizer:AT(this.recurrentRegularizer),biasRegularizer:AT(this.biasRegularizer),activityRegularizer:AT(this.activityRegularizer),kernelConstraint:aE(this.kernelConstraint),recurrentConstraint:aE(this.recurrentConstraint),biasConstraint:aE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(XD);$D.className="GRUCell",Fk($D);var ZD=function(t){function e(e){return 0===e.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new $D(e),t.call(this,e)||this}Gm(e,t);var n=e.prototype;return n.call=function(e,n){var r=this;return Nb((function(){null!=r.cell.dropoutMask&&(Eb(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(Eb(r.cell.recurrentDropoutMask),r.cell.recurrentDropoutMask=null);var a=null==n?null:n.mask,i=null==n?null:n.training,o=null==n?null:n.initialState;return t.prototype.call.call(r,e,{mask:a,training:i,initialState:o})}))},n.getConfig=function(){var e={units:this.units,activation:kT(this.activation),recurrentActivation:kT(this.recurrentActivation),useBias:this.useBias,kernelInitializer:cI(this.kernelInitializer),recurrentInitializer:cI(this.recurrentInitializer),biasInitializer:cI(this.biasInitializer),kernelRegularizer:AT(this.kernelRegularizer),recurrentRegularizer:AT(this.recurrentRegularizer),biasRegularizer:AT(this.biasRegularizer),activityRegularizer:AT(this.activityRegularizer),kernelConstraint:aE(this.kernelConstraint),recurrentConstraint:aE(this.recurrentConstraint),biasConstraint:aE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=t.prototype.getConfig.call(this);return delete n.cell,Object.assign(e,n),e},e.fromConfig=function(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e)},jm(e,[{key:"units",get:function(){return this.cell.units}},{key:"activation",get:function(){return this.cell.activation}},{key:"recurrentActivation",get:function(){return this.cell.recurrentActivation}},{key:"useBias",get:function(){return this.cell.useBias}},{key:"kernelInitializer",get:function(){return this.cell.kernelInitializer}},{key:"recurrentInitializer",get:function(){return this.cell.recurrentInitializer}},{key:"biasInitializer",get:function(){return this.cell.biasInitializer}},{key:"kernelRegularizer",get:function(){return this.cell.kernelRegularizer}},{key:"recurrentRegularizer",get:function(){return this.cell.recurrentRegularizer}},{key:"biasRegularizer",get:function(){return this.cell.biasRegularizer}},{key:"kernelConstraint",get:function(){return this.cell.kernelConstraint}},{key:"recurrentConstraint",get:function(){return this.cell.recurrentConstraint}},{key:"biasConstraint",get:function(){return this.cell.biasConstraint}},{key:"dropout",get:function(){return this.cell.dropout}},{key:"recurrentDropout",get:function(){return this.cell.recurrentDropout}},{key:"implementation",get:function(){return this.cell.implementation}}]),e}(KD);ZD.className="GRU",Fk(ZD);var QD=function(t){function e(e){var n;return(n=t.call(this,e)||this).DEFAULT_ACTIVATION="tanh",n.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=e.units,YN(n.units,"units"),n.activation=CT(void 0===e.activation?n.DEFAULT_ACTIVATION:e.activation),n.recurrentActivation=CT(void 0===e.recurrentActivation?n.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),n.useBias=null==e.useBias||e.useBias,n.kernelInitializer=lI(e.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=lI(e.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=lI(e.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.unitForgetBias=e.unitForgetBias,n.kernelRegularizer=DT(e.kernelRegularizer),n.recurrentRegularizer=DT(e.recurrentRegularizer),n.biasRegularizer=DT(e.biasRegularizer),n.kernelConstraint=oE(e.kernelConstraint),n.recurrentConstraint=oE(e.recurrentConstraint),n.biasConstraint=oE(e.biasConstraint),n.dropout=CE([1,RE([0,null==e.dropout?0:e.dropout])]),n.recurrentDropout=CE([1,RE([0,null==e.recurrentDropout?0:e.recurrentDropout])]),n.implementation=e.implementation,n.stateSize=[n.units,n.units],n.dropoutMask=null,n.recurrentDropoutMask=null,n}Gm(e,t);var n=e.prototype;return n.build=function(t){var e,n,r=(t=bI(t))[t.length-1];if(this.kernel=this.addWeight("kernel",[r,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){var a=this.biasInitializer,i=this.units;n=new((e=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.apply=function(t,e){var n=a.apply([i]),r=(new KE).apply([i]),o=a.apply([2*i]);return OE(OE(n,r),o)},e}(qE)).className="CustomInit",e)}else n=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,n,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0},n.call=function(t,e){var n=this;return Nb((function(){var r=null!=e.training&&e.training;if(3!==(t=t).length)throw new DN("LSTMCell expects 3 input Tensors (inputs, h, c), got "+t.length+".");var a=t[1],i=t[2];t=t[0],0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=n_((function(){return by(t)}),n.dropout,r,4)),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=n_((function(){return by(a)}),n.recurrentDropout,r,4));var o,s,u,c,l=n.dropoutMask,h=n.recurrentDropoutMask;0<n.dropout&&n.dropout<1&&(t=kx(t,l[0]));var f=LE(t,n.kernel.read());0<n.recurrentDropout&&n.recurrentDropout<1&&(a=kx(a,h[0])),f=Db(f,LE(a,n.recurrentKernel.read())),n.useBias&&(f=WE(f,n.bias.read()));var p=Zy(f,4,f.rank-1),d=p[0],m=p[1],v=p[2],g=p[3];o=n.recurrentActivation.apply(d),s=n.recurrentActivation.apply(m),u=Db(kx(s,i),kx(o,n.activation.apply(v))),c=n.recurrentActivation.apply(g);var y=kx(c,n.activation.apply(u));return[y,y,u]}))},n.getConfig=function(){var e={units:this.units,activation:kT(this.activation),recurrentActivation:kT(this.recurrentActivation),useBias:this.useBias,kernelInitializer:cI(this.kernelInitializer),recurrentInitializer:cI(this.recurrentInitializer),biasInitializer:cI(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:AT(this.kernelRegularizer),recurrentRegularizer:AT(this.recurrentRegularizer),biasRegularizer:AT(this.biasRegularizer),activityRegularizer:AT(this.activityRegularizer),kernelConstraint:aE(this.kernelConstraint),recurrentConstraint:aE(this.recurrentConstraint),biasConstraint:aE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e}(XD);QD.className="LSTMCell",Fk(QD);var t_=function(t){function e(e){return 0===e.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new QD(e),t.call(this,e)||this}Gm(e,t);var n=e.prototype;return n.call=function(e,n){var r=this;return Nb((function(){null!=r.cell.dropoutMask&&(Eb(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(Eb(r.cell.recurrentDropoutMask),r.cell.recurrentDropoutMask=null);var a=null==n?null:n.mask,i=null==n?null:n.training,o=null==n?null:n.initialState;return t.prototype.call.call(r,e,{mask:a,training:i,initialState:o})}))},n.getConfig=function(){var e={units:this.units,activation:kT(this.activation),recurrentActivation:kT(this.recurrentActivation),useBias:this.useBias,kernelInitializer:cI(this.kernelInitializer),recurrentInitializer:cI(this.recurrentInitializer),biasInitializer:cI(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:AT(this.kernelRegularizer),recurrentRegularizer:AT(this.recurrentRegularizer),biasRegularizer:AT(this.biasRegularizer),activityRegularizer:AT(this.activityRegularizer),kernelConstraint:aE(this.kernelConstraint),recurrentConstraint:aE(this.recurrentConstraint),biasConstraint:aE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=t.prototype.getConfig.call(this);return delete n.cell,Object.assign(e,n),e},e.fromConfig=function(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e)},jm(e,[{key:"units",get:function(){return this.cell.units}},{key:"activation",get:function(){return this.cell.activation}},{key:"recurrentActivation",get:function(){return this.cell.recurrentActivation}},{key:"useBias",get:function(){return this.cell.useBias}},{key:"kernelInitializer",get:function(){return this.cell.kernelInitializer}},{key:"recurrentInitializer",get:function(){return this.cell.recurrentInitializer}},{key:"biasInitializer",get:function(){return this.cell.biasInitializer}},{key:"unitForgetBias",get:function(){return this.cell.unitForgetBias}},{key:"kernelRegularizer",get:function(){return this.cell.kernelRegularizer}},{key:"recurrentRegularizer",get:function(){return this.cell.recurrentRegularizer}},{key:"biasRegularizer",get:function(){return this.cell.biasRegularizer}},{key:"kernelConstraint",get:function(){return this.cell.kernelConstraint}},{key:"recurrentConstraint",get:function(){return this.cell.recurrentConstraint}},{key:"biasConstraint",get:function(){return this.cell.biasConstraint}},{key:"dropout",get:function(){return this.cell.dropout}},{key:"recurrentDropout",get:function(){return this.cell.recurrentDropout}},{key:"implementation",get:function(){return this.cell.implementation}}]),e}(KD);t_.className="LSTM",Fk(t_);var e_=function(t){function e(e){var n;return(n=t.call(this,e)||this).cells=e.cells,n}Gm(e,t);var n=e.prototype;return n.call=function(t,e){var n=this;return Nb((function(){for(var r,a=(t=t).slice(1),i=[],o=Zm(n.cells.slice().reverse());!(r=o()).done;){var s=r.value;Array.isArray(s.stateSize)?i.push(a.splice(0,s.stateSize.length)):i.push(a.splice(0,1))}i.reverse();for(var u,c=[],l=0;l<n.cells.length;++l){var h=n.cells[l];a=i[l],u=0===l?[t[0]].concat(a):[u[0]].concat(a),u=h.call(u,e),c.push(u.slice(1))}a=[];for(var f,p=Zm(c.slice().reverse());!(f=p()).done;){var d,m=f.value;(d=a).push.apply(d,m)}return[u[0]].concat(a)}))},n.build=function(t){var e;vI(t)&&(t=t[0]),t=t,this.cells.forEach((function(n,r){gE("RNNCell_"+r,(function(){n.build(t),e=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,t=[t[0],e]}))})),this.built=!0},n.getConfig=function(){for(var e,n=[],r=Zm(this.cells);!(e=r()).done;){var a=e.value;n.push({className:a.getClassName(),config:a.getConfig()})}var i={cells:n},o=t.prototype.getConfig.call(this);return Object.assign(i,o),i},e.fromConfig=function(t,e,n){void 0===n&&(n={});for(var r,a=[],i=Zm(e.cells);!(r=i()).done;){var o=r.value;a.push(GI(o,n))}return new t({cells:a})},n.getWeights=function(){for(var t,e=[],n=Zm(this.cells);!(t=n()).done;){var r=t.value;e.push.apply(e,r.weights)}return kI(e)},n.setWeights=function(t){for(var e,n=[],r=Zm(this.cells);!(e=r()).done;)for(var a=e.value,i=a.weights.length,o=t.splice(i),s=0;s<a.weights.length;++s)n.push([a.weights[s],o[s]]);SI(n)},jm(e,[{key:"stateSize",get:function(){for(var t,e=[],n=Zm(this.cells.slice().reverse());!(t=n()).done;){var r=t.value;Array.isArray(r.stateSize)?e.push.apply(e,r.stateSize):e.push(r.stateSize)}return e}},{key:"trainableWeights",get:function(){if(!this.trainable)return[];for(var t,e=[],n=Zm(this.cells);!(t=n()).done;){var r=t.value;e.push.apply(e,r.trainableWeights)}return e}},{key:"nonTrainableWeights",get:function(){for(var t,e=[],n=Zm(this.cells);!(t=n()).done;){var r=t.value;e.push.apply(e,r.nonTrainableWeights)}if(!this.trainable){for(var a,i=[],o=Zm(this.cells);!(a=o()).done;){var s=a.value;i.push.apply(i,s.trainableWeights)}return i.concat(e)}return e}}]),e}(XD);function n_(t,e,n,r){function a(){return VE(t(),e)}if(void 0===n&&(n=null),void 0===r&&(r=1),r>1){for(var i=[],o=0;o<r;o++)i.push(UE(a,t,n));return i.map((function(t){return Ib(t.clone())}))}return Ib(UE(a,t,n).clone())}e_.className="StackedRNNCells",Fk(e_);var r_=function(t){function e(e){var n;return(n=t.call(this,e)||this).layer=e.layer,n}Gm(e,t);var n=e.prototype;return n.build=function(t){this.built=!0},n.getWeights=function(){return this.layer.getWeights()},n.setWeights=function(t){this.layer.setWeights(t)},n.getConfig=function(){var e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},n.setFastWeightInitDuringBuild=function(e){t.prototype.setFastWeightInitDuringBuild.call(this,e),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e)},e.fromConfig=function(t,e,n){void 0===n&&(n={});var r=GI(e.layer,n);delete e.layer;var a={layer:r};return Object.assign(a,e),new t(a)},jm(e,[{key:"trainable",get:function(){return null!=this.layer&&this.layer.trainable},set:function(t){null!=this.layer&&(this.layer.trainable=t)}},{key:"trainableWeights",get:function(){return this.layer.trainableWeights}},{key:"nonTrainableWeights",get:function(){return this.layer.nonTrainableWeights}},{key:"updates",get:function(){return this.layer._updates}},{key:"losses",get:function(){return this.layer.losses}}]),e}(AI),a_=function(t){function e(e){var n;return(n=t.call(this,e)||this).supportsMasking=!0,n}Gm(e,t);var n=e.prototype;return n.build=function(e){if((e=bI(e)).length<3)throw new DN("TimeDistributed layer expects an input shape >= 3D, but received input shape "+JSON.stringify(e));this.inputSpec=[{shape:e}];var n=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(n),this.layer.built=!0),t.prototype.build.call(this,e)},n.computeOutputShape=function(t){var e=[(t=bI(t))[0]].concat(t.slice(2)),n=this.layer.computeOutputShape(e),r=t[1];return[n[0],r].concat(n.slice(1))},n.call=function(t,e){var n=this;return Nb((function(){return HD((function(t,r){return[yI(n.layer.call(t,e)),[]]}),t=yI(t),[],!1,null,null,!1,!0)[1]}))},e}(r_);a_.className="TimeDistributed",Fk(a_);var i_=function(t){function e(e){var n;n=t.call(this,e)||this;var r=e.layer.getConfig(),a={};a.className=e.layer.getClassName(),a.config=r,n.forwardLayer=GI(a),r.goBackwards=!0!==r.goBackwards;var i,o={};if(o.className=e.layer.getClassName(),o.config=r,n.backwardLayer=GI(o),n.forwardLayer.name="forward_"+n.forwardLayer.name,n.backwardLayer.name="backward_"+n.backwardLayer.name,n.mergeMode=void 0===e.mergeMode?"concat":e.mergeMode,i=n.mergeMode,KN(hE,"BidirectionalMergeMode",i),e.weights)throw new _N("weights support is not implemented for Bidirectional layer yet.");return n._stateful=e.layer.stateful,n.returnSequences=e.layer.returnSequences,n.returnState=e.layer.returnState,n.supportsMasking=!0,n._trainable=!0,n.inputSpec=e.layer.inputSpec,n.numConstants=null,n}Gm(e,t);var n=e.prototype;return n.getWeights=function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())},n.setWeights=function(t){var e=t.length,n=Math.floor(e/2);this.forwardLayer.setWeights(t.slice(0,n)),this.backwardLayer.setWeights(t.slice(n))},n.computeOutputShape=function(t){var e,n,r,a=this.forwardLayer.computeOutputShape(t);return Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),a=a,this.returnState?(r=a.slice(1),e=a[0]):e=a[0],e=e,"concat"===this.mergeMode?(e[e.length-1]*=2,n=[e]):n=null==this.mergeMode?[e,e.slice()]:[e],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[e].concat(r).concat(r.slice()):zN(n)},n.apply=function(e,n){var r=null==n?null:n.initialState,a=null==n?null:n.constants;null==n&&(n={});var i=qD(e,r,a,this.numConstants);if(e=i.inputs,r=i.initialState,a=i.constants,Array.isArray(e)&&(r=e.slice(1),e=e[0]),(null==r||0===r.length)&&null==a)return t.prototype.apply.call(this,e,n);var o=[],s=[];if(null!=r){var u=r.length;if(u%2>0)throw new DN("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");n.initialState=r,o.push.apply(o,r);var c=r.map((function(t){return new CI({shape:t.shape})}));this.forwardLayer.stateSpec=c.slice(0,u/2),this.backwardLayer.stateSpec=c.slice(u/2),s.push.apply(s,c)}if(null!=a)throw new _N("Support for constants in Bidirectional layers is not implemented yet.");for(var l=o[0]instanceof RI,h=0,f=o;h<f.length;h++){if(f[h]instanceof RI!==l)throw new DN("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors")}if(l){var p=[e].concat(o),d=this.inputSpec.concat(s),m=this.inputSpec;this.inputSpec=d;var v=t.prototype.apply.call(this,p,n);return this.inputSpec=m,v}return t.prototype.apply.call(this,e,n)},n.call=function(t,e){var n=this;return Nb((function(){var r,a,i,o,s=e.initialState;if(null==s)r=n.forwardLayer.call(t,e),a=n.backwardLayer.call(t,e);else{var u=s.slice(0,s.length/2),c=s.slice(s.length/2);r=n.forwardLayer.call(t,Object.assign(e,{initialState:u})),a=n.backwardLayer.call(t,Object.assign(e,{initialState:c}))}return n.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),n.returnSequences&&(a=rC(a,1)),"concat"===n.mergeMode?o=_E([r,a]):"sum"===n.mergeMode?o=Db(r,a):"ave"===n.mergeMode?o=kx(.5,Db(r,a)):"mul"===n.mergeMode?o=kx(r,a):null==n.mergeMode&&(o=[r,a]),n.returnState?null==n.mergeMode?o.concat(i):[o].concat(i):o}))},n.resetStates=function(t){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()},n.build=function(t){var e=this;gE(this.forwardLayer.name,(function(){e.forwardLayer.build(t)})),gE(this.backwardLayer.name,(function(){e.backwardLayer.build(t)})),this.built=!0},n.computeMask=function(t,e){var n;if(Array.isArray(e)&&(e=e[0]),n=this.returnSequences?null==this.mergeMode?[e,e]:e:null==this.mergeMode?[null,null]:null,this.returnState){var r=this.forwardLayer.states.map((function(t){return null}));return Array.isArray(n)?n.concat(r).concat(r):[n].concat(r).concat(r)}return n},n.setFastWeightInitDuringBuild=function(e){t.prototype.setFastWeightInitDuringBuild.call(this,e),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(e),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(e)},n.getConfig=function(){var e={mergeMode:this.mergeMode},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e},e.fromConfig=function(t,e){var n=GI(e.layer);if(delete e.layer,null!=e.numConstants)throw new _N("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");var r=e;return r.layer=n,new t(r)},jm(e,[{key:"trainable",get:function(){return this._trainable},set:function(t){this._trainable=t,null!=this.forwardLayer&&(this.forwardLayer.trainable=t),null!=this.backwardLayer&&(this.backwardLayer.trainable=t)}},{key:"trainableWeights",get:function(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}},{key:"nonTrainableWeights",get:function(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}}]),e}(r_);function o_(t){return new _D(t)}function s_(t){return new MD(t)}function u_(t){return new BD(t)}function c_(t){return new VD(t)}function l_(t){return new GD(t)}function h_(t){return new DD(t)}function f_(t){return new FD(t)}i_.className="Bidirectional",Fk(i_);var p_={__proto__:null,inputLayer:function(t){return new DI(t)},elu:function(t){return new MT(t)},reLU:function(t){return new _T(t)},leakyReLU:function(t){return new OT(t)},prelu:function(t){return new FT(t)},softmax:function(t){return new zT(t)},thresholdedReLU:function(t){return new LT(t)},conv1d:function(t){return new $T(t)},conv2d:function(t){return new HT(t)},conv2dTranspose:function(t){return new XT(t)},conv3d:function(t){return new KT(t)},separableConv2d:function(t){return new JT(t)},cropping2D:function(t){return new ZT(t)},upSampling2d:function(t){return new QT(t)},depthwiseConv2d:function(t){return new tD(t)},activation:function(t){return new iD(t)},dense:function(t){return new rD(t)},dropout:function(t){return new eD(t)},spatialDropout1d:function(t){return new nD(t)},flatten:function(t){return new aD(t)},repeatVector:function(t){return new oD(t)},reshape:function(t){return new sD(t)},permute:function(t){return new uD(t)},embedding:function(t){return new lD(t)},add:function(t){return new fD(t)},average:function(t){return new dD(t)},concatenate:function(t){return new gD(t)},maximum:function(t){return new mD(t)},minimum:function(t){return new vD(t)},multiply:function(t){return new pD(t)},dot:function(t){return new bD(t)},batchNormalization:function(t){return new RD(t)},layerNormalization:function(t){return new ND(t)},zeroPadding2d:function(t){return new ED(t)},averagePooling1d:o_,avgPool1d:function(t){return o_(t)},avgPooling1d:function(t){return o_(t)},averagePooling2d:s_,avgPool2d:function(t){return s_(t)},avgPooling2d:function(t){return s_(t)},averagePooling3d:u_,avgPool3d:function(t){return u_(t)},avgPooling3d:function(t){return u_(t)},globalAveragePooling1d:function(t){return new WD(t)},globalAveragePooling2d:function(t){return new jD(t)},globalMaxPooling1d:c_,globalMaxPooling2d:l_,maxPooling1d:h_,maxPooling2d:f_,maxPooling3d:function(t){return new zD(t)},gru:function(t){return new ZD(t)},gruCell:function(t){return new $D(t)},lstm:function(t){return new t_(t)},lstmCell:function(t){return new QD(t)},simpleRNN:function(t){return new JD(t)},simpleRNNCell:function(t){return new YD(t)},rnn:function(t){return new KD(t)},stackedRNNCells:function(t){return new e_(t)},bidirectional:function(t){return new i_(t)},timeDistributed:function(t){return new a_(t)},globalMaxPool1d:c_,globalMaxPool2d:l_,maxPool1d:h_,maxPool2d:f_,Layer:AI,RNN:KD,RNNCell:XD,input:uT,gaussianNoise:function(t){return new xD(t)},gaussianDropout:function(t){return new wD(t)},alphaDropout:function(t){return new kD(t)},masking:function(t){return new cD(t)}};var d_={__proto__:null,binaryAccuracy:function(t,e){return eA(t,e)},binaryCrossentropy:function(t,e){return oA(t,e)},sparseCategoricalAccuracy:function(t,e){return sA(t,e)},categoricalAccuracy:function(t,e){return nA(t,e)},categoricalCrossentropy:function(t,e){return uA(t,e)},precision:function(t,e){return aA(t,e)},recall:function(t,e){return iA(t,e)},cosineProximity:function(t,e){return ZI(t,e)},meanAbsoluteError:function(t,e){return KI(t,e)},meanAbsolutePercentageError:function(t,e){return XI(t,e)},MAPE:function(t,e){return XI(t,e)},mape:function(t,e){return XI(t,e)},meanSquaredError:function(t,e){return HI(t,e)},MSE:function(t,e){return HI(t,e)},mse:function(t,e){return HI(t,e)}},m_={__proto__:null,modelFromJSON:function(t,e){return nT.apply(this,arguments)}};var v_={__proto__:null,l1l2:function(t){return new ET(t)},l1:function(t){return RT(e=t),new ET({l1:null!=e?e.l1:null,l2:0});var e},l2:function(t){return RT(e=t),new ET({l2:null!=e?e.l2:null,l1:0});var e}},g_=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).model=null,e}return Gm(e,t),e.prototype.setModel=function(t){if(!(t instanceof eT))throw new Error("model must be a LayersModel, not some other Container");this.model=t},e}(LI);function y_(t,e){return t<e}function b_(t,e){return t>e}var x_=function(t){function e(e){var n;if(n=t.call(this)||this,null==e&&(e={}),e.restoreBestWeights)throw new _N("restoreBestWeights = True is not implemented in EarlyStopping yet.");return n.monitor=e.monitor||"val_loss",n.minDelta=Math.abs(e.minDelta||0),n.patience=e.patience||0,n.verbose=e.verbose||0,n.mode=e.mode||"auto",n.baseline=e.baseline,-1===["auto","min","max"].indexOf(n.mode)&&(console.warn("EarlyStopping mode '"+n.mode+"' is invalid. Falling back to mode 'auto'."),n.mode="auto"),"min"===n.mode?n.monitorFunc=y_:"max"===n.mode||-1!==n.monitor.indexOf("acc")?n.monitorFunc=b_:n.monitorFunc=y_,n.monitorFunc===y_&&(n.minDelta*=-1),n}Gm(e,t);var n=e.prototype;return n.onTrainBegin=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===y_?1/0:-1/0;case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.onEpochEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,OI(n);case 2:if(null!=(r=this.getMonitorValue(n))){t.next=5;break}return t.abrupt("return");case 5:this.monitorFunc(r-this.minDelta,this.best)?(this.best=r,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0));case 6:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),n.onTrainEnd=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.stoppedEpoch>0&&this.verbose&&console.log("Epoch "+this.stoppedEpoch+": early stopping.");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getMonitorValue=function(t){null==t&&(t={});var e=t[this.monitor];return null==e&&console.warn("Metric for EarlyStopping "+this.monitor+" is not available. Available metrics are: "+Object.keys(t)),e},e}(g_);var w_,k_,S_={earlyStopping:function(t){return new x_(t)}};!function(t){t[t.DT_INVALID=0]="DT_INVALID",t[t.DT_FLOAT=1]="DT_FLOAT",t[t.DT_DOUBLE=2]="DT_DOUBLE",t[t.DT_INT32=3]="DT_INT32",t[t.DT_UINT8=4]="DT_UINT8",t[t.DT_INT16=5]="DT_INT16",t[t.DT_INT8=6]="DT_INT8",t[t.DT_STRING=7]="DT_STRING",t[t.DT_COMPLEX64=8]="DT_COMPLEX64",t[t.DT_INT64=9]="DT_INT64",t[t.DT_BOOL=10]="DT_BOOL",t[t.DT_QINT8=11]="DT_QINT8",t[t.DT_QUINT8=12]="DT_QUINT8",t[t.DT_QINT32=13]="DT_QINT32",t[t.DT_BFLOAT16=14]="DT_BFLOAT16",t[t.DT_FLOAT_REF=101]="DT_FLOAT_REF",t[t.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",t[t.DT_INT32_REF=103]="DT_INT32_REF",t[t.DT_UINT8_REF=104]="DT_UINT8_REF",t[t.DT_INT16_REF=105]="DT_INT16_REF",t[t.DT_INT8_REF=106]="DT_INT8_REF",t[t.DT_STRING_REF=107]="DT_STRING_REF",t[t.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",t[t.DT_INT64_REF=109]="DT_INT64_REF",t[t.DT_BOOL_REF=110]="DT_BOOL_REF",t[t.DT_QINT8_REF=111]="DT_QINT8_REF",t[t.DT_QUINT8_REF=112]="DT_QUINT8_REF",t[t.DT_QINT32_REF=113]="DT_QINT32_REF",t[t.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF"}(w_||(w_={})),function(t){!function(t){t[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2"}(t.CheckpointFormatVersion||(t.CheckpointFormatVersion={}))}(k_||(k_={}));var C_={};function R_(t){return C_[t]}function N_(t,e,n,r){var a=e.inputParams[t];if(a&&void 0!==a.inputIndexStart){var i=a.inputIndexStart,o=0===a.inputIndexEnd?void 0:void 0===a.inputIndexEnd?i+1:a.inputIndexEnd;if("tensor"===a.type)return E_(e.inputNames[a.inputIndexStart],n,r);if("tensors"===a.type)return e.inputNames.slice(i,o).map((function(t){return E_(t,n,r)}));var s=Array.prototype.slice.call(E_(e.inputNames.slice(i)[0],n,r).dataSync());return"number"===a.type?s[0]:s}var u=e.attrParams[t];return u&&u.value}function E_(t,e,n){var r=T_(t),a=r[0],i=r[1],o=n.currentContextIds.find((function(t){return!!e[A_(a,t)]}));return void 0!==o?e[A_(a,o)][i]:void 0}function I_(t,e){var n=T_(t),r=n[0],a=n[1];return[A_(r,e&&e.currentContextId),a]}function A_(t,e){return e?t+"-"+e:t}function T_(t){var e=t.lastIndexOf(":");return-1===e?[t,0]:[t.substring(0,e),Number(t.substring(e+1))]}function D_(t,e){for(var n=[],r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}var __={__proto__:null,json:[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},O_={__proto__:null,json:[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"clip_value_min",name:"clipValueMin",type:"number"},{tfName:"clip_value_max",name:"clipValueMax",type:"number"}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"clipValueMin",name:"clipValueMin",type:"number",defaultValue:0},{tfName:"clipValueMax",name:"clipValueMax",type:"number",defaultValue:6}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},F_={__proto__:null,json:[{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"}]}]},M_={__proto__:null,json:[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]}]},L_={__proto__:null,json:[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}]},z_={__proto__:null,json:[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},B_={__proto__:null,json:[{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]}]},P_={__proto__:null,json:[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}]},W_={__proto__:null,json:[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]}]},V_={__proto__:null,json:[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},U_={__proto__:null,json:[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},j_={__proto__:null,json:[{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}]},G_={__proto__:null,json:[{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]}]},q_={__proto__:null,json:[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool",notSupported:!0}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}]},H_={__proto__:null,json:[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}]},K_={__proto__:null,json:[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]}]},X_=function(){function t(){var t,e=[__,O_,F_,M_,L_,z_,B_,V_,W_,P_,U_,j_,G_,q_,H_,K_],n=(t=[]).concat.apply(t,e.map((function(t){return t.json})));this.opMappers=n.reduce((function(t,e){return t[e.tfOpName]=e,t}),{})}jm(t,null,[{key:"Instance",get:function(){return this._instance||(this._instance=new this)}}]);var e=t.prototype;return e.transformGraph=function(t,e){var n=this;void 0===e&&(e={});var r=t.node,a=[],i=[],o=r.reduce((function(t,e){return t[e.name]=n.mapNode(e),e.op.startsWith("Placeholder")&&a.push(t[e.name]),"Const"===e.op&&i.push(t[e.name]),t}),{}),s=[],u=[],c={},l={};null!=e&&(c=this.mapSignatureEntries(e.inputs),l=this.mapSignatureEntries(e.outputs));var h=Object.keys(o);return h.forEach((function(t){var e=o[t];e.inputNames.forEach((function(t){var n=I_(t)[0];e.inputs.push(o[n]),o[n].children.push(e)}))})),0===Object.keys(l).length?h.forEach((function(t){var e=o[t];0===e.children.length&&u.push(e)})):Object.keys(l).forEach((function(t){var e=I_(t)[0],n=o[e];null!=n&&(n.signatureKey=l[t],u.push(n))})),Object.keys(c).length>0?Object.keys(c).forEach((function(t){var e=I_(t)[0],n=o[e];n&&(n.signatureKey=c[t],s.push(n))})):s=a,{nodes:o,inputs:s,outputs:u,weights:i,placeholders:a,signature:e}},e.mapSignatureEntries=function(t){return Object.keys(t||{}).reduce((function(e,n){return e[t[n].name]=n,e}),{})},e.mapNode=function(t){var e=R_(t.op)||this.opMappers[t.op]||{};null==t.attr&&(t.attr={});var n={name:t.name,op:t.op,category:e.category,inputNames:(t.input||[]).map((function(t){return t.startsWith("^")?t.substr(1):t})),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:t.attr};return null!=e.inputs&&(n.inputParams=e.inputs.reduce((function(t,e){return t[e.name]={type:e.type,inputIndexStart:e.start,inputIndexEnd:e.end},t}),{})),null!=e.attrs&&(n.attrParams=e.attrs.reduce((function(e,n){var r=n.type,a=void 0;switch(n.type){case"string":void 0===(a=J_(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=J_(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":void 0===(a=iO(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=iO(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":void 0===(a=Z_(t.attr,n.tfName,n.defaultValue||0))&&n.tfDeprecatedName&&(a=Z_(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":void 0===(a=aO(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=aO(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":void 0===(a=$_(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=$_(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":void 0===(a=sO(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=sO(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":void 0===(a=rO(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=rO(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":void 0===(a=oO(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=oO(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":void 0===(a=tO(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=tO(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":void 0===(a=eO(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=eO(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: "+n.type+" for op: "+t.op)}return e[n.name]={value:a,type:r},e}),{})),n},t}();function Y_(t,e){var n=Array.isArray(t)?String.fromCharCode.apply(null,t):function(t){var e=nv().global;if(void 0!==e.atob)return e.atob(t);if("undefined"!=typeof Buffer)return new Buffer(t,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(t);return e?n:n.toLowerCase()}function J_(t,e,n,r){void 0===r&&(r=!1);var a=t[e];return null!=a?Y_(a.s,r):n}function $_(t,e,n){var r=t[e];return r?r.b:n}function Z_(t,e,n){var r=t[e]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function Q_(t){switch("string"==typeof t&&(t=w_[t]),t){case w_.DT_FLOAT:return"float32";case w_.DT_INT32:case w_.DT_INT64:case w_.DT_INT8:case w_.DT_UINT8:return"int32";case w_.DT_BOOL:return"bool";case w_.DT_DOUBLE:return"float32";case w_.DT_STRING:return"string";default:return null}}function tO(t,e,n){var r=t[e];return r&&r.type?Q_(r.type):n}function eO(t,e,n){var r=t[e];return r&&r.list&&r.list.type?r.list.type.map((function(t){return Q_(t)})):n}function nO(t){if(!t.unknownRank)return null!=t.dim?t.dim.map((function(t){return"number"==typeof t.size?t.size:parseInt(t.size,10)})):[]}function rO(t,e,n){var r=t[e];return r&&r.shape?nO(r.shape):n}function aO(t,e,n){var r=t[e];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((function(t){return"number"==typeof t?t:parseInt(t,10)})):n}function iO(t,e,n,r){void 0===r&&(r=!1);var a=t[e];return a&&a.list&&a.list.s?a.list.s.map((function(t){return Y_(t,r)})):n}function oO(t,e,n){var r=t[e];return r&&r.list&&r.list.shape?r.list.shape.map((function(t){return nO(t)})):n}function sO(t,e,n){var r=t[e];return r&&r.list&&r.list.b?r.list.b:n}var uO=function(){function t(t,e,n){var r=this;this.node=t,this.tensorMap=e,this.context=n,this.inputs=[],this.attrs={},this.inputs=t.inputNames.map((function(t){return r.getInput(t)})),null!=t.rawAttrs&&(this.attrs=Object.keys(t.rawAttrs).reduce((function(t,e){return t[e]=r.getAttr(e),t}),{}))}var e=t.prototype;return e.getInput=function(t){return E_(t,this.tensorMap,this.context)},e.getAttr=function(t,e){var n=this.node.rawAttrs[t];if(null!=n.tensor)return E_(t,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return Z_(this.node.rawAttrs,t,e);if(null!=n.s)return J_(this.node.rawAttrs,t,e);if(null!=n.b)return $_(this.node.rawAttrs,t,e);if(null!=n.shape)return rO(this.node.rawAttrs,t,e);if(null!=n.type)return tO(this.node.rawAttrs,t,e);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return aO(this.node.rawAttrs,t,e);if(null!=n.list.s)return iO(this.node.rawAttrs,t,e);if(null!=n.list.shape)return oO(this.node.rawAttrs,t,e);if(null!=n.list.b)return sO(this.node.rawAttrs,t,e);if(null!=n.list.type)return eO(this.node.rawAttrs,t,e)}return e},t}(),cO=function(){function t(e,n,r,a,i,o,s){this.name=e,this.dtype=n,this.maxSize=r,this.elementShape=a,this.identicalElementShapes=i,this.dynamicSize=o,this.clearAfterRead=s,this.tensors=[],this.closed_=!1,this.id=t.nextId++}var e=t.prototype;return e.clearAndClose=function(){this.tensors.forEach((function(t){return t.tensor.dispose()})),this.tensors=[],this.closed_=!0},e.size=function(){return this.tensors.length},e.read=function(t){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(t<0||t>=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},e.readMany=function(t){var e=this;return t.map((function(t){return e.read(t)}))},e.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 n=this.tensors[t]||{};if(e.dtype!==this.dtype)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+",\n because the value dtype is "+e.dtype+", but TensorArray dtype is "+this.dtype+".");if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=e.shape),this.assertShapesMatchAllowUndefinedSize(this.elementShape,e.shape,"TensorArray "+this.name+": Could not write to TensorArray index "+t+"."),n&&n.read)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+", because it has already been read.");if(n&&n.written)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+", because it has already been written.");n.tensor=e,n.written=!0,this.tensors[t]=n},e.writeMany=function(t,e){var n=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(t,r){return n.write(t,e[r])}))},e.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 n=0;n<this.size();n++)t.push(n)}if(0===t.length)return ay([],[0].concat(this.elementShape));var r=this.readMany(t);return this.assertShapesMatchAllowUndefinedSize(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),Ty(r,0)},e.concat=function(t){if(t&&t!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but concat requested dtype "+t);if(0===this.size())return ay([],[0].concat(this.elementShape));for(var e=[],n=0;n<this.size();n++)e.push(n);var r=this.readMany(e);return this.assertShapesMatchAllowUndefinedSize(this.elementShape,r[0].shape,"TensorArray shape mismatch: tensor array shape ("+this.elementShape+") vs first tensor shape ("+r[0].shape+")"),wy(r,0)},e.scatter=function(t,e){if(e.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+e.dtype);if(t.length!==e.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+t.length+" vs. "+e.shape[0]);var n=Math.max.apply(Math,t);if(!this.dynamicSize&&n>=this.maxSize)throw new Error("Max index must be < array size ("+n+" vs. "+this.maxSize+")");this.writeMany(t,Dy(e,0))},e.split=function(t,e){var n=this;if(e.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+e.dtype);var r=0,a=t.map((function(t){return r+=t}));if(r!==e.shape[0])throw new Error("Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n "+r+", 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 i=0===r?0:e.size/r,o=[];Nb((function(){e=e.reshape([1,r,i]);for(var s=0;s<t.length;++s){var u=[0,0===s?0:a[s-1],0],c=[1,t[s],i];o[s]=rw(e,u,c).reshape(n.elementShape)}return o}));for(var s=[],u=0;u<t.length;u++)s[u]=u;this.writeMany(s,o)},e.assertShapesMatchAllowUndefinedSize=function(t,e,n){void 0===n&&(n=""),gv(this.shapesEqualAllowUndefinedSize(t,e),(function(){return n+" Shapes "+t+" and "+e+" must match"}))},e.shapesEqualAllowUndefinedSize=function(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(-1!==t[n]&&-1!==e[n]&&t[n]!==e[n])return!1;return!0},jm(t,[{key:"closed",get:function(){return this.closed_}}]),t}();cO.nextId=0;var lO=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f,p,d,m,v,g,y,b,x,w,k,S,C,R,N,E,I,A,T,D,_,O,F,M,L,z,B,P,W;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.op,t.next="LoopCond"===t.t0?3:"Switch"===t.t0?4:"Merge"===t.t0?14:"Enter"===t.t0?16:"Exit"===t.t0?20:"NextIteration"===t.t0?23:"TensorArrayV3"===t.t0?26:"TensorArrayWriteV3"===t.t0?36:"TensorArrayReadV3"===t.t0?42:"TensorArrayGatherV3"===t.t0?46:"TensorArrayScatterV3"===t.t0?51:"TensorArrayConcatV3"===t.t0?57:"TensorArraySplitV3"===t.t0?61:"TensorArraySizeV3"===t.t0?67:"TensorArrayCloseV3"===t.t0?70:74;break;case 3:return t.abrupt("return",[N_("pred",e,n,r).clone()]);case 4:return a=N_("pred",e,n,r),i=N_("data",e,n,r),t.next=8,a.data();case 8:if(!t.sent[0]){t.next=12;break}t.t1=[void 0,i.clone()],t.next=13;break;case 12:t.t1=[i.clone(),void 0];case 13:return t.abrupt("return",t.t1);case 14:return o=e.inputNames.find((function(t){return void 0!==E_(t,n,r)})),t.abrupt("return",o?[E_(o,n,r).clone()]:void 0);case 16:return s=N_("frameName",e,n,r),u=N_("tensor",e,n,r),r.enterFrame(s),t.abrupt("return",[u.clone()]);case 20:return c=N_("tensor",e,n,r),r.exitFrame(),t.abrupt("return",[c.clone()]);case 23:return l=N_("tensor",e,n,r),r.nextIteration(),t.abrupt("return",[l.clone()]);case 26:return h=N_("size",e,n,r),f=N_("dtype",e,n,r),p=N_("elementShape",e,n,r),d=N_("dynamicSize",e,n,r),m=N_("clearAfterRead",e,n,r),v=N_("identicalElementShapes",e,n,r),g=N_("name",e,n,r),y=new cO(g,f,h,p,v,d,m),r.addTensorArray(y),t.abrupt("return",[oy(y.id),oy(1)]);case 36:return b=N_("tensorArrayId",e,n,r),x=N_("index",e,n,r),w=N_("tensor",e,n,r),r.getTensorArray(b).write(x,w),t.abrupt("return",[oy(1)]);case 42:return k=N_("tensorArrayId",e,n,r),S=N_("index",e,n,r),C=r.getTensorArray(k),t.abrupt("return",[C.read(S)]);case 46:return R=N_("tensorArrayId",e,n,r),N=N_("indices",e,n,r),E=N_("dtype",e,n,r),I=r.getTensorArray(R),t.abrupt("return",[I.gather(N,E)]);case 51:return A=N_("tensorArrayId",e,n,r),T=N_("indices",e,n,r),D=N_("tensor",e,n,r),r.getTensorArray(A).scatter(T,D),t.abrupt("return",[oy(1)]);case 57:return _=N_("tensorArrayId",e,n,r),O=r.getTensorArray(_),F=N_("dtype",e,n,r),t.abrupt("return",[O.concat(F)]);case 61:return M=N_("tensorArrayId",e,n,r),L=N_("tensor",e,n,r),z=N_("lengths",e,n,r),r.getTensorArray(M).split(z,L),t.abrupt("return",[oy(1)]);case 67:return B=N_("tensorArrayId",e,n,r),P=r.getTensorArray(B),t.abrupt("return",[oy(P.size(),"int32")]);case 70:return W=N_("tensorArrayId",e,n,r),r.getTensorArray(W).clearAndClose(),t.abrupt("return",[oy(0)]);case 74:throw TypeError("Node type "+e.op+" is not implemented");case 75:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}(),hO=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.op,t.next="NonMaxSuppressionV5"===t.t0||"NonMaxSuppressionV3"===t.t0||"NonMaxSuppressionV2"===t.t0?3:"Where"===t.t0?18:"ListDiff"===t.t0?25:26;break;case 3:if(a=N_("boxes",e,n,r),i=N_("scores",e,n,r),o=N_("maxOutputSize",e,n,r),s=N_("iouThreshold",e,n,r),u=N_("scoreThreshold",e,n,r),"NonMaxSuppressionV5"!==e.op){t.next=14;break}return c=N_("softNmsSigma",e,n,r),t.next=12,_R(a,i,o,s,u,c);case 12:return l=t.sent,t.abrupt("return",[l.selectedIndices,l.selectedScores]);case 14:return t.next=16,TR(a,i,o,s,u);case 16:return t.t1=t.sent,t.abrupt("return",[t.t1]);case 18:return h=N_("condition",e,n,r).asType("bool"),t.next=21,fS(h);case 21:return t.t2=t.sent,f=[t.t2],h.dispose(),t.abrupt("return",f);case 25:return t.abrupt("return",_y(N_("x",e,n,r),N_("y",e,n,r)));case 26:throw TypeError("Node type "+e.op+" is not implemented");case 27:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}();function fO(t,e,n){var r=function(t,e,n){switch(t.category){case"arithmetic":return Nb((function(){return function(t,e,n){switch(t.op){case"BiasAdd":case"AddV2":case"Add":return[Db(N_("a",t,e,n),N_("b",t,e,n))];case"AddN":return[Wk(N_("tensors",t,e,n))];case"FloorMod":case"Mod":return[xx(N_("a",t,e,n),N_("b",t,e,n))];case"Mul":return[kx(N_("a",t,e,n),N_("b",t,e,n))];case"RealDiv":case"Div":return[Ix(N_("a",t,e,n),N_("b",t,e,n))];case"DivNoNan":return[pS(N_("a",t,e,n),N_("b",t,e,n))];case"FloorDiv":return[mx(N_("a",t,e,n),N_("b",t,e,n))];case"Sub":return[Dx(N_("a",t,e,n),N_("b",t,e,n))];case"Minimum":return[yx(N_("a",t,e,n),N_("b",t,e,n))];case"Maximum":return[vx(N_("a",t,e,n),N_("b",t,e,n))];case"Pow":return[Cx(N_("a",t,e,n),N_("b",t,e,n))];case"SquaredDifference":return[HS(N_("a",t,e,n),N_("b",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"basic_math":return Nb((function(){return function(t,e,n){switch(t.op){case"Abs":case"ComplexAbs":return[_b(N_("x",t,e,n))];case"Acos":return[Ob(N_("x",t,e,n))];case"Acosh":return[Fb(N_("x",t,e,n))];case"Asin":return[Mb(N_("x",t,e,n))];case"Asinh":return[Lb(N_("x",t,e,n))];case"Atan":return[zb(N_("x",t,e,n))];case"Atan2":return[px(N_("x",t,e,n),N_("y",t,e,n))];case"Atanh":return[Bb(N_("x",t,e,n))];case"Ceil":return[Pb(N_("x",t,e,n))];case"Complex":return[ey(N_("real",t,e,n),N_("imag",t,e,n))];case"Cos":return[Vb(N_("x",t,e,n))];case"Cosh":return[Ub(N_("x",t,e,n))];case"Elu":return[SC(N_("x",t,e,n))];case"Erf":return[jb(N_("x",t,e,n))];case"Exp":return[Gb(N_("x",t,e,n))];case"Expm1":return[qb(N_("x",t,e,n))];case"Floor":return[Hb(N_("x",t,e,n))];case"Log":return[Kb(N_("x",t,e,n))];case"Log1p":return[Xb(N_("x",t,e,n))];case"Imag":return[ry(N_("x",t,e,n))];case"Neg":return[Jb(N_("x",t,e,n))];case"Reciprocal":return[$b(N_("x",t,e,n))];case"Real":return[ny(N_("x",t,e,n))];case"Relu":return[NC(N_("x",t,e,n))];case"Round":return[Zb(N_("x",t,e,n))];case"Selu":return[IC(N_("x",t,e,n))];case"Sigmoid":return[tx(N_("x",t,e,n))];case"Sin":return[ix(N_("x",t,e,n))];case"Sign":return[ex(N_("x",t,e,n))];case"Sinh":return[ox(N_("x",t,e,n))];case"Softplus":return[sx(N_("x",t,e,n))];case"Sqrt":return[ux(N_("x",t,e,n))];case"Square":return[Ax(N_("x",t,e,n))];case"Tanh":return[hx(N_("x",t,e,n))];case"Tan":return[lx(N_("x",t,e,n))];case"Relu6":case"ClipByValue":return[Wb(N_("x",t,e,n),N_("clipValueMin",t,e,n),N_("clipValueMax",t,e,n))];case"Rsqrt":return[Qb(E_(t.inputNames[0],e,n))];case"Prod":return[Jy(N_("x",t,e,n),N_("axes",t,e,n))];case"LeakyRelu":return[CC(N_("x",t,e,n),N_("alpha",t,e,n))];case"Prelu":return[RC(N_("x",t,e,n),N_("alpha",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"control":return lO(t,e,n);case"convolution":return Nb((function(){return function(t,e,n){switch(t.op){case"Conv1D":var r=N_("stride",t,e,n),a=N_("pad",t,e,n),i=N_("dataFormat",t,e,n).toUpperCase(),o=N_("dilation",t,e,n);return[Zk(N_("x",t,e,n),N_("filter",t,e,n),r,a,i,o)];case"Conv2D":var s=N_("strides",t,e,n),u=N_("pad",t,e,n),c=N_("dataFormat",t,e,n).toUpperCase(),l=N_("dilations",t,e,n);return[mb(N_("x",t,e,n),N_("filter",t,e,n),[s[1],s[2]],u,c,[l[1],l[2]])];case"_FusedConv2D":case"FusedDepthwiseConv2dNative":var h=N_("fusedOps",t,e,n),f=h[0],p=h[1],d="biasadd"===f,m="prelu"===p,v="fusedbatchnorm"===f,g=N_("numArgs",t,e,n);if(d){if(m&&2!==g)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!m&&1!==g)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(v)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.");var y=N_("strides",t,e,n),b=N_("pad",t,e,n),x=N_("dataFormat",t,e,n).toUpperCase(),w=N_("dilations",t,e,n),k=N_("args",t,e,n),S=k[0],C=k[1];return[("_FusedConv2D"===t.op?WR:VR)({x:N_("x",t,e,n),filter:N_("filter",t,e,n),strides:[y[1],y[2]],pad:b,dataFormat:x,dilations:[w[1],w[2]],bias:S,activation:p,preluActivationWeights:C})];case"Conv2DBackpropInput":case"Conv2dTranspose":var R=N_("outputShape",t,e,n),N=N_("strides",t,e,n),E=N_("pad",t,e,n);return[Qk(N_("x",t,e,n),N_("filter",t,e,n),R,[N[1],N[2]],E)];case"DepthwiseConv2dNative":case"DepthwiseConv2d":var I=N_("strides",t,e,n),A=N_("pad",t,e,n),T=N_("dilations",t,e,n),D=N_("dataFormat",t,e,n).toUpperCase();return[rS(N_("input",t,e,n),N_("filter",t,e,n),[I[1],I[2]],A,D,[T[1],T[2]])];case"Conv3D":var _=N_("strides",t,e,n),O=N_("pad",t,e,n),F=N_("dataFormat",t,e,n).toUpperCase(),M=N_("dilations",t,e,n);return[tS(N_("x",t,e,n),N_("filter",t,e,n),[_[1],_[2],_[3]],O,F,[M[1],M[2],M[3]])];case"AvgPool":var L=N_("strides",t,e,n),z=N_("pad",t,e,n),B=N_("kernelSize",t,e,n);return[hC(N_("x",t,e,n),[B[1],B[2]],[L[1],L[2]],z)];case"MaxPool":var P=N_("strides",t,e,n),W=N_("pad",t,e,n),V=N_("kernelSize",t,e,n);return[lC(N_("x",t,e,n),[V[1],V[2]],[P[1],P[2]],W)];case"MaxPoolWithArgmax":var U=N_("strides",t,e,n),j=N_("pad",t,e,n),G=N_("kernelSize",t,e,n),q=N_("includeBatchInIndex",t,e,n),H=mC(N_("x",t,e,n),[G[1],G[2]],[U[1],U[2]],j,q);return[H.result,H.indexes];case"AvgPool3D":var K=N_("strides",t,e,n),X=N_("pad",t,e,n),Y=N_("kernelSize",t,e,n);return[dC(N_("x",t,e,n),[Y[1],Y[2],Y[3]],[K[1],K[2],K[3]],X)];case"MaxPool3D":var J=N_("strides",t,e,n),$=N_("pad",t,e,n),Z=N_("kernelSize",t,e,n);return[pC(N_("x",t,e,n),[Z[1],Z[2],Z[3]],[J[1],J[2],J[3]],$)];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"creation":return Nb((function(){return function(t,e,n){switch(t.op){case"Fill":var r=N_("shape",t,e,n),a=N_("dtype",t,e,n);return[vy(r,N_("value",t,e,n),a)];case"LinSpace":return[gy(N_("start",t,e,n),N_("stop",t,e,n),N_("num",t,e,n))];case"Multinomial":var i=N_("logits",t,e,n),o=N_("numSamples",t,e,n),s=N_("seed",t,e,n);return[SS(i,o,s)];case"OneHot":var u=N_("indices",t,e,n),c=N_("depth",t,e,n),l=N_("onValue",t,e,n),h=N_("offValue",t,e,n);return[xk(u,c,l,h)];case"Ones":return[dy(N_("shape",t,e,n),N_("dtype",t,e,n))];case"OnesLike":return[by(N_("x",t,e,n))];case"RandomUniform":return[GS(N_("shape",t,e,n),N_("minval",t,e,n),N_("maxval",t,e,n),N_("dtype",t,e,n))];case"Range":return[yy(N_("start",t,e,n),N_("stop",t,e,n),N_("step",t,e,n),N_("dtype",t,e,n))];case"TruncatedNormal":var f=N_("shape",t,e,n),p=N_("mean",t,e,n),d=N_("stdDev",t,e,n),m=N_("seed",t,e,n);return[KS(f,p,d,N_("dtype",t,e,n),m)];case"Zeros":return[my(N_("shape",t,e,n),N_("dtype",t,e,n))];case"ZerosLike":return[xy(N_("x",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"dynamic":return hO(t,e,n);case"evaluation":return Nb((function(){return function(t,e,n){switch(t.op){case"TopKV2":var r=N_("x",t,e,n),a=N_("k",t,e,n),i=N_("sorted",t,e,n),o=LC(r,a,i);return[o.values,o.indices];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"image":return Nb((function(){return function(t,e,n){switch(t.op){case"ResizeBilinear":var r=N_("images",t,e,n),a=N_("size",t,e,n),i=N_("alignCorners",t,e,n);return[IR(r,[a[0],a[1]],i)];case"ResizeNearestNeighbor":var o=N_("images",t,e,n),s=N_("size",t,e,n),u=N_("alignCorners",t,e,n);return[AR(o,[s[0],s[1]],u)];case"CropAndResize":var c=N_("image",t,e,n),l=N_("boxes",t,e,n),h=N_("boxInd",t,e,n),f=N_("cropSize",t,e,n),p=N_("method",t,e,n),d=N_("extrapolationValue",t,e,n);return[OR(c,l,h,f,p,d)];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"graph":return Nb((function(){return function(t,e,n){switch(t.op){case"Const":return e[t.name];case"PlaceholderWithDefault":var r=N_("default",t,e,n);return[E_(t.name,e,n)||r];case"Placeholder":return[E_(t.name,e,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":return[N_("x",t,e,n).clone()];case"IdentityN":return N_("x",t,e,n).map((function(t){return t.clone()}));case"Snapshot":return[N_("x",t,e,n).clone()];case"Shape":return[sy(N_("x",t,e,n).shape,"int32")];case"ShapeN":return N_("x",t,e,n).map((function(t){return sy(t.shape)}));case"Size":return[oy(N_("x",t,e,n).size,"int32")];case"Rank":return[oy(N_("x",t,e,n).rank,"int32")];case"NoOp":return[oy(1)];case"Print":var a=N_("x",t,e,n),i=N_("data",t,e,n),o=N_("message",t,e,n),s=N_("summarize",t,e,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(var u=0;u<i.length;u++)console.log(Array.prototype.slice.call(i[u].dataSync()).slice(0,s));return[a];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"logical":return Nb((function(){return function(t,e,n){switch(t.op){case"Equal":return[mS(N_("a",t,e,n),N_("b",t,e,n))];case"NotEqual":return[CS(N_("a",t,e,n),N_("b",t,e,n))];case"Greater":return[gS(N_("a",t,e,n),N_("b",t,e,n))];case"GreaterEqual":return[yS(N_("a",t,e,n),N_("b",t,e,n))];case"Less":return[bS(N_("a",t,e,n),N_("b",t,e,n))];case"LessEqual":return[xS(N_("a",t,e,n),N_("b",t,e,n))];case"LogicalAnd":return[sS(N_("a",t,e,n),N_("b",t,e,n))];case"LogicalNot":return[uS(N_("a",t,e,n))];case"LogicalOr":return[cS(N_("a",t,e,n),N_("b",t,e,n))];case"Select":case"SelectV2":return[hS(N_("condition",t,e,n),N_("a",t,e,n),N_("b",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"matrices":return Nb((function(){return function(t,e,n){switch(t.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[Oy(N_("a",t,e,n),N_("b",t,e,n),N_("transposeA",t,e,n),N_("transposeB",t,e,n))];case"Transpose":return[Bx(N_("x",t,e,n),N_("perm",t,e,n))];case"_FusedMatMul":var r=N_("fusedOps",t,e,n),a=r[0],i=r[1],o="biasadd"===a,s="prelu"===i,u=N_("numArgs",t,e,n);if(o){if(s&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!s&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}var c=N_("args",t,e,n),l=c[0],h=c[1];return[PR({a:N_("a",t,e,n),b:N_("b",t,e,n),transposeA:N_("transposeA",t,e,n),transposeB:N_("transposeB",t,e,n),bias:l,activation:i,preluActivationWeights:h})];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"normalization":return Nb((function(){return function(t,e,n){switch(t.op){case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[Uk(N_("x",t,e,n),N_("mean",t,e,n),N_("variance",t,e,n),N_("offset",t,e,n),N_("scale",t,e,n),N_("epsilon",t,e,n))];case"LRN":return[wS(N_("x",t,e,n),N_("radius",t,e,n),N_("bias",t,e,n),N_("alpha",t,e,n),N_("beta",t,e,n))];case"Softmax":return[AC(N_("x",t,e,n))];case"LogSoftmax":return[TC(N_("x",t,e,n))];case"SparseToDense":return[jC(N_("sparseIndices",t,e,n),N_("outputShape",t,e,n),N_("sparseValues",t,e,n),N_("defaultValue",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"reduction":return Nb((function(){return function(t,e,n){switch(t.op){case"Max":var r=N_("axis",t,e,n),a=N_("keepDims",t,e,n);return[kS(N_("x",t,e,n),r,a)];case"Mean":var i=N_("axis",t,e,n),o=N_("keepDims",t,e,n);return[Hy(N_("x",t,e,n),i,o)];case"Min":var s=N_("axis",t,e,n),u=N_("keepDims",t,e,n);return[Ky(N_("x",t,e,n),s,u)];case"Sum":var c=N_("axis",t,e,n),l=N_("keepDims",t,e,n);return[Yy(N_("x",t,e,n),c,l)];case"All":var h=N_("axis",t,e,n),f=N_("keepDims",t,e,n);return[Vy(N_("x",t,e,n),h,f)];case"Any":var p=N_("axis",t,e,n),d=N_("keepDims",t,e,n);return[Uy(N_("x",t,e,n),p,d)];case"ArgMax":var m=N_("axis",t,e,n);return[jy(N_("x",t,e,n),m)];case"ArgMin":var v=N_("axis",t,e,n);return[Gy(N_("x",t,e,n),v)];case"Prod":var g=N_("axis",t,e,n),y=N_("keepDims",t,e,n);return[Jy(N_("x",t,e,n),g,y)];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"slice_join":return Nb((function(){return function(t,e,n){switch(t.op){case"ConcatV2":case"Concat":var r=N_("n",t,e,n),a=N_("axis",t,e,n),i=N_("tensors",t,e,n);return i=i.slice(0,r),[wy(i,a)];case"GatherV2":case"Gather":var o=N_("axis",t,e,n),s=N_("x",t,e,n),u=N_("indices",t,e,n);return[QS(s,u.asType("int32"),o)];case"ReverseV2":case"Reverse":var c=N_("axis",t,e,n),l=N_("x",t,e,n);return[rC(l,c)];case"Slice":var h=N_("begin",t,e,n),f=N_("size",t,e,n);return[rw(N_("x",t,e,n),h,f)];case"StridedSlice":var p=N_("begin",t,e,n),d=N_("end",t,e,n),m=N_("strides",t,e,n),v=N_("beginMask",t,e,n),g=N_("endMask",t,e,n),y=N_("ellipsisMask",t,e,n),b=N_("newAxisMask",t,e,n),x=N_("shrinkAxisMask",t,e,n),w=N_("x",t,e,n);if(1===p.length&&w.shape.length>1)for(var k=1;k<w.shape.length;k++)p.push(0),d.push(w.shape[k]),m.push(m[0]);return[MC(w,p,d,m,v,g,y,b,x)];case"Pack":return Nb((function(){var r=N_("axis",t,e,n),a=N_("tensors",t,e,n),i=a[0].shape,o=a[0].squeeze().shape,s=a.map((function(t){var e=kv(t.shape,i);if(!e&&!kv(t.squeeze().shape,o))throw new Error("the input tensors shape does not match");return e?t:t.reshape(i)}));return[Ty(s,r)]}));case"Unpack":return Nb((function(){var r=N_("axis",t,e,n),a=N_("tensor",t,e,n);return Dy(a,r)}));case"Tile":var S=N_("reps",t,e,n);return[_x(N_("x",t,e,n),S)];case"Split":case"SplitV":var C=N_("axis",t,e,n),R=N_("numOrSizeSplits",t,e,n);return Zy(N_("x",t,e,n),R,C);case"ScatterNd":var N=N_("indices",t,e,n),E=N_("values",t,e,n),I=N_("shape",t,e,n);return[zC(N,E,I)];case"GatherNd":var A=N_("x",t,e,n),T=N_("indices",t,e,n);return[GC(A,T)];case"SparseToDense":var D=N_("sparseIndices",t,e,n),_=N_("outputShape",t,e,n),O=N_("sparseValues",t,e,n),F=N_("defaultValue",t,e,n);return[jC(D,O,_,O.dtype===F.dtype?F:F.asType(O.dtype))];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"spectral":return Nb((function(){return function(t,e,n){switch(t.op){case"FFT":return[BC(N_("x",t,e,n))];case"IFFT":return[PC(N_("x",t,e,n))];case"RFFT":return[WC(N_("x",t,e,n))];case"IRFFT":return[VC(N_("x",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"transformation":return Nb((function(){return function(t,e,n){switch(t.op){case"Cast":return[Ry(N_("x",t,e,n),N_("dtype",t,e,n))];case"ExpandDims":var r=N_("axis",t,e,n);return[Ey(N_("x",t,e,n),r)];case"Squeeze":var a=N_("axis",t,e,n);return[Ay(N_("x",t,e,n),a)];case"Reshape":return[Iy(N_("x",t,e,n),N_("shape",t,e,n))];case"PadV2":case"Pad":return[Xx(N_("x",t,e,n),D_(N_("padding",t,e,n),2),N_("constantValue",t,e,n))];case"SpaceToBatchND":var i=N_("blockShape",t,e,n),o=D_(N_("paddings",t,e,n),2);return[My(N_("x",t,e,n),i,o)];case"BatchToSpaceND":var s=N_("blockShape",t,e,n),u=D_(N_("crops",t,e,n),2);return[Ux(N_("x",t,e,n),s,u)];case"DepthToSpace":var c=N_("blockSize",t,e,n),l=N_("dataFormat",t,e,n).toUpperCase();return[nS(N_("x",t,e,n),c,l)];default:throw TypeError("Node type "+t.op+" is not implemented")}}(t,e,n)}));case"custom":var r=R_(t.op);if(r&&r.customExecutor)return r.customExecutor(new uO(t,e,n));throw TypeError("Custom op "+t.op+" is not registered.");default:throw TypeError("Unknown op '"+t.op+"'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()")}}(t,e,n);return r instanceof Promise?r.then((function(t){return[].concat(t)})):[].concat(r)}var pO=function(){function t(t,e){this.weightMap=t,this.tensorArrayMap=e,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}var e=t.prototype;return e.newFrame=function(t,e){return{id:t,frameName:e,iterationId:0}},e.generateCurrentContextIds=function(){for(var t=[],e=0;e<this.contexts.length-1;e++){var n=this.contexts.slice(0,this.contexts.length-e);t.push(this.contextIdforContexts(n))}t.push(""),this._currentContextIds=t},e.contextIdforContexts=function(t){return t?t.map((function(t){return 0===t.id&&0===t.iterationId?"":t.frameName+"-"+t.iterationId})).join("/"):""},e.enterFrame=function(t){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,t)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))},e.exitFrame=function(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()},e.nextIteration=function(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");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))},e.getWeight=function(t){return this.weightMap[t]},e.addTensorArray=function(t){this.tensorArrayMap[t.id]=t},e.getTensorArray=function(t){return this.tensorArrayMap[t]},jm(t,[{key:"currentContext",set:function(t){this.contexts!==t&&(this.contexts=t,this.generateCurrentContextIds())},get:function(){return this.contexts}},{key:"currentContextId",get:function(){return this._currentContextIds[0]}},{key:"currentContextIds",get:function(){return this._currentContextIds}}]),t}();function dO(t,e,n){for(var r=new Set,a=[],i=null,o=null,s=new Set,u=Object.keys(t).map((function(t){return T_(t)[0]})),c=[].concat(e);c.length>0;){var l=c.pop();(gO(l)||yO(l))&&null==i&&(o=(i=l).children.map((function(t){return t.name})).filter((function(t){return r.has(t)}))),r.add(l.name),null==n[l.name]&&(-1===u.indexOf(l.name)&&(0!==l.inputs.length?l.inputs.forEach((function(t){s.has(t.name)||(s.add(t.name),c.push(t))})):a.push(l.name)))}return{inputs:t,outputs:e,usedNodes:r,missingInputs:a,dynamicNode:i,syncInputs:o}}var mO=["Switch","Merge","Enter","Exit","NextIteration"],vO=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"];function gO(t){return mO.indexOf(t.op)>=0}function yO(t){return vO.indexOf(t.op)>=0}var bO=function(){function t(t){this.graph=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._outputs=t.outputs,this._inputs=t.inputs,this._signature=t.signature}var e=t.prototype;return e.getCompilationKey=function(t,e){var n=t.map((function(t){return t.name})).sort(),r=e.map((function(t){return t.name})).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)},e.compile=function(t,e){var n=dO(t,e,this.weightMap),r=n.missingInputs,a=n.dynamicNode,i=n.syncInputs;if(null!=a)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 ["+i+"]");if(r.length>0){var o=e.map((function(t){return t.name})),s=Object.keys(t);throw new Error("Cannot compute the outputs ["+o+"] from the provided inputs ["+s+"]. Missing the following inputs: ["+r+"]")}return function(t,e,n){var r=n.usedNodes,a=n.inputs,i=[];Object.keys(a).map((function(t){return T_(t)[0]})).map((function(e){return t.nodes[e]})).forEach((function(t){r.has(t.name)&&i.push(t)})),t.weights.forEach((function(t){r.has(t.name)&&i.push(t)}));for(var o=new Set,s=[];i.length>0;){var u=i.pop();o.add(u.name),e[u.name]||s.push(u),u.children.forEach((function(t){!o.has(t.name)&&r.has(t.name)&&t.inputs.every((function(t){return o.has(t.name)}))&&i.push(t)}))}return s}(this.graph,this.weightMap,n)},e.execute=function(t,e){var n=this;t=this.mapInputs(t);var r=Object.keys(t).sort();this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e);var a=r.map((function(t){return n.graph.nodes[T_(t)[0]]})),i=e.map((function(t){return n.graph.nodes[T_(t)[0]]})),o=this.getCompilationKey(a,i),s=this.compiledMap.get(o);null==s&&(s=this.compile(t,i),this.compiledMap.set(o,s));var u={};return Nb((function(){var r=new pO(n._weightMap,u),a=Object.assign({},n.weightMap);Object.keys(t).forEach((function(e){var n=T_(e),r=n[0],i=[];i[n[1]]=t[e],a[r]=i}));for(var i=n.getFrozenTensorIds(a),o={},c=0;c<s.length;c++){var l=s[c];if(!a[l.name]){var h=fO(l,a,r);if(h instanceof Promise)throw new Error("The execution of the op '"+l.op+"' returned a promise. Please use model.executeAsync() instead.");a[l.name]=h,n.checkTensorForDisposal(l.name,l,a,r,i,e,o)}}return e.map((function(t){return E_(t,a,r)}))}))},e.getFrozenTensorIds=function(t){var e=[].concat.apply([],Object.keys(t).map((function(e){return t[e]})).map((function(t){return t.map((function(t){return t.id}))})));return new Set(e)},e.checkTensorForDisposal=function(t,e,n,r,a,i,o){"control"!==e.category&&-1===i.indexOf(t)&&(n[t].forEach((function(t){null!=t&&(o[t.id]=(o[t.id]||0)+e.children.length)})),e.inputs.forEach((function(t){if("control"!==t.category){var e=function(t,e,n){return e[A_(t,n.currentContextId)]}(t.name,n,r);null!=e&&e.forEach((function(t){if(t&&!a.has(t.id)){var e=o[t.id];1===e?(t.dispose(),delete o[t.id]):null!=e&&o[t.id]--}}))}})))},e.executeAsync=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u,c=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),n=this.mapOutputs(n),this.checkOutputs(n),r={},a=new pO(this._weightMap,r),t.next=9,this.executeWithControlFlow(e,a,n);case 9:return i=t.sent,o=n.map((function(t){return E_(t,i,a)})),s=new Set(o.map((function(t){return t.id}))),u=new Set(Object.keys(e).map((function(t){return e[t].id}))),Object.keys(i).forEach((function(t){i[t].forEach((function(t){!t||t.isDisposed||s.has(t.id)||u.has(t.id)||-1!==c.weightIds.indexOf(t.id)||t.dispose()}))})),t.abrupt("return",o);case 15:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.executeWithControlFlow=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n,r){var a,i,o,s,u,c,l,h,f,p,d,m,v,g,y,b,x=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=Object.keys(e),i=a.map((function(t){return x.graph.nodes[T_(t)[0]]})),o=r.map((function(t){return x.graph.nodes[T_(t)[0]]})),s=dO(e,o,this.weightMap),u=s.usedNodes,c=s.missingInputs,l=s.dynamicNode,h=s.syncInputs,f=[].concat(i,this.graph.weights).map((function(t){return{node:t,contexts:n.currentContext}})),p=Object.assign({},this.weightMap),Object.keys(e).forEach((function(t){var n=T_(t),r=n[0],a=[];a[n[1]]=e[t],p[r]=a})),d={},m=this.getFrozenTensorIds(p),v={};case 10:if(!(f.length>0)){t.next=16;break}return g=this.processStack(i,f,n,p,v,m,r,d,u),t.next=14,Promise.all(g);case 14:t.next=10;break;case 16:if(null==l&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."),!((y=o.filter((function(t){return!gO(t)&&!E_(t.name,p,n)})).map((function(t){return t.name}))).length>0)){t.next=22;break}throw b="",null!=l&&(b="Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs ["+h+"]"),new Error("Cannot compute the outputs ["+y+"] from the provided inputs ["+a+"]. Consider providing the following inputs: ["+c+"]. "+b);case 22:return t.abrupt("return",p);case 23:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),e.processStack=function(t,e,n,r,a,i,o,s,u){for(var c=this,l=[],h=function(){var h=e.pop();n.currentContext=h.contexts;var f="";if("Enter"===h.node.op&&N_("isConstant",h.node,r,n)){var p=I_(h.node.name,n);f=p[0]}if(-1===t.indexOf(h.node)){var d=fO(h.node,r,n);if(!f){var m=I_(h.node.name,n);f=m[0]}var v=n.currentContext;d instanceof Promise?l.push(d.then((function(t){return r[f]=t,n.currentContext=v,c.checkTensorForDisposal(f,h.node,r,n,i,o,s),c.processChildNodes(h.node,e,n,r,a,u),t}))):(r[f]=d,c.checkTensorForDisposal(f,h.node,r,n,i,o,s),c.processChildNodes(h.node,e,n,r,a,u))}else c.processChildNodes(h.node,e,n,r,a,u)};e.length>0;)h();return l},e.processChildNodes=function(t,e,n,r,a,i){t.children.forEach((function(t){var o=I_(t.name,n)[0];!a[o]&&i.has(t.name)&&("Merge"===t.op?t.inputNames.some((function(t){return!!E_(t,r,n)}))&&(a[o]=!0,e.push({contexts:n.currentContext,node:t})):t.inputNames.every((function(t){return!!E_(t,r,n)}))&&(a[o]=!0,e.push({contexts:n.currentContext,node:t})))}))},e.dispose=function(){var t=this;Object.keys(this.weightMap).forEach((function(e){return t.weightMap[e].forEach((function(t){return t.dispose()}))}))},e.checkInputShapeAndType=function(t){var e=this;Object.keys(t).forEach((function(n){var r=t[n],a=T_(n)[0],i=e.graph.nodes[a];if(i.attrParams.shape&&i.attrParams.shape.value){var o=i.attrParams.shape.value;gv(o.length===r.shape.length&&r.shape.every((function(t,e){return-1===o[e]||o[e]===t})),(function(){return"The shape of dict['"+i.name+"'] provided in model.execute(dict) must be ["+o+"], but was ["+r.shape+"]"}))}i.attrParams.dtype&&i.attrParams.dtype.value&&gv(r.dtype===i.attrParams.dtype.value,(function(){return"The dtype of dict['"+i.name+"'] provided in model.execute(dict) must be "+i.attrParams.dtype.value+", but was "+r.dtype}))}))},e.mapInputs=function(t){var e={};for(var n in t){if(null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n])e[this._signature.inputs[n].name]=t[n];else e[n]=t[n]}return e},e.checkInputs=function(t){var e=this,n=Object.keys(t).filter((function(t){var n=T_(t)[0];return null==e.graph.nodes[n]}));if(n.length>0)throw new Error("The dict provided in model.execute(dict) has keys: ["+n+"] that are not part of graph")},e.mapOutputs=function(t){var e=this;return t.map((function(t){return null!=e._signature&&null!=e._signature.outputs&&null!=e._signature.outputs[t]?e._signature.outputs[t].name:t}),{})},e.checkOutputs=function(t){var e=this;t.forEach((function(t){var n=T_(t)[0];if(!e.graph.nodes[n])throw new Error("The output '"+t+"' is not found in the graph")}))},jm(t,[{key:"weightMap",get:function(){return this._weightMap},set:function(t){var e,n=Object.keys(t).map((function(e){return t[e].map((function(t){return t.id}))}));this.weightIds=(e=[]).concat.apply(e,n),this._weightMap=t}},{key:"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}}))}},{key:"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}}))}},{key:"inputNodes",get:function(){return this._inputs.map((function(t){return t.signatureKey||t.name}))}},{key:"outputNodes",get:function(){return this._outputs.map((function(t){return t.signatureKey||t.name}))}}]),t}(),xO=function(){function t(t,e){void 0===e&&(e={}),this.modelUrl=t,this.loadOptions=e,this.version="n/a",null==e&&(this.loadOptions={})}var e=t.prototype;return e.findIOHandler=function(){var t=this.modelUrl;if(null!=t.load)this.handler=t;else if(null!=this.loadOptions.requestInit)this.handler=vk(t,this.loadOptions);else{var e=Aw(t,this.loadOptions);if(0===e.length)e.push(vk(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]}},e.load=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.findIOHandler(),null!=this.handler.load){t.next=3;break}throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");case 3:return t.next=5,this.handler.load();case 5:return this.artifacts=t.sent,e=this.artifacts.modelTopology,n={},null!=this.artifacts.userDefinedMetadata&&(n=this.artifacts.userDefinedMetadata.signature),this.version=e.versions.producer+"."+e.versions.minConsumer,r=yw(this.artifacts.weightData,this.artifacts.weightSpecs),this.executor=new bO(X_.Instance.transformGraph(e,n)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),t.abrupt("return",!0);case 14:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.save=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=9;break}if(0!==(r=Iw(e)).length){t.next=6;break}throw new Error("Cannot find any save handlers for URL '"+e+"'");case 6:if(!(r.length>1)){t.next=8;break}throw new Error("Found more than one ("+r.length+") save handlers for URL '"+e+"'");case 8:e=r[0];case 9:if(null!=e.save){t.next=11;break}throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");case 11:return t.abrupt("return",e.save(this.artifacts));case 12:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.predict=function(t,e){return this.execute(t,this.outputNodes)},e.normalizeInputs=function(t){if(!(t instanceof pg||Array.isArray(t)))return t;if((t=Array.isArray(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,n,r){return e[n]=t[r],e}),{})},e.normalizeOutputs=function(t){return t=t||this.outputNodes,Array.isArray(t)?t:[t]},e.execute=function(t,e){t=this.normalizeInputs(t),e=this.normalizeOutputs(e);var n=this.executor.execute(t,e);return n.length>1?n:n[0]},e.executeAsync=function(){var t=Vm(regeneratorRuntime.mark((function t(e,n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.normalizeInputs(e),n=this.normalizeOutputs(n),t.next=4,this.executor.executeAsync(e,n);case 4:return r=t.sent,t.abrupt("return",r.length>1?r:r[0]);case 6:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.convertTensorMapToTensorsMap=function(t){return Object.keys(t).reduce((function(e,n){return e[n]=[t[n]],e}),{})},e.dispose=function(){this.executor.dispose()},jm(t,[{key:"modelVersion",get:function(){return this.version}},{key:"inputNodes",get:function(){return this.executor.inputNodes}},{key:"outputNodes",get:function(){return this.executor.outputNodes}},{key:"inputs",get:function(){return this.executor.inputs}},{key:"outputs",get:function(){return this.executor.outputs}},{key:"weights",get:function(){return this.executor.weightMap}}]),t}();function wO(){return(wO=Vm(regeneratorRuntime.mark((function t(e,n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===n&&(n={}),null!=e){t.next=3;break}throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");case 3:return null==n&&(n={}),n.fromTFHub&&null==e.load&&(e.endsWith("/")||(e+="/"),e+="model.json?tfjs-format=file"),r=new xO(e,n),t.next=8,r.load();case 8:return t.abrupt("return",r);case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function kO(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var a=e(t);if(a.recurse&&null!==a.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(a.recurse){if(EO(t)){var i=Array.isArray(t)?[]:{};for(var o in r.add(t),t){var s=kO(t[o],e,n,r);i[o]=s}return r.delete(t),i}throw new Error("Can't recurse into non-iterable type: "+t)}return n.set(t,a.value),a.value}function SO(t,e){return void 0===e&&(e=CO),function t(e,n,r){void 0===r&&(r=new Set);var a=e[0];if(r.has(a))throw new Error("Circular references are not supported.");var i=n(e);if(i.recurse&&null!==i.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(i.recurse){if(EO(a)){var o=Array.isArray(a)?[]:{};r.add(a);var s=function(a){var i=e.map((function(t){return t[a]})),s=t(i,n,r);o[a]=s};for(var u in a)s(u);return r.delete(a),o}throw new Error("Can't recurse into non-iterable type: "+a)}return i.value}(t,e)}function CO(t){return null===t?null:EO(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function RO(t,e){return NO.apply(this,arguments)}function NO(){return(NO=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o,s,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=new Map,kO(e,n,r),a=0,i=Array.from(r.keys());case 3:if(!(a<i.length)){t.next=14;break}if(o=i[a],!((s=r.get(o))instanceof Promise)){t.next=11;break}return t.next=9,s;case 9:u=t.sent,r.set(o,u);case 11:a++,t.next=3;break;case 14:return c=kO(e,n,r),t.abrupt("return",c);case 16:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function EO(t){return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof pg))}function IO(t){return function(t,e){return kO(t,e)}(t,AO)}function AO(t){return t instanceof pg?{value:t.clone(),recurse:!1}:EO(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var TO=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}var e=t.prototype;return e.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},e.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},e.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},e.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},e.isFull=function(){return this.length()===this.capacity},e.isEmpty=function(){return 0===this.length()},e.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},e.pushAll=function(t){for(var e,n=Zm(t);!(e=n()).done;){var r=e.value;this.push(r)}},e.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},e.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},e.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},e.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),DO=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}Gm(e,t);var n=e.prototype;return n.isFull=function(){return!1},n.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},n.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},n.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e}(TO);function _O(t){return new zO(t)}function OO(t){return new BO(t)}function FO(t,e){return void 0===e&&(e=MO.FAIL),new JO(t,e)}DO.INITIAL_CAPACITY=32;var MO,LO=function(){function t(){}var e=t.prototype;return e.toArray=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[],t.next=3,this.next();case 3:n=t.sent;case 4:if(n.done){t.next=11;break}return e.push(n.value),t.next=8,this.next();case 8:n=t.sent,t.next=4;break;case 11:return t.abrupt("return",e);case 12:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.toArrayForTest=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.prefetch(100),n=[],t.next=4,e.next();case 4:r=t.sent;case 5:if(r.done){t.next=12;break}return n.push(r.value),t.next=9,e.next();case 9:r=t.sent,t.next=5;break;case 12:return t.abrupt("return",n);case 13:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.resolveFully=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.next();case 2:e=t.sent;case 3:if(e.done){t.next=9;break}return t.next=6,this.next();case 6:e=t.sent,t.next=3;break;case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.resolveWhile=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.next();case 2:n=t.sent,r=e(n.value);case 4:if(n.done||!r){t.next=11;break}return t.next=7,this.next();case 7:n=t.sent,r=e(n.value),t.next=4;break;case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.handleErrors=function(t){return new qO(this,t)},e.filter=function(t){return new jO(this,t)},e.map=function(t){return new GO(this,t)},e.mapAsync=function(t){return new HO(this,t)},e.serialMapAsync=function(t){return new HO(this,t).serial()},e.flatmap=function(t){return new XO(this,t)},e.forEachAsync=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.map(e).resolveFully());case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.serialForEach=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.serialMapAsync(e).resolveWhile((function(t){return!0===t})));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new UO(this,t,e)},e.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=CO),this.rowMajorBatch(t,e).map((function(t){return SO(t,n)}))},e.concatenate=function(t,e){return new YO(_O([this,t]),e)},e.take=function(t){return t<0||null==t?this:new VO(this,t)},e.skip=function(t){return t<0||null==t?this:new WO(this,t)},e.prefetch=function(t){return new $O(this,t)},e.shuffle=function(t,e){return new ZO(this,t,e)},e.serial=function(){return new PO(this)},t}(),zO=function(t){function e(e){var n;return(n=t.call(this)||this).items=e,n.trav=0,n}Gm(e,t);var n=e.prototype;return n.summary=function(){return"Array of "+this.items.length+" items"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(this.trav>=this.items.length)){t.next=2;break}return t.abrupt("return",{value:null,done:!0});case 2:return e=this.items[this.trav],this.trav++,t.abrupt("return",{value:IO(e),done:!1});case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),BO=function(t){function e(e){var n;return(n=t.call(this)||this).nextFn=e,n}Gm(e,t);var n=e.prototype;return n.summary=function(){return"Function call"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.abrupt("return",this.nextFn());case 4:throw t.prev=4,t.t0=t.catch(0),t.t0.message="Error thrown while iterating through a dataset: "+t.t0.message,t.t0;case 8:case"end":return t.stop()}}),t,this,[[0,4]])})));return function(){return t.apply(this,arguments)}}(),e}(LO),PO=function(t){function e(e){var n;return(n=t.call(this)||this).upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Serial"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.lastRead=this.lastRead.then((function(){return e.serialNext()})),t.abrupt("return",this.lastRead);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.serialNext=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.upstream.next());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),WO=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Skip"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.lastRead=this.lastRead.then((function(){return e.serialNext()})),t.abrupt("return",this.lastRead);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.serialNext=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(this.count++<this.maxCount)){t.next=9;break}return t.next=3,this.upstream.next();case 3:if(!(e=t.sent).done){t.next=6;break}return t.abrupt("return",e);case 6:Eb(e.value),t.next=0;break;case 9:return t.abrupt("return",this.upstream.next());case 10:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),VO=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.maxCount=n,r.count=0,r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Take"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(this.count++>=this.maxCount)){t.next=2;break}return t.abrupt("return",{value:null,done:!0});case 2:return t.abrupt("return",this.upstream.next());case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),UO=function(t){function e(e,n,r){var a;return void 0===r&&(r=!0),(a=t.call(this)||this).upstream=e,a.batchSize=n,a.enableSmallLastBatch=r,a.lastRead=Promise.resolve({value:null,done:!1}),a}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.lastRead=this.lastRead.then((function(){return e.serialNext()})),t.abrupt("return",this.lastRead);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.serialNext=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=[];case 1:if(!(e.length<this.batchSize)){t.next=12;break}return t.next=4,this.upstream.next();case 4:if(!(n=t.sent).done){t.next=9;break}if(!(this.enableSmallLastBatch&&e.length>0)){t.next=8;break}return t.abrupt("return",{value:e,done:!1});case 8:return t.abrupt("return",{value:null,done:!0});case 9:e.push(n.value),t.next=1;break;case 12:return t.abrupt("return",{value:e,done:!1});case 13:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),jO=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Filter"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.lastRead=this.lastRead.then((function(){return e.serialNext()})),t.abrupt("return",this.lastRead);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.serialNext=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.upstream.next();case 3:if(!(e=t.sent).done&&!this.predicate(e.value)){t.next=6;break}return t.abrupt("return",e);case 6:Eb(e.value),t.next=0;break;case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),GO=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.transform=n,r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Map"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.upstream.next();case 2:if(!(e=t.sent).done){t.next=5;break}return t.abrupt("return",{value:null,done:!0});case 5:for(n=Ng(e.value),r=this.transform(e.value),a=Ng(r),i=Zm(n);!(o=i()).done;)Rg(s=o.value,a)||s.dispose();return t.abrupt("return",{value:r,done:!1});case 10:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),qO=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> handleErrors"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.lastRead=this.lastRead.then((function(){return e.serialNext()})),t.abrupt("return",this.lastRead);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.serialNext=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=1,t.next=4,this.upstream.next();case 4:return t.abrupt("return",t.sent);case 7:if(t.prev=7,t.t0=t.catch(1),this.handler(t.t0)){t.next=11;break}return t.abrupt("return",{value:null,done:!0});case 11:t.next=0;break;case 13:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(){return t.apply(this,arguments)}}(),e}(LO),HO=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.transform=n,r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> AsyncMap"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.upstream.next();case 2:if(!(e=t.sent).done){t.next=5;break}return t.abrupt("return",{value:null,done:!0});case 5:return n=Ng(e.value),t.next=8,this.transform(e.value);case 8:for(r=t.sent,a=Ng(r),i=Zm(n);!(o=i()).done;)Rg(s=o.value,a)||s.dispose();return t.abrupt("return",{value:r,done:!1});case 12:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),KO=function(t){function e(){var e;return(e=t.call(this)||this).outputQueue=new DO,e.lastRead=Promise.resolve({value:null,done:!1}),e}Gm(e,t);var n=e.prototype;return n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.lastRead=this.lastRead.then((function(){return e.serialNext()})),t.abrupt("return",this.lastRead);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.serialNext=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==this.outputQueue.length()){t.next=7;break}return t.next=3,this.pump();case 3:if(t.sent){t.next=5;break}return t.abrupt("return",{value:null,done:!0});case 5:t.next=0;break;case 7:return t.abrupt("return",{value:this.outputQueue.shift(),done:!1});case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),XO=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.transform=n,r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Flatmap"},n.pump=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.upstream.next();case 2:if(!(e=t.sent).done){t.next=5;break}return t.abrupt("return",!1);case 5:for(n=Ng(e.value),r=this.transform(e.value),a=Ng(r),this.outputQueue.pushAll(r),i=Zm(n);!(o=i()).done;)Rg(s=o.value,a)||s.dispose();return t.abrupt("return",!0);case 11:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(KO),YO=function(t){function e(e,n){var r;return(r=t.call(this)||this).baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}Gm(e,t);var n=e.prototype;return n.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.lastRead=this.readFromChain(this.lastRead),t.abrupt("return",this.lastRead);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.readFromChain=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e;case 2:if(null!=this.iterator){t.next=10;break}return t.next=5,this.moreIterators.next();case 5:if(!(n=t.sent).done){t.next=8;break}return t.abrupt("return",{value:null,done:!0});case 8:this.iterator=n.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler));case 10:return t.next=12,this.iterator.next();case 12:if(!(r=t.sent).done){t.next=16;break}return this.iterator=null,t.abrupt("return",this.readFromChain(e));case 16:return t.abrupt("return",r);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(LO);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(MO||(MO={}));var JO=function(t){function e(e,n){var r;return void 0===n&&(n=MO.FAIL),(r=t.call(this)||this).iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}Gm(e,t);var n=e.prototype;return n.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},n.nextState=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=function(t){return t instanceof LO?{value:t.next().then((function(t){return n++,t.done&&r++,t.value})),recurse:!1}:{value:null,recurse:!0}},t.next=3,e;case 3:return n=0,r=0,t.next=7,RO(this.iterators,a);case 7:if(i=t.sent,n!==r){t.next=10;break}return t.abrupt("return",{value:null,done:!0});case 10:if(!(r>0)){t.next=16;break}t.t0=this.mismatchMode,t.next=t.t0===MO.FAIL?14:t.t0===MO.SHORTEST?15:(t.t0,MO.LONGEST,16);break;case 14:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case 15:return t.abrupt("return",{value:null,done:!0});case 16:return this.count++,t.abrupt("return",{value:i,done:!1});case 18:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.currentPromise=this.nextState(this.currentPromise),t.abrupt("return",this.currentPromise);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(LO),$O=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.bufferSize=n,r.buffer=new TO(n),r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Prefetch"},n.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},n.next=function(){return this.refill(),this.buffer.shift()},e}(LO),ZO=function(t){function e(e,n,r){var a;return(a=t.call(this,e,n)||this).upstream=e,a.windowSize=n,a.upstreamExhausted=!1,a.random=BS(r||Jv().toString()),a.lastRead=Promise.resolve({value:null,done:!1}),a}Gm(e,t);var n=e.prototype;return n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.lastRead=this.lastRead.then((function(){return e.serialNext()})),t.abrupt("return",this.lastRead);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.randomInt=function(t){return Math.floor(this.random()*t)},n.chooseIndex=function(){return this.randomInt(this.buffer.length())},n.serialNext=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.upstreamExhausted||this.refill();case 1:if(this.buffer.isEmpty()){t.next=14;break}return e=this.chooseIndex(),t.next=5,this.buffer.shuffleExcise(e);case 5:if(!(n=t.sent).done){t.next=10;break}this.upstreamExhausted=!0,t.next=12;break;case 10:return this.refill(),t.abrupt("return",n);case 12:t.next=1;break;case 14:return t.abrupt("return",{value:null,done:!0});case 15:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}($O),QO=function(){function t(){this.size=null}var e=t.prototype;return e.batch=function(t,e){void 0===e&&(e=!0);var n,r=this;return gv(t>0,(function(){return"batchSize needs to be positive, but it is\n "+t})),n=this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t),tF(Vm(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.iterator();case 2:return n.abrupt("return",n.sent.columnMajorBatch(t,e,eF));case 3:case"end":return n.stop()}}),n)}))),n)},e.concatenate=function(t){var e,n=this;return e=this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null,tF(Vm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.iterator();case 2:return e.t0=e.sent,e.next=5,t.iterator();case 5:return e.t1=e.sent,e.abrupt("return",e.t0.concatenate.call(e.t0,e.t1));case 7:case"end":return e.stop()}}),e)}))),e)},e.filter=function(t){var e,n=this;return e=this.size===1/0?1/0:null,tF(Vm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.iterator();case 2:return e.abrupt("return",e.sent.filter((function(e){return Nb((function(){return t(e)}))})));case 3:case"end":return e.stop()}}),e)}))),e)},e.forEachAsync=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.iterator();case 2:return t.abrupt("return",t.sent.forEachAsync(e));case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.map=function(t){var e=this;return tF(Vm(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.iterator();case 2:return n.abrupt("return",n.sent.map((function(e){return Nb((function(){return t(e)}))})));case 3:case"end":return n.stop()}}),n)}))),this.size)},e.mapAsync=function(t){var e=this;return tF(Vm(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.iterator();case 2:return n.abrupt("return",n.sent.mapAsync(t));case 3:case"end":return n.stop()}}),n)}))),this.size)},e.prefetch=function(t){if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var e=this;return tF(Vm(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.iterator();case 2:return n.abrupt("return",n.sent.prefetch(t));case 3:case"end":return n.stop()}}),n)}))),this.size)},e.repeat=function(t){var e,n=this;return e=null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null,tF(Vm(regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=OO(Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.iterator();case 2:return t.t0=t.sent,t.abrupt("return",{value:t.t0,done:!1});case 4:case"end":return t.stop()}}),t)})))),e.abrupt("return",(a=r.take(t),new YO(a,void 0)));case 2:case"end":return e.stop()}var a}),e)}))),e)},e.skip=function(t){var e,n=this;return e=null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null,tF(Vm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.iterator();case 2:return e.abrupt("return",e.sent.skip(t));case 3:case"end":return e.stop()}}),e)}))),e)},e.shuffle=function(t,e,n){if(void 0===n&&(n=!0),null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError("`Dataset.shuffle()` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for `tf.Tensor`s), consider setting bufferSize to the dataset size ("+this.size+" elements)");var r=this,a=BS(e||Jv().toString());return tF(Vm(regeneratorRuntime.mark((function e(){var i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=a.int32(),n&&(i+=a.int32()),e.next=4,r.iterator();case 4:return e.abrupt("return",e.sent.shuffle(t,i.toString()));case 5:case"end":return e.stop()}}),e)}))),this.size)},e.take=function(t){var e,n=this;return e=null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null,tF(Vm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.iterator();case 2:return e.abrupt("return",e.sent.take(t));case 3:case"end":return e.stop()}}),e)}))),e)},e.toArray=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.size!==1/0){t.next=2;break}throw new Error("Can not convert infinite data stream to array.");case 2:return t.next=4,this.iterator();case 4:return t.abrupt("return",t.sent.toArray());case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.toArrayForTest=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.size!==1/0){t.next=2;break}throw new Error("Can not convert infinite data stream to array.");case 2:return t.next=4,this.iterator();case 4:return t.abrupt("return",t.sent.toArrayForTest());case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();function tF(t,e){return void 0===e&&(e=null),new(function(n){function r(){var t;return(t=n.apply(this,arguments)||this).size=e,t}return Gm(r,n),r.prototype.iterator=function(){var e=Vm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),r}(QO))}function eF(t){return null===t?null:function(t){return null==t||(null===(e=t)||"object"!=typeof e&&"function"!=typeof e)||Array.isArray(t)||"object"==typeof t&&t instanceof pg||Lv(t);var e}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof pg?Ty(t):ay(t)}(t),recurse:!1}:{value:null,recurse:!0}}QO.MAX_BUFFER_SIZE=1e4;var nF=function(t){function e(e){var n;return(n=t.call(this)||this).input=e,n}return Gm(e,t),e.prototype.iterator=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.input.iterator();case 2:return e=t.sent,n=e.decodeUTF8(),r=n.split("\n").map((function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t})),t.abrupt("return",r);case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(QO),rF=Symbol("out"),aF=Symbol("field"),iF=Symbol("quote"),oF=Symbol("quoteafterquote"),sF=Symbol("quoteinquote"),uF=function(t){function e(e,n){var r;return(r=t.call(this)||this).input=e,r.hasHeader=!0,r.fullColumnNames=null,r.columnNamesValidated=!1,r.columnConfigs=null,r.configuredColumnsOnly=!1,r.delimiter=",",r.delimWhitespace=!1,r.base=new nF(e),n||(n={}),r.hasHeader=!1!==n.hasHeader,r.fullColumnNames=n.columnNames,r.columnConfigs=n.columnConfigs,r.configuredColumnsOnly=n.configuredColumnsOnly,n.delimWhitespace?(gv(null==n.delimiter,(function(){return"Delimiter should not be provided when delimWhitespace is true."})),r.delimWhitespace=!0,r.delimiter=" "):r.delimiter=n.delimiter?n.delimiter:",",r}Gm(e,t);var n=e.prototype;return n.columnNames=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.columnNamesValidated){t.next=3;break}return t.next=3,this.setColumnNames();case 3:return t.abrupt("return",this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.setColumnNames=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i,o,s=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.maybeReadHeaderLine();case 2:if(e=t.sent,this.fullColumnNames||e){t.next=7;break}throw new Error("Column names must be provided if there is no header line.");case 7:this.fullColumnNames&&e&&gv(e.length===this.fullColumnNames.length,(function(){return"The length of provided columnNames ("+s.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+")."}));case 8:if(this.fullColumnNames||(this.fullColumnNames=e),n=this.fullColumnNames.reduce((function(t,e){return t[e]=t[e]+1||1,t}),{}),gv(0===(r=Object.keys(n).filter((function(t){return n[t]>1}))).length,(function(){return"Duplicate column names found: "+r.toString()})),!this.columnConfigs){t.next=22;break}a=0,i=Object.keys(this.columnConfigs);case 14:if(!(a<i.length)){t.next=22;break}if(o=i[a],-1!==this.fullColumnNames.indexOf(o)){t.next=19;break}throw new Error('The key "'+o+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");case 19:a++,t.next=14;break;case 22:this.columnNamesValidated=!0;case 23:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.maybeReadHeaderLine=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.hasHeader){t.next=14;break}return t.next=3,this.base.iterator();case 3:return e=t.sent,t.next=6,e.next();case 6:if(!(n=t.sent).done){t.next=9;break}throw new Error("No data was found for CSV parsing.");case 9:return r=n.value,a=this.parseRow(r,!1),t.abrupt("return",a);case 14:return t.abrupt("return",null);case 15:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.iterator=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.columnNamesValidated){t.next=3;break}return t.next=3,this.setColumnNames();case 3:return t.next=5,this.base.iterator();case 5:return e=t.sent,this.hasHeader&&(e=e.skip(1)),t.abrupt("return",e.map((function(t){return n.makeDataElement(t)})));case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},a=0;a<this.fullColumnNames.length;a++){var i=this.fullColumnNames[a],o=this.columnConfigs?this.columnConfigs[i]:null;if(!this.configuredColumnsOnly||o){var s=e[a],u=null;if(""===s)if(o&&void 0!==o.default)u=o.default;else{if(o&&(o.required||o.isLabel))throw new Error("Required column "+i+" is empty in this line: "+t);u=void 0}else{var c=Number(s);if(isNaN(c))u=o&&"bool"===o.dtype?this.getBoolean(s):s;else if(o&&o.dtype)switch(o.dtype){case"float32":u=c;break;case"int32":u=Math.floor(c);break;case"bool":u=this.getBoolean(s);break;default:u=c}else u=c}o&&o.isLabel?r[i]=u:n[i]=u}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,a=t.length,i=rF,o=0;o<a;o++)switch(i){case rF:switch(t.charAt(o)){case'"':r=o+1,i=iF;break;case this.delimiter:if(r=o+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),i=rF;break;default:i=aF,r=o}break;case aF:switch(t.charAt(o)){case this.delimiter:n.push(t.substring(r,o)),i=rF,r=o+1}break;case iF:switch(t.charAt(o)){case'"':i=oF}break;case oF:switch(t.charAt(o)){case this.delimiter:n.push(t.substring(r,o-1)),i=rF,r=o+1;break;case'"':i=iF;break;default:i=sF}break;case sF:switch(t.charAt(o)){case'"':i=iF}}if(i===oF?n.push(t.substring(r,a-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+n);return n},e}(QO),cF=function(t){function e(e){var n;(n=t.call(this)||this).microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+n.fftSize);if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}Gm(e,t);var n=e.prototype;return n.summary=function(){return"microphone"},e.create=function(){var t=Vm(regeneratorRuntime.mark((function t(n){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===n&&(n={}),!nv().get("IS_NODE")){t.next=3;break}throw new Error("microphone API is only supported in browser environment.");case 3:return r=new e(n),t.next=6,r.start();case 6:return t.abrupt("return",r);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),n.start=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1});case 3:this.stream=t.sent,t.next=9;break;case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error thrown while initializing video stream: "+t.t0.message);case 9:if(this.stream){t.next=11;break}throw new Error("Could not obtain audio from microphone.");case 11:if(e=window.AudioContext||window.webkitAudioContext,this.audioContext=new e,this.sampleRateHz){t.next=17;break}this.sampleRateHz=this.audioContext.sampleRate,t.next=19;break;case 17:if(this.audioContext.sampleRate===this.sampleRateHz){t.next=19;break}throw new Error("Mismatch in sampling rate: Expected: "+this.sampleRateHz+"; Actual: "+this.audioContext.sampleRate);case 19:return n=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,n.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),t.abrupt("return");case 27:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(){return t.apply(this,arguments)}}(),n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isClosed){t.next=2;break}return t.abrupt("return",{value:null,done:!0});case 2:return t.next=4,this.getAudioData();case 4:return r=t.sent,this.includeSpectrogram&&(a=this.flattenQueue(r.freqDataQueue),e=this.getTensorFromAudioDataArray(a,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(r.timeDataQueue),n=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),t.abrupt("return",{value:{spectrogram:e,waveform:n},done:!1});case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.capture=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.next();case 2:return t.abrupt("return",t.sent.value);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getAudioData=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[],n=[],r=0,t.abrupt("return",new Promise((function(t){var i=setInterval((function(){a.includeSpectrogram&&(a.analyser.getFloatFrequencyData(a.freqData),a.freqData[0]===-1/0&&t({freqDataQueue:e,timeDataQueue:n}),e.push(a.freqData.slice(0,a.columnTruncateLength))),a.includeWaveform&&(a.analyser.getFloatTimeDomainData(a.timeData),n.push(a.timeData.slice())),++r===a.numFrames&&(clearInterval(i),t({freqDataQueue:e,timeDataQueue:n}))}),a.fftSize/a.sampleRateHz*1e3)})));case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),n.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())},n.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.getSampleRate=function(){return this.sampleRateHz},n.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach((function(t,r){return n.set(t,r*e)})),n},n.getTensorFromAudioDataArray=function(t,e){var n=new Float32Array(wv(e));return n.set(t,n.length-t.length),ay(n,e)},e}(LO),lF=function(t){function e(e,n){var r;if((r=t.call(this)||this).webcamVideoElement=e,r.webcamConfig=n,r.isClosed=!0,r.resize=!1,r.needToResize())if(r.resize=!0,r.cropSize=[r.webcamConfig.resizeHeight,r.webcamConfig.resizeWidth],r.cropBoxInd=sy([0],"int32"),r.webcamConfig.centerCrop){var a=1*r.webcamConfig.resizeWidth/r.webcamVideoElement.width,i=1*r.webcamConfig.resizeHeight/r.webcamVideoElement.height,o=(1-a)/2,s=(1-i)/2,u=o+a,c=i+s;r.cropBox=uy([s,o,c,u],[1,4])}else r.cropBox=uy([0,0,1,1],[1,4]);return r}Gm(e,t);var n=e.prototype;return n.summary=function(){return"webcam"},e.create=function(){var t=Vm(regeneratorRuntime.mark((function t(n,r){var a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r={}),!nv().get("IS_NODE")){t.next=3;break}throw new Error("tf.data.webcam is only supported in browser environment.");case 3:if(n){t.next=9;break}if(n=document.createElement("video"),r.resizeWidth&&r.resizeHeight){t.next=7;break}throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");case 7:n.width=r.resizeWidth,n.height=r.resizeHeight;case 9:return a=new e(n,r),t.next=12,a.start();case 12:return t.abrupt("return",a);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),n.start=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.webcamConfig.facingMode&&gv("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(function(){return"Invalid webcam facing mode: "+e.webcamConfig.facingMode+". Please provide 'user' or 'environment'"})),t.prev=1,t.next=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 4:this.stream=t.sent,t.next=11;break;case 7:throw t.prev=7,t.t0=t.catch(1),t.t0.message="Error thrown while initializing video stream: "+t.t0.message,t.t0;case 11:if(this.stream){t.next=13;break}throw new Error("Could not obtain video from webcam.");case 13:try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,t.abrupt("return",new Promise((function(t){e.webcamVideoElement.onloadedmetadata=function(){t()}})));case 17:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(){return t.apply(this,arguments)}}(),n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isClosed){t.next=2;break}return t.abrupt("return",{value:null,done:!0});case 2:t.prev=2,e=Ck(this.webcamVideoElement),t.next=9;break;case 6:throw t.prev=6,t.t0=t.catch(2),new Error("Error thrown converting video to pixels: "+JSON.stringify(t.t0));case 9:if(!this.resize){t.next=22;break}return t.prev=10,t.abrupt("return",{value:this.cropAndResizeFrame(e),done:!1});case 14:throw t.prev=14,t.t1=t.catch(10),new Error("Error thrown cropping the video: "+t.t1.message);case 17:return t.prev=17,e.dispose(),t.finish(17);case 20:t.next=23;break;case 22:return t.abrupt("return",{value:e,done:!1});case 23:case"end":return t.stop()}}),t,this,[[2,6],[10,14,17,20]])})));return function(){return t.apply(this,arguments)}}(),n.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.cropAndResizeFrame=function(t){var e=this;return Nb((function(){var n,r=t.toFloat().expandDims(0),a=(n=OR(r,e.cropBox,e.cropBoxInd,e.cropSize,"bilinear")).shape;return n.reshape(a.slice(1))}))},n.capture=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.next();case 2:return t.abrupt("return",t.sent.value);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.stop=function(){this.stream.getTracks().forEach((function(t){return t.stop()}));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},e}(LO),hF=function(){},fF=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.split=function(t){return new pF(this,t)},e}(LO),pF=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.impl=new dF(e,n),r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.impl.summary()},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.impl.next());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(fF),dF=function(t){function e(e,n){var r;return(r=t.call(this)||this).upstream=e,r.separator=n,r.carryover="",r}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},n.pump=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.upstream.next();case 2:if(!(e=t.sent).done){t.next=9;break}if(""!==this.carryover){t.next=6;break}return t.abrupt("return",!1);case 6:return this.outputQueue.push(this.carryover),this.carryover="",t.abrupt("return",!0);case 9:for((n=e.value.split(this.separator))[0]=this.carryover+n[0],r=Zm(n.slice(0,-1));!(a=r()).done;)i=a.value,this.outputQueue.push(i);return this.carryover=n[n.length-1],t.abrupt("return",!0);case 14:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(KO),mF=function(t){function e(){return t.apply(this,arguments)||this}return Gm(e,t),e.prototype.decodeUTF8=function(){return new vF(this)},e}(LO),vF=function(t){function e(e){var n;return(n=t.call(this)||this).upstream=e,n.impl=new gF(e),n}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.impl.summary()},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.impl.next());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(fF),gF=function(t){function e(e){var n;if((n=t.call(this)||this).upstream=e,nv().get("IS_BROWSER"))n.decoder=new TextDecoder("utf-8");else{var r=require("string_decoder").StringDecoder;n.decoder=new r("utf8")}return n}Gm(e,t);var n=e.prototype;return n.summary=function(){return this.upstream.summary()+" -> Utf8"},n.pump=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.upstream.next();case 2:if(!(e=t.sent).done){t.next=7;break}return t.abrupt("return",!1);case 7:n=e.value;case 8:return r=nv().get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),t.abrupt("return",!0);case 11:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(KO),yF=function(t){function e(e,n){var r;return void 0===n&&(n={}),(r=t.call(this)||this).file=e,r.options=n,gv(e instanceof Uint8Array||!!nv().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),(function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."})),r.offset=n.offset||0,r.chunkSize=n.chunkSize||1048576,r}Gm(e,t);var n=e.prototype;return n.summary=function(){return"FileChunks "+this.file},n.next=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e,n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))){t.next=2;break}return t.abrupt("return",{value:null,done:!0});case 2:return e=new Promise((function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var a=new FileReader;a.onload=function(n){var r=a.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},a.onabort=function(t){return e(new Error("Aborted"))},a.onerror=function(t){return e(new Error(t.type))};var i=n.file.slice(n.offset,r);a.readAsArrayBuffer(i)}n.offset=r})),t.next=5,e;case 5:return t.t0=t.sent,t.abrupt("return",{value:t.t0,done:!1});case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(mF);function bF(t,e){return xF.apply(this,arguments)}function xF(){return(xF=Vm(regeneratorRuntime.mark((function t(e,n){var r,a,i,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n={}),"string"==typeof e?r=e:(r=e.url,a=wF(e)),t.next=4,Zv(r,a);case 4:if(!(i=t.sent).ok){t.next=14;break}return t.t0=Uint8Array,t.next=9,i.arrayBuffer();case 9:return t.t1=t.sent,o=new t.t0(t.t1),t.abrupt("return",new yF(o,n));case 14:throw new Error(i.statusText);case 15:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var wF=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function kF(t){return"string"==typeof t&&"file://"===t.substr(0,7)}var SF=function(t){function e(e,n){var r;return void 0===n&&(n={}),(r=t.call(this)||this).input=e,r.options=n,r}return Gm(e,t),e.prototype.iterator=function(){var t=Vm(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return kF(this.input)&&nv().get("IS_NODE")&&(e=require("fs"),this.input=e.readFileSync(this.input.substr(7))),t.abrupt("return",new yF(this.input,this.options));case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(hF),CF=function(t){function e(e,n){var r;return void 0===n&&(n={}),(r=t.call(this)||this).url=e,r.fileOptions=n,r}return Gm(e,t),e.prototype.iterator=function(){var t=Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!kF(this.url)){t.next=4;break}return t.abrupt("return",new SF(this.url,this.fileOptions).iterator());case 4:return t.abrupt("return",bF(this.url,this.fileOptions));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(hF);function RF(){return(RF=Vm(regeneratorRuntime.mark((function t(e,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",lF.create(e,n));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function NF(){return(NF=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",cF.create(e));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var EF={__proto__:null,array:function(t){return tF(Vm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",_O(t));case 1:case"end":return e.stop()}}),e)}))),t.length)},Dataset:QO,zip:function(t){if(!EO(t))throw new Error("The argument to zip() must be an object or array.");var e;if(Array.isArray(t))for(var n=0;n<t.length;n++)e=null==e?t[n].size:Math.min(e,t[n].size);else if(t instanceof Object)for(var r in t)e=null==e?t[r].size:Math.min(e,t[r].size);return tF(Vm(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,RO(t,(function(t){if(t instanceof QO)return{value:t.iterator(),recurse:!1};if(EO(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}));case 2:return n=e.sent,e.abrupt("return",FO(n,MO.SHORTEST));case 4:case"end":return e.stop()}}),e)}))),e)},CSVDataset:uF,TextLineDataset:nF,csv:function(t,e){return void 0===e&&(e={}),new uF(new CF(t),e)},func:function(t){var e=OO(t);return tF(Vm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e);case 1:case"end":return t.stop()}}),t)}))))},generator:function(t){return tF(Vm(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t();case 2:return n=e.sent,e.abrupt("return",OO((function(){return n.next()})));case 4:case"end":return e.stop()}}),e)}))))},microphone:function(t){return NF.apply(this,arguments)},webcam:function(t,e){return RF.apply(this,arguments)},FileDataSource:SF,URLDataSource:CF,version_data:"2.0.0"};function IF(t,e,n,r){for(var a=Dv(r,wv(n)),i=0;i<a.length;++i){for(var o=i*e,s=t[o],u=0;u<e;++u){var c=t[o+u];c>s&&(s=c)}a[i]=s}return a}function AF(t,e,n,r,a){for(var i=e.length,o=wv(e),s=qv(e),u=qv(a),c=Dv(n,wv(a)),l=0;l<o;++l){for(var h=ng(l,i,s),f=new Array(h.length),p=0;p<f.length;p++)f[p]=h[r[p]];c[eg(f,i,u)]=t[l]}return c}function TF(t,e){Array.isArray(t)||(t=[t]),t.forEach((function(t){null!=t&&gv("complex64"!==t.dtype,(function(){return e+" does not support complex64 tensors in the CPU backend."}))}))}function DF(t,e,n,r,a,i){for(var o=a.strideHeight,s=a.strideWidth,u=a.dilationHeight,c=a.dilationWidth,l=a.effectiveFilterHeight,h=a.effectiveFilterWidth,f=a.padInfo.top,p=a.padInfo.left,d="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=Sy(a.outShape,n),v=m.values,g=a.outShape[1]*a.outShape[2]*a.outShape[3],y=a.outShape[2]*a.outShape[3],b=a.outShape[3],x=0;x<a.batchSize;++x)for(var w=x*g,k=x*r[0],S=0;S<a.inChannels;++S)for(var C=0;C<a.outHeight;++C)for(var R=C*o-f,N=Math.max(0,R),E=Math.min(a.inHeight,l+R),I=w+C*y,A=0;A<a.outWidth;++A){for(var T=A*s-p,D=Math.max(0,T),_=Math.min(a.inWidth,h+T),O=d,F=0,M=0,L=N;L<E;L+=u){for(var z=k+L*r[1],B=D;B<_;B+=c){var P=t[z+B*r[2]+S];"max"===i&&P>O?O=P:"avg"===i&&(F+=P,M++)}if(isNaN(O))break}v[I+A*b+S]="avg"===i?F/M:O}return m}function _F(t,e,n,r,a,i){void 0===a&&(a=!1),void 0===i&&(i=!1);for(var o=Sy(r.outShape,"int32"),s=r.strideHeight,u=r.strideWidth,c=r.dilationHeight,l=r.dilationWidth,h=r.effectiveFilterHeight,f=r.effectiveFilterWidth,p=r.padInfo.top,d=r.padInfo.left,m=Sy(e,n,t),v=0;v<r.batchSize;++v)for(var g=0;g<r.inChannels;++g)for(var y=0;y<r.outHeight;++y){for(var b=y*s-p,x=b;x<0;)x+=c;for(var w=Math.min(r.inHeight,h+b),k=0;k<r.outWidth;++k){for(var S=k*u-d,C=S;C<0;)C+=l;for(var R=Math.min(r.inWidth,f+S),N=Number.NEGATIVE_INFINITY,E=-1,I=x;I<w;I+=c)for(var A=I-b,T=C;T<R;T+=l){var D=T-S,_=m.get(v,I,T,g);_>N&&(N=_,E=a?i?((v*r.inHeight+I)*r.inWidth+T)*r.inChannels+g:(I*r.inWidth+T)*r.inChannels+g:A*f+D)}o.set(E,v,y,k,g)}}return o}var OF=yR,FF=xN,MF=wN,LF=kN,zF=iS;function BF(t,e,n,r){if("linear"===n)return t.linear(e);if("relu"===n)return t.relu(e);if("elu"===n)return t.elu(e);if("relu6"===n)return t.relu6(e);if("prelu"===n)return t.prelu(e,r);throw new Error("Activation "+n+" has not been implemented for the CPU backend.")}var PF=function(t){function e(){var e;return(e=t.call(this)||this).blockSize=48,e.firstUse=!0,e.data=new RN(Jm(e),Cb()),e}Gm(e,t);var n=e.prototype;return n.write=function(t,e,n){this.firstUse&&(this.firstUse=!1,nv().get("IS_NODE")&&sN("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================"));var r={};return this.data.set(r,{values:t,dtype:n}),r},n.move=function(t,e,n,r){this.data.set(t,{values:e,dtype:r})},n.numDataIds=function(){return this.data.numDataIds()},n.read=function(){var t=Vm(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.readSync(e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.readSync=function(t){var e=this.data.get(t),n=e.dtype,r=e.complexTensors;return"complex64"===n?uN(this.readSync(r.real.dataId),this.readSync(r.imag.dataId)):this.data.get(t).values},n.bufferSync=function(t){var e=this.readSync(t.dataId),n=e;if("string"===t.dtype)try{n=e.map((function(t){return tg(t)}))}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8")}return Sy(t.shape,t.dtype,n)},n.makeOutput=function(t,e,n){var r=this.write(t,e,n);return Cb().makeTensorFromDataId(r,e,n,this)},n.disposeData=function(t){if(this.data.has(t)){var e=this.data.get(t).complexTensors;null!=e&&(e.real.dispose(),e.imag.dispose()),this.data.delete(t)}},n.time=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Jv(),e(),r=Jv()-n,t.abrupt("return",{kernelMs:r});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),n.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."]}},n.complex=function(t,e){var n=this.makeOutput(null,t.shape,"complex64");return this.data.get(n.dataId).complexTensors={real:Cb().keep(t.clone()),imag:Cb().keep(e.clone())},n},n.real=function(t){return this.data.get(t.dataId).complexTensors.real.clone()},n.imag=function(t){return this.data.get(t.dataId).complexTensors.imag.clone()},n.slice=function(t,e,n){if(TF(t,"slice"),tw(t.shape,e,n)){var r=ew(e,t.strides),a=wv(n);return ay(this.readSync(t.dataId).subarray(r,r+a),n,t.dtype)}for(var i=Sy(n,t.dtype),o=this.bufferSync(t),s=0;s<i.size;++s){var u=i.indexToLoc(s).map((function(t,n){return t+e[n]}));i.values[s]=o.get.apply(o,u)}return i.toTensor()},n.stridedSlice=function(t,e,n,r){TF(t,"stridedSlice");var a=$x(e,n,r);if(a.some((function(t){return 0===t})))return ay([],a);for(var i=Sy(a,t.dtype),o=this.bufferSync(t),s=0;s<i.size;s++){for(var u=i.indexToLoc(s),c=new Array(u.length),l=0;l<c.length;l++)c[l]=u[l]*r[l]+e[l];i.set.apply(i,[o.get.apply(o,c)].concat(u))}return i.toTensor()},n.diag=function(t){for(var e=this.readSync(t.dataId),n=Sy([t.size,t.size],t.dtype),r=n.values,a=0;a<e.length;a++)r[a*t.size+a]=e[a];return n.toTensor()},n.unstack=function(t,e){for(var n=t.shape[e],r=new Array(t.rank-1),a=0,i=0;i<t.rank;i++)i!==e&&(r[a++]=t.shape[i]);var o=new Array(t.rank).fill(0),s=t.shape.slice();s[e]=1;for(var u=new Array(n),c=0;c<u.length;c++)o[e]=c,u[c]=this.slice(t,o,s).reshape(r);return u},n.reverse=function(t,e){TF(t,"reverse");for(var n=Sy(t.shape,t.dtype),r=this.bufferSync(t),a=function(a){var i=n.indexToLoc(a),o=i.slice();e.forEach((function(e){return o[e]=t.shape[e]-1-o[e]})),n.set.apply(n,[r.get.apply(r,o)].concat(i))},i=0;i<n.size;i++)a(i);return n.toTensor()},n.concat=function(t,e){var n=this;if("complex64"===t[0].dtype){var r=t.map((function(t){return ny(t)})),a=t.map((function(t){return ry(t)}));return ey(this.concat(r,e),this.concat(a,e))}var i=t.map((function(t){var n=wv(t.shape.slice(e));return t.as2D(-1,n)})),o=Qg(i.map((function(t){return t.shape})),1),s=Sy(o,t[0].dtype).values;if(1===i[0].shape[0]){var u=0;i.forEach((function(t){s.set(n.readSync(t.dataId),u),u+=t.size}))}else{var c=0;i.forEach((function(t){for(var e=n.readSync(t.dataId),r=0,a=0;a<t.shape[0];++a)for(var i=a*o[1]+c,u=0;u<t.shape[1];++u)s[i+u]=e[r++];c+=t.shape[1]}))}var l=Qg(t.map((function(t){return t.shape})),e);return ay(s,l,t[0].dtype)},n.neg=function(t){return TF(t,"neg"),this.multiply(oy(-1),t)},n.add=function(t,e){return"complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),(function(t,e,n,r){return{real:t+n,imag:e+r}})):this.broadcastedBinaryOp(t,e,wg(t.dtype,e.dtype),(function(t,e){return t+e}))},n.addN=function(t){var e=this;TF(t,"addN");for(var n=t.map((function(t){return e.readSync(t.dataId)})),r=Sy(t[0].shape,t[0].dtype),a=r.values,i=0;i<t.length;i++)for(var o=n[i],s=0;s<a.length;s++)a[s]+=o[s];return r.toTensor()},n.softmax=function(t,e){var n=Av([e],t.shape),r=kS(t,n),a=Kg(r.shape,n),i=this.subtract(t,r.reshape(a)),o=this.exp(i),s=this.sum(o,n).reshape(a);return Ix(o,s)},n.subtract=function(t,e){return"complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),(function(t,e,n,r){return{real:t-n,imag:e-r}})):this.broadcastedBinaryOp(t,e,wg(t.dtype,e.dtype),(function(t,e){return t-e}))},n.pow=function(t,e){return TF([t,e],"pow"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return Math.pow(t,e)}))},n.batchMatMul=function(t,e,n,r){TF([t,e],"matMul");for(var a=n?t.shape[1]:t.shape[2],i=n?t.shape[2]:t.shape[1],o=r?e.shape[1]:e.shape[2],s=t.shape[0],u=this.readSync(t.dataId),c=this.readSync(e.dataId),l=n?[t.strides[0],1,t.strides[1]]:[t.strides[0],t.strides[1],1],h=l[0],f=l[1],p=l[2],d=r?[1,e.strides[1],e.strides[0]]:[e.strides[1],1,e.strides[0]],m=d[0],v=d[1],g=d[2],y=i*o,b=Sy([s,i,o],t.dtype),x=b.values,w=this.blockSize,k=0;k<s;k++)for(var S=0;S<i;S+=w)for(var C=0;C<o;C+=w)for(var R=0;R<a;R+=w)for(var N=Math.min(S+w,i),E=Math.min(C+w,o),I=Math.min(R+w,a),A=S;A<N;A++)for(var T=C;T<E;T++){for(var D=0,_=R;_<I;_++)D+=u[k*h+A*f+_*p]*c[_*m+T*v+k*g];x[k*y+(A*o+T)]+=D}return b.toTensor()},n.fusedBatchMatMul=function(t){var e=t.a,n=t.b,r=t.transposeA,a=t.transposeB,i=t.bias,o=t.activation,s=t.preluActivationWeights,u=this.batchMatMul(e,n,r,a);return i&&(u=this.add(u,i)),o&&(u=BF(this,u,o,s)),u},n.multiply=function(t,e){return"complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),(function(t,e,n,r){return{real:t*n-e*r,imag:t*r+e*n}})):this.broadcastedBinaryOp(t,e,wg(t.dtype,e.dtype),(function(t,e){return t*e}))},n.floorDiv=function(t,e){TF([t,e],"floorDiv");return this.broadcastedBinaryOp(t,e,"int32",(function(t,e){return Math.floor(t/e)}))},n.sum=function(t,e){TF(t,"sum"),Xg("sum",e,t.rank);for(var n=Hg(t.shape,e),r=n[0],a=n[1],i=my(r,wg(t.dtype,"int32")),o=wv(a),s=this.readSync(i.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*o,h=0,f=0;f<o;++f)h+=u[l+f];s[c]=h}return i},n.prod=function(t,e){TF(t,"sum");for(var n=Hg(t.shape,e),r=n[0],a=n[1],i=my(r,wg(t.dtype,"int32")),o=wv(a),s=this.readSync(i.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*o,h=1,f=0;f<o;++f)h*=u[l+f];s[c]=h}return i},n.unsortedSegmentSum=function(t,e,n){TF(t,"unsortedSegmentSum");for(var r=[],a=t.rank-e.rank,i=0;i<a;++i)e=e.expandDims(i+1);for(var o=0;o<n;++o){var s=oy(o,"int32"),u=mS(s,e).asType("float32").mul(t).sum(0);r.push(u)}return Ty(r)},n.argMin=function(t,e){TF(t,"argMin");var n=[e];Xg("argMin",n,t.rank);for(var r=Hg(t.shape,n),a=r[0],i=r[1],o=my(a,"int32"),s=wv(i),u=this.readSync(o.dataId),c=this.readSync(t.dataId),l=0;l<u.length;++l){for(var h=l*s,f=c[h],p=0,d=0;d<s;++d){var m=c[h+d];m<f&&(f=m,p=d)}u[l]=p}return o},n.argMax=function(t,e){TF(t,"argMax");var n=[e];Xg("argMax",n,t.rank);for(var r=Hg(t.shape,n),a=r[0],i=r[1],o=my(a,"int32"),s=wv(i),u=this.readSync(o.dataId),c=this.readSync(t.dataId),l=0;l<u.length;++l){for(var h=l*s,f=c[h],p=0,d=0;d<s;++d){var m=c[h+d];m>f&&(f=m,p=d)}u[l]=p}return o},n.cumsum=function(t,e,n,r){if(TF(t,"cumsum"),e!==t.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(t.rank-1)+" but got axis="+e);for(var a=wg(t.dtype,"int32"),i=my(t.shape,a),o=this.readSync(i.dataId),s=this.readSync(t.dataId),u=t.shape[t.rank-1],c=r?function(t,e){return t+u-e-1}:function(t,e){return t+e},l=0;l<s.length;l+=u)for(var h=0;h<u;h++){var f=c(l,h);if(0===h)o[f]=n?0:s[f];else{var p=c(l,h-1);o[f]=n?s[p]+o[p]:s[f]+o[p]}}return i},n.equal=function(t,e){return TF([t,e],"equal"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t===e?1:0}))},n.notEqual=function(t,e){return TF([t,e],"notEqual"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t!==e?1:0}))},n.less=function(t,e){return TF([t,e],"less"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t<e?1:0}))},n.lessEqual=function(t,e){return TF([t,e],"lessEqual"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t<=e?1:0}))},n.greater=function(t,e){return TF([t,e],"greater"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t>e?1:0}))},n.greaterEqual=function(t,e){return TF([t,e],"greaterEqual"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t>=e?1:0}))},n.logicalNot=function(t){TF(t,"logicalNot");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r)n[r]=e[r]?0:1;return this.makeOutput(n,t.shape,"bool")},n.logicalAnd=function(t,e){return TF([t,e],"logicalAnd"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t&&e}))},n.logicalOr=function(t,e){return TF([t,e],"logicalOr"),this.broadcastedBinaryOp(t,e,"bool",(function(t,e){return t||e}))},n.select=function(t,e,n){TF([t,e,n],"select");for(var r=this.readSync(t.dataId),a=this.readSync(e.dataId),i=this.readSync(n.dataId),o=my(e.shape,wg(e.dtype,n.dtype)),s=this.readSync(o.dataId),u=0,c=0===t.rank||t.rank>1||1===e.rank?1:wv(e.shape.slice(1)),l=0;l<r.length;l++)for(var h=0;h<c;h++)1===r[l]?s[u++]=a[l]:s[u++]=i[l];return o},n.where=function(t){TF([t],"where");var e=this.readSync(t.dataId);return zF(t.shape,e)},n.topk=function(t,e,n){TF(t,"topk");var r=this.readSync(t.dataId);return LF(r,t.shape,t.dtype,e)},n.min=function(t,e){TF(t,"min"),Xg("min",e,t.rank);for(var n=Hg(t.shape,e),r=n[0],a=n[1],i=my(r,t.dtype),o=wv(a),s=this.readSync(i.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*o,h=u[l],f=0;f<o;++f){var p=u[l+f];p<h&&(h=p)}s[c]=h}return i},n.minimum=function(t,e){return TF([t,e],"minimum"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return Math.min(t,e)}))},n.mod=function(t,e){return TF([t,e],"mod"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){var n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e}))},n.maximum=function(t,e){return TF([t,e],"maximum"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return Math.max(t,e)}))},n.all=function(t,e){TF(t,"all"),Xg("all",e,t.rank);for(var n=Hg(t.shape,e),r=n[0],a=n[1],i=my(r,t.dtype),o=wv(a),s=this.readSync(i.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*o,h=u[l],f=0;f<o;++f){var p=u[l+f];h=h&&p}s[c]=h}return i},n.any=function(t,e){TF(t,"any"),Xg("any",e,t.rank);for(var n=Hg(t.shape,e),r=n[0],a=n[1],i=my(r,t.dtype),o=wv(a),s=this.readSync(i.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*o,h=u[l],f=0;f<o;++f){var p=u[l+f];h=h||p}s[c]=h}return i},n.squaredDifference=function(t,e){return TF([t,e],"squaredDifference"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){var n=t-e;return n*n}))},n.ceil=function(t){TF(t,"ceil");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=Math.ceil(e[r]);return this.makeOutput(n,t.shape,"float32")},n.floor=function(t){TF(t,"floor");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=Math.floor(e[r]);return this.makeOutput(n,t.shape,"float32")},n.sign=function(t){TF(t,"x");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)e[r]<0?n[r]=-1:e[r]>0?n[r]=1:n[r]=0;return this.makeOutput(n,t.shape,"float32")},n.isNaN=function(t){TF(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r)Number.isNaN(e[r])&&(n[r]=1);return this.makeOutput(n,t.shape,"bool")},n.isInf=function(t){TF(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r)Math.abs(e[r])===1/0&&(n[r]=1);return this.makeOutput(n,t.shape,"bool")},n.isFinite=function(t){TF(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r)Number.isFinite(e[r])&&(n[r]=1);return this.makeOutput(n,t.shape,"bool")},n.round=function(t){TF(t,"round");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var a=Math.floor(e[r]);e[r]-a<.5?n[r]=Math.floor(e[r]):e[r]-a>.5?n[r]=Math.ceil(e[r]):n[r]=a%2==0?a:a+1}return this.makeOutput(n,t.shape,"float32")},n.exp=function(t){TF(t,"exp");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=Math.exp(e[r]);return this.makeOutput(n,t.shape,"float32")},n.expm1=function(t){TF(t,"expm1");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=Math.expm1(e[r]);return this.makeOutput(n,t.shape,"float32")},n.log=function(t){TF(t,"log");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var a=e[r];n[r]=Math.log(a)}return this.makeOutput(n,t.shape,"float32")},n.log1p=function(t){TF(t,"log1p");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var a=e[r];n[r]=Math.log1p(a)}return this.makeOutput(n,t.shape,"float32")},n.sqrt=function(t){TF(t,"sqrt");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var a=e[r];n[r]=Math.sqrt(a)}return this.makeOutput(n,t.shape,"float32")},n.rsqrt=function(t){TF(t,"rsqrt");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var a=e[r];n[r]=1/Math.sqrt(a)}return this.makeOutput(n,t.shape,"float32")},n.reciprocal=function(t){TF(t,"reciprocal");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r)n[r]=1/e[r];return this.makeOutput(n,t.shape,"float32")},n.linear=function(t){return t},n.relu=function(t){TF(t,"relu");for(var e=my(t.shape,t.dtype),n=this.readSync(e.dataId),r=this.readSync(t.dataId),a=0;a<r.length;++a)n[a]=Math.max(0,r[a]);return e},n.relu6=function(t){TF(t,"relu");for(var e=my(t.shape,t.dtype),n=this.readSync(e.dataId),r=this.readSync(t.dataId),a=0;a<r.length;++a)n[a]=Math.min(Math.max(0,r[a]),6);return e},n.prelu=function(t,e){return TF([t,e],"prelu"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return t<0?e*t:t}))},n.elu=function(t){TF(t,"elu");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var a=n[r];e[r]=a>=0?a:Math.exp(a)-1}return this.makeOutput(e,t.shape,"float32")},n.eluDer=function(t,e){TF([t,e],"eluDer");for(var n=new Float32Array(e.size),r=this.readSync(e.dataId),a=this.readSync(t.dataId),i=0;i<r.length;++i){var o=r[i];n[i]=o>=1?a[i]:a[i]*(o+1)}return this.makeOutput(n,e.shape,"float32")},n.selu=function(t){TF(t,"selu");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var a=n[r];e[r]=a>=0?1.0507009873554805*a:1.7580993408473768*(Math.exp(a)-1)}return this.makeOutput(e,t.shape,"float32")},n.clip=function(t,e,n){TF(t,"clip");for(var r=new Float32Array(t.size),a=this.readSync(t.dataId),i=0;i<a.length;++i){var o=a[i];r[i]=o>n?n:o<e?e:o}return this.makeOutput(r,t.shape,"float32")},n.abs=function(t){for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.abs(n[r]);return this.makeOutput(e,t.shape,"float32")},n.complexAbs=function(t){for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<t.size;++r){var a=n[2*r],i=n[2*r+1];e[r]=Math.hypot(a,i)}return this.makeOutput(e,t.shape,"float32")},n.int=function(t){TF(t,"int");for(var e=new Int32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=n[r];return this.makeOutput(e,t.shape,"int32")},n.sigmoid=function(t){TF(t,"sigmoid");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=1/(1+Math.exp(-n[r]));return this.makeOutput(e,t.shape,"float32")},n.softplus=function(t){TF(t,"softplus");for(var e=Math.log(1.1920928955078125e-7)+2,n=new Float32Array(t.size),r=this.readSync(t.dataId),a=0;a<r.length;++a){var i=r[a]>-e,o=r[a]<e,s=Math.exp(r[a]),u=void 0;u=o?s:i?r[a]:Math.log(1+s),n[a]=u}return this.makeOutput(n,t.shape,"float32")},n.sin=function(t){TF(t,"sin");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.sin(n[r]);return this.makeOutput(e,t.shape,"float32")},n.cos=function(t){TF(t,"cos");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.cos(n[r]);return this.makeOutput(e,t.shape,"float32")},n.tan=function(t){TF(t,"tan");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.tan(n[r]);return this.makeOutput(e,t.shape,"float32")},n.asin=function(t){TF(t,"asin");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.asin(n[r]);return this.makeOutput(e,t.shape,"float32")},n.acos=function(t){TF(t,"acos");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.acos(n[r]);return this.makeOutput(e,t.shape,"float32")},n.atan=function(t){TF(t,"atan");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.atan(n[r]);return this.makeOutput(e,t.shape,"float32")},n.atan2=function(t,e){return TF([t,e],"atan2"),this.broadcastedBinaryOp(t,e,t.dtype,(function(t,e){return Math.atan2(t,e)}))},n.sinh=function(t){TF(t,"sinh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.sinh(n[r]);return this.makeOutput(e,t.shape,"float32")},n.cosh=function(t){TF(t,"cosh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.cosh(n[r]);return this.makeOutput(e,t.shape,"float32")},n.tanh=function(t){TF(t,"tanh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Cv(n[r]);return this.makeOutput(e,t.shape,"float32")},n.asinh=function(t){TF(t,"asinh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.asinh(n[r]);return this.makeOutput(e,t.shape,"float32")},n.acosh=function(t){TF(t,"acosh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.acosh(n[r]);return this.makeOutput(e,t.shape,"float32")},n.atanh=function(t){TF(t,"atanh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r)e[r]=Math.atanh(n[r]);return this.makeOutput(e,t.shape,"float32")},n.erf=function(t){TF(t,"erf");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var a=Math.sign(n[r]),i=Math.abs(n[r]),o=1/(1+.3275911*i);e[r]=a*(1-((((1.061405429*o-1.453152027)*o+1.421413741)*o-.284496736)*o+.254829592)*o*Math.exp(-i*i))}return this.makeOutput(e,t.shape,"float32")},n.step=function(t,e){void 0===e&&(e=0),TF(t,"step");for(var n=new Float32Array(t.size),r=this.readSync(t.dataId),a=0;a<r.length;++a){var i=r[a];isNaN(i)?n[a]=NaN:n[a]=i>0?1:e}return this.makeOutput(n,t.shape,"float32")},n.fusedConv2d=function(t){var e=t.input,n=t.filter,r=t.convInfo,a=t.bias,i=t.activation,o=t.preluActivationWeights,s=this.conv2d(e,n,r);return a&&(s=this.add(s,a)),i&&(s=BF(this,s,i,o)),s},n.conv2d=function(t,e,n){TF([t,e],"conv2d");for(var r=n.filterHeight,a=n.filterWidth,i=n.dilationHeight,o=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c="channelsLast"===n.dataFormat,l=Sy(n.outShape,t.dtype),h=t.strides[0],f=c?t.strides[1]:t.strides[2],p=c?t.strides[2]:1,d=c?1:t.strides[1],m=l.strides[0],v=c?l.strides[1]:l.strides[2],g=c?l.strides[2]:1,y=c?1:l.strides[1],b=this.readSync(t.dataId),x=this.readSync(e.dataId),w=l.values,k=0;k<n.batchSize;++k)for(var S=k*h,C=k*m,R=0;R<n.outHeight;++R)for(var N=C+R*v,E=R*n.strideHeight-u,I=0;I<r;I++){var A=E+I*i;if(!(A<0||A>=n.inHeight))for(var T=I*e.strides[0],D=S+A*f,_=0;_<n.outWidth;++_)for(var O=N+_*g,F=_*n.strideWidth-s,M=0;M<a;M++){var L=F+M*o;if(!(L<0||L>=n.inWidth))for(var z=D+L*p,B=T+M*e.strides[1],P=0;P<n.inChannels;++P){for(var W=b[z+P*d],V=0;V<n.outChannels;++V)w[O+V*y]+=W*x[B+V];B+=n.outChannels}}}return l.toTensor()},n.conv3d=function(t,e,n){for(var r=n.filterDepth,a=n.filterHeight,i=n.filterWidth,o=n.dilationDepth,s=n.dilationHeight,u=n.dilationWidth,c=n.padInfo.front,l=n.padInfo.left,h=n.padInfo.top,f=Sy(n.outShape,t.dtype),p=this.readSync(t.dataId),d=this.readSync(e.dataId),m=f.values,v=0;v<n.batchSize;++v)for(var g=v*t.strides[0],y=v*f.strides[0],b=0;b<n.outDepth;++b)for(var x=y+b*f.strides[1],w=b*n.strideDepth-c,k=0;k<r;k++){var S=w+k*o;if(!(S<0||S>=n.inDepth))for(var C=k*e.strides[0],R=g+S*t.strides[1],N=0;N<n.outHeight;++N)for(var E=x+N*f.strides[2],I=N*n.strideHeight-h,A=0;A<a;A++){var T=I+A*s;if(!(T<0||T>=n.inHeight))for(var D=C+A*e.strides[1],_=R+T*t.strides[2],O=0;O<n.outWidth;++O)for(var F=E+O*n.outChannels,M=O*n.strideWidth-l,L=0;L<i;L++){var z=M+L*u;if(!(z<0||z>=n.inWidth))for(var B=D+L*e.strides[2],P=_+z*n.inChannels,W=B,V=0;V<n.inChannels;++V){for(var U=p[P+V],j=0;j<n.outChannels;++j)m[F+j]+=U*d[W+j];W+=n.outChannels}}}}return f.toTensor()},n.conv2dDerInput=function(t,e,n){TF([t,e],"conv2dDerInput");for(var r=Sy(n.inShape,"float32"),a=r.values,i=this.readSync(t.dataId),o=this.readSync(e.dataId),s=e.strides,u=s[0],c=s[1],l=s[2],h=n.batchSize,f=n.filterHeight,p=n.filterWidth,d=n.inChannels,m=n.inHeight,v=n.inWidth,g=n.outChannels,y=n.outHeight,b=n.outWidth,x=n.strideHeight,w=n.strideWidth,k=n.dataFormat,S=f-1-n.padInfo.top,C=p-1-n.padInfo.left,R="channelsLast"===k,N=r.strides[0],E=R?r.strides[1]:r.strides[2],I=R?r.strides[2]:1,A=R?1:r.strides[1],T=t.strides[0],D=R?t.strides[1]:t.strides[2],_=R?t.strides[2]:1,O=R?1:t.strides[1],F=0;F<h;++F)for(var M=0;M<d;++M)for(var L=0;L<m;++L)for(var z=L-S,B=Math.max(0,Math.ceil(z/x)),P=Math.min(y,(f+z)/x),W=0;W<v;++W){for(var V=W-C,U=Math.max(0,Math.ceil(V/w)),j=Math.min(b,(p+V)/w),G=0,q=B;q<P;++q)for(var H=q*x-z,K=U;K<j;++K)for(var X=T*F+D*q+_*K,Y=u*(f-1-H)+c*(p-1-(K*w-V))+l*M,J=0;J<g;++J){G+=i[X+O*J]*o[Y+J]}a[N*F+E*L+I*W+A*M]=G}return r.toTensor()},n.conv3dDerInput=function(t,e,n){for(var r=Sy(n.inShape,"float32"),a=r.values,i=r.strides,o=i[0],s=i[1],u=i[2],c=i[3],l=this.readSync(t.dataId),h=t.strides,f=h[0],p=h[1],d=h[2],m=h[3],v=this.readSync(e.dataId),g=e.strides,y=g[0],b=g[1],x=g[2],w=g[3],k=n.batchSize,S=n.filterDepth,C=n.filterHeight,R=n.filterWidth,N=n.inChannels,E=n.inDepth,I=n.inHeight,A=n.inWidth,T=n.outChannels,D=n.outDepth,_=n.outHeight,O=n.outWidth,F=n.strideDepth,M=n.strideHeight,L=n.strideWidth,z=S-1-n.padInfo.front,B=C-1-n.padInfo.top,P=R-1-n.padInfo.left,W=0;W<k;++W)for(var V=0;V<N;++V)for(var U=0;U<E;++U)for(var j=U-z,G=Math.max(0,Math.ceil(j/F)),q=Math.min(D,(S+j)/F),H=0;H<I;++H)for(var K=H-B,X=Math.max(0,Math.ceil(K/M)),Y=Math.min(_,(C+K)/M),J=0;J<A;++J){for(var $=J-P,Z=Math.max(0,Math.ceil($/L)),Q=Math.min(O,(R+$)/L),tt=0,et=G;et<q;++et)for(var nt=et*F-j,rt=X;rt<Y;++rt)for(var at=rt*M-K,it=Z;it<Q;++it)for(var ot=f*W+p*et+d*rt+m*it,st=y*(S-1-nt)+b*(C-1-at)+x*(R-1-(it*L-$))+w*V,ut=0;ut<T;++ut){tt+=l[ot+ut]*v[st+ut]}a[o*W+s*U+u*H+c*J+V]=tt}return r.toTensor()},n.conv2dDerFilter=function(t,e,n){TF([t,e],"conv2dDerFilter");for(var r=n.strideHeight,a=n.strideWidth,i=n.filterHeight,o=n.filterWidth,s="channelsLast"===n.dataFormat,u=Sy(n.filterShape,"float32"),c=n.padInfo.left,l=n.padInfo.top,h=this.bufferSync(t),f=this.bufferSync(e),p=0;p<i;++p)for(var d=Math.max(0,Math.ceil((l-p)/r)),m=Math.min(n.outHeight,(n.inHeight+l-p)/r),v=0;v<o;++v)for(var g=Math.max(0,Math.ceil((c-v)/a)),y=Math.min(n.outWidth,(n.inWidth+c-v)/a),b=0;b<n.inChannels;++b)for(var x=0;x<n.outChannels;++x){for(var w=0,k=0;k<n.batchSize;++k)for(var S=d;S<m;++S)for(var C=p+S*r-l,R=g;R<y;++R){var N=v+R*a-c;w+=s?h.get(k,C,N,b)*f.get(k,S,R,x):h.get(k,b,C,N)*f.get(k,x,S,R)}u.set(w,p,v,b,x)}return u.toTensor()},n.conv3dDerFilter=function(t,e,n){for(var r=n.strideDepth,a=n.strideHeight,i=n.strideWidth,o=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=Sy(n.filterShape,"float32"),l=c.values,h=c.strides,f=h[0],p=h[1],d=h[2],m=h[3],v=this.readSync(e.dataId),g=e.strides,y=g[0],b=g[1],x=g[2],w=g[3],k=this.readSync(t.dataId),S=t.strides,C=S[0],R=S[1],N=S[2],E=S[3],I=n.padInfo.front,A=n.padInfo.left,T=n.padInfo.top,D=0;D<o;++D)for(var _=Math.max(0,Math.ceil((I-D)/r)),O=Math.min(n.outDepth,(n.inDepth+I-D)/r),F=D*f,M=0;M<s;++M)for(var L=Math.max(0,Math.ceil((T-M)/a)),z=Math.min(n.outHeight,(n.inHeight+T-M)/a),B=M*p+F,P=0;P<u;++P)for(var W=Math.max(0,Math.ceil((A-P)/i)),V=Math.min(n.outWidth,(n.inWidth+A-P)/i),U=P*d+B,j=0;j<n.inChannels;++j)for(var G=j*m+U,q=0;q<n.outChannels;++q){for(var H=0,K=0;K<n.batchSize;++K)for(var X=K*C,Y=K*y,J=_;J<O;++J)for(var $=(D+J*r-I)*R+X,Z=J*b+Y,Q=L;Q<z;++Q)for(var tt=(M+Q*a-T)*N+$,et=Q*x+Z,nt=W;nt<V;++nt){var rt=nt*w+et;H+=k[(P+nt*i-A)*E+tt+j]*v[rt+q]}l[G+q]=H}return c.toTensor()},n.fusedDepthwiseConv2D=function(t){var e=t.input,n=t.filter,r=t.convInfo,a=t.bias,i=t.activation,o=t.preluActivationWeights,s=this.depthwiseConv2D(e,n,r);return a&&(s=this.add(s,a)),i&&(s=BF(this,s,i,o)),s},n.depthwiseConv2D=function(t,e,n){TF([t,e],"depthwiseConv2D");for(var r=n.filterHeight,a=n.filterWidth,i=n.dilationHeight,o=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c=n.outChannels/n.inChannels,l=Sy(n.outShape,t.dtype),h=this.readSync(t.dataId),f=this.readSync(e.dataId),p=l.values,d=0;d<n.batchSize;++d)for(var m=d*t.strides[0],v=d*l.strides[0],g=0;g<n.outHeight;++g)for(var y=v+g*l.strides[1],b=g*n.strideHeight-s,x=0;x<r;++x){var w=b+x*i;if(!(w<0||w>=n.inHeight))for(var k=x*e.strides[0],S=m+w*t.strides[1],C=0;C<n.outWidth;++C)for(var R=y+C*l.strides[2],N=C*n.strideWidth-u,E=0;E<a;++E){var I=N+E*o;if(!(I<0||I>=n.inWidth))for(var A=k+E*e.strides[1],T=S+I*n.inChannels,D=R,_=A,O=0;O<n.inChannels;++O){for(var F=h[T+O],M=0;M<c;++M)p[D+M]+=F*f[_+M];D+=c,_+=c}}}return l.toTensor()},n.depthwiseConv2DDerInput=function(t,e,n){TF([t,e],"depthwiseConv2DDerInput");for(var r=Sy(n.inShape,"float32"),a=r.values,i=r.strides,o=i[0],s=i[1],u=i[2],c=this.readSync(t.dataId),l=t.strides,h=l[0],f=l[1],p=l[2],d=this.readSync(e.dataId),m=e.strides,v=m[0],g=m[1],y=m[2],b=n.batchSize,x=n.filterHeight,w=n.filterWidth,k=n.inChannels,S=n.inHeight,C=n.inWidth,R=n.outChannels,N=n.outHeight,E=n.outWidth,I=n.strideHeight,A=n.strideWidth,T=x-1-n.padInfo.top,D=w-1-n.padInfo.left,_=R/k,O=0;O<b;++O)for(var F=0;F<k;++F)for(var M=0;M<S;++M)for(var L=M-T,z=Math.max(0,Math.ceil(L/I)),B=Math.min(N,(x+L)/I),P=0;P<C;++P){for(var W=P-D,V=Math.max(0,Math.ceil(W/A)),U=Math.min(E,(w+W)/A),j=0,G=z;G<B;++G)for(var q=G*I-L,H=V;H<U;++H)for(var K=h*O+f*G+p*H,X=v*(x-1-q)+g*(w-1-(H*A-W))+y*F,Y=0;Y<_;++Y){j+=c[K+(F*_+Y)]*d[X+Y]}a[o*O+s*M+u*P+F]=j}return r.toTensor()},n.depthwiseConv2DDerFilter=function(t,e,n){TF([t,e],"depthwiseConv2DDerFilter");for(var r=n.strideHeight,a=n.strideWidth,i=n.filterHeight,o=n.filterWidth,s=Sy(n.filterShape,"float32"),u=n.padInfo.left,c=n.padInfo.top,l=n.outChannels/n.inChannels,h=this.bufferSync(t),f=this.bufferSync(e),p=0;p<i;++p)for(var d=Math.max(0,Math.ceil((c-p)/r)),m=Math.min(n.outHeight,(n.inHeight+c-p)/r),v=0;v<o;++v)for(var g=Math.max(0,Math.ceil((u-v)/a)),y=Math.min(n.outWidth,(n.inWidth+u-v)/a),b=0;b<n.outChannels;++b){for(var x=Math.trunc(b/l),w=b%l,k=0,S=0;S<n.batchSize;++S)for(var C=d;C<m;++C)for(var R=p+C*r-c,N=g;N<y;++N){var E=v+N*a-u;k+=h.get(S,R,E,x)*f.get(S,C,N,b)}s.set(k,p,v,x,w)}return s.toTensor()},n.tile=function(t,e){return TF(t,"tile"),MF(this.bufferSync(t),e)},n.pad=function(t,e,n){TF(t,"pad");var r=e.map((function(e,n){return e[0]+t.shape[n]+e[1]})),a=e.map((function(t){return t[0]})),i=this.bufferSync(t),o=Sy(r,t.dtype);0!==n&&o.values.fill(n);for(var s=0;s<t.size;s++){var u=i.indexToLoc(s),c=u.map((function(t,e){return t+a[e]}));o.set.apply(o,[i.get.apply(i,u)].concat(c))}return o.toTensor()},n.gather=function(t,e,n){TF([t,e],"gather");var r=t.shape.slice(),a=this.readSync(e.dataId);r[n]=a.length;for(var i=Sy(r,t.dtype),o=this.bufferSync(t),s=0;s<i.size;++s){var u=i.indexToLoc(s),c=u.slice();c[n]=a[u[n]];var l=o.locToIndex(c);i.values[s]=o.values[l]}return i.toTensor()},n.batchToSpaceND=function(t,e,n){TF([t],"batchToSpaceND");var r=e.reduce((function(t,e){return t*e})),a=nN(t.shape,e,r),i=rN(a.length,e.length),o=aN(t.shape,e,r),s=iN(n,e.length),u=oN(o,n,e.length);return Bx(t.reshape(a),i).reshape(o).slice(s,u)},n.spaceToBatchND=function(t,e,n){TF([t],"spaceToBatchND");var r=e.reduce((function(t,e){return t*e})),a=[[0,0]];a.push.apply(a,n);for(var i=1+e.length;i<t.shape.length;++i)a.push([0,0]);var o=t.pad(a),s=nN(o.shape,e,r,!1),u=rN(s.length,e.length,!1),c=aN(o.shape,e,r,!1);return Bx(o.reshape(s),u).reshape(c)},n.maxPool=function(t,e){return TF(t,"maxPool"),DF(this.readSync(t.dataId),t.shape,t.dtype,t.strides,e,"max").toTensor()},n.maxPoolBackprop=function(t,e,n,r){TF([e,n],"maxPoolBackprop");for(var a=this.readSync(e.dataId),i=Sy(r.outShape,e.dtype,_F(a,e.shape,e.dtype,r).values),o=r.strideHeight,s=r.strideWidth,u=r.dilationHeight,c=r.dilationWidth,l=r.effectiveFilterHeight,h=r.effectiveFilterWidth,f=h-1-r.padInfo.left,p=l-1-r.padInfo.top,d=Sy(e.shape,"float32"),m=this.bufferSync(t),v=0;v<r.batchSize;++v)for(var g=0;g<r.inChannels;++g)for(var y=0;y<r.inHeight;++y)for(var b=0;b<r.inWidth;++b){for(var x=y-p,w=b-f,k=0,S=0;S<l;S+=u){var C=(x+S)/o;if(!(C<0||C>=r.outHeight||Math.floor(C)!==C))for(var R=0;R<h;R+=c){var N=(w+R)/s;if(!(N<0||N>=r.outWidth||Math.floor(N)!==N)){var E=l*h-1-i.get(v,C,N,g)===S*h+R?1:0;if(0!==E)k+=m.get(v,C,N,g)*E}}}d.set(k,v,y,b,g)}return d.toTensor()},n.avgPoolBackprop=function(t,e,n){TF([t,e],"avgPoolBackprop");for(var r=n.strideHeight,a=n.strideWidth,i=n.filterHeight,o=n.filterWidth,s=n.dilationHeight,u=n.dilationWidth,c=n.effectiveFilterHeight,l=n.effectiveFilterWidth,h=l-1-n.padInfo.left,f=c-1-n.padInfo.top,p=Sy(e.shape,"float32"),d=1/(i*o),m=this.bufferSync(t),v=0;v<n.batchSize;++v)for(var g=0;g<n.inChannels;++g)for(var y=0;y<n.inHeight;++y)for(var b=0;b<n.inWidth;++b){for(var x=y-f,w=b-h,k=0,S=0;S<c;S+=s){var C=(x+S)/r;if(!(C<0||C>=n.outHeight||Math.floor(C)!==C))for(var R=0;R<l;R+=u){var N=(w+R)/a;if(!(N<0||N>=n.outWidth||Math.floor(N)!==N))k+=m.get(v,C,N,g)}}p.set(k*d,v,y,b,g)}return p.toTensor()},n.pool3d=function(t,e,n){TF(t,"pool3d");for(var r=e.strideDepth,a=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,h=e.effectiveFilterWidth,f=e.padInfo.front,p=e.padInfo.top,d=e.padInfo.left,m="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,v=this.readSync(t.dataId),g=Sy(e.outShape,t.dtype),y=g.values,b=e.outShape[1]*e.outShape[2]*e.outShape[3]*e.outShape[4],x=e.outShape[2]*e.outShape[3]*e.outShape[4],w=e.outShape[3]*e.outShape[4],k=e.outShape[4],S=0;S<e.batchSize;++S)for(var C=S*b,R=S*t.strides[0],N=0;N<e.inChannels;++N)for(var E=0;E<e.outDepth;++E){for(var I=E*r-f,A=I;A<0;)A+=o;for(var T=Math.min(e.inDepth,c+I),D=C+E*x,_=0;_<e.outHeight;++_){for(var O=_*a-p,F=O;F<0;)F+=s;for(var M=Math.min(e.inHeight,l+O),L=D+_*w,z=0;z<e.outWidth;++z){for(var B=z*i-d,P=B;P<0;)P+=u;for(var W=Math.min(e.inWidth,h+B),V=L+z*k,U=m,j=0,G=0,q=A;q<T;q+=o){for(var H=R+q*t.strides[1],K=F;K<M;K+=s){for(var X=H+K*t.strides[2],Y=P;Y<W;Y+=u){var J=v[X+Y*t.strides[3]+N];if("max"===n&&J>U?U=J:"avg"===n&&(j+=J,G++),isNaN(U))break}if(isNaN(U))break}if(isNaN(U))break}y[V+N]="avg"===n?j/G:U}}}return g.toTensor()},n.avgPool3d=function(t,e){return TF(t,"avgPool3d"),this.pool3d(t,e,"avg").toFloat()},n.avgPool3dBackprop=function(t,e,n){TF([t,e],"avgPool3dBackprop");for(var r=n.strideDepth,a=n.strideHeight,i=n.strideWidth,o=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=n.dilationDepth,l=n.dilationHeight,h=n.dilationWidth,f=n.effectiveFilterDepth,p=n.effectiveFilterHeight,d=n.effectiveFilterWidth,m=f-1-n.padInfo.front,v=d-1-n.padInfo.left,g=p-1-n.padInfo.top,y=Sy(e.shape,"float32"),b=1/(o*s*u),x=this.bufferSync(t),w=0;w<n.batchSize;++w)for(var k=0;k<n.inChannels;++k)for(var S=0;S<n.inDepth;++S)for(var C=0;C<n.inHeight;++C)for(var R=0;R<n.inWidth;++R){for(var N=S-m,E=C-g,I=R-v,A=0,T=0;T<f;T+=c){var D=(N+T)/r;if(!(D<0||D>=n.outDepth||Math.floor(D)!==D))for(var _=0;_<p;_+=l){var O=(E+_)/a;if(!(O<0||O>=n.outHeight||Math.floor(O)!==O))for(var F=0;F<d;F+=h){var M=(I+F)/i;if(!(M<0||M>=n.outWidth||Math.floor(M)!==M))A+=x.get(w,D,O,M,k)}}}y.set(A*b,w,S,C,R,k)}return y.toTensor()},n.maxPool3d=function(t,e){return TF(t,"maxPool3d"),this.pool3d(t,e,"max").toFloat()},n.maxPool3dPositions=function(t,e){for(var n=Sy(e.outShape,"int32"),r=e.strideDepth,a=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,h=e.effectiveFilterWidth,f=e.padInfo.front,p=e.padInfo.top,d=e.padInfo.left,m=this.bufferSync(t),v=0;v<e.batchSize;++v)for(var g=0;g<e.inChannels;++g)for(var y=0;y<e.outDepth;++y){for(var b=y*r-f,x=b;x<0;)x+=o;for(var w=Math.min(e.inDepth,c+b),k=0;k<e.outHeight;++k){for(var S=k*a-p,C=S;C<0;)C+=s;for(var R=Math.min(e.inHeight,l+S),N=0;N<e.outWidth;++N){for(var E=N*i-d,I=E;I<0;)I+=u;for(var A=Math.min(e.inWidth,h+E),T=Number.NEGATIVE_INFINITY,D=-1,_=x;_<w;_+=o)for(var O=_-b,F=C;F<R;F+=s)for(var M=F-S,L=I;L<A;L+=u){var z=L-E,B=m.get(v,_,F,L,g);B>=T&&(T=B,D=O*l*h+M*l+z)}n.set(D,v,y,k,N,g)}}}return n.toTensor()},n.maxPool3dBackprop=function(t,e,n,r){TF([e,n],"maxPool3dBackprop");for(var a=this.maxPool3dPositions(e,r),i=r.strideDepth,o=r.strideHeight,s=r.strideWidth,u=r.dilationDepth,c=r.dilationHeight,l=r.dilationWidth,h=r.effectiveFilterDepth,f=r.effectiveFilterHeight,p=r.effectiveFilterWidth,d=h-1-r.padInfo.front,m=p-1-r.padInfo.left,v=f-1-r.padInfo.top,g=Sy(e.shape,"float32"),y=this.bufferSync(a),b=this.bufferSync(t),x=0;x<r.batchSize;++x)for(var w=0;w<r.inChannels;++w)for(var k=0;k<r.inDepth;++k)for(var S=0;S<r.inHeight;++S)for(var C=0;C<r.inWidth;++C){for(var R=k-d,N=S-v,E=C-m,I=0,A=0;A<h;A+=u){var T=(R+A)/i;if(!(T<0||T>=r.outDepth||Math.floor(T)!==T))for(var D=0;D<f;D+=c){var _=(N+D)/o;if(!(_<0||_>=r.outHeight||Math.floor(_)!==_))for(var O=0;O<p;O+=l){var F=(E+O)/s;if(!(F<0||F>=r.outWidth||Math.floor(F)!==F)){var M=h*f*p-1-y.get(x,T,_,F,w)===A*f*p+D*p+O?1:0;if(0!==M)I+=b.get(x,T,_,F,w)*M}}}}g.set(I,x,k,S,C,w)}return g.toTensor()},n.cast=function(t,e){return vN(t,e,this)},n.reshape=function(t,e){return gN(t,e)},n.avgPool=function(t,e){return TF(t,"avgPool"),TF(t,"maxPool"),DF(this.readSync(t.dataId),t.shape,t.dtype,t.strides,e,"avg").toTensor().toFloat()},n.resizeBilinear=function(t,e,n,r){TF(t,"resizeBilinear");for(var a=t.shape,i=a[0],o=a[1],s=a[2],u=a[3],c=this.readSync(t.dataId),l=new Float32Array(wv([i,e,n,u])),h=[r&&e>1?o-1:o,r&&n>1?s-1:s],f=[r&&e>1?e-1:e,r&&n>1?n-1:n],p=0,d=h[0]/f[0],m=h[1]/f[1],v=0;v<i;v++)for(var g=0;g<e;g++)for(var y=d*g,b=Math.floor(y),x=y-b,w=Math.min(o-1,Math.ceil(y)),k=v*t.strides[0]+b*t.strides[1],S=v*t.strides[0]+w*t.strides[1],C=0;C<n;C++)for(var R=m*C,N=Math.floor(R),E=R-N,I=Math.min(s-1,Math.ceil(R)),A=k+N*t.strides[2],T=S+N*t.strides[2],D=k+I*t.strides[2],_=S+I*t.strides[2],O=0;O<u;O++){var F=c[A+O],M=c[T+O],L=F+(c[D+O]-F)*E,z=L+(M+(c[_+O]-M)*E-L)*x;l[p++]=z}return ay(l,[i,e,n,u])},n.resizeBilinearBackprop=function(t,e,n){TF([t,e],"resizeBilinearBackprop");for(var r=e.shape,a=r[0],i=r[1],o=r[2],s=r[3],u=t.shape,c=u[1],l=u[2],h=new Float32Array(a*i*o*s),f=[n&&c>1?i-1:i,n&&l>1?o-1:o],p=[n&&c>1?c-1:c,n&&l>1?l-1:l],d=f[0]/p[0],m=f[1]/p[1],v=this.readSync(t.dataId),g=0,y=0;y<a;y++)for(var b=y*e.strides[0],x=0;x<c;x++)for(var w=x*d,k=Math.floor(w),S=Math.min(Math.ceil(w),i-1),C=b+k*e.strides[1],R=b+S*e.strides[1],N=w-k,E=1-N,I=0;I<l;I++)for(var A=I*m,T=Math.floor(A),D=Math.min(Math.ceil(A),o-1),_=A-T,O=1-_,F=C+T*e.strides[2],M=C+D*e.strides[2],L=R+T*e.strides[2],z=R+D*e.strides[2],B=E*O,P=E*_,W=N*O,V=N*_,U=0;U<s;U++){var j=v[g++];h[F+U]+=j*B,h[M+U]+=j*P,h[L+U]+=j*W,h[z+U]+=j*V}return ly(h,[a,o,i,s],e.dtype)},n.resizeNearestNeighbor=function(t,e,n,r){TF(t,"resizeNearestNeighbor");for(var a=t.shape,i=a[0],o=a[1],s=a[2],u=a[3],c=this.readSync(t.dataId),l=new Float32Array(i*e*n*u),h=[r&&e>1?o-1:o,r&&n>1?s-1:s],f=[r&&e>1?e-1:e,r&&n>1?n-1:n],p=h[0]/f[0],d=h[1]/f[1],m=0,v=0;v<i;v++)for(var g=v*t.strides[0],y=0;y<e;y++)for(var b=p*y,x=g+Math.min(o-1,r?Math.round(b):Math.floor(b))*t.strides[1],w=0;w<n;w++)for(var k=d*w,S=x+Math.min(s-1,r?Math.round(k):Math.floor(k))*t.strides[2],C=0;C<u;C++){var R=c[S+C];l[m++]=R}return ay(l,[i,e,n,u],t.dtype)},n.resizeNearestNeighborBackprop=function(t,e,n){TF([t,e],"resizeNearestNeighborBackprop");for(var r=e.shape,a=r[0],i=r[1],o=r[2],s=r[3],u=t.shape,c=u[1],l=u[2],h=new Float32Array(a*i*o*s),f=this.readSync(t.dataId),p=[n&&c>1?i-1:i,n&&l>1?o-1:o],d=[n&&c>1?c-1:c,n&&l>1?l-1:l],m=p[0]/d[0],v=p[1]/d[1],g=1/m,y=1/v,b=2*Math.ceil(g)+2,x=2*Math.ceil(y)+2,w=0;w<a;w++)for(var k=w*e.strides[0],S=0;S<i;S++)for(var C=k+S*e.strides[1],R=Math.floor(S*g),N=Math.floor(R-b/2),E=0;E<o;E++)for(var I=C+E*e.strides[2],A=Math.floor(E*y),T=Math.floor(A-x/2),D=0;D<s;D++){for(var _=0,O=0;O<b;O++){var F=O+N;if(!(F<0||F>=c)){var M=k+F*t.strides[1],L=F*m;if(S===Math.min(i-1,n?Math.round(L):Math.floor(L)))for(var z=0;z<x;z++){var B=z+T;if(!(B<0||B>=l)){var P=M+B*t.strides[2],W=B*v;E===Math.min(o-1,n?Math.round(W):Math.floor(W))&&(_+=f[P+D])}}}}h[I+D]=_}return ly(h,e.shape,e.dtype)},n.batchNorm=function(t,e,n,r,a,i){TF([t,e,n,a,r],"batchNorm");for(var o=this.readSync(t.dataId),s=this.readSync(e.dataId),u=this.readSync(n.dataId),c=a?this.readSync(a.dataId):new Float32Array([1]),l=r?this.readSync(r.dataId):new Float32Array([0]),h=new Float32Array(o.length),f=l.length,p=c.length,d=u.length,m=s.length,v=0,g=0,y=0,b=0,x=0;x<o.length;++x)h[x]=l[v++]+(o[x]-s[g++])*c[y++]/Math.sqrt(u[b++]+i),v>=f&&(v=0),g>=m&&(g=0),y>=p&&(y=0),b>=d&&(b=0);return ly(h,t.shape)},n.localResponseNormalization4D=function(t,e,n,r,a){TF(t,"localResponseNormalization4D");var i=t.shape[3],o=i-1,s=this.readSync(t.dataId),u=t.size,c=new Float32Array(u);function l(t){for(var n=t%i,r=t-n+Math.max(0,n-e),a=t-n+Math.min(n+e,o),u=0;r<=a;r++){var c=s[r];u+=c*c}return u}for(var h=0;h<u;h++){var f=l(h),p=s[h]*Math.pow(n+r*f,-a);c[h]=p}return ly(c,t.shape)},n.LRNGrad=function(t,e,n,r,a,i,o){TF(t,"LRNGrad");for(var s=t.shape[3],u=this.readSync(t.dataId),c=this.readSync(e.dataId),l=this.readSync(n.dataId),h=new Float32Array(t.size),f=t.size,p=0;p<f;p++){for(var d=p%s,m=p-d+Math.max(0,d-r),v=p-d+Math.min(s,d+r+1),g=0,y=m;y<v;y++)g+=Math.pow(c[y],2);g=i*g+a;for(var b=m;b<v;b++){var x=-2*i*o*c[b]*l[p]/g;p===b&&(x+=Math.pow(g,-o)),x*=u[p],h[b]+=x}}return ly(h,t.shape)},n.multinomial=function(t,e,n,r){TF(t,"multinomial");for(var a=e?t:AC(t),i=a.shape[0],o=a.shape[1],s=my([i,n],"int32"),u=this.readSync(s.dataId),c=this.readSync(a.dataId),l=0;l<i;++l){var h=l*o,f=new Float32Array(o-1);f[0]=c[h];for(var p=1;p<f.length;++p)f[p]=f[p-1]+c[h+p];for(var d=BS(r.toString()),m=l*n,v=0;v<n;++v){var g=d();u[m+v]=f.length;for(var y=0;y<f.length;y++)if(g<f[y]){u[m+v]=y;break}}}return s},n.oneHot=function(t,e,n,r){TF(t,"oneHot");var a=new Float32Array(t.size*e);a.fill(r);for(var i=this.readSync(t.dataId),o=0;o<t.size;++o)i[o]>=0&&i[o]<e&&(a[o*e+i[o]]=n);return uy(a,[t.size,e],"int32")},n.nonMaxSuppression=function(t,e,n,r,a){TF(t,"nonMaxSuppression");var i=this.readSync(t.dataId),o=this.readSync(e.dataId);return OF(i,o,n,r,a)},n.fft=function(t){return this.fftBatch(t,!1)},n.ifft=function(t){return this.fftBatch(t,!0)},n.fftBatch=function(t,e){for(var n=t.shape[0],r=t.shape[1],a=Sy(t.shape,"float32"),i=Sy(t.shape,"float32"),o=ny(t).as2D(n,r),s=ry(t).as2D(n,r),u=0;u<n;u++)for(var c=o.slice([u,0],[1,r]),l=s.slice([u,0],[1,r]),h=ey(c,l),f=this.readSync(this.fftImpl(h,e).dataId),p=0;p<r;p++){var d=fN(f,p);a.values[u*r+p]=d.real,i.values[u*r+p]=d.imag}return ey(a.toTensor(),i.toTensor()).as2D(n,r)},n.fftImpl=function(t,e){var n=t.as1D(),r=n.size;if(this.isExponentOf2(r)){var a=this.fftRadix2(n,r,e).as2D(t.shape[0],t.shape[1]);return e&&(a=ey(ny(a).div(oy(r)),ry(a).div(oy(r)))),a}var i=this.readSync(t.dataId),o=cN(this.fourierTransformByMatmul(i,r,e));return ey(o.real,o.imag).as2D(t.shape[0],t.shape[1])},n.isExponentOf2=function(t){return 0==(t&t-1)},n.fftRadix2=function(t,e,n){if(1===e)return t;var r=this.readSync(t.dataId),a=e/2,i=lN(r),o=ey(i.real,i.imag).as1D(),s=hN(r),u=ey(s.real,s.imag).as1D();o=this.fftRadix2(o,a,n),u=this.fftRadix2(u,a,n);var c=dN(e,n),l=ey(c.real,c.imag).mul(u),h=o.add(l),f=o.sub(l),p=ny(h).concat(ny(f)),d=ry(h).concat(ry(f));return ey(p,d).as1D()},n.fourierTransformByMatmul=function(t,e,n){for(var r=new Float32Array(2*e),a=0;a<e;a++){for(var i=0,o=0,s=0;s<e;s++){var u=mN(a*s,e,n),c=fN(t,s);i+=c.real*u.real-c.imag*u.imag,o+=c.real*u.imag+c.imag*u.real}n&&(i/=e,o/=e),pN(r,i,o,a)}return r},n.depthToSpace=function(t,e,n){gv("NHWC"===n,(function(){return"Only NHWC dataFormat supported on CPU for depthToSpace. Got "+n})),gv(e>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+e}));for(var r=t.shape[0],a=t.shape[1],i=t.shape[2],o=t.shape[3],s=a*e,u=i*e,c=o/(e*e),l=this.readSync(t.dataId),h=new Float32Array(r*s*u*c),f=0,p=0;p<r;++p)for(var d=0;d<s;++d)for(var m=Math.floor(d/e),v=d%e,g=0;g<u;++g)for(var y=Math.floor(g/e),b=(v*e+g%e)*c,x=0;x<c;++x){var w=x+b+o*(y+i*(m+a*p));h[f++]=l[w]}return ly(h,[r,s,u,c])},n.broadcastedBinaryOp=function(t,e,n,r){var a=zg(t.shape,e.shape),i=Sy(a,n),o=this.readSync(t.dataId),s=this.readSync(e.dataId),u=Mg(t.shape,a),c=Mg(e.shape,a),l=i.values;if(u.length+c.length===0)for(var h=0;h<l.length;++h)l[h]=r(o[h%o.length],s[h%s.length]);else for(var f=this.bufferSync(t),p=this.bufferSync(e),d=function(n){var a=i.indexToLoc(n),h=a.slice(-t.rank);u.forEach((function(t){return h[t]=0}));var d=f.locToIndex(h),m=a.slice(-e.rank);c.forEach((function(t){return m[t]=0}));var v=p.locToIndex(m);l[n]=r(o[d],s[v])},m=0;m<l.length;++m)d(m);return i.toTensor()},n.broadcastedBinaryComplexOp=function(t,e,n){var r=zg(t.shape,e.shape),a=Sy(r,"float32"),i=Sy(r,"float32"),o=this.readSync(t.dataId),s=this.readSync(e.dataId),u=Mg(t.shape,r),c=Mg(e.shape,r),l=a.values,h=i.values;if(u.length+c.length===0)for(var f=0;f<l.length;f++){var p=f%o.length,d=f%s.length,m=n(o[2*p],o[2*p+1],s[2*d],s[2*d+1]);l[f]=m.real,h[f]=m.imag}else for(var v=this.bufferSync(this.data.get(t.dataId).complexTensors.real),g=this.bufferSync(this.data.get(e.dataId).complexTensors.real),y=function(r){var i=a.indexToLoc(r),f=i.slice(-t.rank);u.forEach((function(t){return f[t]=0}));var p=v.locToIndex(f),d=i.slice(-e.rank);c.forEach((function(t){return d[t]=0}));var m=g.locToIndex(d),y=n(o[2*p],o[2*p+1],s[2*m],s[2*m+1]);l[r]=y.real,h[r]=y.imag},b=0;b<l.length;b++)y(b);return this.complex(a.toTensor(),i.toTensor())},n.split=function(t,e,n){return FF(t,e,n)},n.dispose=function(){},n.floatPrecision=function(){return 32},n.epsilon=function(){return t.prototype.epsilon.call(this)},n.cropAndResize=function(t,e,n,r,a,i){for(var o=t.shape,s=o[0],u=o[1],c=o[2],l=o[3],h=e.shape[0],f=r[0],p=r[1],d=Sy([h,f,p,l],"float32"),m=this.readSync(e.dataId),v=this.readSync(n.dataId),g=this.readSync(t.dataId),y=t.strides,b=d.strides,x=0;x<h;x++){var w=4*x,k=m[w],S=m[w+1],C=m[w+2],R=m[w+3],N=v[x];if(!(N>=s))for(var E=f>1?(C-k)*(u-1)/(f-1):0,I=p>1?(R-S)*(c-1)/(p-1):0,A=0;A<f;A++){var T=f>1?k*(u-1)+A*E:.5*(k+C)*(u-1);if(T<0||T>u-1)for(var D=0;D<p;D++)for(var _=0;_<l;_++){var O=_+D*b[2]+A*b[1]+x*b[0];d.values[O]=i}else if("bilinear"===a)for(var F=Math.floor(T),M=Math.ceil(T),L=T-F,z=0;z<p;z++){var B=p>1?S*(c-1)+z*I:.5*(S+R)*(c-1);if(B<0||B>c-1)for(var P=0;P<l;P++){var W=P+z*b[2]+A*b[1]+x*b[0];d.values[W]=i}else for(var V=Math.floor(B),U=Math.ceil(B),j=B-V,G=0;G<l;G++){var q=G+V*y[2]+F*y[1]+N*y[0],H=g[q],K=g[q=G+U*y[2]+F*y[1]+N*y[0]],X=g[q=G+V*y[2]+M*y[1]+N*y[0]],Y=H+(K-H)*j,J=X+(g[q=G+U*y[2]+M*y[1]+N*y[0]]-X)*j;q=G+z*b[2]+A*b[1]+x*b[0],d.values[q]=Y+(J-Y)*L}}else for(var $=0;$<p;++$){var Z=p>1?S*(c-1)+$*I:.5*(S+R)*(c-1);if(Z<0||Z>c-1)for(var Q=0;Q<l;Q++){var tt=Q+$*b[2]+A*b[1]+x*b[0];d.values[tt]=i}else for(var et=Math.round(Z),nt=Math.round(T),rt=0;rt<l;rt++){var at=rt+et*y[2]+nt*y[1]+N*y[0],it=rt+$*b[2]+A*b[1]+x*b[0];d.values[it]=g[at]}}}}return d.toTensor()},n.sparseToDense=function(t,e,n,r){var a=Tk(0,t,n),i=a.sliceRank,o=a.numUpdates,s=a.sliceSize,u=a.strides,c=a.outputSize;return this.scatter(t,e,n,c,s,o,i,u,r,!1)},n.gatherND=function(t,e){var n=e.shape,r=n[n.length-1],a=Nk(t,e),i=a[0],o=a[1],s=a[2],u=a[3];if(0===o)return ay([],i,t.dtype);for(var c=new lg([o,s],t.dtype),l=this.readSync(e.dataId),h=this.readSync(t.dataId),f=0;f<o;f++){for(var p=[],d=0,m=0;m<r;m++){var v=l[f*r+m];d+=v*u[m],p.push(v)}if(d<0||d>=t.size/s)throw new Error("Invalid indices: "+p+" does not index into "+t.shape);for(var g=0;g<s;g++)c.values[f*s+g]=h[d*s+g]}return c.toTensor().reshape(i)},n.scatterND=function(t,e,n){var r=Tk(0,t,n),a=r.sliceRank,i=r.numUpdates,o=r.sliceSize,s=r.strides,u=r.outputSize,c=oy(0);return this.scatter(t,e,n,u,o,i,a,s,c,!0)},n.fill=function(t,e,n){var r=_v(n=n||Uv(e),wv(t));return r.fill(e),Cb().makeTensor(r,t,n,this)},n.onesLike=function(t){if("string"===t.dtype)throw new Error("onesLike is not supported for string tensors");return this.fill(t.shape,1,t.dtype)},n.zerosLike=function(t){var e=_v(t.dtype,wv(t.shape));return this.makeOutput(e,t.shape,t.dtype)},n.linspace=function(t,e,n){return yN(t,e,n)},n.scatter=function(t,e,n,r,a,i,o,s,u,c){var l=[r/a,a],h=this.readSync(t.dataId),f=this.readSync(e.dataId);if(0===r)return ay([],n,e.dtype);var p=new lg(l,e.dtype);p.values.fill(this.readSync(u.dataId)[0]);for(var d=0;d<i;d++){for(var m=[],v=0,g=0;g<o;g++){var y=h[d*o+g];m.push(y),v+=y*s[g]}if(v<0||v>=r/a)throw new Error("Invalid indices: "+m+" does not index into "+n);for(var b=0;b<a;b++)c?p.values[v*a+b]+=f[d*a+b]:p.values[v*a+b]=0===e.rank?f[0]:f[d*a+b]}return p.toTensor().reshape(n)},e}(NN);function WF(t,e){return{kernelName:t,backendName:"cpu",kernelFunc:function(n){var r=n.inputs,a=n.backend,i=r.a,o=r.b,s=a;TF([i,o],t);var u=s.data.get(i.dataId).values,c=s.data.get(o.dataId).values,l=e(i.shape,o.shape,u,c,i.dtype),h=l[0],f=l[1];return{dataId:s.write(h,f,i.dtype),shape:f,dtype:i.dtype}}}}function VF(t){return function(e,n,r,a,i){var o=zg(e,n),s=o.length,u=qv(o),c=Dv(i,wv(o)),l=e.length,h=n.length,f=qv(e),p=qv(n),d=Mg(e,o),m=Mg(n,o);if(d.length+m.length===0)for(var v=0;v<c.length;++v)c[v]=t(r[v%r.length],a[v%a.length]);else for(var g=function(e){var n=ng(e,s,u),i=n.slice(-l);d.forEach((function(t){return i[t]=0}));var o=eg(i,l,f),v=n.slice(-h);m.forEach((function(t){return v[t]=0}));var g=eg(v,h,p);c[e]=t(r[o],a[g])},y=0;y<c.length;++y)g(y);return[c,o]}}var UF=WF("Div",VF((function(t,e){return t/e}))),jF={kernelName:"Max",backendName:"cpu",kernelFunc:function(t){var e=t.inputs,n=t.attrs,r=t.backend,a=e.x,i=n.reductionIndices,o=r,s=a.shape,u=s.length,c=Av(i,s),l=Yg(c,u),h=o.data.get(a.dataId).values;if(null!=l){for(var f=new Array(u),p=0;p<f.length;p++)f[p]=s[l[p]];h=AF(h,s,a.dtype,l,f),c=$g(c.length,u),s=f}TF(a,"max"),Xg("max",c,u);var d=Hg(s,c),m=d[0],v=IF(h,wv(d[1]),m,a.dtype);return{dataId:o.write(v,m,a.dtype),shape:m,dtype:a.dtype}}};for(var GF={kernelName:"MaxPoolWithArgmax",backendName:"cpu",kernelFunc:function(t){var e=t.inputs,n=t.attrs,r=t.backend,a=e.x,i=n.filterSize,o=n.strides,s=n.pad,u=n.includeBatchInIndex,c=r;TF(a,"MaxPoolWithArgmax");var l=c.data.get(a.dataId).values,h=tb(a.shape,i,o,[1,1],s),f=function(t,e,n,r,a){var i=DF(t,0,n,qv(e),a,"max"),o=_F(t,e,n,a,!0,r);return[i.values,o.values]}(l,a.shape,a.dtype,u,h),p=f[0],d=f[1],m=c.write(p,h.outShape,a.dtype),v=c.write(d,h.outShape,a.dtype);return[{dataId:m,shape:h.outShape,dtype:a.dtype},{dataId:v,shape:h.outShape,dtype:"int32"}]}},qF=bR,HF=0,KF=[{kernelName:"NonMaxSuppressionV5",backendName:"cpu",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=t.attrs,a=e.boxes,i=e.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,c=r.softNmsSigma,l=n;TF(a,"NonMaxSuppressionWithScore");var h=l.data.get(a.dataId).values,f=l.data.get(i.dataId).values,p=qF(h,f,o,s,u,c);return[p.selectedIndices,p.selectedScores]}},{kernelName:"Square",backendName:"cpu",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=e.x,a=n;TF(r,"square");for(var i=a.data.get(r.dataId).values,o=new Float32Array(i.length),s=0;s<i.length;++s){var u=i[s];o[s]=u*u}return{dataId:a.write(o,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},WF("SquaredDifference",VF((function(t,e){var n=t-e;return n*n}))),UF,{kernelName:"Transpose",backendName:"cpu",kernelFunc:function(t){var e=t.inputs,n=t.attrs,r=t.backend,a=e.x,i=n.perm,o=r;TF(a,"transpose");for(var s=a.shape.length,u=new Array(s),c=0;c<u.length;c++)u[c]=a.shape[i[c]];var l=AF(o.data.get(a.dataId).values,a.shape,a.dtype,i,u);return{dataId:o.write(l,u,a.dtype),shape:u,dtype:a.dtype}}},GF,jF];HF<KF.length;HF++){lv(KF[HF])}Ab("cpu",(function(){return new PF}),1);var XF,YF,JF,$F={},ZF={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function QF(t){t in $F||($F[t]=function(t){if(1!==t&&2!==t)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var e=function(t){if("undefined"!=typeof OffscreenCanvas&&2===t)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(t);if(e.addEventListener("webglcontextlost",(function(e){e.preventDefault(),delete $F[t]}),!1),1===t)return e.getContext("webgl",ZF)||e.getContext("experimental-webgl",ZF);return e.getContext("webgl2",ZF)}(t));var e=$F[t];return e.isContextLost()?(delete $F[t],QF(t)):(e.disable(e.DEPTH_TEST),e.disable(e.STENCIL_TEST),e.disable(e.BLEND),e.disable(e.DITHER),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SAMPLE_COVERAGE),e.enable(e.SCISSOR_TEST),e.enable(e.CULL_FACE),e.cullFace(e.BACK),$F[t])}function tM(t,e){return[e,t]}function eM(t){var e=wv(t);return Rv(Math.ceil(e/4))}function nM(t,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))]}function rM(t,e){var n,r,a,i,o,s,u,c,l,h=t;return 2===nv().getNumber("WEBGL_VERSION")?(n=h.R32F,r=h.R16F,a=h.RGBA16F,i=h.RGBA32F,o=h.RED,s=4,u=1,c=h.HALF_FLOAT,l=h.FLOAT):(n=t.RGBA,r=t.RGBA,a=t.RGBA,i=h.RGBA,o=t.RGBA,s=4,u=4,c=null!=e?e.HALF_FLOAT_OES:null,l=t.FLOAT),{internalFormatFloat:n,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:i,textureFormatFloat:o,downloadTextureFormat:t.RGBA,downloadUnpackNumChannels:s,defaultNumChannels:u,textureTypeHalfFloat:c,textureTypeFloat:l}}function aM(t,e,n){var r=n();return e&&function(t){var e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+function(t,e){switch(e){case t.NO_ERROR:return"NO_ERROR";case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"Unknown error code "+e}}(t,e))}(t),r}!function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH"}(XF||(XF={})),function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD"}(YF||(YF={})),function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(JF||(JF={}));function iM(t){return!!(nv().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===t||5.96e-8<Math.abs(t)&&Math.abs(t)<65504)}function oM(t,e,n){return gM(t,e,(function(){return t.getExtension(n)}),'Extension "'+n+'" not supported on this browser.')}function sM(t,e,n){var r=gM(t,e,(function(){return t.createShader(t.FRAGMENT_SHADER)}),"Unable to create fragment WebGLShader.");if(aM(t,e,(function(){return t.shaderSource(r,n)})),aM(t,e,(function(){return t.compileShader(r)})),!1===t.getShaderParameter(r,t.COMPILE_STATUS))throw function(t,e){var n=lM.exec(e);if(null==n)return console.log("Couldn't parse line number in error: "+e),void console.log(t);for(var r=+n[1],a=t.split("\n"),i=a.length.toString().length+2,o=a.map((function(t,e){return Nv((e+1).toString(),i)+t})),s=0,u=0;u<o.length;u++)s=Math.max(o[u].length,s);var c=o.slice(0,r-1),l=o.slice(r-1,r),h=o.slice(r);console.log(c.join("\n")),console.log(e.split("\n")[0]),console.log("%c "+Nv(l[0],s),"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(h.join("\n"))}(n,t.getShaderInfoLog(r)),new Error("Failed to compile fragment shader.");return r}var uM,cM,lM=/ERROR: [0-9]+:([0-9]+):/g;function hM(t,e,n){if(aM(t,e,(function(){return t.validateProgram(n)})),!1===t.getProgramParameter(n,t.VALIDATE_STATUS))throw console.log(t.getProgramInfoLog(n)),new Error("Shader program validation failed.")}function fM(t,e,n,r,a,i,o,s){var u=t.getAttribLocation(n,r);return-1!==u&&(aM(t,e,(function(){return t.bindBuffer(t.ARRAY_BUFFER,a)})),aM(t,e,(function(){return t.vertexAttribPointer(u,i,t.FLOAT,!1,o,s)})),aM(t,e,(function(){return t.enableVertexAttribArray(u)})),!0)}function pM(t,e,n,r){!function(t,e){var n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=e+t.TEXTURE0;if(r<t.TEXTURE0||r>n){throw new Error("textureUnit must be in "+("[gl.TEXTURE0, gl.TEXTURE"+n+"]")+".")}}(t,r),aM(t,e,(function(){return t.activeTexture(t.TEXTURE0+r)})),aM(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,n)}))}function dM(t,e,n,r){aM(t,e,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,r)})),aM(t,e,(function(){return t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0)}))}function mM(t,e,n){aM(t,e,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,n)})),aM(t,e,(function(){return t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0)}))}function vM(t){var e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+e}}(t,e))}function gM(t,e,n,r){var a=aM(t,e,(function(){return n()}));if(null==a)throw new Error(r);return a}function yM(t,e){return void 0===e&&(e=2),wv(t.slice(0,t.length-e))}function bM(t){if(0===t.length)throw Error("Cannot get rows and columns of an empty shape array.");return[t.length>1?t[t.length-2]:1,t[t.length-1]]}function xM(t){var e=[1,1,1];return 0===t.length||1===t.length&&1===t[0]||(e=[yM(t)].concat(bM(t))),e}function wM(t){return t%2==0}function kM(t,e){if(kv(t=t.slice(-2),e=e.slice(-2)))return!0;if(!t.length||!e.length)return!0;if(0===t[0]||0===t[1]||0===e[0]||0===e[1])return!0;if(t.length!==e.length){var n=t.slice(-1)[0],r=e.slice(-1)[0];if(n===r)return!0;if(wM(n)&&wM(r)&&(1===t[0]||1===e[0]))return!0}return t[1]===e[1]&&wM(t[0])&&wM(e[0])}function SM(t,e){return null!=t.getExtension(e)}function CM(t){try{if(null!=QF(t))return!0}catch(t){return!1}return!1}function RM(t){if(0===t)return!1;var e=QF(t);if(1!==t){if(SM(e,"EXT_color_buffer_float"))return NM(e);if(SM(e,"EXT_color_buffer_half_float")){var n=e.getExtension("EXT_color_buffer_half_float");return function(t,e){var n=rM(t,e),r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r);t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);var a=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,a),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var i=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(r),t.deleteFramebuffer(a),i}(e,n)}return!1}return!!SM(e,"OES_texture_float")&&(!!SM(e,"WEBGL_color_buffer_float")&&NM(e))}function NM(t){var e=rM(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n);t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);var r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);var a=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(r),a}var EM=nv();EM.registerFlag("HAS_WEBGL",(function(){return EM.getNumber("WEBGL_VERSION")>0})),EM.registerFlag("WEBGL_VERSION",(function(){return CM(2)?2:CM(1)?1:0})),EM.registerFlag("WEBGL_BUFFER_SUPPORTED",(function(){return 2===EM.get("WEBGL_VERSION")})),EM.registerFlag("WEBGL_CPU_FORWARD",(function(){return!0})),EM.registerFlag("WEBGL_FORCE_F16_TEXTURES",(function(){return!1})),EM.registerFlag("WEBGL_PACK",(function(){return EM.getBool("HAS_WEBGL")})),EM.registerFlag("WEBGL_PACK_NORMALIZATION",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_PACK_CLIP",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_PACK_DEPTHWISECONV",(function(){return!1})),EM.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_PACK_REDUCE",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_LAZILY_UNPACK",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_CONV_IM2COL",(function(){return EM.getBool("WEBGL_PACK")})),EM.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(function(){return function(t){if(null==uM){var e=QF(t);uM=e.getParameter(e.MAX_TEXTURE_SIZE)}return uM}(EM.getNumber("WEBGL_VERSION"))})),EM.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(function(){return function(t){if(null==cM){var e=QF(t);cM=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,cM)}(EM.getNumber("WEBGL_VERSION"))})),EM.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(function(){var t=EM.getNumber("WEBGL_VERSION");return 0===t?0:function(t){if(0===t)return 0;var e=QF(t);return SM(e,"EXT_disjoint_timer_query_webgl2")&&2===t?2:SM(e,"EXT_disjoint_timer_query")?1:0}(t)})),EM.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(function(){return EM.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Dg()})),EM.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(function(){return function(t){if(0===t)return!1;var e=QF(t);if(1===t){if(!SM(e,"OES_texture_float"))return!1}else if(!SM(e,"EXT_color_buffer_float"))return!1;return NM(e)}(EM.getNumber("WEBGL_VERSION"))})),EM.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(function(){return!EM.getBool("WEBGL_FORCE_F16_TEXTURES")&&EM.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")})),EM.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(function(){return RM(EM.getNumber("WEBGL_VERSION"))})),EM.registerFlag("WEBGL_FENCE_API_ENABLED",(function(){return 2===(t=EM.getNumber("WEBGL_VERSION"))&&null!=QF(t).fenceSync;var t})),EM.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(function(){return EM.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0}));var IM=function(t,e){this.outputShape=[],this.outputShape=t,this.variableNames=e.map((function(t,e){return"T"+e}));var n=[];this.variableNames.forEach((function(t){n.push("float v"+t+" = get"+t+"AtOutCoords();")}));var r=this.variableNames.map((function(t){return"v"+t})).join(" + ");this.userCode="\n void main() {\n "+n.join("\n ")+"\n\n float result = "+r+";\n setOutput(result);\n }\n "},AM=function(t,e){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.variableNames=e.map((function(t,e){return"T"+e}));var n=[];this.variableNames.forEach((function(t){n.push("vec4 v"+t+" = get"+t+"AtOutCoords();")}));var r=this.variableNames.map((function(t){return"v"+t})).join(" + ");this.userCode="\n void main() {\n "+n.join("\n ")+"\n\n vec4 result = "+r+";\n setOutput(result);\n }\n "},TM=function(t,e,n){this.variableNames=["A"];var r=t.windowSize,a=t.batchSize,i=t.inSize,o=Math.ceil(i/r);n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,o];var s="max"===e?">":"<",u=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * "+r+";\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < "+r+"; i++) {\n int inIdx = "+u+";\n float candidate = getA(batch, inIdx);\n if (candidate "+s+" bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n "};function DM(t,e){return["x","y","z","w","u","v"].slice(0,e).map((function(e){return t+"."+e}))}function _M(t,e){return 1===e?[t]:DM(t,e)}function OM(){var t,e,n,r,a,i,o,s,u,c;return 2===nv().getNumber("WEBGL_VERSION")?(t="#version 300 es",e="in",n="out",r="in",a="texture",i="outputColor",o="out vec4 outputColor;",s="\n bool isnan_custom(float val) {\n return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ",u="",c="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(t="",e="attribute",n="varying",r="varying",a="texture2D",i="gl_FragColor",o="",s="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",u="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",c="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:t,attribute:e,varyingVs:n,varyingFs:r,texture2D:a,output:i,defineOutput:o,defineSpecialNaN:s,defineSpecialInf:u,defineRound:c}}function FM(t,e,n){void 0===n&&(n="index");var r=qv(e);return r.map((function(e,a){return"int "+t[a]+" = "+n+" / "+e+"; "+(a===r.length-1?"int "+t[a+1]+" = "+n+" - "+t[a]+" * "+e:"index -= "+t[a]+" * "+e)+";"})).join("")}function MM(t){var e=qv(t).map((function(t){return t.toString()}));return"\n int getFlatIndex(ivec3 coords) {\n return coords.x * "+e[0]+" + coords.y * "+e[1]+" + coords.z;\n }\n"}var LM="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n",zM=Mg;function BM(t,e,n,r){var a=[];t.forEach((function(t){var e=wv(t.shapeInfo.logicalShape);t.shapeInfo.isUniform?a.push("uniform float "+t.name+(e>1?"["+e+"]":"")+";"):(a.push("uniform sampler2D "+t.name+";"),a.push("uniform int offset"+t.name+";"))}));var i,o,s=a.join("\n"),u=t.map((function(t){return function(t,e,n){void 0===n&&(n=!1);var r="";r+=n?WM(t):PM(t);var a=t.shapeInfo.logicalShape,i=e.logicalShape;a.length<=i.length&&(r+=n?function(t,e){var n,r=t.name,a=r.charAt(0).toUpperCase()+r.slice(1),i="get"+a+"AtOutCoords",o=t.shapeInfo.logicalShape.length,s=e.logicalShape.length,u=zM(t.shapeInfo.logicalShape,e.logicalShape),c=KM(s),l=s-o,h=["x","y","z","w","u","v"];n=0===o?"":s<2&&u.length>=1?"coords = 0;":u.map((function(t){return"coords."+h[t+l]+" = 0;"})).join("\n");var f="";f=s<2&&o>0?"coords":t.shapeInfo.logicalShape.map((function(t,e){return"coords."+h[e+l]})).join(", ");var p="return outputValue;",d=1===wv(t.shapeInfo.logicalShape),m=1===wv(e.logicalShape);if(1!==o||d||m){if(d&&!m)p=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(u.length){var v=o-2,g=o-1;u.indexOf(v)>-1&&u.indexOf(g)>-1?p="return vec4(outputValue.x);":u.indexOf(v)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(g)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}}else p="\n return vec4(outputValue.xy, outputValue.xy);\n ";return"\n vec4 "+i+"() {\n "+c+" coords = getOutputCoords();\n "+n+"\n vec4 outputValue = get"+a+"("+f+");\n "+p+"\n }\n "}(t,e):function(t,e){var n=t.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=e.texShape,o=t.shapeInfo.texShape,s=t.shapeInfo.logicalShape.length,u=e.logicalShape.length;if(!t.shapeInfo.isUniform&&s===u&&null==t.shapeInfo.flatOffset&&kv(o,i))return"\n float "+a+"() {\n return sampleTexture("+n+", resultUV);\n }\n ";var c,l=KM(u),h=zM(t.shapeInfo.logicalShape,e.logicalShape),f=u-s,p=["x","y","z","w","u","v"];c=0===s?"":u<2&&h.length>=1?"coords = 0;":h.map((function(t){return"coords."+p[t+f]+" = 0;"})).join("\n");var d="";d=u<2&&s>0?"coords":t.shapeInfo.logicalShape.map((function(t,e){return"coords."+p[e+f]})).join(", ");return"\n float "+a+"() {\n "+l+" coords = getOutputCoords();\n "+c+"\n return get"+r+"("+d+");\n }\n "}(t,e));return r}(t,e,r)})).join("\n"),c=e.texShape,l=OM(),h=function(t){return"\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return "+t.texture2D+"(textureSampler, uv).r;\n }\n "}(l),f=function(t){return t.version+"\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n "+t.varyingFs+" vec2 resultUV;\n "+t.defineOutput+"\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n "+t.defineSpecialNaN+"\n "+t.defineSpecialInf+"\n "+t.defineRound+"\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n "+VM+"\n "+UM+"\n "+jM+"\n "}(l);return e.isPacked?(i=function(t,e){switch(t.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(t,e){var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(1===n[0])return"\n int getOutputCoords() {\n return 2 * int(resultUV.x * "+n[1]+".0);\n }\n ";if(1===n[1])return"\n int getOutputCoords() {\n return 2 * int(resultUV.y * "+n[0]+".0);\n }\n ";return"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n return 2 * (resTexRC.x * "+n[1]+" + resTexRC.y);\n }\n "}(0,e);case 2:return function(t,e){var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(kv(t,e))return"\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2("+n[0]+", "+n[1]+"));\n }\n ";var r=Math.ceil(t[1]/2);return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n int r = 2 * (index / "+r+");\n int c = imod(index, "+r+") * 2;\n\n return ivec2(r, c);\n }\n "}(t,e);case 3:return n=t,r=e,a=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],i=Math.ceil(n[2]/2),o=i*Math.ceil(n[1]/2),"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+a[0]+", "+a[1]+"));\n int index = resTexRC.x * "+a[1]+" + resTexRC.y;\n\n int b = index / "+o+";\n index -= b * "+o+";\n\n int r = 2 * (index / "+i+");\n int c = imod(index, "+i+") * 2;\n\n return ivec3(b, r, c);\n }\n ";default:return function(t,e){for(var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],r=Math.ceil(t[t.length-1]/2),a=r*Math.ceil(t[t.length-2]/2),i=a,o="",s="b, r, c",u=2;u<t.length-1;u++)i*=t[t.length-u-1],o="\n int b"+u+" = index / "+i+";\n index -= b"+u+" * "+i+";\n "+o,s="b"+u+", "+s;return"\n ivec"+t.length+" getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n\n "+o+"\n\n int b = index / "+a+";\n index -= b * "+a+";\n\n int r = 2 * (index / "+r+");\n int c = imod(index, "+r+") * 2;\n\n return ivec"+t.length+"("+s+");\n }\n "}(t,e)}var n,r,a,i,o}(e.logicalShape,c),o=function(t){return"\n void setOutput(vec4 val) {\n "+t.output+" = val;\n }\n "}(l)):(i=function(t,e){switch(t.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(t,e){if(1===e[0])return"\n int getOutputCoords() {\n return int(resultUV.x * "+e[1]+".0);\n }\n ";if(1===e[1])return"\n int getOutputCoords() {\n return int(resultUV.y * "+e[0]+".0);\n }\n ";return"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n return resTexRC.x * "+e[1]+" + resTexRC.y;\n }\n "}(0,e);case 2:return function(t,e){if(kv(t,e))return"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2("+e[0]+", "+e[1]+"));\n }\n ";if(1===t[1])return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n return ivec2(index, 0);\n }\n ";if(1===t[0])return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n return ivec2(0, index);\n }\n ";return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n int r = index / "+t[1]+";\n int c = index - r * "+t[1]+";\n return ivec2(r, c);\n }\n "}(t,e);case 3:return n=e,r=FM(["r","c","d"],t),"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+n[0]+", "+n[1]+"));\n int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n "+r+"\n return ivec3(r, c, d);\n }\n ";case 4:return function(t,e){var n=FM(["r","c","d","d2"],t);return"\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n "+n+"\n return ivec4(r, c, d, d2);\n }\n "}(t,e);case 5:return function(t,e){var n=FM(["r","c","d","d2","d3"],t);return"\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2("+e[0]+",\n "+e[1]+"));\n\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n\n "+n+"\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n "}(t,e);case 6:return function(t,e){var n=FM(["r","c","d","d2","d3","d4"],t);return"\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n\n "+n+"\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n "}(t,e);default:throw new Error(t.length+"-D output sampling is not yet supported")}var n,r}(e.logicalShape,c),o=function(t){return"\n void setOutput(float val) {\n "+t.output+" = vec4(val, 0, 0, 0);\n }\n "}(l)),r&&(f+=GM),[f,h,o,s,i,u,n].join("\n")}function PM(t){var e=t.shapeInfo.logicalShape;switch(e.length){case 0:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return"float "+n+"() {return "+e+";}";var r=t.shapeInfo.texShape,a=r[0],i=r[1];if(1===a&&1===i)return"\n float "+n+"() {\n return sampleTexture("+e+", halfCR);\n }\n ";var o=t.shapeInfo.texShape,s=o[0],u=o[1],c=qM(e);return"\n float "+n+"() {\n vec2 uv = uvFromFlat("+s+", "+u+", "+c+");\n return sampleTexture("+e+", uv);\n }\n "}(t);case 1:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return"\n float "+n+"(int index) {\n "+HM(t)+"\n }\n ";var r=t.shapeInfo.texShape,a=r[0],i=r[1];if(1===i&&1===a)return"\n float "+n+"(int index) {\n return sampleTexture("+e+", halfCR);\n }\n ";var o=qM(e);if(1===i)return"\n float "+n+"(int index) {\n vec2 uv = vec2(0.5, (float(index + "+o+") + 0.5) / "+a+".0);\n return sampleTexture("+e+", uv);\n }\n ";if(1===a)return"\n float "+n+"(int index) {\n vec2 uv = vec2((float(index + "+o+") + 0.5) / "+i+".0, 0.5);\n return sampleTexture("+e+", uv);\n }\n ";return"\n float "+n+"(int index) {\n vec2 uv = uvFromFlat("+a+", "+i+", index + "+o+");\n return sampleTexture("+e+", uv);\n }\n "}(t);case 2:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t.shapeInfo.texShape;if(null!=a&&kv(e,a)){var i=a[0],o=a[1];return"\n float "+r+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+o+".0, "+i+".0);\n return sampleTexture("+n+", uv);\n }\n "}var s=Tv(e),u=s.newShape,c=s.keptDims,l=u;if(l.length<e.length){var h=XM(t,l);return"\n "+PM(h)+"\n float "+r+"(int row, int col) {\n return "+r+"("+YM(["row","col"],c)+");\n }\n "}if(t.shapeInfo.isUniform)return"\n float "+r+"(int row, int col) {\n int index = round(dot(vec2(row, col), vec2("+e[1]+", 1)));\n "+HM(t)+"\n }\n ";var f=a[0],p=a[1],d=qM(n);if(1===p)return"\n float "+r+"(int row, int col) {\n float index = dot(vec3(row, col, "+d+"), vec3("+e[1]+", 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / "+f+".0);\n return sampleTexture("+n+", uv);\n }\n ";if(1===f)return"\n float "+r+"(int row, int col) {\n float index = dot(vec3(row, col, "+d+"), vec3("+e[1]+", 1, 1));\n vec2 uv = vec2((index + 0.5) / "+p+".0, 0.5);\n return sampleTexture("+n+", uv);\n }\n ";return"\n float "+r+"(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+e[1]+" + col + "+d+";\n vec2 uv = uvFromFlat("+f+", "+p+", index);\n return sampleTexture("+n+", uv);\n }\n"}(t);case 3:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e[1]*e[2],i=e[2],o=Tv(e),s=o.newShape,u=o.keptDims,c=s;if(c.length<e.length){var l=XM(t,c);return"\n "+PM(l)+"\n float "+r+"(int row, int col, int depth) {\n return "+r+"("+YM(["row","col","depth"],u)+");\n }\n "}if(t.shapeInfo.isUniform)return"\n float "+r+"(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3("+a+", "+i+", 1)));\n "+HM(t)+"\n }\n ";var h=t.shapeInfo.texShape,f=h[0],p=h[1],d=t.shapeInfo.flatOffset;if(p===a&&null==d)return"\n float "+r+"(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2("+i+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+p+".0, "+f+".0);\n return sampleTexture("+n+", uv);\n }\n ";if(p===i&&null==d)return"\n float "+r+"(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2("+e[1]+", 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+p+".0, "+f+".0);\n return sampleTexture("+n+", uv);\n }\n ";var m=qM(n);return"\n float "+r+"(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+a+" + col * "+i+" + depth + "+m+";\n vec2 uv = uvFromFlat("+f+", "+p+", index);\n return sampleTexture("+n+", uv);\n }\n "}(t);case 4:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e[3],i=e[2]*a,o=e[1]*i,s=Tv(e),u=s.newShape,c=s.keptDims;if(u.length<e.length){var l=XM(t,u);return"\n "+PM(l)+"\n float "+r+"(int row, int col, int depth, int depth2) {\n return "+r+"("+YM(["row","col","depth","depth2"],c)+");\n }\n "}if(t.shapeInfo.isUniform)return"\n float "+r+"(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4("+o+", "+i+", "+a+", 1)));\n "+HM(t)+"\n }\n ";var h=t.shapeInfo.flatOffset,f=t.shapeInfo.texShape,p=f[0],d=f[1];if(d===o&&null==h)return"\n float "+r+"(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3("+i+", "+a+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+d+".0, "+p+".0);\n return sampleTexture("+n+", uv);\n }\n ";if(d===a&&null==h)return"\n float "+r+"(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3("+e[1]*e[2]+", "+e[2]+", 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+d+".0, "+p+".0);\n return sampleTexture("+n+", uv);\n }\n ";var m=qM(n);return"\n float "+r+"(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+o+" + col * "+i+" +\n depth * "+a+" + depth2;\n vec2 uv = uvFromFlat("+p+", "+d+", index + "+m+");\n return sampleTexture("+n+", uv);\n }\n "}(t);case 5:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e[4],i=e[3]*a,o=e[2]*i,s=e[1]*o,u=Tv(e),c=u.newShape,l=u.keptDims;if(c.length<e.length){var h=XM(t,c);return"\n "+PM(h)+"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n return "+r+"("+YM(["row","col","depth","depth2","depth3"],l)+");\n }\n "}if(t.shapeInfo.isUniform)return"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4("+s+", "+o+", "+i+", "+a+")) +\n depth3;\n "+HM(t)+"\n }\n ";var f=t.shapeInfo.flatOffset,p=t.shapeInfo.texShape,d=p[0],m=p[1];if(m===s&&null==f)return"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4("+o+", "+i+", "+a+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+m+".0, "+d+".0);\n return sampleTexture("+n+", uv);\n }\n ";if(m===a&&null==f)return"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4("+e[1]*e[2]*e[3]+",\n "+e[2]*e[3]+", "+e[3]+", 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+m+".0, "+d+".0);\n return sampleTexture("+n+", uv);\n }\n ";var v=qM(n);return"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+s+" + col * "+o+" + depth * "+i+" +\n depth2 * "+a+" + depth3 + "+v+";\n vec2 uv = uvFromFlat("+d+", "+m+", index);\n return sampleTexture("+n+", uv);\n }\n "}(t);case 6:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=Tv(e),i=a.newShape,o=a.keptDims;if(i.length<e.length){var s=XM(t,i);return"\n "+PM(s)+"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return "+r+"("+YM(["row","col","depth","depth2","depth3","depth4"],o)+");\n }\n "}var u=e[5],c=e[4]*u,l=e[3]*c,h=e[2]*l,f=e[1]*h;if(t.shapeInfo.isUniform)return"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4("+f+", "+h+", "+l+", "+c+")) +\n dot(\n vec2(depth3, depth4),\n vec2("+u+", 1)));\n "+HM(t)+"\n }\n ";var p=t.shapeInfo.flatOffset,d=t.shapeInfo.texShape,m=d[0],v=d[1];if(v===f&&null==p)return"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4("+h+", "+l+", "+c+", "+u+")) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+v+".0, "+m+".0);\n return sampleTexture("+n+", uv);\n }\n ";if(v===u&&null==p)return"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4("+e[1]*e[2]*e[3]*e[4]+",\n "+e[2]*e[3]*e[4]+",\n "+e[3]*e[4]+",\n "+e[4]+")) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+v+".0, "+m+".0);\n return sampleTexture("+n+", uv);\n }\n ";var g=qM(n);return"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+f+" + col * "+h+" + depth * "+l+" +\n depth2 * "+c+" + depth3 * "+u+" + depth4 + "+g+";\n vec2 uv = uvFromFlat("+m+", "+v+", index);\n return sampleTexture("+n+", uv);\n }\n "}(t);default:throw new Error(e.length+"-D input sampling is not yet supported")}}function WM(t){var e,n,r;switch(t.shapeInfo.logicalShape.length){case 0:return e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),r=OM(),"\n vec4 "+n+"() {\n return "+r.texture2D+"("+e+", halfCR);\n }\n ";case 1:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),r=t.shapeInfo.texShape,a=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],i=OM();return"\n vec4 "+n+"(int index) {\n vec2 uv = packedUVfrom1D(\n "+a[0]+", "+a[1]+", index);\n return "+i.texture2D+"("+e+", uv);\n }\n "}(t);case 2:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t.shapeInfo.texShape,i=a[0],o=a[1],s=OM();if(null!=a&&kv(e,a))return"\n vec4 "+r+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+o+".0, "+i+".0);\n\n return "+s.texture2D+"("+n+", uv);\n }\n ";var u=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],c=Math.ceil(e[1]/2);return"\n vec4 "+r+"(int row, int col) {\n vec2 uv = packedUVfrom2D("+c+", "+u[0]+", "+u[1]+", row, col);\n return "+s.texture2D+"("+n+", uv);\n }\n "}(t);case 3:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t.shapeInfo.texShape,i=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];if(1===e[0]){var o=e.slice(1),s=XM(t,o);return"\n "+WM(s)+"\n vec4 "+r+"(int b, int row, int col) {\n return "+r+"("+YM(["b","row","col"],[1,2])+");\n }\n "}var u=i[0],c=i[1],l=Math.ceil(e[2]/2),h=l*Math.ceil(e[1]/2),f=OM();return"\n vec4 "+r+"(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n "+u+", "+c+", "+h+", "+l+", b, row, col);\n return "+f.texture2D+"("+n+", uv);\n }\n "}(t);default:return function(t){for(var e=t.shapeInfo.logicalShape,n=e.length,r=t.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=t.shapeInfo.texShape,o=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],s=o[0],u=o[1],c=Math.ceil(e[n-1]/2),l=c*Math.ceil(e[n-2]/2),h="int b, int row, int col",f="b * "+l+" + (row / 2) * "+c+" + (col / 2)",p=2;p<n-1;p++)h="int b"+p+", "+h,l*=e[n-p-1],f="b"+p+" * "+l+" + "+f;var d=OM();return"\n vec4 "+a+"("+h+") {\n int index = "+f+";\n int texR = index / "+u+";\n int texC = index - texR * "+u+";\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+u+", "+s+");\n return "+d.texture2D+"("+r+", uv);\n }\n "}(t)}}var VM="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",UM="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",jM="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",GM="\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";function qM(t){return"offset"+t}function HM(t){var e=t.name,n=wv(t.shapeInfo.logicalShape);return n<2?"return "+e+";":"\n for (int i = 0; i < "+n+"; i++) {\n if (i == index) {\n return "+e+"[i];\n }\n }\n "}function KM(t){if(t<=1)return"int";if(2===t)return"ivec2";if(3===t)return"ivec3";if(4===t)return"ivec4";if(5===t)return"ivec5";if(6===t)return"ivec6";throw Error("GPU for rank "+t+" is not yet supported")}function XM(t,e){var n=JSON.parse(JSON.stringify(t));return n.shapeInfo.logicalShape=e,n}function YM(t,e){return e.map((function(e){return t[e]})).join(", ")}var JM=function(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,gv(t.length>2,(function(){return"Packed arg"+(n.charAt(0).toUpperCase()+n.slice(1))+" supports only inputs with rank above 2."}));var a=t[t.length-1],i=Math.ceil(a/e);this.outputShape=t.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");var o,s,u=this.outputShape,c=u.length,l=KM(c),h=_M("coords",c);if(1===i){var f=KM(s=c+1);o="\n "+f+" sourceLocR = "+f+"("+h.join()+", 0);\n ++"+h[c-1]+";\n "+f+" sourceLocG = "+f+"("+h.join()+", 0);\n ++"+h[c-2]+";\n "+f+" sourceLocA = "+f+"("+h.join()+", 0);\n --"+h[c-1]+";\n "+f+" sourceLocB = "+f+"("+h.join()+", 0);\n --"+h[c-2]+";"}else s=c,o="\n "+l+" sourceLocR = coords;\n ++"+h[c-1]+";\n "+l+" sourceLocG = coords;\n ++"+h[c-2]+";\n "+l+" sourceLocA = coords;\n --"+h[c-1]+";\n "+l+" sourceLocB = coords;\n --"+h[c-2]+";";var p=["x","y","z","w","u","v"].slice(0,s),d="."+p[s-1],m=p.map((function(t){return"int "+t})),v=_M("sourceLocR",s-1).concat("inIdx.r"),g=_M("sourceLocG",s-1).concat("inIdx.g"),y=_M("sourceLocB",s-1).concat("inIdx.b"),b=_M("sourceLocA",s-1).concat("inIdx.a"),x="max"===n?"greaterThan":"lessThan",w=r?"":"\n inIdx = round(vec4(getBestIndicesAChannel("+v.join()+"),\n getBestIndicesAChannel("+g.join()+"),\n getBestIndicesAChannel("+y.join()+"),\n getBestIndicesAChannel("+b.join()+")));",k="vec4(\n getAChannel("+v.join()+"),\n hasNextCol ? getAChannel("+g.join()+") : 0.,\n hasNextRow ? getAChannel("+y.join()+") : 0.,\n hasNextRow && hasNextCol ? getAChannel("+b.join()+") : 0.)",S=r?"":"\n float getBestIndicesAChannel("+m.join()+") {\n return getChannel(getBestIndicesA("+p.join()+"),\n vec2("+p.slice(-2).join()+"));\n }";this.userCode="\n float getAChannel("+m.join()+") {\n return getChannel(getA("+p.join()+"),\n vec2("+p.slice(-2).join()+"));\n }\n "+S+"\n void main() {\n "+l+" coords = getOutputCoords();\n bool hasNextCol = "+h[c-1]+" < "+(u[c-1]-1)+";\n bool hasNextRow = "+h[c-2]+" < "+(u[c-2]-1)+";\n "+o+"\n ivec4 srcIdx = ivec4(sourceLocR"+d+", sourceLocG"+d+",\n sourceLocB"+d+", sourceLocA"+d+") * "+e+";\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = "+k+";\n\n for (int i = 0; i < "+e+"; i++) {\n inIdx = srcIdx;\n "+w+"\n vec4 candidate = "+k+";\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4("+x+"(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n "},$M=function(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,a=t.strideWidth,i=t.dilationHeight,o=t.dilationWidth,s=t.effectiveFilterHeight,u=t.effectiveFilterWidth,c=s-1-t.padInfo.top,l=u-1-t.padInfo.left,h=1/(e*n);this.userCode="\n const ivec2 pads = ivec2("+c+", "+l+");\n const float avgMultiplier = float("+h+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+s+";\n wR += "+i+") {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+u+";\n wC+= "+o+") {\n float dyC = float(dyCCorner + wC) / "+a+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n "},ZM=function(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,a=t.strideDepth,i=t.strideHeight,o=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterDepth,h=t.effectiveFilterHeight,f=t.effectiveFilterWidth,p=l-1-t.padInfo.front,d=h-1-t.padInfo.top,m=f-1-t.padInfo.left,v=1/(e*n*r);this.userCode="\n const ivec3 pads = ivec3("+p+", "+d+", "+m+");\n const float avgMultiplier = float("+v+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < "+l+";\n wD += "+s+") {\n float dyD = float(dyDCorner + wD) / "+a+".0;\n\n if (dyD < 0.0 || dyD >= "+t.outDepth+".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < "+h+";\n wR += "+u+") {\n float dyR = float(dyRCorner + wR) / "+i+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+f+";\n wC += "+c+") {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n "},QM=function(t,e,n,r,a,i){this.outputShape=[],this.variableNames=["x","mean","variance"],zg(t,e),zg(t,n);var o="0.0";null!=r&&(zg(t,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");var s="1.0";null!=a&&(zg(t,a),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=t,this.userCode="\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = "+o+";\n float scale = "+s+";\n float inv = scale * inversesqrt(variance + float("+i+"));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n "},tL=function(t,e,n,r,a,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],zg(t,e),zg(t,n);var o="vec4(0.0)";null!=r&&(zg(t,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");var s="vec4(1.0)";null!=a&&(zg(t,a),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=t,this.userCode="\n void main() {\n vec4 offset = "+o+";\n vec4 scale = "+s+";\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4("+i+"));\n\n setOutput((x - mean) * inv + offset);\n }\n "},eL="return areal * breal - aimag * bimag;",nL="return areal * bimag + aimag * breal;",rL=function(t,e,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=zg(e,n),this.userCode="\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n "+t+"\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n "},aL="return a + b;",iL="return a - b;",oL="return a * b;",sL="return (a < 0.) ? b * a : a;",uL=function(t,e,n){this.variableNames=["A","B"],this.outputShape=zg(e,n),this.userCode="\n float binaryOperation(float a, float b) {\n "+t+"\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n "},cL="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",lL=function(t,e,n,r){void 0===r&&(r=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=zg(e,n);var a=this.outputShape.length,i="";if(r)if(0===a||1===wv(this.outputShape))i="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(i="\n "+KM(a)+" coords = getOutputCoords();\n ",1===a)i+="\n result.y = (coords + 1) >= "+this.outputShape[0]+" ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ";else{var o=_M("coords",a);i+="\n bool nextRowOutOfBounds =\n ("+o[a-2]+" + 1) >= "+this.outputShape[a-2]+";\n bool nextColOutOfBounds =\n ("+o[a-1]+" + 1) >= "+this.outputShape[a-1]+";\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n "}this.userCode="\n vec4 binaryOperation(vec4 a, vec4 b) {\n "+t+"\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n "+i+"\n\n setOutput(result);\n }\n "},hL=function(){function t(t){this.variableNames=["A"],this.outputShape=t,this.userCode="\n uniform float minVal;\n uniform float maxVal;\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}return t.prototype.getCustomSetupFunc=function(t,e){var n=this;return function(r,a){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(a,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(a,"maxVal")),r.gl.uniform1f(n.minLoc,t),r.gl.uniform1f(n.maxLoc,e)}},t}(),fL=function(){function t(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n uniform float minVal;\n uniform float maxVal;\n\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}return t.prototype.getCustomSetupFunc=function(t,e){var n=this;return function(r,a){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(a,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(a,"maxVal")),r.gl.uniform1f(n.minLoc,t),r.gl.uniform1f(n.maxLoc,e)}},t}(),pL=function(t){this.variableNames=["real","imag"],this.outputShape=t,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "},dL=function(t){this.outputShape=[],this.outputShape=Qg(t,1),this.variableNames=t.map((function(t,e){return"T"+e}));var e=new Array(t.length-1);e[0]=t[0][1];for(var n=1;n<e.length;n++)e[n]=e[n-1]+t[n][1];for(var r=["if (yC < "+e[0]+") setOutput(getT0(yR, yC));"],a=1;a<e.length;a++){var i=e[a-1];r.push("else if (yC < "+e[a]+") setOutput(getT"+a+"(yR, yC-"+i+"));")}var o=e.length,s=e[e.length-1];r.push("else setOutput(getT"+o+"(yR, yC-"+s+"));"),this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n "+r.join("\n ")+"\n }\n "},mL=function(t,e){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=Qg(t,e);var n=this.outputShape,r=n.length,a=KM(r),i=_M("coords",r),o=["x","y","z","w","u","v"].slice(0,r);this.variableNames=t.map((function(t,e){return"T"+e}));var s=new Array(t.length-1);s[0]=t[0][e];for(var u=1;u<s.length;u++)s[u]=s[u-1]+t[u][e];for(var c=o[e],l=o.slice(-2),h=o.join(),f="if ("+c+" < "+s[0]+") {\n return getChannel(\n getT0("+h+"), vec2("+l.join()+"));\n }",p=1;p<s.length;p++){var d=s[p-1];f+="\n if ("+c+" < "+s[p]+" && "+c+" >= "+s[p-1]+") {\n return getChannel(\n getT"+p+"("+vL(o,c,d)+"),\n vec2("+vL(l,c,d)+"));\n }"}var m=s.length,v=s[s.length-1];f+="\n return getChannel(\n getT"+m+"("+vL(o,c,v)+"),\n vec2("+vL(l,c,v)+"));",this.userCode="\n float getValue("+o.map((function(t){return"int "+t}))+") {\n "+f+"\n }\n\n void main() {\n "+a+" coords = getOutputCoords();\n vec4 result = vec4(getValue("+i+"), 0., 0., 0.);\n\n "+i[r-1]+" = "+i[r-1]+" + 1;\n if ("+i[r-1]+" < "+n[r-1]+") {\n result.g = getValue("+i+");\n }\n\n "+i[r-2]+" = "+i[r-2]+" + 1;\n if ("+i[r-2]+" < "+n[r-2]+") {\n result.a = getValue("+i+");\n }\n\n "+i[r-1]+" = "+i[r-1]+" - 1;\n if ("+i[r-2]+" < "+n[r-2]+" &&\n "+i[r-1]+" < "+n[r-1]+") {\n result.b = getValue("+i+");\n }\n setOutput(result);\n }\n "};function vL(t,e,n){var r=t.indexOf(e);return t.map((function(t,e){return e===r?t+" - "+n:t})).join()}var gL=function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,a=t.padInfo.left,i="channelsLast"===t.dataFormat;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < "+t.batchSize+"; b++) {\n for (int yR = 0; yR < "+t.outHeight+"; yR++) {\n int xR = wR + yR * "+e+" - "+r+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+t.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+a+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n if ("+i+") {\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n } else {\n float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n "},yL=function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,a=t.strideWidth,i="channelsLast"===t.dataFormat,o=e-1-t.padInfo.top,s=n-1-t.padInfo.left,u=i?1:2,c=i?2:3,l=i?3:1;this.userCode="\n const ivec2 pads = ivec2("+o+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords["+l+"];\n\n ivec2 dyCorner = ivec2(coords["+u+"], coords["+c+"]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+e+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+e+" - 1 - wR;\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+a+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+n+" - 1 - wC;\n\n for (int d2 = 0; d2 < "+t.outChannels+"; d2++) {\n\n if ("+i+") {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n "},bL=function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,a=t.padInfo.front,i=t.padInfo.top,o=t.padInfo.left;this.userCode="\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < "+t.batchSize+"; b++) {\n for (int yF = 0; yF < "+t.outDepth+"; yF++) {\n int xF = wF + yF * "+e+" - "+a+";\n\n if (xF < 0 || xF >= "+t.inDepth+") {\n continue;\n }\n\n for (int yR = 0; yR < "+t.outHeight+"; yR++) {\n int xR = wR + yR * "+n+" - "+i+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+t.outWidth+"; yC++) {\n int xC = wC + yC * "+r+" - "+o+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},xL=function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,a=t.strideDepth,i=t.strideHeight,o=t.strideWidth,s=e-1-t.padInfo.front,u=n-1-t.padInfo.top,c=r-1-t.padInfo.left;this.userCode="\n const ivec3 pads = ivec3("+s+", "+u+", "+c+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < "+e+"; wF++) {\n float dyF = float(dyFCorner + wF) / "+a+".0;\n\n if (dyF < 0.0 || dyF >= "+t.outDepth+".0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = "+e+" - 1 - wF;\n\n for (int wR = 0; wR < "+n+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+i+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+n+" - 1 - wR;\n\n for (int wC = 0; wC < "+r+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+r+" - 1 - wC;\n\n for (int d2 = 0; d2 < "+t.outChannels+"; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},wL=function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,a=t.padInfo.left,i=t.outChannels/t.inChannels;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * "+i+" + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < "+t.batchSize+"; b++) {\n for (int yR = 0; yR < "+t.outHeight+"; yR++) {\n int xR = wR + yR * "+e+" - "+r+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+t.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+a+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n "},kL=function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,a=t.strideWidth,i=e-1-t.padInfo.top,o=n-1-t.padInfo.left,s=t.outChannels/t.inChannels;this.userCode="\n const ivec2 pads = ivec2("+i+", "+o+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < "+e+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+e+" - 1 - wR;\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+a+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+n+" - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < "+s+"; dm++) {\n int d2 = d1 * "+s+" + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n "},SL=function(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var a=t.padInfo.top,i=t.padInfo.left,o=t.strideHeight,s=t.strideWidth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterHeight,h=t.filterWidth,f=4*Math.floor(t.inChannels/4),p=t.inChannels%4,d="channelsLast"===t.dataFormat,m=d?1:2,v=d?2:3,g=d?3:1,y="",b="";n&&(y=r?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"\n float activation(float x) {\n "+n+"\n }\n ",b="result = activation(result);");var x=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+y+"\n\n const ivec2 strides = ivec2("+o+", "+s+");\n const ivec2 pads = ivec2("+a+", "+i+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords["+g+"];\n\n ivec2 xRCCorner =\n ivec2(coords["+m+"], coords["+v+"]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+l+"; wR++) {\n int xR = xRCorner + wR * "+u+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+h+"; wC++) {\n int xC = xCCorner + wC * "+c+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+f+"; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if ("+d+") {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if ("+(1===p)+") {\n\n if ("+d+") {\n dotProd +=\n getX(batch, xR, xC, "+f+") *\n getW(wR, wC, "+f+", d2);\n } else {\n dotProd +=\n getX(batch, "+f+", xR, xC) *\n getW(wR, wC, "+f+", d2);\n }\n\n } else if ("+(2===p)+") {\n vec2 wValues = vec2(\n getW(wR, wC, "+f+", d2),\n getW(wR, wC, "+f+" + 1, d2)\n );\n\n if ("+d+") {\n vec2 xValues = vec2(\n getX(batch, xR, xC, "+f+"),\n getX(batch, xR, xC, "+f+" + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, "+f+", xR, xC),\n getX(batch, "+f+" + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if ("+(3===p)+") {\n vec3 wValues = vec3(\n getW(wR, wC, "+f+", d2),\n getW(wR, wC, "+f+" + 1, d2),\n getW(wR, wC, "+f+" + 2, d2)\n );\n\n if ("+d+") {\n vec3 xValues = vec3(\n getX(batch, xR, xC, "+f+"),\n getX(batch, xR, xC, "+f+" + 1),\n getX(batch, xR, xC, "+f+" + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, "+f+", xR, xC),\n getX(batch, "+f+" + 1, xR, xC),\n getX(batch, "+f+" + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n "+x+"\n "+b+"\n setOutput(result);\n }\n "},CL=function(t){this.variableNames=["x","W"],this.outputShape=t.outShape;var e=t.padInfo.front,n=t.padInfo.top,r=t.padInfo.left,a=t.strideDepth,i=t.strideHeight,o=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterDepth,h=t.filterHeight,f=t.filterWidth,p=4*Math.floor(t.inChannels/4),d=t.inChannels%4;this.userCode="\n const ivec3 strides = ivec3("+a+", "+i+", "+o+");\n const ivec3 pads = ivec3("+e+", "+n+", "+r+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < "+l+"; wF++) {\n int xF = xFCorner + wF * "+s+";\n\n if (xF < 0 || xF >= "+t.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+h+"; wR++) {\n int xR = xRCorner + wR * "+u+";\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+f+"; wC++) {\n int xC = xCCorner + wC * "+c+";\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+p+"; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if ("+(1===d)+") {\n dotProd +=\n getX(batch, xF, xR, xC, "+p+") *\n getW(wF, wR, wC, "+p+", d2);\n } else if ("+(2===d)+") {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, "+p+"),\n getX(batch, xF, xR, xC, "+p+" + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, "+p+", d2),\n getW(wF, wR, wC, "+p+" + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if ("+(3===d)+") {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, "+p+"),\n getX(batch, xF, xR, xC, "+p+" + 1),\n getX(batch, xF, xR, xC, "+p+" + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, "+p+", d2),\n getW(wF, wR, wC, "+p+" + 1, d2),\n getW(wF, wR, wC, "+p+" + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},RL=function(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var a=t.inHeight,i=t.inWidth,o=t.padInfo.top,s=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,h=t.dilationWidth,f=t.filterHeight,p=t.filterWidth,d=t.outChannels/t.inChannels,m="",v="";n&&(m=r?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"\n float activation(float x) {\n "+n+"\n }\n ",v="result = activation(result);");var g=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+m+"\n\n const ivec2 strides = ivec2("+u+", "+c+");\n const ivec2 pads = ivec2("+o+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / "+d+";\n int q = d2 - d1 * "+d+";\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < "+f+"; wR++) {\n int xR = xRCorner + wR * "+l+";\n\n if (xR < 0 || xR >= "+a+") {\n continue;\n }\n\n for (int wC = 0; wC < "+p+"; wC++) {\n int xC = xCCorner + wC * "+h+";\n\n if (xC < 0 || xC >= "+i+") {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n "+g+"\n "+v+"\n setOutput(result);\n }\n "},NL=function(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.outShape;for(var a=t.inHeight,i=t.inWidth,o=t.padInfo.top,s=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,h=t.dilationWidth,f=t.filterHeight,p=t.filterWidth,d=p,m="int xR; int xC; int xCOffset;",v=0;v<f;v++)for(var g=0;g<p;g++)m+="\n vec4 xTexelR"+v+"C"+2*g+" = vec4(0.);\n vec4 wR"+v+"C"+g+" = vec4(0.);\n vec4 xR"+v+"C"+g+" = vec4(0.);";for(var y=0;y<f;y++)for(var b=0;b<d;b++){var x=2*b;if(m+="\n xR = xRCorner + "+y*l+";\n xC = xCCorner + "+x*h+";\n ",1===c){if(x<p&&(m+=s%2==1?"\n xCOffset = xC + 1;\n if(xR >= 0 && xR < "+a+" && xCOffset >= 0 && xCOffset < "+i+") {\n xTexelR"+y+"C"+x+" = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if(xCOffset + 1 >= "+i+") {\n xTexelR"+y+"C"+x+".zw = vec2(0.);\n }\n } else {\n xTexelR"+y+"C"+x+" = vec4(0.);\n }\n\n xCOffset = xC + 1 - 2;\n if(xR >= 0 && xR < "+a+" && xCOffset >= 0 && xCOffset < "+i+") {\n vec4 previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if(xCOffset + 1 >= "+i+") {\n previous.zw = vec2(0.);\n }\n\n xR"+y+"C"+x+" = vec4(previous.zw, xTexelR"+y+"C"+x+".xy);\n } else {\n xR"+y+"C"+x+" = vec4(0, 0, xTexelR"+y+"C"+x+".xy);\n }\n ":"\n if(xR >= 0 && xR < "+a+" && xC >= 0 && xC < "+i+") {\n xTexelR"+y+"C"+x+" = getX(batch, xR, xC, d1);\n } else {\n xTexelR"+y+"C"+x+" = vec4(0.);\n }\n\n xR"+y+"C"+x+" = xTexelR"+y+"C"+x+";\n ",x+1<p)){var w=s%2==0?mv(h):h;h%2==0&&s%2==1||h%2!=0&&s%2!=1?(m+="\n xCOffset = xC + "+s%2+" + "+w+";\n\n if(xR >= 0 && xR < "+a+" &&\n xCOffset >= 0 && xCOffset < "+i+") {\n xTexelR"+y+"C"+(x+2)+" = getX(batch, xR, xCOffset, d1);\n }\n ",h>1&&(m+="\n xCOffset -= 2;\n if(xR >= 0 && xR < "+a+" &&\n xCOffset >= 0 && xCOffset < "+i+") {\n xTexelR"+y+"C"+x+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+y+"C"+x+" = vec4(0.);\n }\n "),m+="\n xR"+y+"C"+(x+1)+" = vec4(\n xTexelR"+y+"C"+x+".zw, xTexelR"+y+"C"+(x+2)+".xy);\n "):m+="\n xCOffset = xC + "+w+";\n\n if(xR >= 0 && xR < "+a+" &&\n xCOffset >= 0 && xCOffset < "+i+") {\n xTexelR"+y+"C"+(x+2)+" = getX(batch, xR, xCOffset, d1);\n }\n\n xR"+y+"C"+(x+1)+" = xTexelR"+y+"C"+(x+2)+";\n "}}else x<p&&(m+="\n if(xR >= 0 && xR < "+a+") {\n ",s%2==1?(m+="\n xCOffset = xC + 1 - "+c+";\n if(xCOffset >= 0 && xCOffset < "+i+") {\n xTexelR"+y+"C"+x+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+y+"C"+x+" = vec4(0.);\n }\n\n if(xC + 1 >= 0 && xC + 1 < "+i+") {\n xTexelR"+y+"C"+(x+2)+" = getX(batch, xR, xC + 1, d1);\n } else {\n xTexelR"+y+"C"+(x+2)+" = vec4(0.);\n }\n\n xR"+y+"C"+x+" = vec4(\n xTexelR"+y+"C"+x+".zw, xTexelR"+y+"C"+(x+2)+".zw);\n ",x+1<p&&(m+="\n vec4 final = vec4(0.);\n xCOffset = xC + 1 + "+c+";\n if(xCOffset >= 0 && xCOffset < "+i+") {\n final = getX(batch, xR, xCOffset, d1);\n }\n xR"+y+"C"+(x+1)+" = vec4(xTexelR"+y+"C"+(x+2)+".xy, final.xy);\n ")):(m+="\n if(xC >= 0 && xC < "+i+") {\n xTexelR"+y+"C"+x+" = getX(batch, xR, xC, d1);\n } else {\n xTexelR"+y+"C"+x+" = vec4(0.);\n }\n\n xCOffset = xC + "+c+";\n if(xCOffset >= 0 && xCOffset < "+i+") {\n xTexelR"+y+"C"+(x+2)+" = getX(batch, xR, xCOffset, d1);\n } else {\n xTexelR"+y+"C"+(x+2)+" = vec4(0.);\n }\n\n xR"+y+"C"+x+" = vec4(\n xTexelR"+y+"C"+x+".xy, xTexelR"+y+"C"+(x+2)+".xy);\n ",x+1<p&&(m+="\n xR"+y+"C"+(x+1)+" = vec4(\n xTexelR"+y+"C"+x+".zw, xTexelR"+y+"C"+(x+2)+".zw);\n ")),m+="}");x<p&&(m+="\n vec4 wTexelR"+y+"C"+x+" = getW("+y+", "+x+", d1, q);\n wR"+y+"C"+x+" = vec4(wTexelR"+y+"C"+x+".xz, wTexelR"+y+"C"+x+".xz);\n ",x+1<p&&(m+="\n vec4 wTexelR"+y+"C"+(x+1)+" = getW("+y+", "+(x+1)+", d1, q);\n wR"+y+"C"+(x+1)+" =\n vec4(wTexelR"+y+"C"+(x+1)+".xz, wTexelR"+y+"C"+(x+1)+".xz);"))}for(var k=0;k<f;k++)for(var S=0;S<p;S++)m+="dotProd += xR"+k+"C"+S+" * wR"+k+"C"+S+";";var C="",R="";n&&(C=r?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":"vec4 activation(vec4 x) {\n "+n+"\n }",R="result = activation(result);");var N=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+C+"\n\n const ivec2 strides = ivec2("+u+", "+c+");\n const ivec2 pads = ivec2("+o+", "+s+");\n\n void main() {\n\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2;\n int q = 0;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n vec4 dotProd = vec4(0.);\n\n "+m+"\n\n vec4 result = dotProd;\n "+N+"\n "+R+"\n setOutput(result);\n }\n "},EL=function(t,e,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var i=t[0],o=t[1],s=t[2],u=t[3],c=e[0],l=n[0],h=n[1];this.outputShape=[c,l,h,u];var f="bilinear"===r?1:0,p=o-1+".0",d=s-1+".0",m=l>1?[""+(o-1)/(l-1),"(y2-y1) * height_ratio","y1*"+p+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+p],v=m[0],g=m[1],y=m[2],b=h>1?[""+(s-1)/(h-1),"(x2-x1) * width_ratio","x1*"+d+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+d],x=b[0],w=b[1],k=b[2];this.userCode="\n const float height_ratio = float("+v+");\n const float width_ratio = float("+x+");\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= "+i+") {\n return;\n }\n\n float height_scale = "+g+";\n float width_scale = "+w+";\n\n float in_y = "+y+";\n if( in_y < 0.0 || in_y > "+p+" ) {\n setOutput(float("+a+"));\n return;\n }\n float in_x = "+k+";\n if( in_x < 0.0 || in_x > "+d+" ) {\n setOutput(float("+a+"));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if("+f+" == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n "},IL=function(t,e,n){this.variableNames=["x"],this.outputShape=t;var r=t.length,a=t[t.length-1],i=n?"<":">";this.userCode="\n int getIndex(int i) {\n "+(n?"return "+a+" -i - 1;":"return i;")+"\n }\n\n void main() {\n "+KM(r)+" coords = getOutputCoords();\n int end = "+AL(r,"coords")+";\n float val = 0.0;\n for (int i = "+a+" - 1; i >= 0; i -= 1) {\n int idx = getIndex(i);\n if (idx "+i+" end) {\n continue;\n }\n if (idx == end && "+e+") {\n continue;\n }\n "+AL(r,"coords")+" = idx;\n val += getX("+function(t,e){if(1===t)return""+e;if(2===t)return e+".x, "+e+".y";if(3===t)return e+".x, "+e+".y, "+e+".z";if(4===t)return e+".x, "+e+".y, "+e+".z, "+e+".w";throw Error("Cumulative sum for rank "+t+" is not yet supported")}(r,"coords")+");\n }\n setOutput(val);\n }\n "};function AL(t,e){if(1===t)return""+e;if(2===t)return e+".y";if(3===t)return e+".z";if(4===t)return e+".w";throw Error("Cumulative sum for rank "+t+" is not yet supported")}var TL=function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=XF.DENSE;var e=eM(t),n=OM();this.outputShape=t,this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n "+FM(["r","c","d"],t)+"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = 4 * (resTexRC.x * "+e[1]+" + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n "+n.output+" = result;\n }\n "},DL=function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=XF.DENSE;var e=eM(t),n=OM();this.outputShape=t,this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n "+FM(["r","c","d"],t)+"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+e[0]+", "+e[1]+"));\n int index = 4 * (resTexRC.x * "+e[1]+" + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n "+n.output+" = result;\n }\n "},_L=function(){function t(t,e,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=e,this.dataFormat=n,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = "+this.getHeightCoordString()+";\n int w = "+this.getWidthCoordString()+";\n int d = "+this.getDepthCoordString()+";\n\n int in_h = h / "+e+";\n int offset_h = imod(h, "+e+");\n int in_w = w / "+e+";\n int offset_w = imod(w, "+e+");\n int offset_d = (offset_h * "+e+" + offset_w) *\n "+this.getOutputDepthSize()+";\n int in_d = d + offset_d;\n\n float result = "+this.getInputSamplingString()+";\n setOutput(result);\n }\n "}var e=t.prototype;return e.getHeightCoordString=function(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"},e.getWidthCoordString=function(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"},e.getDepthCoordString=function(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"},e.getOutputDepthSize=function(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]},e.getInputSamplingString=function(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"},t}(),OL=function(t){this.variableNames=["X"],this.outputShape=[t,t],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "},FL=function(t){this.variableNames=["A"],this.outTexUsage=YF.DOWNLOAD;var e=OM();this.outputShape=t,this.userCode="\n "+LM+"\n\n void main() {\n float x = getAAtOutCoords();\n "+e.output+" = encode_float(x);\n }\n "},ML=function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=YF.DOWNLOAD;var e=OM();this.outputShape=t,this.userCode="\n "+LM+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n "+e.output+" = encode_float(x);\n }\n "},LL=function(t,e,n){void 0===n&&(n=!1),this.variableNames=["A"];var r=OM(),a=e[0],i=e[1];this.outputShape=t;var o="result";n&&(o="floor(result * 255. + 0.5)"),this.userCode="\n "+MM(t)+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n int flatIndex = getFlatIndex(coords);\n int offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n \n int r = flatIndex / "+i+";\n int c = imod(flatIndex, "+i+");\n vec2 uv = (vec2(c, r) + halfCR) / vec2("+i+".0, "+a+".0);\n vec4 values = "+r.texture2D+"(A, uv);\n\n float result;\n\n if(offset == 0) {\n result = values[0];\n } else if(offset == 1) {\n result = values[1];\n } else if(offset == 2) {\n result = values[2];\n } else {\n result = values[3];\n }\n\n "+r.output+" = vec4("+o+", 0., 0., 0.);\n }\n "},zL=function(t,e,n){void 0===n&&(n=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var r=OM(),a=e[0],i=e[1];this.outputShape=t;var o="",s="result";n&&(s="floor(result * 255. + 0.5)");for(var u=0;u<=1;u++)for(var c=0;c<=1;c++){var l=2*u+c;o+="\n localCoords = coords;\n if(localCoords[2] + "+c+" < "+t[2]+") {\n localCoords[2] += "+c+";\n if(localCoords[1] + "+u+" < "+t[1]+") {\n localCoords[1] += "+u+";\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n r = flatIndex / "+i+";\n c = imod(flatIndex, "+i+");\n uv = (vec2(c, r) + halfCR) / vec2("+i+".0, "+a+".0);\n values = "+r.texture2D+"(A, uv);\n\n if(offset == 0) {\n result["+l+"] = values[0];\n } else if(offset == 1) {\n result["+l+"] = values[1];\n } else if(offset == 2) {\n result["+l+"] = values[2];\n } else {\n result["+l+"] = values[3];\n }\n }\n }\n "}this.userCode="\n "+MM(t)+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n "+o+"\n\n "+r.output+" = "+s+";\n }\n "},BL="return real * expR - imag * expI;",PL="return real * expI + imag * expR;",WL=function(t,e,n){this.variableNames=["real","imag"];var r=e[1];this.outputShape=e;var a=n?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,i=n?r+".0":"1.0";this.userCode="\n const float exponentMultiplier = "+a+";\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n "+t+"\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float("+r+");\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < "+r+"; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / "+i+";\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n "},VL=function(){function t(t,e){this.outputShape=[],this.variableNames=["x"],this.outputShape=t,this.userCode="\n uniform float value;\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}return t.prototype.getCustomSetupFunc=function(t){var e=this;return function(n,r){null==e.valueLoc&&(e.valueLoc=n.getUniformLocationNoThrow(r,"value")),n.gl.uniform1f(e.valueLoc,t)}},t}(),UL=function(t,e,n){this.variableNames=["A","indices"];var r=t.slice();r[n]=e,this.outputShape=r,this.rank=r.length;var a=KM(this.rank),i=function(t,e){var n=t.length;if(n>4)throw Error("Gather for rank "+n+" is not yet supported");if(1===n)return"int(getIndices(resRC))";for(var r=["resRC.x","resRC.y","resRC.z","resRC.w"],a=[],i=0;i<t.length;i++)i===e?a.push("int(getIndices("+r[i]+"))"):a.push(""+r[i]);return a.join()}(t,n);this.userCode="\n void main() {\n "+a+" resRC = getOutputCoords();\n setOutput(getA("+i+"));\n }\n "};var jL=function(t,e,n){this.sliceDim=t,this.strides=e,this.variableNames=["x","indices"],this.outputShape=n;var r=KM(e.length),a=KM(n.length),i=this.sliceDim>1?"strides[j]":"strides";this.userCode="\n "+r+" strides = "+r+"("+this.strides+");\n void main() {\n "+a+" coords = getOutputCoords();\n int flattenIndex = 0;\n for (int j = 0; j < "+this.sliceDim+"; j++) {\n int index = round(getIndices(coords[0], j));\n flattenIndex += index * "+i+";\n }\n setOutput(getX(flattenIndex, coords[1]));\n }\n "};function GL(t,e){var n=OM();return function(t,e,n){var r=gM(t,e,(function(){return t.createShader(t.VERTEX_SHADER)}),"Unable to create vertex WebGLShader.");if(aM(t,e,(function(){return t.shaderSource(r,n)})),aM(t,e,(function(){return t.compileShader(r)})),!1===t.getShaderParameter(r,t.COMPILE_STATUS))throw console.log(t.getShaderInfoLog(r)),new Error("Failed to compile vertex shader.");return r}(t,e,n.version+"\n precision highp float;\n "+n.attribute+" vec3 clipSpacePos;\n "+n.attribute+" vec2 uv;\n "+n.varyingVs+" vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }")}function qL(t,e){return function(t,e,n){var r=gM(t,e,(function(){return t.createBuffer()}),"Unable to create WebGLBuffer");return aM(t,e,(function(){return t.bindBuffer(t.ARRAY_BUFFER,r)})),aM(t,e,(function(){return t.bufferData(t.ARRAY_BUFFER,n,t.STATIC_DRAW)})),r}(t,e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function HL(t,e){return function(t,e,n){var r=gM(t,e,(function(){return t.createBuffer()}),"Unable to create WebGLBuffer");return aM(t,e,(function(){return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r)})),aM(t,e,(function(){return t.bufferData(t.ELEMENT_ARRAY_BUFFER,n,t.STATIC_DRAW)})),r}(t,e,new Uint16Array([0,1,2,2,1,3]))}function KL(t,e,n,r,a,i,o){!function(t,e){var n=nv().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0)throw new Error("Requested texture size "+("["+t+"x"+e+"]")+" is invalid.");if(t>n||e>n)throw new Error("Requested texture size "+("["+t+"x"+e+"]")+" greater than WebGL maximum on this browser / GPU "+("["+n+"x"+n+"]")+".")}(n,r);var s=function(t,e){return gM(t,e,(function(){return t.createTexture()}),"Unable to create WebGLTexture.")}(t,e),u=t.TEXTURE_2D;return aM(t,e,(function(){return t.bindTexture(u,s)})),aM(t,e,(function(){return t.texParameteri(u,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE)})),aM(t,e,(function(){return t.texParameteri(u,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)})),aM(t,e,(function(){return t.texParameteri(u,t.TEXTURE_MIN_FILTER,t.NEAREST)})),aM(t,e,(function(){return t.texParameteri(u,t.TEXTURE_MAG_FILTER,t.NEAREST)})),aM(t,e,(function(){return t.texImage2D(u,0,a,n,r,0,i,o,null)})),aM(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,null)})),s}function XL(t,e,n,r,a,i,o,s){var u=t,c=new Float32Array(function(t,e){var n=nM(t,e);return n[0]*n[1]*4}(i,o));return u.bindBuffer(u.PIXEL_PACK_BUFFER,e),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,c),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),c}var YL=function(){function t(t){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var e=nv().getNumber("WEBGL_VERSION");null!=t?(this.gl=t,function(t,e){$F[t]=e}(e,t)):this.gl=QF(e);var n="WEBGL_color_buffer_float";if(1===nv().getNumber("WEBGL_VERSION")){if(this.textureFloatExtension=oM(this.gl,this.debug,"OES_texture_float"),SM(this.gl,"OES_texture_half_float"))this.textureHalfFloatExtension=oM(this.gl,this.debug,"OES_texture_half_float");else if(nv().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(n),SM(this.gl,"EXT_color_buffer_half_float"))this.colorBufferHalfFloatExtension=oM(this.gl,this.debug,"EXT_color_buffer_half_float");else if(nv().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(n="EXT_color_buffer_float",SM(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!SM(this.gl,"EXT_color_buffer_half_float"))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension("EXT_color_buffer_half_float")}this.vertexBuffer=qL(this.gl,this.debug),this.indexBuffer=HL(this.gl,this.debug),this.framebuffer=function(t,e){return gM(t,e,(function(){return t.createFramebuffer()}),"Unable to create WebGLFramebuffer.")}(this.gl,this.debug),this.textureConfig=rM(this.gl,this.textureHalfFloatExtension)}var e=t.prototype;return e.dispose=function(){var t=this;if(!this.disposed){null!=this.program&&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."),null!=this.outputTexture&&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;aM(e,this.debug,(function(){return e.finish()})),aM(e,this.debug,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,null)})),aM(e,this.debug,(function(){return e.deleteFramebuffer(t.framebuffer)})),aM(e,this.debug,(function(){return e.bindBuffer(e.ARRAY_BUFFER,null)})),aM(e,this.debug,(function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)})),aM(e,this.debug,(function(){return e.deleteBuffer(t.indexBuffer)})),this.disposed=!0}},e.createFloat32MatrixTexture=function(t,e){return this.throwIfDisposed(),function(t,e,n,r,a){var i=tM(n,r);return KL(t,e,i[0],i[1],a.internalFormatFloat,a.textureFormatFloat,t.FLOAT)}(this.gl,this.debug,t,e,this.textureConfig)},e.createFloat16MatrixTexture=function(t,e){return this.throwIfDisposed(),function(t,e,n,r,a){var i=tM(n,r);return KL(t,e,i[0],i[1],a.internalFormatHalfFloat,a.textureFormatFloat,a.textureTypeHalfFloat)}(this.gl,this.debug,t,e,this.textureConfig)},e.createUnsignedBytesMatrixTexture=function(t,e){return this.throwIfDisposed(),function(t,e,n,r,a){var i=tM(n,r);return KL(t,e,i[0],i[1],t.RGBA,t.RGBA,t.UNSIGNED_BYTE)}(this.gl,this.debug,t,e,this.textureConfig)},e.uploadPixelDataToTexture=function(t,e){this.throwIfDisposed(),function(t,e,n,r){aM(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,n)})),r.data instanceof Uint8Array?aM(t,e,(function(){return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,r.width,r.height,0,t.RGBA,t.UNSIGNED_BYTE,r.data)})):aM(t,e,(function(){return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r)})),aM(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,null)}))}(this.gl,this.debug,t,e)},e.uploadDenseMatrixToTexture=function(t,e,n,r){this.throwIfDisposed(),function(t,e,n,r,a,i,o){var s,u,c;aM(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,n)})),i instanceof Uint8Array?(s=new Uint8Array(r*a*4),u=t.UNSIGNED_BYTE,c=t.RGBA):(s=new Float32Array(r*a*4),u=t.FLOAT,c=o.internalFormatPackedFloat),s.set(i),aM(t,e,(function(){return t.texImage2D(t.TEXTURE_2D,0,c,r,a,0,t.RGBA,u,s)})),aM(t,e,(function(){return t.bindTexture(t.TEXTURE_2D,null)}))}(this.gl,this.debug,t,e,n,r,this.textureConfig)},e.createFloat16PackedMatrixTexture=function(t,e){return this.throwIfDisposed(),function(t,e,n,r,a){var i=nM(n,r);return KL(t,e,i[0],i[1],a.internalFormatPackedHalfFloat,t.RGBA,a.textureTypeHalfFloat)}(this.gl,this.debug,t,e,this.textureConfig)},e.createPackedMatrixTexture=function(t,e){return this.throwIfDisposed(),function(t,e,n,r,a){var i=nM(n,r);return KL(t,e,i[0],i[1],a.internalFormatPackedFloat,t.RGBA,t.FLOAT)}(this.gl,this.debug,t,e,this.textureConfig)},e.deleteMatrixTexture=function(t){var e=this;this.throwIfDisposed(),this.outputTexture===t&&(mM(this.gl,this.debug,this.framebuffer),this.outputTexture=null),aM(this.gl,this.debug,(function(){return e.gl.deleteTexture(t)}))},e.downloadByteEncodedFloatMatrixFromOutputTexture=function(t,e,n){var r=this;return this.downloadMatrixDriver(t,(function(){return function(t,e,n,r,a){var i=tM(n,r),o=i[0],s=i[1],u=new Uint8Array(n*r*4);return aM(t,e,(function(){return t.readPixels(0,0,o,s,a.downloadTextureFormat,t.UNSIGNED_BYTE,u)})),new Float32Array(u.buffer)}(r.gl,r.debug,e,n,r.textureConfig)}))},e.downloadPackedMatrixFromBuffer=function(t,e,n,r,a,i){return XL(this.gl,t,0,0,0,a,i,this.textureConfig)},e.downloadFloat32MatrixFromBuffer=function(t,e){return function(t,e,n){var r=t,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,e),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,t,e)},e.createBufferFromTexture=function(t,e,n){this.bindTextureToFrameBuffer(t);var r=function(t,e,n,r,a){var i=t.createBuffer();aM(t,e,(function(){return t.bindBuffer(t.PIXEL_PACK_BUFFER,i)}));var o=16*n*r;return aM(t,e,(function(){return t.bufferData(t.PIXEL_PACK_BUFFER,o,t.STREAM_READ)})),aM(t,e,(function(){return t.readPixels(0,0,r,n,t.RGBA,t.FLOAT,0)})),aM(t,e,(function(){return t.bindBuffer(t.PIXEL_PACK_BUFFER,null)})),i}(this.gl,this.debug,e,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r},e.createAndWaitForFence=function(){var t=this.createFence(this.gl);return this.pollFence(t)},e.createFence=function(t){var e,n,r=this;if(nv().getBool("WEBGL_FENCE_API_ENABLED")){var a=t,i=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),n=function(){var t=a.clientWaitSync(i,0,0);return t===a.ALREADY_SIGNALED||t===a.CONDITION_SATISFIED},e=i}else nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(e=this.beginQuery(),this.endQuery(),n=function(){return r.isQueryAvailable(e,nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):n=function(){return!0};return{query:e,isFencePassed:n}},e.downloadMatrixFromPackedTexture=function(t,e,n){var r=this;return this.downloadMatrixDriver(t,(function(){return function(t,e,n,r){var a=new Float32Array(n*r*4);return aM(t,e,(function(){return t.readPixels(0,0,r,n,t.RGBA,t.FLOAT,a)})),a}(r.gl,r.debug,e,n)}))},e.createProgram=function(t){this.throwIfDisposed();var e=this.gl,n=sM(e,this.debug,t),r=GL(e,this.debug),a=function(t,e){return gM(t,e,(function(){return t.createProgram()}),"Unable to create WebGLProgram.")}(e,this.debug);return aM(e,this.debug,(function(){return e.attachShader(a,r)})),aM(e,this.debug,(function(){return e.attachShader(a,n)})),function(t,e,n){if(aM(t,e,(function(){return t.linkProgram(n)})),!1===t.getProgramParameter(n,t.LINK_STATUS))throw console.log(t.getProgramInfoLog(n)),new Error("Failed to link vertex and fragment shaders.")}(e,this.debug,a),this.debug&&hM(e,this.debug,a),this.vertexAttrsAreBound||(this.setProgram(a),this.vertexAttrsAreBound=function(t,e,n,r){return aM(t,e,(function(){return t.bindBuffer(t.ARRAY_BUFFER,r)})),fM(t,e,n,"clipSpacePos",r,3,20,0)&&fM(t,e,n,"uv",r,2,20,12)}(e,this.debug,this.program,this.vertexBuffer)),a},e.deleteProgram=function(t){var e=this;this.throwIfDisposed(),t===this.program&&(this.program=null),null!=t&&aM(this.gl,this.debug,(function(){return e.gl.deleteProgram(t)}))},e.setProgram=function(t){var e=this;this.throwIfDisposed(),this.program=t,null!=this.program&&this.debug&&hM(this.gl,this.debug,this.program),aM(this.gl,this.debug,(function(){return e.gl.useProgram(t)}))},e.getUniformLocation=function(t,e,n){return void 0===n&&(n=!0),this.throwIfDisposed(),n?function(t,e,n,r){return gM(t,e,(function(){return t.getUniformLocation(n,r)}),'uniform "'+r+'" not present in program.')}(this.gl,this.debug,t,e):function(t,e,n){return t.getUniformLocation(e,n)}(this.gl,t,e)},e.getAttributeLocation=function(t,e){var n=this;return this.throwIfDisposed(),aM(this.gl,this.debug,(function(){return n.gl.getAttribLocation(t,e)}))},e.getUniformLocationNoThrow=function(t,e){return this.throwIfDisposed(),this.gl.getUniformLocation(t,e)},e.setInputMatrixTexture=function(t,e,n){this.throwIfDisposed(),this.throwIfNoProgram(),function(t,e,n,r,a,i){aM(t,e,(function(){return pM(t,e,r,i)})),aM(t,e,(function(){return t.uniform1i(a,i)}))}(this.gl,this.debug,this.program,t,e,n)},e.setOutputMatrixTexture=function(t,e,n){this.setOutputMatrixTextureDriver(t,n,e)},e.setOutputPackedMatrixTexture=function(t,e,n){this.throwIfDisposed();var r=nM(e,n),a=r[0],i=r[1];this.setOutputMatrixTextureDriver(t,a,i)},e.setOutputMatrixWriteRegion=function(t,e,n,r){this.setOutputMatrixWriteRegionDriver(n,t,r,e)},e.setOutputPackedMatrixWriteRegion=function(t,e,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")},e.debugValidate=function(){null!=this.program&&hM(this.gl,this.debug,this.program),vM(this.gl)},e.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var t=this.gl;this.debug&&this.debugValidate(),aM(t,this.debug,(function(){return t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0)}))},e.blockUntilAllProgramsCompleted=function(){var t=this;this.throwIfDisposed(),aM(this.gl,this.debug,(function(){return t.gl.finish()}))},e.getQueryTimerExtension=function(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=oM(this.gl,this.debug,2===nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension},e.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension()},e.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension()},e.beginQuery=function(){if(2===nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var t=this.gl,e=this.getQueryTimerExtensionWebGL2(),n=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,n),n}var r=this.getQueryTimerExtensionWebGL1(),a=r.createQueryEXT();return r.beginQueryEXT(r.TIME_ELAPSED_EXT,a),a},e.endQuery=function(){if(2!==nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var t=this.getQueryTimerExtensionWebGL1();t.endQueryEXT(t.TIME_ELAPSED_EXT)}else{var e=this.gl,n=this.getQueryTimerExtensionWebGL2();e.endQuery(n.TIME_ELAPSED_EXT)}},e.waitForQueryAndGetTime=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Ev((function(){return n.disposed||n.isQueryAvailable(e,nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}));case 2:return t.abrupt("return",this.getQueryTime(e,nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")));case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getQueryTime=function(t,e){if(0===e)return null;if(2===e){var n=this.gl;return n.getQueryParameter(t,n.QUERY_RESULT)/1e6}var r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(t,r.QUERY_RESULT_EXT)/1e6},e.isQueryAvailable=function(t,e){if(0===e)return!0;if(2===e){var n=this.gl,r=this.getQueryTimerExtensionWebGL2(),a=n.getQueryParameter(t,n.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),a&&!this.disjoint}var i=this.getQueryTimerExtensionWebGL1(),o=i.getQueryObjectEXT(t,i.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(i.GPU_DISJOINT_EXT)),o&&!this.disjoint},e.pollFence=function(t){var e=this;return new Promise((function(n){e.addItemToPoll((function(){return t.isFencePassed()}),(function(){return n()}))}))},e.pollItems=function(){for(var t=function(t){for(var e=0;e<t.length;++e){if(!t[e]())break}return e-1}(this.itemsToPoll.map((function(t){return t.isDoneFn}))),e=0;e<=t;++e){(0,this.itemsToPoll[e].resolveFn)()}this.itemsToPoll=this.itemsToPoll.slice(t+1)},e.addItemToPoll=function(t,e){var n=this;this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1||Ev((function(){return n.pollItems(),0===n.itemsToPoll.length}))},e.bindTextureToFrameBuffer=function(t){this.throwIfDisposed(),dM(this.gl,this.debug,t,this.framebuffer),this.debug&&vM(this.gl)},e.unbindTextureToFrameBuffer=function(){null!=this.outputTexture?(dM(this.gl,this.debug,this.outputTexture,this.framebuffer),this.debug&&vM(this.gl)):mM(this.gl,this.debug,this.framebuffer)},e.downloadMatrixDriver=function(t,e){this.bindTextureToFrameBuffer(t);var n=e();return this.unbindTextureToFrameBuffer(),n},e.setOutputMatrixTextureDriver=function(t,e,n){this.throwIfDisposed();var r=this.gl;dM(r,this.debug,t,this.framebuffer),this.debug&&vM(r),this.outputTexture=t,aM(r,this.debug,(function(){return r.viewport(0,0,e,n)})),aM(r,this.debug,(function(){return r.scissor(0,0,e,n)}))},e.setOutputMatrixWriteRegionDriver=function(t,e,n,r){var a=this;this.throwIfDisposed(),aM(this.gl,this.debug,(function(){return a.gl.scissor(t,e,n,r)}))},e.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")},e.throwIfNoProgram=function(){if(null==this.program)throw new Error("No GPU program is currently set.")},jm(t,[{key:"debug",get:function(){return nv().getBool("DEBUG")}}]),t}();function JL(t,e){if(t.length!==e.length)throw Error("Binary was compiled with "+t.length+" inputs, but was executed with "+e.length+" inputs");t.forEach((function(t,n){var r=t.logicalShape,a=e[n],i=a.shape;if(!kv(r,i))throw Error("Binary was compiled with different shapes than the current args. Shapes "+r+" and "+i+" must match");if(!t.isUniform||!a.isUniform){var o=t.texShape,s=a.isUniform?null:a.texData.texShape;if(!kv(o,s))throw Error("Binary was compiled with different texture shapes than the current args. Shape "+o+" and "+s+" must match")}}))}var $L=function(t,e,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var r=n.filterWidth,a=n.inChannels,i=n.strideWidth,o=n.strideHeight,s=n.padInfo,u=n.outWidth,c=n.dilationWidth,l=n.dilationHeight,h=n.dataFormat,f=s.left,p=s.top,d=a*r,m=OM(),v="channelsLast"===h,g=v?0:1,y=v?1:2,b="",x=0;x<=1;x++)for(var w=0;w<=1;w++)b+="\n blockIndex = rc.y + "+w+";\n pos = rc.x + "+x+";\n\n if(blockIndex < "+t[1]+" && pos < "+t[0]+") {\n offsetY = int(blockIndex / ("+u+")) * "+o+" - "+p+";\n d0 = offsetY + "+l+" * (pos / "+d+");\n\n if(d0 < "+e[g]+" && d0 >= 0) {\n\n offsetX = int(mod(float(blockIndex), "+u+".) * "+i+". - "+f+".);\n d1 = offsetX + "+c+" * (int(mod(float(pos), "+d+".) / "+a+".));\n\n if(d1 < "+e[y]+" && d1 >= 0) {\n\n ch = int(mod(float(pos), "+a+".));\n\n if ("+v+") {\n innerDims = vec2(d1, ch);\n result["+(2*x+w)+"] = getChannel(\n getA(d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result["+(2*x+w)+"] = getChannel(\n getA(ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n ";this.userCode="\n void main() {\n ivec2 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n "+b+"\n\n "+m.output+" = result;\n }\n "},ZL=function(t,e,n,r,a){this.variableNames=["x"],this.outputShape=[];var i,o=e,s=t[3]-1;this.outputShape=t;var u="float("+n+") + float("+r+") * sum";i=.5===a?"inversesqrt("+u+")":1===a?"1.0/("+u+")":"exp(log("+u+") * float(-"+a+"));",this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -"+o+"; j <= "+o+"; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= "+s+") {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * "+i+";\n setOutput(val);\n }\n "},QL=function(t,e,n,r,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=t,this.depth=t[3],this.depthRadius=e,this.bias=n,this.alpha=r,this.beta=a,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < "+this.depth+"; ++d) {\n int depthBegin = int(max(0.0, float(d - "+e+")));\n int depthEnd = int(min(float("+this.depth+"),\n float(d + "+e+" + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = "+this.depth+";\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float("+r+") * norm + float("+n+");\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float("+r+")\n * float("+a+")\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * "+a+");\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n "},tz=function(t,e,n,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var i,o=e,s=t[3]-1;this.outputShape=t;var u="float("+n+") + float("+r+") * sum";i=.5===a?"inversesqrt("+u+")":1===a?"1.0/("+u+")":"exp(log("+u+") * float(-"+a+"));",this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < "+this.outputShape[3]+";\n bool hasNextRow = c < "+this.outputShape[2]+";\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - "+o+";\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - "+o+"; j <= "+o+"; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2("+s+"));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * "+i+";\n setOutput(result);\n }\n "},ez=function(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideHeight,n=t.strideWidth,r=t.dilationHeight,a=t.effectiveFilterHeight,i=t.effectiveFilterWidth,o=a-1-t.padInfo.top,s=i-1-t.padInfo.left,u=a*i-1;this.userCode="\n const ivec2 pads = ivec2("+o+", "+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+a+";\n wR += "+r+") {\n float dyR = float(dyRCorner + wR) / "+e+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+i+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+n+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = "+u+" - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * "+i+" + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n "},nz=function(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,a=t.dilationDepth,i=t.dilationHeight,o=t.dilationWidth,s=t.effectiveFilterDepth,u=t.effectiveFilterHeight,c=t.effectiveFilterWidth,l=s-1-t.padInfo.front,h=u-1-t.padInfo.top,f=c-1-t.padInfo.left,p=s*u*c-1;this.userCode="\n const ivec3 pads = ivec3("+l+", "+h+", "+f+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < "+s+";\n wD += "+a+") {\n float dyD = float(dyDCorner + wD) / "+e+".0;\n\n if (dyD < 0.0 || dyD >= "+t.outDepth+".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < "+u+";\n wR += "+i+") {\n float dyR = float(dyRCorner + wR) / "+n+".0;\n\n if (dyR < 0.0 || dyR >= "+t.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+c+";\n wC += "+o+") {\n float dyC = float(dyCCorner + wC) / "+r+".0;\n\n if (dyC < 0.0 || dyC >= "+t.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = "+p+" -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * "+u+" * "+c+" +\n wR * "+c+" + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n "},rz=function(t,e,n,r,a,i,o){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=null),void 0===o&&(o=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;var s=n?t[1]:t[2],u=Math.ceil(s/2),c=n?"i * 2, rc.y":"rc.y, i * 2",l=r?"rc.z, i * 2":"i * 2, rc.z",h=n?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],p="",d="";i&&(p=o?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+i+"\n }":"vec4 activation(vec4 x) {\n "+i+"\n }",d="result = activation(result);");var m=a?"result += getBiasAtOutCoords();":"";a&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),this.userCode="\n "+p+"\n\n const float sharedDimension = "+u+".0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n for (int i = 0; i < "+u+"; i++) {\n vec4 a = getMatrixA(rc.x, "+c+");\n vec4 b = getMatrixB(rc.x, "+l+");\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += ("+h[0]+" * "+f[0]+");\n result += ("+h[1]+" * "+f[1]+");\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n "+m+"\n\n "+d+"\n\n setOutput(result);\n }\n "},az=function(){function t(t,e,n){this.variableNames=["probs"],this.outputShape=[t,n],this.userCode="\n uniform float seed;\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < "+(e-1)+"; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float("+(e-1)+"));\n }\n "}return t.prototype.getCustomSetupFunc=function(t){var e=this;return function(n,r){null==e.seedLoc&&(e.seedLoc=n.getUniformLocation(r,"seed")),n.gl.uniform1f(e.seedLoc,t)}},t}(),iz=function(t,e,n,r){this.variableNames=["indices"],this.outputShape=[t,e],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float("+r+"), float("+n+"),\n float(index == coords.y)));\n }\n "},oz=function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=t;var e=t.length;if(0===e)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{var n=_M("rc",e),r=KM(e),a=function(t,e,n){if(1===t)return"rc > "+e[0];for(var r="",a=t-2;a<t;a++)r+=n[a]+" >= "+e[a],a<t-1&&(r+="||");return r}(e,t,n),i=function(t,e,n,r){if(1===t)return"";var a=r.slice(-2);return"\n int r = "+a[0]+";\n int c = "+a[1]+";\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= "+e+";\n bool rEdge = rp1 >= "+n+";\n "}(e,t[t.length-1],t[t.length-2],n),o=function(t,e){var n=t.length,r=function(t,e){for(var n=[],r=0;r<=1;r++)for(var a=0;a<=1;a++){for(var i=(0===r?"r":"rp1")+", "+(0===a?"c":"cp1"),o=2;o<t;o++)i=e[e.length-1-o]+","+i;n.push(i)}return n}(n,e);if(1===n)return"getA(rc),\n rc + 1 >= "+t[0]+" ? 0. : getA(rc + 1),\n 0, 0";return"getA("+r[0]+"),\n cEdge ? 0. : getA("+r[1]+"),\n rEdge ? 0. : getA("+r[2]+"),\n rEdge || cEdge ? 0. : getA("+r[3]+")"}(t,n);this.userCode="\n void main() {\n "+r+" rc = getOutputCoords();\n\n if("+a+") {\n setOutput(vec4(0));\n } else {\n "+i+"\n\n setOutput(vec4("+o+"));\n }\n }\n "}};var sz=function(t,e,n){this.variableNames=["x"],this.outputShape=e.map((function(e,n){return e[0]+t[n]+e[1]}));var r=t.length,a=KM(r),i=e.map((function(t){return t[0]})).join(","),o=e.map((function(e,n){return e[0]+t[n]})).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?"\n "+a+" start = "+a+"("+i+");\n "+a+" end = "+a+"("+o+");\n\n void main() {\n "+a+" outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(float("+n+"));\n } else {\n "+a+" coords = outC - start;\n setOutput(getX("+s+"));\n }\n }\n ":"\n int start = "+i+";\n int end = "+o+";\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(float("+n+"));\n } else {\n setOutput(getX(outC - start));\n }\n }\n "},uz=function(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map((function(e,n){return e[0]+t[n]+e[1]}));for(var r=t.length,a=KM(r),i=e.map((function(t){return t[0]})).join(","),o=e.map((function(e,n){return e[0]+t[n]})).join(","),s=_M("rc",r),u=_M("source",r),c=s[r-1]+" < "+this.outputShape[r-1],l=1===r?"source":"vec2("+u.slice(-2).join()+")",h=[a+" rc = outputLoc;",s[r-1]+" += 1;\n if("+c+") {\n ",1===r?"":"}\n rc = outputLoc;\n "+s[r-2]+" += 1;\n if("+s[r-2]+" < "+this.outputShape[r-2]+") {",1===r?"":" "+s[r-1]+" += 1;\n if("+c+") {"],f=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",p="",d=0,m=1===r?2:4;d<m;d++)p+="\n "+h[d]+"\n if ("+f+") {\n result["+d+"] = float("+n+");\n } else {\n "+a+" source = rc - start;\n result["+d+"] = getChannel(getX("+u.join()+"), "+l+");\n }\n ";p+=1===r?"} ":"}}",this.userCode="\n const "+a+" start = "+a+"("+i+");\n const "+a+" end = "+a+"("+o+");\n\n void main() {\n "+a+" outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n "+p+"\n setOutput(result);\n }\n "},cz=function(t,e,n,r,a){if(void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");var i=t.filterWidth,o=t.strideHeight,s=t.strideWidth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterHeight,h=t.effectiveFilterWidth,f=t.padInfo.top,p=t.padInfo.left;this.outputShape=t.outShape;var d="avg"===e,m="((batch * "+t.inHeight+" + xR) * "+t.inWidth+" + xC) * "+t.inChannels+" + d",v="(xR * "+t.inWidth+" + xC) * "+t.inChannels+" + d",g="0.0";if(d||(g="-1.0 / 1e-20"),n){this.userCode="\n const ivec2 strides = ivec2("+o+", "+s+");\n const ivec2 pads = ivec2("+f+", "+p+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < "+l+";\n wR += "+u+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+h+";\n wC += "+c+") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = "+(r?a?m:v:"wR * "+h+" + wC")+";\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n "}else{var y=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===e&&(y="avgValue / count");var b=4*Math.floor(i/4),x=i%4,w="\n if ("+d+") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n ";this.userCode="\n const ivec2 strides = ivec2("+o+", "+s+");\n const ivec2 pads = ivec2("+f+", "+p+");\n const float initializationValue = "+g+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= "+t.inWidth+") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4("+g+");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < "+l+";\n wR += "+u+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+b+"; wC += 4) {\n int xC = xCCorner + wC * "+c+";\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+c+", d),\n getValue(batch, xR, xC + 2 * "+c+", d),\n getValue(batch, xR, xC + 3 * "+c+", d)\n );\n\n "+w+"\n }\n\n int xC = xCCorner + "+b+";\n if ("+(1===x)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+w+"\n } else if ("+(2===x)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+c+", d),\n initializationValue,\n initializationValue\n );\n\n "+w+"\n } else if ("+(3===x)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+c+", d),\n getValue(batch, xR, xC + 2 * "+c+", d),\n initializationValue\n );\n\n "+w+"\n }\n }\n setOutput("+y+");\n }\n "}},lz=function(t,e,n,r,a){if(void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");var i=t.filterWidth,o=t.strideDepth,s=t.strideHeight,u=t.strideWidth,c=t.dilationDepth,l=t.dilationHeight,h=t.dilationWidth,f=t.effectiveFilterDepth,p=t.effectiveFilterHeight,d=t.effectiveFilterWidth,m=t.padInfo.front,v=t.padInfo.top,g=t.padInfo.left;this.outputShape=t.outShape;var y="avg"===e,b="0.0";if(y||(b="-1.0 / 1e-20"),n){this.userCode="\n const ivec3 strides =\n ivec3("+o+", "+s+", "+u+");\n const ivec3 pads = ivec3("+m+", "+v+", "+g+");\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < "+f+";\n wD += "+c+") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= "+t.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+p+";\n wR += "+l+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+d+";\n wC += "+h+") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+t.inWidth+") {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = "+(r?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 * "+p+" * "+d+" +\n wR * "+d+" + wC")+";\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n "}else{var x=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===e&&(x="avgValue / count");var w=4*Math.floor(i/4),k=i%4,S="\n if ("+y+") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n ";this.userCode="\n const ivec3 strides =\n ivec3("+o+", "+s+", "+u+");\n const ivec3 pads = ivec3("+m+", "+v+", "+g+");\n const float initializationValue = "+b+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= "+t.inWidth+") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4("+b+");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < "+f+";\n wD += "+c+") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= "+t.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+p+";\n wR += "+l+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+t.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+w+"; wC += 4) {\n int xC = xCCorner + wC * "+h+";\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+h+", ch),\n getValue(batch, xD, xR, xC + 2 * "+h+", ch),\n getValue(batch, xD, xR, xC + 3 * "+h+", ch)\n );\n\n "+S+"\n }\n\n int xC = xCCorner + "+w+";\n if ("+(1===k)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+S+"\n } else if ("+(2===k)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+h+", ch),\n initializationValue,\n initializationValue\n );\n\n "+S+"\n } else if ("+(3===k)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+h+", ch),\n getValue(batch, xD, xR, xC + 2 * "+h+", ch),\n initializationValue\n );\n\n "+S+"\n }\n }\n setOutput("+x+");\n }\n }\n "}},hz=function(t,e){this.variableNames=["x"];var n=t.windowSize,r=t.batchSize,a=t.inSize,i=Math.ceil(a/n);this.outputShape=[r,i];var o="0.0",s="";"prod"===e?o="1.0":"min"===e?(o="1.0 / 1e-20",s="min"):"max"===e&&(o="-1.0 / 1e-20",s="max");var u=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===e?u="sumValue":"prod"===e?u="prodValue":"all"===e?u="allValue":"any"===e&&(u="anyValue");var c=4*Math.floor(n/4),l=n%4,h="\n if ("+("sum"===e)+") {\n sumValue += dot(values, ones);\n } else if ("+("prod"===e)+") {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = "+s+"(values, minMaxValue);\n }\n ",f="vec4";"all"===e?(o="1.0",h="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",f="bvec4"):"any"===e&&(o="0.0",h="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",f="bvec4");var p="";a%n>0&&(p="\n if (inIdx < 0 || inIdx >= "+a+") {\n return initializationValue;\n }\n "),this.userCode="\n const float initializationValue = "+o+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n "+p+"\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * "+n+";\n\n vec4 minMaxValue = vec4("+o+");\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < "+c+"; i += 4) {\n int inIdx = inOffset + i;\n "+f+" values = "+f+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n "+h+"\n }\n\n int inIdx = inOffset + "+c+";\n if ("+(1===l)+") {\n "+f+" values = "+f+"(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+h+"\n } else if ("+(2===l)+") {\n "+f+" values = "+f+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n "+h+"\n } else if ("+(3===l)+") {\n "+f+" values = "+f+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n "+h+"\n }\n setOutput("+u+");\n }\n "},fz=function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var n="",r=0;r<4;r++){var a="thisRC = rc;";r%2==1&&(a+="thisRC.z += 1;"),r>1&&(a+="thisRC.y += 1;"),n+="\n "+a+"\n "+(r>0?"if(thisRC.y < rows && thisRC.z < cols){":"")+"\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result["+r+"] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n "+(r>0?"}":"")+"\n "}this.userCode="\n "+("\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n "+FM(["r","c","d"],e)+"\n return ivec3(r, c, d);\n }\n \n ")+MM(t)+"\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = "+t[1]+";\n int cols = "+t[2]+";\n\n "+n+"\n\n setOutput(result);\n }\n "};var pz=function(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var r=e.shape,a=r[1],i=r[2],o=t.shape,s=o[1],u=o[2],c=[n&&s>1?a-1:a,n&&u>1?i-1:i],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],h=c[0]/l[0],f=c[1]/l[1],p=1/h,d=1/f,m=2*Math.ceil(p)+2,v=2*Math.ceil(d)+2;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float("+h+");\n const float widthScale = float("+f+");\n\n const float invHeightScale = float("+p+");\n const float invWidthScale = float("+d+");\n\n const int winHeight = int("+m+");\n const int winWidth = int("+v+");\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= "+s+") {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= "+u+") {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), "+(a-1)+".0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), "+(i-1)+".0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n "},dz=function(t,e,n,r){this.variableNames=["A"],this.outputShape=[];var a=t[0],i=t[1],o=t[2],s=t[3];this.outputShape=[a,e,n,s];var u=[r&&e>1?i-1:i,r&&n>1?o-1:o],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+");\n const vec2 inputShapeRC = vec2("+i+".0, "+o+".0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(sourceFracIndexRC);\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n "},mz=function(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var a=t[0],i=t[1],o=t[2],s=t[3];this.outputShape=[a,e,n,s];var u=[r&&e>1?i-1:i,r&&n>1?o-1:o],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode="\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+",\n "+u[1]/c[1]+");\n const vec3 inputShapeRC = vec3("+i+".0, "+o+".0,\n "+o+".0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = vec3(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(sourceFracIndexRC);\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < "+(s-1)+";\n bool hasNextRow = coords.z < "+(n-1)+";\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n "},vz=function(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var r=e.shape,a=r[1],i=r[2],o=t.shape,s=o[1],u=o[2],c=[n&&s>1?a-1:a,n&&u>1?i-1:i],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],h=c[0]/l[0],f=c[1]/l[1],p=1/h,d=1/f,m=2*Math.ceil(p)+2,v=2*Math.ceil(d)+2;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float("+h+");\n const float widthScale = float("+f+");\n\n const float invHeightScale = float("+p+");\n const float invWidthScale = float("+d+");\n\n const int winHeight = int("+m+");\n const int winWidth = int("+v+");\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= "+s+") {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= "+u+") {\n continue;\n }\n\n float sourceFracRow =\n float("+c[0]+") *\n (float(dyR) / float("+l[0]+"));\n\n float sourceFracCol =\n float("+c[1]+") *\n (float(dyC) / float("+l[1]+"));\n\n int sourceNearestRow = int(min(\n float(int("+a+") - 1),\n "+n+" ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int("+i+") - 1),\n "+n+" ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n "},gz=function(t,e,n,r){this.variableNames=["A"],this.outputShape=[];var a=t[0],i=t[1],o=t[2],s=t[3];this.outputShape=[a,e,n,s];var u=[r&&e>1?i-1:i,r&&n>1?o-1:o],c=[r&&e>1?e-1:e,r&&n>1?n-1:n],l=r?"0.5":"0.0";this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+u[0]/c[0]+",\n "+u[1]/c[1]+");\n const vec2 inputShapeRC = vec2("+i+".0, "+o+".0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + "+l+")));\n\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n "},yz=function(t,e){this.variableNames=["x"];var n=t.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");if(this.outputShape=t,1!==n){var r=t.map((function(n,r){return function(n){return-1!==e.indexOf(n)&&1!==t[n]?t[n]+" - coords["+n+"] - 1":"coords["+n+"]"}(r)})).join(","),a=KM(n);this.userCode="\n void main() {\n "+a+" coords = getOutputCoords();\n setOutput(getX("+r+"));\n }\n "}else this.userCode="\n void main() {\n int coord = getOutputCoords();\n setOutput(getX("+t[0]+" - coord - 1));\n }\n "},bz=function(t,e){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var n=t.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");this.outputShape=t;var r=_M("rc",n),a=r[n-1]+" + 1 < "+this.outputShape[n-1],i=r[n-2]+" + 1 < "+this.outputShape[n-2],o=KM(n);function s(n){var r=t.map((function(r,a){return function(n,r){return-1!==e.indexOf(n)&&1!==t[n]?t[n]+" - "+r[n]+" - 1":""+r[n]}(a,n)}));return"getChannel(getX("+r.join(",")+"), vec2("+r.slice(-2).join(",")+"))"}this.userCode=1===n?"\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX("+t[0]+" - rc - 1),\n "+t[0]+" - rc - 1);\n if("+a+"){\n result.g = getChannel(getX("+t[0]+" - (rc + 1) - 1),\n "+t[0]+" - (rc + 1) - 1);\n }\n setOutput(result);\n }\n ":"\n void main() {\n "+o+" rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = "+function(t){return s(t)}(r.slice())+";\n if("+a+"){\n result.g = "+function(t){return t[n-1]="("+t[n-1]+" + 1)",s(t)}(r.slice())+";\n }\n if("+i+") {\n result.b = "+function(t){return t[n-2]="("+t[n-2]+" + 1)",s(t)}(r.slice())+";\n if("+a+") {\n result.a = "+function(t){return t[n-1]="("+t[n-1]+" + 1)",t[n-2]="("+t[n-2]+" + 1)",s(t)}(r.slice())+";\n }\n }\n setOutput(result);\n }\n "},xz=function(t,e,n,r,a,i,o){this.variableNames=["updates","indices","defaultValue"],this.outputShape=i;var s=KM(a.length),u=KM(i.length),c="";1===n?c="i":2===n&&(c="i, j");var l="getIndices("+c+")",h="";1===r?h="i":2===r&&(h="i, coords[1]");var f="getUpdates("+h+")",p=e>1?"strides[j]":"strides";this.userCode="\n "+s+" strides = "+s+"("+a+");\n\n void main() {\n "+u+" coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < "+t+"; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < "+e+"; j++) {\n int index = round("+l+");\n flattenedIndex += index * "+p+";\n }\n if (flattenedIndex == coords[0]) {\n sum += "+f+";\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n "},wz=function(t,e){this.variableNames=["x","segmentIds"];var n=t.windowSize,r=t.batchSize,a=t.inSize,i=t.numSegments,o=i*Math.ceil(a/n);this.outputShape=[r,o];var s=4*Math.floor(n/4),u=n%4,c="\n sumValue += dot(values, segFilter);\n ",l="";a%n>0&&(l="\n if (inIdx < 0 || inIdx >= "+a+") {\n return initializationValue;\n }\n ");var h="";a%n>0&&(h="\n if (inIdx < 0 || inIdx >= "+a+") {\n return -1.0;\n }\n "),this.userCode="\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n "+l+"\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n "+h+"\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n "+i+")) * float("+n+"));\n int currentSeg = int(mod(float(outIdx), float("+i+")));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < "+s+"; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n "+c+"\n }\n\n int inIdx = inOffset + "+s+";\n if ("+(1===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n "+c+"\n } else if ("+(2===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n "+c+"\n } else if ("+(3===u)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n "+c+"\n }\n setOutput(sumValue);\n }\n "},kz=function(t,e,n){var r,a;if(this.variableNames=["c","a","b"],this.outputShape=e,n>4)throw Error("Where for rank "+n+" is not yet supported");if(1===n)a="resRC",r="resRC";else{for(var i=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],s=[],u=0;u<e.length;u++)s.push(""+i[u]),u<t&&o.push(""+i[u]);r=o.join(),a=s.join()}var c=KM(n);this.userCode="\n void main() {\n "+c+" resRC = getOutputCoords();\n float cVal = getC("+r+");\n if (cVal >= 1.0) {\n setOutput(getA("+a+"));\n } else {\n setOutput(getB("+a+"));\n }\n }\n "},Sz=function(){function t(t){this.variableNames=["source"],this.outputShape=t,this.rank=t.length;var e,n=KM(this.rank),r="uniform int start["+this.rank+"];",a=function(t){if(1===t)return"sourceLoc";if(t<=6)return Cz.slice(0,t).map((function(t){return"sourceLoc."+t})).join(",");throw Error("Slicing for rank "+t+" is not yet supported")}(this.rank);e="\n "+n+" sourceLoc;\n "+n+" coords = getOutputCoords();\n "+t.map((function(t,e){return"sourceLoc."+Cz[e]+" = start["+e+"] + coords."+Cz[e]+";"})).join("\n")+"\n ",this.userCode="\n "+r+"\n void main() {\n "+e+"\n setOutput(getSource("+a+"));\n }\n "}return t.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(n,r){null==e.startLoc&&(e.startLoc=n.getUniformLocationNoThrow(r,"start"),null==e.startLoc)||n.gl.uniform1iv(e.startLoc,t)}},t}(),Cz=["x","y","z","w","u","v"];var Rz=function(){function t(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length;var e=KM(this.rank),n=_M("coords",this.rank),r=_M("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":"vec2("+r.slice(-2).join()+")",i="getChannel(getSource("+r.join()+"), "+a+")",o="\n result.x = "+i+";\n if (++"+n[this.rank-1]+" < "+t[this.rank-1]+") {\n ++"+r[this.rank-1]+";\n result.y = "+i+";\n --"+r[this.rank-1]+";\n }\n ",s=1===this.rank?"":"\n --"+n[this.rank-1]+";\n if (++"+n[this.rank-2]+" < "+t[this.rank-2]+") {\n ++"+r[this.rank-2]+";\n result.z = "+i+";\n if (++"+n[this.rank-1]+" < "+t[this.rank-1]+") {\n ++"+r[this.rank-1]+";\n result.w = "+i+";\n }\n }\n ",u=this.rank<=4?"sourceLoc = coords +\n "+e+"("+t.map((function(t,e){return"start["+e+"]"})).join()+");":t.map((function(t,e){return r[e]+" = "+n[e]+" + start["+e+"];"})).join("\n");this.userCode="\n uniform int start["+this.rank+"];\n void main() {\n "+e+" coords = getOutputCoords();\n "+e+" sourceLoc;\n "+u+"\n vec4 result = vec4(0.);\n "+o+"\n "+s+"\n setOutput(result);\n }\n "}return t.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(n,r){null==e.startLoc&&(e.startLoc=n.getUniformLocationNoThrow(r,"start"),null==e.startLoc)||n.gl.uniform1iv(e.startLoc,t)}},t}(),Nz=function(t,e,n){this.variableNames=["x"],this.outputShape=n;var r=n.length,a=KM(n.length),i=KM(n.length),o="";if(1===r)o="coords * strides + begin";else{var s=0;o=n.map((function(t,e){return s++,1===n.length?"coords * strides["+e+"] + begin["+e+"]":"coords["+(s-1)+"] * strides["+e+"] + begin["+e+"]"})).join(",")}this.userCode="\n "+a+" begin = "+a+"("+t+");\n "+a+" strides = "+a+"("+e+");\n\n void main() {\n "+i+" coords = getOutputCoords();\n setOutput(getX("+o+"));\n }\n "},Ez=function(){function t(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}var e=t.prototype;return e.acquireTexture=function(t,e,n){var r,a=Iz(e,n),i=Az(t,a,n);if(i in this.freeTextures||(this.freeTextures[i]=[]),i in this.usedTextures||(this.usedTextures[i]=[]),this.freeTextures[i].length>0){this.numFreeTextures--,this.numUsedTextures++,this.log();var o=this.freeTextures[i].shift();return this.usedTextures[i].push(o),o}return this.numUsedTextures++,this.log(),a===JF.PACKED_2X2_FLOAT32?r=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):a===JF.PACKED_2X2_FLOAT16?r=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):a===JF.UNPACKED_FLOAT32?r=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):a===JF.UNPACKED_FLOAT16?r=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):a===JF.PACKED_4X1_UNSIGNED_BYTE&&(r=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[i].push(r),r},e.releaseTexture=function(t,e,n,r){if(null!=this.freeTextures){var a=Az(e,Iz(n,r),r);a in this.freeTextures||(this.freeTextures[a]=[]),this.freeTextures[a].push(t),this.numFreeTextures++,this.numUsedTextures--;var i=this.usedTextures[a],o=i.indexOf(t);if(o<0)throw new Error("Cannot release a texture that was never provided by this texture manager");i.splice(o,1),this.log()}},e.log=function(){if(this.logEnabled){var t=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+t+")")}},e.getNumUsedTextures=function(){return this.numUsedTextures},e.getNumFreeTextures=function(){return this.numFreeTextures},e.dispose=function(){var t=this;if(null!=this.freeTextures){for(var e in this.freeTextures)this.freeTextures[e].forEach((function(e){t.gpgpu.deleteMatrixTexture(e)}));for(var n in this.usedTextures)this.usedTextures[n].forEach((function(e){t.gpgpu.deleteMatrixTexture(e)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0}},t}();function Iz(t,e){if(t===YF.UPLOAD)return JF.PACKED_2X2_FLOAT32;if(t===YF.RENDER||null==t)return function(t){return nv().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?JF.PACKED_2X2_FLOAT32:JF.UNPACKED_FLOAT32:t?JF.PACKED_2X2_FLOAT16:JF.UNPACKED_FLOAT16}(e);if(t===YF.DOWNLOAD||t===YF.PIXELS)return JF.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+t)}function Az(t,e,n){return t[0]+"_"+t[1]+"_"+e+"_"+n}var Tz=function(t,e){this.variableNames=["A"];for(var n=new Array(t.length),r=0;r<n.length;r++)n[r]=t[r]*e[r];this.outputShape=n,this.rank=n.length;var a=KM(this.rank),i=function(t){var e=t.length;if(e>5)throw Error("Tile for rank "+e+" is not yet supported");if(1===e)return"imod(resRC, "+t[0]+")";for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],a=0;a<t.length;a++)r.push("imod("+n[a]+", "+t[a]+")");return r.join()}(t);this.userCode="\n void main() {\n "+a+" resRC = getOutputCoords();\n setOutput(getA("+i+"));\n }\n "};var Dz=function(t,e){this.variableNames=["A"],this.outputShape=t,this.userCode="\n float unaryOperation(float x) {\n "+e+"\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n "},_z="if (isnan(x)) return x;",Oz="return abs(x);",Fz=_z+"\n return (x < 0.0) ? 0.0 : x;\n",Mz=_z+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",Lz="return (x >= 0.0) ? x : (exp(x) - 1.0);";var zz="return -x;",Bz="return ceil(x);",Pz="return floor(x);",Wz="return exp(x);",Vz="return exp(x) - 1.0;",Uz="return x;",jz="\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",Gz="\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",qz="\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n",Hz=function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n vec4 unaryOperation(vec4 x) {\n "+e+"\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n "},Kz=function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t;var e=t.length,n=_M("rc",e),r=KM(e),a=function(t,e){if(1===t)return"rc";for(var n="",r=0;r<t;r++)n+=e[r],r<t-1&&(n+=",");return n}(e,n),i=n.slice(-2),o=e<=1?"rc":"vec2("+i.join(",")+")";this.userCode="\n void main() {\n "+r+" rc = getOutputCoords();\n vec4 packedInput = getA("+a+");\n\n setOutput(getChannel(packedInput, "+o+"));\n }\n "},Xz=JS,Yz=xN,Jz=wN,$z=kN,Zz=iS,Qz={};function tB(t,e){if(void 0===e&&(e=!1),"linear"===t)return"return x;";if("relu"===t)return e?jz:Fz;if("elu"===t)return e?qz:Lz;if("relu6"===t)return e?Gz:Mz;if("prelu"===t)return e?cL:sL;throw new Error("Activation "+t+" has not been implemented for the WebGL backend.")}var eB=function(t){function e(e){var n,r;if((n=t.call(this)||this).pendingRead=new WeakMap,n.pendingDisposal=new WeakSet,n.dataRefCount=new WeakMap,n.numBytesInGPU=0,n.uploadWaitMs=0,n.downloadWaitMs=0,n.warnedAboutMemory=!1,n.pendingDeletes=0,n.disposed=!1,!nv().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==e){var a=QF(nv().getNumber("WEBGL_VERSION"));n.binaryCache=((r=nv().getNumber("WEBGL_VERSION"))in Qz||(Qz[r]={}),Qz[r]),n.gpgpu=new YL(a),n.canvas=a.canvas,n.gpgpuCreatedLocally=!0}else n.gpgpu=e,n.binaryCache={},n.gpgpuCreatedLocally=!1,n.canvas=e.gl.canvas;return n.textureManager=new Ez(n.gpgpu),n.numMBBeforeWarning=null==nv().global.screen?1024:nv().global.screen.height*nv().global.screen.width*window.devicePixelRatio*600/1024/1024,n.texData=new RN(Jm(n),Cb()),n}Gm(e,t);var n=e.prototype;return n.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes},n.write=function(t,e,n){if(nv().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===n&&null!=t)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var r={};return this.texData.set(r,{shape:e,dtype:n,values:t,usage:YF.UPLOAD}),r},n.move=function(t,e,n,r){if(nv().getBool("DEBUG")&&this.checkNumericalProblems(e),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(t,{shape:n,dtype:r,values:e,usage:YF.UPLOAD})},n.readSync=function(t){var e=this.texData.get(t),n=e.values,r=e.dtype,a=e.complexTensors,i=e.slice,o=e.shape,s=e.isPacked;if(null!=i){var u;u=s?new Hz(o,Uz):new Dz(o,Uz);var c=this.runWebGLProgram(u,[{dataId:t,shape:o,dtype:r}],r),l=this.readSync(c.dataId);return this.disposeData(c.dataId),l}if(null!=n)return this.convertAndCacheOnCPU(t);if("string"===r)return n;var h,f,p=null!=this.activeTimers;(p&&(h=Jv()),"complex64"===r)?f=uN(a.real.dataSync(),a.imag.dataSync()):f=this.getValuesFromTexture(t);return p&&(this.downloadWaitMs+=Jv()-h),this.convertAndCacheOnCPU(t,f)},n.read=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a,i,o,s,u,c,l,h,f,p,d,m,v,g,y,b,x,w,k,S;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.pendingRead.has(e)){t.next=3;break}return n=this.pendingRead.get(e),t.abrupt("return",new Promise((function(t){return n.push(t)})));case 3:if(r=this.texData.get(e),a=r.values,i=r.shape,o=r.slice,s=r.dtype,u=r.complexTensors,c=r.isPacked,null==o){t.next=11;break}return l=c?new Hz(i,Uz):new Dz(i,Uz),h=this.runWebGLProgram(l,[{dataId:e,shape:i,dtype:s}],s),f=this.read(h.dataId),this.disposeData(h.dataId),t.abrupt("return",f);case 11:if(null==a){t.next=13;break}return t.abrupt("return",this.convertAndCacheOnCPU(e));case 13:if(nv().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")||2!==nv().getNumber("WEBGL_VERSION")){t.next=15;break}throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");case 15:if(p=null,"complex64"!==s&&nv().get("WEBGL_BUFFER_SUPPORTED")&&(d=this.decode(e),v=this.texData.get(d.dataId),p=(m=this.gpgpu).createBufferFromTexture.apply(m,[v.texture].concat(eM(i)))),this.pendingRead.set(e,[]),"complex64"===s){t.next=21;break}return t.next=21,this.gpgpu.createAndWaitForFence();case 21:if("complex64"!==s){t.next=30;break}return t.next=24,Promise.all([u.real.data(),u.imag.data()]);case 24:y=t.sent,b=y[0],x=y[1],g=uN(b,x),t.next=31;break;case 30:null==p?g=this.getValuesFromTexture(e):(w=wv(i),g=this.gpgpu.downloadFloat32MatrixFromBuffer(p,w));case 31:return null!=d&&this.disposeData(d.dataId),k=this.convertAndCacheOnCPU(e,g),S=this.pendingRead.get(e),this.pendingRead.delete(e),S.forEach((function(t){return t(k)})),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e),this.pendingDeletes--),t.abrupt("return",k);case 38:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.checkNumericalProblems=function(t){if(null!=t)for(var e=0;e<t.length;e++){var n=t[e];if(!iM(n)){if(nv().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error("The value "+n+" cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'");throw Error("The value "+n+" cannot be represented on this device.")}}},n.getValuesFromTexture=function(t){var e=this.texData.get(t),n=e.shape,r=e.dtype,a=e.isPacked,i=wv(n);if(nv().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var o,s=this.decode(t),u=this.texData.get(s.dataId),c=(o=this.gpgpu).downloadMatrixFromPackedTexture.apply(o,[u.texture].concat(eM(n))).subarray(0,i);return this.disposeData(s.dataId),c}var l=nv().getBool("WEBGL_PACK")&&!0===a,h=l?xM(n):n,f=l?new ML(h):new FL(h),p=this.runWebGLProgram(f,[{shape:h,dtype:r,dataId:t}],"float32"),d=this.texData.get(p.dataId),m=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(d.texture,d.texShape[0],d.texShape[1]).subarray(0,i);return this.disposeData(p.dataId),m},n.time=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n,r,a,i,o,s,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.activeTimers,r=[],a=!1,null==this.programTimersStack?(this.programTimersStack=r,a=!0):this.activeTimers.push(r),this.activeTimers=r,e(),i=xv(this.activeTimers.map((function(t){return t.query}))).filter((function(t){return null!=t})),o=xv(this.activeTimers.map((function(t){return t.name}))).filter((function(t){return null!=t})),this.activeTimers=n,a&&(this.programTimersStack=null),s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null},!(nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)){t.next=19;break}return t.next=14,Promise.all(i);case 14:u=t.sent,s.kernelMs=vv(u),s.getExtraProfileInfo=function(){return u.map((function(t,e){return{name:o[e],ms:t}})).map((function(t){return t.name+": "+t.ms})).join(", ")},t.next=20;break;case 19:s.kernelMs={error:"WebGL query timers are not supported in this environment."};case 20:return this.uploadWaitMs=0,this.downloadWaitMs=0,t.abrupt("return",s);case 23:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.memory=function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU}},n.startTimer=function(){return nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Jv(),endMs:null}},n.endTimer=function(t){return nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),t):(t.endMs=Jv(),t)},n.getQueryTime=function(){var t=Vm(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(nv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)){t.next=2;break}return t.abrupt("return",this.gpgpu.waitForQueryAndGetTime(e));case 2:return n=e,t.abrupt("return",n.endMs-n.startMs);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.disposeData=function(t){if(!this.pendingDisposal.has(t)){if(this.pendingRead.has(t))return this.pendingDisposal.add(t),void this.pendingDeletes++;if(this.texData.has(t)){this.releaseGPUData(t);var e=this.texData.get(t).complexTensors;null!=e&&(e.real.dispose(),e.imag.dispose()),this.texData.delete(t)}}},n.releaseGPUData=function(t){var e=this.texData.get(t),n=e.texture,r=e.dtype,a=e.texShape,i=e.usage,o=e.isPacked,s=e.slice,u=s&&s.origDataId||t,c=this.dataRefCount.get(u);c>1?this.dataRefCount.set(u,c-1):(this.dataRefCount.delete(u),null!=n&&(this.numBytesInGPU-=this.computeBytes(a,r),this.textureManager.releaseTexture(n,a,i,o)));var l=this.texData.get(t);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null},n.getTexture=function(t){return this.uploadToGPU(t),this.texData.get(t).texture},n.getDataInfo=function(t){return this.texData.get(t)},n.getCPUBackend=function(){return nv().getBool("WEBGL_CPU_FORWARD")?(null==this.cpuBackend&&(this.cpuBackend=Cb().findBackend("cpu")),this.cpuBackend):null},n.shouldExecuteOnCPU=function(t,e){var n=this;return void 0===e&&(e=128),null!=this.getCPUBackend()&&t.every((function(t){return null==n.texData.get(t.dataId).texture&&wv(t.shape)<e}))},n.getGPGPUContext=function(){return this.gpgpu},n.complex=function(t,e){var n=this.makeOutput(t.shape,"complex64");return this.texData.get(n.dataId).complexTensors={real:Cb().keep(t.clone()),imag:Cb().keep(e.clone())},n},n.real=function(t){return this.texData.get(t.dataId).complexTensors.real.clone()},n.imag=function(t){return this.texData.get(t.dataId).complexTensors.imag.clone()},n.slice=function(t,e,n){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.slice(t,e,n);if(0===wv(n))return ay([],n,t.dtype);var r=this.texData.get(t.dataId).isPacked,a=tw(t.shape,e,n);if(r||!a){var i=nv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Rz(n):new Sz(n),o=i.getCustomSetupFunc(e);return this.compileAndRun(i,[t],null,o)}return this.uploadToGPU(t.dataId),this.shallowSlice(t,e,n)},n.shallowSlice=function(t,e,n){var r=this.texData.get(t.dataId),a=this.makeOutput(n,t.dtype),i=this.texData.get(a.dataId);Object.assign(i,r),i.shape=n,i.dtype=t.dtype;var o=ew(e,t.strides);r.slice&&(o+=r.slice.flatOffset),i.slice={flatOffset:o,origDataId:r.slice&&r.slice.origDataId||t.dataId};var s=this.dataRefCount.get(i.slice.origDataId)||1;return this.dataRefCount.set(i.slice.origDataId,s+1),a},n.stridedSlice=function(t,e,n,r){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.stridedSlice(t,e,n,r);var a=$x(e,n,r);if(a.some((function(t){return 0===t})))return ay([],a);var i=new Nz(e,r,a);return this.compileAndRun(i,[t])},n.reverse=function(t,e){var n=nv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new bz(t.shape,e):new yz(t.shape,e);return this.compileAndRun(n,[t])},n.concat=function(t,e){if("complex64"===t[0].dtype){var n=t.map((function(t){return ny(t)})),r=t.map((function(t){return ry(t)}));return ey(this.concat(n,e),this.concat(r,e))}if(this.shouldExecuteOnCPU(t))return this.cpuBackend.concat(t,e);if(1===t.length)return t[0];if(t.length>nv().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var a=Math.floor(t.length/2),i=this.concat(t.slice(0,a),e),o=this.concat(t.slice(a),e);return this.concat([i,o],e)}if(nv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&t[0].rank>1){var s=new mL(t.map((function(t){return t.shape})),e);return this.compileAndRun(s,t)}var u=Qg(t.map((function(t){return t.shape})),e),c=t.map((function(t){return t.as2D(-1,wv(t.shape.slice(e)))})),l=new dL(c.map((function(t){return t.shape})));return this.compileAndRun(l,c).reshape(u)},n.neg=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.neg(t);if(nv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,zz,t.dtype);var e=new Dz(t.shape,zz);return this.compileAndRun(e,[t])},n.batchMatMul=function(t,e,n,r){var a=n?t.shape[2]:t.shape[1],i=r?e.shape[1]:e.shape[2],o=n?t.shape[1]:t.shape[2],s=t.shape[0];if((1===a||1===i)&&o>1e3){n&&(t=Bx(t,[0,2,1])),r&&(e=Bx(e,[0,2,1]));var u=1===i?t:t.as3D(s,o,1),c=1===i?2:1,l=1===i?e.as3D(s,1,o):e;return this.multiply(u,l).sum(c,!0)}var h=wg(t.dtype,e.dtype),f=new rz(t.shape,[s,a,i],n,r);return this.compileAndRun(f,[t,e],h)},n.fusedBatchMatMul=function(t){var e=t.a,n=t.b,r=t.transposeA,a=t.transposeB,i=t.bias,o=t.activation,s=t.preluActivationWeights,u=r?e.shape[2]:e.shape[1],c=a?n.shape[1]:n.shape[2],l=e.shape[0],h=wg(e.dtype,n.dtype),f=null!=i,p=null!=s,d=o?tB(o,!0):null,m=new rz(e.shape,[l,u,c],r,a,f,d,p),v=[e,n];return i&&v.push(i),s&&v.push(s),this.compileAndRun(m,v,h)},n.multiply=function(t,e){if("complex64"===t.dtype){var n=this.texData.get(t.dataId),r=this.texData.get(e.dataId),a=new rL(eL,t.shape,e.shape),i=new rL(nL,t.shape,e.shape),o=[this.makeComplexComponentTensorInfo(t,n.complexTensors.real),this.makeComplexComponentTensorInfo(t,n.complexTensors.imag),this.makeComplexComponentTensorInfo(e,r.complexTensors.real),this.makeComplexComponentTensorInfo(e,r.complexTensors.imag)],s=this.compileAndRun(a,o),u=this.compileAndRun(i,o),c=this.complex(s,u);return s.dispose(),u.dispose(),c}if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.multiply(t,e);if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,oL,t.dtype);var l=new uL(oL,t.shape,e.shape);return this.compileAndRun(l,[t,e],t.dtype)},n.batchNorm=function(t,e,n,r,a,i){var o=[t,e,n],s=null;null!=r&&(s=r.shape,o.push(r));var u=null;if(null!=a&&(u=a.shape,o.push(a)),nv().getBool("WEBGL_PACK_NORMALIZATION")){var c=new tL(t.shape,e.shape,n.shape,s,u,i);return this.compileAndRun(c,o)}var l=new QM(t.shape,e.shape,n.shape,s,u,i);return this.compileAndRun(l,o)},n.localResponseNormalization4D=function(t,e,n,r,a){var i=nv().getBool("WEBGL_PACK_NORMALIZATION")?new tz(t.shape,e,n,r,a):new ZL(t.shape,e,n,r,a);return this.compileAndRun(i,[t])},n.LRNGrad=function(t,e,n,r,a,i,o){var s=new QL(e.shape,r,a,i,o);return this.compileAndRun(s,[e,n,t])},n.tile=function(t,e){if("string"===t.dtype){var n=this.readSync(t.dataId).map((function(t){return tg(t)})),r=Sy(t.shape,t.dtype,n);return Jz(r,e)}var a=new Tz(t.shape,e);return this.compileAndRun(a,[t])},n.pad=function(t,e,n){var r=nv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new uz(t.shape,e,n):new sz(t.shape,e,n);return this.compileAndRun(r,[t])},n.gather=function(t,e,n){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.gather(t,e,n);var r=new UL(t.shape,e.size,n);return this.compileAndRun(r,[t,e])},n.batchToSpaceND=function(t,e,n){gv(t.rank<=4,(function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"}));var r=e.reduce((function(t,e){return t*e})),a=nN(t.shape,e,r),i=rN(a.length,e.length),o=aN(t.shape,e,r),s=iN(n,e.length),u=oN(o,n,e.length);return Bx(t.reshape(a),i).reshape(o).slice(s,u)},n.spaceToBatchND=function(t,e,n){gv(t.rank<=4,(function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"}));var r=e.reduce((function(t,e){return t*e})),a=[[0,0]];a.push.apply(a,n);for(var i=1+e.length;i<t.shape.length;++i)a.push([0,0]);var o=t.pad(a),s=nN(o.shape,e,r,!1),u=rN(s.length,e.length,!1),c=aN(o.shape,e,r,!1);return Bx(o.reshape(s),u).reshape(c)},n.reduce=function(t,e,n){var r=t.shape[0],a=t.shape[1],i=XS(a),o=new hz({windowSize:i,inSize:a,batchSize:r},e),s=this.compileAndRun(o,[t],n);return 1===s.shape[1]?s:this.reduce(s,e,n)},n.argReduce=function(t,e,n){void 0===n&&(n=null);var r=t.shape[0],a=t.shape[1];null!=n&&(r=n.shape[0],a=n.shape[1]);var i=XS(a),o=new TM({windowSize:i,inSize:a,batchSize:r},e,null==n),s=[t];null!=n&&s.push(n);var u=this.compileAndRun(o,s,"int32");return 1===u.shape[1]?u:this.argReduce(t,e,u)},n.argReducePacked=function(t,e,n){void 0===n&&(n=null);var r=null!=n?n.shape:t.shape,a=XS(r[r.length-1]),i=new JM(r,a,e,null==n),o=null==n?[t]:[t,n],s=this.compileAndRun(i,o,"int32");return s.rank===t.rank?this.argReducePacked(t,e,s):s},n.sum=function(t,e){Xg("sum",e,t.rank);var n=Hg(t.shape,e),r=n[0],a=wv(n[1]),i=t.as2D(-1,a),o=kg(t.dtype);return this.reduce(i,"sum",o).reshape(r)},n.prod=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.prod(t,e);var n=Hg(t.shape,e),r=n[0],a=wv(n[1]),i=t.as2D(-1,a),o=kg(t.dtype);return this.reduce(i,"prod",o).reshape(r)},n.unsortedSegmentSum=function(t,e,n){var r=0,a=Yg([r],t.rank),i=t;null!=a&&(i=Bx(t,a),r=$g(1,t.rank)[0]);var o=Xz.computeOutShape(i.shape,r,n),s=wv([i.shape[r]]),u=i.as2D(-1,s),c=kg(t.dtype),l=this.segOpCompute(u,"unsortedSegmentSum",e,c,n).reshape(o);return null!=a&&(l=Bx(l,Jg(a))),l},n.segOpCompute=function(t,e,n,r,a){var i=t.shape[0],o=t.shape[1],s=Xz.segOpComputeOptimalWindowSize(o,a),u=new wz({windowSize:s,inSize:o,batchSize:i,numSegments:a},e),c=this.compileAndRun(u,[t,n],r);return c.shape[1]===a?c:(n=yy(0,a).tile([o/s]),this.segOpCompute(c,e,n,r,a))},n.argMinMaxReduce=function(t,e,n){var r=[e];if(Xg("arg"+n.charAt(0).toUpperCase()+n.slice(1),r,t.rank),!nv().getBool("WEBGL_PACK_REDUCE")||t.rank<=2){var a=Hg(t.shape,r),i=a[0],o=wv(a[1]),s=t.as2D(-1,o);return this.argReduce(s,n).reshape(i)}return this.argReducePacked(t,n)},n.argMin=function(t,e){return this.argMinMaxReduce(t,e,"min")},n.argMax=function(t,e){return this.argMinMaxReduce(t,e,"max")},n.cumsum=function(t,e,n,r){if(e!==t.rank-1)throw new Error("WebGL cumsum shader expects an inner-most axis="+(t.rank-1)+" but got axis="+e);var a=new IL(t.shape,n,r);return this.compileAndRun(a,[t])},n.equal=function(t,e){if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(equal(a, b));\n","bool");var n=new uL("return float(a == b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},n.notEqual=function(t,e){if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(notEqual(a, b));\n","bool");var n=new uL("return float(a != b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},n.less=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.less(t,e);if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(lessThan(a, b));\n","bool");var n=new uL("return float(a < b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},n.lessEqual=function(t,e){if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(lessThanEqual(a, b));\n","bool");var n=new uL("return float(a <= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},n.greater=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.greater(t,e);if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(greaterThan(a, b));\n","bool");var n=new uL("return float(a > b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},n.greaterEqual=function(t,e){if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(greaterThanEqual(a, b));\n","bool");var n=new uL("return float(a >= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},n.logicalNot=function(t){var e=new Dz(t.shape,"return float(!(x >= 1.0));");return this.compileAndRun(e,[t])},n.logicalAnd=function(t,e){if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n","bool");var n=new uL("return float(a >= 1.0 && b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},n.logicalOr=function(t,e){if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n","bool");var n=new uL("return float(a >= 1.0 || b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool")},n.select=function(t,e,n){var r=new kz(t.rank,e.shape,e.rank);return this.compileAndRun(r,[t,e,n],wg(e.dtype,n.dtype))},n.where=function(t){sN("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");var e=t.dataSync();return Zz(t.shape,e)},n.topk=function(t,e,n){var r=t.dataSync();return $z(r,t.shape,t.dtype,e)},n.min=function(t,e){Xg("min",e,t.rank);var n=Hg(t.shape,e),r=n[0],a=wv(n[1]),i=t.as2D(-1,a);return this.reduce(i,"min",i.dtype).reshape(r)},n.minimum=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.minimum(t,e);var n=nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new lL("\n vec4 result = vec4(min(a, b));\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new uL("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return min(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e])},n.mod=function(t,e){var n=nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new lL("\n vec4 result = mod(a, b);\n vec4 isNaN = vec4(equal(b, vec4(0.0)));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new uL("if (b == 0.0) return NAN;\n return mod(a, b);",t.shape,e.shape);return this.compileAndRun(n,[t,e])},n.maximum=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.maximum(t,e);var n=nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new lL("\n vec4 result = vec4(max(a, b));\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new uL("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return max(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e])},n.all=function(t,e){Xg("all",e,t.rank);var n=Hg(t.shape,e),r=n[0],a=wv(n[1]),i=t.as2D(-1,a);return this.reduce(i,"all",i.dtype).reshape(r)},n.any=function(t,e){Xg("any",e,t.rank);var n=Hg(t.shape,e),r=n[0],a=wv(n[1]),i=t.as2D(-1,a);return this.reduce(i,"any",i.dtype).reshape(r)},n.floorDiv=function(t,e){if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n","int32");var n=new uL("\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n",t.shape,e.shape);return this.compileAndRun(n,[t,e],"int32")},n.add=function(t,e){if("complex64"===t.dtype&&"complex64"===e.dtype)return this.complexSeparableBinaryOp(t,e,aL);if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.add(t,e);var n=wg(t.dtype,e.dtype);if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,aL,n);var r=new uL(aL,t.shape,e.shape);return this.compileAndRun(r,[t,e],n)},n.packedUnaryOp=function(t,e,n){var r=new Hz(t.shape,e);return this.compileAndRun(r,[t],n)},n.packedBinaryOp=function(t,e,n,r,a){void 0===a&&(a=!1);var i=new lL(n,t.shape,e.shape,a);return this.compileAndRun(i,[t,e],r)},n.complexSeparableBinaryOp=function(t,e,n){var r=this,a=this.texData.get(t.dataId),i=this.texData.get(e.dataId),o=[[a.complexTensors.real,i.complexTensors.real],[a.complexTensors.imag,i.complexTensors.imag]].map((function(a){var i=a[0],o=a[1],s=r.makeComplexComponentTensorInfo(t,i),u=r.makeComplexComponentTensorInfo(e,o),c=new uL(n,t.shape,e.shape);return r.compileAndRun(c,[s,u],wg(i.dtype,o.dtype))})),s=o[0],u=o[1],c=this.complex(s,u);return s.dispose(),u.dispose(),c},n.makeComplexComponentTensorInfo=function(t,e){return{dataId:e.dataId,dtype:e.dtype,shape:t.shape}},n.addN=function(t){if(1===t.length)return t[0];if(t.length>nv().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var e=Math.floor(t.length/2),n=this.addN(t.slice(0,e)),r=this.addN(t.slice(e));return this.addN([n,r])}var a=t.map((function(t){return t.dtype})).reduce((function(t,e){return wg(t,e)})),i=t.map((function(t){return t.shape})),o=nv().getBool("WEBGL_PACK")?new AM(t[0].shape,i):new IM(t[0].shape,i);return this.compileAndRun(o,t,a)},n.subtract=function(t,e){if("complex64"===t.dtype&&"complex64"===e.dtype)return this.complexSeparableBinaryOp(t,e,iL);if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.subtract(t,e);var n=wg(t.dtype,e.dtype);if(nv().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,iL,t.dtype);var r=new uL(iL,t.shape,e.shape);return this.compileAndRun(r,[t,e],n)},n.pow=function(t,e){var n=nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new lL("\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new uL("\nif(a < 0.0 && floor(b) < b){\n return NAN;\n}\nif (b == 0.0) {\n return 1.0;\n}\nreturn (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",t.shape,e.shape),r=wg(t.dtype,e.dtype);return this.compileAndRun(n,[t,e],r)},n.ceil=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.ceil(t);if(nv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Bz,t.dtype);var e=new Dz(t.shape,Bz);return this.compileAndRun(e,[t])},n.floor=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.floor(t);if(nv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Pz,t.dtype);var e=new Dz(t.shape,Pz);return this.compileAndRun(e,[t])},n.sign=function(t){var e=new Dz(t.shape,"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n");return this.compileAndRun(e,[t])},n.isNaN=function(t){var e=new Dz(t.shape,"return float(isnan(x));");return this.compileAndRun(e,[t],"bool")},n.isInf=function(t){var e=new Dz(t.shape,"return float(isinf(x));");return this.compileAndRun(e,[t],"bool")},n.isFinite=function(t){var e=new Dz(t.shape,"return float(!isnan(x) && !isinf(x));");return this.compileAndRun(e,[t],"bool")},n.round=function(t){var e=new Dz(t.shape,"\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n");return this.compileAndRun(e,[t])},n.exp=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.exp(t);if(nv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Wz,t.dtype);var e=new Dz(t.shape,Wz);return this.compileAndRun(e,[t])},n.expm1=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.expm1(t);if(nv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Vz,t.dtype);var e=new Dz(t.shape,Vz);return this.compileAndRun(e,[t])},n.softmax=function(t,e){var n=Av([e],t.shape),r=kS(t,n),a=Kg(r.shape,n),i=this.subtract(t,r.reshape(a)),o=this.exp(i),s=this.sum(o,n).reshape(a);return Ix(o,s)},n.log=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.log(t);if(nv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,"\n vec4 result = log(x);\n vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n result.r = isNaN.r == 1.0 ? NAN : result.r;\n result.g = isNaN.g == 1.0 ? NAN : result.g;\n result.b = isNaN.b == 1.0 ? NAN : result.b;\n result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n return result;\n",t.dtype);var e=new Dz(t.shape,"if (x < 0.0) return NAN;\n return log(x);");return this.compileAndRun(e,[t])},n.log1p=function(t){var e=new Dz(t.shape,"return log(1.0 + x);");return this.compileAndRun(e,[t])},n.sqrt=function(t){var e=new Dz(t.shape,"return sqrt(x);");return this.compileAndRun(e,[t])},n.rsqrt=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.rsqrt(t);var e=new Dz(t.shape,"return inversesqrt(x);");return this.compileAndRun(e,[t])},n.reciprocal=function(t){var e=new Dz(t.shape,"return 1.0 / x;");return this.compileAndRun(e,[t])},n.relu=function(t){var e;return e=nv().getBool("WEBGL_PACK")?new Hz(t.shape,jz):new Dz(t.shape,Fz),this.compileAndRun(e,[t])},n.relu6=function(t){var e;return e=nv().getBool("WEBGL_PACK")?new Hz(t.shape,Gz):new Dz(t.shape,Mz),this.compileAndRun(e,[t])},n.prelu=function(t,e){var n=nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new lL(cL,t.shape,e.shape):new uL(sL,t.shape,e.shape);return this.compileAndRun(n,[t,e])},n.elu=function(t){if(nv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,qz,t.dtype);var e=new Dz(t.shape,Lz);return this.compileAndRun(e,[t])},n.eluDer=function(t,e){var n=nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new lL("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",t.shape,e.shape):new uL("return (b >= 1.0) ? a : a * (b + 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e])},n.selu=function(t){var e=new Dz(t.shape,"\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = 1.7580993408473768;\n float scale = 1.0507009873554805;\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n");return this.compileAndRun(e,[t])},n.int=function(t){var e=new Dz(t.shape,"return float(int(x));");return this.compileAndRun(e,[t],"int32")},n.clip=function(t,e,n){var r,a=(r=nv().getBool("WEBGL_PACK_CLIP")?new fL(t.shape):new hL(t.shape)).getCustomSetupFunc(e,n);return this.compileAndRun(r,[t],null,a)},n.abs=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.abs(t);if(nv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Oz,t.dtype);var e=new Dz(t.shape,Oz);return this.compileAndRun(e,[t])},n.complexAbs=function(t){var e=this.texData.get(t.dataId),n=new pL(t.shape),r=[this.makeComplexComponentTensorInfo(t,e.complexTensors.real),this.makeComplexComponentTensorInfo(t,e.complexTensors.imag)];return this.compileAndRun(n,r)},n.sigmoid=function(t){var e=new Dz(t.shape,"return 1.0 / (1.0 + exp(-1.0 * x));");return this.compileAndRun(e,[t])},n.softplus=function(t){var e=new Dz(t.shape,"\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n");return this.compileAndRun(e,[t])},n.sin=function(t){var e=new Dz(t.shape,"if (isnan(x)) return x;\n return sin(x);\n");return this.compileAndRun(e,[t])},n.cos=function(t){var e=new Dz(t.shape,"if (isnan(x)) return x;\n return cos(x);\n");return this.compileAndRun(e,[t])},n.tan=function(t){var e=new Dz(t.shape,"return tan(x);");return this.compileAndRun(e,[t])},n.asin=function(t){var e=new Dz(t.shape,"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n");return this.compileAndRun(e,[t])},n.acos=function(t){var e=new Dz(t.shape,"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n");return this.compileAndRun(e,[t])},n.atan=function(t){var e=new Dz(t.shape,"if (isnan(x)) return x;\n return atan(x);\n");return this.compileAndRun(e,[t])},n.atan2=function(t,e){var n=nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new lL("\n vec4 result = atan(a, b);\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",t.shape,e.shape):new uL("\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return atan(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e])},n.sinh=function(t){var e=new Dz(t.shape,"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t])},n.cosh=function(t){var e=new Dz(t.shape,"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t])},n.tanh=function(t){var e=new Dz(t.shape,"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n");return this.compileAndRun(e,[t])},n.asinh=function(t){var e=new Dz(t.shape,"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));");return this.compileAndRun(e,[t])},n.acosh=function(t){var e=new Dz(t.shape,"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\n return log(x + sqrt(x * x - 1.0));");return this.compileAndRun(e,[t])},n.atanh=function(t){var e=new Dz(t.shape,"if (isnan(x)) return x;\n if ((x < -1.0) || (x > 1.0)) return NAN;\n return (log(1.0 + x) - log(1.0 - x)) / 2.0;");return this.compileAndRun(e,[t])},n.erf=function(t){var e=new Dz(t.shape,'\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = 0.3275911;\n float a1 = 0.254829592;\n float a2 = -0.284496736;\n float a3 = 1.421413741;\n float a4 = -1.453152027;\n float a5 = 1.061405429;\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n');return this.compileAndRun(e,[t])},n.step=function(t,e){var n=new Dz(t.shape,function(t){return void 0===t&&(t=0),_z+"\n return x > 0.0 ? 1.0 : float("+t+");\n "}(e));return this.compileAndRun(n,[t])},n.conv2dByMatMul=function(t,e,n,r,a,i){var o=t.shape,s=this.texData.get(t.dataId),u=n.inChannels,c=o[0]*o[1]*o[2],l=n.outChannels,h="channelsLast"===n.dataFormat,f=(1===c||1===l)&&u>1e3,p=o[2]%2!=0&&!!s.isPacked;if(f||!nv().getBool("WEBGL_LAZILY_UNPACK")||!nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!p){var d=h?o[0]*o[1]*o[2]:o[0]*o[2]*o[3],m=this.reshape(t,[1,d,n.inChannels]),v=this.reshape(e,[1,n.inChannels,n.outChannels]);return this.reshape(this.fusedBatchMatMul({a:m,b:v,transposeA:!1,transposeB:!1,bias:r,activation:a,preluActivationWeights:i}),n.outShape)}var g=h?o[0]*o[1]*(o[2]+1):o[0]*o[2]*(o[3]+1),y={dataId:t.dataId,shape:[1,g,n.inChannels],dtype:t.dtype},b=s.shape;s.shape=s.shape.slice(),s.shape[s.shape.length-2]++,gv(kM(s.shape,y.shape),(function(){return"packed reshape "+s.shape+" to "+y.shape+" isn't free"}));var x=this.reshape(e,[1,n.inChannels,n.outChannels]),w=this.fusedBatchMatMul({a:y,b:x,transposeA:!1,transposeB:!1,bias:r,activation:a,preluActivationWeights:i}),k=this.texData.get(w.dataId);return gv(k.isPacked,(function(){return"batchMatMul result is expected to be packed"})),s.shape=b,k.shape=n.outShape,Cb().makeTensorFromDataId(w.dataId,n.outShape,w.dtype)},n.conv2dWithIm2Row=function(t,e,n,r,a,i){var o=n.filterWidth,s=n.filterHeight,u=n.inChannels,c=n.outWidth,l=n.outHeight,h="channelsLast"===n.dataFormat,f=o*s*u,p=l*c,d=[f,p],m=t.squeeze([0]),v=e.reshape([1,f,-1]),g=new $L(d,m.shape,n),y=this.compileAndRun(g,[m]).reshape([1,d[0],d[1]]),b=null!=r,x=null!=i,w=a?tB(a,!0):null,k=new rz(y.shape,[1,p,n.outChannels],!0,!1,b,w,x),S=[y,v];r&&S.push(r),x&&S.push(i);var C=this.compileAndRun(k,S);return h?C.reshape([1,l,c,n.outChannels]):C.reshape([1,n.outChannels,l,c])},n.fusedConv2d=function(t){var e=t.input,n=t.filter,r=t.convInfo,a=t.bias,i=t.activation,o=t.preluActivationWeights;if(1===r.filterHeight&&1===r.filterWidth&&1===r.dilationHeight&&1===r.dilationWidth&&1===r.strideHeight&&1===r.strideWidth&&("SAME"===r.padInfo.type||"VALID"===r.padInfo.type))return this.conv2dByMatMul(e,n,r,a,i,o);if(nv().getBool("WEBGL_CONV_IM2COL")&&1===e.shape[0])return this.conv2dWithIm2Row(e,n,r,a,i,o);var s=null!=a,u=null!=o,c=i?tB(i,!1):null,l=new SL(r,s,c,u),h=[e,n];return a&&h.push(a),o&&h.push(o),this.compileAndRun(l,h)},n.conv2d=function(t,e,n){if(1===n.filterHeight&&1===n.filterWidth&&1===n.dilationHeight&&1===n.dilationWidth&&1===n.strideHeight&&1===n.strideWidth&&("SAME"===n.padInfo.type||"VALID"===n.padInfo.type))return this.conv2dByMatMul(t,e,n);if(nv().getBool("WEBGL_CONV_IM2COL")&&1===t.shape[0])return this.conv2dWithIm2Row(t,e,n);var r=new SL(n);return this.compileAndRun(r,[t,e])},n.conv2dDerInput=function(t,e,n){var r=new yL(n);return this.compileAndRun(r,[t,e])},n.conv2dDerFilter=function(t,e,n){var r=new gL(n);return this.compileAndRun(r,[t,e])},n.fusedDepthwiseConv2D=function(t){var e,n=t.input,r=t.filter,a=t.convInfo,i=t.bias,o=t.activation,s=t.preluActivationWeights,u=nv().getBool("WEBGL_PACK_DEPTHWISECONV")&&a.strideWidth<=2&&a.outChannels/a.inChannels==1,c=o?tB(o,u):null,l=[n,r],h=null!=i,f=null!=s;return h&&l.push(i),f&&l.push(s),u?(e=new NL(a,h,c,f),this.compileAndRun(e,l)):(e=new RL(a,h,c,f),this.compileAndRun(e,l))},n.depthwiseConv2D=function(t,e,n){var r;return nv().getBool("WEBGL_PACK_DEPTHWISECONV")&&n.strideWidth<=2&&n.outChannels/n.inChannels==1?(r=new NL(n),this.compileAndRun(r,[t,e])):(r=new RL(n),this.compileAndRun(r,[t,e]))},n.depthwiseConv2DDerInput=function(t,e,n){var r=new kL(n);return this.compileAndRun(r,[t,e])},n.depthwiseConv2DDerFilter=function(t,e,n){var r=new wL(n);return this.compileAndRun(r,[t,e])},n.conv3d=function(t,e,n){var r=new CL(n);return this.compileAndRun(r,[t,e])},n.conv3dDerInput=function(t,e,n){var r=new xL(n);return this.compileAndRun(r,[t,e])},n.conv3dDerFilter=function(t,e,n){var r=new bL(n);return this.compileAndRun(r,[t,e])},n.maxPool=function(t,e){var n=new cz(e,"max",!1);return this.compileAndRun(n,[t])},n.avgPool=function(t,e){var n=new cz(e,"avg",!1);return this.compileAndRun(n,[t],"float32")},n.maxPoolBackprop=function(t,e,n,r){var a=new cz(r,"max",!0),i=this.compileAndRun(a,[e]),o=new ez(r),s=this.compileAndRun(o,[t,i],e.dtype);return i.dispose(),s},n.avgPoolBackprop=function(t,e,n){var r=new $M(n);return this.compileAndRun(r,[t],e.dtype)},n.cast=function(t,e){return vN(t,e,this)},n.unstack=function(t,e){for(var n=t.shape[e],r=new Array(t.rank-1),a=0,i=0;i<t.rank;i++)i!==e&&(r[a++]=t.shape[i]);var o=new Array(t.rank).fill(0),s=t.shape.slice();s[e]=1;for(var u=new Array(n),c=0;c<u.length;c++)o[e]=c,u[c]=this.slice(t,o,s).reshape(r);return u},n.avgPool3d=function(t,e){var n=new lz(e,"avg",!1);return this.compileAndRun(n,[t],"float32")},n.avgPool3dBackprop=function(t,e,n){var r=new ZM(n);return this.compileAndRun(r,[t],e.dtype)},n.maxPool3d=function(t,e){var n=new lz(e,"max",!1);return this.compileAndRun(n,[t],"float32")},n.maxPool3dBackprop=function(t,e,n,r){var a=new lz(r,"max",!0),i=this.compileAndRun(a,[e]),o=new nz(r),s=this.compileAndRun(o,[t,i],e.dtype);return i.dispose(),s},n.reshape=function(t,e){var n=this.texData.get(t.dataId);if(n.isPacked&&!kM(t.shape,e)&&(null===n.texture||!kM(n.shape,e))){var r=this.packedReshape(t,e);return Cb().makeTensorFromDataId(r.dataId,r.shape,r.dtype)}return gN(t,e)},n.resizeBilinear=function(t,e,n,r){var a=nv().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new mz(t.shape,e,n,r):new dz(t.shape,e,n,r);return this.compileAndRun(a,[t],"float32")},n.resizeBilinearBackprop=function(t,e,n){var r=new pz(t,e,n);return this.compileAndRun(r,[t])},n.resizeNearestNeighbor=function(t,e,n,r){var a=new gz(t.shape,e,n,r);return this.compileAndRun(a,[t])},n.resizeNearestNeighborBackprop=function(t,e,n){var r=new vz(t,e,n);return this.compileAndRun(r,[t])},n.multinomial=function(t,e,n,r){var a=e?t:AC(t),i=a.shape[0],o=a.shape[1],s=new az(i,o,n),u=s.getCustomSetupFunc(r);return this.compileAndRun(s,[a],"int32",u)},n.oneHot=function(t,e,n,r){var a=new iz(t.size,e,n,r);return this.compileAndRun(a,[t])},n.diag=function(t){var e=new OL(t.size);return this.compileAndRun(e,[t])},n.cropAndResize=function(t,e,n,r,a,i){var o=new EL(t.shape,e.shape,r,a,i);return this.compileAndRun(o,[t,e,n],"float32")},n.depthToSpace=function(t,e,n){gv(e>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+e}));var r=t.shape[0],a="NHWC"===n?t.shape[1]:t.shape[2],i="NHWC"===n?t.shape[2]:t.shape[3],o="NHWC"===n?t.shape[3]:t.shape[1],s=a*e,u=i*e,c=o/(e*e),l=new _L("NHWC"===n?[r,s,u,c]:[r,c,s,u],e,n);return this.compileAndRun(l,[t])},n.split=function(t,e,n){return Yz(t,e,n)},n.scatterND=function(t,e,n){var r=Tk(0,t,n),a=r.sliceRank,i=r.numUpdates,o=r.sliceSize,s=r.strides,u=r.outputSize,c=[u/o,o],l=t.reshape([i,a]),h=e.reshape([i,o]);if(0===u)return gN(ay([]),n);var f=oy(0),p=new xz(i,a,l.rank,h.rank,s,c);return this.compileAndRun(p,[h,l,f]).reshape(n)},n.sparseToDense=function(t,e,n,r){var a=Tk(0,t,n),i=a.sliceRank,o=a.numUpdates,s=a.strides,u=a.outputSize,c=new xz(o,i,t.rank,e.rank,s,[u,1],!1);return this.compileAndRun(c,[e,t,r]).reshape(n)},n.fft=function(t){return this.fftImpl(t,!1)},n.ifft=function(t){return this.fftImpl(t,!0)},n.fftImpl=function(t,e){var n=this.texData.get(t.dataId),r=new WL(BL,t.shape,e),a=new WL(PL,t.shape,e),i=[this.makeComplexComponentTensorInfo(t,n.complexTensors.real),this.makeComplexComponentTensorInfo(t,n.complexTensors.imag)],o=this.compileAndRun(r,i),s=this.compileAndRun(a,i),u=this.complex(o,s).as2D(t.shape[0],t.shape[1]);return o.dispose(),s.dispose(),u},n.gatherND=function(t,e){var n=e.shape,r=n[n.length-1],a=Nk(t,e),i=a[0],o=a[1],s=a[2],u=a[3],c=e.reshape([o,r]),l=t.reshape([t.size/s,s]),h=new jL(r,u,[o,s]);return this.compileAndRun(h,[l,c]).reshape(i)},n.fill=function(t,e,n){if("string"===(n=n||Uv(e))){var r=_v(n,wv(t));return r.fill(e),Cb().makeTensor(r,t,n,this)}var a=new VL(t,e),i=a.getCustomSetupFunc(e);return this.compileAndRun(a,[],n,i)},n.onesLike=function(t){if("string"===t.dtype)throw new Error("onesLike is not supported under string dtype");return this.fill(t.shape,1,t.dtype)},n.zerosLike=function(t){return this.fill(t.shape,"string"===t.dtype?"":0,t.dtype)},n.linspace=function(t,e,n){return yN(t,e,n)},n.makeTensorInfo=function(t,e){var n=this.write(null,t,e);return this.texData.get(n).usage=null,{dataId:n,shape:t,dtype:e}},n.makeOutput=function(t,e){var n=this.makeTensorInfo(t,e).dataId;return Cb().makeTensorFromDataId(n,t,e,this)},n.unpackTensor=function(t){var e=new Kz(t.shape);return this.runWebGLProgram(e,[t],t.dtype)},n.packTensor=function(t){var e=new oz(t.shape);return this.runWebGLProgram(e,[t],t.dtype,null,!0)},n.packedReshape=function(t,e){var n=[yM(t.shape)].concat(bM(t.shape)),r={dtype:t.dtype,shape:n,dataId:t.dataId},a=[yM(e)].concat(bM(e)),i=new fz(a,n),o=this.runWebGLProgram(i,[r],t.dtype,null,!0);return{dataId:o.dataId,shape:e,dtype:o.dtype}},n.decode=function(t){var e,n=this.texData.get(t),r=n.isPacked,a=n.shape,i=n.dtype,o=xM(a);e=r?new DL(o):new TL(o);return{dtype:i,shape:a,dataId:this.runWebGLProgram(e,[{shape:o,dtype:i,dataId:t}],i,null,!0).dataId}},n.runWebGLProgram=function(t,e,n,r,a){var i=this;void 0===a&&(a=!1);var o=this.makeTensorInfo(t.outputShape,n),s=this.texData.get(o.dataId);if(t.packedOutput&&(s.isPacked=!0),t.outPackingScheme===XF.DENSE){var u=eM(t.outputShape);s.texShape=u.map((function(t){return 2*t}))}if(null!=t.outTexUsage&&(s.usage=t.outTexUsage),0===wv(o.shape))return s.values=Dv(o.dtype,0),o;var c=[],l=e.map((function(e){if("complex64"===e.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var n=i.texData.get(e.dataId);if(null==n.texture){if(!t.packedInputs&&wv(e.shape)<=nv().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:e.shape,texData:null,isUniform:!0,uniformValues:n.values};t.packedInputs&&(n.isPacked=!0,n.shape=e.shape)}else if(!!n.isPacked!=!!t.packedInputs)e=n.isPacked?i.unpackTensor(e):i.packTensor(e),c.push(e),n=i.texData.get(e.dataId);else if(n.isPacked&&!kM(n.shape,e.shape)){var r=e,a=e.shape;e.shape=n.shape,e=i.packedReshape(e,a),c.push(e),n=i.texData.get(e.dataId),r.shape=a}return i.uploadToGPU(e.dataId),{shape:e.shape,texData:n,isUniform:!1}}));this.uploadToGPU(o.dataId);var h,f={shape:o.shape,texData:s,isUniform:!1},p=function(t,e,n){var r="";e.concat(n).forEach((function(t){var e=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0,n=t.isUniform?"uniform":t.texData.texShape;r+=t.shape+"_"+n+"_"+e}));var a=t.userCode,i=t.constructor.name;return i+="_"+r+"_"+a}(t,l,f),d=this.getAndSaveBinary(p,(function(){return function(t,e,n,r){var a=e.userCode,i=n.map((function(t,n){var r={logicalShape:t.shape,texShape:t.isUniform?null:t.texData.texShape,isUniform:t.isUniform,isPacked:!t.isUniform&&t.texData.isPacked,flatOffset:null};return null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0&&(r.flatOffset=t.texData.slice.flatOffset),{name:e.variableNames[n],shapeInfo:r}})),o=i.map((function(t){return t.shapeInfo})),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},u=BM(i,s,a,e.packedInputs),c=t.createProgram(u),l=null,h=t.getUniformLocation(c,"NAN",!1);1===nv().getNumber("WEBGL_VERSION")&&(l=t.getUniformLocation(c,"INFINITY",!1));for(var f={},p=0;p<e.variableNames.length;p++){var d=e.variableNames[p];f[d]=t.getUniformLocation(c,d,!1),f["offset"+d]=t.getUniformLocation(c,"offset"+d,!1)}return{program:e,source:u,webGLProgram:c,uniformLocations:f,inShapeInfos:o,outShapeInfo:s,infLoc:l,nanLoc:h}}(i.gpgpu,t,l,f)})),m=null!=this.activeTimers;if(m&&(h=this.startTimer()),function(t,e,n,r,a){JL(e.inShapeInfos,n),JL([e.outShapeInfo],[r]);var i=r.texData.texture,o=r.texData.texShape;r.texData.isPacked?t.setOutputPackedMatrixTexture(i,o[0],o[1]):t.setOutputMatrixTexture(i,o[0],o[1]),t.setProgram(e.webGLProgram),1===nv().getNumber("WEBGL_VERSION")&&null!==e.infLoc&&t.gl.uniform1f(e.infLoc,1/0),null!==e.nanLoc&&t.gl.uniform1f(e.nanLoc,NaN),n.forEach((function(n,r){var a=e.program.variableNames[r],i=e.uniformLocations[a],o=e.uniformLocations["offset"+a];if(null!=i)if(n.isUniform)if(wv(n.shape)<2)t.gl.uniform1f(i,n.uniformValues[0]);else{var s=n.uniformValues;s instanceof Float32Array||(s=new Float32Array(s)),t.gl.uniform1fv(i,s)}else null!=n.texData.slice&&null!=o&&t.gl.uniform1i(o,n.texData.slice.flatOffset),t.setInputMatrixTexture(n.texData.texture,i,r)})),null!=a&&a(t,e.webGLProgram),t.executeProgram()}(this.gpgpu,d,l,f,r),c.forEach((function(t){return i.disposeData(t.dataId)})),m&&(h=this.endTimer(h),this.activeTimers.push({name:t.constructor.name,query:this.getQueryTime(h)})),!nv().getBool("WEBGL_LAZILY_UNPACK")&&s.isPacked&&!1===a){var v=this.unpackTensor(o);return this.disposeData(o.dataId),v}return o},n.compileAndRun=function(t,e,n,r,a){void 0===a&&(a=!1),n=n||e[0].dtype;var i=this.runWebGLProgram(t,e,n,r,a);return Cb().makeTensorFromDataId(i.dataId,i.shape,i.dtype)},n.getAndSaveBinary=function(t,e){return t in this.binaryCache||(this.binaryCache[t]=e()),this.binaryCache[t]},n.getTextureManager=function(){return this.textureManager},n.dispose=function(){var t=this;if(!this.disposed){if(!nv().getBool("IS_TEST"))Object.keys(this.binaryCache).forEach((function(e){t.gpgpu.deleteProgram(t.binaryCache[e].webGLProgram),delete t.binaryCache[e]}));this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0}},n.floatPrecision=function(){var t=this;return null==this.floatPrecisionValue&&(this.floatPrecisionValue=Nb((function(){if(!nv().get("WEBGL_RENDER_FLOAT32_ENABLED")){var e=nv().getBool("DEBUG");nv().set("DEBUG",!1);var n=t.abs(oy(1e-8)).dataSync()[0];if(nv().set("DEBUG",e),n>0)return 32}return 16}))),this.floatPrecisionValue},n.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},n.uploadToGPU=function(t){var e=this.texData.get(t),n=e.shape,r=e.dtype,a=e.values,i=e.texture,o=e.usage,s=e.isPacked;if(null==i){var u,c=null!=this.activeTimers;c&&(u=Jv());var l=e.texShape;if(null==l&&(l=function(t,e){void 0===e&&(e=!1);var n=nv().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e&&(n*=2,1===(t=t.map((function(e,n){return n>=t.length-2?mv(t[n]):t[n]}))).length&&(t=[2,t[0]])),2!==t.length){var r=Tv(t);t=r.newShape}var a=wv(t);if(t.length<=1&&a<=n)return[1,a];if(2===t.length&&t[0]<=n&&t[1]<=n)return t;if(3===t.length&&t[0]*t[1]<=n&&t[2]<=n)return[t[0]*t[1],t[2]];if(3===t.length&&t[0]<=n&&t[1]*t[2]<=n)return[t[0],t[1]*t[2]];if(4===t.length&&t[0]*t[1]*t[2]<=n&&t[3]<=n)return[t[0]*t[1]*t[2],t[3]];if(4===t.length&&t[0]<=n&&t[1]*t[2]*t[3]<=n)return[t[0],t[1]*t[2]*t[3]];if(e){var i=yM(t),o=2,s=2;if(t.length){var u=bM(t);o=u[0],s=u[1]}return Rv(a=i*(o/2)*(s/2)).map((function(t){return 2*t}))}return Rv(a)}(n,s),e.texShape=l),null!=a){var h,f=xM(n),p=l[1],d=l[0],m=a instanceof Uint8Array;if(s){var v=nM(l[0],l[1]);p=v[0],d=v[1],h=new zL(f,[d,p],m)}else h=new LL(f,[d,p],m);var g=this.makeTensorInfo([d,p],r);this.texData.get(g.dataId).usage=m?YF.PIXELS:YF.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId),p,d,a);var y=this.runWebGLProgram(h,[g],r,null,!0),b=this.texData.get(y.dataId);e.texture=b.texture,e.texShape=b.texShape,e.isPacked=b.isPacked,e.usage=b.usage,this.disposeData(g.dataId),this.texData.delete(y.dataId),e.values=null,c&&(this.uploadWaitMs+=Jv()-u)}else{var x=this.acquireTexture(l,o,r,s);e.texture=x}}},n.convertAndCacheOnCPU=function(t,e){var n=this.texData.get(t),r=n.dtype;return this.releaseGPUData(t),null!=e&&(n.values=function(t,e){if("float32"===e||"complex64"===e)return t;if("int32"===e||"bool"===e){for(var n="int32"===e?new Int32Array(t.length):new Uint8Array(t.length),r=0;r<n.length;++r)n[r]=Math.round(t[r]);return n}throw new Error("Unknown dtype "+e)}(e,r)),n.values},n.acquireTexture=function(t,e,n,r){if(this.numBytesInGPU+=this.computeBytes(t,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){var a=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: "+a+" MB, most likely due to a memory leak")}return this.textureManager.acquireTexture(t,e,r)},n.computeBytes=function(t,e){return t[0]*t[1]*zv(e)},e}(NN);var nB,rB=function(t){this.variableNames=["A"];var e=OM(),n=t[0],r=t[1];this.outputShape=t,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+r+".0, "+n+".0);\n\n vec4 values = "+e.texture2D+"(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n "},aB=function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var e=OM(),n=t[0],r=t[1];this.outputShape=t,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+r+".0, "+n+".0);\n vec4 values = "+e.texture2D+"(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n "+e.output+" = result;\n }\n "};var iB=IF,oB=AF;function sB(t,e,n){var r=n.texData.get(t.dataId);return!r.isPacked||kM(t.shape,e)||null!==r.texture&&kM(r.shape,e)?{dataId:t.dataId,shape:e,dtype:t.dtype}:function(t,e,n){var r=[yM(t.shape)].concat(bM(t.shape)),a={dtype:t.dtype,shape:r,dataId:t.dataId},i=[yM(e)].concat(bM(e)),o=new fz(i,r),s=n.runWebGLProgram(o,[a],t.dtype,null,!0);return{dataId:s.dataId,shape:e,dtype:s.dtype}}(t,e,n)}function uB(t,e,n,r){var a=wv(e),i=sB(t,[wv(t.shape)/a,a],r),o=function t(e,n,r,a){var i=e.shape,o=i[0],s=i[1],u=XS(s),c=new hz({windowSize:u,inSize:s,batchSize:o},r),l=a.runWebGLProgram(c,[e],n);return 1===l.shape[1]?l:t(l,n,r,a)}(i,t.dtype,"max",r);return i.dataId!==t.dataId&&r.disposeData(i.dataId),sB(o,n,r)}var cB=function(t,e){this.variableNames=["A"];for(var n=new Array(t.length),r=0;r<n.length;r++)n[r]=t[e[r]];this.outputShape=n,this.rank=n.length;var a=KM(this.rank),i=function(t){var e=t.length;if(e>6)throw Error("Transpose for rank "+e+" is not yet supported");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(e),a=0;a<t.length;a++)r[t[a]]=n[a];return r.join()}(e);this.userCode="\n void main() {\n "+a+" resRC = getOutputCoords();\n setOutput(getA("+i+"));\n }\n "};var lB=function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var n=new Array(t.length),r=0;r<n.length;r++)n[r]=t[e[r]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");for(var a=KM(this.rank),i=DM("rc",this.rank),o=new Array(this.rank),s=0;s<e.length;s++)o[e[s]]=i[s];var u="vec2("+o.slice(-2).join()+")",c="++"+i[this.rank-1]+" < "+n[this.rank-1],l="getChannel(getA("+o.join()+"), "+u+")";this.userCode="\n void main() {\n "+a+" rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = "+l+";\n if("+c+") {\n result[1] = "+l+";\n }\n --"+i[this.rank-1]+";\n if(++"+i[this.rank-2]+" < "+n[this.rank-2]+") {\n result[2] = "+l+";\n if("+c+") {\n result[3] = "+l+";\n }\n }\n setOutput(result);\n }\n "};function hB(t,e,n){var r=nv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new lB(t.shape,e):new cB(t.shape,e);return n.runWebGLProgram(r,[t],t.dtype)}for(var fB=bR,pB=0,dB=[{kernelName:"Max",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.attrs,r=t.backend,a=e.x,i=n.reductionIndices,o=r,s=a.shape.length,u=Av(i,a.shape),c=Yg(u,s),l=null!=c,h=o.shouldExecuteOnCPU([a]),f=a;if(l){if(h){for(var p=o.texData.get(f.dataId).values,d=new Array(s),m=0;m<d.length;m++)d[m]=a.shape[c[m]];var v=oB(p,a.shape,a.dtype,c,d);f=o.makeTensorInfo(d,a.dtype),o.texData.get(f.dataId).values=v}else f=hB(a,c,o);u=$g(u.length,s)}Xg("max",u,s);var g,y=Hg(f.shape,u),b=y[0],x=y[1];if(h){var w=o.texData.get(f.dataId).values,k=iB(w,wv(x),b,a.dtype);g=o.makeTensorInfo(b,a.dtype),o.texData.get(g.dataId).values=k}else g=uB(f,x,b,o);return l&&o.disposeData(f.dataId),g}},{kernelName:"FromPixels",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=t.attrs,a=e.pixels,i=r.numChannels,o="undefined"!=typeof HTMLVideoElement&&a instanceof HTMLVideoElement,s="undefined"!=typeof HTMLImageElement&&a instanceof HTMLImageElement,u=o?[a.videoWidth,a.videoHeight]:[a.width,a.height],c=u[0],l=u[1],h=[l,c],f=[l,c,i];(s||o)&&(null==nB&&(nB=document.createElement("canvas").getContext("2d")),nB.canvas.width=c,nB.canvas.height=l,nB.drawImage(a,0,0,c,l),a=nB.canvas);var p=n.makeTensorInfo(h,"int32");n.texData.get(p.dataId).usage=YF.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId),a);var d=nv().getBool("WEBGL_PACK")?new aB(f):new rB(f),m=n.runWebGLProgram(d,[p],"int32");return n.disposeData(p.dataId),m}},{kernelName:"Div",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.backend;return function(t,e,n){var r=new uL("\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",t.shape,e.shape);return nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&(r=new lL("\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n",t.shape,e.shape,!0)),n.runWebGLProgram(r,[t,e],"float32")}(e.a,e.b,n)}},{kernelName:"NonMaxSuppressionV3",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=t.attrs;sN("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var a=e.boxes,i=e.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,c=n;return yR(c.readSync(a.dataId),c.readSync(i.dataId),o,s,u)}},{kernelName:"NonMaxSuppressionV5",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=t.attrs;sN("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var a=e.boxes,i=e.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,c=r.softNmsSigma,l=n,h=l.readSync(a.dataId),f=l.readSync(i.dataId),p=fB(h,f,o,s,u,c);return[p.selectedIndices,p.selectedScores]}},{kernelName:"Square",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=e.x,a=n,i=new Dz(r.shape,"return x * x;");return a.runWebGLProgram(i,[r],r.dtype)}},{kernelName:"SquaredDifference",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.backend,r=e.a,a=e.b,i=n,o=nv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new lL("return (a - b) * (a - b);",r.shape,a.shape):new uL("return (a - b) * (a - b);",r.shape,a.shape);return i.compileAndRun(o,[r,a])}},{kernelName:"Transpose",backendName:"webgl",kernelFunc:function(t){for(var e,n=t.inputs,r=t.attrs,a=t.backend,i=n.x,o=r.perm,s=a,u=i.shape.length,c=new Array(u),l=0;l<c.length;l++)c[l]=i.shape[o[l]];if(s.shouldExecuteOnCPU([i])){var h=s.texData.get(i.dataId).values,f=oB(h,i.shape,i.dtype,o,c);e=s.makeTensorInfo(c,i.dtype),s.texData.get(e.dataId).values=f}else e=hB(i,o,s);return e}},{kernelName:"MaxPoolWithArgmax",backendName:"webgl",kernelFunc:function(t){var e=t.inputs,n=t.attrs,r=t.backend,a=e.x,i=n.filterSize,o=n.strides,s=n.pad,u=n.includeBatchInIndex,c=r;gv(4===a.shape.length,(function(){return"Error in maxPool: input must be rank 4 but got rank "+a.shape.length+"."}));var l=[1,1];gv(lb(o,l),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+l+"'"}));var h=tb(a.shape,i,o,l,s),f=function(t,e,n,r){var a=new cz(n,"max",!1),i=r.runWebGLProgram(a,[t],"float32");return a=new cz(n,"max",!0,!0,e),[i,r.runWebGLProgram(a,[t],"float32")]}(a,u,h,c);return[f[0],f[1]]}}];pB<dB.length;pB++){lv(dB[pB])}_g()&&Ab("webgl",(function(){return new eB}),2);var mB={"tfjs-core":"2.0.0","tfjs-backend-cpu":"2.0.0","tfjs-backend-webgl":"2.0.0","tfjs-data":"2.0.0","tfjs-layers":"2.0.0","tfjs-converter":"2.0.0",tfjs:"2.0.0"};t.AdadeltaOptimizer=qR,t.AdagradOptimizer=HR,t.AdamOptimizer=KR,t.AdamaxOptimizer=XR,t.Add="Add",t.AddN="AddN",t.BatchMatMul="BatchMatMul",t.BatchToSpaceND="BatchToSpaceND",t.BroadcastTo="BroadcastTo",t.Callback=g_,t.CallbackList=zI,t.Concat="Concat",t.Conv2D="Conv2D",t.Conv2DBackpropFilter="Conv2DBackpropFilter",t.Conv2DBackpropInput="Conv2DBackpropInput",t.Conv3D="Conv3D",t.Conv3DBackpropFilterV2="Conv3DBackpropFilterV2",t.Conv3DBackpropInputV2="Conv3DBackpropInputV2",t.CustomCallback=WI,t.DataStorage=RN,t.DepthToSpace="DepthToSpace",t.DepthwiseConv2dNative="DepthwiseConv2dNative",t.DepthwiseConv2dNativeBackpropFilter="DepthwiseConv2dNativeBackpropFilter",t.DepthwiseConv2dNativeBackpropInput="DepthwiseConv2dNativeBackpropInput",t.Diag="Diag",t.Div="Div",t.EarlyStopping=x_,t.Environment=tv,t.Equal="Equal",t.FromPixels="FromPixels",t.FusedBatchNorm="FusedBatchNorm",t.GraphModel=xO,t.Greater="Greater",t.GreaterEqual="GreaterEqual",t.History=PI,t.Identity="Identity",t.InputSpec=CI,t.KernelBackend=NN,t.LRN="LRN",t.LRNBackprop="LRNBackprop",t.LayerVariable=wI,t.LayersModel=eT,t.Less="Less",t.LessEqual="LessEqual",t.Max="Max",t.MaxPoolWithArgmax="MaxPoolWithArgmax",t.MomentumOptimizer=JR,t.NonMaxSuppressionV3="NonMaxSuppressionV3",t.NonMaxSuppressionV5="NonMaxSuppressionV5",t.NotEqual="NotEqual",t.OneHot="OneHot",t.Optimizer=GR,t.PadV2="PadV2",t.RMSPropOptimizer=$R,t.RNN=KD,t.SGDOptimizer=YR,t.Sequential=sT,t.SpaceToBatchND="SpaceToBatchND",t.SplitV="SplitV",t.Square="Square",t.SquaredDifference="SquaredDifference",t.Sub="Sub",t.SymbolicTensor=RI,t.Tensor=pg,t.TensorBuffer=lg,t.Tile="Tile",t.Transpose="Transpose",t.Variable=bg,t.abs=_b,t.acos=Ob,t.acosh=Fb,t.add=Db,t.addN=Wk,t.addStrict=fx,t.all=Vy,t.any=Uy,t.argMax=jy,t.argMin=Gy,t.asin=Mb,t.asinh=Lb,t.atan=zb,t.atan2=px,t.atanh=Bb,t.avgPool=hC,t.avgPool3d=dC,t.backend=Tb,t.backend_util=bN,t.basicLSTMCell=_C,t.batchNorm=Uk,t.batchNorm2d=jk,t.batchNorm3d=Gk,t.batchNorm4d=qk,t.batchToSpaceND=Ux,t.booleanMaskAsync=nC,t.broadcastTo=Kk,t.browser=Rk,t.buffer=Sy,t.callbacks=S_,t.cast=Ry,t.ceil=Pb,t.clipByValue=Wb,t.clone=Hk,t.complex=ey,t.concat=wy,t.concat1d=Xk,t.concat2d=Yk,t.concat3d=Jk,t.concat4d=$k,t.constraints=sE,t.conv1d=Zk,t.conv2d=mb,t.conv2dTranspose=Qk,t.conv3d=tS,t.conv3dTranspose=eS,t.cos=Vb,t.cosh=Ub,t.cumsum=Ny,t.customGrad=By,t.data=EF,t.deprecationWarn=Sb,t.depthToSpace=nS,t.depthwiseConv2d=rS,t.deregisterOp=function(t){delete C_[t]},t.device_util=Og,t.diag=aS,t.disableDeprecationWarnings=function(){nv().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")},t.dispose=Eb,t.disposeVariables=function(){Tg.disposeVariables()},t.div=Ix,t.divNoNan=pS,t.divStrict=dx,t.dot=dS,t.dropout=qC,t.elu=SC,t.enableDebugMode=function(){nv().set("DEBUG",!0)},t.enableProdMode=function(){nv().set("PROD",!0)},t.engine=Cb,t.env=nv,t.equal=mS,t.equalStrict=vC,t.erf=jb,t.exp=Gb,t.expandDims=Ey,t.expm1=qb,t.eye=vS,t.fft=BC,t.fill=vy,t.findBackend=function(t){return Tg.findBackend(t)},t.findBackendFactory=function(t){return Tg.findBackendFactory(t)},t.floor=Hb,t.floorDiv=mx,t.frame=YC,t.fused=UR,t.gather=QS,t.gatherND=GC,t.gather_util=Ek,t.getBackend=function(){return Tg.backendName},t.getGradient=uv,t.getKernel=sv,t.getKernelsForBackend=cv,t.grad=function(t){return gv(jv(t),(function(){return"The f passed in grad(f) must be a function"})),function(e,n){var r=Ug(e,"x","tf.grad",null),a=null!=n?Ug(n,"dy","tf.grad"):null;return Tg.tidy((function(){var e=Tg.gradients((function(){return t(r)}),[r],a),n=e.value,i=e.grads;return null!=a&&yv(n.shape,a.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Py(i),i[0]}))}},t.grads=function(t){return gv(jv(t),(function(){return"The f passed in grads(f) must be a function"})),function(e,n){gv(Array.isArray(e),(function(){return"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"}));var r=jg(e,"args","tf.grads",null),a=null!=n?Ug(n,"dy","tf.grads"):null;return Tg.tidy((function(){var e=Tg.gradients((function(){return t.apply(void 0,r)}),r,a),n=e.value,i=e.grads;return null!=a&&yv(n.shape,a.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Py(i),i}))}},t.greater=gS,t.greaterEqual=yS,t.greaterEqualStrict=gC,t.greaterStrict=yC,t.hammingWindow=XC,t.hannWindow=KC,t.ifft=PC,t.imag=ry,t.image=FR,t.inTopKAsync=tR,t.initializers=hI,t.input=uT,t.io=bk,t.irfft=VC,t.isFinite=ax,t.isInf=rx,t.isNaN=nx,t.keep=Ib,t.kernel_impls=CN,t.layers=p_,t.leakyRelu=CC,t.less=bS,t.lessEqual=xS,t.lessEqualStrict=bC,t.lessStrict=xC,t.linalg=mR,t.linspace=gy,t.loadGraphModel=function(t,e){return wO.apply(this,arguments)},t.loadLayersModel=function(t,e){return null==e&&(e={}),function(t,e){return rT.apply(this,arguments)}(t,e)},t.localResponseNormalization=wS,t.log=Kb,t.log1p=Xb,t.logSigmoid=Yb,t.logSoftmax=TC,t.logSumExp=qy,t.logicalAnd=sS,t.logicalNot=uS,t.logicalOr=cS,t.logicalXor=lS,t.losses=lR,t.matMul=Oy,t.math=kk,t.max=kS,t.maxPool=lC,t.maxPool3d=pC,t.maxPoolWithArgmax=mC,t.maximum=vx,t.maximumStrict=gx,t.mean=Hy,t.memory=Rb,t.metrics=d_,t.min=Ky,t.minimum=yx,t.minimumStrict=bx,t.mod=xx,t.modStrict=wx,t.model=function(t){return new eT(t)},t.models=m_,t.moments=Xy,t.movingAverage=FC,t.mul=kx,t.mulStrict=Sx,t.multiRNNCell=OC,t.multinomial=SS,t.neg=Jb,t.nextFrame=eN,t.norm=DC,t.notEqual=CS,t.notEqualStrict=wC,t.oneHot=xk,t.ones=dy,t.onesLike=by,t.op=ty,t.outerProduct=RS,t.pad=Xx,t.pad1d=NS,t.pad2d=ES,t.pad3d=IS,t.pad4d=AS,t.pool=fC,t.pow=Cx,t.powStrict=Rx,t.prelu=RC,t.print=Cy,t.prod=Jy,t.profile=function(t){return Tg.profile(t)},t.rand=TS,t.randomGamma=US,t.randomNormal=jS,t.randomUniform=GS,t.range=yy,t.ready=function(){return Tg.ready()},t.real=ny,t.reciprocal=$b,t.registerBackend=Ab,t.registerCallbackConstructor=function(t,e){UI.registerCallbackConstructor(t,e)},t.registerGradient=hv,t.registerKernel=lv,t.registerOp=function(t,e){var n={tfOpName:t,category:"custom",inputs:[],attrs:[],customExecutor:e};C_[t]=n},t.regularizers=v_,t.relu=NC,t.relu6=EC,t.removeBackend=function(t){Tg.removeBackend(t)},t.reshape=Iy,t.reverse=rC,t.reverse1d=aC,t.reverse2d=iC,t.reverse3d=oC,t.reverse4d=sC,t.rfft=WC,t.round=Zb,t.rsqrt=Qb,t.scalar=oy,t.scatterND=zC,t.scatter_util=Dk,t.selu=IC,t.separableConv2d=qS,t.sequential=function(t){return new sT(t)},t.serialization=Mk,t.setBackend=function(t){return Tg.setBackend(t)},t.setPlatform=function(t,e){nv().setPlatform(t,e)},t.setdiff1dAsync=_y,t.sigmoid=tx,t.sign=ex,t.signal=$C,t.sin=ix,t.sinh=ox,t.slice=rw,t.slice1d=aw,t.slice2d=iw,t.slice3d=ow,t.slice4d=sw,t.slice_util=nw,t.softmax=AC,t.softplus=sx,t.spaceToBatchND=My,t.sparseToDense=jC,t.spectral=UC,t.split=Zy,t.sqrt=ux,t.square=Ax,t.squaredDifference=HS,t.squaredDifferenceStrict=Nx,t.squeeze=Ay,t.stack=Ty,t.step=cx,t.stft=JC,t.stridedSlice=MC,t.sub=Dx,t.subStrict=Ex,t.sum=Yy,t.sumOutType=kg,t.tan=lx,t.tanh=hx,t.tensor=ay,t.tensor1d=sy,t.tensor2d=uy,t.tensor3d=cy,t.tensor4d=ly,t.tensor5d=hy,t.tensor6d=fy,t.tensor_util=Eg,t.test_util=Pk,t.tidy=Nb,t.tile=_x,t.time=function(t){return Tg.time(t)},t.topk=LC,t.train=QR,t.transpose=Bx,t.truncatedNormal=KS,t.unregisterGradient=function(t){if(!ov.has(t))throw new Error("The gradient '"+t+"' for backend is not registered");ov.delete(t)},t.unregisterKernel=function(t,e){var n=fv(t,e);if(!iv.has(n))throw new Error("The kernel '"+t+"' for backend '"+e+"' is not registered");iv.delete(n)},t.unsortedSegmentSum=tC,t.unstack=Dy,t.upcastType=wg,t.util=rg,t.valueAndGrad=function(t){return gv(jv(t),(function(){return"The f passed in valueAndGrad(f) must be a function"})),function(e,n){gv(e instanceof pg,(function(){return"The x passed in valueAndGrad(f)(x) must be a tensor"})),gv(null==n||n instanceof pg,(function(){return"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"}));var r=Tg.gradients((function(){return t(e)}),[e],n),a=r.grads,i=r.value;return Py(a),{grad:a[0],value:i}}},t.valueAndGrads=function(t){return gv(jv(t),(function(){return"The f passed in valueAndGrads(f) must be a function"})),function(e,n){gv(Array.isArray(e)&&e.every((function(t){return t instanceof pg})),(function(){return"The args passed in valueAndGrads(f)(args) must be array of tensors"})),gv(null==n||n instanceof pg,(function(){return"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"}));var r=Tg.gradients((function(){return t.apply(void 0,e)}),e,n);return null!=n&&yv(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Py(r.grads),r}},t.variable=py,t.variableGrads=zy,t.version=mB,t.version_converter="2.0.0",t.version_core="2.0.0",t.version_layers="2.0.0",t.where=hS,t.whereAsync=fS,t.zeros=my,t.zerosLike=xy,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=tf.min.js.map